提交 c1afa582 编写于 作者: R Ricardo Cabello

Merge pull request #6858 from gero3/addScaledVector

Add scaled vector
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
......@@ -63,6 +63,11 @@
Sets this vector to *a + b*.
</div>
<h3>[method:Vector2 addScaledVector]( [page:Vector2 v], [page:Float s] ) [page:Vector2 this]</h3>
<div>
Adds the multiple of v and s to this vector.
</div>
<h3>[method:Vector2 sub]( [page:Vector2 v] ) [page:Vector2 this]</h3>
<div>
Subtracts *v* from this vector.
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
......@@ -83,6 +83,11 @@
Sets this vector to *a + b*.
</div>
<h3>[method:Vector3 addScaledVector]( [page:Vector3 v], [page:Float s] ) [page:Vector3 this]</h3>
<div>
Adds the multiple of v and s to this vector.
</div>
<h3>[method:Vector3 sub]( [page:Vector3 v] ) [page:Vector3 this]</h3>
<div>
Subtracts *v* from this vector.
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
......@@ -58,6 +58,11 @@
Sets this vector to *a + b*.
</div>
<h3>[method:Vector4 addScaledVector]( [page:Vector4 v], [page:Float s] ) [page:Vector4 this]</h3>
<div>
Adds the multiple of v and s to this vector.
</div>
<h3>[method:Vector4 sub]( [page:Vector4 v] )</h3>
<div>
Subtracts *v* from this vector.
......
......@@ -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 ) {
......
......@@ -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 ) {
......
......@@ -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 ) {
......
......@@ -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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册