diff --git a/docs/api/math/Vector2.html b/docs/api/math/Vector2.html index 631160a616f59dfeaf0e899c78d33f00851c6d12..54a5ebf58de3416cec6319fd0832046254d139ef 100644 --- a/docs/api/math/Vector2.html +++ b/docs/api/math/Vector2.html @@ -1,7 +1,7 @@ - + @@ -63,6 +63,11 @@ Sets this vector to *a + b*. +

[method:Vector2 addScaledVector]( [page:Vector2 v], [page:Float s] ) [page:Vector2 this]

+
+ Adds the multiple of v and s to this vector. +
+

[method:Vector2 sub]( [page:Vector2 v] ) [page:Vector2 this]

Subtracts *v* from this vector. diff --git a/docs/api/math/Vector3.html b/docs/api/math/Vector3.html index 865d45958621f30680366702146a317084d2fcb9..38306c0df5ab428d34f8fcf80572713589f49c17 100644 --- a/docs/api/math/Vector3.html +++ b/docs/api/math/Vector3.html @@ -1,7 +1,7 @@ - + @@ -83,6 +83,11 @@ Sets this vector to *a + b*.
+

[method:Vector3 addScaledVector]( [page:Vector3 v], [page:Float s] ) [page:Vector3 this]

+
+ Adds the multiple of v and s to this vector. +
+

[method:Vector3 sub]( [page:Vector3 v] ) [page:Vector3 this]

Subtracts *v* from this vector. diff --git a/docs/api/math/Vector4.html b/docs/api/math/Vector4.html index a20e62e4386c9cf42eb141e964400f0e4a810848..db536eb420f17ece93ba293e2d22fc4d746078c5 100644 --- a/docs/api/math/Vector4.html +++ b/docs/api/math/Vector4.html @@ -1,7 +1,7 @@ - + @@ -58,6 +58,11 @@ Sets this vector to *a + b*.
+

[method:Vector4 addScaledVector]( [page:Vector4 v], [page:Float s] ) [page:Vector4 this]

+
+ Adds the multiple of v and s to this vector. +
+

[method:Vector4 sub]( [page:Vector4 v] )

Subtracts *v* from this vector. diff --git a/src/math/Vector2.js b/src/math/Vector2.js index 84f2d8e016671e9daec1448943bbe92fc8178754..e746a0ffc0da24065b680e64f3779fbac386a462 100644 --- a/src/math/Vector2.js +++ b/src/math/Vector2.js @@ -107,6 +107,15 @@ THREE.Vector2.prototype = { return this; }, + + addScaledVector: function ( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + + return this; + + }, sub: function ( v, w ) { diff --git a/src/math/Vector3.js b/src/math/Vector3.js index 7e4ae51400b8a6fd5f2fe5b5e59b27e89cb84392..2aa3d2bf25694bfc2b19d4e8fa56a64fc1394e8c 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -125,6 +125,16 @@ THREE.Vector3.prototype = { return this; }, + + addScaledVector: function ( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + + return this; + + }, sub: function ( v, w ) { diff --git a/src/math/Vector4.js b/src/math/Vector4.js index dbb9e61e2d1818d1d4e628838fe83d85982737fe..42c68cac245d0f1ad1b3292936ac552b8c66a8f8 100644 --- a/src/math/Vector4.js +++ b/src/math/Vector4.js @@ -140,6 +140,17 @@ THREE.Vector4.prototype = { return this; }, + + addScaledVector: function ( v, s ) { + + this.x += v.x * s; + this.y += v.y * s; + this.z += v.z * s; + this.w += v.w * s; + + return this; + + }, sub: function ( v, w ) { diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index 27a050a35cf76f532bd171a5757cf4d364e64a1c..2550004b8b78514bc944f7aac443b230b4e48a77 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -65,6 +65,11 @@ THREE.Mesh.prototype.raycast = ( function () { var vA = new THREE.Vector3(); var vB = new THREE.Vector3(); var vC = new THREE.Vector3(); + + var tempA = new THREE.Vector3(); + var tempB = new THREE.Vector3(); + var tempC = new THREE.Vector3(); + return function ( raycaster, intersects ) { @@ -221,6 +226,7 @@ THREE.Mesh.prototype.raycast = ( function () { var vertices = geometry.vertices; var faces = geometry.faces; + for ( var f = 0, fl = faces.length; f < fl; f ++ ) { var face = faces[ f ]; @@ -248,18 +254,10 @@ THREE.Mesh.prototype.raycast = ( function () { if ( influence === 0 ) continue; var targets = morphTargets[ t ].vertices; - - vA.x += ( targets[ face.a ].x - a.x ) * influence; - vA.y += ( targets[ face.a ].y - a.y ) * influence; - vA.z += ( targets[ face.a ].z - a.z ) * influence; - - vB.x += ( targets[ face.b ].x - b.x ) * influence; - vB.y += ( targets[ face.b ].y - b.y ) * influence; - vB.z += ( targets[ face.b ].z - b.z ) * influence; - - vC.x += ( targets[ face.c ].x - c.x ) * influence; - vC.y += ( targets[ face.c ].y - c.y ) * influence; - vC.z += ( targets[ face.c ].z - c.z ) * influence; + + vA.addScaledVector(tempA.subVectors(targets[ face.a ], a),influence); + vB.addScaledVector(tempB.subVectors(targets[ face.b ], b),influence); + vC.addScaledVector(tempC.subVectors(targets[ face.c ], c),influence); }