1

我有一个简单的 Three.js 代码,可以在 Three.js v68 中正常工作,但它在 Three.js v71 中显示 2 个立方体而不是一个立方体和一个球体。如果我先绘制球体,它将绘制两个球体。

        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 );
        camera.position.z = 5;

        var renderer = new THREE.WebGLRenderer();
        renderer.setSize( window.innerWidth, window.innerHeight );
        document.body.appendChild( renderer.domElement );

        var CubeGeometry = new THREE.BoxGeometry( 1, 1, 1 );
        var CubeMaterial = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
        var cube = new THREE.Mesh( CubeGeometry, CubeMaterial );
        scene.add( cube );

        var spheregeometry = new THREE.SphereGeometry(1, 16, 16);
        var spherematerial = new THREE.MeshBasicMaterial({ color: 0x00ff00});
        var sphere = new THREE.Mesh(spheregeometry, spherematerial);
        sphere.position.set(-2.0, 0, 0);
        scene.add(sphere);

        renderer.render(scene, camera);
4

0 回答 0