Bladeren bron

Some basic performance optimisations on voxel examples. Bottleneck is still Ray caster anyway :/

Mr.doob 14 jaren geleden
bovenliggende
commit
dd52560369

+ 2 - 0
examples/canvas_interactive_voxelpainter.html

@@ -151,6 +151,8 @@
 						voxel.position.x = Math.floor( position.x / 50 ) * 50 + 25;
 						voxel.position.y = Math.floor( position.y / 50 ) * 50 + 25;
 						voxel.position.z = Math.floor( position.z / 50 ) * 50 + 25;
+						voxel.matrixAutoUpdate = false;
+						voxel.updateMatrix();
 						voxel.overdraw = true;
 						scene.addObject( voxel );
 

+ 2 - 1
examples/webgl_interactive_voxelpainter.html

@@ -189,7 +189,8 @@
 
 						var voxel = new THREE.Mesh( cubeGeo, cubeMaterial );
 						voxel.position.copy( voxelPosition );
-
+						voxel.matrixAutoUpdate = false;
+						voxel.updateMatrix();
 						scene.addObject( voxel );
 
 					}

+ 5 - 5
src/core/Matrix4.js

@@ -72,20 +72,20 @@ THREE.Matrix4.prototype = {
 		var x = THREE.Matrix4.__v1, y = THREE.Matrix4.__v2, z = THREE.Matrix4.__v3;
 
 		z.sub( eye, center ).normalize();
-		
+
 		if ( z.length() === 0 ) {
-			
+
 			z.z = 1;
 
 		}
-		
+
 		x.cross( up, z ).normalize();
 
 		if ( x.length() === 0 ) {
-			
+
 			z.x += 0.0001;
 			x.cross( up, z ).normalize();
-			
+
 		}
 
 		y.cross( z, x ).normalize();