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

Updated builds.

上级 a54c8a56
......@@ -2979,15 +2979,9 @@ THREE.Euler.prototype = {
setFromRotationMatrix: function ( m, order ) {
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
// clamp, to handle numerical problems
var clamp = THREE.Math.clamp;
function clamp( x ) {
return Math.min( Math.max( x, -1 ), 1 );
}
// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
var te = m.elements;
var m11 = te[0], m12 = te[4], m13 = te[8];
......@@ -2998,7 +2992,7 @@ THREE.Euler.prototype = {
if ( order === 'XYZ' ) {
this._y = Math.asin( clamp( m13 ) );
this._y = Math.asin( clamp( m13, -1, 1 ) );
if ( Math.abs( m13 ) < 0.99999 ) {
......@@ -3014,7 +3008,7 @@ THREE.Euler.prototype = {
} else if ( order === 'YXZ' ) {
this._x = Math.asin( - clamp( m23 ) );
this._x = Math.asin( - clamp( m23, -1, 1 ) );
if ( Math.abs( m23 ) < 0.99999 ) {
......@@ -3030,7 +3024,7 @@ THREE.Euler.prototype = {
} else if ( order === 'ZXY' ) {
this._x = Math.asin( clamp( m32 ) );
this._x = Math.asin( clamp( m32, -1, 1 ) );
if ( Math.abs( m32 ) < 0.99999 ) {
......@@ -3046,7 +3040,7 @@ THREE.Euler.prototype = {
} else if ( order === 'ZYX' ) {
this._y = Math.asin( - clamp( m31 ) );
this._y = Math.asin( - clamp( m31, -1, 1 ) );
if ( Math.abs( m31 ) < 0.99999 ) {
......@@ -3062,7 +3056,7 @@ THREE.Euler.prototype = {
} else if ( order === 'YZX' ) {
this._z = Math.asin( clamp( m21 ) );
this._z = Math.asin( clamp( m21, -1, 1 ) );
if ( Math.abs( m21 ) < 0.99999 ) {
......@@ -3078,7 +3072,7 @@ THREE.Euler.prototype = {
} else if ( order === 'XZY' ) {
this._z = Math.asin( - clamp( m12 ) );
this._z = Math.asin( - clamp( m12, -1, 1 ) );
if ( Math.abs( m12 ) < 0.99999 ) {
......@@ -3108,15 +3102,9 @@ THREE.Euler.prototype = {
setFromQuaternion: function ( q, order, update ) {
// q is assumed to be normalized
// clamp, to handle numerical problems
function clamp( x ) {
var clamp = THREE.Math.clamp;
return Math.min( Math.max( x, -1 ), 1 );
}
// q is assumed to be normalized
// http://www.mathworks.com/matlabcentral/fileexchange/20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/content/SpinCalc.m
......@@ -3130,38 +3118,38 @@ THREE.Euler.prototype = {
if ( order === 'XYZ' ) {
this._x = Math.atan2( 2 * ( q.x * q.w - q.y * q.z ), ( sqw - sqx - sqy + sqz ) );
this._y = Math.asin( clamp( 2 * ( q.x * q.z + q.y * q.w ) ) );
this._y = Math.asin( clamp( 2 * ( q.x * q.z + q.y * q.w ), -1, 1 ) );
this._z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw + sqx - sqy - sqz ) );
} else if ( order === 'YXZ' ) {
this._x = Math.asin( clamp( 2 * ( q.x * q.w - q.y * q.z ) ) );
this._x = Math.asin( clamp( 2 * ( q.x * q.w - q.y * q.z ), -1, 1 ) );
this._y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw - sqx - sqy + sqz ) );
this._z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw - sqx + sqy - sqz ) );
} else if ( order === 'ZXY' ) {
this._x = Math.asin( clamp( 2 * ( q.x * q.w + q.y * q.z ) ) );
this._x = Math.asin( clamp( 2 * ( q.x * q.w + q.y * q.z ), -1, 1 ) );
this._y = Math.atan2( 2 * ( q.y * q.w - q.z * q.x ), ( sqw - sqx - sqy + sqz ) );
this._z = Math.atan2( 2 * ( q.z * q.w - q.x * q.y ), ( sqw - sqx + sqy - sqz ) );
} else if ( order === 'ZYX' ) {
this._x = Math.atan2( 2 * ( q.x * q.w + q.z * q.y ), ( sqw - sqx - sqy + sqz ) );
this._y = Math.asin( clamp( 2 * ( q.y * q.w - q.x * q.z ) ) );
this._y = Math.asin( clamp( 2 * ( q.y * q.w - q.x * q.z ), -1, 1 ) );
this._z = Math.atan2( 2 * ( q.x * q.y + q.z * q.w ), ( sqw + sqx - sqy - sqz ) );
} else if ( order === 'YZX' ) {
this._x = Math.atan2( 2 * ( q.x * q.w - q.z * q.y ), ( sqw - sqx + sqy - sqz ) );
this._y = Math.atan2( 2 * ( q.y * q.w - q.x * q.z ), ( sqw + sqx - sqy - sqz ) );
this._z = Math.asin( clamp( 2 * ( q.x * q.y + q.z * q.w ) ) );
this._z = Math.asin( clamp( 2 * ( q.x * q.y + q.z * q.w ), -1, 1 ) );
} else if ( order === 'XZY' ) {
this._x = Math.atan2( 2 * ( q.x * q.w + q.y * q.z ), ( sqw - sqx + sqy - sqz ) );
this._y = Math.atan2( 2 * ( q.x * q.z + q.y * q.w ), ( sqw + sqx - sqy - sqz ) );
this._z = Math.asin( clamp( 2 * ( q.z * q.w - q.x * q.y ) ) );
this._z = Math.asin( clamp( 2 * ( q.z * q.w - q.x * q.y ), -1, 1 ) );
} else {
......@@ -6415,7 +6403,9 @@ THREE.Math = {
}(),
isPowerOfTwo: function ( value ) {
return ( value & ( value - 1 ) ) === 0 && value !== 0;
}
};
......@@ -23418,11 +23408,7 @@ THREE.WebGLRenderer = function ( parameters ) {
function painterSortStable ( a, b ) {
if ( a.materialId !== b.materialId ) {
return b.materialId - a.materialId;
} else if ( a.z !== b.z ) {
if ( a.z !== b.z ) {
return b.z - a.z;
......@@ -23511,7 +23497,6 @@ THREE.WebGLRenderer = function ( parameters ) {
object = webglObject.object;
webglObject.id = i;
webglObject.materialId = object.material.id;
webglObject.render = false;
if ( object.visible ) {
......@@ -23918,80 +23903,85 @@ THREE.WebGLRenderer = function ( parameters ) {
object._modelViewMatrix = new THREE.Matrix4();
object._normalMatrix = new THREE.Matrix3();
if ( object.geometry !== undefined && object.geometry.__webglInit === undefined ) {
geometry = object.geometry;
if ( geometry === undefined ) {
// TODO: Hacky...
object.geometry.__webglInit = true;
object.geometry.addEventListener( 'dispose', onGeometryDispose );
object.__webglActive = true;
return;
}
geometry = object.geometry;
if ( geometry.__webglInit === undefined ) {
if ( geometry === undefined ) {
geometry.__webglInit = true;
geometry.addEventListener( 'dispose', onGeometryDispose );
// fail silently for now
if ( geometry instanceof THREE.BufferGeometry ) {
} else if ( geometry instanceof THREE.BufferGeometry ) {
initDirectBuffers( geometry );
initDirectBuffers( geometry );
} else if ( object instanceof THREE.Mesh ) {
} else if ( object instanceof THREE.Mesh ) {
material = object.material;
material = object.material;
if ( geometry.geometryGroups === undefined ) {
if ( geometry.geometryGroups === undefined ) {
geometry.makeGroups( material instanceof THREE.MeshFaceMaterial, _glExtensionElementIndexUint ? 4294967296 : 65535 );
geometry.makeGroups( material instanceof THREE.MeshFaceMaterial, _glExtensionElementIndexUint ? 4294967296 : 65535 );
}
}
// create separate VBOs per geometry chunk
// create separate VBOs per geometry chunk
for ( g in geometry.geometryGroups ) {
for ( g in geometry.geometryGroups ) {
geometryGroup = geometry.geometryGroups[ g ];
geometryGroup = geometry.geometryGroups[ g ];
// initialise VBO on the first access
// initialise VBO on the first access
if ( ! geometryGroup.__webglVertexBuffer ) {
if ( ! geometryGroup.__webglVertexBuffer ) {
createMeshBuffers( geometryGroup );
initMeshBuffers( geometryGroup, object );
createMeshBuffers( geometryGroup );
initMeshBuffers( geometryGroup, object );
geometry.verticesNeedUpdate = true;
geometry.morphTargetsNeedUpdate = true;
geometry.elementsNeedUpdate = true;
geometry.uvsNeedUpdate = true;
geometry.normalsNeedUpdate = true;
geometry.tangentsNeedUpdate = true;
geometry.colorsNeedUpdate = true;
geometry.verticesNeedUpdate = true;
geometry.morphTargetsNeedUpdate = true;
geometry.elementsNeedUpdate = true;
geometry.uvsNeedUpdate = true;
geometry.normalsNeedUpdate = true;
geometry.tangentsNeedUpdate = true;
geometry.colorsNeedUpdate = true;
}
}
}
} else if ( object instanceof THREE.Line ) {
} else if ( object instanceof THREE.Line ) {
if ( ! geometry.__webglVertexBuffer ) {
if ( ! geometry.__webglVertexBuffer ) {
createLineBuffers( geometry );
initLineBuffers( geometry, object );
createLineBuffers( geometry );
initLineBuffers( geometry, object );
geometry.verticesNeedUpdate = true;
geometry.colorsNeedUpdate = true;
geometry.lineDistancesNeedUpdate = true;
geometry.verticesNeedUpdate = true;
geometry.colorsNeedUpdate = true;
geometry.lineDistancesNeedUpdate = true;
}
}
} else if ( object instanceof THREE.ParticleSystem ) {
} else if ( object instanceof THREE.ParticleSystem ) {
if ( ! geometry.__webglVertexBuffer ) {
if ( ! geometry.__webglVertexBuffer ) {
createParticleBuffers( geometry );
initParticleBuffers( geometry, object );
createParticleBuffers( geometry );
initParticleBuffers( geometry, object );
geometry.verticesNeedUpdate = true;
geometry.colorsNeedUpdate = true;
geometry.verticesNeedUpdate = true;
geometry.colorsNeedUpdate = true;
}
}
......@@ -24054,7 +24044,6 @@ THREE.WebGLRenderer = function ( parameters ) {
id: null,
buffer: buffer,
object: object,
materialId: null,
opaque: null,
transparent: null,
z: 0
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册