Browse Source

Updated interactive buffergeometry example.

Mr.doob 11 years ago
parent
commit
cdc37a6796
1 changed files with 7 additions and 11 deletions
  1. 7 11
      examples/webgl_interactive_buffergeometry.html

+ 7 - 11
examples/webgl_interactive_buffergeometry.html

@@ -279,19 +279,15 @@
 				if ( intersects.length > 0 ) {
 
 					var intersect = intersects[ 0 ];
+					var face = intersect.face;
 
-					var object = intersect.object;
-					var positions = object.geometry.attributes.position.array;
+					var linePosition = line.geometry.attributes.position;
+					var meshPosition = mesh.geometry.attributes.position;
 
-					for ( var i = 0, j = 0; i < 4; i ++, j += 3 ) {
-
-						var index = intersect.indices[ i % 3 ] * 3;
-
-						line.geometry.attributes.position.array[ j     ] = positions[ index     ];
-						line.geometry.attributes.position.array[ j + 1 ] = positions[ index + 1 ];
-						line.geometry.attributes.position.array[ j + 2 ] = positions[ index + 2 ];
-
-					}
+					linePosition.copyAt( 0, meshPosition, face.a );
+					linePosition.copyAt( 1, meshPosition, face.b );
+					linePosition.copyAt( 2, meshPosition, face.c );
+					linePosition.copyAt( 3, meshPosition, face.a );
 
 					mesh.updateMatrix();