Przeglądaj źródła

Line/Mesh: raycast code clean up.

Mr.doob 9 lat temu
rodzic
commit
785426f2b6
2 zmienionych plików z 7 dodań i 5 usunięć
  1. 5 3
      src/objects/Line.js
  2. 2 2
      src/objects/Mesh.js

+ 5 - 3
src/objects/Line.js

@@ -36,16 +36,18 @@ THREE.Line.prototype.raycast = ( function () {
 
 		var geometry = this.geometry;
 
+		// Checking boundingSphere distance to ray
+
 		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();
 
-		// Checking boundingSphere distance to ray
+		var matrixWorld = this.matrixWorld;
 
 		sphere.copy( geometry.boundingSphere );
-		sphere.applyMatrix4( this.matrixWorld );
+		sphere.applyMatrix4( matrixWorld );
 
 		if ( raycaster.ray.intersectsSphere( sphere ) === false ) return;
 
-		inverseMatrix.getInverse( this.matrixWorld );
+		inverseMatrix.getInverse( matrixWorld );
 		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
 
 		var vStart = new THREE.Vector3();

+ 2 - 2
src/objects/Mesh.js

@@ -100,7 +100,7 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 	}
 
-	function checkIntersection( object, raycaster, ray, pA, pB, pC, point ){
+	function checkIntersection( object, raycaster, ray, pA, pB, pC, point ) {
 
 		var intersect;
 		var material = object.material;
@@ -199,7 +199,7 @@ THREE.Mesh.prototype.raycast = ( function () {
 			var attributes = geometry.attributes;
 			var positions = attributes.position.array;
 
-			if ( attributes.uv !== undefined ){
+			if ( attributes.uv !== undefined ) {
 
 				uvs = attributes.uv.array;