diff --git a/annotations/pom.xml b/annotations/pom.xml
index 6a026ca4..3be17ae6 100644
--- a/annotations/pom.xml
+++ b/annotations/pom.xml
@@ -5,7 +5,7 @@
org.treblereel.gwt
three4g-parent
- 0.102
+ 0.103
..
diff --git a/core/pom.xml b/core/pom.xml
index 1553b43e..7f40121d 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -5,7 +5,7 @@
org.treblereel.gwt
three4g-parent
- 0.102
+ 0.103
..
diff --git a/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js b/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js
index 42f968da..56f738b3 100644
--- a/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js
+++ b/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.js
@@ -185,7 +185,7 @@
} );
- var REVISION = '102';
+ var REVISION = '103';
var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
var CullFaceNone = 0;
var CullFaceBack = 1;
@@ -979,889 +979,590 @@
} );
/**
- * @author mrdoob / http://mrdoob.com/
- * @author supereggbert / http://www.paulbrunt.co.uk/
- * @author philogb / http://blog.thejit.org/
- * @author jordi_ros / http://plattsoft.com
- * @author D1plo1d / http://github.com/D1plo1d
- * @author alteredq / http://alteredqualia.com/
* @author mikael emtinger / http://gomo.se/
- * @author timknip / http://www.floorplanner.com/
- * @author bhouston / http://clara.io
+ * @author alteredq / http://alteredqualia.com/
* @author WestLangley / http://github.com/WestLangley
+ * @author bhouston / http://clara.io
*/
- function Matrix4() {
-
- this.elements = [
-
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
-
- ];
-
- if ( arguments.length > 0 ) {
-
- console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
+ function Quaternion( x, y, z, w ) {
- }
+ this._x = x || 0;
+ this._y = y || 0;
+ this._z = z || 0;
+ this._w = ( w !== undefined ) ? w : 1;
}
- Object.assign( Matrix4.prototype, {
-
- isMatrix4: true,
-
- set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
-
- var te = this.elements;
-
- te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;
- te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;
- te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;
- te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;
-
- return this;
-
- },
-
- identity: function () {
-
- this.set(
-
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
-
- );
-
- return this;
-
- },
-
- clone: function () {
-
- return new Matrix4().fromArray( this.elements );
-
- },
-
- copy: function ( m ) {
-
- var te = this.elements;
- var me = m.elements;
+ Object.assign( Quaternion, {
- te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];
- te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];
- te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];
- te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];
+ slerp: function ( qa, qb, qm, t ) {
- return this;
+ return qm.copy( qa ).slerp( qb, t );
},
- copyPosition: function ( m ) {
+ slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
- var te = this.elements, me = m.elements;
+ // fuzz-free, array-based Quaternion SLERP operation
- te[ 12 ] = me[ 12 ];
- te[ 13 ] = me[ 13 ];
- te[ 14 ] = me[ 14 ];
+ var x0 = src0[ srcOffset0 + 0 ],
+ y0 = src0[ srcOffset0 + 1 ],
+ z0 = src0[ srcOffset0 + 2 ],
+ w0 = src0[ srcOffset0 + 3 ],
- return this;
+ x1 = src1[ srcOffset1 + 0 ],
+ y1 = src1[ srcOffset1 + 1 ],
+ z1 = src1[ srcOffset1 + 2 ],
+ w1 = src1[ srcOffset1 + 3 ];
- },
+ if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
- extractBasis: function ( xAxis, yAxis, zAxis ) {
+ var s = 1 - t,
- xAxis.setFromMatrixColumn( this, 0 );
- yAxis.setFromMatrixColumn( this, 1 );
- zAxis.setFromMatrixColumn( this, 2 );
+ cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
- return this;
+ dir = ( cos >= 0 ? 1 : - 1 ),
+ sqrSin = 1 - cos * cos;
- },
+ // Skip the Slerp for tiny steps to avoid numeric problems:
+ if ( sqrSin > Number.EPSILON ) {
- makeBasis: function ( xAxis, yAxis, zAxis ) {
+ var sin = Math.sqrt( sqrSin ),
+ len = Math.atan2( sin, cos * dir );
- this.set(
- xAxis.x, yAxis.x, zAxis.x, 0,
- xAxis.y, yAxis.y, zAxis.y, 0,
- xAxis.z, yAxis.z, zAxis.z, 0,
- 0, 0, 0, 1
- );
+ s = Math.sin( s * len ) / sin;
+ t = Math.sin( t * len ) / sin;
- return this;
+ }
- },
+ var tDir = t * dir;
- extractRotation: function () {
+ x0 = x0 * s + x1 * tDir;
+ y0 = y0 * s + y1 * tDir;
+ z0 = z0 * s + z1 * tDir;
+ w0 = w0 * s + w1 * tDir;
- var v1 = new Vector3();
+ // Normalize in case we just did a lerp:
+ if ( s === 1 - t ) {
- return function extractRotation( m ) {
+ var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
- // this method does not support reflection matrices
+ x0 *= f;
+ y0 *= f;
+ z0 *= f;
+ w0 *= f;
- var te = this.elements;
- var me = m.elements;
+ }
- var scaleX = 1 / v1.setFromMatrixColumn( m, 0 ).length();
- var scaleY = 1 / v1.setFromMatrixColumn( m, 1 ).length();
- var scaleZ = 1 / v1.setFromMatrixColumn( m, 2 ).length();
+ }
- te[ 0 ] = me[ 0 ] * scaleX;
- te[ 1 ] = me[ 1 ] * scaleX;
- te[ 2 ] = me[ 2 ] * scaleX;
- te[ 3 ] = 0;
+ dst[ dstOffset ] = x0;
+ dst[ dstOffset + 1 ] = y0;
+ dst[ dstOffset + 2 ] = z0;
+ dst[ dstOffset + 3 ] = w0;
- te[ 4 ] = me[ 4 ] * scaleY;
- te[ 5 ] = me[ 5 ] * scaleY;
- te[ 6 ] = me[ 6 ] * scaleY;
- te[ 7 ] = 0;
+ }
- te[ 8 ] = me[ 8 ] * scaleZ;
- te[ 9 ] = me[ 9 ] * scaleZ;
- te[ 10 ] = me[ 10 ] * scaleZ;
- te[ 11 ] = 0;
+ } );
- te[ 12 ] = 0;
- te[ 13 ] = 0;
- te[ 14 ] = 0;
- te[ 15 ] = 1;
+ Object.defineProperties( Quaternion.prototype, {
- return this;
+ x: {
- };
+ get: function () {
- }(),
+ return this._x;
- makeRotationFromEuler: function ( euler ) {
+ },
- if ( ! ( euler && euler.isEuler ) ) {
+ set: function ( value ) {
- console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );
+ this._x = value;
+ this.onChangeCallback();
}
- var te = this.elements;
-
- var x = euler.x, y = euler.y, z = euler.z;
- var a = Math.cos( x ), b = Math.sin( x );
- var c = Math.cos( y ), d = Math.sin( y );
- var e = Math.cos( z ), f = Math.sin( z );
-
- if ( euler.order === 'XYZ' ) {
-
- var ae = a * e, af = a * f, be = b * e, bf = b * f;
-
- te[ 0 ] = c * e;
- te[ 4 ] = - c * f;
- te[ 8 ] = d;
+ },
- te[ 1 ] = af + be * d;
- te[ 5 ] = ae - bf * d;
- te[ 9 ] = - b * c;
+ y: {
- te[ 2 ] = bf - ae * d;
- te[ 6 ] = be + af * d;
- te[ 10 ] = a * c;
+ get: function () {
- } else if ( euler.order === 'YXZ' ) {
+ return this._y;
- var ce = c * e, cf = c * f, de = d * e, df = d * f;
+ },
- te[ 0 ] = ce + df * b;
- te[ 4 ] = de * b - cf;
- te[ 8 ] = a * d;
+ set: function ( value ) {
- te[ 1 ] = a * f;
- te[ 5 ] = a * e;
- te[ 9 ] = - b;
+ this._y = value;
+ this.onChangeCallback();
- te[ 2 ] = cf * b - de;
- te[ 6 ] = df + ce * b;
- te[ 10 ] = a * c;
+ }
- } else if ( euler.order === 'ZXY' ) {
+ },
- var ce = c * e, cf = c * f, de = d * e, df = d * f;
+ z: {
- te[ 0 ] = ce - df * b;
- te[ 4 ] = - a * f;
- te[ 8 ] = de + cf * b;
+ get: function () {
- te[ 1 ] = cf + de * b;
- te[ 5 ] = a * e;
- te[ 9 ] = df - ce * b;
+ return this._z;
- te[ 2 ] = - a * d;
- te[ 6 ] = b;
- te[ 10 ] = a * c;
+ },
- } else if ( euler.order === 'ZYX' ) {
+ set: function ( value ) {
- var ae = a * e, af = a * f, be = b * e, bf = b * f;
+ this._z = value;
+ this.onChangeCallback();
- te[ 0 ] = c * e;
- te[ 4 ] = be * d - af;
- te[ 8 ] = ae * d + bf;
+ }
- te[ 1 ] = c * f;
- te[ 5 ] = bf * d + ae;
- te[ 9 ] = af * d - be;
+ },
- te[ 2 ] = - d;
- te[ 6 ] = b * c;
- te[ 10 ] = a * c;
+ w: {
- } else if ( euler.order === 'YZX' ) {
+ get: function () {
- var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+ return this._w;
- te[ 0 ] = c * e;
- te[ 4 ] = bd - ac * f;
- te[ 8 ] = bc * f + ad;
+ },
- te[ 1 ] = f;
- te[ 5 ] = a * e;
- te[ 9 ] = - b * e;
+ set: function ( value ) {
- te[ 2 ] = - d * e;
- te[ 6 ] = ad * f + bc;
- te[ 10 ] = ac - bd * f;
+ this._w = value;
+ this.onChangeCallback();
- } else if ( euler.order === 'XZY' ) {
+ }
- var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
+ }
- te[ 0 ] = c * e;
- te[ 4 ] = - f;
- te[ 8 ] = d * e;
+ } );
- te[ 1 ] = ac * f + bd;
- te[ 5 ] = a * e;
- te[ 9 ] = ad * f - bc;
+ Object.assign( Quaternion.prototype, {
- te[ 2 ] = bc * f - ad;
- te[ 6 ] = b * e;
- te[ 10 ] = bd * f + ac;
+ isQuaternion: true,
- }
+ set: function ( x, y, z, w ) {
- // bottom row
- te[ 3 ] = 0;
- te[ 7 ] = 0;
- te[ 11 ] = 0;
+ this._x = x;
+ this._y = y;
+ this._z = z;
+ this._w = w;
- // last column
- te[ 12 ] = 0;
- te[ 13 ] = 0;
- te[ 14 ] = 0;
- te[ 15 ] = 1;
+ this.onChangeCallback();
return this;
},
- makeRotationFromQuaternion: function () {
-
- var zero = new Vector3( 0, 0, 0 );
- var one = new Vector3( 1, 1, 1 );
-
- return function makeRotationFromQuaternion( q ) {
-
- return this.compose( zero, q, one );
-
- };
+ clone: function () {
- }(),
+ return new this.constructor( this._x, this._y, this._z, this._w );
- lookAt: function () {
+ },
- var x = new Vector3();
- var y = new Vector3();
- var z = new Vector3();
+ copy: function ( quaternion ) {
- return function lookAt( eye, target, up ) {
+ this._x = quaternion.x;
+ this._y = quaternion.y;
+ this._z = quaternion.z;
+ this._w = quaternion.w;
- var te = this.elements;
+ this.onChangeCallback();
- z.subVectors( eye, target );
+ return this;
- if ( z.lengthSq() === 0 ) {
+ },
- // eye and target are in the same position
+ setFromEuler: function ( euler, update ) {
- z.z = 1;
+ if ( ! ( euler && euler.isEuler ) ) {
- }
+ throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );
- z.normalize();
- x.crossVectors( up, z );
+ }
- if ( x.lengthSq() === 0 ) {
+ var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
- // up and z are parallel
+ // http://www.mathworks.com/matlabcentral/fileexchange/
+ // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
+ // content/SpinCalc.m
- if ( Math.abs( up.z ) === 1 ) {
+ var cos = Math.cos;
+ var sin = Math.sin;
- z.x += 0.0001;
+ var c1 = cos( x / 2 );
+ var c2 = cos( y / 2 );
+ var c3 = cos( z / 2 );
- } else {
+ var s1 = sin( x / 2 );
+ var s2 = sin( y / 2 );
+ var s3 = sin( z / 2 );
- z.z += 0.0001;
+ if ( order === 'XYZ' ) {
- }
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
- z.normalize();
- x.crossVectors( up, z );
+ } else if ( order === 'YXZ' ) {
- }
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
- x.normalize();
- y.crossVectors( z, x );
+ } else if ( order === 'ZXY' ) {
- te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;
- te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;
- te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
- return this;
+ } else if ( order === 'ZYX' ) {
- };
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
- }(),
+ } else if ( order === 'YZX' ) {
- multiply: function ( m, n ) {
+ this._x = s1 * c2 * c3 + c1 * s2 * s3;
+ this._y = c1 * s2 * c3 + s1 * c2 * s3;
+ this._z = c1 * c2 * s3 - s1 * s2 * c3;
+ this._w = c1 * c2 * c3 - s1 * s2 * s3;
- if ( n !== undefined ) {
+ } else if ( order === 'XZY' ) {
- console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );
- return this.multiplyMatrices( m, n );
+ this._x = s1 * c2 * c3 - c1 * s2 * s3;
+ this._y = c1 * s2 * c3 - s1 * c2 * s3;
+ this._z = c1 * c2 * s3 + s1 * s2 * c3;
+ this._w = c1 * c2 * c3 + s1 * s2 * s3;
}
- return this.multiplyMatrices( this, m );
-
- },
-
- premultiply: function ( m ) {
+ if ( update !== false ) this.onChangeCallback();
- return this.multiplyMatrices( m, this );
+ return this;
},
- multiplyMatrices: function ( a, b ) {
-
- var ae = a.elements;
- var be = b.elements;
- var te = this.elements;
-
- var a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];
- var a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];
- var a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];
- var a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];
-
- var b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];
- var b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];
- var b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];
- var b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];
-
- te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
- te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
- te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
- te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
-
- te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
- te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
- te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
- te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
-
- te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
- te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
- te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
- te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
-
- te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
- te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
- te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
- te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
+ setFromAxisAngle: function ( axis, angle ) {
- return this;
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
- },
+ // assumes axis is normalized
- multiplyScalar: function ( s ) {
+ var halfAngle = angle / 2, s = Math.sin( halfAngle );
- var te = this.elements;
+ this._x = axis.x * s;
+ this._y = axis.y * s;
+ this._z = axis.z * s;
+ this._w = Math.cos( halfAngle );
- te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;
- te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;
- te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;
- te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;
+ this.onChangeCallback();
return this;
},
- applyToBufferAttribute: function () {
-
- var v1 = new Vector3();
-
- return function applyToBufferAttribute( attribute ) {
-
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
-
- v1.x = attribute.getX( i );
- v1.y = attribute.getY( i );
- v1.z = attribute.getZ( i );
-
- v1.applyMatrix4( this );
-
- attribute.setXYZ( i, v1.x, v1.y, v1.z );
-
- }
+ setFromRotationMatrix: function ( m ) {
- return attribute;
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
- };
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
- }(),
+ var te = m.elements,
- determinant: function () {
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],
- var te = this.elements;
+ trace = m11 + m22 + m33,
+ s;
- var n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];
- var n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
- var n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
- var n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];
+ if ( trace > 0 ) {
- //TODO: make this more efficient
- //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
+ s = 0.5 / Math.sqrt( trace + 1.0 );
- return (
- n41 * (
- + n14 * n23 * n32
- - n13 * n24 * n32
- - n14 * n22 * n33
- + n12 * n24 * n33
- + n13 * n22 * n34
- - n12 * n23 * n34
- ) +
- n42 * (
- + n11 * n23 * n34
- - n11 * n24 * n33
- + n14 * n21 * n33
- - n13 * n21 * n34
- + n13 * n24 * n31
- - n14 * n23 * n31
- ) +
- n43 * (
- + n11 * n24 * n32
- - n11 * n22 * n34
- - n14 * n21 * n32
- + n12 * n21 * n34
- + n14 * n22 * n31
- - n12 * n24 * n31
- ) +
- n44 * (
- - n13 * n22 * n31
- - n11 * n23 * n32
- + n11 * n22 * n33
- + n13 * n21 * n32
- - n12 * n21 * n33
- + n12 * n23 * n31
- )
+ this._w = 0.25 / s;
+ this._x = ( m32 - m23 ) * s;
+ this._y = ( m13 - m31 ) * s;
+ this._z = ( m21 - m12 ) * s;
- );
+ } else if ( m11 > m22 && m11 > m33 ) {
- },
+ s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
- transpose: function () {
+ this._w = ( m32 - m23 ) / s;
+ this._x = 0.25 * s;
+ this._y = ( m12 + m21 ) / s;
+ this._z = ( m13 + m31 ) / s;
- var te = this.elements;
- var tmp;
+ } else if ( m22 > m33 ) {
- tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;
- tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;
- tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;
+ s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
- tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;
- tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;
- tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;
+ this._w = ( m13 - m31 ) / s;
+ this._x = ( m12 + m21 ) / s;
+ this._y = 0.25 * s;
+ this._z = ( m23 + m32 ) / s;
- return this;
+ } else {
- },
+ s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
- setPosition: function ( v ) {
+ this._w = ( m21 - m12 ) / s;
+ this._x = ( m13 + m31 ) / s;
+ this._y = ( m23 + m32 ) / s;
+ this._z = 0.25 * s;
- var te = this.elements;
+ }
- te[ 12 ] = v.x;
- te[ 13 ] = v.y;
- te[ 14 ] = v.z;
+ this.onChangeCallback();
return this;
},
- getInverse: function ( m, throwOnDegenerate ) {
+ setFromUnitVectors: function ( vFrom, vTo ) {
- // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
- var te = this.elements,
- me = m.elements,
-
- n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],
- n12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],
- n13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],
- n14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],
+ // assumes direction vectors vFrom and vTo are normalized
- t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
- t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
- t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
- t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
+ var EPS = 0.000001;
- var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
+ var r = vFrom.dot( vTo ) + 1;
- if ( det === 0 ) {
+ if ( r < EPS ) {
- var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
+ r = 0;
- if ( throwOnDegenerate === true ) {
+ if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
- throw new Error( msg );
+ this._x = - vFrom.y;
+ this._y = vFrom.x;
+ this._z = 0;
+ this._w = r;
} else {
- console.warn( msg );
+ this._x = 0;
+ this._y = - vFrom.z;
+ this._z = vFrom.y;
+ this._w = r;
}
- return this.identity();
-
- }
-
- var detInv = 1 / det;
-
- te[ 0 ] = t11 * detInv;
- te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;
- te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;
- te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;
-
- te[ 4 ] = t12 * detInv;
- te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;
- te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;
- te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;
-
- te[ 8 ] = t13 * detInv;
- te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;
- te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;
- te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;
-
- te[ 12 ] = t14 * detInv;
- te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;
- te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;
- te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;
-
- return this;
-
- },
-
- scale: function ( v ) {
-
- var te = this.elements;
- var x = v.x, y = v.y, z = v.z;
-
- te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;
- te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;
- te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;
- te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;
-
- return this;
-
- },
+ } else {
- getMaxScaleOnAxis: function () {
+ // crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3
- var te = this.elements;
+ this._x = vFrom.y * vTo.z - vFrom.z * vTo.y;
+ this._y = vFrom.z * vTo.x - vFrom.x * vTo.z;
+ this._z = vFrom.x * vTo.y - vFrom.y * vTo.x;
+ this._w = r;
- var scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];
- var scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];
- var scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];
+ }
- return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
+ return this.normalize();
},
- makeTranslation: function ( x, y, z ) {
-
- this.set(
-
- 1, 0, 0, x,
- 0, 1, 0, y,
- 0, 0, 1, z,
- 0, 0, 0, 1
-
- );
+ angleTo: function ( q ) {
- return this;
+ return 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) );
},
- makeRotationX: function ( theta ) {
+ rotateTowards: function ( q, step ) {
- var c = Math.cos( theta ), s = Math.sin( theta );
+ var angle = this.angleTo( q );
- this.set(
+ if ( angle === 0 ) return this;
- 1, 0, 0, 0,
- 0, c, - s, 0,
- 0, s, c, 0,
- 0, 0, 0, 1
+ var t = Math.min( 1, step / angle );
- );
+ this.slerp( q, t );
return this;
},
- makeRotationY: function ( theta ) {
-
- var c = Math.cos( theta ), s = Math.sin( theta );
-
- this.set(
-
- c, 0, s, 0,
- 0, 1, 0, 0,
- - s, 0, c, 0,
- 0, 0, 0, 1
-
- );
-
- return this;
+ inverse: function () {
- },
+ // quaternion is assumed to have unit length
- makeRotationZ: function ( theta ) {
+ return this.conjugate();
- var c = Math.cos( theta ), s = Math.sin( theta );
+ },
- this.set(
+ conjugate: function () {
- c, - s, 0, 0,
- s, c, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
+ this._x *= - 1;
+ this._y *= - 1;
+ this._z *= - 1;
- );
+ this.onChangeCallback();
return this;
},
- makeRotationAxis: function ( axis, angle ) {
+ dot: function ( v ) {
- // Based on http://www.gamedev.net/reference/articles/article1199.asp
+ return this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;
- var c = Math.cos( angle );
- var s = Math.sin( angle );
- var t = 1 - c;
- var x = axis.x, y = axis.y, z = axis.z;
- var tx = t * x, ty = t * y;
+ },
- this.set(
+ lengthSq: function () {
- tx * x + c, tx * y - s * z, tx * z + s * y, 0,
- tx * y + s * z, ty * y + c, ty * z - s * x, 0,
- tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
- 0, 0, 0, 1
+ return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
- );
+ },
- return this;
+ length: function () {
- },
+ return Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );
- makeScale: function ( x, y, z ) {
+ },
- this.set(
+ normalize: function () {
- x, 0, 0, 0,
- 0, y, 0, 0,
- 0, 0, z, 0,
- 0, 0, 0, 1
+ var l = this.length();
- );
+ if ( l === 0 ) {
- return this;
+ this._x = 0;
+ this._y = 0;
+ this._z = 0;
+ this._w = 1;
- },
+ } else {
- makeShear: function ( x, y, z ) {
+ l = 1 / l;
- this.set(
+ this._x = this._x * l;
+ this._y = this._y * l;
+ this._z = this._z * l;
+ this._w = this._w * l;
- 1, y, z, 0,
- x, 1, z, 0,
- x, y, 1, 0,
- 0, 0, 0, 1
+ }
- );
+ this.onChangeCallback();
return this;
},
- compose: function ( position, quaternion, scale ) {
-
- var te = this.elements;
+ multiply: function ( q, p ) {
- var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
- var x2 = x + x, y2 = y + y, z2 = z + z;
- var xx = x * x2, xy = x * y2, xz = x * z2;
- var yy = y * y2, yz = y * z2, zz = z * z2;
- var wx = w * x2, wy = w * y2, wz = w * z2;
+ if ( p !== undefined ) {
- var sx = scale.x, sy = scale.y, sz = scale.z;
+ console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );
+ return this.multiplyQuaternions( q, p );
- te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;
- te[ 1 ] = ( xy + wz ) * sx;
- te[ 2 ] = ( xz - wy ) * sx;
- te[ 3 ] = 0;
+ }
- te[ 4 ] = ( xy - wz ) * sy;
- te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;
- te[ 6 ] = ( yz + wx ) * sy;
- te[ 7 ] = 0;
+ return this.multiplyQuaternions( this, q );
- te[ 8 ] = ( xz + wy ) * sz;
- te[ 9 ] = ( yz - wx ) * sz;
- te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;
- te[ 11 ] = 0;
+ },
- te[ 12 ] = position.x;
- te[ 13 ] = position.y;
- te[ 14 ] = position.z;
- te[ 15 ] = 1;
+ premultiply: function ( q ) {
- return this;
+ return this.multiplyQuaternions( q, this );
},
- decompose: function () {
+ multiplyQuaternions: function ( a, b ) {
- var vector = new Vector3();
- var matrix = new Matrix4();
+ // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
- return function decompose( position, quaternion, scale ) {
+ 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 te = this.elements;
+ this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
+ this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
+ this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
+ this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
- var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
- var sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
- var sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
+ this.onChangeCallback();
- // if determine is negative, we need to invert one scale
- var det = this.determinant();
- if ( det < 0 ) sx = - sx;
+ return this;
- position.x = te[ 12 ];
- position.y = te[ 13 ];
- position.z = te[ 14 ];
+ },
- // scale the rotation part
- matrix.copy( this );
+ slerp: function ( qb, t ) {
- var invSX = 1 / sx;
- var invSY = 1 / sy;
- var invSZ = 1 / sz;
+ if ( t === 0 ) return this;
+ if ( t === 1 ) return this.copy( qb );
- matrix.elements[ 0 ] *= invSX;
- matrix.elements[ 1 ] *= invSX;
- matrix.elements[ 2 ] *= invSX;
+ var x = this._x, y = this._y, z = this._z, w = this._w;
- matrix.elements[ 4 ] *= invSY;
- matrix.elements[ 5 ] *= invSY;
- matrix.elements[ 6 ] *= invSY;
+ // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
- matrix.elements[ 8 ] *= invSZ;
- matrix.elements[ 9 ] *= invSZ;
- matrix.elements[ 10 ] *= invSZ;
+ var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
- quaternion.setFromRotationMatrix( matrix );
+ if ( cosHalfTheta < 0 ) {
- scale.x = sx;
- scale.y = sy;
- scale.z = sz;
+ this._w = - qb._w;
+ this._x = - qb._x;
+ this._y = - qb._y;
+ this._z = - qb._z;
- return this;
+ cosHalfTheta = - cosHalfTheta;
- };
+ } else {
- }(),
+ this.copy( qb );
- makePerspective: function ( left, right, top, bottom, near, far ) {
+ }
- if ( far === undefined ) {
+ if ( cosHalfTheta >= 1.0 ) {
- console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );
+ this._w = w;
+ this._x = x;
+ this._y = y;
+ this._z = z;
- }
+ return this;
- var te = this.elements;
- var x = 2 * near / ( right - left );
- var y = 2 * near / ( top - bottom );
+ }
- var a = ( right + left ) / ( right - left );
- var b = ( top + bottom ) / ( top - bottom );
- var c = - ( far + near ) / ( far - near );
- var d = - 2 * far * near / ( far - near );
+ var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
- te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0;
- te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0;
- te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
- te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0;
+ if ( sqrSinHalfTheta <= Number.EPSILON ) {
- return this;
+ var s = 1 - t;
+ this._w = s * w + t * this._w;
+ this._x = s * x + t * this._x;
+ this._y = s * y + t * this._y;
+ this._z = s * z + t * this._z;
- },
+ return this.normalize();
- makeOrthographic: function ( left, right, top, bottom, near, far ) {
+ }
- var te = this.elements;
- var w = 1.0 / ( right - left );
- var h = 1.0 / ( top - bottom );
- var p = 1.0 / ( far - near );
+ var sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
+ var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
+ var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
+ ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
- var x = ( right + left ) * w;
- var y = ( top + bottom ) * h;
- var z = ( far + near ) * p;
+ this._w = ( w * ratioA + this._w * ratioB );
+ this._x = ( x * ratioA + this._x * ratioB );
+ this._y = ( y * ratioA + this._y * ratioB );
+ this._z = ( z * ratioA + this._z * ratioB );
- te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
- te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
- te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z;
- te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
+ this.onChangeCallback();
return this;
},
- equals: function ( matrix ) {
-
- var te = this.elements;
- var me = matrix.elements;
-
- for ( var i = 0; i < 16; i ++ ) {
-
- if ( te[ i ] !== me[ i ] ) return false;
-
- }
+ equals: function ( quaternion ) {
- return true;
+ return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
},
@@ -1869,11 +1570,12 @@
if ( offset === undefined ) offset = 0;
- for ( var i = 0; i < 16; i ++ ) {
-
- this.elements[ i ] = array[ i + offset ];
+ this._x = array[ offset ];
+ this._y = array[ offset + 1 ];
+ this._z = array[ offset + 2 ];
+ this._w = array[ offset + 3 ];
- }
+ this.onChangeCallback();
return this;
@@ -1884,464 +1586,482 @@
if ( array === undefined ) array = [];
if ( offset === undefined ) offset = 0;
- var te = this.elements;
+ array[ offset ] = this._x;
+ array[ offset + 1 ] = this._y;
+ array[ offset + 2 ] = this._z;
+ array[ offset + 3 ] = this._w;
- array[ offset ] = te[ 0 ];
- array[ offset + 1 ] = te[ 1 ];
- array[ offset + 2 ] = te[ 2 ];
- array[ offset + 3 ] = te[ 3 ];
+ return array;
- array[ offset + 4 ] = te[ 4 ];
- array[ offset + 5 ] = te[ 5 ];
- array[ offset + 6 ] = te[ 6 ];
- array[ offset + 7 ] = te[ 7 ];
+ },
- array[ offset + 8 ] = te[ 8 ];
- array[ offset + 9 ] = te[ 9 ];
- array[ offset + 10 ] = te[ 10 ];
- array[ offset + 11 ] = te[ 11 ];
+ onChange: function ( callback ) {
- array[ offset + 12 ] = te[ 12 ];
- array[ offset + 13 ] = te[ 13 ];
- array[ offset + 14 ] = te[ 14 ];
- array[ offset + 15 ] = te[ 15 ];
+ this.onChangeCallback = callback;
- return array;
+ return this;
- }
+ },
+
+ onChangeCallback: function () {}
} );
/**
+ * @author mrdoob / http://mrdoob.com/
+ * @author kile / http://kile.stravaganza.org/
+ * @author philogb / http://blog.thejit.org/
* @author mikael emtinger / http://gomo.se/
- * @author alteredq / http://alteredqualia.com/
+ * @author egraether / http://egraether.com/
* @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://clara.io
*/
- function Quaternion( x, y, z, w ) {
+ function Vector3( x, y, z ) {
- this._x = x || 0;
- this._y = y || 0;
- this._z = z || 0;
- this._w = ( w !== undefined ) ? w : 1;
+ this.x = x || 0;
+ this.y = y || 0;
+ this.z = z || 0;
}
- Object.assign( Quaternion, {
+ Object.assign( Vector3.prototype, {
- slerp: function ( qa, qb, qm, t ) {
+ isVector3: true,
- return qm.copy( qa ).slerp( qb, t );
+ set: function ( x, y, z ) {
- },
+ this.x = x;
+ this.y = y;
+ this.z = z;
- slerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {
+ return this;
- // fuzz-free, array-based Quaternion SLERP operation
+ },
- var x0 = src0[ srcOffset0 + 0 ],
- y0 = src0[ srcOffset0 + 1 ],
- z0 = src0[ srcOffset0 + 2 ],
- w0 = src0[ srcOffset0 + 3 ],
+ setScalar: function ( scalar ) {
- x1 = src1[ srcOffset1 + 0 ],
- y1 = src1[ srcOffset1 + 1 ],
- z1 = src1[ srcOffset1 + 2 ],
- w1 = src1[ srcOffset1 + 3 ];
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
- if ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {
+ return this;
- var s = 1 - t,
+ },
- cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,
+ setX: function ( x ) {
- dir = ( cos >= 0 ? 1 : - 1 ),
- sqrSin = 1 - cos * cos;
+ this.x = x;
- // Skip the Slerp for tiny steps to avoid numeric problems:
- if ( sqrSin > Number.EPSILON ) {
+ return this;
- var sin = Math.sqrt( sqrSin ),
- len = Math.atan2( sin, cos * dir );
+ },
- s = Math.sin( s * len ) / sin;
- t = Math.sin( t * len ) / sin;
+ setY: function ( y ) {
- }
+ this.y = y;
- var tDir = t * dir;
+ return this;
- x0 = x0 * s + x1 * tDir;
- y0 = y0 * s + y1 * tDir;
- z0 = z0 * s + z1 * tDir;
- w0 = w0 * s + w1 * tDir;
+ },
- // Normalize in case we just did a lerp:
- if ( s === 1 - t ) {
+ setZ: function ( z ) {
- var f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );
+ this.z = z;
- x0 *= f;
- y0 *= f;
- z0 *= f;
- w0 *= f;
+ return this;
- }
+ },
- }
+ setComponent: function ( index, value ) {
- dst[ dstOffset ] = x0;
- dst[ dstOffset + 1 ] = y0;
- dst[ dstOffset + 2 ] = z0;
- dst[ dstOffset + 3 ] = w0;
+ switch ( index ) {
- }
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
- } );
+ }
- Object.defineProperties( Quaternion.prototype, {
+ return this;
- x: {
+ },
- get: function () {
+ getComponent: function ( index ) {
- return this._x;
+ switch ( index ) {
- },
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ default: throw new Error( 'index is out of range: ' + index );
- set: function ( value ) {
+ }
- this._x = value;
- this.onChangeCallback();
+ },
- }
+ clone: function () {
+
+ return new this.constructor( this.x, this.y, this.z );
},
- y: {
+ copy: function ( v ) {
- get: function () {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
- return this._y;
+ return this;
- },
+ },
- set: function ( value ) {
+ add: function ( v, w ) {
- this._y = value;
- this.onChangeCallback();
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
}
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+
+ return this;
+
},
- z: {
+ addScalar: function ( s ) {
- get: function () {
+ this.x += s;
+ this.y += s;
+ this.z += s;
- return this._z;
+ return this;
- },
+ },
- set: function ( value ) {
+ addVectors: function ( a, b ) {
- this._z = value;
- this.onChangeCallback();
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
- }
+ return this;
},
- w: {
+ addScaledVector: function ( v, s ) {
- get: function () {
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
- return this._w;
+ return this;
- },
+ },
- set: function ( value ) {
+ sub: function ( v, w ) {
- this._w = value;
- this.onChangeCallback();
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
}
- }
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
- } );
+ return this;
- Object.assign( Quaternion.prototype, {
+ },
- isQuaternion: true,
+ subScalar: function ( s ) {
- set: function ( x, y, z, w ) {
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
- this._x = x;
- this._y = y;
- this._z = z;
- this._w = w;
+ return this;
- this.onChangeCallback();
+ },
+
+ subVectors: function ( a, b ) {
+
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
return this;
},
- clone: function () {
+ multiply: function ( v, w ) {
- return new this.constructor( this._x, this._y, this._z, this._w );
+ if ( w !== undefined ) {
+
+ console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );
+ return this.multiplyVectors( v, w );
+
+ }
+
+ this.x *= v.x;
+ this.y *= v.y;
+ this.z *= v.z;
+
+ return this;
},
- copy: function ( quaternion ) {
+ multiplyScalar: function ( scalar ) {
- this._x = quaternion.x;
- this._y = quaternion.y;
- this._z = quaternion.z;
- this._w = quaternion.w;
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
- this.onChangeCallback();
+ return this;
+
+ },
+
+ multiplyVectors: function ( a, b ) {
+
+ this.x = a.x * b.x;
+ this.y = a.y * b.y;
+ this.z = a.z * b.z;
return this;
},
- setFromEuler: function ( euler, update ) {
+ applyEuler: function () {
- if ( ! ( euler && euler.isEuler ) ) {
+ var quaternion = new Quaternion();
- throw new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+ return function applyEuler( euler ) {
- }
+ if ( ! ( euler && euler.isEuler ) ) {
- var x = euler._x, y = euler._y, z = euler._z, order = euler.order;
+ console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
- // http://www.mathworks.com/matlabcentral/fileexchange/
- // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
- // content/SpinCalc.m
+ }
- var cos = Math.cos;
- var sin = Math.sin;
+ return this.applyQuaternion( quaternion.setFromEuler( euler ) );
- var c1 = cos( x / 2 );
- var c2 = cos( y / 2 );
- var c3 = cos( z / 2 );
+ };
- var s1 = sin( x / 2 );
- var s2 = sin( y / 2 );
- var s3 = sin( z / 2 );
+ }(),
- if ( order === 'XYZ' ) {
+ applyAxisAngle: function () {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ var quaternion = new Quaternion();
- } else if ( order === 'YXZ' ) {
+ return function applyAxisAngle( axis, angle ) {
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
- } else if ( order === 'ZXY' ) {
+ };
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ }(),
- } else if ( order === 'ZYX' ) {
+ applyMatrix3: function ( m ) {
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ var x = this.x, y = this.y, z = this.z;
+ var e = m.elements;
- } else if ( order === 'YZX' ) {
+ this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
+ this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
+ this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
- this._x = s1 * c2 * c3 + c1 * s2 * s3;
- this._y = c1 * s2 * c3 + s1 * c2 * s3;
- this._z = c1 * c2 * s3 - s1 * s2 * c3;
- this._w = c1 * c2 * c3 - s1 * s2 * s3;
+ return this;
- } else if ( order === 'XZY' ) {
+ },
- this._x = s1 * c2 * c3 - c1 * s2 * s3;
- this._y = c1 * s2 * c3 - s1 * c2 * s3;
- this._z = c1 * c2 * s3 + s1 * s2 * c3;
- this._w = c1 * c2 * c3 + s1 * s2 * s3;
+ applyMatrix4: function ( m ) {
- }
+ var x = this.x, y = this.y, z = this.z;
+ var e = m.elements;
- if ( update !== false ) this.onChangeCallback();
+ var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
+
+ this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
+ this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
+ this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
return this;
},
- setFromAxisAngle: function ( axis, angle ) {
+ applyQuaternion: function ( q ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
+ var x = this.x, y = this.y, z = this.z;
+ var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
- // assumes axis is normalized
+ // calculate quat * vector
- var halfAngle = angle / 2, s = Math.sin( halfAngle );
+ var ix = qw * x + qy * z - qz * y;
+ var iy = qw * y + qz * x - qx * z;
+ var iz = qw * z + qx * y - qy * x;
+ var iw = - qx * x - qy * y - qz * z;
- this._x = axis.x * s;
- this._y = axis.y * s;
- this._z = axis.z * s;
- this._w = Math.cos( halfAngle );
+ // calculate result * inverse quat
- this.onChangeCallback();
+ this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
+ this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
+ this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
return this;
},
- setFromRotationMatrix: function ( m ) {
+ project: function ( camera ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
+ return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+ },
- var te = m.elements,
+ unproject: function ( camera ) {
- m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
- m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
- m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],
+ return this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );
- trace = m11 + m22 + m33,
- s;
+ },
- if ( trace > 0 ) {
+ transformDirection: function ( m ) {
- s = 0.5 / Math.sqrt( trace + 1.0 );
+ // input: THREE.Matrix4 affine matrix
+ // vector interpreted as a direction
- this._w = 0.25 / s;
- this._x = ( m32 - m23 ) * s;
- this._y = ( m13 - m31 ) * s;
- this._z = ( m21 - m12 ) * s;
+ var x = this.x, y = this.y, z = this.z;
+ var e = m.elements;
- } else if ( m11 > m22 && m11 > m33 ) {
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;
- s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );
+ return this.normalize();
- this._w = ( m32 - m23 ) / s;
- this._x = 0.25 * s;
- this._y = ( m12 + m21 ) / s;
- this._z = ( m13 + m31 ) / s;
+ },
- } else if ( m22 > m33 ) {
+ divide: function ( v ) {
- s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );
+ this.x /= v.x;
+ this.y /= v.y;
+ this.z /= v.z;
- this._w = ( m13 - m31 ) / s;
- this._x = ( m12 + m21 ) / s;
- this._y = 0.25 * s;
- this._z = ( m23 + m32 ) / s;
+ return this;
- } else {
+ },
- s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );
+ divideScalar: function ( scalar ) {
- this._w = ( m21 - m12 ) / s;
- this._x = ( m13 + m31 ) / s;
- this._y = ( m23 + m32 ) / s;
- this._z = 0.25 * s;
+ return this.multiplyScalar( 1 / scalar );
- }
+ },
- this.onChangeCallback();
+ min: function ( v ) {
+
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
return this;
},
- setFromUnitVectors: function () {
+ max: function ( v ) {
- // assumes direction vectors vFrom and vTo are normalized
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
- var v1 = new Vector3();
- var r;
+ return this;
- var EPS = 0.000001;
+ },
- return function setFromUnitVectors( vFrom, vTo ) {
+ clamp: function ( min, max ) {
- if ( v1 === undefined ) v1 = new Vector3();
+ // assumes min < max, componentwise
- r = vFrom.dot( vTo ) + 1;
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.z = Math.max( min.z, Math.min( max.z, this.z ) );
- if ( r < EPS ) {
+ return this;
- r = 0;
+ },
- if ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {
+ clampScalar: function () {
- v1.set( - vFrom.y, vFrom.x, 0 );
+ var min = new Vector3();
+ var max = new Vector3();
- } else {
+ return function clampScalar( minVal, maxVal ) {
- v1.set( 0, - vFrom.z, vFrom.y );
+ min.set( minVal, minVal, minVal );
+ max.set( maxVal, maxVal, maxVal );
- }
+ return this.clamp( min, max );
- } else {
+ };
- v1.crossVectors( vFrom, vTo );
+ }(),
- }
+ clampLength: function ( min, max ) {
- this._x = v1.x;
- this._y = v1.y;
- this._z = v1.z;
- this._w = r;
+ var length = this.length();
- return this.normalize();
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
- };
+ },
- }(),
+ floor: function () {
- angleTo: function ( q ) {
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
- return 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) );
+ return this;
},
- rotateTowards: function ( q, step ) {
+ ceil: function () {
- var angle = this.angleTo( q );
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
- if ( angle === 0 ) return this;
+ return this;
- var t = Math.min( 1, step / angle );
+ },
- this.slerp( q, t );
+ round: function () {
+
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
return this;
},
- inverse: function () {
+ roundToZero: function () {
- // quaternion is assumed to have unit length
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
- return this.conjugate();
+ return this;
},
- conjugate: function () {
-
- this._x *= - 1;
- this._y *= - 1;
- this._z *= - 1;
+ negate: function () {
- this.onChangeCallback();
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
return this;
@@ -2349,1769 +2069,1904 @@
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;
},
+ // TODO lengthSquared?
+
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;
},
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 );
},
- normalize: function () {
+ manhattanLength: function () {
- var l = this.length();
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
- if ( l === 0 ) {
+ },
- this._x = 0;
- this._y = 0;
- this._z = 0;
- this._w = 1;
+ normalize: function () {
- } else {
+ return this.divideScalar( this.length() || 1 );
- l = 1 / l;
+ },
- this._x = this._x * l;
- this._y = this._y * l;
- this._z = this._z * l;
- this._w = this._w * l;
+ setLength: function ( length ) {
- }
+ return this.normalize().multiplyScalar( length );
- this.onChangeCallback();
+ },
+
+ lerp: function ( v, alpha ) {
+
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
return this;
},
- multiply: function ( q, p ) {
+ lerpVectors: function ( v1, v2, alpha ) {
- if ( p !== undefined ) {
+ return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
- console.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );
- return this.multiplyQuaternions( q, p );
+ },
- }
+ cross: function ( v, w ) {
- return this.multiplyQuaternions( this, q );
+ if ( w !== undefined ) {
- },
+ console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );
+ return this.crossVectors( v, w );
- premultiply: function ( q ) {
+ }
- return this.multiplyQuaternions( q, this );
+ return this.crossVectors( this, v );
},
- multiplyQuaternions: function ( a, b ) {
+ crossVectors: function ( a, b ) {
- // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
+ var ax = a.x, ay = a.y, az = a.z;
+ var bx = b.x, by = b.y, bz = b.z;
- 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;
+ this.x = ay * bz - az * by;
+ this.y = az * bx - ax * bz;
+ this.z = ax * by - ay * bx;
- this._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
- this._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
- this._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
- this._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
+ return this;
- this.onChangeCallback();
+ },
- return this;
+ projectOnVector: function ( vector ) {
+
+ var scalar = vector.dot( this ) / vector.lengthSq();
+
+ return this.copy( vector ).multiplyScalar( scalar );
},
- slerp: function ( qb, t ) {
+ projectOnPlane: function () {
- if ( t === 0 ) return this;
- if ( t === 1 ) return this.copy( qb );
+ var v1 = new Vector3();
- var x = this._x, y = this._y, z = this._z, w = this._w;
+ return function projectOnPlane( planeNormal ) {
- // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
+ v1.copy( this ).projectOnVector( planeNormal );
- var cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;
+ return this.sub( v1 );
- if ( cosHalfTheta < 0 ) {
+ };
- this._w = - qb._w;
- this._x = - qb._x;
- this._y = - qb._y;
- this._z = - qb._z;
+ }(),
- cosHalfTheta = - cosHalfTheta;
+ reflect: function () {
- } else {
+ // reflect incident vector off plane orthogonal to normal
+ // normal is assumed to have unit length
- this.copy( qb );
+ var v1 = new Vector3();
- }
+ return function reflect( normal ) {
- if ( cosHalfTheta >= 1.0 ) {
+ return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
- this._w = w;
- this._x = x;
- this._y = y;
- this._z = z;
+ };
- return this;
+ }(),
- }
+ angleTo: function ( v ) {
- var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
+ var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
- if ( sqrSinHalfTheta <= Number.EPSILON ) {
+ // clamp, to handle numerical problems
- var s = 1 - t;
- this._w = s * w + t * this._w;
- this._x = s * x + t * this._x;
- this._y = s * y + t * this._y;
- this._z = s * z + t * this._z;
+ return Math.acos( _Math.clamp( theta, - 1, 1 ) );
- return this.normalize();
+ },
- }
+ distanceTo: function ( v ) {
- var sinHalfTheta = Math.sqrt( sqrSinHalfTheta );
- var halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );
- var ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,
- ratioB = Math.sin( t * halfTheta ) / sinHalfTheta;
+ return Math.sqrt( this.distanceToSquared( v ) );
- this._w = ( w * ratioA + this._w * ratioB );
- this._x = ( x * ratioA + this._x * ratioB );
- this._y = ( y * ratioA + this._y * ratioB );
- this._z = ( z * ratioA + this._z * ratioB );
+ },
- this.onChangeCallback();
+ distanceToSquared: function ( v ) {
- return this;
+ var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+
+ return dx * dx + dy * dy + dz * dz;
},
- equals: function ( quaternion ) {
+ manhattanDistanceTo: function ( v ) {
- return ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );
+ return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
},
- fromArray: function ( array, offset ) {
+ setFromSpherical: function ( s ) {
- if ( offset === undefined ) offset = 0;
+ return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
- this._x = array[ offset ];
- this._y = array[ offset + 1 ];
- this._z = array[ offset + 2 ];
- this._w = array[ offset + 3 ];
+ },
- this.onChangeCallback();
+ setFromSphericalCoords: function ( radius, phi, theta ) {
+
+ var sinPhiRadius = Math.sin( phi ) * radius;
+
+ this.x = sinPhiRadius * Math.sin( theta );
+ this.y = Math.cos( phi ) * radius;
+ this.z = sinPhiRadius * Math.cos( theta );
return this;
},
- toArray: function ( array, offset ) {
+ setFromCylindrical: function ( c ) {
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
- array[ offset ] = this._x;
- array[ offset + 1 ] = this._y;
- array[ offset + 2 ] = this._z;
- array[ offset + 3 ] = this._w;
+ },
- return array;
+ setFromCylindricalCoords: function ( radius, theta, y ) {
+
+ this.x = radius * Math.sin( theta );
+ this.y = y;
+ this.z = radius * Math.cos( theta );
+
+ return this;
},
- onChange: function ( callback ) {
+ setFromMatrixPosition: function ( m ) {
- this.onChangeCallback = callback;
+ var e = m.elements;
+
+ this.x = e[ 12 ];
+ this.y = e[ 13 ];
+ this.z = e[ 14 ];
return this;
},
- onChangeCallback: function () {}
+ setFromMatrixScale: function ( m ) {
- } );
+ var sx = this.setFromMatrixColumn( m, 0 ).length();
+ var sy = this.setFromMatrixColumn( m, 1 ).length();
+ var sz = this.setFromMatrixColumn( m, 2 ).length();
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author kile / http://kile.stravaganza.org/
- * @author philogb / http://blog.thejit.org/
- * @author mikael emtinger / http://gomo.se/
- * @author egraether / http://egraether.com/
- * @author WestLangley / http://github.com/WestLangley
- */
+ this.x = sx;
+ this.y = sy;
+ this.z = sz;
- function Vector3( x, y, z ) {
+ return this;
- this.x = x || 0;
- this.y = y || 0;
- this.z = z || 0;
+ },
- }
+ setFromMatrixColumn: function ( m, index ) {
- Object.assign( Vector3.prototype, {
+ return this.fromArray( m.elements, index * 4 );
- isVector3: true,
+ },
- set: function ( x, y, z ) {
+ equals: function ( v ) {
- this.x = x;
- this.y = y;
- this.z = z;
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
+
+ },
+
+ fromArray: function ( array, offset ) {
+
+ if ( offset === undefined ) offset = 0;
+
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
return this;
},
- setScalar: function ( scalar ) {
+ toArray: function ( array, offset ) {
- this.x = scalar;
- this.y = scalar;
- this.z = scalar;
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- return this;
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
+
+ return array;
},
- setX: function ( x ) {
+ fromBufferAttribute: function ( attribute, index, offset ) {
- this.x = x;
+ if ( offset !== undefined ) {
+
+ console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );
+
+ }
+
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
+
+ return this;
+
+ }
+
+ } );
- return this;
+ /**
+ * @author alteredq / http://alteredqualia.com/
+ * @author WestLangley / http://github.com/WestLangley
+ * @author bhouston / http://clara.io
+ * @author tschw
+ */
- },
+ function Matrix3() {
- setY: function ( y ) {
+ this.elements = [
- this.y = y;
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
- return this;
+ ];
- },
+ if ( arguments.length > 0 ) {
- setZ: function ( z ) {
+ console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
- this.z = z;
+ }
- return this;
+ }
- },
+ Object.assign( Matrix3.prototype, {
- setComponent: function ( index, value ) {
+ isMatrix3: true,
- switch ( index ) {
+ set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
- case 0: this.x = value; break;
- case 1: this.y = value; break;
- case 2: this.z = value; break;
- default: throw new Error( 'index is out of range: ' + index );
+ var te = this.elements;
- }
+ te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;
+ te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;
+ te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;
return this;
},
- getComponent: function ( index ) {
+ identity: function () {
- switch ( index ) {
+ this.set(
- case 0: return this.x;
- case 1: return this.y;
- case 2: return this.z;
- default: throw new Error( 'index is out of range: ' + index );
+ 1, 0, 0,
+ 0, 1, 0,
+ 0, 0, 1
- }
+ );
+
+ return this;
},
clone: function () {
- return new this.constructor( this.x, this.y, this.z );
+ return new this.constructor().fromArray( this.elements );
},
- copy: function ( v ) {
+ copy: function ( m ) {
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
+ var te = this.elements;
+ var me = m.elements;
+
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
+ te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
+ te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
return this;
},
- add: function ( v, w ) {
+ setFromMatrix4: function ( m ) {
- if ( w !== undefined ) {
+ var me = m.elements;
- console.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
- return this.addVectors( v, w );
+ this.set(
- }
+ me[ 0 ], me[ 4 ], me[ 8 ],
+ me[ 1 ], me[ 5 ], me[ 9 ],
+ me[ 2 ], me[ 6 ], me[ 10 ]
- this.x += v.x;
- this.y += v.y;
- this.z += v.z;
+ );
return this;
},
- addScalar: function ( s ) {
-
- this.x += s;
- this.y += s;
- this.z += s;
-
- return this;
+ applyToBufferAttribute: function () {
- },
+ var v1 = new Vector3();
- addVectors: function ( a, b ) {
+ return function applyToBufferAttribute( attribute ) {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
- this.z = a.z + b.z;
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- return this;
+ v1.x = attribute.getX( i );
+ v1.y = attribute.getY( i );
+ v1.z = attribute.getZ( i );
- },
+ v1.applyMatrix3( this );
- addScaledVector: function ( v, s ) {
+ attribute.setXYZ( i, v1.x, v1.y, v1.z );
- this.x += v.x * s;
- this.y += v.y * s;
- this.z += v.z * s;
+ }
- return this;
+ return attribute;
- },
+ };
- sub: function ( v, w ) {
+ }(),
- if ( w !== undefined ) {
+ multiply: function ( m ) {
- console.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
- return this.subVectors( v, w );
+ return this.multiplyMatrices( this, m );
- }
+ },
- this.x -= v.x;
- this.y -= v.y;
- this.z -= v.z;
+ premultiply: function ( m ) {
- return this;
+ return this.multiplyMatrices( m, this );
},
- subScalar: function ( s ) {
+ multiplyMatrices: function ( a, b ) {
- this.x -= s;
- this.y -= s;
- this.z -= s;
+ var ae = a.elements;
+ var be = b.elements;
+ var te = this.elements;
- return this;
+ var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];
+ var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];
+ var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];
- },
+ var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];
+ var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];
+ var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];
- subVectors: function ( a, b ) {
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;
+ te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;
+ te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;
- this.x = a.x - b.x;
- this.y = a.y - b.y;
- this.z = a.z - b.z;
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;
+ te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;
+ te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;
+
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;
+ te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;
+ te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;
return this;
},
- multiply: function ( v, w ) {
-
- if ( w !== undefined ) {
-
- console.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );
- return this.multiplyVectors( v, w );
+ multiplyScalar: function ( s ) {
- }
+ var te = this.elements;
- this.x *= v.x;
- this.y *= v.y;
- this.z *= v.z;
+ te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;
+ te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;
+ te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;
return this;
},
- multiplyScalar: function ( scalar ) {
+ determinant: function () {
- this.x *= scalar;
- this.y *= scalar;
- this.z *= scalar;
+ var te = this.elements;
- return this;
+ var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],
+ d = te[ 3 ], e = te[ 4 ], f = te[ 5 ],
+ g = te[ 6 ], h = te[ 7 ], i = te[ 8 ];
- },
+ return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
- multiplyVectors: function ( a, b ) {
+ },
- this.x = a.x * b.x;
- this.y = a.y * b.y;
- this.z = a.z * b.z;
+ getInverse: function ( matrix, throwOnDegenerate ) {
- return this;
+ if ( matrix && matrix.isMatrix4 ) {
- },
+ console.error( "THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument." );
- applyEuler: function () {
+ }
- var quaternion = new Quaternion();
+ var me = matrix.elements,
+ te = this.elements,
- return function applyEuler( euler ) {
+ n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],
+ n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],
+ n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],
- if ( ! ( euler && euler.isEuler ) ) {
+ t11 = n33 * n22 - n32 * n23,
+ t12 = n32 * n13 - n33 * n12,
+ t13 = n23 * n12 - n22 * n13,
- console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );
+ det = n11 * t11 + n21 * t12 + n31 * t13;
- }
+ if ( det === 0 ) {
- return this.applyQuaternion( quaternion.setFromEuler( euler ) );
+ var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
- };
+ if ( throwOnDegenerate === true ) {
- }(),
+ throw new Error( msg );
- applyAxisAngle: function () {
+ } else {
- var quaternion = new Quaternion();
+ console.warn( msg );
- return function applyAxisAngle( axis, angle ) {
+ }
- return this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );
+ return this.identity();
- };
+ }
- }(),
+ var detInv = 1 / det;
- applyMatrix3: function ( m ) {
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;
+ te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
+ te[ 3 ] = t12 * detInv;
+ te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;
+ te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;
- this.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;
- this.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;
- this.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;
+ te[ 6 ] = t13 * detInv;
+ te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;
+ te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;
return this;
},
- applyMatrix4: function ( m ) {
-
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
+ transpose: function () {
- var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
+ var tmp, m = this.elements;
- this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
- this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
- this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
+ tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;
+ tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;
+ tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;
return this;
},
- applyQuaternion: function ( q ) {
+ getNormalMatrix: function ( matrix4 ) {
- var x = this.x, y = this.y, z = this.z;
- var qx = q.x, qy = q.y, qz = q.z, qw = q.w;
+ return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();
- // calculate quat * vector
+ },
- var ix = qw * x + qy * z - qz * y;
- var iy = qw * y + qz * x - qx * z;
- var iz = qw * z + qx * y - qy * x;
- var iw = - qx * x - qy * y - qz * z;
+ transposeIntoArray: function ( r ) {
- // calculate result * inverse quat
+ var m = this.elements;
- this.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;
- this.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;
- this.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;
+ r[ 0 ] = m[ 0 ];
+ r[ 1 ] = m[ 3 ];
+ r[ 2 ] = m[ 6 ];
+ r[ 3 ] = m[ 1 ];
+ r[ 4 ] = m[ 4 ];
+ r[ 5 ] = m[ 7 ];
+ r[ 6 ] = m[ 2 ];
+ r[ 7 ] = m[ 5 ];
+ r[ 8 ] = m[ 8 ];
return this;
},
- project: function ( camera ) {
+ setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {
- return this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );
+ var c = Math.cos( rotation );
+ var s = Math.sin( rotation );
+
+ this.set(
+ sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,
+ - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,
+ 0, 0, 1
+ );
},
- unproject: function () {
+ scale: function ( sx, sy ) {
- var matrix = new Matrix4();
+ var te = this.elements;
- return function unproject( camera ) {
+ te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;
+ te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;
- return this.applyMatrix4( matrix.getInverse( camera.projectionMatrix ) ).applyMatrix4( camera.matrixWorld );
+ return this;
- };
+ },
- }(),
+ rotate: function ( theta ) {
- transformDirection: function ( m ) {
+ var c = Math.cos( theta );
+ var s = Math.sin( theta );
- // input: THREE.Matrix4 affine matrix
- // vector interpreted as a direction
+ var te = this.elements;
- var x = this.x, y = this.y, z = this.z;
- var e = m.elements;
+ var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];
+ var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];
- this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;
- this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;
- this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;
+ te[ 0 ] = c * a11 + s * a21;
+ te[ 3 ] = c * a12 + s * a22;
+ te[ 6 ] = c * a13 + s * a23;
- return this.normalize();
+ te[ 1 ] = - s * a11 + c * a21;
+ te[ 4 ] = - s * a12 + c * a22;
+ te[ 7 ] = - s * a13 + c * a23;
+
+ return this;
},
- divide: function ( v ) {
+ translate: function ( tx, ty ) {
- this.x /= v.x;
- this.y /= v.y;
- this.z /= v.z;
+ var te = this.elements;
+
+ te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];
+ te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];
return this;
},
- divideScalar: function ( scalar ) {
+ equals: function ( matrix ) {
- return this.multiplyScalar( 1 / scalar );
+ var te = this.elements;
+ var me = matrix.elements;
- },
+ for ( var i = 0; i < 9; i ++ ) {
- min: function ( v ) {
+ if ( te[ i ] !== me[ i ] ) return false;
- this.x = Math.min( this.x, v.x );
- this.y = Math.min( this.y, v.y );
- this.z = Math.min( this.z, v.z );
+ }
- return this;
+ return true;
},
- max: function ( v ) {
+ fromArray: function ( array, offset ) {
- this.x = Math.max( this.x, v.x );
- this.y = Math.max( this.y, v.y );
- this.z = Math.max( this.z, v.z );
+ if ( offset === undefined ) offset = 0;
+
+ for ( var i = 0; i < 9; i ++ ) {
+
+ this.elements[ i ] = array[ i + offset ];
+
+ }
return this;
},
- clamp: function ( min, max ) {
+ toArray: function ( array, offset ) {
- // assumes min < max, componentwise
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
- this.z = Math.max( min.z, Math.min( max.z, this.z ) );
+ var te = this.elements;
- return this;
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
- },
+ array[ offset + 3 ] = te[ 3 ];
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
- clampScalar: function () {
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
+ array[ offset + 8 ] = te[ 8 ];
- var min = new Vector3();
- var max = new Vector3();
+ return array;
- return function clampScalar( minVal, maxVal ) {
+ }
- min.set( minVal, minVal, minVal );
- max.set( maxVal, maxVal, maxVal );
+ } );
- return this.clamp( min, max );
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author szimek / https://github.com/szimek/
+ */
- };
+ var _canvas;
- }(),
+ var ImageUtils = {
- clampLength: function ( min, max ) {
+ getDataURL: function ( image ) {
- var length = this.length();
+ var canvas;
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+ if ( typeof HTMLCanvasElement == 'undefined' ) {
- },
+ return image.src;
- floor: function () {
+ } else if ( image instanceof HTMLCanvasElement ) {
- this.x = Math.floor( this.x );
- this.y = Math.floor( this.y );
- this.z = Math.floor( this.z );
+ canvas = image;
- return this;
+ } else {
- },
+ if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
- ceil: function () {
+ _canvas.width = image.width;
+ _canvas.height = image.height;
- this.x = Math.ceil( this.x );
- this.y = Math.ceil( this.y );
- this.z = Math.ceil( this.z );
+ var context = _canvas.getContext( '2d' );
- return this;
+ if ( image instanceof ImageData ) {
- },
+ context.putImageData( image, 0, 0 );
- round: function () {
+ } else {
- this.x = Math.round( this.x );
- this.y = Math.round( this.y );
- this.z = Math.round( this.z );
+ context.drawImage( image, 0, 0, image.width, image.height );
- return this;
+ }
- },
+ canvas = _canvas;
- roundToZero: function () {
+ }
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+ if ( canvas.width > 2048 || canvas.height > 2048 ) {
- return this;
+ return canvas.toDataURL( 'image/jpeg', 0.6 );
- },
+ } else {
- negate: function () {
+ return canvas.toDataURL( 'image/png' );
- this.x = - this.x;
- this.y = - this.y;
- this.z = - this.z;
+ }
- return this;
+ }
- },
+ };
- dot: function ( v ) {
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author szimek / https://github.com/szimek/
+ */
- return this.x * v.x + this.y * v.y + this.z * v.z;
+ var textureId = 0;
- },
+ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
- // TODO lengthSquared?
+ Object.defineProperty( this, 'id', { value: textureId ++ } );
- lengthSq: function () {
+ this.uuid = _Math.generateUUID();
- return this.x * this.x + this.y * this.y + this.z * this.z;
+ this.name = '';
- },
+ this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;
+ this.mipmaps = [];
- length: function () {
+ this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;
- return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+ this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;
+ this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;
- },
+ this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
+ this.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter;
+
+ this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
+
+ this.format = format !== undefined ? format : RGBAFormat;
+ this.type = type !== undefined ? type : UnsignedByteType;
+
+ this.offset = new Vector2( 0, 0 );
+ this.repeat = new Vector2( 1, 1 );
+ this.center = new Vector2( 0, 0 );
+ this.rotation = 0;
+
+ this.matrixAutoUpdate = true;
+ this.matrix = new Matrix3();
+
+ this.generateMipmaps = true;
+ this.premultiplyAlpha = false;
+ this.flipY = true;
+ this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
+
+ // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
+ //
+ // Also changing the encoding after already used by a Material will not automatically make the Material
+ // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
+ this.encoding = encoding !== undefined ? encoding : LinearEncoding;
- manhattanLength: function () {
+ this.version = 0;
+ this.onUpdate = null;
- return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );
+ }
- },
+ Texture.DEFAULT_IMAGE = undefined;
+ Texture.DEFAULT_MAPPING = UVMapping;
- normalize: function () {
+ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
- return this.divideScalar( this.length() || 1 );
+ constructor: Texture,
- },
+ isTexture: true,
- setLength: function ( length ) {
+ updateMatrix: function () {
- return this.normalize().multiplyScalar( length );
+ this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
},
- lerp: function ( v, alpha ) {
-
- this.x += ( v.x - this.x ) * alpha;
- this.y += ( v.y - this.y ) * alpha;
- this.z += ( v.z - this.z ) * alpha;
+ clone: function () {
- return this;
+ return new this.constructor().copy( this );
},
- lerpVectors: function ( v1, v2, alpha ) {
-
- return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+ copy: function ( source ) {
- },
+ this.name = source.name;
- cross: function ( v, w ) {
+ this.image = source.image;
+ this.mipmaps = source.mipmaps.slice( 0 );
- if ( w !== undefined ) {
+ this.mapping = source.mapping;
- console.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );
- return this.crossVectors( v, w );
+ this.wrapS = source.wrapS;
+ this.wrapT = source.wrapT;
- }
+ this.magFilter = source.magFilter;
+ this.minFilter = source.minFilter;
- return this.crossVectors( this, v );
+ this.anisotropy = source.anisotropy;
- },
+ this.format = source.format;
+ this.type = source.type;
- crossVectors: function ( a, b ) {
+ this.offset.copy( source.offset );
+ this.repeat.copy( source.repeat );
+ this.center.copy( source.center );
+ this.rotation = source.rotation;
- var ax = a.x, ay = a.y, az = a.z;
- var bx = b.x, by = b.y, bz = b.z;
+ this.matrixAutoUpdate = source.matrixAutoUpdate;
+ this.matrix.copy( source.matrix );
- this.x = ay * bz - az * by;
- this.y = az * bx - ax * bz;
- this.z = ax * by - ay * bx;
+ this.generateMipmaps = source.generateMipmaps;
+ this.premultiplyAlpha = source.premultiplyAlpha;
+ this.flipY = source.flipY;
+ this.unpackAlignment = source.unpackAlignment;
+ this.encoding = source.encoding;
return this;
},
- projectOnVector: function ( vector ) {
-
- var scalar = vector.dot( this ) / vector.lengthSq();
+ toJSON: function ( meta ) {
- return this.copy( vector ).multiplyScalar( scalar );
+ var isRootObject = ( meta === undefined || typeof meta === 'string' );
- },
+ if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
- projectOnPlane: function () {
+ return meta.textures[ this.uuid ];
- var v1 = new Vector3();
+ }
- return function projectOnPlane( planeNormal ) {
+ var output = {
- v1.copy( this ).projectOnVector( planeNormal );
+ metadata: {
+ version: 4.5,
+ type: 'Texture',
+ generator: 'Texture.toJSON'
+ },
- return this.sub( v1 );
+ uuid: this.uuid,
+ name: this.name,
- };
+ mapping: this.mapping,
- }(),
+ repeat: [ this.repeat.x, this.repeat.y ],
+ offset: [ this.offset.x, this.offset.y ],
+ center: [ this.center.x, this.center.y ],
+ rotation: this.rotation,
- reflect: function () {
+ wrap: [ this.wrapS, this.wrapT ],
- // reflect incident vector off plane orthogonal to normal
- // normal is assumed to have unit length
+ format: this.format,
+ type: this.type,
+ encoding: this.encoding,
- var v1 = new Vector3();
+ minFilter: this.minFilter,
+ magFilter: this.magFilter,
+ anisotropy: this.anisotropy,
- return function reflect( normal ) {
+ flipY: this.flipY,
- return this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );
+ premultiplyAlpha: this.premultiplyAlpha,
+ unpackAlignment: this.unpackAlignment
};
- }(),
+ if ( this.image !== undefined ) {
- angleTo: function ( v ) {
+ // TODO: Move to THREE.Image
- var theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );
+ var image = this.image;
- // clamp, to handle numerical problems
+ if ( image.uuid === undefined ) {
- return Math.acos( _Math.clamp( theta, - 1, 1 ) );
+ image.uuid = _Math.generateUUID(); // UGH
- },
+ }
- distanceTo: function ( v ) {
+ if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
- return Math.sqrt( this.distanceToSquared( v ) );
+ var url;
- },
+ if ( Array.isArray( image ) ) {
- distanceToSquared: function ( v ) {
+ // process array of images e.g. CubeTexture
- var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
+ url = [];
- return dx * dx + dy * dy + dz * dz;
+ for ( var i = 0, l = image.length; i < l; i ++ ) {
- },
+ url.push( ImageUtils.getDataURL( image[ i ] ) );
- manhattanDistanceTo: function ( v ) {
+ }
- return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );
+ } else {
- },
+ // process single image
- setFromSpherical: function ( s ) {
+ url = ImageUtils.getDataURL( image );
- return this.setFromSphericalCoords( s.radius, s.phi, s.theta );
+ }
- },
+ meta.images[ image.uuid ] = {
+ uuid: image.uuid,
+ url: url
+ };
- setFromSphericalCoords: function ( radius, phi, theta ) {
+ }
- var sinPhiRadius = Math.sin( phi ) * radius;
+ output.image = image.uuid;
- this.x = sinPhiRadius * Math.sin( theta );
- this.y = Math.cos( phi ) * radius;
- this.z = sinPhiRadius * Math.cos( theta );
+ }
- return this;
+ if ( ! isRootObject ) {
- },
+ meta.textures[ this.uuid ] = output;
- setFromCylindrical: function ( c ) {
+ }
- return this.setFromCylindricalCoords( c.radius, c.theta, c.y );
+ return output;
},
- setFromCylindricalCoords: function ( radius, theta, y ) {
-
- this.x = radius * Math.sin( theta );
- this.y = y;
- this.z = radius * Math.cos( theta );
+ dispose: function () {
- return this;
+ this.dispatchEvent( { type: 'dispose' } );
},
- setFromMatrixPosition: function ( m ) {
+ transformUv: function ( uv ) {
- var e = m.elements;
+ if ( this.mapping !== UVMapping ) return uv;
- this.x = e[ 12 ];
- this.y = e[ 13 ];
- this.z = e[ 14 ];
+ uv.applyMatrix3( this.matrix );
- return this;
+ if ( uv.x < 0 || uv.x > 1 ) {
- },
+ switch ( this.wrapS ) {
- setFromMatrixScale: function ( m ) {
+ case RepeatWrapping:
- var sx = this.setFromMatrixColumn( m, 0 ).length();
- var sy = this.setFromMatrixColumn( m, 1 ).length();
- var sz = this.setFromMatrixColumn( m, 2 ).length();
+ uv.x = uv.x - Math.floor( uv.x );
+ break;
- this.x = sx;
- this.y = sy;
- this.z = sz;
+ case ClampToEdgeWrapping:
- return this;
+ uv.x = uv.x < 0 ? 0 : 1;
+ break;
- },
+ case MirroredRepeatWrapping:
- setFromMatrixColumn: function ( m, index ) {
+ if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {
- return this.fromArray( m.elements, index * 4 );
+ uv.x = Math.ceil( uv.x ) - uv.x;
- },
+ } else {
- equals: function ( v ) {
+ uv.x = uv.x - Math.floor( uv.x );
- return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );
+ }
+ break;
- },
+ }
- fromArray: function ( array, offset ) {
+ }
- if ( offset === undefined ) offset = 0;
+ if ( uv.y < 0 || uv.y > 1 ) {
- this.x = array[ offset ];
- this.y = array[ offset + 1 ];
- this.z = array[ offset + 2 ];
+ switch ( this.wrapT ) {
- return this;
+ case RepeatWrapping:
- },
+ uv.y = uv.y - Math.floor( uv.y );
+ break;
- toArray: function ( array, offset ) {
+ case ClampToEdgeWrapping:
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ uv.y = uv.y < 0 ? 0 : 1;
+ break;
- array[ offset ] = this.x;
- array[ offset + 1 ] = this.y;
- array[ offset + 2 ] = this.z;
+ case MirroredRepeatWrapping:
- return array;
+ if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {
- },
+ uv.y = Math.ceil( uv.y ) - uv.y;
- fromBufferAttribute: function ( attribute, index, offset ) {
+ } else {
- if ( offset !== undefined ) {
+ uv.y = uv.y - Math.floor( uv.y );
- console.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );
+ }
+ break;
+
+ }
}
- this.x = attribute.getX( index );
- this.y = attribute.getY( index );
- this.z = attribute.getZ( index );
+ if ( this.flipY ) {
- return this;
+ uv.y = 1 - uv.y;
+
+ }
+
+ return uv;
}
} );
- /**
- * @author alteredq / http://alteredqualia.com/
- * @author WestLangley / http://github.com/WestLangley
- * @author bhouston / http://clara.io
- * @author tschw
- */
+ Object.defineProperty( Texture.prototype, "needsUpdate", {
- function Matrix3() {
+ set: function ( value ) {
- this.elements = [
+ if ( value === true ) this.version ++;
- 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1
+ }
- ];
+ } );
- if ( arguments.length > 0 ) {
+ /**
+ * @author supereggbert / http://www.paulbrunt.co.uk/
+ * @author philogb / http://blog.thejit.org/
+ * @author mikael emtinger / http://gomo.se/
+ * @author egraether / http://egraether.com/
+ * @author WestLangley / http://github.com/WestLangley
+ */
- console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
+ function Vector4( x, y, z, w ) {
- }
+ this.x = x || 0;
+ this.y = y || 0;
+ this.z = z || 0;
+ this.w = ( w !== undefined ) ? w : 1;
}
- Object.assign( Matrix3.prototype, {
-
- isMatrix3: true,
+ Object.assign( Vector4.prototype, {
- set: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
+ isVector4: true,
- var te = this.elements;
+ set: function ( x, y, z, w ) {
- te[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;
- te[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;
- te[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
return this;
},
- identity: function () {
-
- this.set(
-
- 1, 0, 0,
- 0, 1, 0,
- 0, 0, 1
+ setScalar: function ( scalar ) {
- );
+ this.x = scalar;
+ this.y = scalar;
+ this.z = scalar;
+ this.w = scalar;
return this;
},
- clone: function () {
+ setX: function ( x ) {
- return new this.constructor().fromArray( this.elements );
+ this.x = x;
- },
+ return this;
- copy: function ( m ) {
+ },
- var te = this.elements;
- var me = m.elements;
+ setY: function ( y ) {
- te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
- te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
- te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
+ this.y = y;
return this;
},
- setFromMatrix4: function ( m ) {
+ setZ: function ( z ) {
- var me = m.elements;
+ this.z = z;
- this.set(
+ return this;
- me[ 0 ], me[ 4 ], me[ 8 ],
- me[ 1 ], me[ 5 ], me[ 9 ],
- me[ 2 ], me[ 6 ], me[ 10 ]
+ },
- );
+ setW: function ( w ) {
+
+ this.w = w;
return this;
},
- applyToBufferAttribute: function () {
+ setComponent: function ( index, value ) {
- var v1 = new Vector3();
+ switch ( index ) {
- return function applyToBufferAttribute( attribute ) {
+ case 0: this.x = value; break;
+ case 1: this.y = value; break;
+ case 2: this.z = value; break;
+ case 3: this.w = value; break;
+ default: throw new Error( 'index is out of range: ' + index );
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
+ }
- v1.x = attribute.getX( i );
- v1.y = attribute.getY( i );
- v1.z = attribute.getZ( i );
+ return this;
- v1.applyMatrix3( this );
+ },
- attribute.setXYZ( i, v1.x, v1.y, v1.z );
+ getComponent: function ( index ) {
- }
+ switch ( index ) {
- return attribute;
+ case 0: return this.x;
+ case 1: return this.y;
+ case 2: return this.z;
+ case 3: return this.w;
+ default: throw new Error( 'index is out of range: ' + index );
- };
+ }
- }(),
+ },
- multiply: function ( m ) {
+ clone: function () {
- return this.multiplyMatrices( this, m );
+ return new this.constructor( this.x, this.y, this.z, this.w );
},
- premultiply: function ( m ) {
-
- return this.multiplyMatrices( m, this );
+ copy: function ( v ) {
- },
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ this.w = ( v.w !== undefined ) ? v.w : 1;
- multiplyMatrices: function ( a, b ) {
+ return this;
- var ae = a.elements;
- var be = b.elements;
- var te = this.elements;
+ },
- var a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];
- var a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];
- var a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];
+ add: function ( v, w ) {
- var b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];
- var b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];
- var b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];
+ if ( w !== undefined ) {
- te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;
- te[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;
- te[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;
+ console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
+ return this.addVectors( v, w );
- te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;
- te[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;
- te[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;
+ }
- te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;
- te[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;
- te[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ this.w += v.w;
return this;
},
- multiplyScalar: function ( s ) {
-
- var te = this.elements;
+ addScalar: function ( s ) {
- te[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;
- te[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;
- te[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;
+ this.x += s;
+ this.y += s;
+ this.z += s;
+ this.w += s;
return this;
},
- determinant: function () {
-
- var te = this.elements;
+ addVectors: function ( a, b ) {
- var a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],
- d = te[ 3 ], e = te[ 4 ], f = te[ 5 ],
- g = te[ 6 ], h = te[ 7 ], i = te[ 8 ];
+ this.x = a.x + b.x;
+ this.y = a.y + b.y;
+ this.z = a.z + b.z;
+ this.w = a.w + b.w;
- return a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;
+ return this;
},
- getInverse: function ( matrix, throwOnDegenerate ) {
+ addScaledVector: function ( v, s ) {
- if ( matrix && matrix.isMatrix4 ) {
+ this.x += v.x * s;
+ this.y += v.y * s;
+ this.z += v.z * s;
+ this.w += v.w * s;
- console.error( "THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument." );
+ return this;
- }
+ },
- var me = matrix.elements,
- te = this.elements,
+ sub: function ( v, w ) {
- n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],
- n12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],
- n13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],
+ if ( w !== undefined ) {
- t11 = n33 * n22 - n32 * n23,
- t12 = n32 * n13 - n33 * n12,
- t13 = n23 * n12 - n22 * n13,
+ console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
+ return this.subVectors( v, w );
- det = n11 * t11 + n21 * t12 + n31 * t13;
+ }
- if ( det === 0 ) {
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+ this.w -= v.w;
- var msg = "THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";
+ return this;
- if ( throwOnDegenerate === true ) {
+ },
- throw new Error( msg );
+ subScalar: function ( s ) {
- } else {
+ this.x -= s;
+ this.y -= s;
+ this.z -= s;
+ this.w -= s;
- console.warn( msg );
+ return this;
- }
+ },
- return this.identity();
+ subVectors: function ( a, b ) {
- }
+ this.x = a.x - b.x;
+ this.y = a.y - b.y;
+ this.z = a.z - b.z;
+ this.w = a.w - b.w;
- var detInv = 1 / det;
+ return this;
- te[ 0 ] = t11 * detInv;
- te[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;
- te[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;
+ },
- te[ 3 ] = t12 * detInv;
- te[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;
- te[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;
+ multiplyScalar: function ( scalar ) {
- te[ 6 ] = t13 * detInv;
- te[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;
- te[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;
+ this.x *= scalar;
+ this.y *= scalar;
+ this.z *= scalar;
+ this.w *= scalar;
return this;
},
- transpose: function () {
+ applyMatrix4: function ( m ) {
- var tmp, m = this.elements;
+ var x = this.x, y = this.y, z = this.z, w = this.w;
+ var e = m.elements;
- tmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;
- tmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;
- tmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;
+ this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;
+ this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;
+ this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;
+ this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;
return this;
},
- getNormalMatrix: function ( matrix4 ) {
+ divideScalar: function ( scalar ) {
- return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();
+ return this.multiplyScalar( 1 / scalar );
},
- transposeIntoArray: function ( r ) {
+ setAxisAngleFromQuaternion: function ( q ) {
- var m = this.elements;
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
- r[ 0 ] = m[ 0 ];
- r[ 1 ] = m[ 3 ];
- r[ 2 ] = m[ 6 ];
- r[ 3 ] = m[ 1 ];
- r[ 4 ] = m[ 4 ];
- r[ 5 ] = m[ 7 ];
- r[ 6 ] = m[ 2 ];
- r[ 7 ] = m[ 5 ];
- r[ 8 ] = m[ 8 ];
+ // q is assumed to be normalized
+
+ this.w = 2 * Math.acos( q.w );
+
+ var s = Math.sqrt( 1 - q.w * q.w );
+
+ if ( s < 0.0001 ) {
+
+ this.x = 1;
+ this.y = 0;
+ this.z = 0;
+
+ } else {
+
+ this.x = q.x / s;
+ this.y = q.y / s;
+ this.z = q.z / s;
+
+ }
return this;
},
- setUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {
+ setAxisAngleFromRotationMatrix: function ( m ) {
- var c = Math.cos( rotation );
- var s = Math.sin( rotation );
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
- this.set(
- sx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,
- - sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,
- 0, 0, 1
- );
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
- },
+ var angle, x, y, z, // variables for result
+ epsilon = 0.01, // margin to allow for rounding errors
+ epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees
- scale: function ( sx, sy ) {
+ te = m.elements,
- var te = this.elements;
+ m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
+ m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
+ m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
- te[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;
- te[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;
+ if ( ( Math.abs( m12 - m21 ) < epsilon ) &&
+ ( Math.abs( m13 - m31 ) < epsilon ) &&
+ ( Math.abs( m23 - m32 ) < epsilon ) ) {
- return this;
+ // singularity found
+ // first check for identity matrix which must have +1 for all terms
+ // in leading diagonal and zero in other terms
- },
+ if ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&
+ ( Math.abs( m13 + m31 ) < epsilon2 ) &&
+ ( Math.abs( m23 + m32 ) < epsilon2 ) &&
+ ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {
- rotate: function ( theta ) {
+ // this singularity is identity matrix so angle = 0
- var c = Math.cos( theta );
- var s = Math.sin( theta );
+ this.set( 1, 0, 0, 0 );
- var te = this.elements;
+ return this; // zero angle, arbitrary axis
- var a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];
- var a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];
+ }
- te[ 0 ] = c * a11 + s * a21;
- te[ 3 ] = c * a12 + s * a22;
- te[ 6 ] = c * a13 + s * a23;
+ // otherwise this singularity is angle = 180
- te[ 1 ] = - s * a11 + c * a21;
- te[ 4 ] = - s * a12 + c * a22;
- te[ 7 ] = - s * a13 + c * a23;
+ angle = Math.PI;
- return this;
+ var xx = ( m11 + 1 ) / 2;
+ var yy = ( m22 + 1 ) / 2;
+ var zz = ( m33 + 1 ) / 2;
+ var xy = ( m12 + m21 ) / 4;
+ var xz = ( m13 + m31 ) / 4;
+ var yz = ( m23 + m32 ) / 4;
- },
+ if ( ( xx > yy ) && ( xx > zz ) ) {
- translate: function ( tx, ty ) {
+ // m11 is the largest diagonal term
- var te = this.elements;
+ if ( xx < epsilon ) {
- te[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];
- te[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];
+ x = 0;
+ y = 0.707106781;
+ z = 0.707106781;
- return this;
+ } else {
- },
+ x = Math.sqrt( xx );
+ y = xy / x;
+ z = xz / x;
- equals: function ( matrix ) {
+ }
- var te = this.elements;
- var me = matrix.elements;
+ } else if ( yy > zz ) {
- for ( var i = 0; i < 9; i ++ ) {
+ // m22 is the largest diagonal term
- if ( te[ i ] !== me[ i ] ) return false;
+ if ( yy < epsilon ) {
- }
+ x = 0.707106781;
+ y = 0;
+ z = 0.707106781;
- return true;
+ } else {
- },
+ y = Math.sqrt( yy );
+ x = xy / y;
+ z = yz / y;
- fromArray: function ( array, offset ) {
+ }
- if ( offset === undefined ) offset = 0;
+ } else {
- for ( var i = 0; i < 9; i ++ ) {
+ // m33 is the largest diagonal term so base result on this
- this.elements[ i ] = array[ i + offset ];
+ if ( zz < epsilon ) {
- }
+ x = 0.707106781;
+ y = 0.707106781;
+ z = 0;
- return this;
+ } else {
- },
+ z = Math.sqrt( zz );
+ x = xz / z;
+ y = yz / z;
- toArray: function ( array, offset ) {
+ }
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ }
- var te = this.elements;
+ this.set( x, y, z, angle );
- array[ offset ] = te[ 0 ];
- array[ offset + 1 ] = te[ 1 ];
- array[ offset + 2 ] = te[ 2 ];
+ return this; // return 180 deg rotation
- array[ offset + 3 ] = te[ 3 ];
- array[ offset + 4 ] = te[ 4 ];
- array[ offset + 5 ] = te[ 5 ];
+ }
- array[ offset + 6 ] = te[ 6 ];
- array[ offset + 7 ] = te[ 7 ];
- array[ offset + 8 ] = te[ 8 ];
+ // as we have reached here there are no singularities so we can handle normally
- return array;
+ var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +
+ ( m13 - m31 ) * ( m13 - m31 ) +
+ ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize
- }
+ if ( Math.abs( s ) < 0.001 ) s = 1;
- } );
+ // prevent divide by zero, should not happen if matrix is orthogonal and should be
+ // caught by singularity test above, but I've left it in just in case
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author szimek / https://github.com/szimek/
- */
+ this.x = ( m32 - m23 ) / s;
+ this.y = ( m13 - m31 ) / s;
+ this.z = ( m21 - m12 ) / s;
+ this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );
- var _canvas;
+ return this;
- var ImageUtils = {
+ },
- getDataURL: function ( image ) {
+ min: function ( v ) {
- var canvas;
+ this.x = Math.min( this.x, v.x );
+ this.y = Math.min( this.y, v.y );
+ this.z = Math.min( this.z, v.z );
+ this.w = Math.min( this.w, v.w );
- if ( typeof HTMLCanvasElement == 'undefined' ) {
+ return this;
- return image.src;
+ },
- } else if ( image instanceof HTMLCanvasElement ) {
+ max: function ( v ) {
- canvas = image;
+ this.x = Math.max( this.x, v.x );
+ this.y = Math.max( this.y, v.y );
+ this.z = Math.max( this.z, v.z );
+ this.w = Math.max( this.w, v.w );
- } else {
+ return this;
- if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
+ },
- _canvas.width = image.width;
- _canvas.height = image.height;
+ clamp: function ( min, max ) {
- var context = _canvas.getContext( '2d' );
+ // assumes min < max, componentwise
- if ( image instanceof ImageData ) {
+ this.x = Math.max( min.x, Math.min( max.x, this.x ) );
+ this.y = Math.max( min.y, Math.min( max.y, this.y ) );
+ this.z = Math.max( min.z, Math.min( max.z, this.z ) );
+ this.w = Math.max( min.w, Math.min( max.w, this.w ) );
- context.putImageData( image, 0, 0 );
+ return this;
- } else {
+ },
- context.drawImage( image, 0, 0, image.width, image.height );
+ clampScalar: function () {
+
+ var min, max;
+
+ return function clampScalar( minVal, maxVal ) {
+
+ if ( min === undefined ) {
+
+ min = new Vector4();
+ max = new Vector4();
}
- canvas = _canvas;
+ min.set( minVal, minVal, minVal, minVal );
+ max.set( maxVal, maxVal, maxVal, maxVal );
- }
+ return this.clamp( min, max );
- if ( canvas.width > 2048 || canvas.height > 2048 ) {
+ };
- return canvas.toDataURL( 'image/jpeg', 0.6 );
+ }(),
- } else {
+ clampLength: function ( min, max ) {
- return canvas.toDataURL( 'image/png' );
+ var length = this.length();
- }
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
- }
+ },
- };
+ floor: function () {
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author szimek / https://github.com/szimek/
- */
+ this.x = Math.floor( this.x );
+ this.y = Math.floor( this.y );
+ this.z = Math.floor( this.z );
+ this.w = Math.floor( this.w );
- var textureId = 0;
+ return this;
- function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
+ },
- Object.defineProperty( this, 'id', { value: textureId ++ } );
+ ceil: function () {
- this.uuid = _Math.generateUUID();
+ this.x = Math.ceil( this.x );
+ this.y = Math.ceil( this.y );
+ this.z = Math.ceil( this.z );
+ this.w = Math.ceil( this.w );
- this.name = '';
+ return this;
- this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;
- this.mipmaps = [];
+ },
- this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;
+ round: function () {
- this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;
- this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;
+ this.x = Math.round( this.x );
+ this.y = Math.round( this.y );
+ this.z = Math.round( this.z );
+ this.w = Math.round( this.w );
- this.magFilter = magFilter !== undefined ? magFilter : LinearFilter;
- this.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter;
+ return this;
- this.anisotropy = anisotropy !== undefined ? anisotropy : 1;
+ },
- this.format = format !== undefined ? format : RGBAFormat;
- this.type = type !== undefined ? type : UnsignedByteType;
+ roundToZero: function () {
- this.offset = new Vector2( 0, 0 );
- this.repeat = new Vector2( 1, 1 );
- this.center = new Vector2( 0, 0 );
- this.rotation = 0;
+ this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
+ this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
+ this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
+ this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
- this.matrixAutoUpdate = true;
- this.matrix = new Matrix3();
+ return this;
- this.generateMipmaps = true;
- this.premultiplyAlpha = false;
- this.flipY = true;
- this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)
+ },
- // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.
- //
- // Also changing the encoding after already used by a Material will not automatically make the Material
- // update. You need to explicitly call Material.needsUpdate to trigger it to recompile.
- this.encoding = encoding !== undefined ? encoding : LinearEncoding;
+ negate: function () {
- this.version = 0;
- this.onUpdate = null;
+ this.x = - this.x;
+ this.y = - this.y;
+ this.z = - this.z;
+ this.w = - this.w;
- }
+ return this;
- Texture.DEFAULT_IMAGE = undefined;
- Texture.DEFAULT_MAPPING = UVMapping;
+ },
- Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
+ dot: function ( v ) {
- constructor: Texture,
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
- isTexture: true,
+ },
- updateMatrix: function () {
+ lengthSq: function () {
- this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
},
- clone: function () {
+ length: function () {
- return new this.constructor().copy( this );
+ return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
},
- copy: function ( source ) {
+ manhattanLength: function () {
- this.name = source.name;
+ return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
- this.image = source.image;
- this.mipmaps = source.mipmaps.slice( 0 );
+ },
- this.mapping = source.mapping;
+ normalize: function () {
- this.wrapS = source.wrapS;
- this.wrapT = source.wrapT;
+ return this.divideScalar( this.length() || 1 );
- this.magFilter = source.magFilter;
- this.minFilter = source.minFilter;
+ },
- this.anisotropy = source.anisotropy;
+ setLength: function ( length ) {
- this.format = source.format;
- this.type = source.type;
+ return this.normalize().multiplyScalar( length );
- this.offset.copy( source.offset );
- this.repeat.copy( source.repeat );
- this.center.copy( source.center );
- this.rotation = source.rotation;
+ },
- this.matrixAutoUpdate = source.matrixAutoUpdate;
- this.matrix.copy( source.matrix );
+ lerp: function ( v, alpha ) {
- this.generateMipmaps = source.generateMipmaps;
- this.premultiplyAlpha = source.premultiplyAlpha;
- this.flipY = source.flipY;
- this.unpackAlignment = source.unpackAlignment;
- this.encoding = source.encoding;
+ this.x += ( v.x - this.x ) * alpha;
+ this.y += ( v.y - this.y ) * alpha;
+ this.z += ( v.z - this.z ) * alpha;
+ this.w += ( v.w - this.w ) * alpha;
return this;
},
- toJSON: function ( meta ) {
+ lerpVectors: function ( v1, v2, alpha ) {
- var isRootObject = ( meta === undefined || typeof meta === 'string' );
+ return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
- if ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {
+ },
- return meta.textures[ this.uuid ];
+ equals: function ( v ) {
- }
+ return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
- var output = {
+ },
- metadata: {
- version: 4.5,
- type: 'Texture',
- generator: 'Texture.toJSON'
- },
+ fromArray: function ( array, offset ) {
- uuid: this.uuid,
- name: this.name,
+ if ( offset === undefined ) offset = 0;
- mapping: this.mapping,
+ this.x = array[ offset ];
+ this.y = array[ offset + 1 ];
+ this.z = array[ offset + 2 ];
+ this.w = array[ offset + 3 ];
- repeat: [ this.repeat.x, this.repeat.y ],
- offset: [ this.offset.x, this.offset.y ],
- center: [ this.center.x, this.center.y ],
- rotation: this.rotation,
+ return this;
- wrap: [ this.wrapS, this.wrapT ],
+ },
- format: this.format,
- type: this.type,
- encoding: this.encoding,
+ toArray: function ( array, offset ) {
- minFilter: this.minFilter,
- magFilter: this.magFilter,
- anisotropy: this.anisotropy,
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- flipY: this.flipY,
+ array[ offset ] = this.x;
+ array[ offset + 1 ] = this.y;
+ array[ offset + 2 ] = this.z;
+ array[ offset + 3 ] = this.w;
- premultiplyAlpha: this.premultiplyAlpha,
- unpackAlignment: this.unpackAlignment
+ return array;
- };
+ },
- if ( this.image !== undefined ) {
+ fromBufferAttribute: function ( attribute, index, offset ) {
- // TODO: Move to THREE.Image
+ if ( offset !== undefined ) {
- var image = this.image;
+ console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );
- if ( image.uuid === undefined ) {
+ }
- image.uuid = _Math.generateUUID(); // UGH
+ this.x = attribute.getX( index );
+ this.y = attribute.getY( index );
+ this.z = attribute.getZ( index );
+ this.w = attribute.getW( index );
- }
+ return this;
- if ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {
+ }
- var url;
+ } );
- if ( Array.isArray( image ) ) {
+ /**
+ * @author szimek / https://github.com/szimek/
+ * @author alteredq / http://alteredqualia.com/
+ * @author Marius Kintel / https://github.com/kintel
+ */
- // process array of images e.g. CubeTexture
+ /*
+ In options, we can specify:
+ * Texture parameters for an auto-generated target texture
+ * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
+ */
+ function WebGLRenderTarget( width, height, options ) {
- url = [];
+ this.width = width;
+ this.height = height;
- for ( var i = 0, l = image.length; i < l; i ++ ) {
+ this.scissor = new Vector4( 0, 0, width, height );
+ this.scissorTest = false;
- url.push( ImageUtils.getDataURL( image[ i ] ) );
+ this.viewport = new Vector4( 0, 0, width, height );
- }
+ options = options || {};
- } else {
+ this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
- // process single image
+ this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
+ this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
- url = ImageUtils.getDataURL( image );
+ this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
+ this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
+ this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
- }
+ }
+
+ WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
- meta.images[ image.uuid ] = {
- uuid: image.uuid,
- url: url
- };
+ constructor: WebGLRenderTarget,
- }
+ isWebGLRenderTarget: true,
- output.image = image.uuid;
+ setSize: function ( width, height ) {
- }
+ if ( this.width !== width || this.height !== height ) {
- if ( ! isRootObject ) {
+ this.width = width;
+ this.height = height;
- meta.textures[ this.uuid ] = output;
+ this.dispose();
}
- return output;
+ this.viewport.set( 0, 0, width, height );
+ this.scissor.set( 0, 0, width, height );
},
- dispose: function () {
+ clone: function () {
- this.dispatchEvent( { type: 'dispose' } );
+ return new this.constructor().copy( this );
},
- transformUv: function ( uv ) {
-
- if ( this.mapping !== UVMapping ) return uv;
-
- uv.applyMatrix3( this.matrix );
+ copy: function ( source ) {
- if ( uv.x < 0 || uv.x > 1 ) {
+ this.width = source.width;
+ this.height = source.height;
- switch ( this.wrapS ) {
+ this.viewport.copy( source.viewport );
- case RepeatWrapping:
+ this.texture = source.texture.clone();
- uv.x = uv.x - Math.floor( uv.x );
- break;
+ this.depthBuffer = source.depthBuffer;
+ this.stencilBuffer = source.stencilBuffer;
+ this.depthTexture = source.depthTexture;
- case ClampToEdgeWrapping:
+ return this;
- uv.x = uv.x < 0 ? 0 : 1;
- break;
+ },
- case MirroredRepeatWrapping:
+ dispose: function () {
- if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {
+ this.dispatchEvent( { type: 'dispose' } );
- uv.x = Math.ceil( uv.x ) - uv.x;
+ }
- } else {
+ } );
- uv.x = uv.x - Math.floor( uv.x );
+ /**
+ * @author Mugen87 / https://github.com/Mugen87
+ * @author Matt DesLauriers / @mattdesl
+ */
- }
- break;
+ function WebGLMultisampleRenderTarget( width, height, options ) {
- }
+ WebGLRenderTarget.call( this, width, height, options );
- }
+ this.samples = 4;
- if ( uv.y < 0 || uv.y > 1 ) {
+ }
- switch ( this.wrapT ) {
+ WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), {
- case RepeatWrapping:
+ constructor: WebGLMultisampleRenderTarget,
- uv.y = uv.y - Math.floor( uv.y );
- break;
+ isWebGLMultisampleRenderTarget: true,
- case ClampToEdgeWrapping:
+ copy: function ( source ) {
- uv.y = uv.y < 0 ? 0 : 1;
- break;
+ WebGLRenderTarget.prototype.copy.call( this, source );
- case MirroredRepeatWrapping:
+ this.samples = source.samples;
- if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {
+ return this;
- uv.y = Math.ceil( uv.y ) - uv.y;
+ }
- } else {
+ } );
- uv.y = uv.y - Math.floor( uv.y );
+ /**
+ * @author alteredq / http://alteredqualia.com
+ */
- }
- break;
+ function WebGLRenderTargetCube( width, height, options ) {
- }
+ WebGLRenderTarget.call( this, width, height, options );
- }
+ }
- if ( this.flipY ) {
+ WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype );
+ WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube;
- uv.y = 1 - uv.y;
+ WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;
- }
+ /**
+ * @author alteredq / http://alteredqualia.com/
+ */
- return uv;
+ function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
- }
+ Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
- } );
+ this.image = { data: data, width: width, height: height };
- Object.defineProperty( Texture.prototype, "needsUpdate", {
+ this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
+ this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
- set: function ( value ) {
+ this.generateMipmaps = false;
+ this.flipY = false;
+ this.unpackAlignment = 1;
- if ( value === true ) this.version ++;
+ }
- }
+ DataTexture.prototype = Object.create( Texture.prototype );
+ DataTexture.prototype.constructor = DataTexture;
- } );
+ DataTexture.prototype.isDataTexture = true;
/**
- * @author supereggbert / http://www.paulbrunt.co.uk/
- * @author philogb / http://blog.thejit.org/
- * @author mikael emtinger / http://gomo.se/
- * @author egraether / http://egraether.com/
+ * @author bhouston / http://clara.io
* @author WestLangley / http://github.com/WestLangley
*/
- function Vector4( x, y, z, w ) {
+ function Box3( min, max ) {
- this.x = x || 0;
- this.y = y || 0;
- this.z = z || 0;
- this.w = ( w !== undefined ) ? w : 1;
+ this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );
+ this.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );
}
- Object.assign( Vector4.prototype, {
+ Object.assign( Box3.prototype, {
- isVector4: true,
+ isBox3: true,
- set: function ( x, y, z, w ) {
+ set: function ( min, max ) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
+ this.min.copy( min );
+ this.max.copy( max );
return this;
},
- setScalar: function ( scalar ) {
-
- this.x = scalar;
- this.y = scalar;
- this.z = scalar;
- this.w = scalar;
+ setFromArray: function ( array ) {
- return this;
+ var minX = + Infinity;
+ var minY = + Infinity;
+ var minZ = + Infinity;
- },
+ var maxX = - Infinity;
+ var maxY = - Infinity;
+ var maxZ = - Infinity;
- setX: function ( x ) {
+ for ( var i = 0, l = array.length; i < l; i += 3 ) {
- this.x = x;
+ var x = array[ i ];
+ var y = array[ i + 1 ];
+ var z = array[ i + 2 ];
- return this;
+ if ( x < minX ) minX = x;
+ if ( y < minY ) minY = y;
+ if ( z < minZ ) minZ = z;
- },
+ if ( x > maxX ) maxX = x;
+ if ( y > maxY ) maxY = y;
+ if ( z > maxZ ) maxZ = z;
- setY: function ( y ) {
+ }
- this.y = y;
+ this.min.set( minX, minY, minZ );
+ this.max.set( maxX, maxY, maxZ );
return this;
},
- setZ: function ( z ) {
+ setFromBufferAttribute: function ( attribute ) {
- this.z = z;
+ var minX = + Infinity;
+ var minY = + Infinity;
+ var minZ = + Infinity;
- return this;
+ var maxX = - Infinity;
+ var maxY = - Infinity;
+ var maxZ = - Infinity;
- },
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- setW: function ( w ) {
+ var x = attribute.getX( i );
+ var y = attribute.getY( i );
+ var z = attribute.getZ( i );
- this.w = w;
+ if ( x < minX ) minX = x;
+ if ( y < minY ) minY = y;
+ if ( z < minZ ) minZ = z;
+
+ if ( x > maxX ) maxX = x;
+ if ( y > maxY ) maxY = y;
+ if ( z > maxZ ) maxZ = z;
+
+ }
+
+ this.min.set( minX, minY, minZ );
+ this.max.set( maxX, maxY, maxZ );
return this;
},
- setComponent: function ( index, value ) {
+ setFromPoints: function ( points ) {
- switch ( index ) {
+ this.makeEmpty();
- case 0: this.x = value; break;
- case 1: this.y = value; break;
- case 2: this.z = value; break;
- case 3: this.w = value; break;
- default: throw new Error( 'index is out of range: ' + index );
+ for ( var i = 0, il = points.length; i < il; i ++ ) {
+
+ this.expandByPoint( points[ i ] );
}
@@ -4119,814 +3974,741 @@
},
- getComponent: function ( index ) {
+ setFromCenterAndSize: function () {
- switch ( index ) {
+ var v1 = new Vector3();
- case 0: return this.x;
- case 1: return this.y;
- case 2: return this.z;
- case 3: return this.w;
- default: throw new Error( 'index is out of range: ' + index );
+ return function setFromCenterAndSize( center, size ) {
- }
+ var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
- },
+ this.min.copy( center ).sub( halfSize );
+ this.max.copy( center ).add( halfSize );
- clone: function () {
+ return this;
- return new this.constructor( this.x, this.y, this.z, this.w );
+ };
- },
+ }(),
- copy: function ( v ) {
+ setFromObject: function ( object ) {
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
- this.w = ( v.w !== undefined ) ? v.w : 1;
+ this.makeEmpty();
- return this;
+ return this.expandByObject( object );
},
- add: function ( v, w ) {
-
- if ( w !== undefined ) {
-
- console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );
- return this.addVectors( v, w );
-
- }
-
- this.x += v.x;
- this.y += v.y;
- this.z += v.z;
- this.w += v.w;
+ clone: function () {
- return this;
+ return new this.constructor().copy( this );
},
- addScalar: function ( s ) {
+ copy: function ( box ) {
- this.x += s;
- this.y += s;
- this.z += s;
- this.w += s;
+ this.min.copy( box.min );
+ this.max.copy( box.max );
return this;
},
- addVectors: function ( a, b ) {
+ makeEmpty: function () {
- this.x = a.x + b.x;
- this.y = a.y + b.y;
- this.z = a.z + b.z;
- this.w = a.w + b.w;
+ this.min.x = this.min.y = this.min.z = + Infinity;
+ this.max.x = this.max.y = this.max.z = - Infinity;
return this;
},
- addScaledVector: function ( v, s ) {
+ isEmpty: function () {
- this.x += v.x * s;
- this.y += v.y * s;
- this.z += v.z * s;
- this.w += v.w * s;
+ // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
- return this;
+ return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );
},
- sub: function ( v, w ) {
+ getCenter: function ( target ) {
- if ( w !== undefined ) {
+ if ( target === undefined ) {
- console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );
- return this.subVectors( v, w );
+ console.warn( 'THREE.Box3: .getCenter() target is now required' );
+ target = new Vector3();
}
- this.x -= v.x;
- this.y -= v.y;
- this.z -= v.z;
- this.w -= v.w;
-
- return this;
+ return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
},
- subScalar: function ( s ) {
+ getSize: function ( target ) {
- this.x -= s;
- this.y -= s;
- this.z -= s;
- this.w -= s;
+ if ( target === undefined ) {
- return this;
+ console.warn( 'THREE.Box3: .getSize() target is now required' );
+ target = new Vector3();
+
+ }
+
+ return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
},
- subVectors: function ( a, b ) {
+ expandByPoint: function ( point ) {
- this.x = a.x - b.x;
- this.y = a.y - b.y;
- this.z = a.z - b.z;
- this.w = a.w - b.w;
+ this.min.min( point );
+ this.max.max( point );
return this;
},
- multiplyScalar: function ( scalar ) {
+ expandByVector: function ( vector ) {
- this.x *= scalar;
- this.y *= scalar;
- this.z *= scalar;
- this.w *= scalar;
+ this.min.sub( vector );
+ this.max.add( vector );
return this;
},
- applyMatrix4: function ( m ) {
-
- var x = this.x, y = this.y, z = this.z, w = this.w;
- var e = m.elements;
+ expandByScalar: function ( scalar ) {
- this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;
- this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;
- this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;
- this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;
+ this.min.addScalar( - scalar );
+ this.max.addScalar( scalar );
return this;
},
- divideScalar: function ( scalar ) {
-
- return this.multiplyScalar( 1 / scalar );
-
- },
+ expandByObject: function () {
- setAxisAngleFromQuaternion: function ( q ) {
+ // Computes the world-axis-aligned bounding box of an object (including its children),
+ // accounting for both the object's, and children's, world transforms
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
+ var scope, i, l;
- // q is assumed to be normalized
+ var v1 = new Vector3();
- this.w = 2 * Math.acos( q.w );
+ function traverse( node ) {
- var s = Math.sqrt( 1 - q.w * q.w );
+ var geometry = node.geometry;
- if ( s < 0.0001 ) {
+ if ( geometry !== undefined ) {
- this.x = 1;
- this.y = 0;
- this.z = 0;
+ if ( geometry.isGeometry ) {
- } else {
+ var vertices = geometry.vertices;
- this.x = q.x / s;
- this.y = q.y / s;
- this.z = q.z / s;
+ for ( i = 0, l = vertices.length; i < l; i ++ ) {
- }
+ v1.copy( vertices[ i ] );
+ v1.applyMatrix4( node.matrixWorld );
- return this;
+ scope.expandByPoint( v1 );
- },
+ }
- setAxisAngleFromRotationMatrix: function ( m ) {
+ } else if ( geometry.isBufferGeometry ) {
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
+ var attribute = geometry.attributes.position;
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
+ if ( attribute !== undefined ) {
- var angle, x, y, z, // variables for result
- epsilon = 0.01, // margin to allow for rounding errors
- epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees
+ for ( i = 0, l = attribute.count; i < l; i ++ ) {
- te = m.elements,
+ v1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
- m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],
- m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],
- m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];
+ scope.expandByPoint( v1 );
- if ( ( Math.abs( m12 - m21 ) < epsilon ) &&
- ( Math.abs( m13 - m31 ) < epsilon ) &&
- ( Math.abs( m23 - m32 ) < epsilon ) ) {
+ }
- // singularity found
- // first check for identity matrix which must have +1 for all terms
- // in leading diagonal and zero in other terms
+ }
- if ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&
- ( Math.abs( m13 + m31 ) < epsilon2 ) &&
- ( Math.abs( m23 + m32 ) < epsilon2 ) &&
- ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {
+ }
- // this singularity is identity matrix so angle = 0
+ }
- this.set( 1, 0, 0, 0 );
+ }
- return this; // zero angle, arbitrary axis
+ return function expandByObject( object ) {
- }
+ scope = this;
- // otherwise this singularity is angle = 180
+ object.updateMatrixWorld( true );
- angle = Math.PI;
+ object.traverse( traverse );
- var xx = ( m11 + 1 ) / 2;
- var yy = ( m22 + 1 ) / 2;
- var zz = ( m33 + 1 ) / 2;
- var xy = ( m12 + m21 ) / 4;
- var xz = ( m13 + m31 ) / 4;
- var yz = ( m23 + m32 ) / 4;
+ return this;
- if ( ( xx > yy ) && ( xx > zz ) ) {
+ };
- // m11 is the largest diagonal term
+ }(),
- if ( xx < epsilon ) {
+ containsPoint: function ( point ) {
- x = 0;
- y = 0.707106781;
- z = 0.707106781;
+ return point.x < this.min.x || point.x > this.max.x ||
+ point.y < this.min.y || point.y > this.max.y ||
+ point.z < this.min.z || point.z > this.max.z ? false : true;
- } else {
+ },
- x = Math.sqrt( xx );
- y = xy / x;
- z = xz / x;
+ containsBox: function ( box ) {
- }
+ return this.min.x <= box.min.x && box.max.x <= this.max.x &&
+ this.min.y <= box.min.y && box.max.y <= this.max.y &&
+ this.min.z <= box.min.z && box.max.z <= this.max.z;
- } else if ( yy > zz ) {
+ },
- // m22 is the largest diagonal term
+ getParameter: function ( point, target ) {
- if ( yy < epsilon ) {
+ // This can potentially have a divide by zero if the box
+ // has a size dimension of 0.
- x = 0.707106781;
- y = 0;
- z = 0.707106781;
+ if ( target === undefined ) {
- } else {
+ console.warn( 'THREE.Box3: .getParameter() target is now required' );
+ target = new Vector3();
- y = Math.sqrt( yy );
- x = xy / y;
- z = yz / y;
+ }
- }
+ return target.set(
+ ( point.x - this.min.x ) / ( this.max.x - this.min.x ),
+ ( point.y - this.min.y ) / ( this.max.y - this.min.y ),
+ ( point.z - this.min.z ) / ( this.max.z - this.min.z )
+ );
- } else {
+ },
- // m33 is the largest diagonal term so base result on this
+ intersectsBox: function ( box ) {
- if ( zz < epsilon ) {
+ // using 6 splitting planes to rule out intersections.
+ return box.max.x < this.min.x || box.min.x > this.max.x ||
+ box.max.y < this.min.y || box.min.y > this.max.y ||
+ box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
- x = 0.707106781;
- y = 0.707106781;
- z = 0;
+ },
- } else {
+ intersectsSphere: ( function () {
- z = Math.sqrt( zz );
- x = xz / z;
- y = yz / z;
+ var closestPoint = new Vector3();
- }
+ return function intersectsSphere( sphere ) {
- }
+ // Find the point on the AABB closest to the sphere center.
+ this.clampPoint( sphere.center, closestPoint );
- this.set( x, y, z, angle );
+ // If that point is inside the sphere, the AABB and sphere intersect.
+ return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
- return this; // return 180 deg rotation
+ };
- }
+ } )(),
- // as we have reached here there are no singularities so we can handle normally
+ intersectsPlane: function ( plane ) {
- var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +
- ( m13 - m31 ) * ( m13 - m31 ) +
- ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize
+ // We compute the minimum and maximum dot product values. If those values
+ // are on the same side (back or front) of the plane, then there is no intersection.
- if ( Math.abs( s ) < 0.001 ) s = 1;
+ var min, max;
- // prevent divide by zero, should not happen if matrix is orthogonal and should be
- // caught by singularity test above, but I've left it in just in case
+ if ( plane.normal.x > 0 ) {
- this.x = ( m32 - m23 ) / s;
- this.y = ( m13 - m31 ) / s;
- this.z = ( m21 - m12 ) / s;
- this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );
+ min = plane.normal.x * this.min.x;
+ max = plane.normal.x * this.max.x;
- return this;
+ } else {
- },
+ min = plane.normal.x * this.max.x;
+ max = plane.normal.x * this.min.x;
- min: function ( v ) {
+ }
- this.x = Math.min( this.x, v.x );
- this.y = Math.min( this.y, v.y );
- this.z = Math.min( this.z, v.z );
- this.w = Math.min( this.w, v.w );
+ if ( plane.normal.y > 0 ) {
- return this;
+ min += plane.normal.y * this.min.y;
+ max += plane.normal.y * this.max.y;
- },
+ } else {
- max: function ( v ) {
+ min += plane.normal.y * this.max.y;
+ max += plane.normal.y * this.min.y;
- this.x = Math.max( this.x, v.x );
- this.y = Math.max( this.y, v.y );
- this.z = Math.max( this.z, v.z );
- this.w = Math.max( this.w, v.w );
+ }
- return this;
+ if ( plane.normal.z > 0 ) {
- },
+ min += plane.normal.z * this.min.z;
+ max += plane.normal.z * this.max.z;
- clamp: function ( min, max ) {
+ } else {
- // assumes min < max, componentwise
+ min += plane.normal.z * this.max.z;
+ max += plane.normal.z * this.min.z;
- this.x = Math.max( min.x, Math.min( max.x, this.x ) );
- this.y = Math.max( min.y, Math.min( max.y, this.y ) );
- this.z = Math.max( min.z, Math.min( max.z, this.z ) );
- this.w = Math.max( min.w, Math.min( max.w, this.w ) );
+ }
- return this;
+ return ( min <= - plane.constant && max >= - plane.constant );
},
- clampScalar: function () {
+ intersectsTriangle: ( function () {
- var min, max;
+ // triangle centered vertices
+ var v0 = new Vector3();
+ var v1 = new Vector3();
+ var v2 = new Vector3();
- return function clampScalar( minVal, maxVal ) {
+ // triangle edge vectors
+ var f0 = new Vector3();
+ var f1 = new Vector3();
+ var f2 = new Vector3();
- if ( min === undefined ) {
+ var testAxis = new Vector3();
- min = new Vector4();
- max = new Vector4();
+ var center = new Vector3();
+ var extents = new Vector3();
- }
+ var triangleNormal = new Vector3();
- min.set( minVal, minVal, minVal, minVal );
- max.set( maxVal, maxVal, maxVal, maxVal );
+ function satForAxes( axes ) {
- return this.clamp( min, max );
+ var i, j;
- };
+ for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {
- }(),
+ testAxis.fromArray( axes, i );
+ // project the aabb onto the seperating axis
+ var r = extents.x * Math.abs( testAxis.x ) + extents.y * Math.abs( testAxis.y ) + extents.z * Math.abs( testAxis.z );
+ // project all 3 vertices of the triangle onto the seperating axis
+ var p0 = v0.dot( testAxis );
+ var p1 = v1.dot( testAxis );
+ var p2 = v2.dot( testAxis );
+ // actual test, basically see if either of the most extreme of the triangle points intersects r
+ if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
- clampLength: function ( min, max ) {
+ // points of the projected triangle are outside the projected half-length of the aabb
+ // the axis is seperating and we can exit
+ return false;
- var length = this.length();
+ }
- return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
+ }
- },
+ return true;
- floor: function () {
+ }
- this.x = Math.floor( this.x );
- this.y = Math.floor( this.y );
- this.z = Math.floor( this.z );
- this.w = Math.floor( this.w );
+ return function intersectsTriangle( triangle ) {
- return this;
+ if ( this.isEmpty() ) {
- },
+ return false;
- ceil: function () {
+ }
- this.x = Math.ceil( this.x );
- this.y = Math.ceil( this.y );
- this.z = Math.ceil( this.z );
- this.w = Math.ceil( this.w );
+ // compute box center and extents
+ this.getCenter( center );
+ extents.subVectors( this.max, center );
- return this;
+ // translate triangle to aabb origin
+ v0.subVectors( triangle.a, center );
+ v1.subVectors( triangle.b, center );
+ v2.subVectors( triangle.c, center );
- },
+ // compute edge vectors for triangle
+ f0.subVectors( v1, v0 );
+ f1.subVectors( v2, v1 );
+ f2.subVectors( v0, v2 );
- round: function () {
+ // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
+ // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
+ // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
+ var axes = [
+ 0, - f0.z, f0.y, 0, - f1.z, f1.y, 0, - f2.z, f2.y,
+ f0.z, 0, - f0.x, f1.z, 0, - f1.x, f2.z, 0, - f2.x,
+ - f0.y, f0.x, 0, - f1.y, f1.x, 0, - f2.y, f2.x, 0
+ ];
+ if ( ! satForAxes( axes ) ) {
- this.x = Math.round( this.x );
- this.y = Math.round( this.y );
- this.z = Math.round( this.z );
- this.w = Math.round( this.w );
+ return false;
- return this;
+ }
- },
+ // test 3 face normals from the aabb
+ axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
+ if ( ! satForAxes( axes ) ) {
- roundToZero: function () {
+ return false;
- this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );
- this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );
- this.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );
- this.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );
+ }
- return this;
+ // finally testing the face normal of the triangle
+ // use already existing triangle edge vectors here
+ triangleNormal.crossVectors( f0, f1 );
+ axes = [ triangleNormal.x, triangleNormal.y, triangleNormal.z ];
+ return satForAxes( axes );
- },
+ };
- negate: function () {
+ } )(),
- this.x = - this.x;
- this.y = - this.y;
- this.z = - this.z;
- this.w = - this.w;
+ clampPoint: function ( point, target ) {
- return this;
+ if ( target === undefined ) {
- },
+ console.warn( 'THREE.Box3: .clampPoint() target is now required' );
+ target = new Vector3();
- dot: function ( v ) {
+ }
- return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
+ return target.copy( point ).clamp( this.min, this.max );
},
- lengthSq: function () {
+ distanceToPoint: function () {
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
+ var v1 = new Vector3();
- },
+ return function distanceToPoint( point ) {
- length: function () {
+ var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
+ return clampedPoint.sub( point ).length();
- return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );
+ };
- },
+ }(),
- manhattanLength: function () {
+ getBoundingSphere: function () {
- return Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );
+ var v1 = new Vector3();
- },
+ return function getBoundingSphere( target ) {
- normalize: function () {
+ if ( target === undefined ) {
- return this.divideScalar( this.length() || 1 );
+ console.error( 'THREE.Box3: .getBoundingSphere() target is now required' );
+ //target = new Sphere(); // removed to avoid cyclic dependency
- },
+ }
- setLength: function ( length ) {
+ this.getCenter( target.center );
- return this.normalize().multiplyScalar( length );
+ target.radius = this.getSize( v1 ).length() * 0.5;
- },
+ return target;
- lerp: function ( v, alpha ) {
+ };
- this.x += ( v.x - this.x ) * alpha;
- this.y += ( v.y - this.y ) * alpha;
- this.z += ( v.z - this.z ) * alpha;
- this.w += ( v.w - this.w ) * alpha;
+ }(),
- return this;
+ intersect: function ( box ) {
- },
+ this.min.max( box.min );
+ this.max.min( box.max );
- lerpVectors: function ( v1, v2, alpha ) {
+ // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
+ if ( this.isEmpty() ) this.makeEmpty();
- return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );
+ return this;
},
- equals: function ( v ) {
+ union: function ( box ) {
- return ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );
+ this.min.min( box.min );
+ this.max.max( box.max );
- },
+ return this;
- fromArray: function ( array, offset ) {
+ },
- if ( offset === undefined ) offset = 0;
+ applyMatrix4: function () {
- this.x = array[ offset ];
- this.y = array[ offset + 1 ];
- this.z = array[ offset + 2 ];
- this.w = array[ offset + 3 ];
+ var points = [
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3(),
+ new Vector3()
+ ];
- return this;
+ return function applyMatrix4( matrix ) {
- },
+ // transform of empty box is an empty box.
+ if ( this.isEmpty() ) return this;
- toArray: function ( array, offset ) {
+ // NOTE: I am using a binary pattern to specify all 2^3 combinations below
+ points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
+ points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
+ points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
+ points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
+ points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
+ points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
+ points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
+ points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
- if ( array === undefined ) array = [];
- if ( offset === undefined ) offset = 0;
+ this.setFromPoints( points );
- array[ offset ] = this.x;
- array[ offset + 1 ] = this.y;
- array[ offset + 2 ] = this.z;
- array[ offset + 3 ] = this.w;
+ return this;
- return array;
+ };
- },
+ }(),
- fromBufferAttribute: function ( attribute, index, offset ) {
+ translate: function ( offset ) {
- if ( offset !== undefined ) {
+ this.min.add( offset );
+ this.max.add( offset );
- console.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );
+ return this;
- }
+ },
- this.x = attribute.getX( index );
- this.y = attribute.getY( index );
- this.z = attribute.getZ( index );
- this.w = attribute.getW( index );
+ equals: function ( box ) {
- return this;
+ return box.min.equals( this.min ) && box.max.equals( this.max );
}
} );
/**
- * @author szimek / https://github.com/szimek/
- * @author alteredq / http://alteredqualia.com/
- * @author Marius Kintel / https://github.com/kintel
+ * @author bhouston / http://clara.io
+ * @author mrdoob / http://mrdoob.com/
*/
- /*
- In options, we can specify:
- * Texture parameters for an auto-generated target texture
- * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers
- */
- function WebGLRenderTarget( width, height, options ) {
-
- this.width = width;
- this.height = height;
+ function Sphere( center, radius ) {
- this.scissor = new Vector4( 0, 0, width, height );
- this.scissorTest = false;
+ this.center = ( center !== undefined ) ? center : new Vector3();
+ this.radius = ( radius !== undefined ) ? radius : 0;
- this.viewport = new Vector4( 0, 0, width, height );
+ }
- options = options || {};
+ Object.assign( Sphere.prototype, {
- this.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
+ set: function ( center, radius ) {
- this.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;
- this.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;
+ this.center.copy( center );
+ this.radius = radius;
- this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
- this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
- this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;
+ return this;
- }
+ },
- WebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
+ setFromPoints: function () {
- constructor: WebGLRenderTarget,
+ var box = new Box3();
- isWebGLRenderTarget: true,
+ return function setFromPoints( points, optionalCenter ) {
- setSize: function ( width, height ) {
+ var center = this.center;
- if ( this.width !== width || this.height !== height ) {
+ if ( optionalCenter !== undefined ) {
- this.width = width;
- this.height = height;
+ center.copy( optionalCenter );
- this.dispose();
+ } else {
- }
+ box.setFromPoints( points ).getCenter( center );
- this.viewport.set( 0, 0, width, height );
- this.scissor.set( 0, 0, width, height );
+ }
- },
+ var maxRadiusSq = 0;
- clone: function () {
+ for ( var i = 0, il = points.length; i < il; i ++ ) {
- return new this.constructor().copy( this );
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );
- },
+ }
- copy: function ( source ) {
+ this.radius = Math.sqrt( maxRadiusSq );
- this.width = source.width;
- this.height = source.height;
+ return this;
- this.viewport.copy( source.viewport );
+ };
- this.texture = source.texture.clone();
+ }(),
- this.depthBuffer = source.depthBuffer;
- this.stencilBuffer = source.stencilBuffer;
- this.depthTexture = source.depthTexture;
+ clone: function () {
- return this;
+ return new this.constructor().copy( this );
},
- dispose: function () {
-
- this.dispatchEvent( { type: 'dispose' } );
-
- }
+ copy: function ( sphere ) {
- } );
+ this.center.copy( sphere.center );
+ this.radius = sphere.radius;
- /**
- * @author Mugen87 / https://github.com/Mugen87
- * @author Matt DesLauriers / @mattdesl
- */
+ return this;
- function WebGLMultisampleRenderTarget( width, height, options ) {
+ },
- WebGLRenderTarget.call( this, width, height, options );
+ empty: function () {
- this.samples = 4;
+ return ( this.radius <= 0 );
- }
+ },
- WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), {
+ containsPoint: function ( point ) {
- constructor: WebGLMultisampleRenderTarget,
+ return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );
- isWebGLMultisampleRenderTarget: true,
+ },
- copy: function ( source ) {
+ distanceToPoint: function ( point ) {
- WebGLRenderTarget.prototype.copy.call( this, source );
+ return ( point.distanceTo( this.center ) - this.radius );
- this.samples = source.samples;
+ },
- return this;
+ intersectsSphere: function ( sphere ) {
- }
+ var radiusSum = this.radius + sphere.radius;
- } );
+ return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );
- /**
- * @author alteredq / http://alteredqualia.com
- */
+ },
- function WebGLRenderTargetCube( width, height, options ) {
+ intersectsBox: function ( box ) {
- WebGLRenderTarget.call( this, width, height, options );
+ return box.intersectsSphere( this );
- }
+ },
- WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype );
- WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube;
+ intersectsPlane: function ( plane ) {
- WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;
+ return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;
- /**
- * @author alteredq / http://alteredqualia.com/
- */
+ },
- function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
+ clampPoint: function ( point, target ) {
- Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
+ var deltaLengthSq = this.center.distanceToSquared( point );
- this.image = { data: data, width: width, height: height };
+ if ( target === undefined ) {
- this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
- this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
+ console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
+ target = new Vector3();
- this.generateMipmaps = false;
- this.flipY = false;
- this.unpackAlignment = 1;
+ }
- }
+ target.copy( point );
- DataTexture.prototype = Object.create( Texture.prototype );
- DataTexture.prototype.constructor = DataTexture;
+ if ( deltaLengthSq > ( this.radius * this.radius ) ) {
- DataTexture.prototype.isDataTexture = true;
+ target.sub( this.center ).normalize();
+ target.multiplyScalar( this.radius ).add( this.center );
- /**
- * @author bhouston / http://clara.io
- * @author WestLangley / http://github.com/WestLangley
- */
+ }
- function Box3( min, max ) {
+ return target;
- this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );
- this.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );
+ },
- }
+ getBoundingBox: function ( target ) {
- Object.assign( Box3.prototype, {
+ if ( target === undefined ) {
- isBox3: true,
+ console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
+ target = new Box3();
- set: function ( min, max ) {
+ }
- this.min.copy( min );
- this.max.copy( max );
+ target.set( this.center, this.center );
+ target.expandByScalar( this.radius );
- return this;
+ return target;
},
- setFromArray: function ( array ) {
-
- var minX = + Infinity;
- var minY = + Infinity;
- var minZ = + Infinity;
-
- var maxX = - Infinity;
- var maxY = - Infinity;
- var maxZ = - Infinity;
-
- for ( var i = 0, l = array.length; i < l; i += 3 ) {
+ applyMatrix4: function ( matrix ) {
- var x = array[ i ];
- var y = array[ i + 1 ];
- var z = array[ i + 2 ];
+ this.center.applyMatrix4( matrix );
+ this.radius = this.radius * matrix.getMaxScaleOnAxis();
- if ( x < minX ) minX = x;
- if ( y < minY ) minY = y;
- if ( z < minZ ) minZ = z;
+ return this;
- if ( x > maxX ) maxX = x;
- if ( y > maxY ) maxY = y;
- if ( z > maxZ ) maxZ = z;
+ },
- }
+ translate: function ( offset ) {
- this.min.set( minX, minY, minZ );
- this.max.set( maxX, maxY, maxZ );
+ this.center.add( offset );
return this;
},
- setFromBufferAttribute: function ( attribute ) {
+ equals: function ( sphere ) {
- var minX = + Infinity;
- var minY = + Infinity;
- var minZ = + Infinity;
+ return sphere.center.equals( this.center ) && ( sphere.radius === this.radius );
- var maxX = - Infinity;
- var maxY = - Infinity;
- var maxZ = - Infinity;
+ }
- for ( var i = 0, l = attribute.count; i < l; i ++ ) {
+ } );
- var x = attribute.getX( i );
- var y = attribute.getY( i );
- var z = attribute.getZ( i );
+ /**
+ * @author bhouston / http://clara.io
+ */
- if ( x < minX ) minX = x;
- if ( y < minY ) minY = y;
- if ( z < minZ ) minZ = z;
+ function Plane( normal, constant ) {
- if ( x > maxX ) maxX = x;
- if ( y > maxY ) maxY = y;
- if ( z > maxZ ) maxZ = z;
+ // normal is assumed to be normalized
- }
+ this.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );
+ this.constant = ( constant !== undefined ) ? constant : 0;
- this.min.set( minX, minY, minZ );
- this.max.set( maxX, maxY, maxZ );
+ }
+
+ Object.assign( Plane.prototype, {
+
+ set: function ( normal, constant ) {
+
+ this.normal.copy( normal );
+ this.constant = constant;
return this;
},
- setFromPoints: function ( points ) {
+ setComponents: function ( x, y, z, w ) {
- this.makeEmpty();
+ this.normal.set( x, y, z );
+ this.constant = w;
- for ( var i = 0, il = points.length; i < il; i ++ ) {
+ return this;
- this.expandByPoint( points[ i ] );
+ },
- }
+ setFromNormalAndCoplanarPoint: function ( normal, point ) {
+
+ this.normal.copy( normal );
+ this.constant = - point.dot( this.normal );
return this;
},
- setFromCenterAndSize: function () {
+ setFromCoplanarPoints: function () {
var v1 = new Vector3();
+ var v2 = new Vector3();
- return function setFromCenterAndSize( center, size ) {
+ return function setFromCoplanarPoints( a, b, c ) {
- var halfSize = v1.copy( size ).multiplyScalar( 0.5 );
+ var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
- this.min.copy( center ).sub( halfSize );
- this.max.copy( center ).add( halfSize );
+ // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+
+ this.setFromNormalAndCoplanarPoint( normal, a );
return this;
@@ -4934,156 +4716,162 @@
}(),
- setFromObject: function ( object ) {
-
- this.makeEmpty();
-
- return this.expandByObject( object );
-
- },
-
clone: function () {
return new this.constructor().copy( this );
},
- copy: function ( box ) {
+ copy: function ( plane ) {
- this.min.copy( box.min );
- this.max.copy( box.max );
+ this.normal.copy( plane.normal );
+ this.constant = plane.constant;
return this;
},
- makeEmpty: function () {
+ normalize: function () {
- this.min.x = this.min.y = this.min.z = + Infinity;
- this.max.x = this.max.y = this.max.z = - Infinity;
+ // Note: will lead to a divide by zero if the plane is invalid.
+
+ var inverseNormalLength = 1.0 / this.normal.length();
+ this.normal.multiplyScalar( inverseNormalLength );
+ this.constant *= inverseNormalLength;
return this;
},
- isEmpty: function () {
+ negate: function () {
- // this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes
+ this.constant *= - 1;
+ this.normal.negate();
- return ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );
+ return this;
},
- getCenter: function ( target ) {
+ distanceToPoint: function ( point ) {
- if ( target === undefined ) {
+ return this.normal.dot( point ) + this.constant;
- console.warn( 'THREE.Box3: .getCenter() target is now required' );
- target = new Vector3();
+ },
- }
+ distanceToSphere: function ( sphere ) {
- return this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );
+ return this.distanceToPoint( sphere.center ) - sphere.radius;
},
- getSize: function ( target ) {
+ projectPoint: function ( point, target ) {
if ( target === undefined ) {
- console.warn( 'THREE.Box3: .getSize() target is now required' );
+ console.warn( 'THREE.Plane: .projectPoint() target is now required' );
target = new Vector3();
}
- return this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );
+ return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
},
- expandByPoint: function ( point ) {
+ intersectLine: function () {
- this.min.min( point );
- this.max.max( point );
+ var v1 = new Vector3();
- return this;
+ return function intersectLine( line, target ) {
- },
+ if ( target === undefined ) {
- expandByVector: function ( vector ) {
+ console.warn( 'THREE.Plane: .intersectLine() target is now required' );
+ target = new Vector3();
- this.min.sub( vector );
- this.max.add( vector );
+ }
- return this;
+ var direction = line.delta( v1 );
- },
+ var denominator = this.normal.dot( direction );
- expandByScalar: function ( scalar ) {
+ if ( denominator === 0 ) {
- this.min.addScalar( - scalar );
- this.max.addScalar( scalar );
+ // line is coplanar, return origin
+ if ( this.distanceToPoint( line.start ) === 0 ) {
- return this;
+ return target.copy( line.start );
- },
+ }
- expandByObject: function () {
+ // Unsure if this is the correct method to handle this case.
+ return undefined;
- // Computes the world-axis-aligned bounding box of an object (including its children),
- // accounting for both the object's, and children's, world transforms
+ }
- var scope, i, l;
+ var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
- var v1 = new Vector3();
+ if ( t < 0 || t > 1 ) {
- function traverse( node ) {
+ return undefined;
- var geometry = node.geometry;
+ }
- if ( geometry !== undefined ) {
+ return target.copy( direction ).multiplyScalar( t ).add( line.start );
- if ( geometry.isGeometry ) {
+ };
- var vertices = geometry.vertices;
+ }(),
- for ( i = 0, l = vertices.length; i < l; i ++ ) {
+ intersectsLine: function ( line ) {
- v1.copy( vertices[ i ] );
- v1.applyMatrix4( node.matrixWorld );
+ // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
- scope.expandByPoint( v1 );
+ var startSign = this.distanceToPoint( line.start );
+ var endSign = this.distanceToPoint( line.end );
- }
+ return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );
- } else if ( geometry.isBufferGeometry ) {
+ },
- var attribute = geometry.attributes.position;
+ intersectsBox: function ( box ) {
- if ( attribute !== undefined ) {
+ return box.intersectsPlane( this );
- for ( i = 0, l = attribute.count; i < l; i ++ ) {
+ },
- v1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );
+ intersectsSphere: function ( sphere ) {
- scope.expandByPoint( v1 );
+ return sphere.intersectsPlane( this );
- }
+ },
- }
+ coplanarPoint: function ( target ) {
- }
+ if ( target === undefined ) {
- }
+ console.warn( 'THREE.Plane: .coplanarPoint() target is now required' );
+ target = new Vector3();
}
- return function expandByObject( object ) {
+ return target.copy( this.normal ).multiplyScalar( - this.constant );
- scope = this;
+ },
- object.updateMatrixWorld( true );
+ applyMatrix4: function () {
- object.traverse( traverse );
+ var v1 = new Vector3();
+ var m1 = new Matrix3();
+
+ return function applyMatrix4( matrix, optionalNormalMatrix ) {
+
+ var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+
+ var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+
+ var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+
+ this.constant = - referencePoint.dot( normal );
return this;
@@ -5091,151 +4879,178 @@
}(),
- containsPoint: function ( point ) {
+ translate: function ( offset ) {
- return point.x < this.min.x || point.x > this.max.x ||
- point.y < this.min.y || point.y > this.max.y ||
- point.z < this.min.z || point.z > this.max.z ? false : true;
+ this.constant -= offset.dot( this.normal );
+
+ return this;
},
- containsBox: function ( box ) {
+ equals: function ( plane ) {
- return this.min.x <= box.min.x && box.max.x <= this.max.x &&
- this.min.y <= box.min.y && box.max.y <= this.max.y &&
- this.min.z <= box.min.z && box.max.z <= this.max.z;
+ return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
+
+ }
+
+ } );
+
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
+ * @author bhouston / http://clara.io
+ */
+
+ function Frustum( p0, p1, p2, p3, p4, p5 ) {
+
+ this.planes = [
+
+ ( p0 !== undefined ) ? p0 : new Plane(),
+ ( p1 !== undefined ) ? p1 : new Plane(),
+ ( p2 !== undefined ) ? p2 : new Plane(),
+ ( p3 !== undefined ) ? p3 : new Plane(),
+ ( p4 !== undefined ) ? p4 : new Plane(),
+ ( p5 !== undefined ) ? p5 : new Plane()
+
+ ];
+
+ }
+
+ Object.assign( Frustum.prototype, {
+
+ set: function ( p0, p1, p2, p3, p4, p5 ) {
+
+ var planes = this.planes;
+
+ planes[ 0 ].copy( p0 );
+ planes[ 1 ].copy( p1 );
+ planes[ 2 ].copy( p2 );
+ planes[ 3 ].copy( p3 );
+ planes[ 4 ].copy( p4 );
+ planes[ 5 ].copy( p5 );
+
+ return this;
},
- getParameter: function ( point, target ) {
+ clone: function () {
- // This can potentially have a divide by zero if the box
- // has a size dimension of 0.
+ return new this.constructor().copy( this );
- if ( target === undefined ) {
+ },
- console.warn( 'THREE.Box3: .getParameter() target is now required' );
- target = new Vector3();
+ copy: function ( frustum ) {
+
+ var planes = this.planes;
+
+ for ( var i = 0; i < 6; i ++ ) {
+
+ planes[ i ].copy( frustum.planes[ i ] );
}
- return target.set(
- ( point.x - this.min.x ) / ( this.max.x - this.min.x ),
- ( point.y - this.min.y ) / ( this.max.y - this.min.y ),
- ( point.z - this.min.z ) / ( this.max.z - this.min.z )
- );
+ return this;
},
- intersectsBox: function ( box ) {
+ setFromMatrix: function ( m ) {
- // using 6 splitting planes to rule out intersections.
- return box.max.x < this.min.x || box.min.x > this.max.x ||
- box.max.y < this.min.y || box.min.y > this.max.y ||
- box.max.z < this.min.z || box.min.z > this.max.z ? false : true;
+ var planes = this.planes;
+ var me = m.elements;
+ var me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
+ var me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
+ var me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
+ var me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
- },
+ planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
+ planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
+ planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
+ planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
+ planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
+ planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
- intersectsSphere: ( function () {
+ return this;
- var closestPoint = new Vector3();
+ },
- return function intersectsSphere( sphere ) {
+ intersectsObject: function () {
- // Find the point on the AABB closest to the sphere center.
- this.clampPoint( sphere.center, closestPoint );
+ var sphere = new Sphere();
- // If that point is inside the sphere, the AABB and sphere intersect.
- return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );
+ return function intersectsObject( object ) {
- };
+ var geometry = object.geometry;
- } )(),
+ if ( geometry.boundingSphere === null )
+ geometry.computeBoundingSphere();
- intersectsPlane: function ( plane ) {
+ sphere.copy( geometry.boundingSphere )
+ .applyMatrix4( object.matrixWorld );
- // We compute the minimum and maximum dot product values. If those values
- // are on the same side (back or front) of the plane, then there is no intersection.
+ return this.intersectsSphere( sphere );
- var min, max;
+ };
- if ( plane.normal.x > 0 ) {
+ }(),
- min = plane.normal.x * this.min.x;
- max = plane.normal.x * this.max.x;
+ intersectsSprite: function () {
- } else {
+ var sphere = new Sphere();
- min = plane.normal.x * this.max.x;
- max = plane.normal.x * this.min.x;
+ return function intersectsSprite( sprite ) {
- }
+ sphere.center.set( 0, 0, 0 );
+ sphere.radius = 0.7071067811865476;
+ sphere.applyMatrix4( sprite.matrixWorld );
- if ( plane.normal.y > 0 ) {
+ return this.intersectsSphere( sphere );
- min += plane.normal.y * this.min.y;
- max += plane.normal.y * this.max.y;
+ };
- } else {
+ }(),
- min += plane.normal.y * this.max.y;
- max += plane.normal.y * this.min.y;
+ intersectsSphere: function ( sphere ) {
- }
+ var planes = this.planes;
+ var center = sphere.center;
+ var negRadius = - sphere.radius;
- if ( plane.normal.z > 0 ) {
+ for ( var i = 0; i < 6; i ++ ) {
- min += plane.normal.z * this.min.z;
- max += plane.normal.z * this.max.z;
+ var distance = planes[ i ].distanceToPoint( center );
- } else {
+ if ( distance < negRadius ) {
- min += plane.normal.z * this.max.z;
- max += plane.normal.z * this.min.z;
+ return false;
+
+ }
}
- return ( min <= - plane.constant && max >= - plane.constant );
+ return true;
},
- intersectsTriangle: ( function () {
-
- // triangle centered vertices
- var v0 = new Vector3();
- var v1 = new Vector3();
- var v2 = new Vector3();
+ intersectsBox: function () {
- // triangle edge vectors
- var f0 = new Vector3();
- var f1 = new Vector3();
- var f2 = new Vector3();
+ var p = new Vector3();
- var testAxis = new Vector3();
+ return function intersectsBox( box ) {
- var center = new Vector3();
- var extents = new Vector3();
+ var planes = this.planes;
- var triangleNormal = new Vector3();
+ for ( var i = 0; i < 6; i ++ ) {
- function satForAxes( axes ) {
+ var plane = planes[ i ];
- var i, j;
+ // corner at max distance
- for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {
+ p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
+ p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
+ p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
- testAxis.fromArray( axes, i );
- // project the aabb onto the seperating axis
- var r = extents.x * Math.abs( testAxis.x ) + extents.y * Math.abs( testAxis.y ) + extents.z * Math.abs( testAxis.z );
- // project all 3 vertices of the triangle onto the seperating axis
- var p0 = v0.dot( testAxis );
- var p1 = v1.dot( testAxis );
- var p2 = v2.dot( testAxis );
- // actual test, basically see if either of the most extreme of the triangle points intersects r
- if ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {
+ if ( plane.distanceToPoint( p ) < 0 ) {
- // points of the projected triangle are outside the projected half-length of the aabb
- // the axis is seperating and we can exit
return false;
}
@@ -5244,161 +5059,183 @@
return true;
- }
+ };
- return function intersectsTriangle( triangle ) {
+ }(),
- if ( this.isEmpty() ) {
+ containsPoint: function ( point ) {
+
+ var planes = this.planes;
+
+ for ( var i = 0; i < 6; i ++ ) {
+
+ if ( planes[ i ].distanceToPoint( point ) < 0 ) {
return false;
}
- // compute box center and extents
- this.getCenter( center );
- extents.subVectors( this.max, center );
+ }
- // translate triangle to aabb origin
- v0.subVectors( triangle.a, center );
- v1.subVectors( triangle.b, center );
- v2.subVectors( triangle.c, center );
+ return true;
- // compute edge vectors for triangle
- f0.subVectors( v1, v0 );
- f1.subVectors( v2, v1 );
- f2.subVectors( v0, v2 );
+ }
- // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb
- // make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation
- // axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)
- var axes = [
- 0, - f0.z, f0.y, 0, - f1.z, f1.y, 0, - f2.z, f2.y,
- f0.z, 0, - f0.x, f1.z, 0, - f1.x, f2.z, 0, - f2.x,
- - f0.y, f0.x, 0, - f1.y, f1.x, 0, - f2.y, f2.x, 0
- ];
- if ( ! satForAxes( axes ) ) {
+ } );
- return false;
+ /**
+ * @author mrdoob / http://mrdoob.com/
+ * @author supereggbert / http://www.paulbrunt.co.uk/
+ * @author philogb / http://blog.thejit.org/
+ * @author jordi_ros / http://plattsoft.com
+ * @author D1plo1d / http://github.com/D1plo1d
+ * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
+ * @author timknip / http://www.floorplanner.com/
+ * @author bhouston / http://clara.io
+ * @author WestLangley / http://github.com/WestLangley
+ */
- }
+ function Matrix4() {
- // test 3 face normals from the aabb
- axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];
- if ( ! satForAxes( axes ) ) {
+ this.elements = [
- return false;
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
- }
+ ];
- // finally testing the face normal of the triangle
- // use already existing triangle edge vectors here
- triangleNormal.crossVectors( f0, f1 );
- axes = [ triangleNormal.x, triangleNormal.y, triangleNormal.z ];
- return satForAxes( axes );
+ if ( arguments.length > 0 ) {
- };
+ console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
- } )(),
+ }
- clampPoint: function ( point, target ) {
+ }
- if ( target === undefined ) {
+ Object.assign( Matrix4.prototype, {
- console.warn( 'THREE.Box3: .clampPoint() target is now required' );
- target = new Vector3();
+ isMatrix4: true,
- }
+ set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
- return target.copy( point ).clamp( this.min, this.max );
+ var te = this.elements;
+
+ te[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;
+ te[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;
+ te[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;
+ te[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;
+
+ return this;
},
- distanceToPoint: function () {
+ identity: function () {
- var v1 = new Vector3();
+ this.set(
- return function distanceToPoint( point ) {
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
- var clampedPoint = v1.copy( point ).clamp( this.min, this.max );
- return clampedPoint.sub( point ).length();
+ );
- };
+ return this;
- }(),
+ },
- getBoundingSphere: function () {
+ clone: function () {
- var v1 = new Vector3();
+ return new Matrix4().fromArray( this.elements );
- return function getBoundingSphere( target ) {
+ },
- if ( target === undefined ) {
+ copy: function ( m ) {
- console.warn( 'THREE.Box3: .getBoundingSphere() target is now required' );
- target = new Sphere();
+ var te = this.elements;
+ var me = m.elements;
- }
+ te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];
+ te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];
+ te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];
+ te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];
- this.getCenter( target.center );
+ return this;
- target.radius = this.getSize( v1 ).length() * 0.5;
+ },
- return target;
+ copyPosition: function ( m ) {
- };
+ var te = this.elements, me = m.elements;
- }(),
+ te[ 12 ] = me[ 12 ];
+ te[ 13 ] = me[ 13 ];
+ te[ 14 ] = me[ 14 ];
- intersect: function ( box ) {
+ return this;
- this.min.max( box.min );
- this.max.min( box.max );
+ },
- // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.
- if ( this.isEmpty() ) this.makeEmpty();
+ extractBasis: function ( xAxis, yAxis, zAxis ) {
+
+ xAxis.setFromMatrixColumn( this, 0 );
+ yAxis.setFromMatrixColumn( this, 1 );
+ zAxis.setFromMatrixColumn( this, 2 );
return this;
},
- union: function ( box ) {
+ makeBasis: function ( xAxis, yAxis, zAxis ) {
- this.min.min( box.min );
- this.max.max( box.max );
+ this.set(
+ xAxis.x, yAxis.x, zAxis.x, 0,
+ xAxis.y, yAxis.y, zAxis.y, 0,
+ xAxis.z, yAxis.z, zAxis.z, 0,
+ 0, 0, 0, 1
+ );
return this;
},
- applyMatrix4: function () {
+ extractRotation: function () {
- var points = [
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3(),
- new Vector3()
- ];
+ var v1 = new Vector3();
- return function applyMatrix4( matrix ) {
+ return function extractRotation( m ) {
- // transform of empty box is an empty box.
- if ( this.isEmpty() ) return this;
+ // this method does not support reflection matrices
- // NOTE: I am using a binary pattern to specify all 2^3 combinations below
- points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000
- points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001
- points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010
- points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011
- points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100
- points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101
- points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110
- points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111
+ var te = this.elements;
+ var me = m.elements;
- this.setFromPoints( points );
+ var scaleX = 1 / v1.setFromMatrixColumn( m, 0 ).length();
+ var scaleY = 1 / v1.setFromMatrixColumn( m, 1 ).length();
+ var scaleZ = 1 / v1.setFromMatrixColumn( m, 2 ).length();
+
+ te[ 0 ] = me[ 0 ] * scaleX;
+ te[ 1 ] = me[ 1 ] * scaleX;
+ te[ 2 ] = me[ 2 ] * scaleX;
+ te[ 3 ] = 0;
+
+ te[ 4 ] = me[ 4 ] * scaleY;
+ te[ 5 ] = me[ 5 ] * scaleY;
+ te[ 6 ] = me[ 6 ] * scaleY;
+ te[ 7 ] = 0;
+
+ te[ 8 ] = me[ 8 ] * scaleZ;
+ te[ 9 ] = me[ 9 ] * scaleZ;
+ te[ 10 ] = me[ 10 ] * scaleZ;
+ te[ 11 ] = 0;
+
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
return this;
@@ -5406,621 +5243,775 @@
}(),
- translate: function ( offset ) {
+ makeRotationFromEuler: function ( euler ) {
- this.min.add( offset );
- this.max.add( offset );
+ if ( ! ( euler && euler.isEuler ) ) {
- return this;
+ console.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );
- },
+ }
- equals: function ( box ) {
+ var te = this.elements;
- return box.min.equals( this.min ) && box.max.equals( this.max );
+ var x = euler.x, y = euler.y, z = euler.z;
+ var a = Math.cos( x ), b = Math.sin( x );
+ var c = Math.cos( y ), d = Math.sin( y );
+ var e = Math.cos( z ), f = Math.sin( z );
- }
+ if ( euler.order === 'XYZ' ) {
- } );
+ var ae = a * e, af = a * f, be = b * e, bf = b * f;
- /**
- * @author bhouston / http://clara.io
- * @author mrdoob / http://mrdoob.com/
- */
+ te[ 0 ] = c * e;
+ te[ 4 ] = - c * f;
+ te[ 8 ] = d;
- function Sphere( center, radius ) {
+ te[ 1 ] = af + be * d;
+ te[ 5 ] = ae - bf * d;
+ te[ 9 ] = - b * c;
- this.center = ( center !== undefined ) ? center : new Vector3();
- this.radius = ( radius !== undefined ) ? radius : 0;
+ te[ 2 ] = bf - ae * d;
+ te[ 6 ] = be + af * d;
+ te[ 10 ] = a * c;
- }
+ } else if ( euler.order === 'YXZ' ) {
- Object.assign( Sphere.prototype, {
+ var ce = c * e, cf = c * f, de = d * e, df = d * f;
- set: function ( center, radius ) {
+ te[ 0 ] = ce + df * b;
+ te[ 4 ] = de * b - cf;
+ te[ 8 ] = a * d;
- this.center.copy( center );
- this.radius = radius;
+ te[ 1 ] = a * f;
+ te[ 5 ] = a * e;
+ te[ 9 ] = - b;
- return this;
+ te[ 2 ] = cf * b - de;
+ te[ 6 ] = df + ce * b;
+ te[ 10 ] = a * c;
- },
+ } else if ( euler.order === 'ZXY' ) {
- setFromPoints: function () {
+ var ce = c * e, cf = c * f, de = d * e, df = d * f;
- var box = new Box3();
+ te[ 0 ] = ce - df * b;
+ te[ 4 ] = - a * f;
+ te[ 8 ] = de + cf * b;
- return function setFromPoints( points, optionalCenter ) {
+ te[ 1 ] = cf + de * b;
+ te[ 5 ] = a * e;
+ te[ 9 ] = df - ce * b;
- var center = this.center;
+ te[ 2 ] = - a * d;
+ te[ 6 ] = b;
+ te[ 10 ] = a * c;
- if ( optionalCenter !== undefined ) {
+ } else if ( euler.order === 'ZYX' ) {
- center.copy( optionalCenter );
+ var ae = a * e, af = a * f, be = b * e, bf = b * f;
- } else {
+ te[ 0 ] = c * e;
+ te[ 4 ] = be * d - af;
+ te[ 8 ] = ae * d + bf;
- box.setFromPoints( points ).getCenter( center );
+ te[ 1 ] = c * f;
+ te[ 5 ] = bf * d + ae;
+ te[ 9 ] = af * d - be;
- }
+ te[ 2 ] = - d;
+ te[ 6 ] = b * c;
+ te[ 10 ] = a * c;
- var maxRadiusSq = 0;
+ } else if ( euler.order === 'YZX' ) {
- for ( var i = 0, il = points.length; i < il; i ++ ) {
+ var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
- maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );
+ te[ 0 ] = c * e;
+ te[ 4 ] = bd - ac * f;
+ te[ 8 ] = bc * f + ad;
- }
+ te[ 1 ] = f;
+ te[ 5 ] = a * e;
+ te[ 9 ] = - b * e;
- this.radius = Math.sqrt( maxRadiusSq );
+ te[ 2 ] = - d * e;
+ te[ 6 ] = ad * f + bc;
+ te[ 10 ] = ac - bd * f;
- return this;
+ } else if ( euler.order === 'XZY' ) {
- };
+ var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
- }(),
+ te[ 0 ] = c * e;
+ te[ 4 ] = - f;
+ te[ 8 ] = d * e;
- clone: function () {
+ te[ 1 ] = ac * f + bd;
+ te[ 5 ] = a * e;
+ te[ 9 ] = ad * f - bc;
- return new this.constructor().copy( this );
+ te[ 2 ] = bc * f - ad;
+ te[ 6 ] = b * e;
+ te[ 10 ] = bd * f + ac;
- },
+ }
- copy: function ( sphere ) {
+ // bottom row
+ te[ 3 ] = 0;
+ te[ 7 ] = 0;
+ te[ 11 ] = 0;
- this.center.copy( sphere.center );
- this.radius = sphere.radius;
+ // last column
+ te[ 12 ] = 0;
+ te[ 13 ] = 0;
+ te[ 14 ] = 0;
+ te[ 15 ] = 1;
return this;
},
- empty: function () {
+ makeRotationFromQuaternion: function () {
- return ( this.radius <= 0 );
+ var zero = new Vector3( 0, 0, 0 );
+ var one = new Vector3( 1, 1, 1 );
- },
+ return function makeRotationFromQuaternion( q ) {
- containsPoint: function ( point ) {
+ return this.compose( zero, q, one );
- return ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );
+ };
- },
+ }(),
- distanceToPoint: function ( point ) {
+ lookAt: function () {
- return ( point.distanceTo( this.center ) - this.radius );
+ var x = new Vector3();
+ var y = new Vector3();
+ var z = new Vector3();
- },
+ return function lookAt( eye, target, up ) {
- intersectsSphere: function ( sphere ) {
+ var te = this.elements;
- var radiusSum = this.radius + sphere.radius;
+ z.subVectors( eye, target );
- return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );
+ if ( z.lengthSq() === 0 ) {
- },
+ // eye and target are in the same position
- intersectsBox: function ( box ) {
+ z.z = 1;
- return box.intersectsSphere( this );
+ }
- },
+ z.normalize();
+ x.crossVectors( up, z );
- intersectsPlane: function ( plane ) {
+ if ( x.lengthSq() === 0 ) {
- return Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;
+ // up and z are parallel
- },
+ if ( Math.abs( up.z ) === 1 ) {
- clampPoint: function ( point, target ) {
+ z.x += 0.0001;
- var deltaLengthSq = this.center.distanceToSquared( point );
+ } else {
- if ( target === undefined ) {
+ z.z += 0.0001;
- console.warn( 'THREE.Sphere: .clampPoint() target is now required' );
- target = new Vector3();
+ }
- }
+ z.normalize();
+ x.crossVectors( up, z );
- target.copy( point );
+ }
- if ( deltaLengthSq > ( this.radius * this.radius ) ) {
+ x.normalize();
+ y.crossVectors( z, x );
- target.sub( this.center ).normalize();
- target.multiplyScalar( this.radius ).add( this.center );
+ te[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;
+ te[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;
+ te[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;
- }
+ return this;
- return target;
+ };
- },
+ }(),
- getBoundingBox: function ( target ) {
+ multiply: function ( m, n ) {
- if ( target === undefined ) {
+ if ( n !== undefined ) {
- console.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );
- target = new Box3();
+ console.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );
+ return this.multiplyMatrices( m, n );
}
- target.set( this.center, this.center );
- target.expandByScalar( this.radius );
-
- return target;
-
- },
-
- applyMatrix4: function ( matrix ) {
-
- this.center.applyMatrix4( matrix );
- this.radius = this.radius * matrix.getMaxScaleOnAxis();
-
- return this;
+ return this.multiplyMatrices( this, m );
},
- translate: function ( offset ) {
-
- this.center.add( offset );
+ premultiply: function ( m ) {
- return this;
+ return this.multiplyMatrices( m, this );
},
- equals: function ( sphere ) {
-
- return sphere.center.equals( this.center ) && ( sphere.radius === this.radius );
-
- }
-
- } );
-
- /**
- * @author bhouston / http://clara.io
- */
+ multiplyMatrices: function ( a, b ) {
- function Plane( normal, constant ) {
+ var ae = a.elements;
+ var be = b.elements;
+ var te = this.elements;
- // normal is assumed to be normalized
+ var a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];
+ var a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];
+ var a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];
+ var a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];
- this.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );
- this.constant = ( constant !== undefined ) ? constant : 0;
+ var b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];
+ var b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];
+ var b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];
+ var b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];
- }
+ te[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
+ te[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
+ te[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
+ te[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
- Object.assign( Plane.prototype, {
+ te[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
+ te[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
+ te[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
+ te[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
- set: function ( normal, constant ) {
+ te[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
+ te[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
+ te[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
+ te[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
- this.normal.copy( normal );
- this.constant = constant;
+ te[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
+ te[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
+ te[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
+ te[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
return this;
},
- setComponents: function ( x, y, z, w ) {
-
- this.normal.set( x, y, z );
- this.constant = w;
-
- return this;
-
- },
+ multiplyScalar: function ( s ) {
- setFromNormalAndCoplanarPoint: function ( normal, point ) {
+ var te = this.elements;
- this.normal.copy( normal );
- this.constant = - point.dot( this.normal );
+ te[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;
+ te[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;
+ te[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;
+ te[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;
return this;
},
- setFromCoplanarPoints: function () {
+ applyToBufferAttribute: function () {
var v1 = new Vector3();
- var v2 = new Vector3();
- return function setFromCoplanarPoints( a, b, c ) {
+ return function applyToBufferAttribute( attribute ) {
- var normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();
+ for ( var i = 0, l = attribute.count; i < l; i ++ ) {
- // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?
+ v1.x = attribute.getX( i );
+ v1.y = attribute.getY( i );
+ v1.z = attribute.getZ( i );
- this.setFromNormalAndCoplanarPoint( normal, a );
+ v1.applyMatrix4( this );
- return this;
+ attribute.setXYZ( i, v1.x, v1.y, v1.z );
+
+ }
+
+ return attribute;
};
}(),
- clone: function () {
+ determinant: function () {
- return new this.constructor().copy( this );
+ var te = this.elements;
- },
+ var n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];
+ var n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];
+ var n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];
+ var n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];
- copy: function ( plane ) {
+ //TODO: make this more efficient
+ //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
- this.normal.copy( plane.normal );
- this.constant = plane.constant;
+ return (
+ n41 * (
+ + n14 * n23 * n32
+ - n13 * n24 * n32
+ - n14 * n22 * n33
+ + n12 * n24 * n33
+ + n13 * n22 * n34
+ - n12 * n23 * n34
+ ) +
+ n42 * (
+ + n11 * n23 * n34
+ - n11 * n24 * n33
+ + n14 * n21 * n33
+ - n13 * n21 * n34
+ + n13 * n24 * n31
+ - n14 * n23 * n31
+ ) +
+ n43 * (
+ + n11 * n24 * n32
+ - n11 * n22 * n34
+ - n14 * n21 * n32
+ + n12 * n21 * n34
+ + n14 * n22 * n31
+ - n12 * n24 * n31
+ ) +
+ n44 * (
+ - n13 * n22 * n31
+ - n11 * n23 * n32
+ + n11 * n22 * n33
+ + n13 * n21 * n32
+ - n12 * n21 * n33
+ + n12 * n23 * n31
+ )
- return this;
+ );
},
- normalize: function () {
-
- // Note: will lead to a divide by zero if the plane is invalid.
-
- var inverseNormalLength = 1.0 / this.normal.length();
- this.normal.multiplyScalar( inverseNormalLength );
- this.constant *= inverseNormalLength;
-
- return this;
+ transpose: function () {
- },
+ var te = this.elements;
+ var tmp;
- negate: function () {
+ tmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;
+ tmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;
+ tmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;
- this.constant *= - 1;
- this.normal.negate();
+ tmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;
+ tmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;
+ tmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;
return this;
},
- distanceToPoint: function ( point ) {
-
- return this.normal.dot( point ) + this.constant;
+ setPosition: function ( v ) {
- },
+ var te = this.elements;
- distanceToSphere: function ( sphere ) {
+ te[ 12 ] = v.x;
+ te[ 13 ] = v.y;
+ te[ 14 ] = v.z;
- return this.distanceToPoint( sphere.center ) - sphere.radius;
+ return this;
},
- projectPoint: function ( point, target ) {
+ getInverse: function ( m, throwOnDegenerate ) {
- if ( target === undefined ) {
+ // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
+ var te = this.elements,
+ me = m.elements,
- console.warn( 'THREE.Plane: .projectPoint() target is now required' );
- target = new Vector3();
+ n11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],
+ n12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],
+ n13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],
+ n14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],
- }
+ t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
+ t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
+ t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
+ t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
- return target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );
+ var det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
- },
+ if ( det === 0 ) {
- intersectLine: function () {
+ var msg = "THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";
- var v1 = new Vector3();
+ if ( throwOnDegenerate === true ) {
- return function intersectLine( line, target ) {
+ throw new Error( msg );
- if ( target === undefined ) {
+ } else {
- console.warn( 'THREE.Plane: .intersectLine() target is now required' );
- target = new Vector3();
+ console.warn( msg );
}
- var direction = line.delta( v1 );
-
- var denominator = this.normal.dot( direction );
+ return this.identity();
- if ( denominator === 0 ) {
+ }
- // line is coplanar, return origin
- if ( this.distanceToPoint( line.start ) === 0 ) {
+ var detInv = 1 / det;
- return target.copy( line.start );
+ te[ 0 ] = t11 * detInv;
+ te[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;
+ te[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;
+ te[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;
- }
+ te[ 4 ] = t12 * detInv;
+ te[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;
+ te[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;
+ te[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;
- // Unsure if this is the correct method to handle this case.
- return undefined;
+ te[ 8 ] = t13 * detInv;
+ te[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;
+ te[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;
+ te[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;
- }
+ te[ 12 ] = t14 * detInv;
+ te[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;
+ te[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;
+ te[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;
- var t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;
+ return this;
- if ( t < 0 || t > 1 ) {
+ },
- return undefined;
+ scale: function ( v ) {
- }
+ var te = this.elements;
+ var x = v.x, y = v.y, z = v.z;
- return target.copy( direction ).multiplyScalar( t ).add( line.start );
+ te[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;
+ te[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;
+ te[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;
+ te[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;
- };
+ return this;
- }(),
+ },
- intersectsLine: function ( line ) {
+ getMaxScaleOnAxis: function () {
- // Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.
+ var te = this.elements;
- var startSign = this.distanceToPoint( line.start );
- var endSign = this.distanceToPoint( line.end );
+ var scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];
+ var scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];
+ var scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];
- return ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );
+ return Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );
},
- intersectsBox: function ( box ) {
+ makeTranslation: function ( x, y, z ) {
- return box.intersectsPlane( this );
+ this.set(
- },
+ 1, 0, 0, x,
+ 0, 1, 0, y,
+ 0, 0, 1, z,
+ 0, 0, 0, 1
- intersectsSphere: function ( sphere ) {
+ );
- return sphere.intersectsPlane( this );
+ return this;
},
- coplanarPoint: function ( target ) {
+ makeRotationX: function ( theta ) {
- if ( target === undefined ) {
+ var c = Math.cos( theta ), s = Math.sin( theta );
- console.warn( 'THREE.Plane: .coplanarPoint() target is now required' );
- target = new Vector3();
+ this.set(
- }
+ 1, 0, 0, 0,
+ 0, c, - s, 0,
+ 0, s, c, 0,
+ 0, 0, 0, 1
- return target.copy( this.normal ).multiplyScalar( - this.constant );
+ );
+
+ return this;
},
- applyMatrix4: function () {
+ makeRotationY: function ( theta ) {
- var v1 = new Vector3();
- var m1 = new Matrix3();
+ var c = Math.cos( theta ), s = Math.sin( theta );
- return function applyMatrix4( matrix, optionalNormalMatrix ) {
+ this.set(
- var normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );
+ c, 0, s, 0,
+ 0, 1, 0, 0,
+ - s, 0, c, 0,
+ 0, 0, 0, 1
- var referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );
+ );
- var normal = this.normal.applyMatrix3( normalMatrix ).normalize();
+ return this;
- this.constant = - referencePoint.dot( normal );
+ },
- return this;
+ makeRotationZ: function ( theta ) {
- };
+ var c = Math.cos( theta ), s = Math.sin( theta );
- }(),
+ this.set(
- translate: function ( offset ) {
+ c, - s, 0, 0,
+ s, c, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1
- this.constant -= offset.dot( this.normal );
+ );
return this;
},
- equals: function ( plane ) {
-
- return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
-
- }
+ makeRotationAxis: function ( axis, angle ) {
- } );
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
- /**
- * @author mrdoob / http://mrdoob.com/
- * @author alteredq / http://alteredqualia.com/
- * @author bhouston / http://clara.io
- */
+ var c = Math.cos( angle );
+ var s = Math.sin( angle );
+ var t = 1 - c;
+ var x = axis.x, y = axis.y, z = axis.z;
+ var tx = t * x, ty = t * y;
- function Frustum( p0, p1, p2, p3, p4, p5 ) {
+ this.set(
- this.planes = [
+ tx * x + c, tx * y - s * z, tx * z + s * y, 0,
+ tx * y + s * z, ty * y + c, ty * z - s * x, 0,
+ tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
+ 0, 0, 0, 1
- ( p0 !== undefined ) ? p0 : new Plane(),
- ( p1 !== undefined ) ? p1 : new Plane(),
- ( p2 !== undefined ) ? p2 : new Plane(),
- ( p3 !== undefined ) ? p3 : new Plane(),
- ( p4 !== undefined ) ? p4 : new Plane(),
- ( p5 !== undefined ) ? p5 : new Plane()
+ );
- ];
+ return this;
- }
+ },
- Object.assign( Frustum.prototype, {
+ makeScale: function ( x, y, z ) {
- set: function ( p0, p1, p2, p3, p4, p5 ) {
+ this.set(
- var planes = this.planes;
+ x, 0, 0, 0,
+ 0, y, 0, 0,
+ 0, 0, z, 0,
+ 0, 0, 0, 1
- planes[ 0 ].copy( p0 );
- planes[ 1 ].copy( p1 );
- planes[ 2 ].copy( p2 );
- planes[ 3 ].copy( p3 );
- planes[ 4 ].copy( p4 );
- planes[ 5 ].copy( p5 );
+ );
return this;
},
- clone: function () {
+ makeShear: function ( x, y, z ) {
- return new this.constructor().copy( this );
+ this.set(
- },
+ 1, y, z, 0,
+ x, 1, z, 0,
+ x, y, 1, 0,
+ 0, 0, 0, 1
- copy: function ( frustum ) {
+ );
- var planes = this.planes;
+ return this;
- for ( var i = 0; i < 6; i ++ ) {
+ },
- planes[ i ].copy( frustum.planes[ i ] );
+ compose: function ( position, quaternion, scale ) {
- }
+ var te = this.elements;
- return this;
+ var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
+ var x2 = x + x, y2 = y + y, z2 = z + z;
+ var xx = x * x2, xy = x * y2, xz = x * z2;
+ var yy = y * y2, yz = y * z2, zz = z * z2;
+ var wx = w * x2, wy = w * y2, wz = w * z2;
- },
+ var sx = scale.x, sy = scale.y, sz = scale.z;
- setFromMatrix: function ( m ) {
+ te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;
+ te[ 1 ] = ( xy + wz ) * sx;
+ te[ 2 ] = ( xz - wy ) * sx;
+ te[ 3 ] = 0;
- var planes = this.planes;
- var me = m.elements;
- var me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];
- var me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];
- var me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];
- var me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];
+ te[ 4 ] = ( xy - wz ) * sy;
+ te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;
+ te[ 6 ] = ( yz + wx ) * sy;
+ te[ 7 ] = 0;
- planes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();
- planes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();
- planes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();
- planes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();
- planes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();
- planes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();
+ te[ 8 ] = ( xz + wy ) * sz;
+ te[ 9 ] = ( yz - wx ) * sz;
+ te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;
+ te[ 11 ] = 0;
- return this;
+ te[ 12 ] = position.x;
+ te[ 13 ] = position.y;
+ te[ 14 ] = position.z;
+ te[ 15 ] = 1;
+
+ return this;
},
- intersectsObject: function () {
+ decompose: function () {
- var sphere = new Sphere();
+ var vector = new Vector3();
+ var matrix = new Matrix4();
- return function intersectsObject( object ) {
+ return function decompose( position, quaternion, scale ) {
- var geometry = object.geometry;
+ var te = this.elements;
- if ( geometry.boundingSphere === null )
- geometry.computeBoundingSphere();
+ var sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();
+ var sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();
+ var sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();
- sphere.copy( geometry.boundingSphere )
- .applyMatrix4( object.matrixWorld );
+ // if determine is negative, we need to invert one scale
+ var det = this.determinant();
+ if ( det < 0 ) sx = - sx;
- return this.intersectsSphere( sphere );
+ position.x = te[ 12 ];
+ position.y = te[ 13 ];
+ position.z = te[ 14 ];
- };
+ // scale the rotation part
+ matrix.copy( this );
- }(),
+ var invSX = 1 / sx;
+ var invSY = 1 / sy;
+ var invSZ = 1 / sz;
- intersectsSprite: function () {
+ matrix.elements[ 0 ] *= invSX;
+ matrix.elements[ 1 ] *= invSX;
+ matrix.elements[ 2 ] *= invSX;
- var sphere = new Sphere();
+ matrix.elements[ 4 ] *= invSY;
+ matrix.elements[ 5 ] *= invSY;
+ matrix.elements[ 6 ] *= invSY;
- return function intersectsSprite( sprite ) {
+ matrix.elements[ 8 ] *= invSZ;
+ matrix.elements[ 9 ] *= invSZ;
+ matrix.elements[ 10 ] *= invSZ;
- sphere.center.set( 0, 0, 0 );
- sphere.radius = 0.7071067811865476;
- sphere.applyMatrix4( sprite.matrixWorld );
+ quaternion.setFromRotationMatrix( matrix );
- return this.intersectsSphere( sphere );
+ scale.x = sx;
+ scale.y = sy;
+ scale.z = sz;
+
+ return this;
};
}(),
- intersectsSphere: function ( sphere ) {
-
- var planes = this.planes;
- var center = sphere.center;
- var negRadius = - sphere.radius;
+ makePerspective: function ( left, right, top, bottom, near, far ) {
- for ( var i = 0; i < 6; i ++ ) {
+ if ( far === undefined ) {
- var distance = planes[ i ].distanceToPoint( center );
+ console.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );
- if ( distance < negRadius ) {
+ }
- return false;
+ var te = this.elements;
+ var x = 2 * near / ( right - left );
+ var y = 2 * near / ( top - bottom );
- }
+ var a = ( right + left ) / ( right - left );
+ var b = ( top + bottom ) / ( top - bottom );
+ var c = - ( far + near ) / ( far - near );
+ var d = - 2 * far * near / ( far - near );
- }
+ te[ 0 ] = x; te[ 4 ] = 0; te[ 8 ] = a; te[ 12 ] = 0;
+ te[ 1 ] = 0; te[ 5 ] = y; te[ 9 ] = b; te[ 13 ] = 0;
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = c; te[ 14 ] = d;
+ te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = - 1; te[ 15 ] = 0;
- return true;
+ return this;
},
- intersectsBox: function () {
+ makeOrthographic: function ( left, right, top, bottom, near, far ) {
- var p = new Vector3();
+ var te = this.elements;
+ var w = 1.0 / ( right - left );
+ var h = 1.0 / ( top - bottom );
+ var p = 1.0 / ( far - near );
- return function intersectsBox( box ) {
+ var x = ( right + left ) * w;
+ var y = ( top + bottom ) * h;
+ var z = ( far + near ) * p;
- var planes = this.planes;
+ te[ 0 ] = 2 * w; te[ 4 ] = 0; te[ 8 ] = 0; te[ 12 ] = - x;
+ te[ 1 ] = 0; te[ 5 ] = 2 * h; te[ 9 ] = 0; te[ 13 ] = - y;
+ te[ 2 ] = 0; te[ 6 ] = 0; te[ 10 ] = - 2 * p; te[ 14 ] = - z;
+ te[ 3 ] = 0; te[ 7 ] = 0; te[ 11 ] = 0; te[ 15 ] = 1;
- for ( var i = 0; i < 6; i ++ ) {
+ return this;
- var plane = planes[ i ];
+ },
- // corner at max distance
+ equals: function ( matrix ) {
- p.x = plane.normal.x > 0 ? box.max.x : box.min.x;
- p.y = plane.normal.y > 0 ? box.max.y : box.min.y;
- p.z = plane.normal.z > 0 ? box.max.z : box.min.z;
+ var te = this.elements;
+ var me = matrix.elements;
- if ( plane.distanceToPoint( p ) < 0 ) {
+ for ( var i = 0; i < 16; i ++ ) {
- return false;
+ if ( te[ i ] !== me[ i ] ) return false;
- }
+ }
- }
+ return true;
- return true;
+ },
- };
+ fromArray: function ( array, offset ) {
- }(),
+ if ( offset === undefined ) offset = 0;
- containsPoint: function ( point ) {
+ for ( var i = 0; i < 16; i ++ ) {
- var planes = this.planes;
+ this.elements[ i ] = array[ i + offset ];
- for ( var i = 0; i < 6; i ++ ) {
+ }
- if ( planes[ i ].distanceToPoint( point ) < 0 ) {
+ return this;
- return false;
+ },
- }
+ toArray: function ( array, offset ) {
- }
+ if ( array === undefined ) array = [];
+ if ( offset === undefined ) offset = 0;
- return true;
+ var te = this.elements;
+
+ array[ offset ] = te[ 0 ];
+ array[ offset + 1 ] = te[ 1 ];
+ array[ offset + 2 ] = te[ 2 ];
+ array[ offset + 3 ] = te[ 3 ];
+
+ array[ offset + 4 ] = te[ 4 ];
+ array[ offset + 5 ] = te[ 5 ];
+ array[ offset + 6 ] = te[ 6 ];
+ array[ offset + 7 ] = te[ 7 ];
+
+ array[ offset + 8 ] = te[ 8 ];
+ array[ offset + 9 ] = te[ 9 ];
+ array[ offset + 10 ] = te[ 10 ];
+ array[ offset + 11 ] = te[ 11 ];
+
+ array[ offset + 12 ] = te[ 12 ];
+ array[ offset + 13 ] = te[ 13 ];
+ array[ offset + 14 ] = te[ 14 ];
+ array[ offset + 15 ] = te[ 15 ];
+
+ return array;
}
@@ -11780,35 +11771,59 @@
computeBoundingBox: function () {
- if ( this.boundingBox === null ) {
+ var box = new Box3();
- this.boundingBox = new Box3();
+ return function computeBoundingBox() {
- }
+ if ( this.boundingBox === null ) {
- var position = this.attributes.position;
+ this.boundingBox = new Box3();
- if ( position !== undefined ) {
+ }
+
+ var position = this.attributes.position;
+ var morphAttributesPosition = this.morphAttributes.position;
- this.boundingBox.setFromBufferAttribute( position );
+ if ( position !== undefined ) {
- } else {
+ this.boundingBox.setFromBufferAttribute( position );
- this.boundingBox.makeEmpty();
+ // process morph attributes if present
- }
+ if ( morphAttributesPosition ) {
- if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
- console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
+ var morphAttribute = morphAttributesPosition[ i ];
+ box.setFromBufferAttribute( morphAttribute );
- }
+ this.boundingBox.expandByPoint( box.min );
+ this.boundingBox.expandByPoint( box.max );
- },
+ }
+
+ }
+
+ } else {
+
+ this.boundingBox.makeEmpty();
+
+ }
+
+ if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {
+
+ console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this );
+
+ }
+
+ };
+
+ }(),
computeBoundingSphere: function () {
var box = new Box3();
+ var boxMorphTargets = new Box3();
var vector = new Vector3();
return function computeBoundingSphere() {
@@ -11820,28 +11835,67 @@
}
var position = this.attributes.position;
+ var morphAttributesPosition = this.morphAttributes.position;
if ( position ) {
+ // first, find the center of the bounding sphere
+
var center = this.boundingSphere.center;
box.setFromBufferAttribute( position );
+
+ // process morph attributes if present
+
+ if ( morphAttributesPosition ) {
+
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+
+ var morphAttribute = morphAttributesPosition[ i ];
+ boxMorphTargets.setFromBufferAttribute( morphAttribute );
+
+ box.expandByPoint( boxMorphTargets.min );
+ box.expandByPoint( boxMorphTargets.max );
+
+ }
+
+ }
+
box.getCenter( center );
- // hoping to find a boundingSphere with a radius smaller than the
+ // second, try to find a boundingSphere with a radius smaller than the
// boundingSphere of the boundingBox: sqrt(3) smaller in the best case
var maxRadiusSq = 0;
for ( var i = 0, il = position.count; i < il; i ++ ) {
- vector.x = position.getX( i );
- vector.y = position.getY( i );
- vector.z = position.getZ( i );
+ vector.fromBufferAttribute( position, i );
+
maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
}
+ // process morph attributes if present
+
+ if ( morphAttributesPosition ) {
+
+ for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {
+
+ var morphAttribute = morphAttributesPosition[ i ];
+
+ for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) {
+
+ vector.fromBufferAttribute( morphAttribute, i );
+
+ maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );
+
+ }
+
+ }
+
+ }
+
this.boundingSphere.radius = Math.sqrt( maxRadiusSq );
if ( isNaN( this.boundingSphere.radius ) ) {
@@ -14406,6 +14460,10 @@
var tempB = new Vector3();
var tempC = new Vector3();
+ var morphA = new Vector3();
+ var morphB = new Vector3();
+ var morphC = new Vector3();
+
var uvA = new Vector2();
var uvB = new Vector2();
var uvC = new Vector2();
@@ -14444,12 +14502,43 @@
}
- function checkBufferGeometryIntersection( object, material, raycaster, ray, position, uv, a, b, c ) {
+ function checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, uv, a, b, c ) {
vA.fromBufferAttribute( position, a );
vB.fromBufferAttribute( position, b );
vC.fromBufferAttribute( position, c );
+ var morphInfluences = object.morphTargetInfluences;
+
+ if ( material.morphTargets && morphPosition && morphInfluences ) {
+
+ morphA.set( 0, 0, 0 );
+ morphB.set( 0, 0, 0 );
+ morphC.set( 0, 0, 0 );
+
+ for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
+
+ var influence = morphInfluences[ i ];
+ var morphAttribute = morphPosition[ i ];
+
+ if ( influence === 0 ) continue;
+
+ tempA.fromBufferAttribute( morphAttribute, a );
+ tempB.fromBufferAttribute( morphAttribute, b );
+ tempC.fromBufferAttribute( morphAttribute, c );
+
+ morphA.addScaledVector( tempA.sub( vA ), influence );
+ morphB.addScaledVector( tempB.sub( vB ), influence );
+ morphC.addScaledVector( tempC.sub( vC ), influence );
+
+ }
+
+ vA.add( morphA );
+ vB.add( morphB );
+ vC.add( morphC );
+
+ }
+
var intersection = checkIntersection( object, material, raycaster, ray, vA, vB, vC, intersectionPoint );
if ( intersection ) {
@@ -14512,6 +14601,7 @@
var a, b, c;
var index = geometry.index;
var position = geometry.attributes.position;
+ var morphPosition = geometry.morphAttributes.position;
var uv = geometry.attributes.uv;
var groups = geometry.groups;
var drawRange = geometry.drawRange;
@@ -14539,7 +14629,7 @@
b = index.getX( j + 1 );
c = index.getX( j + 2 );
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, uv, a, b, c );
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, morphPosition, uv, a, b, c );
if ( intersection ) {
@@ -14564,7 +14654,7 @@
b = index.getX( i + 1 );
c = index.getX( i + 2 );
- intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, uv, a, b, c );
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, morphPosition, uv, a, b, c );
if ( intersection ) {
@@ -14597,7 +14687,7 @@
b = j + 1;
c = j + 2;
- intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, uv, a, b, c );
+ intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, morphPosition, uv, a, b, c );
if ( intersection ) {
@@ -14622,7 +14712,7 @@
b = i + 1;
c = i + 2;
- intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, uv, a, b, c );
+ intersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, morphPosition, uv, a, b, c );
if ( intersection ) {
@@ -14660,39 +14750,6 @@
fvB = vertices[ face.b ];
fvC = vertices[ face.c ];
- if ( faceMaterial.morphTargets === true ) {
-
- var morphTargets = geometry.morphTargets;
- var morphInfluences = this.morphTargetInfluences;
-
- vA.set( 0, 0, 0 );
- vB.set( 0, 0, 0 );
- vC.set( 0, 0, 0 );
-
- for ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) {
-
- var influence = morphInfluences[ t ];
-
- if ( influence === 0 ) continue;
-
- var targets = morphTargets[ t ].vertices;
-
- vA.addScaledVector( tempA.subVectors( targets[ face.a ], fvA ), influence );
- vB.addScaledVector( tempB.subVectors( targets[ face.b ], fvB ), influence );
- vC.addScaledVector( tempC.subVectors( targets[ face.c ], fvC ), influence );
-
- }
-
- vA.add( fvA );
- vB.add( fvB );
- vC.add( fvC );
-
- fvA = vA;
- fvB = vB;
- fvC = vC;
-
- }
-
intersection = checkIntersection( this, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint );
if ( intersection ) {
@@ -14750,6 +14807,18 @@
var background = scene.background;
+ // Ignore background in AR
+ // TODO: Reconsider this.
+
+ var vr = renderer.vr;
+ var session = vr.getSession && vr.getSession();
+
+ if ( session && session.environmentBlendMode === 'additive' ) {
+
+ background = null;
+
+ }
+
if ( background === null ) {
setClear( clearColor, clearAlpha );
@@ -15845,6 +15914,30 @@
} );
+ /**
+ * @author Takahiro https://github.com/takahirox
+ */
+
+ function DataTexture2DArray( data, width, height, depth ) {
+
+ Texture.call( this, null );
+
+ this.image = { data: data, width: width, height: height, depth: depth };
+
+ this.magFilter = NearestFilter;
+ this.minFilter = NearestFilter;
+
+ this.wrapR = ClampToEdgeWrapping;
+
+ this.generateMipmaps = false;
+ this.flipY = false;
+
+ }
+
+ DataTexture2DArray.prototype = Object.create( Texture.prototype );
+ DataTexture2DArray.prototype.constructor = DataTexture2DArray;
+ DataTexture2DArray.prototype.isDataTexture2DArray = true;
+
/**
* @author Artur Trzesiok
*/
@@ -15884,7 +15977,7 @@
*
* Uniforms of a program.
* Those form a tree structure with a special top-level container for the root,
- * which you get by calling 'new WebGLUniforms( gl, program, renderer )'.
+ * which you get by calling 'new WebGLUniforms( gl, program )'.
*
*
* Properties of inner nodes including the top-level container:
@@ -15895,15 +15988,15 @@
*
* Methods of all nodes except the top-level container:
*
- * .setValue( gl, value, [renderer] )
+ * .setValue( gl, value, [textures] )
*
* uploads a uniform value(s)
- * the 'renderer' parameter is needed for sampler uniforms
+ * the 'textures' parameter is needed for sampler uniforms
*
*
- * Static methods of the top-level container (renderer factorizations):
+ * Static methods of the top-level container (textures factorizations):
*
- * .upload( gl, seq, values, renderer )
+ * .upload( gl, seq, values, textures )
*
* sets uniforms in 'seq' to 'values[id].value'
*
@@ -15912,16 +16005,12 @@
* filters 'seq' entries with corresponding entry in values
*
*
- * Methods of the top-level container (renderer factorizations):
+ * Methods of the top-level container (textures factorizations):
*
- * .setValue( gl, name, value )
+ * .setValue( gl, name, value, textures )
*
* sets uniform with name 'name' to 'value'
*
- * .set( gl, obj, prop )
- *
- * sets uniform from object and property with same name than uniform
- *
* .setOptional( gl, obj, prop )
*
* like .set for an optional property of the object
@@ -15929,18 +16018,10 @@
*/
var emptyTexture = new Texture();
+ var emptyTexture2dArray = new DataTexture2DArray();
var emptyTexture3d = new DataTexture3D();
var emptyCubeTexture = new CubeTexture();
- // --- Base for inner nodes (including the root) ---
-
- function UniformContainer() {
-
- this.seq = [];
- this.map = {};
-
- }
-
// --- Utilities ---
// Array Caches (provide typed arrays for temporary by size)
@@ -16017,7 +16098,7 @@
// Texture unit allocation
- function allocTexUnits( renderer, n ) {
+ function allocTexUnits( textures, n ) {
var r = arrayCacheI32[ n ];
@@ -16029,7 +16110,7 @@
}
for ( var i = 0; i !== n; ++ i )
- r[ i ] = renderer.allocTextureUnit();
+ r[ i ] = textures.allocateTextureUnit();
return r;
@@ -16249,10 +16330,26 @@
// Single texture (2D / Cube)
- function setValueT1( gl, v, renderer ) {
+ function setValueT1( gl, v, textures ) {
+
+ var cache = this.cache;
+ var unit = textures.allocateTextureUnit();
+
+ if ( cache[ 0 ] !== unit ) {
+
+ gl.uniform1i( this.addr, unit );
+ cache[ 0 ] = unit;
+
+ }
+
+ textures.safeSetTexture2D( v || emptyTexture, unit );
+
+ }
+
+ function setValueT2DArray1( gl, v, textures ) {
var cache = this.cache;
- var unit = renderer.allocTextureUnit();
+ var unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
@@ -16261,14 +16358,14 @@
}
- renderer.setTexture2D( v || emptyTexture, unit );
+ textures.setTexture2DArray( v || emptyTexture2dArray, unit );
}
- function setValueT3D1( gl, v, renderer ) {
+ function setValueT3D1( gl, v, textures ) {
var cache = this.cache;
- var unit = renderer.allocTextureUnit();
+ var unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
@@ -16277,14 +16374,14 @@
}
- renderer.setTexture3D( v || emptyTexture3d, unit );
+ textures.setTexture3D( v || emptyTexture3d, unit );
}
- function setValueT6( gl, v, renderer ) {
+ function setValueT6( gl, v, textures ) {
var cache = this.cache;
- var unit = renderer.allocTextureUnit();
+ var unit = textures.allocateTextureUnit();
if ( cache[ 0 ] !== unit ) {
@@ -16293,7 +16390,7 @@
}
- renderer.setTextureCube( v || emptyCubeTexture, unit );
+ textures.safeSetTextureCube( v || emptyCubeTexture, unit );
}
@@ -16351,8 +16448,9 @@
case 0x8b5c: return setValue4fm; // _MAT4
case 0x8b5e: case 0x8d66: return setValueT1; // SAMPLER_2D, SAMPLER_EXTERNAL_OES
- case 0x8B5F: return setValueT3D1; // SAMPLER_3D
+ case 0x8b5f: return setValueT3D1; // SAMPLER_3D
case 0x8b60: return setValueT6; // SAMPLER_CUBE
+ case 0x8DC1: return setValueT2DArray1; // SAMPLER_2D_ARRAY
case 0x1404: case 0x8b56: return setValue1i; // INT, BOOL
case 0x8b53: case 0x8b57: return setValue2iv; // _VEC2
@@ -16472,12 +16570,12 @@
// Array of textures (2D / Cube)
- function setValueT1a( gl, v, renderer ) {
+ function setValueT1a( gl, v, textures ) {
var cache = this.cache;
var n = v.length;
- var units = allocTexUnits( renderer, n );
+ var units = allocTexUnits( textures, n );
if ( arraysEqual( cache, units ) === false ) {
@@ -16488,18 +16586,18 @@
for ( var i = 0; i !== n; ++ i ) {
- renderer.setTexture2D( v[ i ] || emptyTexture, units[ i ] );
+ textures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] );
}
}
- function setValueT6a( gl, v, renderer ) {
+ function setValueT6a( gl, v, textures ) {
var cache = this.cache;
var n = v.length;
- var units = allocTexUnits( renderer, n );
+ var units = allocTexUnits( textures, n );
if ( arraysEqual( cache, units ) === false ) {
@@ -16510,7 +16608,7 @@
for ( var i = 0; i !== n; ++ i ) {
- renderer.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );
+ textures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );
}
@@ -16586,18 +16684,19 @@
this.id = id;
- UniformContainer.call( this ); // mix-in
+ this.seq = [];
+ this.map = {};
}
- StructuredUniform.prototype.setValue = function ( gl, value, renderer ) {
+ StructuredUniform.prototype.setValue = function ( gl, value, textures ) {
var seq = this.seq;
for ( var i = 0, n = seq.length; i !== n; ++ i ) {
var u = seq[ i ];
- u.setValue( gl, value[ u.id ], renderer );
+ u.setValue( gl, value[ u.id ], textures );
}
@@ -16677,11 +16776,10 @@
// Root Container
- function WebGLUniforms( gl, program, renderer ) {
-
- UniformContainer.call( this );
+ function WebGLUniforms( gl, program ) {
- this.renderer = renderer;
+ this.seq = [];
+ this.map = {};
var n = gl.getProgramParameter( program, 35718 );
@@ -16696,11 +16794,11 @@
}
- WebGLUniforms.prototype.setValue = function ( gl, name, value ) {
+ WebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) {
var u = this.map[ name ];
- if ( u !== undefined ) u.setValue( gl, value, this.renderer );
+ if ( u !== undefined ) u.setValue( gl, value, textures );
};
@@ -16715,7 +16813,7 @@
// Static interface
- WebGLUniforms.upload = function ( gl, seq, values, renderer ) {
+ WebGLUniforms.upload = function ( gl, seq, values, textures ) {
for ( var i = 0, n = seq.length; i !== n; ++ i ) {
@@ -16725,7 +16823,7 @@
if ( v.needsUpdate !== false ) {
// note: always updating when .needsUpdate is undefined
- u.setValue( gl, v.value, renderer );
+ u.setValue( gl, v.value, textures );
}
@@ -16995,7 +17093,7 @@
}
- function WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities ) {
+ function WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities, textures ) {
var gl = renderer.context;
@@ -17459,7 +17557,7 @@
if ( cachedUniforms === undefined ) {
- cachedUniforms = new WebGLUniforms( gl, program, renderer );
+ cachedUniforms = new WebGLUniforms( gl, program, textures );
}
@@ -17535,7 +17633,7 @@
* @author mrdoob / http://mrdoob.com/
*/
- function WebGLPrograms( renderer, extensions, capabilities ) {
+ function WebGLPrograms( renderer, extensions, capabilities, textures ) {
var programs = [];
@@ -17809,7 +17907,7 @@
if ( program === undefined ) {
- program = new WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities );
+ program = new WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities, textures );
programs.push( program );
}
@@ -17903,7 +18001,7 @@
return a.renderOrder - b.renderOrder;
- } else if ( a.program && b.program && a.program !== b.program ) {
+ } else if ( a.program !== b.program ) {
return a.program.id - b.program.id;
@@ -17954,6 +18052,8 @@
var opaque = [];
var transparent = [];
+ var defaultProgram = { id: - 1 };
+
function init() {
renderItemsIndex = 0;
@@ -17974,7 +18074,7 @@
object: object,
geometry: geometry,
material: material,
- program: material.program,
+ program: material.program || defaultProgram,
groupOrder: groupOrder,
renderOrder: object.renderOrder,
z: z,
@@ -17989,7 +18089,7 @@
renderItem.object = object;
renderItem.geometry = geometry;
renderItem.material = material;
- renderItem.program = material.program;
+ renderItem.program = material.program || defaultProgram;
renderItem.groupOrder = groupOrder;
renderItem.renderOrder = object.renderOrder;
renderItem.z = z;
@@ -20138,7 +20238,9 @@
// only perform resize for certain image types
- if ( image instanceof ImageBitmap || image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
+ if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
+ ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
+ ( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
var floor = needsPowerOfTwo ? _Math.floorPowerOfTwo : Math.floor;
@@ -20159,7 +20261,7 @@
console.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );
- return useOffscreenCanvas ? canvas.transferToImageBitmap() : canvas;
+ return canvas;
} else {
@@ -20359,7 +20461,31 @@
//
+ var textureUnits = 0;
+
+ function resetTextureUnits() {
+ textureUnits = 0;
+
+ }
+
+ function allocateTextureUnit() {
+
+ var textureUnit = textureUnits;
+
+ if ( textureUnit >= capabilities.maxTextures ) {
+
+ console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
+
+ }
+
+ textureUnits += 1;
+
+ return textureUnit;
+
+ }
+
+ //
function setTexture2D( texture, slot ) {
@@ -20393,6 +20519,22 @@
}
+ function setTexture2DArray( texture, slot ) {
+
+ var textureProperties = properties.get( texture );
+
+ if ( texture.version > 0 && textureProperties.__version !== texture.version ) {
+
+ uploadTexture( textureProperties, texture, slot );
+ return;
+
+ }
+
+ state.activeTexture( 33984 + slot );
+ state.bindTexture( 35866, textureProperties.__webglTexture );
+
+ }
+
function setTexture3D( texture, slot ) {
var textureProperties = properties.get( texture );
@@ -20545,7 +20687,7 @@
_gl.texParameteri( textureType, 10242, utils.convert( texture.wrapS ) );
_gl.texParameteri( textureType, 10243, utils.convert( texture.wrapT ) );
- if ( textureType === 32879 ) {
+ if ( textureType === 32879 || textureType === 35866 ) {
_gl.texParameteri( textureType, 32882, utils.convert( texture.wrapR ) );
@@ -20559,7 +20701,7 @@
_gl.texParameteri( textureType, 10242, 33071 );
_gl.texParameteri( textureType, 10243, 33071 );
- if ( textureType === 32879 ) {
+ if ( textureType === 32879 || textureType === 35866 ) {
_gl.texParameteri( textureType, 32882, 33071 );
@@ -20618,7 +20760,10 @@
function uploadTexture( textureProperties, texture, slot ) {
- var textureType = ( texture.isDataTexture3D ) ? 32879 : 3553;
+ var textureType = 3553;
+
+ if ( texture.isDataTexture2DArray ) textureType = 35866;
+ if ( texture.isDataTexture3D ) textureType = 32879;
initTexture( textureProperties, texture );
@@ -20750,6 +20895,11 @@
textureProperties.__maxMipLevel = mipmaps.length - 1;
+ } else if ( texture.isDataTexture2DArray ) {
+
+ state.texImage3D( 35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
+ textureProperties.__maxMipLevel = 0;
+
} else if ( texture.isDataTexture3D ) {
state.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
@@ -21147,7 +21297,71 @@
}
+ // backwards compatibility
+
+ var warnedTexture2D = false;
+ var warnedTextureCube = false;
+
+ function safeSetTexture2D( texture, slot ) {
+
+ if ( texture && texture.isWebGLRenderTarget ) {
+
+ if ( warnedTexture2D === false ) {
+
+ console.warn( "THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead." );
+ warnedTexture2D = true;
+
+ }
+
+ texture = texture.texture;
+
+ }
+
+ setTexture2D( texture, slot );
+
+ }
+
+ function safeSetTextureCube( texture, slot ) {
+
+ if ( texture && texture.isWebGLRenderTargetCube ) {
+
+ if ( warnedTextureCube === false ) {
+
+ console.warn( "THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead." );
+ warnedTextureCube = true;
+
+ }
+
+ texture = texture.texture;
+
+ }
+
+ // currently relying on the fact that WebGLRenderTargetCube.texture is a Texture and NOT a CubeTexture
+ // TODO: unify these code paths
+ if ( ( texture && texture.isCubeTexture ) ||
+ ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {
+
+ // CompressedTexture can have Array in image :/
+
+ // this function alone should take care of cube textures
+ setTextureCube( texture, slot );
+
+ } else {
+
+ // assumed: texture property of THREE.WebGLRenderTargetCube
+ setTextureCubeDynamic( texture, slot );
+
+ }
+
+ }
+
+ //
+
+ this.allocateTextureUnit = allocateTextureUnit;
+ this.resetTextureUnits = resetTextureUnits;
+
this.setTexture2D = setTexture2D;
+ this.setTexture2DArray = setTexture2DArray;
this.setTexture3D = setTexture3D;
this.setTextureCube = setTextureCube;
this.setTextureCubeDynamic = setTextureCubeDynamic;
@@ -21155,6 +21369,9 @@
this.updateRenderTargetMipmap = updateRenderTargetMipmap;
this.updateMultisampleRenderTarget = updateMultisampleRenderTarget;
+ this.safeSetTexture2D = safeSetTexture2D;
+ this.safeSetTextureCube = safeSetTextureCube;
+
}
/**
@@ -22103,6 +22320,8 @@
animation.setAnimationLoop( callback );
+ if ( isPresenting() ) animation.start();
+
};
this.submitFrame = function () {
@@ -22530,10 +22749,6 @@
//
- _usedTextureUnits = 0,
-
- //
-
_width = _canvas.width,
_height = _canvas.height,
@@ -22662,7 +22877,7 @@
geometries = new WebGLGeometries( _gl, attributes, info );
objects = new WebGLObjects( geometries, info );
morphtargets = new WebGLMorphtargets( _gl );
- programCache = new WebGLPrograms( _this, extensions, capabilities );
+ programCache = new WebGLPrograms( _this, extensions, capabilities, textures );
renderLists = new WebGLRenderLists();
renderStates = new WebGLRenderStates();
@@ -23590,6 +23805,10 @@
//
+ scene.onAfterRender( _this, scene, camera );
+
+ //
+
if ( _currentRenderTarget !== null ) {
// Generate mipmap if we're using any kind of mipmap filtering
@@ -23610,8 +23829,6 @@
state.setPolygonOffset( false );
- scene.onAfterRender( _this, scene, camera );
-
if ( vr.enabled ) {
vr.submitFrame();
@@ -23661,7 +23878,11 @@
var geometry = objects.update( object );
var material = object.material;
- currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
+ if ( material.visible ) {
+
+ currentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );
+
+ }
}
@@ -24014,7 +24235,7 @@
function setProgram( camera, fog, material, object ) {
- _usedTextureUnits = 0;
+ textures.resetTextureUnits();
var materialProperties = properties.get( material );
var lights = currentRenderState.state.lights;
@@ -24201,7 +24422,7 @@
}
- p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture );
+ p_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );
p_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );
} else {
@@ -24331,13 +24552,13 @@
if ( m_uniforms.ltc_1 !== undefined ) m_uniforms.ltc_1.value = UniformsLib.LTC_1;
if ( m_uniforms.ltc_2 !== undefined ) m_uniforms.ltc_2.value = UniformsLib.LTC_2;
- WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, _this );
+ WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
}
if ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {
- WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, _this );
+ WebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );
material.uniformsNeedUpdate = false;
}
@@ -24800,125 +25021,6 @@
}
- // Textures
-
- function allocTextureUnit() {
-
- var textureUnit = _usedTextureUnits;
-
- if ( textureUnit >= capabilities.maxTextures ) {
-
- console.warn( 'THREE.WebGLRenderer: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );
-
- }
-
- _usedTextureUnits += 1;
-
- return textureUnit;
-
- }
-
- this.allocTextureUnit = allocTextureUnit;
-
- // this.setTexture2D = setTexture2D;
- this.setTexture2D = ( function () {
-
- var warned = false;
-
- // backwards compatibility: peel texture.texture
- return function setTexture2D( texture, slot ) {
-
- if ( texture && texture.isWebGLRenderTarget ) {
-
- if ( ! warned ) {
-
- console.warn( "THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead." );
- warned = true;
-
- }
-
- texture = texture.texture;
-
- }
-
- textures.setTexture2D( texture, slot );
-
- };
-
- }() );
-
- this.setTexture3D = ( function () {
-
- // backwards compatibility: peel texture.texture
- return function setTexture3D( texture, slot ) {
-
- textures.setTexture3D( texture, slot );
-
- };
-
- }() );
-
- this.setTexture = ( function () {
-
- var warned = false;
-
- return function setTexture( texture, slot ) {
-
- if ( ! warned ) {
-
- console.warn( "THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead." );
- warned = true;
-
- }
-
- textures.setTexture2D( texture, slot );
-
- };
-
- }() );
-
- this.setTextureCube = ( function () {
-
- var warned = false;
-
- return function setTextureCube( texture, slot ) {
-
- // backwards compatibility: peel texture.texture
- if ( texture && texture.isWebGLRenderTargetCube ) {
-
- if ( ! warned ) {
-
- console.warn( "THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead." );
- warned = true;
-
- }
-
- texture = texture.texture;
-
- }
-
- // currently relying on the fact that WebGLRenderTargetCube.texture is a Texture and NOT a CubeTexture
- // TODO: unify these code paths
- if ( ( texture && texture.isCubeTexture ) ||
- ( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {
-
- // CompressedTexture can have Array in image :/
-
- // this function alone should take care of cube textures
- textures.setTextureCube( texture, slot );
-
- } else {
-
- // assumed: texture property of THREE.WebGLRenderTargetCube
-
- textures.setTextureCubeDynamic( texture, slot );
-
- }
-
- };
-
- }() );
-
//
this.setFramebuffer = function ( value ) {
@@ -24991,7 +25093,7 @@
if ( isCube ) {
var textureProperties = properties.get( renderTarget.texture );
- _gl.framebufferTexture2D( 36160, 36064, 34069 + activeCubeFace || 0, textureProperties.__webglTexture, activeMipMapLevel || 0 );
+ _gl.framebufferTexture2D( 36160, 36064, 34069 + ( activeCubeFace || 0 ), textureProperties.__webglTexture, activeMipMapLevel || 0 );
}
@@ -25078,7 +25180,7 @@
var height = texture.image.height;
var glFormat = utils.convert( texture.format );
- this.setTexture2D( texture, 0 );
+ textures.setTexture2D( texture, 0 );
_gl.copyTexImage2D( 3553, level || 0, glFormat, position.x, position.y, width, height, 0 );
@@ -25091,7 +25193,7 @@
var glFormat = utils.convert( dstTexture.format );
var glType = utils.convert( dstTexture.type );
- this.setTexture2D( dstTexture, 0 );
+ textures.setTexture2D( dstTexture, 0 );
if ( srcTexture.isDataTexture ) {
@@ -26473,20 +26575,9 @@
}() ),
- copy: function ( source ) {
-
- Object3D.prototype.copy.call( this, source );
-
- this.geometry.copy( source.geometry );
- this.material.copy( source.material );
-
- return this;
-
- },
-
clone: function () {
- return new this.constructor().copy( this );
+ return new this.constructor( this.geometry, this.material ).copy( this );
}
@@ -30248,6 +30339,10 @@
var v = iy / heightSegments;
+ // special case for the poles
+
+ var uOffset = ( iy == 0 ) ? 0.5 / widthSegments : ( ( iy == heightSegments ) ? - 0.5 / widthSegments : 0 );
+
for ( ix = 0; ix <= widthSegments; ix ++ ) {
var u = ix / widthSegments;
@@ -30262,12 +30357,12 @@
// normal
- normal.set( vertex.x, vertex.y, vertex.z ).normalize();
+ normal.copy( vertex ).normalize();
normals.push( normal.x, normal.y, normal.z );
// uv
- uvs.push( u, 1 - v );
+ uvs.push( u + uOffset, 1 - v );
verticesRow.push( index ++ );
@@ -34582,7 +34677,7 @@
},
- parse: function ( json, onLoad ) {
+ parse: function ( json ) {
var animations = [];
@@ -34594,7 +34689,7 @@
}
- onLoad( animations );
+ return animations;
},
@@ -39100,7 +39195,16 @@
} ).then( function ( blob ) {
- return createImageBitmap( blob, scope.options );
+ if ( scope.options === undefined ) {
+
+ // Workaround for FireFox. It causes an error if you pass options.
+ return createImageBitmap( blob );
+
+ } else {
+
+ return createImageBitmap( blob, scope.options );
+
+ }
} ).then( function ( imageBitmap ) {
@@ -45113,8 +45217,28 @@
}
- GridHelper.prototype = Object.create( LineSegments.prototype );
- GridHelper.prototype.constructor = GridHelper;
+ GridHelper.prototype = Object.assign( Object.create( LineSegments.prototype ), {
+
+ constructor: GridHelper,
+
+ copy: function ( source ) {
+
+ LineSegments.prototype.copy.call( this, source );
+
+ this.geometry.copy( source.geometry );
+ this.material.copy( source.material );
+
+ return this;
+
+ },
+
+ clone: function () {
+
+ return new this.constructor().copy( this );
+
+ }
+
+ } );
/**
* @author mrdoob / http://mrdoob.com/
@@ -45652,10 +45776,10 @@
var w = 1, h = 1;
- // we need just camera projection matrix
+ // we need just camera projection matrix inverse
// world matrix must be identity
- camera.projectionMatrix.copy( this.camera.projectionMatrix );
+ camera.projectionMatrixInverse.copy( this.camera.projectionMatrixInverse );
// center / target
@@ -47368,42 +47492,36 @@
this.clear( color, depth, stencil );
},
-
animate: function ( callback ) {
console.warn( 'THREE.WebGLRenderer: .animate() is now .setAnimationLoop().' );
this.setAnimationLoop( callback );
},
-
getCurrentRenderTarget: function () {
console.warn( 'THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().' );
return this.getRenderTarget();
},
-
getMaxAnisotropy: function () {
console.warn( 'THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().' );
return this.capabilities.getMaxAnisotropy();
},
-
getPrecision: function () {
console.warn( 'THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.' );
return this.capabilities.precision;
},
-
resetGLState: function () {
console.warn( 'THREE.WebGLRenderer: .resetGLState() is now .state.reset().' );
return this.state.reset();
},
-
supportsFloatTextures: function () {
console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' );
@@ -47482,6 +47600,26 @@
console.warn( 'THREE.WebGLRenderer: .setFaceCulling() has been removed.' );
+ },
+ allocTextureUnit: function () {
+
+ console.warn( 'THREE.WebGLRenderer: .allocTextureUnit() has been removed.' );
+
+ },
+ setTexture: function () {
+
+ console.warn( 'THREE.WebGLRenderer: .setTexture() has been removed.' );
+
+ },
+ setTexture2D: function () {
+
+ console.warn( 'THREE.WebGLRenderer: .setTexture2D() has been removed.' );
+
+ },
+ setTextureCube: function () {
+
+ console.warn( 'THREE.WebGLRenderer: .setTextureCube() has been removed.' );
+
}
} );
@@ -47969,6 +48107,7 @@
exports.Group = Group;
exports.VideoTexture = VideoTexture;
exports.DataTexture = DataTexture;
+ exports.DataTexture2DArray = DataTexture2DArray;
exports.DataTexture3D = DataTexture3D;
exports.CompressedTexture = CompressedTexture;
exports.CubeTexture = CubeTexture;
diff --git a/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.min.js b/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.min.js
index ec0a4328..a1b5bce6 100644
--- a/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.min.js
+++ b/core/src/main/resources/org/treblereel/gwt/three4g/resources/js/three.min.js
@@ -1,356 +1,340 @@
// threejs.org/license
-(function(l,ka){"object"===typeof exports&&"undefined"!==typeof module?ka(exports):"function"===typeof define&&define.amd?define(["exports"],ka):(l=l||self,ka(l.THREE={}))})(this,function(l){function ka(){}function B(a,b){this.x=a||0;this.y=b||0}function J(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];0b&&(b=a[c]);return b}function C(){Object.defineProperty(this,"id",{value:Xf+=2});this.uuid=H.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}
-function Ob(a,b,c,d,e,f){G.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new rb(a,b,c,d,e,f));this.mergeVertices()}function rb(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,l,fa,A,B){var r=f/fa,u=g/A,w=f/2,x=g/2,z=l/2;g=fa+1;var D=A+1,y=f=0,Q,Fa,ta=new n;for(Fa=0;Fab&&(b=a[c]);return b}function z(){Object.defineProperty(this,"id",{value:Yf+=2});this.uuid=K.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}
+function Rb(a,b,c,d,e,f){N.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.fromBufferGeometry(new ub(a,b,c,d,e,f));this.mergeVertices()}function ub(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,l,ua,F,Zf){var r=f/ua,u=g/F,x=f/2,w=g/2,A=l/2;g=ua+1;var y=F+1,X=f=0,Q,J,D=new n;for(J=0;Jm;m++){if(q=d[m])if(h=q[0],k=q[1]){p&&e.addAttribute("morphTarget"+m,
-p[h]);f&&e.addAttribute("morphNormal"+m,f[h]);c[m]=k;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function ig(a,b){var c={};return{update:function(d){var e=b.render.frame,f=d.geometry,g=a.get(d,f);c[g.id]!==e&&(f.isGeometry&&g.updateFromObject(d),a.update(g),c[g.id]=e);return g},dispose:function(){c={}}}}function $a(a,b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];V.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,k,m);this.flipY=!1}function Qb(a,b,c,d){V.call(this,null);
-this.image={data:a,width:b,height:c,depth:d};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1}function Rb(a,b,c){var d=a[0];if(0>=d||0/gm,
-function(a,c){a=U[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return fe(a)})}function kf(a){return a.replace(/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);cm;m++){if(q=d[m])if(h=q[0],k=q[1]){p&&e.addAttribute("morphTarget"+m,
+p[h]);f&&e.addAttribute("morphNormal"+m,f[h]);c[m]=k;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function kg(a,b){var c={};return{update:function(d){var e=b.render.frame,f=d.geometry,g=a.get(d,f);c[g.id]!==e&&(f.isGeometry&&g.updateFromObject(d),a.update(g),c[g.id]=e);return g},dispose:function(){c={}}}}function bb(a,b,c,d,e,f,g,h,k,m){a=void 0!==a?a:[];W.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,k,m);this.flipY=!1}function Sb(a,b,c,d){W.call(this,null);
+this.image={data:a,width:b,height:c,depth:d};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1}function Tb(a,b,c,d){W.call(this,null);this.image={data:a,width:b,height:c,depth:d};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1}function Ub(a,b,c){var d=a[0];if(0>=d||0/gm,function(a,c){a=T[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return ee(a)})}function kf(a){return a.replace(/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,
+function(a,c,d,e){a="";for(c=parseInt(c);cd||a.height>d)e=d/Math.max(a.width,a.height);if(1>e||!0===b){if(a instanceof ImageBitmap||a instanceof HTMLImageElement||a instanceof HTMLCanvasElement)return d=b?H.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),void 0===B&&(B=h(b,e)),c=c?h(b,e):B,c.width=b,c.height=e,c.getContext("2d").drawImage(a,0,0,b,e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+
-a.width+"x"+a.height+") to ("+b+"x"+e+")."),F?c.transferToImageBitmap():c;"data"in a&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").")}return a}function m(a){return H.isPowerOfTwo(a.width)&&H.isPowerOfTwo(a.height)}function p(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function q(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function v(a,c){if(!e.isWebGL2)return a;var d=a;6403===a&&
-(5126===c&&(d=33326),5131===c&&(d=33325),5121===c&&(d=33321));6407===a&&(5126===c&&(d=34837),5131===c&&(d=34843),5121===c&&(d=32849));6408===a&&(5126===c&&(d=34836),5131===c&&(d=34842),5121===c&&(d=32856));33325===d||33326===d||34842===d||34836===d?b.get("EXT_color_buffer_float"):(34843===d||34837===d)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.");return d}function l(a){return 1003===a||1004===a||1005===a?9728:9729}function r(b){b=
-b.target;b.removeEventListener("dispose",r);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&delete A[b.id];g.memory.textures--}function u(b){b=b.target;b.removeEventListener("dispose",u);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);
-else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--}function n(a,b){var e=d.get(a);if(a.isVideoTexture){var f=a.id,h=g.render.frame;A[f]!==h&&(A[f]=h,a.update())}if(0r;r++)t[r]=g||l?l?b.image[r].image:b.image[r]:k(b.image[r],!1,!0,e.maxCubemapSize);var u=t[0],n=m(u)||e.isWebGL2,w=f.convert(b.format),y=f.convert(b.type),D=v(w,y);
-z(34067,b,n);for(r=0;6>r;r++)if(g)for(var A,fa=t[r].mipmaps,Q=0,Ac=fa.length;Qr;r++)h.__webglFramebuffer[r]=a.createFramebuffer();else if(h.__webglFramebuffer=a.createFramebuffer(),r)if(e.isWebGL2){h.__webglMultisampledFramebuffer=a.createFramebuffer();h.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,h.__webglColorRenderbuffer);r=f.convert(b.texture.format);var w=f.convert(b.texture.type);r=v(r,w);w=fa(b);a.renderbufferStorageMultisample(36161,w,r,b.width,
-b.height);a.bindFramebuffer(36160,h.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,h.__webglColorRenderbuffer);a.bindRenderbuffer(36161,null);b.depthBuffer&&(h.__webglDepthRenderbuffer=a.createRenderbuffer(),Q(h.__webglDepthRenderbuffer,b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(l){c.bindTexture(34067,k.__webglTexture);z(34067,b.texture,t);for(r=0;6>r;r++)y(h.__webglFramebuffer[r],
-b,36064,34069+r);p(b.texture,t)&&q(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,k.__webglTexture),z(3553,b.texture,t),y(h.__webglFramebuffer,b,36064,3553),p(b.texture,t)&&q(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){h=d.get(b);k=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(k)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");
-a.bindFramebuffer(36160,h.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);n(b.depthTexture,0);h=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(36160,
-36096,3553,h,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,h,0);else throw Error("Unknown depthTexture format");}else if(k)for(h.__webglDepthbuffer=[],k=0;6>k;k++)a.bindFramebuffer(36160,h.__webglFramebuffer[k]),h.__webglDepthbuffer[k]=a.createRenderbuffer(),Q(h.__webglDepthbuffer[k],b);else a.bindFramebuffer(36160,h.__webglFramebuffer),h.__webglDepthbuffer=a.createRenderbuffer(),Q(h.__webglDepthbuffer,b);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=
-function(a){var b=a.texture,f=m(a)||e.isWebGL2;if(p(b,f)){f=a.isWebGLRenderTargetCube?34067:3553;var g=d.get(b).__webglTexture;c.bindTexture(f,g);q(f,b,a.width,a.height);c.bindTexture(f,null)}};this.updateMultisampleRenderTarget=function(b){if(b.isWebGLMultisampleRenderTarget)if(e.isWebGL2){var c=d.get(b);a.bindFramebuffer(36008,c.__webglMultisampledFramebuffer);a.bindFramebuffer(36009,c.__webglFramebuffer);c=b.width;var f=b.height,g=16384;b.depthBuffer&&(g|=256);b.stencilBuffer&&(g|=1024);a.blitFramebuffer(0,
-0,c,f,0,0,c,f,g,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")}}function of(a,b,c){return{convert:function(a){if(1E3===a)return 10497;if(1001===a)return 33071;if(1002===a)return 33648;if(1003===a)return 9728;if(1004===a)return 9984;if(1005===a)return 9986;if(1006===a)return 9729;if(1007===a)return 9985;if(1008===a)return 9987;if(1009===a)return 5121;if(1017===a)return 32819;if(1018===a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120;
-if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(c.isWebGL2)return 5131;var d=b.get("OES_texture_half_float");if(null!==d)return d.HALF_FLOAT_OES}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410;if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(100===a)return 32774;if(101===a)return 32778;if(102===a)return 32779;if(200===
-a)return 0;if(201===a)return 1;if(202===a)return 768;if(203===a)return 769;if(204===a)return 770;if(205===a)return 771;if(206===a)return 772;if(207===a)return 773;if(208===a)return 774;if(209===a)return 775;if(210===a)return 776;if(33776===a||33777===a||33778===a||33779===a)if(d=b.get("WEBGL_compressed_texture_s3tc"),null!==d){if(33776===a)return d.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return d.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return d.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===a)return d.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===
-a||35841===a||35842===a||35843===a)if(d=b.get("WEBGL_compressed_texture_pvrtc"),null!==d){if(35840===a)return d.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===a)return d.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return d.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return d.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===a&&(d=b.get("WEBGL_compressed_texture_etc1"),null!==d))return d.COMPRESSED_RGB_ETC1_WEBGL;if(37808===a||37809===a||37810===a||37811===a||37812===a||37813===a||37814===a||37815===a||37816===
-a||37817===a||37818===a||37819===a||37820===a||37821===a)if(d=b.get("WEBGL_compressed_texture_astc"),null!==d)return a;if(103===a||104===a){if(c.isWebGL2){if(103===a)return 32775;if(104===a)return 32776}d=b.get("EXT_blend_minmax");if(null!==d){if(103===a)return d.MIN_EXT;if(104===a)return d.MAX_EXT}}if(1020===a){if(c.isWebGL2)return 34042;d=b.get("WEBGL_depth_texture");if(null!==d)return d.UNSIGNED_INT_24_8_WEBGL}return 0}}}function Sb(){E.call(this);this.type="Group"}function Ua(){E.call(this);this.type=
-"Camera";this.matrixWorldInverse=new J;this.projectionMatrix=new J;this.projectionMatrixInverse=new J}function S(a,b,c,d){Ua.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function Ec(a){S.call(this);this.cameras=a||[]}function pf(a,b,c){qf.setFromMatrixPosition(b.matrixWorld);rf.setFromMatrixPosition(c.matrixWorld);
-var d=qf.distanceTo(rf),e=b.projectionMatrix.elements,f=c.projectionMatrix.elements,g=e[14]/(e[10]-1);c=e[14]/(e[10]+1);var h=(e[9]+1)/e[5],k=(e[9]-1)/e[5],m=(e[8]-1)/e[0],p=(f[8]+1)/f[0];e=g*m;f=g*p;p=d/(-m+p);m=p*-m;b.matrixWorld.decompose(a.position,a.quaternion,a.scale);a.translateX(m);a.translateZ(p);a.matrixWorld.compose(a.position,a.quaternion,a.scale);a.matrixWorldInverse.getInverse(a.matrixWorld);b=g+p;g=c+p;a.projectionMatrix.makePerspective(e-m,f+(d-m),h*c/g*b,k*c/g*b,b,g)}function sf(a){function b(){return null!==
-e&&!0===e.isPresenting}function c(){if(b()){var c=e.getEyeParameters("left"),f=c.renderWidth*p;c=c.renderHeight*p;D=a.getPixelRatio();a.getSize(x);a.setDrawingBufferSize(2*f,c,1);Q.start()}else d.enabled&&a.setDrawingBufferSize(x.width,x.height,D),Q.stop()}var d=this,e=null,f=null,g=null,h=[],k=new J,m=new J,p=1,q="stage";"undefined"!==typeof window&&"VRFrameData"in window&&(f=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var v=new J,l=new aa,r=new n,u=new S;u.bounds=
-new ba(0,0,.5,1);u.layers.enable(1);var w=new S;w.bounds=new ba(.5,0,.5,1);w.layers.enable(2);var z=new Ec([u,w]);z.layers.enable(1);z.layers.enable(2);var x=new B,D,y=[];this.enabled=!1;this.getController=function(a){var b=h[a];void 0===b&&(b=new Sb,b.matrixAutoUpdate=!1,b.visible=!1,h[a]=b);return b};this.getDevice=function(){return e};this.setDevice=function(a){void 0!==a&&(e=a);Q.setContext(a)};this.setFramebufferScaleFactor=function(a){p=a};this.setFrameOfReferenceType=function(a){q=a};this.setPoseTarget=
-function(a){void 0!==a&&(g=a)};this.getCamera=function(a){var c="stage"===q?1.6:0;if(!1===b())return a.position.set(0,c,0),a.rotation.set(0,0,0),a;e.depthNear=a.near;e.depthFar=a.far;e.getFrameData(f);if("stage"===q){var d=e.stageParameters;d?k.fromArray(d.sittingToStandingTransform):k.makeTranslation(0,c,0)}c=f.pose;d=null!==g?g:a;d.matrix.copy(k);d.matrix.decompose(d.position,d.quaternion,d.scale);null!==c.orientation&&(l.fromArray(c.orientation),d.quaternion.multiply(l));null!==c.position&&(l.setFromRotationMatrix(k),
-r.fromArray(c.position),r.applyQuaternion(l),d.position.add(r));d.updateMatrixWorld();u.near=a.near;w.near=a.near;u.far=a.far;w.far=a.far;u.matrixWorldInverse.fromArray(f.leftViewMatrix);w.matrixWorldInverse.fromArray(f.rightViewMatrix);m.getInverse(k);"stage"===q&&(u.matrixWorldInverse.multiply(m),w.matrixWorldInverse.multiply(m));a=d.parent;null!==a&&(v.getInverse(a.matrixWorld),u.matrixWorldInverse.multiply(v),w.matrixWorldInverse.multiply(v));u.matrixWorld.getInverse(u.matrixWorldInverse);w.matrixWorld.getInverse(w.matrixWorldInverse);
-u.projectionMatrix.fromArray(f.leftProjectionMatrix);w.projectionMatrix.fromArray(f.rightProjectionMatrix);pf(z,u,w);a=e.getLayers();a.length&&(a=a[0],null!==a.leftBounds&&4===a.leftBounds.length&&u.bounds.fromArray(a.leftBounds),null!==a.rightBounds&&4===a.rightBounds.length&&w.bounds.fromArray(a.rightBounds));a:for(a=0;af.matrixWorld.determinant();Z.setMaterial(e,
-h);var k=l(a,c,e,f),m=!1;if(b!==d.id||U!==k.id||ta!==(!0===e.wireframe))b=d.id,U=k.id,ta=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(xa.update(f,d,e,k),m=!0);h=d.index;var p=d.attributes.position;c=1;!0===e.wireframe&&(h=ua.getWireframeAttribute(d),c=2);a=Aa;if(null!==h){var q=ra.get(h);a=Ba;a.setIndex(q)}if(m){if(d&&d.isInstancedBufferGeometry&&!za.isWebGL2&&null===la.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
-else{Z.initAttributes();m=d.attributes;k=k.getAttributes();var v=e.defaultAttributeValues;for(A in k){var r=k[A];if(0<=r){var t=m[A];if(void 0!==t){var n=t.normalized,u=t.itemSize,w=ra.get(t);if(void 0!==w){var x=w.buffer,z=w.type;w=w.bytesPerElement;if(t.isInterleavedBufferAttribute){var y=t.data,D=y.stride;t=t.offset;y&&y.isInstancedInterleavedBuffer?(Z.enableAttributeAndDivisor(r,y.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=y.meshPerAttribute*y.count)):Z.enableAttribute(r);
-O.bindBuffer(34962,x);O.vertexAttribPointer(r,u,z,n,D*w,t*w)}else t.isInstancedBufferAttribute?(Z.enableAttributeAndDivisor(r,t.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=t.meshPerAttribute*t.count)):Z.enableAttribute(r),O.bindBuffer(34962,x),O.vertexAttribPointer(r,u,z,n,0,0)}}else if(void 0!==v&&(n=v[A],void 0!==n))switch(n.length){case 2:O.vertexAttrib2fv(r,n);break;case 3:O.vertexAttrib3fv(r,n);break;case 4:O.vertexAttrib4fv(r,n);break;default:O.vertexAttrib1fv(r,n)}}}Z.disableUnusedAttributes()}null!==
-h&&O.bindBuffer(34963,q.buffer)}q=Infinity;null!==h?q=h.count:void 0!==p&&(q=p.count);h=d.drawRange.start*c;p=null!==g?g.start*c:0;var A=Math.max(h,p);g=Math.max(0,Math.min(q,h+d.drawRange.count*c,p+(null!==g?g.count*c:Infinity))-1-A+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)Z.setLineWidth(e.wireframeLinewidth*(null===G?T:1)),a.setMode(1);else switch(f.drawMode){case 0:a.setMode(4);break;case 1:a.setMode(5);break;case 2:a.setMode(6)}else f.isLine?(e=e.linewidth,void 0===e&&(e=1),Z.setLineWidth(e*
-(null===G?T:1)),f.isLineSegments?a.setMode(1):f.isLineLoop?a.setMode(2):a.setMode(3)):f.isPoints?a.setMode(0):f.isSprite&&a.setMode(4);d&&d.isInstancedBufferGeometry?0=za.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+a+" texture units while this GPU supports only "+za.maxTextures);ia+=1;return a};this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&&(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),
-a=!0),b=b.texture);da.setTexture2D(b,c)}}();this.setTexture3D=function(){return function(a,b){da.setTexture3D(a,b)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);da.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),
-a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?da.setTextureCube(b,c):da.setTextureCubeDynamic(b,c)}}();this.setFramebuffer=function(a){L=a};this.getRenderTarget=function(){return G};this.setRenderTarget=function(a,b,c){(G=a)&&void 0===Da.get(a).__webglFramebuffer&&da.setupRenderTarget(a);var d=L,e=!1;a?(d=Da.get(a).__webglFramebuffer,a.isWebGLRenderTargetCube?(d=d[b||0],e=!0):d=a.isWebGLMultisampleRenderTarget?Da.get(a).__webglMultisampledFramebuffer:d,V.copy(a.viewport),
-W.copy(a.scissor),ca=a.scissorTest):(V.copy(ea).multiplyScalar(T),W.copy(aa).multiplyScalar(T),ca=pa);M!==d&&(O.bindFramebuffer(36160,d),M=d);Z.viewport(V);Z.scissor(W);Z.setScissorTest(ca);e&&(a=Da.get(a.texture),O.framebufferTexture2D(36160,36064,34069+b||0,a.__webglTexture,c||0))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(a&&a.isWebGLRenderTarget){var g=Da.get(a).__webglFramebuffer;if(g){var h=!1;g!==M&&(O.bindFramebuffer(36160,g),h=!0);try{var k=a.texture,m=k.format,p=k.type;1023!==
-m&&ja.convert(m)!==O.getParameter(35739)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===p||ja.convert(p)===O.getParameter(35738)||1015===p&&(za.isWebGL2||la.get("OES_texture_float")||la.get("WEBGL_color_buffer_float"))||1016===p&&(za.isWebGL2?la.get("EXT_color_buffer_float"):la.get("EXT_color_buffer_half_float"))?36053===O.checkFramebufferStatus(36160)?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&O.readPixels(b,c,d,e,ja.convert(m),
-ja.convert(p),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&O.bindFramebuffer(36160,M)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")};this.copyFramebufferToTexture=function(a,b,c){var d=b.image.width,e=b.image.height,
-f=ja.convert(b.format);this.setTexture2D(b,0);O.copyTexImage2D(3553,c||0,f,a.x,a.y,d,e,0)};this.copyTextureToTexture=function(a,b,c,d){var e=b.image.width,f=b.image.height,g=ja.convert(c.format),h=ja.convert(c.type);this.setTexture2D(c,0);b.isDataTexture?O.texSubImage2D(3553,d||0,a.x,a.y,e,f,g,h,b.image.data):O.texSubImage2D(3553,d||0,a.x,a.y,g,h,b.image)}}function yd(a,b){this.name="";this.color=new K(a);this.density=void 0!==b?b:2.5E-4}function zd(a,b,c){this.name="";this.color=new K(a);this.near=
-void 0!==b?b:1;this.far=void 0!==c?c:1E3}function Ad(){E.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function ub(a,b){this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function Fc(a,b,c,d){this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function jb(a){M.call(this);this.type="SpriteMaterial";this.color=new K(16777215);this.map=null;this.rotation=0;
-this.sizeAttenuation=!0;this.lights=!1;this.transparent=!0;this.setValues(a)}function Gc(a){E.call(this);this.type="Sprite";if(void 0===Tb){Tb=new C;var b=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]);b=new ub(b,5);Tb.setIndex([0,1,2,0,2,3]);Tb.addAttribute("position",new Fc(b,3,0,!1));Tb.addAttribute("uv",new Fc(b,2,3,!1))}this.geometry=Tb;this.material=void 0!==a?a:new jb;this.center=new B(.5,.5)}function Hc(){E.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,
-value:[]}})}function Ic(a,b){a&&a.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");va.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new J;this.bindMatrixInverse=new J}function Bd(a,b){a=a||[];this.bones=a.slice(0);this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton boneInverses is the wrong length."),
-this.boneInverses=[],a=0,b=this.bones.length;ac;c++){var q=p[h[c]];var l=p[h[(c+1)%3]];f[0]=Math.min(q,l);f[1]=Math.max(q,l);q=f[0]+
-","+f[1];void 0===g[q]&&(g[q]={index1:f[0],index2:f[1]})}}for(q in g)m=g[q],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new n,null!==a.index){k=a.attributes.position;p=a.index;var t=a.groups;0===t.length&&(t=[{start:0,count:p.count,materialIndex:0}]);a=0;for(e=t.length;ac;c++)q=p.getX(m+c),l=p.getX(m+(c+1)%3),f[0]=Math.min(q,l),f[1]=Math.max(q,l),q=f[0]+","+
-f[1],void 0===g[q]&&(g[q]={index1:f[0],index2:f[1]});for(q in g)m=g[q],h.fromBufferAttribute(k,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(k,m.index2),b.push(h.x,h.y,h.z)}else for(k=a.attributes.position,m=0,d=k.count/3;mc;c++)g=3*m+c,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new F(b,3))}function Lc(a,b,c){G.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,
-stacks:c};this.fromBufferGeometry(new Xb(a,b,c));this.mergeVertices()}function Xb(a,b,c){C.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new n,k=new n,m=new n,p=new n,q=new n,l,t;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var r=b+1;for(l=0;l<=c;l++){var u=l/c;for(t=0;t<=b;t++){var w=t/b;a(w,u,k);e.push(k.x,k.y,k.z);0<=w-1E-5?(a(w-1E-5,u,m),p.subVectors(k,m)):(a(w+
-1E-5,u,m),p.subVectors(m,k));0<=u-1E-5?(a(w,u-1E-5,m),q.subVectors(k,m)):(a(w,u+1E-5,m),q.subVectors(m,k));h.crossVectors(p,q).normalize();f.push(h.x,h.y,h.z);g.push(w,u)}}for(l=0;ld&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}C.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],k=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",new F(h,3));this.addAttribute("normal",new F(h.slice(),3));this.addAttribute("uv",new F(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Nc(a,b){G.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Yb(a,b));this.mergeVertices()}
-function Yb(a,b){Aa.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Oc(a,b){G.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new vb(a,b));this.mergeVertices()}function vb(a,b){Aa.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters=
-{radius:a,detail:b}}function Pc(a,b){G.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Zb(a,b));this.mergeVertices()}function Zb(a,b){var c=(1+Math.sqrt(5))/2;Aa.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters=
-{radius:a,detail:b}}function Qc(a,b){G.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new $b(a,b));this.mergeVertices()}function $b(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;Aa.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,
-6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Rc(a,b,c,d,e,f){G.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new wb(a,b,c,d,e);this.tangents=a.tangents;this.normals=
-a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function wb(a,b,c,d,e){function f(e){p=a.getPointAt(e/b,p);var f=g.normals[e];e=g.binormals[e];for(l=0;l<=d;l++){var m=l/d*Math.PI*2,q=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+q*e.x;k.y=m*f.y+q*e.y;k.z=m*f.z+q*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=p.x+c*k.x;h.y=p.y+c*k.y;h.z=p.z+c*k.z;t.push(h.x,h.y,h.z)}}C.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,
-closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new n,k=new n,m=new B,p=new n,q,l,t=[],r=[],u=[],w=[];for(q=0;q=b;e-=d)f=vf(e,a[e],a[e+1],f);f&&xb(f,f.next)&&(Uc(f),f=f.next);return f}function Vc(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!xb(a,a.next)&&0!==qa(a.prev,a,a.next))a=a.next;else{Uc(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function Wc(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=ke(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=
-k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,p,q,l,t=1;do{k=h;var r=h=null;for(p=0;k;){p++;var n=k;for(m=q=0;mq.x?p.x>t.x?p.x:t.x:q.x>t.x?q.x:t.x,D=p.y>q.y?p.y>t.y?p.y:t.y:q.y>
-t.y?q.y:t.y;m=ke(p.x=m;){if(w!==r.prev&&w!==r.next&&Dd(p.x,p.y,q.x,q.y,t.x,t.y,w.x,w.y)&&0<=qa(w.prev,w,w.next)){r=!1;break a}w=w.prevZ}r=!0}}else a:if(r=a,p=r.prev,q=r,t=r.next,0<=qa(p,q,t))r=!1;else{for(m=r.next.next;m!==r.prev;){if(Dd(p.x,p.y,
-q.x,q.y,t.x,t.y,m.x,m.y)&&0<=qa(m.prev,m,m.next)){r=!1;break a}m=m.next}r=!0}if(r)b.push(k.i/c),b.push(a.i/c),b.push(n.i/c),Uc(a),h=a=n.next;else if(a=n,a===h){if(!g)Wc(Vc(a),b,c,d,e,f,1);else if(1===g){g=b;h=c;k=a;do n=k.prev,r=k.next.next,!xb(n,r)&&wf(n,k,k.next,r)&&Xc(n,r)&&Xc(r,n)&&(g.push(n.i/h),g.push(k.i/h),g.push(r.i/h),Uc(k),Uc(k.next),k=a=r),k=k.next;while(k!==a);a=k;Wc(a,b,c,d,e,f,2)}else if(2===g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(k=g.i!==h.i){k=g;n=h;if(r=k.next.i!==n.i&&k.prev.i!==
-n.i){b:{r=k;do{if(r.i!==k.i&&r.next.i!==k.i&&r.i!==n.i&&r.next.i!==n.i&&wf(r,r.next,k,n)){r=!0;break b}r=r.next}while(r!==k);r=!1}r=!r}if(r=r&&Xc(k,n)&&Xc(n,k)){r=k;p=!1;q=(k.x+n.x)/2;n=(k.y+n.y)/2;do r.y>n!==r.next.y>n&&r.next.y!==r.y&&q<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(p=!p),r=r.next;while(r!==k);r=p}k=r}if(k){a=xf(g,h);g=Vc(g,g.next);a=Vc(a,a.next);Wc(g,b,c,d,e,f);Wc(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function ah(a,b){return a.x-b.x}function bh(a,b){var c=b,
-d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x=c.x&&c.x>=g&&d!==c.x&&Dd(eh.x)&&Xc(c,a)&&(h=c,m=p)}c=c.next}return h}function ke(a,
-b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function ch(a){var b=a,c=a;do b.xqa(a.prev,a,a.next)?0<=qa(a,b,a.next)&&0<=qa(a,a.prev,b):0>qa(a,b,a.prev)||0>qa(a,a.next,b)}function xf(a,b){var c=new le(a.i,a.x,a.y),d=new le(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function vf(a,b,c,d){a=new le(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):
-(a.prev=a,a.next=a);return a}function Uc(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function le(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function yf(a){var b=a.length;2Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/k;b=b.y+d/k;g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new B(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?
-f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new B(f/e,d/e)}function h(a,b){for(N=a.length;0<=--N;){var c=N;var f=N-1;0>f&&(f=a.length-1);var g,h=x+2*A;for(g=0;gp;p++){var l=m[f[p]];var n=m[f[(p+1)%3]];d[0]=Math.min(l,n);d[1]=Math.max(l,n);l=d[0]+","+d[1];void 0===e[l]?e[l]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[l].face2=h}for(l in e)if(d=e[l],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.addAttribute("position",new F(c,3))}function Cb(a,b,c,d,e,f,g,h){G.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,
-radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new bb(a,b,c,d,e,f,g,h));this.mergeVertices()}function bb(a,b,c,d,e,f,g,h){function k(c){var e,f=new B,k=new n,q=0,u=!0===c?a:b,x=!0===c?1:-1;var C=r;for(e=1;e<=d;e++)l.push(0,w*x,0),v.push(0,x,0),t.push(.5,.5),r++;var E=r;for(e=0;e<=d;e++){var F=e/d*h+g,H=Math.cos(F);F=Math.sin(F);k.x=u*F;k.y=w*x;k.z=u*H;l.push(k.x,k.y,k.z);v.push(0,x,0);f.x=.5*H+.5;f.y=.5*F*x+.5;t.push(f.x,f.y);
-r++}for(e=0;ethis.duration&&this.resetDuration()}function eh(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ic;case "vector":case "vector2":case "vector3":case "vector4":return jc;case "color":return Hd;case "quaternion":return fd;case "bool":case "boolean":return Gd;case "string":return Jd}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+
-a);}function fh(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=eh(a.type);if(void 0===a.times){var c=[],d=[];sa.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)}function me(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};
-this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h=a;return this}}function Ka(a){this.manager=void 0!==a?a:Ba}function Cf(a){this.manager=void 0!==a?a:Ba}function Df(a){this.manager=void 0!==a?a:Ba;this._parser=null}function ne(a){this.manager=void 0!==a?a:Ba;this._parser=null}function gd(a){this.manager=
-void 0!==a?a:Ba}function oe(a){this.manager=void 0!==a?a:Ba}function Kd(a){this.manager=void 0!==a?a:Ba}function L(){this.type="Curve";this.arcLengthDivisions=200}function Ea(a,b,c,d,e,f,g,h){L.call(this);this.type="EllipseCurve";this.aX=a||0;this.aY=b||0;this.xRadius=c||1;this.yRadius=d||1;this.aStartAngle=e||0;this.aEndAngle=f||2*Math.PI;this.aClockwise=g||!1;this.aRotation=h||0}function kc(a,b,c,d,e,f){Ea.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function pe(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,
-f,g,h,k){e=k*(g-e);h=k*(h-f);a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},initNonuniformCatmullRom:function(e,f,g,h,k,m,p){e=((f-e)/k-(g-e)/(k+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+p)+(h-g)/p)*m;a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},calc:function(e){var f=e*e;return a+b*e+c*f+d*f*e}}}function oa(a,b,c,d){L.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function Ef(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*
-a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function hd(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function id(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function La(a,b,c,d){L.call(this);this.type="CubicBezierCurve";this.v0=a||new B;this.v1=b||new B;this.v2=c||new B;this.v3=d||new B}function Xa(a,b,c,d){L.call(this);this.type="CubicBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n;this.v3=d||new n}function ja(a,b){L.call(this);this.type="LineCurve";this.v1=a||
-new B;this.v2=b||new B}function Ma(a,b){L.call(this);this.type="LineCurve3";this.v1=a||new n;this.v2=b||new n}function Na(a,b,c){L.call(this);this.type="QuadraticBezierCurve";this.v0=a||new B;this.v1=b||new B;this.v2=c||new B}function Ya(a,b,c){L.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n}function Oa(a){L.call(this);this.type="SplineCurve";this.points=a||[]}function cb(){L.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function Pa(a){cb.call(this);
-this.type="Path";this.currentPoint=new B;a&&this.setFromPoints(a)}function kb(a){Pa.call(this,a);this.uuid=H.generateUUID();this.type="Shape";this.holes=[]}function ia(a,b){E.call(this);this.type="Light";this.color=new K(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function Ld(a,b,c){ia.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(E.DefaultUp);this.updateMatrix();this.groundColor=new K(b)}function Kb(a){this.camera=a;this.bias=0;this.radius=1;
-this.mapSize=new B(512,512);this.map=null;this.matrix=new J}function Md(){Kb.call(this,new S(50,1,.5,500))}function Nd(a,b,c,d,e,f){ia.call(this,a,b);this.type="SpotLight";this.position.copy(E.DefaultUp);this.updateMatrix();this.target=new E;Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new Md}
-function Od(a,b,c,d){ia.call(this,a,b);this.type="PointLight";Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new Kb(new S(90,1,.5,500))}function jd(a,b,c,d,e,f){Ua.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=void 0!==a?a:-1;this.right=void 0!==b?b:1;this.top=void 0!==c?c:1;this.bottom=void 0!==d?d:-1;this.near=void 0!==
-e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function Pd(){Kb.call(this,new jd(-5,5,5,-5,.5,500))}function Qd(a,b){ia.call(this,a,b);this.type="DirectionalLight";this.position.copy(E.DefaultUp);this.updateMatrix();this.target=new E;this.shadow=new Pd}function Rd(a,b){ia.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}function Sd(a,b,c,d){ia.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function Td(a){this.manager=void 0!==
-a?a:Ba;this.textures={}}function qe(a){this.manager=void 0!==a?a:Ba}function re(a){this.manager=void 0!==a?a:Ba;this.resourcePath=""}function se(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");this.manager=void 0!==a?a:Ba;this.options=void 0}function te(){this.type="ShapePath";this.color=new K;this.subPaths=[];this.currentPath=null}function ue(a){this.type=
-"Font";this.data=a}function Ff(a){this.manager=void 0!==a?a:Ba}function kd(){}function ve(a){this.manager=void 0!==a?a:Ba}function Gf(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new S;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new S;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function ld(a,b,c,d){E.call(this);this.type="CubeCamera";var e=new S(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new n(1,0,0));this.add(e);var f=new S(90,
-1,a,b);f.up.set(0,-1,0);f.lookAt(new n(-1,0,0));this.add(f);var g=new S(90,1,a,b);g.up.set(0,0,1);g.lookAt(new n(0,1,0));this.add(g);var h=new S(90,1,a,b);h.up.set(0,0,-1);h.lookAt(new n(0,-1,0));this.add(h);var k=new S(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new n(0,0,1));this.add(k);var m=new S(90,1,a,b);m.up.set(0,-1,0);m.lookAt(new n(0,0,-1));this.add(m);d=d||{format:1022,magFilter:1006,minFilter:1006};this.renderTarget=new mb(c,c,d);this.renderTarget.texture.name="CubeCamera";this.update=function(a,
-b){null===this.parent&&this.updateMatrixWorld();var c=a.getRenderTarget(),d=this.renderTarget,p=d.texture.generateMipmaps;d.texture.generateMipmaps=!1;a.setRenderTarget(d,0);a.render(b,e);a.setRenderTarget(d,1);a.render(b,f);a.setRenderTarget(d,2);a.render(b,g);a.setRenderTarget(d,3);a.render(b,h);a.setRenderTarget(d,4);a.render(b,k);d.texture.generateMipmaps=p;a.setRenderTarget(d,5);a.render(b,m);a.setRenderTarget(c)};this.clear=function(a,b,c,d){for(var e=a.getRenderTarget(),f=this.renderTarget,
-g=0;6>g;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function we(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function xe(){E.call(this);this.type="AudioListener";this.context=ye.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null;this.timeDelta=0}function lc(a){E.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());
-this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function ze(a){lc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function Ae(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function Be(a,
-b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function Hf(a,b,c){c=c||ma.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function ma(a,b,c){this.path=b;this.parsedPath=c||ma.parseTrackName(b);this.node=ma.findNode(a,this.parsedPath.nodeName)||
-a;this.rootNode=a}function If(){this.uuid=H.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function Jf(a,b,
-c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=
-this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Ce(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ud(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function De(){C.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function Ee(a,b,c){ub.call(this,a,b);this.meshPerAttribute=
-c||1}function Fe(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));P.call(this,a,b,c);this.meshPerAttribute=d||1}function Kf(a,b,c,d){this.ray=new tb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");
-return this.Points}}})}function Lf(a,b){return a.distance-b.distance}function Ge(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new F(b,3));b=new R({fog:!1});this.cone=new W(a,b);this.add(this.cone);this.update()}function Of(a){var b=[];a&&a.isBone&&b.push(a);for(var c=
-0;ca?-1:0b;b++)a[b]=(16>b?"0":"")+b.toString(16);return function(){var b=4294967295*Math.random()|0,d=4294967295*Math.random()|0,e=4294967295*Math.random()|0,f=4294967295*Math.random()|0;return(a[b&255]+a[b>>8&255]+a[b>>16&255]+a[b>>24&255]+"-"+a[d&255]+a[d>>8&255]+"-"+a[d>>
-16&15|64]+a[d>>24&255]+"-"+a[e&63|128]+a[e>>8&255]+"-"+a[e>>16&255]+a[e>>24&255]+a[f&255]+a[f>>8&255]+a[f>>16&255]+a[f>>24&255]).toUpperCase()}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;
-a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*H.DEG2RAD},radToDeg:function(a){return a*H.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/
-Math.LN2))}};Object.defineProperties(B.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(B.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+
-a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},
-addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=
-a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,
-b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a=new B,b=new B;return function(c,d){a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=
-Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+
-Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=
-(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);
-return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(J.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,k,m,l,q,n,t,r,u){var p=this.elements;p[0]=a;p[4]=b;p[8]=c;p[12]=d;p[1]=e;p[5]=f;p[9]=g;p[13]=h;p[2]=k;p[6]=m;p[10]=l;p[14]=q;p[3]=n;p[7]=t;p[11]=r;p[15]=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new J).fromArray(this.elements)},
-copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,
-b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a=new n;return function(b){var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[3]=0;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[7]=0;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this}}(),makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
-var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,p=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-p*d;b[9]=-c*g;b[2]=p-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,p=d*e,b[0]=a+p*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=p+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,p=d*e,b[0]=a-p*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=
-p-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,p=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+p,b[1]=g*e,b[5]=p*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,p=c*d,b[0]=g*h,b[4]=p-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-p*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,p=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+p,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=p*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(){var a=
-new n(0,0,0),b=new n(1,1,1);return function(c){return this.compose(a,c,b)}}(),lookAt:function(){var a=new n,b=new n,c=new n;return function(d,e,f){var g=this.elements;c.subVectors(d,e);0===c.lengthSq()&&(c.z=1);c.normalize();a.crossVectors(f,c);0===a.lengthSq()&&(1===Math.abs(f.z)?c.x+=1E-4:c.z+=1E-4,c.normalize(),a.crossVectors(f,c));a.normalize();b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==
-b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],k=c[5],m=c[9],p=c[13],l=c[2],n=c[6],t=c[10],r=c[14],u=c[3],w=c[7],z=c[11];c=c[15];var x=d[0],D=d[4],y=d[8],Q=d[12],B=d[1],A=d[5],C=d[9],F=d[13],E=d[2],
-H=d[6],G=d[10],I=d[14],L=d[3],J=d[7],K=d[11];d=d[15];b[0]=a*x+e*B+f*E+g*L;b[4]=a*D+e*A+f*H+g*J;b[8]=a*y+e*C+f*G+g*K;b[12]=a*Q+e*F+f*I+g*d;b[1]=h*x+k*B+m*E+p*L;b[5]=h*D+k*A+m*H+p*J;b[9]=h*y+k*C+m*G+p*K;b[13]=h*Q+k*F+m*I+p*d;b[2]=l*x+n*B+t*E+r*L;b[6]=l*D+n*A+t*H+r*J;b[10]=l*y+n*C+t*G+r*K;b[14]=l*Q+n*F+t*I+r*d;b[3]=u*x+w*B+z*E+c*L;b[7]=u*D+w*A+z*H+c*J;b[11]=u*y+w*C+z*G+c*K;b[15]=u*Q+w*F+z*I+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=
-a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(){var a=new n;return function(b){for(var c=0,d=b.count;cthis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.copy(this);c=1/g;f=1/h;var m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);
-e.x=g;e.y=h;e.z=k;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=
-2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];
-a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});Object.assign(aa,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],q=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==q){f=1-g;var n=h*d+k*l+m*q+c*e,t=0<=n?1:-1,r=1-n*n;r>Number.EPSILON&&(r=Math.sqrt(r),n=Math.atan2(r,n*t),f=Math.sin(f*n)/r,g=Math.sin(g*
-n)/r);t*=g;h=h*f+d*t;k=k*f+l*t;m=m*f+q*t;c=c*f+e*t;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(aa.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=
-a;this.onChangeCallback()}}});Object.assign(aa.prototype,{isQuaternion:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");
-var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),k=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"YXZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"ZXY"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"ZYX"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"YZX"===a?(this._x=
-c*k*f+h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f-c*d*e):"XZY"===a&&(this._x=c*k*f-h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f+c*d*e);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6];b=b[10];var m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a=new n,b;return function(c,d){void 0===a&&(a=new n);b=c.dot(d)+1;1E-6>b?
-(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),angleTo:function(a){return 2*Math.acos(Math.abs(H.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*
-a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),
+h(2960)},setMask:function(d){c===d||b||(a.stencilMask(d),c=d)},setFunc:function(b,c,g){if(d!==b||e!==c||f!==g)a.stencilFunc(b,c,g),d=b,e=c,f=g},setOp:function(b,c,d){if(k!==b||m!==c||p!==d)a.stencilOp(b,c,d),k=b,m=c,p=d},setLocked:function(a){b=a},setClear:function(b){q!==b&&(a.clearStencil(b),q=b)},reset:function(){b=!1;q=p=m=k=f=e=d=c=null}}},n=a.getParameter(34921),A=new Uint8Array(n),w=new Uint8Array(n),y=new Uint8Array(n),D={},J=null,ua=null,F=null,B=null,wd=null,E=null,fa=null,C=null,z=null,
+G=null,X=!1,Q=null,ce=null,da=null,Se=null,of=null,M=a.getParameter(35661),I=!1;n=0;n=a.getParameter(7938);-1!==n.indexOf("WebGL")?(n=parseFloat(/^WebGL ([0-9])/.exec(n)[1]),I=1<=n):-1!==n.indexOf("OpenGL ES")&&(n=parseFloat(/^OpenGL ES ([0-9])/.exec(n)[1]),I=2<=n);var P=null,Ea={},N=new Y,H=new Y,K={};K[3553]=e(3553,3553,1);K[34067]=e(34067,34069,6);l.setClear(0,0,0,1);r.setClear(1);u.setClear(0);g(2929);r.setFunc(3);m(!1);p(1);g(2884);k(0);return{buffers:{color:l,depth:r,stencil:u},initAttributes:function(){for(var a=
+0,b=A.length;ad||a.height>d)e=d/Math.max(a.width,a.height);if(1>e||!0===b){if("undefined"!==typeof HTMLImageElement&&a instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&a instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&a instanceof ImageBitmap)return d=b?K.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),
+void 0===C&&(C=h(b,e)),c=c?h(b,e):C,c.width=b,c.height=e,c.getContext("2d").drawImage(a,0,0,b,e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+b+"x"+e+")."),c;"data"in a&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").")}return a}function m(a){return K.isPowerOfTwo(a.width)&&K.isPowerOfTwo(a.height)}function p(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function q(b,c,e,
+f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function v(a,c){if(!e.isWebGL2)return a;var d=a;6403===a&&(5126===c&&(d=33326),5131===c&&(d=33325),5121===c&&(d=33321));6407===a&&(5126===c&&(d=34837),5131===c&&(d=34843),5121===c&&(d=32849));6408===a&&(5126===c&&(d=34836),5131===c&&(d=34842),5121===c&&(d=32856));33325===d||33326===d||34842===d||34836===d?b.get("EXT_color_buffer_float"):(34843===d||34837===d)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.");
+return d}function l(a){return 1003===a||1004===a||1005===a?9728:9729}function r(b){b=b.target;b.removeEventListener("dispose",r);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&delete E[b.id];g.memory.textures--}function u(b){b=b.target;b.removeEventListener("dispose",u);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=
+0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d.remove(b.texture);d.remove(b)}g.memory.textures--}function n(a,b){var e=d.get(a);if(a.isVideoTexture){var f=a.id,h=g.render.frame;E[f]!==h&&(E[f]=h,a.update())}if(0r;r++)t[r]=g||l?l?b.image[r].image:
+b.image[r]:k(b.image[r],!1,!0,e.maxCubemapSize);var u=t[0],n=m(u)||e.isWebGL2,x=f.convert(b.format),w=f.convert(b.type),Q=v(x,w);y(34067,b,n);for(r=0;6>r;r++)if(g)for(var X,J=t[r].mipmaps,A=0,F=J.length;A=e.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+e.maxTextures);z+=1;return a};this.resetTextureUnits=function(){z=0};this.setTexture2D=n;this.setTexture2DArray=function(a,b){var e=d.get(a);0r;r++)h.__webglFramebuffer[r]=a.createFramebuffer();else if(h.__webglFramebuffer=a.createFramebuffer(),r)if(e.isWebGL2){h.__webglMultisampledFramebuffer=
+a.createFramebuffer();h.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,h.__webglColorRenderbuffer);r=f.convert(b.texture.format);var x=f.convert(b.texture.type);r=v(r,x);x=B(b);a.renderbufferStorageMultisample(36161,x,r,b.width,b.height);a.bindFramebuffer(36160,h.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,h.__webglColorRenderbuffer);a.bindRenderbuffer(36161,null);b.depthBuffer&&(h.__webglDepthRenderbuffer=a.createRenderbuffer(),F(h.__webglDepthRenderbuffer,
+b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(l){c.bindTexture(34067,k.__webglTexture);y(34067,b.texture,t);for(r=0;6>r;r++)ua(h.__webglFramebuffer[r],b,36064,34069+r);p(b.texture,t)&&q(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,k.__webglTexture),y(3553,b.texture,t),ua(h.__webglFramebuffer,b,36064,3553),p(b.texture,t)&&q(3553,b.texture,b.width,b.height),c.bindTexture(3553,
+null);if(b.depthBuffer){h=d.get(b);k=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(k)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(36160,h.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&b.depthTexture.image.width===
+b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);n(b.depthTexture,0);h=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(36160,36096,3553,h,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,h,0);else throw Error("Unknown depthTexture format");}else if(k)for(h.__webglDepthbuffer=[],k=0;6>k;k++)a.bindFramebuffer(36160,h.__webglFramebuffer[k]),
+h.__webglDepthbuffer[k]=a.createRenderbuffer(),F(h.__webglDepthbuffer[k],b);else a.bindFramebuffer(36160,h.__webglFramebuffer),h.__webglDepthbuffer=a.createRenderbuffer(),F(h.__webglDepthbuffer,b);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(a){var b=a.texture,f=m(a)||e.isWebGL2;if(p(b,f)){f=a.isWebGLRenderTargetCube?34067:3553;var g=d.get(b).__webglTexture;c.bindTexture(f,g);q(f,b,a.width,a.height);c.bindTexture(f,null)}};this.updateMultisampleRenderTarget=function(b){if(b.isWebGLMultisampleRenderTarget)if(e.isWebGL2){var c=
+d.get(b);a.bindFramebuffer(36008,c.__webglMultisampledFramebuffer);a.bindFramebuffer(36009,c.__webglFramebuffer);c=b.width;var f=b.height,g=16384;b.depthBuffer&&(g|=256);b.stencilBuffer&&(g|=1024);a.blitFramebuffer(0,0,c,f,0,0,c,f,g,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")};this.safeSetTexture2D=function(a,b){a&&a.isWebGLRenderTarget&&(!1===G&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),
+G=!0),a=a.texture);n(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLRenderTargetCube&&(!1===I&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),I=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?A(a,b):w(a,b)}}function pf(a,b,c){return{convert:function(a){if(1E3===a)return 10497;if(1001===a)return 33071;if(1002===a)return 33648;if(1003===a)return 9728;if(1004===a)return 9984;
+if(1005===a)return 9986;if(1006===a)return 9729;if(1007===a)return 9985;if(1008===a)return 9987;if(1009===a)return 5121;if(1017===a)return 32819;if(1018===a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120;if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(c.isWebGL2)return 5131;var d=b.get("OES_texture_half_float");if(null!==d)return d.HALF_FLOAT_OES}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===
+a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410;if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(100===a)return 32774;if(101===a)return 32778;if(102===a)return 32779;if(200===a)return 0;if(201===a)return 1;if(202===a)return 768;if(203===a)return 769;if(204===a)return 770;if(205===a)return 771;if(206===a)return 772;if(207===a)return 773;if(208===a)return 774;if(209===a)return 775;if(210===a)return 776;if(33776===a||33777===a||33778===a||33779===a)if(d=b.get("WEBGL_compressed_texture_s3tc"),
+null!==d){if(33776===a)return d.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return d.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return d.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===a)return d.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===a||35841===a||35842===a||35843===a)if(d=b.get("WEBGL_compressed_texture_pvrtc"),null!==d){if(35840===a)return d.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===a)return d.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return d.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return d.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===
+a&&(d=b.get("WEBGL_compressed_texture_etc1"),null!==d))return d.COMPRESSED_RGB_ETC1_WEBGL;if(37808===a||37809===a||37810===a||37811===a||37812===a||37813===a||37814===a||37815===a||37816===a||37817===a||37818===a||37819===a||37820===a||37821===a)if(d=b.get("WEBGL_compressed_texture_astc"),null!==d)return a;if(103===a||104===a){if(c.isWebGL2){if(103===a)return 32775;if(104===a)return 32776}d=b.get("EXT_blend_minmax");if(null!==d){if(103===a)return d.MIN_EXT;if(104===a)return d.MAX_EXT}}if(1020===a){if(c.isWebGL2)return 34042;
+d=b.get("WEBGL_depth_texture");if(null!==d)return d.UNSIGNED_INT_24_8_WEBGL}return 0}}}function Vb(){C.call(this);this.type="Group"}function Xa(){C.call(this);this.type="Camera";this.matrixWorldInverse=new P;this.projectionMatrix=new P;this.projectionMatrixInverse=new P}function ja(a,b,c,d){Xa.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=
+0;this.updateProjectionMatrix()}function Gc(a){ja.call(this);this.cameras=a||[]}function qf(a,b,c){rf.setFromMatrixPosition(b.matrixWorld);sf.setFromMatrixPosition(c.matrixWorld);var d=rf.distanceTo(sf),e=b.projectionMatrix.elements,f=c.projectionMatrix.elements,g=e[14]/(e[10]-1);c=e[14]/(e[10]+1);var h=(e[9]+1)/e[5],k=(e[9]-1)/e[5],m=(e[8]-1)/e[0],p=(f[8]+1)/f[0];e=g*m;f=g*p;p=d/(-m+p);m=p*-m;b.matrixWorld.decompose(a.position,a.quaternion,a.scale);a.translateX(m);a.translateZ(p);a.matrixWorld.compose(a.position,
+a.quaternion,a.scale);a.matrixWorldInverse.getInverse(a.matrixWorld);b=g+p;g=c+p;a.projectionMatrix.makePerspective(e-m,f+(d-m),h*c/g*b,k*c/g*b,b,g)}function tf(a){function b(){return null!==e&&!0===e.isPresenting}function c(){if(b()){var c=e.getEyeParameters("left"),f=c.renderWidth*p;c=c.renderHeight*p;y=a.getPixelRatio();a.getSize(w);a.setDrawingBufferSize(2*f,c,1);J.start()}else d.enabled&&a.setDrawingBufferSize(w.width,w.height,y),J.stop()}var d=this,e=null,f=null,g=null,h=[],k=new P,m=new P,
+p=1,q="stage";"undefined"!==typeof window&&"VRFrameData"in window&&(f=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var v=new P,l=new aa,r=new n,u=new ja;u.bounds=new Y(0,0,.5,1);u.layers.enable(1);var x=new ja;x.bounds=new Y(.5,0,.5,1);x.layers.enable(2);var A=new Gc([u,x]);A.layers.enable(1);A.layers.enable(2);var w=new B,y,D=[];this.enabled=!1;this.getController=function(a){var b=h[a];void 0===b&&(b=new Vb,b.matrixAutoUpdate=!1,b.visible=!1,h[a]=b);return b};this.getDevice=
+function(){return e};this.setDevice=function(a){void 0!==a&&(e=a);J.setContext(a)};this.setFramebufferScaleFactor=function(a){p=a};this.setFrameOfReferenceType=function(a){q=a};this.setPoseTarget=function(a){void 0!==a&&(g=a)};this.getCamera=function(a){var c="stage"===q?1.6:0;if(!1===b())return a.position.set(0,c,0),a.rotation.set(0,0,0),a;e.depthNear=a.near;e.depthFar=a.far;e.getFrameData(f);if("stage"===q){var d=e.stageParameters;d?k.fromArray(d.sittingToStandingTransform):k.makeTranslation(0,
+c,0)}c=f.pose;d=null!==g?g:a;d.matrix.copy(k);d.matrix.decompose(d.position,d.quaternion,d.scale);null!==c.orientation&&(l.fromArray(c.orientation),d.quaternion.multiply(l));null!==c.position&&(l.setFromRotationMatrix(k),r.fromArray(c.position),r.applyQuaternion(l),d.position.add(r));d.updateMatrixWorld();u.near=a.near;x.near=a.near;u.far=a.far;x.far=a.far;u.matrixWorldInverse.fromArray(f.leftViewMatrix);x.matrixWorldInverse.fromArray(f.rightViewMatrix);m.getInverse(k);"stage"===q&&(u.matrixWorldInverse.multiply(m),
+x.matrixWorldInverse.multiply(m));a=d.parent;null!==a&&(v.getInverse(a.matrixWorld),u.matrixWorldInverse.multiply(v),x.matrixWorldInverse.multiply(v));u.matrixWorld.getInverse(u.matrixWorldInverse);x.matrixWorld.getInverse(x.matrixWorldInverse);u.projectionMatrix.fromArray(f.leftProjectionMatrix);x.projectionMatrix.fromArray(f.rightProjectionMatrix);qf(A,u,x);a=e.getLayers();a.length&&(a=a[0],null!==a.leftBounds&&4===a.leftBounds.length&&u.bounds.fromArray(a.leftBounds),null!==a.rightBounds&&4===
+a.rightBounds.length&&x.bounds.fromArray(a.rightBounds));a:for(a=0;af.matrixWorld.determinant();ca.setMaterial(e,h);var k=l(a,c,e,f),m=!1;if(b!==d.id||O!==k.id||da!==(!0===e.wireframe))b=d.id,O=k.id,da=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(va.update(f,d,e,k),m=!0);h=d.index;var p=d.attributes.position;c=1;!0===e.wireframe&&(h=sa.getWireframeAttribute(d),c=2);a=wa;if(null!==h){var q=pa.get(h);a=ya;a.setIndex(q)}if(m){if(d&&
+d.isInstancedBufferGeometry&&!Aa.isWebGL2&&null===na.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{ca.initAttributes();m=d.attributes;k=k.getAttributes();var v=e.defaultAttributeValues;for(D in k){var r=k[D];if(0<=r){var t=m[D];if(void 0!==t){var n=t.normalized,u=t.itemSize,x=pa.get(t);if(void 0!==x){var w=x.buffer,A=x.type;x=x.bytesPerElement;if(t.isInterleavedBufferAttribute){var y=
+t.data,J=y.stride;t=t.offset;y&&y.isInstancedInterleavedBuffer?(ca.enableAttributeAndDivisor(r,y.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=y.meshPerAttribute*y.count)):ca.enableAttribute(r);L.bindBuffer(34962,w);L.vertexAttribPointer(r,u,A,n,J*x,t*x)}else t.isInstancedBufferAttribute?(ca.enableAttributeAndDivisor(r,t.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=t.meshPerAttribute*t.count)):ca.enableAttribute(r),L.bindBuffer(34962,w),L.vertexAttribPointer(r,
+u,A,n,0,0)}}else if(void 0!==v&&(n=v[D],void 0!==n))switch(n.length){case 2:L.vertexAttrib2fv(r,n);break;case 3:L.vertexAttrib3fv(r,n);break;case 4:L.vertexAttrib4fv(r,n);break;default:L.vertexAttrib1fv(r,n)}}}ca.disableUnusedAttributes()}null!==h&&L.bindBuffer(34963,q.buffer)}q=Infinity;null!==h?q=h.count:void 0!==p&&(q=p.count);h=d.drawRange.start*c;p=null!==g?g.start*c:0;var D=Math.max(h,p);g=Math.max(0,Math.min(q,h+d.drawRange.count*c,p+(null!==g?g.count*c:Infinity))-1-D+1);if(0!==g){if(f.isMesh)if(!0===
+e.wireframe)ca.setLineWidth(e.wireframeLinewidth*(null===N?H:1)),a.setMode(1);else switch(f.drawMode){case 0:a.setMode(4);break;case 1:a.setMode(5);break;case 2:a.setMode(6)}else f.isLine?(e=e.linewidth,void 0===e&&(e=1),ca.setLineWidth(e*(null===N?H:1)),f.isLineSegments?a.setMode(1):f.isLineLoop?a.setMode(2):a.setMode(3)):f.isPoints?a.setMode(0):f.isSprite&&a.setMode(4);d&&d.isInstancedBufferGeometry?0c;c++){var q=p[h[c]];var l=p[h[(c+1)%3]];f[0]=Math.min(q,l);f[1]=Math.max(q,l);q=f[0]+","+f[1];void 0===g[q]&&(g[q]={index1:f[0],index2:f[1]})}}for(q in g)m=g[q],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new n,null!==a.index){k=
+a.attributes.position;p=a.index;var t=a.groups;0===t.length&&(t=[{start:0,count:p.count,materialIndex:0}]);a=0;for(e=t.length;ac;c++)q=p.getX(m+c),l=p.getX(m+(c+1)%3),f[0]=Math.min(q,l),f[1]=Math.max(q,l),q=f[0]+","+f[1],void 0===g[q]&&(g[q]={index1:f[0],index2:f[1]});for(q in g)m=g[q],h.fromBufferAttribute(k,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(k,m.index2),b.push(h.x,h.y,h.z)}else for(k=a.attributes.position,m=0,d=
+k.count/3;mc;c++)g=3*m+c,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(k,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new E(b,3))}function Nc(a,b,c){N.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new $b(a,b,c));this.mergeVertices()}function $b(a,b,c){z.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new n,
+k=new n,m=new n,p=new n,q=new n,l,t;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var r=b+1;for(l=0;l<=c;l++){var u=l/c;for(t=0;t<=b;t++){var x=t/b;a(x,u,k);e.push(k.x,k.y,k.z);0<=x-1E-5?(a(x-1E-5,u,m),p.subVectors(k,m)):(a(x+1E-5,u,m),p.subVectors(m,k));0<=u-1E-5?(a(x,u-1E-5,m),q.subVectors(k,m)):(a(x,u+1E-5,m),q.subVectors(m,k));h.crossVectors(p,q).normalize();f.push(h.x,h.y,h.z);g.push(x,u)}}for(l=0;ld&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}z.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],k=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",
+new E(h,3));this.addAttribute("normal",new E(h.slice(),3));this.addAttribute("uv",new E(k,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Pc(a,b){N.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new ac(a,b));this.mergeVertices()}function ac(a,b){ka.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Qc(a,b){N.call(this);
+this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new yb(a,b));this.mergeVertices()}function yb(a,b){ka.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Rc(a,b){N.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new bc(a,b));this.mergeVertices()}function bc(a,b){var c=
+(1+Math.sqrt(5))/2;ka.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Sc(a,b){N.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new cc(a,b));this.mergeVertices()}function cc(a,b){var c=
+(1+Math.sqrt(5))/2,d=1/c;ka.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters=
+{radius:a,detail:b}}function Tc(a,b,c,d,e,f){N.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new zb(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function zb(a,b,c,d,e){function f(e){p=a.getPointAt(e/b,p);var f=g.normals[e];e=g.binormals[e];for(l=0;l<=d;l++){var m=l/d*Math.PI*
+2,q=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+q*e.x;k.y=m*f.y+q*e.y;k.z=m*f.z+q*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=p.x+c*k.x;h.y=p.y+c*k.y;h.z=p.z+c*k.z;t.push(h.x,h.y,h.z)}}z.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new n,k=new n,m=new B,p=new n,q,l,t=[],r=[],u=[],x=[];for(q=
+0;q=b;e-=d)f=wf(e,a[e],a[e+1],f);f&&Ab(f,f.next)&&(Wc(f),f=f.next);return f}function Xc(a,b){if(!a)return a;
+b||(b=a);do{var c=!1;if(a.steiner||!Ab(a,a.next)&&0!==wa(a.prev,a,a.next))a=a.next;else{Wc(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function Yc(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=je(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,p,q,l,t=1;do{k=h;var r=h=null;for(p=0;k;){p++;var n=k;for(m=q=0;mq.x?p.x>t.x?p.x:t.x:q.x>t.x?q.x:t.x,y=p.y>q.y?p.y>t.y?p.y:t.y:q.y>t.y?q.y:t.y;m=je(p.x=m;){if(x!==r.prev&&x!==r.next&&Dd(p.x,p.y,q.x,q.y,t.x,t.y,x.x,x.y)&&0<=wa(x.prev,x,x.next)){r=!1;break a}x=x.prevZ}r=!0}}else a:if(r=a,p=r.prev,q=r,t=r.next,0<=wa(p,q,t))r=!1;else{for(m=r.next.next;m!==r.prev;){if(Dd(p.x,p.y,q.x,q.y,t.x,t.y,m.x,m.y)&&0<=wa(m.prev,m,m.next)){r=!1;break a}m=m.next}r=!0}if(r)b.push(k.i/c),b.push(a.i/c),b.push(n.i/c),Wc(a),h=a=n.next;else if(a=n,a===h){if(!g)Yc(Xc(a),b,c,d,e,f,1);else if(1===g){g=b;h=c;k=a;do n=k.prev,
+r=k.next.next,!Ab(n,r)&&xf(n,k,k.next,r)&&Zc(n,r)&&Zc(r,n)&&(g.push(n.i/h),g.push(k.i/h),g.push(r.i/h),Wc(k),Wc(k.next),k=a=r),k=k.next;while(k!==a);a=k;Yc(a,b,c,d,e,f,2)}else if(2===g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(k=g.i!==h.i){k=g;n=h;if(r=k.next.i!==n.i&&k.prev.i!==n.i){b:{r=k;do{if(r.i!==k.i&&r.next.i!==k.i&&r.i!==n.i&&r.next.i!==n.i&&xf(r,r.next,k,n)){r=!0;break b}r=r.next}while(r!==k);r=!1}r=!r}if(r=r&&Zc(k,n)&&Zc(n,k)){r=k;p=!1;q=(k.x+n.x)/2;n=(k.y+n.y)/2;do r.y>n!==r.next.y>n&&
+r.next.y!==r.y&&q<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(p=!p),r=r.next;while(r!==k);r=p}k=r}if(k){a=yf(g,h);g=Xc(g,g.next);a=Xc(a,a.next);Yc(g,b,c,d,e,f);Yc(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function eh(a,b){return a.x-b.x}function fh(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x=c.x&&c.x>=g&&d!==c.x&&Dd(eh.x)&&Zc(c,a)&&(h=c,m=p)}c=c.next}return h}function je(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function gh(a){var b=
+a,c=a;do b.xwa(a.prev,a,a.next)?0<=wa(a,b,a.next)&&0<=wa(a,a.prev,b):0>wa(a,b,a.prev)||
+0>wa(a,a.next,b)}function yf(a,b){var c=new ke(a.i,a.x,a.y),d=new ke(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function wf(a,b,c,d){a=new ke(a,b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function Wc(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function ke(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next=
+this.prev=null;this.steiner=!1}function zf(a){var b=a.length;2Number.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/k;b=b.y+d/k;g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+d*d;if(2>=e)return new B(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new B(f/e,d/e)}function h(a,b){for(H=a.length;0<=
+--H;){var c=H;var f=H-1;0>f&&(f=a.length-1);var g,h=w+2*F;for(g=0;gp;p++){var l=m[f[p]];var n=m[f[(p+1)%3]];d[0]=Math.min(l,n);d[1]=Math.max(l,n);l=d[0]+","+d[1];void 0===e[l]?e[l]={index1:d[0],index2:d[1],
+face1:h,face2:void 0}:e[l].face2=h}for(l in e)if(d=e[l],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.addAttribute("position",new E(c,3))}function Fb(a,b,c,d,e,f,g,h){N.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new db(a,b,c,d,e,f,g,h));this.mergeVertices()}function db(a,
+b,c,d,e,f,g,h){function k(c){var e,f=new B,k=new n,q=0,u=!0===c?a:b,w=!0===c?1:-1;var z=r;for(e=1;e<=d;e++)l.push(0,x*w,0),v.push(0,w,0),t.push(.5,.5),r++;var C=r;for(e=0;e<=d;e++){var E=e/d*h+g,G=Math.cos(E);E=Math.sin(E);k.x=u*E;k.y=x*w;k.z=u*G;l.push(k.x,k.y,k.z);v.push(0,w,0);f.x=.5*G+.5;f.y=.5*E*w+.5;t.push(f.x,f.y);r++}for(e=0;ethis.duration&&this.resetDuration()}function ih(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return lc;case "vector":case "vector2":case "vector3":case "vector4":return mc;case "color":return Hd;case "quaternion":return hd;case "bool":case "boolean":return Gd;case "string":return Jd}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function jh(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");
+var b=ih(a.type);if(void 0===a.times){var c=[],d=[];pa.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)}function le(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};
+this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h=a;return this}}function Ma(a){this.manager=void 0!==a?a:za}function Df(a){this.manager=void 0!==a?a:za}function Ef(a){this.manager=void 0!==a?a:za;this._parser=null}function me(a){this.manager=void 0!==a?a:za;this._parser=null}function id(a){this.manager=void 0!==a?a:za}function ne(a){this.manager=void 0!==a?a:za}function Kd(a){this.manager=void 0!==a?a:za}
+function I(){this.type="Curve";this.arcLengthDivisions=200}function Ga(a,b,c,d,e,f,g,h){I.call(this);this.type="EllipseCurve";this.aX=a||0;this.aY=b||0;this.xRadius=c||1;this.yRadius=d||1;this.aStartAngle=e||0;this.aEndAngle=f||2*Math.PI;this.aClockwise=g||!1;this.aRotation=h||0}function nc(a,b,c,d,e,f){Ga.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function oe(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,f,g,h,k){e=k*(g-e);h=k*(h-f);a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},initNonuniformCatmullRom:function(e,
+f,g,h,k,m,p){e=((f-e)/k-(g-e)/(k+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+p)+(h-g)/p)*m;a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},calc:function(e){var f=e*e;return a+b*e+c*f+d*f*e}}}function qa(a,b,c,d){I.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function Ff(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function jd(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function kd(a,
+b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function Na(a,b,c,d){I.call(this);this.type="CubicBezierCurve";this.v0=a||new B;this.v1=b||new B;this.v2=c||new B;this.v3=d||new B}function $a(a,b,c,d){I.call(this);this.type="CubicBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n;this.v3=d||new n}function xa(a,b){I.call(this);this.type="LineCurve";this.v1=a||new B;this.v2=b||new B}function Oa(a,b){I.call(this);this.type="LineCurve3";this.v1=a||new n;this.v2=b||
+new n}function Pa(a,b,c){I.call(this);this.type="QuadraticBezierCurve";this.v0=a||new B;this.v1=b||new B;this.v2=c||new B}function ab(a,b,c){I.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n}function Qa(a){I.call(this);this.type="SplineCurve";this.points=a||[]}function eb(){I.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function Ra(a){eb.call(this);this.type="Path";this.currentPoint=new B;a&&this.setFromPoints(a)}function nb(a){Ra.call(this,
+a);this.uuid=K.generateUUID();this.type="Shape";this.holes=[]}function ea(a,b){C.call(this);this.type="Light";this.color=new M(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function Ld(a,b,c){ea.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(C.DefaultUp);this.updateMatrix();this.groundColor=new M(b)}function Nb(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new B(512,512);this.map=null;this.matrix=new P}function Md(){Nb.call(this,new ja(50,
+1,.5,500))}function Nd(a,b,c,d,e,f){ea.call(this,a,b);this.type="SpotLight";this.position.copy(C.DefaultUp);this.updateMatrix();this.target=new C;Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new Md}function Od(a,b,c,d){ea.call(this,a,b);this.type="PointLight";Object.defineProperty(this,"power",
+{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new Nb(new ja(90,1,.5,500))}function ld(a,b,c,d,e,f){Xa.call(this);this.type="OrthographicCamera";this.zoom=1;this.view=null;this.left=void 0!==a?a:-1;this.right=void 0!==b?b:1;this.top=void 0!==c?c:1;this.bottom=void 0!==d?d:-1;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function Pd(){Nb.call(this,
+new ld(-5,5,5,-5,.5,500))}function Qd(a,b){ea.call(this,a,b);this.type="DirectionalLight";this.position.copy(C.DefaultUp);this.updateMatrix();this.target=new C;this.shadow=new Pd}function Rd(a,b){ea.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}function Sd(a,b,c,d){ea.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function Td(a){this.manager=void 0!==a?a:za;this.textures={}}function pe(a){this.manager=void 0!==a?a:za}function qe(a){this.manager=
+void 0!==a?a:za;this.resourcePath=""}function re(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");this.manager=void 0!==a?a:za;this.options=void 0}function se(){this.type="ShapePath";this.color=new M;this.subPaths=[];this.currentPath=null}function te(a){this.type="Font";this.data=a}function Gf(a){this.manager=void 0!==a?a:za}function md(){}
+function ue(a){this.manager=void 0!==a?a:za}function Hf(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new ja;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new ja;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function nd(a,b,c,d){C.call(this);this.type="CubeCamera";var e=new ja(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new n(1,0,0));this.add(e);var f=new ja(90,1,a,b);f.up.set(0,-1,0);f.lookAt(new n(-1,0,0));this.add(f);var g=new ja(90,
+1,a,b);g.up.set(0,0,1);g.lookAt(new n(0,1,0));this.add(g);var h=new ja(90,1,a,b);h.up.set(0,0,-1);h.lookAt(new n(0,-1,0));this.add(h);var k=new ja(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new n(0,0,1));this.add(k);var m=new ja(90,1,a,b);m.up.set(0,-1,0);m.lookAt(new n(0,0,-1));this.add(m);d=d||{format:1022,magFilter:1006,minFilter:1006};this.renderTarget=new pb(c,c,d);this.renderTarget.texture.name="CubeCamera";this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=a.getRenderTarget(),
+d=this.renderTarget,p=d.texture.generateMipmaps;d.texture.generateMipmaps=!1;a.setRenderTarget(d,0);a.render(b,e);a.setRenderTarget(d,1);a.render(b,f);a.setRenderTarget(d,2);a.render(b,g);a.setRenderTarget(d,3);a.render(b,h);a.setRenderTarget(d,4);a.render(b,k);d.texture.generateMipmaps=p;a.setRenderTarget(d,5);a.render(b,m);a.setRenderTarget(c)};this.clear=function(a,b,c,d){for(var e=a.getRenderTarget(),f=this.renderTarget,g=0;6>g;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function ve(a){this.autoStart=
+void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function we(){C.call(this);this.type="AudioListener";this.context=xe.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null;this.timeDelta=0}function oc(a){C.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=
+this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function ye(a){oc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function ze(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function Ae(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=
+this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function If(a,b,c){c=c||ma.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function ma(a,b,c){this.path=b;this.parsedPath=c||ma.parseTrackName(b);this.node=ma.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function Jf(){this.uuid=K.generateUUID();this._objects=Array.prototype.slice.call(arguments);
+this.nCachedObjects_=0;var a={};this._indicesByUUID=a;for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function Kf(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,
+endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=
+this.zeroSlopeAtStart=!0}function Be(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ud(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Ce(){z.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function De(a,b,c){xb.call(this,a,b);this.meshPerAttribute=c||1}function Ee(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));
+S.call(this,a,b,c);this.meshPerAttribute=d||1}function Lf(a,b,c,d){this.ray=new wb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function Mf(a,b){return a.distance-b.distance}function Fe(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=
+a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new E(b,3));b=new R({fog:!1});this.cone=new V(a,b);this.add(this.cone);this.update()}function Pf(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;c
+a?-1:0b;b++)a[b]=(16>b?"0":"")+b.toString(16);return function(){var b=4294967295*Math.random()|0,d=4294967295*Math.random()|0,e=4294967295*Math.random()|0,f=4294967295*Math.random()|0;return(a[b&255]+a[b>>8&255]+a[b>>16&255]+a[b>>24&255]+"-"+a[d&255]+a[d>>8&255]+"-"+a[d>>16&15|64]+a[d>>24&255]+
+"-"+a[e&63|128]+a[e>>8&255]+"-"+a[e>>16&255]+a[e>>24&255]+a[f&255]+a[f>>8&255]+a[f>>16&255]+a[f>>24&255]).toUpperCase()}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*
+a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*K.DEG2RAD},radToDeg:function(a){return a*K.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}};Object.defineProperties(B.prototype,
+{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(B.prototype,{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;
+case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},
+addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
+divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,
+this.y));return this},clampScalar:function(){var a=new B,b=new B;return function(c,d){a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=
+0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||
+1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,
+a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=
+this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(aa,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var p=e[f+1],l=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==p||m!==l){f=1-g;var n=h*d+k*p+m*l+c*e,t=0<=n?1:-1,r=1-n*n;r>Number.EPSILON&&(r=Math.sqrt(r),n=Math.atan2(r,n*t),f=Math.sin(f*n)/r,g=Math.sin(g*n)/r);t*=g;h=h*f+d*t;k=k*f+p*t;m=m*f+l*t;c=c*f+e*t;f===1-g&&(g=1/Math.sqrt(h*
+h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(aa.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=a;this.onChangeCallback()}}});Object.assign(aa.prototype,{isQuaternion:!0,
+set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/
+2),k=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"YXZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"ZXY"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"ZYX"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"YZX"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f-
+c*d*e):"XZY"===a&&(this._x=c*k*f-h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f+c*d*e);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6];b=b[10];var m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(a,b){var c=a.dot(b)+1;1E-6>c?(c=0,Math.abs(a.x)>Math.abs(a.z)?(this._x=-a.y,this._y=a.x,this._z=0):(this._x=0,this._y=-a.z,this._z=a.y)):(this._x=
+a.y*b.z-a.z*b.y,this._y=a.z*b.x-a.x*b.z,this._z=a.x*b.y-a.y*b.x);this._w=c;return this.normalize()},angleTo:function(a){return 2*Math.acos(Math.abs(K.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},
+lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),
this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;var f=b._x,g=b._y,h=b._z;b=b._w;this._x=c*b+a*f+d*h-e*g;this._y=d*b+a*g+e*f-c*h;this._z=e*b+a*h+c*g-d*f;this._w=a*b-c*f-d*g-e*h;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;
0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize();a=Math.sqrt(a);var h=Math.atan2(a,g);g=Math.sin((1-b)*h)/a;b=Math.sin(b*h)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this.onChangeCallback();return this},equals:function(a){return a._x===
this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},
@@ -359,64 +343,82 @@ this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},a
a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),
this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a=new aa;return function(b){b&&b.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a=new aa;return function(b,
c){return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,
-c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)},unproject:function(){var a=new J;return function(b){return this.applyMatrix4(a.getInverse(b.projectionMatrix)).applyMatrix4(b.matrixWorld)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=
-a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,
-Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a=new n,b=new n;return function(c,d){a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);
-this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*
+c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)},unproject:function(a){return this.applyMatrix4(a.projectionMatrixInverse).applyMatrix4(a.matrixWorld)},transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;
+this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=
+Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a=new n,b=new n;return function(c,d){a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);
+this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*
this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},
cross:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b)):this.crossVectors(this,a)},crossVectors:function(a,b){var c=a.x,d=a.y;a=a.z;var e=b.x,f=b.y;b=b.z;this.x=d*b-a*f;this.y=a*e-c*b;this.z=c*f-d*e;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a=new n;return function(b){a.copy(this).projectOnVector(b);
-return this.sub(a)}}(),reflect:function(){var a=new n;return function(b){return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(H.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-
+return this.sub(a)}}(),reflect:function(){var a=new n;return function(b){return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(K.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-
a.z)},setFromSpherical:function(a){return this.setFromSphericalCoords(a.radius,a.phi,a.theta)},setFromSphericalCoords:function(a,b,c){var d=Math.sin(b)*a;this.x=d*Math.sin(c);this.y=Math.cos(b)*a;this.z=d*Math.cos(c);return this},setFromCylindrical:function(a){return this.setFromCylindricalCoords(a.radius,a.theta,a.y)},setFromCylindricalCoords:function(a,b,c){this.x=a*Math.sin(b);this.y=c;this.z=a*Math.cos(b);return this},setFromMatrixPosition:function(a){a=a.elements;this.x=a[12];this.y=a[13];this.z=
a[14];return this},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===
-b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});Object.assign(pa.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},
+b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});Object.assign(ba.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},
copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToBufferAttribute:function(){var a=new n;return function(b){for(var c=0,d=b.count;cc;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=
-this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}});var tc,lb={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===tc&&(tc=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));tc.width=a.width;tc.height=a.height;var b=tc.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=tc}return 2048<
-a.width||2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y);return a}});Object.defineProperty(V.prototype,
-"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(ba.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=
+magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var d=this.image;void 0===d.uuid&&(d.uuid=K.generateUUID());if(!b&&void 0===a.images[d.uuid]){if(Array.isArray(d)){var e=[];for(var f=0,g=d.length;fa.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y);return a}});Object.defineProperty(W.prototype,
+"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(Y.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=
b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),
this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,
b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*
e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){a=a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var h=a[2];var k=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-k)){if(.1>Math.abs(c+
e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+k)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+k)/4;b>f&&b>m?.01>b?(k=0,c=h=.707106781):(k=Math.sqrt(b),h=c/k,c=d/k):f>m?.01>f?(k=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),k=c/h,c=g/h):.01>m?(h=k=.707106781,c=0):(c=Math.sqrt(m),k=d/c,h=g/c);this.set(k,h,c,a);return this}a=Math.sqrt((k-g)*(k-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(k-g)/a;this.y=(d-h)/a;this.z=(e-c)/a;
this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,
-this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new ba,b=new ba);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);
+this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new Y,b=new Y);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);
this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},
dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=
(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromBufferAttribute:function(a,
-b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}});Ra.prototype=Object.assign(Object.create(ka.prototype),{constructor:Ra,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=
-a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Zd.prototype=Object.assign(Object.create(Ra.prototype),{constructor:Zd,isWebGLMultisampleRenderTarget:!0,copy:function(a){Ra.prototype.copy.call(this,a);this.samples=a.samples;return this}});mb.prototype=Object.create(Ra.prototype);mb.prototype.constructor=
-mb;mb.prototype.isWebGLRenderTargetCube=!0;nb.prototype=Object.create(V.prototype);nb.prototype.constructor=nb;nb.prototype.isDataTexture=!0;Object.assign(Za.prototype,{isBox3:!0,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;he&&(e=m);l>f&&(f=l);q>g&&(g=q)}this.min.set(b,c,d);this.max.set(e,
-f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.count;he&&(e=m);l>f&&(f=l);q>g&&(g=q)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;be&&(e=m);p>f&&(f=p);l>g&&(g=l)}this.min.set(b,c,d);this.max.set(e,
+f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.count;he&&(e=m);p>f&&(f=p);l>g&&(g=l)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"),b=new n);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},
intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},intersectsSphere:function(){var a=new n;return function(b){this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){if(0=-a.constant},intersectsTriangle:function(){function a(a){var e;var f=0;for(e=a.length-3;f<=e;f+=3){h.fromArray(a,f);var g=m.x*Math.abs(h.x)+m.y*Math.abs(h.y)+m.z*Math.abs(h.z),k=b.dot(h),l=c.dot(h),p=d.dot(h);if(Math.max(-Math.max(k,l,p),Math.min(k,l,p))>g)return!1}return!0}var b=new n,
-c=new n,d=new n,e=new n,f=new n,g=new n,h=new n,k=new n,m=new n,l=new n;return function(h){if(this.isEmpty())return!1;this.getCenter(k);m.subVectors(this.max,k);b.subVectors(h.a,k);c.subVectors(h.b,k);d.subVectors(h.c,k);e.subVectors(c,b);f.subVectors(d,c);g.subVectors(b,d);h=[0,-e.z,e.y,0,-f.z,f.y,0,-g.z,g.y,e.z,0,-e.x,f.z,0,-f.x,g.z,0,-g.x,-e.y,e.x,0,-f.y,f.x,0,-g.y,g.x,0];if(!a(h))return!1;h=[1,0,0,0,1,0,0,0,1];if(!a(h))return!1;l.crossVectors(e,f);h=[l.x,l.y,l.z];return a(h)}}(),clampPoint:function(a,
-b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new n);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new n;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new n;return function(b){void 0===b&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),b=new Ha);this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);
+a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y);0=-a.constant},intersectsTriangle:function(){function a(a){var e;var f=0;for(e=a.length-3;f<=e;f+=3){h.fromArray(a,f);var g=m.x*Math.abs(h.x)+m.y*Math.abs(h.y)+m.z*Math.abs(h.z),k=b.dot(h),p=c.dot(h),l=d.dot(h);if(Math.max(-Math.max(k,p,l),Math.min(k,p,l))>g)return!1}return!0}var b=new n,
+c=new n,d=new n,e=new n,f=new n,g=new n,h=new n,k=new n,m=new n,p=new n;return function(h){if(this.isEmpty())return!1;this.getCenter(k);m.subVectors(this.max,k);b.subVectors(h.a,k);c.subVectors(h.b,k);d.subVectors(h.c,k);e.subVectors(c,b);f.subVectors(d,c);g.subVectors(b,d);h=[0,-e.z,e.y,0,-f.z,f.y,0,-g.z,g.y,e.z,0,-e.x,f.z,0,-f.x,g.z,0,-g.x,-e.y,e.x,0,-f.y,f.x,0,-g.y,g.x,0];if(!a(h))return!1;h=[1,0,0,0,1,0,0,0,1];if(!a(h))return!1;p.crossVectors(e,f);h=[p.x,p.y,p.z];return a(h)}}(),clampPoint:function(a,
+b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new n);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new n;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new n;return function(b){void 0===b&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);
this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new n,new n,new n,new n,new n,new n,new n,new n];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);
-a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Ha.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},
-setFromPoints:function(){var a=new Za;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=c=0,f=b.length;e=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},
+a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Ua.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},
+setFromPoints:function(){var a=new Ja;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=c=0,f=b.length;e=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},
distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a);void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),b=new n);b.copy(a);c>this.radius*
-this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Za);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&
-a.radius===this.radius}});Object.assign(Sa.prototype,{set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new n,b=new n;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),
+this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new Ja);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&
+a.radius===this.radius}});Object.assign(Va.prototype,{set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new n,b=new n;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),
clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){void 0===
b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new n);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)},intersectLine:function(){var a=new n;return function(b,c){void 0===c&&(console.warn("THREE.Plane: .intersectLine() target is now required"),c=new n);var d=b.delta(a),e=this.normal.dot(d);if(0===e){if(0===this.distanceToPoint(b.start))return c.copy(b.start)}else if(e=-(b.start.dot(this.normal)+this.constant)/e,!(0>e||1b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],l=c[8],q=c[9],n=c[10],t=c[11],r=c[12],u=c[13],w=c[14];c=c[15];b[0].setComponents(f-a,m-g,t-l,c-r).normalize();b[1].setComponents(f+a,m+g,t+l,c+r).normalize();b[2].setComponents(f+d,m+h,t+q,c+u).normalize();b[3].setComponents(f-d,m-h,t-q,c-u).normalize();b[4].setComponents(f-e,m-k,t-n,c-w).normalize();b[5].setComponents(f+e,
-m+k,t+n,c+w).normalize();return this},intersectsObject:function(){var a=new Ha;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a=new Ha;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=
-0;6>d;d++)if(b[d].distanceToPoint(c)d;d++){var e=c[d];a.x=0e.distanceToPoint(a))return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var U={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",
+intersectsLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],p=c[8],l=c[9],n=c[10],t=c[11],r=c[12],u=c[13],x=c[14];c=c[15];b[0].setComponents(f-a,m-g,t-p,c-r).normalize();b[1].setComponents(f+a,m+g,t+p,c+r).normalize();b[2].setComponents(f+d,m+h,t+l,c+u).normalize();b[3].setComponents(f-d,m-h,t-l,c-u).normalize();b[4].setComponents(f-e,m-k,t-n,c-x).normalize();b[5].setComponents(f+e,
+m+k,t+n,c+x).normalize();return this},intersectsObject:function(){var a=new Ua;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a=new Ua;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=
+0;6>d;d++)if(b[d].distanceToPoint(c)d;d++){var e=c[d];a.x=0e.distanceToPoint(a))return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});Object.assign(P.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,k,m,l,q,n,t,r,u){var p=
+this.elements;p[0]=a;p[4]=b;p[8]=c;p[12]=d;p[1]=e;p[5]=f;p[9]=g;p[13]=h;p[2]=k;p[6]=m;p[10]=l;p[14]=q;p[3]=n;p[7]=t;p[11]=r;p[15]=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new P).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},
+copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a=new n;return function(b){var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();
+b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[3]=0;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[7]=0;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this}}(),makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);
+e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,p=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-p*d;b[9]=-c*g;b[2]=p-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,p=d*e,b[0]=a+p*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=p+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,p=d*e,b[0]=a-p*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=p-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,p=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+p,b[1]=g*e,b[5]=
+p*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,p=c*d,b[0]=g*h,b[4]=p-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-p*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,p=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+p,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=p*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(){var a=new n(0,0,0),b=new n(1,1,1);return function(c){return this.compose(a,c,b)}}(),lookAt:function(){var a=
+new n,b=new n,c=new n;return function(d,e,f){var g=this.elements;c.subVectors(d,e);0===c.lengthSq()&&(c.z=1);c.normalize();a.crossVectors(f,c);0===a.lengthSq()&&(1===Math.abs(f.z)?c.x+=1E-4:c.z+=1E-4,c.normalize(),a.crossVectors(f,c));a.normalize();b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),
+this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],k=c[5],m=c[9],p=c[13],l=c[2],n=c[6],t=c[10],r=c[14],u=c[3],x=c[7],A=c[11];c=c[15];var w=d[0],y=d[4],D=d[8],J=d[12],B=d[1],F=d[5],C=d[9],z=d[13],E=d[2],G=d[6],I=d[10],K=d[14],M=d[3],X=d[7],Q=d[11];d=d[15];b[0]=a*w+e*B+f*E+g*M;b[4]=a*y+e*F+f*G+g*X;b[8]=a*D+e*C+f*I+
+g*Q;b[12]=a*J+e*z+f*K+g*d;b[1]=h*w+k*B+m*E+p*M;b[5]=h*y+k*F+m*G+p*X;b[9]=h*D+k*C+m*I+p*Q;b[13]=h*J+k*z+m*K+p*d;b[2]=l*w+n*B+t*E+r*M;b[6]=l*y+n*F+t*G+r*X;b[10]=l*D+n*C+t*I+r*Q;b[14]=l*J+n*z+t*K+r*d;b[3]=u*w+x*B+A*E+c*M;b[7]=u*y+x*F+A*G+c*X;b[11]=u*D+x*C+A*I+c*Q;b[15]=u*J+x*z+A*K+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(){var a=
+new n;return function(b){for(var c=0,d=b.count;cthis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.copy(this);c=1/g;f=1/h;var m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
+var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;
+a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});var T={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",
alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",
aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick( specularColor, dotNV );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}",
bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",
@@ -484,41 +486,41 @@ points_vert:"uniform float size;\nuniform float scale;\n#include \n#incl
shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",
sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",
sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},
-gh={clone:Mb,merge:xa},hh={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,
+kh={clone:Pb,merge:ia},lh={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,
darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,
grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,
lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,
palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,
-teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(K.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;
-return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,c,d){b=H.euclideanModulo(b,1);c=H.clamp(c,0,1);d=H.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+
+teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Object.assign(M.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;
+return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,c,d){b=K.euclideanModulo(b,1);c=K.clamp(c,0,1);d=K.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+
a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],
10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/360;var e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),
-16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=
a(b.b);return this}}(),copyLinearToSRGB:function(){function a(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}return function(b){this.r=a(b.r);this.g=a(b.g);this.b=a(b.b);return this}}(),convertSRGBToLinear:function(){this.copySRGBToLinear(this);return this},convertLinearToSRGB:function(){this.copyLinearToSRGB(this);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){void 0===
a&&(console.warn("THREE.Color: .getHSL() target is now required"),a={h:0,s:0,l:0});var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var k=e-f;f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(cMath.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(q,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(q,-1,1)),.99999>Math.abs(q)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,
-1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(q,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(q,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=
-b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a=new J;return function(b,c,d){a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new aa;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=
-a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new n(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}});Object.assign(ae.prototype,{set:function(a){this.mask=1<g;g++)if(d[g]===d[(g+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(d=a[f],this.faces.splice(d,1),c=0,e=
this.faceVertexUvs.length;ca?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new n;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=
new n,b=new n,c=new n;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),n=c.lengthSq(),v=Math.abs(1-k*k);if(0=-t?e<=t?(h=1/v,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+n):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+n):e<=-t?(d=Math.max(0,-(-k*h+m)),e=0e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius*a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);
return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(da||h>c)return null;
if(h>g||g!==g)g=h;if(ac?null:this.at(0<=g?g:c,b)},intersectsBox:function(){var a=new n;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new n,b=new n,c=new n,d=new n;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;
-g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});Object.assign(ua,{getNormal:function(){var a=new n;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new n);e.subVectors(d,c);a.subVectors(b,
+g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});Object.assign(ra,{getNormal:function(){var a=new n;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new n);e.subVectors(d,c);a.subVectors(b,
c);e.cross(a);b=e.lengthSq();return 0=a.x+a.y}}(),getUV:function(){var a=new n;return function(b,c,d,e,f,g,h,k){this.getBarycoord(b,c,d,e,a);k.set(0,0);k.addScaledVector(f,a.x);k.addScaledVector(g,a.y);k.addScaledVector(h,a.z);return k}}()});Object.assign(ua.prototype,{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},
-clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a=new n,b=new n;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return ua.getNormal(this.a,
-this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new n);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return ua.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return ua.containsPoint(a,this.a,this.b,this.c)},getUV:function(a,b,c,d,e){return ua.getUV(a,this.a,this.b,this.c,b,c,d,e)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=
-new n,b=new n,c=new n,d=new n,e=new n,f=new n;return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h=new n);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var q=a.dot(d),v=b.dot(d);if(0>=q&&0>=v)return h.copy(k);e.subVectors(g,m);var t=a.dot(e),r=b.dot(e);if(0<=t&&r<=t)return h.copy(m);var u=q*r-t*v;if(0>=u&&0<=q&&0>=t)return m=q/(q-t),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var w=
-b.dot(f);if(0<=w&&g<=w)return h.copy(l);q=g*v-q*w;if(0>=q&&0<=v&&0>=w)return u=v/(v-w),h.copy(k).addScaledVector(b,u);v=t*w-g*r;if(0>=v&&0<=r-t&&0<=g-w)return c.subVectors(l,m),u=(r-t)/(r-t+(g-w)),h.copy(m).addScaledVector(c,u);l=1/(v+q+u);m=q*l;u*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,u)}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});ya.prototype=Object.create(M.prototype);ya.prototype.constructor=ya;ya.prototype.isMeshBasicMaterial=
-!0;ya.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;
-this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};va.prototype=Object.assign(Object.create(E.prototype),{constructor:va,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){E.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));
+new n;return function(b,c,d,e){ra.getBarycoord(b,c,d,e,a);return 0<=a.x&&0<=a.y&&1>=a.x+a.y}}(),getUV:function(){var a=new n;return function(b,c,d,e,f,g,h,k){this.getBarycoord(b,c,d,e,a);k.set(0,0);k.addScaledVector(f,a.x);k.addScaledVector(g,a.y);k.addScaledVector(h,a.z);return k}}()});Object.assign(ra.prototype,{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},
+clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a=new n,b=new n;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return ra.getNormal(this.a,
+this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new n);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return ra.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return ra.containsPoint(a,this.a,this.b,this.c)},getUV:function(a,b,c,d,e){return ra.getUV(a,this.a,this.b,this.c,b,c,d,e)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=
+new n,b=new n,c=new n,d=new n,e=new n,f=new n;return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h=new n);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var q=a.dot(d),v=b.dot(d);if(0>=q&&0>=v)return h.copy(k);e.subVectors(g,m);var t=a.dot(e),r=b.dot(e);if(0<=t&&r<=t)return h.copy(m);var u=q*r-t*v;if(0>=u&&0<=q&&0>=t)return m=q/(q-t),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var x=
+b.dot(f);if(0<=x&&g<=x)return h.copy(l);q=g*v-q*x;if(0>=q&&0<=v&&0>=x)return u=v/(v-x),h.copy(k).addScaledVector(b,u);v=t*x-g*r;if(0>=v&&0<=r-t&&0<=g-x)return c.subVectors(l,m),u=(r-t)/(r-t+(g-x)),h.copy(m).addScaledVector(c,u);l=1/(v+q+u);m=q*l;u*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,u)}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});Da.prototype=Object.create(O.prototype);Da.prototype.constructor=Da;Da.prototype.isMeshBasicMaterial=
+!0;Da.prototype.copy=function(a){O.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;
+this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};va.prototype=Object.assign(Object.create(C.prototype),{constructor:va,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){C.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));
return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0c.far?null:{distance:b,point:u.clone(),object:a}}function b(b,c,d,e,k,m,l,p,n){f.fromBufferAttribute(k,l);g.fromBufferAttribute(k,p);h.fromBufferAttribute(k,n);if(b=a(b,c,d,e,f,g,h,r))m&&(q.fromBufferAttribute(m,l),v.fromBufferAttribute(m,p),t.fromBufferAttribute(m,
-n),b.uv=ua.getUV(r,f,g,h,q,v,t,new B)),m=new Nb(l,p,n),ua.getNormal(f,g,h,m.normal),b.face=m;return b}var c=new J,d=new tb,e=new Ha,f=new n,g=new n,h=new n,k=new n,m=new n,l=new n,q=new B,v=new B,t=new B,r=new n,u=new n;return function(p,n){var u=this.geometry,w=this.material,y=this.matrixWorld;if(void 0!==w&&(null===u.boundingSphere&&u.computeBoundingSphere(),e.copy(u.boundingSphere),e.applyMatrix4(y),!1!==p.ray.intersectsSphere(e)&&(c.getInverse(y),d.copy(p.ray).applyMatrix4(c),null===u.boundingBox||
-!1!==d.intersectsBox(u.boundingBox))))if(u.isBufferGeometry){var z=u.index,C=u.attributes.position,A=u.attributes.uv,F=u.groups;u=u.drawRange;var E,H;if(null!==z)if(Array.isArray(w)){var G=0;for(E=F.length;Ge.far||f.push({distance:r,point:b.clone(),uv:ua.getUV(b,h,k,m,l,q,v,new B),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){E.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});
-Hc.prototype=Object.assign(Object.create(E.prototype),{constructor:Hc,copy:function(a){E.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;
-for(;ef||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g=
-0,r=t.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,
-point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),copy:function(a){E.prototype.copy.call(this,a);this.geometry.copy(a.geometry);this.material.copy(a.material);return this},clone:function(){return(new this.constructor).copy(this)}});W.prototype=Object.assign(Object.create(da.prototype),{constructor:W,isLineSegments:!0,computeLineDistances:function(){var a=new n,b=new n;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===c.index){for(var d=
-c.attributes.position,e=[],f=0,g=d.count;fd.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:q.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);
-m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l=m*m;m=new n;var q=new n;if(h.isBufferGeometry){var v=h.index;h=h.attributes.position.array;if(null!==v){var t=v.array;v=0;for(var r=t.length;v=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Vb.prototype=Object.create(V.prototype);Vb.prototype.constructor=Vb;Vb.prototype.isCompressedTexture=!0;Jc.prototype=Object.create(V.prototype);Jc.prototype.constructor=Jc;Jc.prototype.isCanvasTexture=!0;Kc.prototype=Object.create(V.prototype);Kc.prototype.constructor=Kc;Kc.prototype.isDepthTexture=!0;Wb.prototype=Object.create(C.prototype);Wb.prototype.constructor=Wb;Lc.prototype=
-Object.create(G.prototype);Lc.prototype.constructor=Lc;Xb.prototype=Object.create(C.prototype);Xb.prototype.constructor=Xb;Mc.prototype=Object.create(G.prototype);Mc.prototype.constructor=Mc;Aa.prototype=Object.create(C.prototype);Aa.prototype.constructor=Aa;Nc.prototype=Object.create(G.prototype);Nc.prototype.constructor=Nc;Yb.prototype=Object.create(Aa.prototype);Yb.prototype.constructor=Yb;Oc.prototype=Object.create(G.prototype);Oc.prototype.constructor=Oc;vb.prototype=Object.create(Aa.prototype);
-vb.prototype.constructor=vb;Pc.prototype=Object.create(G.prototype);Pc.prototype.constructor=Pc;Zb.prototype=Object.create(Aa.prototype);Zb.prototype.constructor=Zb;Qc.prototype=Object.create(G.prototype);Qc.prototype.constructor=Qc;$b.prototype=Object.create(Aa.prototype);$b.prototype.constructor=$b;Rc.prototype=Object.create(G.prototype);Rc.prototype.constructor=Rc;wb.prototype=Object.create(C.prototype);wb.prototype.constructor=wb;wb.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);
-a.path=this.parameters.path.toJSON();return a};Sc.prototype=Object.create(G.prototype);Sc.prototype.constructor=Sc;ac.prototype=Object.create(C.prototype);ac.prototype.constructor=ac;Tc.prototype=Object.create(G.prototype);Tc.prototype.constructor=Tc;bc.prototype=Object.create(C.prototype);bc.prototype.constructor=bc;var ih={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=uf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k=c;d=[];var m;var l=0;for(m=b.length;l80*c){var t=h=a[0];var r=d=a[1];for(k=c;kh&&(h=l),b>d&&(d=b);h=Math.max(h-t,d-r);h=0!==h?1/h:0}Wc(f,g,c,t,r,h);return g}},ab={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e
-ab.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];yf(a);zf(c,a);var f=a.length;b.forEach(yf);for(a=0;aMath.abs(g-k)?[new B(a,1-c),new B(h,1-d),
-new B(m,1-e),new B(n,1-b)]:[new B(g,1-c),new B(k,1-d),new B(l,1-e),new B(v,1-b)]}};Yc.prototype=Object.create(G.prototype);Yc.prototype.constructor=Yc;cc.prototype=Object.create(Va.prototype);cc.prototype.constructor=cc;Zc.prototype=Object.create(G.prototype);Zc.prototype.constructor=Zc;zb.prototype=Object.create(C.prototype);zb.prototype.constructor=zb;$c.prototype=Object.create(G.prototype);$c.prototype.constructor=$c;dc.prototype=Object.create(C.prototype);dc.prototype.constructor=dc;ad.prototype=
-Object.create(G.prototype);ad.prototype.constructor=ad;ec.prototype=Object.create(C.prototype);ec.prototype.constructor=ec;Ab.prototype=Object.create(G.prototype);Ab.prototype.constructor=Ab;Ab.prototype.toJSON=function(){var a=G.prototype.toJSON.call(this);return Bf(this.parameters.shapes,a)};Bb.prototype=Object.create(C.prototype);Bb.prototype.constructor=Bb;Bb.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return Bf(this.parameters.shapes,a)};fc.prototype=Object.create(C.prototype);
-fc.prototype.constructor=fc;Cb.prototype=Object.create(G.prototype);Cb.prototype.constructor=Cb;bb.prototype=Object.create(C.prototype);bb.prototype.constructor=bb;bd.prototype=Object.create(Cb.prototype);bd.prototype.constructor=bd;cd.prototype=Object.create(bb.prototype);cd.prototype.constructor=cd;dd.prototype=Object.create(G.prototype);dd.prototype.constructor=dd;gc.prototype=Object.create(C.prototype);gc.prototype.constructor=gc;var na=Object.freeze({WireframeGeometry:Wb,ParametricGeometry:Lc,
-ParametricBufferGeometry:Xb,TetrahedronGeometry:Nc,TetrahedronBufferGeometry:Yb,OctahedronGeometry:Oc,OctahedronBufferGeometry:vb,IcosahedronGeometry:Pc,IcosahedronBufferGeometry:Zb,DodecahedronGeometry:Qc,DodecahedronBufferGeometry:$b,PolyhedronGeometry:Mc,PolyhedronBufferGeometry:Aa,TubeGeometry:Rc,TubeBufferGeometry:wb,TorusKnotGeometry:Sc,TorusKnotBufferGeometry:ac,TorusGeometry:Tc,TorusBufferGeometry:bc,TextGeometry:Yc,TextBufferGeometry:cc,SphereGeometry:Zc,SphereBufferGeometry:zb,RingGeometry:$c,
-RingBufferGeometry:dc,PlaneGeometry:Bc,PlaneBufferGeometry:sb,LatheGeometry:ad,LatheBufferGeometry:ec,ShapeGeometry:Ab,ShapeBufferGeometry:Bb,ExtrudeGeometry:yb,ExtrudeBufferGeometry:Va,EdgesGeometry:fc,ConeGeometry:bd,ConeBufferGeometry:cd,CylinderGeometry:Cb,CylinderBufferGeometry:bb,CircleGeometry:dd,CircleBufferGeometry:gc,BoxGeometry:Ob,BoxBufferGeometry:rb});Db.prototype=Object.create(M.prototype);Db.prototype.constructor=Db;Db.prototype.isShadowMaterial=!0;Db.prototype.copy=function(a){M.prototype.copy.call(this,
-a);this.color.copy(a.color);return this};hc.prototype=Object.create(Ca.prototype);hc.prototype.constructor=hc;hc.prototype.isRawShaderMaterial=!0;Wa.prototype=Object.create(M.prototype);Wa.prototype.constructor=Wa;Wa.prototype.isMeshStandardMaterial=!0;Wa.prototype.copy=function(a){M.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;
+raycast:function(){function a(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==b.side,h)))return null;w.copy(h);w.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(w);return bc.far?null:{distance:b,point:w.clone(),object:a}}function b(b,c,d,e,p,n,w,C,z,E){f.fromBufferAttribute(p,C);g.fromBufferAttribute(p,z);h.fromBufferAttribute(p,E);p=b.morphTargetInfluences;if(c.morphTargets&&n&&p){q.set(0,0,0);v.set(0,0,0);t.set(0,0,0);for(var y=
+0,J=n.length;ye.far||f.push({distance:r,point:b.clone(),uv:ra.getUV(b,h,k,m,l,q,v,new B),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},
+copy:function(a){C.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});Jc.prototype=Object.assign(Object.create(C.prototype),{constructor:Jc,copy:function(a){C.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||
+e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g=0,r=t.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});V.prototype=Object.assign(Object.create(oa.prototype),{constructor:V,isLineSegments:!0,computeLineDistances:function(){var a=new n,b=new n;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===
+c.index){for(var d=c.attributes.position,e=[],f=0,g=d.count;fd.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:q.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);
+b.copy(d.ray).applyMatrix4(a);m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l=m*m;m=new n;var q=new n;if(h.isBufferGeometry){var v=h.index;h=h.attributes.position.array;if(null!==v){var t=v.array;v=0;for(var r=t.length;v=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Yb.prototype=Object.create(W.prototype);Yb.prototype.constructor=Yb;Yb.prototype.isCompressedTexture=!0;Lc.prototype=Object.create(W.prototype);Lc.prototype.constructor=Lc;Lc.prototype.isCanvasTexture=!0;Mc.prototype=Object.create(W.prototype);Mc.prototype.constructor=Mc;Mc.prototype.isDepthTexture=!0;Zb.prototype=Object.create(z.prototype);Zb.prototype.constructor=Zb;Nc.prototype=
+Object.create(N.prototype);Nc.prototype.constructor=Nc;$b.prototype=Object.create(z.prototype);$b.prototype.constructor=$b;Oc.prototype=Object.create(N.prototype);Oc.prototype.constructor=Oc;ka.prototype=Object.create(z.prototype);ka.prototype.constructor=ka;Pc.prototype=Object.create(N.prototype);Pc.prototype.constructor=Pc;ac.prototype=Object.create(ka.prototype);ac.prototype.constructor=ac;Qc.prototype=Object.create(N.prototype);Qc.prototype.constructor=Qc;yb.prototype=Object.create(ka.prototype);
+yb.prototype.constructor=yb;Rc.prototype=Object.create(N.prototype);Rc.prototype.constructor=Rc;bc.prototype=Object.create(ka.prototype);bc.prototype.constructor=bc;Sc.prototype=Object.create(N.prototype);Sc.prototype.constructor=Sc;cc.prototype=Object.create(ka.prototype);cc.prototype.constructor=cc;Tc.prototype=Object.create(N.prototype);Tc.prototype.constructor=Tc;zb.prototype=Object.create(z.prototype);zb.prototype.constructor=zb;zb.prototype.toJSON=function(){var a=z.prototype.toJSON.call(this);
+a.path=this.parameters.path.toJSON();return a};Uc.prototype=Object.create(N.prototype);Uc.prototype.constructor=Uc;dc.prototype=Object.create(z.prototype);dc.prototype.constructor=dc;Vc.prototype=Object.create(N.prototype);Vc.prototype.constructor=Vc;ec.prototype=Object.create(z.prototype);ec.prototype.constructor=ec;var mh={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=vf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k=c;d=[];var m;var l=0;for(m=b.length;l80*c){var t=h=a[0];var r=d=a[1];for(k=c;kh&&(h=l),b>d&&(d=b);h=Math.max(h-t,d-r);h=0!==h?1/h:0}Yc(f,g,c,t,r,h);return g}},cb={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e
+cb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];zf(a);Af(c,a);var f=a.length;b.forEach(zf);for(a=0;aMath.abs(g-k)?[new B(a,1-c),new B(h,1-d),
+new B(m,1-e),new B(n,1-b)]:[new B(g,1-c),new B(k,1-d),new B(l,1-e),new B(v,1-b)]}};$c.prototype=Object.create(N.prototype);$c.prototype.constructor=$c;fc.prototype=Object.create(Ya.prototype);fc.prototype.constructor=fc;ad.prototype=Object.create(N.prototype);ad.prototype.constructor=ad;Cb.prototype=Object.create(z.prototype);Cb.prototype.constructor=Cb;bd.prototype=Object.create(N.prototype);bd.prototype.constructor=bd;gc.prototype=Object.create(z.prototype);gc.prototype.constructor=gc;cd.prototype=
+Object.create(N.prototype);cd.prototype.constructor=cd;hc.prototype=Object.create(z.prototype);hc.prototype.constructor=hc;Db.prototype=Object.create(N.prototype);Db.prototype.constructor=Db;Db.prototype.toJSON=function(){var a=N.prototype.toJSON.call(this);return Cf(this.parameters.shapes,a)};Eb.prototype=Object.create(z.prototype);Eb.prototype.constructor=Eb;Eb.prototype.toJSON=function(){var a=z.prototype.toJSON.call(this);return Cf(this.parameters.shapes,a)};ic.prototype=Object.create(z.prototype);
+ic.prototype.constructor=ic;Fb.prototype=Object.create(N.prototype);Fb.prototype.constructor=Fb;db.prototype=Object.create(z.prototype);db.prototype.constructor=db;dd.prototype=Object.create(Fb.prototype);dd.prototype.constructor=dd;ed.prototype=Object.create(db.prototype);ed.prototype.constructor=ed;fd.prototype=Object.create(N.prototype);fd.prototype.constructor=fd;jc.prototype=Object.create(z.prototype);jc.prototype.constructor=jc;var ya=Object.freeze({WireframeGeometry:Zb,ParametricGeometry:Nc,
+ParametricBufferGeometry:$b,TetrahedronGeometry:Pc,TetrahedronBufferGeometry:ac,OctahedronGeometry:Qc,OctahedronBufferGeometry:yb,IcosahedronGeometry:Rc,IcosahedronBufferGeometry:bc,DodecahedronGeometry:Sc,DodecahedronBufferGeometry:cc,PolyhedronGeometry:Oc,PolyhedronBufferGeometry:ka,TubeGeometry:Tc,TubeBufferGeometry:zb,TorusKnotGeometry:Uc,TorusKnotBufferGeometry:dc,TorusGeometry:Vc,TorusBufferGeometry:ec,TextGeometry:$c,TextBufferGeometry:fc,SphereGeometry:ad,SphereBufferGeometry:Cb,RingGeometry:bd,
+RingBufferGeometry:gc,PlaneGeometry:Dc,PlaneBufferGeometry:vb,LatheGeometry:cd,LatheBufferGeometry:hc,ShapeGeometry:Db,ShapeBufferGeometry:Eb,ExtrudeGeometry:Bb,ExtrudeBufferGeometry:Ya,EdgesGeometry:ic,ConeGeometry:dd,ConeBufferGeometry:ed,CylinderGeometry:Fb,CylinderBufferGeometry:db,CircleGeometry:fd,CircleBufferGeometry:jc,BoxGeometry:Rb,BoxBufferGeometry:ub});Gb.prototype=Object.create(O.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isShadowMaterial=!0;Gb.prototype.copy=function(a){O.prototype.copy.call(this,
+a);this.color.copy(a.color);return this};kc.prototype=Object.create(Ca.prototype);kc.prototype.constructor=kc;kc.prototype.isRawShaderMaterial=!0;Za.prototype=Object.create(O.prototype);Za.prototype.constructor=Za;Za.prototype.isMeshStandardMaterial=!0;Za.prototype.copy=function(a){O.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;
this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=
-a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Eb.prototype=Object.create(Wa.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isMeshPhysicalMaterial=!0;Eb.prototype.copy=function(a){Wa.prototype.copy.call(this,
-a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};Ja.prototype=Object.create(M.prototype);Ja.prototype.constructor=Ja;Ja.prototype.isMeshPhongMaterial=!0;Ja.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=
+a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Hb.prototype=Object.create(Za.prototype);Hb.prototype.constructor=Hb;Hb.prototype.isMeshPhysicalMaterial=!0;Hb.prototype.copy=function(a){Za.prototype.copy.call(this,
+a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};La.prototype=Object.create(O.prototype);La.prototype.constructor=La;La.prototype.isMeshPhongMaterial=!0;La.prototype.copy=function(a){O.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=
a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=
-a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Fb.prototype=Object.create(Ja.prototype);Fb.prototype.constructor=Fb;Fb.prototype.isMeshToonMaterial=!0;Fb.prototype.copy=function(a){Ja.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;
-return this};Gb.prototype=Object.create(M.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isMeshNormalMaterial=!0;Gb.prototype.copy=function(a){M.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=
-a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Hb.prototype=Object.create(M.prototype);Hb.prototype.constructor=Hb;Hb.prototype.isMeshLambertMaterial=!0;Hb.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=
-a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Ib.prototype=
-Object.create(M.prototype);Ib.prototype.constructor=Ib;Ib.prototype.isMeshMatcapMaterial=!0;Ib.prototype.copy=function(a){M.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;
-this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Jb.prototype=Object.create(R.prototype);Jb.prototype.constructor=Jb;Jb.prototype.isLineDashedMaterial=!0;Jb.prototype.copy=function(a){R.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var jh=Object.freeze({ShadowMaterial:Db,SpriteMaterial:jb,RawShaderMaterial:hc,ShaderMaterial:Ca,PointsMaterial:Ia,MeshPhysicalMaterial:Eb,
-MeshStandardMaterial:Wa,MeshPhongMaterial:Ja,MeshToonMaterial:Fb,MeshNormalMaterial:Gb,MeshLambertMaterial:Hb,MeshDepthMaterial:gb,MeshDistanceMaterial:hb,MeshBasicMaterial:ya,MeshMatcapMaterial:Ib,LineDashedMaterial:Jb,LineBasicMaterial:R,Material:M}),sa={arraySlice:function(a,b,c){return sa.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},
+a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Ib.prototype=Object.create(La.prototype);Ib.prototype.constructor=Ib;Ib.prototype.isMeshToonMaterial=!0;Ib.prototype.copy=function(a){La.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;
+return this};Jb.prototype=Object.create(O.prototype);Jb.prototype.constructor=Jb;Jb.prototype.isMeshNormalMaterial=!0;Jb.prototype.copy=function(a){O.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=
+a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Kb.prototype=Object.create(O.prototype);Kb.prototype.constructor=Kb;Kb.prototype.isMeshLambertMaterial=!0;Kb.prototype.copy=function(a){O.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=
+a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Lb.prototype=
+Object.create(O.prototype);Lb.prototype.constructor=Lb;Lb.prototype.isMeshMatcapMaterial=!0;Lb.prototype.copy=function(a){O.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;
+this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Mb.prototype=Object.create(R.prototype);Mb.prototype.constructor=Mb;Mb.prototype.isLineDashedMaterial=!0;Mb.prototype.copy=function(a){R.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var nh=Object.freeze({ShadowMaterial:Gb,SpriteMaterial:mb,RawShaderMaterial:kc,ShaderMaterial:Ca,PointsMaterial:Ka,MeshPhysicalMaterial:Hb,
+MeshStandardMaterial:Za,MeshPhongMaterial:La,MeshToonMaterial:Ib,MeshNormalMaterial:Jb,MeshLambertMaterial:Kb,MeshDepthMaterial:ib,MeshDistanceMaterial:jb,MeshBasicMaterial:Da,MeshMatcapMaterial:Lb,LineDashedMaterial:Mb,LineBasicMaterial:R,Material:O}),pa={arraySlice:function(a,b,c){return pa.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},
isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=
-f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}}};Object.assign(wa.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=sa.arraySlice(c,e,f),this.values=sa.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",
-this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&sa.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,
-c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;gb;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=pa.arraySlice(c,e,f),this.values=pa.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",
+this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&pa.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,
+c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;gg)e=a+1;else if(0b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(H.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(H.clamp(e[0].dot(e[a]),-1,1)),c/=a,0d;)d+=c;for(;d>c;)d-=c;de&&(e=1);1E-4>d&&(d=e);1E-4>k&&(k=e);Le.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,k);Me.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,k);Ne.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,k)}else"catmullrom"===this.curveType&&(Le.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),Me.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),Ne.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(Le.calc(a),
-Me.calc(a),Ne.calc(a));return b};oa.prototype.copy=function(a){L.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;bc.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(Ef(d,e.x,f.x,g.x,c.x),Ef(d,e.y,f.y,g.y,c.y));return b};Oa.prototype.copy=function(a){L.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();
+a-1E-4;a+=1E-4;0>b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(K.clamp(d[k-1].dot(d[k]),-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(K.clamp(e[0].dot(e[a]),-1,1)),c/=a,0d;)d+=c;for(;d>c;)d-=c;de&&(e=1);1E-4>d&&(d=e);1E-4>k&&(k=e);Ke.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,k);Le.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,k);Me.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,k)}else"catmullrom"===this.curveType&&(Ke.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),Le.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),Me.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(Ke.calc(a),
+Le.calc(a),Me.calc(a));return b};qa.prototype.copy=function(a){I.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;bc.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set(Ff(d,e.x,f.x,g.x,c.x),Ff(d,e.y,f.y,g.y,c.y));return b};Qa.prototype.copy=function(a){I.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();
return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;cNumber.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=ab.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new kb;h.curves=g.curves;b.push(h);return b}var k=!e(f[0].getPoints());
-k=a?!k:k;h=[];var l=[],n=[],q=0;l[q]=void 0;n[q]=[];for(var v=0,t=f.length;vNumber.EPSILON){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=m*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=cb.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new nb;h.curves=g.curves;
+b.push(h);return b}var k=!e(f[0].getPoints());k=a?!k:k;h=[];var m=[],l=[],n=0;m[n]=void 0;l[n]=[];for(var v=0,t=f.length;vl.opacity&&(l.transparent=!0);d.setTextures(k);return d.parse(l)}}()});var Yd,ye={getContext:function(){void 0===Yd&&(Yd=new (window.AudioContext||window.webkitAudioContext));return Yd},setContext:function(a){Yd=a}};Object.assign(ve.prototype,{load:function(a,b,c,d){var e=new Ka(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);ye.getContext().decodeAudioData(a,function(a){b(a)})},c,d)},setPath:function(a){this.path=a;
-return this}});Object.assign(Gf.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new J,l=new J;return function(m){if(a!==this||b!==m.focus||c!==m.fov||d!==m.aspect*this.aspect||e!==m.near||f!==m.far||g!==m.zoom||h!==this.eyeSep){a=this;b=m.focus;c=m.fov;d=m.aspect*this.aspect;e=m.near;f=m.far;g=m.zoom;var n=m.projectionMatrix.clone();h=this.eyeSep/2;var p=h*e/b,t=e*Math.tan(H.DEG2RAD*c*.5)/g;l.elements[12]=-h;k.elements[12]=h;var r=-t*d+p;var u=t*d+p;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/
-(u-r);this.cameraL.projectionMatrix.copy(n);r=-t*d-p;u=t*d-p;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/(u-r);this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(m.matrixWorld).multiply(l);this.cameraR.matrixWorld.copy(m.matrixWorld).multiply(k)}}()});ld.prototype=Object.create(E.prototype);ld.prototype.constructor=ld;Object.assign(we.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0},
-stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});xe.prototype=Object.assign(Object.create(E.prototype),{constructor:xe,getInput:function(){return this.gain},removeFilter:function(){null!==
+l.type&&delete l.specular;1>l.opacity&&(l.transparent=!0);d.setTextures(k);return d.parse(l)}}()});var Zd,xe={getContext:function(){void 0===Zd&&(Zd=new (window.AudioContext||window.webkitAudioContext));return Zd},setContext:function(a){Zd=a}};Object.assign(ue.prototype,{load:function(a,b,c,d){var e=new Ma(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);xe.getContext().decodeAudioData(a,function(a){b(a)})},c,d)},setPath:function(a){this.path=a;
+return this}});Object.assign(Hf.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new P,l=new P;return function(m){if(a!==this||b!==m.focus||c!==m.fov||d!==m.aspect*this.aspect||e!==m.near||f!==m.far||g!==m.zoom||h!==this.eyeSep){a=this;b=m.focus;c=m.fov;d=m.aspect*this.aspect;e=m.near;f=m.far;g=m.zoom;var n=m.projectionMatrix.clone();h=this.eyeSep/2;var p=h*e/b,t=e*Math.tan(K.DEG2RAD*c*.5)/g;l.elements[12]=-h;k.elements[12]=h;var r=-t*d+p;var u=t*d+p;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/
+(u-r);this.cameraL.projectionMatrix.copy(n);r=-t*d-p;u=t*d-p;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/(u-r);this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(m.matrixWorld).multiply(l);this.cameraR.matrixWorld.copy(m.matrixWorld).multiply(k)}}()});nd.prototype=Object.create(C.prototype);nd.prototype.constructor=nd;Object.assign(ve.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0},
+stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});we.prototype=Object.assign(Object.create(C.prototype),{constructor:we,getInput:function(){return this.gain},removeFilter:function(){null!==
this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value},
-setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(){var a=new n,b=new aa,c=new n,d=new n,e=new we;return function(f){E.prototype.updateMatrixWorld.call(this,f);f=this.context.listener;var g=this.up;this.timeDelta=e.getDelta();this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);if(f.positionX){var h=this.context.currentTime+this.timeDelta;f.positionX.linearRampToValueAtTime(a.x,h);f.positionY.linearRampToValueAtTime(a.y,
-h);f.positionZ.linearRampToValueAtTime(a.z,h);f.forwardX.linearRampToValueAtTime(d.x,h);f.forwardY.linearRampToValueAtTime(d.y,h);f.forwardZ.linearRampToValueAtTime(d.z,h);f.upX.linearRampToValueAtTime(g.x,h);f.upY.linearRampToValueAtTime(g.y,h);f.upZ.linearRampToValueAtTime(g.z,h)}else f.setPosition(a.x,a.y,a.z),f.setOrientation(d.x,d.y,d.z,g.x,g.y,g.z)}}()});lc.prototype=Object.assign(Object.create(E.prototype),{constructor:lc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=
+setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(){var a=new n,b=new aa,c=new n,d=new n,e=new ve;return function(f){C.prototype.updateMatrixWorld.call(this,f);f=this.context.listener;var g=this.up;this.timeDelta=e.getDelta();this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);if(f.positionX){var h=this.context.currentTime+this.timeDelta;f.positionX.linearRampToValueAtTime(a.x,h);f.positionY.linearRampToValueAtTime(a.y,
+h);f.positionZ.linearRampToValueAtTime(a.z,h);f.forwardX.linearRampToValueAtTime(d.x,h);f.forwardY.linearRampToValueAtTime(d.y,h);f.forwardZ.linearRampToValueAtTime(d.z,h);f.upX.linearRampToValueAtTime(g.x,h);f.upY.linearRampToValueAtTime(g.y,h);f.upZ.linearRampToValueAtTime(g.z,h)}else f.setPosition(a.x,a.y,a.z),f.setOrientation(d.x,d.y,d.z,g.x,g.y,g.z)}}()});oc.prototype=Object.assign(Object.create(C.prototype),{constructor:oc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=
!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setMediaElementSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaNode";this.source=this.context.createMediaElementSource(a);this.connect();return this},setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
else{var a=this.context.createBufferSource();a.buffer=this.buffer;a.loop=this.loop;a.onended=this.onEnded.bind(this);this.startTime=this.context.currentTime;a.start(this.startTime,this.offset);this.isPlaying=!0;this.source=a;this.setDetune(this.detune);this.setPlaybackRate(this.playbackRate);return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return!0===this.isPlaying&&(this.source.stop(),this.source.onended=
null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),this.source.onended=null,this.offset=0,this.isPlaying=!1,this},connect:function(){if(0d&&this._mixBufferRegion(c,a,3*b,1-d,b);d=b;for(var f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,
-b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){aa.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}});Object.assign(Hf.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,
-b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(ma,{Composite:Hf,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new ma.Composite(a,b,c):new ma(a,b,c)},sanitizeNodeName:function(){var a=/[\[\]\.:\/]/g;return function(b){return b.replace(/\s/g,"_").replace(a,"")}}(),parseTrackName:function(){var a="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",
+b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){aa.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}});Object.assign(If.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,
+b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(ma,{Composite:If,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new ma.Composite(a,b,c):new ma(a,b,c)},sanitizeNodeName:function(){var a=/[\[\]\.:\/]/g;return function(b){return b.replace(/\s/g,"_").replace(a,"")}}(),parseTrackName:function(){var a="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",
b=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]");a=/(WCOD+)?/.source.replace("WCOD",a);var c=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),d=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),e=new RegExp("^"+b+a+c+d+"$"),f=["material","materials","bones"];return function(a){var b=e.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};var c=b.nodeName&&
b.nodeName.lastIndexOf(".");if(void 0!==c&&-1!==c){var d=b.nodeName.substring(c+1);-1!==f.indexOf(d)&&(b.nodeName=b.nodeName.substring(0,c),b.objectName=d)}if(null===b.propertyName||0===b.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+a);return b}}(),findNode:function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==c)return c}if(a.children){var d=function(a){for(var c=
0;c=b){var n=b++,q=a[n];c[q.uuid]=l;a[l]=q;c[k]=n;a[n]=h;h=0;for(k=e;h!==k;++h){q=d[h];var v=q[l];q[l]=q[n];q[n]=v}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=arguments[g].uuid,l=d[k];if(void 0!==l)if(delete d[k],lc.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0];
b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1===e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>
a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}if(f&&
-1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});Ce.prototype=
-Object.assign(Object.create(ka.prototype),{constructor:Ce,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,k=h[g];void 0===k&&(k={},h[g]=k);for(h=0;h!==e;++h){var l=d[h],n=l.name,q=k[n];if(void 0===q){q=f[h];if(void 0!==q){null===q._cacheIndex&&(++q.referenceCount,this._addInactiveBinding(q,g,n));continue}q=new Be(ma.create(c,n,b&&b._propertyBindings[h].binding.parsedPath),l.ValueTypeName,
+1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});Be.prototype=
+Object.assign(Object.create(ta.prototype),{constructor:Be,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,k=h[g];void 0===k&&(k={},h[g]=k);for(h=0;h!==e;++h){var l=d[h],n=l.name,q=k[n];if(void 0===q){q=f[h];if(void 0!==q){null===q._cacheIndex&&(++q.referenceCount,this._addInactiveBinding(q,g,n));continue}q=new Ae(ma.create(c,n,b&&b._propertyBindings[h].binding.parsedPath),l.ValueTypeName,
l.getValueSize());++q.referenceCount;this._addInactiveBinding(q,g,n)}f[h]=q;a[h].resultBuffer=q.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=
a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},
get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&athis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new B);
return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new B);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new B;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);
-this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(Ie.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0===
+this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});Object.assign(He.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0===
a&&(console.warn("THREE.Line3: .getCenter() target is now required"),a=new n);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new n);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b=
-new n);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new n,b=new n;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);c=b.dot(b);c=b.dot(a)/c;d&&(c=H.clamp(c,0,1));return c}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),c=new n);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);
-this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});md.prototype=Object.create(E.prototype);md.prototype.constructor=md;md.prototype.isImmediateRenderObject=!0;nd.prototype=Object.create(W.prototype);nd.prototype.constructor=nd;nd.prototype.update=function(){var a=new n,b=new n,c=new pa;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=
+new n);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new n,b=new n;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);c=b.dot(b);c=b.dot(a)/c;d&&(c=K.clamp(c,0,1));return c}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),c=new n);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);
+this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});od.prototype=Object.create(C.prototype);od.prototype.constructor=od;od.prototype.isImmediateRenderObject=!0;pd.prototype=Object.create(V.prototype);pd.prototype.constructor=pd;pd.prototype.update=function(){var a=new n,b=new n,c=new ba;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=
this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,n=k.length;lMath.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);E.prototype.updateMatrixWorld.call(this,a)};var Wd,Je;eb.prototype=Object.create(E.prototype);eb.prototype.constructor=eb;eb.prototype.setDirection=function(){var a=new n,b;return function(c){.99999c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),
-this.quaternion.setFromAxisAngle(a,b))}}();eb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};eb.prototype.setColor=function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};eb.prototype.copy=function(a){E.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};eb.prototype.clone=
-function(){return(new this.constructor).copy(this)};td.prototype=Object.create(W.prototype);td.prototype.constructor=td;L.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(L.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(cb.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getPoints(a);
-return this.createGeometry(a)},createSpacedPointsGeometry:function(a){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getSpacedPoints(a);return this.createGeometry(a)},createGeometry:function(a){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var b=new G,c=0,d=a.length;cMath.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=0>b?1:0;this.lookAt(this.plane.normal);C.prototype.updateMatrixWorld.call(this,a)};var Xd,Ie;gb.prototype=Object.create(C.prototype);
+gb.prototype.constructor=gb;gb.prototype.setDirection=function(){var a=new n,b;return function(c){.99999c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();gb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};gb.prototype.setColor=
+function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};gb.prototype.copy=function(a){C.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};gb.prototype.clone=function(){return(new this.constructor).copy(this)};ud.prototype=Object.create(V.prototype);ud.prototype.constructor=ud;I.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(I.prototype);a.prototype.constructor=a;a.prototype.getPoint=
+b;return a};Object.assign(eb.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getPoints(a);return this.createGeometry(a)},createSpacedPointsGeometry:function(a){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getSpacedPoints(a);return this.createGeometry(a)},createGeometry:function(a){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
+for(var b=new N,c=0,d=a.length;c
org.treblereel.gwt
three4g-parent
- 0.102
+ 0.103
..
diff --git a/extensions/src/main/java/org/treblereel/gwt/three4g/extensions/utils/SkeletonUtils.java b/extensions/src/main/java/org/treblereel/gwt/three4g/extensions/utils/SkeletonUtils.java
new file mode 100644
index 00000000..94694bf2
--- /dev/null
+++ b/extensions/src/main/java/org/treblereel/gwt/three4g/extensions/utils/SkeletonUtils.java
@@ -0,0 +1,77 @@
+package org.treblereel.gwt.three4g.extensions.utils;
+
+import elemental2.core.JsMap;
+import jsinterop.annotations.JsType;
+import org.treblereel.gwt.three4g.Three4gElement;
+import org.treblereel.gwt.three4g.animation.AnimationClip;
+import org.treblereel.gwt.three4g.core.Object3D;
+import org.treblereel.gwt.three4g.helpers.SkeletonHelper;
+import org.treblereel.gwt.three4g.objects.Bone;
+import org.treblereel.gwt.three4g.objects.Skeleton;
+
+/**
+ * Utility functions for Skeleton, SkinnedMesh, and Bone manipulation.
+ * @author Dmitrii Tikhomirov
+ * Created by treblereel 10/21/19
+ */
+@Three4gElement(paths = "js/utils/SkeletonUtils.js")
+@JsType(isNative = true, namespace = "THREE")
+public class SkeletonUtils {
+
+ SkeletonUtils() {
+
+ }
+
+ /**
+ * Clones the given object and its descendants, ensuring that any SkinnedMesh instances are correctly associated with their bones. Bones are also cloned, and must be descendants of the object passed to this method. Other data, like geometries and materials, are reused by reference.
+ * @param object3D
+ * @return
+ */
+ public native static Object3D clone(Object3D object3D);
+
+ public native static T findBoneTrackData(String name, Object[] tracks);
+
+ public native static Bone getBoneByName(String name, Skeleton skeleton);
+
+ public native static Bone[] getBones(Skeleton skeleton);
+
+ public native static Bone[] getEqualsBonesNames(Skeleton skeleton, Skeleton targetSkeleton);
+
+ public native static SkeletonHelper getHelperFromSkeleton(Skeleton skeleton);
+
+ public native static Bone getNearestBone(Bone bone, Object[] names);
+
+ public native static T getSkeletonOffsets(SkeletonHelper target, SkeletonHelper source);
+
+ public native static T getSkeletonOffsets(SkeletonHelper target, SkeletonHelper source, Option option);
+
+ public native static SkeletonUtils renameBones(SkeletonHelper skeleton, T[] names);
+
+ public native static AnimationClip retarget(SkeletonHelper target, SkeletonHelper source);
+
+ public native static AnimationClip retarget(SkeletonHelper target, SkeletonHelper source, Option option);
+
+ public native static AnimationClip retargetClip(SkeletonHelper target, SkeletonHelper source, AnimationClip clip);
+
+ public native static AnimationClip retargetClip(SkeletonHelper target, SkeletonHelper source, AnimationClip clip, Option option);
+
+ @JsType(isNative = true, namespace = "THREE", name = "Object")
+ public static class Option {
+
+ public JsMap names;
+
+ public JsMap offsets;
+
+ public int fps;
+
+ public boolean useFirstFramePosition;
+
+ public boolean preserveMatrix;
+
+ public boolean useTargetMatrix;
+
+ public boolean preserveHipPosition;
+
+ public String hip;
+ }
+}
diff --git a/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/exporters/GLTFExporter.js b/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/exporters/GLTFExporter.js
index 9b983e71..4be2647f 100644
--- a/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/exporters/GLTFExporter.js
+++ b/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/exporters/GLTFExporter.js
@@ -80,7 +80,8 @@ THREE.GLTFExporter.prototype = {
embedImages: true,
animations: [],
forceIndices: false,
- forcePowerOfTwoTextures: false
+ forcePowerOfTwoTextures: false,
+ includeCustomExtensions: false
};
options = Object.assign( {}, DEFAULT_OPTIONS, options );
@@ -340,21 +341,50 @@ THREE.GLTFExporter.prototype = {
* Serializes a userData.
*
* @param {THREE.Object3D|THREE.Material} object
- * @returns {Object}
+ * @param {Object} gltfProperty
*/
- function serializeUserData( object ) {
+ function serializeUserData( object, gltfProperty ) {
+
+ if ( Object.keys( object.userData ).length === 0 ) {
+
+ return;
+
+ }
try {
- return JSON.parse( JSON.stringify( object.userData ) );
+ var json = JSON.parse( JSON.stringify( object.userData ) );
+
+ if ( options.includeCustomExtensions && json.gltfExtensions ) {
+
+ if ( gltfProperty.extensions === undefined ) {
+
+ gltfProperty.extensions = {};
+
+ }
+
+ for ( var extensionName in json.gltfExtensions ) {
+
+ gltfProperty.extensions[ extensionName ] = json.gltfExtensions[ extensionName ];
+ extensionsUsed[ extensionName ] = true;
+
+ }
+
+ delete json.gltfExtensions;
+
+ }
+
+ if ( Object.keys( json ).length > 0 ) {
+
+ gltfProperty.extras = json;
+
+ }
} catch ( error ) {
console.warn( 'THREE.GLTFExporter: userData of \'' + object.name + '\' ' +
'won\'t be serialized because of JSON.stringify error - ' + error.message );
- return {};
-
}
}
@@ -1025,11 +1055,7 @@ THREE.GLTFExporter.prototype = {
}
- if ( Object.keys( material.userData ).length > 0 ) {
-
- gltfMaterial.extras = serializeUserData( material );
-
- }
+ serializeUserData( material, gltfMaterial );
outputJSON.materials.push( gltfMaterial );
@@ -1136,9 +1162,22 @@ THREE.GLTFExporter.prototype = {
var modifiedAttribute = null;
for ( var attributeName in geometry.attributes ) {
+ // Ignore morph target attributes, which are exported later.
+ if ( attributeName.substr( 0, 5 ) === 'morph' ) continue;
+
var attribute = geometry.attributes[ attributeName ];
attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
+ // Prefix all geometry attributes except the ones specifically
+ // listed in the spec; non-spec attributes are considered custom.
+ var validVertexAttributes =
+ /^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/;
+ if ( ! validVertexAttributes.test( attributeName ) ) {
+
+ attributeName = '_' + attributeName;
+
+ }
+
if ( cachedData.attributes.has( attribute ) ) {
attributes[ attributeName ] = cachedData.attributes.get( attribute );
@@ -1158,15 +1197,11 @@ THREE.GLTFExporter.prototype = {
}
- if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) {
+ var accessor = processAccessor( modifiedAttribute || attribute, geometry );
+ if ( accessor !== null ) {
- var accessor = processAccessor( modifiedAttribute || attribute, geometry );
- if ( accessor !== null ) {
-
- attributes[ attributeName ] = accessor;
- cachedData.attributes.set( attribute, accessor );
-
- }
+ attributes[ attributeName ] = accessor;
+ cachedData.attributes.set( attribute, accessor );
}
@@ -1276,8 +1311,6 @@ THREE.GLTFExporter.prototype = {
}
- var extras = ( Object.keys( geometry.userData ).length > 0 ) ? serializeUserData( geometry ) : undefined;
-
var forceIndices = options.forceIndices;
var isMultiMaterial = Array.isArray( mesh.material );
@@ -1319,7 +1352,7 @@ THREE.GLTFExporter.prototype = {
attributes: attributes,
};
- if ( extras ) primitive.extras = extras;
+ serializeUserData( geometry, primitive );
if ( targets.length > 0 ) primitive.targets = targets;
@@ -1336,6 +1369,8 @@ THREE.GLTFExporter.prototype = {
}
+ if ( primitive.indices === null ) delete primitive.indices;
+
}
var material = processMaterial( materials[ groups[ i ].materialIndex ] );
@@ -1699,11 +1734,7 @@ THREE.GLTFExporter.prototype = {
}
- if ( object.userData && Object.keys( object.userData ).length > 0 ) {
-
- gltfNode.extras = serializeUserData( object );
-
- }
+ serializeUserData( object, gltfNode );
if ( object.isMesh || object.isLine || object.isPoints ) {
@@ -1734,7 +1765,7 @@ THREE.GLTFExporter.prototype = {
} else if ( object.isLight ) {
- console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.' );
+ console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.', object );
return null;
}
@@ -1844,6 +1875,8 @@ THREE.GLTFExporter.prototype = {
}
+ serializeUserData( scene, gltfScene );
+
}
/**
@@ -2125,7 +2158,7 @@ THREE.GLTFExporter.Utils = {
console.warn( 'THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.' );
sourceTrack = sourceTrack.clone();
- sourceTrack.setInterpolation( InterpolateLinear );
+ sourceTrack.setInterpolation( THREE.InterpolateLinear );
}
diff --git a/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/loaders/GLTFLoader.js b/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/loaders/GLTFLoader.js
index f835173b..1208709d 100644
--- a/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/loaders/GLTFLoader.js
+++ b/extensions/src/main/resources/org/treblereel/gwt/three4g/extensions/resources/js/loaders/GLTFLoader.js
@@ -218,23 +218,7 @@ THREE.GLTFLoader = ( function () {
} );
- parser.parse( function ( scene, scenes, cameras, animations, json ) {
-
- var glTF = {
- scene: scene,
- scenes: scenes,
- cameras: cameras,
- animations: animations,
- asset: json.asset,
- parser: parser,
- userData: {}
- };
-
- addUnknownExtensionsToUserData( extensions, glTF, json );
-
- onLoad( glTF );
-
- }, onError );
+ parser.parse( onLoad, onError );
}
@@ -512,7 +496,6 @@ THREE.GLTFLoader = ( function () {
this.name = EXTENSIONS.KHR_DRACO_MESH_COMPRESSION;
this.json = json;
this.dracoLoader = dracoLoader;
- THREE.DRACOLoader.getDecoderModule();
}
@@ -528,21 +511,23 @@ THREE.GLTFLoader = ( function () {
for ( var attributeName in gltfAttributeMap ) {
- if ( ! ( attributeName in ATTRIBUTES ) ) continue;
+ var threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
- threeAttributeMap[ ATTRIBUTES[ attributeName ] ] = gltfAttributeMap[ attributeName ];
+ threeAttributeMap[ threeAttributeName ] = gltfAttributeMap[ attributeName ];
}
for ( attributeName in primitive.attributes ) {
- if ( ATTRIBUTES[ attributeName ] !== undefined && gltfAttributeMap[ attributeName ] !== undefined ) {
+ var threeAttributeName = ATTRIBUTES[ attributeName ] || attributeName.toLowerCase();
+
+ if ( gltfAttributeMap[ attributeName ] !== undefined ) {
var accessorDef = json.accessors[ primitive.attributes[ attributeName ] ];
var componentType = WEBGL_COMPONENT_TYPES[ accessorDef.componentType ];
- attributeTypeMap[ ATTRIBUTES[ attributeName ] ] = componentType;
- attributeNormalizedMap[ ATTRIBUTES[ attributeName ] ] = accessorDef.normalized === true;
+ attributeTypeMap[ threeAttributeName ] = componentType;
+ attributeNormalizedMap[ threeAttributeName ] = accessorDef.normalized === true;
}
@@ -1218,10 +1203,8 @@ THREE.GLTFLoader = ( function () {
};
var INTERPOLATION = {
- CUBICSPLINE: THREE.InterpolateSmooth, // We use custom interpolation GLTFCubicSplineInterpolation for CUBICSPLINE.
- // KeyframeTrack.optimize() can't handle glTF Cubic Spline output values layout,
- // using THREE.InterpolateSmooth for KeyframeTrack instantiation to prevent optimization.
- // See KeyframeTrack.optimize() for the detail.
+ CUBICSPLINE: undefined, // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
+ // keyframe track will be initialized with a default interpolation type, then modified.
LINEAR: THREE.InterpolateLinear,
STEP: THREE.InterpolateDiscrete
};
@@ -1267,12 +1250,14 @@ THREE.GLTFLoader = ( function () {
}
+ var defaultMaterial;
+
/**
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
*/
function createDefaultMaterial() {
- return new THREE.MeshStandardMaterial( {
+ defaultMaterial = defaultMaterial || new THREE.MeshStandardMaterial( {
color: 0xFFFFFF,
emissive: 0x000000,
metalness: 1,
@@ -1282,6 +1267,8 @@ THREE.GLTFLoader = ( function () {
side: THREE.FrontSide
} );
+ return defaultMaterial;
+
}
function addUnknownExtensionsToUserData( knownExtensions, object, objectDef ) {
@@ -1358,34 +1345,21 @@ THREE.GLTFLoader = ( function () {
if ( hasMorphPosition ) {
- // TODO: Error-prone use of a callback inside a loop.
- var accessor = target.POSITION !== undefined
+ var pendingAccessor = target.POSITION !== undefined
? parser.getDependency( 'accessor', target.POSITION )
- .then( function ( accessor ) {
-
- // Cloning not to pollute original accessor below
- return cloneBufferAttribute( accessor );
-
- } )
: geometry.attributes.position;
- pendingPositionAccessors.push( accessor );
+ pendingPositionAccessors.push( pendingAccessor );
}
if ( hasMorphNormal ) {
- // TODO: Error-prone use of a callback inside a loop.
- var accessor = target.NORMAL !== undefined
+ var pendingAccessor = target.NORMAL !== undefined
? parser.getDependency( 'accessor', target.NORMAL )
- .then( function ( accessor ) {
-
- return cloneBufferAttribute( accessor );
-
- } )
: geometry.attributes.normal;
- pendingNormalAccessors.push( accessor );
+ pendingNormalAccessors.push( pendingAccessor );
}
@@ -1399,6 +1373,24 @@ THREE.GLTFLoader = ( function () {
var morphPositions = accessors[ 0 ];
var morphNormals = accessors[ 1 ];
+ // Clone morph target accessors before modifying them.
+
+ for ( var i = 0, il = morphPositions.length; i < il; i ++ ) {
+
+ if ( geometry.attributes.position === morphPositions[ i ] ) continue;
+
+ morphPositions[ i ] = cloneBufferAttribute( morphPositions[ i ] );
+
+ }
+
+ for ( var i = 0, il = morphNormals.length; i < il; i ++ ) {
+
+ if ( geometry.attributes.normal === morphNormals[ i ] ) continue;
+
+ morphNormals[ i ] = cloneBufferAttribute( morphNormals[ i ] );
+
+ }
+
for ( var i = 0, il = targets.length; i < il; i ++ ) {
var target = targets[ i ];
@@ -1570,34 +1562,6 @@ THREE.GLTFLoader = ( function () {
}
- function createArrayKeyBufferGeometry( a ) {
-
- var arrayKey = '';
-
- for ( var i = 0, il = a.length; i < il; i ++ ) {
-
- arrayKey += ':' + a[ i ].uuid;
-
- }
-
- return arrayKey;
-
- }
-
- function createMultiPassGeometryKey( geometry, primitives ) {
-
- var key = geometry.uuid;
-
- for ( var i = 0, il = primitives.length; i < il; i ++ ) {
-
- key += i + createPrimitiveKey( primitives[ i ] );
-
- }
-
- return key;
-
- }
-
function cloneBufferAttribute( attribute ) {
if ( attribute.isInterleavedBufferAttribute ) {
@@ -1623,48 +1587,6 @@ THREE.GLTFLoader = ( function () {
}
- /**
- * Checks if we can build a single Mesh with MultiMaterial from multiple primitives.
- * Returns true if all primitives use the same attributes/morphAttributes/mode
- * and also have index. Otherwise returns false.
- *
- * @param {Array} primitives
- * @return {Boolean}
- */
- function isMultiPassGeometry( primitives ) {
-
- if ( primitives.length < 2 ) return false;
-
- var primitive0 = primitives[ 0 ];
- var targets0 = primitive0.targets || [];
-
- if ( primitive0.indices === undefined ) return false;
-
- for ( var i = 1, il = primitives.length; i < il; i ++ ) {
-
- var primitive = primitives[ i ];
-
- if ( primitive0.mode !== primitive.mode ) return false;
- if ( primitive.indices === undefined ) return false;
- if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] ) return false;
- if ( ! isObjectEqual( primitive0.attributes, primitive.attributes ) ) return false;
-
- var targets = primitive.targets || [];
-
- if ( targets0.length !== targets.length ) return false;
-
- for ( var j = 0, jl = targets0.length; j < jl; j ++ ) {
-
- if ( ! isObjectEqual( targets0[ j ], targets[ j ] ) ) return false;
-
- }
-
- }
-
- return true;
-
- }
-
/* GLTF PARSER */
function GLTFParser( json, extensions, options ) {
@@ -1678,8 +1600,6 @@ THREE.GLTFLoader = ( function () {
// BufferGeometry caching
this.primitiveCache = {};
- this.multiplePrimitivesCache = {};
- this.multiPassGeometryCache = {};
this.textureLoader = new THREE.TextureLoader( this.options.manager );
this.textureLoader.setCrossOrigin( this.options.crossOrigin );
@@ -1691,7 +1611,9 @@ THREE.GLTFLoader = ( function () {
GLTFParser.prototype.parse = function ( onLoad, onError ) {
+ var parser = this;
var json = this.json;
+ var extensions = this.extensions;
// Clear the loader cache
this.cache.removeAll();
@@ -1699,21 +1621,27 @@ THREE.GLTFLoader = ( function () {
// Mark the special nodes/meshes in json for efficient parse
this.markDefs();
- // Fire the callback on complete
- this.getMultiDependencies( [
+ Promise.all( [
- 'scene',
- 'animation',
- 'camera'
+ this.getDependencies( 'scene' ),
+ this.getDependencies( 'animation' ),
+ this.getDependencies( 'camera' ),
] ).then( function ( dependencies ) {
- var scenes = dependencies.scenes || [];
- var scene = scenes[ json.scene || 0 ];
- var animations = dependencies.animations || [];
- var cameras = dependencies.cameras || [];
+ var result = {
+ scene: dependencies[ 0 ][ json.scene || 0 ],
+ scenes: dependencies[ 0 ],
+ animations: dependencies[ 1 ],
+ cameras: dependencies[ 2 ],
+ asset: json.asset,
+ parser: parser,
+ userData: {}
+ };
+
+ addUnknownExtensionsToUserData( extensions, result, json );
- onLoad( scene, scenes, cameras, animations, json );
+ onLoad( result );
} ).catch( onError );
@@ -1886,40 +1814,6 @@ THREE.GLTFLoader = ( function () {
};
- /**
- * Requests all multiple dependencies of the specified types asynchronously, with caching.
- * @param {Array} types
- * @return {Promise