浏览代码

Examples: physics_cannon_instancing clean up.

Mr.doob 5 年之前
父节点
当前提交
84f610df56
共有 1 个文件被更改,包括 2 次插入21 次删除
  1. 2 21
      examples/physics_cannon_instancing.html

+ 2 - 21
examples/physics_cannon_instancing.html

@@ -58,17 +58,10 @@
 				scene.add( plane );
 				physics.addMesh( plane );
 
-				/*
-				function getSize() {
-
-					return Math.random() * 0.1 + 0.05;
-
-				}
-				*/
-
 				var geometry = new THREE.BoxBufferGeometry( 0.1, 0.1, 0.1 );
-				var material = new THREE.MeshLambertMaterial( /*{ vertexColors: true }*/ );
+				var material = new THREE.MeshLambertMaterial();
 				var mesh = new THREE.InstancedMesh( geometry, material, 200 );
+				mesh.instanceMatrix.setUsage( THREE.DynamicDrawUsage ); // will be updated every frame
 				mesh.castShadow = true;
 				mesh.receiveShadow = true;
 				scene.add( mesh );
@@ -84,18 +77,6 @@
 
 				}
 
-				/*
-				var instanceColors = [];
-
-				for ( var i = 0; i < mesh.count; i ++ ) {
-
-					instanceColors.push( Math.random(), Math.random(), Math.random() );
-
-				}
-
-				mesh.geometry.setAttribute( 'instanceColor', new THREE.InstancedBufferAttribute( new Float32Array( instanceColors ), 3 ) );
-				*/
-
 				physics.addMesh( mesh, 1 );
 
 				//