|
@@ -190,6 +190,44 @@ THREE.Vector3.prototype = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ applyEuler: function () {
|
|
|
|
+
|
|
|
|
+ var quaternion;
|
|
|
|
+
|
|
|
|
+ return function ( euler ) {
|
|
|
|
+
|
|
|
|
+ if ( euler instanceof THREE.Euler === false ) {
|
|
|
|
+
|
|
|
|
+ console.error( 'ERROR: Vector3\'s .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.' );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( quaternion === undefined ) quaternion = new THREE.Quaternion();
|
|
|
|
+
|
|
|
|
+ this.applyQuaternion( quaternion.setFromEuler( euler ) );
|
|
|
|
+
|
|
|
|
+ return this;
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ }(),
|
|
|
|
+
|
|
|
|
+ applyAxisAngle: function () {
|
|
|
|
+
|
|
|
|
+ var quaternion;
|
|
|
|
+
|
|
|
|
+ return function ( axis, angle ) {
|
|
|
|
+
|
|
|
|
+ if ( quaternion === undefined ) quaternion = new THREE.Quaternion();
|
|
|
|
+
|
|
|
|
+ this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
|
|
|
|
+
|
|
|
|
+ return this;
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ }(),
|
|
|
|
+
|
|
applyMatrix3: function ( m ) {
|
|
applyMatrix3: function ( m ) {
|
|
|
|
|
|
var x = this.x;
|
|
var x = this.x;
|
|
@@ -557,6 +595,55 @@ THREE.Vector3.prototype = {
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ projectOnVector: function () {
|
|
|
|
+
|
|
|
|
+ var v1;
|
|
|
|
+
|
|
|
|
+ return function ( vector ) {
|
|
|
|
+
|
|
|
|
+ if ( v1 === undefined ) v1 = new THREE.Vector3();
|
|
|
|
+
|
|
|
|
+ v1.copy( vector ).normalize();
|
|
|
|
+
|
|
|
|
+ return this.copy( v1 ).multiplyScalar( this.dot( v1 ) );
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ }(),
|
|
|
|
+
|
|
|
|
+ projectOnPlane: function () {
|
|
|
|
+
|
|
|
|
+ var v1;
|
|
|
|
+
|
|
|
|
+ return function ( planeNormal ) {
|
|
|
|
+
|
|
|
|
+ if ( v1 === undefined ) v1 = new THREE.Vector3();
|
|
|
|
+
|
|
|
|
+ v1.copy( this ).projectOnVector( planeNormal );
|
|
|
|
+
|
|
|
|
+ return this.sub( v1 );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }(),
|
|
|
|
+
|
|
|
|
+ reflect: function () {
|
|
|
|
+
|
|
|
|
+ // reflect incident vector off plane orthogonal to normal
|
|
|
|
+ // normal is assumed to have unit length
|
|
|
|
+
|
|
|
|
+ var v1;
|
|
|
|
+
|
|
|
|
+ return function ( normal ) {
|
|
|
|
+
|
|
|
|
+ if ( v1 === undefined ) v1 = new THREE.Vector3();
|
|
|
|
+
|
|
|
|
+ return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }(),
|
|
|
|
+
|
|
angleTo: function ( v ) {
|
|
angleTo: function ( v ) {
|
|
|
|
|
|
var theta = this.dot( v ) / ( this.length() * v.length() );
|
|
var theta = this.dot( v ) / ( this.length() * v.length() );
|
|
@@ -683,85 +770,4 @@ THREE.Vector3.prototype = {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-THREE.extend( THREE.Vector3.prototype, {
|
|
|
|
-
|
|
|
|
- applyEuler: function () {
|
|
|
|
-
|
|
|
|
- var quaternion = new THREE.Quaternion();
|
|
|
|
-
|
|
|
|
- return function ( euler ) {
|
|
|
|
-
|
|
|
|
- if ( euler instanceof THREE.Euler === false ) {
|
|
|
|
-
|
|
|
|
- console.error( 'ERROR: Vector3\'s .applyEuler() now expects a Euler rotation rather than a Vector3 and order. Please update your code.' );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.applyQuaternion( quaternion.setFromEuler( euler ) );
|
|
|
|
-
|
|
|
|
- return this;
|
|
|
|
-
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- }(),
|
|
|
|
-
|
|
|
|
- applyAxisAngle: function () {
|
|
|
|
-
|
|
|
|
- var quaternion = new THREE.Quaternion();
|
|
|
|
-
|
|
|
|
- return function ( axis, angle ) {
|
|
|
|
-
|
|
|
|
- this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
|
|
|
|
-
|
|
|
|
- return this;
|
|
|
|
-
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- }(),
|
|
|
|
-
|
|
|
|
- projectOnVector: function () {
|
|
|
|
-
|
|
|
|
- var v1 = new THREE.Vector3();
|
|
|
|
-
|
|
|
|
- return function ( vector ) {
|
|
|
|
-
|
|
|
|
- v1.copy( vector ).normalize();
|
|
|
|
- var d = this.dot( v1 );
|
|
|
|
- return this.copy( v1 ).multiplyScalar( d );
|
|
|
|
-
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- }(),
|
|
|
|
-
|
|
|
|
- projectOnPlane: function () {
|
|
|
|
-
|
|
|
|
- var v1 = new THREE.Vector3();
|
|
|
|
-
|
|
|
|
- return function ( planeNormal ) {
|
|
|
|
-
|
|
|
|
- v1.copy( this ).projectOnVector( planeNormal );
|
|
|
|
-
|
|
|
|
- return this.sub( v1 );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }(),
|
|
|
|
-
|
|
|
|
- reflect: function () {
|
|
|
|
-
|
|
|
|
- // reflect incident vector off plane orthogonal to normal
|
|
|
|
- // normal is assumed to have unit length
|
|
|
|
-
|
|
|
|
- var v1 = new THREE.Vector3();
|
|
|
|
-
|
|
|
|
- return function ( normal ) {
|
|
|
|
-
|
|
|
|
- return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
-} );
|
|
|
|
|
|
+};
|