Bläddra i källkod

Merge pull request #20369 from manthrax/fix-raycast-points-interleavedbufferattribute

Points: Add InterleavedBufferAttribute support to raycast.
Mr.doob 4 år sedan
förälder
incheckning
78d534d7e8
1 ändrade filer med 4 tillägg och 4 borttagningar
  1. 4 4
      src/objects/Points.js

+ 4 - 4
src/objects/Points.js

@@ -69,7 +69,7 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			const index = geometry.index;
 			const attributes = geometry.attributes;
-			const positions = attributes.position.array;
+			const positionAttr = attributes.position;
 
 			if ( index !== null ) {
 
@@ -79,7 +79,7 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 					const a = indices[ i ];
 
-					_position.fromArray( positions, a * 3 );
+					_position.fromBufferAttribute( attributes.position, a );
 
 					testPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );
 
@@ -87,9 +87,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			} else {
 
-				for ( let i = 0, l = positions.length / 3; i < l; i ++ ) {
+				for ( let i = 0, l = positionAttr.count; i < l; i ++ ) {
 
-					_position.fromArray( positions, i * 3 );
+					_position.fromBufferAttribute( attributes.position, i );
 
 					testPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );