Quellcode durchsuchen

Line/Points: Avoid raw array access in raycast(). (#21475)

Michael Herzog vor 4 Jahren
Ursprung
Commit
8c6ae24935
2 geänderte Dateien mit 5 neuen und 9 gelöschten Zeilen
  1. 3 5
      src/objects/Line.js
  2. 2 4
      src/objects/Points.js

+ 3 - 5
src/objects/Line.js

@@ -122,12 +122,10 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			if ( index !== null ) {
 
-				const indices = index.array;
+				for ( let i = 0, l = index.count - 1; i < l; i += step ) {
 
-				for ( let i = 0, l = indices.length - 1; i < l; i += step ) {
-
-					const a = indices[ i ];
-					const b = indices[ i + 1 ];
+					const a = index.getX( i );
+					const b = index.getX( i + 1 );
 
 					vStart.fromBufferAttribute( positionAttribute, a );
 					vEnd.fromBufferAttribute( positionAttribute, b );

+ 2 - 4
src/objects/Points.js

@@ -73,11 +73,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			if ( index !== null ) {
 
-				const indices = index.array;
+				for ( let i = 0, il = index.count; i < il; i ++ ) {
 
-				for ( let i = 0, il = indices.length; i < il; i ++ ) {
-
-					const a = indices[ i ];
+					const a = index.getX( i );
 
 					_position.fromBufferAttribute( positionAttribute, a );