Browse Source

Updated voxelpainter examples to use Vector3.floor()

Mr.doob 11 years ago
parent
commit
d1cff82ec0

+ 2 - 7
examples/canvas_interactive_voxelpainter.html

@@ -180,14 +180,9 @@
 						var normal = intersect.face.normal.clone();
 						normal.applyMatrix3( normalMatrix ).normalize();
 
-						var position = new THREE.Vector3().addVectors( intersect.point, normal );
-
 						var voxel = new THREE.Mesh( cubeGeometry, cubeMaterial );
-						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.position.addVectors( intersect.point, normal );
+						voxel.position.divideScalar( 50 ).floor().multiplyScalar( 50 ).addScalar( 25 );
 						scene.add( voxel );
 
 					}

+ 1 - 4
examples/webgl_interactive_voxelpainter.html

@@ -171,10 +171,7 @@
 				tmpVec.applyMatrix3( normalMatrix ).normalize();
 
 				voxelPosition.addVectors( intersector.point, tmpVec );
-
-				voxelPosition.x = Math.floor( voxelPosition.x / 50 ) * 50 + 25;
-				voxelPosition.y = Math.floor( voxelPosition.y / 50 ) * 50 + 25;
-				voxelPosition.z = Math.floor( voxelPosition.z / 50 ) * 50 + 25;
+				voxelPosition.divideScalar( 50 ).floor().multiplyScalar( 50 ).addScalar( 25 );
 
 			}