diff --git a/build/three.js b/build/three.js index 64ca6e2d216142..c5a3a19ca0ec83 100644 --- a/build/three.js +++ b/build/three.js @@ -61,31 +61,27 @@ // Missing in IE // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign - ( function () { + Object.assign = function ( target ) { - Object.assign = function ( target ) { + if ( target === undefined || target === null ) { - if ( target === undefined || target === null ) { + throw new TypeError( 'Cannot convert undefined or null to object' ); - throw new TypeError( 'Cannot convert undefined or null to object' ); - - } + } - var output = Object( target ); + var output = Object( target ); - for ( var index = 1; index < arguments.length; index ++ ) { + for ( var index = 1; index < arguments.length; index ++ ) { - var source = arguments[ index ]; + var source = arguments[ index ]; - if ( source !== undefined && source !== null ) { + if ( source !== undefined && source !== null ) { - for ( var nextKey in source ) { + for ( var nextKey in source ) { - if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) { + if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) { - output[ nextKey ] = source[ nextKey ]; - - } + output[ nextKey ] = source[ nextKey ]; } @@ -93,11 +89,11 @@ } - return output; + } - }; + return output; - } )(); + }; } @@ -1631,7 +1627,8 @@ * @author WestLangley / http://github.com/WestLangley */ - var _vector, _quaternion; + var _vector = new Vector3(); + var _quaternion = new Quaternion(); function Vector3( x, y, z ) { @@ -1856,8 +1853,6 @@ applyEuler: function ( euler ) { - if ( _quaternion === undefined ) _quaternion = new Quaternion(); - if ( ! ( euler && euler.isEuler ) ) { console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); @@ -1870,8 +1865,6 @@ applyAxisAngle: function ( axis, angle ) { - if ( _quaternion === undefined ) _quaternion = new Quaternion(); - return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) ); }, @@ -2160,8 +2153,6 @@ projectOnPlane: function ( planeNormal ) { - if ( _vector === undefined ) _vector = new Vector3(); - _vector.copy( this ).projectOnVector( planeNormal ); return this.sub( _vector ); @@ -2170,8 +2161,6 @@ reflect: function ( normal ) { - if ( _vector === undefined ) _vector = new Vector3(); - // reflect incident vector off plane orthogonal to normal // normal is assumed to have unit length @@ -2331,7 +2320,7 @@ * @author tschw */ - var _vector$1; + var _vector$1 = new Vector3(); function Matrix3() { @@ -2418,8 +2407,6 @@ applyToBufferAttribute: function ( attribute ) { - if ( _vector$1 === undefined ) _vector$1 = new Vector3(); - for ( var i = 0, l = attribute.count; i < l; i ++ ) { _vector$1.x = attribute.getX( i ); @@ -3855,6 +3842,14 @@ } ); + var _v1 = new Vector3(); + var _m1 = new Matrix4(); + var _zero = new Vector3( 0, 0, 0 ); + var _one = new Vector3( 1, 1, 1 ); + var _x = new Vector3(); + var _y = new Vector3(); + var _z = new Vector3(); + /** * @author mrdoob / http://mrdoob.com/ * @author supereggbert / http://www.paulbrunt.co.uk/ @@ -3868,10 +3863,6 @@ * @author WestLangley / http://github.com/WestLangley */ - var _v1, _m1; - var _zero, _one; - var _x, _y, _z; - function Matrix4() { this.elements = [ @@ -3980,8 +3971,6 @@ extractRotation: function ( m ) { - if ( _v1 === undefined ) _v1 = new Vector3(); - // this method does not support reflection matrices var te = this.elements; @@ -4145,27 +4134,12 @@ makeRotationFromQuaternion: function ( q ) { - if ( _zero === undefined ) { - - _zero = new Vector3( 0, 0, 0 ); - _one = new Vector3( 1, 1, 1 ); - - } - return this.compose( _zero, q, _one ); }, lookAt: function ( eye, target, up ) { - if ( _x === undefined ) { - - _x = new Vector3(); - _y = new Vector3(); - _z = new Vector3(); - - } - var te = this.elements; _z.subVectors( eye, target ); @@ -4285,8 +4259,6 @@ applyToBufferAttribute: function ( attribute ) { - if ( _v1 === undefined ) _v1 = new Vector3(); - for ( var i = 0, l = attribute.count; i < l; i ++ ) { _v1.x = attribute.getX( i ); @@ -4637,13 +4609,6 @@ decompose: function ( position, quaternion, scale ) { - if ( _m1 === undefined ) { - - _m1 = new Matrix4(); - _v1 = new Vector3(); - - } - var te = this.elements; var sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length(); @@ -4801,7 +4766,8 @@ * @author bhouston / http://clara.io */ - var _matrix, _quaternion$1; + var _matrix = new Matrix4(); + var _quaternion$1 = new Quaternion(); function Euler( x, y, z, order ) { @@ -5049,8 +5015,6 @@ setFromQuaternion: function ( q, order, update ) { - if ( _matrix === undefined ) _matrix = new Matrix4(); - _matrix.makeRotationFromQuaternion( q ); return this.setFromRotationMatrix( _matrix, order, update ); @@ -5067,8 +5031,6 @@ // WARNING: this discards revolution information -bhouston - if ( _quaternion$1 === undefined ) _quaternion$1 = new Quaternion(); - _quaternion$1.setFromEuler( this ); return this.setFromQuaternion( _quaternion$1, newOrder ); @@ -5178,6 +5140,24 @@ } ); + var _object3DId = 0; + + var _v1$1 = new Vector3(); + var _q1 = new Quaternion(); + var _m1$1 = new Matrix4(); + var _target = new Vector3(); + + var _position = new Vector3(); + var _scale = new Vector3(); + var _quaternion$2 = new Quaternion(); + + var _xAxis = new Vector3( 1, 0, 0 ); + var _yAxis = new Vector3( 0, 1, 0 ); + var _zAxis = new Vector3( 0, 0, 1 ); + + var _addedEvent = { type: 'added' }; + var _removedEvent = { type: 'removed' }; + /** * @author mrdoob / http://mrdoob.com/ * @author mikael emtinger / http://gomo.se/ @@ -5186,11 +5166,9 @@ * @author elephantatwork / www.elephantatwork.ch */ - var object3DId = 0; - function Object3D() { - Object.defineProperty( this, 'id', { value: object3DId ++ } ); + Object.defineProperty( this, 'id', { value: _object3DId ++ } ); this.uuid = _Math.generateUUID(); @@ -5330,135 +5308,81 @@ }, - rotateOnAxis: function () { + rotateOnAxis: function ( axis, angle ) { // rotate object on axis in object space // axis is assumed to be normalized - var q1 = new Quaternion(); - - return function rotateOnAxis( axis, angle ) { + _q1.setFromAxisAngle( axis, angle ); - q1.setFromAxisAngle( axis, angle ); - - this.quaternion.multiply( q1 ); - - return this; + this.quaternion.multiply( _q1 ); - }; + return this; - }(), + }, - rotateOnWorldAxis: function () { + rotateOnWorldAxis: function ( axis, angle ) { // rotate object on axis in world space // axis is assumed to be normalized // method assumes no rotated parent - var q1 = new Quaternion(); - - return function rotateOnWorldAxis( axis, angle ) { - - q1.setFromAxisAngle( axis, angle ); - - this.quaternion.premultiply( q1 ); - - return this; - - }; - - }(), - - rotateX: function () { - - var v1 = new Vector3( 1, 0, 0 ); + _q1.setFromAxisAngle( axis, angle ); - return function rotateX( angle ) { + this.quaternion.premultiply( _q1 ); - return this.rotateOnAxis( v1, angle ); - - }; - - }(), - - rotateY: function () { - - var v1 = new Vector3( 0, 1, 0 ); + return this; - return function rotateY( angle ) { + }, - return this.rotateOnAxis( v1, angle ); + rotateX: function ( angle ) { - }; + return this.rotateOnAxis( _xAxis, angle ); - }(), + }, - rotateZ: function () { + rotateY: function ( angle ) { - var v1 = new Vector3( 0, 0, 1 ); + return this.rotateOnAxis( _yAxis, angle ); - return function rotateZ( angle ) { + }, - return this.rotateOnAxis( v1, angle ); + rotateZ: function ( angle ) { - }; + return this.rotateOnAxis( _zAxis, angle ); - }(), + }, - translateOnAxis: function () { + translateOnAxis: function ( axis, distance ) { // translate object by distance along axis in object space // axis is assumed to be normalized - var v1 = new Vector3(); - - return function translateOnAxis( axis, distance ) { - - v1.copy( axis ).applyQuaternion( this.quaternion ); - - this.position.add( v1.multiplyScalar( distance ) ); - - return this; - - }; - - }(), - - translateX: function () { - - var v1 = new Vector3( 1, 0, 0 ); - - return function translateX( distance ) { - - return this.translateOnAxis( v1, distance ); - - }; + _v1$1.copy( axis ).applyQuaternion( this.quaternion ); - }(), + this.position.add( _v1$1.multiplyScalar( distance ) ); - translateY: function () { - - var v1 = new Vector3( 0, 1, 0 ); + return this; - return function translateY( distance ) { + }, - return this.translateOnAxis( v1, distance ); + translateX: function ( distance ) { - }; + return this.translateOnAxis( _xAxis, distance ); - }(), + }, - translateZ: function () { + translateY: function ( distance ) { - var v1 = new Vector3( 0, 0, 1 ); + return this.translateOnAxis( _yAxis, distance ); - return function translateZ( distance ) { + }, - return this.translateOnAxis( v1, distance ); + translateZ: function ( distance ) { - }; + return this.translateOnAxis( _zAxis, distance ); - }(), + }, localToWorld: function ( vector ) { @@ -5466,68 +5390,53 @@ }, - worldToLocal: function () { - - var m1 = new Matrix4(); + worldToLocal: function ( vector ) { - return function worldToLocal( vector ) { + return vector.applyMatrix4( _m1$1.getInverse( this.matrixWorld ) ); - return vector.applyMatrix4( m1.getInverse( this.matrixWorld ) ); - - }; - - }(), + }, - lookAt: function () { + lookAt: function ( x, y, z ) { // This method does not support objects having non-uniformly-scaled parent(s) - var q1 = new Quaternion(); - var m1 = new Matrix4(); - var target = new Vector3(); - var position = new Vector3(); - - return function lookAt( x, y, z ) { - - if ( x.isVector3 ) { - - target.copy( x ); + if ( x.isVector3 ) { - } else { + _target.copy( x ); - target.set( x, y, z ); + } else { - } + _target.set( x, y, z ); - var parent = this.parent; + } - this.updateWorldMatrix( true, false ); + var parent = this.parent; - position.setFromMatrixPosition( this.matrixWorld ); + this.updateWorldMatrix( true, false ); - if ( this.isCamera || this.isLight ) { + _position.setFromMatrixPosition( this.matrixWorld ); - m1.lookAt( position, target, this.up ); + if ( this.isCamera || this.isLight ) { - } else { + _m1$1.lookAt( _position, _target, this.up ); - m1.lookAt( target, position, this.up ); + } else { - } + _m1$1.lookAt( _target, _position, this.up ); - this.quaternion.setFromRotationMatrix( m1 ); + } - if ( parent ) { + this.quaternion.setFromRotationMatrix( _m1$1 ); - m1.extractRotation( parent.matrixWorld ); - q1.setFromRotationMatrix( m1 ); - this.quaternion.premultiply( q1.inverse() ); + if ( parent ) { - } + _m1$1.extractRotation( parent.matrixWorld ); + _q1.setFromRotationMatrix( _m1$1 ); + this.quaternion.premultiply( _q1.inverse() ); - }; + } - }(), + }, add: function ( object ) { @@ -5561,7 +5470,7 @@ object.parent = this; this.children.push( object ); - object.dispatchEvent( { type: 'added' } ); + object.dispatchEvent( _addedEvent ); } else { @@ -5594,7 +5503,7 @@ object.parent = null; this.children.splice( index, 1 ); - object.dispatchEvent( { type: 'removed' } ); + object.dispatchEvent( _removedEvent ); } @@ -5602,37 +5511,31 @@ }, - attach: function () { + attach: function ( object ) { // adds object as a child of this, while maintaining the object's world transform - var m = new Matrix4(); - - return function attach( object ) { + this.updateWorldMatrix( true, false ); - this.updateWorldMatrix( true, false ); - - m.getInverse( this.matrixWorld ); - - if ( object.parent !== null ) { + _m1$1.getInverse( this.matrixWorld ); - object.parent.updateWorldMatrix( true, false ); + if ( object.parent !== null ) { - m.multiply( object.parent.matrixWorld ); + object.parent.updateWorldMatrix( true, false ); - } + _m1$1.multiply( object.parent.matrixWorld ); - object.applyMatrix( m ); + } - object.updateWorldMatrix( false, false ); + object.applyMatrix( _m1$1 ); - this.add( object ); + object.updateWorldMatrix( false, false ); - return this; + this.add( object ); - }; + return this; - }(), + }, getObjectById: function ( id ) { @@ -5682,53 +5585,39 @@ }, - getWorldQuaternion: function () { - - var position = new Vector3(); - var scale = new Vector3(); - - return function getWorldQuaternion( target ) { - - if ( target === undefined ) { - - console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' ); - target = new Quaternion(); - - } - - this.updateMatrixWorld( true ); + getWorldQuaternion: function ( target ) { - this.matrixWorld.decompose( position, target, scale ); + if ( target === undefined ) { - return target; + console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' ); + target = new Quaternion(); - }; + } - }(), + this.updateMatrixWorld( true ); - getWorldScale: function () { + this.matrixWorld.decompose( _position, target, _scale ); - var position = new Vector3(); - var quaternion = new Quaternion(); + return target; - return function getWorldScale( target ) { + }, - if ( target === undefined ) { + getWorldScale: function ( target ) { - console.warn( 'THREE.Object3D: .getWorldScale() target is now required' ); - target = new Vector3(); + if ( target === undefined ) { - } + console.warn( 'THREE.Object3D: .getWorldScale() target is now required' ); + target = new Vector3(); - this.updateMatrixWorld( true ); + } - this.matrixWorld.decompose( position, quaternion, target ); + this.updateMatrixWorld( true ); - return target; + this.matrixWorld.decompose( _position, _quaternion$2, target ); - }; + return target; - }(), + }, getWorldDirection: function ( target ) { @@ -6161,20 +6050,40 @@ } ); + var _points = [ + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3() + ]; + var _vector$2 = new Vector3(); + + // triangle centered vertices + + var _v0 = new Vector3(); + var _v1$2 = new Vector3(); + var _v2 = new Vector3(); + + // triangle edge vectors + + var _f0 = new Vector3(); + var _f1 = new Vector3(); + var _f2 = new Vector3(); + + var _center = new Vector3(); + var _extents = new Vector3(); + var _triangleNormal = new Vector3(); + var _testAxis = new Vector3(); + /** * @author bhouston / http://clara.io * @author WestLangley / http://github.com/WestLangley */ - var _points; - var _vector$2; - - var _v0, _v1$1, _v2; - var _f0, _f1, _f2; - var _center; - var _extents; - var _triangleNormal; - function Box3( min, max ) { this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity ); @@ -6277,8 +6186,6 @@ setFromCenterAndSize: function ( center, size ) { - if ( _vector$2 === undefined ) _vector$2 = new Vector3(); - var halfSize = _vector$2.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); @@ -6383,8 +6290,6 @@ expandByObject: function ( object ) { - if ( _vector$2 === undefined ) _vector$2 = new Vector3(); - var i, l; // Computes the world-axis-aligned bounding box of an object (including its children), @@ -6490,8 +6395,6 @@ intersectsSphere: function ( sphere ) { - if ( _vector$2 === undefined ) _vector$2 = new Vector3(); - // Find the point on the AABB closest to the sphere center. this.clampPoint( sphere.center, _vector$2 ); @@ -6549,26 +6452,6 @@ intersectsTriangle: function ( triangle ) { - if ( _v0 === undefined ) { - - // triangle centered vertices - - _v0 = new Vector3(); - _v1$1 = new Vector3(); - _v2 = new Vector3(); - - // triangle edge vectors - - _f0 = new Vector3(); - _f1 = new Vector3(); - _f2 = new Vector3(); - - _center = new Vector3(); - _extents = new Vector3(); - _triangleNormal = new Vector3(); - - } - if ( this.isEmpty() ) { return false; @@ -6581,12 +6464,12 @@ // translate triangle to aabb origin _v0.subVectors( triangle.a, _center ); - _v1$1.subVectors( triangle.b, _center ); + _v1$2.subVectors( triangle.b, _center ); _v2.subVectors( triangle.c, _center ); // compute edge vectors for triangle - _f0.subVectors( _v1$1, _v0 ); - _f1.subVectors( _v2, _v1$1 ); + _f0.subVectors( _v1$2, _v0 ); + _f1.subVectors( _v2, _v1$2 ); _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 @@ -6597,7 +6480,7 @@ _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, _v0, _v1$1, _v2, _extents ) ) { + if ( ! satForAxes( axes, _v0, _v1$2, _v2, _extents ) ) { return false; @@ -6605,7 +6488,7 @@ // test 3 face normals from the aabb axes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ]; - if ( ! satForAxes( axes, _v0, _v1$1, _v2, _extents ) ) { + if ( ! satForAxes( axes, _v0, _v1$2, _v2, _extents ) ) { return false; @@ -6616,7 +6499,7 @@ _triangleNormal.crossVectors( _f0, _f1 ); axes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ]; - return satForAxes( axes, _v0, _v1$1, _v2, _extents ); + return satForAxes( axes, _v0, _v1$2, _v2, _extents ); }, @@ -6635,8 +6518,6 @@ distanceToPoint: function ( point ) { - if ( _vector$2 === undefined ) _vector$2 = new Vector3(); - var clampedPoint = _vector$2.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); @@ -6645,8 +6526,6 @@ getBoundingSphere: function ( target ) { - if ( _vector$2 === undefined ) _vector$2 = new Vector3(); - if ( target === undefined ) { console.error( 'THREE.Box3: .getBoundingSphere() target is now required' ); @@ -6685,21 +6564,6 @@ applyMatrix4: function ( matrix ) { - if ( _points === undefined ) { - - _points = [ - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3() - ]; - - } - // transform of empty box is an empty box. if ( this.isEmpty() ) return this; @@ -6736,12 +6600,8 @@ } ); - var _testAxis; - function satForAxes( axes, v0, v1, v2, extents ) { - if ( _testAxis === undefined ) _testAxis = new Vector3(); - var i, j; for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) { @@ -6768,13 +6628,13 @@ } + var _box = new Box3(); + /** * @author bhouston / http://clara.io * @author mrdoob / http://mrdoob.com/ */ - var _box; - function Sphere( center, radius ) { this.center = ( center !== undefined ) ? center : new Vector3(); @@ -6795,8 +6655,6 @@ setFromPoints: function ( points, optionalCenter ) { - if ( _box === undefined ) _box = new Box3(); - var center = this.center; if ( optionalCenter !== undefined ) { @@ -6941,14 +6799,19 @@ } ); + var _vector$3 = new Vector3(); + var _segCenter = new Vector3(); + var _segDir = new Vector3(); + var _diff = new Vector3(); + + var _edge1 = new Vector3(); + var _edge2 = new Vector3(); + var _normal = new Vector3(); + /** * @author bhouston / http://clara.io */ - var _vector$3; - var _segCenter, _segDir, _diff; - var _diff, _edge1, _edge2, _normal; - function Ray( origin, direction ) { this.origin = ( origin !== undefined ) ? origin : new Vector3(); @@ -7005,8 +6868,6 @@ recast: function ( t ) { - if ( _vector$3 === undefined ) _vector$3 = new Vector3(); - this.origin.copy( this.at( t, _vector$3 ) ); return this; @@ -7044,8 +6905,6 @@ distanceSqToPoint: function ( point ) { - if ( _vector$3 === undefined ) _vector$3 = new Vector3(); - var directionDistance = _vector$3.subVectors( point, this.origin ).dot( this.direction ); // point behind the ray @@ -7064,14 +6923,6 @@ distanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) { - if ( _segCenter === undefined ) { - - _segCenter = new Vector3(); - _segDir = new Vector3(); - _diff = new Vector3(); - - } - // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h // It returns the min distance between the ray and the segment // defined by v0 and v1 @@ -7191,8 +7042,6 @@ intersectSphere: function ( sphere, target ) { - if ( _vector$3 === undefined ) _vector$3 = new Vector3(); - _vector$3.subVectors( sphere.center, this.origin ); var tca = _vector$3.dot( this.direction ); var d2 = _vector$3.dot( _vector$3 ) - tca * tca; @@ -7365,8 +7214,6 @@ intersectsBox: function ( box ) { - if ( _vector$3 === undefined ) _vector$3 = new Vector3(); - return this.intersectBox( box, _vector$3 ) !== null; }, @@ -7375,15 +7222,6 @@ // Compute the offset origin, edges, and normal. - if ( _diff === undefined ) { - - _diff = new Vector3(); - _edge1 = new Vector3(); - _edge2 = new Vector3(); - _normal = new Vector3(); - - } - // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h _edge1.subVectors( b, a ); @@ -7477,8 +7315,17 @@ * @author mrdoob / http://mrdoob.com/ */ - var _v0$1, _v1$2, _v2$1, _v3; - var _vab, _vac, _vbc, _vap, _vbp, _vcp; + var _v0$1 = new Vector3(); + var _v1$3 = new Vector3(); + var _v2$1 = new Vector3(); + var _v3 = new Vector3(); + + var _vab = new Vector3(); + var _vac = new Vector3(); + var _vbc = new Vector3(); + var _vap = new Vector3(); + var _vbp = new Vector3(); + var _vcp = new Vector3(); function Triangle( a, b, c ) { @@ -7492,8 +7339,6 @@ getNormal: function ( a, b, c, target ) { - if ( _v0$1 === undefined ) _v0$1 = new Vector3(); - if ( target === undefined ) { console.warn( 'THREE.Triangle: .getNormal() target is now required' ); @@ -7520,23 +7365,15 @@ // based on: http://www.blackpawn.com/texts/pointinpoly/default.html getBarycoord: function ( point, a, b, c, target ) { - if ( _v2$1 === undefined ) { - - _v0$1 = new Vector3(); - _v1$2 = new Vector3(); - _v2$1 = new Vector3(); - - } - _v0$1.subVectors( c, a ); - _v1$2.subVectors( b, a ); + _v1$3.subVectors( b, a ); _v2$1.subVectors( point, a ); var dot00 = _v0$1.dot( _v0$1 ); - var dot01 = _v0$1.dot( _v1$2 ); + var dot01 = _v0$1.dot( _v1$3 ); var dot02 = _v0$1.dot( _v2$1 ); - var dot11 = _v1$2.dot( _v1$2 ); - var dot12 = _v1$2.dot( _v2$1 ); + var dot11 = _v1$3.dot( _v1$3 ); + var dot12 = _v1$3.dot( _v2$1 ); var denom = ( dot00 * dot11 - dot01 * dot01 ); @@ -7567,8 +7404,6 @@ containsPoint: function ( point, a, b, c ) { - if ( _v3 === undefined ) _v3 = new Vector3(); - Triangle.getBarycoord( point, a, b, c, _v3 ); return ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 ); @@ -7577,8 +7412,6 @@ getUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) { - if ( _v3 === undefined ) _v3 = new Vector3(); - this.getBarycoord( point, p1, p2, p3, _v3 ); target.set( 0, 0 ); @@ -7592,18 +7425,11 @@ isFrontFacing: function ( a, b, c, direction ) { - if ( _v1$2 === undefined ) { - - _v0$1 = new Vector3(); - _v1$2 = new Vector3(); - - } - _v0$1.subVectors( c, b ); - _v1$2.subVectors( a, b ); + _v1$3.subVectors( a, b ); // strictly front facing - return ( _v0$1.cross( _v1$2 ).dot( direction ) < 0 ) ? true : false; + return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false; } @@ -7649,17 +7475,10 @@ getArea: function () { - if ( _v1$2 === undefined ) { - - _v0$1 = new Vector3(); - _v1$2 = new Vector3(); - - } - _v0$1.subVectors( this.c, this.b ); - _v1$2.subVectors( this.a, this.b ); + _v1$3.subVectors( this.a, this.b ); - return _v0$1.cross( _v1$2 ).length() * 0.5; + return _v0$1.cross( _v1$3 ).length() * 0.5; }, @@ -7727,17 +7546,6 @@ closestPointToPoint: function ( p, target ) { - if ( _vab === undefined ) { - - _vab = new Vector3(); - _vac = new Vector3(); - _vbc = new Vector3(); - _vap = new Vector3(); - _vbp = new Vector3(); - _vcp = new Vector3(); - - } - if ( target === undefined ) { console.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' ); @@ -8643,6 +8451,13 @@ if ( this.clearCoat !== undefined ) data.clearCoat = this.clearCoat; if ( this.clearCoatRoughness !== undefined ) data.clearCoatRoughness = this.clearCoatRoughness; + if ( this.clearCoatNormalMap && this.clearCoatNormalMap.isTexture ) { + + data.clearCoatNormalMap = this.clearCoatNormalMap.toJSON( meta ).uuid; + data.clearCoatNormalScale = this.clearCoatNormalScale.toArray(); + + } + if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid; if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid; if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid; @@ -9716,11 +9531,18 @@ * @author mrdoob / http://mrdoob.com/ */ - var bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id + var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id + + var _m1$2 = new Matrix4(); + var _obj = new Object3D(); + var _offset = new Vector3(); + var _box$1 = new Box3(); + var _boxMorphTargets = new Box3(); + var _vector$4 = new Vector3(); function BufferGeometry() { - Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } ); + Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } ); this.uuid = _Math.generateUUID(); @@ -9883,129 +9705,89 @@ }, - rotateX: function () { + rotateX: function ( angle ) { // rotate geometry around world x-axis - var m1 = new Matrix4(); - - return function rotateX( angle ) { + _m1$2.makeRotationX( angle ); - m1.makeRotationX( angle ); + this.applyMatrix( _m1$2 ); - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateY: function () { + rotateY: function ( angle ) { // rotate geometry around world y-axis - var m1 = new Matrix4(); + _m1$2.makeRotationY( angle ); - return function rotateY( angle ) { + this.applyMatrix( _m1$2 ); - m1.makeRotationY( angle ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateZ: function () { + rotateZ: function ( angle ) { // rotate geometry around world z-axis - var m1 = new Matrix4(); - - return function rotateZ( angle ) { + _m1$2.makeRotationZ( angle ); - m1.makeRotationZ( angle ); + this.applyMatrix( _m1$2 ); - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - translate: function () { + translate: function ( x, y, z ) { // translate geometry - var m1 = new Matrix4(); - - return function translate( x, y, z ) { - - m1.makeTranslation( x, y, z ); + _m1$2.makeTranslation( x, y, z ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1$2 ); - return this; - - }; + return this; - }(), + }, - scale: function () { + scale: function ( x, y, z ) { // scale geometry - var m1 = new Matrix4(); - - return function scale( x, y, z ) { - - m1.makeScale( x, y, z ); - - this.applyMatrix( m1 ); - - return this; - - }; + _m1$2.makeScale( x, y, z ); - }(), + this.applyMatrix( _m1$2 ); - lookAt: function () { + return this; - var obj = new Object3D(); + }, - return function lookAt( vector ) { + lookAt: function ( vector ) { - obj.lookAt( vector ); + _obj.lookAt( vector ); - obj.updateMatrix(); + _obj.updateMatrix(); - this.applyMatrix( obj.matrix ); + this.applyMatrix( _obj.matrix ); - }; + return this; - }(), + }, center: function () { - var offset = new Vector3(); + this.computeBoundingBox(); - return function center() { + this.boundingBox.getCenter( _offset ).negate(); - this.computeBoundingBox(); - - this.boundingBox.getCenter( offset ).negate(); + this.translate( _offset.x, _offset.y, _offset.z ); - this.translate( offset.x, offset.y, offset.z ); - - return this; - - }; + return this; - }(), + }, setFromObject: function ( object ) { @@ -10302,144 +10084,130 @@ computeBoundingBox: function () { - var box = new Box3(); - - return function computeBoundingBox() { - - if ( this.boundingBox === null ) { - - this.boundingBox = new Box3(); + if ( this.boundingBox === null ) { - } + this.boundingBox = new Box3(); - var position = this.attributes.position; - var morphAttributesPosition = this.morphAttributes.position; + } - if ( position !== undefined ) { + var position = this.attributes.position; + var morphAttributesPosition = this.morphAttributes.position; - this.boundingBox.setFromBufferAttribute( position ); + if ( position !== undefined ) { - // process morph attributes if present + this.boundingBox.setFromBufferAttribute( position ); - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; - box.setFromBufferAttribute( morphAttribute ); + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - this.boundingBox.expandByPoint( box.min ); - this.boundingBox.expandByPoint( box.max ); + var morphAttribute = morphAttributesPosition[ i ]; + _box$1.setFromBufferAttribute( morphAttribute ); - } + this.boundingBox.expandByPoint( _box$1.min ); + this.boundingBox.expandByPoint( _box$1.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 ); + } else { - } + this.boundingBox.makeEmpty(); - }; + } - }(), + if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) { - computeBoundingSphere: function () { + console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this ); - var box = new Box3(); - var boxMorphTargets = new Box3(); - var vector = new Vector3(); + } - return function computeBoundingSphere() { + }, - if ( this.boundingSphere === null ) { + computeBoundingSphere: function () { - this.boundingSphere = new Sphere(); + if ( this.boundingSphere === null ) { - } + this.boundingSphere = new Sphere(); - var position = this.attributes.position; - var morphAttributesPosition = this.morphAttributes.position; + } - if ( position ) { + var position = this.attributes.position; + var morphAttributesPosition = this.morphAttributes.position; - // first, find the center of the bounding sphere + if ( position ) { - var center = this.boundingSphere.center; + // first, find the center of the bounding sphere - box.setFromBufferAttribute( position ); + var center = this.boundingSphere.center; - // process morph attributes if present + _box$1.setFromBufferAttribute( position ); - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; - boxMorphTargets.setFromBufferAttribute( morphAttribute ); + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - box.expandByPoint( boxMorphTargets.min ); - box.expandByPoint( boxMorphTargets.max ); + var morphAttribute = morphAttributesPosition[ i ]; + _boxMorphTargets.setFromBufferAttribute( morphAttribute ); - } + _box$1.expandByPoint( _boxMorphTargets.min ); + _box$1.expandByPoint( _boxMorphTargets.max ); } - box.getCenter( center ); + } - // second, try to find a boundingSphere with a radius smaller than the - // boundingSphere of the boundingBox: sqrt(3) smaller in the best case + _box$1.getCenter( center ); - var maxRadiusSq = 0; + // second, try to find a boundingSphere with a radius smaller than the + // boundingSphere of the boundingBox: sqrt(3) smaller in the best case - for ( var i = 0, il = position.count; i < il; i ++ ) { + var maxRadiusSq = 0; - vector.fromBufferAttribute( position, i ); + for ( var i = 0, il = position.count; i < il; i ++ ) { - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + _vector$4.fromBufferAttribute( position, i ); - } + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); - // process morph attributes if present + } - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { + var morphAttribute = morphAttributesPosition[ i ]; - vector.fromBufferAttribute( morphAttribute, j ); + for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + _vector$4.fromBufferAttribute( morphAttribute, j ); - } + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); } } - this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); + } - if ( isNaN( this.boundingSphere.radius ) ) { + this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); - console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); + if ( isNaN( this.boundingSphere.radius ) ) { - } + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); } - }; + } - }(), + }, computeFaceNormals: function () { @@ -10601,27 +10369,21 @@ normalizeNormals: function () { - var vector = new Vector3(); - - return function normalizeNormals() { + var normals = this.attributes.normal; - var normals = this.attributes.normal; + for ( var i = 0, il = normals.count; i < il; i ++ ) { - for ( var i = 0, il = normals.count; i < il; i ++ ) { + _vector$4.x = normals.getX( i ); + _vector$4.y = normals.getY( i ); + _vector$4.z = normals.getZ( i ); - vector.x = normals.getX( i ); - vector.y = normals.getY( i ); - vector.z = normals.getZ( i ); + _vector$4.normalize(); - vector.normalize(); + normals.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); - normals.setXYZ( i, vector.x, vector.y, vector.z ); - - } - - }; + } - }(), + }, toNonIndexed: function () { @@ -10974,12 +10736,28 @@ * @author jonobr1 / http://jonobr1.com/ */ - var _inverseMatrix, _ray, _sphere; - var _vA, _vB, _vC; - var _tempA, _tempB, _tempC; - var _morphA, _morphB, _morphC; - var _uvA, _uvB, _uvC; - var _intersectionPoint, _intersectionPointWorld; + var _inverseMatrix = new Matrix4(); + var _ray = new Ray(); + var _sphere = new Sphere(); + + var _vA = new Vector3(); + var _vB = new Vector3(); + var _vC = new Vector3(); + + var _tempA = new Vector3(); + 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(); + + var _intersectionPoint = new Vector3(); + var _intersectionPointWorld = new Vector3(); function Mesh( geometry, material ) { @@ -11078,33 +10856,6 @@ raycast: function ( raycaster, intersects ) { - if ( _intersectionPointWorld === undefined ) { - - _inverseMatrix = new Matrix4(); - _ray = new Ray(); - _sphere = new Sphere(); - - _vA = new Vector3(); - _vB = new Vector3(); - _vC = new Vector3(); - - _tempA = new Vector3(); - _tempB = new Vector3(); - _tempC = new Vector3(); - - _morphA = new Vector3(); - _morphB = new Vector3(); - _morphC = new Vector3(); - - _uvA = new Vector2(); - _uvB = new Vector2(); - _uvC = new Vector2(); - - _intersectionPoint = new Vector3(); - _intersectionPointWorld = new Vector3(); - - } - var geometry = this.geometry; var material = this.material; var matrixWorld = this.matrixWorld; @@ -11437,11 +11188,14 @@ * @author bhouston / http://clara.io */ - var geometryId = 0; // Geometry uses even numbers as Id + var _geometryId = 0; // Geometry uses even numbers as Id + var _m1$3 = new Matrix4(); + var _obj$1 = new Object3D(); + var _offset$1 = new Vector3(); function Geometry() { - Object.defineProperty( this, 'id', { value: geometryId += 2 } ); + Object.defineProperty( this, 'id', { value: _geometryId += 2 } ); this.uuid = _Math.generateUUID(); @@ -11525,111 +11279,77 @@ }, - rotateX: function () { + rotateX: function ( angle ) { // rotate geometry around world x-axis - var m1 = new Matrix4(); - - return function rotateX( angle ) { + _m1$3.makeRotationX( angle ); - m1.makeRotationX( angle ); + this.applyMatrix( _m1$3 ); - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateY: function () { + rotateY: function ( angle ) { // rotate geometry around world y-axis - var m1 = new Matrix4(); - - return function rotateY( angle ) { - - m1.makeRotationY( angle ); + _m1$3.makeRotationY( angle ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1$3 ); - return this; - - }; + return this; - }(), + }, - rotateZ: function () { + rotateZ: function ( angle ) { // rotate geometry around world z-axis - var m1 = new Matrix4(); - - return function rotateZ( angle ) { + _m1$3.makeRotationZ( angle ); - m1.makeRotationZ( angle ); - - this.applyMatrix( m1 ); - - return this; + this.applyMatrix( _m1$3 ); - }; + return this; - }(), + }, - translate: function () { + translate: function ( x, y, z ) { // translate geometry - var m1 = new Matrix4(); + _m1$3.makeTranslation( x, y, z ); - return function translate( x, y, z ) { + this.applyMatrix( _m1$3 ); - m1.makeTranslation( x, y, z ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - scale: function () { + scale: function ( x, y, z ) { // scale geometry - var m1 = new Matrix4(); - - return function scale( x, y, z ) { - - m1.makeScale( x, y, z ); - - this.applyMatrix( m1 ); + _m1$3.makeScale( x, y, z ); - return this; - - }; - - }(), + this.applyMatrix( _m1$3 ); - lookAt: function () { + return this; - var obj = new Object3D(); + }, - return function lookAt( vector ) { + lookAt: function ( vector ) { - obj.lookAt( vector ); + _obj$1.lookAt( vector ); - obj.updateMatrix(); + _obj$1.updateMatrix(); - this.applyMatrix( obj.matrix ); + this.applyMatrix( _obj$1.matrix ); - }; + return this; - }(), + }, fromBufferGeometry: function ( geometry ) { @@ -11766,21 +11486,15 @@ center: function () { - var offset = new Vector3(); + this.computeBoundingBox(); - return function center() { - - this.computeBoundingBox(); + this.boundingBox.getCenter( _offset$1 ).negate(); - this.boundingBox.getCenter( offset ).negate(); - - this.translate( offset.x, offset.y, offset.z ); - - return this; + this.translate( _offset$1.x, _offset$1.y, _offset$1.z ); - }; + return this; - }(), + }, normalize: function () { @@ -13870,7 +13584,9 @@ * @author bhouston / http://clara.io */ - var _vector1, _vector2, _normalMatrix; + var _vector1 = new Vector3(); + var _vector2 = new Vector3(); + var _normalMatrix = new Matrix3(); function Plane( normal, constant ) { @@ -13914,13 +13630,6 @@ setFromCoplanarPoints: function ( a, b, c ) { - if ( _vector1 === undefined ) { - - _vector1 = new Vector3(); - _vector2 = new Vector3(); - - } - var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize(); // Q: should an error be thrown if normal is zero (e.g. degenerate plane)? @@ -13994,8 +13703,6 @@ intersectLine: function ( line, target ) { - if ( _vector1 === undefined ) _vector1 = new Vector3(); - if ( target === undefined ) { console.warn( 'THREE.Plane: .intersectLine() target is now required' ); @@ -14071,13 +13778,6 @@ applyMatrix4: function ( matrix, optionalNormalMatrix ) { - if ( _normalMatrix === undefined ) { - - _normalMatrix = new Matrix3(); - _vector1 = new Vector3(); - - } - var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix ); var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix ); @@ -14112,8 +13812,8 @@ * @author bhouston / http://clara.io */ - var _sphere$1; - var _vector$4; + var _sphere$1 = new Sphere(); + var _vector$5 = new Vector3(); function Frustum( p0, p1, p2, p3, p4, p5 ) { @@ -14189,8 +13889,6 @@ intersectsObject: function ( object ) { - if ( _sphere$1 === undefined ) _sphere$1 = new Sphere(); - var geometry = object.geometry; if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); @@ -14203,8 +13901,6 @@ intersectsSprite: function ( sprite ) { - if ( _sphere$1 === undefined ) _sphere$1 = new Sphere(); - _sphere$1.center.set( 0, 0, 0 ); _sphere$1.radius = 0.7071067811865476; _sphere$1.applyMatrix4( sprite.matrixWorld ); @@ -14237,8 +13933,6 @@ intersectsBox: function ( box ) { - if ( _vector$4 === undefined ) _vector$4 = new Vector3(); - var planes = this.planes; for ( var i = 0; i < 6; i ++ ) { @@ -14247,11 +13941,11 @@ // corner at max distance - _vector$4.x = plane.normal.x > 0 ? box.max.x : box.min.x; - _vector$4.y = plane.normal.y > 0 ? box.max.y : box.min.y; - _vector$4.z = plane.normal.z > 0 ? box.max.z : box.min.z; + _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z; - if ( plane.distanceToPoint( _vector$4 ) < 0 ) { + if ( plane.distanceToPoint( _vector$5 ) < 0 ) { return false; @@ -14317,7 +14011,7 @@ var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; - var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n\tvec3 clearCoatNormal;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}"; + var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef PHYSICAL\n\tvec3 clearCoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}"; var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif"; @@ -14347,7 +14041,7 @@ var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif"; - var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; + var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; @@ -14369,11 +14063,11 @@ var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif"; - var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifndef STANDARD\n\t\tfloat ccDotNV = saturate( dot( geometry.clearCoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; + var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifdef PHYSICAL\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef PHYSICAL\n\t\tfloat ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef PHYSICAL\n\t\tfloat ccDotNV = saturate( dot( geometry.clearCoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; - var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tgeometry.clearCoatNormal = clearCoatNormal;\n#else\n\tgeometry.clearCoatNormal = geometryNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif"; + var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef PHYSICAL\n\tgeometry.clearCoatNormal = clearCoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif"; - var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif"; + var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifdef PHYSICAL\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif"; var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, irradiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif"; @@ -14409,7 +14103,7 @@ var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#endif\n#endif\n#if ( defined ( USE_NORMALMAP ) && !defined ( OBJECTSPACE_NORMALMAP )) || defined ( USE_CLEARCOAT_NORMALMAP )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvec3 NfromST = cross( S, T );\n\t\t\tif( dot( NfromST, N ) > 0.0 ) {\n\t\t\t\tS *= -1.0;\n\t\t\t\tT *= -1.0;\n\t\t\t}\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif"; - var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearCoatNormal = geometryNormal;\n#endif"; + var clearcoat_normal_fragment_begin = "#ifdef PHYSICAL\n\tvec3 clearCoatNormal = geometryNormal;\n#endif"; var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearCoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearCoatNormalScale * mapN.xy;\n\t\tclearCoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearCoatNormal = perturbNormal2Arb( - vViewPosition, clearCoatNormal, clearCoatNormalScale, clearCoatNormalMap );\n\t#endif\n#endif"; @@ -14421,15 +14115,15 @@ var project_vertex = "vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;"; - var dithering_fragment = "#if defined( DITHERING )\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; + var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; - var dithering_pars_fragment = "#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; + var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; - var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; + var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; @@ -14453,11 +14147,11 @@ var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}"; - var uv_pars_fragment = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif"; + var uv_pars_fragment = "#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif"; - var uv_pars_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif"; + var uv_pars_vertex = "#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif"; - var uv_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; + var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; @@ -14507,7 +14201,7 @@ var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; - var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; + var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef PHYSICAL\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; var meshphysical_vert = "#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; @@ -15693,15 +15387,17 @@ function renderInstances( geometry, start, count ) { - var extension; + var extension, methodName; if ( capabilities.isWebGL2 ) { extension = gl; + methodName = 'drawArraysInstanced'; } else { extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawArraysInstancedANGLE'; if ( extension === null ) { @@ -15712,7 +15408,7 @@ } - extension[ capabilities.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount ); + extension[ methodName ]( mode, start, count, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount ); @@ -16068,13 +15764,13 @@ function WebGLGeometries( gl, attributes, info ) { - var geometries = {}; - var wireframeAttributes = {}; + var geometries = new WeakMap(); + var wireframeAttributes = new WeakMap(); function onGeometryDispose( event ) { var geometry = event.target; - var buffergeometry = geometries[ geometry.id ]; + var buffergeometry = geometries.get( geometry ); if ( buffergeometry.index !== null ) { @@ -16090,14 +15786,14 @@ geometry.removeEventListener( 'dispose', onGeometryDispose ); - delete geometries[ geometry.id ]; + geometries.delete( geometry ); - var attribute = wireframeAttributes[ buffergeometry.id ]; + var attribute = wireframeAttributes.get( buffergeometry ); if ( attribute ) { attributes.remove( attribute ); - delete wireframeAttributes[ buffergeometry.id ]; + wireframeAttributes.delete( buffergeometry ); } @@ -16109,7 +15805,7 @@ function get( object, geometry ) { - var buffergeometry = geometries[ geometry.id ]; + var buffergeometry = geometries.get( geometry ); if ( buffergeometry ) return buffergeometry; @@ -16131,7 +15827,7 @@ } - geometries[ geometry.id ] = buffergeometry; + geometries.set( geometry, buffergeometry ); info.memory.geometries ++; @@ -16221,19 +15917,19 @@ // - var previousAttribute = wireframeAttributes[ geometry.id ]; + var previousAttribute = wireframeAttributes.get( geometry ); if ( previousAttribute ) attributes.remove( previousAttribute ); // - wireframeAttributes[ geometry.id ] = attribute; + wireframeAttributes.set( geometry, attribute ); } function getWireframeAttribute( geometry ) { - var currentAttribute = wireframeAttributes[ geometry.id ]; + var currentAttribute = wireframeAttributes.get( geometry ); if ( currentAttribute ) { @@ -16257,7 +15953,7 @@ } - return wireframeAttributes[ geometry.id ]; + return wireframeAttributes.get( geometry ); } @@ -16305,15 +16001,17 @@ function renderInstances( geometry, start, count ) { - var extension; + var extension, methodName; if ( capabilities.isWebGL2 ) { extension = gl; + methodName = 'drawElementsInstanced'; } else { - var extension = extensions.get( 'ANGLE_instanced_arrays' ); + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawElementsInstancedANGLE'; if ( extension === null ) { @@ -16324,7 +16022,7 @@ } - extension[ capabilities.isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); + extension[ methodName ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount ); @@ -17906,7 +17604,7 @@ '#define MAX_BONES ' + parameters.maxBones, ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', - ( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', @@ -17926,6 +17624,7 @@ parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexUvs ? '#define USE_UV' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', @@ -18020,7 +17719,7 @@ '#define GAMMA_FACTOR ' + gammaFactorDefine, ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', - ( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', @@ -18042,6 +17741,7 @@ parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexUvs ? '#define USE_UV' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', @@ -18060,7 +17760,7 @@ parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', - parameters.envMap && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', + ( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', @@ -18317,7 +18017,7 @@ "precision", "supportsVertexTextures", "map", "mapEncoding", "matcap", "matcapEncoding", "envMap", "envMapMode", "envMapEncoding", "lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "clearCoatNormalMap", "displacementMap", "specularMap", "roughnessMap", "metalnessMap", "gradientMap", - "alphaMap", "combine", "vertexColors", "vertexTangents", "fog", "useFog", "fogExp", + "alphaMap", "combine", "vertexColors", "vertexTangents", "fog", "useFog", "fogExp2", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", "maxMorphTargets", "maxMorphNormals", "premultipliedAlpha", @@ -18452,10 +18152,11 @@ vertexTangents: ( material.normalMap && material.vertexTangents ), vertexColors: material.vertexColors, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearCoatNormalMap, fog: !! fog, useFog: material.fog, - fogExp: ( fog && fog.isFogExp2 ), + fogExp2: ( fog && fog.isFogExp2 ), flatShading: material.flatShading, @@ -18804,7 +18505,7 @@ function WebGLRenderLists() { - var lists = {}; + var lists = new WeakMap(); function onSceneDispose( event ) { @@ -18812,29 +18513,29 @@ scene.removeEventListener( 'dispose', onSceneDispose ); - delete lists[ scene.id ]; + lists.delete( scene ); } function get( scene, camera ) { - var cameras = lists[ scene.id ]; + var cameras = lists.get( scene ); var list; if ( cameras === undefined ) { list = new WebGLRenderList(); - lists[ scene.id ] = {}; - lists[ scene.id ][ camera.id ] = list; + lists.set( scene, new WeakMap() ); + lists.get( scene ).set( camera, list ); scene.addEventListener( 'dispose', onSceneDispose ); } else { - list = cameras[ camera.id ]; + list = cameras.get( camera ); if ( list === undefined ) { list = new WebGLRenderList(); - cameras[ camera.id ] = list; + cameras.set( camera, list ); } @@ -18846,7 +18547,7 @@ function dispose() { - lists = {}; + lists = new WeakMap(); } @@ -19315,7 +19016,7 @@ function WebGLRenderStates() { - var renderStates = {}; + var renderStates = new WeakMap(); function onSceneDispose( event ) { @@ -19323,7 +19024,7 @@ scene.removeEventListener( 'dispose', onSceneDispose ); - delete renderStates[ scene.id ]; + renderStates.delete( scene ); } @@ -19331,24 +19032,24 @@ var renderState; - if ( renderStates[ scene.id ] === undefined ) { + if ( renderStates.has( scene ) === false ) { renderState = new WebGLRenderState(); - renderStates[ scene.id ] = {}; - renderStates[ scene.id ][ camera.id ] = renderState; + renderStates.set( scene, new WeakMap() ); + renderStates.get( scene ).set( camera, renderState ); scene.addEventListener( 'dispose', onSceneDispose ); } else { - if ( renderStates[ scene.id ][ camera.id ] === undefined ) { + if ( renderStates.get( scene ).has( camera ) === false ) { renderState = new WebGLRenderState(); - renderStates[ scene.id ][ camera.id ] = renderState; + renderStates.get( scene ).set( camera, renderState ); } else { - renderState = renderStates[ scene.id ][ camera.id ]; + renderState = renderStates.get( scene ).get( camera ); } @@ -19360,7 +19061,7 @@ function dispose() { - renderStates = {}; + renderStates = new WeakMap(); } @@ -20945,7 +20646,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) { - var _videoTextures = {}; + var _videoTextures = new WeakMap(); var _canvas; // @@ -21127,7 +20828,7 @@ if ( texture.isVideoTexture ) { - delete _videoTextures[ texture.id ]; + _videoTextures.delete( texture ); } @@ -21295,104 +20996,110 @@ function setTextureCube( texture, slot ) { + if ( texture.image.length !== 6 ) return; + var textureProperties = properties.get( texture ); - if ( texture.image.length === 6 ) { + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { - if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + initTexture( textureProperties, texture ); - initTexture( textureProperties, texture ); + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); - state.activeTexture( 33984 + slot ); - state.bindTexture( 34067, textureProperties.__webglTexture ); + _gl.pixelStorei( 37440, texture.flipY ); - _gl.pixelStorei( 37440, texture.flipY ); + var isCompressed = ( texture && texture.isCompressedTexture ); + var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); - var isCompressed = ( texture && texture.isCompressedTexture ); - var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); + var cubeImage = []; - var cubeImage = []; + for ( var i = 0; i < 6; i ++ ) { - for ( var i = 0; i < 6; i ++ ) { + if ( ! isCompressed && ! isDataTexture ) { - if ( ! isCompressed && ! isDataTexture ) { + cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize ); - cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize ); + } else { - } else { + cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; - cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; + } - } + } - } + var image = cubeImage[ 0 ], + supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, + glFormat = utils.convert( texture.format ), + glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( glFormat, glType ); - var image = cubeImage[ 0 ], - supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, - glFormat = utils.convert( texture.format ), - glType = utils.convert( texture.type ), - glInternalFormat = getInternalFormat( glFormat, glType ); + setTextureParameters( 34067, texture, supportsMips ); - setTextureParameters( 34067, texture, supportsMips ); + var mipmaps; - var mipmaps = texture.mipmaps; + if ( isCompressed ) { for ( var i = 0; i < 6; i ++ ) { - if ( ! isCompressed ) { + mipmaps = cubeImage[ i ].mipmaps; - if ( isDataTexture ) { + for ( var j = 0; j < mipmaps.length; j ++ ) { - state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); + var mipmap = mipmaps[ j ]; - for ( var j = 0; j < mipmaps.length; ++ j ) { + if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) { - var mipmap = mipmaps[ j ]; - var image = mipmap.image[ i ].image; + if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { - state.texImage2D( 34069 + i, j + 1, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data ); + state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); } } else { - state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); + state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); - for ( var j = 0; j < mipmaps.length; ++ j ) { + } - var mipmap = mipmaps[ j ]; + } - state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); + } - } + textureProperties.__maxMipLevel = mipmaps.length - 1; - } + } else { - } else { + mipmaps = texture.mipmaps; - var mipmaps = cubeImage[ i ].mipmaps; + for ( var i = 0; i < 6; i ++ ) { - for ( var j = 0, jl = mipmaps.length; j < jl; j ++ ) { + if ( isDataTexture ) { - var mipmap = mipmaps[ j ]; + state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); - if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) { + for ( var j = 0; j < mipmaps.length; j ++ ) { - if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { + var mipmap = mipmaps[ j ]; + var mipmapImage = mipmap.image[ i ].image; - state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data ); - } else { + } - console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); + } else { - } + state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); - } else { + for ( var j = 0; j < mipmaps.length; j ++ ) { - state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + var mipmap = mipmaps[ j ]; - } + state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); } @@ -21400,25 +21107,25 @@ } - textureProperties.__maxMipLevel = isCompressed ? mipmaps.length - 1 : mipmaps.length; + textureProperties.__maxMipLevel = mipmaps.length; - if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + } - // We assume images for cube map have the same size. - generateMipmap( 34067, texture, image.width, image.height ); + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - } + // We assume images for cube map have the same size. + generateMipmap( 34067, texture, image.width, image.height ); - textureProperties.__version = texture.version; + } - if ( texture.onUpdate ) texture.onUpdate( texture ); + textureProperties.__version = texture.version; - } else { + if ( texture.onUpdate ) texture.onUpdate( texture ); - state.activeTexture( 33984 + slot ); - state.bindTexture( 34067, textureProperties.__webglTexture ); + } else { - } + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); } @@ -22036,14 +21743,13 @@ function updateVideoTexture( texture ) { - var id = texture.id; var frame = info.render.frame; // Check the last frame we updated the VideoTexture - if ( _videoTextures[ id ] !== frame ) { + if ( _videoTextures.get( texture ) !== frame ) { - _videoTextures[ id ] = frame; + _videoTextures.set( texture, frame ); texture.update(); } @@ -26065,10 +25771,21 @@ var _geometry; - var _intersectPoint, _worldScale, _mvPosition; - var _alignedPosition, _rotatedPosition, _viewWorldMatrix; - var _vA$1, _vB$1, _vC$1; - var _uvA$1, _uvB$1, _uvC$1; + var _intersectPoint = new Vector3(); + var _worldScale = new Vector3(); + var _mvPosition = new Vector3(); + + var _alignedPosition = new Vector2(); + var _rotatedPosition = new Vector2(); + var _viewWorldMatrix = new Matrix4(); + + var _vA$1 = new Vector3(); + var _vB$1 = new Vector3(); + var _vC$1 = new Vector3(); + + var _uvA$1 = new Vector2(); + var _uvB$1 = new Vector2(); + var _uvC$1 = new Vector2(); function Sprite( material ) { @@ -26110,34 +25827,20 @@ raycast: function ( raycaster, intersects ) { - if ( _uvC$1 === undefined ) { - - _intersectPoint = new Vector3(); - _worldScale = new Vector3(); - _mvPosition = new Vector3(); - - _alignedPosition = new Vector2(); - _rotatedPosition = new Vector2(); - _viewWorldMatrix = new Matrix4(); - - _vA$1 = new Vector3(); - _vB$1 = new Vector3(); - _vC$1 = new Vector3(); + if ( raycaster.camera === null ) { - _uvA$1 = new Vector2(); - _uvB$1 = new Vector2(); - _uvC$1 = new Vector2(); + console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' ); } _worldScale.setFromMatrixScale( this.matrixWorld ); - _viewWorldMatrix.copy( raycaster._camera.matrixWorld ); - this.modelViewMatrix.multiplyMatrices( raycaster._camera.matrixWorldInverse, this.matrixWorld ); + _viewWorldMatrix.copy( raycaster.camera.matrixWorld ); + this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld ); _mvPosition.setFromMatrixPosition( this.modelViewMatrix ); - if ( raycaster._camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { + if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { _worldScale.multiplyScalar( - _mvPosition.z ); @@ -26248,7 +25951,8 @@ * @author mrdoob / http://mrdoob.com/ */ - var _v1$3, _v2$2; + var _v1$4 = new Vector3(); + var _v2$2 = new Vector3(); function LOD() { @@ -26337,11 +26041,9 @@ raycast: function ( raycaster, intersects ) { - if ( _v1$3 === undefined ) _v1$3 = new Vector3(); + _v1$4.setFromMatrixPosition( this.matrixWorld ); - _v1$3.setFromMatrixPosition( this.matrixWorld ); - - var distance = raycaster.ray.origin.distanceTo( _v1$3 ); + var distance = raycaster.ray.origin.distanceTo( _v1$4 ); this.getObjectForDistance( distance ).raycast( raycaster, intersects ); @@ -26349,21 +26051,14 @@ update: function ( camera ) { - if ( _v2$2 === undefined ) { - - _v1$3 = new Vector3(); - _v2$2 = new Vector3(); - - } - var levels = this.levels; if ( levels.length > 1 ) { - _v1$3.setFromMatrixPosition( camera.matrixWorld ); + _v1$4.setFromMatrixPosition( camera.matrixWorld ); _v2$2.setFromMatrixPosition( this.matrixWorld ); - var distance = _v1$3.distanceTo( _v2$2 ); + var distance = _v1$4.distanceTo( _v2$2 ); levels[ 0 ].object.visible = true; @@ -26538,7 +26233,8 @@ * @author ikerr / http://verold.com */ - var _offsetMatrix, _identityMatrix; + var _offsetMatrix = new Matrix4(); + var _identityMatrix = new Matrix4(); function Skeleton( bones, boneInverses ) { @@ -26648,13 +26344,6 @@ update: function () { - if ( _identityMatrix === undefined ) { - - _offsetMatrix = new Matrix4(); - _identityMatrix = new Matrix4(); - - } - var bones = this.bones; var boneInverses = this.boneInverses; var boneMatrices = this.boneMatrices; @@ -26784,8 +26473,11 @@ * @author mrdoob / http://mrdoob.com/ */ - var _start, _end; - var _inverseMatrix$1, _ray$1, _sphere$2; + var _start = new Vector3(); + var _end = new Vector3(); + var _inverseMatrix$1 = new Matrix4(); + var _ray$1 = new Ray(); + var _sphere$2 = new Sphere(); function Line( geometry, material, mode ) { @@ -26812,13 +26504,6 @@ computeLineDistances: function () { - if ( _end === undefined ) { - - _start = new Vector3(); - _end = new Vector3(); - - } - var geometry = this.geometry; if ( geometry.isBufferGeometry ) { @@ -26870,14 +26555,6 @@ raycast: function ( raycaster, intersects ) { - if ( _sphere$2 === undefined ) { - - _inverseMatrix$1 = new Matrix4(); - _ray$1 = new Ray(); - _sphere$2 = new Sphere(); - - } - var precision = raycaster.linePrecision; var geometry = this.geometry; @@ -27032,7 +26709,8 @@ * @author mrdoob / http://mrdoob.com/ */ - var _start$1, _end$1; + var _start$1 = new Vector3(); + var _end$1 = new Vector3(); function LineSegments( geometry, material ) { @@ -27050,13 +26728,6 @@ computeLineDistances: function () { - if ( _end$1 === undefined ) { - - _start$1 = new Vector3(); - _end$1 = new Vector3(); - - } - var geometry = this.geometry; if ( geometry.isBufferGeometry ) { @@ -27192,7 +26863,10 @@ * @author alteredq / http://alteredqualia.com/ */ - var _inverseMatrix$2, _ray$2, _sphere$3; + var _inverseMatrix$2 = new Matrix4(); + var _ray$2 = new Ray(); + var _sphere$3 = new Sphere(); + var _position$1 = new Vector3(); function Points( geometry, material ) { @@ -27215,15 +26889,6 @@ raycast: function ( raycaster, intersects ) { - if ( _sphere$3 === undefined ) { - - _inverseMatrix$2 = new Matrix4(); - _ray$2 = new Ray(); - _sphere$3 = new Sphere(); - - } - - var object = this; var geometry = this.geometry; var matrixWorld = this.matrixWorld; var threshold = raycaster.params.Points.threshold; @@ -27245,36 +26910,6 @@ var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); var localThresholdSq = localThreshold * localThreshold; - var position = new Vector3(); - var intersectPoint = new Vector3(); - - function testPoint( point, index ) { - - var rayPointDistanceSq = _ray$2.distanceSqToPoint( point ); - - if ( rayPointDistanceSq < localThresholdSq ) { - - _ray$2.closestPointToPoint( point, intersectPoint ); - intersectPoint.applyMatrix4( matrixWorld ); - - var distance = raycaster.ray.origin.distanceTo( intersectPoint ); - - if ( distance < raycaster.near || distance > raycaster.far ) return; - - intersects.push( { - - distance: distance, - distanceToRay: Math.sqrt( rayPointDistanceSq ), - point: intersectPoint.clone(), - index: index, - face: null, - object: object - - } ); - - } - - } if ( geometry.isBufferGeometry ) { @@ -27290,9 +26925,9 @@ var a = indices[ i ]; - position.fromArray( positions, a * 3 ); + _position$1.fromArray( positions, a * 3 ); - testPoint( position, a ); + testPoint( _position$1, a, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -27300,9 +26935,9 @@ for ( var i = 0, l = positions.length / 3; i < l; i ++ ) { - position.fromArray( positions, i * 3 ); + _position$1.fromArray( positions, i * 3 ); - testPoint( position, i ); + testPoint( _position$1, i, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -27314,7 +26949,7 @@ for ( var i = 0, l = vertices.length; i < l; i ++ ) { - testPoint( vertices[ i ], i ); + testPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -27376,6 +27011,36 @@ } ); + function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) { + + var rayPointDistanceSq = _ray$2.distanceSqToPoint( point ); + + if ( rayPointDistanceSq < localThresholdSq ) { + + var intersectPoint = new Vector3(); + + _ray$2.closestPointToPoint( point, intersectPoint ); + intersectPoint.applyMatrix4( matrixWorld ); + + var distance = raycaster.ray.origin.distanceTo( intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + distanceToRay: Math.sqrt( rayPointDistanceSq ), + point: intersectPoint, + index: index, + face: null, + object: object + + } ); + + } + + } + /** * @author mrdoob / http://mrdoob.com/ */ @@ -38432,6 +38097,9 @@ if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + if ( json.clearCoatNormalMap !== undefined ) material.clearCoatNormalMap = getTexture( json.clearCoatNormalMap ); + if ( json.clearCoatNormalScale !== undefined ) material.clearCoatNormalScale = new Vector2().fromArray( json.clearCoatNormalScale ); + return material; }, @@ -40313,6 +39981,19 @@ * @author alteredq / http://alteredqualia.com/ */ + var _BlendingMode = { + NoBlending: NoBlending, + NormalBlending: NormalBlending, + AdditiveBlending: AdditiveBlending, + SubtractiveBlending: SubtractiveBlending, + MultiplyBlending: MultiplyBlending, + CustomBlending: CustomBlending + }; + + var _color = new Color(); + var _textureLoader = new TextureLoader(); + var _materialLoader = new MaterialLoader(); + function Loader() {} Loader.Handlers = { @@ -40372,261 +40053,244 @@ }, - createMaterial: ( function () { - - var BlendingMode = { - NoBlending: NoBlending, - NormalBlending: NormalBlending, - AdditiveBlending: AdditiveBlending, - SubtractiveBlending: SubtractiveBlending, - MultiplyBlending: MultiplyBlending, - CustomBlending: CustomBlending - }; - - var color = new Color(); - var textureLoader = new TextureLoader(); - var materialLoader = new MaterialLoader(); - - return function createMaterial( m, texturePath, crossOrigin ) { + createMaterial: function ( m, texturePath, crossOrigin ) { - // convert from old material format + // convert from old material format - var textures = {}; - - function loadTexture( path, repeat, offset, wrap, anisotropy ) { + var textures = {}; - var fullPath = texturePath + path; - var loader = Loader.Handlers.get( fullPath ); + // - var texture; + var json = { + uuid: _Math.generateUUID(), + type: 'MeshLambertMaterial' + }; - if ( loader !== null ) { + for ( var name in m ) { - texture = loader.load( fullPath ); + var value = m[ name ]; - } else { + switch ( name ) { - textureLoader.setCrossOrigin( crossOrigin ); - texture = textureLoader.load( fullPath ); + case 'DbgColor': + case 'DbgIndex': + case 'opticalDensity': + case 'illumination': + break; + case 'DbgName': + json.name = value; + break; + case 'blending': + json.blending = _BlendingMode[ value ]; + break; + case 'colorAmbient': + case 'mapAmbient': + console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); + break; + case 'colorDiffuse': + json.color = _color.fromArray( value ).getHex(); + break; + case 'colorSpecular': + json.specular = _color.fromArray( value ).getHex(); + break; + case 'colorEmissive': + json.emissive = _color.fromArray( value ).getHex(); + break; + case 'specularCoef': + json.shininess = value; + break; + case 'shading': + if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial'; + if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; + if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial'; + break; + case 'mapDiffuse': + json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapDiffuseRepeat': + case 'mapDiffuseOffset': + case 'mapDiffuseWrap': + case 'mapDiffuseAnisotropy': + break; + case 'mapEmissive': + json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapEmissiveRepeat': + case 'mapEmissiveOffset': + case 'mapEmissiveWrap': + case 'mapEmissiveAnisotropy': + break; + case 'mapLight': + json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapLightRepeat': + case 'mapLightOffset': + case 'mapLightWrap': + case 'mapLightAnisotropy': + break; + case 'mapAO': + json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapAORepeat': + case 'mapAOOffset': + case 'mapAOWrap': + case 'mapAOAnisotropy': + break; + case 'mapBump': + json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapBumpScale': + json.bumpScale = value; + break; + case 'mapBumpRepeat': + case 'mapBumpOffset': + case 'mapBumpWrap': + case 'mapBumpAnisotropy': + break; + case 'mapNormal': + json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapNormalFactor': + json.normalScale = value; + break; + case 'mapNormalRepeat': + case 'mapNormalOffset': + case 'mapNormalWrap': + case 'mapNormalAnisotropy': + break; + case 'mapSpecular': + json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapSpecularRepeat': + case 'mapSpecularOffset': + case 'mapSpecularWrap': + case 'mapSpecularAnisotropy': + break; + case 'mapMetalness': + json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapMetalnessRepeat': + case 'mapMetalnessOffset': + case 'mapMetalnessWrap': + case 'mapMetalnessAnisotropy': + break; + case 'mapRoughness': + json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapRoughnessRepeat': + case 'mapRoughnessOffset': + case 'mapRoughnessWrap': + case 'mapRoughnessAnisotropy': + break; + case 'mapAlpha': + json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapAlphaRepeat': + case 'mapAlphaOffset': + case 'mapAlphaWrap': + case 'mapAlphaAnisotropy': + break; + case 'flipSided': + json.side = BackSide; + break; + case 'doubleSided': + json.side = DoubleSide; + break; + case 'transparency': + console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); + json.opacity = value; + break; + case 'depthTest': + case 'depthWrite': + case 'colorWrite': + case 'opacity': + case 'reflectivity': + case 'transparent': + case 'visible': + case 'wireframe': + json[ name ] = value; + break; + case 'vertexColors': + if ( value === true ) json.vertexColors = VertexColors; + if ( value === 'face' ) json.vertexColors = FaceColors; + break; + default: + console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); + break; - } + } - if ( repeat !== undefined ) { + } - texture.repeat.fromArray( repeat ); + if ( json.type === 'MeshBasicMaterial' ) delete json.emissive; + if ( json.type !== 'MeshPhongMaterial' ) delete json.specular; - if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping; - if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping; + if ( json.opacity < 1 ) json.transparent = true; - } + _materialLoader.setTextures( textures ); - if ( offset !== undefined ) { + return _materialLoader.parse( json ); - texture.offset.fromArray( offset ); + } - } + } ); - if ( wrap !== undefined ) { + function loadTexture( path, repeat, offset, wrap, anisotropy, textures, texturePath, crossOrigin ) { - if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping; - if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping; + var fullPath = texturePath + path; + var loader = Loader.Handlers.get( fullPath ); - if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping; - if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping; + var texture; - } + if ( loader !== null ) { - if ( anisotropy !== undefined ) { + texture = loader.load( fullPath ); - texture.anisotropy = anisotropy; + } else { - } + _textureLoader.setCrossOrigin( crossOrigin ); + texture = _textureLoader.load( fullPath ); - var uuid = _Math.generateUUID(); + } - textures[ uuid ] = texture; + if ( repeat !== undefined ) { - return uuid; + texture.repeat.fromArray( repeat ); - } + if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping; + if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping; - // + } - var json = { - uuid: _Math.generateUUID(), - type: 'MeshLambertMaterial' - }; + if ( offset !== undefined ) { - for ( var name in m ) { + texture.offset.fromArray( offset ); - var value = m[ name ]; + } - switch ( name ) { + if ( wrap !== undefined ) { - case 'DbgColor': - case 'DbgIndex': - case 'opticalDensity': - case 'illumination': - break; - case 'DbgName': - json.name = value; - break; - case 'blending': - json.blending = BlendingMode[ value ]; - break; - case 'colorAmbient': - case 'mapAmbient': - console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); - break; - case 'colorDiffuse': - json.color = color.fromArray( value ).getHex(); - break; - case 'colorSpecular': - json.specular = color.fromArray( value ).getHex(); - break; - case 'colorEmissive': - json.emissive = color.fromArray( value ).getHex(); - break; - case 'specularCoef': - json.shininess = value; - break; - case 'shading': - if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial'; - if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; - if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial'; - break; - case 'mapDiffuse': - json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy ); - break; - case 'mapDiffuseRepeat': - case 'mapDiffuseOffset': - case 'mapDiffuseWrap': - case 'mapDiffuseAnisotropy': - break; - case 'mapEmissive': - json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy ); - break; - case 'mapEmissiveRepeat': - case 'mapEmissiveOffset': - case 'mapEmissiveWrap': - case 'mapEmissiveAnisotropy': - break; - case 'mapLight': - json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy ); - break; - case 'mapLightRepeat': - case 'mapLightOffset': - case 'mapLightWrap': - case 'mapLightAnisotropy': - break; - case 'mapAO': - json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy ); - break; - case 'mapAORepeat': - case 'mapAOOffset': - case 'mapAOWrap': - case 'mapAOAnisotropy': - break; - case 'mapBump': - json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy ); - break; - case 'mapBumpScale': - json.bumpScale = value; - break; - case 'mapBumpRepeat': - case 'mapBumpOffset': - case 'mapBumpWrap': - case 'mapBumpAnisotropy': - break; - case 'mapNormal': - json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy ); - break; - case 'mapNormalFactor': - json.normalScale = value; - break; - case 'mapNormalRepeat': - case 'mapNormalOffset': - case 'mapNormalWrap': - case 'mapNormalAnisotropy': - break; - case 'mapSpecular': - json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy ); - break; - case 'mapSpecularRepeat': - case 'mapSpecularOffset': - case 'mapSpecularWrap': - case 'mapSpecularAnisotropy': - break; - case 'mapMetalness': - json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy ); - break; - case 'mapMetalnessRepeat': - case 'mapMetalnessOffset': - case 'mapMetalnessWrap': - case 'mapMetalnessAnisotropy': - break; - case 'mapRoughness': - json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy ); - break; - case 'mapRoughnessRepeat': - case 'mapRoughnessOffset': - case 'mapRoughnessWrap': - case 'mapRoughnessAnisotropy': - break; - case 'mapAlpha': - json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy ); - break; - case 'mapAlphaRepeat': - case 'mapAlphaOffset': - case 'mapAlphaWrap': - case 'mapAlphaAnisotropy': - break; - case 'flipSided': - json.side = BackSide; - break; - case 'doubleSided': - json.side = DoubleSide; - break; - case 'transparency': - console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); - json.opacity = value; - break; - case 'depthTest': - case 'depthWrite': - case 'colorWrite': - case 'opacity': - case 'reflectivity': - case 'transparent': - case 'visible': - case 'wireframe': - json[ name ] = value; - break; - case 'vertexColors': - if ( value === true ) json.vertexColors = VertexColors; - if ( value === 'face' ) json.vertexColors = FaceColors; - break; - default: - console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); - break; + if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping; + if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping; - } + if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping; + if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping; - } + } - if ( json.type === 'MeshBasicMaterial' ) delete json.emissive; - if ( json.type !== 'MeshPhongMaterial' ) delete json.specular; + if ( anisotropy !== undefined ) { - if ( json.opacity < 1 ) json.transparent = true; + texture.anisotropy = anisotropy; - materialLoader.setTextures( textures ); + } - return materialLoader.parse( json ); + var uuid = _Math.generateUUID(); - }; + textures[ uuid ] = texture; - } )() + return uuid; - } ); + } /** * @author mrdoob / http://mrdoob.com/ @@ -41069,7 +40733,8 @@ } ); - var _eyeRight, _eyeLeft; + var _eyeRight = new Matrix4(); + var _eyeLeft = new Matrix4(); /** * @author mrdoob / http://mrdoob.com/ @@ -41107,13 +40772,6 @@ update: function ( camera ) { - if ( _eyeRight === undefined ) { - - _eyeRight = new Matrix4(); - _eyeLeft = new Matrix4(); - - } - var cache = this._cache; var needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || @@ -41248,8 +40906,10 @@ * @author mrdoob / http://mrdoob.com/ */ - var _position, _quaternion$2, _scale; - var _orientation; + var _position$2 = new Vector3(); + var _quaternion$3 = new Quaternion(); + var _scale$1 = new Vector3(); + var _orientation = new Vector3(); function AudioListener() { @@ -41342,23 +41002,14 @@ Object3D.prototype.updateMatrixWorld.call( this, force ); - if ( _position === undefined ) { - - _position = new Vector3(); - _quaternion$2 = new Quaternion(); - _scale = new Vector3(); - _orientation = new Vector3(); - - } - var listener = this.context.listener; var up = this.up; this.timeDelta = this._clock.getDelta(); - this.matrixWorld.decompose( _position, _quaternion$2, _scale ); + this.matrixWorld.decompose( _position$2, _quaternion$3, _scale$1 ); - _orientation.set( 0, 0, - 1 ).applyQuaternion( _quaternion$2 ); + _orientation.set( 0, 0, - 1 ).applyQuaternion( _quaternion$3 ); if ( listener.positionX ) { @@ -41366,9 +41017,9 @@ var endTime = this.context.currentTime + this.timeDelta; - listener.positionX.linearRampToValueAtTime( _position.x, endTime ); - listener.positionY.linearRampToValueAtTime( _position.y, endTime ); - listener.positionZ.linearRampToValueAtTime( _position.z, endTime ); + listener.positionX.linearRampToValueAtTime( _position$2.x, endTime ); + listener.positionY.linearRampToValueAtTime( _position$2.y, endTime ); + listener.positionZ.linearRampToValueAtTime( _position$2.z, endTime ); listener.forwardX.linearRampToValueAtTime( _orientation.x, endTime ); listener.forwardY.linearRampToValueAtTime( _orientation.y, endTime ); listener.forwardZ.linearRampToValueAtTime( _orientation.z, endTime ); @@ -41378,7 +41029,7 @@ } else { - listener.setPosition( _position.x, _position.y, _position.z ); + listener.setPosition( _position$2.x, _position$2.y, _position$2.z ); listener.setOrientation( _orientation.x, _orientation.y, _orientation.z, up.x, up.y, up.z ); } @@ -41411,6 +41062,7 @@ this.loop = false; this.startTime = 0; this.offset = 0; + this.duration = undefined; this.playbackRate = 1; this.isPlaying = false; this.hasPlaybackControl = true; @@ -41485,7 +41137,7 @@ source.loop = this.loop; source.onended = this.onEnded.bind( this ); this.startTime = this.context.currentTime; - source.start( this.startTime, this.offset ); + source.start( this.startTime, this.offset, this.duration ); this.isPlaying = true; @@ -41733,8 +41385,10 @@ * @author mrdoob / http://mrdoob.com/ */ - var _position$1, _quaternion$3, _scale$1; - var _orientation$1; + var _position$3 = new Vector3(); + var _quaternion$4 = new Quaternion(); + var _scale$2 = new Vector3(); + var _orientation$1 = new Vector3(); function PositionalAudio( listener ) { @@ -41826,20 +41480,11 @@ Object3D.prototype.updateMatrixWorld.call( this, force ); - if ( _position$1 === undefined ) { - - _position$1 = new Vector3(); - _quaternion$3 = new Quaternion(); - _scale$1 = new Vector3(); - _orientation$1 = new Vector3(); - - } - if ( this.hasPlaybackControl === true && this.isPlaying === false ) return; - this.matrixWorld.decompose( _position$1, _quaternion$3, _scale$1 ); + this.matrixWorld.decompose( _position$3, _quaternion$4, _scale$2 ); - _orientation$1.set( 0, 0, 1 ).applyQuaternion( _quaternion$3 ); + _orientation$1.set( 0, 0, 1 ).applyQuaternion( _quaternion$4 ); var panner = this.panner; @@ -41849,16 +41494,16 @@ var endTime = this.context.currentTime + this.listener.timeDelta; - panner.positionX.linearRampToValueAtTime( _position$1.x, endTime ); - panner.positionY.linearRampToValueAtTime( _position$1.y, endTime ); - panner.positionZ.linearRampToValueAtTime( _position$1.z, endTime ); + panner.positionX.linearRampToValueAtTime( _position$3.x, endTime ); + panner.positionY.linearRampToValueAtTime( _position$3.y, endTime ); + panner.positionZ.linearRampToValueAtTime( _position$3.z, endTime ); panner.orientationX.linearRampToValueAtTime( _orientation$1.x, endTime ); panner.orientationY.linearRampToValueAtTime( _orientation$1.y, endTime ); panner.orientationZ.linearRampToValueAtTime( _orientation$1.z, endTime ); } else { - panner.setPosition( _position$1.x, _position$1.y, _position$1.z ); + panner.setPosition( _position$3.x, _position$3.y, _position$3.z ); panner.setOrientation( _orientation$1.x, _orientation$1.y, _orientation$1.z ); } @@ -42124,7 +41769,40 @@ */ // Characters [].:/ are reserved for track binding syntax. - var RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; + var _RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; + var _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' ); + + // Attempts to allow node names from any language. ES5's `\w` regexp matches + // only latin characters, and the unicode \p{L} is not yet supported. So + // instead, we exclude reserved characters and match everything else. + var _wordChar = '[^' + _RESERVED_CHARS_RE + ']'; + var _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; + + // Parent directories, delimited by '/' or ':'. Currently unused, but must + // be matched to parse the rest of the track name. + var _directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', _wordChar ); + + // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. + var _nodeRe = /(WCOD+)?/.source.replace( 'WCOD', _wordCharOrDot ); + + // Object on target node, and accessor. May not contain reserved + // characters. Accessor may contain any character except closing bracket. + var _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', _wordChar ); + + // Property and accessor. May not contain reserved characters. Accessor may + // contain any non-bracket characters. + var _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', _wordChar ); + + var _trackRe = new RegExp( '' + + '^' + + _directoryRe + + _nodeRe + + _objectRe + + _propertyRe + + '$' + ); + + var _supportedObjectNames = [ 'material', 'materials', 'bones' ]; function Composite( targetGroup, path, optionalParsedPath ) { @@ -42224,101 +41902,59 @@ * @param {string} name Node name to be sanitized. * @return {string} */ - sanitizeNodeName: ( function () { - - var reservedRe = new RegExp( '[' + RESERVED_CHARS_RE + ']', 'g' ); - - return function sanitizeNodeName( name ) { - - return name.replace( /\s/g, '_' ).replace( reservedRe, '' ); - - }; - - }() ), - - parseTrackName: function () { - - // Attempts to allow node names from any language. ES5's `\w` regexp matches - // only latin characters, and the unicode \p{L} is not yet supported. So - // instead, we exclude reserved characters and match everything else. - var wordChar = '[^' + RESERVED_CHARS_RE + ']'; - var wordCharOrDot = '[^' + RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; - - // Parent directories, delimited by '/' or ':'. Currently unused, but must - // be matched to parse the rest of the track name. - var directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', wordChar ); - - // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. - var nodeRe = /(WCOD+)?/.source.replace( 'WCOD', wordCharOrDot ); - - // Object on target node, and accessor. May not contain reserved - // characters. Accessor may contain any character except closing bracket. - var objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', wordChar ); - - // Property and accessor. May not contain reserved characters. Accessor may - // contain any non-bracket characters. - var propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', wordChar ); - - var trackRe = new RegExp( '' - + '^' - + directoryRe - + nodeRe - + objectRe - + propertyRe - + '$' - ); + sanitizeNodeName: function ( name ) { - var supportedObjectNames = [ 'material', 'materials', 'bones' ]; + return name.replace( /\s/g, '_' ).replace( _reservedRe, '' ); - return function parseTrackName( trackName ) { + }, - var matches = trackRe.exec( trackName ); + parseTrackName: function ( trackName ) { - if ( ! matches ) { + var matches = _trackRe.exec( trackName ); - throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); + if ( ! matches ) { - } + throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); - var results = { - // directoryName: matches[ 1 ], // (tschw) currently unused - nodeName: matches[ 2 ], - objectName: matches[ 3 ], - objectIndex: matches[ 4 ], - propertyName: matches[ 5 ], // required - propertyIndex: matches[ 6 ] - }; + } - var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); + var results = { + // directoryName: matches[ 1 ], // (tschw) currently unused + nodeName: matches[ 2 ], + objectName: matches[ 3 ], + objectIndex: matches[ 4 ], + propertyName: matches[ 5 ], // required + propertyIndex: matches[ 6 ] + }; - if ( lastDot !== undefined && lastDot !== - 1 ) { + var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); - var objectName = results.nodeName.substring( lastDot + 1 ); + if ( lastDot !== undefined && lastDot !== - 1 ) { - // Object names must be checked against a whitelist. Otherwise, there - // is no way to parse 'foo.bar.baz': 'baz' must be a property, but - // 'bar' could be the objectName, or part of a nodeName (which can - // include '.' characters). - if ( supportedObjectNames.indexOf( objectName ) !== - 1 ) { + var objectName = results.nodeName.substring( lastDot + 1 ); - results.nodeName = results.nodeName.substring( 0, lastDot ); - results.objectName = objectName; + // Object names must be checked against a whitelist. Otherwise, there + // is no way to parse 'foo.bar.baz': 'baz' must be a property, but + // 'bar' could be the objectName, or part of a nodeName (which can + // include '.' characters). + if ( _supportedObjectNames.indexOf( objectName ) !== - 1 ) { - } + results.nodeName = results.nodeName.substring( 0, lastDot ); + results.objectName = objectName; } - if ( results.propertyName === null || results.propertyName.length === 0 ) { + } - throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); + if ( results.propertyName === null || results.propertyName.length === 0 ) { - } + throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); - return results; + } - }; + return results; - }(), + }, findNode: function ( root, nodeName ) { @@ -44711,6 +44347,7 @@ this.near = near || 0; this.far = far || Infinity; + this.camera = null; this.params = { Mesh: {}, @@ -44777,13 +44414,13 @@ this.ray.origin.setFromMatrixPosition( camera.matrixWorld ); this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize(); - this._camera = camera; + this.camera = camera; } else if ( ( camera && camera.isOrthographicCamera ) ) { this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ); - this._camera = camera; + this.camera = camera; } else { @@ -44983,7 +44620,7 @@ * @author bhouston / http://clara.io */ - var _vector$5; + var _vector$6 = new Vector2(); function Box2( min, max ) { @@ -45019,9 +44656,7 @@ setFromCenterAndSize: function ( center, size ) { - if ( _vector$5 === undefined ) _vector$5 = new Vector2(); - - var halfSize = _vector$5.copy( size ).multiplyScalar( 0.5 ); + var halfSize = _vector$6.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -45171,9 +44806,7 @@ distanceToPoint: function ( point ) { - if ( _vector$5 === undefined ) _vector$5 = new Vector2(); - - var clampedPoint = _vector$5.copy( point ).clamp( this.min, this.max ); + var clampedPoint = _vector$6.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); }, @@ -45217,7 +44850,8 @@ * @author bhouston / http://clara.io */ - var _startP, _startEnd; + var _startP = new Vector3(); + var _startEnd = new Vector3(); function Line3( start, end ) { @@ -45305,13 +44939,6 @@ closestPointToPointParameter: function ( point, clampToLine ) { - if ( _startP === undefined ) { - - _startP = new Vector3(); - _startEnd = new Vector3(); - - } - _startP.subVectors( point, this.start ); _startEnd.subVectors( this.end, this.start ); @@ -45385,7 +45012,10 @@ * @author WestLangley / http://github.com/WestLangley */ - var _v1$4, _v2$3, _normalMatrix$1, _keys; + var _v1$5 = new Vector3(); + var _v2$3 = new Vector3(); + var _normalMatrix$1 = new Matrix3(); + var _keys = [ 'a', 'b', 'c' ]; function VertexNormalsHelper( object, size, hex, linewidth ) { @@ -45436,15 +45066,6 @@ VertexNormalsHelper.prototype.update = function () { - if ( _normalMatrix$1 === undefined ) { - - _v1$4 = new Vector3(); - _v2$3 = new Vector3(); - _normalMatrix$1 = new Matrix3(); - _keys = [ 'a', 'b', 'c' ]; - - } - this.object.updateMatrixWorld( true ); _normalMatrix$1.getNormalMatrix( this.object.matrixWorld ); @@ -45475,11 +45096,11 @@ var normal = face.vertexNormals[ j ]; - _v1$4.copy( vertex ).applyMatrix4( matrixWorld ); + _v1$5.copy( vertex ).applyMatrix4( matrixWorld ); - _v2$3.copy( normal ).applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$4 ); + _v2$3.copy( normal ).applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$5 ); - position.setXYZ( idx, _v1$4.x, _v1$4.y, _v1$4.z ); + position.setXYZ( idx, _v1$5.x, _v1$5.y, _v1$5.z ); idx = idx + 1; @@ -45503,13 +45124,13 @@ for ( var j = 0, jl = objPos.count; j < jl; j ++ ) { - _v1$4.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld ); + _v1$5.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld ); _v2$3.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) ); - _v2$3.applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$4 ); + _v2$3.applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$5 ); - position.setXYZ( idx, _v1$4.x, _v1$4.y, _v1$4.z ); + position.setXYZ( idx, _v1$5.x, _v1$5.y, _v1$5.z ); idx = idx + 1; @@ -45531,7 +45152,7 @@ * @author WestLangley / http://github.com/WestLangley */ - var _vector$6; + var _vector$7 = new Vector3(); function SpotLightHelper( light, color ) { @@ -45590,8 +45211,6 @@ SpotLightHelper.prototype.update = function () { - if ( _vector$6 === undefined ) _vector$6 = new Vector3(); - this.light.updateMatrixWorld(); var coneLength = this.light.distance ? this.light.distance : 1000; @@ -45599,9 +45218,9 @@ this.cone.scale.set( coneWidth, coneWidth, coneLength ); - _vector$6.setFromMatrixPosition( this.light.target.matrixWorld ); + _vector$7.setFromMatrixPosition( this.light.target.matrixWorld ); - this.cone.lookAt( _vector$6 ); + this.cone.lookAt( _vector$7 ); if ( this.color !== undefined ) { @@ -45623,7 +45242,9 @@ * @author Mugen87 / https://github.com/Mugen87 */ - var _vector$7, _boneMatrix, _matrixWorldInv; + var _vector$8 = new Vector3(); + var _boneMatrix = new Matrix4(); + var _matrixWorldInv = new Matrix4(); function getBoneList( object ) { @@ -45692,14 +45313,6 @@ SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { - if ( _matrixWorldInv === undefined ) { - - _vector$7 = new Vector3(); - _boneMatrix = new Matrix4(); - _matrixWorldInv = new Matrix4(); - - } - var bones = this.bones; var geometry = this.geometry; @@ -45714,12 +45327,12 @@ if ( bone.parent && bone.parent.isBone ) { _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld ); - _vector$7.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j, _vector$7.x, _vector$7.y, _vector$7.z ); + _vector$8.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j, _vector$8.x, _vector$8.y, _vector$8.z ); _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld ); - _vector$7.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j + 1, _vector$7.x, _vector$7.y, _vector$7.z ); + _vector$8.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j + 1, _vector$8.x, _vector$8.y, _vector$8.z ); j += 2; @@ -45901,7 +45514,9 @@ * @author Mugen87 / https://github.com/Mugen87 */ - var _vector$8, _color1, _color2; + var _vector$9 = new Vector3(); + var _color1 = new Color(); + var _color2 = new Color(); function HemisphereLightHelper( light, size, color ) { @@ -45944,14 +45559,6 @@ HemisphereLightHelper.prototype.update = function () { - if ( _color2 === undefined ) { - - _vector$8 = new Vector3(); - _color1 = new Color(); - _color2 = new Color(); - - } - var mesh = this.children[ 0 ]; if ( this.color !== undefined ) { @@ -45977,7 +45584,7 @@ } - mesh.lookAt( _vector$8.setFromMatrixPosition( this.light.matrixWorld ).negate() ); + mesh.lookAt( _vector$9.setFromMatrixPosition( this.light.matrixWorld ).negate() ); }; @@ -46383,7 +45990,9 @@ * @author WestLangley / http://github.com/WestLangley */ - var _v1$5, _v2$4, _normalMatrix$2; + var _v1$6 = new Vector3(); + var _v2$4 = new Vector3(); + var _normalMatrix$2 = new Matrix3(); function FaceNormalsHelper( object, size, hex, linewidth ) { @@ -46435,14 +46044,6 @@ FaceNormalsHelper.prototype.update = function () { - if ( _normalMatrix$2 === undefined ) { - - _v1$5 = new Vector3(); - _v2$4 = new Vector3(); - _normalMatrix$2 = new Matrix3(); - - } - this.object.updateMatrixWorld( true ); _normalMatrix$2.getNormalMatrix( this.object.matrixWorld ); @@ -46467,15 +46068,15 @@ var normal = face.normal; - _v1$5.copy( vertices[ face.a ] ) + _v1$6.copy( vertices[ face.a ] ) .add( vertices[ face.b ] ) .add( vertices[ face.c ] ) .divideScalar( 3 ) .applyMatrix4( matrixWorld ); - _v2$4.copy( normal ).applyMatrix3( _normalMatrix$2 ).normalize().multiplyScalar( this.size ).add( _v1$5 ); + _v2$4.copy( normal ).applyMatrix3( _normalMatrix$2 ).normalize().multiplyScalar( this.size ).add( _v1$6 ); - position.setXYZ( idx, _v1$5.x, _v1$5.y, _v1$5.z ); + position.setXYZ( idx, _v1$6.x, _v1$6.y, _v1$6.z ); idx = idx + 1; @@ -46495,7 +46096,9 @@ * @author WestLangley / http://github.com/WestLangley */ - var _v1$6, _v2$5, _v3$1; + var _v1$7 = new Vector3(); + var _v2$5 = new Vector3(); + var _v3$1 = new Vector3(); function DirectionalLightHelper( light, size, color ) { @@ -46549,17 +46152,9 @@ DirectionalLightHelper.prototype.update = function () { - if ( _v3$1 === undefined ) { - - _v1$6 = new Vector3(); - _v2$5 = new Vector3(); - _v3$1 = new Vector3(); - - } - - _v1$6.setFromMatrixPosition( this.light.matrixWorld ); + _v1$7.setFromMatrixPosition( this.light.matrixWorld ); _v2$5.setFromMatrixPosition( this.light.target.matrixWorld ); - _v3$1.subVectors( _v2$5, _v1$6 ); + _v3$1.subVectors( _v2$5, _v1$7 ); this.lightPlane.lookAt( _v2$5 ); @@ -46590,7 +46185,8 @@ * http://evanw.github.com/lightgl.js/tests/shadowmap.html */ - var _vector$9, _camera; + var _vector$a = new Vector3(); + var _camera = new Camera(); function CameraHelper( camera ) { @@ -46701,8 +46297,6 @@ CameraHelper.prototype.update = function () { - if ( _camera === undefined ) _camera = new Camera(); - var geometry = this.geometry; var pointMap = this.pointMap; @@ -46756,9 +46350,7 @@ function setPoint( point, pointMap, geometry, camera, x, y, z ) { - if ( _vector$9 === undefined ) _vector$9 = new Vector3(); - - _vector$9.set( x, y, z ).unproject( camera ); + _vector$a.set( x, y, z ).unproject( camera ); var points = pointMap[ point ]; @@ -46768,7 +46360,7 @@ for ( var i = 0, l = points.length; i < l; i ++ ) { - position.setXYZ( points[ i ], _vector$9.x, _vector$9.y, _vector$9.z ); + position.setXYZ( points[ i ], _vector$a.x, _vector$a.y, _vector$a.z ); } @@ -46781,7 +46373,7 @@ * @author Mugen87 / http://github.com/Mugen87 */ - var _box$1; + var _box$2 = new Box3(); function BoxHelper( object, color ) { @@ -46809,8 +46401,6 @@ BoxHelper.prototype.update = function ( object ) { - if ( _box$1 === undefined ) _box$1 = new Box3(); - if ( object !== undefined ) { console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' ); @@ -46819,14 +46409,14 @@ if ( this.object !== undefined ) { - _box$1.setFromObject( this.object ); + _box$2.setFromObject( this.object ); } - if ( _box$1.isEmpty() ) return; + if ( _box$2.isEmpty() ) return; - var min = _box$1.min; - var max = _box$1.max; + var min = _box$2.min; + var max = _box$2.max; /* 5____4 @@ -47004,7 +46594,7 @@ * headWidth - Number */ - var _axis; + var _axis = new Vector3(); var _lineGeometry, _coneGeometry; function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { @@ -47050,8 +46640,6 @@ ArrowHelper.prototype.setDirection = function ( dir ) { - if ( _axis === undefined ) _axis = new Vector3(); - // dir is assumed to be normalized if ( dir.y > 0.99999 ) { @@ -47662,17 +47250,10 @@ }, getPosition: function () { - var v1; - - return function getPosition() { + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return new Vector3().setFromMatrixColumn( this, 3 ); - if ( v1 === undefined ) v1 = new Vector3(); - console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); - return v1.setFromMatrixColumn( this, 3 ); - - }; - - }(), + }, setRotationFromQuaternion: function ( q ) { console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); diff --git a/build/three.min.js b/build/three.min.js index eb8fa3db3d9138..243742696fb469 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -1,581 +1,581 @@ -(function(k,la){"object"===typeof exports&&"undefined"!==typeof module?la(exports):"function"===typeof define&&define.amd?define(["exports"],la):(k=k||self,la(k.THREE={}))})(this,function(k){function la(){}function z(a,b){this.x=a||0;this.y=b||0}function ta(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function n(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function va(){this.elements=[1,0,0,0,1,0,0,0,1];0h)return!1}return!0}function ib(a,b){this.center=void 0!==a?a:new n;this.radius=void 0!==b?b:0}function bc(a,b){this.origin=void 0!==a?a:new n;this.direction=void 0!==b?b:new n}function U(a,b,c){this.a=void 0!==a?a:new n;this.b=void 0!==b?b:new n;this.c=void 0!==c?c:new n}function K(a,b,c){return void 0=== -b&&void 0===c?this.set(a):this.setRGB(a,b,c)}function gg(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function hg(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function ig(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function Lc(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new n;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new K;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex= -void 0!==f?f:0}function R(){Object.defineProperty(this,"id",{value:Ci++});this.uuid=P.generateUUID();this.name="";this.type="Material";this.lights=this.fog=!0;this.blending=1;this.side=0;this.vertexTangents=this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilFunc=519;this.stencilRef=0;this.stencilMask= -255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite=!1;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha=!1;this.visible=!0;this.userData={};this.needsUpdate=!0}function Ka(a){R.call(this);this.type="MeshBasicMaterial";this.color=new K(16777215);this.lightMap=this.map= -null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=this.morphTargets=this.skinning=!1;this.setValues(a)}function O(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=a;this.itemSize=b;this.count= -void 0!==a?a.length/b:0;this.normalized=!0===c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function Jd(a,b,c){O.call(this,new Int8Array(a),b,c)}function Kd(a,b,c){O.call(this,new Uint8Array(a),b,c)}function Ld(a,b,c){O.call(this,new Uint8ClampedArray(a),b,c)}function Md(a,b,c){O.call(this,new Int16Array(a),b,c)}function cc(a,b,c){O.call(this,new Uint16Array(a),b,c)}function Nd(a,b,c){O.call(this,new Int32Array(a),b,c)}function dc(a,b,c){O.call(this,new Uint32Array(a),b,c)} -function A(a,b,c){O.call(this,new Float32Array(a),b,c)}function Od(a,b,c){O.call(this,new Float64Array(a),b,c)}function sh(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function th(a){if(0===a.length)return-Infinity;for(var b=a[0],c=1,d=a.length;c< -d;++c)a[c]>b&&(b=a[c]);return b}function D(){Object.defineProperty(this,"id",{value:Di+=2});this.uuid=P.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 S(a,b){C.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new D;this.material=void 0!==b?b:new Ka({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()} -function uh(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;Mc.copy(h);Mc.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Mc);return bc.far?null:{distance:b,point:Mc.clone(),object:a}}function Ye(a,b,c,d,e,f,g,h,l,m,p){Hb.fromBufferAttribute(e,l);Ib.fromBufferAttribute(e,m);Jb.fromBufferAttribute(e,p);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Ze.set(0,0,0);$e.set(0,0,0);af.set(0,0,0);for(var t=0, -u=f.length;tg;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function Lb(a,b,c){hb.call(this,a,b,c)}function ic(a,b,c,d,e,f,g,h,l,m,p,t){Y.call(this,null,f,g,h,l,m,d,e,p,t);this.image={data:a,width:b,height:c};this.magFilter=void 0!==l?l:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1}function kb(a,b){this.normal=void 0!==a?a:new n(1,0,0);this.constant=void 0!==b?b:0}function bf(a,b,c,d,e,f){this.planes=[void 0!==a?a:new kb, -void 0!==b?b:new kb,void 0!==c?c:new kb,void 0!==d?d:new kb,void 0!==e?e:new kb,void 0!==f?f:new kb]}function ng(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function Fi(a){function b(b,c){var d=b.array,e=b.dynamic?35048:35044,h=a.createBuffer();a.bindBuffer(c,h);a.bufferData(c,d,e);b.onUploadCallback(); +// threejs.org/license +(function(k,ra){"object"===typeof exports&&"undefined"!==typeof module?ra(exports):"function"===typeof define&&define.amd?define(["exports"],ra):(k=k||self,ra(k.THREE={}))})(this,function(k){function ra(){}function z(a,b){this.x=a||0;this.y=b||0}function qa(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function n(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function ja(){this.elements=[1,0,0,0,1,0,0,0,1];0h)return!1}return!0}function nb(a,b){this.center=void 0!==a?a:new n;this.radius=void 0!==b?b:0}function Tb(a,b){this.origin=void 0!==a?a:new n;this.direction=void 0!==b?b:new n}function sa(a,b,c){this.a=void 0!==a?a:new n;this.b=void 0!==b?b:new n;this.c=void 0!==c?c:new n}function J(a,b,c){return void 0===b&&void 0=== +c?this.set(a):this.setRGB(a,b,c)}function Pf(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function Qf(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function Rf(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function Ac(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new n;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new J;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex= +void 0!==f?f:0}function P(){Object.defineProperty(this,"id",{value:Qi++});this.uuid=O.generateUUID();this.name="";this.type="Material";this.lights=this.fog=!0;this.blending=1;this.side=0;this.vertexTangents=this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilFunc=519;this.stencilRef=0;this.stencilMask= +255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite=!1;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha=!1;this.visible=!0;this.userData={};this.needsUpdate=!0}function xa(a){P.call(this);this.type="MeshBasicMaterial";this.color=new J(16777215);this.lightMap=this.map= +null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.lights=this.morphTargets=this.skinning=!1;this.setValues(a)}function S(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=a;this.itemSize=b;this.count= +void 0!==a?a.length/b:0;this.normalized=!0===c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function yd(a,b,c){S.call(this,new Int8Array(a),b,c)}function zd(a,b,c){S.call(this,new Uint8Array(a),b,c)}function Ad(a,b,c){S.call(this,new Uint8ClampedArray(a),b,c)}function Bd(a,b,c){S.call(this,new Int16Array(a),b,c)}function Ub(a,b,c){S.call(this,new Uint16Array(a),b,c)}function Cd(a,b,c){S.call(this,new Int32Array(a),b,c)}function Vb(a,b,c){S.call(this,new Uint32Array(a),b,c)} +function A(a,b,c){S.call(this,new Float32Array(a),b,c)}function Dd(a,b,c){S.call(this,new Float64Array(a),b,c)}function ch(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function dh(a){if(0===a.length)return-Infinity;for(var b=a[0],c=1,d=a.length;c< +d;++c)a[c]>b&&(b=a[c]);return b}function C(){Object.defineProperty(this,"id",{value:Ri+=2});this.uuid=O.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 ta(a,b){D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new C;this.material=void 0!==b?b:new xa({color:16777215*Math.random()});this.drawMode=0;this.updateMorphTargets()} +function eh(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;Ge.copy(h);Ge.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Ge);return bc.far?null:{distance:b,point:Ge.clone(),object:a}}function He(a,b,c,d,e,f,g,h,l,m,t){Wb.fromBufferAttribute(e,l);Xb.fromBufferAttribute(e,m);Yb.fromBufferAttribute(e,t);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Sf.set(0,0,0);Tf.set(0,0,0);Uf.set(0,0,0);for(var r=0, +u=f.length;rg;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function Db(a,b,c){$a.call(this,a,b,c)}function $b(a,b,c,d,e,f,g,h,l,m,t,r){ba.call(this,null,f,g,h,l,m,d,e,t,r);this.image={data:a,width:b,height:c};this.magFilter=void 0!==l?l:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1}function cb(a,b){this.normal=void 0!==a?a:new n(1,0,0);this.constant=void 0!==b?b:0}function Ie(a,b,c,d,e,f){this.planes=[void 0!==a?a: +new cb,void 0!==b?b:new cb,void 0!==c?c:new cb,void 0!==d?d:new cb,void 0!==e?e:new cb,void 0!==f?f:new cb]}function Wf(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function Ti(a){function b(b,c){var d=b.array,e=b.dynamic?35048:35044,h=a.createBuffer();a.bindBuffer(c,h);a.bufferData(c,d,e);b.onUploadCallback(); c=5126;d instanceof Float32Array?c=5126:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=5123:d instanceof Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int32Array?c=5124:d instanceof Int8Array?c=5120:d instanceof Uint8Array&&(c=5121);return{buffer:h,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var c=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data); return c.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var d=c.get(b);d&&(a.deleteBuffer(d.buffer),c.delete(b))},update:function(d,e){d.isInterleavedBufferAttribute&&(d=d.data);var f=c.get(d);if(void 0===f)c.set(d,b(d,e));else if(f.versionm;m++){if(t=d[m])if(h=t[0],l=t[1]){p&&e.addAttribute("morphTarget"+m,p[h]);f&&e.addAttribute("morphNormal"+m,f[h]);c[m]=l;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function Qi(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 vb(a,b,c,d,e,f,g,h,l,m){a= -void 0!==a?a:[];Y.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,l,m);this.flipY=!1}function Qc(a,b,c,d){Y.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 Rc(a,b,c,d){Y.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 Sc(a,b,c){var d=a[0];if(0>=d||0/gm,function(a,c){a=L[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return pg(a)})}function Lh(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(r=d[m])if(h=r[0],l=r[1]){t&&e.addAttribute("morphTarget"+m,t[h]);f&&e.addAttribute("morphNormal"+m,f[h]);c[m]=l;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function dj(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 qb(a,b,c,d,e,f,g,h,l,m){a=void 0!==a?a:[];ba.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,l,m);this.flipY=!1}function Gc(a,b,c,d){ba.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 Hc(a,b, +c,d){ba.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 Ic(a,b,c){var d=a[0];if(0>=d||0/gm,function(a,c){a=N[c];if(void 0===a)throw Error("Can not resolve #include <"+c+">");return Yf(a)})}function yh(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);cc;c++)b.probe.push(new n);var d=new n,e=new Q,f=new Q;return{setup:function(c,h,l){for(var g=0,p=0,t=0,k=0;9>k;k++)b.probe[k].set(0, -0,0);var r=h=0,q=0,n=0,v=0,y=0,w=0,I=0;l=l.matrixWorldInverse;c.sort(Jj);k=0;for(var G=c.length;kEa;Ea++)b.probe[Ea].addScaledVector(B.sh.coefficients[Ea],Z);else if(B.isDirectionalLight){var E=a.get(B);E.color.copy(B.color).multiplyScalar(B.intensity);E.direction.setFromMatrixPosition(B.matrixWorld);d.setFromMatrixPosition(B.target.matrixWorld); -E.direction.sub(d);E.direction.transformDirection(l);if(E.shadow=B.castShadow)Z=B.shadow,E.shadowBias=Z.bias,E.shadowRadius=Z.radius,E.shadowMapSize=Z.mapSize,b.directionalShadowMap[h]=Ea,b.directionalShadowMatrix[h]=B.shadow.matrix,y++;b.directional[h]=E;h++}else if(B.isSpotLight){E=a.get(B);E.position.setFromMatrixPosition(B.matrixWorld);E.position.applyMatrix4(l);E.color.copy(La).multiplyScalar(Z);E.distance=z;E.direction.setFromMatrixPosition(B.matrixWorld);d.setFromMatrixPosition(B.target.matrixWorld); -E.direction.sub(d);E.direction.transformDirection(l);E.coneCos=Math.cos(B.angle);E.penumbraCos=Math.cos(B.angle*(1-B.penumbra));E.decay=B.decay;if(E.shadow=B.castShadow)Z=B.shadow,E.shadowBias=Z.bias,E.shadowRadius=Z.radius,E.shadowMapSize=Z.mapSize,b.spotShadowMap[q]=Ea,b.spotShadowMatrix[q]=B.shadow.matrix,I++;b.spot[q]=E;q++}else if(B.isRectAreaLight)E=a.get(B),E.color.copy(La).multiplyScalar(Z),E.position.setFromMatrixPosition(B.matrixWorld),E.position.applyMatrix4(l),f.identity(),e.copy(B.matrixWorld), -e.premultiply(l),f.extractRotation(e),E.halfWidth.set(.5*B.width,0,0),E.halfHeight.set(0,.5*B.height,0),E.halfWidth.applyMatrix4(f),E.halfHeight.applyMatrix4(f),b.rectArea[n]=E,n++;else if(B.isPointLight){E=a.get(B);E.position.setFromMatrixPosition(B.matrixWorld);E.position.applyMatrix4(l);E.color.copy(B.color).multiplyScalar(B.intensity);E.distance=B.distance;E.decay=B.decay;if(E.shadow=B.castShadow)Z=B.shadow,E.shadowBias=Z.bias,E.shadowRadius=Z.radius,E.shadowMapSize=Z.mapSize,E.shadowCameraNear= -Z.camera.near,E.shadowCameraFar=Z.camera.far,b.pointShadowMap[r]=Ea,b.pointShadowMatrix[r]=B.shadow.matrix,w++;b.point[r]=E;r++}else B.isHemisphereLight&&(E=a.get(B),E.direction.setFromMatrixPosition(B.matrixWorld),E.direction.transformDirection(l),E.direction.normalize(),E.skyColor.copy(B.color).multiplyScalar(Z),E.groundColor.copy(B.groundColor).multiplyScalar(Z),b.hemi[v]=E,v++)}b.ambient[0]=g;b.ambient[1]=p;b.ambient[2]=t;c=b.hash;if(c.directionalLength!==h||c.pointLength!==r||c.spotLength!== -q||c.rectAreaLength!==n||c.hemiLength!==v||c.numDirectionalShadows!==y||c.numPointShadows!==w||c.numSpotShadows!==I)b.directional.length=h,b.spot.length=q,b.rectArea.length=n,b.point.length=r,b.hemi.length=v,b.directionalShadowMap.length=y,b.pointShadowMap.length=w,b.spotShadowMap.length=I,b.directionalShadowMatrix.length=y,b.pointShadowMatrix.length=w,b.spotShadowMatrix.length=I,c.directionalLength=h,c.pointLength=r,c.spotLength=q,c.rectAreaLength=n,c.hemiLength=v,c.numDirectionalShadows=y,c.numPointShadows= -w,c.numSpotShadows=I,b.version=Lj++},state:b}}function Nh(){var a=new Kj,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},pushShadow:function(a){c.push(a)}}}function Mj(){function a(c){c=c.target;c.removeEventListener("dispose",a);delete b[c.id]}var b={};return{get:function(c,d){if(void 0===b[c.id]){var e=new Nh;b[c.id]={};b[c.id][d.id]=e;c.addEventListener("dispose",a)}else void 0=== -b[c.id][d.id]?(e=new Nh,b[c.id][d.id]=e):e=b[c.id][d.id];return e},dispose:function(){b={}}}}function Nb(a){R.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.setValues(a)}function Ob(a){R.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new n;this.nearDistance= -1;this.farDistance=1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.lights=this.fog=!1;this.setValues(a)}function Oh(a,b,c){function d(b,c,d,e,f,g){var h=b.geometry;var l=t;var m=b.customDepthMaterial;d&&(l=k,m=b.customDistanceMaterial);m?l=m:(m=!1,c.morphTargets&&(h&&h.isBufferGeometry?m=h.morphAttributes&&h.morphAttributes.position&&0d||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?P.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),void 0===E&&(E=h(b,e)),c=c?h(b,e):E,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 P.isPowerOfTwo(a.width)&&P.isPowerOfTwo(a.height)}function p(a,b){return a.generateMipmaps&& -b&&1003!==a.minFilter&&1006!==a.minFilter}function t(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function k(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 r(a){return 1003===a||1004===a||1005===a?9728:9729}function q(b){b=b.target;b.removeEventListener("dispose",q);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&delete Ea[b.id];g.memory.textures--}function n(b){b=b.target;b.removeEventListener("dispose",n);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 v(a,b){var e=d.get(a);if(a.isVideoTexture){var f=a.id,h=g.render.frame;Ea[f]!==h&&(Ea[f]=h,a.update())}if(0< -a.version&&e.__version!==a.version)if(f=a.image,void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(!1===f.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{B(e,a,b);return}c.activeTexture(33984+b);c.bindTexture(3553,e.__webglTexture)}function y(b,g){var h=d.get(b);if(6===b.image.length)if(0r;r++)q[r]=g||u?u?b.image[r].image:b.image[r]:l(b.image[r],!1,!0,e.maxCubemapSize);var n=q[0],x=m(n)||e.isWebGL2,v=f.convert(b.format),w=f.convert(b.type),V=k(v,w);I(34067,b,x);var y=b.mipmaps;for(r=0;6>r;r++)if(g){y=q[r].mipmaps;ja=0;for(var B=y.length;ja=e.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+e.maxTextures);D+=1;return a}; -this.resetTextureUnits=function(){D=0};this.setTexture2D=v;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=k(r,x);x=A(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(),Z(h.__webglDepthRenderbuffer,b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2."); -if(u){c.bindTexture(34067,l.__webglTexture);I(34067,b.texture,q);for(r=0;6>r;r++)z(h.__webglFramebuffer[r],b,36064,34069+r);p(b.texture,q)&&t(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,l.__webglTexture),I(3553,b.texture,q),z(h.__webglFramebuffer,b,36064,3553),p(b.texture,q)&&t(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){h=d.get(b);l=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(l)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); -v(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(l)for(h.__webglDepthbuffer=[],l=0;6>l;l++)a.bindFramebuffer(36160,h.__webglFramebuffer[l]),h.__webglDepthbuffer[l]=a.createRenderbuffer(),Z(h.__webglDepthbuffer[l],b);else a.bindFramebuffer(36160,h.__webglFramebuffer),h.__webglDepthbuffer= -a.createRenderbuffer(),Z(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);t(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===J&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),J=!0),a=a.texture);v(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLRenderTargetCube&& -(!1===K&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),K=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?y(a,b):w(a,b)}}function Qh(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 Tc(){C.call(this);this.type="Group"}function Sd(a){na.call(this);this.cameras=a||[]}function Rh(a,b,c){Sh.setFromMatrixPosition(b.matrixWorld);Th.setFromMatrixPosition(c.matrixWorld);var d=Sh.distanceTo(Th),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],l=(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,l*c/g*b,b,g)}function rg(a){function b(){return null!==h&&!0===h.isPresenting}function c(){if(b()){var c=h.getEyeParameters("left");e=2*c.renderWidth*r;f=c.renderHeight*r;La=a.getPixelRatio();a.getSize(B);a.setDrawingBufferSize(e,f,1);w.viewport.set(0,0,e/2,f);I.viewport.set(e/ -2,0,e/2,f);A.start();g.dispatchEvent({type:"sessionstart"})}else g.enabled&&a.setDrawingBufferSize(B.width,B.height,La),A.stop(),g.dispatchEvent({type:"sessionend"})}function d(a,b){null!==b&&4===b.length&&a.set(b[0]*e,b[1]*f,b[2]*e,b[3]*f)}var e,f,g=this,h=null,l=null,m=null,p=[],t=new Q,k=new Q,r=1,q="local-floor";"undefined"!==typeof window&&"VRFrameData"in window&&(l=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var x=new Q,v=new ta,y=new n,w=new na;w.viewport= -new ia;w.layers.enable(1);var I=new na;I.viewport=new ia;I.layers.enable(2);var G=new Sd([w,I]);G.layers.enable(1);G.layers.enable(2);var B=new z,La,Z=[];this.enabled=!1;this.getController=function(a){var b=p[a];void 0===b&&(b=new Tc,b.matrixAutoUpdate=!1,b.visible=!1,p[a]=b);return b};this.getDevice=function(){return h};this.setDevice=function(a){void 0!==a&&(h=a);A.setContext(a)};this.setFramebufferScaleFactor=function(a){r=a};this.setReferenceSpaceType=function(a){q=a};this.setPoseTarget=function(a){void 0!== -a&&(m=a)};this.getCamera=function(a){var c="local-floor"===q?1.6:0;if(!1===b())return a.position.set(0,c,0),a.rotation.set(0,0,0),a;h.depthNear=a.near;h.depthFar=a.far;h.getFrameData(l);if("local-floor"===q){var e=h.stageParameters;e?t.fromArray(e.sittingToStandingTransform):t.makeTranslation(0,c,0)}c=l.pose;e=null!==m?m:a;e.matrix.copy(t);e.matrix.decompose(e.position,e.quaternion,e.scale);null!==c.orientation&&(v.fromArray(c.orientation),e.quaternion.multiply(v));null!==c.position&&(v.setFromRotationMatrix(t), -y.fromArray(c.position),y.applyQuaternion(v),e.position.add(y));e.updateMatrixWorld();w.near=a.near;I.near=a.near;w.far=a.far;I.far=a.far;w.matrixWorldInverse.fromArray(l.leftViewMatrix);I.matrixWorldInverse.fromArray(l.rightViewMatrix);k.getInverse(t);"local-floor"===q&&(w.matrixWorldInverse.multiply(k),I.matrixWorldInverse.multiply(k));a=e.parent;null!==a&&(x.getInverse(a.matrixWorld),w.matrixWorldInverse.multiply(x),I.matrixWorldInverse.multiply(x));w.matrixWorld.getInverse(w.matrixWorldInverse); -I.matrixWorld.getInverse(I.matrixWorldInverse);w.projectionMatrix.fromArray(l.leftProjectionMatrix);I.projectionMatrix.fromArray(l.rightProjectionMatrix);Rh(G,w,I);a=h.getLayers();a.length&&(a=a[0],d(w.viewport,a.leftBounds),d(I.viewport,a.rightBounds));a:for(a=0;ac;c++)b.probe.push(new n);var d=new n,e=new R,f=new R;return{setup:function(c,h,l){for(var g=0,t=0,r=0,k=0;9>k;k++)b.probe[k].set(0,0,0);var q=h=0,p=0,n=0,v=0,y=0,w=0,H=0;l=l.matrixWorldInverse;c.sort(Xj);k=0;for(var F=c.length;kBa;Ba++)b.probe[Ba].addScaledVector(B.sh.coefficients[Ba],Z);else if(B.isDirectionalLight){var K=a.get(B);K.color.copy(B.color).multiplyScalar(B.intensity);K.direction.setFromMatrixPosition(B.matrixWorld);d.setFromMatrixPosition(B.target.matrixWorld);K.direction.sub(d);K.direction.transformDirection(l);if(K.shadow=B.castShadow)Z=B.shadow,K.shadowBias=Z.bias,K.shadowRadius=Z.radius,K.shadowMapSize=Z.mapSize,b.directionalShadowMap[h]=Ba,b.directionalShadowMatrix[h]=B.shadow.matrix,y++;b.directional[h]= +K;h++}else if(B.isSpotLight){K=a.get(B);K.position.setFromMatrixPosition(B.matrixWorld);K.position.applyMatrix4(l);K.color.copy(Fa).multiplyScalar(Z);K.distance=z;K.direction.setFromMatrixPosition(B.matrixWorld);d.setFromMatrixPosition(B.target.matrixWorld);K.direction.sub(d);K.direction.transformDirection(l);K.coneCos=Math.cos(B.angle);K.penumbraCos=Math.cos(B.angle*(1-B.penumbra));K.decay=B.decay;if(K.shadow=B.castShadow)Z=B.shadow,K.shadowBias=Z.bias,K.shadowRadius=Z.radius,K.shadowMapSize=Z.mapSize, +b.spotShadowMap[p]=Ba,b.spotShadowMatrix[p]=B.shadow.matrix,H++;b.spot[p]=K;p++}else if(B.isRectAreaLight)K=a.get(B),K.color.copy(Fa).multiplyScalar(Z),K.position.setFromMatrixPosition(B.matrixWorld),K.position.applyMatrix4(l),f.identity(),e.copy(B.matrixWorld),e.premultiply(l),f.extractRotation(e),K.halfWidth.set(.5*B.width,0,0),K.halfHeight.set(0,.5*B.height,0),K.halfWidth.applyMatrix4(f),K.halfHeight.applyMatrix4(f),b.rectArea[n]=K,n++;else if(B.isPointLight){K=a.get(B);K.position.setFromMatrixPosition(B.matrixWorld); +K.position.applyMatrix4(l);K.color.copy(B.color).multiplyScalar(B.intensity);K.distance=B.distance;K.decay=B.decay;if(K.shadow=B.castShadow)Z=B.shadow,K.shadowBias=Z.bias,K.shadowRadius=Z.radius,K.shadowMapSize=Z.mapSize,K.shadowCameraNear=Z.camera.near,K.shadowCameraFar=Z.camera.far,b.pointShadowMap[q]=Ba,b.pointShadowMatrix[q]=B.shadow.matrix,w++;b.point[q]=K;q++}else B.isHemisphereLight&&(K=a.get(B),K.direction.setFromMatrixPosition(B.matrixWorld),K.direction.transformDirection(l),K.direction.normalize(), +K.skyColor.copy(B.color).multiplyScalar(Z),K.groundColor.copy(B.groundColor).multiplyScalar(Z),b.hemi[v]=K,v++)}b.ambient[0]=g;b.ambient[1]=t;b.ambient[2]=r;c=b.hash;if(c.directionalLength!==h||c.pointLength!==q||c.spotLength!==p||c.rectAreaLength!==n||c.hemiLength!==v||c.numDirectionalShadows!==y||c.numPointShadows!==w||c.numSpotShadows!==H)b.directional.length=h,b.spot.length=p,b.rectArea.length=n,b.point.length=q,b.hemi.length=v,b.directionalShadowMap.length=y,b.pointShadowMap.length=w,b.spotShadowMap.length= +H,b.directionalShadowMatrix.length=y,b.pointShadowMatrix.length=w,b.spotShadowMatrix.length=H,c.directionalLength=h,c.pointLength=q,c.spotLength=p,c.rectAreaLength=n,c.hemiLength=v,c.numDirectionalShadows=y,c.numPointShadows=w,c.numSpotShadows=H,b.version=Zj++},state:b}}function Ah(){var a=new Yj,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},pushShadow:function(a){c.push(a)}}} +function ak(){function a(c){c=c.target;c.removeEventListener("dispose",a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){if(!1===b.has(c)){var e=new Ah;b.set(c,new WeakMap);b.get(c).set(d,e);c.addEventListener("dispose",a)}else!1===b.get(c).has(d)?(e=new Ah,b.get(c).set(d,e)):e=b.get(c).get(d);return e},dispose:function(){b=new WeakMap}}}function Fb(a){P.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map= +null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.setValues(a)}function Gb(a){P.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new n;this.nearDistance=1;this.farDistance=1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.lights=this.fog=!1;this.setValues(a)}function Bh(a,b,c){function d(b,c,d,e,f,g){var h=b.geometry; +var l=r;var m=b.customDepthMaterial;d&&(l=k,m=b.customDistanceMaterial);m?l=m:(m=!1,c.morphTargets&&(h&&h.isBufferGeometry?m=h.morphAttributes&&h.morphAttributes.position&&0 +d||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?O.floorPowerOfTwo:Math.floor,b=d(e*a.width),e=d(e*a.height),void 0===K&&(K=h(b,e)),c=c?h(b,e):K,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 O.isPowerOfTwo(a.width)&&O.isPowerOfTwo(a.height)}function t(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==a.minFilter}function r(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function k(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 q(a){return 1003===a||1004===a||1005===a?9728:9729}function p(b){b=b.target;b.removeEventListener("dispose", +p);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&Ba.delete(b);g.memory.textures--}function n(b){b=b.target;b.removeEventListener("dispose",n);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 v(a,b){var e=d.get(a);if(a.isVideoTexture){var f=g.render.frame;Ba.get(a)!==f&&(Ba.set(a,f),a.update())}if(0p;p++)q[p]=u||g?g?b.image[p].image:b.image[p]:l(b.image[p],!1,!0,e.maxCubemapSize);var n=q[0],x=m(n)||e.isWebGL2,v=f.convert(b.format), +w=f.convert(b.type),V=k(v,w);H(34067,b,x);if(u){for(p=0;6>p;p++){var B=q[p].mipmaps;for(u=0;up;p++)if(g)for(c.texImage2D(34069+ +p,0,V,q[p].width,q[p].height,0,v,w,q[p].data),u=0;u=e.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+e.maxTextures);C+=1;return a};this.resetTextureUnits=function(){C=0};this.setTexture2D=v;this.setTexture2DArray=function(a,b){var e=d.get(a);0p;p++)h.__webglFramebuffer[p]=a.createFramebuffer();else if(h.__webglFramebuffer=a.createFramebuffer(), +p)if(e.isWebGL2){h.__webglMultisampledFramebuffer=a.createFramebuffer();h.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,h.__webglColorRenderbuffer);p=f.convert(b.texture.format);var x=f.convert(b.texture.type);p=k(p,x);x=A(b);a.renderbufferStorageMultisample(36161,x,p,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(),Z(h.__webglDepthRenderbuffer,b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){c.bindTexture(34067,l.__webglTexture);H(34067,b.texture,q);for(p=0;6>p;p++)z(h.__webglFramebuffer[p],b,36064,34069+p);t(b.texture,q)&&r(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,l.__webglTexture),H(3553,b.texture,q),z(h.__webglFramebuffer,b,36064,3553),t(b.texture, +q)&&r(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){h=d.get(b);l=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(l)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);v(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(l)for(h.__webglDepthbuffer= +[],l=0;6>l;l++)a.bindFramebuffer(36160,h.__webglFramebuffer[l]),h.__webglDepthbuffer[l]=a.createRenderbuffer(),Z(h.__webglDepthbuffer[l],b);else a.bindFramebuffer(36160,h.__webglFramebuffer),h.__webglDepthbuffer=a.createRenderbuffer(),Z(h.__webglDepthbuffer,b);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(a){var b=a.texture,f=m(a)||e.isWebGL2;if(t(b,f)){f=a.isWebGLRenderTargetCube?34067:3553;var g=d.get(b).__webglTexture;c.bindTexture(f,g);r(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===I&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),I=!0),a=a.texture);v(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLRenderTargetCube&&(!1===J&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),J=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?y(a,b):w(a,b)}}function Dh(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 Jc(){D.call(this);this.type="Group"}function Jd(a){W.call(this);this.cameras=a||[]}function Eh(a,b,c){Fh.setFromMatrixPosition(b.matrixWorld);Gh.setFromMatrixPosition(c.matrixWorld);var d=Fh.distanceTo(Gh),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],l=(e[9]-1)/e[5],m=(e[8]-1)/e[0],t=(f[8]+1)/f[0];e=g*m;f=g*t;t=d/(-m+t);m=t*-m;b.matrixWorld.decompose(a.position,a.quaternion,a.scale);a.translateX(m);a.translateZ(t);a.matrixWorld.compose(a.position,a.quaternion,a.scale);a.matrixWorldInverse.getInverse(a.matrixWorld);b=g+t;g=c+t;a.projectionMatrix.makePerspective(e-m,f+(d-m),h*c/g*b,l*c/g*b,b,g)}function $f(a){function b(){return null!==h&&!0===h.isPresenting}function c(){if(b()){var c= +h.getEyeParameters("left");e=2*c.renderWidth*q;f=c.renderHeight*q;Fa=a.getPixelRatio();a.getSize(B);a.setDrawingBufferSize(e,f,1);w.viewport.set(0,0,e/2,f);H.viewport.set(e/2,0,e/2,f);A.start();g.dispatchEvent({type:"sessionstart"})}else g.enabled&&a.setDrawingBufferSize(B.width,B.height,Fa),A.stop(),g.dispatchEvent({type:"sessionend"})}function d(a,b){null!==b&&4===b.length&&a.set(b[0]*e,b[1]*f,b[2]*e,b[3]*f)}var e,f,g=this,h=null,l=null,m=null,t=[],r=new R,k=new R,q=1,p="local-floor";"undefined"!== +typeof window&&"VRFrameData"in window&&(l=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var x=new R,v=new qa,y=new n,w=new W;w.viewport=new ia;w.layers.enable(1);var H=new W;H.viewport=new ia;H.layers.enable(2);var F=new Jd([w,H]);F.layers.enable(1);F.layers.enable(2);var B=new z,Fa,Z=[];this.enabled=!1;this.getController=function(a){var b=t[a];void 0===b&&(b=new Jc,b.matrixAutoUpdate=!1,b.visible=!1,t[a]=b);return b};this.getDevice=function(){return h};this.setDevice= +function(a){void 0!==a&&(h=a);A.setContext(a)};this.setFramebufferScaleFactor=function(a){q=a};this.setReferenceSpaceType=function(a){p=a};this.setPoseTarget=function(a){void 0!==a&&(m=a)};this.getCamera=function(a){var c="local-floor"===p?1.6:0;if(!1===b())return a.position.set(0,c,0),a.rotation.set(0,0,0),a;h.depthNear=a.near;h.depthFar=a.far;h.getFrameData(l);if("local-floor"===p){var e=h.stageParameters;e?r.fromArray(e.sittingToStandingTransform):r.makeTranslation(0,c,0)}c=l.pose;e=null!==m?m: +a;e.matrix.copy(r);e.matrix.decompose(e.position,e.quaternion,e.scale);null!==c.orientation&&(v.fromArray(c.orientation),e.quaternion.multiply(v));null!==c.position&&(v.setFromRotationMatrix(r),y.fromArray(c.position),y.applyQuaternion(v),e.position.add(y));e.updateMatrixWorld();w.near=a.near;H.near=a.near;w.far=a.far;H.far=a.far;w.matrixWorldInverse.fromArray(l.leftViewMatrix);H.matrixWorldInverse.fromArray(l.rightViewMatrix);k.getInverse(r);"local-floor"===p&&(w.matrixWorldInverse.multiply(k),H.matrixWorldInverse.multiply(k)); +a=e.parent;null!==a&&(x.getInverse(a.matrixWorld),w.matrixWorldInverse.multiply(x),H.matrixWorldInverse.multiply(x));w.matrixWorld.getInverse(w.matrixWorldInverse);H.matrixWorld.getInverse(H.matrixWorldInverse);w.projectionMatrix.fromArray(l.leftProjectionMatrix);H.projectionMatrix.fromArray(l.rightProjectionMatrix);Eh(F,w,H);a=h.getLayers();a.length&&(a=a[0],d(w.viewport,a.leftBounds),d(H.viewport,a.rightBounds));a:for(a=0;af.matrixWorld.determinant();fa.setMaterial(e,h);var l=k(a,c,e,f),m=!1;if(b!==d.id||Y!==l.id||aa!==(!0===e.wireframe))b=d.id,Y=l.id,aa=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(za.update(f,d,e,l),m=!0);h=d.index;var p=d.attributes.position;c=1;!0===e.wireframe&&(h=xa.getWireframeAttribute(d),c=2);a=Aa;if(null!==h){var t=ua.get(h);a=Ba;a.setIndex(t)}if(m){if(d&&d.isInstancedBufferGeometry&&!Fa.isWebGL2&&null===qa.get("ANGLE_instanced_arrays"))console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."); -else{fa.initAttributes();m=d.attributes;l=l.getAttributes();var r=e.defaultAttributeValues;for(G in l){var u=l[G];if(0<=u){var q=m[G];if(void 0!==q){var n=q.normalized,x=q.itemSize,v=ua.get(q);if(void 0!==v){var w=v.buffer,y=v.type;v=v.bytesPerElement;if(q.isInterleavedBufferAttribute){var B=q.data,I=B.stride;q=q.offset;B&&B.isInstancedInterleavedBuffer?(fa.enableAttributeAndDivisor(u,B.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=B.meshPerAttribute*B.count)):fa.enableAttribute(u); -N.bindBuffer(34962,w);N.vertexAttribPointer(u,x,y,n,I*v,q*v)}else q.isInstancedBufferAttribute?(fa.enableAttributeAndDivisor(u,q.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=q.meshPerAttribute*q.count)):fa.enableAttribute(u),N.bindBuffer(34962,w),N.vertexAttribPointer(u,x,y,n,0,0)}}else if(void 0!==r&&(n=r[G],void 0!==n))switch(n.length){case 2:N.vertexAttrib2fv(u,n);break;case 3:N.vertexAttrib3fv(u,n);break;case 4:N.vertexAttrib4fv(u,n);break;default:N.vertexAttrib1fv(u,n)}}}fa.disableUnusedAttributes()}null!== -h&&N.bindBuffer(34963,t.buffer)}t=Infinity;null!==h?t=h.count:void 0!==p&&(t=p.count);h=d.drawRange.start*c;p=null!==g?g.start*c:0;var G=Math.max(h,p);g=Math.max(0,Math.min(t,h+d.drawRange.count*c,p+(null!==g?g.count*c:Infinity))-1-G+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)fa.setLineWidth(e.wireframeLinewidth*(null===L?ea: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),fa.setLineWidth(e* -(null===L?ea: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 t=p[h[c]];var k=p[h[(c+1)%3]];f[0]=Math.min(t,k);f[1]=Math.max(t,k);t=f[0]+","+f[1];void 0===g[t]&&(g[t]={index1:f[0],index2:f[1]})}}for(t in g)m=g[t],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){l=a.attributes.position;p=a.index;var r=a.groups;0===r.length&&(r=[{start:0,count:p.count,materialIndex:0}]);a=0;for(e=r.length;ac;c++)t=p.getX(m+c),k=p.getX(m+(c+1)%3),f[0]=Math.min(t,k),f[1]=Math.max(t,k),t=f[0]+","+f[1],void 0===g[t]&&(g[t]={index1:f[0],index2:f[1]});for(t in g)m=g[t],h.fromBufferAttribute(l,m.index1), -b.push(h.x,h.y,h.z),h.fromBufferAttribute(l,m.index2),b.push(h.x,h.y,h.z)}else for(l=a.attributes.position,m=0,d=l.count/3;mc;c++)g=3*m+c,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new A(b,3))}function Zd(a,b,c){F.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Zc(a,b,c));this.mergeVertices()}function Zc(a,b,c){D.call(this); -this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new n,l=new n,m=new n,p=new n,t=new n,k,r;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var q=b+1;for(k=0;k<=c;k++){var x=k/c;for(r=0;r<=b;r++){var v=r/b;a(v,x,l);e.push(l.x,l.y,l.z);0<=v-1E-5?(a(v-1E-5,x,m),p.subVectors(l,m)):(a(v+1E-5,x,m),p.subVectors(m,l));0<=x-1E-5?(a(v,x-1E-5,m),t.subVectors(l,m)):(a(v,x+1E-5,m),t.subVectors(m, -l));h.crossVectors(p,t).normalize();f.push(h.x,h.y,h.z);g.push(v,x)}}for(k=0;kd&&1===a.x&&(l[b]=a.x-1);0===c.x&&0===c.z&&(l[b]=d/2/Math.PI+.5)}D.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],l=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;he&&(.2>b&&(l[a+0]+=1),.2>c&&(l[a+2]+=1),.2>d&&(l[a+4]+=1))})();this.addAttribute("position",new A(h,3));this.addAttribute("normal",new A(h.slice(),3));this.addAttribute("uv",new A(l,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function ae(a,b){F.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new $c(a,b));this.mergeVertices()}function $c(a,b){ya.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 be(a,b){F.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new mc(a,b));this.mergeVertices()}function mc(a,b){ya.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 ce(a,b){F.call(this);this.type="IcosahedronGeometry";this.parameters= -{radius:a,detail:b};this.fromBufferGeometry(new ad(a,b));this.mergeVertices()}function ad(a,b){var c=(1+Math.sqrt(5))/2;ya.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 de(a,b){F.call(this);this.type="DodecahedronGeometry";this.parameters= -{radius:a,detail:b};this.fromBufferGeometry(new bd(a,b));this.mergeVertices()}function bd(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;ya.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 ee(a,b,c,d,e,f){F.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 nc(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function nc(a, -b,c,d,e){function f(e){p=a.getPointAt(e/b,p);var f=g.normals[e];e=g.binormals[e];for(u=0;u<=d;u++){var m=u/d*Math.PI*2,k=Math.sin(m);m=-Math.cos(m);l.x=m*f.x+k*e.x;l.y=m*f.y+k*e.y;l.z=m*f.z+k*e.z;l.normalize();q.push(l.x,l.y,l.z);h.x=p.x+c*l.x;h.y=p.y+c*l.y;h.z=p.z+c*l.z;r.push(h.x,h.y,h.z)}}D.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,l=new n,m=new z,p=new n,k,u,r=[],q=[],x=[],v=[];for(k=0;k=b;e-=d)f=Xh(e,a[e],a[e+1],f);f&&oc(f,f.next)&&(he(f),f=f.next);return f}function ie(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!oc(a,a.next)&&0!==ra(a.prev,a,a.next))a=a.next;else{he(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function je(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,l=h;do null===l.z&&(l.z=wg(l.x,l.y,d,e,f)),l.prevZ=l.prev,l=l.nextZ=l.next;while(l!==h);l.prevZ.nextZ=null;l.prevZ=null;h=l;var m,p,k,u,r=1;do{l=h;var q=h=null;for(p=0;l;){p++; -var n=l;for(m=k=0;mn!==q.next.y>n&&q.next.y!==q.y&&k<(q.next.x-q.x)*(n-q.y)/(q.next.y-q.y)+q.x&&(p=!p),q=q.next;while(q!==l);q=p}l=q}if(l){a=Zh(g,h);g=ie(g,g.next);a=ie(a,a.next);je(g,b,c,d,e,f);je(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function Pj(a,b,c,d){var e=a.prev,f=a.next;if(0<=ra(e,a,f))return!1;var g=e.x>a.x?e.x>f.x?e.x:f.x:a.x>f.x?a.x:f.x,h=e.y>a.y?e.y>f.y?e.y:f.y:a.y>f.y?a.y:f.y,l=wg(e.x=l&&d&&d.z<=b;){if(c!==a.prev&&c!==a.next&&ed(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=ra(c.prev,c,c.next))return!1;c=c.prevZ;if(d!==a.prev&&d!==a.next&&ed(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=ra(d.prev,d,d.next))return!1;d=d.nextZ}for(;c&&c.z>=l;){if(c!==a.prev&&c!==a.next&&ed(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=ra(c.prev,c,c.next))return!1;c=c.prevZ}for(;d&&d.z<=b;){if(d!==a.prev&&d!==a.next&&ed(e.x,e.y, -a.x,a.y,f.x,f.y,d.x,d.y)&&0<=ra(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function Qj(a,b){return a.x-b.x}function Rj(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&&ed(e< -l?d:f,e,g,l,eh.x)&&ke(c,a)&&(h=c,m=p)}c=c.next}return h}function wg(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 Sj(a){var b=a,c=a;do{if(b.xra(a.prev,a,a.next)?0<=ra(a,b,a.next)&&0<=ra(a,a.prev,b):0>ra(a,b,a.prev)||0>ra(a,a.next,b)}function Zh(a,b){var c=new xg(a.i,a.x,a.y),d=new xg(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 Xh(a,b,c,d){a=new xg(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 he(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 xg(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 $h(a){var b=a.length;2Number.EPSILON){var l=Math.sqrt(h), -m=Math.sqrt(f*f+g*g);h=b.x-e/l;b=b.y+d/l;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 z(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 z(f/e,d/e)}function h(a,b){for(M=a.length;0<=--M;){var c=M;var f=M-1;0>f&&(f=a.length-1);var g,h=w+2*C;for(g=0;gk;k++){var t=m[f[k]];var n=m[f[(k+1)%3]];d[0]=Math.min(t,n);d[1]=Math.max(t,n);t=d[0]+","+d[1];void 0===e[t]?e[t]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[t].face2=h}for(t in e)if(d=e[t], -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 A(c,3))}function sc(a,b,c,d,e,f,g,h){F.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 xb(a,b,c,d,e,f,g,h));this.mergeVertices()}function xb(a,b,c,d,e,f,g,h){function l(c){var e,f=new z,l=new n, -p=0,w=!0===c?a:b,x=!0===c?1:-1;var A=q;for(e=1;e<=d;e++)t.push(0,v*x,0),u.push(0,x,0),r.push(.5,.5),q++;var E=q;for(e=0;e<=d;e++){var C=e/d*h+g,D=Math.cos(C);C=Math.sin(C);l.x=w*C;l.y=v*x;l.z=w*D;t.push(l.x,l.y,l.z);u.push(0,x,0);f.x=.5*D+.5;f.y=.5*C*x+.5;r.push(f.x,f.y);q++}for(e=0;ethis.duration&& -this.resetDuration()}function Uj(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return ld;case "vector":case "vector2":case "vector3":case "vector4":return md;case "color":return nf;case "quaternion":return te;case "bool":case "boolean":return mf;case "string":return pf}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function Vj(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=Uj(a.type); -if(void 0===a.times){var c=[],d=[];ha.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 yg(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 Xa(a){this.manager=void 0!==a?a:Ga}function di(a){this.manager=void 0!==a?a:Ga}function ei(a){this.manager=void 0!==a?a:Ga;this._parser=null}function zg(a){this.manager=void 0!==a?a:Ga;this._parser=null}function ue(a){this.manager=void 0!==a?a:Ga}function Ag(a){this.manager=void 0!==a?a:Ga}function qf(a){this.manager=void 0!==a?a:Ga}function H(){this.type= -"Curve";this.arcLengthDivisions=200}function Oa(a,b,c,d,e,f,g,h){H.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 nd(a,b,c,d,e,f){Oa.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function Bg(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,f,g,h,l){e=l*(g-e);h=l*(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,l,m,k){e=((f-e)/l-(g-e)/(l+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+k)+(h-g)/k)*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 pa(a,b,c,d){H.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function fi(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 ve(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function we(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 Ya(a,b,c,d){H.call(this);this.type="CubicBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z;this.v3=d||new z}function ob(a,b,c,d){H.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 Ha(a,b){H.call(this);this.type="LineCurve";this.v1=a||new z;this.v2=b||new z}function Za(a,b){H.call(this);this.type="LineCurve3";this.v1=a||new n;this.v2=b|| -new n}function $a(a,b,c){H.call(this);this.type="QuadraticBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z}function pb(a,b,c){H.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n}function ab(a){H.call(this);this.type="SplineCurve";this.points=a||[]}function yb(){H.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function bb(a){yb.call(this);this.type="Path";this.currentPoint=new z;a&&this.setFromPoints(a)}function Sb(a){bb.call(this, -a);this.uuid=P.generateUUID();this.type="Shape";this.holes=[]}function T(a,b){C.call(this);this.type="Light";this.color=new K(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function rf(a,b,c){T.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(C.DefaultUp);this.updateMatrix();this.groundColor=new K(b)}function Ac(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new z(512,512);this.map=null;this.matrix=new Q}function sf(){Ac.call(this,new na(50, -1,.5,500))}function tf(a,b,c,d,e,f){T.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 sf}function uf(a,b,c,d){T.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 Ac(new na(90,1,.5,500))}function xe(a,b,c,d,e,f){jb.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 vf(){Ac.call(this, -new xe(-5,5,5,-5,.5,500))}function wf(a,b){T.call(this,a,b);this.type="DirectionalLight";this.position.copy(C.DefaultUp);this.updateMatrix();this.target=new C;this.shadow=new vf}function xf(a,b){T.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}function yf(a,b,c,d){T.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function zf(a){this.manager=void 0!==a?a:Ga;this.textures={}}function Af(){D.call(this);this.type="InstancedBufferGeometry"; -this.maxInstancedCount=void 0}function Bf(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));O.call(this,a,b,c);this.meshPerAttribute=d||1}function Cg(a){this.manager=void 0!==a?a:Ga}function Dg(a){this.manager=void 0!==a?a:Ga;this.resourcePath=""}function Eg(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:Ga;this.options=void 0}function Fg(){this.type="ShapePath";this.color=new K;this.subPaths=[];this.currentPath=null}function Gg(a){this.type="Font";this.data=a}function gi(a){this.manager=void 0!==a?a:Ga}function ye(){}function Hg(a){this.manager=void 0!==a?a:Ga}function Cf(){this.coefficients=[];for(var a=0;9>a;a++)this.coefficients.push(new n)}function cb(a,b){T.call(this,void 0,b);this.sh=void 0!==a?a:new Cf} -function Ig(a,b,c){cb.call(this,void 0,c);a=(new K).set(a);c=(new K).set(b);b=new n(a.r,a.g,a.b);a=new n(c.r,c.g,c.b);c=Math.sqrt(Math.PI);var d=c*Math.sqrt(.75);this.sh.coefficients[0].copy(b).add(a).multiplyScalar(c);this.sh.coefficients[1].copy(b).sub(a).multiplyScalar(d)}function Jg(a,b){cb.call(this,void 0,b);a=(new K).set(a);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}function hi(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new na; -this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new na;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1;this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function Kg(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function Lg(){C.call(this);this.type="AudioListener";this.context=Mg.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination); -this.filter=null;this.timeDelta=0;this._clock=new Kg}function od(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 Ng(a){od.call(this,a);this.panner=this.context.createPanner();this.panner.panningModel="HRTF"; -this.panner.connect(this.gain)}function Og(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 Pg(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 ii(a,b,c){c=c||za.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function za(a,b,c){this.path=b;this.parsedPath=c||za.parseTrackName(b);this.node=za.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function ji(){this.uuid=P.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 ki(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 Qg(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Df(a,b){"string"===typeof a&& -(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Rg(a,b,c){kc.call(this,a,b);this.meshPerAttribute=c||1}function li(a,b,c,d){this.ray=new bc(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 mi(a,b){return a.distance- -b.distance}function Sg(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 A(b,3));b=new ba({fog:!1});this.cone=new aa(a,b);this.add(this.cone);this.update()}function pi(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;ca?-1:0Ge;Ge++)wa[Ge]=(16>Ge?"0":"")+Ge.toString(16);var P={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()|0,d=4294967295*Math.random()|0;return(wa[a&255]+wa[a>>8&255]+wa[a>>16&255]+wa[a>>24&255]+"-"+wa[b&255]+wa[b>>8&255]+"-"+wa[b>>16&15|64]+wa[b>>24&255]+"-"+wa[c&63|128]+wa[c>>8&255]+"-"+wa[c>>16&255]+wa[c>>24&255]+wa[d&255]+wa[d>>8&255]+wa[d>>16& -255]+wa[d>>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*P.DEG2RAD},radToDeg:function(a){return a*P.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(z.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(z.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(a, -b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));return this},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(ta,{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],l=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var k=e[f+1],t=e[f+2];e=e[f+3];if(c!==e||h!==d||l!==k||m!==t){f=1-g;var n=h*d+l*k+m*t+c*e,r=0<=n?1:-1,q=1-n*n;q>Number.EPSILON&&(q=Math.sqrt(q),n=Math.atan2(q,n*r),f=Math.sin(f*n)/q,g=Math.sin(g*n)/q);r*=g;h=h*f+d*r;l=l*f+k*r;m=m*f+t*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+l*l+m*m+c*c),h*=g,l*=g,m*=g, -c*=g)}a[b]=h;a[b+1]=l;a[b+2]=m;a[b+3]=c}});Object.defineProperties(ta.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(ta.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),l=f(d/2);f=f(e/2);c=g(c/ -2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f-c*d*e):"YXZ"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f+c*d*e):"ZXY"===a?(this._x=c*l*f-h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f-c*d*e):"ZYX"===a?(this._x=c*l*f-h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f+c*d*e):"YZX"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f-c*d*e):"XZY"===a&&(this._x= -c*l*f-h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f+c*d*e);!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],l=b[6];b=b[10];var m=c+f+b;0f&&c>b? -(c=2*Math.sqrt(1+c-f-b),this._w=(l-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+l)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+l)/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(P.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(),this._onChangeCallback(),this;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(){}});var Bc,yd;Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y= -b;this.z=c;return this},setScalar:function(a){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},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=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;default:throw Error("index is out of range: "+ -a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .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;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=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;return this},addScaledVector:function(a, -b){this.x+=a.x*b;this.y+=a.y*b;this.z+=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(a){void 0===yd&&(yd=new ta);a&&a.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(yd.setFromEuler(a))},applyAxisAngle:function(a,b){void 0===yd&&(yd=new ta); -return this.applyQuaternion(yd.setFromAxisAngle(a,b))},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,l=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+l*-g-m*-f;this.y=l*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-l*-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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));return this},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(a){void 0===Bc&&(Bc=new n);Bc.copy(this).projectOnVector(a); -return this.sub(Bc)},reflect:function(a){void 0===Bc&&(Bc=new n);return this.sub(Bc.copy(a).multiplyScalar(2*this.dot(a)))},angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(P.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}});var Bb;Object.assign(va.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,l){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]=l;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(a){void 0===Bb&&(Bb=new n);for(var b=0,c=a.count;bc;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 zd,Tb={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===zd&&(zd=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));zd.width=a.width;zd.height=a.height;var b=zd.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=zd}return 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(Y.prototype,"needsUpdate", -{set:function(a){!0===a&&this.version++}});Object.defineProperties(ia.prototype,{width:{get:function(){return this.z},set:function(a){this.z=a}},height:{get:function(){return this.w},set:function(a){this.w=a}}});Object.assign(ia.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 l=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-l)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+l)&&.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+l)/4;b>f&&b>m?.01>b?(l=0,c=h=.707106781):(l=Math.sqrt(b),h=c/l,c=d/l):f>m?.01>f?(l=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),l=c/h,c=g/h):.01>m?(h=l=.707106781,c=0):(c= -Math.sqrt(m),l=d/c,h=g/c);this.set(l,h,c,a);return this}a=Math.sqrt((l-g)*(l-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(l-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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));this.w=Math.max(a,Math.min(b,this.w));return this},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}});hb.prototype=Object.assign(Object.create(la.prototype),{constructor:hb,isWebGLRenderTarget:!0, -setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.texture.image.width=a,this.texture.image.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"})}}); -dg.prototype=Object.assign(Object.create(hb.prototype),{constructor:dg,isWebGLMultisampleRenderTarget:!0,copy:function(a){hb.prototype.copy.call(this,a);this.samples=a.samples;return this}});var ua,da,Xg,si,qb,He,Aa;Object.assign(Q.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,l,m,k,n,u,r,q,x){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]=l;p[6]=m;p[10]=k;p[14]=n;p[3]=u;p[7]=r;p[11]=q;p[15]=x;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 Q).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(a){void 0===ua&&(ua=new n);var b=this.elements,c=a.elements,d=1/ua.setFromMatrixColumn(a,0).length(),e=1/ua.setFromMatrixColumn(a,1).length();a=1/ua.setFromMatrixColumn(a,2).length();b[0]=c[0]*d;b[1]=c[1]*d;b[2]=c[2]*d;b[3]=0;b[4]=c[4]*e;b[5]=c[5]*e;b[6]=c[6]*e;b[7]=0;b[8]=c[8]*a;b[9]=c[9]*a;b[10]=c[10]*a;b[11]=0;b[12]=0;b[13]=0; -b[14]=0;b[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 l=f*e,m=c*h,k=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=l+m*d;b[5]=a-k*d;b[9]=-c*g;b[2]=k-a*d;b[6]=m+l*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,l=g*e,m=d* -h,k=d*e,b[0]=a+k*c,b[4]=m*c-l,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=l*c-m,b[6]=k+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a-k*c,b[4]=-f*e,b[8]=m+l*c,b[1]=l+m*c,b[5]=f*h,b[9]=k-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,l=f*e,m=c*h,k=c*e,b[0]=g*h,b[4]=m*d-l,b[8]=a*d+k,b[1]=g*e,b[5]=k*d+a,b[9]=l*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=k-a*e,b[8]=m*e+l,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=l*e+m,b[10]=a-k*e):"XZY"=== -a.order&&(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+k,b[5]=f*h,b[9]=l*e-m,b[2]=m*e-l,b[6]=c*h,b[10]=k*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(a){void 0===Xg&&(Xg=new n(0,0,0),si=new n(1,1,1));return this.compose(Xg,a,si)},lookAt:function(a,b,c){void 0===qb&&(qb=new n,He=new n,Aa=new n);var d=this.elements;Aa.subVectors(a,b);0===Aa.lengthSq()&&(Aa.z=1);Aa.normalize();qb.crossVectors(c,Aa);0===qb.lengthSq()&&(1===Math.abs(c.z)? -Aa.x+=1E-4:Aa.z+=1E-4,Aa.normalize(),qb.crossVectors(c,Aa));qb.normalize();He.crossVectors(Aa,qb);d[0]=qb.x;d[4]=He.x;d[8]=Aa.x;d[1]=qb.y;d[5]=He.y;d[9]=Aa.y;d[2]=qb.z;d[6]=He.z;d[10]=Aa.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],l=c[5],m=c[9],k=c[13],n=c[2],u=c[6],r=c[10],q=c[14],x=c[3],v=c[7],y=c[11];c=c[15];var w=d[0],z=d[4],G=d[8],B=d[12],A=d[1],C=d[5],D=d[9],F=d[13],E=d[2],H=d[6],J=d[10],K=d[14],L=d[3],O=d[7],P=d[11];d=d[15];b[0]=a*w+e*A+f*E+g*L;b[4]=a*z+e*C+f*H+g*O;b[8]=a*G+e*D+f*J+g*P;b[12]=a*B+e*F+f*K+g*d;b[1]=h*w+l*A+m*E+k*L;b[5]=h*z+l*C+m*H+k*O;b[9]=h*G+l*D+m*J+k*P;b[13]=h*B+l*F+m*K+k*d;b[2]=n*w+u*A+r*E+q*L;b[6]=n*z+u*C+r*H+ -q*O;b[10]=n*G+u*D+r*J+q*P;b[14]=n*B+u*F+r*K+q*d;b[3]=x*w+v*A+y*E+c*L;b[7]=x*z+v*C+y*H+c*O;b[11]=x*G+v*D+y*J+c*P;b[15]=x*B+v*F+y*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(a){void 0===ua&&(ua=new n);for(var b=0,c=a.count;bthis.determinant()&&(e=-e);a.x=d[12];a.y=d[13];a.z=d[14];da.copy(this);a=1/e;d=1/f;var h=1/g;da.elements[0]*=a;da.elements[1]*=a;da.elements[2]*=a;da.elements[4]*=d;da.elements[5]*=d;da.elements[6]*=d;da.elements[8]*=h;da.elements[9]*=h;da.elements[10]*=h;b.setFromRotationMatrix(da);c.x=e;c.y=f;c.z=g;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),l=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*l;g[9]=0;g[13]=-((c+d)*l);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 Hf,If;ac.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" "); -ac.DefaultOrder="XYZ";Object.defineProperties(ac.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()}},order:{get:function(){return this._order},set:function(a){this._order=a;this._onChangeCallback()}}});Object.assign(ac.prototype,{isEuler:!0,set:function(a,b,c,d){this._x=a;this._y= -b;this._z=c;this._order=d||this._order;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=P.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],l=e[5],m=e[9],k=e[2],n=e[6];e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.9999999>Math.abs(g)?(this._x=Math.atan2(-m, -e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(n,l),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.9999999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-k,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(n,-1,1)),.9999999>Math.abs(n)?(this._y=Math.atan2(-k,e),this._z=Math.atan2(-f,l)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(k,-1,1)),.9999999>Math.abs(k)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f, -l))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.9999999>Math.abs(h)?(this._x=Math.atan2(-m,l),this._y=Math.atan2(-k,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.9999999>Math.abs(f)?(this._x=Math.atan2(n,l),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;!1!==c&&this._onChangeCallback();return this},setFromQuaternion:function(a,b,c){void 0===Hf&&(Hf=new Q); -Hf.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(Hf,b,c)},setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(a){void 0===If&&(If=new ta);If.setFromEuler(this);return this.setFromQuaternion(If,a)},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(eg.prototype,{set:function(a){this.mask=1<e&&(e=m);k>f&&(f=k);n>g&&(g=n)}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,l=a.count;he&&(e=m);k>f&&(f=k);n>g&&(g=n)}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(a){void 0===ka&&(ka=new n);this.clampPoint(a.center,ka);return ka.distanceToSquared(a.center)<=a.radius*a.radius},intersectsPlane:function(a){if(0=-a.constant},intersectsTriangle:function(a){void 0===Ub&&(Ub=new n,Cc=new n,Dc=new n,Cb=new n,Db=new n,Vb=new n,Ad=new n,Ie=new n,Je=new n);if(this.isEmpty())return!1;this.getCenter(Ad);Ie.subVectors(this.max,Ad);Ub.subVectors(a.a,Ad);Cc.subVectors(a.b,Ad);Dc.subVectors(a.c,Ad);Cb.subVectors(Cc,Ub);Db.subVectors(Dc,Cc);Vb.subVectors(Ub,Dc);a=[0, --Cb.z,Cb.y,0,-Db.z,Db.y,0,-Vb.z,Vb.y,Cb.z,0,-Cb.x,Db.z,0,-Db.x,Vb.z,0,-Vb.x,-Cb.y,Cb.x,0,-Db.y,Db.x,0,-Vb.y,Vb.x,0];if(!fg(a,Ub,Cc,Dc,Ie))return!1;a=[1,0,0,0,1,0,0,0,1];if(!fg(a,Ub,Cc,Dc,Ie))return!1;Je.crossVectors(Cb,Db);a=[Je.x,Je.y,Je.z];return fg(a,Ub,Cc,Dc,Ie)},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(a){void 0===ka&&(ka=new n);return ka.copy(a).clamp(this.min, -this.max).sub(a).length()},getBoundingSphere:function(a){void 0===ka&&(ka=new n);void 0===a&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(a.center);a.radius=.5*this.getSize(ka).length();return a},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(a){void 0===db&&(db=[new n,new n,new n,new n,new n,new n,new n, -new n]);if(this.isEmpty())return this;db[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(a);db[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(a);db[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(a);db[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(a);db[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(a);db[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(a);db[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(a);db[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(a); -this.setFromPoints(db);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)}});var tb,Yg;Object.assign(ib.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(a,b){void 0===Yg&&(Yg=new Sa);var c=this.center;void 0!==b?c.copy(b):Yg.setFromPoints(a).getCenter(c);for(var d=b=0,e=a.length;d=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 Sa);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}});var sa,Ke,Le,eb,Jf,Me,Kf;Object.assign(bc.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin); -this.direction.copy(a.direction);return this},at:function(a,b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),b=new n);return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(a){void 0===sa&&(sa=new n);this.origin.copy(this.at(a,sa));return this},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b= -new n);b.subVectors(a,this.origin);a=b.dot(this.direction);return 0>a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(a){void 0===sa&&(sa=new n);var b=sa.subVectors(a,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(a);sa.copy(this.direction).multiplyScalar(b).add(this.origin);return sa.distanceToSquared(a)},distanceSqToSegment:function(a,b, -c,d){void 0===Ke&&(Ke=new n,Le=new n,eb=new n);Ke.copy(a).add(b).multiplyScalar(.5);Le.copy(b).sub(a).normalize();eb.copy(this.origin).sub(Ke);var e=.5*a.distanceTo(b),f=-this.direction.dot(Le),g=eb.dot(this.direction),h=-eb.dot(Le),l=eb.lengthSq(),m=Math.abs(1-f*f);if(0=-k?b<=k?(e=1/m,a*=e,b*=e,f=a*(a+f*b+2*g)+b*(f*a+b+2*h)+l):(b=e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):(b=-e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):b<=-k?(a=Math.max(0,-(-f*e+g)),b=0a)return null;a=Math.sqrt(a-d);d=c-a;c+=a;return 0>d&&0>c?null:0>d?this.at(c,b):this.at(d,b)},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(a){void 0===sa&&(sa=new n);return null!==this.intersectBox(a,sa)},intersectTriangle:function(a,b,c,d,e){void 0===eb&&(eb=new n,Jf=new n,Me=new n,Kf=new n);Jf.subVectors(b,a);Me.subVectors(c,a);Kf.crossVectors(Jf,Me);b=this.direction.dot(Kf);if(0b)d=-1,b=-b;else return null;eb.subVectors(this.origin,a);a=d*this.direction.dot(Me.crossVectors(eb, -Me));if(0>a)return null;c=d*this.direction.dot(Jf.cross(eb));if(0>c||a+c>b)return null;a=-d*eb.dot(Kf);return 0>a?null:this.at(a/b,e)},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)}});var Ba,Ia,Ne,Pa,Wb,Ec,Zg,Lf,Mf,Nf;Object.assign(U,{getNormal:function(a,b,c,d){void 0===Ba&&(Ba=new n);void 0===d&&(console.warn("THREE.Triangle: .getNormal() target is now required"), -d=new n);d.subVectors(c,b);Ba.subVectors(a,b);d.cross(Ba);a=d.lengthSq();return 0=Pa.x+Pa.y},getUV:function(a,b,c,d,e,f,g,h){void 0===Pa&&(Pa=new n);this.getBarycoord(a,b,c,d,Pa);h.set(0,0);h.addScaledVector(e,Pa.x);h.addScaledVector(f,Pa.y);h.addScaledVector(g,Pa.z);return h},isFrontFacing:function(a,b,c,d){void 0===Ia&&(Ba=new n,Ia=new n);Ba.subVectors(c,b);Ia.subVectors(a,b);return 0>Ba.cross(Ia).dot(d)?!0:!1}});Object.assign(U.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(){void 0===Ia&&(Ba=new n,Ia=new n);Ba.subVectors(this.c,this.b);Ia.subVectors(this.a,this.b);return.5*Ba.cross(Ia).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 U.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 U.getBarycoord(a,this.a,this.b,this.c,b)},getUV:function(a,b,c,d,e){return U.getUV(a,this.a, -this.b,this.c,b,c,d,e)},containsPoint:function(a){return U.containsPoint(a,this.a,this.b,this.c)},isFrontFacing:function(a){return U.isFrontFacing(this.a,this.b,this.c,a)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(a,b){void 0===Wb&&(Wb=new n,Ec=new n,Zg=new n,Lf=new n,Mf=new n,Nf=new n);void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new n);var c=this.a,d=this.b,e=this.c;Wb.subVectors(d,c);Ec.subVectors(e, -c);Lf.subVectors(a,c);var f=Wb.dot(Lf),g=Ec.dot(Lf);if(0>=f&&0>=g)return b.copy(c);Mf.subVectors(a,d);var h=Wb.dot(Mf),l=Ec.dot(Mf);if(0<=h&&l<=h)return b.copy(d);var m=f*l-h*g;if(0>=m&&0<=f&&0>=h)return d=f/(f-h),b.copy(c).addScaledVector(Wb,d);Nf.subVectors(a,e);a=Wb.dot(Nf);var k=Ec.dot(Nf);if(0<=k&&a<=k)return b.copy(e);f=a*g-f*k;if(0>=f&&0<=g&&0>=k)return m=g/(g-k),b.copy(c).addScaledVector(Ec,m);g=h*k-a*l;if(0>=g&&0<=l-h&&0<=a-k)return Zg.subVectors(e,d),m=(l-h)/(l-h+(a-k)),b.copy(d).addScaledVector(Zg, -m);e=1/(g+f+m);d=f*e;m*=e;return b.copy(c).addScaledVector(Wb,d).addScaledVector(Ec,m)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});var Wj={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},Ja={h:0,s:0,l:0},Of={h:0,s:0,l:0};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(a,b,c){a=P.euclideanModulo(a,1);b=P.clamp(b,0,1);c=P.clamp(c,0,1);0===b?this.r=this.g=this.b=c:(b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=gg(c,b,a+1/3),this.g=gg(c,b,a),this.b=gg(c,b,a-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&&0=h?l/(e+f):l/(2-e-f);switch(e){case b:g=(c-d)/l+(cthis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;d.stencilWrite=this.stencilWrite;d.stencilFunc=this.stencilFunc;d.stencilRef=this.stencilRef;d.stencilMask=this.stencilMask;d.stencilFail= -this.stencilFail;d.stencilZFail=this.stencilZFail;d.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize); -void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0g;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;c\n\t#include \n}",fragmentShader:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}", -side:1,blending:0});d.uniforms.tEquirect.value=b;b=new S(new Kb(5,5,5),d);c.add(b);d=new Pc(1,10,1);d.renderTarget=this;d.renderTarget.texture.name="CubeCameraTexture";d.update(a,c);b.geometry.dispose();b.material.dispose();return this};ic.prototype=Object.create(Y.prototype);ic.prototype.constructor=ic;ic.prototype.isDataTexture=!0;var Yb,ti,ah;Object.assign(kb.prototype,{isPlane:!0,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(a,b,c){void 0===Yb&&(Yb=new n,ti=new n);b=Yb.subVectors(c,b).cross(ti.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(b,a);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(a,b){void 0=== -Yb&&(Yb=new n);void 0===b&&(console.warn("THREE.Plane: .intersectLine() target is now required"),b=new n);var c=a.delta(Yb),d=this.normal.dot(c);if(0===d){if(0===this.distanceToPoint(a.start))return b.copy(a.start)}else if(d=-(a.start.dot(this.normal)+this.constant)/d,!(0>d||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],l=c[6],m=c[7],k=c[8],n=c[9],u=c[10],r=c[11],q=c[12],x=c[13],v=c[14];c=c[15];b[0].setComponents(f-a,m-g,r-k,c-q).normalize();b[1].setComponents(f+a,m+g,r+k,c+q).normalize();b[2].setComponents(f+d,m+h,r+n,c+x).normalize();b[3].setComponents(f-d,m-h,r-n,c-x).normalize();b[4].setComponents(f-e,m-l,r-u,c-v).normalize();b[5].setComponents(f+e,m+l,r+u,c+v).normalize();return this},intersectsObject:function(a){void 0===rb&&(rb=new ib);var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere(); -rb.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(rb)},intersectsSprite:function(a){void 0===rb&&(rb=new ib);rb.center.set(0,0,0);rb.radius=.7071067811865476;rb.applyMatrix4(a.matrixWorld);return this.intersectsSphere(rb)},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)c;c++){var d=b[c];Bd.x=0d.distanceToPoint(Bd))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 L={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}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, 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_RoughnessDependent( specularColor, dotNV, roughness );\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}", +b.envMap&&(a.envMapIntensity.value=b.envMapIntensity)}a=a||{};var v=void 0!==a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),y=void 0!==a.context?a.context:null,w=void 0!==a.alpha?a.alpha:!1,H=void 0!==a.depth?a.depth:!0,F=void 0!==a.stencil?a.stencil:!0,B=void 0!==a.antialias?a.antialias:!1,A=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,C=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,D=void 0!==a.powerPreference?a.powerPreference:"default", +J=void 0!==a.failIfMajorPerformanceCaveat?a.failIfMajorPerformanceCaveat:!1,K=null,G=null;this.domElement=v;this.debug={checkShaderErrors:!0};this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=!1;this.toneMappingWhitePoint=this.toneMappingExposure=this.toneMapping=1;this.maxMorphTargets=8;this.maxMorphNormals=4;var E=this, +P=!1,S=null,N=0,V=0,Q=null,ba=null,pb=-1;var T=b=null;var aa=!1;var ha=null,Na=null,W=new ia,Id=new ia,la=null,L=v.width,X=v.height,da=1,U=new ia(0,0,L,X),ja=new ia(0,0,L,X),sa=!1,Zf=new Ie,Ma=new Xi,Ke=!1,ta=!1,Hd=new R,Hb=new n;try{w={alpha:w,depth:H,stencil:F,antialias:B,premultipliedAlpha:A,preserveDrawingBuffer:C,powerPreference:D,failIfMajorPerformanceCaveat:J,xrCompatible:!0};v.addEventListener("webglcontextlost",d,!1);v.addEventListener("webglcontextrestored",e,!1);var M=y||v.getContext("webgl", +w)||v.getContext("experimental-webgl",w);if(null===M){if(null!==v.getContext("webgl"))throw Error("Error creating WebGL context with your selected attributes.");throw Error("Error creating WebGL context.");}void 0===M.getShaderPrecisionFormat&&(M.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ih){throw console.error("THREE.WebGLRenderer: "+Ih.message),Ih;}var na,Ea,ea,fa,Y,ca,ua,wa,qa,pa,va,ra,ma,ya,Aa,Ca,ka;c();var oa="undefined"!==typeof navigator&&"xr"in navigator&& +"supportsSession"in navigator.xr?new Hh(E,M):new $f(E);this.vr=oa;var Da=new Bh(E,qa,Ea.maxTextureSize);this.shadowMap=Da;this.getContext=function(){return M};this.getContextAttributes=function(){return M.getContextAttributes()};this.forceContextLoss=function(){var a=na.get("WEBGL_lose_context");a&&a.loseContext()};this.forceContextRestore=function(){var a=na.get("WEBGL_lose_context");a&&a.restoreContext()};this.getPixelRatio=function(){return da};this.setPixelRatio=function(a){void 0!==a&&(da=a, +this.setSize(L,X,!1))};this.getSize=function(a){void 0===a&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),a=new z);return a.set(L,X)};this.setSize=function(a,b,c){oa.isPresenting()?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(L=a,X=b,v.width=Math.floor(a*da),v.height=Math.floor(b*da),!1!==c&&(v.style.width=a+"px",v.style.height=b+"px"),this.setViewport(0,0,a,b))};this.getDrawingBufferSize=function(a){void 0===a&&(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"), +a=new z);return a.set(L*da,X*da).floor()};this.setDrawingBufferSize=function(a,b,c){L=a;X=b;da=c;v.width=Math.floor(a*c);v.height=Math.floor(b*c);this.setViewport(0,0,a,b)};this.getCurrentViewport=function(a){void 0===a&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),a=new ia);return a.copy(W)};this.getViewport=function(a){return a.copy(U)};this.setViewport=function(a,b,c,d){a.isVector4?U.set(a.x,a.y,a.z,a.w):U.set(a,b,c,d);ea.viewport(W.copy(U).multiplyScalar(da).floor())}; +this.getScissor=function(a){return a.copy(ja)};this.setScissor=function(a,b,c,d){a.isVector4?ja.set(a.x,a.y,a.z,a.w):ja.set(a,b,c,d);ea.scissor(Id.copy(ja).multiplyScalar(da).floor())};this.getScissorTest=function(){return sa};this.setScissorTest=function(a){ea.setScissorTest(sa=a)};this.getClearColor=function(){return ma.getClearColor()};this.setClearColor=function(){ma.setClearColor.apply(ma,arguments)};this.getClearAlpha=function(){return ma.getClearAlpha()};this.setClearAlpha=function(){ma.setClearAlpha.apply(ma, +arguments)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=16384;if(void 0===b||b)d|=256;if(void 0===c||c)d|=1024;M.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.dispose=function(){v.removeEventListener("webglcontextlost",d,!1);v.removeEventListener("webglcontextrestored",e,!1);va.dispose();ra.dispose();Y.dispose();qa.dispose();oa.dispose();xa.stop()};this.renderBufferImmediate= +function(a,b){ea.initAttributes();var c=Y.get(a);a.hasPositions&&!c.position&&(c.position=M.createBuffer());a.hasNormals&&!c.normal&&(c.normal=M.createBuffer());a.hasUvs&&!c.uv&&(c.uv=M.createBuffer());a.hasColors&&!c.color&&(c.color=M.createBuffer());b=b.getAttributes();a.hasPositions&&(M.bindBuffer(34962,c.position),M.bufferData(34962,a.positionArray,35048),ea.enableAttribute(b.position),M.vertexAttribPointer(b.position,3,5126,!1,0,0));a.hasNormals&&(M.bindBuffer(34962,c.normal),M.bufferData(34962, +a.normalArray,35048),ea.enableAttribute(b.normal),M.vertexAttribPointer(b.normal,3,5126,!1,0,0));a.hasUvs&&(M.bindBuffer(34962,c.uv),M.bufferData(34962,a.uvArray,35048),ea.enableAttribute(b.uv),M.vertexAttribPointer(b.uv,2,5126,!1,0,0));a.hasColors&&(M.bindBuffer(34962,c.color),M.bufferData(34962,a.colorArray,35048),ea.enableAttribute(b.color),M.vertexAttribPointer(b.color,3,5126,!1,0,0));ea.disableUnusedAttributes();M.drawArrays(4,0,a.count);a.count=0};this.renderBufferDirect=function(a,c,d,e,f, +g){var h=f.isMesh&&0>f.matrixWorld.determinant();ea.setMaterial(e,h);var l=u(a,c,e,f),m=!1;if(b!==d.id||T!==l.id||aa!==(!0===e.wireframe))b=d.id,T=l.id,aa=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(ya.update(f,d,e,l),m=!0);h=d.index;var t=d.attributes.position;c=1;!0===e.wireframe&&(h=wa.getWireframeAttribute(d),c=2);a=Aa;if(null!==h){var k=ua.get(h);a=Ca;a.setIndex(k)}if(m){if(d&&d.isInstancedBufferGeometry&&!Ea.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{ea.initAttributes();m=d.attributes;l=l.getAttributes();var r=e.defaultAttributeValues;for(F in l){var p=l[F];if(0<=p){var q=m[F];if(void 0!==q){var n=q.normalized,x=q.itemSize,v=ua.get(q);if(void 0!==v){var w=v.buffer,y=v.type;v=v.bytesPerElement;if(q.isInterleavedBufferAttribute){var B=q.data,H=B.stride;q=q.offset;B&&B.isInstancedInterleavedBuffer?(ea.enableAttributeAndDivisor(p,B.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=B.meshPerAttribute*B.count)):ea.enableAttribute(p); +M.bindBuffer(34962,w);M.vertexAttribPointer(p,x,y,n,H*v,q*v)}else q.isInstancedBufferAttribute?(ea.enableAttributeAndDivisor(p,q.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=q.meshPerAttribute*q.count)):ea.enableAttribute(p),M.bindBuffer(34962,w),M.vertexAttribPointer(p,x,y,n,0,0)}}else if(void 0!==r&&(n=r[F],void 0!==n))switch(n.length){case 2:M.vertexAttrib2fv(p,n);break;case 3:M.vertexAttrib3fv(p,n);break;case 4:M.vertexAttrib4fv(p,n);break;default:M.vertexAttrib1fv(p,n)}}}ea.disableUnusedAttributes()}null!== +h&&M.bindBuffer(34963,k.buffer)}k=Infinity;null!==h?k=h.count:void 0!==t&&(k=t.count);h=d.drawRange.start*c;t=null!==g?g.start*c:0;var F=Math.max(h,t);g=Math.max(0,Math.min(k,h+d.drawRange.count*c,t+(null!==g?g.count*c:Infinity))-1-F+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)ea.setLineWidth(e.wireframeLinewidth*(null===Q?da: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),ea.setLineWidth(e* +(null===Q?da: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?0e.far||f.push({distance:a,distanceToRay:Math.sqrt(h), +point:c,index:b,face:null,object:g}))}function eg(a,b,c,d,e,f,g,h,l){ba.call(this,a,b,c,d,e,f,g,h,l);this.format=void 0!==g?g:1022;this.minFilter=void 0!==f?f:1006;this.magFilter=void 0!==e?e:1006;this.generateMipmaps=!1}function Nc(a,b,c,d,e,f,g,h,l,m,t,k){ba.call(this,null,f,g,h,l,m,d,e,t,k);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Pd(a,b,c,d,e,f,g,h,l){ba.call(this,a,b,c,d,e,f,g,h,l);this.needsUpdate=!0}function Qd(a,b,c,d,e,f,g,h,l,m){m=void 0!== +m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);ba.call(this,null,d,e,f,g,h,m,c,l);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Oc(a){C.call(this);this.type="WireframeGeometry";var b=[],c,d,e,f=[0,0],g={},h=["a","b","c"];if(a&&a.isGeometry){var l=a.faces;var m=0;for(d= +l.length;mc;c++){var k=t[h[c]];var u=t[h[(c+1)%3]];f[0]=Math.min(k,u);f[1]=Math.max(k,u);k=f[0]+","+f[1];void 0===g[k]&&(g[k]={index1:f[0],index2:f[1]})}}for(k in g)m=g[k],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){l=a.attributes.position;t=a.index;var q=a.groups;0===q.length&&(q=[{start:0,count:t.count,materialIndex:0}]);a=0;for(e=q.length;ac;c++)k=t.getX(m+c),u=t.getX(m+(c+1)%3),f[0]=Math.min(k,u),f[1]=Math.max(k,u),k=f[0]+","+f[1],void 0===g[k]&&(g[k]={index1:f[0],index2:f[1]});for(k in g)m=g[k],h.fromBufferAttribute(l,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(l,m.index2),b.push(h.x,h.y,h.z)}else for(l=a.attributes.position,m=0,d=l.count/3;mc;c++)g=3*m+c,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z);this.addAttribute("position", +new A(b,3))}function Rd(a,b,c){E.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Pc(a,b,c));this.mergeVertices()}function Pc(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,l=new n,m=new n,t=new n,k=new n,u,q;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var p=b+1;for(u=0;u<=c;u++){var x= +u/c;for(q=0;q<=b;q++){var v=q/b;a(v,x,l);e.push(l.x,l.y,l.z);0<=v-1E-5?(a(v-1E-5,x,m),t.subVectors(l,m)):(a(v+1E-5,x,m),t.subVectors(m,l));0<=x-1E-5?(a(v,x-1E-5,m),k.subVectors(l,m)):(a(v,x+1E-5,m),k.subVectors(m,l));h.crossVectors(t,k).normalize();f.push(h.x,h.y,h.z);g.push(v,x)}}for(u=0;ud&&1===a.x&&(l[b]=a.x-1);0===c.x&&0===c.z&&(l[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=[],l=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;he&&(.2>b&&(l[a+0]+=1),.2>c&&(l[a+2]+=1),.2>d&&(l[a+4]+=1))})();this.addAttribute("position",new A(h,3));this.addAttribute("normal",new A(h.slice(),3));this.addAttribute("uv",new A(l,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Td(a,b){E.call(this); +this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qc(a,b));this.mergeVertices()}function Qc(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 Ud(a,b){E.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new cc(a,b));this.mergeVertices()}function cc(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 Vd(a,b){E.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rc(a,b));this.mergeVertices()}function Rc(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 Wd(a,b){E.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sc(a,b));this.mergeVertices()}function Sc(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 Xd(a,b,c,d,e,f){E.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 dc(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function dc(a,b,c,d,e){function f(e){t=a.getPointAt(e/b,t);var f=g.normals[e];e=g.binormals[e];for(u=0;u<=d;u++){var m=u/d*Math.PI*2,k=Math.sin(m);m=-Math.cos(m);l.x=m*f.x+k*e.x;l.y=m*f.y+k*e.y;l.z=m*f.z+k*e.z;l.normalize();p.push(l.x,l.y,l.z);h.x=t.x+c*l.x;h.y=t.y+c*l.y;h.z=t.z+c*l.z;q.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,l=new n,m=new z,t=new n,k,u,q=[],p=[],x=[],v=[];for(k=0;k=b;e-=d)f=Lh(e,a[e],a[e+1],f);f&&ec(f,f.next)&&($d(f),f=f.next);return f}function ae(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!ec(a,a.next)&&0!==ca(a.prev,a,a.next))a=a.next;else{$d(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b} +function be(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,l=h;do null===l.z&&(l.z=fg(l.x,l.y,d,e,f)),l.prevZ=l.prev,l=l.nextZ=l.next;while(l!==h);l.prevZ.nextZ=null;l.prevZ=null;h=l;var m,t,k,u,q=1;do{l=h;var p=h=null;for(t=0;l;){t++;var n=l;for(m=k=0;mn!==p.next.y>n&&p.next.y!==p.y&&k<(p.next.x-p.x)*(n-p.y)/(p.next.y-p.y)+p.x&&(t=!t),p=p.next;while(p!==l);p=t}l=p}if(l){a=Nh(g,h);g=ae(g,g.next);a=ae(a,a.next);be(g,b,c,d,e,f);be(a,b,c,d,e,f);break a}h= +h.next}g=g.next}while(g!==a)}break}}}}function dk(a,b,c,d){var e=a.prev,f=a.next;if(0<=ca(e,a,f))return!1;var g=e.x>a.x?e.x>f.x?e.x:f.x:a.x>f.x?a.x:f.x,h=e.y>a.y?e.y>f.y?e.y:f.y:a.y>f.y?a.y:f.y,l=fg(e.x=l&&d&&d.z<=b;){if(c!==a.prev&&c!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=ca(c.prev,c,c.next))return!1;c=c.prevZ;if(d!==a.prev&&d!==a.next&&Vc(e.x,e.y,a.x,a.y, +f.x,f.y,d.x,d.y)&&0<=ca(d.prev,d,d.next))return!1;d=d.nextZ}for(;c&&c.z>=l;){if(c!==a.prev&&c!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=ca(c.prev,c,c.next))return!1;c=c.prevZ}for(;d&&d.z<=b;){if(d!==a.prev&&d!==a.next&&Vc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=ca(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function ek(a,b){return a.x-b.x}function fk(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&&Vc(eh.x)&&ce(c,a)&&(h=c,m=t)}c=c.next}return h}function fg(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 gk(a){var b=a,c=a;do{if(b.xca(a.prev,a,a.next)?0<=ca(a,b,a.next)&&0<=ca(a,a.prev,b):0>ca(a,b,a.prev)||0>ca(a,a.next,b)}function Nh(a,b){var c=new gg(a.i,a.x,a.y),d=new gg(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 Lh(a,b,c,d){a=new gg(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 $d(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 gg(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 Oh(a){var b=a.length;2Number.EPSILON){var l=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/l;b=b.y+d/l;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 z(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 z(f/e,d/e)}function h(a,b){for(L=a.length;0<=--L;){var c=L;var f=L-1;0>f&&(f=a.length-1);var g,h=w+2*D;for(g=0;gk;k++){var r=m[f[k]];var n=m[f[(k+1)%3]];d[0]=Math.min(r,n);d[1]=Math.max(r,n);r=d[0]+","+d[1];void 0===e[r]?e[r]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[r].face2=h}for(r in e)if(d=e[r],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 A(c,3))}function ic(a,b,c,d, +e,f,g,h){E.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 sb(a,b,c,d,e,f,g,h));this.mergeVertices()}function sb(a,b,c,d,e,f,g,h){function l(c){var e,f=new z,l=new n,t=0,x=!0===c?a:b,w=!0===c?1:-1;var A=p;for(e=1;e<=d;e++)r.push(0,v*w,0),u.push(0,w,0),q.push(.5,.5),p++;var D=p;for(e=0;e<=d;e++){var C=e/d*h+g,E=Math.cos(C);C=Math.sin(C);l.x=x*C;l.y=v*w; +l.z=x*E;r.push(l.x,l.y,l.z);u.push(0,w,0);f.x=.5*E+.5;f.y=.5*C*w+.5;q.push(f.x,f.y);p++}for(e=0;ethis.duration&&this.resetDuration()}function ik(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return bd;case "vector":case "vector2":case "vector3":case "vector4":return cd; +case "color":return Te;case "quaternion":return le;case "bool":case "boolean":return Se;case "string":return Ve}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function jk(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=ik(a.type);if(void 0===a.times){var c=[],d=[];fa.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 hg(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 Qa(a){this.manager=void 0!==a?a:oa}function Sh(a){this.manager= +void 0!==a?a:oa}function Th(a){this.manager=void 0!==a?a:oa;this._parser=null}function ig(a){this.manager=void 0!==a?a:oa;this._parser=null}function me(a){this.manager=void 0!==a?a:oa}function jg(a){this.manager=void 0!==a?a:oa}function We(a){this.manager=void 0!==a?a:oa}function G(){this.type="Curve";this.arcLengthDivisions=200}function Ia(a,b,c,d,e,f,g,h){G.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 dd(a,b,c,d,e,f){Ia.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function kg(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,f,g,h,l){e=l*(g-e);h=l*(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,l,m,k){e=((f-e)/l-(g-e)/(l+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+k)+(h-g)/k)*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 pa(a,b,c,d){G.call(this); +this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||!1;this.curveType=c||"centripetal";this.tension=d||.5}function Uh(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 ne(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function oe(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 Ra(a,b,c,d){G.call(this);this.type="CubicBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z;this.v3=d||new z}function gb(a, +b,c,d){G.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 Da(a,b){G.call(this);this.type="LineCurve";this.v1=a||new z;this.v2=b||new z}function Sa(a,b){G.call(this);this.type="LineCurve3";this.v1=a||new n;this.v2=b||new n}function Ta(a,b,c){G.call(this);this.type="QuadraticBezierCurve";this.v0=a||new z;this.v1=b||new z;this.v2=c||new z}function hb(a,b,c){G.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new n;this.v1=b|| +new n;this.v2=c||new n}function Ua(a){G.call(this);this.type="SplineCurve";this.points=a||[]}function tb(){G.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function Va(a){tb.call(this);this.type="Path";this.currentPoint=new z;a&&this.setFromPoints(a)}function Kb(a){Va.call(this,a);this.uuid=O.generateUUID();this.type="Shape";this.holes=[]}function aa(a,b){D.call(this);this.type="Light";this.color=new J(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function Xe(a,b,c){aa.call(this, +a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.copy(D.DefaultUp);this.updateMatrix();this.groundColor=new J(b)}function qc(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new z(512,512);this.map=null;this.matrix=new R}function Ye(){qc.call(this,new W(50,1,.5,500))}function Ze(a,b,c,d,e,f){aa.call(this,a,b);this.type="SpotLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D;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 Ye}function $e(a,b,c,d){aa.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 qc(new W(90,1,.5,500))}function pe(a,b,c,d,e,f){bb.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 af(){qc.call(this,new pe(-5,5,5,-5,.5,500))}function bf(a,b){aa.call(this,a,b);this.type="DirectionalLight";this.position.copy(D.DefaultUp);this.updateMatrix();this.target=new D;this.shadow=new af}function cf(a,b){aa.call(this,a,b);this.type="AmbientLight"; +this.castShadow=void 0}function df(a,b,c,d){aa.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function ef(a){this.manager=void 0!==a?a:oa;this.textures={}}function ff(){C.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function gf(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 lg(a){this.manager=void 0!==a?a:oa}function mg(a){this.manager=void 0!==a?a:oa;this.resourcePath=""}function ng(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:oa;this.options=void 0}function og(){this.type="ShapePath";this.color=new J;this.subPaths=[];this.currentPath=null}function pg(a){this.type= +"Font";this.data=a}function Vh(a){this.manager=void 0!==a?a:oa}function qe(){}function ib(a,b,c,d,e,f,g,h){a=g+a;g=qe.Handlers.get(a);null!==g?h=g.load(a):(Wh.setCrossOrigin(h),h=Wh.load(a));void 0!==b&&(h.repeat.fromArray(b),1!==b[0]&&(h.wrapS=1E3),1!==b[1]&&(h.wrapT=1E3));void 0!==c&&h.offset.fromArray(c);void 0!==d&&("repeat"===d[0]&&(h.wrapS=1E3),"mirror"===d[0]&&(h.wrapS=1002),"repeat"===d[1]&&(h.wrapT=1E3),"mirror"===d[1]&&(h.wrapT=1002));void 0!==e&&(h.anisotropy=e);b=O.generateUUID();f[b]= +h;return b}function qg(a){this.manager=void 0!==a?a:oa}function hf(){this.coefficients=[];for(var a=0;9>a;a++)this.coefficients.push(new n)}function Wa(a,b){aa.call(this,void 0,b);this.sh=void 0!==a?a:new hf}function rg(a,b,c){Wa.call(this,void 0,c);a=(new J).set(a);c=(new J).set(b);b=new n(a.r,a.g,a.b);a=new n(c.r,c.g,c.b);c=Math.sqrt(Math.PI);var d=c*Math.sqrt(.75);this.sh.coefficients[0].copy(b).add(a).multiplyScalar(c);this.sh.coefficients[1].copy(b).sub(a).multiplyScalar(d)}function sg(a,b){Wa.call(this, +void 0,b);a=(new J).set(a);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}function Xh(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new W;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new W;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1;this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function tg(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime= +this.startTime=0;this.running=!1}function ug(){D.call(this);this.type="AudioListener";this.context=vg.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null;this.timeDelta=0;this._clock=new tg}function ed(a){D.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.duration= +void 0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function wg(a){ed.call(this,a);this.panner=this.context.createPanner();this.panner.panningModel="HRTF";this.panner.connect(this.gain)}function xg(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 yg(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 Yh(a,b,c){c=c||va.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function va(a,b,c){this.path=b;this.parsedPath=c||va.parseTrackName(b);this.node=va.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function Zh(){this.uuid=O.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 $h(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 zg(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function jf(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Ag(a,b,c){bc.call(this,a,b);this.meshPerAttribute=c||1}function ai(a,b,c,d){this.ray=new Tb(a,b);this.near=c||0;this.far=d||Infinity;this.camera=null;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 bi(a,b){return a.distance-b.distance}function Bg(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 A(b,3));b=new Q({fog:!1});this.cone=new T(a,b);this.add(this.cone);this.update()}function ei(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;ca?-1:0ye;ye++)wa[ye]=(16>ye?"0":"")+ +ye.toString(16);var O={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()|0,d=4294967295*Math.random()|0;return(wa[a&255]+wa[a>>8&255]+wa[a>>16&255]+wa[a>>24&255]+"-"+wa[b&255]+wa[b>>8&255]+"-"+wa[b>>16&15|64]+wa[b>>24&255]+"-"+wa[c&63|128]+wa[c>>8&255]+"-"+wa[c>>16&255]+wa[c>>24&255]+wa[d&255]+wa[d>>8&255]+wa[d>>16&255]+wa[d>>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*O.DEG2RAD},radToDeg:function(a){return a*O.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(z.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(z.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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));return this},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(qa,{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],l=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var k=e[f+1],r=e[f+2];e=e[f+3];if(c!==e||h!==d||l!==k||m!==r){f=1-g;var n=h*d+l*k+m*r+c*e,q=0<=n?1:-1,p=1-n*n;p>Number.EPSILON&&(p=Math.sqrt(p),n=Math.atan2(p,n*q),f=Math.sin(f*n)/p,g=Math.sin(g*n)/p);q*=g;h=h*f+d*q;l=l*f+k*q;m=m*f+r*q;c=c*f+e*q;f===1-g&&(g=1/Math.sqrt(h*h+l*l+m*m+c*c),h*=g,l*=g,m*=g,c*=g)}a[b]=h;a[b+1]=l;a[b+2]=m;a[b+3]=c}});Object.defineProperties(qa.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(qa.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),l=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f-c*d*e):"YXZ"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f-c*l*e,this._z= +h*l*e-c*d*f,this._w=h*l*f+c*d*e):"ZXY"===a?(this._x=c*l*f-h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f-c*d*e):"ZYX"===a?(this._x=c*l*f-h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f+c*d*e):"YZX"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f-c*d*e):"XZY"===a&&(this._x=c*l*f-h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f+c*d*e);!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],l=b[6];b=b[10];var m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(l-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+l)/ +c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+l)/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(O.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(),this._onChangeCallback(),this;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(){}});var Gg=new n,hi=new qa;Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){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},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=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;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this}, +add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .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;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=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;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=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(a){a&&a.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(hi.setFromEuler(a))},applyAxisAngle:function(a,b){return this.applyQuaternion(hi.setFromAxisAngle(a,b))},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,l=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+l*-g-m*-f;this.y=l*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-l*-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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a, +Math.min(b,this.z));return this},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(a){Gg.copy(this).projectOnVector(a);return this.sub(Gg)},reflect:function(a){return this.sub(Gg.copy(a).multiplyScalar(2*this.dot(a)))},angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(O.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}});var rc=new n;Object.assign(ja.prototype,{isMatrix3:!0,set:function(a, +b,c,d,e,f,g,h,l){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]=l;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(a){for(var b=0,c=a.count;bc;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 nd,Lb={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===nd&&(nd=document.createElementNS("http://www.w3.org/1999/xhtml", +"canvas"));nd.width=a.width;nd.height=a.height;var b=nd.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=nd}return 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(ba.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.defineProperties(ia.prototype,{width:{get:function(){return this.z},set:function(a){this.z=a}},height:{get:function(){return this.w},set:function(a){this.w=a}}});Object.assign(ia.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 l=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-l)){if(.1>Math.abs(c+e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+l)&&.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+l)/4;b>f&&b>m?.01>b?(l=0,c=h=.707106781):(l=Math.sqrt(b),h=c/l,c=d/l):f>m?.01>f?(l=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),l=c/h,c=g/h):.01>m?(h=l=.707106781,c=0):(c=Math.sqrt(m),l=d/c,h=g/c);this.set(l,h,c,a);return this}a=Math.sqrt((l-g)*(l-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(l-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(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b, +this.y));this.z=Math.max(a,Math.min(b,this.z));this.w=Math.max(a,Math.min(b,this.w));return this},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}});$a.prototype=Object.assign(Object.create(ra.prototype),{constructor:$a,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.texture.image.width=a,this.texture.image.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"})}});Mf.prototype=Object.assign(Object.create($a.prototype),{constructor:Mf,isWebGLMultisampleRenderTarget:!0,copy:function(a){$a.prototype.copy.call(this,a);this.samples=a.samples;return this}});var Ja=new n,U=new R,kk=new n(0,0,0),lk=new n(1,1,1),Mb=new n,of=new n,ya=new n;Object.assign(R.prototype,{isMatrix4:!0, +set:function(a,b,c,d,e,f,g,h,l,m,k,r,n,q,p,x){var t=this.elements;t[0]=a;t[4]=b;t[8]=c;t[12]=d;t[1]=e;t[5]=f;t[9]=g;t[13]=h;t[2]=l;t[6]=m;t[10]=k;t[14]=r;t[3]=n;t[7]=q;t[11]=p;t[15]=x;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 R).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(a){var b=this.elements,c=a.elements,d=1/Ja.setFromMatrixColumn(a,0).length(), +e=1/Ja.setFromMatrixColumn(a,1).length();a=1/Ja.setFromMatrixColumn(a,2).length();b[0]=c[0]*d;b[1]=c[1]*d;b[2]=c[2]*d;b[3]=0;b[4]=c[4]*e;b[5]=c[5]*e;b[6]=c[6]*e;b[7]=0;b[8]=c[8]*a;b[9]=c[9]*a;b[10]=c[10]*a;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[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 l=f*e,m=c*h,k=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=l+m*d;b[5]=a-k*d;b[9]=-c*g;b[2]=k-a*d;b[6]=m+l*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a+k*c,b[4]=m*c-l,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=l*c-m,b[6]=k+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a-k*c,b[4]=-f*e,b[8]=m+l*c,b[1]=l+m*c,b[5]=f*h,b[9]=k-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,l=f*e,m=c*h,k=c*e,b[0]=g*h, +b[4]=m*d-l,b[8]=a*d+k,b[1]=g*e,b[5]=k*d+a,b[9]=l*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=k-a*e,b[8]=m*e+l,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=l*e+m,b[10]=a-k*e):"XZY"===a.order&&(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+k,b[5]=f*h,b[9]=l*e-m,b[2]=m*e-l,b[6]=c*h,b[10]=k*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(a){return this.compose(kk,a,lk)},lookAt:function(a,b, +c){var d=this.elements;ya.subVectors(a,b);0===ya.lengthSq()&&(ya.z=1);ya.normalize();Mb.crossVectors(c,ya);0===Mb.lengthSq()&&(1===Math.abs(c.z)?ya.x+=1E-4:ya.z+=1E-4,ya.normalize(),Mb.crossVectors(c,ya));Mb.normalize();of.crossVectors(ya,Mb);d[0]=Mb.x;d[4]=of.x;d[8]=ya.x;d[1]=Mb.y;d[5]=of.y;d[9]=ya.y;d[2]=Mb.z;d[6]=of.z;d[10]=ya.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],l=c[5],m=c[9],k=c[13],r=c[2],n=c[6],q=c[10],p=c[14],x=c[3],v=c[7],y=c[11];c=c[15];var w=d[0],z=d[4],F=d[8],B=d[12],A=d[1],C=d[5],D=d[9],E=d[13],G=d[2],I=d[6],J=d[10],N=d[14],O=d[3],P=d[7],Q=d[11];d=d[15];b[0]=a*w+e*A+f*G+g*O;b[4]=a*z+e*C+f*I+g*P;b[8]=a*F+e*D+f*J+ +g*Q;b[12]=a*B+e*E+f*N+g*d;b[1]=h*w+l*A+m*G+k*O;b[5]=h*z+l*C+m*I+k*P;b[9]=h*F+l*D+m*J+k*Q;b[13]=h*B+l*E+m*N+k*d;b[2]=r*w+n*A+q*G+p*O;b[6]=r*z+n*C+q*I+p*P;b[10]=r*F+n*D+q*J+p*Q;b[14]=r*B+n*E+q*N+p*d;b[3]=x*w+v*A+y*G+c*O;b[7]=x*z+v*C+y*I+c*P;b[11]=x*F+v*D+y*J+c*Q;b[15]=x*B+v*E+y*N+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(a){for(var b= +0,c=a.count;bthis.determinant()&&(e=-e);a.x=d[12];a.y=d[13];a.z=d[14];U.copy(this);a=1/e;d=1/f;var h=1/g;U.elements[0]*=a;U.elements[1]*=a;U.elements[2]*=a;U.elements[4]*=d;U.elements[5]*=d;U.elements[6]*=d;U.elements[8]*=h;U.elements[9]*=h;U.elements[10]*=h;b.setFromRotationMatrix(U);c.x=e;c.y=f;c.z=g;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),l=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*l;g[9]=0;g[13]=-((c+d)*l);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 ii=new R,ji=new qa;Rb.RotationOrders= +"XYZ YZX ZXY XZY YXZ ZYX".split(" ");Rb.DefaultOrder="XYZ";Object.defineProperties(Rb.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()}},order:{get:function(){return this._order},set:function(a){this._order=a;this._onChangeCallback()}}});Object.assign(Rb.prototype,{isEuler:!0,set:function(a, +b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=O.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],l=e[5],m=e[9],k=e[2],n=e[6];e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.9999999>Math.abs(g)? +(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(n,l),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.9999999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-k,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(n,-1,1)),.9999999>Math.abs(n)?(this._y=Math.atan2(-k,e),this._z=Math.atan2(-f,l)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(k,-1,1)),.9999999>Math.abs(k)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)): +(this._x=0,this._z=Math.atan2(-f,l))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.9999999>Math.abs(h)?(this._x=Math.atan2(-m,l),this._y=Math.atan2(-k,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.9999999>Math.abs(f)?(this._x=Math.atan2(n,l),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;!1!==c&&this._onChangeCallback();return this},setFromQuaternion:function(a, +b,c){ii.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(ii,b,c)},setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(a){ji.setFromEuler(this);return this.setFromQuaternion(ji,a)},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(Nf.prototype,{set:function(a){this.mask=1<e&&(e=m);k>f&&(f=k);n>g&&(g=n)}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,l=a.count;he&&(e=m);k>f&&(f=k);n>g&&(g=n)}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(a){this.clampPoint(a.center,jb);return jb.distanceToSquared(a.center)<=a.radius*a.radius},intersectsPlane:function(a){if(0=-a.constant},intersectsTriangle:function(a){if(this.isEmpty())return!1;this.getCenter(Ae);qf.subVectors(this.max,Ae);pd.subVectors(a.a,Ae);qd.subVectors(a.b,Ae);rd.subVectors(a.c,Ae);Nb.subVectors(qd,pd);Ob.subVectors(rd,qd);sc.subVectors(pd,rd);a=[0,-Nb.z,Nb.y,0,-Ob.z,Ob.y,0,-sc.z, +sc.y,Nb.z,0,-Nb.x,Ob.z,0,-Ob.x,sc.z,0,-sc.x,-Nb.y,Nb.x,0,-Ob.y,Ob.x,0,-sc.y,sc.x,0];if(!Of(a,pd,qd,rd,qf))return!1;a=[1,0,0,0,1,0,0,0,1];if(!Of(a,pd,qd,rd,qf))return!1;rf.crossVectors(Nb,Ob);a=[rf.x,rf.y,rf.z];return Of(a,pd,qd,rd,qf)},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(a){return jb.copy(a).clamp(this.min,this.max).sub(a).length()},getBoundingSphere:function(a){void 0=== +a&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(a.center);a.radius=.5*this.getSize(jb).length();return a},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(a){if(this.isEmpty())return this;xb[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(a);xb[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(a); +xb[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(a);xb[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(a);xb[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(a);xb[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(a);xb[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(a);xb[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(a);this.setFromPoints(xb);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)}});var qk=new ab;Object.assign(nb.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(a,b){var c=this.center;void 0!==b?c.copy(b):qk.setFromPoints(a).getCenter(c);for(var d=b=0,e=a.length;d= +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 ab);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}});var yb=new n,Hg=new n,sf=new n,Pb=new n,Ig=new n,tf=new n,Jg=new n;Object.assign(Tb.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"), +b=new n);return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(a){this.origin.copy(this.at(a,yb));return this},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b=new n);b.subVectors(a,this.origin);a=b.dot(this.direction);return 0>a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))}, +distanceSqToPoint:function(a){var b=yb.subVectors(a,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(a);yb.copy(this.direction).multiplyScalar(b).add(this.origin);return yb.distanceToSquared(a)},distanceSqToSegment:function(a,b,c,d){Hg.copy(a).add(b).multiplyScalar(.5);sf.copy(b).sub(a).normalize();Pb.copy(this.origin).sub(Hg);var e=.5*a.distanceTo(b),f=-this.direction.dot(sf),g=Pb.dot(this.direction),h=-Pb.dot(sf),l=Pb.lengthSq(),m=Math.abs(1-f*f);if(0=-k?b<=k?(e=1/m,a*=e,b*=e,f=a*(a+f*b+2*g)+b*(f*a+b+2*h)+l):(b=e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):(b=-e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):b<=-k?(a=Math.max(0,-(-f*e+g)),b=0a)return null;a=Math.sqrt(a-d);d=c-a;c+=a;return 0>d&&0>c?null:0>d?this.at(c,b):this.at(d,b)},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(a){return null!==this.intersectBox(a,yb)},intersectTriangle:function(a,b,c,d,e){Ig.subVectors(b,a);tf.subVectors(c,a);Jg.crossVectors(Ig,tf);b=this.direction.dot(Jg);if(0b)d=-1,b=-b;else return null; +Pb.subVectors(this.origin,a);a=d*this.direction.dot(tf.crossVectors(Pb,tf));if(0>a)return null;c=d*this.direction.dot(Ig.cross(Pb));if(0>c||a+c>b)return null;a=-d*Pb.dot(Jg);return 0>a?null:this.at(a/b,e)},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)}});var Xa=new n,zb=new n,Kg=new n,Ab=new n,sd=new n,td=new n,oi=new n,Lg=new n,Mg=new n,Ng=new n;Object.assign(sa, +{getNormal:function(a,b,c,d){void 0===d&&(console.warn("THREE.Triangle: .getNormal() target is now required"),d=new n);d.subVectors(c,b);Xa.subVectors(a,b);d.cross(Xa);a=d.lengthSq();return 0=Ab.x+Ab.y},getUV:function(a,b,c,d,e,f,g,h){this.getBarycoord(a,b,c,d,Ab);h.set(0,0);h.addScaledVector(e,Ab.x);h.addScaledVector(f,Ab.y);h.addScaledVector(g,Ab.z);return h},isFrontFacing:function(a,b,c,d){Xa.subVectors(c,b);zb.subVectors(a,b);return 0>Xa.cross(zb).dot(d)?!0:!1}});Object.assign(sa.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(){Xa.subVectors(this.c,this.b);zb.subVectors(this.a,this.b);return.5*Xa.cross(zb).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 sa.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 sa.getBarycoord(a,this.a,this.b,this.c,b)},getUV:function(a,b,c,d,e){return sa.getUV(a,this.a,this.b,this.c,b,c,d,e)},containsPoint:function(a){return sa.containsPoint(a, +this.a,this.b,this.c)},isFrontFacing:function(a){return sa.isFrontFacing(this.a,this.b,this.c,a)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new n);var c=this.a,d=this.b,e=this.c;sd.subVectors(d,c);td.subVectors(e,c);Lg.subVectors(a,c);var f=sd.dot(Lg),g=td.dot(Lg);if(0>=f&&0>=g)return b.copy(c);Mg.subVectors(a,d);var h=sd.dot(Mg),l=td.dot(Mg);if(0<=h&&l<= +h)return b.copy(d);var m=f*l-h*g;if(0>=m&&0<=f&&0>=h)return d=f/(f-h),b.copy(c).addScaledVector(sd,d);Ng.subVectors(a,e);a=sd.dot(Ng);var k=td.dot(Ng);if(0<=k&&a<=k)return b.copy(e);f=a*g-f*k;if(0>=f&&0<=g&&0>=k)return m=g/(g-k),b.copy(c).addScaledVector(td,m);g=h*k-a*l;if(0>=g&&0<=l-h&&0<=a-k)return oi.subVectors(e,d),m=(l-h)/(l-h+(a-k)),b.copy(d).addScaledVector(oi,m);e=1/(g+f+m);d=f*e;m*=e;return b.copy(c).addScaledVector(sd,d).addScaledVector(td,m)},equals:function(a){return a.a.equals(this.a)&& +a.b.equals(this.b)&&a.c.equals(this.c)}});var rk={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},za={h:0,s:0,l:0},uf={h:0,s:0,l:0};Object.assign(J.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(a,b,c){a=O.euclideanModulo(a,1);b=O.clamp(b,0,1);c=O.clamp(c,0,1);0===b?this.r=this.g=this.b=c:(b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=Pf(c,b,a+1/3),this.g=Pf(c,b,a),this.b=Pf(c,b,a-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&&0=h?l/(e+f):l/(2-e-f);switch(e){case b:g=(c- +d)/l+(cthis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;d.stencilWrite=this.stencilWrite;d.stencilFunc= +this.stencilFunc;d.stencilRef=this.stencilRef;d.stencilMask=this.stencilMask;d.stencilFail=this.stencilFail;d.stencilZFail=this.stencilZFail;d.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&1!==this.linewidth&&(d.linewidth=this.linewidth); +void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0g;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;c\n\t#include \n}", +fragmentShader:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}",side:1,blending:0});d.uniforms.tEquirect.value=b;b=new ta(new Cb(5, +5,5),d);c.add(b);d=new Fc(1,10,1);d.renderTarget=this;d.renderTarget.texture.name="CubeCameraTexture";d.update(a,c);b.geometry.dispose();b.material.dispose();return this};$b.prototype=Object.create(ba.prototype);$b.prototype.constructor=$b;$b.prototype.isDataTexture=!0;var Sg=new n,tk=new n,uk=new ja;Object.assign(cb.prototype,{isPlane:!0,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(a,b,c){b=Sg.subVectors(c,b).cross(tk.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(b,a);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(a,b){void 0===b&&(console.warn("THREE.Plane: .intersectLine() target is now required"),b=new n);var c= +a.delta(Sg),d=this.normal.dot(c);if(0===d){if(0===this.distanceToPoint(a.start))return b.copy(a.start)}else if(d=-(a.start.dot(this.normal)+this.constant)/d,!(0>d||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],l=c[6],m=c[7],k=c[8],n=c[9],u=c[10],q=c[11],p=c[12],x=c[13],v=c[14];c=c[15];b[0].setComponents(f-a,m-g,q-k,c-p).normalize();b[1].setComponents(f+a,m+g,q+k,c+p).normalize();b[2].setComponents(f+ +d,m+h,q+n,c+x).normalize();b[3].setComponents(f-d,m-h,q-n,c-x).normalize();b[4].setComponents(f-e,m-l,q-u,c-v).normalize();b[5].setComponents(f+e,m+l,q+u,c+v).normalize();return this},intersectsObject:function(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();ud.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(ud)},intersectsSprite:function(a){ud.center.set(0,0,0);ud.radius=.7071067811865476;ud.applyMatrix4(a.matrixWorld);return this.intersectsSphere(ud)}, +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)c;c++){var d=b[c];xf.x=0d.distanceToPoint(xf))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 N={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}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, 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_RoughnessDependent( specularColor, dotNV, roughness );\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", clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif", clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif", -color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n\tvec3 clearCoatNormal;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}", +color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef PHYSICAL\n\tvec3 clearCoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}", cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif", defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif", emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", @@ -583,15 +583,15 @@ envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif", envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif", envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif", -fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", +fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif", lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif", lights_pars_begin:"uniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif", lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)", lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif", -lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifndef STANDARD\n\t\tfloat ccDotNV = saturate( dot( geometry.clearCoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}", -lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tgeometry.clearCoatNormal = clearCoatNormal;\n#else\n\tgeometry.clearCoatNormal = geometryNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif", -lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif", +lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifdef PHYSICAL\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef PHYSICAL\n\t\tfloat ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef PHYSICAL\n\t\tfloat ccDotNV = saturate( dot( geometry.clearCoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}", +lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef PHYSICAL\n\tgeometry.clearCoatNormal = clearCoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif", +lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifdef PHYSICAL\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif", lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, irradiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n#endif", logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif", map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif", @@ -600,19 +600,18 @@ morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - p normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;", normal_fragment_maps:"#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t#ifdef FLIP_SIDED\n\t\t\tnormal = - normal;\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tnormal = normalize( normalMatrix * normal );\n\t#else\n\t\t#ifdef USE_TANGENT\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\t\tmapN.xy = normalScale * mapN.xy;\n\t\t\tnormal = normalize( vTBN * mapN );\n\t\t#else\n\t\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t\t#endif\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif", normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#endif\n#endif\n#if ( defined ( USE_NORMALMAP ) && !defined ( OBJECTSPACE_NORMALMAP )) || defined ( USE_CLEARCOAT_NORMALMAP )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvec3 NfromST = cross( S, T );\n\t\t\tif( dot( NfromST, N ) > 0.0 ) {\n\t\t\t\tS *= -1.0;\n\t\t\t\tT *= -1.0;\n\t\t\t}\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif", -clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearCoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearCoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearCoatNormalScale * mapN.xy;\n\t\tclearCoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearCoatNormal = perturbNormal2Arb( - vViewPosition, clearCoatNormal, clearCoatNormalScale, clearCoatNormalMap );\n\t#endif\n#endif", +clearcoat_normal_fragment_begin:"#ifdef PHYSICAL\n\tvec3 clearCoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearCoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearCoatNormalScale * mapN.xy;\n\t\tclearCoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearCoatNormal = perturbNormal2Arb( - vViewPosition, clearCoatNormal, clearCoatNormalScale, clearCoatNormalMap );\n\t#endif\n#endif", clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearCoatNormalMap;\n\tuniform vec2 clearCoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}", -premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#if defined( DITHERING )\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif", -roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif", +premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif", +roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif", shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif", shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}", skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif", skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif", specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}", -uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif", -uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif", -uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}", +uv_pars_fragment:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif", +worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}", cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}", depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}", depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", @@ -629,7 +628,7 @@ meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\n meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}", meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}", -meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", +meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef PHYSICAL\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}", meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}", normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) || defined( USE_CLEARCOAT_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}", normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) || defined( USE_CLEARCOAT_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) || defined( USE_CLEARCOAT_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}", @@ -638,235 +637,234 @@ 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}"}, -J={common:{diffuse:{value:new K(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new va},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null}, -normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new K(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{}, +I={common:{diffuse:{value:new J(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new ja},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null}, +normalScale:{value:new z(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new J(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{}, shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}}, -pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new K(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new va}},sprite:{diffuse:{value:new K(15658734)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new va}}}, -lb={basic:{uniforms:Ca([J.common,J.specularmap,J.envmap,J.aomap,J.lightmap,J.fog]),vertexShader:L.meshbasic_vert,fragmentShader:L.meshbasic_frag},lambert:{uniforms:Ca([J.common,J.specularmap,J.envmap,J.aomap,J.lightmap,J.emissivemap,J.fog,J.lights,{emissive:{value:new K(0)}}]),vertexShader:L.meshlambert_vert,fragmentShader:L.meshlambert_frag},phong:{uniforms:Ca([J.common,J.specularmap,J.envmap,J.aomap,J.lightmap,J.emissivemap,J.bumpmap,J.normalmap,J.displacementmap,J.gradientmap,J.fog,J.lights,{emissive:{value:new K(0)}, -specular:{value:new K(1118481)},shininess:{value:30}}]),vertexShader:L.meshphong_vert,fragmentShader:L.meshphong_frag},standard:{uniforms:Ca([J.common,J.envmap,J.aomap,J.lightmap,J.emissivemap,J.bumpmap,J.normalmap,J.displacementmap,J.roughnessmap,J.metalnessmap,J.fog,J.lights,{emissive:{value:new K(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:L.meshphysical_vert,fragmentShader:L.meshphysical_frag},matcap:{uniforms:Ca([J.common,J.bumpmap,J.normalmap,J.displacementmap, -J.fog,{matcap:{value:null}}]),vertexShader:L.meshmatcap_vert,fragmentShader:L.meshmatcap_frag},points:{uniforms:Ca([J.points,J.fog]),vertexShader:L.points_vert,fragmentShader:L.points_frag},dashed:{uniforms:Ca([J.common,J.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:L.linedashed_vert,fragmentShader:L.linedashed_frag},depth:{uniforms:Ca([J.common,J.displacementmap]),vertexShader:L.depth_vert,fragmentShader:L.depth_frag},normal:{uniforms:Ca([J.common,J.bumpmap,J.normalmap, -J.displacementmap,{opacity:{value:1}}]),vertexShader:L.normal_vert,fragmentShader:L.normal_frag},sprite:{uniforms:Ca([J.sprite,J.fog]),vertexShader:L.sprite_vert,fragmentShader:L.sprite_frag},background:{uniforms:{uvTransform:{value:new va},t2D:{value:null}},vertexShader:L.background_vert,fragmentShader:L.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:L.cube_vert,fragmentShader:L.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:L.equirect_vert, -fragmentShader:L.equirect_frag},distanceRGBA:{uniforms:Ca([J.common,J.displacementmap,{referencePosition:{value:new n},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:L.distanceRGBA_vert,fragmentShader:L.distanceRGBA_frag},shadow:{uniforms:Ca([J.lights,J.fog,{color:{value:new K(0)},opacity:{value:1}}]),vertexShader:L.shadow_vert,fragmentShader:L.shadow_frag}};lb.physical={uniforms:Ca([lb.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0},clearCoatNormalScale:{value:new z(1, -1)},clearCoatNormalMap:{value:null}}]),vertexShader:L.meshphysical_vert,fragmentShader:L.meshphysical_frag};Pd.prototype=Object.create(F.prototype);Pd.prototype.constructor=Pd;jc.prototype=Object.create(D.prototype);jc.prototype.constructor=jc;vb.prototype=Object.create(Y.prototype);vb.prototype.constructor=vb;vb.prototype.isCubeTexture=!0;Object.defineProperty(vb.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Qc.prototype=Object.create(Y.prototype);Qc.prototype.constructor= -Qc;Qc.prototype.isDataTexture2DArray=!0;Rc.prototype=Object.create(Y.prototype);Rc.prototype.constructor=Rc;Rc.prototype.isDataTexture3D=!0;var Ch=new Y,$i=new Qc,bj=new Rc,Dh=new vb,wh=[],yh=[],Bh=new Float32Array(16),Ah=new Float32Array(9),zh=new Float32Array(4);Eh.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Ma(b,a)};Fh.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==f;++e){var g= -d[e];g.setValue(a,b[g.id],c)}};var og=/([\w\d_]+)(\])?(\[|\.)?/g;Mb.prototype.setValue=function(a,b,c,d){b=this.map[b];void 0!==b&&b.setValue(a,c,d)};Mb.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Mb.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Mb.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var Cj=0,Lj=0;Nb.prototype=Object.create(R.prototype); -Nb.prototype.constructor=Nb;Nb.prototype.isMeshDepthMaterial=!0;Nb.prototype.copy=function(a){R.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};Ob.prototype=Object.create(R.prototype); -Ob.prototype.constructor=Ob;Ob.prototype.isMeshDistanceMaterial=!0;Ob.prototype.copy=function(a){R.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;return this};Tc.prototype=Object.assign(Object.create(C.prototype), -{constructor:Tc,isGroup:!0});Sd.prototype=Object.assign(Object.create(na.prototype),{constructor:Sd,isArrayCamera:!0});var Sh=new n,Th=new n;Object.assign(rg.prototype,la.prototype);Object.assign(Uh.prototype,la.prototype);Object.assign(ef.prototype,{isFogExp2:!0,clone:function(){return new ef(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});Object.assign(ff.prototype,{isFog:!0,clone:function(){return new ff(this.color,this.near, -this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});Object.defineProperty(kc.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(kc.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(a){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==a?a.length/this.stride:0;this.array=a;return this},setDynamic:function(a){this.dynamic= -a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;da.far||b.push({distance:e,point:Cd.clone(),uv:U.getUV(Cd,Oe,Dd,Pe,bh,Qf, -Rf,new z),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}});var Hc,Sf;Vd.prototype=Object.assign(Object.create(C.prototype),{constructor:Vd,isLOD:!0,copy:function(a){C.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=b[c].distance)b[c-1].object.visible=!1,b[c].object.visible=!0;else break;for(;cc||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}}else for(d=0,t=k.length/3-1;dc||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u, -point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}else if(d.isGeometry)for(f=d.vertices,g=f.length,d=0;dc||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var Re,Ed; -aa.prototype=Object.assign(Object.create(xa.prototype),{constructor:aa,isLineSegments:!0,computeLineDistances:function(){void 0===Ed&&(Re=new n,Ed=new n);var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[],d=0,e=b.count;da.far||b.push({distance:c,distanceToRay:Math.sqrt(g),point:l.clone(),index:e,face:null,object:d}))}void 0===Jc&&(gh=new Q,Uf=new bc,Jc=new ib);var d=this,e=this.geometry,f=this.matrixWorld, -g=a.params.Points.threshold;null===e.boundingSphere&&e.computeBoundingSphere();Jc.copy(e.boundingSphere);Jc.applyMatrix4(f);Jc.radius+=g;if(!1!==a.ray.intersectsSphere(Jc)){gh.getInverse(f);Uf.copy(a.ray).applyMatrix4(gh);g/=(this.scale.x+this.scale.y+this.scale.z)/3;var h=g*g;g=new n;var l=new n;if(e.isBufferGeometry){var m=e.index;e=e.attributes.position.array;if(null!==m){var k=m.array;m=0;for(var t=k.length;m=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Xc.prototype=Object.create(Y.prototype);Xc.prototype.constructor=Xc;Xc.prototype.isCompressedTexture=!0;Xd.prototype=Object.create(Y.prototype);Xd.prototype.constructor=Xd;Xd.prototype.isCanvasTexture=!0;Yd.prototype=Object.create(Y.prototype); -Yd.prototype.constructor=Yd;Yd.prototype.isDepthTexture=!0;Yc.prototype=Object.create(D.prototype);Yc.prototype.constructor=Yc;Zd.prototype=Object.create(F.prototype);Zd.prototype.constructor=Zd;Zc.prototype=Object.create(D.prototype);Zc.prototype.constructor=Zc;$d.prototype=Object.create(F.prototype);$d.prototype.constructor=$d;ya.prototype=Object.create(D.prototype);ya.prototype.constructor=ya;ae.prototype=Object.create(F.prototype);ae.prototype.constructor=ae;$c.prototype=Object.create(ya.prototype); -$c.prototype.constructor=$c;be.prototype=Object.create(F.prototype);be.prototype.constructor=be;mc.prototype=Object.create(ya.prototype);mc.prototype.constructor=mc;ce.prototype=Object.create(F.prototype);ce.prototype.constructor=ce;ad.prototype=Object.create(ya.prototype);ad.prototype.constructor=ad;de.prototype=Object.create(F.prototype);de.prototype.constructor=de;bd.prototype=Object.create(ya.prototype);bd.prototype.constructor=bd;ee.prototype=Object.create(F.prototype);ee.prototype.constructor= -ee;nc.prototype=Object.create(D.prototype);nc.prototype.constructor=nc;nc.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();return a};fe.prototype=Object.create(F.prototype);fe.prototype.constructor=fe;cd.prototype=Object.create(D.prototype);cd.prototype.constructor=cd;ge.prototype=Object.create(F.prototype);ge.prototype.constructor=ge;dd.prototype=Object.create(D.prototype);dd.prototype.constructor=dd;var Yj={triangulate:function(a,b,c){c=c||2;var d= -b&&b.length,e=d?b[0]*c:a.length,f=Wh(a,0,e,c,!0),g=[];if(!f||f.next===f.prev)return g;var h;if(d){var l=c;d=[];var m;var k=0;for(m=b.length;k80*c){var r=h=a[0];var q=d=a[1];for(l=c;lh&&(h=k),b>d&&(d=b);h=Math.max(h-r,d-q);h=0!==h?1/h: -0}je(f,g,c,r,q,h);return g}},wb={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;ewb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];$h(a);ai(c,a);var f=a.length;b.forEach($h);for(a=0;aMath.abs(g-l)?[new z(a,1-c),new z(h,1-d),new z(m,1-e),new z(n,1-b)]:[new z(g,1-c),new z(l,1-d),new z(k,1-e),new z(u,1-b)]}};le.prototype=Object.create(F.prototype);le.prototype.constructor=le;fd.prototype=Object.create(mb.prototype);fd.prototype.constructor=fd;me.prototype=Object.create(F.prototype);me.prototype.constructor=me;Rb.prototype=Object.create(D.prototype);Rb.prototype.constructor= -Rb;ne.prototype=Object.create(F.prototype);ne.prototype.constructor=ne;gd.prototype=Object.create(D.prototype);gd.prototype.constructor=gd;oe.prototype=Object.create(F.prototype);oe.prototype.constructor=oe;hd.prototype=Object.create(D.prototype);hd.prototype.constructor=hd;qc.prototype=Object.create(F.prototype);qc.prototype.constructor=qc;qc.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);return ci(this.parameters.shapes,a)};rc.prototype=Object.create(D.prototype);rc.prototype.constructor= -rc;rc.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);return ci(this.parameters.shapes,a)};id.prototype=Object.create(D.prototype);id.prototype.constructor=id;sc.prototype=Object.create(F.prototype);sc.prototype.constructor=sc;xb.prototype=Object.create(D.prototype);xb.prototype.constructor=xb;pe.prototype=Object.create(sc.prototype);pe.prototype.constructor=pe;qe.prototype=Object.create(xb.prototype);qe.prototype.constructor=qe;re.prototype=Object.create(F.prototype);re.prototype.constructor= -re;jd.prototype=Object.create(D.prototype);jd.prototype.constructor=jd;var Da=Object.freeze({WireframeGeometry:Yc,ParametricGeometry:Zd,ParametricBufferGeometry:Zc,TetrahedronGeometry:ae,TetrahedronBufferGeometry:$c,OctahedronGeometry:be,OctahedronBufferGeometry:mc,IcosahedronGeometry:ce,IcosahedronBufferGeometry:ad,DodecahedronGeometry:de,DodecahedronBufferGeometry:bd,PolyhedronGeometry:$d,PolyhedronBufferGeometry:ya,TubeGeometry:ee,TubeBufferGeometry:nc,TorusKnotGeometry:fe,TorusKnotBufferGeometry:cd, -TorusGeometry:ge,TorusBufferGeometry:dd,TextGeometry:le,TextBufferGeometry:fd,SphereGeometry:me,SphereBufferGeometry:Rb,RingGeometry:ne,RingBufferGeometry:gd,PlaneGeometry:Pd,PlaneBufferGeometry:jc,LatheGeometry:oe,LatheBufferGeometry:hd,ShapeGeometry:qc,ShapeBufferGeometry:rc,ExtrudeGeometry:pc,ExtrudeBufferGeometry:mb,EdgesGeometry:id,ConeGeometry:pe,ConeBufferGeometry:qe,CylinderGeometry:sc,CylinderBufferGeometry:xb,CircleGeometry:re,CircleBufferGeometry:jd,BoxGeometry:Oc,BoxBufferGeometry:Kb}); -tc.prototype=Object.create(R.prototype);tc.prototype.constructor=tc;tc.prototype.isShadowMaterial=!0;tc.prototype.copy=function(a){R.prototype.copy.call(this,a);this.color.copy(a.color);return this};kd.prototype=Object.create(ma.prototype);kd.prototype.constructor=kd;kd.prototype.isRawShaderMaterial=!0;nb.prototype=Object.create(R.prototype);nb.prototype.constructor=nb;nb.prototype.isMeshStandardMaterial=!0;nb.prototype.copy=function(a){R.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}; -uc.prototype=Object.create(nb.prototype);uc.prototype.constructor=uc;uc.prototype.isMeshPhysicalMaterial=!0;uc.prototype.copy=function(a){nb.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;this.clearCoatNormalMap=a.clearCoatNormalMap;this.clearCoatNormalScale.copy(a.clearCoatNormalScale);return this};Wa.prototype=Object.create(R.prototype);Wa.prototype.constructor=Wa;Wa.prototype.isMeshPhongMaterial= -!0;Wa.prototype.copy=function(a){R.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};vc.prototype=Object.create(Wa.prototype);vc.prototype.constructor=vc;vc.prototype.isMeshToonMaterial=!0;vc.prototype.copy=function(a){Wa.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;return this};wc.prototype=Object.create(R.prototype);wc.prototype.constructor=wc;wc.prototype.isMeshNormalMaterial=!0;wc.prototype.copy=function(a){R.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};xc.prototype=Object.create(R.prototype);xc.prototype.constructor=xc;xc.prototype.isMeshLambertMaterial= -!0;xc.prototype.copy=function(a){R.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};yc.prototype=Object.create(R.prototype);yc.prototype.constructor=yc;yc.prototype.isMeshMatcapMaterial=!0;yc.prototype.copy=function(a){R.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};zc.prototype=Object.create(ba.prototype);zc.prototype.constructor=zc;zc.prototype.isLineDashedMaterial= -!0;zc.prototype.copy=function(a){ba.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Zj=Object.freeze({ShadowMaterial:tc,SpriteMaterial:Qb,RawShaderMaterial:kd,ShaderMaterial:ma,PointsMaterial:Va,MeshPhysicalMaterial:uc,MeshStandardMaterial:nb,MeshPhongMaterial:Wa,MeshToonMaterial:vc,MeshNormalMaterial:wc,MeshLambertMaterial:xc,MeshDepthMaterial:Nb,MeshDistanceMaterial:Ob,MeshBasicMaterial:Ka,MeshMatcapMaterial:yc,LineDashedMaterial:zc, -LineBasicMaterial:ba,Material:R}),ha={arraySlice:function(a,b,c){return ha.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,l=0;l!==b;++l)e[g++]=a[h+l];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(Na.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=ha.arraySlice(c,e,f),this.values=ha.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&&ha.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(P.clamp(d[l-1].dot(d[l]),-1,1)),e[l].applyMatrix4(h.makeRotationAxis(g,c))),f[l].crossVectors(d[l],e[l]);if(!0=== -b)for(c=Math.acos(P.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>l&&(l=e);hh.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,l);ih.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,l);jh.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,l)}else"catmullrom"===this.curveType&& -(hh.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),ih.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),jh.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(hh.calc(a),ih.calc(a),jh.calc(a));return b};pa.prototype.copy=function(a){H.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(fi(d,e.x,f.x,g.x,c.x),fi(d,e.y,f.y,g.y,c.y));return b};ab.prototype.copy=function(a){H.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>k&&(g=b[f],l=-l,h=b[e],k=-k),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=k*(a.x-g.x)-l*(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=wb.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 Sb;h.curves=g.curves; -b.push(h);return b}var l=!e(f[0].getPoints());l=a?!l:l;h=[];var k=[],n=[],t=0;k[t]=void 0;n[t]=[];for(var u=0,r=f.length;uk.opacity&&(k.transparent=!0);d.setTextures(l);return d.parse(k)}}()});var Wf,Mg={getContext:function(){void 0===Wf&&(Wf=new (window.AudioContext||window.webkitAudioContext));return Wf},setContext:function(a){Wf=a}};Object.assign(Hg.prototype,{load:function(a,b,c,d){var e=new Xa(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);Mg.getContext().decodeAudioData(a,function(a){b(a)})}, -c,d)},setPath:function(a){this.path=a;return this}});Object.assign(Cf.prototype,{isSphericalHarmonics3:!0,set:function(a){for(var b=0;9>b;b++)this.coefficients[b].copy(a[b]);return this},zero:function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this},getAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.282095);b.addScale(e[1],.488603*d);b.addScale(e[2],.488603*a);b.addScale(e[3],.488603*c);b.addScale(e[4],1.092548*c*d);b.addScale(e[5],1.092548* -d*a);b.addScale(e[6],.315392*(3*a*a-1));b.addScale(e[7],1.092548*c*a);b.addScale(e[8],.546274*(c*c-d*d));return b},getIrradianceAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.886227);b.addScale(e[1],1.023328*d);b.addScale(e[2],1.023328*a);b.addScale(e[3],1.023328*c);b.addScale(e[4],.858086*c*d);b.addScale(e[5],.858086*d*a);b.addScale(e[6],.743125*a*a-.247708);b.addScale(e[7],.858086*c*a);b.addScale(e[8],.429043*(c*c-d*d));return b},add:function(a){for(var b= -0;9>b;b++)this.coefficients[b].add(a.coefficients[b]);return this},scale:function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a);return this},lerp:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].lerp(a.coefficients[c],b);return this},equals:function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0},copy:function(a){return this.set(a.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(a){for(var b= -this.coefficients,c=0;9>c;c++)b[c].fromArray(a,3*c);return this},toArray:function(){for(var a=[],b=this.coefficients,c=0;9>c;c++)b[c].toArray(a,3*c);return a}});Object.assign(Cf,{getBasisAt:function(a,b){var c=a.x,d=a.y;a=a.z;b[0]=.282095;b[1]=.488603*d;b[2]=.488603*a;b[3]=.488603*c;b[4]=1.092548*c*d;b[5]=1.092548*d*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*c*a;b[8]=.546274*(c*c-d*d)}});cb.prototype=Object.assign(Object.create(T.prototype),{constructor:cb,isLightProbe:!0,copy:function(a){T.prototype.copy.call(this, -a);this.sh.copy(a.sh);this.intensity=a.intensity;return this},toJSON:function(a){return T.prototype.toJSON.call(this,a)}});Ig.prototype=Object.assign(Object.create(cb.prototype),{constructor:Ig,isHemisphereLightProbe:!0,copy:function(a){cb.prototype.copy.call(this,a);return this},toJSON:function(a){return cb.prototype.toJSON.call(this,a)}});Jg.prototype=Object.assign(Object.create(cb.prototype),{constructor:Jg,isAmbientLightProbe:!0,copy:function(a){cb.prototype.copy.call(this,a);return this},toJSON:function(a){return cb.prototype.toJSON.call(this, -a)}});var Xf,nh;Object.assign(hi.prototype,{update:function(a){void 0===Xf&&(Xf=new Q,nh=new Q);var b=this._cache;if(b.focus!==a.focus||b.fov!==a.fov||b.aspect!==a.aspect*this.aspect||b.near!==a.near||b.far!==a.far||b.zoom!==a.zoom||b.eyeSep!==this.eyeSep){b.focus=a.focus;b.fov=a.fov;b.aspect=a.aspect*this.aspect;b.near=a.near;b.far=a.far;b.zoom=a.zoom;b.eyeSep=this.eyeSep;var c=a.projectionMatrix.clone(),d=b.eyeSep/2,e=d*b.near/b.focus,f=b.near*Math.tan(P.DEG2RAD*b.fov*.5)/b.zoom;nh.elements[12]= --d;Xf.elements[12]=d;d=-f*b.aspect+e;var g=f*b.aspect+e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraL.projectionMatrix.copy(c);d=-f*b.aspect-e;g=f*b.aspect-e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraR.projectionMatrix.copy(c)}this.cameraL.matrixWorld.copy(a.matrixWorld).multiply(nh);this.cameraR.matrixWorld.copy(a.matrixWorld).multiply(Xf)}});Object.assign(Kg.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}});var Eb,oh,wi,Zb;Lg.prototype=Object.assign(Object.create(C.prototype),{constructor:Lg, -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(a){C.prototype.updateMatrixWorld.call(this,a);void 0===Eb&&(Eb=new n,oh=new ta,wi=new n,Zb=new n);a=this.context.listener;var b=this.up;this.timeDelta=this._clock.getDelta();this.matrixWorld.decompose(Eb,oh,wi);Zb.set(0,0,-1).applyQuaternion(oh);if(a.positionX){var c=this.context.currentTime+this.timeDelta; -a.positionX.linearRampToValueAtTime(Eb.x,c);a.positionY.linearRampToValueAtTime(Eb.y,c);a.positionZ.linearRampToValueAtTime(Eb.z,c);a.forwardX.linearRampToValueAtTime(Zb.x,c);a.forwardY.linearRampToValueAtTime(Zb.y,c);a.forwardZ.linearRampToValueAtTime(Zb.z,c);a.upX.linearRampToValueAtTime(b.x,c);a.upY.linearRampToValueAtTime(b.y,c);a.upZ.linearRampToValueAtTime(b.z,c)}else a.setPosition(Eb.x,Eb.y,Eb.z),a.setOrientation(Zb.x,Zb.y,Zb.z,b.x,b.y,b.z)}});od.prototype=Object.assign(Object.create(C.prototype), -{constructor:od,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."); +pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new J(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new ja}},sprite:{diffuse:{value:new J(15658734)},opacity:{value:1},center:{value:new z(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new ja}}}, +db={basic:{uniforms:Ca([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.fog]),vertexShader:N.meshbasic_vert,fragmentShader:N.meshbasic_frag},lambert:{uniforms:Ca([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.fog,I.lights,{emissive:{value:new J(0)}}]),vertexShader:N.meshlambert_vert,fragmentShader:N.meshlambert_frag},phong:{uniforms:Ca([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.gradientmap,I.fog,I.lights,{emissive:{value:new J(0)}, +specular:{value:new J(1118481)},shininess:{value:30}}]),vertexShader:N.meshphong_vert,fragmentShader:N.meshphong_frag},standard:{uniforms:Ca([I.common,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.roughnessmap,I.metalnessmap,I.fog,I.lights,{emissive:{value:new J(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:N.meshphysical_vert,fragmentShader:N.meshphysical_frag},matcap:{uniforms:Ca([I.common,I.bumpmap,I.normalmap,I.displacementmap, +I.fog,{matcap:{value:null}}]),vertexShader:N.meshmatcap_vert,fragmentShader:N.meshmatcap_frag},points:{uniforms:Ca([I.points,I.fog]),vertexShader:N.points_vert,fragmentShader:N.points_frag},dashed:{uniforms:Ca([I.common,I.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:N.linedashed_vert,fragmentShader:N.linedashed_frag},depth:{uniforms:Ca([I.common,I.displacementmap]),vertexShader:N.depth_vert,fragmentShader:N.depth_frag},normal:{uniforms:Ca([I.common,I.bumpmap,I.normalmap, +I.displacementmap,{opacity:{value:1}}]),vertexShader:N.normal_vert,fragmentShader:N.normal_frag},sprite:{uniforms:Ca([I.sprite,I.fog]),vertexShader:N.sprite_vert,fragmentShader:N.sprite_frag},background:{uniforms:{uvTransform:{value:new ja},t2D:{value:null}},vertexShader:N.background_vert,fragmentShader:N.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:N.cube_vert,fragmentShader:N.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:N.equirect_vert, +fragmentShader:N.equirect_frag},distanceRGBA:{uniforms:Ca([I.common,I.displacementmap,{referencePosition:{value:new n},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:N.distanceRGBA_vert,fragmentShader:N.distanceRGBA_frag},shadow:{uniforms:Ca([I.lights,I.fog,{color:{value:new J(0)},opacity:{value:1}}]),vertexShader:N.shadow_vert,fragmentShader:N.shadow_frag}};db.physical={uniforms:Ca([db.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0},clearCoatNormalScale:{value:new z(1, +1)},clearCoatNormalMap:{value:null}}]),vertexShader:N.meshphysical_vert,fragmentShader:N.meshphysical_frag};Fd.prototype=Object.create(E.prototype);Fd.prototype.constructor=Fd;ac.prototype=Object.create(C.prototype);ac.prototype.constructor=ac;qb.prototype=Object.create(ba.prototype);qb.prototype.constructor=qb;qb.prototype.isCubeTexture=!0;Object.defineProperty(qb.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Gc.prototype=Object.create(ba.prototype);Gc.prototype.constructor= +Gc;Gc.prototype.isDataTexture2DArray=!0;Hc.prototype=Object.create(ba.prototype);Hc.prototype.constructor=Hc;Hc.prototype.isDataTexture3D=!0;var ph=new ba,nj=new Gc,pj=new Hc,qh=new qb,jh=[],lh=[],oh=new Float32Array(16),nh=new Float32Array(9),mh=new Float32Array(4);rh.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Ga(b,a)};sh.prototype.setValue=function(a,b,c){for(var d=this.seq,e=0,f=d.length;e!==f;++e){var g= +d[e];g.setValue(a,b[g.id],c)}};var Xf=/([\w\d_]+)(\])?(\[|\.)?/g;Eb.prototype.setValue=function(a,b,c,d){b=this.map[b];void 0!==b&&b.setValue(a,c,d)};Eb.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Eb.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Eb.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var Qj=0,Zj=0;Fb.prototype=Object.create(P.prototype); +Fb.prototype.constructor=Fb;Fb.prototype.isMeshDepthMaterial=!0;Fb.prototype.copy=function(a){P.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};Gb.prototype=Object.create(P.prototype); +Gb.prototype.constructor=Gb;Gb.prototype.isMeshDistanceMaterial=!0;Gb.prototype.copy=function(a){P.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;return this};Jc.prototype=Object.assign(Object.create(D.prototype), +{constructor:Jc,isGroup:!0});Jd.prototype=Object.assign(Object.create(W.prototype),{constructor:Jd,isArrayCamera:!0});var Fh=new n,Gh=new n;Object.assign($f.prototype,ra.prototype);Object.assign(Hh.prototype,ra.prototype);Object.assign(Le.prototype,{isFogExp2:!0,clone:function(){return new Le(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});Object.assign(Me.prototype,{isFog:!0,clone:function(){return new Me(this.color,this.near,this.far)}, +toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});Object.defineProperty(bc.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(bc.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setArray:function(a){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==a?a.length/this.stride:0;this.array=a;return this},setDynamic:function(a){this.dynamic=a;return this}, +copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;da.far||b.push({distance:e,point:Be.clone(),uv:sa.getUV(Be, +yf,Ce,zf,qi,Tg,ri,new z),face:null,object:this})},clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){D.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});var Af=new n,si=new n;Nd.prototype=Object.assign(Object.create(D.prototype),{constructor:Nd,isLOD:!0,copy:function(a){D.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=b[c].distance)b[c-1].object.visible=!1,b[c].object.visible=!0;else break;for(;cc||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}}else for(d=0,r=k.length/3-1;dc||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null, +object:this}))}else if(d.isGeometry)for(f=d.vertices,g=f.length,d=0;dc||(h.applyMatrix4(this.matrixWorld),u=a.ray.origin.distanceTo(h),ua.far||b.push({distance:u,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var Cf=new n,Df=new n;T.prototype=Object.assign(Object.create(Y.prototype),{constructor:T, +isLineSegments:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[],d=0,e=b.count;d=a.HAVE_CURRENT_DATA&& +(this.needsUpdate=!0)}});Nc.prototype=Object.create(ba.prototype);Nc.prototype.constructor=Nc;Nc.prototype.isCompressedTexture=!0;Pd.prototype=Object.create(ba.prototype);Pd.prototype.constructor=Pd;Pd.prototype.isCanvasTexture=!0;Qd.prototype=Object.create(ba.prototype);Qd.prototype.constructor=Qd;Qd.prototype.isDepthTexture=!0;Oc.prototype=Object.create(C.prototype);Oc.prototype.constructor=Oc;Rd.prototype=Object.create(E.prototype);Rd.prototype.constructor=Rd;Pc.prototype=Object.create(C.prototype); +Pc.prototype.constructor=Pc;Sd.prototype=Object.create(E.prototype);Sd.prototype.constructor=Sd;ka.prototype=Object.create(C.prototype);ka.prototype.constructor=ka;Td.prototype=Object.create(E.prototype);Td.prototype.constructor=Td;Qc.prototype=Object.create(ka.prototype);Qc.prototype.constructor=Qc;Ud.prototype=Object.create(E.prototype);Ud.prototype.constructor=Ud;cc.prototype=Object.create(ka.prototype);cc.prototype.constructor=cc;Vd.prototype=Object.create(E.prototype);Vd.prototype.constructor= +Vd;Rc.prototype=Object.create(ka.prototype);Rc.prototype.constructor=Rc;Wd.prototype=Object.create(E.prototype);Wd.prototype.constructor=Wd;Sc.prototype=Object.create(ka.prototype);Sc.prototype.constructor=Sc;Xd.prototype=Object.create(E.prototype);Xd.prototype.constructor=Xd;dc.prototype=Object.create(C.prototype);dc.prototype.constructor=dc;dc.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();return a};Yd.prototype=Object.create(E.prototype);Yd.prototype.constructor= +Yd;Tc.prototype=Object.create(C.prototype);Tc.prototype.constructor=Tc;Zd.prototype=Object.create(E.prototype);Zd.prototype.constructor=Zd;Uc.prototype=Object.create(C.prototype);Uc.prototype.constructor=Uc;var wk={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=Kh(a,0,e,c,!0),g=[];if(!f||f.next===f.prev)return g;var h;if(d){var l=c;d=[];var k;var n=0;for(k=b.length;n80*c){var q=h=a[0];var p=d=a[1];for(l=c;lh&&(h=n),b>d&&(d=b);h=Math.max(h-q,d-p);h=0!==h?1/h:0}be(f,g,c,q,p,h);return g}},rb={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;erb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];Oh(a);Ph(c,a);var f=a.length;b.forEach(Oh); +for(a=0;aMath.abs(g-l)?[new z(a,1-c),new z(h,1-d),new z(k,1-e),new z(r,1-b)]:[new z(g,1-c),new z(l,1-d),new z(n,1-e),new z(u,1-b)]}};de.prototype=Object.create(E.prototype); +de.prototype.constructor=de;Wc.prototype=Object.create(eb.prototype);Wc.prototype.constructor=Wc;ee.prototype=Object.create(E.prototype);ee.prototype.constructor=ee;Jb.prototype=Object.create(C.prototype);Jb.prototype.constructor=Jb;fe.prototype=Object.create(E.prototype);fe.prototype.constructor=fe;Xc.prototype=Object.create(C.prototype);Xc.prototype.constructor=Xc;ge.prototype=Object.create(E.prototype);ge.prototype.constructor=ge;Yc.prototype=Object.create(C.prototype);Yc.prototype.constructor= +Yc;gc.prototype=Object.create(E.prototype);gc.prototype.constructor=gc;gc.prototype.toJSON=function(){var a=E.prototype.toJSON.call(this);return Rh(this.parameters.shapes,a)};hc.prototype=Object.create(C.prototype);hc.prototype.constructor=hc;hc.prototype.toJSON=function(){var a=C.prototype.toJSON.call(this);return Rh(this.parameters.shapes,a)};Zc.prototype=Object.create(C.prototype);Zc.prototype.constructor=Zc;ic.prototype=Object.create(E.prototype);ic.prototype.constructor=ic;sb.prototype=Object.create(C.prototype); +sb.prototype.constructor=sb;he.prototype=Object.create(ic.prototype);he.prototype.constructor=he;ie.prototype=Object.create(sb.prototype);ie.prototype.constructor=ie;je.prototype=Object.create(E.prototype);je.prototype.constructor=je;$c.prototype=Object.create(C.prototype);$c.prototype.constructor=$c;var Aa=Object.freeze({WireframeGeometry:Oc,ParametricGeometry:Rd,ParametricBufferGeometry:Pc,TetrahedronGeometry:Td,TetrahedronBufferGeometry:Qc,OctahedronGeometry:Ud,OctahedronBufferGeometry:cc,IcosahedronGeometry:Vd, +IcosahedronBufferGeometry:Rc,DodecahedronGeometry:Wd,DodecahedronBufferGeometry:Sc,PolyhedronGeometry:Sd,PolyhedronBufferGeometry:ka,TubeGeometry:Xd,TubeBufferGeometry:dc,TorusKnotGeometry:Yd,TorusKnotBufferGeometry:Tc,TorusGeometry:Zd,TorusBufferGeometry:Uc,TextGeometry:de,TextBufferGeometry:Wc,SphereGeometry:ee,SphereBufferGeometry:Jb,RingGeometry:fe,RingBufferGeometry:Xc,PlaneGeometry:Fd,PlaneBufferGeometry:ac,LatheGeometry:ge,LatheBufferGeometry:Yc,ShapeGeometry:gc,ShapeBufferGeometry:hc,ExtrudeGeometry:fc, +ExtrudeBufferGeometry:eb,EdgesGeometry:Zc,ConeGeometry:he,ConeBufferGeometry:ie,CylinderGeometry:ic,CylinderBufferGeometry:sb,CircleGeometry:je,CircleBufferGeometry:$c,BoxGeometry:Ec,BoxBufferGeometry:Cb});jc.prototype=Object.create(P.prototype);jc.prototype.constructor=jc;jc.prototype.isShadowMaterial=!0;jc.prototype.copy=function(a){P.prototype.copy.call(this,a);this.color.copy(a.color);return this};ad.prototype=Object.create(ma.prototype);ad.prototype.constructor=ad;ad.prototype.isRawShaderMaterial= +!0;fb.prototype=Object.create(P.prototype);fb.prototype.constructor=fb;fb.prototype.isMeshStandardMaterial=!0;fb.prototype.copy=function(a){P.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};kc.prototype=Object.create(fb.prototype);kc.prototype.constructor=kc;kc.prototype.isMeshPhysicalMaterial=!0;kc.prototype.copy=function(a){fb.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness; +this.clearCoatNormalMap=a.clearCoatNormalMap;this.clearCoatNormalScale.copy(a.clearCoatNormalScale);return this};Pa.prototype=Object.create(P.prototype);Pa.prototype.constructor=Pa;Pa.prototype.isMeshPhongMaterial=!0;Pa.prototype.copy=function(a){P.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};lc.prototype=Object.create(Pa.prototype);lc.prototype.constructor=lc;lc.prototype.isMeshToonMaterial=!0;lc.prototype.copy=function(a){Pa.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;return this};mc.prototype=Object.create(P.prototype); +mc.prototype.constructor=mc;mc.prototype.isMeshNormalMaterial=!0;mc.prototype.copy=function(a){P.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};nc.prototype=Object.create(P.prototype);nc.prototype.constructor=nc;nc.prototype.isMeshLambertMaterial=!0;nc.prototype.copy=function(a){P.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};oc.prototype=Object.create(P.prototype);oc.prototype.constructor=oc;oc.prototype.isMeshMatcapMaterial= +!0;oc.prototype.copy=function(a){P.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};pc.prototype=Object.create(Q.prototype);pc.prototype.constructor=pc;pc.prototype.isLineDashedMaterial=!0;pc.prototype.copy=function(a){Q.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var xk=Object.freeze({ShadowMaterial:jc,SpriteMaterial:Ib,RawShaderMaterial:ad,ShaderMaterial:ma,PointsMaterial:Oa,MeshPhysicalMaterial:kc,MeshStandardMaterial:fb,MeshPhongMaterial:Pa,MeshToonMaterial:lc,MeshNormalMaterial:mc, +MeshLambertMaterial:nc,MeshDepthMaterial:Fb,MeshDistanceMaterial:Gb,MeshBasicMaterial:xa,MeshMatcapMaterial:oc,LineDashedMaterial:pc,LineBasicMaterial:Q,Material:P}),fa={arraySlice:function(a,b,c){return fa.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,l=0;l!==b;++l)e[g++]=a[h+l];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(Ha.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=fa.arraySlice(c,e,f),this.values=fa.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&&fa.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(O.clamp(d[l-1].dot(d[l]),-1,1)),e[l].applyMatrix4(h.makeRotationAxis(g,c))),f[l].crossVectors(d[l],e[l]);if(!0===b)for(c=Math.acos(O.clamp(e[0].dot(e[a]),-1,1)),c/=a,0 +d;)d+=c;for(;d>c;)d-=c;de&&(e=1);1E-4>d&&(d=e);1E-4>l&&(l=e);Ug.initNonuniformCatmullRom(f.x, +g.x,h.x,c.x,d,e,l);Vg.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,l);Wg.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,l)}else"catmullrom"===this.curveType&&(Ug.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),Vg.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),Wg.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(Ug.calc(a),Vg.calc(a),Wg.calc(a));return b};pa.prototype.copy=function(a){G.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(Uh(d,e.x,f.x,g.x,c.x),Uh(d,e.y,f.y,g.y,c.y));return b};Ua.prototype.copy=function(a){G.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>k&&(g=b[f],l=-l,h=b[e],k=-k),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e= +k*(a.x-g.x)-l*(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=rb.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 l=!e(f[0].getPoints());l=a?!l:l;h=[];var k=[],n=[],r=0;k[r]=void 0;n[r]=[];for(var u=0,q=f.length;ue.opacity&&(e.transparent=!0);Ai.setTextures(d);return Ai.parse(e)}});var Gf,vg={getContext:function(){void 0===Gf&&(Gf=new (window.AudioContext||window.webkitAudioContext));return Gf},setContext:function(a){Gf=a}};Object.assign(qg.prototype,{load:function(a,b,c,d){var e=new Qa(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);vg.getContext().decodeAudioData(a,function(a){b(a)})},c,d)},setPath:function(a){this.path=a; +return this}});Object.assign(hf.prototype,{isSphericalHarmonics3:!0,set:function(a){for(var b=0;9>b;b++)this.coefficients[b].copy(a[b]);return this},zero:function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this},getAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.282095);b.addScale(e[1],.488603*d);b.addScale(e[2],.488603*a);b.addScale(e[3],.488603*c);b.addScale(e[4],1.092548*c*d);b.addScale(e[5],1.092548*d*a);b.addScale(e[6],.315392*(3* +a*a-1));b.addScale(e[7],1.092548*c*a);b.addScale(e[8],.546274*(c*c-d*d));return b},getIrradianceAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.886227);b.addScale(e[1],1.023328*d);b.addScale(e[2],1.023328*a);b.addScale(e[3],1.023328*c);b.addScale(e[4],.858086*c*d);b.addScale(e[5],.858086*d*a);b.addScale(e[6],.743125*a*a-.247708);b.addScale(e[7],.858086*c*a);b.addScale(e[8],.429043*(c*c-d*d));return b},add:function(a){for(var b=0;9>b;b++)this.coefficients[b].add(a.coefficients[b]); +return this},scale:function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a);return this},lerp:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].lerp(a.coefficients[c],b);return this},equals:function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0},copy:function(a){return this.set(a.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(a){for(var b=this.coefficients,c=0;9>c;c++)b[c].fromArray(a,3*c); +return this},toArray:function(){for(var a=[],b=this.coefficients,c=0;9>c;c++)b[c].toArray(a,3*c);return a}});Object.assign(hf,{getBasisAt:function(a,b){var c=a.x,d=a.y;a=a.z;b[0]=.282095;b[1]=.488603*d;b[2]=.488603*a;b[3]=.488603*c;b[4]=1.092548*c*d;b[5]=1.092548*d*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*c*a;b[8]=.546274*(c*c-d*d)}});Wa.prototype=Object.assign(Object.create(aa.prototype),{constructor:Wa,isLightProbe:!0,copy:function(a){aa.prototype.copy.call(this,a);this.sh.copy(a.sh);this.intensity= +a.intensity;return this},toJSON:function(a){return aa.prototype.toJSON.call(this,a)}});rg.prototype=Object.assign(Object.create(Wa.prototype),{constructor:rg,isHemisphereLightProbe:!0,copy:function(a){Wa.prototype.copy.call(this,a);return this},toJSON:function(a){return Wa.prototype.toJSON.call(this,a)}});sg.prototype=Object.assign(Object.create(Wa.prototype),{constructor:sg,isAmbientLightProbe:!0,copy:function(a){Wa.prototype.copy.call(this,a);return this},toJSON:function(a){return Wa.prototype.toJSON.call(this, +a)}});var Bi=new R,Ci=new R;Object.assign(Xh.prototype,{update:function(a){var b=this._cache;if(b.focus!==a.focus||b.fov!==a.fov||b.aspect!==a.aspect*this.aspect||b.near!==a.near||b.far!==a.far||b.zoom!==a.zoom||b.eyeSep!==this.eyeSep){b.focus=a.focus;b.fov=a.fov;b.aspect=a.aspect*this.aspect;b.near=a.near;b.far=a.far;b.zoom=a.zoom;b.eyeSep=this.eyeSep;var c=a.projectionMatrix.clone(),d=b.eyeSep/2,e=d*b.near/b.focus,f=b.near*Math.tan(O.DEG2RAD*b.fov*.5)/b.zoom;Ci.elements[12]=-d;Bi.elements[12]=d; +d=-f*b.aspect+e;var g=f*b.aspect+e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraL.projectionMatrix.copy(c);d=-f*b.aspect-e;g=f*b.aspect-e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraR.projectionMatrix.copy(c)}this.cameraL.matrixWorld.copy(a.matrixWorld).multiply(Ci);this.cameraR.matrixWorld.copy(a.matrixWorld).multiply(Bi)}});Object.assign(tg.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}});var wc=new n,Di=new qa,Ak=new n,xc=new n;ug.prototype=Object.assign(Object.create(D.prototype), +{constructor:ug,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(a){D.prototype.updateMatrixWorld.call(this,a);a=this.context.listener;var b=this.up;this.timeDelta=this._clock.getDelta();this.matrixWorld.decompose(wc,Di,Ak);xc.set(0,0,-1).applyQuaternion(Di);if(a.positionX){var c=this.context.currentTime+this.timeDelta; +a.positionX.linearRampToValueAtTime(wc.x,c);a.positionY.linearRampToValueAtTime(wc.y,c);a.positionZ.linearRampToValueAtTime(wc.z,c);a.forwardX.linearRampToValueAtTime(xc.x,c);a.forwardY.linearRampToValueAtTime(xc.y,c);a.forwardZ.linearRampToValueAtTime(xc.z,c);a.upX.linearRampToValueAtTime(b.x,c);a.upY.linearRampToValueAtTime(b.y,c);a.upZ.linearRampToValueAtTime(b.z,c)}else a.setPosition(wc.x,wc.y,wc.z),a.setOrientation(xc.x,xc.y,xc.z,b.x,b.y,b.z)}});ed.prototype=Object.assign(Object.create(D.prototype), +{constructor:ed,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.duration);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){ta.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(ii.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(za,{Composite:ii,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new za.Composite(a,b,c):new za(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;cd&&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){qa.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}}});var Ck=/[\[\]\.:\/]/g,Dk="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Ek=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Fk=/(WCOD+)?/.source.replace("WCOD",Dk),Gk=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hk=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"), +Ik=new RegExp("^"+Ek+Fk+Gk+Hk+"$"),Jk=["material","materials","bones"];Object.assign(Yh.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(va,{Composite:Yh,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new va.Composite(a,b,c):new va(a,b,c)},sanitizeNodeName:function(a){return a.replace(/\s/g,"_").replace(Ck,"")},parseTrackName:function(a){var b=Ik.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!==Jk.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++,t=a[n];c[t.uuid]=m;a[m]=t;c[k]=n;a[n]=h;h=0;for(k=e;h!==k;++h){t=d[h];var u=t[m];t[m]=t[n];t[n]=u}}}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,m=d[k];if(void 0!==m)if(delete d[k],m=b){var n=b++,r=a[n];c[r.uuid]=k;a[k]=r;c[l]=n;a[n]=h;h=0;for(l=e;h!==l;++h){r=d[h];var u=r[k];r[k]=r[n];r[n]=u}}}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 l=arguments[g].uuid,k=d[l];if(void 0!==k)if(delete d[l],kc.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{this.time=b;break a}this.clampWhenFinished?this.paused=!0:this.enabled=!1;this.time=b;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,this.time=b=0a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this.time=b,this._mixer.dispatchEvent({type:"loop", action:this,loopDelta:d}))}else this.time=b;if(f&&1===(e&1))return c-b}return 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}});Qg.prototype=Object.assign(Object.create(la.prototype),{constructor:Qg,_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 m=d[h],n=m.name,t=k[n];if(void 0===t){t=f[h];if(void 0!==t){null===t._cacheIndex&&(++t.referenceCount,this._addInactiveBinding(t,g,n));continue}t=new Pg(za.create(c,n,b&&b._propertyBindings[h].binding.parsedPath), -m.ValueTypeName,m.getValueSize());++t.referenceCount;this._addInactiveBinding(t,g,n)}f[h]=t;a[h].resultBuffer=t.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)}}, +c;return this}});zg.prototype=Object.assign(Object.create(ra.prototype),{constructor:zg,_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 m=d[h],n=m.name,r=k[n];if(void 0===r){r=f[h];if(void 0!==r){null===r._cacheIndex&&(++r.referenceCount,this._addInactiveBinding(r,g,n));continue}r=new yg(va.create(c,n,b&&b._propertyBindings[h].binding.parsedPath), +m.ValueTypeName,m.getValueSize());++r.referenceCount;this._addInactiveBinding(r,g,n)}f[h]=r;a[h].resultBuffer=r.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 z);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 z);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){void 0===Fd&& -(Fd=new z);return Fd.copy(a).clamp(this.min,this.max).sub(a).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)}});var Yf,Se;Object.assign(Ug.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(a,b){void 0===Yf&&(Yf=new n,Se=new n);Yf.subVectors(a,this.start);Se.subVectors(this.end,this.start);a=Se.dot(Se);a=Se.dot(Yf)/a;b&&(a=P.clamp(a,0,1));return a},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)}});ze.prototype=Object.create(C.prototype);ze.prototype.constructor=ze;ze.prototype.isImmediateRenderObject=!0;var gb,sb,Te,yi;Ae.prototype=Object.create(aa.prototype);Ae.prototype.constructor=Ae;Ae.prototype.update=function(){void 0===Te&&(gb=new n,sb=new n,Te=new va, -yi=["a","b","c"]);this.object.updateMatrixWorld(!0);Te.getNormalMatrix(this.object.matrixWorld);var a=this.object.matrixWorld,b=this.geometry.attributes.position,c=this.object.geometry;if(c&&c.isGeometry)for(var d=c.vertices,e=c.faces,f=c=0,g=e.length;fMath.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 cg,Gf,Vg;Ab.prototype=Object.create(C.prototype);Ab.prototype.constructor=Ab;Ab.prototype.setDirection=function(a){void 0===cg&& -(cg=new n);.99999a.y?this.quaternion.set(1,0,0,0):(cg.set(a.z,0,-a.x).normalize(),this.quaternion.setFromAxisAngle(cg,Math.acos(a.y)))};Ab.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()};Ab.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};Ab.prototype.copy= -function(a){C.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};Ab.prototype.clone=function(){return(new this.constructor).copy(this)};Fe.prototype=Object.create(aa.prototype);Fe.prototype.constructor=Fe;H.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(H.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(yb.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 F,c=0,d=a.length;cthis.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 z);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 z);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return Fi.copy(a).clamp(this.min,this.max).sub(a).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)}});var Gi=new n,Hf=new n;Object.assign(Dg.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(a,b){Gi.subVectors(a,this.start);Hf.subVectors(this.end,this.start);a=Hf.dot(Hf);a=Hf.dot(Gi)/a;b&&(a=O.clamp(a,0,1));return a},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)}});re.prototype=Object.create(D.prototype);re.prototype.constructor=re;re.prototype.isImmediateRenderObject=!0;var mb=new n,Bb=new n,ah=new ja,Kk=["a","b","c"];se.prototype=Object.create(T.prototype);se.prototype.constructor=se;se.prototype.update=function(){this.object.updateMatrixWorld(!0);ah.getNormalMatrix(this.object.matrixWorld);var a=this.object.matrixWorld,b=this.geometry.attributes.position, +c=this.object.geometry;if(c&&c.isGeometry)for(var d=c.vertices,e=c.faces,f=c=0,g=e.length;fMath.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);D.prototype.updateMatrixWorld.call(this,a)};var Ni=new n,nf,Eg;vb.prototype=Object.create(D.prototype);vb.prototype.constructor=vb;vb.prototype.setDirection=function(a){.99999a.y?this.quaternion.set(1,0,0,0):(Ni.set(a.z,0,-a.x).normalize(),this.quaternion.setFromAxisAngle(Ni,Math.acos(a.y)))};vb.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()};vb.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};vb.prototype.copy=function(a){D.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};vb.prototype.clone=function(){return(new this.constructor).copy(this)};xe.prototype=Object.create(T.prototype); +xe.prototype.constructor=xe;G.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");a.prototype=Object.create(G.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(tb.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 E,c=0,d=a.length;c= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 ); @@ -7571,8 +7406,6 @@ Object.assign( Triangle, { getUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) { - if ( _v3 === undefined ) _v3 = new Vector3(); - this.getBarycoord( point, p1, p2, p3, _v3 ); target.set( 0, 0 ); @@ -7586,18 +7419,11 @@ Object.assign( Triangle, { isFrontFacing: function ( a, b, c, direction ) { - if ( _v1$2 === undefined ) { - - _v0$1 = new Vector3(); - _v1$2 = new Vector3(); - - } - _v0$1.subVectors( c, b ); - _v1$2.subVectors( a, b ); + _v1$3.subVectors( a, b ); // strictly front facing - return ( _v0$1.cross( _v1$2 ).dot( direction ) < 0 ) ? true : false; + return ( _v0$1.cross( _v1$3 ).dot( direction ) < 0 ) ? true : false; } @@ -7643,17 +7469,10 @@ Object.assign( Triangle.prototype, { getArea: function () { - if ( _v1$2 === undefined ) { - - _v0$1 = new Vector3(); - _v1$2 = new Vector3(); - - } - _v0$1.subVectors( this.c, this.b ); - _v1$2.subVectors( this.a, this.b ); + _v1$3.subVectors( this.a, this.b ); - return _v0$1.cross( _v1$2 ).length() * 0.5; + return _v0$1.cross( _v1$3 ).length() * 0.5; }, @@ -7721,17 +7540,6 @@ Object.assign( Triangle.prototype, { closestPointToPoint: function ( p, target ) { - if ( _vab === undefined ) { - - _vab = new Vector3(); - _vac = new Vector3(); - _vbc = new Vector3(); - _vap = new Vector3(); - _vbp = new Vector3(); - _vcp = new Vector3(); - - } - if ( target === undefined ) { console.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' ); @@ -8637,6 +8445,13 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( this.clearCoat !== undefined ) data.clearCoat = this.clearCoat; if ( this.clearCoatRoughness !== undefined ) data.clearCoatRoughness = this.clearCoatRoughness; + if ( this.clearCoatNormalMap && this.clearCoatNormalMap.isTexture ) { + + data.clearCoatNormalMap = this.clearCoatNormalMap.toJSON( meta ).uuid; + data.clearCoatNormalScale = this.clearCoatNormalScale.toArray(); + + } + if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid; if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid; if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid; @@ -9710,11 +9525,18 @@ function arrayMax( array ) { * @author mrdoob / http://mrdoob.com/ */ -var bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id +var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id + +var _m1$2 = new Matrix4(); +var _obj = new Object3D(); +var _offset = new Vector3(); +var _box$1 = new Box3(); +var _boxMorphTargets = new Box3(); +var _vector$4 = new Vector3(); function BufferGeometry() { - Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } ); + Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } ); this.uuid = _Math.generateUUID(); @@ -9877,129 +9699,89 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy }, - rotateX: function () { + rotateX: function ( angle ) { // rotate geometry around world x-axis - var m1 = new Matrix4(); - - return function rotateX( angle ) { + _m1$2.makeRotationX( angle ); - m1.makeRotationX( angle ); + this.applyMatrix( _m1$2 ); - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateY: function () { + rotateY: function ( angle ) { // rotate geometry around world y-axis - var m1 = new Matrix4(); + _m1$2.makeRotationY( angle ); - return function rotateY( angle ) { + this.applyMatrix( _m1$2 ); - m1.makeRotationY( angle ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateZ: function () { + rotateZ: function ( angle ) { // rotate geometry around world z-axis - var m1 = new Matrix4(); - - return function rotateZ( angle ) { + _m1$2.makeRotationZ( angle ); - m1.makeRotationZ( angle ); + this.applyMatrix( _m1$2 ); - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - translate: function () { + translate: function ( x, y, z ) { // translate geometry - var m1 = new Matrix4(); - - return function translate( x, y, z ) { - - m1.makeTranslation( x, y, z ); + _m1$2.makeTranslation( x, y, z ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1$2 ); - return this; - - }; + return this; - }(), + }, - scale: function () { + scale: function ( x, y, z ) { // scale geometry - var m1 = new Matrix4(); - - return function scale( x, y, z ) { - - m1.makeScale( x, y, z ); - - this.applyMatrix( m1 ); - - return this; - - }; + _m1$2.makeScale( x, y, z ); - }(), + this.applyMatrix( _m1$2 ); - lookAt: function () { + return this; - var obj = new Object3D(); + }, - return function lookAt( vector ) { + lookAt: function ( vector ) { - obj.lookAt( vector ); + _obj.lookAt( vector ); - obj.updateMatrix(); + _obj.updateMatrix(); - this.applyMatrix( obj.matrix ); + this.applyMatrix( _obj.matrix ); - }; + return this; - }(), + }, center: function () { - var offset = new Vector3(); + this.computeBoundingBox(); - return function center() { + this.boundingBox.getCenter( _offset ).negate(); - this.computeBoundingBox(); - - this.boundingBox.getCenter( offset ).negate(); + this.translate( _offset.x, _offset.y, _offset.z ); - this.translate( offset.x, offset.y, offset.z ); - - return this; - - }; + return this; - }(), + }, setFromObject: function ( object ) { @@ -10296,144 +10078,130 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy computeBoundingBox: function () { - var box = new Box3(); - - return function computeBoundingBox() { - - if ( this.boundingBox === null ) { - - this.boundingBox = new Box3(); + if ( this.boundingBox === null ) { - } + this.boundingBox = new Box3(); - var position = this.attributes.position; - var morphAttributesPosition = this.morphAttributes.position; + } - if ( position !== undefined ) { + var position = this.attributes.position; + var morphAttributesPosition = this.morphAttributes.position; - this.boundingBox.setFromBufferAttribute( position ); + if ( position !== undefined ) { - // process morph attributes if present + this.boundingBox.setFromBufferAttribute( position ); - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; - box.setFromBufferAttribute( morphAttribute ); + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - this.boundingBox.expandByPoint( box.min ); - this.boundingBox.expandByPoint( box.max ); + var morphAttribute = morphAttributesPosition[ i ]; + _box$1.setFromBufferAttribute( morphAttribute ); - } + this.boundingBox.expandByPoint( _box$1.min ); + this.boundingBox.expandByPoint( _box$1.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 ); + } else { - } + this.boundingBox.makeEmpty(); - }; + } - }(), + if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) { - computeBoundingSphere: function () { + console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this ); - var box = new Box3(); - var boxMorphTargets = new Box3(); - var vector = new Vector3(); + } - return function computeBoundingSphere() { + }, - if ( this.boundingSphere === null ) { + computeBoundingSphere: function () { - this.boundingSphere = new Sphere(); + if ( this.boundingSphere === null ) { - } + this.boundingSphere = new Sphere(); - var position = this.attributes.position; - var morphAttributesPosition = this.morphAttributes.position; + } - if ( position ) { + var position = this.attributes.position; + var morphAttributesPosition = this.morphAttributes.position; - // first, find the center of the bounding sphere + if ( position ) { - var center = this.boundingSphere.center; + // first, find the center of the bounding sphere - box.setFromBufferAttribute( position ); + var center = this.boundingSphere.center; - // process morph attributes if present + _box$1.setFromBufferAttribute( position ); - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; - boxMorphTargets.setFromBufferAttribute( morphAttribute ); + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - box.expandByPoint( boxMorphTargets.min ); - box.expandByPoint( boxMorphTargets.max ); + var morphAttribute = morphAttributesPosition[ i ]; + _boxMorphTargets.setFromBufferAttribute( morphAttribute ); - } + _box$1.expandByPoint( _boxMorphTargets.min ); + _box$1.expandByPoint( _boxMorphTargets.max ); } - box.getCenter( center ); + } - // second, try to find a boundingSphere with a radius smaller than the - // boundingSphere of the boundingBox: sqrt(3) smaller in the best case + _box$1.getCenter( center ); - var maxRadiusSq = 0; + // second, try to find a boundingSphere with a radius smaller than the + // boundingSphere of the boundingBox: sqrt(3) smaller in the best case - for ( var i = 0, il = position.count; i < il; i ++ ) { + var maxRadiusSq = 0; - vector.fromBufferAttribute( position, i ); + for ( var i = 0, il = position.count; i < il; i ++ ) { - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + _vector$4.fromBufferAttribute( position, i ); - } + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); - // process morph attributes if present + } - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { + var morphAttribute = morphAttributesPosition[ i ]; - vector.fromBufferAttribute( morphAttribute, j ); + for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + _vector$4.fromBufferAttribute( morphAttribute, j ); - } + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector$4 ) ); } } - this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); + } - if ( isNaN( this.boundingSphere.radius ) ) { + this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); - console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); + if ( isNaN( this.boundingSphere.radius ) ) { - } + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); } - }; + } - }(), + }, computeFaceNormals: function () { @@ -10595,27 +10363,21 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy normalizeNormals: function () { - var vector = new Vector3(); - - return function normalizeNormals() { + var normals = this.attributes.normal; - var normals = this.attributes.normal; + for ( var i = 0, il = normals.count; i < il; i ++ ) { - for ( var i = 0, il = normals.count; i < il; i ++ ) { + _vector$4.x = normals.getX( i ); + _vector$4.y = normals.getY( i ); + _vector$4.z = normals.getZ( i ); - vector.x = normals.getX( i ); - vector.y = normals.getY( i ); - vector.z = normals.getZ( i ); + _vector$4.normalize(); - vector.normalize(); + normals.setXYZ( i, _vector$4.x, _vector$4.y, _vector$4.z ); - normals.setXYZ( i, vector.x, vector.y, vector.z ); - - } - - }; + } - }(), + }, toNonIndexed: function () { @@ -10968,12 +10730,28 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy * @author jonobr1 / http://jonobr1.com/ */ -var _inverseMatrix, _ray, _sphere; -var _vA, _vB, _vC; -var _tempA, _tempB, _tempC; -var _morphA, _morphB, _morphC; -var _uvA, _uvB, _uvC; -var _intersectionPoint, _intersectionPointWorld; +var _inverseMatrix = new Matrix4(); +var _ray = new Ray(); +var _sphere = new Sphere(); + +var _vA = new Vector3(); +var _vB = new Vector3(); +var _vC = new Vector3(); + +var _tempA = new Vector3(); +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(); + +var _intersectionPoint = new Vector3(); +var _intersectionPointWorld = new Vector3(); function Mesh( geometry, material ) { @@ -11072,33 +10850,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _intersectionPointWorld === undefined ) { - - _inverseMatrix = new Matrix4(); - _ray = new Ray(); - _sphere = new Sphere(); - - _vA = new Vector3(); - _vB = new Vector3(); - _vC = new Vector3(); - - _tempA = new Vector3(); - _tempB = new Vector3(); - _tempC = new Vector3(); - - _morphA = new Vector3(); - _morphB = new Vector3(); - _morphC = new Vector3(); - - _uvA = new Vector2(); - _uvB = new Vector2(); - _uvC = new Vector2(); - - _intersectionPoint = new Vector3(); - _intersectionPointWorld = new Vector3(); - - } - var geometry = this.geometry; var material = this.material; var matrixWorld = this.matrixWorld; @@ -11431,11 +11182,14 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi * @author bhouston / http://clara.io */ -var geometryId = 0; // Geometry uses even numbers as Id +var _geometryId = 0; // Geometry uses even numbers as Id +var _m1$3 = new Matrix4(); +var _obj$1 = new Object3D(); +var _offset$1 = new Vector3(); function Geometry() { - Object.defineProperty( this, 'id', { value: geometryId += 2 } ); + Object.defineProperty( this, 'id', { value: _geometryId += 2 } ); this.uuid = _Math.generateUUID(); @@ -11519,111 +11273,77 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), }, - rotateX: function () { + rotateX: function ( angle ) { // rotate geometry around world x-axis - var m1 = new Matrix4(); - - return function rotateX( angle ) { + _m1$3.makeRotationX( angle ); - m1.makeRotationX( angle ); + this.applyMatrix( _m1$3 ); - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateY: function () { + rotateY: function ( angle ) { // rotate geometry around world y-axis - var m1 = new Matrix4(); - - return function rotateY( angle ) { - - m1.makeRotationY( angle ); + _m1$3.makeRotationY( angle ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1$3 ); - return this; - - }; + return this; - }(), + }, - rotateZ: function () { + rotateZ: function ( angle ) { // rotate geometry around world z-axis - var m1 = new Matrix4(); - - return function rotateZ( angle ) { + _m1$3.makeRotationZ( angle ); - m1.makeRotationZ( angle ); - - this.applyMatrix( m1 ); - - return this; + this.applyMatrix( _m1$3 ); - }; + return this; - }(), + }, - translate: function () { + translate: function ( x, y, z ) { // translate geometry - var m1 = new Matrix4(); + _m1$3.makeTranslation( x, y, z ); - return function translate( x, y, z ) { + this.applyMatrix( _m1$3 ); - m1.makeTranslation( x, y, z ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - scale: function () { + scale: function ( x, y, z ) { // scale geometry - var m1 = new Matrix4(); - - return function scale( x, y, z ) { - - m1.makeScale( x, y, z ); - - this.applyMatrix( m1 ); + _m1$3.makeScale( x, y, z ); - return this; - - }; - - }(), + this.applyMatrix( _m1$3 ); - lookAt: function () { + return this; - var obj = new Object3D(); + }, - return function lookAt( vector ) { + lookAt: function ( vector ) { - obj.lookAt( vector ); + _obj$1.lookAt( vector ); - obj.updateMatrix(); + _obj$1.updateMatrix(); - this.applyMatrix( obj.matrix ); + this.applyMatrix( _obj$1.matrix ); - }; + return this; - }(), + }, fromBufferGeometry: function ( geometry ) { @@ -11760,21 +11480,15 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), center: function () { - var offset = new Vector3(); + this.computeBoundingBox(); - return function center() { - - this.computeBoundingBox(); + this.boundingBox.getCenter( _offset$1 ).negate(); - this.boundingBox.getCenter( offset ).negate(); - - this.translate( offset.x, offset.y, offset.z ); - - return this; + this.translate( _offset$1.x, _offset$1.y, _offset$1.z ); - }; + return this; - }(), + }, normalize: function () { @@ -13864,7 +13578,9 @@ DataTexture.prototype.isDataTexture = true; * @author bhouston / http://clara.io */ -var _vector1, _vector2, _normalMatrix; +var _vector1 = new Vector3(); +var _vector2 = new Vector3(); +var _normalMatrix = new Matrix3(); function Plane( normal, constant ) { @@ -13908,13 +13624,6 @@ Object.assign( Plane.prototype, { setFromCoplanarPoints: function ( a, b, c ) { - if ( _vector1 === undefined ) { - - _vector1 = new Vector3(); - _vector2 = new Vector3(); - - } - var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize(); // Q: should an error be thrown if normal is zero (e.g. degenerate plane)? @@ -13988,8 +13697,6 @@ Object.assign( Plane.prototype, { intersectLine: function ( line, target ) { - if ( _vector1 === undefined ) _vector1 = new Vector3(); - if ( target === undefined ) { console.warn( 'THREE.Plane: .intersectLine() target is now required' ); @@ -14065,13 +13772,6 @@ Object.assign( Plane.prototype, { applyMatrix4: function ( matrix, optionalNormalMatrix ) { - if ( _normalMatrix === undefined ) { - - _normalMatrix = new Matrix3(); - _vector1 = new Vector3(); - - } - var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix ); var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix ); @@ -14106,8 +13806,8 @@ Object.assign( Plane.prototype, { * @author bhouston / http://clara.io */ -var _sphere$1; -var _vector$4; +var _sphere$1 = new Sphere(); +var _vector$5 = new Vector3(); function Frustum( p0, p1, p2, p3, p4, p5 ) { @@ -14183,8 +13883,6 @@ Object.assign( Frustum.prototype, { intersectsObject: function ( object ) { - if ( _sphere$1 === undefined ) _sphere$1 = new Sphere(); - var geometry = object.geometry; if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); @@ -14197,8 +13895,6 @@ Object.assign( Frustum.prototype, { intersectsSprite: function ( sprite ) { - if ( _sphere$1 === undefined ) _sphere$1 = new Sphere(); - _sphere$1.center.set( 0, 0, 0 ); _sphere$1.radius = 0.7071067811865476; _sphere$1.applyMatrix4( sprite.matrixWorld ); @@ -14231,8 +13927,6 @@ Object.assign( Frustum.prototype, { intersectsBox: function ( box ) { - if ( _vector$4 === undefined ) _vector$4 = new Vector3(); - var planes = this.planes; for ( var i = 0; i < 6; i ++ ) { @@ -14241,11 +13935,11 @@ Object.assign( Frustum.prototype, { // corner at max distance - _vector$4.x = plane.normal.x > 0 ? box.max.x : box.min.x; - _vector$4.y = plane.normal.y > 0 ? box.max.y : box.min.y; - _vector$4.z = plane.normal.z > 0 ? box.max.z : box.min.z; + _vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x; + _vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y; + _vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z; - if ( plane.distanceToPoint( _vector$4 ) < 0 ) { + if ( plane.distanceToPoint( _vector$5 ) < 0 ) { return false; @@ -14311,7 +14005,7 @@ var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; -var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n\tvec3 clearCoatNormal;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}"; +var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef PHYSICAL\n\tvec3 clearCoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}"; var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif"; @@ -14341,7 +14035,7 @@ var fog_vertex = "#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif"; var fog_pars_vertex = "#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif"; -var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; +var fog_fragment = "#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif"; var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; @@ -14363,11 +14057,11 @@ var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHAD var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif"; -var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifndef STANDARD\n\t\tfloat ccDotNV = saturate( dot( geometry.clearCoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatInv * radiance * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; +var lights_physical_pars_fragment = "struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifdef PHYSICAL\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef PHYSICAL\n\t\tfloat ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef PHYSICAL\n\t\tfloat ccDotNV = saturate( dot( geometry.clearCoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearCoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\tfloat clearCoatInv = 1.0 - clearCoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearCoatInv * radiance * singleScattering;\n\treflectedLight.indirectDiffuse += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}"; -var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tgeometry.clearCoatNormal = clearCoatNormal;\n#else\n\tgeometry.clearCoatNormal = geometryNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif"; +var lights_fragment_begin = "\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef PHYSICAL\n\tgeometry.clearCoatNormal = clearCoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif"; -var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n radiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif"; +var lights_fragment_maps = "#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifdef PHYSICAL\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif"; var lights_fragment_end = "#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, irradiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif"; @@ -14403,7 +14097,7 @@ var normal_fragment_maps = "#ifdef USE_NORMALMAP\n\t#ifdef OBJECTSPACE_NORMALMAP var normalmap_pars_fragment = "#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\t#ifdef OBJECTSPACE_NORMALMAP\n\t\tuniform mat3 normalMatrix;\n\t#endif\n#endif\n#if ( defined ( USE_NORMALMAP ) && !defined ( OBJECTSPACE_NORMALMAP )) || defined ( USE_CLEARCOAT_NORMALMAP )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvec3 NfromST = cross( S, T );\n\t\t\tif( dot( NfromST, N ) > 0.0 ) {\n\t\t\t\tS *= -1.0;\n\t\t\t\tT *= -1.0;\n\t\t\t}\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif"; -var clearcoat_normal_fragment_begin = "#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearCoatNormal = geometryNormal;\n#endif"; +var clearcoat_normal_fragment_begin = "#ifdef PHYSICAL\n\tvec3 clearCoatNormal = geometryNormal;\n#endif"; var clearcoat_normal_fragment_maps = "#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearCoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearCoatNormalScale * mapN.xy;\n\t\tclearCoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearCoatNormal = perturbNormal2Arb( - vViewPosition, clearCoatNormal, clearCoatNormalScale, clearCoatNormalMap );\n\t#endif\n#endif"; @@ -14415,15 +14109,15 @@ var premultiplied_alpha_fragment = "#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.r var project_vertex = "vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;"; -var dithering_fragment = "#if defined( DITHERING )\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; +var dithering_fragment = "#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif"; -var dithering_pars_fragment = "#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; +var dithering_pars_fragment = "#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif"; var roughnessmap_fragment = "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif"; var roughnessmap_pars_fragment = "#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif"; -var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; +var shadowmap_pars_fragment = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif"; var shadowmap_pars_vertex = "#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif"; @@ -14447,11 +14141,11 @@ var tonemapping_fragment = "#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = to var tonemapping_pars_fragment = "#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}"; -var uv_pars_fragment = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif"; +var uv_pars_fragment = "#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif"; -var uv_pars_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif"; +var uv_pars_vertex = "#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif"; -var uv_vertex = "#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; +var uv_vertex = "#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif"; var uv2_pars_fragment = "#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif"; @@ -14501,7 +14195,7 @@ var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissiv var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}"; -var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; +var meshphysical_frag = "#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef PHYSICAL\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}"; var meshphysical_vert = "#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}"; @@ -15687,15 +15381,17 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) { function renderInstances( geometry, start, count ) { - var extension; + var extension, methodName; if ( capabilities.isWebGL2 ) { extension = gl; + methodName = 'drawArraysInstanced'; } else { extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawArraysInstancedANGLE'; if ( extension === null ) { @@ -15706,7 +15402,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) { } - extension[ capabilities.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount ); + extension[ methodName ]( mode, start, count, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount ); @@ -16062,13 +15758,13 @@ function WebGLExtensions( gl ) { function WebGLGeometries( gl, attributes, info ) { - var geometries = {}; - var wireframeAttributes = {}; + var geometries = new WeakMap(); + var wireframeAttributes = new WeakMap(); function onGeometryDispose( event ) { var geometry = event.target; - var buffergeometry = geometries[ geometry.id ]; + var buffergeometry = geometries.get( geometry ); if ( buffergeometry.index !== null ) { @@ -16084,14 +15780,14 @@ function WebGLGeometries( gl, attributes, info ) { geometry.removeEventListener( 'dispose', onGeometryDispose ); - delete geometries[ geometry.id ]; + geometries.delete( geometry ); - var attribute = wireframeAttributes[ buffergeometry.id ]; + var attribute = wireframeAttributes.get( buffergeometry ); if ( attribute ) { attributes.remove( attribute ); - delete wireframeAttributes[ buffergeometry.id ]; + wireframeAttributes.delete( buffergeometry ); } @@ -16103,7 +15799,7 @@ function WebGLGeometries( gl, attributes, info ) { function get( object, geometry ) { - var buffergeometry = geometries[ geometry.id ]; + var buffergeometry = geometries.get( geometry ); if ( buffergeometry ) return buffergeometry; @@ -16125,7 +15821,7 @@ function WebGLGeometries( gl, attributes, info ) { } - geometries[ geometry.id ] = buffergeometry; + geometries.set( geometry, buffergeometry ); info.memory.geometries ++; @@ -16215,19 +15911,19 @@ function WebGLGeometries( gl, attributes, info ) { // - var previousAttribute = wireframeAttributes[ geometry.id ]; + var previousAttribute = wireframeAttributes.get( geometry ); if ( previousAttribute ) attributes.remove( previousAttribute ); // - wireframeAttributes[ geometry.id ] = attribute; + wireframeAttributes.set( geometry, attribute ); } function getWireframeAttribute( geometry ) { - var currentAttribute = wireframeAttributes[ geometry.id ]; + var currentAttribute = wireframeAttributes.get( geometry ); if ( currentAttribute ) { @@ -16251,7 +15947,7 @@ function WebGLGeometries( gl, attributes, info ) { } - return wireframeAttributes[ geometry.id ]; + return wireframeAttributes.get( geometry ); } @@ -16299,15 +15995,17 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { function renderInstances( geometry, start, count ) { - var extension; + var extension, methodName; if ( capabilities.isWebGL2 ) { extension = gl; + methodName = 'drawElementsInstanced'; } else { - var extension = extensions.get( 'ANGLE_instanced_arrays' ); + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawElementsInstancedANGLE'; if ( extension === null ) { @@ -16318,7 +16016,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { } - extension[ capabilities.isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); + extension[ methodName ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount ); @@ -17900,7 +17598,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, '#define MAX_BONES ' + parameters.maxBones, ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', - ( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', @@ -17920,6 +17618,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexUvs ? '#define USE_UV' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', @@ -18014,7 +17713,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, '#define GAMMA_FACTOR ' + gammaFactorDefine, ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', - ( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', @@ -18036,6 +17735,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexUvs ? '#define USE_UV' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', @@ -18054,7 +17754,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', - parameters.envMap && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', + ( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', @@ -18311,7 +18011,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) { "precision", "supportsVertexTextures", "map", "mapEncoding", "matcap", "matcapEncoding", "envMap", "envMapMode", "envMapEncoding", "lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "clearCoatNormalMap", "displacementMap", "specularMap", "roughnessMap", "metalnessMap", "gradientMap", - "alphaMap", "combine", "vertexColors", "vertexTangents", "fog", "useFog", "fogExp", + "alphaMap", "combine", "vertexColors", "vertexTangents", "fog", "useFog", "fogExp2", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", "maxMorphTargets", "maxMorphNormals", "premultipliedAlpha", @@ -18446,10 +18146,11 @@ function WebGLPrograms( renderer, extensions, capabilities ) { vertexTangents: ( material.normalMap && material.vertexTangents ), vertexColors: material.vertexColors, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearCoatNormalMap, fog: !! fog, useFog: material.fog, - fogExp: ( fog && fog.isFogExp2 ), + fogExp2: ( fog && fog.isFogExp2 ), flatShading: material.flatShading, @@ -18798,7 +18499,7 @@ function WebGLRenderList() { function WebGLRenderLists() { - var lists = {}; + var lists = new WeakMap(); function onSceneDispose( event ) { @@ -18806,29 +18507,29 @@ function WebGLRenderLists() { scene.removeEventListener( 'dispose', onSceneDispose ); - delete lists[ scene.id ]; + lists.delete( scene ); } function get( scene, camera ) { - var cameras = lists[ scene.id ]; + var cameras = lists.get( scene ); var list; if ( cameras === undefined ) { list = new WebGLRenderList(); - lists[ scene.id ] = {}; - lists[ scene.id ][ camera.id ] = list; + lists.set( scene, new WeakMap() ); + lists.get( scene ).set( camera, list ); scene.addEventListener( 'dispose', onSceneDispose ); } else { - list = cameras[ camera.id ]; + list = cameras.get( camera ); if ( list === undefined ) { list = new WebGLRenderList(); - cameras[ camera.id ] = list; + cameras.set( camera, list ); } @@ -18840,7 +18541,7 @@ function WebGLRenderLists() { function dispose() { - lists = {}; + lists = new WeakMap(); } @@ -19309,7 +19010,7 @@ function WebGLRenderState() { function WebGLRenderStates() { - var renderStates = {}; + var renderStates = new WeakMap(); function onSceneDispose( event ) { @@ -19317,7 +19018,7 @@ function WebGLRenderStates() { scene.removeEventListener( 'dispose', onSceneDispose ); - delete renderStates[ scene.id ]; + renderStates.delete( scene ); } @@ -19325,24 +19026,24 @@ function WebGLRenderStates() { var renderState; - if ( renderStates[ scene.id ] === undefined ) { + if ( renderStates.has( scene ) === false ) { renderState = new WebGLRenderState(); - renderStates[ scene.id ] = {}; - renderStates[ scene.id ][ camera.id ] = renderState; + renderStates.set( scene, new WeakMap() ); + renderStates.get( scene ).set( camera, renderState ); scene.addEventListener( 'dispose', onSceneDispose ); } else { - if ( renderStates[ scene.id ][ camera.id ] === undefined ) { + if ( renderStates.get( scene ).has( camera ) === false ) { renderState = new WebGLRenderState(); - renderStates[ scene.id ][ camera.id ] = renderState; + renderStates.get( scene ).set( camera, renderState ); } else { - renderState = renderStates[ scene.id ][ camera.id ]; + renderState = renderStates.get( scene ).get( camera ); } @@ -19354,7 +19055,7 @@ function WebGLRenderStates() { function dispose() { - renderStates = {}; + renderStates = new WeakMap(); } @@ -20939,7 +20640,7 @@ function WebGLState( gl, extensions, utils, capabilities ) { function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) { - var _videoTextures = {}; + var _videoTextures = new WeakMap(); var _canvas; // @@ -21121,7 +20822,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( texture.isVideoTexture ) { - delete _videoTextures[ texture.id ]; + _videoTextures.delete( texture ); } @@ -21289,104 +20990,110 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function setTextureCube( texture, slot ) { + if ( texture.image.length !== 6 ) return; + var textureProperties = properties.get( texture ); - if ( texture.image.length === 6 ) { + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { - if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + initTexture( textureProperties, texture ); - initTexture( textureProperties, texture ); + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); - state.activeTexture( 33984 + slot ); - state.bindTexture( 34067, textureProperties.__webglTexture ); + _gl.pixelStorei( 37440, texture.flipY ); - _gl.pixelStorei( 37440, texture.flipY ); + var isCompressed = ( texture && texture.isCompressedTexture ); + var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); - var isCompressed = ( texture && texture.isCompressedTexture ); - var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); + var cubeImage = []; - var cubeImage = []; + for ( var i = 0; i < 6; i ++ ) { - for ( var i = 0; i < 6; i ++ ) { + if ( ! isCompressed && ! isDataTexture ) { - if ( ! isCompressed && ! isDataTexture ) { + cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize ); - cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize ); + } else { - } else { + cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; - cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; + } - } + } - } + var image = cubeImage[ 0 ], + supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, + glFormat = utils.convert( texture.format ), + glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( glFormat, glType ); - var image = cubeImage[ 0 ], - supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, - glFormat = utils.convert( texture.format ), - glType = utils.convert( texture.type ), - glInternalFormat = getInternalFormat( glFormat, glType ); + setTextureParameters( 34067, texture, supportsMips ); - setTextureParameters( 34067, texture, supportsMips ); + var mipmaps; - var mipmaps = texture.mipmaps; + if ( isCompressed ) { for ( var i = 0; i < 6; i ++ ) { - if ( ! isCompressed ) { + mipmaps = cubeImage[ i ].mipmaps; - if ( isDataTexture ) { + for ( var j = 0; j < mipmaps.length; j ++ ) { - state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); + var mipmap = mipmaps[ j ]; - for ( var j = 0; j < mipmaps.length; ++ j ) { + if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) { - var mipmap = mipmaps[ j ]; - var image = mipmap.image[ i ].image; + if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { - state.texImage2D( 34069 + i, j + 1, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data ); + state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); } } else { - state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); + state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); - for ( var j = 0; j < mipmaps.length; ++ j ) { + } - var mipmap = mipmaps[ j ]; + } - state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); + } - } + textureProperties.__maxMipLevel = mipmaps.length - 1; - } + } else { - } else { + mipmaps = texture.mipmaps; - var mipmaps = cubeImage[ i ].mipmaps; + for ( var i = 0; i < 6; i ++ ) { - for ( var j = 0, jl = mipmaps.length; j < jl; j ++ ) { + if ( isDataTexture ) { - var mipmap = mipmaps[ j ]; + state.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); - if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) { + for ( var j = 0; j < mipmaps.length; j ++ ) { - if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { + var mipmap = mipmaps[ j ]; + var mipmapImage = mipmap.image[ i ].image; - state.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + state.texImage2D( 34069 + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data ); - } else { + } - console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); + } else { - } + state.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); - } else { + for ( var j = 0; j < mipmaps.length; j ++ ) { - state.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + var mipmap = mipmaps[ j ]; - } + state.texImage2D( 34069 + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); } @@ -21394,25 +21101,25 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - textureProperties.__maxMipLevel = isCompressed ? mipmaps.length - 1 : mipmaps.length; + textureProperties.__maxMipLevel = mipmaps.length; - if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + } - // We assume images for cube map have the same size. - generateMipmap( 34067, texture, image.width, image.height ); + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - } + // We assume images for cube map have the same size. + generateMipmap( 34067, texture, image.width, image.height ); - textureProperties.__version = texture.version; + } - if ( texture.onUpdate ) texture.onUpdate( texture ); + textureProperties.__version = texture.version; - } else { + if ( texture.onUpdate ) texture.onUpdate( texture ); - state.activeTexture( 33984 + slot ); - state.bindTexture( 34067, textureProperties.__webglTexture ); + } else { - } + state.activeTexture( 33984 + slot ); + state.bindTexture( 34067, textureProperties.__webglTexture ); } @@ -22030,14 +21737,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function updateVideoTexture( texture ) { - var id = texture.id; var frame = info.render.frame; // Check the last frame we updated the VideoTexture - if ( _videoTextures[ id ] !== frame ) { + if ( _videoTextures.get( texture ) !== frame ) { - _videoTextures[ id ] = frame; + _videoTextures.set( texture, frame ); texture.update(); } @@ -26059,10 +25765,21 @@ SpriteMaterial.prototype.copy = function ( source ) { var _geometry; -var _intersectPoint, _worldScale, _mvPosition; -var _alignedPosition, _rotatedPosition, _viewWorldMatrix; -var _vA$1, _vB$1, _vC$1; -var _uvA$1, _uvB$1, _uvC$1; +var _intersectPoint = new Vector3(); +var _worldScale = new Vector3(); +var _mvPosition = new Vector3(); + +var _alignedPosition = new Vector2(); +var _rotatedPosition = new Vector2(); +var _viewWorldMatrix = new Matrix4(); + +var _vA$1 = new Vector3(); +var _vB$1 = new Vector3(); +var _vC$1 = new Vector3(); + +var _uvA$1 = new Vector2(); +var _uvB$1 = new Vector2(); +var _uvC$1 = new Vector2(); function Sprite( material ) { @@ -26104,34 +25821,20 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _uvC$1 === undefined ) { - - _intersectPoint = new Vector3(); - _worldScale = new Vector3(); - _mvPosition = new Vector3(); - - _alignedPosition = new Vector2(); - _rotatedPosition = new Vector2(); - _viewWorldMatrix = new Matrix4(); - - _vA$1 = new Vector3(); - _vB$1 = new Vector3(); - _vC$1 = new Vector3(); + if ( raycaster.camera === null ) { - _uvA$1 = new Vector2(); - _uvB$1 = new Vector2(); - _uvC$1 = new Vector2(); + console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' ); } _worldScale.setFromMatrixScale( this.matrixWorld ); - _viewWorldMatrix.copy( raycaster._camera.matrixWorld ); - this.modelViewMatrix.multiplyMatrices( raycaster._camera.matrixWorldInverse, this.matrixWorld ); + _viewWorldMatrix.copy( raycaster.camera.matrixWorld ); + this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld ); _mvPosition.setFromMatrixPosition( this.modelViewMatrix ); - if ( raycaster._camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { + if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { _worldScale.multiplyScalar( - _mvPosition.z ); @@ -26242,7 +25945,8 @@ function transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) * @author mrdoob / http://mrdoob.com/ */ -var _v1$3, _v2$2; +var _v1$4 = new Vector3(); +var _v2$2 = new Vector3(); function LOD() { @@ -26331,11 +26035,9 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _v1$3 === undefined ) _v1$3 = new Vector3(); + _v1$4.setFromMatrixPosition( this.matrixWorld ); - _v1$3.setFromMatrixPosition( this.matrixWorld ); - - var distance = raycaster.ray.origin.distanceTo( _v1$3 ); + var distance = raycaster.ray.origin.distanceTo( _v1$4 ); this.getObjectForDistance( distance ).raycast( raycaster, intersects ); @@ -26343,21 +26045,14 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { update: function ( camera ) { - if ( _v2$2 === undefined ) { - - _v1$3 = new Vector3(); - _v2$2 = new Vector3(); - - } - var levels = this.levels; if ( levels.length > 1 ) { - _v1$3.setFromMatrixPosition( camera.matrixWorld ); + _v1$4.setFromMatrixPosition( camera.matrixWorld ); _v2$2.setFromMatrixPosition( this.matrixWorld ); - var distance = _v1$3.distanceTo( _v2$2 ); + var distance = _v1$4.distanceTo( _v2$2 ); levels[ 0 ].object.visible = true; @@ -26532,7 +26227,8 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { * @author ikerr / http://verold.com */ -var _offsetMatrix, _identityMatrix; +var _offsetMatrix = new Matrix4(); +var _identityMatrix = new Matrix4(); function Skeleton( bones, boneInverses ) { @@ -26642,13 +26338,6 @@ Object.assign( Skeleton.prototype, { update: function () { - if ( _identityMatrix === undefined ) { - - _offsetMatrix = new Matrix4(); - _identityMatrix = new Matrix4(); - - } - var bones = this.bones; var boneInverses = this.boneInverses; var boneMatrices = this.boneMatrices; @@ -26778,8 +26467,11 @@ LineBasicMaterial.prototype.copy = function ( source ) { * @author mrdoob / http://mrdoob.com/ */ -var _start, _end; -var _inverseMatrix$1, _ray$1, _sphere$2; +var _start = new Vector3(); +var _end = new Vector3(); +var _inverseMatrix$1 = new Matrix4(); +var _ray$1 = new Ray(); +var _sphere$2 = new Sphere(); function Line( geometry, material, mode ) { @@ -26806,13 +26498,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { computeLineDistances: function () { - if ( _end === undefined ) { - - _start = new Vector3(); - _end = new Vector3(); - - } - var geometry = this.geometry; if ( geometry.isBufferGeometry ) { @@ -26864,14 +26549,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _sphere$2 === undefined ) { - - _inverseMatrix$1 = new Matrix4(); - _ray$1 = new Ray(); - _sphere$2 = new Sphere(); - - } - var precision = raycaster.linePrecision; var geometry = this.geometry; @@ -27026,7 +26703,8 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { * @author mrdoob / http://mrdoob.com/ */ -var _start$1, _end$1; +var _start$1 = new Vector3(); +var _end$1 = new Vector3(); function LineSegments( geometry, material ) { @@ -27044,13 +26722,6 @@ LineSegments.prototype = Object.assign( Object.create( Line.prototype ), { computeLineDistances: function () { - if ( _end$1 === undefined ) { - - _start$1 = new Vector3(); - _end$1 = new Vector3(); - - } - var geometry = this.geometry; if ( geometry.isBufferGeometry ) { @@ -27186,7 +26857,10 @@ PointsMaterial.prototype.copy = function ( source ) { * @author alteredq / http://alteredqualia.com/ */ -var _inverseMatrix$2, _ray$2, _sphere$3; +var _inverseMatrix$2 = new Matrix4(); +var _ray$2 = new Ray(); +var _sphere$3 = new Sphere(); +var _position$1 = new Vector3(); function Points( geometry, material ) { @@ -27209,15 +26883,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _sphere$3 === undefined ) { - - _inverseMatrix$2 = new Matrix4(); - _ray$2 = new Ray(); - _sphere$3 = new Sphere(); - - } - - var object = this; var geometry = this.geometry; var matrixWorld = this.matrixWorld; var threshold = raycaster.params.Points.threshold; @@ -27239,36 +26904,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); var localThresholdSq = localThreshold * localThreshold; - var position = new Vector3(); - var intersectPoint = new Vector3(); - - function testPoint( point, index ) { - - var rayPointDistanceSq = _ray$2.distanceSqToPoint( point ); - - if ( rayPointDistanceSq < localThresholdSq ) { - - _ray$2.closestPointToPoint( point, intersectPoint ); - intersectPoint.applyMatrix4( matrixWorld ); - - var distance = raycaster.ray.origin.distanceTo( intersectPoint ); - - if ( distance < raycaster.near || distance > raycaster.far ) return; - - intersects.push( { - - distance: distance, - distanceToRay: Math.sqrt( rayPointDistanceSq ), - point: intersectPoint.clone(), - index: index, - face: null, - object: object - - } ); - - } - - } if ( geometry.isBufferGeometry ) { @@ -27284,9 +26919,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { var a = indices[ i ]; - position.fromArray( positions, a * 3 ); + _position$1.fromArray( positions, a * 3 ); - testPoint( position, a ); + testPoint( _position$1, a, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -27294,9 +26929,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 0, l = positions.length / 3; i < l; i ++ ) { - position.fromArray( positions, i * 3 ); + _position$1.fromArray( positions, i * 3 ); - testPoint( position, i ); + testPoint( _position$1, i, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -27308,7 +26943,7 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 0, l = vertices.length; i < l; i ++ ) { - testPoint( vertices[ i ], i ); + testPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -27370,6 +27005,36 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { } ); +function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) { + + var rayPointDistanceSq = _ray$2.distanceSqToPoint( point ); + + if ( rayPointDistanceSq < localThresholdSq ) { + + var intersectPoint = new Vector3(); + + _ray$2.closestPointToPoint( point, intersectPoint ); + intersectPoint.applyMatrix4( matrixWorld ); + + var distance = raycaster.ray.origin.distanceTo( intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + distanceToRay: Math.sqrt( rayPointDistanceSq ), + point: intersectPoint, + index: index, + face: null, + object: object + + } ); + + } + +} + /** * @author mrdoob / http://mrdoob.com/ */ @@ -38426,6 +38091,9 @@ Object.assign( MaterialLoader.prototype, { if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + if ( json.clearCoatNormalMap !== undefined ) material.clearCoatNormalMap = getTexture( json.clearCoatNormalMap ); + if ( json.clearCoatNormalScale !== undefined ) material.clearCoatNormalScale = new Vector2().fromArray( json.clearCoatNormalScale ); + return material; }, @@ -40307,6 +39975,19 @@ Object.assign( FontLoader.prototype, { * @author alteredq / http://alteredqualia.com/ */ +var _BlendingMode = { + NoBlending: NoBlending, + NormalBlending: NormalBlending, + AdditiveBlending: AdditiveBlending, + SubtractiveBlending: SubtractiveBlending, + MultiplyBlending: MultiplyBlending, + CustomBlending: CustomBlending +}; + +var _color = new Color(); +var _textureLoader = new TextureLoader(); +var _materialLoader = new MaterialLoader(); + function Loader() {} Loader.Handlers = { @@ -40366,261 +40047,244 @@ Object.assign( Loader.prototype, { }, - createMaterial: ( function () { - - var BlendingMode = { - NoBlending: NoBlending, - NormalBlending: NormalBlending, - AdditiveBlending: AdditiveBlending, - SubtractiveBlending: SubtractiveBlending, - MultiplyBlending: MultiplyBlending, - CustomBlending: CustomBlending - }; - - var color = new Color(); - var textureLoader = new TextureLoader(); - var materialLoader = new MaterialLoader(); - - return function createMaterial( m, texturePath, crossOrigin ) { + createMaterial: function ( m, texturePath, crossOrigin ) { - // convert from old material format + // convert from old material format - var textures = {}; - - function loadTexture( path, repeat, offset, wrap, anisotropy ) { + var textures = {}; - var fullPath = texturePath + path; - var loader = Loader.Handlers.get( fullPath ); + // - var texture; + var json = { + uuid: _Math.generateUUID(), + type: 'MeshLambertMaterial' + }; - if ( loader !== null ) { + for ( var name in m ) { - texture = loader.load( fullPath ); + var value = m[ name ]; - } else { + switch ( name ) { - textureLoader.setCrossOrigin( crossOrigin ); - texture = textureLoader.load( fullPath ); + case 'DbgColor': + case 'DbgIndex': + case 'opticalDensity': + case 'illumination': + break; + case 'DbgName': + json.name = value; + break; + case 'blending': + json.blending = _BlendingMode[ value ]; + break; + case 'colorAmbient': + case 'mapAmbient': + console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); + break; + case 'colorDiffuse': + json.color = _color.fromArray( value ).getHex(); + break; + case 'colorSpecular': + json.specular = _color.fromArray( value ).getHex(); + break; + case 'colorEmissive': + json.emissive = _color.fromArray( value ).getHex(); + break; + case 'specularCoef': + json.shininess = value; + break; + case 'shading': + if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial'; + if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; + if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial'; + break; + case 'mapDiffuse': + json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapDiffuseRepeat': + case 'mapDiffuseOffset': + case 'mapDiffuseWrap': + case 'mapDiffuseAnisotropy': + break; + case 'mapEmissive': + json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapEmissiveRepeat': + case 'mapEmissiveOffset': + case 'mapEmissiveWrap': + case 'mapEmissiveAnisotropy': + break; + case 'mapLight': + json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapLightRepeat': + case 'mapLightOffset': + case 'mapLightWrap': + case 'mapLightAnisotropy': + break; + case 'mapAO': + json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapAORepeat': + case 'mapAOOffset': + case 'mapAOWrap': + case 'mapAOAnisotropy': + break; + case 'mapBump': + json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapBumpScale': + json.bumpScale = value; + break; + case 'mapBumpRepeat': + case 'mapBumpOffset': + case 'mapBumpWrap': + case 'mapBumpAnisotropy': + break; + case 'mapNormal': + json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapNormalFactor': + json.normalScale = value; + break; + case 'mapNormalRepeat': + case 'mapNormalOffset': + case 'mapNormalWrap': + case 'mapNormalAnisotropy': + break; + case 'mapSpecular': + json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapSpecularRepeat': + case 'mapSpecularOffset': + case 'mapSpecularWrap': + case 'mapSpecularAnisotropy': + break; + case 'mapMetalness': + json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapMetalnessRepeat': + case 'mapMetalnessOffset': + case 'mapMetalnessWrap': + case 'mapMetalnessAnisotropy': + break; + case 'mapRoughness': + json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapRoughnessRepeat': + case 'mapRoughnessOffset': + case 'mapRoughnessWrap': + case 'mapRoughnessAnisotropy': + break; + case 'mapAlpha': + json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapAlphaRepeat': + case 'mapAlphaOffset': + case 'mapAlphaWrap': + case 'mapAlphaAnisotropy': + break; + case 'flipSided': + json.side = BackSide; + break; + case 'doubleSided': + json.side = DoubleSide; + break; + case 'transparency': + console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); + json.opacity = value; + break; + case 'depthTest': + case 'depthWrite': + case 'colorWrite': + case 'opacity': + case 'reflectivity': + case 'transparent': + case 'visible': + case 'wireframe': + json[ name ] = value; + break; + case 'vertexColors': + if ( value === true ) json.vertexColors = VertexColors; + if ( value === 'face' ) json.vertexColors = FaceColors; + break; + default: + console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); + break; - } + } - if ( repeat !== undefined ) { + } - texture.repeat.fromArray( repeat ); + if ( json.type === 'MeshBasicMaterial' ) delete json.emissive; + if ( json.type !== 'MeshPhongMaterial' ) delete json.specular; - if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping; - if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping; + if ( json.opacity < 1 ) json.transparent = true; - } + _materialLoader.setTextures( textures ); - if ( offset !== undefined ) { + return _materialLoader.parse( json ); - texture.offset.fromArray( offset ); + } - } +} ); - if ( wrap !== undefined ) { +function loadTexture( path, repeat, offset, wrap, anisotropy, textures, texturePath, crossOrigin ) { - if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping; - if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping; + var fullPath = texturePath + path; + var loader = Loader.Handlers.get( fullPath ); - if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping; - if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping; + var texture; - } + if ( loader !== null ) { - if ( anisotropy !== undefined ) { + texture = loader.load( fullPath ); - texture.anisotropy = anisotropy; + } else { - } + _textureLoader.setCrossOrigin( crossOrigin ); + texture = _textureLoader.load( fullPath ); - var uuid = _Math.generateUUID(); + } - textures[ uuid ] = texture; + if ( repeat !== undefined ) { - return uuid; + texture.repeat.fromArray( repeat ); - } + if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping; + if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping; - // + } - var json = { - uuid: _Math.generateUUID(), - type: 'MeshLambertMaterial' - }; + if ( offset !== undefined ) { - for ( var name in m ) { + texture.offset.fromArray( offset ); - var value = m[ name ]; + } - switch ( name ) { + if ( wrap !== undefined ) { - case 'DbgColor': - case 'DbgIndex': - case 'opticalDensity': - case 'illumination': - break; - case 'DbgName': - json.name = value; - break; - case 'blending': - json.blending = BlendingMode[ value ]; - break; - case 'colorAmbient': - case 'mapAmbient': - console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); - break; - case 'colorDiffuse': - json.color = color.fromArray( value ).getHex(); - break; - case 'colorSpecular': - json.specular = color.fromArray( value ).getHex(); - break; - case 'colorEmissive': - json.emissive = color.fromArray( value ).getHex(); - break; - case 'specularCoef': - json.shininess = value; - break; - case 'shading': - if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial'; - if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; - if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial'; - break; - case 'mapDiffuse': - json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy ); - break; - case 'mapDiffuseRepeat': - case 'mapDiffuseOffset': - case 'mapDiffuseWrap': - case 'mapDiffuseAnisotropy': - break; - case 'mapEmissive': - json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy ); - break; - case 'mapEmissiveRepeat': - case 'mapEmissiveOffset': - case 'mapEmissiveWrap': - case 'mapEmissiveAnisotropy': - break; - case 'mapLight': - json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy ); - break; - case 'mapLightRepeat': - case 'mapLightOffset': - case 'mapLightWrap': - case 'mapLightAnisotropy': - break; - case 'mapAO': - json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy ); - break; - case 'mapAORepeat': - case 'mapAOOffset': - case 'mapAOWrap': - case 'mapAOAnisotropy': - break; - case 'mapBump': - json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy ); - break; - case 'mapBumpScale': - json.bumpScale = value; - break; - case 'mapBumpRepeat': - case 'mapBumpOffset': - case 'mapBumpWrap': - case 'mapBumpAnisotropy': - break; - case 'mapNormal': - json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy ); - break; - case 'mapNormalFactor': - json.normalScale = value; - break; - case 'mapNormalRepeat': - case 'mapNormalOffset': - case 'mapNormalWrap': - case 'mapNormalAnisotropy': - break; - case 'mapSpecular': - json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy ); - break; - case 'mapSpecularRepeat': - case 'mapSpecularOffset': - case 'mapSpecularWrap': - case 'mapSpecularAnisotropy': - break; - case 'mapMetalness': - json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy ); - break; - case 'mapMetalnessRepeat': - case 'mapMetalnessOffset': - case 'mapMetalnessWrap': - case 'mapMetalnessAnisotropy': - break; - case 'mapRoughness': - json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy ); - break; - case 'mapRoughnessRepeat': - case 'mapRoughnessOffset': - case 'mapRoughnessWrap': - case 'mapRoughnessAnisotropy': - break; - case 'mapAlpha': - json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy ); - break; - case 'mapAlphaRepeat': - case 'mapAlphaOffset': - case 'mapAlphaWrap': - case 'mapAlphaAnisotropy': - break; - case 'flipSided': - json.side = BackSide; - break; - case 'doubleSided': - json.side = DoubleSide; - break; - case 'transparency': - console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); - json.opacity = value; - break; - case 'depthTest': - case 'depthWrite': - case 'colorWrite': - case 'opacity': - case 'reflectivity': - case 'transparent': - case 'visible': - case 'wireframe': - json[ name ] = value; - break; - case 'vertexColors': - if ( value === true ) json.vertexColors = VertexColors; - if ( value === 'face' ) json.vertexColors = FaceColors; - break; - default: - console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); - break; + if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping; + if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping; - } + if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping; + if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping; - } + } - if ( json.type === 'MeshBasicMaterial' ) delete json.emissive; - if ( json.type !== 'MeshPhongMaterial' ) delete json.specular; + if ( anisotropy !== undefined ) { - if ( json.opacity < 1 ) json.transparent = true; + texture.anisotropy = anisotropy; - materialLoader.setTextures( textures ); + } - return materialLoader.parse( json ); + var uuid = _Math.generateUUID(); - }; + textures[ uuid ] = texture; - } )() + return uuid; -} ); +} /** * @author mrdoob / http://mrdoob.com/ @@ -41063,7 +40727,8 @@ AmbientLightProbe.prototype = Object.assign( Object.create( LightProbe.prototype } ); -var _eyeRight, _eyeLeft; +var _eyeRight = new Matrix4(); +var _eyeLeft = new Matrix4(); /** * @author mrdoob / http://mrdoob.com/ @@ -41101,13 +40766,6 @@ Object.assign( StereoCamera.prototype, { update: function ( camera ) { - if ( _eyeRight === undefined ) { - - _eyeRight = new Matrix4(); - _eyeLeft = new Matrix4(); - - } - var cache = this._cache; var needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || @@ -41242,8 +40900,10 @@ Object.assign( Clock.prototype, { * @author mrdoob / http://mrdoob.com/ */ -var _position, _quaternion$2, _scale; -var _orientation; +var _position$2 = new Vector3(); +var _quaternion$3 = new Quaternion(); +var _scale$1 = new Vector3(); +var _orientation = new Vector3(); function AudioListener() { @@ -41336,23 +40996,14 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), { Object3D.prototype.updateMatrixWorld.call( this, force ); - if ( _position === undefined ) { - - _position = new Vector3(); - _quaternion$2 = new Quaternion(); - _scale = new Vector3(); - _orientation = new Vector3(); - - } - var listener = this.context.listener; var up = this.up; this.timeDelta = this._clock.getDelta(); - this.matrixWorld.decompose( _position, _quaternion$2, _scale ); + this.matrixWorld.decompose( _position$2, _quaternion$3, _scale$1 ); - _orientation.set( 0, 0, - 1 ).applyQuaternion( _quaternion$2 ); + _orientation.set( 0, 0, - 1 ).applyQuaternion( _quaternion$3 ); if ( listener.positionX ) { @@ -41360,9 +41011,9 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), { var endTime = this.context.currentTime + this.timeDelta; - listener.positionX.linearRampToValueAtTime( _position.x, endTime ); - listener.positionY.linearRampToValueAtTime( _position.y, endTime ); - listener.positionZ.linearRampToValueAtTime( _position.z, endTime ); + listener.positionX.linearRampToValueAtTime( _position$2.x, endTime ); + listener.positionY.linearRampToValueAtTime( _position$2.y, endTime ); + listener.positionZ.linearRampToValueAtTime( _position$2.z, endTime ); listener.forwardX.linearRampToValueAtTime( _orientation.x, endTime ); listener.forwardY.linearRampToValueAtTime( _orientation.y, endTime ); listener.forwardZ.linearRampToValueAtTime( _orientation.z, endTime ); @@ -41372,7 +41023,7 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), { } else { - listener.setPosition( _position.x, _position.y, _position.z ); + listener.setPosition( _position$2.x, _position$2.y, _position$2.z ); listener.setOrientation( _orientation.x, _orientation.y, _orientation.z, up.x, up.y, up.z ); } @@ -41405,6 +41056,7 @@ function Audio( listener ) { this.loop = false; this.startTime = 0; this.offset = 0; + this.duration = undefined; this.playbackRate = 1; this.isPlaying = false; this.hasPlaybackControl = true; @@ -41479,7 +41131,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { source.loop = this.loop; source.onended = this.onEnded.bind( this ); this.startTime = this.context.currentTime; - source.start( this.startTime, this.offset ); + source.start( this.startTime, this.offset, this.duration ); this.isPlaying = true; @@ -41727,8 +41379,10 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { * @author mrdoob / http://mrdoob.com/ */ -var _position$1, _quaternion$3, _scale$1; -var _orientation$1; +var _position$3 = new Vector3(); +var _quaternion$4 = new Quaternion(); +var _scale$2 = new Vector3(); +var _orientation$1 = new Vector3(); function PositionalAudio( listener ) { @@ -41820,20 +41474,11 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), { Object3D.prototype.updateMatrixWorld.call( this, force ); - if ( _position$1 === undefined ) { - - _position$1 = new Vector3(); - _quaternion$3 = new Quaternion(); - _scale$1 = new Vector3(); - _orientation$1 = new Vector3(); - - } - if ( this.hasPlaybackControl === true && this.isPlaying === false ) return; - this.matrixWorld.decompose( _position$1, _quaternion$3, _scale$1 ); + this.matrixWorld.decompose( _position$3, _quaternion$4, _scale$2 ); - _orientation$1.set( 0, 0, 1 ).applyQuaternion( _quaternion$3 ); + _orientation$1.set( 0, 0, 1 ).applyQuaternion( _quaternion$4 ); var panner = this.panner; @@ -41843,16 +41488,16 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), { var endTime = this.context.currentTime + this.listener.timeDelta; - panner.positionX.linearRampToValueAtTime( _position$1.x, endTime ); - panner.positionY.linearRampToValueAtTime( _position$1.y, endTime ); - panner.positionZ.linearRampToValueAtTime( _position$1.z, endTime ); + panner.positionX.linearRampToValueAtTime( _position$3.x, endTime ); + panner.positionY.linearRampToValueAtTime( _position$3.y, endTime ); + panner.positionZ.linearRampToValueAtTime( _position$3.z, endTime ); panner.orientationX.linearRampToValueAtTime( _orientation$1.x, endTime ); panner.orientationY.linearRampToValueAtTime( _orientation$1.y, endTime ); panner.orientationZ.linearRampToValueAtTime( _orientation$1.z, endTime ); } else { - panner.setPosition( _position$1.x, _position$1.y, _position$1.z ); + panner.setPosition( _position$3.x, _position$3.y, _position$3.z ); panner.setOrientation( _orientation$1.x, _orientation$1.y, _orientation$1.z ); } @@ -42118,7 +41763,40 @@ Object.assign( PropertyMixer.prototype, { */ // Characters [].:/ are reserved for track binding syntax. -var RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +var _RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +var _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' ); + +// Attempts to allow node names from any language. ES5's `\w` regexp matches +// only latin characters, and the unicode \p{L} is not yet supported. So +// instead, we exclude reserved characters and match everything else. +var _wordChar = '[^' + _RESERVED_CHARS_RE + ']'; +var _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; + +// Parent directories, delimited by '/' or ':'. Currently unused, but must +// be matched to parse the rest of the track name. +var _directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', _wordChar ); + +// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. +var _nodeRe = /(WCOD+)?/.source.replace( 'WCOD', _wordCharOrDot ); + +// Object on target node, and accessor. May not contain reserved +// characters. Accessor may contain any character except closing bracket. +var _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', _wordChar ); + +// Property and accessor. May not contain reserved characters. Accessor may +// contain any non-bracket characters. +var _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', _wordChar ); + +var _trackRe = new RegExp( '' + + '^' + + _directoryRe + + _nodeRe + + _objectRe + + _propertyRe + + '$' +); + +var _supportedObjectNames = [ 'material', 'materials', 'bones' ]; function Composite( targetGroup, path, optionalParsedPath ) { @@ -42218,101 +41896,59 @@ Object.assign( PropertyBinding, { * @param {string} name Node name to be sanitized. * @return {string} */ - sanitizeNodeName: ( function () { - - var reservedRe = new RegExp( '[' + RESERVED_CHARS_RE + ']', 'g' ); - - return function sanitizeNodeName( name ) { - - return name.replace( /\s/g, '_' ).replace( reservedRe, '' ); - - }; - - }() ), - - parseTrackName: function () { - - // Attempts to allow node names from any language. ES5's `\w` regexp matches - // only latin characters, and the unicode \p{L} is not yet supported. So - // instead, we exclude reserved characters and match everything else. - var wordChar = '[^' + RESERVED_CHARS_RE + ']'; - var wordCharOrDot = '[^' + RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; - - // Parent directories, delimited by '/' or ':'. Currently unused, but must - // be matched to parse the rest of the track name. - var directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', wordChar ); - - // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. - var nodeRe = /(WCOD+)?/.source.replace( 'WCOD', wordCharOrDot ); - - // Object on target node, and accessor. May not contain reserved - // characters. Accessor may contain any character except closing bracket. - var objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', wordChar ); - - // Property and accessor. May not contain reserved characters. Accessor may - // contain any non-bracket characters. - var propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', wordChar ); - - var trackRe = new RegExp( '' - + '^' - + directoryRe - + nodeRe - + objectRe - + propertyRe - + '$' - ); + sanitizeNodeName: function ( name ) { - var supportedObjectNames = [ 'material', 'materials', 'bones' ]; + return name.replace( /\s/g, '_' ).replace( _reservedRe, '' ); - return function parseTrackName( trackName ) { + }, - var matches = trackRe.exec( trackName ); + parseTrackName: function ( trackName ) { - if ( ! matches ) { + var matches = _trackRe.exec( trackName ); - throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); + if ( ! matches ) { - } + throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); - var results = { - // directoryName: matches[ 1 ], // (tschw) currently unused - nodeName: matches[ 2 ], - objectName: matches[ 3 ], - objectIndex: matches[ 4 ], - propertyName: matches[ 5 ], // required - propertyIndex: matches[ 6 ] - }; + } - var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); + var results = { + // directoryName: matches[ 1 ], // (tschw) currently unused + nodeName: matches[ 2 ], + objectName: matches[ 3 ], + objectIndex: matches[ 4 ], + propertyName: matches[ 5 ], // required + propertyIndex: matches[ 6 ] + }; - if ( lastDot !== undefined && lastDot !== - 1 ) { + var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); - var objectName = results.nodeName.substring( lastDot + 1 ); + if ( lastDot !== undefined && lastDot !== - 1 ) { - // Object names must be checked against a whitelist. Otherwise, there - // is no way to parse 'foo.bar.baz': 'baz' must be a property, but - // 'bar' could be the objectName, or part of a nodeName (which can - // include '.' characters). - if ( supportedObjectNames.indexOf( objectName ) !== - 1 ) { + var objectName = results.nodeName.substring( lastDot + 1 ); - results.nodeName = results.nodeName.substring( 0, lastDot ); - results.objectName = objectName; + // Object names must be checked against a whitelist. Otherwise, there + // is no way to parse 'foo.bar.baz': 'baz' must be a property, but + // 'bar' could be the objectName, or part of a nodeName (which can + // include '.' characters). + if ( _supportedObjectNames.indexOf( objectName ) !== - 1 ) { - } + results.nodeName = results.nodeName.substring( 0, lastDot ); + results.objectName = objectName; } - if ( results.propertyName === null || results.propertyName.length === 0 ) { + } - throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); + if ( results.propertyName === null || results.propertyName.length === 0 ) { - } + throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); - return results; + } - }; + return results; - }(), + }, findNode: function ( root, nodeName ) { @@ -44705,6 +44341,7 @@ function Raycaster( origin, direction, near, far ) { this.near = near || 0; this.far = far || Infinity; + this.camera = null; this.params = { Mesh: {}, @@ -44771,13 +44408,13 @@ Object.assign( Raycaster.prototype, { this.ray.origin.setFromMatrixPosition( camera.matrixWorld ); this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize(); - this._camera = camera; + this.camera = camera; } else if ( ( camera && camera.isOrthographicCamera ) ) { this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ); - this._camera = camera; + this.camera = camera; } else { @@ -44977,7 +44614,7 @@ Object.assign( Cylindrical.prototype, { * @author bhouston / http://clara.io */ -var _vector$5; +var _vector$6 = new Vector2(); function Box2( min, max ) { @@ -45013,9 +44650,7 @@ Object.assign( Box2.prototype, { setFromCenterAndSize: function ( center, size ) { - if ( _vector$5 === undefined ) _vector$5 = new Vector2(); - - var halfSize = _vector$5.copy( size ).multiplyScalar( 0.5 ); + var halfSize = _vector$6.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -45165,9 +44800,7 @@ Object.assign( Box2.prototype, { distanceToPoint: function ( point ) { - if ( _vector$5 === undefined ) _vector$5 = new Vector2(); - - var clampedPoint = _vector$5.copy( point ).clamp( this.min, this.max ); + var clampedPoint = _vector$6.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); }, @@ -45211,7 +44844,8 @@ Object.assign( Box2.prototype, { * @author bhouston / http://clara.io */ -var _startP, _startEnd; +var _startP = new Vector3(); +var _startEnd = new Vector3(); function Line3( start, end ) { @@ -45299,13 +44933,6 @@ Object.assign( Line3.prototype, { closestPointToPointParameter: function ( point, clampToLine ) { - if ( _startP === undefined ) { - - _startP = new Vector3(); - _startEnd = new Vector3(); - - } - _startP.subVectors( point, this.start ); _startEnd.subVectors( this.end, this.start ); @@ -45379,7 +45006,10 @@ ImmediateRenderObject.prototype.isImmediateRenderObject = true; * @author WestLangley / http://github.com/WestLangley */ -var _v1$4, _v2$3, _normalMatrix$1, _keys; +var _v1$5 = new Vector3(); +var _v2$3 = new Vector3(); +var _normalMatrix$1 = new Matrix3(); +var _keys = [ 'a', 'b', 'c' ]; function VertexNormalsHelper( object, size, hex, linewidth ) { @@ -45430,15 +45060,6 @@ VertexNormalsHelper.prototype.constructor = VertexNormalsHelper; VertexNormalsHelper.prototype.update = function () { - if ( _normalMatrix$1 === undefined ) { - - _v1$4 = new Vector3(); - _v2$3 = new Vector3(); - _normalMatrix$1 = new Matrix3(); - _keys = [ 'a', 'b', 'c' ]; - - } - this.object.updateMatrixWorld( true ); _normalMatrix$1.getNormalMatrix( this.object.matrixWorld ); @@ -45469,11 +45090,11 @@ VertexNormalsHelper.prototype.update = function () { var normal = face.vertexNormals[ j ]; - _v1$4.copy( vertex ).applyMatrix4( matrixWorld ); + _v1$5.copy( vertex ).applyMatrix4( matrixWorld ); - _v2$3.copy( normal ).applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$4 ); + _v2$3.copy( normal ).applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$5 ); - position.setXYZ( idx, _v1$4.x, _v1$4.y, _v1$4.z ); + position.setXYZ( idx, _v1$5.x, _v1$5.y, _v1$5.z ); idx = idx + 1; @@ -45497,13 +45118,13 @@ VertexNormalsHelper.prototype.update = function () { for ( var j = 0, jl = objPos.count; j < jl; j ++ ) { - _v1$4.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld ); + _v1$5.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld ); _v2$3.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) ); - _v2$3.applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$4 ); + _v2$3.applyMatrix3( _normalMatrix$1 ).normalize().multiplyScalar( this.size ).add( _v1$5 ); - position.setXYZ( idx, _v1$4.x, _v1$4.y, _v1$4.z ); + position.setXYZ( idx, _v1$5.x, _v1$5.y, _v1$5.z ); idx = idx + 1; @@ -45525,7 +45146,7 @@ VertexNormalsHelper.prototype.update = function () { * @author WestLangley / http://github.com/WestLangley */ -var _vector$6; +var _vector$7 = new Vector3(); function SpotLightHelper( light, color ) { @@ -45584,8 +45205,6 @@ SpotLightHelper.prototype.dispose = function () { SpotLightHelper.prototype.update = function () { - if ( _vector$6 === undefined ) _vector$6 = new Vector3(); - this.light.updateMatrixWorld(); var coneLength = this.light.distance ? this.light.distance : 1000; @@ -45593,9 +45212,9 @@ SpotLightHelper.prototype.update = function () { this.cone.scale.set( coneWidth, coneWidth, coneLength ); - _vector$6.setFromMatrixPosition( this.light.target.matrixWorld ); + _vector$7.setFromMatrixPosition( this.light.target.matrixWorld ); - this.cone.lookAt( _vector$6 ); + this.cone.lookAt( _vector$7 ); if ( this.color !== undefined ) { @@ -45617,7 +45236,9 @@ SpotLightHelper.prototype.update = function () { * @author Mugen87 / https://github.com/Mugen87 */ -var _vector$7, _boneMatrix, _matrixWorldInv; +var _vector$8 = new Vector3(); +var _boneMatrix = new Matrix4(); +var _matrixWorldInv = new Matrix4(); function getBoneList( object ) { @@ -45686,14 +45307,6 @@ SkeletonHelper.prototype.constructor = SkeletonHelper; SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { - if ( _matrixWorldInv === undefined ) { - - _vector$7 = new Vector3(); - _boneMatrix = new Matrix4(); - _matrixWorldInv = new Matrix4(); - - } - var bones = this.bones; var geometry = this.geometry; @@ -45708,12 +45321,12 @@ SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { if ( bone.parent && bone.parent.isBone ) { _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.matrixWorld ); - _vector$7.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j, _vector$7.x, _vector$7.y, _vector$7.z ); + _vector$8.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j, _vector$8.x, _vector$8.y, _vector$8.z ); _boneMatrix.multiplyMatrices( _matrixWorldInv, bone.parent.matrixWorld ); - _vector$7.setFromMatrixPosition( _boneMatrix ); - position.setXYZ( j + 1, _vector$7.x, _vector$7.y, _vector$7.z ); + _vector$8.setFromMatrixPosition( _boneMatrix ); + position.setXYZ( j + 1, _vector$8.x, _vector$8.y, _vector$8.z ); j += 2; @@ -45895,7 +45508,9 @@ RectAreaLightHelper.prototype.dispose = function () { * @author Mugen87 / https://github.com/Mugen87 */ -var _vector$8, _color1, _color2; +var _vector$9 = new Vector3(); +var _color1 = new Color(); +var _color2 = new Color(); function HemisphereLightHelper( light, size, color ) { @@ -45938,14 +45553,6 @@ HemisphereLightHelper.prototype.dispose = function () { HemisphereLightHelper.prototype.update = function () { - if ( _color2 === undefined ) { - - _vector$8 = new Vector3(); - _color1 = new Color(); - _color2 = new Color(); - - } - var mesh = this.children[ 0 ]; if ( this.color !== undefined ) { @@ -45971,7 +45578,7 @@ HemisphereLightHelper.prototype.update = function () { } - mesh.lookAt( _vector$8.setFromMatrixPosition( this.light.matrixWorld ).negate() ); + mesh.lookAt( _vector$9.setFromMatrixPosition( this.light.matrixWorld ).negate() ); }; @@ -46377,7 +45984,9 @@ PositionalAudioHelper.prototype.dispose = function () { * @author WestLangley / http://github.com/WestLangley */ -var _v1$5, _v2$4, _normalMatrix$2; +var _v1$6 = new Vector3(); +var _v2$4 = new Vector3(); +var _normalMatrix$2 = new Matrix3(); function FaceNormalsHelper( object, size, hex, linewidth ) { @@ -46429,14 +46038,6 @@ FaceNormalsHelper.prototype.constructor = FaceNormalsHelper; FaceNormalsHelper.prototype.update = function () { - if ( _normalMatrix$2 === undefined ) { - - _v1$5 = new Vector3(); - _v2$4 = new Vector3(); - _normalMatrix$2 = new Matrix3(); - - } - this.object.updateMatrixWorld( true ); _normalMatrix$2.getNormalMatrix( this.object.matrixWorld ); @@ -46461,15 +46062,15 @@ FaceNormalsHelper.prototype.update = function () { var normal = face.normal; - _v1$5.copy( vertices[ face.a ] ) + _v1$6.copy( vertices[ face.a ] ) .add( vertices[ face.b ] ) .add( vertices[ face.c ] ) .divideScalar( 3 ) .applyMatrix4( matrixWorld ); - _v2$4.copy( normal ).applyMatrix3( _normalMatrix$2 ).normalize().multiplyScalar( this.size ).add( _v1$5 ); + _v2$4.copy( normal ).applyMatrix3( _normalMatrix$2 ).normalize().multiplyScalar( this.size ).add( _v1$6 ); - position.setXYZ( idx, _v1$5.x, _v1$5.y, _v1$5.z ); + position.setXYZ( idx, _v1$6.x, _v1$6.y, _v1$6.z ); idx = idx + 1; @@ -46489,7 +46090,9 @@ FaceNormalsHelper.prototype.update = function () { * @author WestLangley / http://github.com/WestLangley */ -var _v1$6, _v2$5, _v3$1; +var _v1$7 = new Vector3(); +var _v2$5 = new Vector3(); +var _v3$1 = new Vector3(); function DirectionalLightHelper( light, size, color ) { @@ -46543,17 +46146,9 @@ DirectionalLightHelper.prototype.dispose = function () { DirectionalLightHelper.prototype.update = function () { - if ( _v3$1 === undefined ) { - - _v1$6 = new Vector3(); - _v2$5 = new Vector3(); - _v3$1 = new Vector3(); - - } - - _v1$6.setFromMatrixPosition( this.light.matrixWorld ); + _v1$7.setFromMatrixPosition( this.light.matrixWorld ); _v2$5.setFromMatrixPosition( this.light.target.matrixWorld ); - _v3$1.subVectors( _v2$5, _v1$6 ); + _v3$1.subVectors( _v2$5, _v1$7 ); this.lightPlane.lookAt( _v2$5 ); @@ -46584,7 +46179,8 @@ DirectionalLightHelper.prototype.update = function () { * http://evanw.github.com/lightgl.js/tests/shadowmap.html */ -var _vector$9, _camera; +var _vector$a = new Vector3(); +var _camera = new Camera(); function CameraHelper( camera ) { @@ -46695,8 +46291,6 @@ CameraHelper.prototype.constructor = CameraHelper; CameraHelper.prototype.update = function () { - if ( _camera === undefined ) _camera = new Camera(); - var geometry = this.geometry; var pointMap = this.pointMap; @@ -46750,9 +46344,7 @@ CameraHelper.prototype.update = function () { function setPoint( point, pointMap, geometry, camera, x, y, z ) { - if ( _vector$9 === undefined ) _vector$9 = new Vector3(); - - _vector$9.set( x, y, z ).unproject( camera ); + _vector$a.set( x, y, z ).unproject( camera ); var points = pointMap[ point ]; @@ -46762,7 +46354,7 @@ function setPoint( point, pointMap, geometry, camera, x, y, z ) { for ( var i = 0, l = points.length; i < l; i ++ ) { - position.setXYZ( points[ i ], _vector$9.x, _vector$9.y, _vector$9.z ); + position.setXYZ( points[ i ], _vector$a.x, _vector$a.y, _vector$a.z ); } @@ -46775,7 +46367,7 @@ function setPoint( point, pointMap, geometry, camera, x, y, z ) { * @author Mugen87 / http://github.com/Mugen87 */ -var _box$1; +var _box$2 = new Box3(); function BoxHelper( object, color ) { @@ -46803,8 +46395,6 @@ BoxHelper.prototype.constructor = BoxHelper; BoxHelper.prototype.update = function ( object ) { - if ( _box$1 === undefined ) _box$1 = new Box3(); - if ( object !== undefined ) { console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' ); @@ -46813,14 +46403,14 @@ BoxHelper.prototype.update = function ( object ) { if ( this.object !== undefined ) { - _box$1.setFromObject( this.object ); + _box$2.setFromObject( this.object ); } - if ( _box$1.isEmpty() ) return; + if ( _box$2.isEmpty() ) return; - var min = _box$1.min; - var max = _box$1.max; + var min = _box$2.min; + var max = _box$2.max; /* 5____4 @@ -46998,7 +46588,7 @@ PlaneHelper.prototype.updateMatrixWorld = function ( force ) { * headWidth - Number */ -var _axis; +var _axis = new Vector3(); var _lineGeometry, _coneGeometry; function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { @@ -47044,8 +46634,6 @@ ArrowHelper.prototype.constructor = ArrowHelper; ArrowHelper.prototype.setDirection = function ( dir ) { - if ( _axis === undefined ) _axis = new Vector3(); - // dir is assumed to be normalized if ( dir.y > 0.99999 ) { @@ -47656,17 +47244,10 @@ Object.assign( Matrix4.prototype, { }, getPosition: function () { - var v1; - - return function getPosition() { + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return new Vector3().setFromMatrixColumn( this, 3 ); - if ( v1 === undefined ) v1 = new Vector3(); - console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); - return v1.setFromMatrixColumn( this, 3 ); - - }; - - }(), + }, setRotationFromQuaternion: function ( q ) { console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); diff --git a/docs/api/en/audio/Audio.html b/docs/api/en/audio/Audio.html index b739dd966ba373..b4f91083ac7e07 100644 --- a/docs/api/en/audio/Audio.html +++ b/docs/api/en/audio/Audio.html @@ -91,6 +91,9 @@

[property:Number startTime]

[property:Number offset]

An offset to the time within the audio buffer that playback should begin. Same as the *offset* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *0*.

+

[property:Number duration]

+

Overrides the duration of the audio. Same as the *duration* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *undefined* to play the whole buffer.

+

[property:String source]

An [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode AudioBufferSourceNode] created using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource AudioContext.createBufferSource]().

diff --git a/docs/api/en/core/Raycaster.html b/docs/api/en/core/Raycaster.html index 61de6225bc2590..2d15cdbc03c9d7 100644 --- a/docs/api/en/core/Raycaster.html +++ b/docs/api/en/core/Raycaster.html @@ -103,6 +103,14 @@

[property:float near]

This value shouldn't be negative and should be smaller than the far property.

+

[property:Camera camera]

+

+ The camera to use when raycasting against view-dependent objects such as billboarded objects like [page:Sprites]. This field + can be set manually or is set when calling "setFromCamera". + + Defaults to null. +

+

[property:Object params]

An object with the following properties: diff --git a/docs/api/en/math/Matrix4.html b/docs/api/en/math/Matrix4.html index cc40f54e563600..f37b05e1f1bbf1 100644 --- a/docs/api/en/math/Matrix4.html +++ b/docs/api/en/math/Matrix4.html @@ -56,7 +56,7 @@

A Note on Row-Major and Column-Major Ordering

This means that calling -var m = new Matrix4(); +var m = new THREE.Matrix4(); m.set( 11, 12, 13, 14, 21, 22, 23, 24, diff --git a/docs/api/en/scenes/FogExp2.html b/docs/api/en/scenes/FogExp2.html index 2fdbf28b6ec233..bd196454bbdb4f 100644 --- a/docs/api/en/scenes/FogExp2.html +++ b/docs/api/en/scenes/FogExp2.html @@ -10,7 +10,7 @@

[name]

-

This class contains the parameters that define exponential fog, i.e., that grows exponentially denser with the distance.

+

This class contains the parameters that define exponential squared fog, which gives a clear view near the camera and a faster than exponentially densening fog farther from the camera.

Constructor

diff --git a/docs/manual/en/introduction/Creating-a-scene.html b/docs/manual/en/introduction/Creating-a-scene.html index eda03230f134b8..8b21df630c4587 100644 --- a/docs/manual/en/introduction/Creating-a-scene.html +++ b/docs/manual/en/introduction/Creating-a-scene.html @@ -20,7 +20,7 @@

Before we start

<!DOCTYPE html> <html> <head> - <meta charset=utf-8> + <meta charset="utf-8"> <title>My first three.js app</title> <style> body { margin: 0; } @@ -118,7 +118,7 @@

Animating the cube

The result

Congratulations! You have now completed your first three.js application. It's simple, you have to start somewhere.

-

The full code is available below. Play around with it to get a better understanding of how it works.

+

The full code is available below and as an editable [link:https://jsfiddle.net/mkba0ecu/ live example]. Play around with it to get a better understanding of how it works.

<html> diff --git a/docs/manual/en/introduction/How-to-use-WebGL2.html b/docs/manual/en/introduction/How-to-use-WebGL2.html index 139295061da8fa..00d136287b44b5 100644 --- a/docs/manual/en/introduction/How-to-use-WebGL2.html +++ b/docs/manual/en/introduction/How-to-use-WebGL2.html @@ -48,9 +48,14 @@

Workflow

automatically convert the built-in material's shader code to GLSL ES 3.00.

+

+ Since you are manually creating the WebGL 2 rendering context, you also have to pass in all necessary context attributes. + Note: It's not possible to modify these attributes after the context has been created, so passing them to the WebGLRenderer won't have any effect. +

+ var canvas = document.createElement( 'canvas' ); -var context = canvas.getContext( 'webgl2' ); +var context = canvas.getContext( 'webgl2', { alpha: false } ); var renderer = new THREE.WebGLRenderer( { canvas: canvas, context: context } ); diff --git a/docs/manual/zh/introduction/Creating-a-scene.html b/docs/manual/zh/introduction/Creating-a-scene.html index 1c2c6b18818afa..b8d63faa3d5a83 100644 --- a/docs/manual/zh/introduction/Creating-a-scene.html +++ b/docs/manual/zh/introduction/Creating-a-scene.html @@ -20,7 +20,7 @@

开始之前

<!DOCTYPE html> <html> <head> - <meta charset=utf-8> + <meta charset="utf-8"> <title>My first three.js app</title> <style> body { margin: 0; } diff --git a/editor/index.html b/editor/index.html index 907288d68dab3f..48bd5f0de0965b 100644 --- a/editor/index.html +++ b/editor/index.html @@ -22,8 +22,6 @@ - - @@ -45,7 +43,6 @@ - diff --git a/editor/js/Loader.js b/editor/js/Loader.js index 53b166469faee4..a552d05567e6f4 100644 --- a/editor/js/Loader.js +++ b/editor/js/Loader.js @@ -140,35 +140,6 @@ var Loader = function ( editor ) { break; - case 'ctm': - - reader.addEventListener( 'load', function ( event ) { - - var data = new Uint8Array( event.target.result ); - - var stream = new CTM.Stream( data ); - stream.offset = 0; - - var loader = new THREE.CTMLoader(); - loader.createModel( new CTM.File( stream ), function ( geometry ) { - - geometry.sourceType = "ctm"; - geometry.sourceFile = file.name; - - var material = new THREE.MeshStandardMaterial(); - - var mesh = new THREE.Mesh( geometry, material ); - mesh.name = filename; - - editor.execute( new AddObjectCommand( editor, mesh ) ); - - } ); - - }, false ); - reader.readAsArrayBuffer( file ); - - break; - case 'dae': reader.addEventListener( 'load', function ( event ) { diff --git a/editor/sw.js b/editor/sw.js index 23438018f67eee..ea7658c9821c1a 100644 --- a/editor/sw.js +++ b/editor/sw.js @@ -13,8 +13,6 @@ const staticAssets = [ '../examples/js/libs/chevrotain.min.js', '../examples/js/libs/jszip.min.js', '../examples/js/libs/inflate.min.js', - '../examples/js/libs/lzma.js', - '../examples/js/libs/ctm.js', '../examples/js/loaders/AMFLoader.js', '../examples/js/loaders/AWDLoader.js', @@ -36,7 +34,6 @@ const staticAssets = [ '../examples/js/loaders/TDSLoader.js', '../examples/js/loaders/VRMLLoader.js', '../examples/js/loaders/VTKLoader.js', - '../examples/js/loaders/ctm/CTMLoader.js', '../examples/js/exporters/ColladaExporter.js', '../examples/js/exporters/GLTFExporter.js', diff --git a/examples/files.js b/examples/files.js index f6880cee334ba1..ef2ce551d4f399 100644 --- a/examples/files.js +++ b/examples/files.js @@ -85,8 +85,6 @@ var files = { "webgl_loader_collada", "webgl_loader_collada_kinematics", "webgl_loader_collada_skinning", - "webgl_loader_ctm", - "webgl_loader_ctm_materials", "webgl_loader_draco", "webgl_loader_fbx", "webgl_loader_fbx_nurbs", @@ -103,7 +101,6 @@ var files = { "webgl_loader_mmd", "webgl_loader_mmd_pose", "webgl_loader_mmd_audio", - "webgl_loader_nodes", "webgl_loader_nrrd", "webgl_loader_obj", "webgl_loader_obj_mtl", @@ -160,13 +157,10 @@ var files = { "webgl_materials_envmaps", "webgl_materials_envmaps_exr", "webgl_materials_envmaps_hdr", - "webgl_materials_envmaps_hdr_nodes", "webgl_materials_envmaps_parallax", - "webgl_materials_envmaps_pmrem_nodes", "webgl_materials_grass", "webgl_materials_lightmap", "webgl_materials_matcap", - "webgl_materials_nodes", "webgl_materials_normalmap", "webgl_materials_normalmap_object_space", "webgl_materials_parallaxmap", @@ -194,7 +188,6 @@ var files = { "webgl_materials_sheen", "webgl_math_orientation_transform", "webgl_mirror", - "webgl_mirror_nodes", "webgl_modifier_simplifier", "webgl_modifier_subdivision", "webgl_modifier_tessellation", @@ -215,7 +208,6 @@ var files = { "webgl_panorama_equirectangular", "webgl_performance", "webgl_performance_doublesided", - "webgl_performance_nodes", "webgl_performance_static", "webgl_points_billboards", "webgl_points_dynamic", @@ -243,7 +235,6 @@ var files = { "webgl_shadowmesh", "webgl_skinning_simple", "webgl_sprites", - "webgl_sprites_nodes", "webgl_terrain_dynamic", "webgl_test_memory", "webgl_test_memory2", @@ -253,6 +244,17 @@ var files = { "webgl_water", "webgl_water_flowmap" ], + "webgl / nodes": [ + "webgl_loader_nodes", + "webgl_materials_envmaps_hdr_nodes", + "webgl_materials_envmaps_pmrem_nodes", + "webgl_materials_nodes", + "webgl_mirror_nodes", + "webgl_performance_nodes", + "webgl_postprocessing_nodes", + "webgl_postprocessing_nodes_pass", + "webgl_sprites_nodes", + ], "webgl / postprocessing": [ "webgl_postprocessing", "webgl_postprocessing_advanced", @@ -268,8 +270,6 @@ var files = { "webgl_postprocessing_masking", "webgl_postprocessing_ssaa", "webgl_postprocessing_ssaa_unbiased", - "webgl_postprocessing_nodes", - "webgl_postprocessing_nodes_pass", "webgl_postprocessing_outline", "webgl_postprocessing_pixel", "webgl_postprocessing_procedural", diff --git a/examples/js/controls/DragControls.js b/examples/js/controls/DragControls.js index 9067e0edc87b64..6ea844aa8d5c5b 100644 --- a/examples/js/controls/DragControls.js +++ b/examples/js/controls/DragControls.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / https://github.com/zz85 * @author mrdoob / http://mrdoob.com * Running this will allow you to drag three.js objects around the screen. diff --git a/examples/js/controls/OrbitControls.js b/examples/js/controls/OrbitControls.js index f23982baa97774..82792fb7f78fbb 100644 --- a/examples/js/controls/OrbitControls.js +++ b/examples/js/controls/OrbitControls.js @@ -460,32 +460,24 @@ THREE.OrbitControls = function ( object, domElement ) { function handleMouseDownRotate( event ) { - //console.log( 'handleMouseDownRotate' ); - rotateStart.set( event.clientX, event.clientY ); } function handleMouseDownDolly( event ) { - //console.log( 'handleMouseDownDolly' ); - dollyStart.set( event.clientX, event.clientY ); } function handleMouseDownPan( event ) { - //console.log( 'handleMouseDownPan' ); - panStart.set( event.clientX, event.clientY ); } function handleMouseMoveRotate( event ) { - //console.log( 'handleMouseMoveRotate' ); - rotateEnd.set( event.clientX, event.clientY ); rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); @@ -504,8 +496,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleMouseMoveDolly( event ) { - //console.log( 'handleMouseMoveDolly' ); - dollyEnd.set( event.clientX, event.clientY ); dollyDelta.subVectors( dollyEnd, dollyStart ); @@ -528,8 +518,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleMouseMovePan( event ) { - //console.log( 'handleMouseMovePan' ); - panEnd.set( event.clientX, event.clientY ); panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); @@ -544,14 +532,12 @@ THREE.OrbitControls = function ( object, domElement ) { function handleMouseUp( /*event*/ ) { - // console.log( 'handleMouseUp' ); + // no-op } function handleMouseWheel( event ) { - // console.log( 'handleMouseWheel' ); - if ( event.deltaY < 0 ) { dollyOut( getZoomScale() ); @@ -568,8 +554,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleKeyDown( event ) { - // console.log( 'handleKeyDown' ); - var needsUpdate = false; switch ( event.keyCode ) { @@ -610,8 +594,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchStartRotate( event ) { - //console.log( 'handleTouchStartRotate' ); - if ( event.touches.length == 1 ) { rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -629,8 +611,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchStartPan( event ) { - //console.log( 'handleTouchStartPan' ); - if ( event.touches.length == 1 ) { panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -648,8 +628,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchStartDolly( event ) { - //console.log( 'handleTouchStartDolly' ); - var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; @@ -661,8 +639,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchStartDollyPan( event ) { - //console.log( 'handleTouchStartDollyPan' ); - if ( scope.enableZoom ) handleTouchStartDolly( event ); if ( scope.enablePan ) handleTouchStartPan( event ); @@ -671,8 +647,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchStartDollyRotate( event ) { - //console.log( 'handleTouchStartDollyRotate' ); - if ( scope.enableZoom ) handleTouchStartDolly( event ); if ( scope.enableRotate ) handleTouchStartRotate( event ); @@ -681,8 +655,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchMoveRotate( event ) { - //console.log( 'handleTouchMoveRotate' ); - if ( event.touches.length == 1 ) { rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -710,8 +682,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchMovePan( event ) { - //console.log( 'handleTouchMoveRotate' ); - if ( event.touches.length == 1 ) { panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -735,8 +705,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchMoveDolly( event ) { - //console.log( 'handleTouchMoveRotate' ); - var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; @@ -754,8 +722,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchMoveDollyPan( event ) { - //console.log( 'handleTouchMoveDollyPan' ); - if ( scope.enableZoom ) handleTouchMoveDolly( event ); if ( scope.enablePan ) handleTouchMovePan( event ); @@ -764,8 +730,6 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchMoveDollyRotate( event ) { - //console.log( 'handleTouchMoveDollyPan' ); - if ( scope.enableZoom ) handleTouchMoveDolly( event ); if ( scope.enableRotate ) handleTouchMoveRotate( event ); @@ -774,7 +738,7 @@ THREE.OrbitControls = function ( object, domElement ) { function handleTouchEnd( /*event*/ ) { - //console.log( 'handleTouchEnd' ); + // no-op } @@ -1181,130 +1145,6 @@ THREE.OrbitControls = function ( object, domElement ) { THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype ); THREE.OrbitControls.prototype.constructor = THREE.OrbitControls; -Object.defineProperties( THREE.OrbitControls.prototype, { - - center: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .center has been renamed to .target' ); - return this.target; - - } - - }, - - // backward compatibility - - noZoom: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); - return ! this.enableZoom; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); - this.enableZoom = ! value; - - } - - }, - - noRotate: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); - return ! this.enableRotate; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); - this.enableRotate = ! value; - - } - - }, - - noPan: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); - return ! this.enablePan; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); - this.enablePan = ! value; - - } - - }, - - noKeys: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); - return ! this.enableKeys; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); - this.enableKeys = ! value; - - } - - }, - - staticMoving: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); - return ! this.enableDamping; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); - this.enableDamping = ! value; - - } - - }, - - dynamicDampingFactor: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); - return this.dampingFactor; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); - this.dampingFactor = value; - - } - - } - -} ); // This set of controls performs orbiting, dollying (zooming), and panning. // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). diff --git a/examples/js/controls/OrthographicTrackballControls.js b/examples/js/controls/OrthographicTrackballControls.js index e4fd51720a26da..1d5e4f909e9594 100644 --- a/examples/js/controls/OrthographicTrackballControls.js +++ b/examples/js/controls/OrthographicTrackballControls.js @@ -265,7 +265,7 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { mouseChange.copy( _panEnd ).sub( _panStart ); - if ( mouseChange.lengthSq() ) { + if ( mouseChange.lengthSq() > EPS ) { // Scale movement to keep clicked/dragged position under cursor var scale_x = ( _this.object.right - _this.object.left ) / _this.object.zoom; diff --git a/examples/js/curves/CurveExtras.js b/examples/js/curves/CurveExtras.js index c83da13d00a0b0..110eda83a16964 100644 --- a/examples/js/curves/CurveExtras.js +++ b/examples/js/curves/CurveExtras.js @@ -1,4 +1,4 @@ -/* +/** * A bunch of parametric curves * @author zz85 * diff --git a/examples/js/effects/AsciiEffect.js b/examples/js/effects/AsciiEffect.js index d99e158961a264..bc878471f65de6 100644 --- a/examples/js/effects/AsciiEffect.js +++ b/examples/js/effects/AsciiEffect.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / https://github.com/zz85 * * Ascii generation is based on http://www.nihilogic.dk/labs/jsascii/ diff --git a/examples/js/exporters/ColladaExporter.js b/examples/js/exporters/ColladaExporter.js index 85222c80eb3ca8..7864c32a1a5964 100644 --- a/examples/js/exporters/ColladaExporter.js +++ b/examples/js/exporters/ColladaExporter.js @@ -485,7 +485,7 @@ THREE.ColladaExporter.prototype = { ( m.side === THREE.DoubleSide ? - `1` : + `1` : '' ) + diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index 49af98dcb630fb..98caa2db455ade 100644 --- a/examples/js/exporters/GLTFExporter.js +++ b/examples/js/exporters/GLTFExporter.js @@ -895,7 +895,7 @@ THREE.GLTFExporter.prototype = { } - if ( material.isShaderMaterial ) { + if ( material.isShaderMaterial && !material.isGLTFSpecularGlossinessMaterial ) { console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' ); return null; @@ -915,6 +915,12 @@ THREE.GLTFExporter.prototype = { extensionsUsed[ 'KHR_materials_unlit' ] = true; + } else if ( material.isGLTFSpecularGlossinessMaterial ) { + + gltfMaterial.extensions = { KHR_materials_pbrSpecularGlossiness: {} }; + + extensionsUsed[ 'KHR_materials_pbrSpecularGlossiness' ] = true; + } else if ( ! material.isMeshStandardMaterial ) { console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' ); @@ -947,6 +953,23 @@ THREE.GLTFExporter.prototype = { } + // pbrSpecularGlossiness diffuse, specular and glossiness factor + if ( material.isGLTFSpecularGlossinessMaterial ) { + + if ( gltfMaterial.pbrMetallicRoughness.baseColorFactor ) { + + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseFactor = gltfMaterial.pbrMetallicRoughness.baseColorFactor; + + } + + var specularFactor = [ 1, 1, 1 ]; + material.specular.toArray( specularFactor, 0 ); + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularFactor = specularFactor; + + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.glossinessFactor = material.glossiness; + + } + // pbrMetallicRoughness.metallicRoughnessTexture if ( material.metalnessMap || material.roughnessMap ) { @@ -964,12 +987,28 @@ THREE.GLTFExporter.prototype = { } - // pbrMetallicRoughness.baseColorTexture + // pbrMetallicRoughness.baseColorTexture or pbrSpecularGlossiness diffuseTexture if ( material.map ) { var baseColorMapDef = { index: processTexture( material.map ) }; applyTextureTransform( baseColorMapDef, material.map ); + + if ( material.isGLTFSpecularGlossinessMaterial ) { + + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseTexture = baseColorMapDef; + + } + gltfMaterial.pbrMetallicRoughness.baseColorTexture = baseColorMapDef; + + } + + // pbrSpecularGlossiness specular map + if ( material.isGLTFSpecularGlossinessMaterial && material.specularMap ) { + + var specularMapDef = { index: processTexture( material.specularMap ) }; + applyTextureTransform( specularMapDef, material.specularMap ); + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularGlossinessTexture = specularMapDef; } @@ -1004,7 +1043,7 @@ THREE.GLTFExporter.prototype = { var normalMapDef = { index: processTexture( material.normalMap ) }; - if ( material.normalScale.x !== - 1 ) { + if ( material.normalScale && material.normalScale.x !== - 1 ) { if ( material.normalScale.x !== material.normalScale.y ) { diff --git a/examples/js/geometries/ParametricGeometries.js b/examples/js/geometries/ParametricGeometries.js index 25a65231cfa0da..33ce0dda4c0cc3 100644 --- a/examples/js/geometries/ParametricGeometries.js +++ b/examples/js/geometries/ParametricGeometries.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 * * Experimenting of primitive geometry creation using Surface Parametric equations diff --git a/examples/js/libs/ctm.js b/examples/js/libs/ctm.js deleted file mode 100644 index ae002cba2d8e0c..00000000000000 --- a/examples/js/libs/ctm.js +++ /dev/null @@ -1,658 +0,0 @@ -/* -Copyright (c) 2011 Juan Mellado - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -/* -References: -- "OpenCTM: The Open Compressed Triangle Mesh file format" by Marcus Geelnard - http://openctm.sourceforge.net/ -*/ - -var CTM = CTM || {}; - -// browserify support -if ( typeof module === 'object' ) { - - module.exports = CTM; - -} - -CTM.CompressionMethod = { - RAW: 0x00574152, - MG1: 0x0031474d, - MG2: 0x0032474d -}; - -CTM.Flags = { - NORMALS: 0x00000001 -}; - -CTM.File = function(stream) { - this.load(stream); -}; - -CTM.File.prototype.load = function(stream) { - this.header = new CTM.FileHeader(stream); - - this.body = new CTM.FileBody(this.header); - - this.getReader().read(stream, this.body); -}; - -CTM.File.prototype.getReader = function() { - var reader; - - switch (this.header.compressionMethod){ - case CTM.CompressionMethod.RAW: - reader = new CTM.ReaderRAW(); - break; - case CTM.CompressionMethod.MG1: - reader = new CTM.ReaderMG1(); - break; - case CTM.CompressionMethod.MG2: - reader = new CTM.ReaderMG2(); - break; - } - - return reader; -}; - -CTM.FileHeader = function(stream) { - stream.readInt32(); //magic "OCTM" - this.fileFormat = stream.readInt32(); - this.compressionMethod = stream.readInt32(); - this.vertexCount = stream.readInt32(); - this.triangleCount = stream.readInt32(); - this.uvMapCount = stream.readInt32(); - this.attrMapCount = stream.readInt32(); - this.flags = stream.readInt32(); - this.comment = stream.readString(); -}; - -CTM.FileHeader.prototype.hasNormals = function() { - return this.flags & CTM.Flags.NORMALS; -}; - -CTM.FileBody = function(header) { - var i = header.triangleCount * 3, - v = header.vertexCount * 3, - n = header.hasNormals() ? header.vertexCount * 3 : 0, - u = header.vertexCount * 2, - a = header.vertexCount * 4, - j = 0; - - var data = new ArrayBuffer( - (i + v + n + (u * header.uvMapCount) + (a * header.attrMapCount) ) * 4); - - this.indices = new Uint32Array(data, 0, i); - - this.vertices = new Float32Array(data, i * 4, v); - - if ( header.hasNormals() ) { - this.normals = new Float32Array(data, (i + v) * 4, n); - } - - if (header.uvMapCount) { - this.uvMaps = []; - for (j = 0; j < header.uvMapCount; ++ j) { - this.uvMaps[j] = { uv: new Float32Array(data, - (i + v + n + (j * u) ) * 4, u) }; - } - } - - if (header.attrMapCount) { - this.attrMaps = []; - for (j = 0; j < header.attrMapCount; ++ j) { - this.attrMaps[j] = { attr: new Float32Array(data, - (i + v + n + (u * header.uvMapCount) + (j * a) ) * 4, a) }; - } - } -}; - -CTM.FileMG2Header = function(stream) { - stream.readInt32(); //magic "MG2H" - this.vertexPrecision = stream.readFloat32(); - this.normalPrecision = stream.readFloat32(); - this.lowerBoundx = stream.readFloat32(); - this.lowerBoundy = stream.readFloat32(); - this.lowerBoundz = stream.readFloat32(); - this.higherBoundx = stream.readFloat32(); - this.higherBoundy = stream.readFloat32(); - this.higherBoundz = stream.readFloat32(); - this.divx = stream.readInt32(); - this.divy = stream.readInt32(); - this.divz = stream.readInt32(); - - this.sizex = (this.higherBoundx - this.lowerBoundx) / this.divx; - this.sizey = (this.higherBoundy - this.lowerBoundy) / this.divy; - this.sizez = (this.higherBoundz - this.lowerBoundz) / this.divz; -}; - -CTM.ReaderRAW = function() { -}; - -CTM.ReaderRAW.prototype.read = function(stream, body) { - this.readIndices(stream, body.indices); - this.readVertices(stream, body.vertices); - - if (body.normals) { - this.readNormals(stream, body.normals); - } - if (body.uvMaps) { - this.readUVMaps(stream, body.uvMaps); - } - if (body.attrMaps) { - this.readAttrMaps(stream, body.attrMaps); - } -}; - -CTM.ReaderRAW.prototype.readIndices = function(stream, indices) { - stream.readInt32(); //magic "INDX" - stream.readArrayInt32(indices); -}; - -CTM.ReaderRAW.prototype.readVertices = function(stream, vertices) { - stream.readInt32(); //magic "VERT" - stream.readArrayFloat32(vertices); -}; - -CTM.ReaderRAW.prototype.readNormals = function(stream, normals) { - stream.readInt32(); //magic "NORM" - stream.readArrayFloat32(normals); -}; - -CTM.ReaderRAW.prototype.readUVMaps = function(stream, uvMaps) { - var i = 0; - for (; i < uvMaps.length; ++ i) { - stream.readInt32(); //magic "TEXC" - - uvMaps[i].name = stream.readString(); - uvMaps[i].filename = stream.readString(); - stream.readArrayFloat32(uvMaps[i].uv); - } -}; - -CTM.ReaderRAW.prototype.readAttrMaps = function(stream, attrMaps) { - var i = 0; - for (; i < attrMaps.length; ++ i) { - stream.readInt32(); //magic "ATTR" - - attrMaps[i].name = stream.readString(); - stream.readArrayFloat32(attrMaps[i].attr); - } -}; - -CTM.ReaderMG1 = function() { -}; - -CTM.ReaderMG1.prototype.read = function(stream, body) { - this.readIndices(stream, body.indices); - this.readVertices(stream, body.vertices); - - if (body.normals) { - this.readNormals(stream, body.normals); - } - if (body.uvMaps) { - this.readUVMaps(stream, body.uvMaps); - } - if (body.attrMaps) { - this.readAttrMaps(stream, body.attrMaps); - } -}; - -CTM.ReaderMG1.prototype.readIndices = function(stream, indices) { - stream.readInt32(); //magic "INDX" - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(indices, 3); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - CTM.restoreIndices(indices, indices.length); -}; - -CTM.ReaderMG1.prototype.readVertices = function(stream, vertices) { - stream.readInt32(); //magic "VERT" - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(vertices, 1); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); -}; - -CTM.ReaderMG1.prototype.readNormals = function(stream, normals) { - stream.readInt32(); //magic "NORM" - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(normals, 3); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); -}; - -CTM.ReaderMG1.prototype.readUVMaps = function(stream, uvMaps) { - var i = 0; - for (; i < uvMaps.length; ++ i) { - stream.readInt32(); //magic "TEXC" - - uvMaps[i].name = stream.readString(); - uvMaps[i].filename = stream.readString(); - - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - } -}; - -CTM.ReaderMG1.prototype.readAttrMaps = function(stream, attrMaps) { - var i = 0; - for (; i < attrMaps.length; ++ i) { - stream.readInt32(); //magic "ATTR" - - attrMaps[i].name = stream.readString(); - - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - } -}; - -CTM.ReaderMG2 = function() { -}; - -CTM.ReaderMG2.prototype.read = function(stream, body) { - this.MG2Header = new CTM.FileMG2Header(stream); - - this.readVertices(stream, body.vertices); - this.readIndices(stream, body.indices); - - if (body.normals) { - this.readNormals(stream, body); - } - if (body.uvMaps) { - this.readUVMaps(stream, body.uvMaps); - } - if (body.attrMaps) { - this.readAttrMaps(stream, body.attrMaps); - } -}; - -CTM.ReaderMG2.prototype.readVertices = function(stream, vertices) { - stream.readInt32(); //magic "VERT" - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(vertices, 3); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - var gridIndices = this.readGridIndices(stream, vertices); - - CTM.restoreVertices(vertices, this.MG2Header, gridIndices, this.MG2Header.vertexPrecision); -}; - -CTM.ReaderMG2.prototype.readGridIndices = function(stream, vertices) { - stream.readInt32(); //magic "GIDX" - stream.readInt32(); //packed size - - var gridIndices = new Uint32Array(vertices.length / 3); - - var interleaved = new CTM.InterleavedStream(gridIndices, 1); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - CTM.restoreGridIndices(gridIndices, gridIndices.length); - - return gridIndices; -}; - -CTM.ReaderMG2.prototype.readIndices = function(stream, indices) { - stream.readInt32(); //magic "INDX" - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(indices, 3); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - CTM.restoreIndices(indices, indices.length); -}; - -CTM.ReaderMG2.prototype.readNormals = function(stream, body) { - stream.readInt32(); //magic "NORM" - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(body.normals, 3); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - var smooth = CTM.calcSmoothNormals(body.indices, body.vertices); - - CTM.restoreNormals(body.normals, smooth, this.MG2Header.normalPrecision); -}; - -CTM.ReaderMG2.prototype.readUVMaps = function(stream, uvMaps) { - var i = 0; - for (; i < uvMaps.length; ++ i) { - stream.readInt32(); //magic "TEXC" - - uvMaps[i].name = stream.readString(); - uvMaps[i].filename = stream.readString(); - - var precision = stream.readFloat32(); - - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(uvMaps[i].uv, 2); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - CTM.restoreMap(uvMaps[i].uv, 2, precision); - } -}; - -CTM.ReaderMG2.prototype.readAttrMaps = function(stream, attrMaps) { - var i = 0; - for (; i < attrMaps.length; ++ i) { - stream.readInt32(); //magic "ATTR" - - attrMaps[i].name = stream.readString(); - - var precision = stream.readFloat32(); - - stream.readInt32(); //packed size - - var interleaved = new CTM.InterleavedStream(attrMaps[i].attr, 4); - LZMA.decompress(stream, stream, interleaved, interleaved.data.length); - - CTM.restoreMap(attrMaps[i].attr, 4, precision); - } -}; - -CTM.restoreIndices = function(indices, len) { - var i = 3; - if (len > 0) { - indices[2] += indices[0]; - indices[1] += indices[0]; - } - for (; i < len; i += 3) { - indices[i] += indices[i - 3]; - - if (indices[i] === indices[i - 3]) { - indices[i + 1] += indices[i - 2]; - }else { - indices[i + 1] += indices[i]; - } - - indices[i + 2] += indices[i]; - } -}; - -CTM.restoreGridIndices = function(gridIndices, len) { - var i = 1; - for (; i < len; ++ i) { - gridIndices[i] += gridIndices[i - 1]; - } -}; - -CTM.restoreVertices = function(vertices, grid, gridIndices, precision) { - var gridIdx, delta, x, y, z, - intVertices = new Uint32Array(vertices.buffer, vertices.byteOffset, vertices.length), - ydiv = grid.divx, zdiv = ydiv * grid.divy, - prevGridIdx = 0x7fffffff, prevDelta = 0, - i = 0, j = 0, len = gridIndices.length; - - for (; i < len; j += 3) { - x = gridIdx = gridIndices[i ++]; - - z = ~~(x / zdiv); - x -= ~~(z * zdiv); - y = ~~(x / ydiv); - x -= ~~(y * ydiv); - - delta = intVertices[j]; - if (gridIdx === prevGridIdx) { - delta += prevDelta; - } - - vertices[j] = grid.lowerBoundx + - x * grid.sizex + precision * delta; - vertices[j + 1] = grid.lowerBoundy + - y * grid.sizey + precision * intVertices[j + 1]; - vertices[j + 2] = grid.lowerBoundz + - z * grid.sizez + precision * intVertices[j + 2]; - - prevGridIdx = gridIdx; - prevDelta = delta; - } -}; - -CTM.restoreNormals = function(normals, smooth, precision) { - var ro, phi, theta, sinPhi, - nx, ny, nz, by, bz, len, - intNormals = new Uint32Array(normals.buffer, normals.byteOffset, normals.length), - i = 0, k = normals.length, - PI_DIV_2 = 3.141592653589793238462643 * 0.5; - - for (; i < k; i += 3) { - ro = intNormals[i] * precision; - phi = intNormals[i + 1]; - - if (phi === 0) { - normals[i] = smooth[i] * ro; - normals[i + 1] = smooth[i + 1] * ro; - normals[i + 2] = smooth[i + 2] * ro; - }else { - - if (phi <= 4) { - theta = (intNormals[i + 2] - 2) * PI_DIV_2; - }else { - theta = ( (intNormals[i + 2] * 4 / phi) - 2) * PI_DIV_2; - } - - phi *= precision * PI_DIV_2; - sinPhi = ro * Math.sin(phi); - - nx = sinPhi * Math.cos(theta); - ny = sinPhi * Math.sin(theta); - nz = ro * Math.cos(phi); - - bz = smooth[i + 1]; - by = smooth[i] - smooth[i + 2]; - - len = Math.sqrt(2 * bz * bz + by * by); - if (len > 1e-20) { - by /= len; - bz /= len; - } - - normals[i] = smooth[i] * nz + (smooth[i + 1] * bz - smooth[i + 2] * by) * ny - bz * nx; - normals[i + 1] = smooth[i + 1] * nz - (smooth[i + 2] + smooth[i]) * bz * ny + by * nx; - normals[i + 2] = smooth[i + 2] * nz + (smooth[i] * by + smooth[i + 1] * bz) * ny + bz * nx; - } - } -}; - -CTM.restoreMap = function(map, count, precision) { - var delta, value, - intMap = new Uint32Array(map.buffer, map.byteOffset, map.length), - i = 0, j, len = map.length; - - for (; i < count; ++ i) { - delta = 0; - - for (j = i; j < len; j += count) { - value = intMap[j]; - - delta += value & 1 ? -( (value + 1) >> 1) : value >> 1; - - map[j] = delta * precision; - } - } -}; - -CTM.calcSmoothNormals = function(indices, vertices) { - var smooth = new Float32Array(vertices.length), - indx, indy, indz, nx, ny, nz, - v1x, v1y, v1z, v2x, v2y, v2z, len, - i, k; - - for (i = 0, k = indices.length; i < k;) { - indx = indices[i ++] * 3; - indy = indices[i ++] * 3; - indz = indices[i ++] * 3; - - v1x = vertices[indy] - vertices[indx]; - v2x = vertices[indz] - vertices[indx]; - v1y = vertices[indy + 1] - vertices[indx + 1]; - v2y = vertices[indz + 1] - vertices[indx + 1]; - v1z = vertices[indy + 2] - vertices[indx + 2]; - v2z = vertices[indz + 2] - vertices[indx + 2]; - - nx = v1y * v2z - v1z * v2y; - ny = v1z * v2x - v1x * v2z; - nz = v1x * v2y - v1y * v2x; - - len = Math.sqrt(nx * nx + ny * ny + nz * nz); - if (len > 1e-10) { - nx /= len; - ny /= len; - nz /= len; - } - - smooth[indx] += nx; - smooth[indx + 1] += ny; - smooth[indx + 2] += nz; - smooth[indy] += nx; - smooth[indy + 1] += ny; - smooth[indy + 2] += nz; - smooth[indz] += nx; - smooth[indz + 1] += ny; - smooth[indz + 2] += nz; - } - - for (i = 0, k = smooth.length; i < k; i += 3) { - len = Math.sqrt(smooth[i] * smooth[i] + - smooth[i + 1] * smooth[i + 1] + - smooth[i + 2] * smooth[i + 2]); - - if (len > 1e-10) { - smooth[i] /= len; - smooth[i + 1] /= len; - smooth[i + 2] /= len; - } - } - - return smooth; -}; - -CTM.isLittleEndian = (function() { - var buffer = new ArrayBuffer(2), - bytes = new Uint8Array(buffer), - ints = new Uint16Array(buffer); - - bytes[0] = 1; - - return ints[0] === 1; -}()); - -CTM.InterleavedStream = function(data, count) { - this.data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength); - this.offset = CTM.isLittleEndian ? 3 : 0; - this.count = count * 4; - this.len = this.data.length; -}; - -CTM.InterleavedStream.prototype.writeByte = function(value) { - this.data[this.offset] = value; - - this.offset += this.count; - if (this.offset >= this.len) { - - this.offset -= this.len - 4; - if (this.offset >= this.count) { - - this.offset -= this.count + (CTM.isLittleEndian ? 1 : -1); - } - } -}; - -CTM.Stream = function(data) { - this.data = data; - this.offset = 0; -}; - -CTM.Stream.prototype.TWO_POW_MINUS23 = Math.pow(2, -23); - -CTM.Stream.prototype.TWO_POW_MINUS126 = Math.pow(2, -126); - -CTM.Stream.prototype.readByte = function() { - return this.data[this.offset ++] & 0xff; -}; - -CTM.Stream.prototype.readInt32 = function() { - var i = this.readByte(); - i |= this.readByte() << 8; - i |= this.readByte() << 16; - return i | (this.readByte() << 24); -}; - -CTM.Stream.prototype.readFloat32 = function() { - var m = this.readByte(); - m += this.readByte() << 8; - - var b1 = this.readByte(); - var b2 = this.readByte(); - - m += (b1 & 0x7f) << 16; - var e = ( (b2 & 0x7f) << 1) | ( (b1 & 0x80) >>> 7); - var s = b2 & 0x80 ? -1 : 1; - - if (e === 255) { - return m !== 0 ? NaN : s * Infinity; - } - if (e > 0) { - return s * (1 + (m * this.TWO_POW_MINUS23) ) * Math.pow(2, e - 127); - } - if (m !== 0) { - return s * m * this.TWO_POW_MINUS126; - } - return s * 0; -}; - -CTM.Stream.prototype.readString = function() { - var len = this.readInt32(); - - this.offset += len; - - return String.fromCharCode.apply(null, this.data.subarray(this.offset - len, this.offset)); -}; - -CTM.Stream.prototype.readArrayInt32 = function(array) { - var i = 0, len = array.length; - - while (i < len) { - array[i ++] = this.readInt32(); - } - - return array; -}; - -CTM.Stream.prototype.readArrayFloat32 = function(array) { - var i = 0, len = array.length; - - while (i < len) { - array[i ++] = this.readFloat32(); - } - - return array; -}; diff --git a/examples/js/libs/lzma.js b/examples/js/libs/lzma.js deleted file mode 100644 index ff90c5be6fa77c..00000000000000 --- a/examples/js/libs/lzma.js +++ /dev/null @@ -1,517 +0,0 @@ - -var LZMA = LZMA || {}; - -// browserify support -if ( typeof module === 'object' ) { - - module.exports = LZMA; - -} - -LZMA.OutWindow = function() { - this._windowSize = 0; -}; - -LZMA.OutWindow.prototype.create = function(windowSize) { - if ( (!this._buffer) || (this._windowSize !== windowSize) ) { - this._buffer = []; - } - this._windowSize = windowSize; - this._pos = 0; - this._streamPos = 0; -}; - -LZMA.OutWindow.prototype.flush = function() { - var size = this._pos - this._streamPos; - if (size !== 0) { - while (size --) { - this._stream.writeByte(this._buffer[this._streamPos ++]); - } - if (this._pos >= this._windowSize) { - this._pos = 0; - } - this._streamPos = this._pos; - } -}; - -LZMA.OutWindow.prototype.releaseStream = function() { - this.flush(); - this._stream = null; -}; - -LZMA.OutWindow.prototype.setStream = function(stream) { - this.releaseStream(); - this._stream = stream; -}; - -LZMA.OutWindow.prototype.init = function(solid) { - if (!solid) { - this._streamPos = 0; - this._pos = 0; - } -}; - -LZMA.OutWindow.prototype.copyBlock = function(distance, len) { - var pos = this._pos - distance - 1; - if (pos < 0) { - pos += this._windowSize; - } - while (len --) { - if (pos >= this._windowSize) { - pos = 0; - } - this._buffer[this._pos ++] = this._buffer[pos ++]; - if (this._pos >= this._windowSize) { - this.flush(); - } - } -}; - -LZMA.OutWindow.prototype.putByte = function(b) { - this._buffer[this._pos ++] = b; - if (this._pos >= this._windowSize) { - this.flush(); - } -}; - -LZMA.OutWindow.prototype.getByte = function(distance) { - var pos = this._pos - distance - 1; - if (pos < 0) { - pos += this._windowSize; - } - return this._buffer[pos]; -}; - -LZMA.RangeDecoder = function() { -}; - -LZMA.RangeDecoder.prototype.setStream = function(stream) { - this._stream = stream; -}; - -LZMA.RangeDecoder.prototype.releaseStream = function() { - this._stream = null; -}; - -LZMA.RangeDecoder.prototype.init = function() { - var i = 5; - - this._code = 0; - this._range = -1; - - while (i --) { - this._code = (this._code << 8) | this._stream.readByte(); - } -}; - -LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits) { - var result = 0, i = numTotalBits, t; - - while (i --) { - this._range >>>= 1; - t = (this._code - this._range) >>> 31; - this._code -= this._range & (t - 1); - result = (result << 1) | (1 - t); - - if ( (this._range & 0xff000000) === 0) { - this._code = (this._code << 8) | this._stream.readByte(); - this._range <<= 8; - } - } - - return result; -}; - -LZMA.RangeDecoder.prototype.decodeBit = function(probs, index) { - var prob = probs[index], - newBound = (this._range >>> 11) * prob; - - if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ) { - this._range = newBound; - probs[index] += (2048 - prob) >>> 5; - if ( (this._range & 0xff000000) === 0) { - this._code = (this._code << 8) | this._stream.readByte(); - this._range <<= 8; - } - return 0; - } - - this._range -= newBound; - this._code -= newBound; - probs[index] -= prob >>> 5; - if ( (this._range & 0xff000000) === 0) { - this._code = (this._code << 8) | this._stream.readByte(); - this._range <<= 8; - } - return 1; -}; - -LZMA.initBitModels = function(probs, len) { - while (len --) { - probs[len] = 1024; - } -}; - -LZMA.BitTreeDecoder = function(numBitLevels) { - this._models = []; - this._numBitLevels = numBitLevels; -}; - -LZMA.BitTreeDecoder.prototype.init = function() { - LZMA.initBitModels(this._models, 1 << this._numBitLevels); -}; - -LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder) { - var m = 1, i = this._numBitLevels; - - while (i --) { - m = (m << 1) | rangeDecoder.decodeBit(this._models, m); - } - return m - (1 << this._numBitLevels); -}; - -LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder) { - var m = 1, symbol = 0, i = 0, bit; - - for (; i < this._numBitLevels; ++ i) { - bit = rangeDecoder.decodeBit(this._models, m); - m = (m << 1) | bit; - symbol |= bit << i; - } - return symbol; -}; - -LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels) { - var m = 1, symbol = 0, i = 0, bit; - - for (; i < numBitLevels; ++ i) { - bit = rangeDecoder.decodeBit(models, startIndex + m); - m = (m << 1) | bit; - symbol |= bit << i; - } - return symbol; -}; - -LZMA.LenDecoder = function() { - this._choice = []; - this._lowCoder = []; - this._midCoder = []; - this._highCoder = new LZMA.BitTreeDecoder(8); - this._numPosStates = 0; -}; - -LZMA.LenDecoder.prototype.create = function(numPosStates) { - for (; this._numPosStates < numPosStates; ++ this._numPosStates) { - this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3); - this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3); - } -}; - -LZMA.LenDecoder.prototype.init = function() { - var i = this._numPosStates; - LZMA.initBitModels(this._choice, 2); - while (i --) { - this._lowCoder[i].init(); - this._midCoder[i].init(); - } - this._highCoder.init(); -}; - -LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState) { - if (rangeDecoder.decodeBit(this._choice, 0) === 0) { - return this._lowCoder[posState].decode(rangeDecoder); - } - if (rangeDecoder.decodeBit(this._choice, 1) === 0) { - return 8 + this._midCoder[posState].decode(rangeDecoder); - } - return 16 + this._highCoder.decode(rangeDecoder); -}; - -LZMA.Decoder2 = function() { - this._decoders = []; -}; - -LZMA.Decoder2.prototype.init = function() { - LZMA.initBitModels(this._decoders, 0x300); -}; - -LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder) { - var symbol = 1; - - do { - symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol); - }while (symbol < 0x100); - - return symbol & 0xff; -}; - -LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte) { - var symbol = 1, matchBit, bit; - - do { - matchBit = (matchByte >> 7) & 1; - matchByte <<= 1; - bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol); - symbol = (symbol << 1) | bit; - if (matchBit !== bit) { - while (symbol < 0x100) { - symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol); - } - break; - } - }while (symbol < 0x100); - - return symbol & 0xff; -}; - -LZMA.LiteralDecoder = function() { -}; - -LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits) { - var i; - - if (this._coders - && (this._numPrevBits === numPrevBits) - && (this._numPosBits === numPosBits) ) { - return; - } - this._numPosBits = numPosBits; - this._posMask = (1 << numPosBits) - 1; - this._numPrevBits = numPrevBits; - - this._coders = []; - - i = 1 << (this._numPrevBits + this._numPosBits); - while (i --) { - this._coders[i] = new LZMA.Decoder2(); - } -}; - -LZMA.LiteralDecoder.prototype.init = function() { - var i = 1 << (this._numPrevBits + this._numPosBits); - while (i --) { - this._coders[i].init(); - } -}; - -LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte) { - return this._coders[( (pos & this._posMask) << this._numPrevBits) - + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )]; -}; - -LZMA.Decoder = function() { - this._outWindow = new LZMA.OutWindow(); - this._rangeDecoder = new LZMA.RangeDecoder(); - this._isMatchDecoders = []; - this._isRepDecoders = []; - this._isRepG0Decoders = []; - this._isRepG1Decoders = []; - this._isRepG2Decoders = []; - this._isRep0LongDecoders = []; - this._posSlotDecoder = []; - this._posDecoders = []; - this._posAlignDecoder = new LZMA.BitTreeDecoder(4); - this._lenDecoder = new LZMA.LenDecoder(); - this._repLenDecoder = new LZMA.LenDecoder(); - this._literalDecoder = new LZMA.LiteralDecoder(); - this._dictionarySize = -1; - this._dictionarySizeCheck = -1; - - this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6); - this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6); - this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6); - this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6); -}; - -LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize) { - if (dictionarySize < 0) { - return false; - } - if (this._dictionarySize !== dictionarySize) { - this._dictionarySize = dictionarySize; - this._dictionarySizeCheck = Math.max(this._dictionarySize, 1); - this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) ); - } - return true; -}; - -LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb) { - var numPosStates = 1 << pb; - - if (lc > 8 || lp > 4 || pb > 4) { - return false; - } - - this._literalDecoder.create(lp, lc); - - this._lenDecoder.create(numPosStates); - this._repLenDecoder.create(numPosStates); - this._posStateMask = numPosStates - 1; - - return true; -}; - -LZMA.Decoder.prototype.init = function() { - var i = 4; - - this._outWindow.init(false); - - LZMA.initBitModels(this._isMatchDecoders, 192); - LZMA.initBitModels(this._isRep0LongDecoders, 192); - LZMA.initBitModels(this._isRepDecoders, 12); - LZMA.initBitModels(this._isRepG0Decoders, 12); - LZMA.initBitModels(this._isRepG1Decoders, 12); - LZMA.initBitModels(this._isRepG2Decoders, 12); - LZMA.initBitModels(this._posDecoders, 114); - - this._literalDecoder.init(); - - while (i --) { - this._posSlotDecoder[i].init(); - } - - this._lenDecoder.init(); - this._repLenDecoder.init(); - this._posAlignDecoder.init(); - this._rangeDecoder.init(); -}; - -LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize) { - var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0, - posState, decoder2, len, distance, posSlot, numDirectBits; - - this._rangeDecoder.setStream(inStream); - this._outWindow.setStream(outStream); - - this.init(); - - while (outSize < 0 || nowPos64 < outSize) { - posState = nowPos64 & this._posStateMask; - - if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0) { - decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte); - - if (state >= 7) { - prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) ); - }else { - prevByte = decoder2.decodeNormal(this._rangeDecoder); - } - this._outWindow.putByte(prevByte); - - state = state < 4 ? 0 : state - (state < 10 ? 3 : 6); - - }else { - - if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1) { - len = 0; - if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0) { - if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0) { - state = state < 7 ? 9 : 11; - len = 1; - } - }else { - if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0) { - distance = rep1; - }else { - if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0) { - distance = rep2; - }else { - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - if (len === 0) { - len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState); - state = state < 7 ? 8 : 11; - } - }else { - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - - len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState); - state = state < 7 ? 7 : 10; - - posSlot = this._posSlotDecoder[len <= 5 ? len - 2 : 3].decode(this._rangeDecoder); - if (posSlot >= 4) { - - numDirectBits = (posSlot >> 1) - 1; - rep0 = (2 | (posSlot & 1) ) << numDirectBits; - - if (posSlot < 14) { - rep0 += LZMA.reverseDecode2(this._posDecoders, - rep0 - posSlot - 1, this._rangeDecoder, numDirectBits); - }else { - rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4; - rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder); - if (rep0 < 0) { - if (rep0 === -1) { - break; - } - return false; - } - } - }else { - rep0 = posSlot; - } - } - - if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck) { - return false; - } - - this._outWindow.copyBlock(rep0, len); - nowPos64 += len; - prevByte = this._outWindow.getByte(0); - } - } - - this._outWindow.flush(); - this._outWindow.releaseStream(); - this._rangeDecoder.releaseStream(); - - return true; -}; - -LZMA.Decoder.prototype.setDecoderProperties = function(properties) { - var value, lc, lp, pb, dictionarySize; - - if (properties.size < 5) { - return false; - } - - value = properties.readByte(); - lc = value % 9; - value = ~~(value / 9); - lp = value % 5; - pb = ~~(value / 5); - - if ( !this.setLcLpPb(lc, lp, pb) ) { - return false; - } - - dictionarySize = properties.readByte(); - dictionarySize |= properties.readByte() << 8; - dictionarySize |= properties.readByte() << 16; - dictionarySize += properties.readByte() * 16777216; - - return this.setDictionarySize(dictionarySize); -}; - -LZMA.decompress = function(properties, inStream, outStream, outSize) { - var decoder = new LZMA.Decoder(); - - if ( !decoder.setDecoderProperties(properties) ) { - throw "Incorrect stream properties"; - } - - if ( !decoder.decode(inStream, outStream, outSize) ) { - throw "Error in data stream"; - } - - return true; -}; diff --git a/examples/js/loaders/AMFLoader.js b/examples/js/loaders/AMFLoader.js index 55ef7cd3b770ac..5ff54107e8222f 100644 --- a/examples/js/loaders/AMFLoader.js +++ b/examples/js/loaders/AMFLoader.js @@ -1,4 +1,4 @@ -/* +/** * @author tamarintech / https://tamarintech.com * * Description: Early release of an AMF Loader following the pattern of the diff --git a/examples/js/loaders/DDSLoader.js b/examples/js/loaders/DDSLoader.js index f15a489849415a..2f60f4b304356f 100644 --- a/examples/js/loaders/DDSLoader.js +++ b/examples/js/loaders/DDSLoader.js @@ -1,4 +1,4 @@ -/* +/** * @author mrdoob / http://mrdoob.com/ */ diff --git a/examples/js/loaders/STLLoader.js b/examples/js/loaders/STLLoader.js index c54b93175e15ab..9ddd51377817fc 100644 --- a/examples/js/loaders/STLLoader.js +++ b/examples/js/loaders/STLLoader.js @@ -3,6 +3,7 @@ * @author mrdoob / http://mrdoob.com/ * @author gero3 / https://github.com/gero3 * @author Mugen87 / https://github.com/Mugen87 + * @author neverhood311 / https://github.com/neverhood311 * * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs. * @@ -27,6 +28,31 @@ * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors }); * } else { .... } * var mesh = new THREE.Mesh( geometry, material ); + * + * For ASCII STLs containing multiple solids, each solid is assigned to a different group. + * Groups can be used to assign a different color by defining an array of materials with the same length of + * geometry.groups and passing it to the Mesh constructor: + * + * var mesh = new THREE.Mesh( geometry, material ); + * + * For example: + * + * var materials = []; + * var nGeometryGroups = geometry.groups.length; + * + * var colorMap = ...; // Some logic to index colors. + * + * for (var i = 0; i < nGeometryGroups; i++) { + * + * var material = new THREE.MeshPhongMaterial({ + * color: colorMap[i], + * wireframe: false + * }); + * + * } + * + * materials.push(material); + * var mesh = new THREE.Mesh(geometry, materials); */ @@ -106,7 +132,7 @@ THREE.STLLoader.prototype = { // If "solid" text is matched to the current offset, declare it to be an ASCII STL. - if ( matchDataViewAt ( solid, reader, off ) ) return false; + if ( matchDataViewAt( solid, reader, off ) ) return false; } @@ -148,7 +174,7 @@ THREE.STLLoader.prototype = { ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) { hasColors = true; - colors = []; + colors = new Float32Array( faces * 3 * 3 ); defaultR = reader.getUint8( index + 6 ) / 255; defaultG = reader.getUint8( index + 7 ) / 255; @@ -164,8 +190,8 @@ THREE.STLLoader.prototype = { var geometry = new THREE.BufferGeometry(); - var vertices = []; - var normals = []; + var vertices = new Float32Array( faces * 3 * 3 ); + var normals = new Float32Array( faces * 3 * 3 ); for ( var face = 0; face < faces; face ++ ) { @@ -199,16 +225,21 @@ THREE.STLLoader.prototype = { for ( var i = 1; i <= 3; i ++ ) { var vertexstart = start + i * 12; + var componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 ); - vertices.push( reader.getFloat32( vertexstart, true ) ); - vertices.push( reader.getFloat32( vertexstart + 4, true ) ); - vertices.push( reader.getFloat32( vertexstart + 8, true ) ); + vertices[ componentIdx ] = reader.getFloat32( vertexstart, true ); + vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true ); + vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true ); - normals.push( normalX, normalY, normalZ ); + normals[ componentIdx ] = normalX; + normals[ componentIdx + 1 ] = normalY; + normals[ componentIdx + 2 ] = normalZ; if ( hasColors ) { - colors.push( r, g, b ); + colors[ componentIdx ] = r; + colors[ componentIdx + 1 ] = g; + colors[ componentIdx + 2 ] = b; } @@ -216,12 +247,12 @@ THREE.STLLoader.prototype = { } - geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) ); - geometry.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) ); + geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) ); if ( hasColors ) { - geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array( colors ), 3 ) ); + geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) ); geometry.hasColors = true; geometry.alpha = alpha; @@ -234,6 +265,7 @@ THREE.STLLoader.prototype = { function parseASCII( data ) { var geometry = new THREE.BufferGeometry(); + var patternSolid = /solid([\s\S]*?)endsolid/g; var patternFace = /facet([\s\S]*?)endfacet/g; var faceCounter = 0; @@ -248,53 +280,80 @@ THREE.STLLoader.prototype = { var result; - while ( ( result = patternFace.exec( data ) ) !== null ) { + var groupVertexes = []; + var groupCount = 0; + var startVertex = 0; + var endVertex = 0; - var vertexCountPerFace = 0; - var normalCountPerFace = 0; + while ( ( result = patternSolid.exec( data ) ) !== null ) { - var text = result[ 0 ]; + startVertex = endVertex; - while ( ( result = patternNormal.exec( text ) ) !== null ) { + var solid = result[ 0 ]; - normal.x = parseFloat( result[ 1 ] ); - normal.y = parseFloat( result[ 2 ] ); - normal.z = parseFloat( result[ 3 ] ); - normalCountPerFace ++; + while ( ( result = patternFace.exec( solid ) ) !== null ) { - } + var vertexCountPerFace = 0; + var normalCountPerFace = 0; - while ( ( result = patternVertex.exec( text ) ) !== null ) { + var text = result[ 0 ]; - vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) ); - normals.push( normal.x, normal.y, normal.z ); - vertexCountPerFace ++; + while ( ( result = patternNormal.exec( text ) ) !== null ) { - } + normal.x = parseFloat( result[ 1 ] ); + normal.y = parseFloat( result[ 2 ] ); + normal.z = parseFloat( result[ 3 ] ); + normalCountPerFace ++; - // every face have to own ONE valid normal + } - if ( normalCountPerFace !== 1 ) { + while ( ( result = patternVertex.exec( text ) ) !== null ) { - console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter ); + vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) ); + normals.push( normal.x, normal.y, normal.z ); + vertexCountPerFace ++; + endVertex ++; - } + } - // each face have to own THREE valid vertices + // every face have to own ONE valid normal - if ( vertexCountPerFace !== 3 ) { + if ( normalCountPerFace !== 1 ) { - console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter ); + console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter ); + + } + + // each face have to own THREE valid vertices + + if ( vertexCountPerFace !== 3 ) { + + console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter ); + + } + + faceCounter ++; } - faceCounter ++; + groupVertexes.push( { startVertex: startVertex, endVertex: endVertex } ); + groupCount ++; } geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); + if ( groupCount > 0 ) { + + for ( var i = 0; i < groupVertexes.length; i ++ ) { + + geometry.addGroup( groupVertexes[ i ].startVertex, groupVertexes[ i ].endVertex, i ); + + } + + } + return geometry; } @@ -321,6 +380,7 @@ THREE.STLLoader.prototype = { array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian } + return array_buffer.buffer || array_buffer; } else { diff --git a/examples/js/loaders/TDSLoader.js b/examples/js/loaders/TDSLoader.js index 8f527d31fb2424..b0306c781ff886 100644 --- a/examples/js/loaders/TDSLoader.js +++ b/examples/js/loaders/TDSLoader.js @@ -1,4 +1,4 @@ -/* +/** * Autodesk 3DS three.js file loader, based on lib3ds. * * Loads geometry with uv and materials basic properties with texture support. diff --git a/examples/js/loaders/TGALoader.js b/examples/js/loaders/TGALoader.js index db833edb49552f..b84c95941fc5f8 100644 --- a/examples/js/loaders/TGALoader.js +++ b/examples/js/loaders/TGALoader.js @@ -1,4 +1,4 @@ -/* +/** * @author Daosheng Mu / https://github.com/DaoshengMu/ * @author mrdoob / http://mrdoob.com/ * @author takahirox / https://github.com/takahirox/ diff --git a/examples/js/loaders/ctm/CTMLoader.js b/examples/js/loaders/ctm/CTMLoader.js deleted file mode 100644 index dc02964498ac36..00000000000000 --- a/examples/js/loaders/ctm/CTMLoader.js +++ /dev/null @@ -1,279 +0,0 @@ -/** - * Loader for CTM encoded models generated by OpenCTM tools: - * http://openctm.sourceforge.net/ - * - * Uses js-openctm library by Juan Mellado - * http://code.google.com/p/js-openctm/ - * - * @author alteredq / http://alteredqualia.com/ - * - * OpenCTM LICENSE: - * - * Copyright (c) 2009-2010 Marcus Geelnard - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - * - */ - -/* global CTM */ - -THREE.CTMLoader = function () { - - this.workerPath = null; - -}; - -THREE.CTMLoader.prototype.constructor = THREE.CTMLoader; - -THREE.CTMLoader.prototype.setWorkerPath = function ( workerPath ) { - - this.workerPath = workerPath; - -}; - -// Load multiple CTM parts defined in JSON - -THREE.CTMLoader.prototype.loadParts = function ( url, callback, parameters ) { - - parameters = parameters || {}; - - var scope = this; - - var xhr = new XMLHttpRequest(); - - var basePath = parameters.basePath ? parameters.basePath : THREE.LoaderUtils.extractUrlBase( url ); - - xhr.onreadystatechange = function () { - - if ( xhr.readyState === 4 ) { - - if ( xhr.status === 200 || xhr.status === 0 ) { - - var jsonObject = JSON.parse( xhr.responseText ); - - var materials = [], geometries = [], counter = 0; - - function callbackFinal( geometry ) { - - counter += 1; - - geometries.push( geometry ); - - if ( counter === jsonObject.offsets.length ) { - - callback( geometries, materials ); - - } - - } - - - // init materials - - for ( var i = 0; i < jsonObject.materials.length; i ++ ) { - - materials[ i ] = THREE.Loader.prototype.createMaterial( jsonObject.materials[ i ], basePath ); - - } - - // load joined CTM file - - var partUrl = basePath + jsonObject.data; - var parametersPart = { useWorker: parameters.useWorker, worker: parameters.worker, offsets: jsonObject.offsets }; - scope.load( partUrl, callbackFinal, parametersPart ); - - } - - } - - }; - - xhr.open( "GET", url, true ); - xhr.setRequestHeader( "Content-Type", "text/plain" ); - xhr.send( null ); - -}; - -// Load CTMLoader compressed models -// - parameters -// - url (required) -// - callback (required) - -THREE.CTMLoader.prototype.load = function ( url, callback, parameters ) { - - parameters = parameters || {}; - - var scope = this; - - var offsets = parameters.offsets !== undefined ? parameters.offsets : [ 0 ]; - - var xhr = new XMLHttpRequest(), - callbackProgress = null; - - var length = 0; - - xhr.onreadystatechange = function () { - - if ( xhr.readyState === 4 ) { - - if ( xhr.status === 200 || xhr.status === 0 ) { - - var binaryData = new Uint8Array( xhr.response ); - - var s = Date.now(); - - if ( parameters.useWorker ) { - - var worker = parameters.worker || new Worker( scope.workerPath ); - - worker.onmessage = function ( event ) { - - var files = event.data; - - for ( var i = 0; i < files.length; i ++ ) { - - var ctmFile = files[ i ]; - - var e1 = Date.now(); - // console.log( "CTM data parse time [worker]: " + (e1-s) + " ms" ); - - scope._createGeometry( ctmFile, callback ); - - var e = Date.now(); - console.log( "model load time [worker]: " + ( e - e1 ) + " ms, total: " + ( e - s ) ); - - } - - - }; - - worker.postMessage( { "data": binaryData, "offsets": offsets }, [ binaryData.buffer ] ); - - } else { - - for ( var i = 0; i < offsets.length; i ++ ) { - - var stream = new CTM.Stream( binaryData ); - stream.offset = offsets[ i ]; - - var ctmFile = new CTM.File( stream ); - - scope._createGeometry( ctmFile, callback ); - - } - - //var e = Date.now(); - //console.log( "CTM data parse time [inline]: " + (e-s) + " ms" ); - - } - - } else { - - console.error( "Couldn't load [" + url + "] [" + xhr.status + "]" ); - - } - - } else if ( xhr.readyState === 3 ) { - - if ( callbackProgress ) { - - if ( length === 0 ) { - - length = xhr.getResponseHeader( "Content-Length" ); - - } - - callbackProgress( { total: length, loaded: xhr.responseText.length } ); - - } - - } else if ( xhr.readyState === 2 ) { - - length = xhr.getResponseHeader( "Content-Length" ); - - } - - }; - - xhr.open( "GET", url, true ); - xhr.responseType = "arraybuffer"; - - xhr.send( null ); - -}; - - -THREE.CTMLoader.prototype._createGeometry = function ( file, callback ) { - - var geometry = new THREE.BufferGeometry(); - - var indices = file.body.indices; - var positions = file.body.vertices; - var normals = file.body.normals; - - var uvs, colors; - - var uvMaps = file.body.uvMaps; - - if ( uvMaps !== undefined && uvMaps.length > 0 ) { - - uvs = uvMaps[ 0 ].uv; - - } - - var attrMaps = file.body.attrMaps; - - if ( attrMaps !== undefined && attrMaps.length > 0 && attrMaps[ 0 ].name === 'Color' ) { - - colors = attrMaps[ 0 ].attr; - - } - - geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) ); - geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); - - if ( normals !== undefined ) { - - geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) ); - - } - - if ( uvs !== undefined ) { - - geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) ); - - } - - if ( colors !== undefined ) { - - geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 4 ) ); - - } - - // compute vertex normals if not present in the CTM model - if ( geometry.attributes.normal === undefined ) { - - geometry.computeVertexNormals(); - - } - - callback( geometry ); - -}; diff --git a/examples/js/loaders/ctm/CTMWorker.js b/examples/js/loaders/ctm/CTMWorker.js deleted file mode 100644 index a43d63161d86fc..00000000000000 --- a/examples/js/loaders/ctm/CTMWorker.js +++ /dev/null @@ -1,19 +0,0 @@ -importScripts( "../../libs/lzma.js", "../../libs/ctm.js" ); - -self.onmessage = function ( event ) { - - var files = []; - - for ( var i = 0; i < event.data.offsets.length; i ++ ) { - - var stream = new CTM.Stream( event.data.data ); - stream.offset = event.data.offsets[ i ]; - - files[ i ] = new CTM.File( stream, [ event.data.data.buffer ] ); - - } - - self.postMessage( files ); - self.close(); - -}; diff --git a/examples/js/modifiers/SimplifyModifier.js b/examples/js/modifiers/SimplifyModifier.js index b67239cce85124..3e20c8d036c78b 100644 --- a/examples/js/modifiers/SimplifyModifier.js +++ b/examples/js/modifiers/SimplifyModifier.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog * * Simplification Geometry Modifier diff --git a/examples/js/modifiers/SubdivisionModifier.js b/examples/js/modifiers/SubdivisionModifier.js index d12ca31f09959b..1af8b0e687d410 100644 --- a/examples/js/modifiers/SubdivisionModifier.js +++ b/examples/js/modifiers/SubdivisionModifier.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog * @author centerionware / http://www.centerionware.com * diff --git a/examples/js/shaders/TranslucentShader.js b/examples/js/shaders/TranslucentShader.js index efdbc8e74b34a0..d3839290aeb5ef 100644 --- a/examples/js/shaders/TranslucentShader.js +++ b/examples/js/shaders/TranslucentShader.js @@ -61,6 +61,7 @@ THREE.TranslucentShader = { ].join( "\n" ), fragmentShader: [ + "#define USE_UV", "#define USE_MAP", "#define PHONG", "#define TRANSLUCENT", @@ -137,7 +138,7 @@ THREE.TranslucentShader = { " RE_Direct( directLight, geometry, material, reflectedLight );", - " #if defined( TRANSLUCENT ) && defined( USE_MAP )", + " #if defined( TRANSLUCENT ) && defined( USE_UV )", " RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);", " #endif", " }", @@ -159,7 +160,7 @@ THREE.TranslucentShader = { " RE_Direct( directLight, geometry, material, reflectedLight );", - " #if defined( TRANSLUCENT ) && defined( USE_MAP )", + " #if defined( TRANSLUCENT ) && defined( USE_UV )", " RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);", " #endif", " }", diff --git a/examples/js/utils/UVsDebug.js b/examples/js/utils/UVsDebug.js index 3af7e7475e2260..8175901f652bbd 100644 --- a/examples/js/utils/UVsDebug.js +++ b/examples/js/utils/UVsDebug.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / http://github.com/zz85 * @author WestLangley / http://github.com/WestLangley * @author Mugen87 / https://github.com/Mugen87 diff --git a/examples/jsm/controls/DragControls.js b/examples/jsm/controls/DragControls.js index 0aa90fcc25f70a..f59f24082984e1 100644 --- a/examples/jsm/controls/DragControls.js +++ b/examples/jsm/controls/DragControls.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / https://github.com/zz85 * @author mrdoob / http://mrdoob.com * Running this will allow you to drag three.js objects around the screen. diff --git a/examples/jsm/controls/OrbitControls.js b/examples/jsm/controls/OrbitControls.js index 94771eeabb958f..83f22cd8680e6d 100644 --- a/examples/jsm/controls/OrbitControls.js +++ b/examples/jsm/controls/OrbitControls.js @@ -470,32 +470,24 @@ var OrbitControls = function ( object, domElement ) { function handleMouseDownRotate( event ) { - //console.log( 'handleMouseDownRotate' ); - rotateStart.set( event.clientX, event.clientY ); } function handleMouseDownDolly( event ) { - //console.log( 'handleMouseDownDolly' ); - dollyStart.set( event.clientX, event.clientY ); } function handleMouseDownPan( event ) { - //console.log( 'handleMouseDownPan' ); - panStart.set( event.clientX, event.clientY ); } function handleMouseMoveRotate( event ) { - //console.log( 'handleMouseMoveRotate' ); - rotateEnd.set( event.clientX, event.clientY ); rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); @@ -514,8 +506,6 @@ var OrbitControls = function ( object, domElement ) { function handleMouseMoveDolly( event ) { - //console.log( 'handleMouseMoveDolly' ); - dollyEnd.set( event.clientX, event.clientY ); dollyDelta.subVectors( dollyEnd, dollyStart ); @@ -538,8 +528,6 @@ var OrbitControls = function ( object, domElement ) { function handleMouseMovePan( event ) { - //console.log( 'handleMouseMovePan' ); - panEnd.set( event.clientX, event.clientY ); panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); @@ -554,14 +542,12 @@ var OrbitControls = function ( object, domElement ) { function handleMouseUp( /*event*/ ) { - // console.log( 'handleMouseUp' ); + // no-op } function handleMouseWheel( event ) { - // console.log( 'handleMouseWheel' ); - if ( event.deltaY < 0 ) { dollyOut( getZoomScale() ); @@ -578,8 +564,6 @@ var OrbitControls = function ( object, domElement ) { function handleKeyDown( event ) { - // console.log( 'handleKeyDown' ); - var needsUpdate = false; switch ( event.keyCode ) { @@ -620,8 +604,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchStartRotate( event ) { - //console.log( 'handleTouchStartRotate' ); - if ( event.touches.length == 1 ) { rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -639,8 +621,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchStartPan( event ) { - //console.log( 'handleTouchStartPan' ); - if ( event.touches.length == 1 ) { panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -658,8 +638,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchStartDolly( event ) { - //console.log( 'handleTouchStartDolly' ); - var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; @@ -671,8 +649,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchStartDollyPan( event ) { - //console.log( 'handleTouchStartDollyPan' ); - if ( scope.enableZoom ) handleTouchStartDolly( event ); if ( scope.enablePan ) handleTouchStartPan( event ); @@ -681,8 +657,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchStartDollyRotate( event ) { - //console.log( 'handleTouchStartDollyRotate' ); - if ( scope.enableZoom ) handleTouchStartDolly( event ); if ( scope.enableRotate ) handleTouchStartRotate( event ); @@ -691,8 +665,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchMoveRotate( event ) { - //console.log( 'handleTouchMoveRotate' ); - if ( event.touches.length == 1 ) { rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -720,8 +692,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchMovePan( event ) { - //console.log( 'handleTouchMoveRotate' ); - if ( event.touches.length == 1 ) { panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); @@ -745,8 +715,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchMoveDolly( event ) { - //console.log( 'handleTouchMoveRotate' ); - var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; @@ -764,8 +732,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchMoveDollyPan( event ) { - //console.log( 'handleTouchMoveDollyPan' ); - if ( scope.enableZoom ) handleTouchMoveDolly( event ); if ( scope.enablePan ) handleTouchMovePan( event ); @@ -774,8 +740,6 @@ var OrbitControls = function ( object, domElement ) { function handleTouchMoveDollyRotate( event ) { - //console.log( 'handleTouchMoveDollyPan' ); - if ( scope.enableZoom ) handleTouchMoveDolly( event ); if ( scope.enableRotate ) handleTouchMoveRotate( event ); @@ -784,7 +748,7 @@ var OrbitControls = function ( object, domElement ) { function handleTouchEnd( /*event*/ ) { - //console.log( 'handleTouchEnd' ); + // no-op } @@ -1191,130 +1155,6 @@ var OrbitControls = function ( object, domElement ) { OrbitControls.prototype = Object.create( EventDispatcher.prototype ); OrbitControls.prototype.constructor = OrbitControls; -Object.defineProperties( OrbitControls.prototype, { - - center: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .center has been renamed to .target' ); - return this.target; - - } - - }, - - // backward compatibility - - noZoom: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); - return ! this.enableZoom; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' ); - this.enableZoom = ! value; - - } - - }, - - noRotate: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); - return ! this.enableRotate; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' ); - this.enableRotate = ! value; - - } - - }, - - noPan: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); - return ! this.enablePan; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' ); - this.enablePan = ! value; - - } - - }, - - noKeys: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); - return ! this.enableKeys; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' ); - this.enableKeys = ! value; - - } - - }, - - staticMoving: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); - return ! this.enableDamping; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' ); - this.enableDamping = ! value; - - } - - }, - - dynamicDampingFactor: { - - get: function () { - - console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); - return this.dampingFactor; - - }, - - set: function ( value ) { - - console.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' ); - this.dampingFactor = value; - - } - - } - -} ); // This set of controls performs orbiting, dollying (zooming), and panning. // Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default). diff --git a/examples/jsm/controls/OrthographicTrackballControls.js b/examples/jsm/controls/OrthographicTrackballControls.js index 2ab3dba5b346f6..0c49d9453ef556 100644 --- a/examples/jsm/controls/OrthographicTrackballControls.js +++ b/examples/jsm/controls/OrthographicTrackballControls.js @@ -272,7 +272,7 @@ var OrthographicTrackballControls = function ( object, domElement ) { mouseChange.copy( _panEnd ).sub( _panStart ); - if ( mouseChange.lengthSq() ) { + if ( mouseChange.lengthSq() > EPS ) { // Scale movement to keep clicked/dragged position under cursor var scale_x = ( _this.object.right - _this.object.left ) / _this.object.zoom; diff --git a/examples/jsm/controls/TransformControls.d.ts b/examples/jsm/controls/TransformControls.d.ts index 8484077df02530..d03c2e27f52afa 100644 --- a/examples/jsm/controls/TransformControls.d.ts +++ b/examples/jsm/controls/TransformControls.d.ts @@ -42,8 +42,8 @@ export class TransformControls extends Object3D { pointerUp(pointer: Object): void; getMode(): string; setMode(mode: string): void; - setTranslationSnap(translationSnap: Vector3): void; - setRotationSnap(rotationSnap: Euler): void; + setTranslationSnap(translationSnap: Number | null): void; + setRotationSnap(rotationSnap: Number | null): void; setSize(size: number): void; setSpace(space: string): void; dispose(): void; diff --git a/examples/jsm/curves/CurveExtras.js b/examples/jsm/curves/CurveExtras.js index 7950912afaaae5..f9699d7755739f 100644 --- a/examples/jsm/curves/CurveExtras.js +++ b/examples/jsm/curves/CurveExtras.js @@ -1,4 +1,4 @@ -/* +/** * A bunch of parametric curves * @author zz85 * diff --git a/examples/jsm/effects/AsciiEffect.js b/examples/jsm/effects/AsciiEffect.js index 44821074469a06..bafd8709e63240 100644 --- a/examples/jsm/effects/AsciiEffect.js +++ b/examples/jsm/effects/AsciiEffect.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / https://github.com/zz85 * * Ascii generation is based on http://www.nihilogic.dk/labs/jsascii/ diff --git a/examples/jsm/exporters/ColladaExporter.js b/examples/jsm/exporters/ColladaExporter.js index 804ca5b3fb0732..d2206d28b77169 100644 --- a/examples/jsm/exporters/ColladaExporter.js +++ b/examples/jsm/exporters/ColladaExporter.js @@ -496,7 +496,7 @@ ColladaExporter.prototype = { ( m.side === DoubleSide ? - `1` : + `1` : '' ) + diff --git a/examples/jsm/exporters/GLTFExporter.js b/examples/jsm/exporters/GLTFExporter.js index b2e14e1f25bfb1..005a7453a9e84b 100644 --- a/examples/jsm/exporters/GLTFExporter.js +++ b/examples/jsm/exporters/GLTFExporter.js @@ -919,7 +919,7 @@ GLTFExporter.prototype = { } - if ( material.isShaderMaterial ) { + if ( material.isShaderMaterial && !material.isGLTFSpecularGlossinessMaterial ) { console.warn( 'GLTFExporter: THREE.ShaderMaterial not supported.' ); return null; @@ -939,6 +939,12 @@ GLTFExporter.prototype = { extensionsUsed[ 'KHR_materials_unlit' ] = true; + } else if ( material.isGLTFSpecularGlossinessMaterial ) { + + gltfMaterial.extensions = { KHR_materials_pbrSpecularGlossiness: {} }; + + extensionsUsed[ 'KHR_materials_pbrSpecularGlossiness' ] = true; + } else if ( ! material.isMeshStandardMaterial ) { console.warn( 'GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.' ); @@ -971,6 +977,23 @@ GLTFExporter.prototype = { } + // pbrSpecularGlossiness diffuse, specular and glossiness factor + if ( material.isGLTFSpecularGlossinessMaterial ) { + + if ( gltfMaterial.pbrMetallicRoughness.baseColorFactor ) { + + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseFactor = gltfMaterial.pbrMetallicRoughness.baseColorFactor; + + } + + var specularFactor = [ 1, 1, 1 ]; + material.specular.toArray( specularFactor, 0 ); + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularFactor = specularFactor; + + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.glossinessFactor = material.glossiness; + + } + // pbrMetallicRoughness.metallicRoughnessTexture if ( material.metalnessMap || material.roughnessMap ) { @@ -988,12 +1011,28 @@ GLTFExporter.prototype = { } - // pbrMetallicRoughness.baseColorTexture + // pbrMetallicRoughness.baseColorTexture or pbrSpecularGlossiness diffuseTexture if ( material.map ) { var baseColorMapDef = { index: processTexture( material.map ) }; applyTextureTransform( baseColorMapDef, material.map ); + + if ( material.isGLTFSpecularGlossinessMaterial ) { + + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.diffuseTexture = baseColorMapDef; + + } + gltfMaterial.pbrMetallicRoughness.baseColorTexture = baseColorMapDef; + + } + + // pbrSpecularGlossiness specular map + if ( material.isGLTFSpecularGlossinessMaterial && material.specularMap ) { + + var specularMapDef = { index: processTexture( material.specularMap ) }; + applyTextureTransform( specularMapDef, material.specularMap ); + gltfMaterial.extensions.KHR_materials_pbrSpecularGlossiness.specularGlossinessTexture = specularMapDef; } @@ -1028,7 +1067,7 @@ GLTFExporter.prototype = { var normalMapDef = { index: processTexture( material.normalMap ) }; - if ( material.normalScale.x !== - 1 ) { + if ( material.normalScale && material.normalScale.x !== - 1 ) { if ( material.normalScale.x !== material.normalScale.y ) { diff --git a/examples/jsm/geometries/ParametricGeometries.js b/examples/jsm/geometries/ParametricGeometries.js index 34218dfa0ee19c..a08bdf3d6fab91 100644 --- a/examples/jsm/geometries/ParametricGeometries.js +++ b/examples/jsm/geometries/ParametricGeometries.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 * * Experimenting of primitive geometry creation using Surface Parametric equations diff --git a/examples/jsm/loaders/AMFLoader.js b/examples/jsm/loaders/AMFLoader.js index e9f5012ea296b8..fa40b3d8d7665b 100644 --- a/examples/jsm/loaders/AMFLoader.js +++ b/examples/jsm/loaders/AMFLoader.js @@ -1,4 +1,4 @@ -/* +/** * @author tamarintech / https://tamarintech.com * * Description: Early release of an AMF Loader following the pattern of the diff --git a/examples/jsm/loaders/DDSLoader.js b/examples/jsm/loaders/DDSLoader.js index cae0fa1702b624..15a1fc087cc305 100644 --- a/examples/jsm/loaders/DDSLoader.js +++ b/examples/jsm/loaders/DDSLoader.js @@ -1,4 +1,4 @@ -/* +/** * @author mrdoob / http://mrdoob.com/ */ diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index a9386b111719f2..2fede81a23ab97 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -2205,6 +2205,7 @@ var GLTFLoader = ( function () { pointsMaterial.color.copy( material.color ); pointsMaterial.map = material.map; pointsMaterial.lights = false; // PointsMaterial doesn't support lights yet + pointsMaterial.sizeAttenuation = false; // glTF spec says points should be 1px this.cache.add( cacheKey, pointsMaterial ); diff --git a/examples/jsm/loaders/STLLoader.js b/examples/jsm/loaders/STLLoader.js index e39417fc454600..678dbd218f150b 100644 --- a/examples/jsm/loaders/STLLoader.js +++ b/examples/jsm/loaders/STLLoader.js @@ -3,6 +3,7 @@ * @author mrdoob / http://mrdoob.com/ * @author gero3 / https://github.com/gero3 * @author Mugen87 / https://github.com/Mugen87 + * @author neverhood311 / https://github.com/neverhood311 * * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs. * @@ -27,6 +28,31 @@ * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: THREE.VertexColors }); * } else { .... } * var mesh = new THREE.Mesh( geometry, material ); + * + * For ASCII STLs containing multiple solids, each solid is assigned to a different group. + * Groups can be used to assign a different color by defining an array of materials with the same length of + * geometry.groups and passing it to the Mesh constructor: + * + * var mesh = new THREE.Mesh( geometry, material ); + * + * For example: + * + * var materials = []; + * var nGeometryGroups = geometry.groups.length; + * + * var colorMap = ...; // Some logic to index colors. + * + * for (var i = 0; i < nGeometryGroups; i++) { + * + * var material = new THREE.MeshPhongMaterial({ + * color: colorMap[i], + * wireframe: false + * }); + * + * } + * + * materials.push(material); + * var mesh = new THREE.Mesh(geometry, materials); */ import { @@ -116,7 +142,7 @@ STLLoader.prototype = { // If "solid" text is matched to the current offset, declare it to be an ASCII STL. - if ( matchDataViewAt ( solid, reader, off ) ) return false; + if ( matchDataViewAt( solid, reader, off ) ) return false; } @@ -158,7 +184,7 @@ STLLoader.prototype = { ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) { hasColors = true; - colors = []; + colors = new Float32Array( faces * 3 * 3 ); defaultR = reader.getUint8( index + 6 ) / 255; defaultG = reader.getUint8( index + 7 ) / 255; @@ -174,8 +200,8 @@ STLLoader.prototype = { var geometry = new BufferGeometry(); - var vertices = []; - var normals = []; + var vertices = new Float32Array( faces * 3 * 3 ); + var normals = new Float32Array( faces * 3 * 3 ); for ( var face = 0; face < faces; face ++ ) { @@ -209,16 +235,21 @@ STLLoader.prototype = { for ( var i = 1; i <= 3; i ++ ) { var vertexstart = start + i * 12; + var componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 ); - vertices.push( reader.getFloat32( vertexstart, true ) ); - vertices.push( reader.getFloat32( vertexstart + 4, true ) ); - vertices.push( reader.getFloat32( vertexstart + 8, true ) ); + vertices[ componentIdx ] = reader.getFloat32( vertexstart, true ); + vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true ); + vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true ); - normals.push( normalX, normalY, normalZ ); + normals[ componentIdx ] = normalX; + normals[ componentIdx + 1 ] = normalY; + normals[ componentIdx + 2 ] = normalZ; if ( hasColors ) { - colors.push( r, g, b ); + colors[ componentIdx ] = r; + colors[ componentIdx + 1 ] = g; + colors[ componentIdx + 2 ] = b; } @@ -226,12 +257,12 @@ STLLoader.prototype = { } - geometry.addAttribute( 'position', new BufferAttribute( new Float32Array( vertices ), 3 ) ); - geometry.addAttribute( 'normal', new BufferAttribute( new Float32Array( normals ), 3 ) ); + geometry.addAttribute( 'position', new BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'normal', new BufferAttribute( normals, 3 ) ); if ( hasColors ) { - geometry.addAttribute( 'color', new BufferAttribute( new Float32Array( colors ), 3 ) ); + geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) ); geometry.hasColors = true; geometry.alpha = alpha; @@ -244,6 +275,7 @@ STLLoader.prototype = { function parseASCII( data ) { var geometry = new BufferGeometry(); + var patternSolid = /solid([\s\S]*?)endsolid/g; var patternFace = /facet([\s\S]*?)endfacet/g; var faceCounter = 0; @@ -258,53 +290,80 @@ STLLoader.prototype = { var result; - while ( ( result = patternFace.exec( data ) ) !== null ) { + var groupVertexes = []; + var groupCount = 0; + var startVertex = 0; + var endVertex = 0; - var vertexCountPerFace = 0; - var normalCountPerFace = 0; + while ( ( result = patternSolid.exec( data ) ) !== null ) { - var text = result[ 0 ]; + startVertex = endVertex; - while ( ( result = patternNormal.exec( text ) ) !== null ) { + var solid = result[ 0 ]; - normal.x = parseFloat( result[ 1 ] ); - normal.y = parseFloat( result[ 2 ] ); - normal.z = parseFloat( result[ 3 ] ); - normalCountPerFace ++; + while ( ( result = patternFace.exec( solid ) ) !== null ) { - } + var vertexCountPerFace = 0; + var normalCountPerFace = 0; - while ( ( result = patternVertex.exec( text ) ) !== null ) { + var text = result[ 0 ]; - vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) ); - normals.push( normal.x, normal.y, normal.z ); - vertexCountPerFace ++; + while ( ( result = patternNormal.exec( text ) ) !== null ) { - } + normal.x = parseFloat( result[ 1 ] ); + normal.y = parseFloat( result[ 2 ] ); + normal.z = parseFloat( result[ 3 ] ); + normalCountPerFace ++; - // every face have to own ONE valid normal + } - if ( normalCountPerFace !== 1 ) { + while ( ( result = patternVertex.exec( text ) ) !== null ) { - console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter ); + vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) ); + normals.push( normal.x, normal.y, normal.z ); + vertexCountPerFace ++; + endVertex ++; - } + } - // each face have to own THREE valid vertices + // every face have to own ONE valid normal - if ( vertexCountPerFace !== 3 ) { + if ( normalCountPerFace !== 1 ) { - console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter ); + console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter ); + + } + + // each face have to own THREE valid vertices + + if ( vertexCountPerFace !== 3 ) { + + console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter ); + + } + + faceCounter ++; } - faceCounter ++; + groupVertexes.push( { startVertex: startVertex, endVertex: endVertex } ); + groupCount ++; } geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); geometry.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) ); + if ( groupCount > 0 ) { + + for ( var i = 0; i < groupVertexes.length; i ++ ) { + + geometry.addGroup( groupVertexes[ i ].startVertex, groupVertexes[ i ].endVertex, i ); + + } + + } + return geometry; } @@ -331,6 +390,7 @@ STLLoader.prototype = { array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian } + return array_buffer.buffer || array_buffer; } else { diff --git a/examples/jsm/loaders/TDSLoader.js b/examples/jsm/loaders/TDSLoader.js index baf5432fb51017..164e4142eef4a6 100644 --- a/examples/jsm/loaders/TDSLoader.js +++ b/examples/jsm/loaders/TDSLoader.js @@ -1,4 +1,4 @@ -/* +/** * Autodesk 3DS three.js file loader, based on lib3ds. * * Loads geometry with uv and materials basic properties with texture support. diff --git a/examples/jsm/loaders/TGALoader.js b/examples/jsm/loaders/TGALoader.js index d53bac512da3c1..b47435a599326e 100644 --- a/examples/jsm/loaders/TGALoader.js +++ b/examples/jsm/loaders/TGALoader.js @@ -1,4 +1,4 @@ -/* +/** * @author Daosheng Mu / https://github.com/DaoshengMu/ * @author mrdoob / http://mrdoob.com/ * @author takahirox / https://github.com/takahirox/ diff --git a/examples/jsm/loaders/ctm/CTMLoader.d.ts b/examples/jsm/loaders/ctm/CTMLoader.d.ts deleted file mode 100644 index b9c6dee5265aee..00000000000000 --- a/examples/jsm/loaders/ctm/CTMLoader.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { - BufferGeometry, - Material -} from '../../../../src/Three'; - -export interface CTMLoaderParameters { - basePath?: string; - offsets?: number[]; - useWorker?: boolean; - worker?: object; -} - -export class CTMLoader { - constructor(); - workerPath: string; - - load(url: string, onLoad: (geometry: BufferGeometry) => void, parameters: CTMLoaderParameters): void; - loadParts(url: string, onLoad: (geometries: BufferGeometry[], materials: Material[]) => void, parameters: CTMLoaderParameters): void; - setWorkerPath(value: string): this; -} diff --git a/examples/jsm/loaders/ctm/CTMLoader.js b/examples/jsm/loaders/ctm/CTMLoader.js deleted file mode 100644 index 67f50e06f628e5..00000000000000 --- a/examples/jsm/loaders/ctm/CTMLoader.js +++ /dev/null @@ -1,288 +0,0 @@ -/** - * Loader for CTM encoded models generated by OpenCTM tools: - * http://openctm.sourceforge.net/ - * - * Uses js-openctm library by Juan Mellado - * http://code.google.com/p/js-openctm/ - * - * @author alteredq / http://alteredqualia.com/ - * - * OpenCTM LICENSE: - * - * Copyright (c) 2009-2010 Marcus Geelnard - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - * - */ - -import { - BufferAttribute, - BufferGeometry, - Loader, - LoaderUtils -} from "../../../../build/three.module.js"; - -/* global CTM */ - -var CTMLoader = function () { - - this.workerPath = null; - -}; - -CTMLoader.prototype.constructor = CTMLoader; - -CTMLoader.prototype.setWorkerPath = function ( workerPath ) { - - this.workerPath = workerPath; - -}; - -// Load multiple CTM parts defined in JSON - -CTMLoader.prototype.loadParts = function ( url, callback, parameters ) { - - parameters = parameters || {}; - - var scope = this; - - var xhr = new XMLHttpRequest(); - - var basePath = parameters.basePath ? parameters.basePath : LoaderUtils.extractUrlBase( url ); - - xhr.onreadystatechange = function () { - - if ( xhr.readyState === 4 ) { - - if ( xhr.status === 200 || xhr.status === 0 ) { - - var jsonObject = JSON.parse( xhr.responseText ); - - var materials = [], geometries = [], counter = 0; - - function callbackFinal( geometry ) { - - counter += 1; - - geometries.push( geometry ); - - if ( counter === jsonObject.offsets.length ) { - - callback( geometries, materials ); - - } - - } - - - // init materials - - for ( var i = 0; i < jsonObject.materials.length; i ++ ) { - - materials[ i ] = Loader.prototype.createMaterial( jsonObject.materials[ i ], basePath ); - - } - - // load joined CTM file - - var partUrl = basePath + jsonObject.data; - var parametersPart = { useWorker: parameters.useWorker, worker: parameters.worker, offsets: jsonObject.offsets }; - scope.load( partUrl, callbackFinal, parametersPart ); - - } - - } - - }; - - xhr.open( "GET", url, true ); - xhr.setRequestHeader( "Content-Type", "text/plain" ); - xhr.send( null ); - -}; - -// Load CTMLoader compressed models -// - parameters -// - url (required) -// - callback (required) - -CTMLoader.prototype.load = function ( url, callback, parameters ) { - - parameters = parameters || {}; - - var scope = this; - - var offsets = parameters.offsets !== undefined ? parameters.offsets : [ 0 ]; - - var xhr = new XMLHttpRequest(), - callbackProgress = null; - - var length = 0; - - xhr.onreadystatechange = function () { - - if ( xhr.readyState === 4 ) { - - if ( xhr.status === 200 || xhr.status === 0 ) { - - var binaryData = new Uint8Array( xhr.response ); - - var s = Date.now(); - - if ( parameters.useWorker ) { - - var worker = parameters.worker || new Worker( scope.workerPath ); - - worker.onmessage = function ( event ) { - - var files = event.data; - - for ( var i = 0; i < files.length; i ++ ) { - - var ctmFile = files[ i ]; - - var e1 = Date.now(); - // console.log( "CTM data parse time [worker]: " + (e1-s) + " ms" ); - - scope._createGeometry( ctmFile, callback ); - - var e = Date.now(); - console.log( "model load time [worker]: " + ( e - e1 ) + " ms, total: " + ( e - s ) ); - - } - - - }; - - worker.postMessage( { "data": binaryData, "offsets": offsets }, [ binaryData.buffer ] ); - - } else { - - for ( var i = 0; i < offsets.length; i ++ ) { - - var stream = new CTM.Stream( binaryData ); - stream.offset = offsets[ i ]; - - var ctmFile = new CTM.File( stream ); - - scope._createGeometry( ctmFile, callback ); - - } - - //var e = Date.now(); - //console.log( "CTM data parse time [inline]: " + (e-s) + " ms" ); - - } - - } else { - - console.error( "Couldn't load [" + url + "] [" + xhr.status + "]" ); - - } - - } else if ( xhr.readyState === 3 ) { - - if ( callbackProgress ) { - - if ( length === 0 ) { - - length = xhr.getResponseHeader( "Content-Length" ); - - } - - callbackProgress( { total: length, loaded: xhr.responseText.length } ); - - } - - } else if ( xhr.readyState === 2 ) { - - length = xhr.getResponseHeader( "Content-Length" ); - - } - - }; - - xhr.open( "GET", url, true ); - xhr.responseType = "arraybuffer"; - - xhr.send( null ); - -}; - - -CTMLoader.prototype._createGeometry = function ( file, callback ) { - - var geometry = new BufferGeometry(); - - var indices = file.body.indices; - var positions = file.body.vertices; - var normals = file.body.normals; - - var uvs, colors; - - var uvMaps = file.body.uvMaps; - - if ( uvMaps !== undefined && uvMaps.length > 0 ) { - - uvs = uvMaps[ 0 ].uv; - - } - - var attrMaps = file.body.attrMaps; - - if ( attrMaps !== undefined && attrMaps.length > 0 && attrMaps[ 0 ].name === 'Color' ) { - - colors = attrMaps[ 0 ].attr; - - } - - geometry.setIndex( new BufferAttribute( indices, 1 ) ); - geometry.addAttribute( 'position', new BufferAttribute( positions, 3 ) ); - - if ( normals !== undefined ) { - - geometry.addAttribute( 'normal', new BufferAttribute( normals, 3 ) ); - - } - - if ( uvs !== undefined ) { - - geometry.addAttribute( 'uv', new BufferAttribute( uvs, 2 ) ); - - } - - if ( colors !== undefined ) { - - geometry.addAttribute( 'color', new BufferAttribute( colors, 4 ) ); - - } - - // compute vertex normals if not present in the CTM model - if ( geometry.attributes.normal === undefined ) { - - geometry.computeVertexNormals(); - - } - - callback( geometry ); - -}; - -export { CTMLoader }; diff --git a/examples/jsm/modifiers/SimplifyModifier.js b/examples/jsm/modifiers/SimplifyModifier.js index 9caa4b9da98579..196e57fdf391a3 100644 --- a/examples/jsm/modifiers/SimplifyModifier.js +++ b/examples/jsm/modifiers/SimplifyModifier.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog * * Simplification Geometry Modifier diff --git a/examples/jsm/modifiers/SubdivisionModifier.js b/examples/jsm/modifiers/SubdivisionModifier.js index 0e43d05d265761..cd912a90768b46 100644 --- a/examples/jsm/modifiers/SubdivisionModifier.js +++ b/examples/jsm/modifiers/SubdivisionModifier.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog * @author centerionware / http://www.centerionware.com * diff --git a/examples/jsm/nodes/accessors/NormalNode.js b/examples/jsm/nodes/accessors/NormalNode.js index 5621a2a1b8027e..e5990f9424e793 100644 --- a/examples/jsm/nodes/accessors/NormalNode.js +++ b/examples/jsm/nodes/accessors/NormalNode.js @@ -36,7 +36,8 @@ NormalNode.prototype.generate = function ( builder, output ) { case NormalNode.LOCAL: - result = 'normal'; + if ( builder.isShader( 'vertex' ) ) result = 'objectNormal'; + else result = 'geometryNormal'; break; diff --git a/examples/jsm/nodes/accessors/ReflectNode.js b/examples/jsm/nodes/accessors/ReflectNode.js index 390ddb05896137..902004875126cb 100644 --- a/examples/jsm/nodes/accessors/ReflectNode.js +++ b/examples/jsm/nodes/accessors/ReflectNode.js @@ -3,6 +3,8 @@ */ import { TempNode } from '../core/TempNode.js'; +import { PositionNode } from './PositionNode.js'; +import { NormalNode } from './NormalNode.js'; function ReflectNode( scope ) { @@ -44,7 +46,10 @@ ReflectNode.prototype.generate = function ( builder, output ) { case ReflectNode.VECTOR: - builder.addNodeCode( 'vec3 reflectVec = inverseTransformDirection( reflect( -normalize( vViewPosition ), normal ), viewMatrix );' ); + var viewNormal = new NormalNode().build( builder, 'v3' ); + var viewPosition = new PositionNode( PositionNode.VIEW ).build( builder, 'v3' ); + + builder.addNodeCode( 'vec3 reflectVec = inverseTransformDirection( reflect( -normalize( ' + viewPosition + ' ), ' + viewNormal + ' ), viewMatrix );' ); result = 'reflectVec'; diff --git a/examples/jsm/nodes/core/FunctionNode.js b/examples/jsm/nodes/core/FunctionNode.js index 23d9d5cfa9eb57..32403c57edc201 100644 --- a/examples/jsm/nodes/core/FunctionNode.js +++ b/examples/jsm/nodes/core/FunctionNode.js @@ -12,6 +12,7 @@ var declarationRegexp = /^([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i, function FunctionNode( src, includes, extensions, keywords, type ) { this.isMethod = type === undefined; + this.isInterface = false; TempNode.call( this, type ); @@ -139,7 +140,11 @@ FunctionNode.prototype.generate = function ( builder, output ) { } else if ( this.isMethod ) { - builder.include( this, false, src ); + if ( ! this.isInterface ) { + + builder.include( this, false, src ); + + } return this.name; @@ -181,7 +186,7 @@ FunctionNode.prototype.parse = function ( src, includes, extensions, keywords ) var qualifier = inputs[ i ++ ]; var type, name; - if ( qualifier == 'in' || qualifier == 'out' || qualifier == 'inout' ) { + if ( qualifier === 'in' || qualifier === 'out' || qualifier === 'inout' ) { type = inputs[ i ++ ]; @@ -204,6 +209,8 @@ FunctionNode.prototype.parse = function ( src, includes, extensions, keywords ) } + this.isInterface = this.src.indexOf('{') === -1; + } else { this.type = ''; diff --git a/examples/jsm/nodes/materials/StandardNodeMaterial.js b/examples/jsm/nodes/materials/StandardNodeMaterial.js index fae44b8ac7e552..9f74b0f5598f5d 100644 --- a/examples/jsm/nodes/materials/StandardNodeMaterial.js +++ b/examples/jsm/nodes/materials/StandardNodeMaterial.js @@ -27,6 +27,7 @@ NodeUtils.addShortcuts( StandardNodeMaterial.prototype, 'fragment', [ 'reflectivity', 'clearCoat', 'clearCoatRoughness', + 'clearCoatNormal', 'normal', 'emissive', 'ambient', diff --git a/examples/jsm/nodes/materials/nodes/StandardNode.js b/examples/jsm/nodes/materials/nodes/StandardNode.js index 880f22ca107c28..0b6da0b94b483d 100644 --- a/examples/jsm/nodes/materials/nodes/StandardNode.js +++ b/examples/jsm/nodes/materials/nodes/StandardNode.js @@ -32,9 +32,7 @@ StandardNode.prototype.build = function ( builder ) { var code; - builder.define( this.clearCoat || this.clearCoatRoughness ? 'PHYSICAL' : 'STANDARD' ); - - if ( this.energyPreservation ) builder.define( 'ENERGY_PRESERVATION' ); + builder.define( this.clearCoat || this.clearCoatRoughness || this.clearCoatNormal ? 'PHYSICAL' : 'STANDARD' ); builder.requires.lights = true; @@ -147,6 +145,7 @@ StandardNode.prototype.build = function ( builder ) { if ( this.clearCoat ) this.clearCoat.analyze( builder ); if ( this.clearCoatRoughness ) this.clearCoatRoughness.analyze( builder ); + if ( this.clearCoatNormal ) this.clearCoatNormal.analyze( builder ); if ( this.reflectivity ) this.reflectivity.analyze( builder ); @@ -188,6 +187,7 @@ StandardNode.prototype.build = function ( builder ) { var clearCoat = this.clearCoat ? this.clearCoat.flow( builder, 'f' ) : undefined; var clearCoatRoughness = this.clearCoatRoughness ? this.clearCoatRoughness.flow( builder, 'f' ) : undefined; + var clearCoatNormal = this.clearCoatNormal ? this.clearCoatNormal.flow( builder, 'v3' ) : undefined; var reflectivity = this.reflectivity ? this.reflectivity.flow( builder, 'f' ) : undefined; @@ -244,6 +244,7 @@ StandardNode.prototype.build = function ( builder ) { // add before: prevent undeclared normal " #include ", + " #include ", // add before: prevent undeclared material " PhysicalMaterial material;", @@ -295,6 +296,15 @@ StandardNode.prototype.build = function ( builder ) { } + if ( clearCoatNormal ) { + + output.push( + clearCoatNormal.code, + 'clearCoatNormal = ' + clearCoatNormal.result + ';' + ); + + } + // optimization for now output.push( diff --git a/examples/jsm/nodes/misc/TextureCubeNode.js b/examples/jsm/nodes/misc/TextureCubeNode.js index 14dc2fd1422429..b318b57ef94c08 100644 --- a/examples/jsm/nodes/misc/TextureCubeNode.js +++ b/examples/jsm/nodes/misc/TextureCubeNode.js @@ -11,17 +11,19 @@ import { NormalNode } from '../accessors/NormalNode.js'; import { ColorSpaceNode } from '../utils/ColorSpaceNode.js'; import { BlinnExponentToRoughnessNode } from '../bsdfs/BlinnExponentToRoughnessNode.js'; -function TextureCubeNode( value, textureSize ) { +function TextureCubeNode( value, textureSize, uv, bias ) { TempNode.call( this, 'v4' ); this.value = value; this.textureSize = textureSize || new FloatNode( 1024 ); + this.uv = uv || new ReflectNode( ReflectNode.VECTOR ); + this.bias = bias || new BlinnExponentToRoughnessNode(); this.radianceCache = { uv: new TextureCubeUVNode( - new ReflectNode( ReflectNode.VECTOR ), + this.uv, this.textureSize, - new BlinnExponentToRoughnessNode() + this.bias ) }; this.irradianceCache = { uv: new TextureCubeUVNode( diff --git a/examples/jsm/shaders/TranslucentShader.js b/examples/jsm/shaders/TranslucentShader.js index 96cd51ca74dd79..9a4000b669ffc5 100644 --- a/examples/jsm/shaders/TranslucentShader.js +++ b/examples/jsm/shaders/TranslucentShader.js @@ -68,6 +68,7 @@ var TranslucentShader = { ].join( "\n" ), fragmentShader: [ + "#define USE_UV", "#define USE_MAP", "#define PHONG", "#define TRANSLUCENT", @@ -144,7 +145,7 @@ var TranslucentShader = { " RE_Direct( directLight, geometry, material, reflectedLight );", - " #if defined( TRANSLUCENT ) && defined( USE_MAP )", + " #if defined( TRANSLUCENT ) && defined( USE_UV )", " RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);", " #endif", " }", @@ -166,7 +167,7 @@ var TranslucentShader = { " RE_Direct( directLight, geometry, material, reflectedLight );", - " #if defined( TRANSLUCENT ) && defined( USE_MAP )", + " #if defined( TRANSLUCENT ) && defined( USE_UV )", " RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);", " #endif", " }", diff --git a/examples/jsm/utils/UVsDebug.js b/examples/jsm/utils/UVsDebug.js index d3d6c37d49d785..9c71000e6edada 100644 --- a/examples/jsm/utils/UVsDebug.js +++ b/examples/jsm/utils/UVsDebug.js @@ -1,4 +1,4 @@ -/* +/** * @author zz85 / http://github.com/zz85 * @author WestLangley / http://github.com/WestLangley * @author Mugen87 / https://github.com/Mugen87 diff --git a/examples/misc_controls_transform.html b/examples/misc_controls_transform.html index 7a0755694aaa97..234d7b0d238bbf 100644 --- a/examples/misc_controls_transform.html +++ b/examples/misc_controls_transform.html @@ -83,7 +83,7 @@ case 17: // Ctrl control.setTranslationSnap( 100 ); - control.setRotationSnap( Math.degToRad( 15 ) ); + control.setRotationSnap( THREE.Math.degToRad( 15 ) ); break; case 87: // W diff --git a/examples/models/ctm/LeePerry.ctm b/examples/models/ctm/LeePerry.ctm deleted file mode 100644 index 55477019c1f6a6..00000000000000 Binary files a/examples/models/ctm/LeePerry.ctm and /dev/null differ diff --git a/examples/models/ctm/WaltHead.ctm b/examples/models/ctm/WaltHead.ctm deleted file mode 100644 index 460cbb0ff3c8a0..00000000000000 Binary files a/examples/models/ctm/WaltHead.ctm and /dev/null differ diff --git a/examples/models/ctm/ben.ctm b/examples/models/ctm/ben.ctm deleted file mode 100644 index 4825fe0f92a745..00000000000000 Binary files a/examples/models/ctm/ben.ctm and /dev/null differ diff --git a/examples/models/ctm/camaro/camaro.ctm b/examples/models/ctm/camaro/camaro.ctm deleted file mode 100644 index d92c1955dfeda5..00000000000000 Binary files a/examples/models/ctm/camaro/camaro.ctm and /dev/null differ diff --git a/examples/models/ctm/camaro/camaro.js b/examples/models/ctm/camaro/camaro.js deleted file mode 100644 index e91218b3b2029a..00000000000000 --- a/examples/models/ctm/camaro/camaro.js +++ /dev/null @@ -1,113 +0,0 @@ -{ -"data" : "camaro.ctm", - -"offsets": [ 0, 39262, 79223, 83542, 94677, 95890, 144902, 470461 ], - -"materials" : - [ - { - "DbgColor" : 15658734, - "DbgIndex" : 0, - "DbgName" : "Body_car-ao", - "colorDiffuse" : [0.1816, 0.3264, 0.3704], - "colorSpecular" : [2.0, 2.0, 2.0], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 778.431373, - "opacity" : 1.0 - }, - - { - "DbgColor" : 15597568, - "DbgIndex" : 1, - "DbgName" : "tire_car-ao", - "colorDiffuse" : [0.2168, 0.2168, 0.2104], - "colorSpecular" : [0.1, 0.1, 0.1], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 15.686275, - "opacity" : 1.0 - }, - - { - "DbgColor" : 60928, - "DbgIndex" : 2, - "DbgName" : "black2_car-ao", - "colorDiffuse" : [0.0, 0.0, 0.0], - "colorSpecular" : [0.0, 0.0, 0.0], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 0.0, - "opacity" : 1.0 - }, - - { - "DbgColor" : 238, - "DbgIndex" : 3, - "DbgName" : "tireling_car-ao", - "colorDiffuse" : [0.4, 0.4, 0.4], - "colorSpecular" : [0.2, 0.2, 0.2], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 15.686275, - "opacity" : 1.0 - }, - - { - "DbgColor" : 15658496, - "DbgIndex" : 4, - "DbgName" : "glass_car-ao", - "colorDiffuse" : [0.16, 0.248, 0.2448], - "colorSpecular" : [2.0, 2.0, 2.0], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 778.431373, - "opacity" : 0.34 - }, - - { - "DbgColor" : 61166, - "DbgIndex" : 5, - "DbgName" : "black_car-ao", - "colorDiffuse" : [0.0816, 0.0816, 0.0816], - "colorSpecular" : [0.2, 0.2, 0.2], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 3.921569, - "opacity" : 1.0 - }, - - { - "DbgColor" : 15597806, - "DbgIndex" : 6, - "DbgName" : "mirror_car-ao", - "colorDiffuse" : [0.24, 0.24, 0.24], - "colorSpecular" : [2.0, 2.0, 2.0], - "illumination" : 2, - "mapDiffuse" : "car-ao.png", - "opticalDensity" : 1.0, - "specularCoef" : 778.431373, - "opacity" : 1.0 - }, - - - { - "DbgColor" : 3744854, - "DbgIndex" : 8, - "DbgName" : "Material.001_plane-ao-256", - "colorDiffuse" : [0.798635, 0.776149, 0.8], - "colorSpecular" : [0.5, 0.5, 0.5], - "illumination" : 2, - "mapDiffuse" : "plane-ao-256.png", - "opticalDensity" : 1.0, - "specularCoef" : 96.078431, - "opacity" : 1.0 - } - ] -} diff --git a/examples/models/ctm/camaro/car-ao.png b/examples/models/ctm/camaro/car-ao.png deleted file mode 100644 index 9748ca51bc60e6..00000000000000 Binary files a/examples/models/ctm/camaro/car-ao.png and /dev/null differ diff --git a/examples/models/ctm/camaro/plane-ao-256.png b/examples/models/ctm/camaro/plane-ao-256.png deleted file mode 100644 index e183a44b7686fc..00000000000000 Binary files a/examples/models/ctm/camaro/plane-ao-256.png and /dev/null differ diff --git a/examples/models/ctm/hand.ctm b/examples/models/ctm/hand.ctm deleted file mode 100644 index 38eb1046c6a244..00000000000000 Binary files a/examples/models/ctm/hand.ctm and /dev/null differ diff --git a/examples/textures/nvidia_tentacle/tentacle_object_space.png b/examples/textures/nvidia_tentacle/tentacle_object_space.png deleted file mode 100644 index 2ae9fc70bb6436..00000000000000 Binary files a/examples/textures/nvidia_tentacle/tentacle_object_space.png and /dev/null differ diff --git a/examples/textures/nvidia_tentacle/tentacle_tangent_space.png b/examples/textures/nvidia_tentacle/tentacle_tangent_space.png deleted file mode 100644 index 498c7dc2376ca1..00000000000000 Binary files a/examples/textures/nvidia_tentacle/tentacle_tangent_space.png and /dev/null differ diff --git a/examples/textures/pbr/Scratched_gold/Scratched_gold.txt b/examples/textures/pbr/Scratched_gold/Scratched_gold.txt new file mode 100644 index 00000000000000..336d1117a64764 --- /dev/null +++ b/examples/textures/pbr/Scratched_gold/Scratched_gold.txt @@ -0,0 +1 @@ +https://www.cgbookcase.com/textures/scratched-gold-01 diff --git a/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_AO.png b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_AO.png new file mode 100644 index 00000000000000..d21e89492cca72 Binary files /dev/null and b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_AO.png differ diff --git a/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Base_Color.png b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Base_Color.png new file mode 100644 index 00000000000000..6086f514a866e0 Binary files /dev/null and b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Base_Color.png differ diff --git a/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Height.png b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Height.png new file mode 100644 index 00000000000000..85828d9ecc3d65 Binary files /dev/null and b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Height.png differ diff --git a/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Normal.png b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Normal.png new file mode 100644 index 00000000000000..89b05e2d230ca9 Binary files /dev/null and b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Normal.png differ diff --git a/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Roughness.png b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Roughness.png new file mode 100644 index 00000000000000..76be4298753802 Binary files /dev/null and b/examples/textures/pbr/Scratched_gold/Scratched_gold_01_1K_Roughness.png differ diff --git a/examples/webgl_furnace_test.html b/examples/webgl_furnace_test.html index 707f4890fe42be..96092e6fd5ba22 100644 --- a/examples/webgl_furnace_test.html +++ b/examples/webgl_furnace_test.html @@ -60,18 +60,22 @@ function createObjects() { - var geo = new THREE.SphereBufferGeometry( 0.4, 32, 32 ); + var geometry = new THREE.SphereBufferGeometry( 0.4, 32, 32 ); + var count = 10; + for ( var x = 0; x <= count; x ++ ) { - var mesh = new THREE.Mesh( geo, new THREE.MeshPhysicalMaterial( { + var material = new THREE.MeshPhysicalMaterial( { roughness: x / count, metalness: 1, color: 0xffffff, envMap: radianceMap, envMapIntensity: 1, reflectivity: 1, - } ) ); + } ); + + var mesh = new THREE.Mesh( geometry, material ); mesh.position.x = x - ( Math.floor( count / 2 ) ); scene.add( mesh ); diff --git a/examples/webgl_loader_ctm_materials.html b/examples/webgl_loader_ctm_materials.html deleted file mode 100644 index d739d83aa7dba6..00000000000000 --- a/examples/webgl_loader_ctm_materials.html +++ /dev/null @@ -1,242 +0,0 @@ - - - - three.js webgl - CTM loader materials - - - - - -
- three.js webgl - - using js-openctm
- camaro by dskfnwn - - skybox by Paul Debevec -
- - - - - diff --git a/examples/webgl_loader_stl.html b/examples/webgl_loader_stl.html index c755a91e7ef90c..2c0ade62070d19 100644 --- a/examples/webgl_loader_stl.html +++ b/examples/webgl_loader_stl.html @@ -181,9 +181,6 @@ directionalLight.shadow.camera.near = 1; directionalLight.shadow.camera.far = 4; - directionalLight.shadow.mapSize.width = 1024; - directionalLight.shadow.mapSize.height = 1024; - directionalLight.shadow.bias = - 0.002; } diff --git a/examples/webgl_materials_clearcoat_normalmap.html b/examples/webgl_materials_clearcoat_normalmap.html index 9221bf81c4f5ff..cd7dcf34591852 100644 --- a/examples/webgl_materials_clearcoat_normalmap.html +++ b/examples/webgl_materials_clearcoat_normalmap.html @@ -85,9 +85,9 @@ normalMap.wrapS = THREE.RepeatWrapping; normalMap.wrapT = THREE.RepeatWrapping; - var clearCoatNormaMap = textureLoader.load( "textures/waternormals.jpg" ); - clearCoatNormaMap.wrapS = THREE.RepeatWrapping; - clearCoatNormaMap.wrapT = THREE.RepeatWrapping; + var normalMap2 = textureLoader.load( "textures/water/Water_1_M_Normal.jpg" ); + + var clearCoatNormaMap = textureLoader.load( "textures/pbr/Scratched_gold/Scratched_gold_01_1K_Normal.png" ); // @@ -119,9 +119,11 @@ var material = new THREE.MeshPhysicalMaterial( { clearCoat: 1.0, + metalness: 0.0, + color: 0xff0000, envMap: hdrCubeRenderTarget.texture, - map: diffuse, - clearCoatNormalMap: clearCoatNormaMap + clearCoatNormalMap: clearCoatNormaMap, + clearCoatNormalScale: new THREE.Vector2( 2.0, 2.0 ) } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.x = - 100; @@ -132,10 +134,13 @@ var material = new THREE.MeshPhysicalMaterial( { clearCoat: 1.0, + metalness: 1.0, + color: 0xff0000, envMap: hdrCubeRenderTarget.texture, - map: diffuse, - normalMap: normalMap, - clearCoatNormalMap: clearCoatNormaMap + normalMap: normalMap2, + normalScale: new THREE.Vector2( 0.15, 0.15 ), + clearCoatNormalMap: clearCoatNormaMap, + clearCoatNormalScale: new THREE.Vector2( 2.0, 2.0 ) } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.x = 100; diff --git a/examples/webgl_materials_nodes.html b/examples/webgl_materials_nodes.html index 26bd064d10bfb8..fb8b371c3ffb58 100644 --- a/examples/webgl_materials_nodes.html +++ b/examples/webgl_materials_nodes.html @@ -71,63 +71,56 @@ } - var cubemap = function () { + var premTexture, pmremCube, pmremGenerator, pmremCubeUVPacker, premSize = 1024; - var path = "textures/cube/Park2/"; - var format = '.jpg'; - var urls = [ - path + 'posx' + format, path + 'negx' + format, - path + 'posy' + format, path + 'negy' + format, - path + 'posz' + format, path + 'negz' + format - ]; + function updatePREM( textureCube ) { - var textureCube = new THREE.CubeTextureLoader().load( urls ); - textureCube.format = THREE.RGBFormat; + pmremCube = pmremCube || textureCube; - library[ textureCube.uuid ] = textureCube; + if ( ! pmremCube || ! renderer ) return; - return textureCube; + var minFilter = pmremCube.minFilter; + var magFilter = pmremCube.magFilter; + var generateMipmaps = pmremCube.generateMipmaps; - }(); + pmremGenerator = new PMREMGenerator( pmremCube, undefined, premSize / 4 ); + pmremGenerator.update( renderer ); - function generatePREM( cubeMap, textureSize ) { + pmremCubeUVPacker = new PMREMCubeUVPacker( pmremGenerator.cubeLods ); + pmremCubeUVPacker.update( renderer ); - textureSize = textureSize || 1024; + pmremCube.minFilter = minFilter; + pmremCube.magFilter = magFilter; + pmremCube.generateMipmaps = pmremCube.generateMipmaps; + pmremCube.needsUpdate = true; - var pmremGenerator = new PMREMGenerator( cubeMap, undefined, textureSize / 4 ); - pmremGenerator.update( renderer ); + premTexture = pmremCubeUVPacker.CubeUVRenderTarget.texture - var pmremCubeUVPacker = new PMREMCubeUVPacker( pmremGenerator.cubeLods ); - pmremCubeUVPacker.update( renderer ); + library[ premTexture.uuid ] = premTexture; pmremGenerator.dispose(); pmremCubeUVPacker.dispose(); - return pmremCubeUVPacker.CubeUVRenderTarget.texture; - } - var premTexture; - - function getPREM( callback, textureSize ) { - - if ( premTexture ) return callback( premTexture ); - - var hdrUrls = [ 'px.hdr', 'nx.hdr', 'py.hdr', 'ny.hdr', 'pz.hdr', 'nz.hdr' ]; - var hdrCubeMap = new HDRCubeTextureLoader() - .setPath( './textures/cube/pisaHDR/' ) - .setDataType( THREE.UnsignedByteType ) - .load( hdrUrls, function () { + var cubemap = function () { - premTexture = generatePREM( hdrCubeMap, textureSize ); + var path = "textures/cube/Park2/"; + var format = '.jpg'; + var urls = [ + path + 'posx' + format, path + 'negx' + format, + path + 'posy' + format, path + 'negy' + format, + path + 'posz' + format, path + 'negz' + format + ]; - library[ premTexture.uuid ] = premTexture; + var textureCube = new THREE.CubeTextureLoader().load( urls, updatePREM ); + textureCube.format = THREE.RGBFormat; - callback( premTexture ); + library[ textureCube.uuid ] = textureCube; - } ); + return textureCube; - } + }(); window.addEventListener( 'load', init ); @@ -176,6 +169,8 @@ library[ camera.uuid ] = camera; library[ mesh.uuid ] = mesh; + updatePREM(); + window.addEventListener( 'resize', onWindowResize, false ); updateMaterial(); @@ -226,6 +221,7 @@ 'adv / expression': 'expression', 'adv / sss': 'sss', 'adv / translucent': 'translucent', + 'adv / bias': 'bias', 'node / position': 'node-position', 'node / normal': 'node-normal', 'node / reflect': 'node-reflect', @@ -504,14 +500,8 @@ mtl.normal = new Nodes.NormalMapNode( new Nodes.TextureNode( getTexture( "grassNormal" ) ) ); mtl.normal.scale = normalMask; - getPREM(function(texture) { - - var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( texture ) ); - - mtl.environment = new Nodes.OperatorNode( envNode, intensity, Nodes.OperatorNode.MUL ); - mtl.needsUpdate = true; - - }); + var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( premTexture ) ); + mtl.environment = new Nodes.OperatorNode( envNode, intensity, Nodes.OperatorNode.MUL ); // GUI @@ -587,18 +577,13 @@ mtl.normal = new Nodes.NormalMapNode( new Nodes.TextureNode( getTexture( "grassNormal" ) ) ); mtl.normal.scale = normalScale; - getPREM(function(texture) { - - var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( texture ) ); - - var subSlotNode = new Nodes.SubSlotNode(); - subSlotNode.slots['radiance'] = new Nodes.OperatorNode( radiance, envNode, Nodes.OperatorNode.MUL ); - subSlotNode.slots['irradiance'] = new Nodes.OperatorNode( irradiance, envNode, Nodes.OperatorNode.MUL ); + var envNode = new Nodes.TextureCubeNode( new Nodes.TextureNode( premTexture ) ); - mtl.environment = subSlotNode; - mtl.needsUpdate = true; + var subSlotNode = new Nodes.SubSlotNode(); + subSlotNode.slots['radiance'] = new Nodes.OperatorNode( radiance, envNode, Nodes.OperatorNode.MUL ); + subSlotNode.slots['irradiance'] = new Nodes.OperatorNode( irradiance, envNode, Nodes.OperatorNode.MUL ); - }); + mtl.environment = subSlotNode // GUI @@ -757,6 +742,7 @@ //mtl.reflectivity = // reflectivity (float) //mtl.clearCoat = // clearCoat (float) //mtl.clearCoatRoughness = // clearCoatRoughness (float) + //mtl.clearCoatNormal = // clearCoatNormal (vec3) //mtl.normal = // normal (vec3) //mtl.emissive = // emissive color (vec3) //mtl.ambient = // ambient color (vec3) @@ -769,6 +755,7 @@ var mask = new Nodes.SwitchNode( new Nodes.TextureNode( getTexture( "decalDiffuse" ) ), 'w' ); var normalScale = new Nodes.FloatNode( .3 ); + var clearCoatNormalScale = new Nodes.FloatNode( .1 ); var roughnessA = new Nodes.FloatNode( .5 ); var metalnessA = new Nodes.FloatNode( .5 ); @@ -800,12 +787,20 @@ Nodes.OperatorNode.MUL ); + var clearCoatNormalMask = new Nodes.OperatorNode( + mask, + clearCoatNormalScale, + Nodes.OperatorNode.MUL + ); + mtl.color = new Nodes.ColorNode( 0xEEEEEE ); mtl.roughness = roughness; mtl.metalness = metalness; mtl.reflectivity = reflectivity; mtl.clearCoat = clearCoat; mtl.clearCoatRoughness = clearCoatRoughness; + mtl.clearCoatNormal = new Nodes.NormalMapNode( new Nodes.TextureNode( getTexture( "grassNormal" ) ) ); + mtl.clearCoatNormal.scale = clearCoatNormalMask; mtl.environment = new Nodes.CubeTextureNode( cubemap ); mtl.normal = new Nodes.NormalMapNode( new Nodes.TextureNode( getTexture( "grassNormal" ) ) ); mtl.normal.scale = normalMask; @@ -836,6 +831,12 @@ }, false, 0, 1 ); + addGui( 'clearCoatNormalScale', clearCoatNormalScale.value, function ( val ) { + + clearCoatNormalScale.value = val; + + }, false, 0, 1 ); + addGui( 'roughnessA', roughnessA.value, function ( val ) { roughnessA.value = val; @@ -2483,6 +2484,67 @@ break; + case 'bias': + + // MATERIAL + + var bias = new Nodes.FloatNode( .5 ); + var maxMIPLevel = new Nodes.MaxMIPLevelNode( new Nodes.TextureCubeNode( cubemap ) ); + var mipsBias = new Nodes.OperatorNode( bias, maxMIPLevel, Nodes.OperatorNode.MUL ); + + mtl = new Nodes.PhongNodeMaterial(); + mtl.color.value.setHex( 0xFFFFFF ); + + function biasMode( val ) { + + switch( val ) { + + case 'prem': + + mtl.color = new Nodes.TextureCubeNode( new Nodes.TextureNode( premTexture ), undefined, undefined, bias ); + + break; + + case 'lod': + + var textureCubeFunction = new Nodes.FunctionNode( 'vec4 textureCubeLodEXT( samplerCube texture, vec3 uv, float bias );', undefined, { shaderTextureLOD: true } ); + + mtl.color = new Nodes.FunctionCallNode( textureCubeFunction, [ new Nodes.CubeTextureNode( cubemap ), new Nodes.ReflectNode(), mipsBias ] ); + + break; + + case 'basic': + + var textureCubeFunction = new Nodes.FunctionNode( 'vec4 textureCube( samplerCube texture, vec3 uv, float bias );' ); + + mtl.color = new Nodes.FunctionCallNode( textureCubeFunction, [ new Nodes.CubeTextureNode( cubemap ), new Nodes.ReflectNode(), mipsBias ] ); + + break; + + } + + mtl.needsUpdate = true; + + } + + biasMode( 'prem' ); + + // GUI + + addGui( 'scope', { + PREM: 'prem', + LOD: 'lod', + BASIC: 'basic' + }, biasMode ); + + addGui( 'bias', bias.value, function ( val ) { + + bias.value = val; + + }, false, 0, 1 ); + + break; + case 'node-position': // MATERIAL @@ -2534,28 +2596,42 @@ case 'node-reflect': - // MATERIAL + // MATERIAL - var node = new Nodes.ReflectNode(); + var node = new Nodes.ReflectNode(); - mtl = new Nodes.PhongNodeMaterial(); - mtl.environment = new Nodes.CubeTextureNode( cubemap, node ); + var nodeMaterial = new Nodes.StandardNodeMaterial(); + nodeMaterial.environment = new Nodes.CubeTextureNode( cubemap, node ); + nodeMaterial.roughness.value = .5; + nodeMaterial.metalness.value = 1; - // GUI + var standardMaterial = new THREE.MeshStandardMaterial( { + color: nodeMaterial.color.value, + side: defaultSide, + envMap: cubemap, + roughness: nodeMaterial.roughness.value, + metalness: 1 + } ); - addGui( 'scope', { - vector: Nodes.ReflectNode.VECTOR, - cube: Nodes.ReflectNode.CUBE, - sphere: Nodes.ReflectNode.SPHERE - }, function ( val ) { + mtl = nodeMaterial; - node.scope = val; + // GUI - mtl.needsUpdate = true; + addGui( 'node', true, function ( val ) { - } ); + mtl = val ? nodeMaterial : standardMaterial; + mesh.material = mtl; - break; + } ); + + addGui( 'roughness', nodeMaterial.roughness.value, function ( val ) { + + nodeMaterial.roughness.value = val; + standardMaterial.roughness = val; + + }, false, 0, 1 ); + + break; case 'varying': diff --git a/examples/webgl_shadowmap_performance.html b/examples/webgl_shadowmap_performance.html index 86e7ee5756a88e..c836df0d220107 100644 --- a/examples/webgl_shadowmap_performance.html +++ b/examples/webgl_shadowmap_performance.html @@ -100,6 +100,8 @@ renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); container.appendChild( renderer.domElement ); + renderer.gammaOutput = true; + renderer.gammaFactor = 2.2; renderer.autoClear = false; // @@ -137,7 +139,7 @@ // GROUND var geometry = new THREE.PlaneBufferGeometry( 100, 100 ); - var planeMaterial = new THREE.MeshPhongMaterial( { color: 0xffdd99 } ); + var planeMaterial = new THREE.MeshPhongMaterial( { color: 0xffb851 } ); var ground = new THREE.Mesh( geometry, planeMaterial ); diff --git a/package-lock.json b/package-lock.json index 307923f04d37e4..047cef301ac738 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,22 +1,22 @@ { "name": "three", - "version": "0.105.1", + "version": "0.107.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", - "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz", + "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==", "dev": true, "requires": { "@babel/highlight": "^7.0.0" } }, "@babel/highlight": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", - "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz", + "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==", "dev": true, "requires": { "chalk": "^2.0.0", @@ -36,55 +36,81 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, + "@types/json-schema": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz", + "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", + "dev": true + }, "@types/node": { - "version": "12.0.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.10.tgz", - "integrity": "sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ==", + "version": "12.7.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.2.tgz", + "integrity": "sha512-dyYO+f6ihZEtNPDcWNR1fkoTDf3zAK3lAABDze3mz6POyIercH0lEUawUFXlG8xaQZmm1yEBON/4TsYv/laDYg==", "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.11.0.tgz", - "integrity": "sha512-mXv9ccCou89C8/4avKHuPB2WkSZyY/XcTQUXd5LFZAcLw1I3mWYVjUu6eS9Ja0QkP/ClolbcW9tb3Ov/pMdcqw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.0.0.tgz", + "integrity": "sha512-Mo45nxTTELODdl7CgpZKJISvLb+Fu64OOO2ZFc2x8sYSnUpFrBUW3H+H/ZGYmEkfnL6VkdtOSxgdt+Av79j0sA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "1.11.0", - "eslint-utils": "^1.3.1", + "@typescript-eslint/experimental-utils": "2.0.0", + "eslint-utils": "^1.4.0", "functional-red-black-tree": "^1.0.1", "regexpp": "^2.0.1", - "tsutils": "^3.7.0" + "tsutils": "^3.14.0" + }, + "dependencies": { + "eslint-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.0.tgz", + "integrity": "sha512-7ehnzPaP5IIEh1r1tkjuIrxqhNkzUJa9z3R92tLJdZIVdWaczEhr3EbhGtsMrVxi1KeR8qA7Off6SWc5WNQqyQ==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.0.0" + } + } } }, "@typescript-eslint/experimental-utils": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.11.0.tgz", - "integrity": "sha512-7LbfaqF6B8oa8cp/315zxKk8FFzosRzzhF8Kn/ZRsRsnpm7Qcu25cR/9RnAQo5utZ2KIWVgaALr+ZmcbG47ruw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.0.0.tgz", + "integrity": "sha512-XGJG6GNBXIEx/mN4eTRypN/EUmsd0VhVGQ1AG+WTgdvjHl0G8vHhVBHrd/5oI6RRYBRnedNymSYWW1HAdivtmg==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "1.11.0", + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.0.0", "eslint-scope": "^4.0.0" } }, "@typescript-eslint/parser": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.11.0.tgz", - "integrity": "sha512-5xBExyXaxVyczrZvbRKEXvaTUFFq7gIM9BynXukXZE0zF3IQP/FxF4mPmmh3gJ9egafZFqByCpPTFm3dk4SY7Q==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.0.0.tgz", + "integrity": "sha512-ibyMBMr0383ZKserIsp67+WnNVoM402HKkxqXGlxEZsXtnGGurbnY90pBO3e0nBUM7chEEOcxUhgw9aPq7fEBA==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "1.11.0", - "@typescript-eslint/typescript-estree": "1.11.0", + "@typescript-eslint/experimental-utils": "2.0.0", + "@typescript-eslint/typescript-estree": "2.0.0", "eslint-visitor-keys": "^1.0.0" } }, "@typescript-eslint/typescript-estree": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.11.0.tgz", - "integrity": "sha512-fquUHF5tAx1sM2OeRCC7wVxFd1iMELWMGCzOSmJ3pLzArj9+kRixdlC4d5MncuzXpjEqc6045p3KwM0o/3FuUA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.0.0.tgz", + "integrity": "sha512-NXbmzA3vWrSgavymlzMWNecgNOuiMMp62MO3kI7awZRLRcsA1QrYWo6q08m++uuAGVbXH/prZi2y1AWuhSu63w==", "dev": true, "requires": { "lodash.unescape": "4.0.1", - "semver": "5.5.0" + "semver": "^6.2.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } } }, "acorn": { @@ -100,9 +126,9 @@ "dev": true }, "ajv": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", - "integrity": "sha512-nffhOpkymDECQyR0mnsUtoCE8RlX38G0rYP+wgLWFyZuUyuuojSSvi/+euOiQBIn63whYwYVIIH1TvE3tu4OEg==", + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz", + "integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", @@ -112,10 +138,13 @@ } }, "ansi-escapes": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.2.1.tgz", + "integrity": "sha512-Cg3ymMAdN10wOk/VYfLV7KCQyv7EDirJ64500sU7n9UlmioEtDuU5Gd+hj73hXSU/ex7tHJSssmyftDdkMLO8Q==", + "dev": true, + "requires": { + "type-fest": "^0.5.2" + } }, "ansi-regex": { "version": "3.0.0", @@ -210,12 +239,12 @@ "dev": true }, "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", "dev": true, "requires": { - "restore-cursor": "^2.0.0" + "restore-cursor": "^3.1.0" } }, "cli-width": { @@ -463,9 +492,9 @@ } }, "emoji-regex": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", - "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "end-of-stream": { @@ -499,9 +528,9 @@ "dev": true }, "eslint": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.0.1.tgz", - "integrity": "sha512-DyQRaMmORQ+JsWShYsSg4OPTjY56u1nCjAmICrE8vLWqyLKxhFXOthwMj1SA8xwfrv0CofLNVnqbfyhwCkaO0w==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.1.0.tgz", + "integrity": "sha512-QhrbdRD7ofuV09IuE2ySWBz0FyXCq0rriLTZXZqaWSI79CVtHVRdkFuFTViiqzZhkCgfOh9USpriuGN2gIpZDQ==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -510,7 +539,7 @@ "cross-spawn": "^6.0.5", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", + "eslint-scope": "^5.0.0", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", "espree": "^6.0.0", @@ -518,35 +547,61 @@ "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob-parent": "^3.1.0", + "glob-parent": "^5.0.0", "globals": "^11.7.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", + "inquirer": "^6.4.1", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", - "lodash": "^4.17.11", + "lodash": "^4.17.14", "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", "progress": "^2.0.0", "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", "table": "^5.2.3", - "text-table": "^0.2.0" + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" }, "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "eslint-scope": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", + "integrity": "sha512-oYrhJW7S0bxAFDvWqzvMPRm6pcgcnWc4QnofCAqRTRfQC0JcwenzGglTtsLyIuuWFfkqDG9vz67cnttSd53djw==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } } } }, @@ -629,9 +684,9 @@ "dev": true }, "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, "eventemitter3": { @@ -656,9 +711,9 @@ } }, "external-editor": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", - "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", "dev": true, "requires": { "chardet": "^0.7.0", @@ -694,9 +749,9 @@ "dev": true }, "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.0.0.tgz", + "integrity": "sha512-HKri+WoWoUgr83pehn/SIgLOMZ9nAWC6dcGj26RY2R4F50u4+RTUz0RCrUlOV3nKRAICW1UGzyb+kcX2qK1S/g==", "dev": true, "requires": { "escape-string-regexp": "^1.0.5" @@ -799,24 +854,12 @@ } }, "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.0.0.tgz", + "integrity": "sha512-Z2RwiujPRGluePM6j699ktJYxmPpJKCfpGA13jz2hmFZC7gKetzrWvg5KN3+OsIFmydGyZ1AVwERCq1w/ZZwRg==", "dev": true, "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } + "is-glob": "^4.0.1" } }, "globals": { @@ -826,17 +869,17 @@ "dev": true }, "google-closure-compiler": { - "version": "20190618.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20190618.0.0.tgz", - "integrity": "sha512-f5zJQSWnlawuQlGo9TxcuprBGxIS5ksikj/pjDxdlRTXWt3dOKqEFA3CN8QshNYDl6oEjtO/ehiNx64fqEgkUA==", + "version": "20190729.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20190729.0.0.tgz", + "integrity": "sha512-z+egAPJmOkEgop6ZUjrE+bIOKqbKdx57J+SAGVgq9DAQnr3yVxQ+h9b8PSLcpgzMw/Y0rMCHpM3HkCTE2Y1ePQ==", "dev": true, "requires": { "chalk": "2.x", - "google-closure-compiler-java": "^20190618.0.0", - "google-closure-compiler-js": "^20190618.0.0", - "google-closure-compiler-linux": "^20190618.0.0", - "google-closure-compiler-osx": "^20190618.0.0", - "google-closure-compiler-windows": "^20190618.0.0", + "google-closure-compiler-java": "^20190729.0.0", + "google-closure-compiler-js": "^20190729.0.0", + "google-closure-compiler-linux": "^20190729.0.0", + "google-closure-compiler-osx": "^20190729.0.0", + "google-closure-compiler-windows": "^20190729.0.0", "minimist": "1.x", "vinyl": "2.x", "vinyl-sourcemaps-apply": "^0.2.0" @@ -851,35 +894,35 @@ } }, "google-closure-compiler-java": { - "version": "20190618.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20190618.0.0.tgz", - "integrity": "sha512-y6gAyJHMH5k2SM0qj/lyErEjmFGMvcT3glcx5Lsrl99CGwImJY0gDi+Cy9S0pczZvLG+wUW33AEfEW9MtdRZ6A==", + "version": "20190729.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-java/-/google-closure-compiler-java-20190729.0.0.tgz", + "integrity": "sha512-SGStZiyasN31tlmKUMMzCNRXTZqeij5N7iEeHSIGOsUdlKw5Zj8VPbaqbCcHvfgpQaUbn29zCTgTYiYFJRkbwA==", "dev": true }, "google-closure-compiler-js": { - "version": "20190618.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-js/-/google-closure-compiler-js-20190618.0.0.tgz", - "integrity": "sha512-Xc/84uN00GLUzRwWx25Lg11VuSTz/1odWy0d+pM3F/26fXqi16ZhhkVoe6VVFklSSMVDyGTPAH0ZkyfZhinKhA==", + "version": "20190729.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-js/-/google-closure-compiler-js-20190729.0.0.tgz", + "integrity": "sha512-ZDJRK3eiNfKLsO1+uVxHnvB8RTQMLHlJNKouMBcPzPNOAurEFRboHf5nx/0llO+MXVWZDIPhxpbuuD3WnQsprA==", "dev": true }, "google-closure-compiler-linux": { - "version": "20190618.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20190618.0.0.tgz", - "integrity": "sha512-idWJ/sFmOSYfCmDbCVMcaBX2NCUCxukjt2UzT5PJmpoVLmJuwwoVbpQZVfvgRvEH4bLzvvcvJRfn5nIiODjjaQ==", + "version": "20190729.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-linux/-/google-closure-compiler-linux-20190729.0.0.tgz", + "integrity": "sha512-W4TRrQ1+FrCFu3yn4M0JTWTJCFsqLlBjkliB/xLFuWb5E7XQ8Xe/sPtkmeNzCo+ftd6B/KD7acaH2oMU0brMag==", "dev": true, "optional": true }, "google-closure-compiler-osx": { - "version": "20190618.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20190618.0.0.tgz", - "integrity": "sha512-OzXMW+hKq76NJt9MIRQhV7pHTzHISCXtg+LZUPcqNT+V/tcvOlrSaflokmvyJPzEVk889QArYp8JgZ7mqHuY5g==", + "version": "20190729.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-osx/-/google-closure-compiler-osx-20190729.0.0.tgz", + "integrity": "sha512-g3mLUVFD85nRwVyl8X6ywZ14YFP6fo+kXdIvrBGxxUkUU8VbeIgr6GlgtAUS0eZ0WVs2hr5w6kjk7+5kyeBSJg==", "dev": true, "optional": true }, "google-closure-compiler-windows": { - "version": "20190618.0.0", - "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20190618.0.0.tgz", - "integrity": "sha512-2qzY/fQneEg+zFvRGoNeJkAY6VU5OcmBT37l+xTBGQvy/AauCLWltSGcOYNEi7Qd3OEBVIcAJ+CzNOV9s3jfwA==", + "version": "20190729.0.0", + "resolved": "https://registry.npmjs.org/google-closure-compiler-windows/-/google-closure-compiler-windows-20190729.0.0.tgz", + "integrity": "sha512-tzFfu2ixOoAWJUcCsagNFE4o0xHV+LI4cD3AmI36ll2e0NW1aUjDPhiG5TSfAnMIvZwgkikG5tqnPnk8ljauAA==", "dev": true, "optional": true }, @@ -958,9 +1001,9 @@ "dev": true }, "import-fresh": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", - "integrity": "sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", + "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -990,22 +1033,22 @@ "dev": true }, "inquirer": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.4.1.tgz", - "integrity": "sha512-/Jw+qPZx4EDYsaT6uz7F4GJRNFMRdKNeUZw3ZnKV8lyuUgz/YWRCSUAJMZSVhSq4Ec0R2oYnyi6b3d4JXcL5Nw==", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.1.tgz", + "integrity": "sha512-uxNHBeQhRXIoHWTSNYUFhQVrHYFThIt6IVo2fFmSe8aBwdR3/w6b58hJpiL/fMukFkvGzjg+hSxFtwvVmKZmXw==", "dev": true, "requires": { - "ansi-escapes": "^3.2.0", + "ansi-escapes": "^4.2.1", "chalk": "^2.4.2", - "cli-cursor": "^2.1.0", + "cli-cursor": "^3.1.0", "cli-width": "^2.0.0", "external-editor": "^3.0.3", - "figures": "^2.0.0", - "lodash": "^4.17.11", - "mute-stream": "0.0.7", + "figures": "^3.0.0", + "lodash": "^4.17.15", + "mute-stream": "0.0.8", "run-async": "^2.2.0", "rxjs": "^6.4.0", - "string-width": "^2.1.0", + "string-width": "^4.1.0", "strip-ansi": "^5.1.0", "through": "^2.3.6" }, @@ -1016,6 +1059,29 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + }, + "string-width": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.1.0.tgz", + "integrity": "sha512-NrX+1dVVh+6Y9dnQ19pR0pP4FiEIlUvdTGn8pw6CKTNq5sgib2nIhmUNT5TAmhWmvKr3WcxBcP3E8nWezuipuQ==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^5.2.0" + } + }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -1214,7 +1280,7 @@ }, "mkdirp": { "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { @@ -1228,9 +1294,9 @@ "dev": true }, "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", "dev": true }, "natural-compare": { @@ -1288,20 +1354,12 @@ } }, "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" - }, - "dependencies": { - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - } + "mimic-fn": "^2.1.0" } }, "opener": { @@ -1355,7 +1413,7 @@ }, "os-tmpdir": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, @@ -1420,12 +1478,6 @@ "json-parse-better-errors": "^1.0.1" } }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", @@ -1434,7 +1486,7 @@ }, "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, @@ -1622,12 +1674,12 @@ "dev": true }, "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", "dev": true, "requires": { - "onetime": "^2.0.0", + "onetime": "^5.1.0", "signal-exit": "^3.0.2" } }, @@ -1641,14 +1693,22 @@ } }, "rollup": { - "version": "1.16.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.16.2.tgz", - "integrity": "sha512-UAZxaQvH0klYZdF+90xv9nGb+m4p8jdoaow1VL5/RzDK/gN/4CjvaMmJNcOIv1/+gtzswKhAg/467mzF0sLpAg==", + "version": "1.19.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.19.4.tgz", + "integrity": "sha512-G24w409GNj7i/Yam2cQla6qV2k6Nug8bD2DZg9v63QX/cH/dEdbNJg8H4lUm5M1bRpPKRUC465Rm9H51JTKOfQ==", "dev": true, "requires": { "@types/estree": "0.0.39", - "@types/node": "^12.0.8", - "acorn": "^6.1.1" + "@types/node": "^12.6.9", + "acorn": "^6.2.1" + }, + "dependencies": { + "acorn": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz", + "integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA==", + "dev": true + } } }, "run-async": { @@ -1756,7 +1816,7 @@ "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", "dev": true, "requires": { "spdx-exceptions": "^2.1.0", @@ -1810,9 +1870,9 @@ "dev": true }, "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", + "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", "dev": true }, "supports-color": { @@ -1833,13 +1893,13 @@ } }, "table": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", - "integrity": "sha512-E6CK1/pZe2N75rGZQotFOdmzWQ1AILtgYbMAbAjvms0S1l5IDB47zG3nCnFGB/w+7nB3vKofbLXCH7HPBo864w==", + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "dev": true, "requires": { - "ajv": "^6.9.1", - "lodash": "^4.17.11", + "ajv": "^6.10.2", + "lodash": "^4.17.14", "slice-ansi": "^2.1.0", "string-width": "^3.0.0" }, @@ -1850,6 +1910,12 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, "string-width": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", @@ -1880,7 +1946,7 @@ }, "through": { "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, @@ -1906,9 +1972,9 @@ "dev": true }, "tsutils": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz", - "integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==", + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", + "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -1923,6 +1989,12 @@ "prelude-ls": "~1.1.2" } }, + "type-fest": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.5.2.tgz", + "integrity": "sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==", + "dev": true + }, "typescript": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", @@ -1959,6 +2031,12 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "v8-compile-cache": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", + "integrity": "sha512-usZBT3PW+LOjM25wbqIlZwPeJV+3OSz3M1k1Ws8snlW39dZyYL9lOGC5FgPVHfk0jKmjiDV8Z0mIbVQPiwFs7g==", + "dev": true + }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -2015,7 +2093,7 @@ }, "wrap-ansi": { "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "dev": true, "requires": { diff --git a/package.json b/package.json index 8fb73d93ebb15a..77f1cf39e0f3ef 100644 --- a/package.json +++ b/package.json @@ -67,17 +67,17 @@ }, "homepage": "https://threejs.org/", "devDependencies": { - "@typescript-eslint/eslint-plugin": "^1.11.0", - "@typescript-eslint/parser": "^1.11.0", + "@typescript-eslint/eslint-plugin": "^2.0.0", + "@typescript-eslint/parser": "^2.0.0", "concurrently": "^4.1.1", - "eslint": "^6.0.1", + "eslint": "^6.1.0", "eslint-config-mdcs": "^4.2.3", "eslint-plugin-html": "^6.0.0", "failonlyreporter": "^1.0.0", - "google-closure-compiler": "20190618.0.0", + "google-closure-compiler": "20190729.0.0", "http-server": "^0.11.1", "qunit": "^2.9.2", - "rollup": "^1.16.2", + "rollup": "^1.19.4", "typescript": "^3.5.2" }, "jspm": { diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index a8e20bb92f7e57..b461b7c14aff2a 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -594,17 +594,10 @@ Object.assign( Matrix4.prototype, { }, getPosition: function () { - var v1; + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return new Vector3().setFromMatrixColumn( this, 3 ); - return function getPosition() { - - if ( v1 === undefined ) v1 = new Vector3(); - console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); - return v1.setFromMatrixColumn( this, 3 ); - - }; - - }(), + }, setRotationFromQuaternion: function ( q ) { console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); diff --git a/src/animation/PropertyBinding.js b/src/animation/PropertyBinding.js index f0c6b7892a78ac..252d30f259b1b9 100644 --- a/src/animation/PropertyBinding.js +++ b/src/animation/PropertyBinding.js @@ -9,7 +9,40 @@ */ // Characters [].:/ are reserved for track binding syntax. -var RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +var _RESERVED_CHARS_RE = '\\[\\]\\.:\\/'; +var _reservedRe = new RegExp( '[' + _RESERVED_CHARS_RE + ']', 'g' ); + +// Attempts to allow node names from any language. ES5's `\w` regexp matches +// only latin characters, and the unicode \p{L} is not yet supported. So +// instead, we exclude reserved characters and match everything else. +var _wordChar = '[^' + _RESERVED_CHARS_RE + ']'; +var _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; + +// Parent directories, delimited by '/' or ':'. Currently unused, but must +// be matched to parse the rest of the track name. +var _directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', _wordChar ); + +// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. +var _nodeRe = /(WCOD+)?/.source.replace( 'WCOD', _wordCharOrDot ); + +// Object on target node, and accessor. May not contain reserved +// characters. Accessor may contain any character except closing bracket. +var _objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', _wordChar ); + +// Property and accessor. May not contain reserved characters. Accessor may +// contain any non-bracket characters. +var _propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', _wordChar ); + +var _trackRe = new RegExp( '' + + '^' + + _directoryRe + + _nodeRe + + _objectRe + + _propertyRe + + '$' +); + +var _supportedObjectNames = [ 'material', 'materials', 'bones' ]; function Composite( targetGroup, path, optionalParsedPath ) { @@ -109,101 +142,59 @@ Object.assign( PropertyBinding, { * @param {string} name Node name to be sanitized. * @return {string} */ - sanitizeNodeName: ( function () { - - var reservedRe = new RegExp( '[' + RESERVED_CHARS_RE + ']', 'g' ); - - return function sanitizeNodeName( name ) { - - return name.replace( /\s/g, '_' ).replace( reservedRe, '' ); - - }; - - }() ), - - parseTrackName: function () { - - // Attempts to allow node names from any language. ES5's `\w` regexp matches - // only latin characters, and the unicode \p{L} is not yet supported. So - // instead, we exclude reserved characters and match everything else. - var wordChar = '[^' + RESERVED_CHARS_RE + ']'; - var wordCharOrDot = '[^' + RESERVED_CHARS_RE.replace( '\\.', '' ) + ']'; - - // Parent directories, delimited by '/' or ':'. Currently unused, but must - // be matched to parse the rest of the track name. - var directoryRe = /((?:WC+[\/:])*)/.source.replace( 'WC', wordChar ); + sanitizeNodeName: function ( name ) { - // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'. - var nodeRe = /(WCOD+)?/.source.replace( 'WCOD', wordCharOrDot ); + return name.replace( /\s/g, '_' ).replace( _reservedRe, '' ); - // Object on target node, and accessor. May not contain reserved - // characters. Accessor may contain any character except closing bracket. - var objectRe = /(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace( 'WC', wordChar ); - - // Property and accessor. May not contain reserved characters. Accessor may - // contain any non-bracket characters. - var propertyRe = /\.(WC+)(?:\[(.+)\])?/.source.replace( 'WC', wordChar ); - - var trackRe = new RegExp( '' - + '^' - + directoryRe - + nodeRe - + objectRe - + propertyRe - + '$' - ); - - var supportedObjectNames = [ 'material', 'materials', 'bones' ]; - - return function parseTrackName( trackName ) { + }, - var matches = trackRe.exec( trackName ); + parseTrackName: function ( trackName ) { - if ( ! matches ) { + var matches = _trackRe.exec( trackName ); - throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); + if ( ! matches ) { - } + throw new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName ); - var results = { - // directoryName: matches[ 1 ], // (tschw) currently unused - nodeName: matches[ 2 ], - objectName: matches[ 3 ], - objectIndex: matches[ 4 ], - propertyName: matches[ 5 ], // required - propertyIndex: matches[ 6 ] - }; + } - var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); + var results = { + // directoryName: matches[ 1 ], // (tschw) currently unused + nodeName: matches[ 2 ], + objectName: matches[ 3 ], + objectIndex: matches[ 4 ], + propertyName: matches[ 5 ], // required + propertyIndex: matches[ 6 ] + }; - if ( lastDot !== undefined && lastDot !== - 1 ) { + var lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' ); - var objectName = results.nodeName.substring( lastDot + 1 ); + if ( lastDot !== undefined && lastDot !== - 1 ) { - // Object names must be checked against a whitelist. Otherwise, there - // is no way to parse 'foo.bar.baz': 'baz' must be a property, but - // 'bar' could be the objectName, or part of a nodeName (which can - // include '.' characters). - if ( supportedObjectNames.indexOf( objectName ) !== - 1 ) { + var objectName = results.nodeName.substring( lastDot + 1 ); - results.nodeName = results.nodeName.substring( 0, lastDot ); - results.objectName = objectName; + // Object names must be checked against a whitelist. Otherwise, there + // is no way to parse 'foo.bar.baz': 'baz' must be a property, but + // 'bar' could be the objectName, or part of a nodeName (which can + // include '.' characters). + if ( _supportedObjectNames.indexOf( objectName ) !== - 1 ) { - } + results.nodeName = results.nodeName.substring( 0, lastDot ); + results.objectName = objectName; } - if ( results.propertyName === null || results.propertyName.length === 0 ) { + } - throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); + if ( results.propertyName === null || results.propertyName.length === 0 ) { - } + throw new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName ); - return results; + } - }; + return results; - }(), + }, findNode: function ( root, nodeName ) { diff --git a/src/audio/Audio.d.ts b/src/audio/Audio.d.ts index 1edf7c8d95c08b..d27e56b73ef12b 100644 --- a/src/audio/Audio.d.ts +++ b/src/audio/Audio.d.ts @@ -17,6 +17,7 @@ export class Audio extends Object3D { loop: boolean; startTime: number; offset: number; + duration: number | undefined; playbackRate: number; isPlaying: boolean; hasPlaybackControl: boolean; diff --git a/src/audio/Audio.js b/src/audio/Audio.js index 35b72753543eb4..6d3dd62dcc7422 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -24,6 +24,7 @@ function Audio( listener ) { this.loop = false; this.startTime = 0; this.offset = 0; + this.duration = undefined; this.playbackRate = 1; this.isPlaying = false; this.hasPlaybackControl = true; @@ -98,7 +99,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { source.loop = this.loop; source.onended = this.onEnded.bind( this ); this.startTime = this.context.currentTime; - source.start( this.startTime, this.offset ); + source.start( this.startTime, this.offset, this.duration ); this.isPlaying = true; diff --git a/src/audio/AudioListener.js b/src/audio/AudioListener.js index 839b21fa30c9aa..d217c65632d066 100644 --- a/src/audio/AudioListener.js +++ b/src/audio/AudioListener.js @@ -8,8 +8,10 @@ import { Clock } from '../core/Clock.js'; import { Object3D } from '../core/Object3D.js'; import { AudioContext } from './AudioContext.js'; -var _position, _quaternion, _scale; -var _orientation; +var _position = new Vector3(); +var _quaternion = new Quaternion(); +var _scale = new Vector3(); +var _orientation = new Vector3(); function AudioListener() { @@ -102,15 +104,6 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), { Object3D.prototype.updateMatrixWorld.call( this, force ); - if ( _position === undefined ) { - - _position = new Vector3(); - _quaternion = new Quaternion(); - _scale = new Vector3(); - _orientation = new Vector3(); - - } - var listener = this.context.listener; var up = this.up; diff --git a/src/audio/PositionalAudio.js b/src/audio/PositionalAudio.js index e9377a779c4484..04400efa7e0bdb 100644 --- a/src/audio/PositionalAudio.js +++ b/src/audio/PositionalAudio.js @@ -7,8 +7,10 @@ import { Quaternion } from '../math/Quaternion.js'; import { Audio } from './Audio.js'; import { Object3D } from '../core/Object3D.js'; -var _position, _quaternion, _scale; -var _orientation; +var _position = new Vector3(); +var _quaternion = new Quaternion(); +var _scale = new Vector3(); +var _orientation = new Vector3(); function PositionalAudio( listener ) { @@ -100,15 +102,6 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), { Object3D.prototype.updateMatrixWorld.call( this, force ); - if ( _position === undefined ) { - - _position = new Vector3(); - _quaternion = new Quaternion(); - _scale = new Vector3(); - _orientation = new Vector3(); - - } - if ( this.hasPlaybackControl === true && this.isPlaying === false ) return; this.matrixWorld.decompose( _position, _quaternion, _scale ); diff --git a/src/cameras/StereoCamera.js b/src/cameras/StereoCamera.js index 6f3b82473595d1..b5c80dea1a2d9a 100644 --- a/src/cameras/StereoCamera.js +++ b/src/cameras/StereoCamera.js @@ -2,7 +2,8 @@ import { Matrix4 } from '../math/Matrix4.js'; import { _Math } from '../math/Math.js'; import { PerspectiveCamera } from './PerspectiveCamera.js'; -var _eyeRight, _eyeLeft; +var _eyeRight = new Matrix4(); +var _eyeLeft = new Matrix4(); /** * @author mrdoob / http://mrdoob.com/ @@ -40,13 +41,6 @@ Object.assign( StereoCamera.prototype, { update: function ( camera ) { - if ( _eyeRight === undefined ) { - - _eyeRight = new Matrix4(); - _eyeLeft = new Matrix4(); - - } - var cache = this._cache; var needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 1db3cfbc3111bc..32f354eaa8de02 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -15,11 +15,18 @@ import { arrayMax } from '../utils.js'; * @author mrdoob / http://mrdoob.com/ */ -var bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id +var _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id + +var _m1 = new Matrix4(); +var _obj = new Object3D(); +var _offset = new Vector3(); +var _box = new Box3(); +var _boxMorphTargets = new Box3(); +var _vector = new Vector3(); function BufferGeometry() { - Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } ); + Object.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } ); this.uuid = _Math.generateUUID(); @@ -182,129 +189,89 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy }, - rotateX: function () { + rotateX: function ( angle ) { // rotate geometry around world x-axis - var m1 = new Matrix4(); - - return function rotateX( angle ) { - - m1.makeRotationX( angle ); + _m1.makeRotationX( angle ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1 ); - return this; - - }; + return this; - }(), + }, - rotateY: function () { + rotateY: function ( angle ) { // rotate geometry around world y-axis - var m1 = new Matrix4(); - - return function rotateY( angle ) { - - m1.makeRotationY( angle ); - - this.applyMatrix( m1 ); + _m1.makeRotationY( angle ); - return this; + this.applyMatrix( _m1 ); - }; + return this; - }(), + }, - rotateZ: function () { + rotateZ: function ( angle ) { // rotate geometry around world z-axis - var m1 = new Matrix4(); - - return function rotateZ( angle ) { - - m1.makeRotationZ( angle ); + _m1.makeRotationZ( angle ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1 ); - return this; - - }; + return this; - }(), + }, - translate: function () { + translate: function ( x, y, z ) { // translate geometry - var m1 = new Matrix4(); + _m1.makeTranslation( x, y, z ); - return function translate( x, y, z ) { + this.applyMatrix( _m1 ); - m1.makeTranslation( x, y, z ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - scale: function () { + scale: function ( x, y, z ) { // scale geometry - var m1 = new Matrix4(); - - return function scale( x, y, z ) { - - m1.makeScale( x, y, z ); - - this.applyMatrix( m1 ); - - return this; - - }; + _m1.makeScale( x, y, z ); - }(), + this.applyMatrix( _m1 ); - lookAt: function () { + return this; - var obj = new Object3D(); + }, - return function lookAt( vector ) { + lookAt: function ( vector ) { - obj.lookAt( vector ); + _obj.lookAt( vector ); - obj.updateMatrix(); + _obj.updateMatrix(); - this.applyMatrix( obj.matrix ); + this.applyMatrix( _obj.matrix ); - }; + return this; - }(), + }, center: function () { - var offset = new Vector3(); - - return function center() { - - this.computeBoundingBox(); - - this.boundingBox.getCenter( offset ).negate(); + this.computeBoundingBox(); - this.translate( offset.x, offset.y, offset.z ); + this.boundingBox.getCenter( _offset ).negate(); - return this; + this.translate( _offset.x, _offset.y, _offset.z ); - }; + return this; - }(), + }, setFromObject: function ( object ) { @@ -601,144 +568,130 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy computeBoundingBox: function () { - var box = new Box3(); - - return function computeBoundingBox() { + if ( this.boundingBox === null ) { - if ( this.boundingBox === null ) { + this.boundingBox = new Box3(); - this.boundingBox = new Box3(); - - } - - var position = this.attributes.position; - var morphAttributesPosition = this.morphAttributes.position; + } - if ( position !== undefined ) { + var position = this.attributes.position; + var morphAttributesPosition = this.morphAttributes.position; - this.boundingBox.setFromBufferAttribute( position ); + if ( position !== undefined ) { - // process morph attributes if present + this.boundingBox.setFromBufferAttribute( position ); - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; - box.setFromBufferAttribute( morphAttribute ); + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - this.boundingBox.expandByPoint( box.min ); - this.boundingBox.expandByPoint( box.max ); + 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 ); + } else { - } + this.boundingBox.makeEmpty(); - }; + } - }(), + if ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) { - computeBoundingSphere: function () { + console.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this ); - var box = new Box3(); - var boxMorphTargets = new Box3(); - var vector = new Vector3(); + } - return function computeBoundingSphere() { + }, - if ( this.boundingSphere === null ) { + computeBoundingSphere: function () { - this.boundingSphere = new Sphere(); + if ( this.boundingSphere === null ) { - } + this.boundingSphere = new Sphere(); - var position = this.attributes.position; - var morphAttributesPosition = this.morphAttributes.position; + } - if ( position ) { + var position = this.attributes.position; + var morphAttributesPosition = this.morphAttributes.position; - // first, find the center of the bounding sphere + if ( position ) { - var center = this.boundingSphere.center; + // first, find the center of the bounding sphere - box.setFromBufferAttribute( position ); + var center = this.boundingSphere.center; - // process morph attributes if present + _box.setFromBufferAttribute( position ); - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; - boxMorphTargets.setFromBufferAttribute( morphAttribute ); + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - box.expandByPoint( boxMorphTargets.min ); - box.expandByPoint( boxMorphTargets.max ); + var morphAttribute = morphAttributesPosition[ i ]; + _boxMorphTargets.setFromBufferAttribute( morphAttribute ); - } + _box.expandByPoint( _boxMorphTargets.min ); + _box.expandByPoint( _boxMorphTargets.max ); } - box.getCenter( center ); + } - // second, try to find a boundingSphere with a radius smaller than the - // boundingSphere of the boundingBox: sqrt(3) smaller in the best case + _box.getCenter( center ); - var maxRadiusSq = 0; + // second, try to find a boundingSphere with a radius smaller than the + // boundingSphere of the boundingBox: sqrt(3) smaller in the best case - for ( var i = 0, il = position.count; i < il; i ++ ) { + var maxRadiusSq = 0; - vector.fromBufferAttribute( position, i ); + for ( var i = 0, il = position.count; i < il; i ++ ) { - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + _vector.fromBufferAttribute( position, i ); - } + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) ); - // process morph attributes if present + } - if ( morphAttributesPosition ) { + // process morph attributes if present - for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { + if ( morphAttributesPosition ) { - var morphAttribute = morphAttributesPosition[ i ]; + for ( var i = 0, il = morphAttributesPosition.length; i < il; i ++ ) { - for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { + var morphAttribute = morphAttributesPosition[ i ]; - vector.fromBufferAttribute( morphAttribute, j ); + for ( var j = 0, jl = morphAttribute.count; j < jl; j ++ ) { - maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) ); + _vector.fromBufferAttribute( morphAttribute, j ); - } + maxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) ); } } - this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); + } - if ( isNaN( this.boundingSphere.radius ) ) { + this.boundingSphere.radius = Math.sqrt( maxRadiusSq ); - console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); + if ( isNaN( this.boundingSphere.radius ) ) { - } + console.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this ); } - }; + } - }(), + }, computeFaceNormals: function () { @@ -900,27 +853,21 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy normalizeNormals: function () { - var vector = new Vector3(); - - return function normalizeNormals() { - - var normals = this.attributes.normal; + var normals = this.attributes.normal; - for ( var i = 0, il = normals.count; i < il; i ++ ) { + for ( var i = 0, il = normals.count; i < il; i ++ ) { - vector.x = normals.getX( i ); - vector.y = normals.getY( i ); - vector.z = normals.getZ( i ); + _vector.x = normals.getX( i ); + _vector.y = normals.getY( i ); + _vector.z = normals.getZ( i ); - vector.normalize(); + _vector.normalize(); - normals.setXYZ( i, vector.x, vector.y, vector.z ); + normals.setXYZ( i, _vector.x, _vector.y, _vector.z ); - } - - }; + } - }(), + }, toNonIndexed: function () { diff --git a/src/core/Geometry.js b/src/core/Geometry.js index cda0b2e91cf7df..222d4547f0b041 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -19,11 +19,14 @@ import { _Math } from '../math/Math.js'; * @author bhouston / http://clara.io */ -var geometryId = 0; // Geometry uses even numbers as Id +var _geometryId = 0; // Geometry uses even numbers as Id +var _m1 = new Matrix4(); +var _obj = new Object3D(); +var _offset = new Vector3(); function Geometry() { - Object.defineProperty( this, 'id', { value: geometryId += 2 } ); + Object.defineProperty( this, 'id', { value: _geometryId += 2 } ); this.uuid = _Math.generateUUID(); @@ -107,111 +110,77 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), }, - rotateX: function () { + rotateX: function ( angle ) { // rotate geometry around world x-axis - var m1 = new Matrix4(); + _m1.makeRotationX( angle ); - return function rotateX( angle ) { + this.applyMatrix( _m1 ); - m1.makeRotationX( angle ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateY: function () { + rotateY: function ( angle ) { // rotate geometry around world y-axis - var m1 = new Matrix4(); + _m1.makeRotationY( angle ); - return function rotateY( angle ) { + this.applyMatrix( _m1 ); - m1.makeRotationY( angle ); - - this.applyMatrix( m1 ); - - return this; - - }; + return this; - }(), + }, - rotateZ: function () { + rotateZ: function ( angle ) { // rotate geometry around world z-axis - var m1 = new Matrix4(); - - return function rotateZ( angle ) { - - m1.makeRotationZ( angle ); + _m1.makeRotationZ( angle ); - this.applyMatrix( m1 ); + this.applyMatrix( _m1 ); - return this; - - }; + return this; - }(), + }, - translate: function () { + translate: function ( x, y, z ) { // translate geometry - var m1 = new Matrix4(); - - return function translate( x, y, z ) { - - m1.makeTranslation( x, y, z ); - - this.applyMatrix( m1 ); + _m1.makeTranslation( x, y, z ); - return this; + this.applyMatrix( _m1 ); - }; + return this; - }(), + }, - scale: function () { + scale: function ( x, y, z ) { // scale geometry - var m1 = new Matrix4(); - - return function scale( x, y, z ) { - - m1.makeScale( x, y, z ); - - this.applyMatrix( m1 ); + _m1.makeScale( x, y, z ); - return this; + this.applyMatrix( _m1 ); - }; - - }(), - - lookAt: function () { + return this; - var obj = new Object3D(); + }, - return function lookAt( vector ) { + lookAt: function ( vector ) { - obj.lookAt( vector ); + _obj.lookAt( vector ); - obj.updateMatrix(); + _obj.updateMatrix(); - this.applyMatrix( obj.matrix ); + this.applyMatrix( _obj.matrix ); - }; + return this; - }(), + }, fromBufferGeometry: function ( geometry ) { @@ -348,21 +317,15 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), center: function () { - var offset = new Vector3(); - - return function center() { - - this.computeBoundingBox(); - - this.boundingBox.getCenter( offset ).negate(); + this.computeBoundingBox(); - this.translate( offset.x, offset.y, offset.z ); + this.boundingBox.getCenter( _offset ).negate(); - return this; + this.translate( _offset.x, _offset.y, _offset.z ); - }; + return this; - }(), + }, normalize: function () { diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 1f7c541c28869b..74502b77228e25 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -8,6 +8,24 @@ import { Matrix3 } from '../math/Matrix3.js'; import { _Math } from '../math/Math.js'; import { TrianglesDrawMode } from '../constants.js'; +var _object3DId = 0; + +var _v1 = new Vector3(); +var _q1 = new Quaternion(); +var _m1 = new Matrix4(); +var _target = new Vector3(); + +var _position = new Vector3(); +var _scale = new Vector3(); +var _quaternion = new Quaternion(); + +var _xAxis = new Vector3( 1, 0, 0 ); +var _yAxis = new Vector3( 0, 1, 0 ); +var _zAxis = new Vector3( 0, 0, 1 ); + +var _addedEvent = { type: 'added' }; +var _removedEvent = { type: 'removed' }; + /** * @author mrdoob / http://mrdoob.com/ * @author mikael emtinger / http://gomo.se/ @@ -16,11 +34,9 @@ import { TrianglesDrawMode } from '../constants.js'; * @author elephantatwork / www.elephantatwork.ch */ -var object3DId = 0; - function Object3D() { - Object.defineProperty( this, 'id', { value: object3DId ++ } ); + Object.defineProperty( this, 'id', { value: _object3DId ++ } ); this.uuid = _Math.generateUUID(); @@ -160,135 +176,81 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), }, - rotateOnAxis: function () { + rotateOnAxis: function ( axis, angle ) { // rotate object on axis in object space // axis is assumed to be normalized - var q1 = new Quaternion(); + _q1.setFromAxisAngle( axis, angle ); - return function rotateOnAxis( axis, angle ) { + this.quaternion.multiply( _q1 ); - q1.setFromAxisAngle( axis, angle ); - - this.quaternion.multiply( q1 ); - - return this; - - }; + return this; - }(), + }, - rotateOnWorldAxis: function () { + rotateOnWorldAxis: function ( axis, angle ) { // rotate object on axis in world space // axis is assumed to be normalized // method assumes no rotated parent - var q1 = new Quaternion(); - - return function rotateOnWorldAxis( axis, angle ) { - - q1.setFromAxisAngle( axis, angle ); - - this.quaternion.premultiply( q1 ); - - return this; - - }; - - }(), - - rotateX: function () { - - var v1 = new Vector3( 1, 0, 0 ); - - return function rotateX( angle ) { - - return this.rotateOnAxis( v1, angle ); - - }; + _q1.setFromAxisAngle( axis, angle ); - }(), + this.quaternion.premultiply( _q1 ); - rotateY: function () { - - var v1 = new Vector3( 0, 1, 0 ); + return this; - return function rotateY( angle ) { + }, - return this.rotateOnAxis( v1, angle ); + rotateX: function ( angle ) { - }; + return this.rotateOnAxis( _xAxis, angle ); - }(), + }, - rotateZ: function () { + rotateY: function ( angle ) { - var v1 = new Vector3( 0, 0, 1 ); + return this.rotateOnAxis( _yAxis, angle ); - return function rotateZ( angle ) { + }, - return this.rotateOnAxis( v1, angle ); + rotateZ: function ( angle ) { - }; + return this.rotateOnAxis( _zAxis, angle ); - }(), + }, - translateOnAxis: function () { + translateOnAxis: function ( axis, distance ) { // translate object by distance along axis in object space // axis is assumed to be normalized - var v1 = new Vector3(); - - return function translateOnAxis( axis, distance ) { - - v1.copy( axis ).applyQuaternion( this.quaternion ); - - this.position.add( v1.multiplyScalar( distance ) ); - - return this; - - }; + _v1.copy( axis ).applyQuaternion( this.quaternion ); - }(), + this.position.add( _v1.multiplyScalar( distance ) ); - translateX: function () { - - var v1 = new Vector3( 1, 0, 0 ); - - return function translateX( distance ) { - - return this.translateOnAxis( v1, distance ); - - }; - - }(), - - translateY: function () { - - var v1 = new Vector3( 0, 1, 0 ); + return this; - return function translateY( distance ) { + }, - return this.translateOnAxis( v1, distance ); + translateX: function ( distance ) { - }; + return this.translateOnAxis( _xAxis, distance ); - }(), + }, - translateZ: function () { + translateY: function ( distance ) { - var v1 = new Vector3( 0, 0, 1 ); + return this.translateOnAxis( _yAxis, distance ); - return function translateZ( distance ) { + }, - return this.translateOnAxis( v1, distance ); + translateZ: function ( distance ) { - }; + return this.translateOnAxis( _zAxis, distance ); - }(), + }, localToWorld: function ( vector ) { @@ -296,68 +258,53 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), }, - worldToLocal: function () { - - var m1 = new Matrix4(); - - return function worldToLocal( vector ) { + worldToLocal: function ( vector ) { - return vector.applyMatrix4( m1.getInverse( this.matrixWorld ) ); + return vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) ); - }; - - }(), + }, - lookAt: function () { + lookAt: function ( x, y, z ) { // This method does not support objects having non-uniformly-scaled parent(s) - var q1 = new Quaternion(); - var m1 = new Matrix4(); - var target = new Vector3(); - var position = new Vector3(); - - return function lookAt( x, y, z ) { + if ( x.isVector3 ) { - if ( x.isVector3 ) { + _target.copy( x ); - target.copy( x ); - - } else { - - target.set( x, y, z ); + } else { - } + _target.set( x, y, z ); - var parent = this.parent; + } - this.updateWorldMatrix( true, false ); + var parent = this.parent; - position.setFromMatrixPosition( this.matrixWorld ); + this.updateWorldMatrix( true, false ); - if ( this.isCamera || this.isLight ) { + _position.setFromMatrixPosition( this.matrixWorld ); - m1.lookAt( position, target, this.up ); + if ( this.isCamera || this.isLight ) { - } else { + _m1.lookAt( _position, _target, this.up ); - m1.lookAt( target, position, this.up ); + } else { - } + _m1.lookAt( _target, _position, this.up ); - this.quaternion.setFromRotationMatrix( m1 ); + } - if ( parent ) { + this.quaternion.setFromRotationMatrix( _m1 ); - m1.extractRotation( parent.matrixWorld ); - q1.setFromRotationMatrix( m1 ); - this.quaternion.premultiply( q1.inverse() ); + if ( parent ) { - } + _m1.extractRotation( parent.matrixWorld ); + _q1.setFromRotationMatrix( _m1 ); + this.quaternion.premultiply( _q1.inverse() ); - }; + } - }(), + }, add: function ( object ) { @@ -391,7 +338,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), object.parent = this; this.children.push( object ); - object.dispatchEvent( { type: 'added' } ); + object.dispatchEvent( _addedEvent ); } else { @@ -424,7 +371,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), object.parent = null; this.children.splice( index, 1 ); - object.dispatchEvent( { type: 'removed' } ); + object.dispatchEvent( _removedEvent ); } @@ -432,37 +379,31 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), }, - attach: function () { + attach: function ( object ) { // adds object as a child of this, while maintaining the object's world transform - var m = new Matrix4(); - - return function attach( object ) { - - this.updateWorldMatrix( true, false ); - - m.getInverse( this.matrixWorld ); + this.updateWorldMatrix( true, false ); - if ( object.parent !== null ) { + _m1.getInverse( this.matrixWorld ); - object.parent.updateWorldMatrix( true, false ); + if ( object.parent !== null ) { - m.multiply( object.parent.matrixWorld ); + object.parent.updateWorldMatrix( true, false ); - } + _m1.multiply( object.parent.matrixWorld ); - object.applyMatrix( m ); + } - object.updateWorldMatrix( false, false ); + object.applyMatrix( _m1 ); - this.add( object ); + object.updateWorldMatrix( false, false ); - return this; + this.add( object ); - }; + return this; - }(), + }, getObjectById: function ( id ) { @@ -512,53 +453,39 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), }, - getWorldQuaternion: function () { - - var position = new Vector3(); - var scale = new Vector3(); - - return function getWorldQuaternion( target ) { - - if ( target === undefined ) { - - console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' ); - target = new Quaternion(); - - } + getWorldQuaternion: function ( target ) { - this.updateMatrixWorld( true ); - - this.matrixWorld.decompose( position, target, scale ); + if ( target === undefined ) { - return target; + console.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' ); + target = new Quaternion(); - }; + } - }(), + this.updateMatrixWorld( true ); - getWorldScale: function () { + this.matrixWorld.decompose( _position, target, _scale ); - var position = new Vector3(); - var quaternion = new Quaternion(); + return target; - return function getWorldScale( target ) { + }, - if ( target === undefined ) { + getWorldScale: function ( target ) { - console.warn( 'THREE.Object3D: .getWorldScale() target is now required' ); - target = new Vector3(); + if ( target === undefined ) { - } + console.warn( 'THREE.Object3D: .getWorldScale() target is now required' ); + target = new Vector3(); - this.updateMatrixWorld( true ); + } - this.matrixWorld.decompose( position, quaternion, target ); + this.updateMatrixWorld( true ); - return target; + this.matrixWorld.decompose( _position, _quaternion, target ); - }; + return target; - }(), + }, getWorldDirection: function ( target ) { diff --git a/src/core/Raycaster.d.ts b/src/core/Raycaster.d.ts index e182701ffe30a9..483f7237f58bd3 100644 --- a/src/core/Raycaster.d.ts +++ b/src/core/Raycaster.d.ts @@ -55,6 +55,12 @@ export class Raycaster { */ far: number; + /** + * The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field + * can be set manually or is set when calling "setFromCamera". + */ + camera: Camera; + params: RaycasterParameters; /** diff --git a/src/core/Raycaster.js b/src/core/Raycaster.js index 4c98e6df1e2d86..926884f24531c7 100644 --- a/src/core/Raycaster.js +++ b/src/core/Raycaster.js @@ -13,6 +13,7 @@ function Raycaster( origin, direction, near, far ) { this.near = near || 0; this.far = far || Infinity; + this.camera = null; this.params = { Mesh: {}, @@ -79,13 +80,13 @@ Object.assign( Raycaster.prototype, { this.ray.origin.setFromMatrixPosition( camera.matrixWorld ); this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize(); - this._camera = camera; + this.camera = camera; } else if ( ( camera && camera.isOrthographicCamera ) ) { this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld ); - this._camera = camera; + this.camera = camera; } else { diff --git a/src/helpers/ArrowHelper.js b/src/helpers/ArrowHelper.js index b8c72ccafb6ef9..34c35096fd183c 100644 --- a/src/helpers/ArrowHelper.js +++ b/src/helpers/ArrowHelper.js @@ -24,7 +24,7 @@ import { Mesh } from '../objects/Mesh.js'; import { Line } from '../objects/Line.js'; import { Vector3 } from '../math/Vector3.js'; -var _axis; +var _axis = new Vector3(); var _lineGeometry, _coneGeometry; function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { @@ -70,8 +70,6 @@ ArrowHelper.prototype.constructor = ArrowHelper; ArrowHelper.prototype.setDirection = function ( dir ) { - if ( _axis === undefined ) _axis = new Vector3(); - // dir is assumed to be normalized if ( dir.y > 0.99999 ) { diff --git a/src/helpers/BoxHelper.js b/src/helpers/BoxHelper.js index 3b29eb2da586d8..e7458a1cef2f6c 100644 --- a/src/helpers/BoxHelper.js +++ b/src/helpers/BoxHelper.js @@ -9,7 +9,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; import { BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; -var _box; +var _box = new Box3(); function BoxHelper( object, color ) { @@ -37,8 +37,6 @@ BoxHelper.prototype.constructor = BoxHelper; BoxHelper.prototype.update = function ( object ) { - if ( _box === undefined ) _box = new Box3(); - if ( object !== undefined ) { console.warn( 'THREE.BoxHelper: .update() has no longer arguments.' ); diff --git a/src/helpers/CameraHelper.js b/src/helpers/CameraHelper.js index e54b45698d5903..47f5f7fae92a81 100644 --- a/src/helpers/CameraHelper.js +++ b/src/helpers/CameraHelper.js @@ -17,7 +17,8 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; -var _vector, _camera; +var _vector = new Vector3(); +var _camera = new Camera(); function CameraHelper( camera ) { @@ -128,8 +129,6 @@ CameraHelper.prototype.constructor = CameraHelper; CameraHelper.prototype.update = function () { - if ( _camera === undefined ) _camera = new Camera(); - var geometry = this.geometry; var pointMap = this.pointMap; @@ -183,8 +182,6 @@ CameraHelper.prototype.update = function () { function setPoint( point, pointMap, geometry, camera, x, y, z ) { - if ( _vector === undefined ) _vector = new Vector3(); - _vector.set( x, y, z ).unproject( camera ); var points = pointMap[ point ]; diff --git a/src/helpers/DirectionalLightHelper.js b/src/helpers/DirectionalLightHelper.js index ccdb0553fc4ed0..2d09ff4f193f46 100644 --- a/src/helpers/DirectionalLightHelper.js +++ b/src/helpers/DirectionalLightHelper.js @@ -11,7 +11,9 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; -var _v1, _v2, _v3; +var _v1 = new Vector3(); +var _v2 = new Vector3(); +var _v3 = new Vector3(); function DirectionalLightHelper( light, size, color ) { @@ -65,14 +67,6 @@ DirectionalLightHelper.prototype.dispose = function () { DirectionalLightHelper.prototype.update = function () { - if ( _v3 === undefined ) { - - _v1 = new Vector3(); - _v2 = new Vector3(); - _v3 = new Vector3(); - - } - _v1.setFromMatrixPosition( this.light.matrixWorld ); _v2.setFromMatrixPosition( this.light.target.matrixWorld ); _v3.subVectors( _v2, _v1 ); diff --git a/src/helpers/FaceNormalsHelper.js b/src/helpers/FaceNormalsHelper.js index ae4e0ff6b07465..54523284935ced 100644 --- a/src/helpers/FaceNormalsHelper.js +++ b/src/helpers/FaceNormalsHelper.js @@ -10,7 +10,9 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; -var _v1, _v2, _normalMatrix; +var _v1 = new Vector3(); +var _v2 = new Vector3(); +var _normalMatrix = new Matrix3(); function FaceNormalsHelper( object, size, hex, linewidth ) { @@ -62,14 +64,6 @@ FaceNormalsHelper.prototype.constructor = FaceNormalsHelper; FaceNormalsHelper.prototype.update = function () { - if ( _normalMatrix === undefined ) { - - _v1 = new Vector3(); - _v2 = new Vector3(); - _normalMatrix = new Matrix3(); - - } - this.object.updateMatrixWorld( true ); _normalMatrix.getNormalMatrix( this.object.matrixWorld ); diff --git a/src/helpers/HemisphereLightHelper.js b/src/helpers/HemisphereLightHelper.js index ad39e504f4c8b1..20f65ba1e31ae4 100644 --- a/src/helpers/HemisphereLightHelper.js +++ b/src/helpers/HemisphereLightHelper.js @@ -13,7 +13,9 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; import { OctahedronBufferGeometry } from '../geometries/OctahedronGeometry.js'; import { BufferAttribute } from '../core/BufferAttribute.js'; -var _vector, _color1, _color2; +var _vector = new Vector3(); +var _color1 = new Color(); +var _color2 = new Color(); function HemisphereLightHelper( light, size, color ) { @@ -56,14 +58,6 @@ HemisphereLightHelper.prototype.dispose = function () { HemisphereLightHelper.prototype.update = function () { - if ( _color2 === undefined ) { - - _vector = new Vector3(); - _color1 = new Color(); - _color2 = new Color(); - - } - var mesh = this.children[ 0 ]; if ( this.color !== undefined ) { diff --git a/src/helpers/SkeletonHelper.js b/src/helpers/SkeletonHelper.js index 7b1e0fa29d9272..20441dc110acce 100644 --- a/src/helpers/SkeletonHelper.js +++ b/src/helpers/SkeletonHelper.js @@ -16,7 +16,9 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { Object3D } from '../core/Object3D.js'; -var _vector, _boneMatrix, _matrixWorldInv; +var _vector = new Vector3(); +var _boneMatrix = new Matrix4(); +var _matrixWorldInv = new Matrix4(); function getBoneList( object ) { @@ -85,14 +87,6 @@ SkeletonHelper.prototype.constructor = SkeletonHelper; SkeletonHelper.prototype.updateMatrixWorld = function ( force ) { - if ( _matrixWorldInv === undefined ) { - - _vector = new Vector3(); - _boneMatrix = new Matrix4(); - _matrixWorldInv = new Matrix4(); - - } - var bones = this.bones; var geometry = this.geometry; diff --git a/src/helpers/SpotLightHelper.js b/src/helpers/SpotLightHelper.js index f13009493eb472..b2ea419e28b91b 100644 --- a/src/helpers/SpotLightHelper.js +++ b/src/helpers/SpotLightHelper.js @@ -11,7 +11,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; -var _vector; +var _vector = new Vector3(); function SpotLightHelper( light, color ) { @@ -70,8 +70,6 @@ SpotLightHelper.prototype.dispose = function () { SpotLightHelper.prototype.update = function () { - if ( _vector === undefined ) _vector = new Vector3(); - this.light.updateMatrixWorld(); var coneLength = this.light.distance ? this.light.distance : 1000; diff --git a/src/helpers/VertexNormalsHelper.js b/src/helpers/VertexNormalsHelper.js index 5bd2cd50058af8..fa5b56ef5815c4 100644 --- a/src/helpers/VertexNormalsHelper.js +++ b/src/helpers/VertexNormalsHelper.js @@ -10,7 +10,10 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; import { Float32BufferAttribute } from '../core/BufferAttribute.js'; import { BufferGeometry } from '../core/BufferGeometry.js'; -var _v1, _v2, _normalMatrix, _keys; +var _v1 = new Vector3(); +var _v2 = new Vector3(); +var _normalMatrix = new Matrix3(); +var _keys = [ 'a', 'b', 'c' ]; function VertexNormalsHelper( object, size, hex, linewidth ) { @@ -61,15 +64,6 @@ VertexNormalsHelper.prototype.constructor = VertexNormalsHelper; VertexNormalsHelper.prototype.update = function () { - if ( _normalMatrix === undefined ) { - - _v1 = new Vector3(); - _v2 = new Vector3(); - _normalMatrix = new Matrix3(); - _keys = [ 'a', 'b', 'c' ]; - - } - this.object.updateMatrixWorld( true ); _normalMatrix.getNormalMatrix( this.object.matrixWorld ); diff --git a/src/loaders/Loader.js b/src/loaders/Loader.js index d1c9726fd13b8a..df99344aa177b1 100644 --- a/src/loaders/Loader.js +++ b/src/loaders/Loader.js @@ -24,6 +24,19 @@ import { Color } from '../math/Color.js'; * @author alteredq / http://alteredqualia.com/ */ +var _BlendingMode = { + NoBlending: NoBlending, + NormalBlending: NormalBlending, + AdditiveBlending: AdditiveBlending, + SubtractiveBlending: SubtractiveBlending, + MultiplyBlending: MultiplyBlending, + CustomBlending: CustomBlending +}; + +var _color = new Color(); +var _textureLoader = new TextureLoader(); +var _materialLoader = new MaterialLoader(); + function Loader() {} Loader.Handlers = { @@ -83,260 +96,243 @@ Object.assign( Loader.prototype, { }, - createMaterial: ( function () { - - var BlendingMode = { - NoBlending: NoBlending, - NormalBlending: NormalBlending, - AdditiveBlending: AdditiveBlending, - SubtractiveBlending: SubtractiveBlending, - MultiplyBlending: MultiplyBlending, - CustomBlending: CustomBlending - }; + createMaterial: function ( m, texturePath, crossOrigin ) { - var color = new Color(); - var textureLoader = new TextureLoader(); - var materialLoader = new MaterialLoader(); + // convert from old material format - return function createMaterial( m, texturePath, crossOrigin ) { + var textures = {}; - // convert from old material format + // - var textures = {}; + var json = { + uuid: _Math.generateUUID(), + type: 'MeshLambertMaterial' + }; - function loadTexture( path, repeat, offset, wrap, anisotropy ) { + for ( var name in m ) { + + var value = m[ name ]; + + switch ( name ) { + + case 'DbgColor': + case 'DbgIndex': + case 'opticalDensity': + case 'illumination': + break; + case 'DbgName': + json.name = value; + break; + case 'blending': + json.blending = _BlendingMode[ value ]; + break; + case 'colorAmbient': + case 'mapAmbient': + console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); + break; + case 'colorDiffuse': + json.color = _color.fromArray( value ).getHex(); + break; + case 'colorSpecular': + json.specular = _color.fromArray( value ).getHex(); + break; + case 'colorEmissive': + json.emissive = _color.fromArray( value ).getHex(); + break; + case 'specularCoef': + json.shininess = value; + break; + case 'shading': + if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial'; + if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; + if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial'; + break; + case 'mapDiffuse': + json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapDiffuseRepeat': + case 'mapDiffuseOffset': + case 'mapDiffuseWrap': + case 'mapDiffuseAnisotropy': + break; + case 'mapEmissive': + json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapEmissiveRepeat': + case 'mapEmissiveOffset': + case 'mapEmissiveWrap': + case 'mapEmissiveAnisotropy': + break; + case 'mapLight': + json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapLightRepeat': + case 'mapLightOffset': + case 'mapLightWrap': + case 'mapLightAnisotropy': + break; + case 'mapAO': + json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapAORepeat': + case 'mapAOOffset': + case 'mapAOWrap': + case 'mapAOAnisotropy': + break; + case 'mapBump': + json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapBumpScale': + json.bumpScale = value; + break; + case 'mapBumpRepeat': + case 'mapBumpOffset': + case 'mapBumpWrap': + case 'mapBumpAnisotropy': + break; + case 'mapNormal': + json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapNormalFactor': + json.normalScale = value; + break; + case 'mapNormalRepeat': + case 'mapNormalOffset': + case 'mapNormalWrap': + case 'mapNormalAnisotropy': + break; + case 'mapSpecular': + json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapSpecularRepeat': + case 'mapSpecularOffset': + case 'mapSpecularWrap': + case 'mapSpecularAnisotropy': + break; + case 'mapMetalness': + json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapMetalnessRepeat': + case 'mapMetalnessOffset': + case 'mapMetalnessWrap': + case 'mapMetalnessAnisotropy': + break; + case 'mapRoughness': + json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapRoughnessRepeat': + case 'mapRoughnessOffset': + case 'mapRoughnessWrap': + case 'mapRoughnessAnisotropy': + break; + case 'mapAlpha': + json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy, textures, texturePath, crossOrigin ); + break; + case 'mapAlphaRepeat': + case 'mapAlphaOffset': + case 'mapAlphaWrap': + case 'mapAlphaAnisotropy': + break; + case 'flipSided': + json.side = BackSide; + break; + case 'doubleSided': + json.side = DoubleSide; + break; + case 'transparency': + console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); + json.opacity = value; + break; + case 'depthTest': + case 'depthWrite': + case 'colorWrite': + case 'opacity': + case 'reflectivity': + case 'transparent': + case 'visible': + case 'wireframe': + json[ name ] = value; + break; + case 'vertexColors': + if ( value === true ) json.vertexColors = VertexColors; + if ( value === 'face' ) json.vertexColors = FaceColors; + break; + default: + console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); + break; - var fullPath = texturePath + path; - var loader = Loader.Handlers.get( fullPath ); + } - var texture; + } - if ( loader !== null ) { + if ( json.type === 'MeshBasicMaterial' ) delete json.emissive; + if ( json.type !== 'MeshPhongMaterial' ) delete json.specular; - texture = loader.load( fullPath ); + if ( json.opacity < 1 ) json.transparent = true; - } else { + _materialLoader.setTextures( textures ); - textureLoader.setCrossOrigin( crossOrigin ); - texture = textureLoader.load( fullPath ); + return _materialLoader.parse( json ); - } + } - if ( repeat !== undefined ) { +} ); - texture.repeat.fromArray( repeat ); +function loadTexture( path, repeat, offset, wrap, anisotropy, textures, texturePath, crossOrigin ) { - if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping; - if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping; + var fullPath = texturePath + path; + var loader = Loader.Handlers.get( fullPath ); - } + var texture; - if ( offset !== undefined ) { + if ( loader !== null ) { - texture.offset.fromArray( offset ); + texture = loader.load( fullPath ); - } + } else { - if ( wrap !== undefined ) { + _textureLoader.setCrossOrigin( crossOrigin ); + texture = _textureLoader.load( fullPath ); - if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping; - if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping; + } - if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping; - if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping; + if ( repeat !== undefined ) { - } + texture.repeat.fromArray( repeat ); - if ( anisotropy !== undefined ) { + if ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping; + if ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping; - texture.anisotropy = anisotropy; + } - } + if ( offset !== undefined ) { - var uuid = _Math.generateUUID(); + texture.offset.fromArray( offset ); - textures[ uuid ] = texture; + } - return uuid; + if ( wrap !== undefined ) { - } + if ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping; + if ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping; - // - - var json = { - uuid: _Math.generateUUID(), - type: 'MeshLambertMaterial' - }; - - for ( var name in m ) { - - var value = m[ name ]; - - switch ( name ) { - - case 'DbgColor': - case 'DbgIndex': - case 'opticalDensity': - case 'illumination': - break; - case 'DbgName': - json.name = value; - break; - case 'blending': - json.blending = BlendingMode[ value ]; - break; - case 'colorAmbient': - case 'mapAmbient': - console.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' ); - break; - case 'colorDiffuse': - json.color = color.fromArray( value ).getHex(); - break; - case 'colorSpecular': - json.specular = color.fromArray( value ).getHex(); - break; - case 'colorEmissive': - json.emissive = color.fromArray( value ).getHex(); - break; - case 'specularCoef': - json.shininess = value; - break; - case 'shading': - if ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial'; - if ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial'; - if ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial'; - break; - case 'mapDiffuse': - json.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy ); - break; - case 'mapDiffuseRepeat': - case 'mapDiffuseOffset': - case 'mapDiffuseWrap': - case 'mapDiffuseAnisotropy': - break; - case 'mapEmissive': - json.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy ); - break; - case 'mapEmissiveRepeat': - case 'mapEmissiveOffset': - case 'mapEmissiveWrap': - case 'mapEmissiveAnisotropy': - break; - case 'mapLight': - json.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy ); - break; - case 'mapLightRepeat': - case 'mapLightOffset': - case 'mapLightWrap': - case 'mapLightAnisotropy': - break; - case 'mapAO': - json.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy ); - break; - case 'mapAORepeat': - case 'mapAOOffset': - case 'mapAOWrap': - case 'mapAOAnisotropy': - break; - case 'mapBump': - json.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy ); - break; - case 'mapBumpScale': - json.bumpScale = value; - break; - case 'mapBumpRepeat': - case 'mapBumpOffset': - case 'mapBumpWrap': - case 'mapBumpAnisotropy': - break; - case 'mapNormal': - json.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy ); - break; - case 'mapNormalFactor': - json.normalScale = value; - break; - case 'mapNormalRepeat': - case 'mapNormalOffset': - case 'mapNormalWrap': - case 'mapNormalAnisotropy': - break; - case 'mapSpecular': - json.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy ); - break; - case 'mapSpecularRepeat': - case 'mapSpecularOffset': - case 'mapSpecularWrap': - case 'mapSpecularAnisotropy': - break; - case 'mapMetalness': - json.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy ); - break; - case 'mapMetalnessRepeat': - case 'mapMetalnessOffset': - case 'mapMetalnessWrap': - case 'mapMetalnessAnisotropy': - break; - case 'mapRoughness': - json.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy ); - break; - case 'mapRoughnessRepeat': - case 'mapRoughnessOffset': - case 'mapRoughnessWrap': - case 'mapRoughnessAnisotropy': - break; - case 'mapAlpha': - json.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy ); - break; - case 'mapAlphaRepeat': - case 'mapAlphaOffset': - case 'mapAlphaWrap': - case 'mapAlphaAnisotropy': - break; - case 'flipSided': - json.side = BackSide; - break; - case 'doubleSided': - json.side = DoubleSide; - break; - case 'transparency': - console.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' ); - json.opacity = value; - break; - case 'depthTest': - case 'depthWrite': - case 'colorWrite': - case 'opacity': - case 'reflectivity': - case 'transparent': - case 'visible': - case 'wireframe': - json[ name ] = value; - break; - case 'vertexColors': - if ( value === true ) json.vertexColors = VertexColors; - if ( value === 'face' ) json.vertexColors = FaceColors; - break; - default: - console.error( 'THREE.Loader.createMaterial: Unsupported', name, value ); - break; - - } + if ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping; + if ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping; - } + } - if ( json.type === 'MeshBasicMaterial' ) delete json.emissive; - if ( json.type !== 'MeshPhongMaterial' ) delete json.specular; + if ( anisotropy !== undefined ) { - if ( json.opacity < 1 ) json.transparent = true; + texture.anisotropy = anisotropy; - materialLoader.setTextures( textures ); + } - return materialLoader.parse( json ); + var uuid = _Math.generateUUID(); - }; + textures[ uuid ] = texture; - } )() + return uuid; -} ); +} export { Loader }; diff --git a/src/loaders/MaterialLoader.js b/src/loaders/MaterialLoader.js index f538e960861800..8810f7aefbb359 100644 --- a/src/loaders/MaterialLoader.js +++ b/src/loaders/MaterialLoader.js @@ -229,6 +229,9 @@ Object.assign( MaterialLoader.prototype, { if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + if ( json.clearCoatNormalMap !== undefined ) material.clearCoatNormalMap = getTexture( json.clearCoatNormalMap ); + if ( json.clearCoatNormalScale !== undefined ) material.clearCoatNormalScale = new Vector2().fromArray( json.clearCoatNormalScale ); + return material; }, diff --git a/src/materials/Material.d.ts b/src/materials/Material.d.ts index 00eedb1c8f2875..407df0c9d97d87 100644 --- a/src/materials/Material.d.ts +++ b/src/materials/Material.d.ts @@ -333,9 +333,4 @@ export class Material extends EventDispatcher { */ toJSON( meta?: any ): any; - /** - * Call .dispatchEvent ( { type: 'update' }) on the material. - */ - update(): void; - } diff --git a/src/materials/Material.js b/src/materials/Material.js index 218ff11a249d15..4c12282e5fb18e 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -175,6 +175,13 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ), if ( this.clearCoat !== undefined ) data.clearCoat = this.clearCoat; if ( this.clearCoatRoughness !== undefined ) data.clearCoatRoughness = this.clearCoatRoughness; + if ( this.clearCoatNormalMap && this.clearCoatNormalMap.isTexture ) { + + data.clearCoatNormalMap = this.clearCoatNormalMap.toJSON( meta ).uuid; + data.clearCoatNormalScale = this.clearCoatNormalScale.toArray(); + + } + if ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid; if ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid; if ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid; diff --git a/src/materials/MeshStandardMaterial.d.ts b/src/materials/MeshStandardMaterial.d.ts index f7c01ec0182772..206ae0b3d626f3 100644 --- a/src/materials/MeshStandardMaterial.d.ts +++ b/src/materials/MeshStandardMaterial.d.ts @@ -29,7 +29,7 @@ export interface MeshStandardMaterialParameters extends MaterialParameters { alphaMap?: Texture; envMap?: Texture; envMapIntensity?: number; - energyPreservation: boolean; + energyPreservation?: boolean; refractionRatio?: number; wireframe?: boolean; wireframeLinewidth?: number; diff --git a/src/math/Box2.js b/src/math/Box2.js index f30a9e451bb2a4..c8e75b1117855b 100644 --- a/src/math/Box2.js +++ b/src/math/Box2.js @@ -4,7 +4,7 @@ import { Vector2 } from './Vector2.js'; * @author bhouston / http://clara.io */ -var _vector; +var _vector = new Vector2(); function Box2( min, max ) { @@ -40,8 +40,6 @@ Object.assign( Box2.prototype, { setFromCenterAndSize: function ( center, size ) { - if ( _vector === undefined ) _vector = new Vector2(); - var halfSize = _vector.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); this.max.copy( center ).add( halfSize ); @@ -192,8 +190,6 @@ Object.assign( Box2.prototype, { distanceToPoint: function ( point ) { - if ( _vector === undefined ) _vector = new Vector2(); - var clampedPoint = _vector.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); diff --git a/src/math/Box3.js b/src/math/Box3.js index 78bade50ef628e..eb1aea375c5d50 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -1,19 +1,39 @@ import { Vector3 } from './Vector3.js'; +var _points = [ + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3(), + new Vector3() +]; +var _vector = new Vector3(); + +// triangle centered vertices + +var _v0 = new Vector3(); +var _v1 = new Vector3(); +var _v2 = new Vector3(); + +// triangle edge vectors + +var _f0 = new Vector3(); +var _f1 = new Vector3(); +var _f2 = new Vector3(); + +var _center = new Vector3(); +var _extents = new Vector3(); +var _triangleNormal = new Vector3(); +var _testAxis = new Vector3(); + /** * @author bhouston / http://clara.io * @author WestLangley / http://github.com/WestLangley */ -var _points; -var _vector; - -var _v0, _v1, _v2; -var _f0, _f1, _f2; -var _center; -var _extents; -var _triangleNormal; - function Box3( min, max ) { this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity ); @@ -116,8 +136,6 @@ Object.assign( Box3.prototype, { setFromCenterAndSize: function ( center, size ) { - if ( _vector === undefined ) _vector = new Vector3(); - var halfSize = _vector.copy( size ).multiplyScalar( 0.5 ); this.min.copy( center ).sub( halfSize ); @@ -222,8 +240,6 @@ Object.assign( Box3.prototype, { expandByObject: function ( object ) { - if ( _vector === undefined ) _vector = new Vector3(); - var i, l; // Computes the world-axis-aligned bounding box of an object (including its children), @@ -329,8 +345,6 @@ Object.assign( Box3.prototype, { intersectsSphere: function ( sphere ) { - if ( _vector === undefined ) _vector = new Vector3(); - // Find the point on the AABB closest to the sphere center. this.clampPoint( sphere.center, _vector ); @@ -388,26 +402,6 @@ Object.assign( Box3.prototype, { intersectsTriangle: function ( triangle ) { - if ( _v0 === undefined ) { - - // triangle centered vertices - - _v0 = new Vector3(); - _v1 = new Vector3(); - _v2 = new Vector3(); - - // triangle edge vectors - - _f0 = new Vector3(); - _f1 = new Vector3(); - _f2 = new Vector3(); - - _center = new Vector3(); - _extents = new Vector3(); - _triangleNormal = new Vector3(); - - } - if ( this.isEmpty() ) { return false; @@ -474,8 +468,6 @@ Object.assign( Box3.prototype, { distanceToPoint: function ( point ) { - if ( _vector === undefined ) _vector = new Vector3(); - var clampedPoint = _vector.copy( point ).clamp( this.min, this.max ); return clampedPoint.sub( point ).length(); @@ -484,8 +476,6 @@ Object.assign( Box3.prototype, { getBoundingSphere: function ( target ) { - if ( _vector === undefined ) _vector = new Vector3(); - if ( target === undefined ) { console.error( 'THREE.Box3: .getBoundingSphere() target is now required' ); @@ -524,21 +514,6 @@ Object.assign( Box3.prototype, { applyMatrix4: function ( matrix ) { - if ( _points === undefined ) { - - _points = [ - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3(), - new Vector3() - ]; - - } - // transform of empty box is an empty box. if ( this.isEmpty() ) return this; @@ -575,12 +550,8 @@ Object.assign( Box3.prototype, { } ); -var _testAxis; - function satForAxes( axes, v0, v1, v2, extents ) { - if ( _testAxis === undefined ) _testAxis = new Vector3(); - var i, j; for ( i = 0, j = axes.length - 3; i <= j; i += 3 ) { diff --git a/src/math/Euler.d.ts b/src/math/Euler.d.ts index aebd3cfaad9fd4..e8e1b874178e30 100644 --- a/src/math/Euler.d.ts +++ b/src/math/Euler.d.ts @@ -2,156 +2,6 @@ import { Matrix4 } from './Matrix4'; import { Quaternion } from './Quaternion'; import { Vector3 } from './Vector3'; -export namespace ColorKeywords { - export const aliceblue: number; - export const antiquewhite: number; - export const aqua: number; - export const aquamarine: number; - export const azure: number; - export const beige: number; - export const bisque: number; - export const black: number; - export const blanchedalmond: number; - export const blue: number; - export const blueviolet: number; - export const brown: number; - export const burlywood: number; - export const cadetblue: number; - export const chartreuse: number; - export const chocolate: number; - export const coral: number; - export const cornflowerblue: number; - export const cornsilk: number; - export const crimson: number; - export const cyan: number; - export const darkblue: number; - export const darkcyan: number; - export const darkgoldenrod: number; - export const darkgray: number; - export const darkgreen: number; - export const darkgrey: number; - export const darkkhaki: number; - export const darkmagenta: number; - export const darkolivegreen: number; - export const darkorange: number; - export const darkorchid: number; - export const darkred: number; - export const darksalmon: number; - export const darkseagreen: number; - export const darkslateblue: number; - export const darkslategray: number; - export const darkslategrey: number; - export const darkturquoise: number; - export const darkviolet: number; - export const deeppink: number; - export const deepskyblue: number; - export const dimgray: number; - export const dimgrey: number; - export const dodgerblue: number; - export const firebrick: number; - export const floralwhite: number; - export const forestgreen: number; - export const fuchsia: number; - export const gainsboro: number; - export const ghostwhite: number; - export const gold: number; - export const goldenrod: number; - export const gray: number; - export const green: number; - export const greenyellow: number; - export const grey: number; - export const honeydew: number; - export const hotpink: number; - export const indianred: number; - export const indigo: number; - export const ivory: number; - export const khaki: number; - export const lavender: number; - export const lavenderblush: number; - export const lawngreen: number; - export const lemonchiffon: number; - export const lightblue: number; - export const lightcoral: number; - export const lightcyan: number; - export const lightgoldenrodyellow: number; - export const lightgray: number; - export const lightgreen: number; - export const lightgrey: number; - export const lightpink: number; - export const lightsalmon: number; - export const lightseagreen: number; - export const lightskyblue: number; - export const lightslategray: number; - export const lightslategrey: number; - export const lightsteelblue: number; - export const lightyellow: number; - export const lime: number; - export const limegreen: number; - export const linen: number; - export const magenta: number; - export const maroon: number; - export const mediumaquamarine: number; - export const mediumblue: number; - export const mediumorchid: number; - export const mediumpurple: number; - export const mediumseagreen: number; - export const mediumslateblue: number; - export const mediumspringgreen: number; - export const mediumturquoise: number; - export const mediumvioletred: number; - export const midnightblue: number; - export const mintcream: number; - export const mistyrose: number; - export const moccasin: number; - export const navajowhite: number; - export const navy: number; - export const oldlace: number; - export const olive: number; - export const olivedrab: number; - export const orange: number; - export const orangered: number; - export const orchid: number; - export const palegoldenrod: number; - export const palegreen: number; - export const paleturquoise: number; - export const palevioletred: number; - export const papayawhip: number; - export const peachpuff: number; - export const peru: number; - export const pink: number; - export const plum: number; - export const powderblue: number; - export const purple: number; - export const red: number; - export const rosybrown: number; - export const royalblue: number; - export const saddlebrown: number; - export const salmon: number; - export const sandybrown: number; - export const seagreen: number; - export const seashell: number; - export const sienna: number; - export const silver: number; - export const skyblue: number; - export const slateblue: number; - export const slategray: number; - export const slategrey: number; - export const snow: number; - export const springgreen: number; - export const steelblue: number; - export const tan: number; - export const teal: number; - export const thistle: number; - export const tomato: number; - export const turquoise: number; - export const violet: number; - export const wheat: number; - export const white: number; - export const whitesmoke: number; - export const yellow: number; - export const yellowgreen: number; -} - export class Euler { constructor( x?: number, y?: number, z?: number, order?: string ); diff --git a/src/math/Euler.js b/src/math/Euler.js index da2eeed521513d..76d70af1372f51 100644 --- a/src/math/Euler.js +++ b/src/math/Euler.js @@ -9,7 +9,8 @@ import { _Math } from './Math.js'; * @author bhouston / http://clara.io */ -var _matrix, _quaternion; +var _matrix = new Matrix4(); +var _quaternion = new Quaternion(); function Euler( x, y, z, order ) { @@ -257,8 +258,6 @@ Object.assign( Euler.prototype, { setFromQuaternion: function ( q, order, update ) { - if ( _matrix === undefined ) _matrix = new Matrix4(); - _matrix.makeRotationFromQuaternion( q ); return this.setFromRotationMatrix( _matrix, order, update ); @@ -275,8 +274,6 @@ Object.assign( Euler.prototype, { // WARNING: this discards revolution information -bhouston - if ( _quaternion === undefined ) _quaternion = new Quaternion(); - _quaternion.setFromEuler( this ); return this.setFromQuaternion( _quaternion, newOrder ); diff --git a/src/math/Frustum.js b/src/math/Frustum.js index b7b01ef67aac3e..5451f62d959b49 100644 --- a/src/math/Frustum.js +++ b/src/math/Frustum.js @@ -8,8 +8,8 @@ import { Plane } from './Plane.js'; * @author bhouston / http://clara.io */ -var _sphere; -var _vector; +var _sphere = new Sphere(); +var _vector = new Vector3(); function Frustum( p0, p1, p2, p3, p4, p5 ) { @@ -85,8 +85,6 @@ Object.assign( Frustum.prototype, { intersectsObject: function ( object ) { - if ( _sphere === undefined ) _sphere = new Sphere(); - var geometry = object.geometry; if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere(); @@ -99,8 +97,6 @@ Object.assign( Frustum.prototype, { intersectsSprite: function ( sprite ) { - if ( _sphere === undefined ) _sphere = new Sphere(); - _sphere.center.set( 0, 0, 0 ); _sphere.radius = 0.7071067811865476; _sphere.applyMatrix4( sprite.matrixWorld ); @@ -133,8 +129,6 @@ Object.assign( Frustum.prototype, { intersectsBox: function ( box ) { - if ( _vector === undefined ) _vector = new Vector3(); - var planes = this.planes; for ( var i = 0; i < 6; i ++ ) { diff --git a/src/math/Line3.js b/src/math/Line3.js index ee070bcad49bc5..be56b6d1681645 100644 --- a/src/math/Line3.js +++ b/src/math/Line3.js @@ -5,7 +5,8 @@ import { _Math } from './Math.js'; * @author bhouston / http://clara.io */ -var _startP, _startEnd; +var _startP = new Vector3(); +var _startEnd = new Vector3(); function Line3( start, end ) { @@ -93,13 +94,6 @@ Object.assign( Line3.prototype, { closestPointToPointParameter: function ( point, clampToLine ) { - if ( _startP === undefined ) { - - _startP = new Vector3(); - _startEnd = new Vector3(); - - } - _startP.subVectors( point, this.start ); _startEnd.subVectors( this.end, this.start ); diff --git a/src/math/Matrix3.js b/src/math/Matrix3.js index 75d3b8d9398e41..5654a8d9fcd9c4 100644 --- a/src/math/Matrix3.js +++ b/src/math/Matrix3.js @@ -7,7 +7,7 @@ import { Vector3 } from './Vector3.js'; * @author tschw */ -var _vector; +var _vector = new Vector3(); function Matrix3() { @@ -94,8 +94,6 @@ Object.assign( Matrix3.prototype, { applyToBufferAttribute: function ( attribute ) { - if ( _vector === undefined ) _vector = new Vector3(); - for ( var i = 0, l = attribute.count; i < l; i ++ ) { _vector.x = attribute.getX( i ); diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index 7dac3d0ebe3019..b0d92b3b9305ab 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -1,5 +1,13 @@ import { Vector3 } from './Vector3.js'; +var _v1 = new Vector3(); +var _m1 = new Matrix4(); +var _zero = new Vector3( 0, 0, 0 ); +var _one = new Vector3( 1, 1, 1 ); +var _x = new Vector3(); +var _y = new Vector3(); +var _z = new Vector3(); + /** * @author mrdoob / http://mrdoob.com/ * @author supereggbert / http://www.paulbrunt.co.uk/ @@ -13,10 +21,6 @@ import { Vector3 } from './Vector3.js'; * @author WestLangley / http://github.com/WestLangley */ -var _v1, _m1; -var _zero, _one; -var _x, _y, _z; - function Matrix4() { this.elements = [ @@ -125,8 +129,6 @@ Object.assign( Matrix4.prototype, { extractRotation: function ( m ) { - if ( _v1 === undefined ) _v1 = new Vector3(); - // this method does not support reflection matrices var te = this.elements; @@ -290,27 +292,12 @@ Object.assign( Matrix4.prototype, { makeRotationFromQuaternion: function ( q ) { - if ( _zero === undefined ) { - - _zero = new Vector3( 0, 0, 0 ); - _one = new Vector3( 1, 1, 1 ); - - } - return this.compose( _zero, q, _one ); }, lookAt: function ( eye, target, up ) { - if ( _x === undefined ) { - - _x = new Vector3(); - _y = new Vector3(); - _z = new Vector3(); - - } - var te = this.elements; _z.subVectors( eye, target ); @@ -430,8 +417,6 @@ Object.assign( Matrix4.prototype, { applyToBufferAttribute: function ( attribute ) { - if ( _v1 === undefined ) _v1 = new Vector3(); - for ( var i = 0, l = attribute.count; i < l; i ++ ) { _v1.x = attribute.getX( i ); @@ -782,13 +767,6 @@ Object.assign( Matrix4.prototype, { decompose: function ( position, quaternion, scale ) { - if ( _m1 === undefined ) { - - _m1 = new Matrix4(); - _v1 = new Vector3(); - - } - var te = this.elements; var sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length(); diff --git a/src/math/Plane.js b/src/math/Plane.js index ae780ea5fdf9c4..2e2baeb5e95bf6 100644 --- a/src/math/Plane.js +++ b/src/math/Plane.js @@ -5,7 +5,9 @@ import { Vector3 } from './Vector3.js'; * @author bhouston / http://clara.io */ -var _vector1, _vector2, _normalMatrix; +var _vector1 = new Vector3(); +var _vector2 = new Vector3(); +var _normalMatrix = new Matrix3(); function Plane( normal, constant ) { @@ -49,13 +51,6 @@ Object.assign( Plane.prototype, { setFromCoplanarPoints: function ( a, b, c ) { - if ( _vector1 === undefined ) { - - _vector1 = new Vector3(); - _vector2 = new Vector3(); - - } - var normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize(); // Q: should an error be thrown if normal is zero (e.g. degenerate plane)? @@ -129,8 +124,6 @@ Object.assign( Plane.prototype, { intersectLine: function ( line, target ) { - if ( _vector1 === undefined ) _vector1 = new Vector3(); - if ( target === undefined ) { console.warn( 'THREE.Plane: .intersectLine() target is now required' ); @@ -206,13 +199,6 @@ Object.assign( Plane.prototype, { applyMatrix4: function ( matrix, optionalNormalMatrix ) { - if ( _normalMatrix === undefined ) { - - _normalMatrix = new Matrix3(); - _vector1 = new Vector3(); - - } - var normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix ); var referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix ); diff --git a/src/math/Ray.js b/src/math/Ray.js index fbb9c25e4373cc..fa58a0ad3438bb 100644 --- a/src/math/Ray.js +++ b/src/math/Ray.js @@ -1,13 +1,18 @@ import { Vector3 } from './Vector3.js'; +var _vector = new Vector3(); +var _segCenter = new Vector3(); +var _segDir = new Vector3(); +var _diff = new Vector3(); + +var _edge1 = new Vector3(); +var _edge2 = new Vector3(); +var _normal = new Vector3(); + /** * @author bhouston / http://clara.io */ -var _vector; -var _segCenter, _segDir, _diff; -var _diff, _edge1, _edge2, _normal; - function Ray( origin, direction ) { this.origin = ( origin !== undefined ) ? origin : new Vector3(); @@ -64,8 +69,6 @@ Object.assign( Ray.prototype, { recast: function ( t ) { - if ( _vector === undefined ) _vector = new Vector3(); - this.origin.copy( this.at( t, _vector ) ); return this; @@ -103,8 +106,6 @@ Object.assign( Ray.prototype, { distanceSqToPoint: function ( point ) { - if ( _vector === undefined ) _vector = new Vector3(); - var directionDistance = _vector.subVectors( point, this.origin ).dot( this.direction ); // point behind the ray @@ -123,14 +124,6 @@ Object.assign( Ray.prototype, { distanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) { - if ( _segCenter === undefined ) { - - _segCenter = new Vector3(); - _segDir = new Vector3(); - _diff = new Vector3(); - - } - // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h // It returns the min distance between the ray and the segment // defined by v0 and v1 @@ -250,8 +243,6 @@ Object.assign( Ray.prototype, { intersectSphere: function ( sphere, target ) { - if ( _vector === undefined ) _vector = new Vector3(); - _vector.subVectors( sphere.center, this.origin ); var tca = _vector.dot( this.direction ); var d2 = _vector.dot( _vector ) - tca * tca; @@ -424,8 +415,6 @@ Object.assign( Ray.prototype, { intersectsBox: function ( box ) { - if ( _vector === undefined ) _vector = new Vector3(); - return this.intersectBox( box, _vector ) !== null; }, @@ -434,15 +423,6 @@ Object.assign( Ray.prototype, { // Compute the offset origin, edges, and normal. - if ( _diff === undefined ) { - - _diff = new Vector3(); - _edge1 = new Vector3(); - _edge2 = new Vector3(); - _normal = new Vector3(); - - } - // from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h _edge1.subVectors( b, a ); diff --git a/src/math/Sphere.js b/src/math/Sphere.js index ab2a14f2289214..52db669514320f 100644 --- a/src/math/Sphere.js +++ b/src/math/Sphere.js @@ -1,13 +1,13 @@ import { Box3 } from './Box3.js'; import { Vector3 } from './Vector3.js'; +var _box = new Box3(); + /** * @author bhouston / http://clara.io * @author mrdoob / http://mrdoob.com/ */ -var _box; - function Sphere( center, radius ) { this.center = ( center !== undefined ) ? center : new Vector3(); @@ -28,8 +28,6 @@ Object.assign( Sphere.prototype, { setFromPoints: function ( points, optionalCenter ) { - if ( _box === undefined ) _box = new Box3(); - var center = this.center; if ( optionalCenter !== undefined ) { diff --git a/src/math/Spherical.d.ts b/src/math/Spherical.d.ts index 3c4e2181849e4d..5e402f02c6208f 100644 --- a/src/math/Spherical.d.ts +++ b/src/math/Spherical.d.ts @@ -8,10 +8,11 @@ export class Spherical { phi: number; theta: number; - set( radius: number, phi: number, theta: number ): Spherical; + set( radius: number, phi: number, theta: number ): this; clone(): this; copy( other: Spherical ): this; makeSafe(): void; - setFromVector3( vec3: Vector3 ): Spherical; + setFromVector3( v: Vector3 ): this; + setFromCartesianCoords( x: number, y: number, z: number ): this; } diff --git a/src/math/Triangle.js b/src/math/Triangle.js index 89e0cf59907cc9..12f23ef11661bb 100644 --- a/src/math/Triangle.js +++ b/src/math/Triangle.js @@ -5,8 +5,17 @@ import { Vector3 } from './Vector3.js'; * @author mrdoob / http://mrdoob.com/ */ -var _v0, _v1, _v2, _v3; -var _vab, _vac, _vbc, _vap, _vbp, _vcp; +var _v0 = new Vector3(); +var _v1 = new Vector3(); +var _v2 = new Vector3(); +var _v3 = new Vector3(); + +var _vab = new Vector3(); +var _vac = new Vector3(); +var _vbc = new Vector3(); +var _vap = new Vector3(); +var _vbp = new Vector3(); +var _vcp = new Vector3(); function Triangle( a, b, c ) { @@ -20,8 +29,6 @@ Object.assign( Triangle, { getNormal: function ( a, b, c, target ) { - if ( _v0 === undefined ) _v0 = new Vector3(); - if ( target === undefined ) { console.warn( 'THREE.Triangle: .getNormal() target is now required' ); @@ -48,14 +55,6 @@ Object.assign( Triangle, { // based on: http://www.blackpawn.com/texts/pointinpoly/default.html getBarycoord: function ( point, a, b, c, target ) { - if ( _v2 === undefined ) { - - _v0 = new Vector3(); - _v1 = new Vector3(); - _v2 = new Vector3(); - - } - _v0.subVectors( c, a ); _v1.subVectors( b, a ); _v2.subVectors( point, a ); @@ -95,8 +94,6 @@ Object.assign( Triangle, { containsPoint: function ( point, a, b, c ) { - if ( _v3 === undefined ) _v3 = new Vector3(); - Triangle.getBarycoord( point, a, b, c, _v3 ); return ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 ); @@ -105,8 +102,6 @@ Object.assign( Triangle, { getUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) { - if ( _v3 === undefined ) _v3 = new Vector3(); - this.getBarycoord( point, p1, p2, p3, _v3 ); target.set( 0, 0 ); @@ -120,13 +115,6 @@ Object.assign( Triangle, { isFrontFacing: function ( a, b, c, direction ) { - if ( _v1 === undefined ) { - - _v0 = new Vector3(); - _v1 = new Vector3(); - - } - _v0.subVectors( c, b ); _v1.subVectors( a, b ); @@ -177,13 +165,6 @@ Object.assign( Triangle.prototype, { getArea: function () { - if ( _v1 === undefined ) { - - _v0 = new Vector3(); - _v1 = new Vector3(); - - } - _v0.subVectors( this.c, this.b ); _v1.subVectors( this.a, this.b ); @@ -255,17 +236,6 @@ Object.assign( Triangle.prototype, { closestPointToPoint: function ( p, target ) { - if ( _vab === undefined ) { - - _vab = new Vector3(); - _vac = new Vector3(); - _vbc = new Vector3(); - _vap = new Vector3(); - _vbp = new Vector3(); - _vcp = new Vector3(); - - } - if ( target === undefined ) { console.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' ); diff --git a/src/math/Vector3.d.ts b/src/math/Vector3.d.ts index aace67a1dc3163..cbf8dde30b46f8 100644 --- a/src/math/Vector3.d.ts +++ b/src/math/Vector3.d.ts @@ -236,7 +236,9 @@ export class Vector3 implements Vector { distanceToManhattan( v: Vector3 ): number; setFromSpherical( s: Spherical ): this; + setFromSphericalCoords( r: number, phi: number, theta:number ): this; setFromCylindrical( s: Cylindrical ): this; + setFromCylindricalCoords( radius: number, theta: number, y: number ): this; setFromMatrixPosition( m: Matrix4 ): this; setFromMatrixScale( m: Matrix4 ): this; setFromMatrixColumn( matrix: Matrix4, index: number ): this; diff --git a/src/math/Vector3.js b/src/math/Vector3.js index a25a71666743d3..d1c4dffe3da38d 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -10,7 +10,8 @@ import { Quaternion } from './Quaternion.js'; * @author WestLangley / http://github.com/WestLangley */ -var _vector, _quaternion; +var _vector = new Vector3(); +var _quaternion = new Quaternion(); function Vector3( x, y, z ) { @@ -235,8 +236,6 @@ Object.assign( Vector3.prototype, { applyEuler: function ( euler ) { - if ( _quaternion === undefined ) _quaternion = new Quaternion(); - if ( ! ( euler && euler.isEuler ) ) { console.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' ); @@ -249,8 +248,6 @@ Object.assign( Vector3.prototype, { applyAxisAngle: function ( axis, angle ) { - if ( _quaternion === undefined ) _quaternion = new Quaternion(); - return this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) ); }, @@ -539,8 +536,6 @@ Object.assign( Vector3.prototype, { projectOnPlane: function ( planeNormal ) { - if ( _vector === undefined ) _vector = new Vector3(); - _vector.copy( this ).projectOnVector( planeNormal ); return this.sub( _vector ); @@ -549,8 +544,6 @@ Object.assign( Vector3.prototype, { reflect: function ( normal ) { - if ( _vector === undefined ) _vector = new Vector3(); - // reflect incident vector off plane orthogonal to normal // normal is assumed to have unit length diff --git a/src/math/Vector4.d.ts b/src/math/Vector4.d.ts index f088e2a9b03aae..1204d988de1fdc 100644 --- a/src/math/Vector4.d.ts +++ b/src/math/Vector4.d.ts @@ -4,10 +4,6 @@ import { Matrix3 } from './Matrix3'; import { BufferAttribute } from './../core/BufferAttribute'; import { Vector } from './Vector2'; -/** - * @deprecated use {@link Vector3 THREE.Vector3} instead. - */ - /** * 4D vector. * diff --git a/src/objects/LOD.js b/src/objects/LOD.js index 99ee5f85ce6539..098ec8a0db2f82 100644 --- a/src/objects/LOD.js +++ b/src/objects/LOD.js @@ -7,7 +7,8 @@ import { Object3D } from '../core/Object3D.js'; * @author mrdoob / http://mrdoob.com/ */ -var _v1, _v2; +var _v1 = new Vector3(); +var _v2 = new Vector3(); function LOD() { @@ -96,8 +97,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _v1 === undefined ) _v1 = new Vector3(); - _v1.setFromMatrixPosition( this.matrixWorld ); var distance = raycaster.ray.origin.distanceTo( _v1 ); @@ -108,13 +107,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { update: function ( camera ) { - if ( _v2 === undefined ) { - - _v1 = new Vector3(); - _v2 = new Vector3(); - - } - var levels = this.levels; if ( levels.length > 1 ) { diff --git a/src/objects/Line.js b/src/objects/Line.js index 24c3e2d2283a02..b1ee1f56cb03b7 100644 --- a/src/objects/Line.js +++ b/src/objects/Line.js @@ -11,8 +11,11 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js'; * @author mrdoob / http://mrdoob.com/ */ -var _start, _end; -var _inverseMatrix, _ray, _sphere; +var _start = new Vector3(); +var _end = new Vector3(); +var _inverseMatrix = new Matrix4(); +var _ray = new Ray(); +var _sphere = new Sphere(); function Line( geometry, material, mode ) { @@ -39,13 +42,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { computeLineDistances: function () { - if ( _end === undefined ) { - - _start = new Vector3(); - _end = new Vector3(); - - } - var geometry = this.geometry; if ( geometry.isBufferGeometry ) { @@ -97,14 +93,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _sphere === undefined ) { - - _inverseMatrix = new Matrix4(); - _ray = new Ray(); - _sphere = new Sphere(); - - } - var precision = raycaster.linePrecision; var geometry = this.geometry; diff --git a/src/objects/LineSegments.js b/src/objects/LineSegments.js index e8153527eb7ccc..6bbb7e2e962064 100644 --- a/src/objects/LineSegments.js +++ b/src/objects/LineSegments.js @@ -6,7 +6,8 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js'; * @author mrdoob / http://mrdoob.com/ */ -var _start, _end; +var _start = new Vector3(); +var _end = new Vector3(); function LineSegments( geometry, material ) { @@ -24,13 +25,6 @@ LineSegments.prototype = Object.assign( Object.create( Line.prototype ), { computeLineDistances: function () { - if ( _end === undefined ) { - - _start = new Vector3(); - _end = new Vector3(); - - } - var geometry = this.geometry; if ( geometry.isBufferGeometry ) { diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index 0d42f4cd3e3b3f..6f16a21c200141 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -17,12 +17,28 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; * @author jonobr1 / http://jonobr1.com/ */ -var _inverseMatrix, _ray, _sphere; -var _vA, _vB, _vC; -var _tempA, _tempB, _tempC; -var _morphA, _morphB, _morphC; -var _uvA, _uvB, _uvC; -var _intersectionPoint, _intersectionPointWorld; +var _inverseMatrix = new Matrix4(); +var _ray = new Ray(); +var _sphere = new Sphere(); + +var _vA = new Vector3(); +var _vB = new Vector3(); +var _vC = new Vector3(); + +var _tempA = new Vector3(); +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(); + +var _intersectionPoint = new Vector3(); +var _intersectionPointWorld = new Vector3(); function Mesh( geometry, material ) { @@ -121,33 +137,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _intersectionPointWorld === undefined ) { - - _inverseMatrix = new Matrix4(); - _ray = new Ray(); - _sphere = new Sphere(); - - _vA = new Vector3(); - _vB = new Vector3(); - _vC = new Vector3(); - - _tempA = new Vector3(); - _tempB = new Vector3(); - _tempC = new Vector3(); - - _morphA = new Vector3(); - _morphB = new Vector3(); - _morphC = new Vector3(); - - _uvA = new Vector2(); - _uvB = new Vector2(); - _uvC = new Vector2(); - - _intersectionPoint = new Vector3(); - _intersectionPointWorld = new Vector3(); - - } - var geometry = this.geometry; var material = this.material; var matrixWorld = this.matrixWorld; diff --git a/src/objects/Points.js b/src/objects/Points.js index 292834be04ee0f..63ff08036c4ce2 100644 --- a/src/objects/Points.js +++ b/src/objects/Points.js @@ -10,7 +10,10 @@ import { BufferGeometry } from '../core/BufferGeometry.js'; * @author alteredq / http://alteredqualia.com/ */ -var _inverseMatrix, _ray, _sphere; +var _inverseMatrix = new Matrix4(); +var _ray = new Ray(); +var _sphere = new Sphere(); +var _position = new Vector3(); function Points( geometry, material ) { @@ -33,15 +36,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _sphere === undefined ) { - - _inverseMatrix = new Matrix4(); - _ray = new Ray(); - _sphere = new Sphere(); - - } - - var object = this; var geometry = this.geometry; var matrixWorld = this.matrixWorld; var threshold = raycaster.params.Points.threshold; @@ -63,36 +57,6 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 ); var localThresholdSq = localThreshold * localThreshold; - var position = new Vector3(); - var intersectPoint = new Vector3(); - - function testPoint( point, index ) { - - var rayPointDistanceSq = _ray.distanceSqToPoint( point ); - - if ( rayPointDistanceSq < localThresholdSq ) { - - _ray.closestPointToPoint( point, intersectPoint ); - intersectPoint.applyMatrix4( matrixWorld ); - - var distance = raycaster.ray.origin.distanceTo( intersectPoint ); - - if ( distance < raycaster.near || distance > raycaster.far ) return; - - intersects.push( { - - distance: distance, - distanceToRay: Math.sqrt( rayPointDistanceSq ), - point: intersectPoint.clone(), - index: index, - face: null, - object: object - - } ); - - } - - } if ( geometry.isBufferGeometry ) { @@ -108,9 +72,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { var a = indices[ i ]; - position.fromArray( positions, a * 3 ); + _position.fromArray( positions, a * 3 ); - testPoint( position, a ); + testPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -118,9 +82,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 0, l = positions.length / 3; i < l; i ++ ) { - position.fromArray( positions, i * 3 ); + _position.fromArray( positions, i * 3 ); - testPoint( position, i ); + testPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -132,7 +96,7 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 0, l = vertices.length; i < l; i ++ ) { - testPoint( vertices[ i ], i ); + testPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this ); } @@ -194,4 +158,34 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), { } ); +function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) { + + var rayPointDistanceSq = _ray.distanceSqToPoint( point ); + + if ( rayPointDistanceSq < localThresholdSq ) { + + var intersectPoint = new Vector3(); + + _ray.closestPointToPoint( point, intersectPoint ); + intersectPoint.applyMatrix4( matrixWorld ); + + var distance = raycaster.ray.origin.distanceTo( intersectPoint ); + + if ( distance < raycaster.near || distance > raycaster.far ) return; + + intersects.push( { + + distance: distance, + distanceToRay: Math.sqrt( rayPointDistanceSq ), + point: intersectPoint, + index: index, + face: null, + object: object + + } ); + + } + +} + export { Points }; diff --git a/src/objects/Skeleton.js b/src/objects/Skeleton.js index 1bbab5e9afb461..7ea99fb42010b8 100644 --- a/src/objects/Skeleton.js +++ b/src/objects/Skeleton.js @@ -7,7 +7,8 @@ import { Matrix4 } from '../math/Matrix4.js'; * @author ikerr / http://verold.com */ -var _offsetMatrix, _identityMatrix; +var _offsetMatrix = new Matrix4(); +var _identityMatrix = new Matrix4(); function Skeleton( bones, boneInverses ) { @@ -117,13 +118,6 @@ Object.assign( Skeleton.prototype, { update: function () { - if ( _identityMatrix === undefined ) { - - _offsetMatrix = new Matrix4(); - _identityMatrix = new Matrix4(); - - } - var bones = this.bones; var boneInverses = this.boneInverses; var boneMatrices = this.boneMatrices; diff --git a/src/objects/Sprite.js b/src/objects/Sprite.js index 764c976060bfd8..0518effd721004 100644 --- a/src/objects/Sprite.js +++ b/src/objects/Sprite.js @@ -15,10 +15,21 @@ import { SpriteMaterial } from '../materials/SpriteMaterial.js'; var _geometry; -var _intersectPoint, _worldScale, _mvPosition; -var _alignedPosition, _rotatedPosition, _viewWorldMatrix; -var _vA, _vB, _vC; -var _uvA, _uvB, _uvC; +var _intersectPoint = new Vector3(); +var _worldScale = new Vector3(); +var _mvPosition = new Vector3(); + +var _alignedPosition = new Vector2(); +var _rotatedPosition = new Vector2(); +var _viewWorldMatrix = new Matrix4(); + +var _vA = new Vector3(); +var _vB = new Vector3(); +var _vC = new Vector3(); + +var _uvA = new Vector2(); +var _uvB = new Vector2(); +var _uvC = new Vector2(); function Sprite( material ) { @@ -60,34 +71,20 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), { raycast: function ( raycaster, intersects ) { - if ( _uvC === undefined ) { - - _intersectPoint = new Vector3(); - _worldScale = new Vector3(); - _mvPosition = new Vector3(); - - _alignedPosition = new Vector2(); - _rotatedPosition = new Vector2(); - _viewWorldMatrix = new Matrix4(); - - _vA = new Vector3(); - _vB = new Vector3(); - _vC = new Vector3(); + if ( raycaster.camera === null ) { - _uvA = new Vector2(); - _uvB = new Vector2(); - _uvC = new Vector2(); + console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' ); } _worldScale.setFromMatrixScale( this.matrixWorld ); - _viewWorldMatrix.copy( raycaster._camera.matrixWorld ); - this.modelViewMatrix.multiplyMatrices( raycaster._camera.matrixWorldInverse, this.matrixWorld ); + _viewWorldMatrix.copy( raycaster.camera.matrixWorld ); + this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld ); _mvPosition.setFromMatrixPosition( this.modelViewMatrix ); - if ( raycaster._camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { + if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) { _worldScale.multiplyScalar( - _mvPosition.z ); diff --git a/src/polyfills.js b/src/polyfills.js index 7b618faffc533e..c165a89a59bca3 100644 --- a/src/polyfills.js +++ b/src/polyfills.js @@ -55,33 +55,29 @@ if ( Object.assign === undefined ) { // Missing in IE // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign - ( function () { + Object.assign = function ( target ) { - Object.assign = function ( target ) { + 'use strict'; - 'use strict'; + if ( target === undefined || target === null ) { - if ( target === undefined || target === null ) { + throw new TypeError( 'Cannot convert undefined or null to object' ); - throw new TypeError( 'Cannot convert undefined or null to object' ); - - } - - var output = Object( target ); + } - for ( var index = 1; index < arguments.length; index ++ ) { + var output = Object( target ); - var source = arguments[ index ]; + for ( var index = 1; index < arguments.length; index ++ ) { - if ( source !== undefined && source !== null ) { + var source = arguments[ index ]; - for ( var nextKey in source ) { + if ( source !== undefined && source !== null ) { - if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) { + for ( var nextKey in source ) { - output[ nextKey ] = source[ nextKey ]; + if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) { - } + output[ nextKey ] = source[ nextKey ]; } @@ -89,10 +85,10 @@ if ( Object.assign === undefined ) { } - return output; + } - }; + return output; - } )(); + }; } diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 15f3aec61b2226..4810dd21cfe6f5 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1,5 +1,4 @@ import { - REVISION, RGBAFormat, HalfFloatType, FloatType, diff --git a/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js b/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js index a4b864851239ab..05f3c7738364e1 100644 --- a/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +++ b/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js @@ -1,7 +1,7 @@ export default /* glsl */` -#ifdef USE_CLEARCOAT_NORMALMAP +#ifdef PHYSICAL - vec3 clearCoatNormal = geometryNormal; + vec3 clearCoatNormal = geometryNormal; #endif `; diff --git a/src/renderers/shaders/ShaderChunk/common.glsl.js b/src/renderers/shaders/ShaderChunk/common.glsl.js index 58553ae8736b66..5445f66fc6051f 100644 --- a/src/renderers/shaders/ShaderChunk/common.glsl.js +++ b/src/renderers/shaders/ShaderChunk/common.glsl.js @@ -8,7 +8,7 @@ export default /* glsl */` #define EPSILON 1e-6 #define saturate(a) clamp( a, 0.0, 1.0 ) -#define whiteCompliment(a) ( 1.0 - saturate( a ) ) +#define whiteComplement(a) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } @@ -39,7 +39,9 @@ struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; +#ifdef PHYSICAL vec3 clearCoatNormal; +#endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { diff --git a/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js index 29bd79dd4af1a9..25d801a6782a1e 100644 --- a/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js @@ -1,5 +1,5 @@ export default /* glsl */` -#if defined( DITHERING ) +#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); diff --git a/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js index da654f1233687d..2217fbc5d88411 100644 --- a/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js @@ -1,5 +1,5 @@ export default /* glsl */` -#if defined( DITHERING ) +#ifdef DITHERING // based on https://www.shadertoy.com/view/MslGR8 vec3 dithering( vec3 color ) { diff --git a/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js index 24dc2fba66dde5..996a17e149d156 100644 --- a/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js @@ -3,7 +3,7 @@ export default /* glsl */` #ifdef FOG_EXP2 - float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) ); + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth ); #else diff --git a/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js b/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js index 71173489818674..5d7b2d422c3229 100644 --- a/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +++ b/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js @@ -20,14 +20,10 @@ geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = normalize( vViewPosition ); -#ifdef USE_CLEARCOAT_NORMALMAP +#ifdef PHYSICAL geometry.clearCoatNormal = clearCoatNormal; -#else - - geometry.clearCoatNormal = geometryNormal; - #endif IncidentLight directLight; diff --git a/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js b/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js index d59e7c61bd5cb3..13adcb7bb4e4ca 100644 --- a/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +++ b/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js @@ -25,9 +25,9 @@ export default /* glsl */` #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) - radiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel ); + radiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, Material_BlinnShininessExponent( material ), maxMipLevel ); - #ifndef STANDARD + #ifdef PHYSICAL clearCoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearCoatNormal, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel ); diff --git a/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js index 5dbb78621d6f0d..78f1dacc072332 100644 --- a/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js @@ -5,7 +5,7 @@ struct PhysicalMaterial { float specularRoughness; vec3 specularColor; - #ifndef STANDARD + #ifdef PHYSICAL float clearCoat; float clearCoatRoughness; #endif @@ -80,7 +80,7 @@ void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricC #endif - #ifndef STANDARD + #ifdef PHYSICAL float ccDotNL = saturate( dot( geometry.clearCoatNormal, directLight.direction ) ); diff --git a/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js b/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js index e0bed67de3de80..4e8cbc0ed4f01b 100644 --- a/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +++ b/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js @@ -33,7 +33,7 @@ export default /* glsl */` #endif -// non perturbed normal for clearcoat +// non perturbed normal for clearcoat among others vec3 geometryNormal = normal; diff --git a/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js index d1c8b22382881a..83ff4536e88a0d 100644 --- a/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js @@ -41,7 +41,7 @@ export default /* glsl */` const vec2 offset = vec2( 0.0, 1.0 ); vec2 texelSize = vec2( 1.0 ) / size; - vec2 centroidUV = floor( uv * size + 0.5 ) / size; + vec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize; float lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare ); float lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare ); diff --git a/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js index ecea9ca95ffc8c..ecdf15b7d9c08f 100644 --- a/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js @@ -1,5 +1,5 @@ export default /* glsl */` -#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP ) +#ifdef USE_UV varying vec2 vUv; diff --git a/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js b/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js index d22fc8b688e114..fd918927e9eb81 100644 --- a/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +++ b/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js @@ -1,5 +1,5 @@ export default /* glsl */` -#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP ) +#ifdef USE_UV varying vec2 vUv; uniform mat3 uvTransform; diff --git a/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js b/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js index 71007abbb60209..ca031fe1af537b 100644 --- a/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +++ b/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js @@ -1,5 +1,5 @@ export default /* glsl */` -#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP ) +#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; diff --git a/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js b/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js index 73b49fdaef6dae..627258bc96c702 100644 --- a/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js +++ b/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js @@ -7,7 +7,7 @@ uniform float roughness; uniform float metalness; uniform float opacity; -#ifndef STANDARD +#ifdef PHYSICAL uniform float clearCoat; uniform float clearCoatRoughness; #endif diff --git a/src/renderers/webgl/WebGLBufferRenderer.js b/src/renderers/webgl/WebGLBufferRenderer.js index 2978c56a2c9cf2..c630098bfa2ee6 100644 --- a/src/renderers/webgl/WebGLBufferRenderer.js +++ b/src/renderers/webgl/WebGLBufferRenderer.js @@ -22,15 +22,17 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) { function renderInstances( geometry, start, count ) { - var extension; + var extension, methodName; if ( capabilities.isWebGL2 ) { extension = gl; + methodName = 'drawArraysInstanced'; } else { extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawArraysInstancedANGLE'; if ( extension === null ) { @@ -41,7 +43,7 @@ function WebGLBufferRenderer( gl, extensions, info, capabilities ) { } - extension[ capabilities.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount ); + extension[ methodName ]( mode, start, count, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount ); diff --git a/src/renderers/webgl/WebGLGeometries.js b/src/renderers/webgl/WebGLGeometries.js index 7a888d856ab5d8..281a075b7b94b3 100644 --- a/src/renderers/webgl/WebGLGeometries.js +++ b/src/renderers/webgl/WebGLGeometries.js @@ -8,13 +8,13 @@ import { arrayMax } from '../../utils.js'; function WebGLGeometries( gl, attributes, info ) { - var geometries = {}; - var wireframeAttributes = {}; + var geometries = new WeakMap(); + var wireframeAttributes = new WeakMap(); function onGeometryDispose( event ) { var geometry = event.target; - var buffergeometry = geometries[ geometry.id ]; + var buffergeometry = geometries.get( geometry ); if ( buffergeometry.index !== null ) { @@ -30,14 +30,14 @@ function WebGLGeometries( gl, attributes, info ) { geometry.removeEventListener( 'dispose', onGeometryDispose ); - delete geometries[ geometry.id ]; + geometries.delete( geometry ); - var attribute = wireframeAttributes[ buffergeometry.id ]; + var attribute = wireframeAttributes.get( buffergeometry ); if ( attribute ) { attributes.remove( attribute ); - delete wireframeAttributes[ buffergeometry.id ]; + wireframeAttributes.delete( buffergeometry ); } @@ -49,7 +49,7 @@ function WebGLGeometries( gl, attributes, info ) { function get( object, geometry ) { - var buffergeometry = geometries[ geometry.id ]; + var buffergeometry = geometries.get( geometry ); if ( buffergeometry ) return buffergeometry; @@ -71,7 +71,7 @@ function WebGLGeometries( gl, attributes, info ) { } - geometries[ geometry.id ] = buffergeometry; + geometries.set( geometry, buffergeometry ); info.memory.geometries ++; @@ -161,19 +161,19 @@ function WebGLGeometries( gl, attributes, info ) { // - var previousAttribute = wireframeAttributes[ geometry.id ]; + var previousAttribute = wireframeAttributes.get( geometry ); if ( previousAttribute ) attributes.remove( previousAttribute ); // - wireframeAttributes[ geometry.id ] = attribute; + wireframeAttributes.set( geometry, attribute ); } function getWireframeAttribute( geometry ) { - var currentAttribute = wireframeAttributes[ geometry.id ]; + var currentAttribute = wireframeAttributes.get( geometry ); if ( currentAttribute ) { @@ -197,7 +197,7 @@ function WebGLGeometries( gl, attributes, info ) { } - return wireframeAttributes[ geometry.id ]; + return wireframeAttributes.get( geometry ); } diff --git a/src/renderers/webgl/WebGLIndexedBufferRenderer.js b/src/renderers/webgl/WebGLIndexedBufferRenderer.js index c23f2e3e1b5ce4..a3d4322f028029 100644 --- a/src/renderers/webgl/WebGLIndexedBufferRenderer.js +++ b/src/renderers/webgl/WebGLIndexedBufferRenderer.js @@ -31,15 +31,17 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { function renderInstances( geometry, start, count ) { - var extension; + var extension, methodName; if ( capabilities.isWebGL2 ) { extension = gl; + methodName = 'drawElementsInstanced'; } else { - var extension = extensions.get( 'ANGLE_instanced_arrays' ); + extension = extensions.get( 'ANGLE_instanced_arrays' ); + methodName = 'drawElementsInstancedANGLE'; if ( extension === null ) { @@ -50,7 +52,7 @@ function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { } - extension[ capabilities.isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); + extension[ methodName ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); info.update( count, mode, geometry.maxInstancedCount ); diff --git a/src/renderers/webgl/WebGLProgram.js b/src/renderers/webgl/WebGLProgram.js index e981a381c220f8..057d1cf3ecbd64 100644 --- a/src/renderers/webgl/WebGLProgram.js +++ b/src/renderers/webgl/WebGLProgram.js @@ -380,7 +380,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, '#define MAX_BONES ' + parameters.maxBones, ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', - ( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', @@ -400,6 +400,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexUvs ? '#define USE_UV' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', @@ -494,7 +495,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, '#define GAMMA_FACTOR ' + gammaFactorDefine, ( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '', - ( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '', + ( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matcap ? '#define USE_MATCAP' : '', @@ -518,6 +519,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.vertexUvs ? '#define USE_UV' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', @@ -536,7 +538,7 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters, parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '', - parameters.envMap && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', + ( ( material.extensions ? material.extensions.shaderTextureLOD : false ) || parameters.envMap ) && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', diff --git a/src/renderers/webgl/WebGLPrograms.js b/src/renderers/webgl/WebGLPrograms.js index 934e8f531587e0..a87b89f5d4b73f 100644 --- a/src/renderers/webgl/WebGLPrograms.js +++ b/src/renderers/webgl/WebGLPrograms.js @@ -31,7 +31,7 @@ function WebGLPrograms( renderer, extensions, capabilities ) { "precision", "supportsVertexTextures", "map", "mapEncoding", "matcap", "matcapEncoding", "envMap", "envMapMode", "envMapEncoding", "lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "objectSpaceNormalMap", "clearCoatNormalMap", "displacementMap", "specularMap", "roughnessMap", "metalnessMap", "gradientMap", - "alphaMap", "combine", "vertexColors", "vertexTangents", "fog", "useFog", "fogExp", + "alphaMap", "combine", "vertexColors", "vertexTangents", "fog", "useFog", "fogExp2", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", "maxMorphTargets", "maxMorphNormals", "premultipliedAlpha", @@ -169,10 +169,11 @@ function WebGLPrograms( renderer, extensions, capabilities ) { vertexTangents: ( material.normalMap && material.vertexTangents ), vertexColors: material.vertexColors, + vertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearCoatNormalMap, fog: !! fog, useFog: material.fog, - fogExp: ( fog && fog.isFogExp2 ), + fogExp2: ( fog && fog.isFogExp2 ), flatShading: material.flatShading, diff --git a/src/renderers/webgl/WebGLRenderLists.js b/src/renderers/webgl/WebGLRenderLists.js index d48262cd838bae..9f7456e22e690c 100644 --- a/src/renderers/webgl/WebGLRenderLists.js +++ b/src/renderers/webgl/WebGLRenderLists.js @@ -152,7 +152,7 @@ function WebGLRenderList() { function WebGLRenderLists() { - var lists = {}; + var lists = new WeakMap(); function onSceneDispose( event ) { @@ -160,29 +160,29 @@ function WebGLRenderLists() { scene.removeEventListener( 'dispose', onSceneDispose ); - delete lists[ scene.id ]; + lists.delete( scene ); } function get( scene, camera ) { - var cameras = lists[ scene.id ]; + var cameras = lists.get( scene ); var list; if ( cameras === undefined ) { list = new WebGLRenderList(); - lists[ scene.id ] = {}; - lists[ scene.id ][ camera.id ] = list; + lists.set( scene, new WeakMap() ); + lists.get( scene ).set( camera, list ); scene.addEventListener( 'dispose', onSceneDispose ); } else { - list = cameras[ camera.id ]; + list = cameras.get( camera ); if ( list === undefined ) { list = new WebGLRenderList(); - cameras[ camera.id ] = list; + cameras.set( camera, list ); } @@ -194,7 +194,7 @@ function WebGLRenderLists() { function dispose() { - lists = {}; + lists = new WeakMap(); } diff --git a/src/renderers/webgl/WebGLRenderStates.js b/src/renderers/webgl/WebGLRenderStates.js index b9a6af90b18cda..818cff6467bf87 100644 --- a/src/renderers/webgl/WebGLRenderStates.js +++ b/src/renderers/webgl/WebGLRenderStates.js @@ -56,7 +56,7 @@ function WebGLRenderState() { function WebGLRenderStates() { - var renderStates = {}; + var renderStates = new WeakMap(); function onSceneDispose( event ) { @@ -64,7 +64,7 @@ function WebGLRenderStates() { scene.removeEventListener( 'dispose', onSceneDispose ); - delete renderStates[ scene.id ]; + renderStates.delete( scene ); } @@ -72,24 +72,24 @@ function WebGLRenderStates() { var renderState; - if ( renderStates[ scene.id ] === undefined ) { + if ( renderStates.has( scene ) === false ) { renderState = new WebGLRenderState(); - renderStates[ scene.id ] = {}; - renderStates[ scene.id ][ camera.id ] = renderState; + renderStates.set( scene, new WeakMap() ); + renderStates.get( scene ).set( camera, renderState ); scene.addEventListener( 'dispose', onSceneDispose ); } else { - if ( renderStates[ scene.id ][ camera.id ] === undefined ) { + if ( renderStates.get( scene ).has( camera ) === false ) { renderState = new WebGLRenderState(); - renderStates[ scene.id ][ camera.id ] = renderState; + renderStates.get( scene ).set( camera, renderState ); } else { - renderState = renderStates[ scene.id ][ camera.id ]; + renderState = renderStates.get( scene ).get( camera ); } @@ -101,7 +101,7 @@ function WebGLRenderStates() { function dispose() { - renderStates = {}; + renderStates = new WeakMap(); } diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 85de4730d95176..238d51b5f99de7 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -7,7 +7,7 @@ import { _Math } from '../../math/Math.js'; function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) { - var _videoTextures = {}; + var _videoTextures = new WeakMap(); var _canvas; // @@ -189,7 +189,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( texture.isVideoTexture ) { - delete _videoTextures[ texture.id ]; + _videoTextures.delete( texture ); } @@ -357,104 +357,110 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function setTextureCube( texture, slot ) { + if ( texture.image.length !== 6 ) return; + var textureProperties = properties.get( texture ); - if ( texture.image.length === 6 ) { + if ( texture.version > 0 && textureProperties.__version !== texture.version ) { - if ( texture.version > 0 && textureProperties.__version !== texture.version ) { + initTexture( textureProperties, texture ); - initTexture( textureProperties, texture ); + state.activeTexture( _gl.TEXTURE0 + slot ); + state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture ); - state.activeTexture( _gl.TEXTURE0 + slot ); - state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture ); + _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY ); - _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY ); + var isCompressed = ( texture && texture.isCompressedTexture ); + var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); - var isCompressed = ( texture && texture.isCompressedTexture ); - var isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture ); + var cubeImage = []; - var cubeImage = []; + for ( var i = 0; i < 6; i ++ ) { - for ( var i = 0; i < 6; i ++ ) { + if ( ! isCompressed && ! isDataTexture ) { - if ( ! isCompressed && ! isDataTexture ) { + cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize ); - cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize ); + } else { - } else { + cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; - cubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ]; + } - } + } - } + var image = cubeImage[ 0 ], + supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, + glFormat = utils.convert( texture.format ), + glType = utils.convert( texture.type ), + glInternalFormat = getInternalFormat( glFormat, glType ); - var image = cubeImage[ 0 ], - supportsMips = isPowerOfTwo( image ) || capabilities.isWebGL2, - glFormat = utils.convert( texture.format ), - glType = utils.convert( texture.type ), - glInternalFormat = getInternalFormat( glFormat, glType ); + setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips ); - setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips ); + var mipmaps; - var mipmaps = texture.mipmaps; + if ( isCompressed ) { for ( var i = 0; i < 6; i ++ ) { - if ( ! isCompressed ) { + mipmaps = cubeImage[ i ].mipmaps; + + for ( var j = 0; j < mipmaps.length; j ++ ) { - if ( isDataTexture ) { + var mipmap = mipmaps[ j ]; - state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); + if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) { - for ( var j = 0; j < mipmaps.length; ++ j ) { + if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { - var mipmap = mipmaps[ j ]; - var image = mipmap.image[ i ].image; + state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); - state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data ); + } else { + + console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); } } else { - state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); + state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); - for ( var j = 0; j < mipmaps.length; ++ j ) { + } - var mipmap = mipmaps[ j ]; + } - state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); + } - } + textureProperties.__maxMipLevel = mipmaps.length - 1; - } + } else { - } else { + mipmaps = texture.mipmaps; - var mipmaps = cubeImage[ i ].mipmaps; + for ( var i = 0; i < 6; i ++ ) { - for ( var j = 0, jl = mipmaps.length; j < jl; j ++ ) { + if ( isDataTexture ) { - var mipmap = mipmaps[ j ]; + state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data ); - if ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) { + for ( var j = 0; j < mipmaps.length; j ++ ) { - if ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) { + var mipmap = mipmaps[ j ]; + var mipmapImage = mipmap.image[ i ].image; - state.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data ); + state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data ); - } else { + } - console.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' ); + } else { - } + state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] ); - } else { + for ( var j = 0; j < mipmaps.length; j ++ ) { - state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data ); + var mipmap = mipmaps[ j ]; - } + state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] ); } @@ -462,25 +468,25 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - textureProperties.__maxMipLevel = isCompressed ? mipmaps.length - 1 : mipmaps.length; + textureProperties.__maxMipLevel = mipmaps.length; - if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { + } - // We assume images for cube map have the same size. - generateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height ); + if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - } + // We assume images for cube map have the same size. + generateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height ); - textureProperties.__version = texture.version; + } - if ( texture.onUpdate ) texture.onUpdate( texture ); + textureProperties.__version = texture.version; - } else { + if ( texture.onUpdate ) texture.onUpdate( texture ); - state.activeTexture( _gl.TEXTURE0 + slot ); - state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture ); + } else { - } + state.activeTexture( _gl.TEXTURE0 + slot ); + state.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture ); } @@ -1098,14 +1104,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, function updateVideoTexture( texture ) { - var id = texture.id; var frame = info.render.frame; // Check the last frame we updated the VideoTexture - if ( _videoTextures[ id ] !== frame ) { + if ( _videoTextures.get( texture ) !== frame ) { - _videoTextures[ id ] = frame; + _videoTextures.set( texture, frame ); texture.update(); } diff --git a/test/unit/src/core/Object3D.tests.js b/test/unit/src/core/Object3D.tests.js index 82c60e819903c0..5d135b96a3ccac 100644 --- a/test/unit/src/core/Object3D.tests.js +++ b/test/unit/src/core/Object3D.tests.js @@ -416,6 +416,35 @@ export default QUnit.module( 'Core', () => { } ); + QUnit.test( "localTransformVariableInstantiation", ( assert ) => { + + var a = new Object3D(); + var b = new Object3D(); + var c = new Object3D(); + var d = new Object3D(); + + a.getWorldDirection( new Vector3() ); + a.lookAt( new Vector3( 0, - 1, 1 ) ); + + assert.ok( true, "Calling lookAt after getWorldDirection does not create errors" ); + + b.getWorldPosition( new Vector3() ); + b.lookAt( new Vector3( 0, - 1, 1 ) ); + + assert.ok( true, "Calling lookAt after getWorldPosition does not create errors" ); + + c.getWorldQuaternion( new Quaternion() ); + c.lookAt( new Vector3( 0, - 1, 1 ) ); + + assert.ok( true, "Calling lookAt after getWorldQuaternion does not create errors" ); + + d.getWorldScale( new Vector3() ); + d.lookAt( new Vector3( 0, - 1, 1 ) ); + + assert.ok( true, "Calling lookAt after getWorldScale does not create errors" ); + + } ); + QUnit.todo( "raycast", ( assert ) => { assert.ok( false, "everything's gonna be alright" ); diff --git a/utils/modularize.js b/utils/modularize.js index 443d87440be0c7..f427716f12045f 100644 --- a/utils/modularize.js +++ b/utils/modularize.js @@ -71,7 +71,6 @@ var files = [ { path: 'lines/Wireframe.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' }, { name: 'LineMaterial', path: 'lines/LineMaterial.js' } ], ignoreList: [] }, { path: 'lines/WireframeGeometry2.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' } ], ignoreList: [] }, - { path: 'loaders/ctm/CTMLoader.js', dependencies: [], ignoreList: [] }, { path: 'loaders/deprecated/LegacyGLTFLoader.js', dependencies: [], ignoreList: [ 'AnimationMixer' ] }, { path: 'loaders/deprecated/LegacyJSONLoader.js', dependencies: [], ignoreList: [ 'ObjectLoader' ] }, { path: 'loaders/3MFLoader.js', dependencies: [], ignoreList: [] }, diff --git a/utils/packLDrawModel.js b/utils/packLDrawModel.js index fa3009e7b6b9f4..534c534ca5c179 100644 --- a/utils/packLDrawModel.js +++ b/utils/packLDrawModel.js @@ -1,4 +1,4 @@ -/* +/** * @author yomboprime / https://github.com/yomboprime/ * * LDraw object packer