提交 a61ec09c 编写于 作者: M Mr.doob

Updated builds.

上级 c794292c
...@@ -1977,23 +1977,22 @@ ...@@ -1977,23 +1977,22 @@
function Quaternion( x, y, z, w ) { function Quaternion( x, y, z, w ) {
this._x = x || 0; this.x = x || 0;
this._y = y || 0; this.y = y || 0;
this._z = z || 0; this.z = z || 0;
this._w = ( w !== undefined ) ? w : 1; this.w = ( w !== undefined ) ? w : 1;
} }
Object.assign( Quaternion, { Object.assign( Quaternion, {
slerp: function( qa, qb, qm, t ) { slerp: function ( qa, qb, qm, t ) {
return qm.copy( qa ).slerp( qb, t ); return qm.copy( qa ).slerp( qb, t );
}, },
slerpFlat: function( slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
// fuzz-free, array-based Quaternion SLERP operation // fuzz-free, array-based Quaternion SLERP operation
...@@ -2057,88 +2056,14 @@ ...@@ -2057,88 +2056,14 @@
} ); } );
Object.defineProperties( Quaternion.prototype, {
"x" : {
get: function () {
return this._x;
},
set: function ( value ) {
this._x = value;
this.onChangeCallback();
}
},
"y" : {
get: function () {
return this._y;
},
set: function ( value ) {
this._y = value;
this.onChangeCallback();
}
},
"z" : {
get: function () {
return this._z;
},
set: function ( value ) {
this._z = value;
this.onChangeCallback();
}
},
"w" : {
get: function () {
return this._w;
},
set: function ( value ) {
this._w = value;
this.onChangeCallback();
}
}
});
Object.assign( Quaternion.prototype, { Object.assign( Quaternion.prototype, {
set: function ( x, y, z, w ) { set: function ( x, y, z, w ) {
this._x = x; this.x = x;
this._y = y; this.y = y;
this._z = z; this.z = z;
this._w = w; this.w = w;
this.onChangeCallback();
return this; return this;
...@@ -2146,24 +2071,22 @@ ...@@ -2146,24 +2071,22 @@
clone: function () { clone: function () {
return new this.constructor( this._x, this._y, this._z, this._w ); return new this.constructor( this.x, this.y, this.z, this.w );
}, },
copy: function ( quaternion ) { copy: function ( quaternion ) {
this._x = quaternion.x; this.x = quaternion.x;
this._y = quaternion.y; this.y = quaternion.y;
this._z = quaternion.z; this.z = quaternion.z;
this._w = quaternion.w; this.w = quaternion.w;
this.onChangeCallback();
return this; return this;
}, },
setFromEuler: function ( euler, update ) { setFromEuler: function ( euler ) {
if ( ( euler && euler.isEuler ) === false ) { if ( ( euler && euler.isEuler ) === false ) {
...@@ -2171,7 +2094,7 @@ ...@@ -2171,7 +2094,7 @@
} }
var x = euler._x, y = euler._y, z = euler._z, order = euler.order; var x = euler.x, y = euler.y, z = euler.z, order = euler.order;
// http://www.mathworks.com/matlabcentral/fileexchange/ // http://www.mathworks.com/matlabcentral/fileexchange/
// 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
...@@ -2190,50 +2113,48 @@ ...@@ -2190,50 +2113,48 @@
if ( order === 'XYZ' ) { if ( order === 'XYZ' ) {
this._x = s1 * c2 * c3 + c1 * s2 * s3; this.x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3; this.y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3; this.z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3; this.w = c1 * c2 * c3 - s1 * s2 * s3;
} else if ( order === 'YXZ' ) { } else if ( order === 'YXZ' ) {
this._x = s1 * c2 * c3 + c1 * s2 * s3; this.x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3; this.y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3; this.z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3; this.w = c1 * c2 * c3 + s1 * s2 * s3;
} else if ( order === 'ZXY' ) { } else if ( order === 'ZXY' ) {
this._x = s1 * c2 * c3 - c1 * s2 * s3; this.x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3; this.y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3; this.z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3; this.w = c1 * c2 * c3 - s1 * s2 * s3;
} else if ( order === 'ZYX' ) { } else if ( order === 'ZYX' ) {
this._x = s1 * c2 * c3 - c1 * s2 * s3; this.x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3; this.y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3; this.z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3; this.w = c1 * c2 * c3 + s1 * s2 * s3;
} else if ( order === 'YZX' ) { } else if ( order === 'YZX' ) {
this._x = s1 * c2 * c3 + c1 * s2 * s3; this.x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3; this.y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3; this.z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3; this.w = c1 * c2 * c3 - s1 * s2 * s3;
} else if ( order === 'XZY' ) { } else if ( order === 'XZY' ) {
this._x = s1 * c2 * c3 - c1 * s2 * s3; this.x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3; this.y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3; this.z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3; this.w = c1 * c2 * c3 + s1 * s2 * s3;
} }
if ( update !== false ) this.onChangeCallback();
return this; return this;
}, },
...@@ -2246,12 +2167,10 @@ ...@@ -2246,12 +2167,10 @@
var halfAngle = angle / 2, s = Math.sin( halfAngle ); var halfAngle = angle / 2, s = Math.sin( halfAngle );
this._x = axis.x * s; this.x = axis.x * s;
this._y = axis.y * s; this.y = axis.y * s;
this._z = axis.z * s; this.z = axis.z * s;
this._w = Math.cos( halfAngle ); this.w = Math.cos( halfAngle );
this.onChangeCallback();
return this; return this;
...@@ -2276,42 +2195,40 @@ ...@@ -2276,42 +2195,40 @@
s = 0.5 / Math.sqrt( trace + 1.0 ); s = 0.5 / Math.sqrt( trace + 1.0 );
this._w = 0.25 / s; this.w = 0.25 / s;
this._x = ( m32 - m23 ) * s; this.x = ( m32 - m23 ) * s;
this._y = ( m13 - m31 ) * s; this.y = ( m13 - m31 ) * s;
this._z = ( m21 - m12 ) * s; this.z = ( m21 - m12 ) * s;
} else if ( m11 > m22 && m11 > m33 ) { } else if ( m11 > m22 && m11 > m33 ) {
s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
this._w = ( m32 - m23 ) / s; this.w = ( m32 - m23 ) / s;
this._x = 0.25 * s; this.x = 0.25 * s;
this._y = ( m12 + m21 ) / s; this.y = ( m12 + m21 ) / s;
this._z = ( m13 + m31 ) / s; this.z = ( m13 + m31 ) / s;
} else if ( m22 > m33 ) { } else if ( m22 > m33 ) {
s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
this._w = ( m13 - m31 ) / s; this.w = ( m13 - m31 ) / s;
this._x = ( m12 + m21 ) / s; this.x = ( m12 + m21 ) / s;
this._y = 0.25 * s; this.y = 0.25 * s;
this._z = ( m23 + m32 ) / s; this.z = ( m23 + m32 ) / s;
} else { } else {
s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
this._w = ( m21 - m12 ) / s; this.w = ( m21 - m12 ) / s;
this._x = ( m13 + m31 ) / s; this.x = ( m13 + m31 ) / s;
this._y = ( m23 + m32 ) / s; this.y = ( m23 + m32 ) / s;
this._z = 0.25 * s; this.z = 0.25 * s;
} }
this.onChangeCallback();
return this; return this;
}, },
...@@ -2353,10 +2270,10 @@ ...@@ -2353,10 +2270,10 @@
} }
this._x = v1.x; this.x = v1.x;
this._y = v1.y; this.y = v1.y;
this._z = v1.z; this.z = v1.z;
this._w = r; this.w = r;
return this.normalize(); return this.normalize();
...@@ -2372,11 +2289,9 @@ ...@@ -2372,11 +2289,9 @@
conjugate: function () { conjugate: function () {
this._x *= - 1; this.x *= - 1;
this._y *= - 1; this.y *= - 1;
this._z *= - 1; this.z *= - 1;
this.onChangeCallback();
return this; return this;
...@@ -2384,19 +2299,19 @@ ...@@ -2384,19 +2299,19 @@
dot: function ( v ) { dot: function ( v ) {
return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
}, },
lengthSq: function () { lengthSq: function () {
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
}, },
length: function () { length: function () {
return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
}, },
...@@ -2406,24 +2321,22 @@ ...@@ -2406,24 +2321,22 @@
if ( l === 0 ) { if ( l === 0 ) {
this._x = 0; this.x = 0;
this._y = 0; this.y = 0;
this._z = 0; this.z = 0;
this._w = 1; this.w = 1;
} else { } else {
l = 1 / l; l = 1 / l;
this._x = this._x * l; this.x = this.x * l;
this._y = this._y * l; this.y = this.y * l;
this._z = this._z * l; this.z = this.z * l;
this._w = this._w * l; this.w = this.w * l;
} }
this.onChangeCallback();
return this; return this;
}, },
...@@ -2451,15 +2364,13 @@ ...@@ -2451,15 +2364,13 @@
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; var qax = a.x, qay = a.y, qaz = a.z, qaw = a.w;
var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; var qbx = b.x, qby = b.y, qbz = b.z, qbw = b.w;
this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
this.onChangeCallback();
return this; return this;
...@@ -2470,18 +2381,18 @@ ...@@ -2470,18 +2381,18 @@
if ( t === 0 ) return this; if ( t === 0 ) return this;
if ( t === 1 ) return this.copy( qb ); if ( t === 1 ) return this.copy( qb );
var x = this._x, y = this._y, z = this._z, w = this._w; var x = this.x, y = this.y, z = this.z, w = this.w;
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; var cosHalfTheta = w * qb.w + x * qb.x + y * qb.y + z * qb.z;
if ( cosHalfTheta < 0 ) { if ( cosHalfTheta < 0 ) {
this._w = - qb._w; this.w = - qb.w;
this._x = - qb._x; this.x = - qb.x;
this._y = - qb._y; this.y = - qb.y;
this._z = - qb._z; this.z = - qb.z;
cosHalfTheta = - cosHalfTheta; cosHalfTheta = - cosHalfTheta;
...@@ -2493,10 +2404,10 @@ ...@@ -2493,10 +2404,10 @@
if ( cosHalfTheta >= 1.0 ) { if ( cosHalfTheta >= 1.0 ) {
this._w = w; this.w = w;
this._x = x; this.x = x;
this._y = y; this.y = y;
this._z = z; this.z = z;
return this; return this;
...@@ -2506,10 +2417,10 @@ ...@@ -2506,10 +2417,10 @@
if ( Math.abs( sinHalfTheta ) < 0.001 ) { if ( Math.abs( sinHalfTheta ) < 0.001 ) {
this._w = 0.5 * ( w + this._w ); this.w = 0.5 * ( w + this.w );
this._x = 0.5 * ( x + this._x ); this.x = 0.5 * ( x + this.x );
this._y = 0.5 * ( y + this._y ); this.y = 0.5 * ( y + this.y );
this._z = 0.5 * ( z + this._z ); this.z = 0.5 * ( z + this.z );
return this; return this;
...@@ -2519,12 +2430,10 @@ ...@@ -2519,12 +2430,10 @@
var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
this._w = ( w * ratioA + this._w * ratioB ); this.w = ( w * ratioA + this.w * ratioB );
this._x = ( x * ratioA + this._x * ratioB ); this.x = ( x * ratioA + this.x * ratioB );
this._y = ( y * ratioA + this._y * ratioB ); this.y = ( y * ratioA + this.y * ratioB );
this._z = ( z * ratioA + this._z * ratioB ); this.z = ( z * ratioA + this.z * ratioB );
this.onChangeCallback();
return this; return this;
...@@ -2532,7 +2441,7 @@ ...@@ -2532,7 +2441,7 @@
equals: function ( quaternion ) { equals: function ( quaternion ) {
return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); return ( quaternion.x === this.x ) && ( quaternion.y === this.y ) && ( quaternion.z === this.z ) && ( quaternion.w === this.w );
}, },
...@@ -2540,12 +2449,10 @@ ...@@ -2540,12 +2449,10 @@
if ( offset === undefined ) offset = 0; if ( offset === undefined ) offset = 0;
this._x = array[ offset ]; this.x = array[ offset ];
this._y = array[ offset + 1 ]; this.y = array[ offset + 1 ];
this._z = array[ offset + 2 ]; this.z = array[ offset + 2 ];
this._w = array[ offset + 3 ]; this.w = array[ offset + 3 ];
this.onChangeCallback();
return this; return this;
...@@ -2556,24 +2463,14 @@ ...@@ -2556,24 +2463,14 @@
if ( array === undefined ) array = []; if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0; if ( offset === undefined ) offset = 0;
array[ offset ] = this._x; array[ offset ] = this.x;
array[ offset + 1 ] = this._y; array[ offset + 1 ] = this.y;
array[ offset + 2 ] = this._z; array[ offset + 2 ] = this.z;
array[ offset + 3 ] = this._w; array[ offset + 3 ] = this.w;
return array; return array;
}, }
onChange: function ( callback ) {
this.onChangeCallback = callback;
return this;
},
onChangeCallback: function () {}
} ); } );
...@@ -4783,14 +4680,6 @@ ...@@ -4783,14 +4680,6 @@
}; };
WebGLUniforms.prototype.set = function ( gl, object, name ) {
var u = this.map[ name ];
if ( u !== undefined ) u.setValue( gl, object[ name ], this.renderer );
};
WebGLUniforms.prototype.setOptional = function ( gl, object, name ) { WebGLUniforms.prototype.setOptional = function ( gl, object, name ) {
var v = object[ name ]; var v = object[ name ];
...@@ -9968,7 +9857,7 @@ ...@@ -9968,7 +9857,7 @@
Object.defineProperties( Euler.prototype, { Object.defineProperties( Euler.prototype, {
"x" : { x: {
get: function () { get: function () {
...@@ -9985,7 +9874,7 @@ ...@@ -9985,7 +9874,7 @@
}, },
"y" : { y: {
get: function () { get: function () {
...@@ -10002,7 +9891,7 @@ ...@@ -10002,7 +9891,7 @@
}, },
"z" : { z: {
get: function () { get: function () {
...@@ -10019,7 +9908,7 @@ ...@@ -10019,7 +9908,7 @@
}, },
"order" : { order: {
get: function () { get: function () {
...@@ -10036,7 +9925,7 @@ ...@@ -10036,7 +9925,7 @@
} }
}); } );
Object.assign( Euler.prototype, { Object.assign( Euler.prototype, {
...@@ -10361,24 +10250,18 @@ ...@@ -10361,24 +10250,18 @@
this.up = Object3D.DefaultUp.clone(); this.up = Object3D.DefaultUp.clone();
var position = new Vector3(); var position = new Vector3();
var rotation = new Euler();
var quaternion = new Quaternion(); var quaternion = new Quaternion();
var scale = new Vector3( 1, 1, 1 ); var scale = new Vector3( 1, 1, 1 );
function onRotationChange() { var rotation = new Euler();
quaternion.setFromEuler( rotation, false );
}
function onQuaternionChange() { function onRotationChange() {
rotation.setFromQuaternion( quaternion, undefined, false ); quaternion.setFromEuler( rotation );
} }
rotation.onChange( onRotationChange ); rotation.onChange( onRotationChange );
quaternion.onChange( onQuaternionChange );
Object.defineProperties( this, { Object.defineProperties( this, {
position: { position: {
...@@ -10452,7 +10335,7 @@ ...@@ -10452,7 +10335,7 @@
setRotationFromEuler: function ( euler ) { setRotationFromEuler: function ( euler ) {
this.quaternion.setFromEuler( euler, true ); this.quaternion.setFromEuler( euler );
}, },
...@@ -20944,8 +20827,6 @@ ...@@ -20944,8 +20827,6 @@
// opaque pass (front-to-back order) // opaque pass (front-to-back order)
state.setBlending( NoBlending );
if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera ); if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
// transparent pass (back-to-front order) // transparent pass (back-to-front order)
...@@ -21436,7 +21317,7 @@ ...@@ -21436,7 +21317,7 @@
if ( refreshProgram || camera !== _currentCamera ) { if ( refreshProgram || camera !== _currentCamera ) {
p_uniforms.set( _gl, camera, 'projectionMatrix' ); p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
if ( capabilities.logarithmicDepthBuffer ) { if ( capabilities.logarithmicDepthBuffer ) {
...@@ -21489,8 +21370,8 @@ ...@@ -21489,8 +21370,8 @@
} }
p_uniforms.set( _gl, _this, 'toneMappingExposure' ); p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
p_uniforms.set( _gl, _this, 'toneMappingWhitePoint' ); p_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );
} }
...@@ -21536,8 +21417,8 @@ ...@@ -21536,8 +21417,8 @@
} }
p_uniforms.set( _gl, skeleton, 'boneTexture' ); p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture );
p_uniforms.set( _gl, skeleton, 'boneTextureSize' ); p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
} else { } else {
...@@ -21650,8 +21531,8 @@ ...@@ -21650,8 +21531,8 @@
// common matrices // common matrices
p_uniforms.set( _gl, object, 'modelViewMatrix' ); p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
p_uniforms.set( _gl, object, 'normalMatrix' ); p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld ); p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
return program; return program;
......
此差异已折叠。
...@@ -1971,23 +1971,22 @@ WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true; ...@@ -1971,23 +1971,22 @@ WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;
function Quaternion( x, y, z, w ) { function Quaternion( x, y, z, w ) {
this._x = x || 0; this.x = x || 0;
this._y = y || 0; this.y = y || 0;
this._z = z || 0; this.z = z || 0;
this._w = ( w !== undefined ) ? w : 1; this.w = ( w !== undefined ) ? w : 1;
} }
Object.assign( Quaternion, { Object.assign( Quaternion, {
slerp: function( qa, qb, qm, t ) { slerp: function ( qa, qb, qm, t ) {
return qm.copy( qa ).slerp( qb, t ); return qm.copy( qa ).slerp( qb, t );
}, },
slerpFlat: function( slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
// fuzz-free, array-based Quaternion SLERP operation // fuzz-free, array-based Quaternion SLERP operation
...@@ -2051,88 +2050,14 @@ Object.assign( Quaternion, { ...@@ -2051,88 +2050,14 @@ Object.assign( Quaternion, {
} ); } );
Object.defineProperties( Quaternion.prototype, {
"x" : {
get: function () {
return this._x;
},
set: function ( value ) {
this._x = value;
this.onChangeCallback();
}
},
"y" : {
get: function () {
return this._y;
},
set: function ( value ) {
this._y = value;
this.onChangeCallback();
}
},
"z" : {
get: function () {
return this._z;
},
set: function ( value ) {
this._z = value;
this.onChangeCallback();
}
},
"w" : {
get: function () {
return this._w;
},
set: function ( value ) {
this._w = value;
this.onChangeCallback();
}
}
});
Object.assign( Quaternion.prototype, { Object.assign( Quaternion.prototype, {
set: function ( x, y, z, w ) { set: function ( x, y, z, w ) {
this._x = x; this.x = x;
this._y = y; this.y = y;
this._z = z; this.z = z;
this._w = w; this.w = w;
this.onChangeCallback();
return this; return this;
...@@ -2140,24 +2065,22 @@ Object.assign( Quaternion.prototype, { ...@@ -2140,24 +2065,22 @@ Object.assign( Quaternion.prototype, {
clone: function () { clone: function () {
return new this.constructor( this._x, this._y, this._z, this._w ); return new this.constructor( this.x, this.y, this.z, this.w );
}, },
copy: function ( quaternion ) { copy: function ( quaternion ) {
this._x = quaternion.x; this.x = quaternion.x;
this._y = quaternion.y; this.y = quaternion.y;
this._z = quaternion.z; this.z = quaternion.z;
this._w = quaternion.w; this.w = quaternion.w;
this.onChangeCallback();
return this; return this;
}, },
setFromEuler: function ( euler, update ) { setFromEuler: function ( euler ) {
if ( ( euler && euler.isEuler ) === false ) { if ( ( euler && euler.isEuler ) === false ) {
...@@ -2165,7 +2088,7 @@ Object.assign( Quaternion.prototype, { ...@@ -2165,7 +2088,7 @@ Object.assign( Quaternion.prototype, {
} }
var x = euler._x, y = euler._y, z = euler._z, order = euler.order; var x = euler.x, y = euler.y, z = euler.z, order = euler.order;
// http://www.mathworks.com/matlabcentral/fileexchange/ // http://www.mathworks.com/matlabcentral/fileexchange/
// 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/ // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
...@@ -2184,50 +2107,48 @@ Object.assign( Quaternion.prototype, { ...@@ -2184,50 +2107,48 @@ Object.assign( Quaternion.prototype, {
if ( order === 'XYZ' ) { if ( order === 'XYZ' ) {
this._x = s1 * c2 * c3 + c1 * s2 * s3; this.x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3; this.y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3; this.z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3; this.w = c1 * c2 * c3 - s1 * s2 * s3;
} else if ( order === 'YXZ' ) { } else if ( order === 'YXZ' ) {
this._x = s1 * c2 * c3 + c1 * s2 * s3; this.x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3; this.y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3; this.z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3; this.w = c1 * c2 * c3 + s1 * s2 * s3;
} else if ( order === 'ZXY' ) { } else if ( order === 'ZXY' ) {
this._x = s1 * c2 * c3 - c1 * s2 * s3; this.x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3; this.y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3; this.z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3; this.w = c1 * c2 * c3 - s1 * s2 * s3;
} else if ( order === 'ZYX' ) { } else if ( order === 'ZYX' ) {
this._x = s1 * c2 * c3 - c1 * s2 * s3; this.x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3; this.y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3; this.z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3; this.w = c1 * c2 * c3 + s1 * s2 * s3;
} else if ( order === 'YZX' ) { } else if ( order === 'YZX' ) {
this._x = s1 * c2 * c3 + c1 * s2 * s3; this.x = s1 * c2 * c3 + c1 * s2 * s3;
this._y = c1 * s2 * c3 + s1 * c2 * s3; this.y = c1 * s2 * c3 + s1 * c2 * s3;
this._z = c1 * c2 * s3 - s1 * s2 * c3; this.z = c1 * c2 * s3 - s1 * s2 * c3;
this._w = c1 * c2 * c3 - s1 * s2 * s3; this.w = c1 * c2 * c3 - s1 * s2 * s3;
} else if ( order === 'XZY' ) { } else if ( order === 'XZY' ) {
this._x = s1 * c2 * c3 - c1 * s2 * s3; this.x = s1 * c2 * c3 - c1 * s2 * s3;
this._y = c1 * s2 * c3 - s1 * c2 * s3; this.y = c1 * s2 * c3 - s1 * c2 * s3;
this._z = c1 * c2 * s3 + s1 * s2 * c3; this.z = c1 * c2 * s3 + s1 * s2 * c3;
this._w = c1 * c2 * c3 + s1 * s2 * s3; this.w = c1 * c2 * c3 + s1 * s2 * s3;
} }
if ( update !== false ) this.onChangeCallback();
return this; return this;
}, },
...@@ -2240,12 +2161,10 @@ Object.assign( Quaternion.prototype, { ...@@ -2240,12 +2161,10 @@ Object.assign( Quaternion.prototype, {
var halfAngle = angle / 2, s = Math.sin( halfAngle ); var halfAngle = angle / 2, s = Math.sin( halfAngle );
this._x = axis.x * s; this.x = axis.x * s;
this._y = axis.y * s; this.y = axis.y * s;
this._z = axis.z * s; this.z = axis.z * s;
this._w = Math.cos( halfAngle ); this.w = Math.cos( halfAngle );
this.onChangeCallback();
return this; return this;
...@@ -2270,42 +2189,40 @@ Object.assign( Quaternion.prototype, { ...@@ -2270,42 +2189,40 @@ Object.assign( Quaternion.prototype, {
s = 0.5 / Math.sqrt( trace + 1.0 ); s = 0.5 / Math.sqrt( trace + 1.0 );
this._w = 0.25 / s; this.w = 0.25 / s;
this._x = ( m32 - m23 ) * s; this.x = ( m32 - m23 ) * s;
this._y = ( m13 - m31 ) * s; this.y = ( m13 - m31 ) * s;
this._z = ( m21 - m12 ) * s; this.z = ( m21 - m12 ) * s;
} else if ( m11 > m22 && m11 > m33 ) { } else if ( m11 > m22 && m11 > m33 ) {
s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 ); s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
this._w = ( m32 - m23 ) / s; this.w = ( m32 - m23 ) / s;
this._x = 0.25 * s; this.x = 0.25 * s;
this._y = ( m12 + m21 ) / s; this.y = ( m12 + m21 ) / s;
this._z = ( m13 + m31 ) / s; this.z = ( m13 + m31 ) / s;
} else if ( m22 > m33 ) { } else if ( m22 > m33 ) {
s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 ); s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
this._w = ( m13 - m31 ) / s; this.w = ( m13 - m31 ) / s;
this._x = ( m12 + m21 ) / s; this.x = ( m12 + m21 ) / s;
this._y = 0.25 * s; this.y = 0.25 * s;
this._z = ( m23 + m32 ) / s; this.z = ( m23 + m32 ) / s;
} else { } else {
s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 ); s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
this._w = ( m21 - m12 ) / s; this.w = ( m21 - m12 ) / s;
this._x = ( m13 + m31 ) / s; this.x = ( m13 + m31 ) / s;
this._y = ( m23 + m32 ) / s; this.y = ( m23 + m32 ) / s;
this._z = 0.25 * s; this.z = 0.25 * s;
} }
this.onChangeCallback();
return this; return this;
}, },
...@@ -2347,10 +2264,10 @@ Object.assign( Quaternion.prototype, { ...@@ -2347,10 +2264,10 @@ Object.assign( Quaternion.prototype, {
} }
this._x = v1.x; this.x = v1.x;
this._y = v1.y; this.y = v1.y;
this._z = v1.z; this.z = v1.z;
this._w = r; this.w = r;
return this.normalize(); return this.normalize();
...@@ -2366,11 +2283,9 @@ Object.assign( Quaternion.prototype, { ...@@ -2366,11 +2283,9 @@ Object.assign( Quaternion.prototype, {
conjugate: function () { conjugate: function () {
this._x *= - 1; this.x *= - 1;
this._y *= - 1; this.y *= - 1;
this._z *= - 1; this.z *= - 1;
this.onChangeCallback();
return this; return this;
...@@ -2378,19 +2293,19 @@ Object.assign( Quaternion.prototype, { ...@@ -2378,19 +2293,19 @@ Object.assign( Quaternion.prototype, {
dot: function ( v ) { dot: function ( v ) {
return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w; return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
}, },
lengthSq: function () { lengthSq: function () {
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
}, },
length: function () { length: function () {
return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w ); return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
}, },
...@@ -2400,24 +2315,22 @@ Object.assign( Quaternion.prototype, { ...@@ -2400,24 +2315,22 @@ Object.assign( Quaternion.prototype, {
if ( l === 0 ) { if ( l === 0 ) {
this._x = 0; this.x = 0;
this._y = 0; this.y = 0;
this._z = 0; this.z = 0;
this._w = 1; this.w = 1;
} else { } else {
l = 1 / l; l = 1 / l;
this._x = this._x * l; this.x = this.x * l;
this._y = this._y * l; this.y = this.y * l;
this._z = this._z * l; this.z = this.z * l;
this._w = this._w * l; this.w = this.w * l;
} }
this.onChangeCallback();
return this; return this;
}, },
...@@ -2445,15 +2358,13 @@ Object.assign( Quaternion.prototype, { ...@@ -2445,15 +2358,13 @@ Object.assign( Quaternion.prototype, {
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
var qax = a._x, qay = a._y, qaz = a._z, qaw = a._w; var qax = a.x, qay = a.y, qaz = a.z, qaw = a.w;
var qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w; var qbx = b.x, qby = b.y, qbz = b.z, qbw = b.w;
this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
this.onChangeCallback();
return this; return this;
...@@ -2464,18 +2375,18 @@ Object.assign( Quaternion.prototype, { ...@@ -2464,18 +2375,18 @@ Object.assign( Quaternion.prototype, {
if ( t === 0 ) return this; if ( t === 0 ) return this;
if ( t === 1 ) return this.copy( qb ); if ( t === 1 ) return this.copy( qb );
var x = this._x, y = this._y, z = this._z, w = this._w; var x = this.x, y = this.y, z = this.z, w = this.w;
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/ // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z; var cosHalfTheta = w * qb.w + x * qb.x + y * qb.y + z * qb.z;
if ( cosHalfTheta < 0 ) { if ( cosHalfTheta < 0 ) {
this._w = - qb._w; this.w = - qb.w;
this._x = - qb._x; this.x = - qb.x;
this._y = - qb._y; this.y = - qb.y;
this._z = - qb._z; this.z = - qb.z;
cosHalfTheta = - cosHalfTheta; cosHalfTheta = - cosHalfTheta;
...@@ -2487,10 +2398,10 @@ Object.assign( Quaternion.prototype, { ...@@ -2487,10 +2398,10 @@ Object.assign( Quaternion.prototype, {
if ( cosHalfTheta >= 1.0 ) { if ( cosHalfTheta >= 1.0 ) {
this._w = w; this.w = w;
this._x = x; this.x = x;
this._y = y; this.y = y;
this._z = z; this.z = z;
return this; return this;
...@@ -2500,10 +2411,10 @@ Object.assign( Quaternion.prototype, { ...@@ -2500,10 +2411,10 @@ Object.assign( Quaternion.prototype, {
if ( Math.abs( sinHalfTheta ) < 0.001 ) { if ( Math.abs( sinHalfTheta ) < 0.001 ) {
this._w = 0.5 * ( w + this._w ); this.w = 0.5 * ( w + this.w );
this._x = 0.5 * ( x + this._x ); this.x = 0.5 * ( x + this.x );
this._y = 0.5 * ( y + this._y ); this.y = 0.5 * ( y + this.y );
this._z = 0.5 * ( z + this._z ); this.z = 0.5 * ( z + this.z );
return this; return this;
...@@ -2513,12 +2424,10 @@ Object.assign( Quaternion.prototype, { ...@@ -2513,12 +2424,10 @@ Object.assign( Quaternion.prototype, {
var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta, var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
this._w = ( w * ratioA + this._w * ratioB ); this.w = ( w * ratioA + this.w * ratioB );
this._x = ( x * ratioA + this._x * ratioB ); this.x = ( x * ratioA + this.x * ratioB );
this._y = ( y * ratioA + this._y * ratioB ); this.y = ( y * ratioA + this.y * ratioB );
this._z = ( z * ratioA + this._z * ratioB ); this.z = ( z * ratioA + this.z * ratioB );
this.onChangeCallback();
return this; return this;
...@@ -2526,7 +2435,7 @@ Object.assign( Quaternion.prototype, { ...@@ -2526,7 +2435,7 @@ Object.assign( Quaternion.prototype, {
equals: function ( quaternion ) { equals: function ( quaternion ) {
return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w ); return ( quaternion.x === this.x ) && ( quaternion.y === this.y ) && ( quaternion.z === this.z ) && ( quaternion.w === this.w );
}, },
...@@ -2534,12 +2443,10 @@ Object.assign( Quaternion.prototype, { ...@@ -2534,12 +2443,10 @@ Object.assign( Quaternion.prototype, {
if ( offset === undefined ) offset = 0; if ( offset === undefined ) offset = 0;
this._x = array[ offset ]; this.x = array[ offset ];
this._y = array[ offset + 1 ]; this.y = array[ offset + 1 ];
this._z = array[ offset + 2 ]; this.z = array[ offset + 2 ];
this._w = array[ offset + 3 ]; this.w = array[ offset + 3 ];
this.onChangeCallback();
return this; return this;
...@@ -2550,24 +2457,14 @@ Object.assign( Quaternion.prototype, { ...@@ -2550,24 +2457,14 @@ Object.assign( Quaternion.prototype, {
if ( array === undefined ) array = []; if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0; if ( offset === undefined ) offset = 0;
array[ offset ] = this._x; array[ offset ] = this.x;
array[ offset + 1 ] = this._y; array[ offset + 1 ] = this.y;
array[ offset + 2 ] = this._z; array[ offset + 2 ] = this.z;
array[ offset + 3 ] = this._w; array[ offset + 3 ] = this.w;
return array; return array;
}, }
onChange: function ( callback ) {
this.onChangeCallback = callback;
return this;
},
onChangeCallback: function () {}
} ); } );
...@@ -4777,14 +4674,6 @@ WebGLUniforms.prototype.setValue = function ( gl, name, value ) { ...@@ -4777,14 +4674,6 @@ WebGLUniforms.prototype.setValue = function ( gl, name, value ) {
}; };
WebGLUniforms.prototype.set = function ( gl, object, name ) {
var u = this.map[ name ];
if ( u !== undefined ) u.setValue( gl, object[ name ], this.renderer );
};
WebGLUniforms.prototype.setOptional = function ( gl, object, name ) { WebGLUniforms.prototype.setOptional = function ( gl, object, name ) {
var v = object[ name ]; var v = object[ name ];
...@@ -9962,7 +9851,7 @@ Euler.DefaultOrder = 'XYZ'; ...@@ -9962,7 +9851,7 @@ Euler.DefaultOrder = 'XYZ';
Object.defineProperties( Euler.prototype, { Object.defineProperties( Euler.prototype, {
"x" : { x: {
get: function () { get: function () {
...@@ -9979,7 +9868,7 @@ Object.defineProperties( Euler.prototype, { ...@@ -9979,7 +9868,7 @@ Object.defineProperties( Euler.prototype, {
}, },
"y" : { y: {
get: function () { get: function () {
...@@ -9996,7 +9885,7 @@ Object.defineProperties( Euler.prototype, { ...@@ -9996,7 +9885,7 @@ Object.defineProperties( Euler.prototype, {
}, },
"z" : { z: {
get: function () { get: function () {
...@@ -10013,7 +9902,7 @@ Object.defineProperties( Euler.prototype, { ...@@ -10013,7 +9902,7 @@ Object.defineProperties( Euler.prototype, {
}, },
"order" : { order: {
get: function () { get: function () {
...@@ -10030,7 +9919,7 @@ Object.defineProperties( Euler.prototype, { ...@@ -10030,7 +9919,7 @@ Object.defineProperties( Euler.prototype, {
} }
}); } );
Object.assign( Euler.prototype, { Object.assign( Euler.prototype, {
...@@ -10355,24 +10244,18 @@ function Object3D() { ...@@ -10355,24 +10244,18 @@ function Object3D() {
this.up = Object3D.DefaultUp.clone(); this.up = Object3D.DefaultUp.clone();
var position = new Vector3(); var position = new Vector3();
var rotation = new Euler();
var quaternion = new Quaternion(); var quaternion = new Quaternion();
var scale = new Vector3( 1, 1, 1 ); var scale = new Vector3( 1, 1, 1 );
function onRotationChange() { var rotation = new Euler();
quaternion.setFromEuler( rotation, false );
}
function onQuaternionChange() { function onRotationChange() {
rotation.setFromQuaternion( quaternion, undefined, false ); quaternion.setFromEuler( rotation );
} }
rotation.onChange( onRotationChange ); rotation.onChange( onRotationChange );
quaternion.onChange( onQuaternionChange );
Object.defineProperties( this, { Object.defineProperties( this, {
position: { position: {
...@@ -10446,7 +10329,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { ...@@ -10446,7 +10329,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
setRotationFromEuler: function ( euler ) { setRotationFromEuler: function ( euler ) {
this.quaternion.setFromEuler( euler, true ); this.quaternion.setFromEuler( euler );
}, },
...@@ -20938,8 +20821,6 @@ function WebGLRenderer( parameters ) { ...@@ -20938,8 +20821,6 @@ function WebGLRenderer( parameters ) {
// opaque pass (front-to-back order) // opaque pass (front-to-back order)
state.setBlending( NoBlending );
if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera ); if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
// transparent pass (back-to-front order) // transparent pass (back-to-front order)
...@@ -21430,7 +21311,7 @@ function WebGLRenderer( parameters ) { ...@@ -21430,7 +21311,7 @@ function WebGLRenderer( parameters ) {
if ( refreshProgram || camera !== _currentCamera ) { if ( refreshProgram || camera !== _currentCamera ) {
p_uniforms.set( _gl, camera, 'projectionMatrix' ); p_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );
if ( capabilities.logarithmicDepthBuffer ) { if ( capabilities.logarithmicDepthBuffer ) {
...@@ -21483,8 +21364,8 @@ function WebGLRenderer( parameters ) { ...@@ -21483,8 +21364,8 @@ function WebGLRenderer( parameters ) {
} }
p_uniforms.set( _gl, _this, 'toneMappingExposure' ); p_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );
p_uniforms.set( _gl, _this, 'toneMappingWhitePoint' ); p_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );
} }
...@@ -21530,8 +21411,8 @@ function WebGLRenderer( parameters ) { ...@@ -21530,8 +21411,8 @@ function WebGLRenderer( parameters ) {
} }
p_uniforms.set( _gl, skeleton, 'boneTexture' ); p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture );
p_uniforms.set( _gl, skeleton, 'boneTextureSize' ); p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
} else { } else {
...@@ -21644,8 +21525,8 @@ function WebGLRenderer( parameters ) { ...@@ -21644,8 +21525,8 @@ function WebGLRenderer( parameters ) {
// common matrices // common matrices
p_uniforms.set( _gl, object, 'modelViewMatrix' ); p_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );
p_uniforms.set( _gl, object, 'normalMatrix' ); p_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );
p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld ); p_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );
return program; return program;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册