diff --git a/build/ros3d.cjs.js b/build/ros3d.cjs.js index b29f9eda..09effefd 100644 --- a/build/ros3d.cjs.js +++ b/build/ros3d.cjs.js @@ -163,8 +163,6 @@ Object.assign( EventDispatcher.prototype, { }, dispatchEvent: function ( event ) { - var this$1 = this; - if ( this._listeners === undefined ) { return; } @@ -179,7 +177,7 @@ Object.assign( EventDispatcher.prototype, { for ( var i = 0, l = array.length; i < l; i ++ ) { - array[ i ].call( this$1, event ); + array[ i ].call( this, event ); } @@ -1413,8 +1411,6 @@ Object.assign( Matrix4.prototype, { var v1 = new Vector3(); return function applyToBufferAttribute( attribute ) { - var this$1 = this; - for ( var i = 0, l = attribute.count; i < l; i ++ ) { @@ -1422,7 +1418,7 @@ Object.assign( Matrix4.prototype, { v1.y = attribute.getY( i ); v1.z = attribute.getZ( i ); - v1.applyMatrix4( this$1 ); + v1.applyMatrix4( this ); attribute.setXYZ( i, v1.x, v1.y, v1.z ); @@ -1844,14 +1840,12 @@ Object.assign( Matrix4.prototype, { }, fromArray: function ( array, offset ) { - var this$1 = this; - if ( offset === undefined ) { offset = 0; } for ( var i = 0; i < 16; i ++ ) { - this$1.elements[ i ] = array[ i + offset ]; + this.elements[ i ] = array[ i + offset ]; } @@ -3317,8 +3311,6 @@ Object.assign( Matrix3.prototype, { var v1 = new Vector3(); return function applyToBufferAttribute( attribute ) { - var this$1 = this; - for ( var i = 0, l = attribute.count; i < l; i ++ ) { @@ -3326,7 +3318,7 @@ Object.assign( Matrix3.prototype, { v1.y = attribute.getY( i ); v1.z = attribute.getZ( i ); - v1.applyMatrix3( this$1 ); + v1.applyMatrix3( this ); attribute.setXYZ( i, v1.x, v1.y, v1.z ); @@ -3570,14 +3562,12 @@ Object.assign( Matrix3.prototype, { }, fromArray: function ( array, offset ) { - var this$1 = this; - if ( offset === undefined ) { offset = 0; } for ( var i = 0; i < 9; i ++ ) { - this$1.elements[ i ] = array[ i + offset ]; + this.elements[ i ] = array[ i + offset ]; } @@ -5249,8 +5239,6 @@ function parseUniform( activeInfo, addr, container ) { // Root Container function WebGLUniforms( gl, program, renderer ) { - var this$1 = this; - UniformContainer.call( this ); @@ -5264,7 +5252,7 @@ function WebGLUniforms( gl, program, renderer ) { path = info.name, addr = gl.getUniformLocation( program, path ); - parseUniform( info, addr, this$1 ); + parseUniform( info, addr, this ); } @@ -6031,14 +6019,12 @@ var UniformsLib = { var UniformsUtils = { merge: function ( uniforms ) { - var this$1 = this; - var merged = {}; for ( var u = 0; u < uniforms.length; u ++ ) { - var tmp = this$1.clone( uniforms[ u ] ); + var tmp = this.clone( uniforms[ u ] ); for ( var p in tmp ) { @@ -6680,14 +6666,12 @@ Object.assign( Box2.prototype, { }, setFromPoints: function ( points ) { - var this$1 = this; - this.makeEmpty(); for ( var i = 0, il = points.length; i < il; i ++ ) { - this$1.expandByPoint( points[ i ] ); + this.expandByPoint( points[ i ] ); } @@ -7718,8 +7702,6 @@ Object.assign( Material.prototype, EventDispatcher.prototype, { onBeforeCompile: function () {}, setValues: function ( values ) { - var this$1 = this; - if ( values === undefined ) { return; } @@ -7737,17 +7719,17 @@ Object.assign( Material.prototype, EventDispatcher.prototype, { // for backward compatability if shading is set in the constructor if ( key === 'shading' ) { - console.warn( 'THREE.' + this$1.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); - this$1.flatShading = ( newValue === FlatShading ) ? true : false; + console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + this.flatShading = ( newValue === FlatShading ) ? true : false; continue; } - var currentValue = this$1[ key ]; + var currentValue = this[ key ]; if ( currentValue === undefined ) { - console.warn( "THREE." + this$1.type + ": '" + key + "' is not a property of this material." ); + console.warn( "THREE." + this.type + ": '" + key + "' is not a property of this material." ); continue; } @@ -7763,11 +7745,11 @@ Object.assign( Material.prototype, EventDispatcher.prototype, { } else if ( key === 'overdraw' ) { // ensure overdraw is backwards-compatible with legacy boolean type - this$1[ key ] = Number( newValue ); + this[ key ] = Number( newValue ); } else { - this$1[ key ] = newValue; + this[ key ] = newValue; } @@ -8259,14 +8241,12 @@ Object.assign( Box3.prototype, { }, setFromPoints: function ( points ) { - var this$1 = this; - this.makeEmpty(); for ( var i = 0, il = points.length; i < il; i ++ ) { - this$1.expandByPoint( points[ i ] ); + this.expandByPoint( points[ i ] ); } @@ -10541,14 +10521,13 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { add: function ( object ) { var arguments$1 = arguments; - var this$1 = this; if ( arguments.length > 1 ) { for ( var i = 0; i < arguments.length; i ++ ) { - this$1.add( arguments$1[ i ] ); + this.add( arguments$1[ i ] ); } @@ -10588,14 +10567,13 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { remove: function ( object ) { var arguments$1 = arguments; - var this$1 = this; if ( arguments.length > 1 ) { for ( var i = 0; i < arguments.length; i ++ ) { - this$1.remove( arguments$1[ i ] ); + this.remove( arguments$1[ i ] ); } @@ -10632,14 +10610,12 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }, getObjectByProperty: function ( name, value ) { - var this$1 = this; - if ( this[ name ] === value ) { return this; } for ( var i = 0, l = this.children.length; i < l; i ++ ) { - var child = this$1.children[ i ]; + var child = this.children[ i ]; var object = child.getObjectByProperty( name, value ); if ( object !== undefined ) { @@ -10823,8 +10799,6 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }, toJSON: function ( meta ) { - var this$1 = this; - // meta is a string when called from JSON.stringify var isRootObject = ( meta === undefined || typeof meta === 'string' ); @@ -10895,7 +10869,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { for ( var i = 0, l = this.material.length; i < l; i ++ ) { - uuids.push( serialize( meta.materials, this$1.material[ i ] ) ); + uuids.push( serialize( meta.materials, this.material[ i ] ) ); } @@ -10917,7 +10891,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { for ( var i = 0; i < this.children.length; i ++ ) { - object.children.push( this$1.children[ i ].toJSON( meta ).object ); + object.children.push( this.children[ i ].toJSON( meta ).object ); } @@ -10967,8 +10941,6 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }, copy: function ( source, recursive ) { - var this$1 = this; - if ( recursive === undefined ) { recursive = true; } @@ -11002,7 +10974,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { for ( var i = 0; i < source.children.length; i ++ ) { var child = source.children[ i ]; - this$1.add( child.clone() ); + this.add( child.clone() ); } @@ -11250,8 +11222,6 @@ Object.assign( Face3.prototype, { }, copy: function ( source ) { - var this$1 = this; - this.a = source.a; this.b = source.b; @@ -11264,13 +11234,13 @@ Object.assign( Face3.prototype, { for ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) { - this$1.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); + this.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); } for ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) { - this$1.vertexColors[ i ] = source.vertexColors[ i ].clone(); + this.vertexColors[ i ] = source.vertexColors[ i ].clone(); } @@ -11333,21 +11303,19 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { isGeometry: true, applyMatrix: function ( matrix ) { - var this$1 = this; - var normalMatrix = new Matrix3().getNormalMatrix( matrix ); for ( var i = 0, il = this.vertices.length; i < il; i ++ ) { - var vertex = this$1.vertices[ i ]; + var vertex = this.vertices[ i ]; vertex.applyMatrix4( matrix ); } for ( var i = 0, il = this.faces.length; i < il; i ++ ) { - var face = this$1.faces[ i ]; + var face = this.faces[ i ]; face.normal.applyMatrix3( normalMatrix ).normalize(); for ( var j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) { @@ -11658,18 +11626,16 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeFaceNormals: function () { - var this$1 = this; - var cb = new Vector3(), ab = new Vector3(); for ( var f = 0, fl = this.faces.length; f < fl; f ++ ) { - var face = this$1.faces[ f ]; + var face = this.faces[ f ]; - var vA = this$1.vertices[ face.a ]; - var vB = this$1.vertices[ face.b ]; - var vC = this$1.vertices[ face.c ]; + var vA = this.vertices[ face.a ]; + var vB = this.vertices[ face.b ]; + var vC = this.vertices[ face.c ]; cb.subVectors( vC, vB ); ab.subVectors( vA, vB ); @@ -11684,8 +11650,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeVertexNormals: function ( areaWeighted ) { - var this$1 = this; - if ( areaWeighted === undefined ) { areaWeighted = true; } @@ -11709,11 +11673,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; - vA = this$1.vertices[ face.a ]; - vB = this$1.vertices[ face.b ]; - vC = this$1.vertices[ face.c ]; + vA = this.vertices[ face.a ]; + vB = this.vertices[ face.b ]; + vC = this.vertices[ face.c ]; cb.subVectors( vC, vB ); ab.subVectors( vA, vB ); @@ -11731,7 +11695,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; vertices[ face.a ].add( face.normal ); vertices[ face.b ].add( face.normal ); @@ -11749,7 +11713,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; var vertexNormals = face.vertexNormals; @@ -11778,8 +11742,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeFlatVertexNormals: function () { - var this$1 = this; - var f, fl, face; @@ -11787,7 +11749,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; var vertexNormals = face.vertexNormals; @@ -11816,8 +11778,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeMorphNormals: function () { - var this$1 = this; - var i, il, f, fl, face; @@ -11827,7 +11787,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; if ( ! face.__originalFaceNormal ) { @@ -11866,14 +11826,14 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { // create on first access - if ( ! this$1.morphNormals[ i ] ) { + if ( ! this.morphNormals[ i ] ) { - this$1.morphNormals[ i ] = {}; - this$1.morphNormals[ i ].faceNormals = []; - this$1.morphNormals[ i ].vertexNormals = []; + this.morphNormals[ i ] = {}; + this.morphNormals[ i ].faceNormals = []; + this.morphNormals[ i ].vertexNormals = []; - var dstNormalsFace = this$1.morphNormals[ i ].faceNormals; - var dstNormalsVertex = this$1.morphNormals[ i ].vertexNormals; + var dstNormalsFace = this.morphNormals[ i ].faceNormals; + var dstNormalsVertex = this.morphNormals[ i ].vertexNormals; var faceNormal, vertexNormals; @@ -11889,11 +11849,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - var morphNormals = this$1.morphNormals[ i ]; + var morphNormals = this.morphNormals[ i ]; // set vertices to morph target - tmpGeo.vertices = this$1.morphTargets[ i ].vertices; + tmpGeo.vertices = this.morphTargets[ i ].vertices; // compute morph normals @@ -11906,7 +11866,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; faceNormal = morphNormals.faceNormals[ f ]; vertexNormals = morphNormals.vertexNormals[ f ]; @@ -11925,7 +11885,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; face.normal = face.__originalFaceNormal; face.vertexNormals = face.__originalVertexNormals; @@ -11935,8 +11895,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeLineDistances: function () { - var this$1 = this; - var d = 0; var vertices = this.vertices; @@ -11949,7 +11907,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.lineDistances[ i ] = d; + this.lineDistances[ i ] = d; } @@ -12121,8 +12079,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { */ mergeVertices: function () { - var this$1 = this; - var verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique) var unique = [], changes = []; @@ -12135,13 +12091,13 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = this.vertices.length; i < il; i ++ ) { - v = this$1.vertices[ i ]; + v = this.vertices[ i ]; key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision ); if ( verticesMap[ key ] === undefined ) { verticesMap[ key ] = i; - unique.push( this$1.vertices[ i ] ); + unique.push( this.vertices[ i ] ); changes[ i ] = unique.length - 1; } else { @@ -12160,7 +12116,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = this.faces.length; i < il; i ++ ) { - face = this$1.faces[ i ]; + face = this.faces[ i ]; face.a = changes[ face.a ]; face.b = changes[ face.b ]; @@ -12187,11 +12143,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { var idx = faceIndicesToRemove[ i ]; - this$1.faces.splice( idx, 1 ); + this.faces.splice( idx, 1 ); for ( j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) { - this$1.faceVertexUvs[ j ].splice( idx, 1 ); + this.faceVertexUvs[ j ].splice( idx, 1 ); } @@ -12206,15 +12162,13 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, setFromPoints: function ( points ) { - var this$1 = this; - this.vertices = []; for ( var i = 0, l = points.length; i < l; i ++ ) { var point = points[ i ]; - this$1.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) ); + this.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) ); } @@ -12270,8 +12224,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, toJSON: function () { - var this$1 = this; - var data = { metadata: { @@ -12305,7 +12257,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( var i = 0; i < this.vertices.length; i ++ ) { - var vertex = this$1.vertices[ i ]; + var vertex = this.vertices[ i ]; vertices.push( vertex.x, vertex.y, vertex.z ); } @@ -12320,11 +12272,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( var i = 0; i < this.faces.length; i ++ ) { - var face = this$1.faces[ i ]; + var face = this.faces[ i ]; var hasMaterial = true; var hasFaceUv = false; // deprecated - var hasFaceVertexUv = this$1.faceVertexUvs[ 0 ][ i ] !== undefined; + var hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined; var hasFaceNormal = face.normal.length() > 0; var hasFaceVertexNormal = face.vertexNormals.length > 0; var hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1; @@ -12347,7 +12299,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { if ( hasFaceVertexUv ) { - var faceVertexUvs = this$1.faceVertexUvs[ 0 ][ i ]; + var faceVertexUvs = this.faceVertexUvs[ 0 ][ i ]; faces.push( getUvIndex( faceVertexUvs[ 0 ] ), @@ -12495,8 +12447,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, copy: function ( source ) { - var this$1 = this; - var i, il, j, jl, k, kl; @@ -12524,7 +12474,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = vertices.length; i < il; i ++ ) { - this$1.vertices.push( vertices[ i ].clone() ); + this.vertices.push( vertices[ i ].clone() ); } @@ -12534,7 +12484,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = colors.length; i < il; i ++ ) { - this$1.colors.push( colors[ i ].clone() ); + this.colors.push( colors[ i ].clone() ); } @@ -12544,7 +12494,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = faces.length; i < il; i ++ ) { - this$1.faces.push( faces[ i ].clone() ); + this.faces.push( faces[ i ].clone() ); } @@ -12554,9 +12504,9 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { var faceVertexUvs = source.faceVertexUvs[ i ]; - if ( this$1.faceVertexUvs[ i ] === undefined ) { + if ( this.faceVertexUvs[ i ] === undefined ) { - this$1.faceVertexUvs[ i ] = []; + this.faceVertexUvs[ i ] = []; } @@ -12572,7 +12522,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.faceVertexUvs[ i ].push( uvsCopy ); + this.faceVertexUvs[ i ].push( uvsCopy ); } @@ -12615,7 +12565,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.morphTargets.push( morphTarget ); + this.morphTargets.push( morphTarget ); } @@ -12662,7 +12612,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.morphNormals.push( morphNormal ); + this.morphNormals.push( morphNormal ); } @@ -12672,7 +12622,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = skinWeights.length; i < il; i ++ ) { - this$1.skinWeights.push( skinWeights[ i ].clone() ); + this.skinWeights.push( skinWeights[ i ].clone() ); } @@ -12682,7 +12632,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = skinIndices.length; i < il; i ++ ) { - this$1.skinIndices.push( skinIndices[ i ].clone() ); + this.skinIndices.push( skinIndices[ i ].clone() ); } @@ -12692,7 +12642,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = lineDistances.length; i < il; i ++ ) { - this$1.lineDistances.push( lineDistances[ i ] ); + this.lineDistances.push( lineDistances[ i ] ); } @@ -12816,15 +12766,13 @@ Object.assign( BufferAttribute.prototype, { }, copyAt: function ( index1, attribute, index2 ) { - var this$1 = this; - index1 *= this.itemSize; index2 *= attribute.itemSize; for ( var i = 0, l = this.itemSize; i < l; i ++ ) { - this$1.array[ index1 + i ] = attribute.array[ index2 + i ]; + this.array[ index1 + i ] = attribute.array[ index2 + i ]; } @@ -13250,8 +13198,6 @@ Object.assign( DirectGeometry.prototype, { }, fromGeometry: function ( geometry ) { - var this$1 = this; - var faces = geometry.faces; var vertices = geometry.vertices; @@ -13314,19 +13260,19 @@ Object.assign( DirectGeometry.prototype, { var face = faces[ i ]; - this$1.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); + this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); var vertexNormals = face.vertexNormals; if ( vertexNormals.length === 3 ) { - this$1.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); + this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); } else { var normal = face.normal; - this$1.normals.push( normal, normal, normal ); + this.normals.push( normal, normal, normal ); } @@ -13334,13 +13280,13 @@ Object.assign( DirectGeometry.prototype, { if ( vertexColors.length === 3 ) { - this$1.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); + this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); } else { var color = face.color; - this$1.colors.push( color, color, color ); + this.colors.push( color, color, color ); } @@ -13350,13 +13296,13 @@ Object.assign( DirectGeometry.prototype, { if ( vertexUvs !== undefined ) { - this$1.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); } else { console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i ); - this$1.uvs.push( new Vector2(), new Vector2(), new Vector2() ); + this.uvs.push( new Vector2(), new Vector2(), new Vector2() ); } @@ -13368,13 +13314,13 @@ Object.assign( DirectGeometry.prototype, { if ( vertexUvs !== undefined ) { - this$1.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); } else { console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i ); - this$1.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); + this.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); } @@ -13402,13 +13348,13 @@ Object.assign( DirectGeometry.prototype, { if ( hasSkinIndices ) { - this$1.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); + this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); } if ( hasSkinWeights ) { - this$1.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); + this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); } @@ -13925,8 +13871,6 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { }, fromDirectGeometry: function ( geometry ) { - var this$1 = this; - var positions = new Float32Array( geometry.vertices.length * 3 ); this.addAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) ); @@ -13988,7 +13932,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { } - this$1.morphAttributes[ name ] = array; + this.morphAttributes[ name ] = array; } @@ -14453,8 +14397,6 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { }, copy: function ( source ) { - var this$1 = this; - var name, i, l; @@ -14488,7 +14430,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { for ( name in attributes ) { var attribute = attributes[ name ]; - this$1.addAttribute( name, attribute.clone() ); + this.addAttribute( name, attribute.clone() ); } @@ -14507,7 +14449,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { } - this$1.morphAttributes[ name ] = array; + this.morphAttributes[ name ] = array; } @@ -14518,7 +14460,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { for ( i = 0, l = groups.length; i < l; i ++ ) { var group = groups[ i ]; - this$1.addGroup( group.start, group.count, group.materialIndex ); + this.addGroup( group.start, group.count, group.materialIndex ); } @@ -16075,8 +16017,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { }, updateMorphTargets: function () { - var this$1 = this; - var geometry = this.geometry; var m, ml, name; @@ -16099,8 +16039,8 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { name = morphAttribute[ m ].name || String( m ); - this$1.morphTargetInfluences.push( 0 ); - this$1.morphTargetDictionary[ name ] = m; + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; } @@ -16121,8 +16061,8 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { name = morphTargets[ m ].name || String( m ); - this$1.morphTargetInfluences.push( 0 ); - this$1.morphTargetDictionary[ name ] = m; + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; } @@ -16230,8 +16170,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { } return function raycast( raycaster, intersects ) { - var this$1 = this; - var geometry = this.geometry; var material = this.material; @@ -16281,7 +16219,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { b = index.getX( i + 1 ); c = index.getX( i + 2 ); - intersection = checkBufferGeometryIntersection( this$1, raycaster, ray, position, uv, a, b, c ); + intersection = checkBufferGeometryIntersection( this, raycaster, ray, position, uv, a, b, c ); if ( intersection ) { @@ -16302,7 +16240,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { b = i + 1; c = i + 2; - intersection = checkBufferGeometryIntersection( this$1, raycaster, ray, position, uv, a, b, c ); + intersection = checkBufferGeometryIntersection( this, raycaster, ray, position, uv, a, b, c ); if ( intersection ) { @@ -16341,7 +16279,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( faceMaterial.morphTargets === true ) { var morphTargets = geometry.morphTargets; - var morphInfluences = this$1.morphTargetInfluences; + var morphInfluences = this.morphTargetInfluences; vA.set( 0, 0, 0 ); vB.set( 0, 0, 0 ); @@ -16371,7 +16309,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { } - intersection = checkIntersection( this$1, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint ); + intersection = checkIntersection( this, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint ); if ( intersection ) { @@ -23908,8 +23846,6 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { isLensFlare: true, copy: function ( source ) { - var this$1 = this; - Object3D.prototype.copy.call( this, source ); @@ -23918,7 +23854,7 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 0, l = source.lensFlares.length; i < l; i ++ ) { - this$1.lensFlares.push( source.lensFlares[ i ] ); + this.lensFlares.push( source.lensFlares[ i ] ); } @@ -23956,8 +23892,6 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { */ updateLensFlares: function () { - var this$1 = this; - var f, fl = this.lensFlares.length; var flare; @@ -23966,10 +23900,10 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( f = 0; f < fl; f ++ ) { - flare = this$1.lensFlares[ f ]; + flare = this.lensFlares[ f ]; - flare.x = this$1.positionScreen.x + vecX * flare.distance; - flare.y = this$1.positionScreen.y + vecY * flare.distance; + flare.x = this.positionScreen.x + vecX * flare.distance; + flare.y = this.positionScreen.y + vecY * flare.distance; flare.wantedRotation = flare.x * Math.PI * 0.25; flare.rotation += ( flare.wantedRotation - flare.rotation ) * 0.25; @@ -24116,8 +24050,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { constructor: LOD, copy: function ( source ) { - var this$1 = this; - Object3D.prototype.copy.call( this, source, false ); @@ -24127,7 +24059,7 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { var level = levels[ i ]; - this$1.addLevel( level.object.clone(), level.distance ); + this.addLevel( level.object.clone(), level.distance ); } @@ -24271,8 +24203,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { */ function Skeleton( bones, boneInverses ) { - var this$1 = this; - // copy the bone array @@ -24301,7 +24231,7 @@ function Skeleton( bones, boneInverses ) { for ( var i = 0, il = this.bones.length; i < il; i ++ ) { - this$1.boneInverses.push( new Matrix4() ); + this.boneInverses.push( new Matrix4() ); } @@ -24314,8 +24244,6 @@ function Skeleton( bones, boneInverses ) { Object.assign( Skeleton.prototype, { calculateInverses: function () { - var this$1 = this; - this.boneInverses = []; @@ -24323,21 +24251,19 @@ Object.assign( Skeleton.prototype, { var inverse = new Matrix4(); - if ( this$1.bones[ i ] ) { + if ( this.bones[ i ] ) { - inverse.getInverse( this$1.bones[ i ].matrixWorld ); + inverse.getInverse( this.bones[ i ].matrixWorld ); } - this$1.boneInverses.push( inverse ); + this.boneInverses.push( inverse ); } }, pose: function () { - var this$1 = this; - var bone, i, il; @@ -24345,11 +24271,11 @@ Object.assign( Skeleton.prototype, { for ( i = 0, il = this.bones.length; i < il; i ++ ) { - bone = this$1.bones[ i ]; + bone = this.bones[ i ]; if ( bone ) { - bone.matrixWorld.getInverse( this$1.boneInverses[ i ] ); + bone.matrixWorld.getInverse( this.boneInverses[ i ] ); } @@ -24359,7 +24285,7 @@ Object.assign( Skeleton.prototype, { for ( i = 0, il = this.bones.length; i < il; i ++ ) { - bone = this$1.bones[ i ]; + bone = this.bones[ i ]; if ( bone ) { @@ -24479,8 +24405,6 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { isSkinnedMesh: true, initBones: function () { - var this$1 = this; - var bones = [], bone, gbone; var i, il; @@ -24491,7 +24415,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { for ( i = 0, il = this.geometry.bones.length; i < il; i ++ ) { - gbone = this$1.geometry.bones[ i ]; + gbone = this.geometry.bones[ i ]; // create new 'Bone' object @@ -24511,7 +24435,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { for ( i = 0, il = this.geometry.bones.length; i < il; i ++ ) { - gbone = this$1.geometry.bones[ i ]; + gbone = this.geometry.bones[ i ]; if ( ( gbone.parent !== - 1 ) && ( gbone.parent !== null ) && ( bones[ gbone.parent ] !== undefined ) ) { @@ -24523,7 +24447,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { // topmost bone, immediate child of the skinned mesh - this$1.add( bones[ i ] ); + this.add( bones[ i ] ); } @@ -24566,8 +24490,6 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { }, normalizeSkinWeights: function () { - var this$1 = this; - var scale, i; @@ -24575,7 +24497,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { for ( i = 0; i < this.geometry.skinWeights.length; i ++ ) { - var sw = this$1.geometry.skinWeights[ i ]; + var sw = this.geometry.skinWeights[ i ]; scale = 1.0 / sw.manhattanLength(); @@ -24738,8 +24660,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { var sphere = new Sphere(); return function raycast( raycaster, intersects ) { - var this$1 = this; - var precision = raycaster.linePrecision; var precisionSq = precision * precision; @@ -24789,7 +24709,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( distSq > precisionSq ) { continue; } - interRay.applyMatrix4( this$1.matrixWorld ); //Move back to world space for distance calculation + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation var distance = raycaster.ray.origin.distanceTo( interRay ); @@ -24800,11 +24720,11 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this$1.matrixWorld ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), index: i, face: null, faceIndex: null, - object: this$1 + object: this } ); @@ -24821,7 +24741,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( distSq > precisionSq ) { continue; } - interRay.applyMatrix4( this$1.matrixWorld ); //Move back to world space for distance calculation + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation var distance = raycaster.ray.origin.distanceTo( interRay ); @@ -24832,11 +24752,11 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this$1.matrixWorld ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), index: i, face: null, faceIndex: null, - object: this$1 + object: this } ); @@ -24855,7 +24775,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( distSq > precisionSq ) { continue; } - interRay.applyMatrix4( this$1.matrixWorld ); //Move back to world space for distance calculation + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation var distance = raycaster.ray.origin.distanceTo( interRay ); @@ -24866,11 +24786,11 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this$1.matrixWorld ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), index: i, face: null, faceIndex: null, - object: this$1 + object: this } ); @@ -27465,8 +27385,6 @@ ExtrudeBufferGeometry.prototype.getArrays = function () { }; ExtrudeBufferGeometry.prototype.addShapeList = function ( shapes, options ) { - var this$1 = this; - var sl = shapes.length; options.arrays = this.getArrays(); @@ -27474,7 +27392,7 @@ ExtrudeBufferGeometry.prototype.addShapeList = function ( shapes, options ) { for ( var s = 0; s < sl; s ++ ) { var shape = shapes[ s ]; - this$1.addShape( shape, options ); + this.addShape( shape, options ); } @@ -28754,8 +28672,6 @@ ShapeGeometry.prototype.constructor = ShapeGeometry; // ShapeBufferGeometry function ShapeBufferGeometry( shapes, curveSegments ) { - var this$1 = this; - BufferGeometry.call( this ); @@ -28792,7 +28708,7 @@ function ShapeBufferGeometry( shapes, curveSegments ) { addShape( shapes[ i ] ); - this$1.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support + this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support groupStart += groupCount; groupCount = 0; @@ -30402,8 +30318,6 @@ function FileLoader( manager ) { Object.assign( FileLoader.prototype, { load: function ( url, onLoad, onProgress, onError ) { - var this$1 = this; - if ( url === undefined ) { url = ''; } @@ -30643,9 +30557,9 @@ Object.assign( FileLoader.prototype, { if ( request.overrideMimeType ) { request.overrideMimeType( this.mimeType !== undefined ? this.mimeType : 'text/plain' ); } - for ( var header in this$1.requestHeader ) { + for ( var header in this.requestHeader ) { - request.setRequestHeader( header, this$1.requestHeader[ header ] ); + request.setRequestHeader( header, this.requestHeader[ header ] ); } @@ -31789,8 +31703,6 @@ function Interpolant( parameterPositions, sampleValues, sampleSize, resultBuffer Object.assign( Interpolant.prototype, { evaluate: function ( t ) { - var this$1 = this; - var pp = this.parameterPositions, i1 = this._cachedIndex, @@ -31821,8 +31733,8 @@ Object.assign( Interpolant.prototype, { // after end i1 = pp.length; - this$1._cachedIndex = i1; - return this$1.afterEnd_( i1 - 1, t, t0 ); + this._cachedIndex = i1; + return this.afterEnd_( i1 - 1, t, t0 ); } @@ -31869,8 +31781,8 @@ Object.assign( Interpolant.prototype, { // before start - this$1._cachedIndex = 0; - return this$1.beforeStart_( 0, t, t1 ); + this._cachedIndex = 0; + return this.beforeStart_( 0, t, t1 ); } @@ -32404,8 +32316,6 @@ KeyframeTrackPrototype = { // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable validate: function () { - var this$1 = this; - var valid = true; @@ -32437,7 +32347,7 @@ KeyframeTrackPrototype = { if ( typeof currTime === 'number' && isNaN( currTime ) ) { - console.error( 'THREE.KeyframeTrackPrototype: Time is not a valid number.', this$1, i, currTime ); + console.error( 'THREE.KeyframeTrackPrototype: Time is not a valid number.', this, i, currTime ); valid = false; break; @@ -32445,7 +32355,7 @@ KeyframeTrackPrototype = { if ( prevTime !== null && prevTime > currTime ) { - console.error( 'THREE.KeyframeTrackPrototype: Out of order keys.', this$1, i, currTime, prevTime ); + console.error( 'THREE.KeyframeTrackPrototype: Out of order keys.', this, i, currTime, prevTime ); valid = false; break; @@ -32465,7 +32375,7 @@ KeyframeTrackPrototype = { if ( isNaN( value ) ) { - console.error( 'THREE.KeyframeTrackPrototype: Value is not a valid number.', this$1, i, value ); + console.error( 'THREE.KeyframeTrackPrototype: Value is not a valid number.', this, i, value ); valid = false; break; @@ -33279,14 +33189,12 @@ Object.assign( AnimationClip, { Object.assign( AnimationClip.prototype, { resetDuration: function () { - var this$1 = this; - var tracks = this.tracks, duration = 0; for ( var i = 0, n = tracks.length; i !== n; ++ i ) { - var track = this$1.tracks[ i ]; + var track = this.tracks[ i ]; duration = Math.max( duration, track.times[ track.times.length - 1 ] ); @@ -33297,12 +33205,10 @@ Object.assign( AnimationClip.prototype, { }, trim: function () { - var this$1 = this; - for ( var i = 0; i < this.tracks.length; i ++ ) { - this$1.tracks[ i ].trim( 0, this$1.duration ); + this.tracks[ i ].trim( 0, this.duration ); } @@ -33311,12 +33217,10 @@ Object.assign( AnimationClip.prototype, { }, optimize: function () { - var this$1 = this; - for ( var i = 0; i < this.tracks.length; i ++ ) { - this$1.tracks[ i ].optimize(); + this.tracks[ i ].optimize(); } @@ -33649,14 +33553,12 @@ Object.assign( Loader.prototype, { }, initMaterials: function ( materials, texturePath, crossOrigin ) { - var this$1 = this; - var array = []; for ( var i = 0; i < materials.length; ++ i ) { - array[ i ] = this$1.createMaterial( materials[ i ], texturePath, crossOrigin ); + array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin ); } @@ -34583,8 +34485,6 @@ Object.assign( ObjectLoader.prototype, { }, parseGeometries: function ( json ) { - var this$1 = this; - var geometries = {}; @@ -34774,7 +34674,7 @@ Object.assign( ObjectLoader.prototype, { case 'Geometry': - geometry = geometryLoader.parse( data, this$1.texturePath ).geometry; + geometry = geometryLoader.parse( data, this.texturePath ).geometry; break; @@ -34975,8 +34875,6 @@ Object.assign( ObjectLoader.prototype, { var matrix = new Matrix4(); return function parseObject( data, geometries, materials ) { - var this$1 = this; - var object; @@ -35222,7 +35120,7 @@ Object.assign( ObjectLoader.prototype, { for ( var i = 0; i < children.length; i ++ ) { - object.add( this$1.parseObject( children[ i ], geometries, materials ) ); + object.add( this.parseObject( children[ i ], geometries, materials ) ); } @@ -35429,8 +35327,6 @@ Object.assign( Curve.prototype, { // Get sequence of points using getPoint( t ) getPoints: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = 5; } @@ -35438,7 +35334,7 @@ Object.assign( Curve.prototype, { for ( var d = 0; d <= divisions; d ++ ) { - points.push( this$1.getPoint( d / divisions ) ); + points.push( this.getPoint( d / divisions ) ); } @@ -35449,8 +35345,6 @@ Object.assign( Curve.prototype, { // Get sequence of points using getPointAt( u ) getSpacedPoints: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = 5; } @@ -35458,7 +35352,7 @@ Object.assign( Curve.prototype, { for ( var d = 0; d <= divisions; d ++ ) { - points.push( this$1.getPointAt( d / divisions ) ); + points.push( this.getPointAt( d / divisions ) ); } @@ -35478,8 +35372,6 @@ Object.assign( Curve.prototype, { // Get list of cumulative segment lengths getLengths: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = this.arcLengthDivisions; } @@ -35501,7 +35393,7 @@ Object.assign( Curve.prototype, { for ( p = 1; p <= divisions; p ++ ) { - current = this$1.getPoint( p / divisions ); + current = this.getPoint( p / divisions ); sum += current.distanceTo( last ); cache.push( sum ); last = current; @@ -35629,8 +35521,6 @@ Object.assign( Curve.prototype, { }, computeFrenetFrames: function ( segments, closed ) { - var this$1 = this; - // see http://www.cs.indiana.edu/pub/techreports/TR425.pdf @@ -35651,7 +35541,7 @@ Object.assign( Curve.prototype, { u = i / segments; - tangents[ i ] = this$1.getTangentAt( u ); + tangents[ i ] = this.getTangentAt( u ); tangents[ i ].normalize(); } @@ -35880,8 +35770,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { // 4. Return curve.getPointAt(t') getPoint: function ( t ) { - var this$1 = this; - var d = t * this.getLength(); var curveLengths = this.getCurveLengths(); @@ -35894,7 +35782,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { if ( curveLengths[ i ] >= d ) { var diff = curveLengths[ i ] - d; - var curve = this$1.curves[ i ]; + var curve = this.curves[ i ]; var segmentLength = curve.getLength(); var u = segmentLength === 0 ? 0 : 1 - diff / segmentLength; @@ -35937,8 +35825,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { // We cannot overwrite getLengths() because UtoT mapping uses it. getCurveLengths: function () { - var this$1 = this; - // We use cache values if curves and cache array are same length @@ -35955,7 +35841,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { for ( var i = 0, l = this.curves.length; i < l; i ++ ) { - sums += this$1.curves[ i ].getLength(); + sums += this.curves[ i ].getLength(); lengths.push( sums ); } @@ -35967,8 +35853,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { }, getSpacedPoints: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = 40; } @@ -35976,7 +35860,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { for ( var i = 0; i <= divisions; i ++ ) { - points.push( this$1.getPoint( i / divisions ) ); + points.push( this.getPoint( i / divisions ) ); } @@ -36030,8 +35914,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { }, copy: function ( source ) { - var this$1 = this; - Curve.prototype.copy.call( this, source ); @@ -36041,7 +35923,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { var curve = source.curves[ i ]; - this$1.curves.push( curve.clone() ); + this.curves.push( curve.clone() ); } @@ -36202,8 +36084,6 @@ SplineCurve.prototype.getPoint = function ( t, optionalTarget ) { }; SplineCurve.prototype.copy = function ( source ) { - var this$1 = this; - Curve.prototype.copy.call( this, source ); @@ -36213,7 +36093,7 @@ SplineCurve.prototype.copy = function ( source ) { var point = source.points[ i ]; - this$1.points.push( point.clone() ); + this.points.push( point.clone() ); } @@ -36314,14 +36194,12 @@ QuadraticBezierCurve.prototype.copy = function ( source ) { var PathPrototype = Object.assign( Object.create( CurvePath.prototype ), { setFromPoints: function ( points ) { - var this$1 = this; - this.moveTo( points[ 0 ].x, points[ 0 ].y ); for ( var i = 1, l = points.length; i < l; i ++ ) { - this$1.lineTo( points[ i ].x, points[ i ].y ); + this.lineTo( points[ i ].x, points[ i ].y ); } @@ -36493,14 +36371,12 @@ Shape.prototype = Object.assign( Object.create( PathPrototype ), { constructor: Shape, getPointsHoles: function ( divisions ) { - var this$1 = this; - var holesPts = []; for ( var i = 0, l = this.holes.length; i < l; i ++ ) { - holesPts[ i ] = this$1.holes[ i ].getPoints( divisions ); + holesPts[ i ] = this.holes[ i ].getPoints( divisions ); } @@ -36522,8 +36398,6 @@ Shape.prototype = Object.assign( Object.create( PathPrototype ), { }, copy: function ( source ) { - var this$1 = this; - Path.prototype.copy.call( this, source ); @@ -36533,7 +36407,7 @@ Shape.prototype = Object.assign( Object.create( PathPrototype ), { var hole = source.holes[ i ]; - this$1.holes.push( hole.clone() ); + this.holes.push( hole.clone() ); } @@ -37552,8 +37426,6 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { }, connect: function () { - var this$1 = this; - if ( this.filters.length > 0 ) { @@ -37561,7 +37433,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 1, l = this.filters.length; i < l; i ++ ) { - this$1.filters[ i - 1 ].connect( this$1.filters[ i ] ); + this.filters[ i - 1 ].connect( this.filters[ i ] ); } @@ -37578,8 +37450,6 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { }, disconnect: function () { - var this$1 = this; - if ( this.filters.length > 0 ) { @@ -37587,7 +37457,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 1, l = this.filters.length; i < l; i ++ ) { - this$1.filters[ i - 1 ].disconnect( this$1.filters[ i ] ); + this.filters[ i - 1 ].disconnect( this.filters[ i ] ); } @@ -39861,8 +39731,6 @@ function AnimationMixer( root ) { Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { _bindAction: function ( action, prototypeAction ) { - var this$1 = this; - var root = action._localRoot || this._root, tracks = action._clip.tracks, @@ -39901,7 +39769,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( binding._cacheIndex === null ) { ++ binding.referenceCount; - this$1._addInactiveBinding( binding, rootUuid, trackName ); + this._addInactiveBinding( binding, rootUuid, trackName ); } @@ -39917,7 +39785,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { track.ValueTypeName, track.getValueSize() ); ++ binding.referenceCount; - this$1._addInactiveBinding( binding, rootUuid, trackName ); + this._addInactiveBinding( binding, rootUuid, trackName ); bindings[ i ] = binding; @@ -39930,8 +39798,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { }, _activateAction: function ( action ) { - var this$1 = this; - if ( ! this._isActiveAction( action ) ) { @@ -39960,7 +39826,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( binding.useCount ++ === 0 ) { - this$1._lendBinding( binding ); + this._lendBinding( binding ); binding.saveOriginalState(); } @@ -39974,8 +39840,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { }, _deactivateAction: function ( action ) { - var this$1 = this; - if ( this._isActiveAction( action ) ) { @@ -39989,7 +39853,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( -- binding.useCount === 0 ) { binding.restoreOriginalState(); - this$1._takeBackBinding( binding ); + this._takeBackBinding( binding ); } @@ -40160,8 +40024,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { }, _removeInactiveBindingsForAction: function ( action ) { - var this$1 = this; - var bindings = action._propertyBindings; for ( var i = 0, n = bindings.length; i !== n; ++ i ) { @@ -40170,7 +40032,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( -- binding.referenceCount === 0 ) { - this$1._removeInactiveBinding( binding ); + this._removeInactiveBinding( binding ); } @@ -40501,8 +40363,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { // free all resources specific to a particular clip uncacheClip: function ( clip ) { - var this$1 = this; - var actions = this._actions, clipUuid = clip.uuid, @@ -40521,7 +40381,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { var action = actionsToRemove[ i ]; - this$1._deactivateAction( action ); + this._deactivateAction( action ); var cacheIndex = action._cacheIndex, lastInactiveAction = actions[ actions.length - 1 ]; @@ -40533,7 +40393,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { actions[ cacheIndex ] = lastInactiveAction; actions.pop(); - this$1._removeInactiveBindingsForAction( action ); + this._removeInactiveBindingsForAction( action ); } @@ -40545,8 +40405,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { // free all resources specific to a particular root target object uncacheRoot: function ( root ) { - var this$1 = this; - var rootUuid = root.uuid, actionsByClip = this._actionsByClip; @@ -40558,8 +40416,8 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( action !== undefined ) { - this$1._deactivateAction( action ); - this$1._removeInactiveAction( action ); + this._deactivateAction( action ); + this._removeInactiveAction( action ); } @@ -40574,7 +40432,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { var binding = bindingByName[ trackName ]; binding.restoreOriginalState(); - this$1._removeInactiveBinding( binding ); + this._removeInactiveBinding( binding ); } @@ -40864,15 +40722,13 @@ Object.assign( InterleavedBuffer.prototype, { }, copyAt: function ( index1, attribute, index2 ) { - var this$1 = this; - index1 *= this.stride; index2 *= attribute.stride; for ( var i = 0, l = this.stride; i < l; i ++ ) { - this$1.array[ index1 + i ] = attribute.array[ index2 + i ]; + this.array[ index1 + i ] = attribute.array[ index2 + i ]; } @@ -41072,8 +40928,6 @@ Object.assign( Raycaster.prototype, { }, intersectObjects: function ( objects, recursive ) { - var this$1 = this; - var intersects = []; @@ -41086,7 +40940,7 @@ Object.assign( Raycaster.prototype, { for ( var i = 0, l = objects.length; i < l; i ++ ) { - intersectObject( objects[ i ], this$1, intersects, recursive ); + intersectObject( objects[ i ], this, intersects, recursive ); } @@ -41383,8 +41237,6 @@ VertexNormalsHelper.prototype.update = ( function () { var normalMatrix = new Matrix3(); return function update() { - var this$1 = this; - var keys = [ 'a', 'b', 'c' ]; @@ -41420,7 +41272,7 @@ VertexNormalsHelper.prototype.update = ( function () { v1.copy( vertex ).applyMatrix4( matrixWorld ); - v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this$1.size ).add( v1 ); + v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 ); position.setXYZ( idx, v1.x, v1.y, v1.z ); @@ -41450,7 +41302,7 @@ VertexNormalsHelper.prototype.update = ( function () { v2.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) ); - v2.applyMatrix3( normalMatrix ).normalize().multiplyScalar( this$1.size ).add( v1 ); + v2.applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 ); position.setXYZ( idx, v1.x, v1.y, v1.z ); @@ -42117,8 +41969,6 @@ FaceNormalsHelper.prototype.update = ( function () { var normalMatrix = new Matrix3(); return function update() { - var this$1 = this; - this.object.updateMatrixWorld( true ); @@ -42150,7 +42000,7 @@ FaceNormalsHelper.prototype.update = ( function () { .divideScalar( 3 ) .applyMatrix4( matrixWorld ); - v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this$1.size ).add( v1 ); + v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 ); position.setXYZ( idx, v1.x, v1.y, v1.z ); @@ -42984,8 +42834,6 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) { }; CatmullRomCurve3.prototype.copy = function ( source ) { - var this$1 = this; - Curve.prototype.copy.call( this, source ); @@ -42995,7 +42843,7 @@ CatmullRomCurve3.prototype.copy = function ( source ) { var point = source.points[ i ]; - this$1.points.push( point.clone() ); + this.points.push( point.clone() ); } @@ -45247,6 +45095,9 @@ var INTERACTIVE_MARKER_MOVE_AXIS = 3; var INTERACTIVE_MARKER_MOVE_PLANE = 4; var INTERACTIVE_MARKER_ROTATE_AXIS = 5; var INTERACTIVE_MARKER_MOVE_ROTATE = 6; +var INTERACTIVE_MARKER_MOVE_3D = 7; +var INTERACTIVE_MARKER_ROTATE_3D = 8; +var INTERACTIVE_MARKER_MOVE_ROTATE_3D = 9; // Interactive marker rotation behavior var INTERACTIVE_MARKER_INHERIT = 0; @@ -45380,7 +45231,7 @@ var closestAxisPoint = function(axisRay, camera, mousePos) { * @author Julius Kammerl - jkammerl@willowgarage.com */ -var DepthCloud = (function (superclass) { +var DepthCloud = /*@__PURE__*/(function (superclass) { function DepthCloud(options) { superclass.call(this); options = options || {}; @@ -45392,6 +45243,7 @@ var DepthCloud = (function (superclass) { this.pointSize = options.pointSize || 3; this.width = options.width || 1024; this.height = options.height || 1024; + this.resolutionFactor = Math.max(this.width, this.height) / 1024; this.whiteness = options.whiteness || 0; this.varianceThreshold = options.varianceThreshold || 0.000016667; @@ -45421,6 +45273,7 @@ var DepthCloud = (function (superclass) { '', 'uniform float focallength;', 'uniform float maxDepthPerTile;', + 'uniform float resolutionFactor;', '', 'varying vec2 vUvP;', 'varying vec2 colorP;', @@ -45524,8 +45377,8 @@ var DepthCloud = (function (superclass) { ' float z = -depth;', ' ', ' pos = vec4(', - ' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength) * -1.0,', - ' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength),', + ' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength) * -1.0,', + ' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength),', ' (- z + zOffset / 1000.0) * maxDepthPerTile,', ' 1.0);', ' ', @@ -45595,8 +45448,6 @@ var DepthCloud = (function (superclass) { * Callback called when video metadata is ready */ DepthCloud.prototype.initStreamer = function initStreamer () { - var this$1 = this; - if (this.metaLoaded) { this.texture = new THREE$1.Texture(this.video); @@ -45605,10 +45456,10 @@ var DepthCloud = (function (superclass) { for (var i = 0, l = this.width * this.height; i < l; i++) { var vertex = new THREE$1.Vector3(); - vertex.x = (i % this$1.width); - vertex.y = Math.floor(i / this$1.width); + vertex.x = (i % this.width); + vertex.y = Math.floor(i / this.width); - this$1.geometry.vertices.push(vertex); + this.geometry.vertices.push(vertex); } this.material = new THREE$1.ShaderMaterial({ @@ -45649,6 +45500,10 @@ var DepthCloud = (function (superclass) { type : 'f', value : this.maxDepthPerTile }, + 'resolutionFactor': { + type : 'f', + value : this.resolutionFactor + }, }, vertexShader : this.vertex_shader, fragmentShader : this.fragment_shader @@ -45692,7 +45547,7 @@ var DepthCloud = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var Arrow = (function (superclass) { +var Arrow = /*@__PURE__*/(function (superclass) { function Arrow(options) { options = options || {}; var origin = options.origin || new THREE$1.Vector3(0, 0, 0); @@ -49563,7 +49418,7 @@ THREE$1.ColladaLoader.prototype = { * @author Russell Toris - rctoris@wpi.edu */ -var MeshResource = (function (superclass) { +var MeshResource = /*@__PURE__*/(function (superclass) { function MeshResource(options) { superclass.call(this); var that = this; @@ -49646,7 +49501,7 @@ var MeshResource = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var TriangleList = (function (superclass) { +var TriangleList = /*@__PURE__*/(function (superclass) { function TriangleList(options) { options = options || {}; var material = options.material || new THREE$1.MeshBasicMaterial(); @@ -49721,7 +49576,7 @@ var TriangleList = (function (superclass) { * @author Russell Toris - rctoris@wpi.edu */ -var Marker = (function (superclass) { +var Marker = /*@__PURE__*/(function (superclass) { function Marker(options) { superclass.call(this); @@ -50205,7 +50060,7 @@ var Marker = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var InteractiveMarkerControl = (function (superclass) { +var InteractiveMarkerControl = /*@__PURE__*/(function (superclass) { function InteractiveMarkerControl(options) { superclass.call(this); var that = this; @@ -50221,6 +50076,8 @@ var InteractiveMarkerControl = (function (superclass) { this.loader = options.loader; this.dragging = false; this.startMousePos = new THREE$1.Vector2(); + this.isShift = false; + // orientation for the control var controlOri = new THREE$1.Quaternion(message.orientation.x, message.orientation.y, @@ -50235,6 +50092,9 @@ var InteractiveMarkerControl = (function (superclass) { // determine mouse interaction switch (message.interaction_mode) { + case INTERACTIVE_MARKER_MOVE_ROTATE_3D: + case INTERACTIVE_MARKER_MOVE_3D: + this.addEventListener('mousemove', this.parent.move3d.bind(this.parent, this, controlAxis)); case INTERACTIVE_MARKER_MOVE_AXIS: this.addEventListener('mousemove', this.parent.moveAxis.bind(this.parent, this, controlAxis)); this.addEventListener('touchmove', this.parent.moveAxis.bind(this.parent, this, controlAxis)); @@ -50305,6 +50165,17 @@ var InteractiveMarkerControl = (function (superclass) { that.dispatchEvent(event3d); } }); + + window.addEventListener('keydown', function(event){ + if(event.keyCode === 16){ + that.isShift = true; + } + }); + window.addEventListener('keyup', function(event){ + if(event.keyCode === 16){ + that.isShift = false; + } + }); } // rotation behavior @@ -50451,7 +50322,7 @@ var InteractiveMarkerControl = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var InteractiveMarkerMenu = (function (superclass) { +var InteractiveMarkerMenu = /*@__PURE__*/(function (superclass) { function InteractiveMarkerMenu(options) { superclass.call(this); var that = this; @@ -50625,7 +50496,7 @@ var InteractiveMarkerMenu = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var InteractiveMarker = (function (superclass) { +var InteractiveMarker = /*@__PURE__*/(function (superclass) { function InteractiveMarker(options) { superclass.call(this); @@ -50722,6 +50593,53 @@ var InteractiveMarker = (function (superclass) { event3d.stopPropagation(); } }; + + /** + * Move with respect to the plane based on the contorl and event. + * + * @param control - the control to use + * @param origNormal - the normal of the origin + * @param event3d - the event that caused this + */ + InteractiveMarker.prototype.move3d = function move3d (control, origNormal, event3d) { + // by default, move in a plane + if (this.dragging) { + + if(control.isShift){ + // this doesn't work + // // use the camera position and the marker position to determine the axis + // var newAxis = control.camera.position.clone(); + // newAxis.sub(this.position); + // // now mimic same steps constructor uses to create origAxis + // var controlOri = new THREE.Quaternion(newAxis.x, newAxis.y, + // newAxis.z, 1); + // controlOri.normalize(); + // var controlAxis = new THREE.Vector3(1, 0, 0); + // controlAxis.applyQuaternion(controlOri); + // origAxis = controlAxis; + }else{ + // we want to use the origin plane that is closest to the camera + var cameraVector = control.camera.getWorldDirection(); + var x = Math.abs(cameraVector.x); + var y = Math.abs(cameraVector.y); + var z = Math.abs(cameraVector.z); + var controlOri = new THREE$1.Quaternion(1, 0, 0, 1); + if(y > x && y > z){ + // orientation for the control + controlOri = new THREE$1.Quaternion(0, 0, 1, 1); + }else if(z > x && z > y){ + // orientation for the control + controlOri = new THREE$1.Quaternion(0, 1, 0, 1); + } + controlOri.normalize(); + + // transform x axis into local frame + origNormal = new THREE$1.Vector3(1, 0, 0); + origNormal.applyQuaternion(controlOri); + this.movePlane(control, origNormal, event3d); + } + } + }; /** * Move with respect to the plane based on the contorl and event. * @@ -50925,728 +50843,720 @@ function createCommonjsModule(fn, module) { } var eventemitter2 = createCommonjsModule(function (module, exports) { -!function(undefined) { - - var isArray = Array.isArray ? Array.isArray : function _isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]"; - }; - var defaultMaxListeners = 10; - - function init() { - this._events = {}; - if (this._conf) { - configure.call(this, this._conf); - } - } - - function configure(conf) { - if (conf) { - this._conf = conf; - - conf.delimiter && (this.delimiter = conf.delimiter); - this._events.maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners; - conf.wildcard && (this.wildcard = conf.wildcard); - conf.newListener && (this.newListener = conf.newListener); - conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak); - - if (this.wildcard) { - this.listenerTree = {}; - } - } else { - this._events.maxListeners = defaultMaxListeners; - } - } - - function logPossibleMemoryLeak(count, eventName) { - var errorMsg = '(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.'; - - if(this.verboseMemoryLeak){ - errorMsg += ' Event name: %s.'; - console.error(errorMsg, count, eventName); - } else { - console.error(errorMsg, count); - } - - if (console.trace){ - console.trace(); - } - } - - function EventEmitter(conf) { - this._events = {}; - this.newListener = false; - this.verboseMemoryLeak = false; - configure.call(this, conf); - } - EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property - - // - // Attention, function return type now is array, always ! - // It has zero elements if no any matches found and one or more - // elements (leafs) if there are matches - // - function searchListenerTree(handlers, type, tree, i) { - if (!tree) { - return []; - } - var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached, - typeLength = type.length, currentType = type[i], nextType = type[i+1]; - if (i === typeLength && tree._listeners) { - // - // If at the end of the event(s) list and the tree has listeners - // invoke those listeners. - // - if (typeof tree._listeners === 'function') { - handlers && handlers.push(tree._listeners); - return [tree]; - } else { - for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) { - handlers && handlers.push(tree._listeners[leaf]); - } - return [tree]; - } - } - - if ((currentType === '*' || currentType === '**') || tree[currentType]) { - // - // If the event emitted is '*' at this part - // or there is a concrete match at this patch - // - if (currentType === '*') { - for (branch in tree) { - if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1)); - } - } - return listeners; - } else if(currentType === '**') { - endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*')); - if(endReached && tree._listeners) { - // The next element has a _listeners, add it to the handlers. - listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength)); - } - - for (branch in tree) { - if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { - if(branch === '*' || branch === '**') { - if(tree[branch]._listeners && !endReached) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength)); - } - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); - } else if(branch === nextType) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2)); - } else { - // No match on this one, shift into the tree but not in the type array. - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); - } - } - } - return listeners; - } - - listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1)); - } - - xTree = tree['*']; - if (xTree) { - // - // If the listener tree will allow any match for this part, - // then recursively explore all branches of the tree - // - searchListenerTree(handlers, type, xTree, i+1); - } - - xxTree = tree['**']; - if(xxTree) { - if(i < typeLength) { - if(xxTree._listeners) { - // If we have a listener on a '**', it will catch all, so add its handler. - searchListenerTree(handlers, type, xxTree, typeLength); - } - - // Build arrays of matching next branches and others. - for(branch in xxTree) { - if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) { - if(branch === nextType) { - // We know the next element will match, so jump twice. - searchListenerTree(handlers, type, xxTree[branch], i+2); - } else if(branch === currentType) { - // Current node matches, move into the tree. - searchListenerTree(handlers, type, xxTree[branch], i+1); - } else { - isolatedBranch = {}; - isolatedBranch[branch] = xxTree[branch]; - searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1); - } - } - } - } else if(xxTree._listeners) { - // We have reached the end and still on a '**' - searchListenerTree(handlers, type, xxTree, typeLength); - } else if(xxTree['*'] && xxTree['*']._listeners) { - searchListenerTree(handlers, type, xxTree['*'], typeLength); - } - } - - return listeners; - } - - function growListenerTree(type, listener) { - var this$1 = this; - - - type = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - - // - // Looks for two consecutive '**', if so, don't add the event at all. - // - for(var i = 0, len = type.length; i+1 < len; i++) { - if(type[i] === '**' && type[i+1] === '**') { - return; - } - } - - var tree = this.listenerTree; - var name = type.shift(); - - while (name !== undefined) { - - if (!tree[name]) { - tree[name] = {}; - } - - tree = tree[name]; - - if (type.length === 0) { - - if (!tree._listeners) { - tree._listeners = listener; - } - else { - if (typeof tree._listeners === 'function') { - tree._listeners = [tree._listeners]; - } - - tree._listeners.push(listener); - - if ( - !tree._listeners.warned && - this$1._events.maxListeners > 0 && - tree._listeners.length > this$1._events.maxListeners - ) { - tree._listeners.warned = true; - logPossibleMemoryLeak.call(this$1, tree._listeners.length, name); - } - } - return true; - } - name = type.shift(); - } - return true; - } - - // By default EventEmitters will print a warning if more than - // 10 listeners are added to it. This is a useful default which - // helps finding memory leaks. - // - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - - EventEmitter.prototype.delimiter = '.'; - - EventEmitter.prototype.setMaxListeners = function(n) { - if (n !== undefined) { - this._events || init.call(this); - this._events.maxListeners = n; - if (!this._conf) { this._conf = {}; } - this._conf.maxListeners = n; - } - }; - - EventEmitter.prototype.event = ''; - - EventEmitter.prototype.once = function(event, fn) { - this.many(event, 1, fn); - return this; - }; - - EventEmitter.prototype.many = function(event, ttl, fn) { - var self = this; - - if (typeof fn !== 'function') { - throw new Error('many only accepts instances of Function'); - } - - function listener() { - if (--ttl === 0) { - self.off(event, listener); - } - fn.apply(this, arguments); - } - - listener._origin = fn; - - this.on(event, listener); - - return self; - }; - +!function(undefined) { + + var isArray = Array.isArray ? Array.isArray : function _isArray(obj) { + return Object.prototype.toString.call(obj) === "[object Array]"; + }; + var defaultMaxListeners = 10; + + function init() { + this._events = {}; + if (this._conf) { + configure.call(this, this._conf); + } + } + + function configure(conf) { + if (conf) { + this._conf = conf; + + conf.delimiter && (this.delimiter = conf.delimiter); + this._events.maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners; + conf.wildcard && (this.wildcard = conf.wildcard); + conf.newListener && (this.newListener = conf.newListener); + conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak); + + if (this.wildcard) { + this.listenerTree = {}; + } + } else { + this._events.maxListeners = defaultMaxListeners; + } + } + + function logPossibleMemoryLeak(count, eventName) { + var errorMsg = '(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.'; + + if(this.verboseMemoryLeak){ + errorMsg += ' Event name: %s.'; + console.error(errorMsg, count, eventName); + } else { + console.error(errorMsg, count); + } + + if (console.trace){ + console.trace(); + } + } + + function EventEmitter(conf) { + this._events = {}; + this.newListener = false; + this.verboseMemoryLeak = false; + configure.call(this, conf); + } + EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property + + // + // Attention, function return type now is array, always ! + // It has zero elements if no any matches found and one or more + // elements (leafs) if there are matches + // + function searchListenerTree(handlers, type, tree, i) { + if (!tree) { + return []; + } + var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached, + typeLength = type.length, currentType = type[i], nextType = type[i+1]; + if (i === typeLength && tree._listeners) { + // + // If at the end of the event(s) list and the tree has listeners + // invoke those listeners. + // + if (typeof tree._listeners === 'function') { + handlers && handlers.push(tree._listeners); + return [tree]; + } else { + for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) { + handlers && handlers.push(tree._listeners[leaf]); + } + return [tree]; + } + } + + if ((currentType === '*' || currentType === '**') || tree[currentType]) { + // + // If the event emitted is '*' at this part + // or there is a concrete match at this patch + // + if (currentType === '*') { + for (branch in tree) { + if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1)); + } + } + return listeners; + } else if(currentType === '**') { + endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*')); + if(endReached && tree._listeners) { + // The next element has a _listeners, add it to the handlers. + listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength)); + } + + for (branch in tree) { + if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { + if(branch === '*' || branch === '**') { + if(tree[branch]._listeners && !endReached) { + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength)); + } + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); + } else if(branch === nextType) { + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2)); + } else { + // No match on this one, shift into the tree but not in the type array. + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); + } + } + } + return listeners; + } + + listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1)); + } + + xTree = tree['*']; + if (xTree) { + // + // If the listener tree will allow any match for this part, + // then recursively explore all branches of the tree + // + searchListenerTree(handlers, type, xTree, i+1); + } + + xxTree = tree['**']; + if(xxTree) { + if(i < typeLength) { + if(xxTree._listeners) { + // If we have a listener on a '**', it will catch all, so add its handler. + searchListenerTree(handlers, type, xxTree, typeLength); + } + + // Build arrays of matching next branches and others. + for(branch in xxTree) { + if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) { + if(branch === nextType) { + // We know the next element will match, so jump twice. + searchListenerTree(handlers, type, xxTree[branch], i+2); + } else if(branch === currentType) { + // Current node matches, move into the tree. + searchListenerTree(handlers, type, xxTree[branch], i+1); + } else { + isolatedBranch = {}; + isolatedBranch[branch] = xxTree[branch]; + searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1); + } + } + } + } else if(xxTree._listeners) { + // We have reached the end and still on a '**' + searchListenerTree(handlers, type, xxTree, typeLength); + } else if(xxTree['*'] && xxTree['*']._listeners) { + searchListenerTree(handlers, type, xxTree['*'], typeLength); + } + } + + return listeners; + } + + function growListenerTree(type, listener) { + + type = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + + // + // Looks for two consecutive '**', if so, don't add the event at all. + // + for(var i = 0, len = type.length; i+1 < len; i++) { + if(type[i] === '**' && type[i+1] === '**') { + return; + } + } + + var tree = this.listenerTree; + var name = type.shift(); + + while (name !== undefined) { + + if (!tree[name]) { + tree[name] = {}; + } + + tree = tree[name]; + + if (type.length === 0) { + + if (!tree._listeners) { + tree._listeners = listener; + } + else { + if (typeof tree._listeners === 'function') { + tree._listeners = [tree._listeners]; + } + + tree._listeners.push(listener); + + if ( + !tree._listeners.warned && + this._events.maxListeners > 0 && + tree._listeners.length > this._events.maxListeners + ) { + tree._listeners.warned = true; + logPossibleMemoryLeak.call(this, tree._listeners.length, name); + } + } + return true; + } + name = type.shift(); + } + return true; + } + + // By default EventEmitters will print a warning if more than + // 10 listeners are added to it. This is a useful default which + // helps finding memory leaks. + // + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + + EventEmitter.prototype.delimiter = '.'; + + EventEmitter.prototype.setMaxListeners = function(n) { + if (n !== undefined) { + this._events || init.call(this); + this._events.maxListeners = n; + if (!this._conf) { this._conf = {}; } + this._conf.maxListeners = n; + } + }; + + EventEmitter.prototype.event = ''; + + EventEmitter.prototype.once = function(event, fn) { + this.many(event, 1, fn); + return this; + }; + + EventEmitter.prototype.many = function(event, ttl, fn) { + var self = this; + + if (typeof fn !== 'function') { + throw new Error('many only accepts instances of Function'); + } + + function listener() { + if (--ttl === 0) { + self.off(event, listener); + } + fn.apply(this, arguments); + } + + listener._origin = fn; + + this.on(event, listener); + + return self; + }; + EventEmitter.prototype.emit = function() { var arguments$1 = arguments; - var this$1 = this; - - - this._events || init.call(this); - - var type = arguments[0]; - - if (type === 'newListener' && !this.newListener) { - if (!this._events.newListener) { - return false; - } - } - - var al = arguments.length; - var args,l,i,j; - var handler; - - if (this._all && this._all.length) { - handler = this._all.slice(); - if (al > 3) { - args = new Array(al); - for (j = 0; j < al; j++) { args[j] = arguments$1[j]; } - } - - for (i = 0, l = handler.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - handler[i].call(this$1, type); - break; - case 2: - handler[i].call(this$1, type, arguments$1[1]); - break; - case 3: - handler[i].call(this$1, type, arguments$1[1], arguments$1[2]); - break; - default: - handler[i].apply(this$1, args); - } - } - } - - if (this.wildcard) { - handler = []; - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - searchListenerTree.call(this, handler, ns, this.listenerTree, 0); - } else { - handler = this._events[type]; - if (typeof handler === 'function') { - this.event = type; - switch (al) { - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - default: - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - handler.apply(this, args); - } - return true; - } else if (handler) { - // need to make copy of handlers because list can change in the middle - // of emit call - handler = handler.slice(); - } - } - - if (handler && handler.length) { - if (al > 3) { - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - } - for (i = 0, l = handler.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - handler[i].call(this$1); - break; - case 2: - handler[i].call(this$1, arguments$1[1]); - break; - case 3: - handler[i].call(this$1, arguments$1[1], arguments$1[2]); - break; - default: - handler[i].apply(this$1, args); - } - } - return true; - } else if (!this._all && type === 'error') { - if (arguments[1] instanceof Error) { - throw arguments[1]; // Unhandled 'error' event - } else { - throw new Error("Uncaught, unspecified 'error' event."); - } - return false; - } - - return !!this._all; - }; - + + + this._events || init.call(this); + + var type = arguments[0]; + + if (type === 'newListener' && !this.newListener) { + if (!this._events.newListener) { + return false; + } + } + + var al = arguments.length; + var args,l,i,j; + var handler; + + if (this._all && this._all.length) { + handler = this._all.slice(); + if (al > 3) { + args = new Array(al); + for (j = 0; j < al; j++) { args[j] = arguments$1[j]; } + } + + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + handler[i].call(this, type); + break; + case 2: + handler[i].call(this, type, arguments$1[1]); + break; + case 3: + handler[i].call(this, type, arguments$1[1], arguments$1[2]); + break; + default: + handler[i].apply(this, args); + } + } + } + + if (this.wildcard) { + handler = []; + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + searchListenerTree.call(this, handler, ns, this.listenerTree, 0); + } else { + handler = this._events[type]; + if (typeof handler === 'function') { + this.event = type; + switch (al) { + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + default: + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + handler.apply(this, args); + } + return true; + } else if (handler) { + // need to make copy of handlers because list can change in the middle + // of emit call + handler = handler.slice(); + } + } + + if (handler && handler.length) { + if (al > 3) { + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + } + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + handler[i].call(this); + break; + case 2: + handler[i].call(this, arguments$1[1]); + break; + case 3: + handler[i].call(this, arguments$1[1], arguments$1[2]); + break; + default: + handler[i].apply(this, args); + } + } + return true; + } else if (!this._all && type === 'error') { + if (arguments[1] instanceof Error) { + throw arguments[1]; // Unhandled 'error' event + } else { + throw new Error("Uncaught, unspecified 'error' event."); + } + return false; + } + + return !!this._all; + }; + EventEmitter.prototype.emitAsync = function() { var arguments$1 = arguments; - var this$1 = this; - - - this._events || init.call(this); - - var type = arguments[0]; - - if (type === 'newListener' && !this.newListener) { - if (!this._events.newListener) { return Promise.resolve([false]); } - } - - var promises= []; - - var al = arguments.length; - var args,l,i,j; - var handler; - - if (this._all) { - if (al > 3) { - args = new Array(al); - for (j = 1; j < al; j++) { args[j] = arguments$1[j]; } - } - for (i = 0, l = this._all.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - promises.push(this$1._all[i].call(this$1, type)); - break; - case 2: - promises.push(this$1._all[i].call(this$1, type, arguments$1[1])); - break; - case 3: - promises.push(this$1._all[i].call(this$1, type, arguments$1[1], arguments$1[2])); - break; - default: - promises.push(this$1._all[i].apply(this$1, args)); - } - } - } - - if (this.wildcard) { - handler = []; - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - searchListenerTree.call(this, handler, ns, this.listenerTree, 0); - } else { - handler = this._events[type]; - } - - if (typeof handler === 'function') { - this.event = type; - switch (al) { - case 1: - promises.push(handler.call(this)); - break; - case 2: - promises.push(handler.call(this, arguments[1])); - break; - case 3: - promises.push(handler.call(this, arguments[1], arguments[2])); - break; - default: - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - promises.push(handler.apply(this, args)); - } - } else if (handler && handler.length) { - if (al > 3) { - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - } - for (i = 0, l = handler.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - promises.push(handler[i].call(this$1)); - break; - case 2: - promises.push(handler[i].call(this$1, arguments$1[1])); - break; - case 3: - promises.push(handler[i].call(this$1, arguments$1[1], arguments$1[2])); - break; - default: - promises.push(handler[i].apply(this$1, args)); - } - } - } else if (!this._all && type === 'error') { - if (arguments[1] instanceof Error) { - return Promise.reject(arguments[1]); // Unhandled 'error' event - } else { - return Promise.reject("Uncaught, unspecified 'error' event."); - } - } - - return Promise.all(promises); - }; - - EventEmitter.prototype.on = function(type, listener) { - if (typeof type === 'function') { - this.onAny(type); - return this; - } - - if (typeof listener !== 'function') { - throw new Error('on only accepts instances of Function'); - } - this._events || init.call(this); - - // To avoid recursion in the case that type == "newListeners"! Before - // adding it to the listeners, first emit "newListeners". - this.emit('newListener', type, listener); - - if (this.wildcard) { - growListenerTree.call(this, type, listener); - return this; - } - - if (!this._events[type]) { - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - } - else { - if (typeof this._events[type] === 'function') { - // Change to array. - this._events[type] = [this._events[type]]; - } - - // If we've already got an array, just append. - this._events[type].push(listener); - - // Check for listener leak - if ( - !this._events[type].warned && - this._events.maxListeners > 0 && - this._events[type].length > this._events.maxListeners - ) { - this._events[type].warned = true; - logPossibleMemoryLeak.call(this, this._events[type].length, type); - } - } - - return this; - }; - - EventEmitter.prototype.onAny = function(fn) { - if (typeof fn !== 'function') { - throw new Error('onAny only accepts instances of Function'); - } - - if (!this._all) { - this._all = []; - } - - // Add the function to the event listener collection. - this._all.push(fn); - return this; - }; - - EventEmitter.prototype.addListener = EventEmitter.prototype.on; - - EventEmitter.prototype.off = function(type, listener) { - var this$1 = this; - - if (typeof listener !== 'function') { - throw new Error('removeListener only takes instances of Function'); - } - - var handlers,leafs=[]; - - if(this.wildcard) { - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); - } - else { - // does not use listeners(), so no side effect of creating _events[type] - if (!this._events[type]) { return this; } - handlers = this._events[type]; - leafs.push({_listeners:handlers}); - } - - for (var iLeaf=0; iLeaf 0) { - recursivelyGarbageCollect(root[key]); - } - if (Object.keys(obj).length === 0) { - delete root[key]; - } - } - } - recursivelyGarbageCollect(this.listenerTree); - - return this; - }; - - EventEmitter.prototype.offAny = function(fn) { - var this$1 = this; - - var i = 0, l = 0, fns; - if (fn && this._all && this._all.length > 0) { - fns = this._all; - for(i = 0, l = fns.length; i < l; i++) { - if(fn === fns[i]) { - fns.splice(i, 1); - this$1.emit("removeListenerAny", fn); - return this$1; - } - } - } else { - fns = this._all; - for(i = 0, l = fns.length; i < l; i++) - { this$1.emit("removeListenerAny", fns[i]); } - this._all = []; - } - return this; - }; - - EventEmitter.prototype.removeListener = EventEmitter.prototype.off; - - EventEmitter.prototype.removeAllListeners = function(type) { - if (arguments.length === 0) { - !this._events || init.call(this); - return this; - } - - if (this.wildcard) { - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); - - for (var iLeaf=0; iLeaf 3) { + args = new Array(al); + for (j = 1; j < al; j++) { args[j] = arguments$1[j]; } + } + for (i = 0, l = this._all.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + promises.push(this._all[i].call(this, type)); + break; + case 2: + promises.push(this._all[i].call(this, type, arguments$1[1])); + break; + case 3: + promises.push(this._all[i].call(this, type, arguments$1[1], arguments$1[2])); + break; + default: + promises.push(this._all[i].apply(this, args)); + } + } + } + + if (this.wildcard) { + handler = []; + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + searchListenerTree.call(this, handler, ns, this.listenerTree, 0); + } else { + handler = this._events[type]; + } + + if (typeof handler === 'function') { + this.event = type; + switch (al) { + case 1: + promises.push(handler.call(this)); + break; + case 2: + promises.push(handler.call(this, arguments[1])); + break; + case 3: + promises.push(handler.call(this, arguments[1], arguments[2])); + break; + default: + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + promises.push(handler.apply(this, args)); + } + } else if (handler && handler.length) { + if (al > 3) { + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + } + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + promises.push(handler[i].call(this)); + break; + case 2: + promises.push(handler[i].call(this, arguments$1[1])); + break; + case 3: + promises.push(handler[i].call(this, arguments$1[1], arguments$1[2])); + break; + default: + promises.push(handler[i].apply(this, args)); + } + } + } else if (!this._all && type === 'error') { + if (arguments[1] instanceof Error) { + return Promise.reject(arguments[1]); // Unhandled 'error' event + } else { + return Promise.reject("Uncaught, unspecified 'error' event."); + } + } + + return Promise.all(promises); + }; + + EventEmitter.prototype.on = function(type, listener) { + if (typeof type === 'function') { + this.onAny(type); + return this; + } + + if (typeof listener !== 'function') { + throw new Error('on only accepts instances of Function'); + } + this._events || init.call(this); + + // To avoid recursion in the case that type == "newListeners"! Before + // adding it to the listeners, first emit "newListeners". + this.emit('newListener', type, listener); + + if (this.wildcard) { + growListenerTree.call(this, type, listener); + return this; + } + + if (!this._events[type]) { + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + } + else { + if (typeof this._events[type] === 'function') { + // Change to array. + this._events[type] = [this._events[type]]; + } + + // If we've already got an array, just append. + this._events[type].push(listener); + + // Check for listener leak + if ( + !this._events[type].warned && + this._events.maxListeners > 0 && + this._events[type].length > this._events.maxListeners + ) { + this._events[type].warned = true; + logPossibleMemoryLeak.call(this, this._events[type].length, type); + } + } + + return this; + }; + + EventEmitter.prototype.onAny = function(fn) { + if (typeof fn !== 'function') { + throw new Error('onAny only accepts instances of Function'); + } + + if (!this._all) { + this._all = []; + } + + // Add the function to the event listener collection. + this._all.push(fn); + return this; + }; + + EventEmitter.prototype.addListener = EventEmitter.prototype.on; + + EventEmitter.prototype.off = function(type, listener) { + if (typeof listener !== 'function') { + throw new Error('removeListener only takes instances of Function'); + } + + var handlers,leafs=[]; + + if(this.wildcard) { + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); + } + else { + // does not use listeners(), so no side effect of creating _events[type] + if (!this._events[type]) { return this; } + handlers = this._events[type]; + leafs.push({_listeners:handlers}); + } + + for (var iLeaf=0; iLeaf 0) { + recursivelyGarbageCollect(root[key]); + } + if (Object.keys(obj).length === 0) { + delete root[key]; + } + } + } + recursivelyGarbageCollect(this.listenerTree); + + return this; + }; + + EventEmitter.prototype.offAny = function(fn) { + var i = 0, l = 0, fns; + if (fn && this._all && this._all.length > 0) { + fns = this._all; + for(i = 0, l = fns.length; i < l; i++) { + if(fn === fns[i]) { + fns.splice(i, 1); + this.emit("removeListenerAny", fn); + return this; + } + } + } else { + fns = this._all; + for(i = 0, l = fns.length; i < l; i++) + { this.emit("removeListenerAny", fns[i]); } + this._all = []; + } + return this; + }; + + EventEmitter.prototype.removeListener = EventEmitter.prototype.off; + + EventEmitter.prototype.removeAllListeners = function(type) { + if (arguments.length === 0) { + !this._events || init.call(this); + return this; + } + + if (this.wildcard) { + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); + + for (var iLeaf=0; iLeaf= message.range_min && range <= message.range_max){ var angle = message.angle_min + i * message.angle_increment; - this$1.points.positions.array[j++] = range * Math.cos(angle); - this$1.points.positions.array[j++] = range * Math.sin(angle); - this$1.points.positions.array[j++] = 0.0; + this.points.positions.array[j++] = range * Math.cos(angle); + this.points.positions.array[j++] = range * Math.sin(angle); + this.points.positions.array[j++] = 0.0; } } this.points.update(j/3); @@ -53285,7 +53176,7 @@ decode64.e={}; for(var i=0;i<64;i++){decode64.e[decode64.S.charAt(i)]=i;} -var PointCloud2 = (function (superclass) { +var PointCloud2 = /*@__PURE__*/(function (superclass) { function PointCloud2(options) { superclass.call(this); options = options || {}; @@ -53317,8 +53208,6 @@ var PointCloud2 = (function (superclass) { this.rosTopic.subscribe(this.processMessage.bind(this)); }; PointCloud2.prototype.processMessage = function processMessage (msg){ - var this$1 = this; - if(!this.points.setup(msg.header.frame_id, msg.point_step, msg.fields)) { return; } @@ -53341,15 +53230,15 @@ var PointCloud2 = (function (superclass) { var base, color; for(var i = 0; i < n; i++){ base = i * pointRatio * msg.point_step; - this$1.points.positions.array[3*i ] = dv.getFloat32(base+x, littleEndian); - this$1.points.positions.array[3*i + 1] = dv.getFloat32(base+y, littleEndian); - this$1.points.positions.array[3*i + 2] = dv.getFloat32(base+z, littleEndian); - - if(this$1.points.colors){ - color = this$1.points.colormap(this$1.points.getColor(dv,base,littleEndian)); - this$1.points.colors.array[3*i ] = color.r; - this$1.points.colors.array[3*i + 1] = color.g; - this$1.points.colors.array[3*i + 2] = color.b; + this.points.positions.array[3*i ] = dv.getFloat32(base+x, littleEndian); + this.points.positions.array[3*i + 1] = dv.getFloat32(base+y, littleEndian); + this.points.positions.array[3*i + 2] = dv.getFloat32(base+z, littleEndian); + + if(this.points.colors){ + color = this.points.colormap(this.points.getColor(dv,base,littleEndian)); + this.points.colors.array[3*i ] = color.r; + this.points.colors.array[3*i + 1] = color.g; + this.points.colors.array[3*i + 2] = color.b; } } this.points.update(n); @@ -53363,10 +53252,8 @@ var PointCloud2 = (function (superclass) { * @author Russell Toris - rctoris@wpi.edu */ -var Urdf = (function (superclass) { +var Urdf = /*@__PURE__*/(function (superclass) { function Urdf(options) { - var this$1 = this; - options = options || {}; var urdfModel = options.urdfModel; var path = options.path || '/'; @@ -53422,7 +53309,7 @@ var Urdf = (function (superclass) { tfClient : tfClient, object : mesh }); - this$1.add(sceneNode); + this.add(sceneNode); } else { console.warn('Could not load geometry mesh: '+uri); } @@ -53457,7 +53344,7 @@ var Urdf = (function (superclass) { tfClient: tfClient, object: shapeMesh }); - this$1.add(scene); + this.add(scene); } } } @@ -53612,8 +53499,6 @@ Highlighter.prototype.makeEverythingInvisible = function makeEverythingInvisible * @param scene - the object to traverse */ Highlighter.prototype.makeHighlightedVisible = function makeHighlightedVisible (scene) { - var this$1 = this; - var makeVisible = function(currentObject) { if ( currentObject instanceof THREE$1.Mesh || currentObject instanceof THREE$1.Line || currentObject instanceof THREE$1.Sprite ) { @@ -53621,8 +53506,8 @@ Highlighter.prototype.makeHighlightedVisible = function makeHighlightedVisible ( } }; - for (var uuid in this$1.hoverObjs) { - var selectedObject = this$1.hoverObjs[uuid]; + for (var uuid in this.hoverObjs) { + var selectedObject = this.hoverObjs[uuid]; // Make each selected object and all of its children visible selectedObject.visible = true; selectedObject.traverse(makeVisible); @@ -53646,7 +53531,7 @@ Highlighter.prototype.restoreVisibility = function restoreVisibility (scene) { * @author David Gossow - dgossow@willowgarage.com */ -var MouseHandler = (function (superclass) { +var MouseHandler = /*@__PURE__*/(function (superclass) { function MouseHandler(options) { superclass.call(this); this.renderer = options.renderer; @@ -53817,8 +53702,6 @@ var MouseHandler = (function (superclass) { * @returns if an event was canceled */ MouseHandler.prototype.notify = function notify (target, type, event3D) { - var this$1 = this; - // ensure the type is set // event3D.type = type; @@ -53844,7 +53727,7 @@ var MouseHandler = (function (superclass) { && event3D.currentTarget.dispatchEvent instanceof Function) { event3D.currentTarget.dispatchEvent(event3D); if (event3D.cancelBubble) { - this$1.dispatchEvent(event3D); + this.dispatchEvent(event3D); return 0; // Event Accepted } else if(event3D.continueBubble) { @@ -53868,7 +53751,7 @@ var MouseHandler = (function (superclass) { * @author AlteredQualia - http://alteredqualia.com */ -var OrbitControls = (function (superclass) { +var OrbitControls = /*@__PURE__*/(function (superclass) { function OrbitControls(options) { superclass.call(this); var that = this; @@ -54528,6 +54411,9 @@ exports.INTERACTIVE_MARKER_MOVE_AXIS = INTERACTIVE_MARKER_MOVE_AXIS; exports.INTERACTIVE_MARKER_MOVE_PLANE = INTERACTIVE_MARKER_MOVE_PLANE; exports.INTERACTIVE_MARKER_ROTATE_AXIS = INTERACTIVE_MARKER_ROTATE_AXIS; exports.INTERACTIVE_MARKER_MOVE_ROTATE = INTERACTIVE_MARKER_MOVE_ROTATE; +exports.INTERACTIVE_MARKER_MOVE_3D = INTERACTIVE_MARKER_MOVE_3D; +exports.INTERACTIVE_MARKER_ROTATE_3D = INTERACTIVE_MARKER_ROTATE_3D; +exports.INTERACTIVE_MARKER_MOVE_ROTATE_3D = INTERACTIVE_MARKER_MOVE_ROTATE_3D; exports.INTERACTIVE_MARKER_INHERIT = INTERACTIVE_MARKER_INHERIT; exports.INTERACTIVE_MARKER_FIXED = INTERACTIVE_MARKER_FIXED; exports.INTERACTIVE_MARKER_VIEW_FACING = INTERACTIVE_MARKER_VIEW_FACING; diff --git a/build/ros3d.esm.js b/build/ros3d.esm.js index f400bc79..4c3cdd09 100644 --- a/build/ros3d.esm.js +++ b/build/ros3d.esm.js @@ -159,8 +159,6 @@ Object.assign( EventDispatcher.prototype, { }, dispatchEvent: function ( event ) { - var this$1 = this; - if ( this._listeners === undefined ) { return; } @@ -175,7 +173,7 @@ Object.assign( EventDispatcher.prototype, { for ( var i = 0, l = array.length; i < l; i ++ ) { - array[ i ].call( this$1, event ); + array[ i ].call( this, event ); } @@ -1409,8 +1407,6 @@ Object.assign( Matrix4.prototype, { var v1 = new Vector3(); return function applyToBufferAttribute( attribute ) { - var this$1 = this; - for ( var i = 0, l = attribute.count; i < l; i ++ ) { @@ -1418,7 +1414,7 @@ Object.assign( Matrix4.prototype, { v1.y = attribute.getY( i ); v1.z = attribute.getZ( i ); - v1.applyMatrix4( this$1 ); + v1.applyMatrix4( this ); attribute.setXYZ( i, v1.x, v1.y, v1.z ); @@ -1840,14 +1836,12 @@ Object.assign( Matrix4.prototype, { }, fromArray: function ( array, offset ) { - var this$1 = this; - if ( offset === undefined ) { offset = 0; } for ( var i = 0; i < 16; i ++ ) { - this$1.elements[ i ] = array[ i + offset ]; + this.elements[ i ] = array[ i + offset ]; } @@ -3313,8 +3307,6 @@ Object.assign( Matrix3.prototype, { var v1 = new Vector3(); return function applyToBufferAttribute( attribute ) { - var this$1 = this; - for ( var i = 0, l = attribute.count; i < l; i ++ ) { @@ -3322,7 +3314,7 @@ Object.assign( Matrix3.prototype, { v1.y = attribute.getY( i ); v1.z = attribute.getZ( i ); - v1.applyMatrix3( this$1 ); + v1.applyMatrix3( this ); attribute.setXYZ( i, v1.x, v1.y, v1.z ); @@ -3566,14 +3558,12 @@ Object.assign( Matrix3.prototype, { }, fromArray: function ( array, offset ) { - var this$1 = this; - if ( offset === undefined ) { offset = 0; } for ( var i = 0; i < 9; i ++ ) { - this$1.elements[ i ] = array[ i + offset ]; + this.elements[ i ] = array[ i + offset ]; } @@ -5245,8 +5235,6 @@ function parseUniform( activeInfo, addr, container ) { // Root Container function WebGLUniforms( gl, program, renderer ) { - var this$1 = this; - UniformContainer.call( this ); @@ -5260,7 +5248,7 @@ function WebGLUniforms( gl, program, renderer ) { path = info.name, addr = gl.getUniformLocation( program, path ); - parseUniform( info, addr, this$1 ); + parseUniform( info, addr, this ); } @@ -6027,14 +6015,12 @@ var UniformsLib = { var UniformsUtils = { merge: function ( uniforms ) { - var this$1 = this; - var merged = {}; for ( var u = 0; u < uniforms.length; u ++ ) { - var tmp = this$1.clone( uniforms[ u ] ); + var tmp = this.clone( uniforms[ u ] ); for ( var p in tmp ) { @@ -6676,14 +6662,12 @@ Object.assign( Box2.prototype, { }, setFromPoints: function ( points ) { - var this$1 = this; - this.makeEmpty(); for ( var i = 0, il = points.length; i < il; i ++ ) { - this$1.expandByPoint( points[ i ] ); + this.expandByPoint( points[ i ] ); } @@ -7714,8 +7698,6 @@ Object.assign( Material.prototype, EventDispatcher.prototype, { onBeforeCompile: function () {}, setValues: function ( values ) { - var this$1 = this; - if ( values === undefined ) { return; } @@ -7733,17 +7715,17 @@ Object.assign( Material.prototype, EventDispatcher.prototype, { // for backward compatability if shading is set in the constructor if ( key === 'shading' ) { - console.warn( 'THREE.' + this$1.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); - this$1.flatShading = ( newValue === FlatShading ) ? true : false; + console.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' ); + this.flatShading = ( newValue === FlatShading ) ? true : false; continue; } - var currentValue = this$1[ key ]; + var currentValue = this[ key ]; if ( currentValue === undefined ) { - console.warn( "THREE." + this$1.type + ": '" + key + "' is not a property of this material." ); + console.warn( "THREE." + this.type + ": '" + key + "' is not a property of this material." ); continue; } @@ -7759,11 +7741,11 @@ Object.assign( Material.prototype, EventDispatcher.prototype, { } else if ( key === 'overdraw' ) { // ensure overdraw is backwards-compatible with legacy boolean type - this$1[ key ] = Number( newValue ); + this[ key ] = Number( newValue ); } else { - this$1[ key ] = newValue; + this[ key ] = newValue; } @@ -8255,14 +8237,12 @@ Object.assign( Box3.prototype, { }, setFromPoints: function ( points ) { - var this$1 = this; - this.makeEmpty(); for ( var i = 0, il = points.length; i < il; i ++ ) { - this$1.expandByPoint( points[ i ] ); + this.expandByPoint( points[ i ] ); } @@ -10537,14 +10517,13 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { add: function ( object ) { var arguments$1 = arguments; - var this$1 = this; if ( arguments.length > 1 ) { for ( var i = 0; i < arguments.length; i ++ ) { - this$1.add( arguments$1[ i ] ); + this.add( arguments$1[ i ] ); } @@ -10584,14 +10563,13 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { remove: function ( object ) { var arguments$1 = arguments; - var this$1 = this; if ( arguments.length > 1 ) { for ( var i = 0; i < arguments.length; i ++ ) { - this$1.remove( arguments$1[ i ] ); + this.remove( arguments$1[ i ] ); } @@ -10628,14 +10606,12 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }, getObjectByProperty: function ( name, value ) { - var this$1 = this; - if ( this[ name ] === value ) { return this; } for ( var i = 0, l = this.children.length; i < l; i ++ ) { - var child = this$1.children[ i ]; + var child = this.children[ i ]; var object = child.getObjectByProperty( name, value ); if ( object !== undefined ) { @@ -10819,8 +10795,6 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }, toJSON: function ( meta ) { - var this$1 = this; - // meta is a string when called from JSON.stringify var isRootObject = ( meta === undefined || typeof meta === 'string' ); @@ -10891,7 +10865,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { for ( var i = 0, l = this.material.length; i < l; i ++ ) { - uuids.push( serialize( meta.materials, this$1.material[ i ] ) ); + uuids.push( serialize( meta.materials, this.material[ i ] ) ); } @@ -10913,7 +10887,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { for ( var i = 0; i < this.children.length; i ++ ) { - object.children.push( this$1.children[ i ].toJSON( meta ).object ); + object.children.push( this.children[ i ].toJSON( meta ).object ); } @@ -10963,8 +10937,6 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }, copy: function ( source, recursive ) { - var this$1 = this; - if ( recursive === undefined ) { recursive = true; } @@ -10998,7 +10970,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { for ( var i = 0; i < source.children.length; i ++ ) { var child = source.children[ i ]; - this$1.add( child.clone() ); + this.add( child.clone() ); } @@ -11246,8 +11218,6 @@ Object.assign( Face3.prototype, { }, copy: function ( source ) { - var this$1 = this; - this.a = source.a; this.b = source.b; @@ -11260,13 +11230,13 @@ Object.assign( Face3.prototype, { for ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) { - this$1.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); + this.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); } for ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) { - this$1.vertexColors[ i ] = source.vertexColors[ i ].clone(); + this.vertexColors[ i ] = source.vertexColors[ i ].clone(); } @@ -11329,21 +11299,19 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { isGeometry: true, applyMatrix: function ( matrix ) { - var this$1 = this; - var normalMatrix = new Matrix3().getNormalMatrix( matrix ); for ( var i = 0, il = this.vertices.length; i < il; i ++ ) { - var vertex = this$1.vertices[ i ]; + var vertex = this.vertices[ i ]; vertex.applyMatrix4( matrix ); } for ( var i = 0, il = this.faces.length; i < il; i ++ ) { - var face = this$1.faces[ i ]; + var face = this.faces[ i ]; face.normal.applyMatrix3( normalMatrix ).normalize(); for ( var j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) { @@ -11654,18 +11622,16 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeFaceNormals: function () { - var this$1 = this; - var cb = new Vector3(), ab = new Vector3(); for ( var f = 0, fl = this.faces.length; f < fl; f ++ ) { - var face = this$1.faces[ f ]; + var face = this.faces[ f ]; - var vA = this$1.vertices[ face.a ]; - var vB = this$1.vertices[ face.b ]; - var vC = this$1.vertices[ face.c ]; + var vA = this.vertices[ face.a ]; + var vB = this.vertices[ face.b ]; + var vC = this.vertices[ face.c ]; cb.subVectors( vC, vB ); ab.subVectors( vA, vB ); @@ -11680,8 +11646,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeVertexNormals: function ( areaWeighted ) { - var this$1 = this; - if ( areaWeighted === undefined ) { areaWeighted = true; } @@ -11705,11 +11669,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; - vA = this$1.vertices[ face.a ]; - vB = this$1.vertices[ face.b ]; - vC = this$1.vertices[ face.c ]; + vA = this.vertices[ face.a ]; + vB = this.vertices[ face.b ]; + vC = this.vertices[ face.c ]; cb.subVectors( vC, vB ); ab.subVectors( vA, vB ); @@ -11727,7 +11691,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; vertices[ face.a ].add( face.normal ); vertices[ face.b ].add( face.normal ); @@ -11745,7 +11709,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; var vertexNormals = face.vertexNormals; @@ -11774,8 +11738,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeFlatVertexNormals: function () { - var this$1 = this; - var f, fl, face; @@ -11783,7 +11745,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; var vertexNormals = face.vertexNormals; @@ -11812,8 +11774,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeMorphNormals: function () { - var this$1 = this; - var i, il, f, fl, face; @@ -11823,7 +11783,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; if ( ! face.__originalFaceNormal ) { @@ -11862,14 +11822,14 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { // create on first access - if ( ! this$1.morphNormals[ i ] ) { + if ( ! this.morphNormals[ i ] ) { - this$1.morphNormals[ i ] = {}; - this$1.morphNormals[ i ].faceNormals = []; - this$1.morphNormals[ i ].vertexNormals = []; + this.morphNormals[ i ] = {}; + this.morphNormals[ i ].faceNormals = []; + this.morphNormals[ i ].vertexNormals = []; - var dstNormalsFace = this$1.morphNormals[ i ].faceNormals; - var dstNormalsVertex = this$1.morphNormals[ i ].vertexNormals; + var dstNormalsFace = this.morphNormals[ i ].faceNormals; + var dstNormalsVertex = this.morphNormals[ i ].vertexNormals; var faceNormal, vertexNormals; @@ -11885,11 +11845,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - var morphNormals = this$1.morphNormals[ i ]; + var morphNormals = this.morphNormals[ i ]; // set vertices to morph target - tmpGeo.vertices = this$1.morphTargets[ i ].vertices; + tmpGeo.vertices = this.morphTargets[ i ].vertices; // compute morph normals @@ -11902,7 +11862,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; faceNormal = morphNormals.faceNormals[ f ]; vertexNormals = morphNormals.vertexNormals[ f ]; @@ -11921,7 +11881,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { - face = this$1.faces[ f ]; + face = this.faces[ f ]; face.normal = face.__originalFaceNormal; face.vertexNormals = face.__originalVertexNormals; @@ -11931,8 +11891,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, computeLineDistances: function () { - var this$1 = this; - var d = 0; var vertices = this.vertices; @@ -11945,7 +11903,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.lineDistances[ i ] = d; + this.lineDistances[ i ] = d; } @@ -12117,8 +12075,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { */ mergeVertices: function () { - var this$1 = this; - var verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique) var unique = [], changes = []; @@ -12131,13 +12087,13 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = this.vertices.length; i < il; i ++ ) { - v = this$1.vertices[ i ]; + v = this.vertices[ i ]; key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision ); if ( verticesMap[ key ] === undefined ) { verticesMap[ key ] = i; - unique.push( this$1.vertices[ i ] ); + unique.push( this.vertices[ i ] ); changes[ i ] = unique.length - 1; } else { @@ -12156,7 +12112,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = this.faces.length; i < il; i ++ ) { - face = this$1.faces[ i ]; + face = this.faces[ i ]; face.a = changes[ face.a ]; face.b = changes[ face.b ]; @@ -12183,11 +12139,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { var idx = faceIndicesToRemove[ i ]; - this$1.faces.splice( idx, 1 ); + this.faces.splice( idx, 1 ); for ( j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) { - this$1.faceVertexUvs[ j ].splice( idx, 1 ); + this.faceVertexUvs[ j ].splice( idx, 1 ); } @@ -12202,15 +12158,13 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, setFromPoints: function ( points ) { - var this$1 = this; - this.vertices = []; for ( var i = 0, l = points.length; i < l; i ++ ) { var point = points[ i ]; - this$1.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) ); + this.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) ); } @@ -12266,8 +12220,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, toJSON: function () { - var this$1 = this; - var data = { metadata: { @@ -12301,7 +12253,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( var i = 0; i < this.vertices.length; i ++ ) { - var vertex = this$1.vertices[ i ]; + var vertex = this.vertices[ i ]; vertices.push( vertex.x, vertex.y, vertex.z ); } @@ -12316,11 +12268,11 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( var i = 0; i < this.faces.length; i ++ ) { - var face = this$1.faces[ i ]; + var face = this.faces[ i ]; var hasMaterial = true; var hasFaceUv = false; // deprecated - var hasFaceVertexUv = this$1.faceVertexUvs[ 0 ][ i ] !== undefined; + var hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined; var hasFaceNormal = face.normal.length() > 0; var hasFaceVertexNormal = face.vertexNormals.length > 0; var hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1; @@ -12343,7 +12295,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { if ( hasFaceVertexUv ) { - var faceVertexUvs = this$1.faceVertexUvs[ 0 ][ i ]; + var faceVertexUvs = this.faceVertexUvs[ 0 ][ i ]; faces.push( getUvIndex( faceVertexUvs[ 0 ] ), @@ -12491,8 +12443,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, copy: function ( source ) { - var this$1 = this; - var i, il, j, jl, k, kl; @@ -12520,7 +12470,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = vertices.length; i < il; i ++ ) { - this$1.vertices.push( vertices[ i ].clone() ); + this.vertices.push( vertices[ i ].clone() ); } @@ -12530,7 +12480,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = colors.length; i < il; i ++ ) { - this$1.colors.push( colors[ i ].clone() ); + this.colors.push( colors[ i ].clone() ); } @@ -12540,7 +12490,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = faces.length; i < il; i ++ ) { - this$1.faces.push( faces[ i ].clone() ); + this.faces.push( faces[ i ].clone() ); } @@ -12550,9 +12500,9 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { var faceVertexUvs = source.faceVertexUvs[ i ]; - if ( this$1.faceVertexUvs[ i ] === undefined ) { + if ( this.faceVertexUvs[ i ] === undefined ) { - this$1.faceVertexUvs[ i ] = []; + this.faceVertexUvs[ i ] = []; } @@ -12568,7 +12518,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.faceVertexUvs[ i ].push( uvsCopy ); + this.faceVertexUvs[ i ].push( uvsCopy ); } @@ -12611,7 +12561,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.morphTargets.push( morphTarget ); + this.morphTargets.push( morphTarget ); } @@ -12658,7 +12608,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } - this$1.morphNormals.push( morphNormal ); + this.morphNormals.push( morphNormal ); } @@ -12668,7 +12618,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = skinWeights.length; i < il; i ++ ) { - this$1.skinWeights.push( skinWeights[ i ].clone() ); + this.skinWeights.push( skinWeights[ i ].clone() ); } @@ -12678,7 +12628,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = skinIndices.length; i < il; i ++ ) { - this$1.skinIndices.push( skinIndices[ i ].clone() ); + this.skinIndices.push( skinIndices[ i ].clone() ); } @@ -12688,7 +12638,7 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { for ( i = 0, il = lineDistances.length; i < il; i ++ ) { - this$1.lineDistances.push( lineDistances[ i ] ); + this.lineDistances.push( lineDistances[ i ] ); } @@ -12812,15 +12762,13 @@ Object.assign( BufferAttribute.prototype, { }, copyAt: function ( index1, attribute, index2 ) { - var this$1 = this; - index1 *= this.itemSize; index2 *= attribute.itemSize; for ( var i = 0, l = this.itemSize; i < l; i ++ ) { - this$1.array[ index1 + i ] = attribute.array[ index2 + i ]; + this.array[ index1 + i ] = attribute.array[ index2 + i ]; } @@ -13246,8 +13194,6 @@ Object.assign( DirectGeometry.prototype, { }, fromGeometry: function ( geometry ) { - var this$1 = this; - var faces = geometry.faces; var vertices = geometry.vertices; @@ -13310,19 +13256,19 @@ Object.assign( DirectGeometry.prototype, { var face = faces[ i ]; - this$1.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); + this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); var vertexNormals = face.vertexNormals; if ( vertexNormals.length === 3 ) { - this$1.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); + this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); } else { var normal = face.normal; - this$1.normals.push( normal, normal, normal ); + this.normals.push( normal, normal, normal ); } @@ -13330,13 +13276,13 @@ Object.assign( DirectGeometry.prototype, { if ( vertexColors.length === 3 ) { - this$1.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); + this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); } else { var color = face.color; - this$1.colors.push( color, color, color ); + this.colors.push( color, color, color ); } @@ -13346,13 +13292,13 @@ Object.assign( DirectGeometry.prototype, { if ( vertexUvs !== undefined ) { - this$1.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); } else { console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i ); - this$1.uvs.push( new Vector2(), new Vector2(), new Vector2() ); + this.uvs.push( new Vector2(), new Vector2(), new Vector2() ); } @@ -13364,13 +13310,13 @@ Object.assign( DirectGeometry.prototype, { if ( vertexUvs !== undefined ) { - this$1.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); } else { console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i ); - this$1.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); + this.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); } @@ -13398,13 +13344,13 @@ Object.assign( DirectGeometry.prototype, { if ( hasSkinIndices ) { - this$1.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); + this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); } if ( hasSkinWeights ) { - this$1.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); + this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); } @@ -13921,8 +13867,6 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { }, fromDirectGeometry: function ( geometry ) { - var this$1 = this; - var positions = new Float32Array( geometry.vertices.length * 3 ); this.addAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) ); @@ -13984,7 +13928,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { } - this$1.morphAttributes[ name ] = array; + this.morphAttributes[ name ] = array; } @@ -14449,8 +14393,6 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { }, copy: function ( source ) { - var this$1 = this; - var name, i, l; @@ -14484,7 +14426,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { for ( name in attributes ) { var attribute = attributes[ name ]; - this$1.addAttribute( name, attribute.clone() ); + this.addAttribute( name, attribute.clone() ); } @@ -14503,7 +14445,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { } - this$1.morphAttributes[ name ] = array; + this.morphAttributes[ name ] = array; } @@ -14514,7 +14456,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { for ( i = 0, l = groups.length; i < l; i ++ ) { var group = groups[ i ]; - this$1.addGroup( group.start, group.count, group.materialIndex ); + this.addGroup( group.start, group.count, group.materialIndex ); } @@ -16071,8 +16013,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { }, updateMorphTargets: function () { - var this$1 = this; - var geometry = this.geometry; var m, ml, name; @@ -16095,8 +16035,8 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { name = morphAttribute[ m ].name || String( m ); - this$1.morphTargetInfluences.push( 0 ); - this$1.morphTargetDictionary[ name ] = m; + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; } @@ -16117,8 +16057,8 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { name = morphTargets[ m ].name || String( m ); - this$1.morphTargetInfluences.push( 0 ); - this$1.morphTargetDictionary[ name ] = m; + this.morphTargetInfluences.push( 0 ); + this.morphTargetDictionary[ name ] = m; } @@ -16226,8 +16166,6 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { } return function raycast( raycaster, intersects ) { - var this$1 = this; - var geometry = this.geometry; var material = this.material; @@ -16277,7 +16215,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { b = index.getX( i + 1 ); c = index.getX( i + 2 ); - intersection = checkBufferGeometryIntersection( this$1, raycaster, ray, position, uv, a, b, c ); + intersection = checkBufferGeometryIntersection( this, raycaster, ray, position, uv, a, b, c ); if ( intersection ) { @@ -16298,7 +16236,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { b = i + 1; c = i + 2; - intersection = checkBufferGeometryIntersection( this$1, raycaster, ray, position, uv, a, b, c ); + intersection = checkBufferGeometryIntersection( this, raycaster, ray, position, uv, a, b, c ); if ( intersection ) { @@ -16337,7 +16275,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( faceMaterial.morphTargets === true ) { var morphTargets = geometry.morphTargets; - var morphInfluences = this$1.morphTargetInfluences; + var morphInfluences = this.morphTargetInfluences; vA.set( 0, 0, 0 ); vB.set( 0, 0, 0 ); @@ -16367,7 +16305,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), { } - intersection = checkIntersection( this$1, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint ); + intersection = checkIntersection( this, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint ); if ( intersection ) { @@ -23904,8 +23842,6 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { isLensFlare: true, copy: function ( source ) { - var this$1 = this; - Object3D.prototype.copy.call( this, source ); @@ -23914,7 +23850,7 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 0, l = source.lensFlares.length; i < l; i ++ ) { - this$1.lensFlares.push( source.lensFlares[ i ] ); + this.lensFlares.push( source.lensFlares[ i ] ); } @@ -23952,8 +23888,6 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { */ updateLensFlares: function () { - var this$1 = this; - var f, fl = this.lensFlares.length; var flare; @@ -23962,10 +23896,10 @@ LensFlare.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( f = 0; f < fl; f ++ ) { - flare = this$1.lensFlares[ f ]; + flare = this.lensFlares[ f ]; - flare.x = this$1.positionScreen.x + vecX * flare.distance; - flare.y = this$1.positionScreen.y + vecY * flare.distance; + flare.x = this.positionScreen.x + vecX * flare.distance; + flare.y = this.positionScreen.y + vecY * flare.distance; flare.wantedRotation = flare.x * Math.PI * 0.25; flare.rotation += ( flare.wantedRotation - flare.rotation ) * 0.25; @@ -24112,8 +24046,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { constructor: LOD, copy: function ( source ) { - var this$1 = this; - Object3D.prototype.copy.call( this, source, false ); @@ -24123,7 +24055,7 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { var level = levels[ i ]; - this$1.addLevel( level.object.clone(), level.distance ); + this.addLevel( level.object.clone(), level.distance ); } @@ -24267,8 +24199,6 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), { */ function Skeleton( bones, boneInverses ) { - var this$1 = this; - // copy the bone array @@ -24297,7 +24227,7 @@ function Skeleton( bones, boneInverses ) { for ( var i = 0, il = this.bones.length; i < il; i ++ ) { - this$1.boneInverses.push( new Matrix4() ); + this.boneInverses.push( new Matrix4() ); } @@ -24310,8 +24240,6 @@ function Skeleton( bones, boneInverses ) { Object.assign( Skeleton.prototype, { calculateInverses: function () { - var this$1 = this; - this.boneInverses = []; @@ -24319,21 +24247,19 @@ Object.assign( Skeleton.prototype, { var inverse = new Matrix4(); - if ( this$1.bones[ i ] ) { + if ( this.bones[ i ] ) { - inverse.getInverse( this$1.bones[ i ].matrixWorld ); + inverse.getInverse( this.bones[ i ].matrixWorld ); } - this$1.boneInverses.push( inverse ); + this.boneInverses.push( inverse ); } }, pose: function () { - var this$1 = this; - var bone, i, il; @@ -24341,11 +24267,11 @@ Object.assign( Skeleton.prototype, { for ( i = 0, il = this.bones.length; i < il; i ++ ) { - bone = this$1.bones[ i ]; + bone = this.bones[ i ]; if ( bone ) { - bone.matrixWorld.getInverse( this$1.boneInverses[ i ] ); + bone.matrixWorld.getInverse( this.boneInverses[ i ] ); } @@ -24355,7 +24281,7 @@ Object.assign( Skeleton.prototype, { for ( i = 0, il = this.bones.length; i < il; i ++ ) { - bone = this$1.bones[ i ]; + bone = this.bones[ i ]; if ( bone ) { @@ -24475,8 +24401,6 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { isSkinnedMesh: true, initBones: function () { - var this$1 = this; - var bones = [], bone, gbone; var i, il; @@ -24487,7 +24411,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { for ( i = 0, il = this.geometry.bones.length; i < il; i ++ ) { - gbone = this$1.geometry.bones[ i ]; + gbone = this.geometry.bones[ i ]; // create new 'Bone' object @@ -24507,7 +24431,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { for ( i = 0, il = this.geometry.bones.length; i < il; i ++ ) { - gbone = this$1.geometry.bones[ i ]; + gbone = this.geometry.bones[ i ]; if ( ( gbone.parent !== - 1 ) && ( gbone.parent !== null ) && ( bones[ gbone.parent ] !== undefined ) ) { @@ -24519,7 +24443,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { // topmost bone, immediate child of the skinned mesh - this$1.add( bones[ i ] ); + this.add( bones[ i ] ); } @@ -24562,8 +24486,6 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { }, normalizeSkinWeights: function () { - var this$1 = this; - var scale, i; @@ -24571,7 +24493,7 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), { for ( i = 0; i < this.geometry.skinWeights.length; i ++ ) { - var sw = this$1.geometry.skinWeights[ i ]; + var sw = this.geometry.skinWeights[ i ]; scale = 1.0 / sw.manhattanLength(); @@ -24734,8 +24656,6 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { var sphere = new Sphere(); return function raycast( raycaster, intersects ) { - var this$1 = this; - var precision = raycaster.linePrecision; var precisionSq = precision * precision; @@ -24785,7 +24705,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( distSq > precisionSq ) { continue; } - interRay.applyMatrix4( this$1.matrixWorld ); //Move back to world space for distance calculation + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation var distance = raycaster.ray.origin.distanceTo( interRay ); @@ -24796,11 +24716,11 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this$1.matrixWorld ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), index: i, face: null, faceIndex: null, - object: this$1 + object: this } ); @@ -24817,7 +24737,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( distSq > precisionSq ) { continue; } - interRay.applyMatrix4( this$1.matrixWorld ); //Move back to world space for distance calculation + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation var distance = raycaster.ray.origin.distanceTo( interRay ); @@ -24828,11 +24748,11 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this$1.matrixWorld ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), index: i, face: null, faceIndex: null, - object: this$1 + object: this } ); @@ -24851,7 +24771,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( distSq > precisionSq ) { continue; } - interRay.applyMatrix4( this$1.matrixWorld ); //Move back to world space for distance calculation + interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation var distance = raycaster.ray.origin.distanceTo( interRay ); @@ -24862,11 +24782,11 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), { distance: distance, // What do we want? intersection point on the ray or on the segment?? // point: raycaster.ray.at( distance ), - point: interSegment.clone().applyMatrix4( this$1.matrixWorld ), + point: interSegment.clone().applyMatrix4( this.matrixWorld ), index: i, face: null, faceIndex: null, - object: this$1 + object: this } ); @@ -27461,8 +27381,6 @@ ExtrudeBufferGeometry.prototype.getArrays = function () { }; ExtrudeBufferGeometry.prototype.addShapeList = function ( shapes, options ) { - var this$1 = this; - var sl = shapes.length; options.arrays = this.getArrays(); @@ -27470,7 +27388,7 @@ ExtrudeBufferGeometry.prototype.addShapeList = function ( shapes, options ) { for ( var s = 0; s < sl; s ++ ) { var shape = shapes[ s ]; - this$1.addShape( shape, options ); + this.addShape( shape, options ); } @@ -28750,8 +28668,6 @@ ShapeGeometry.prototype.constructor = ShapeGeometry; // ShapeBufferGeometry function ShapeBufferGeometry( shapes, curveSegments ) { - var this$1 = this; - BufferGeometry.call( this ); @@ -28788,7 +28704,7 @@ function ShapeBufferGeometry( shapes, curveSegments ) { addShape( shapes[ i ] ); - this$1.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support + this.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support groupStart += groupCount; groupCount = 0; @@ -30398,8 +30314,6 @@ function FileLoader( manager ) { Object.assign( FileLoader.prototype, { load: function ( url, onLoad, onProgress, onError ) { - var this$1 = this; - if ( url === undefined ) { url = ''; } @@ -30639,9 +30553,9 @@ Object.assign( FileLoader.prototype, { if ( request.overrideMimeType ) { request.overrideMimeType( this.mimeType !== undefined ? this.mimeType : 'text/plain' ); } - for ( var header in this$1.requestHeader ) { + for ( var header in this.requestHeader ) { - request.setRequestHeader( header, this$1.requestHeader[ header ] ); + request.setRequestHeader( header, this.requestHeader[ header ] ); } @@ -31785,8 +31699,6 @@ function Interpolant( parameterPositions, sampleValues, sampleSize, resultBuffer Object.assign( Interpolant.prototype, { evaluate: function ( t ) { - var this$1 = this; - var pp = this.parameterPositions, i1 = this._cachedIndex, @@ -31817,8 +31729,8 @@ Object.assign( Interpolant.prototype, { // after end i1 = pp.length; - this$1._cachedIndex = i1; - return this$1.afterEnd_( i1 - 1, t, t0 ); + this._cachedIndex = i1; + return this.afterEnd_( i1 - 1, t, t0 ); } @@ -31865,8 +31777,8 @@ Object.assign( Interpolant.prototype, { // before start - this$1._cachedIndex = 0; - return this$1.beforeStart_( 0, t, t1 ); + this._cachedIndex = 0; + return this.beforeStart_( 0, t, t1 ); } @@ -32400,8 +32312,6 @@ KeyframeTrackPrototype = { // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable validate: function () { - var this$1 = this; - var valid = true; @@ -32433,7 +32343,7 @@ KeyframeTrackPrototype = { if ( typeof currTime === 'number' && isNaN( currTime ) ) { - console.error( 'THREE.KeyframeTrackPrototype: Time is not a valid number.', this$1, i, currTime ); + console.error( 'THREE.KeyframeTrackPrototype: Time is not a valid number.', this, i, currTime ); valid = false; break; @@ -32441,7 +32351,7 @@ KeyframeTrackPrototype = { if ( prevTime !== null && prevTime > currTime ) { - console.error( 'THREE.KeyframeTrackPrototype: Out of order keys.', this$1, i, currTime, prevTime ); + console.error( 'THREE.KeyframeTrackPrototype: Out of order keys.', this, i, currTime, prevTime ); valid = false; break; @@ -32461,7 +32371,7 @@ KeyframeTrackPrototype = { if ( isNaN( value ) ) { - console.error( 'THREE.KeyframeTrackPrototype: Value is not a valid number.', this$1, i, value ); + console.error( 'THREE.KeyframeTrackPrototype: Value is not a valid number.', this, i, value ); valid = false; break; @@ -33275,14 +33185,12 @@ Object.assign( AnimationClip, { Object.assign( AnimationClip.prototype, { resetDuration: function () { - var this$1 = this; - var tracks = this.tracks, duration = 0; for ( var i = 0, n = tracks.length; i !== n; ++ i ) { - var track = this$1.tracks[ i ]; + var track = this.tracks[ i ]; duration = Math.max( duration, track.times[ track.times.length - 1 ] ); @@ -33293,12 +33201,10 @@ Object.assign( AnimationClip.prototype, { }, trim: function () { - var this$1 = this; - for ( var i = 0; i < this.tracks.length; i ++ ) { - this$1.tracks[ i ].trim( 0, this$1.duration ); + this.tracks[ i ].trim( 0, this.duration ); } @@ -33307,12 +33213,10 @@ Object.assign( AnimationClip.prototype, { }, optimize: function () { - var this$1 = this; - for ( var i = 0; i < this.tracks.length; i ++ ) { - this$1.tracks[ i ].optimize(); + this.tracks[ i ].optimize(); } @@ -33645,14 +33549,12 @@ Object.assign( Loader.prototype, { }, initMaterials: function ( materials, texturePath, crossOrigin ) { - var this$1 = this; - var array = []; for ( var i = 0; i < materials.length; ++ i ) { - array[ i ] = this$1.createMaterial( materials[ i ], texturePath, crossOrigin ); + array[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin ); } @@ -34579,8 +34481,6 @@ Object.assign( ObjectLoader.prototype, { }, parseGeometries: function ( json ) { - var this$1 = this; - var geometries = {}; @@ -34770,7 +34670,7 @@ Object.assign( ObjectLoader.prototype, { case 'Geometry': - geometry = geometryLoader.parse( data, this$1.texturePath ).geometry; + geometry = geometryLoader.parse( data, this.texturePath ).geometry; break; @@ -34971,8 +34871,6 @@ Object.assign( ObjectLoader.prototype, { var matrix = new Matrix4(); return function parseObject( data, geometries, materials ) { - var this$1 = this; - var object; @@ -35218,7 +35116,7 @@ Object.assign( ObjectLoader.prototype, { for ( var i = 0; i < children.length; i ++ ) { - object.add( this$1.parseObject( children[ i ], geometries, materials ) ); + object.add( this.parseObject( children[ i ], geometries, materials ) ); } @@ -35425,8 +35323,6 @@ Object.assign( Curve.prototype, { // Get sequence of points using getPoint( t ) getPoints: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = 5; } @@ -35434,7 +35330,7 @@ Object.assign( Curve.prototype, { for ( var d = 0; d <= divisions; d ++ ) { - points.push( this$1.getPoint( d / divisions ) ); + points.push( this.getPoint( d / divisions ) ); } @@ -35445,8 +35341,6 @@ Object.assign( Curve.prototype, { // Get sequence of points using getPointAt( u ) getSpacedPoints: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = 5; } @@ -35454,7 +35348,7 @@ Object.assign( Curve.prototype, { for ( var d = 0; d <= divisions; d ++ ) { - points.push( this$1.getPointAt( d / divisions ) ); + points.push( this.getPointAt( d / divisions ) ); } @@ -35474,8 +35368,6 @@ Object.assign( Curve.prototype, { // Get list of cumulative segment lengths getLengths: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = this.arcLengthDivisions; } @@ -35497,7 +35389,7 @@ Object.assign( Curve.prototype, { for ( p = 1; p <= divisions; p ++ ) { - current = this$1.getPoint( p / divisions ); + current = this.getPoint( p / divisions ); sum += current.distanceTo( last ); cache.push( sum ); last = current; @@ -35625,8 +35517,6 @@ Object.assign( Curve.prototype, { }, computeFrenetFrames: function ( segments, closed ) { - var this$1 = this; - // see http://www.cs.indiana.edu/pub/techreports/TR425.pdf @@ -35647,7 +35537,7 @@ Object.assign( Curve.prototype, { u = i / segments; - tangents[ i ] = this$1.getTangentAt( u ); + tangents[ i ] = this.getTangentAt( u ); tangents[ i ].normalize(); } @@ -35876,8 +35766,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { // 4. Return curve.getPointAt(t') getPoint: function ( t ) { - var this$1 = this; - var d = t * this.getLength(); var curveLengths = this.getCurveLengths(); @@ -35890,7 +35778,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { if ( curveLengths[ i ] >= d ) { var diff = curveLengths[ i ] - d; - var curve = this$1.curves[ i ]; + var curve = this.curves[ i ]; var segmentLength = curve.getLength(); var u = segmentLength === 0 ? 0 : 1 - diff / segmentLength; @@ -35933,8 +35821,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { // We cannot overwrite getLengths() because UtoT mapping uses it. getCurveLengths: function () { - var this$1 = this; - // We use cache values if curves and cache array are same length @@ -35951,7 +35837,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { for ( var i = 0, l = this.curves.length; i < l; i ++ ) { - sums += this$1.curves[ i ].getLength(); + sums += this.curves[ i ].getLength(); lengths.push( sums ); } @@ -35963,8 +35849,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { }, getSpacedPoints: function ( divisions ) { - var this$1 = this; - if ( divisions === undefined ) { divisions = 40; } @@ -35972,7 +35856,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { for ( var i = 0; i <= divisions; i ++ ) { - points.push( this$1.getPoint( i / divisions ) ); + points.push( this.getPoint( i / divisions ) ); } @@ -36026,8 +35910,6 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { }, copy: function ( source ) { - var this$1 = this; - Curve.prototype.copy.call( this, source ); @@ -36037,7 +35919,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { var curve = source.curves[ i ]; - this$1.curves.push( curve.clone() ); + this.curves.push( curve.clone() ); } @@ -36198,8 +36080,6 @@ SplineCurve.prototype.getPoint = function ( t, optionalTarget ) { }; SplineCurve.prototype.copy = function ( source ) { - var this$1 = this; - Curve.prototype.copy.call( this, source ); @@ -36209,7 +36089,7 @@ SplineCurve.prototype.copy = function ( source ) { var point = source.points[ i ]; - this$1.points.push( point.clone() ); + this.points.push( point.clone() ); } @@ -36310,14 +36190,12 @@ QuadraticBezierCurve.prototype.copy = function ( source ) { var PathPrototype = Object.assign( Object.create( CurvePath.prototype ), { setFromPoints: function ( points ) { - var this$1 = this; - this.moveTo( points[ 0 ].x, points[ 0 ].y ); for ( var i = 1, l = points.length; i < l; i ++ ) { - this$1.lineTo( points[ i ].x, points[ i ].y ); + this.lineTo( points[ i ].x, points[ i ].y ); } @@ -36489,14 +36367,12 @@ Shape.prototype = Object.assign( Object.create( PathPrototype ), { constructor: Shape, getPointsHoles: function ( divisions ) { - var this$1 = this; - var holesPts = []; for ( var i = 0, l = this.holes.length; i < l; i ++ ) { - holesPts[ i ] = this$1.holes[ i ].getPoints( divisions ); + holesPts[ i ] = this.holes[ i ].getPoints( divisions ); } @@ -36518,8 +36394,6 @@ Shape.prototype = Object.assign( Object.create( PathPrototype ), { }, copy: function ( source ) { - var this$1 = this; - Path.prototype.copy.call( this, source ); @@ -36529,7 +36403,7 @@ Shape.prototype = Object.assign( Object.create( PathPrototype ), { var hole = source.holes[ i ]; - this$1.holes.push( hole.clone() ); + this.holes.push( hole.clone() ); } @@ -37548,8 +37422,6 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { }, connect: function () { - var this$1 = this; - if ( this.filters.length > 0 ) { @@ -37557,7 +37429,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 1, l = this.filters.length; i < l; i ++ ) { - this$1.filters[ i - 1 ].connect( this$1.filters[ i ] ); + this.filters[ i - 1 ].connect( this.filters[ i ] ); } @@ -37574,8 +37446,6 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { }, disconnect: function () { - var this$1 = this; - if ( this.filters.length > 0 ) { @@ -37583,7 +37453,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { for ( var i = 1, l = this.filters.length; i < l; i ++ ) { - this$1.filters[ i - 1 ].disconnect( this$1.filters[ i ] ); + this.filters[ i - 1 ].disconnect( this.filters[ i ] ); } @@ -39857,8 +39727,6 @@ function AnimationMixer( root ) { Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { _bindAction: function ( action, prototypeAction ) { - var this$1 = this; - var root = action._localRoot || this._root, tracks = action._clip.tracks, @@ -39897,7 +39765,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( binding._cacheIndex === null ) { ++ binding.referenceCount; - this$1._addInactiveBinding( binding, rootUuid, trackName ); + this._addInactiveBinding( binding, rootUuid, trackName ); } @@ -39913,7 +39781,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { track.ValueTypeName, track.getValueSize() ); ++ binding.referenceCount; - this$1._addInactiveBinding( binding, rootUuid, trackName ); + this._addInactiveBinding( binding, rootUuid, trackName ); bindings[ i ] = binding; @@ -39926,8 +39794,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { }, _activateAction: function ( action ) { - var this$1 = this; - if ( ! this._isActiveAction( action ) ) { @@ -39956,7 +39822,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( binding.useCount ++ === 0 ) { - this$1._lendBinding( binding ); + this._lendBinding( binding ); binding.saveOriginalState(); } @@ -39970,8 +39836,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { }, _deactivateAction: function ( action ) { - var this$1 = this; - if ( this._isActiveAction( action ) ) { @@ -39985,7 +39849,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( -- binding.useCount === 0 ) { binding.restoreOriginalState(); - this$1._takeBackBinding( binding ); + this._takeBackBinding( binding ); } @@ -40156,8 +40020,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { }, _removeInactiveBindingsForAction: function ( action ) { - var this$1 = this; - var bindings = action._propertyBindings; for ( var i = 0, n = bindings.length; i !== n; ++ i ) { @@ -40166,7 +40028,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( -- binding.referenceCount === 0 ) { - this$1._removeInactiveBinding( binding ); + this._removeInactiveBinding( binding ); } @@ -40497,8 +40359,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { // free all resources specific to a particular clip uncacheClip: function ( clip ) { - var this$1 = this; - var actions = this._actions, clipUuid = clip.uuid, @@ -40517,7 +40377,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { var action = actionsToRemove[ i ]; - this$1._deactivateAction( action ); + this._deactivateAction( action ); var cacheIndex = action._cacheIndex, lastInactiveAction = actions[ actions.length - 1 ]; @@ -40529,7 +40389,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { actions[ cacheIndex ] = lastInactiveAction; actions.pop(); - this$1._removeInactiveBindingsForAction( action ); + this._removeInactiveBindingsForAction( action ); } @@ -40541,8 +40401,6 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { // free all resources specific to a particular root target object uncacheRoot: function ( root ) { - var this$1 = this; - var rootUuid = root.uuid, actionsByClip = this._actionsByClip; @@ -40554,8 +40412,8 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { if ( action !== undefined ) { - this$1._deactivateAction( action ); - this$1._removeInactiveAction( action ); + this._deactivateAction( action ); + this._removeInactiveAction( action ); } @@ -40570,7 +40428,7 @@ Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, { var binding = bindingByName[ trackName ]; binding.restoreOriginalState(); - this$1._removeInactiveBinding( binding ); + this._removeInactiveBinding( binding ); } @@ -40860,15 +40718,13 @@ Object.assign( InterleavedBuffer.prototype, { }, copyAt: function ( index1, attribute, index2 ) { - var this$1 = this; - index1 *= this.stride; index2 *= attribute.stride; for ( var i = 0, l = this.stride; i < l; i ++ ) { - this$1.array[ index1 + i ] = attribute.array[ index2 + i ]; + this.array[ index1 + i ] = attribute.array[ index2 + i ]; } @@ -41068,8 +40924,6 @@ Object.assign( Raycaster.prototype, { }, intersectObjects: function ( objects, recursive ) { - var this$1 = this; - var intersects = []; @@ -41082,7 +40936,7 @@ Object.assign( Raycaster.prototype, { for ( var i = 0, l = objects.length; i < l; i ++ ) { - intersectObject( objects[ i ], this$1, intersects, recursive ); + intersectObject( objects[ i ], this, intersects, recursive ); } @@ -41379,8 +41233,6 @@ VertexNormalsHelper.prototype.update = ( function () { var normalMatrix = new Matrix3(); return function update() { - var this$1 = this; - var keys = [ 'a', 'b', 'c' ]; @@ -41416,7 +41268,7 @@ VertexNormalsHelper.prototype.update = ( function () { v1.copy( vertex ).applyMatrix4( matrixWorld ); - v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this$1.size ).add( v1 ); + v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 ); position.setXYZ( idx, v1.x, v1.y, v1.z ); @@ -41446,7 +41298,7 @@ VertexNormalsHelper.prototype.update = ( function () { v2.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) ); - v2.applyMatrix3( normalMatrix ).normalize().multiplyScalar( this$1.size ).add( v1 ); + v2.applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 ); position.setXYZ( idx, v1.x, v1.y, v1.z ); @@ -42113,8 +41965,6 @@ FaceNormalsHelper.prototype.update = ( function () { var normalMatrix = new Matrix3(); return function update() { - var this$1 = this; - this.object.updateMatrixWorld( true ); @@ -42146,7 +41996,7 @@ FaceNormalsHelper.prototype.update = ( function () { .divideScalar( 3 ) .applyMatrix4( matrixWorld ); - v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this$1.size ).add( v1 ); + v2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 ); position.setXYZ( idx, v1.x, v1.y, v1.z ); @@ -42980,8 +42830,6 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) { }; CatmullRomCurve3.prototype.copy = function ( source ) { - var this$1 = this; - Curve.prototype.copy.call( this, source ); @@ -42991,7 +42839,7 @@ CatmullRomCurve3.prototype.copy = function ( source ) { var point = source.points[ i ]; - this$1.points.push( point.clone() ); + this.points.push( point.clone() ); } @@ -45243,6 +45091,9 @@ var INTERACTIVE_MARKER_MOVE_AXIS = 3; var INTERACTIVE_MARKER_MOVE_PLANE = 4; var INTERACTIVE_MARKER_ROTATE_AXIS = 5; var INTERACTIVE_MARKER_MOVE_ROTATE = 6; +var INTERACTIVE_MARKER_MOVE_3D = 7; +var INTERACTIVE_MARKER_ROTATE_3D = 8; +var INTERACTIVE_MARKER_MOVE_ROTATE_3D = 9; // Interactive marker rotation behavior var INTERACTIVE_MARKER_INHERIT = 0; @@ -45376,7 +45227,7 @@ var closestAxisPoint = function(axisRay, camera, mousePos) { * @author Julius Kammerl - jkammerl@willowgarage.com */ -var DepthCloud = (function (superclass) { +var DepthCloud = /*@__PURE__*/(function (superclass) { function DepthCloud(options) { superclass.call(this); options = options || {}; @@ -45388,6 +45239,7 @@ var DepthCloud = (function (superclass) { this.pointSize = options.pointSize || 3; this.width = options.width || 1024; this.height = options.height || 1024; + this.resolutionFactor = Math.max(this.width, this.height) / 1024; this.whiteness = options.whiteness || 0; this.varianceThreshold = options.varianceThreshold || 0.000016667; @@ -45417,6 +45269,7 @@ var DepthCloud = (function (superclass) { '', 'uniform float focallength;', 'uniform float maxDepthPerTile;', + 'uniform float resolutionFactor;', '', 'varying vec2 vUvP;', 'varying vec2 colorP;', @@ -45520,8 +45373,8 @@ var DepthCloud = (function (superclass) { ' float z = -depth;', ' ', ' pos = vec4(', - ' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength) * -1.0,', - ' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength),', + ' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength) * -1.0,', + ' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength),', ' (- z + zOffset / 1000.0) * maxDepthPerTile,', ' 1.0);', ' ', @@ -45591,8 +45444,6 @@ var DepthCloud = (function (superclass) { * Callback called when video metadata is ready */ DepthCloud.prototype.initStreamer = function initStreamer () { - var this$1 = this; - if (this.metaLoaded) { this.texture = new THREE$1.Texture(this.video); @@ -45601,10 +45452,10 @@ var DepthCloud = (function (superclass) { for (var i = 0, l = this.width * this.height; i < l; i++) { var vertex = new THREE$1.Vector3(); - vertex.x = (i % this$1.width); - vertex.y = Math.floor(i / this$1.width); + vertex.x = (i % this.width); + vertex.y = Math.floor(i / this.width); - this$1.geometry.vertices.push(vertex); + this.geometry.vertices.push(vertex); } this.material = new THREE$1.ShaderMaterial({ @@ -45645,6 +45496,10 @@ var DepthCloud = (function (superclass) { type : 'f', value : this.maxDepthPerTile }, + 'resolutionFactor': { + type : 'f', + value : this.resolutionFactor + }, }, vertexShader : this.vertex_shader, fragmentShader : this.fragment_shader @@ -45688,7 +45543,7 @@ var DepthCloud = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var Arrow = (function (superclass) { +var Arrow = /*@__PURE__*/(function (superclass) { function Arrow(options) { options = options || {}; var origin = options.origin || new THREE$1.Vector3(0, 0, 0); @@ -49559,7 +49414,7 @@ THREE$1.ColladaLoader.prototype = { * @author Russell Toris - rctoris@wpi.edu */ -var MeshResource = (function (superclass) { +var MeshResource = /*@__PURE__*/(function (superclass) { function MeshResource(options) { superclass.call(this); var that = this; @@ -49642,7 +49497,7 @@ var MeshResource = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var TriangleList = (function (superclass) { +var TriangleList = /*@__PURE__*/(function (superclass) { function TriangleList(options) { options = options || {}; var material = options.material || new THREE$1.MeshBasicMaterial(); @@ -49717,7 +49572,7 @@ var TriangleList = (function (superclass) { * @author Russell Toris - rctoris@wpi.edu */ -var Marker = (function (superclass) { +var Marker = /*@__PURE__*/(function (superclass) { function Marker(options) { superclass.call(this); @@ -50201,7 +50056,7 @@ var Marker = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var InteractiveMarkerControl = (function (superclass) { +var InteractiveMarkerControl = /*@__PURE__*/(function (superclass) { function InteractiveMarkerControl(options) { superclass.call(this); var that = this; @@ -50217,6 +50072,8 @@ var InteractiveMarkerControl = (function (superclass) { this.loader = options.loader; this.dragging = false; this.startMousePos = new THREE$1.Vector2(); + this.isShift = false; + // orientation for the control var controlOri = new THREE$1.Quaternion(message.orientation.x, message.orientation.y, @@ -50231,6 +50088,9 @@ var InteractiveMarkerControl = (function (superclass) { // determine mouse interaction switch (message.interaction_mode) { + case INTERACTIVE_MARKER_MOVE_ROTATE_3D: + case INTERACTIVE_MARKER_MOVE_3D: + this.addEventListener('mousemove', this.parent.move3d.bind(this.parent, this, controlAxis)); case INTERACTIVE_MARKER_MOVE_AXIS: this.addEventListener('mousemove', this.parent.moveAxis.bind(this.parent, this, controlAxis)); this.addEventListener('touchmove', this.parent.moveAxis.bind(this.parent, this, controlAxis)); @@ -50301,6 +50161,17 @@ var InteractiveMarkerControl = (function (superclass) { that.dispatchEvent(event3d); } }); + + window.addEventListener('keydown', function(event){ + if(event.keyCode === 16){ + that.isShift = true; + } + }); + window.addEventListener('keyup', function(event){ + if(event.keyCode === 16){ + that.isShift = false; + } + }); } // rotation behavior @@ -50447,7 +50318,7 @@ var InteractiveMarkerControl = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var InteractiveMarkerMenu = (function (superclass) { +var InteractiveMarkerMenu = /*@__PURE__*/(function (superclass) { function InteractiveMarkerMenu(options) { superclass.call(this); var that = this; @@ -50621,7 +50492,7 @@ var InteractiveMarkerMenu = (function (superclass) { * @author David Gossow - dgossow@willowgarage.com */ -var InteractiveMarker = (function (superclass) { +var InteractiveMarker = /*@__PURE__*/(function (superclass) { function InteractiveMarker(options) { superclass.call(this); @@ -50718,6 +50589,53 @@ var InteractiveMarker = (function (superclass) { event3d.stopPropagation(); } }; + + /** + * Move with respect to the plane based on the contorl and event. + * + * @param control - the control to use + * @param origNormal - the normal of the origin + * @param event3d - the event that caused this + */ + InteractiveMarker.prototype.move3d = function move3d (control, origNormal, event3d) { + // by default, move in a plane + if (this.dragging) { + + if(control.isShift){ + // this doesn't work + // // use the camera position and the marker position to determine the axis + // var newAxis = control.camera.position.clone(); + // newAxis.sub(this.position); + // // now mimic same steps constructor uses to create origAxis + // var controlOri = new THREE.Quaternion(newAxis.x, newAxis.y, + // newAxis.z, 1); + // controlOri.normalize(); + // var controlAxis = new THREE.Vector3(1, 0, 0); + // controlAxis.applyQuaternion(controlOri); + // origAxis = controlAxis; + }else{ + // we want to use the origin plane that is closest to the camera + var cameraVector = control.camera.getWorldDirection(); + var x = Math.abs(cameraVector.x); + var y = Math.abs(cameraVector.y); + var z = Math.abs(cameraVector.z); + var controlOri = new THREE$1.Quaternion(1, 0, 0, 1); + if(y > x && y > z){ + // orientation for the control + controlOri = new THREE$1.Quaternion(0, 0, 1, 1); + }else if(z > x && z > y){ + // orientation for the control + controlOri = new THREE$1.Quaternion(0, 1, 0, 1); + } + controlOri.normalize(); + + // transform x axis into local frame + origNormal = new THREE$1.Vector3(1, 0, 0); + origNormal.applyQuaternion(controlOri); + this.movePlane(control, origNormal, event3d); + } + } + }; /** * Move with respect to the plane based on the contorl and event. * @@ -50921,728 +50839,720 @@ function createCommonjsModule(fn, module) { } var eventemitter2 = createCommonjsModule(function (module, exports) { -!function(undefined) { - - var isArray = Array.isArray ? Array.isArray : function _isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]"; - }; - var defaultMaxListeners = 10; - - function init() { - this._events = {}; - if (this._conf) { - configure.call(this, this._conf); - } - } - - function configure(conf) { - if (conf) { - this._conf = conf; - - conf.delimiter && (this.delimiter = conf.delimiter); - this._events.maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners; - conf.wildcard && (this.wildcard = conf.wildcard); - conf.newListener && (this.newListener = conf.newListener); - conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak); - - if (this.wildcard) { - this.listenerTree = {}; - } - } else { - this._events.maxListeners = defaultMaxListeners; - } - } - - function logPossibleMemoryLeak(count, eventName) { - var errorMsg = '(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.'; - - if(this.verboseMemoryLeak){ - errorMsg += ' Event name: %s.'; - console.error(errorMsg, count, eventName); - } else { - console.error(errorMsg, count); - } - - if (console.trace){ - console.trace(); - } - } - - function EventEmitter(conf) { - this._events = {}; - this.newListener = false; - this.verboseMemoryLeak = false; - configure.call(this, conf); - } - EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property - - // - // Attention, function return type now is array, always ! - // It has zero elements if no any matches found and one or more - // elements (leafs) if there are matches - // - function searchListenerTree(handlers, type, tree, i) { - if (!tree) { - return []; - } - var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached, - typeLength = type.length, currentType = type[i], nextType = type[i+1]; - if (i === typeLength && tree._listeners) { - // - // If at the end of the event(s) list and the tree has listeners - // invoke those listeners. - // - if (typeof tree._listeners === 'function') { - handlers && handlers.push(tree._listeners); - return [tree]; - } else { - for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) { - handlers && handlers.push(tree._listeners[leaf]); - } - return [tree]; - } - } - - if ((currentType === '*' || currentType === '**') || tree[currentType]) { - // - // If the event emitted is '*' at this part - // or there is a concrete match at this patch - // - if (currentType === '*') { - for (branch in tree) { - if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1)); - } - } - return listeners; - } else if(currentType === '**') { - endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*')); - if(endReached && tree._listeners) { - // The next element has a _listeners, add it to the handlers. - listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength)); - } - - for (branch in tree) { - if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { - if(branch === '*' || branch === '**') { - if(tree[branch]._listeners && !endReached) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength)); - } - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); - } else if(branch === nextType) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2)); - } else { - // No match on this one, shift into the tree but not in the type array. - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); - } - } - } - return listeners; - } - - listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1)); - } - - xTree = tree['*']; - if (xTree) { - // - // If the listener tree will allow any match for this part, - // then recursively explore all branches of the tree - // - searchListenerTree(handlers, type, xTree, i+1); - } - - xxTree = tree['**']; - if(xxTree) { - if(i < typeLength) { - if(xxTree._listeners) { - // If we have a listener on a '**', it will catch all, so add its handler. - searchListenerTree(handlers, type, xxTree, typeLength); - } - - // Build arrays of matching next branches and others. - for(branch in xxTree) { - if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) { - if(branch === nextType) { - // We know the next element will match, so jump twice. - searchListenerTree(handlers, type, xxTree[branch], i+2); - } else if(branch === currentType) { - // Current node matches, move into the tree. - searchListenerTree(handlers, type, xxTree[branch], i+1); - } else { - isolatedBranch = {}; - isolatedBranch[branch] = xxTree[branch]; - searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1); - } - } - } - } else if(xxTree._listeners) { - // We have reached the end and still on a '**' - searchListenerTree(handlers, type, xxTree, typeLength); - } else if(xxTree['*'] && xxTree['*']._listeners) { - searchListenerTree(handlers, type, xxTree['*'], typeLength); - } - } - - return listeners; - } - - function growListenerTree(type, listener) { - var this$1 = this; - - - type = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - - // - // Looks for two consecutive '**', if so, don't add the event at all. - // - for(var i = 0, len = type.length; i+1 < len; i++) { - if(type[i] === '**' && type[i+1] === '**') { - return; - } - } - - var tree = this.listenerTree; - var name = type.shift(); - - while (name !== undefined) { - - if (!tree[name]) { - tree[name] = {}; - } - - tree = tree[name]; - - if (type.length === 0) { - - if (!tree._listeners) { - tree._listeners = listener; - } - else { - if (typeof tree._listeners === 'function') { - tree._listeners = [tree._listeners]; - } - - tree._listeners.push(listener); - - if ( - !tree._listeners.warned && - this$1._events.maxListeners > 0 && - tree._listeners.length > this$1._events.maxListeners - ) { - tree._listeners.warned = true; - logPossibleMemoryLeak.call(this$1, tree._listeners.length, name); - } - } - return true; - } - name = type.shift(); - } - return true; - } - - // By default EventEmitters will print a warning if more than - // 10 listeners are added to it. This is a useful default which - // helps finding memory leaks. - // - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - - EventEmitter.prototype.delimiter = '.'; - - EventEmitter.prototype.setMaxListeners = function(n) { - if (n !== undefined) { - this._events || init.call(this); - this._events.maxListeners = n; - if (!this._conf) { this._conf = {}; } - this._conf.maxListeners = n; - } - }; - - EventEmitter.prototype.event = ''; - - EventEmitter.prototype.once = function(event, fn) { - this.many(event, 1, fn); - return this; - }; - - EventEmitter.prototype.many = function(event, ttl, fn) { - var self = this; - - if (typeof fn !== 'function') { - throw new Error('many only accepts instances of Function'); - } - - function listener() { - if (--ttl === 0) { - self.off(event, listener); - } - fn.apply(this, arguments); - } - - listener._origin = fn; - - this.on(event, listener); - - return self; - }; - +!function(undefined) { + + var isArray = Array.isArray ? Array.isArray : function _isArray(obj) { + return Object.prototype.toString.call(obj) === "[object Array]"; + }; + var defaultMaxListeners = 10; + + function init() { + this._events = {}; + if (this._conf) { + configure.call(this, this._conf); + } + } + + function configure(conf) { + if (conf) { + this._conf = conf; + + conf.delimiter && (this.delimiter = conf.delimiter); + this._events.maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners; + conf.wildcard && (this.wildcard = conf.wildcard); + conf.newListener && (this.newListener = conf.newListener); + conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak); + + if (this.wildcard) { + this.listenerTree = {}; + } + } else { + this._events.maxListeners = defaultMaxListeners; + } + } + + function logPossibleMemoryLeak(count, eventName) { + var errorMsg = '(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.'; + + if(this.verboseMemoryLeak){ + errorMsg += ' Event name: %s.'; + console.error(errorMsg, count, eventName); + } else { + console.error(errorMsg, count); + } + + if (console.trace){ + console.trace(); + } + } + + function EventEmitter(conf) { + this._events = {}; + this.newListener = false; + this.verboseMemoryLeak = false; + configure.call(this, conf); + } + EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property + + // + // Attention, function return type now is array, always ! + // It has zero elements if no any matches found and one or more + // elements (leafs) if there are matches + // + function searchListenerTree(handlers, type, tree, i) { + if (!tree) { + return []; + } + var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached, + typeLength = type.length, currentType = type[i], nextType = type[i+1]; + if (i === typeLength && tree._listeners) { + // + // If at the end of the event(s) list and the tree has listeners + // invoke those listeners. + // + if (typeof tree._listeners === 'function') { + handlers && handlers.push(tree._listeners); + return [tree]; + } else { + for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) { + handlers && handlers.push(tree._listeners[leaf]); + } + return [tree]; + } + } + + if ((currentType === '*' || currentType === '**') || tree[currentType]) { + // + // If the event emitted is '*' at this part + // or there is a concrete match at this patch + // + if (currentType === '*') { + for (branch in tree) { + if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1)); + } + } + return listeners; + } else if(currentType === '**') { + endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*')); + if(endReached && tree._listeners) { + // The next element has a _listeners, add it to the handlers. + listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength)); + } + + for (branch in tree) { + if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { + if(branch === '*' || branch === '**') { + if(tree[branch]._listeners && !endReached) { + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength)); + } + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); + } else if(branch === nextType) { + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2)); + } else { + // No match on this one, shift into the tree but not in the type array. + listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); + } + } + } + return listeners; + } + + listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1)); + } + + xTree = tree['*']; + if (xTree) { + // + // If the listener tree will allow any match for this part, + // then recursively explore all branches of the tree + // + searchListenerTree(handlers, type, xTree, i+1); + } + + xxTree = tree['**']; + if(xxTree) { + if(i < typeLength) { + if(xxTree._listeners) { + // If we have a listener on a '**', it will catch all, so add its handler. + searchListenerTree(handlers, type, xxTree, typeLength); + } + + // Build arrays of matching next branches and others. + for(branch in xxTree) { + if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) { + if(branch === nextType) { + // We know the next element will match, so jump twice. + searchListenerTree(handlers, type, xxTree[branch], i+2); + } else if(branch === currentType) { + // Current node matches, move into the tree. + searchListenerTree(handlers, type, xxTree[branch], i+1); + } else { + isolatedBranch = {}; + isolatedBranch[branch] = xxTree[branch]; + searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1); + } + } + } + } else if(xxTree._listeners) { + // We have reached the end and still on a '**' + searchListenerTree(handlers, type, xxTree, typeLength); + } else if(xxTree['*'] && xxTree['*']._listeners) { + searchListenerTree(handlers, type, xxTree['*'], typeLength); + } + } + + return listeners; + } + + function growListenerTree(type, listener) { + + type = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + + // + // Looks for two consecutive '**', if so, don't add the event at all. + // + for(var i = 0, len = type.length; i+1 < len; i++) { + if(type[i] === '**' && type[i+1] === '**') { + return; + } + } + + var tree = this.listenerTree; + var name = type.shift(); + + while (name !== undefined) { + + if (!tree[name]) { + tree[name] = {}; + } + + tree = tree[name]; + + if (type.length === 0) { + + if (!tree._listeners) { + tree._listeners = listener; + } + else { + if (typeof tree._listeners === 'function') { + tree._listeners = [tree._listeners]; + } + + tree._listeners.push(listener); + + if ( + !tree._listeners.warned && + this._events.maxListeners > 0 && + tree._listeners.length > this._events.maxListeners + ) { + tree._listeners.warned = true; + logPossibleMemoryLeak.call(this, tree._listeners.length, name); + } + } + return true; + } + name = type.shift(); + } + return true; + } + + // By default EventEmitters will print a warning if more than + // 10 listeners are added to it. This is a useful default which + // helps finding memory leaks. + // + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + + EventEmitter.prototype.delimiter = '.'; + + EventEmitter.prototype.setMaxListeners = function(n) { + if (n !== undefined) { + this._events || init.call(this); + this._events.maxListeners = n; + if (!this._conf) { this._conf = {}; } + this._conf.maxListeners = n; + } + }; + + EventEmitter.prototype.event = ''; + + EventEmitter.prototype.once = function(event, fn) { + this.many(event, 1, fn); + return this; + }; + + EventEmitter.prototype.many = function(event, ttl, fn) { + var self = this; + + if (typeof fn !== 'function') { + throw new Error('many only accepts instances of Function'); + } + + function listener() { + if (--ttl === 0) { + self.off(event, listener); + } + fn.apply(this, arguments); + } + + listener._origin = fn; + + this.on(event, listener); + + return self; + }; + EventEmitter.prototype.emit = function() { var arguments$1 = arguments; - var this$1 = this; - - - this._events || init.call(this); - - var type = arguments[0]; - - if (type === 'newListener' && !this.newListener) { - if (!this._events.newListener) { - return false; - } - } - - var al = arguments.length; - var args,l,i,j; - var handler; - - if (this._all && this._all.length) { - handler = this._all.slice(); - if (al > 3) { - args = new Array(al); - for (j = 0; j < al; j++) { args[j] = arguments$1[j]; } - } - - for (i = 0, l = handler.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - handler[i].call(this$1, type); - break; - case 2: - handler[i].call(this$1, type, arguments$1[1]); - break; - case 3: - handler[i].call(this$1, type, arguments$1[1], arguments$1[2]); - break; - default: - handler[i].apply(this$1, args); - } - } - } - - if (this.wildcard) { - handler = []; - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - searchListenerTree.call(this, handler, ns, this.listenerTree, 0); - } else { - handler = this._events[type]; - if (typeof handler === 'function') { - this.event = type; - switch (al) { - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - default: - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - handler.apply(this, args); - } - return true; - } else if (handler) { - // need to make copy of handlers because list can change in the middle - // of emit call - handler = handler.slice(); - } - } - - if (handler && handler.length) { - if (al > 3) { - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - } - for (i = 0, l = handler.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - handler[i].call(this$1); - break; - case 2: - handler[i].call(this$1, arguments$1[1]); - break; - case 3: - handler[i].call(this$1, arguments$1[1], arguments$1[2]); - break; - default: - handler[i].apply(this$1, args); - } - } - return true; - } else if (!this._all && type === 'error') { - if (arguments[1] instanceof Error) { - throw arguments[1]; // Unhandled 'error' event - } else { - throw new Error("Uncaught, unspecified 'error' event."); - } - return false; - } - - return !!this._all; - }; - + + + this._events || init.call(this); + + var type = arguments[0]; + + if (type === 'newListener' && !this.newListener) { + if (!this._events.newListener) { + return false; + } + } + + var al = arguments.length; + var args,l,i,j; + var handler; + + if (this._all && this._all.length) { + handler = this._all.slice(); + if (al > 3) { + args = new Array(al); + for (j = 0; j < al; j++) { args[j] = arguments$1[j]; } + } + + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + handler[i].call(this, type); + break; + case 2: + handler[i].call(this, type, arguments$1[1]); + break; + case 3: + handler[i].call(this, type, arguments$1[1], arguments$1[2]); + break; + default: + handler[i].apply(this, args); + } + } + } + + if (this.wildcard) { + handler = []; + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + searchListenerTree.call(this, handler, ns, this.listenerTree, 0); + } else { + handler = this._events[type]; + if (typeof handler === 'function') { + this.event = type; + switch (al) { + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + default: + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + handler.apply(this, args); + } + return true; + } else if (handler) { + // need to make copy of handlers because list can change in the middle + // of emit call + handler = handler.slice(); + } + } + + if (handler && handler.length) { + if (al > 3) { + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + } + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + handler[i].call(this); + break; + case 2: + handler[i].call(this, arguments$1[1]); + break; + case 3: + handler[i].call(this, arguments$1[1], arguments$1[2]); + break; + default: + handler[i].apply(this, args); + } + } + return true; + } else if (!this._all && type === 'error') { + if (arguments[1] instanceof Error) { + throw arguments[1]; // Unhandled 'error' event + } else { + throw new Error("Uncaught, unspecified 'error' event."); + } + return false; + } + + return !!this._all; + }; + EventEmitter.prototype.emitAsync = function() { var arguments$1 = arguments; - var this$1 = this; - - - this._events || init.call(this); - - var type = arguments[0]; - - if (type === 'newListener' && !this.newListener) { - if (!this._events.newListener) { return Promise.resolve([false]); } - } - - var promises= []; - - var al = arguments.length; - var args,l,i,j; - var handler; - - if (this._all) { - if (al > 3) { - args = new Array(al); - for (j = 1; j < al; j++) { args[j] = arguments$1[j]; } - } - for (i = 0, l = this._all.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - promises.push(this$1._all[i].call(this$1, type)); - break; - case 2: - promises.push(this$1._all[i].call(this$1, type, arguments$1[1])); - break; - case 3: - promises.push(this$1._all[i].call(this$1, type, arguments$1[1], arguments$1[2])); - break; - default: - promises.push(this$1._all[i].apply(this$1, args)); - } - } - } - - if (this.wildcard) { - handler = []; - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - searchListenerTree.call(this, handler, ns, this.listenerTree, 0); - } else { - handler = this._events[type]; - } - - if (typeof handler === 'function') { - this.event = type; - switch (al) { - case 1: - promises.push(handler.call(this)); - break; - case 2: - promises.push(handler.call(this, arguments[1])); - break; - case 3: - promises.push(handler.call(this, arguments[1], arguments[2])); - break; - default: - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - promises.push(handler.apply(this, args)); - } - } else if (handler && handler.length) { - if (al > 3) { - args = new Array(al - 1); - for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } - } - for (i = 0, l = handler.length; i < l; i++) { - this$1.event = type; - switch (al) { - case 1: - promises.push(handler[i].call(this$1)); - break; - case 2: - promises.push(handler[i].call(this$1, arguments$1[1])); - break; - case 3: - promises.push(handler[i].call(this$1, arguments$1[1], arguments$1[2])); - break; - default: - promises.push(handler[i].apply(this$1, args)); - } - } - } else if (!this._all && type === 'error') { - if (arguments[1] instanceof Error) { - return Promise.reject(arguments[1]); // Unhandled 'error' event - } else { - return Promise.reject("Uncaught, unspecified 'error' event."); - } - } - - return Promise.all(promises); - }; - - EventEmitter.prototype.on = function(type, listener) { - if (typeof type === 'function') { - this.onAny(type); - return this; - } - - if (typeof listener !== 'function') { - throw new Error('on only accepts instances of Function'); - } - this._events || init.call(this); - - // To avoid recursion in the case that type == "newListeners"! Before - // adding it to the listeners, first emit "newListeners". - this.emit('newListener', type, listener); - - if (this.wildcard) { - growListenerTree.call(this, type, listener); - return this; - } - - if (!this._events[type]) { - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - } - else { - if (typeof this._events[type] === 'function') { - // Change to array. - this._events[type] = [this._events[type]]; - } - - // If we've already got an array, just append. - this._events[type].push(listener); - - // Check for listener leak - if ( - !this._events[type].warned && - this._events.maxListeners > 0 && - this._events[type].length > this._events.maxListeners - ) { - this._events[type].warned = true; - logPossibleMemoryLeak.call(this, this._events[type].length, type); - } - } - - return this; - }; - - EventEmitter.prototype.onAny = function(fn) { - if (typeof fn !== 'function') { - throw new Error('onAny only accepts instances of Function'); - } - - if (!this._all) { - this._all = []; - } - - // Add the function to the event listener collection. - this._all.push(fn); - return this; - }; - - EventEmitter.prototype.addListener = EventEmitter.prototype.on; - - EventEmitter.prototype.off = function(type, listener) { - var this$1 = this; - - if (typeof listener !== 'function') { - throw new Error('removeListener only takes instances of Function'); - } - - var handlers,leafs=[]; - - if(this.wildcard) { - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); - } - else { - // does not use listeners(), so no side effect of creating _events[type] - if (!this._events[type]) { return this; } - handlers = this._events[type]; - leafs.push({_listeners:handlers}); - } - - for (var iLeaf=0; iLeaf 0) { - recursivelyGarbageCollect(root[key]); - } - if (Object.keys(obj).length === 0) { - delete root[key]; - } - } - } - recursivelyGarbageCollect(this.listenerTree); - - return this; - }; - - EventEmitter.prototype.offAny = function(fn) { - var this$1 = this; - - var i = 0, l = 0, fns; - if (fn && this._all && this._all.length > 0) { - fns = this._all; - for(i = 0, l = fns.length; i < l; i++) { - if(fn === fns[i]) { - fns.splice(i, 1); - this$1.emit("removeListenerAny", fn); - return this$1; - } - } - } else { - fns = this._all; - for(i = 0, l = fns.length; i < l; i++) - { this$1.emit("removeListenerAny", fns[i]); } - this._all = []; - } - return this; - }; - - EventEmitter.prototype.removeListener = EventEmitter.prototype.off; - - EventEmitter.prototype.removeAllListeners = function(type) { - if (arguments.length === 0) { - !this._events || init.call(this); - return this; - } - - if (this.wildcard) { - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); - - for (var iLeaf=0; iLeaf 3) { + args = new Array(al); + for (j = 1; j < al; j++) { args[j] = arguments$1[j]; } + } + for (i = 0, l = this._all.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + promises.push(this._all[i].call(this, type)); + break; + case 2: + promises.push(this._all[i].call(this, type, arguments$1[1])); + break; + case 3: + promises.push(this._all[i].call(this, type, arguments$1[1], arguments$1[2])); + break; + default: + promises.push(this._all[i].apply(this, args)); + } + } + } + + if (this.wildcard) { + handler = []; + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + searchListenerTree.call(this, handler, ns, this.listenerTree, 0); + } else { + handler = this._events[type]; + } + + if (typeof handler === 'function') { + this.event = type; + switch (al) { + case 1: + promises.push(handler.call(this)); + break; + case 2: + promises.push(handler.call(this, arguments[1])); + break; + case 3: + promises.push(handler.call(this, arguments[1], arguments[2])); + break; + default: + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + promises.push(handler.apply(this, args)); + } + } else if (handler && handler.length) { + if (al > 3) { + args = new Array(al - 1); + for (j = 1; j < al; j++) { args[j - 1] = arguments$1[j]; } + } + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + promises.push(handler[i].call(this)); + break; + case 2: + promises.push(handler[i].call(this, arguments$1[1])); + break; + case 3: + promises.push(handler[i].call(this, arguments$1[1], arguments$1[2])); + break; + default: + promises.push(handler[i].apply(this, args)); + } + } + } else if (!this._all && type === 'error') { + if (arguments[1] instanceof Error) { + return Promise.reject(arguments[1]); // Unhandled 'error' event + } else { + return Promise.reject("Uncaught, unspecified 'error' event."); + } + } + + return Promise.all(promises); + }; + + EventEmitter.prototype.on = function(type, listener) { + if (typeof type === 'function') { + this.onAny(type); + return this; + } + + if (typeof listener !== 'function') { + throw new Error('on only accepts instances of Function'); + } + this._events || init.call(this); + + // To avoid recursion in the case that type == "newListeners"! Before + // adding it to the listeners, first emit "newListeners". + this.emit('newListener', type, listener); + + if (this.wildcard) { + growListenerTree.call(this, type, listener); + return this; + } + + if (!this._events[type]) { + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + } + else { + if (typeof this._events[type] === 'function') { + // Change to array. + this._events[type] = [this._events[type]]; + } + + // If we've already got an array, just append. + this._events[type].push(listener); + + // Check for listener leak + if ( + !this._events[type].warned && + this._events.maxListeners > 0 && + this._events[type].length > this._events.maxListeners + ) { + this._events[type].warned = true; + logPossibleMemoryLeak.call(this, this._events[type].length, type); + } + } + + return this; + }; + + EventEmitter.prototype.onAny = function(fn) { + if (typeof fn !== 'function') { + throw new Error('onAny only accepts instances of Function'); + } + + if (!this._all) { + this._all = []; + } + + // Add the function to the event listener collection. + this._all.push(fn); + return this; + }; + + EventEmitter.prototype.addListener = EventEmitter.prototype.on; + + EventEmitter.prototype.off = function(type, listener) { + if (typeof listener !== 'function') { + throw new Error('removeListener only takes instances of Function'); + } + + var handlers,leafs=[]; + + if(this.wildcard) { + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); + } + else { + // does not use listeners(), so no side effect of creating _events[type] + if (!this._events[type]) { return this; } + handlers = this._events[type]; + leafs.push({_listeners:handlers}); + } + + for (var iLeaf=0; iLeaf 0) { + recursivelyGarbageCollect(root[key]); + } + if (Object.keys(obj).length === 0) { + delete root[key]; + } + } + } + recursivelyGarbageCollect(this.listenerTree); + + return this; + }; + + EventEmitter.prototype.offAny = function(fn) { + var i = 0, l = 0, fns; + if (fn && this._all && this._all.length > 0) { + fns = this._all; + for(i = 0, l = fns.length; i < l; i++) { + if(fn === fns[i]) { + fns.splice(i, 1); + this.emit("removeListenerAny", fn); + return this; + } + } + } else { + fns = this._all; + for(i = 0, l = fns.length; i < l; i++) + { this.emit("removeListenerAny", fns[i]); } + this._all = []; + } + return this; + }; + + EventEmitter.prototype.removeListener = EventEmitter.prototype.off; + + EventEmitter.prototype.removeAllListeners = function(type) { + if (arguments.length === 0) { + !this._events || init.call(this); + return this; + } + + if (this.wildcard) { + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); + + for (var iLeaf=0; iLeaf= message.range_min && range <= message.range_max){ var angle = message.angle_min + i * message.angle_increment; - this$1.points.positions.array[j++] = range * Math.cos(angle); - this$1.points.positions.array[j++] = range * Math.sin(angle); - this$1.points.positions.array[j++] = 0.0; + this.points.positions.array[j++] = range * Math.cos(angle); + this.points.positions.array[j++] = range * Math.sin(angle); + this.points.positions.array[j++] = 0.0; } } this.points.update(j/3); @@ -53281,7 +53172,7 @@ decode64.e={}; for(var i=0;i<64;i++){decode64.e[decode64.S.charAt(i)]=i;} -var PointCloud2 = (function (superclass) { +var PointCloud2 = /*@__PURE__*/(function (superclass) { function PointCloud2(options) { superclass.call(this); options = options || {}; @@ -53313,8 +53204,6 @@ var PointCloud2 = (function (superclass) { this.rosTopic.subscribe(this.processMessage.bind(this)); }; PointCloud2.prototype.processMessage = function processMessage (msg){ - var this$1 = this; - if(!this.points.setup(msg.header.frame_id, msg.point_step, msg.fields)) { return; } @@ -53337,15 +53226,15 @@ var PointCloud2 = (function (superclass) { var base, color; for(var i = 0; i < n; i++){ base = i * pointRatio * msg.point_step; - this$1.points.positions.array[3*i ] = dv.getFloat32(base+x, littleEndian); - this$1.points.positions.array[3*i + 1] = dv.getFloat32(base+y, littleEndian); - this$1.points.positions.array[3*i + 2] = dv.getFloat32(base+z, littleEndian); - - if(this$1.points.colors){ - color = this$1.points.colormap(this$1.points.getColor(dv,base,littleEndian)); - this$1.points.colors.array[3*i ] = color.r; - this$1.points.colors.array[3*i + 1] = color.g; - this$1.points.colors.array[3*i + 2] = color.b; + this.points.positions.array[3*i ] = dv.getFloat32(base+x, littleEndian); + this.points.positions.array[3*i + 1] = dv.getFloat32(base+y, littleEndian); + this.points.positions.array[3*i + 2] = dv.getFloat32(base+z, littleEndian); + + if(this.points.colors){ + color = this.points.colormap(this.points.getColor(dv,base,littleEndian)); + this.points.colors.array[3*i ] = color.r; + this.points.colors.array[3*i + 1] = color.g; + this.points.colors.array[3*i + 2] = color.b; } } this.points.update(n); @@ -53359,10 +53248,8 @@ var PointCloud2 = (function (superclass) { * @author Russell Toris - rctoris@wpi.edu */ -var Urdf = (function (superclass) { +var Urdf = /*@__PURE__*/(function (superclass) { function Urdf(options) { - var this$1 = this; - options = options || {}; var urdfModel = options.urdfModel; var path = options.path || '/'; @@ -53418,7 +53305,7 @@ var Urdf = (function (superclass) { tfClient : tfClient, object : mesh }); - this$1.add(sceneNode); + this.add(sceneNode); } else { console.warn('Could not load geometry mesh: '+uri); } @@ -53453,7 +53340,7 @@ var Urdf = (function (superclass) { tfClient: tfClient, object: shapeMesh }); - this$1.add(scene); + this.add(scene); } } } @@ -53608,8 +53495,6 @@ Highlighter.prototype.makeEverythingInvisible = function makeEverythingInvisible * @param scene - the object to traverse */ Highlighter.prototype.makeHighlightedVisible = function makeHighlightedVisible (scene) { - var this$1 = this; - var makeVisible = function(currentObject) { if ( currentObject instanceof THREE$1.Mesh || currentObject instanceof THREE$1.Line || currentObject instanceof THREE$1.Sprite ) { @@ -53617,8 +53502,8 @@ Highlighter.prototype.makeHighlightedVisible = function makeHighlightedVisible ( } }; - for (var uuid in this$1.hoverObjs) { - var selectedObject = this$1.hoverObjs[uuid]; + for (var uuid in this.hoverObjs) { + var selectedObject = this.hoverObjs[uuid]; // Make each selected object and all of its children visible selectedObject.visible = true; selectedObject.traverse(makeVisible); @@ -53642,7 +53527,7 @@ Highlighter.prototype.restoreVisibility = function restoreVisibility (scene) { * @author David Gossow - dgossow@willowgarage.com */ -var MouseHandler = (function (superclass) { +var MouseHandler = /*@__PURE__*/(function (superclass) { function MouseHandler(options) { superclass.call(this); this.renderer = options.renderer; @@ -53813,8 +53698,6 @@ var MouseHandler = (function (superclass) { * @returns if an event was canceled */ MouseHandler.prototype.notify = function notify (target, type, event3D) { - var this$1 = this; - // ensure the type is set // event3D.type = type; @@ -53840,7 +53723,7 @@ var MouseHandler = (function (superclass) { && event3D.currentTarget.dispatchEvent instanceof Function) { event3D.currentTarget.dispatchEvent(event3D); if (event3D.cancelBubble) { - this$1.dispatchEvent(event3D); + this.dispatchEvent(event3D); return 0; // Event Accepted } else if(event3D.continueBubble) { @@ -53864,7 +53747,7 @@ var MouseHandler = (function (superclass) { * @author AlteredQualia - http://alteredqualia.com */ -var OrbitControls = (function (superclass) { +var OrbitControls = /*@__PURE__*/(function (superclass) { function OrbitControls(options) { superclass.call(this); var that = this; @@ -54498,4 +54381,4 @@ Viewer.prototype.resize = function resize (width, height) { this.renderer.setSize(width, height); }; -export { REVISION$1 as REVISION, MARKER_ARROW, MARKER_CUBE, MARKER_SPHERE, MARKER_CYLINDER, MARKER_LINE_STRIP, MARKER_LINE_LIST, MARKER_CUBE_LIST, MARKER_SPHERE_LIST, MARKER_POINTS, MARKER_TEXT_VIEW_FACING, MARKER_MESH_RESOURCE, MARKER_TRIANGLE_LIST, INTERACTIVE_MARKER_KEEP_ALIVE, INTERACTIVE_MARKER_POSE_UPDATE, INTERACTIVE_MARKER_MENU_SELECT, INTERACTIVE_MARKER_BUTTON_CLICK, INTERACTIVE_MARKER_MOUSE_DOWN, INTERACTIVE_MARKER_MOUSE_UP, INTERACTIVE_MARKER_NONE, INTERACTIVE_MARKER_MENU, INTERACTIVE_MARKER_BUTTON, INTERACTIVE_MARKER_MOVE_AXIS, INTERACTIVE_MARKER_MOVE_PLANE, INTERACTIVE_MARKER_ROTATE_AXIS, INTERACTIVE_MARKER_MOVE_ROTATE, INTERACTIVE_MARKER_INHERIT, INTERACTIVE_MARKER_FIXED, INTERACTIVE_MARKER_VIEW_FACING, makeColorMaterial, intersectPlane, findClosestPoint, closestAxisPoint, DepthCloud, InteractiveMarker, InteractiveMarkerClient, InteractiveMarkerControl, InteractiveMarkerHandle, InteractiveMarkerMenu, Marker, MarkerArrayClient, MarkerClient, Arrow, Arrow2, Axes, Grid, MeshResource, TriangleList, OccupancyGrid, OccupancyGridClient, Odometry, Path$1 as Path, Point, Polygon, Pose$1 as Pose, PoseArray, PoseWithCovariance, LaserScan, Points$1 as Points, PointCloud2, Urdf, UrdfClient, Highlighter, MouseHandler, OrbitControls, SceneNode, Viewer }; +export { REVISION$1 as REVISION, MARKER_ARROW, MARKER_CUBE, MARKER_SPHERE, MARKER_CYLINDER, MARKER_LINE_STRIP, MARKER_LINE_LIST, MARKER_CUBE_LIST, MARKER_SPHERE_LIST, MARKER_POINTS, MARKER_TEXT_VIEW_FACING, MARKER_MESH_RESOURCE, MARKER_TRIANGLE_LIST, INTERACTIVE_MARKER_KEEP_ALIVE, INTERACTIVE_MARKER_POSE_UPDATE, INTERACTIVE_MARKER_MENU_SELECT, INTERACTIVE_MARKER_BUTTON_CLICK, INTERACTIVE_MARKER_MOUSE_DOWN, INTERACTIVE_MARKER_MOUSE_UP, INTERACTIVE_MARKER_NONE, INTERACTIVE_MARKER_MENU, INTERACTIVE_MARKER_BUTTON, INTERACTIVE_MARKER_MOVE_AXIS, INTERACTIVE_MARKER_MOVE_PLANE, INTERACTIVE_MARKER_ROTATE_AXIS, INTERACTIVE_MARKER_MOVE_ROTATE, INTERACTIVE_MARKER_MOVE_3D, INTERACTIVE_MARKER_ROTATE_3D, INTERACTIVE_MARKER_MOVE_ROTATE_3D, INTERACTIVE_MARKER_INHERIT, INTERACTIVE_MARKER_FIXED, INTERACTIVE_MARKER_VIEW_FACING, makeColorMaterial, intersectPlane, findClosestPoint, closestAxisPoint, DepthCloud, InteractiveMarker, InteractiveMarkerClient, InteractiveMarkerControl, InteractiveMarkerHandle, InteractiveMarkerMenu, Marker, MarkerArrayClient, MarkerClient, Arrow, Arrow2, Axes, Grid, MeshResource, TriangleList, OccupancyGrid, OccupancyGridClient, Odometry, Path$1 as Path, Point, Polygon, Pose$1 as Pose, PoseArray, PoseWithCovariance, LaserScan, Points$1 as Points, PointCloud2, Urdf, UrdfClient, Highlighter, MouseHandler, OrbitControls, SceneNode, Viewer }; diff --git a/build/ros3d.js b/build/ros3d.js index 22cd6a70..c86f459e 100644 --- a/build/ros3d.js +++ b/build/ros3d.js @@ -45079,6 +45079,9 @@ var INTERACTIVE_MARKER_MOVE_AXIS = 3; var INTERACTIVE_MARKER_MOVE_PLANE = 4; var INTERACTIVE_MARKER_ROTATE_AXIS = 5; var INTERACTIVE_MARKER_MOVE_ROTATE = 6; +var INTERACTIVE_MARKER_MOVE_3D = 7; +var INTERACTIVE_MARKER_ROTATE_3D = 8; +var INTERACTIVE_MARKER_MOVE_ROTATE_3D = 9; // Interactive marker rotation behavior var INTERACTIVE_MARKER_INHERIT = 0; @@ -45241,6 +45244,7 @@ class DepthCloud extends THREE$1.Object3D { this.pointSize = options.pointSize || 3; this.width = options.width || 1024; this.height = options.height || 1024; + this.resolutionFactor = Math.max(this.width, this.height) / 1024; this.whiteness = options.whiteness || 0; this.varianceThreshold = options.varianceThreshold || 0.000016667; @@ -45270,6 +45274,7 @@ class DepthCloud extends THREE$1.Object3D { '', 'uniform float focallength;', 'uniform float maxDepthPerTile;', + 'uniform float resolutionFactor;', '', 'varying vec2 vUvP;', 'varying vec2 colorP;', @@ -45373,8 +45378,8 @@ class DepthCloud extends THREE$1.Object3D { ' float z = -depth;', ' ', ' pos = vec4(', - ' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength) * -1.0,', - ' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength),', + ' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength) * -1.0,', + ' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength),', ' (- z + zOffset / 1000.0) * maxDepthPerTile,', ' 1.0);', ' ', @@ -45494,6 +45499,10 @@ class DepthCloud extends THREE$1.Object3D { type : 'f', value : this.maxDepthPerTile }, + 'resolutionFactor': { + type : 'f', + value : this.resolutionFactor + }, }, vertexShader : this.vertex_shader, fragmentShader : this.fragment_shader @@ -50112,6 +50121,8 @@ class InteractiveMarkerControl extends THREE$1.Object3D { this.loader = options.loader; this.dragging = false; this.startMousePos = new THREE$1.Vector2(); + this.isShift = false; + // orientation for the control var controlOri = new THREE$1.Quaternion(message.orientation.x, message.orientation.y, @@ -50126,6 +50137,9 @@ class InteractiveMarkerControl extends THREE$1.Object3D { // determine mouse interaction switch (message.interaction_mode) { + case INTERACTIVE_MARKER_MOVE_ROTATE_3D: + case INTERACTIVE_MARKER_MOVE_3D: + this.addEventListener('mousemove', this.parent.move3d.bind(this.parent, this, controlAxis)); case INTERACTIVE_MARKER_MOVE_AXIS: this.addEventListener('mousemove', this.parent.moveAxis.bind(this.parent, this, controlAxis)); this.addEventListener('touchmove', this.parent.moveAxis.bind(this.parent, this, controlAxis)); @@ -50196,6 +50210,17 @@ class InteractiveMarkerControl extends THREE$1.Object3D { that.dispatchEvent(event3d); } }); + + window.addEventListener('keydown', function(event){ + if(event.keyCode === 16){ + that.isShift = true; + } + }); + window.addEventListener('keyup', function(event){ + if(event.keyCode === 16){ + that.isShift = false; + } + }); } // rotation behavior @@ -50628,6 +50653,54 @@ class InteractiveMarker extends THREE$1.Object3D { } }; + + /** + * Move with respect to the plane based on the contorl and event. + * + * @param control - the control to use + * @param origNormal - the normal of the origin + * @param event3d - the event that caused this + */ + move3d(control, origNormal, event3d) { + // by default, move in a plane + if (this.dragging) { + + if(control.isShift){ + // this doesn't work + // // use the camera position and the marker position to determine the axis + // var newAxis = control.camera.position.clone(); + // newAxis.sub(this.position); + // // now mimic same steps constructor uses to create origAxis + // var controlOri = new THREE.Quaternion(newAxis.x, newAxis.y, + // newAxis.z, 1); + // controlOri.normalize(); + // var controlAxis = new THREE.Vector3(1, 0, 0); + // controlAxis.applyQuaternion(controlOri); + // origAxis = controlAxis; + }else{ + // we want to use the origin plane that is closest to the camera + var cameraVector = control.camera.getWorldDirection(); + var x = Math.abs(cameraVector.x); + var y = Math.abs(cameraVector.y); + var z = Math.abs(cameraVector.z); + var controlOri = new THREE$1.Quaternion(1, 0, 0, 1); + if(y > x && y > z){ + // orientation for the control + controlOri = new THREE$1.Quaternion(0, 0, 1, 1); + }else if(z > x && z > y){ + // orientation for the control + controlOri = new THREE$1.Quaternion(0, 1, 0, 1); + } + controlOri.normalize(); + + // transform x axis into local frame + origNormal = new THREE$1.Vector3(1, 0, 0); + origNormal.applyQuaternion(controlOri); + this.movePlane(control, origNormal, event3d); + } + } + }; + /** * Move with respect to the plane based on the contorl and event. * @@ -50838,716 +50911,716 @@ function createCommonjsModule(fn, module) { } var eventemitter2 = createCommonjsModule(function (module, exports) { -!function(undefined) { - - var isArray = Array.isArray ? Array.isArray : function _isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]"; - }; - var defaultMaxListeners = 10; - - function init() { - this._events = {}; - if (this._conf) { - configure.call(this, this._conf); - } - } - - function configure(conf) { - if (conf) { - this._conf = conf; - - conf.delimiter && (this.delimiter = conf.delimiter); - this._events.maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners; - conf.wildcard && (this.wildcard = conf.wildcard); - conf.newListener && (this.newListener = conf.newListener); - conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak); - - if (this.wildcard) { - this.listenerTree = {}; - } - } else { - this._events.maxListeners = defaultMaxListeners; - } - } - - function logPossibleMemoryLeak(count, eventName) { - var errorMsg = '(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.'; - - if(this.verboseMemoryLeak){ - errorMsg += ' Event name: %s.'; - console.error(errorMsg, count, eventName); - } else { - console.error(errorMsg, count); - } - - if (console.trace){ - console.trace(); - } - } - - function EventEmitter(conf) { - this._events = {}; - this.newListener = false; - this.verboseMemoryLeak = false; - configure.call(this, conf); - } - EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property - - // - // Attention, function return type now is array, always ! - // It has zero elements if no any matches found and one or more - // elements (leafs) if there are matches - // - function searchListenerTree(handlers, type, tree, i) { - if (!tree) { - return []; - } - var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached, - typeLength = type.length, currentType = type[i], nextType = type[i+1]; - if (i === typeLength && tree._listeners) { - // - // If at the end of the event(s) list and the tree has listeners - // invoke those listeners. - // - if (typeof tree._listeners === 'function') { - handlers && handlers.push(tree._listeners); - return [tree]; - } else { - for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) { - handlers && handlers.push(tree._listeners[leaf]); - } - return [tree]; - } - } - - if ((currentType === '*' || currentType === '**') || tree[currentType]) { - // - // If the event emitted is '*' at this part - // or there is a concrete match at this patch - // - if (currentType === '*') { - for (branch in tree) { - if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1)); - } - } - return listeners; - } else if(currentType === '**') { - endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*')); - if(endReached && tree._listeners) { - // The next element has a _listeners, add it to the handlers. - listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength)); - } - - for (branch in tree) { - if (branch !== '_listeners' && tree.hasOwnProperty(branch)) { - if(branch === '*' || branch === '**') { - if(tree[branch]._listeners && !endReached) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength)); - } - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); - } else if(branch === nextType) { - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2)); - } else { - // No match on this one, shift into the tree but not in the type array. - listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i)); - } - } - } - return listeners; - } - - listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1)); - } - - xTree = tree['*']; - if (xTree) { - // - // If the listener tree will allow any match for this part, - // then recursively explore all branches of the tree - // - searchListenerTree(handlers, type, xTree, i+1); - } - - xxTree = tree['**']; - if(xxTree) { - if(i < typeLength) { - if(xxTree._listeners) { - // If we have a listener on a '**', it will catch all, so add its handler. - searchListenerTree(handlers, type, xxTree, typeLength); - } - - // Build arrays of matching next branches and others. - for(branch in xxTree) { - if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) { - if(branch === nextType) { - // We know the next element will match, so jump twice. - searchListenerTree(handlers, type, xxTree[branch], i+2); - } else if(branch === currentType) { - // Current node matches, move into the tree. - searchListenerTree(handlers, type, xxTree[branch], i+1); - } else { - isolatedBranch = {}; - isolatedBranch[branch] = xxTree[branch]; - searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1); - } - } - } - } else if(xxTree._listeners) { - // We have reached the end and still on a '**' - searchListenerTree(handlers, type, xxTree, typeLength); - } else if(xxTree['*'] && xxTree['*']._listeners) { - searchListenerTree(handlers, type, xxTree['*'], typeLength); - } - } - - return listeners; - } - - function growListenerTree(type, listener) { - - type = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - - // - // Looks for two consecutive '**', if so, don't add the event at all. - // - for(var i = 0, len = type.length; i+1 < len; i++) { - if(type[i] === '**' && type[i+1] === '**') { - return; - } - } - - var tree = this.listenerTree; - var name = type.shift(); - - while (name !== undefined) { - - if (!tree[name]) { - tree[name] = {}; - } - - tree = tree[name]; - - if (type.length === 0) { - - if (!tree._listeners) { - tree._listeners = listener; - } - else { - if (typeof tree._listeners === 'function') { - tree._listeners = [tree._listeners]; - } - - tree._listeners.push(listener); - - if ( - !tree._listeners.warned && - this._events.maxListeners > 0 && - tree._listeners.length > this._events.maxListeners - ) { - tree._listeners.warned = true; - logPossibleMemoryLeak.call(this, tree._listeners.length, name); - } - } - return true; - } - name = type.shift(); - } - return true; - } - - // By default EventEmitters will print a warning if more than - // 10 listeners are added to it. This is a useful default which - // helps finding memory leaks. - // - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - - EventEmitter.prototype.delimiter = '.'; - - EventEmitter.prototype.setMaxListeners = function(n) { - if (n !== undefined) { - this._events || init.call(this); - this._events.maxListeners = n; - if (!this._conf) this._conf = {}; - this._conf.maxListeners = n; - } - }; - - EventEmitter.prototype.event = ''; - - EventEmitter.prototype.once = function(event, fn) { - this.many(event, 1, fn); - return this; - }; - - EventEmitter.prototype.many = function(event, ttl, fn) { - var self = this; - - if (typeof fn !== 'function') { - throw new Error('many only accepts instances of Function'); - } - - function listener() { - if (--ttl === 0) { - self.off(event, listener); - } - fn.apply(this, arguments); - } - - listener._origin = fn; - - this.on(event, listener); - - return self; - }; - - EventEmitter.prototype.emit = function() { - - this._events || init.call(this); - - var type = arguments[0]; - - if (type === 'newListener' && !this.newListener) { - if (!this._events.newListener) { - return false; - } - } - - var al = arguments.length; - var args,l,i,j; - var handler; - - if (this._all && this._all.length) { - handler = this._all.slice(); - if (al > 3) { - args = new Array(al); - for (j = 0; j < al; j++) args[j] = arguments[j]; - } - - for (i = 0, l = handler.length; i < l; i++) { - this.event = type; - switch (al) { - case 1: - handler[i].call(this, type); - break; - case 2: - handler[i].call(this, type, arguments[1]); - break; - case 3: - handler[i].call(this, type, arguments[1], arguments[2]); - break; - default: - handler[i].apply(this, args); - } - } - } - - if (this.wildcard) { - handler = []; - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - searchListenerTree.call(this, handler, ns, this.listenerTree, 0); - } else { - handler = this._events[type]; - if (typeof handler === 'function') { - this.event = type; - switch (al) { - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - default: - args = new Array(al - 1); - for (j = 1; j < al; j++) args[j - 1] = arguments[j]; - handler.apply(this, args); - } - return true; - } else if (handler) { - // need to make copy of handlers because list can change in the middle - // of emit call - handler = handler.slice(); - } - } - - if (handler && handler.length) { - if (al > 3) { - args = new Array(al - 1); - for (j = 1; j < al; j++) args[j - 1] = arguments[j]; - } - for (i = 0, l = handler.length; i < l; i++) { - this.event = type; - switch (al) { - case 1: - handler[i].call(this); - break; - case 2: - handler[i].call(this, arguments[1]); - break; - case 3: - handler[i].call(this, arguments[1], arguments[2]); - break; - default: - handler[i].apply(this, args); - } - } - return true; - } else if (!this._all && type === 'error') { - if (arguments[1] instanceof Error) { - throw arguments[1]; // Unhandled 'error' event - } else { - throw new Error("Uncaught, unspecified 'error' event."); - } - return false; - } - - return !!this._all; - }; - - EventEmitter.prototype.emitAsync = function() { - - this._events || init.call(this); - - var type = arguments[0]; - - if (type === 'newListener' && !this.newListener) { - if (!this._events.newListener) { return Promise.resolve([false]); } - } - - var promises= []; - - var al = arguments.length; - var args,l,i,j; - var handler; - - if (this._all) { - if (al > 3) { - args = new Array(al); - for (j = 1; j < al; j++) args[j] = arguments[j]; - } - for (i = 0, l = this._all.length; i < l; i++) { - this.event = type; - switch (al) { - case 1: - promises.push(this._all[i].call(this, type)); - break; - case 2: - promises.push(this._all[i].call(this, type, arguments[1])); - break; - case 3: - promises.push(this._all[i].call(this, type, arguments[1], arguments[2])); - break; - default: - promises.push(this._all[i].apply(this, args)); - } - } - } - - if (this.wildcard) { - handler = []; - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - searchListenerTree.call(this, handler, ns, this.listenerTree, 0); - } else { - handler = this._events[type]; - } - - if (typeof handler === 'function') { - this.event = type; - switch (al) { - case 1: - promises.push(handler.call(this)); - break; - case 2: - promises.push(handler.call(this, arguments[1])); - break; - case 3: - promises.push(handler.call(this, arguments[1], arguments[2])); - break; - default: - args = new Array(al - 1); - for (j = 1; j < al; j++) args[j - 1] = arguments[j]; - promises.push(handler.apply(this, args)); - } - } else if (handler && handler.length) { - if (al > 3) { - args = new Array(al - 1); - for (j = 1; j < al; j++) args[j - 1] = arguments[j]; - } - for (i = 0, l = handler.length; i < l; i++) { - this.event = type; - switch (al) { - case 1: - promises.push(handler[i].call(this)); - break; - case 2: - promises.push(handler[i].call(this, arguments[1])); - break; - case 3: - promises.push(handler[i].call(this, arguments[1], arguments[2])); - break; - default: - promises.push(handler[i].apply(this, args)); - } - } - } else if (!this._all && type === 'error') { - if (arguments[1] instanceof Error) { - return Promise.reject(arguments[1]); // Unhandled 'error' event - } else { - return Promise.reject("Uncaught, unspecified 'error' event."); - } - } - - return Promise.all(promises); - }; - - EventEmitter.prototype.on = function(type, listener) { - if (typeof type === 'function') { - this.onAny(type); - return this; - } - - if (typeof listener !== 'function') { - throw new Error('on only accepts instances of Function'); - } - this._events || init.call(this); - - // To avoid recursion in the case that type == "newListeners"! Before - // adding it to the listeners, first emit "newListeners". - this.emit('newListener', type, listener); - - if (this.wildcard) { - growListenerTree.call(this, type, listener); - return this; - } - - if (!this._events[type]) { - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - } - else { - if (typeof this._events[type] === 'function') { - // Change to array. - this._events[type] = [this._events[type]]; - } - - // If we've already got an array, just append. - this._events[type].push(listener); - - // Check for listener leak - if ( - !this._events[type].warned && - this._events.maxListeners > 0 && - this._events[type].length > this._events.maxListeners - ) { - this._events[type].warned = true; - logPossibleMemoryLeak.call(this, this._events[type].length, type); - } - } - - return this; - }; - - EventEmitter.prototype.onAny = function(fn) { - if (typeof fn !== 'function') { - throw new Error('onAny only accepts instances of Function'); - } - - if (!this._all) { - this._all = []; - } - - // Add the function to the event listener collection. - this._all.push(fn); - return this; - }; - - EventEmitter.prototype.addListener = EventEmitter.prototype.on; - - EventEmitter.prototype.off = function(type, listener) { - if (typeof listener !== 'function') { - throw new Error('removeListener only takes instances of Function'); - } - - var handlers,leafs=[]; - - if(this.wildcard) { - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); - } - else { - // does not use listeners(), so no side effect of creating _events[type] - if (!this._events[type]) return this; - handlers = this._events[type]; - leafs.push({_listeners:handlers}); - } - - for (var iLeaf=0; iLeaf 0) { - recursivelyGarbageCollect(root[key]); - } - if (Object.keys(obj).length === 0) { - delete root[key]; - } - } - } - recursivelyGarbageCollect(this.listenerTree); - - return this; - }; - - EventEmitter.prototype.offAny = function(fn) { - var i = 0, l = 0, fns; - if (fn && this._all && this._all.length > 0) { - fns = this._all; - for(i = 0, l = fns.length; i < l; i++) { - if(fn === fns[i]) { - fns.splice(i, 1); - this.emit("removeListenerAny", fn); - return this; - } - } - } else { - fns = this._all; - for(i = 0, l = fns.length; i < l; i++) - this.emit("removeListenerAny", fns[i]); - this._all = []; - } - return this; - }; - - EventEmitter.prototype.removeListener = EventEmitter.prototype.off; - - EventEmitter.prototype.removeAllListeners = function(type) { - if (arguments.length === 0) { - !this._events || init.call(this); - return this; - } - - if (this.wildcard) { - var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); - var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); - - for (var iLeaf=0; iLeaf 0 && + tree._listeners.length > this._events.maxListeners + ) { + tree._listeners.warned = true; + logPossibleMemoryLeak.call(this, tree._listeners.length, name); + } + } + return true; + } + name = type.shift(); + } + return true; + } + + // By default EventEmitters will print a warning if more than + // 10 listeners are added to it. This is a useful default which + // helps finding memory leaks. + // + // Obviously not all Emitters should be limited to 10. This function allows + // that to be increased. Set to zero for unlimited. + + EventEmitter.prototype.delimiter = '.'; + + EventEmitter.prototype.setMaxListeners = function(n) { + if (n !== undefined) { + this._events || init.call(this); + this._events.maxListeners = n; + if (!this._conf) this._conf = {}; + this._conf.maxListeners = n; + } + }; + + EventEmitter.prototype.event = ''; + + EventEmitter.prototype.once = function(event, fn) { + this.many(event, 1, fn); + return this; + }; + + EventEmitter.prototype.many = function(event, ttl, fn) { + var self = this; + + if (typeof fn !== 'function') { + throw new Error('many only accepts instances of Function'); + } + + function listener() { + if (--ttl === 0) { + self.off(event, listener); + } + fn.apply(this, arguments); + } + + listener._origin = fn; + + this.on(event, listener); + + return self; + }; + + EventEmitter.prototype.emit = function() { + + this._events || init.call(this); + + var type = arguments[0]; + + if (type === 'newListener' && !this.newListener) { + if (!this._events.newListener) { + return false; + } + } + + var al = arguments.length; + var args,l,i,j; + var handler; + + if (this._all && this._all.length) { + handler = this._all.slice(); + if (al > 3) { + args = new Array(al); + for (j = 0; j < al; j++) args[j] = arguments[j]; + } + + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + handler[i].call(this, type); + break; + case 2: + handler[i].call(this, type, arguments[1]); + break; + case 3: + handler[i].call(this, type, arguments[1], arguments[2]); + break; + default: + handler[i].apply(this, args); + } + } + } + + if (this.wildcard) { + handler = []; + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + searchListenerTree.call(this, handler, ns, this.listenerTree, 0); + } else { + handler = this._events[type]; + if (typeof handler === 'function') { + this.event = type; + switch (al) { + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + default: + args = new Array(al - 1); + for (j = 1; j < al; j++) args[j - 1] = arguments[j]; + handler.apply(this, args); + } + return true; + } else if (handler) { + // need to make copy of handlers because list can change in the middle + // of emit call + handler = handler.slice(); + } + } + + if (handler && handler.length) { + if (al > 3) { + args = new Array(al - 1); + for (j = 1; j < al; j++) args[j - 1] = arguments[j]; + } + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + handler[i].call(this); + break; + case 2: + handler[i].call(this, arguments[1]); + break; + case 3: + handler[i].call(this, arguments[1], arguments[2]); + break; + default: + handler[i].apply(this, args); + } + } + return true; + } else if (!this._all && type === 'error') { + if (arguments[1] instanceof Error) { + throw arguments[1]; // Unhandled 'error' event + } else { + throw new Error("Uncaught, unspecified 'error' event."); + } + return false; + } + + return !!this._all; + }; + + EventEmitter.prototype.emitAsync = function() { + + this._events || init.call(this); + + var type = arguments[0]; + + if (type === 'newListener' && !this.newListener) { + if (!this._events.newListener) { return Promise.resolve([false]); } + } + + var promises= []; + + var al = arguments.length; + var args,l,i,j; + var handler; + + if (this._all) { + if (al > 3) { + args = new Array(al); + for (j = 1; j < al; j++) args[j] = arguments[j]; + } + for (i = 0, l = this._all.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + promises.push(this._all[i].call(this, type)); + break; + case 2: + promises.push(this._all[i].call(this, type, arguments[1])); + break; + case 3: + promises.push(this._all[i].call(this, type, arguments[1], arguments[2])); + break; + default: + promises.push(this._all[i].apply(this, args)); + } + } + } + + if (this.wildcard) { + handler = []; + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + searchListenerTree.call(this, handler, ns, this.listenerTree, 0); + } else { + handler = this._events[type]; + } + + if (typeof handler === 'function') { + this.event = type; + switch (al) { + case 1: + promises.push(handler.call(this)); + break; + case 2: + promises.push(handler.call(this, arguments[1])); + break; + case 3: + promises.push(handler.call(this, arguments[1], arguments[2])); + break; + default: + args = new Array(al - 1); + for (j = 1; j < al; j++) args[j - 1] = arguments[j]; + promises.push(handler.apply(this, args)); + } + } else if (handler && handler.length) { + if (al > 3) { + args = new Array(al - 1); + for (j = 1; j < al; j++) args[j - 1] = arguments[j]; + } + for (i = 0, l = handler.length; i < l; i++) { + this.event = type; + switch (al) { + case 1: + promises.push(handler[i].call(this)); + break; + case 2: + promises.push(handler[i].call(this, arguments[1])); + break; + case 3: + promises.push(handler[i].call(this, arguments[1], arguments[2])); + break; + default: + promises.push(handler[i].apply(this, args)); + } + } + } else if (!this._all && type === 'error') { + if (arguments[1] instanceof Error) { + return Promise.reject(arguments[1]); // Unhandled 'error' event + } else { + return Promise.reject("Uncaught, unspecified 'error' event."); + } + } + + return Promise.all(promises); + }; + + EventEmitter.prototype.on = function(type, listener) { + if (typeof type === 'function') { + this.onAny(type); + return this; + } + + if (typeof listener !== 'function') { + throw new Error('on only accepts instances of Function'); + } + this._events || init.call(this); + + // To avoid recursion in the case that type == "newListeners"! Before + // adding it to the listeners, first emit "newListeners". + this.emit('newListener', type, listener); + + if (this.wildcard) { + growListenerTree.call(this, type, listener); + return this; + } + + if (!this._events[type]) { + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + } + else { + if (typeof this._events[type] === 'function') { + // Change to array. + this._events[type] = [this._events[type]]; + } + + // If we've already got an array, just append. + this._events[type].push(listener); + + // Check for listener leak + if ( + !this._events[type].warned && + this._events.maxListeners > 0 && + this._events[type].length > this._events.maxListeners + ) { + this._events[type].warned = true; + logPossibleMemoryLeak.call(this, this._events[type].length, type); + } + } + + return this; + }; + + EventEmitter.prototype.onAny = function(fn) { + if (typeof fn !== 'function') { + throw new Error('onAny only accepts instances of Function'); + } + + if (!this._all) { + this._all = []; + } + + // Add the function to the event listener collection. + this._all.push(fn); + return this; + }; + + EventEmitter.prototype.addListener = EventEmitter.prototype.on; + + EventEmitter.prototype.off = function(type, listener) { + if (typeof listener !== 'function') { + throw new Error('removeListener only takes instances of Function'); + } + + var handlers,leafs=[]; + + if(this.wildcard) { + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); + } + else { + // does not use listeners(), so no side effect of creating _events[type] + if (!this._events[type]) return this; + handlers = this._events[type]; + leafs.push({_listeners:handlers}); + } + + for (var iLeaf=0; iLeaf 0) { + recursivelyGarbageCollect(root[key]); + } + if (Object.keys(obj).length === 0) { + delete root[key]; + } + } + } + recursivelyGarbageCollect(this.listenerTree); + + return this; + }; + + EventEmitter.prototype.offAny = function(fn) { + var i = 0, l = 0, fns; + if (fn && this._all && this._all.length > 0) { + fns = this._all; + for(i = 0, l = fns.length; i < l; i++) { + if(fn === fns[i]) { + fns.splice(i, 1); + this.emit("removeListenerAny", fn); + return this; + } + } + } else { + fns = this._all; + for(i = 0, l = fns.length; i < l; i++) + this.emit("removeListenerAny", fns[i]); + this._all = []; + } + return this; + }; + + EventEmitter.prototype.removeListener = EventEmitter.prototype.off; + + EventEmitter.prototype.removeAllListeners = function(type) { + if (arguments.length === 0) { + !this._events || init.call(this); + return this; + } + + if (this.wildcard) { + var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice(); + var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0); + + for (var iLeaf=0; iLeaf0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i>=4,e+=n[19===t?3&r|8:r]);return e}),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*vt.DEG2RAD},radToDeg:function(e){return e*vt.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};function yt(e,t){this.x=e||0,this.y=t||0}function xt(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function bt(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1}function wt(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}function _t(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(yt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(yt.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:(a=new yt,s=new yt,function(e,t){return a.set(e,e),s.set(t,t),this.clamp(a,s)}),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},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 e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,o=this.y-e.y;return this.x=n*i-o*r+e.x,this.y=n*r+o*i+e.y,this}}),Object.assign(xt.prototype,{isMatrix4:!0,set:function(e,t,i,r,n,o,a,s,c,h,l,u,p,d,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=h,g[10]=l,g[14]=u,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new xt).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:(d=new wt,function(e){var t=this.elements,i=e.elements,r=1/d.setFromMatrixColumn(e,0).length(),n=1/d.setFromMatrixColumn(e,1).length(),o=1/d.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,this}),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,r=e.y,n=e.z,o=Math.cos(i),a=Math.sin(i),s=Math.cos(r),c=Math.sin(r),h=Math.cos(n),l=Math.sin(n);if("XYZ"===e.order){var u=o*h,p=o*l,d=a*h,f=a*l;t[0]=s*h,t[4]=-s*l,t[8]=c,t[1]=p+d*c,t[5]=u-f*c,t[9]=-a*s,t[2]=f-u*c,t[6]=d+p*c,t[10]=o*s}else if("YXZ"===e.order){var m=s*h,g=s*l,v=c*h,y=c*l;t[0]=m+y*a,t[4]=v*a-g,t[8]=o*c,t[1]=o*l,t[5]=o*h,t[9]=-a,t[2]=g*a-v,t[6]=y+m*a,t[10]=o*s}else if("ZXY"===e.order){m=s*h,g=s*l,v=c*h,y=c*l;t[0]=m-y*a,t[4]=-o*l,t[8]=v+g*a,t[1]=g+v*a,t[5]=o*h,t[9]=y-m*a,t[2]=-o*c,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){u=o*h,p=o*l,d=a*h,f=a*l;t[0]=s*h,t[4]=d*c-p,t[8]=u*c+f,t[1]=s*l,t[5]=f*c+u,t[9]=p*c-d,t[2]=-c,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var x=o*s,b=o*c,w=a*s,_=a*c;t[0]=s*h,t[4]=_-x*l,t[8]=w*l+b,t[1]=l,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=b*l+w,t[10]=x-_*l}else if("XZY"===e.order){x=o*s,b=o*c,w=a*s,_=a*c;t[0]=s*h,t[4]=-l,t[8]=c*h,t[1]=x*l+_,t[5]=o*h,t[9]=b*l-w,t[2]=w*l-b,t[6]=a*h,t[10]=_*l+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,i=e._x,r=e._y,n=e._z,o=e._w,a=i+i,s=r+r,c=n+n,h=i*a,l=i*s,u=i*c,p=r*s,d=r*c,f=n*c,m=o*a,g=o*s,v=o*c;return t[0]=1-(p+f),t[4]=l-v,t[8]=u+g,t[1]=l+v,t[5]=1-(h+f),t[9]=d-m,t[2]=u-g,t[6]=d+m,t[10]=1-(h+p),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:(l=new wt,u=new wt,p=new wt,function(e,t,i){var r=this.elements;return p.subVectors(e,t),0===p.lengthSq()&&(p.z=1),p.normalize(),l.crossVectors(i,p),0===l.lengthSq()&&(1===Math.abs(i.z)?p.x+=1e-4:p.z+=1e-4,p.normalize(),l.crossVectors(i,p)),l.normalize(),u.crossVectors(p,l),r[0]=l.x,r[4]=u.x,r[8]=p.x,r[1]=l.y,r[5]=u.y,r[9]=p.y,r[2]=l.z,r[6]=u.z,r[10]=p.z,this}),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],h=i[1],l=i[5],u=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],x=i[11],b=i[15],w=r[0],_=r[4],M=r[8],E=r[12],T=r[1],S=r[5],A=r[9],R=r[13],L=r[2],C=r[6],P=r[10],N=r[14],I=r[3],O=r[7],D=r[11],U=r[15];return n[0]=o*w+a*T+s*L+c*I,n[4]=o*_+a*S+s*C+c*O,n[8]=o*M+a*A+s*P+c*D,n[12]=o*E+a*R+s*N+c*U,n[1]=h*w+l*T+u*L+p*I,n[5]=h*_+l*S+u*C+p*O,n[9]=h*M+l*A+u*P+p*D,n[13]=h*E+l*R+u*N+p*U,n[2]=d*w+f*T+m*L+g*I,n[6]=d*_+f*S+m*C+g*O,n[10]=d*M+f*A+m*P+g*D,n[14]=d*E+f*R+m*N+g*U,n[3]=v*w+y*T+x*L+b*I,n[7]=v*_+y*S+x*C+b*O,n[11]=v*M+y*A+x*P+b*D,n[15]=v*E+y*R+x*N+b*U,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new wt;return function(t){for(var i=0,r=t.count;i=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,g*v);m=Math.sin(m*b)/x,a=Math.sin(a*b)/x}var w=a*v;if(s=s*m+u*w,c=c*m+p*w,h=h*m+d*w,l=l*m+f*w,m===1-a){var _=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=_,c*=_,h*=_,l*=_}}e[t]=s,e[t+1]=c,e[t+2]=h,e[t+3]=l}}),Object.defineProperties(bt.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(bt.prototype,{set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,r=e._y,n=e._z,o=e.order,a=Math.cos,s=Math.sin,c=a(i/2),h=a(r/2),l=a(n/2),u=s(i/2),p=s(r/2),d=s(n/2);return"XYZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"YXZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"ZXY"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"ZYX"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"YZX"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l-u*p*d):"XZY"===o&&(this._x=u*h*l-c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l+u*p*d),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],n=i[4],o=i[8],a=i[1],s=i[5],c=i[9],h=i[2],l=i[6],u=i[10],p=r+s+u;return p>0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(l-c)*t,this._y=(o-h)*t,this._z=(a-n)*t):r>s&&r>u?(t=2*Math.sqrt(1+r-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(o+h)/t):s>u?(t=2*Math.sqrt(1+s-r-u),this._w=(o-h)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-r-s),this._w=(a-n)/t,this._x=(o+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new wt;return function(i,r){return void 0===t&&(t=new wt),(e=i.dot(r)+1)<1e-6?(e=0,Math.abs(i.x)>Math.abs(i.z)?t.set(-i.y,i.x,0):t.set(0,-i.z,i.y)):t.crossVectors(i,r),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,o=e._w,a=t._x,s=t._y,c=t._z,h=t._w;return this._x=i*h+o*a+r*c-n*s,this._y=r*h+o*s+n*a-i*c,this._z=n*h+o*c+i*s-r*a,this._w=o*h-i*a-r*s-n*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+n*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,a),h=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=o*h+this._w*l,this._x=i*h+this._x*l,this._y=r*h+this._y*l,this._z=n*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(wt.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:(f=new bt,function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(f.setFromEuler(e))}),applyAxisAngle:function(){var e=new bt;return function(t,i){return this.applyQuaternion(e.setFromAxisAngle(t,i))}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,o=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,o=e.y,a=e.z,s=e.w,c=s*t+o*r-a*i,h=s*i+a*t-n*r,l=s*r+n*i-o*t,u=-n*t-o*i-a*r;return this.x=c*s+u*-n+h*-a-l*-o,this.y=h*s+u*-o+l*-n-c*-a,this.z=l*s+u*-a+c*-o-h*-n,this},project:function(){var e=new xt;return function(t){return e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e=new xt;return function(t){return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new wt,t=new wt;return function(i,r){return e.set(i,i,i),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new wt;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new wt;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(vt.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(_t.prototype,{isMatrix3:!0,set:function(e,t,i,r,n,o,a,s,c){var h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=n,h[5]=s,h[6]=i,h[7]=o,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new wt;return function(t){for(var i=0,r=t.count;i2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}(r)}),i.image=r.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(300===this.mapping){if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xe:e.x=e.x-Math.floor(e.x);break;case be:e.x=e.x<0?0:1;break;case we:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case xe:e.y=e.y-Math.floor(e.y);break;case be:e.y=e.y<0?0:1;break;case we:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}}),Object.assign(Tt.prototype,{isVector4:!0,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,r,n,o=e.elements,a=o[0],s=o[4],c=o[8],h=o[1],l=o[5],u=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-h)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+h)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(a+l+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(a+1)/2,g=(l+1)/2,v=(f+1)/2,y=(s+h)/4,x=(c+p)/4,b=(u+d)/4;return m>g&&m>v?m<.01?(i=0,r=.707106781,n=.707106781):(r=y/(i=Math.sqrt(m)),n=x/i):g>v?g<.01?(i=.707106781,r=0,n=.707106781):(i=y/(r=Math.sqrt(g)),n=b/r):v<.01?(i=.707106781,r=.707106781,n=0):(i=x/(n=Math.sqrt(v)),r=b/n),this.set(i,r,n,t),this}var w=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(h-s)*(h-s));return Math.abs(w)<.001&&(w=1),this.x=(d-u)/w,this.y=(c-p)/w,this.z=(h-s)/w,this.w=Math.acos((a+l+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new Tt,t=new Tt),e.set(i,i,i,i),t.set(r,r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),Object.assign(St.prototype,i.prototype,{isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),At.prototype=Object.create(St.prototype),At.prototype.constructor=At,At.prototype.isWebGLRenderTargetCube=!0,Rt.prototype=Object.create(Et.prototype),Rt.prototype.constructor=Rt,Rt.prototype.isDataTexture=!0,Lt.prototype=Object.create(Et.prototype),Lt.prototype.constructor=Lt,Lt.prototype.isCubeTexture=!0,Object.defineProperty(Lt.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});var Ct=new Et,Pt=new Lt;function Nt(){this.seq=[],this.map={}}var It=[],Ot=[],Dt=new Float32Array(16),Ut=new Float32Array(9);function Ft(e,t,i){var r=e[0];if(r<=0||r>0)return e;var n=t*i,o=It[n];if(void 0===o&&(o=new Float32Array(n),It[n]=o),0!==t){r.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=i,e[a].toArray(o,s)}return o}function Bt(e,t){var i=Ot[t];void 0===i&&(i=new Int32Array(t),Ot[t]=i);for(var r=0;r!==t;++r)i[r]=e.allocTextureUnit();return i}function zt(e,t){e.uniform1f(this.addr,t)}function kt(e,t){e.uniform1i(this.addr,t)}function Gt(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function Vt(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)}function Ht(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function jt(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function Wt(e,t){void 0===t.elements?e.uniformMatrix3fv(this.addr,!1,t):(Ut.set(t.elements),e.uniformMatrix3fv(this.addr,!1,Ut))}function Xt(e,t){void 0===t.elements?e.uniformMatrix4fv(this.addr,!1,t):(Dt.set(t.elements),e.uniformMatrix4fv(this.addr,!1,Dt))}function qt(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),i.setTexture2D(t||Ct,r)}function Yt(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),i.setTextureCube(t||Pt,r)}function Zt(e,t){e.uniform2iv(this.addr,t)}function Qt(e,t){e.uniform3iv(this.addr,t)}function Jt(e,t){e.uniform4iv(this.addr,t)}function Kt(e,t){e.uniform1fv(this.addr,t)}function $t(e,t){e.uniform1iv(this.addr,t)}function ei(e,t){e.uniform2fv(this.addr,Ft(t,this.size,2))}function ti(e,t){e.uniform3fv(this.addr,Ft(t,this.size,3))}function ii(e,t){e.uniform4fv(this.addr,Ft(t,this.size,4))}function ri(e,t){e.uniformMatrix2fv(this.addr,!1,Ft(t,this.size,4))}function ni(e,t){e.uniformMatrix3fv(this.addr,!1,Ft(t,this.size,9))}function oi(e,t){e.uniformMatrix4fv(this.addr,!1,Ft(t,this.size,16))}function ai(e,t,i){var r=t.length,n=Bt(i,r);e.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTexture2D(t[o]||Ct,n[o])}function si(e,t,i){var r=t.length,n=Bt(i,r);e.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTextureCube(t[o]||Pt,n[o])}function ci(e,t,i){this.id=e,this.addr=i,this.setValue=function(e){switch(e){case 5126:return zt;case 35664:return Gt;case 35665:return Vt;case 35666:return Ht;case 35674:return jt;case 35675:return Wt;case 35676:return Xt;case 35678:case 36198:return qt;case 35680:return Yt;case 5124:case 35670:return kt;case 35667:case 35671:return Zt;case 35668:case 35672:return Qt;case 35669:case 35673:return Jt}}(t.type)}function hi(e,t,i){this.id=e,this.addr=i,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Kt;case 35664:return ei;case 35665:return ti;case 35666:return ii;case 35674:return ri;case 35675:return ni;case 35676:return oi;case 35678:return ai;case 35680:return si;case 5124:case 35670:return $t;case 35667:case 35671:return Zt;case 35668:case 35672:return Qt;case 35669:case 35673:return Jt}}(t.type)}function li(e){this.id=e,Nt.call(this)}li.prototype.setValue=function(e,t){for(var i=this.seq,r=0,n=i.length;r!==n;++r){var o=i[r];o.setValue(e,t[o.id])}};var ui=/([\w\d_]+)(\])?(\[|\.)?/g;function pi(e,t){e.seq.push(t),e.map[t.id]=t}function di(e,t,i){var r=e.name,n=r.length;for(ui.lastIndex=0;;){var o=ui.exec(r),a=ui.lastIndex,s=o[1],c="]"===o[2],h=o[3];if(c&&(s|=0),void 0===h||"["===h&&a+2===n){pi(i,void 0===h?new ci(s,e,t):new hi(s,e,t));break}var l=i.map[s];void 0===l&&pi(i,l=new li(s)),i=l}}function fi(e,t,i){Nt.call(this),this.renderer=i;for(var r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=0;n>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(){function e(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}return function(t,i,r){if(t=vt.euclideanModulo(t,1),i=vt.clamp(i,0,1),r=vt.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var n=r<=.5?r*(1+i):r+i-r*i,o=2*r-n;this.r=e(o,n,t+1/3),this.g=e(o,n,t),this.b=e(o,n,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(a,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var h,l=(h=i[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}e&&e.length>0&&(void 0!==(h=mi[e])?this.setHex(h):console.warn("THREE.Color: Unknown color "+e));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(){var e=this.r,t=this.g,i=this.b;return this.r=e*e,this.g=t*t,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){var t,i,r=e||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),c=Math.min(n,o,a),h=(c+s)/2;if(c===s)t=0,i=0;else{var l=s-c;switch(i=h<=.5?l/(s+c):l/(2-s-c),s){case n:t=(o-a)/l+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\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.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - 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\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\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\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\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}\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\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",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};\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}\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(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\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",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.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\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.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, 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.x, 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 = value.rgb * cLogLuvM;\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 = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",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( 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\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_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\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_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\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",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\n",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\n",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\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",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 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\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\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\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\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\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 ltcMat;\tuniform sampler2D ltcMag;\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\n#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( 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 GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.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(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\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",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)\n",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\n",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\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), 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 clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\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}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\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\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\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\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\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\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\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 ( NUM_HEMI_LIGHTS > 0 )\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\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\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\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",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\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#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#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\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\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",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}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",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\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\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\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( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, 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( 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 / 9.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\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; 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_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; 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_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; 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}\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 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\n",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\n",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#endif\n",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 gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",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}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_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_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_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\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\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( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\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}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\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\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\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}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\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 \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#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#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\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\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\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 \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\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + 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}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\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 \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\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}\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\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}\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}\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#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 \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\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}\n",meshphysical_vert:"#define PHYSICAL\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 \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}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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#endif\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 )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \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\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\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#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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}\n",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},bi={basic:{uniforms:yi.merge([vi.common,vi.specularmap,vi.envmap,vi.aomap,vi.lightmap,vi.fog]),vertexShader:xi.meshbasic_vert,fragmentShader:xi.meshbasic_frag},lambert:{uniforms:yi.merge([vi.common,vi.specularmap,vi.envmap,vi.aomap,vi.lightmap,vi.emissivemap,vi.fog,vi.lights,{emissive:{value:new gi(0)}}]),vertexShader:xi.meshlambert_vert,fragmentShader:xi.meshlambert_frag},phong:{uniforms:yi.merge([vi.common,vi.specularmap,vi.envmap,vi.aomap,vi.lightmap,vi.emissivemap,vi.bumpmap,vi.normalmap,vi.displacementmap,vi.gradientmap,vi.fog,vi.lights,{emissive:{value:new gi(0)},specular:{value:new gi(1118481)},shininess:{value:30}}]),vertexShader:xi.meshphong_vert,fragmentShader:xi.meshphong_frag},standard:{uniforms:yi.merge([vi.common,vi.envmap,vi.aomap,vi.lightmap,vi.emissivemap,vi.bumpmap,vi.normalmap,vi.displacementmap,vi.roughnessmap,vi.metalnessmap,vi.fog,vi.lights,{emissive:{value:new gi(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:xi.meshphysical_vert,fragmentShader:xi.meshphysical_frag},points:{uniforms:yi.merge([vi.points,vi.fog]),vertexShader:xi.points_vert,fragmentShader:xi.points_frag},dashed:{uniforms:yi.merge([vi.common,vi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xi.linedashed_vert,fragmentShader:xi.linedashed_frag},depth:{uniforms:yi.merge([vi.common,vi.displacementmap]),vertexShader:xi.depth_vert,fragmentShader:xi.depth_frag},normal:{uniforms:yi.merge([vi.common,vi.bumpmap,vi.normalmap,vi.displacementmap,{opacity:{value:1}}]),vertexShader:xi.normal_vert,fragmentShader:xi.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xi.cube_vert,fragmentShader:xi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xi.equirect_vert,fragmentShader:xi.equirect_frag},distanceRGBA:{uniforms:yi.merge([vi.common,vi.displacementmap,{referencePosition:{value:new wt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xi.distanceRGBA_vert,fragmentShader:xi.distanceRGBA_frag},shadow:{uniforms:yi.merge([vi.lights,vi.fog,{color:{value:new gi(0)},opacity:{value:1}}]),vertexShader:xi.shadow_vert,fragmentShader:xi.shadow_frag}};function wi(e,t){this.min=void 0!==e?e:new yt(1/0,1/0),this.max=void 0!==t?t:new yt(-1/0,-1/0)}function _i(e,t,i,r,n){var o,a,s,c,h,l,u,p;function d(){var e=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),r=new Uint16Array([0,1,2,0,2,3]);o=t.createBuffer(),a=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r,t.STATIC_DRAW),u=t.createTexture(),p=t.createTexture(),i.bindTexture(t.TEXTURE_2D,u),t.texImage2D(t.TEXTURE_2D,0,t.RGB,16,16,0,t.RGB,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),i.bindTexture(t.TEXTURE_2D,p),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,16,16,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),s={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","\tvUV = uv;","\tvec2 pos = position;","\tif ( renderType == 2 ) {","\t\tvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","\t\tvVisibility = visibility.r / 9.0;","\t\tvVisibility *= 1.0 - visibility.g / 9.0;","\t\tvVisibility *= visibility.b / 9.0;","\t\tvVisibility *= 1.0 - visibility.a / 9.0;","\t\tpos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","\t\tpos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","\t}","\tgl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","\tif ( renderType == 0 ) {","\t\tgl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","\t} else if ( renderType == 1 ) {","\t\tgl_FragColor = texture2D( map, vUV );","\t} else {","\t\tvec4 texture = texture2D( map, vUV );","\t\ttexture.a *= opacity * vVisibility;","\t\tgl_FragColor = texture;","\t\tgl_FragColor.rgb *= color;","\t}","}"].join("\n")},c=function(e){var i=t.createProgram(),r=t.createShader(t.FRAGMENT_SHADER),o=t.createShader(t.VERTEX_SHADER),a="precision "+n.precision+" float;\n";return t.shaderSource(r,a+e.fragmentShader),t.shaderSource(o,a+e.vertexShader),t.compileShader(r),t.compileShader(o),t.attachShader(i,r),t.attachShader(i,o),t.linkProgram(i),i}(s),h={vertex:t.getAttribLocation(c,"position"),uv:t.getAttribLocation(c,"uv")},l={renderType:t.getUniformLocation(c,"renderType"),map:t.getUniformLocation(c,"map"),occlusionMap:t.getUniformLocation(c,"occlusionMap"),opacity:t.getUniformLocation(c,"opacity"),color:t.getUniformLocation(c,"color"),scale:t.getUniformLocation(c,"scale"),rotation:t.getUniformLocation(c,"rotation"),screenPosition:t.getUniformLocation(c,"screenPosition")}}this.render=function(e,n,s,f){if(0!==e.length){var m=new wt,g=f.w/f.z,v=.5*f.z,y=.5*f.w,x=16/f.w,b=new yt(x*g,x),w=new wt(1,1,0),_=new yt(1,1),M=new wi;M.min.set(f.x,f.y),M.max.set(f.x+(f.z-16),f.y+(f.w-16)),void 0===c&&d(),i.useProgram(c),i.initAttributes(),i.enableAttribute(h.vertex),i.enableAttribute(h.uv),i.disableUnusedAttributes(),t.uniform1i(l.occlusionMap,0),t.uniform1i(l.map,1),t.bindBuffer(t.ARRAY_BUFFER,o),t.vertexAttribPointer(h.vertex,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(h.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),i.disable(t.CULL_FACE),i.buffers.depth.setMask(!1);for(var E=0,T=e.length;E.001&&L.scale>.001&&(w.x=L.x,w.y=L.y,w.z=L.z,x=L.size*L.scale/f.w,b.x=x*g,b.y=x,t.uniform3f(l.screenPosition,w.x,w.y,w.z),t.uniform2f(l.scale,b.x,b.y),t.uniform1f(l.rotation,L.rotation),t.uniform1f(l.opacity,L.opacity),t.uniform3f(l.color,L.color.r,L.color.g,L.color.b),i.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst),r.setTexture2D(L.texture,1),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0))}}}i.enable(t.CULL_FACE),i.enable(t.DEPTH_TEST),i.buffers.depth.setMask(!0),i.reset()}}}function Mi(e,t,i,r,n,o,a,s,c){Et.call(this,e,t,i,r,n,o,a,s,c),this.needsUpdate=!0}function Ei(e,t,i,r,n){var o,a,s,c,h,l,u=new wt,p=new bt,d=new wt;function f(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),i=new Uint16Array([0,1,2,0,2,3]);o=t.createBuffer(),a=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.bufferData(t.ELEMENT_ARRAY_BUFFER,i,t.STATIC_DRAW),s=function(){var e=t.createProgram(),i=t.createShader(t.VERTEX_SHADER),r=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(i,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float fogDepth;","void main() {","\tvUV = uvOffset + uv * uvScale;","\tvec2 alignedPosition = position * scale;","\tvec2 rotatedPosition;","\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","\tvec4 mvPosition;","\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","\tmvPosition.xy += rotatedPosition;","\tgl_Position = projectionMatrix * mvPosition;","\tfogDepth = - mvPosition.z;","}"].join("\n")),t.shaderSource(r,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","varying float fogDepth;","void main() {","\tvec4 texture = texture2D( map, vUV );","\tgl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","\tif ( gl_FragColor.a < alphaTest ) discard;","\tif ( fogType > 0 ) {","\t\tfloat fogFactor = 0.0;","\t\tif ( fogType == 1 ) {","\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );","\t\t} else {","\t\t\tconst float LOG2 = 1.442695;","\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );","\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","\t\t}","\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );","\t}","}"].join("\n")),t.compileShader(i),t.compileShader(r),t.attachShader(e,i),t.attachShader(e,r),t.linkProgram(e),e}(),c={position:t.getAttribLocation(s,"position"),uv:t.getAttribLocation(s,"uv")},h={uvOffset:t.getUniformLocation(s,"uvOffset"),uvScale:t.getUniformLocation(s,"uvScale"),rotation:t.getUniformLocation(s,"rotation"),scale:t.getUniformLocation(s,"scale"),color:t.getUniformLocation(s,"color"),map:t.getUniformLocation(s,"map"),opacity:t.getUniformLocation(s,"opacity"),modelViewMatrix:t.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:t.getUniformLocation(s,"projectionMatrix"),fogType:t.getUniformLocation(s,"fogType"),fogDensity:t.getUniformLocation(s,"fogDensity"),fogNear:t.getUniformLocation(s,"fogNear"),fogFar:t.getUniformLocation(s,"fogFar"),fogColor:t.getUniformLocation(s,"fogColor"),fogDepth:t.getUniformLocation(s,"fogDepth"),alphaTest:t.getUniformLocation(s,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var u=r.getContext("2d");u.fillStyle="white",u.fillRect(0,0,8,8),l=new Mi(r)}function m(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}this.render=function(n,g,v){if(0!==n.length){void 0===s&&f(),i.useProgram(s),i.initAttributes(),i.enableAttribute(c.position),i.enableAttribute(c.uv),i.disableUnusedAttributes(),i.disable(t.CULL_FACE),i.enable(t.BLEND),t.bindBuffer(t.ARRAY_BUFFER,o),t.vertexAttribPointer(c.position,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(c.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.uniformMatrix4fv(h.projectionMatrix,!1,v.projectionMatrix.elements),i.activeTexture(t.TEXTURE0),t.uniform1i(h.map,0);var y=0,x=0,b=g.fog;b?(t.uniform3f(h.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(t.uniform1f(h.fogNear,b.near),t.uniform1f(h.fogFar,b.far),t.uniform1i(h.fogType,1),y=1,x=1):b.isFogExp2&&(t.uniform1f(h.fogDensity,b.density),t.uniform1i(h.fogType,2),y=2,x=2)):(t.uniform1i(h.fogType,0),y=0,x=0);for(var w=0,_=n.length;w<_;w++){(E=n[w]).modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,E.matrixWorld),E.z=-E.modelViewMatrix.elements[14]}n.sort(m);var M=[];for(w=0,_=n.length;w<_;w++){var E,T=(E=n[w]).material;if(!1!==T.visible){E.onBeforeRender(e,g,v,void 0,T,void 0),t.uniform1f(h.alphaTest,T.alphaTest),t.uniformMatrix4fv(h.modelViewMatrix,!1,E.modelViewMatrix.elements),E.matrixWorld.decompose(u,p,d),M[0]=d.x,M[1]=d.y;var S=0;g.fog&&T.fog&&(S=x),y!==S&&(t.uniform1i(h.fogType,S),y=S),null!==T.map?(t.uniform2f(h.uvOffset,T.map.offset.x,T.map.offset.y),t.uniform2f(h.uvScale,T.map.repeat.x,T.map.repeat.y)):(t.uniform2f(h.uvOffset,0,0),t.uniform2f(h.uvScale,1,1)),t.uniform1f(h.opacity,T.opacity),t.uniform3f(h.color,T.color.r,T.color.g,T.color.b),t.uniform1f(h.rotation,T.rotation),t.uniform2fv(h.scale,M),i.setBlending(T.blending,T.blendEquation,T.blendSrc,T.blendDst,T.blendEquationAlpha,T.blendSrcAlpha,T.blendDstAlpha,T.premultipliedAlpha),i.buffers.depth.setTest(T.depthTest),i.buffers.depth.setMask(T.depthWrite),i.buffers.color.setMask(T.colorWrite),r.setTexture2D(T.map||l,0),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),E.onAfterRender(e,g,v,void 0,T,void 0)}}i.enable(t.CULL_FACE),i.reset()}}}bi.physical={uniforms:yi.merge([bi.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:xi.meshphysical_vert,fragmentShader:xi.meshphysical_frag},Object.assign(wi.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return(t||new yt).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return(t||new yt).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new yt;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Mi.prototype=Object.create(Et.prototype),Mi.prototype.constructor=Mi;var Ti,Si,Ai,Ri,Li,Ci,Pi,Ni=0;function Ii(){Object.defineProperty(this,"id",{value:Ni++}),this.uuid=vt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=L,this.side=_,this.flatShading=!1,this.vertexColors=T,this.opacity=1,this.transparent=!1,this.blendSrc=H,this.blendDst=j,this.blendEquation=O,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=$,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function Oi(e){Ii.call(this),this.type="MeshDepthMaterial",this.depthPacking=mt,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(e)}function Di(e){Ii.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new wt,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(e)}function Ui(e,t){this.min=void 0!==e?e:new wt(1/0,1/0,1/0),this.max=void 0!==t?t:new wt(-1/0,-1/0,-1/0)}function Fi(e,t){this.center=void 0!==e?e:new wt,this.radius=void 0!==t?t:0}function Bi(e,t){this.normal=void 0!==e?e:new wt(1,0,0),this.constant=void 0!==t?t:0}function zi(e,t,i,r,n,o){this.planes=[void 0!==e?e:new Bi,void 0!==t?t:new Bi,void 0!==i?i:new Bi,void 0!==r?r:new Bi,void 0!==n?n:new Bi,void 0!==o?o:new Bi]}function ki(e,t,i){for(var r=new zi,n=new xt,o=new yt,a=new yt(i,i),s=new wt,c=new wt,h=1,l=2,u=1+(h|l),p=new Array(u),d=new Array(u),f={},m=[new wt(1,0,0),new wt(-1,0,0),new wt(0,0,1),new wt(0,0,-1),new wt(0,1,0),new wt(0,-1,0)],g=[new wt(0,1,0),new wt(0,1,0),new wt(0,1,0),new wt(0,1,0),new wt(0,0,1),new wt(0,0,-1)],v=[new Tt,new Tt,new Tt,new Tt,new Tt,new Tt],y=0;y!==u;++y){var x=0!=(y&h),w=0!=(y&l),T=new Oi({depthPacking:gt,morphTargets:x,skinning:w});p[y]=T;var S=new Di({morphTargets:x,skinning:w});d[y]=S}var A=this;function R(t,i,r,n,o,a){var s=t.geometry,c=null,u=p,m=t.customDepthMaterial;if(r&&(u=d,m=t.customDistanceMaterial),m)c=m;else{var g=!1;i.morphTargets&&(s&&s.isBufferGeometry?g=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(g=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===i.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var v=t.isSkinnedMesh&&i.skinning,y=0;g&&(y|=h),v&&(y|=l),c=u[y]}if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var x=c.uuid,b=i.uuid,w=f[x];void 0===w&&(w={},f[x]=w);var T=w[b];void 0===T&&(T=c.clone(),w[b]=T),c=T}c.visible=i.visible,c.wireframe=i.wireframe;var S=i.side;return A.renderSingleSided&&S==E&&(S=_),A.renderReverseSided&&(S===_?S=M:S===M&&(S=_)),c.side=S,c.clipShadows=i.clipShadows,c.clippingPlanes=i.clippingPlanes,c.clipIntersection=i.clipIntersection,c.wireframeLinewidth=i.wireframeLinewidth,c.linewidth=i.linewidth,r&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(n),c.nearDistance=o,c.farDistance=a),c}function L(i,n,o,a){if(!1!==i.visible){if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&i.castShadow&&(!i.frustumCulled||r.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);var s=t.update(i),h=i.material;if(Array.isArray(h))for(var l=s.groups,u=0,p=l.length;u0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){var n=r(e.textures),o=r(e.images);n.length>0&&(i.textures=n),o.length>0&&(i.images=o)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,i=null;if(null!==t){var r=t.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Oi.prototype=Object.create(Ii.prototype),Oi.prototype.constructor=Oi,Oi.prototype.isMeshDepthMaterial=!0,Oi.prototype.copy=function(e){return Ii.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},Di.prototype=Object.create(Ii.prototype),Di.prototype.constructor=Di,Di.prototype.isMeshDistanceMaterial=!0,Di.prototype.copy=function(e){return Ii.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this},Object.assign(Ui.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=e.length;sn&&(n=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(t,i,r),this.max.set(n,o,a),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=e.count;sn&&(n=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(t,i,r),this.max.set(n,o,a),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return(t||new wt).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:(Si=new wt,function(e){return this.clampPoint(e.center,Si),Si.distanceToSquared(e.center)<=e.radius*e.radius}),intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=e.constant&&i>=e.constant},clampPoint:function(e,t){return(t||new wt).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new wt;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new wt;return function(t){var i=t||new Fi;return this.getCenter(i.center),i.radius=.5*this.getSize(e).length(),i}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:(Ti=[new wt,new wt,new wt,new wt,new wt,new wt,new wt,new wt],function(e){return this.isEmpty()?this:(Ti[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ti[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ti[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ti[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ti[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ti[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ti[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ti[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ti),this)}),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(Fi.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:(Ai=new Ui,function(e,t){var i=this.center;void 0!==t?i.copy(t):Ai.setFromPoints(e).getCenter(i);for(var r=0,n=0,o=e.length;nthis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(e){var t=e||new Ui;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(Bi.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new wt,t=new wt;return function(i,r,n){var o=e.subVectors(n,r).cross(t.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return(t||new wt).copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new wt;return function(t,i){var r=i||new wt,n=t.delta(e),o=this.normal.dot(n);if(0===o)return 0===this.distanceToPoint(t.start)?r.copy(t.start):void 0;var a=-(t.start.dot(this.normal)+this.constant)/o;return a<0||a>1?void 0:r.copy(n).multiplyScalar(a).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return(e||new wt).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new wt,t=new _t;return function(i,r){var n=r||t.getNormalMatrix(i),o=this.coplanarPoint(e).applyMatrix4(i),a=this.normal.applyMatrix3(n).normalize();return this.constant=-o.dot(a),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(zi.prototype,{set:function(e,t,i,r,n,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],c=i[5],h=i[6],l=i[7],u=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return t[0].setComponents(a-r,l-s,f-u,y-m).normalize(),t[1].setComponents(a+r,l+s,f+u,y+m).normalize(),t[2].setComponents(a+n,l+c,f+p,y+g).normalize(),t[3].setComponents(a-n,l-c,f-p,y-g).normalize(),t[4].setComponents(a-o,l-h,f-d,y-v).normalize(),t[5].setComponents(a+o,l+h,f+d,y+v).normalize(),this},intersectsObject:(Ci=new Fi,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Ci.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ci)}),intersectsSprite:function(){var e=new Fi;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,i=e.center,r=-e.radius,n=0;n<6;n++){if(t[n].distanceToPoint(i)0?e.min.x:e.max.x,Li.x=r.normal.x>0?e.max.x:e.min.x,Ri.y=r.normal.y>0?e.min.y:e.max.y,Li.y=r.normal.y>0?e.max.y:e.min.y,Ri.z=r.normal.z>0?e.min.z:e.max.z,Li.z=r.normal.z>0?e.max.z:e.min.z;var n=r.distanceToPoint(Ri),o=r.distanceToPoint(Li);if(n<0&&o<0)return!1}return!0}),containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}}),Vi.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Vi.DefaultOrder="XYZ",Object.defineProperties(Vi.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),Object.assign(Vi.prototype,{isEuler:!0,set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var r=vt.clamp,n=e.elements,o=n[0],a=n[4],s=n[8],c=n[1],h=n[5],l=n[9],u=n[2],p=n[6],d=n[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===t?(this._y=Math.asin(-r(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,h))):"YZX"===t?(this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===t?(this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,h),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==i&&this.onChangeCallback(),this},setFromQuaternion:function(){var e=new xt;return function(t,i,r){return e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,i,r)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:(Pi=new bt,function(e){return Pi.setFromEuler(this),this.setFromQuaternion(Pi,e)}),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new wt(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(Hi.prototype,{set:function(e){this.mask=1<1){for(var t=0;t1){for(var t=0;t0){r.children=[];for(a=0;a0&&(i.geometries=c),h.length>0&&(i.materials=h),l.length>0&&(i.textures=l),u.length>0&&(i.images=u)}return i.object=r,i;function p(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var i=0;it&&(t=e[i]);return t}Object.assign(tr.prototype,i.prototype,{isGeometry:!0,applyMatrix:function(e){for(var t=(new _t).getNormalMatrix(e),i=0,r=this.vertices.length;i0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,i;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,r,n;for(i=0,r=this.faces.length;i0&&(e+=t[i].distanceTo(t[i-1])),this.lineDistances[i]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ui),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Fi),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(e&&e.isGeometry){var r,n=this.vertices.length,o=this.vertices,a=e.vertices,s=this.faces,c=e.faces,h=this.faceVertexUvs[0],l=e.faceVertexUvs[0],u=this.colors,p=e.colors;void 0===i&&(i=0),void 0!==t&&(r=(new _t).getNormalMatrix(t));for(var d=0,f=a.length;d=0;i--){var f=p[i];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=d.vertexColors.length>0,x=0;if(x=M(x=M(x=M(x=M(x=M(x=M(x=M(x=M(x,0,0),1,!0),2,!1),3,f),4,m),5,g),6,v),7,y),a.push(x),a.push(d.a,d.b,d.c),a.push(d.materialIndex),f){var b=this.faceVertexUvs[0][n];a.push(S(b[0]),S(b[1]),S(b[2]))}if(m&&a.push(E(d.normal)),g){var w=d.vertexNormals;a.push(E(w[0]),E(w[1]),E(w[2]))}if(v&&a.push(T(d.color)),y){var _=d.vertexColors;a.push(T(_[0]),T(_[1]),T(_[2]))}}function M(e,t,i){return i?e|1<0&&(e.data.colors=h),u.length>0&&(e.data.uvs=[u]),e.data.faces=a,e},clone:function(){return(new tr).copy(this)},copy:function(e){var t,i,r,n,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,i=s.length;t0,a=n[1]&&n[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(var h=0;h0){l=[];for(h=0;h0?1:-1,h.push(L.x,L.y,L.z),l.push(y/m),l.push(1-x/g),A+=1}}for(x=0;x1&&i.sort(Ir),r.length>1&&r.sort(Or)}}},e[r]=n),n},dispose:function(){e={}}}}function Ur(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Fr(){var e=new function(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new wt,color:new gi,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new yt};break;case"SpotLight":i={position:new wt,direction:new wt,color:new gi,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new yt};break;case"PointLight":i={position:new wt,color:new gi,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new yt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new wt,skyColor:new gi,groundColor:new gi};break;case"RectAreaLight":i={color:new gi,position:new wt,halfWidth:new wt,halfHeight:new wt}}return e[t.id]=i,i}}},t={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},i=new wt,r=new xt,n=new xt;return{setup:function(o,a,s){for(var c=0,h=0,l=0,u=0,p=0,d=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v65535?hr:sr)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(t)):(this.attributes[e]=t,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(e,new ir(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var i=this.attributes.normal;void 0!==i&&((new _t).getNormalMatrix(e).applyToBufferAttribute(i),i.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new xt;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new xt;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new xt;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new xt;return function(t,i,r){return e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e=new xt;return function(t,i,r){return e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e=new Zi;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){this.computeBoundingBox();var e=this.boundingBox.getCenter().negate();return this.translate(e.x,e.y,e.z),e},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var i=new lr(3*t.vertices.length,3),r=new lr(3*t.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(t.vertices)),this.addAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var n=new lr(t.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,r=e.length;i0){var i=new Float32Array(3*e.normals.length);this.addAttribute("normal",new ir(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.addAttribute("color",new ir(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var n=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new ir(n,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new ir(o,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var a=new(dr(e.indices)>65535?Uint32Array:Uint16Array)(3*e.indices.length);this.setIndex(new ir(a,1).copyIndicesArray(e.indices))}for(var s in this.groups=e.groups,e.morphTargets){for(var c=[],h=e.morphTargets[s],l=0,u=h.length;l0){var f=new lr(4*e.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var m=new lr(4*e.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ui);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new Ui,t=new wt;return function(){null===this.boundingSphere&&(this.boundingSphere=new Fi);var i=this.attributes.position;if(i){var r=this.boundingSphere.center;e.setFromBufferAttribute(i),e.getCenter(r);for(var n=0,o=0,a=i.count;o0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new _r).copy(this)},copy:function(e){var t,i,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone());var o=e.attributes;for(t in o){var a=o[t];this.addAttribute(t,a.clone())}var s=e.morphAttributes;for(t in s){var c=[],h=s[t];for(i=0,r=h.length;i0)if(o=h*l-u,s=c*d,(n=h*u-l)>=0)if(o>=-s)if(o<=s){var f=1/d;a=(n*=f)*(n+h*(o*=f)+2*l)+o*(h*n+o+2*u)+p}else o=c,a=-(n=Math.max(0,-(h*o+l)))*n+o*(o+2*u)+p;else o=-c,a=-(n=Math.max(0,-(h*o+l)))*n+o*(o+2*u)+p;else o<=-s?a=-(n=Math.max(0,-(-h*c+l)))*n+(o=n>0?-c:Math.min(Math.max(-c,-u),c))*(o+2*u)+p:o<=s?(n=0,a=(o=Math.min(Math.max(-c,-u),c))*(o+2*u)+p):a=-(n=Math.max(0,-(h*c+l)))*n+(o=n>0?c:Math.min(Math.max(-c,-u),c))*(o+2*u)+p;else o=h>0?-c:c,a=-(n=Math.max(0,-(h*o+l)))*n+o*(o+2*u)+p;return i&&i.copy(this.direction).multiplyScalar(n).add(this.origin),r&&r.copy(gr).multiplyScalar(o).add(mr),a}),intersectSphere:function(){var e=new wt;return function(t,i){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),n=e.dot(e)-r*r,o=t.radius*t.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=r-a,c=r+a;return s<0&&c<0?null:s<0?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var i,r,n,o,a,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,r=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,r=(e.min.x-u.x)*c),h>=0?(n=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),i>o||n>r?null:((n>i||i!=i)&&(i=n),(o=0?(a=(e.min.z-u.z)*l,s=(e.max.z-u.z)*l):(a=(e.max.z-u.z)*l,s=(e.min.z-u.z)*l),i>s||a>r?null:((a>i||i!=i)&&(i=a),(s=0?i:r,t)))},intersectsBox:(fr=new wt,function(e){return null!==this.intersectBox(e,fr)}),intersectTriangle:function(){var e=new wt,t=new wt,i=new wt,r=new wt;return function(n,o,a,s,c){t.subVectors(o,n),i.subVectors(a,n),r.crossVectors(t,i);var h,l=this.direction.dot(r);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}e.subVectors(this.origin,n);var u=h*this.direction.dot(i.crossVectors(e,i));if(u<0)return null;var p=h*this.direction.dot(t.cross(e));if(p<0)return null;if(u+p>l)return null;var d=-h*e.dot(r);return d<0?null:this.at(d/l,c)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(Cr.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return(e||new wt).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return(e||new wt).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var i=t||new wt;return this.delta(i).multiplyScalar(e).add(this.start)},closestPointToPointParameter:(yr=new wt,xr=new wt,function(e,t){yr.subVectors(e,this.start),xr.subVectors(this.end,this.start);var i=xr.dot(xr),r=xr.dot(yr)/i;return t&&(r=vt.clamp(r,0,1)),r}),closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t),n=i||new wt;return this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Object.assign(Pr,{normal:(br=new wt,function(e,t,i,r){var n=r||new wt;n.subVectors(i,t),br.subVectors(e,t),n.cross(br);var o=n.lengthSq();return o>0?n.multiplyScalar(1/Math.sqrt(o)):n.set(0,0,0)}),barycoordFromPoint:function(){var e=new wt,t=new wt,i=new wt;return function(r,n,o,a,s){e.subVectors(a,n),t.subVectors(o,n),i.subVectors(r,n);var c=e.dot(e),h=e.dot(t),l=e.dot(i),u=t.dot(t),p=t.dot(i),d=c*u-h*h,f=s||new wt;if(0===d)return f.set(-2,-1,-1);var m=1/d,g=(u*l-h*p)*m,v=(c*p-h*l)*m;return f.set(1-g-v,v,g)}}(),containsPoint:function(){var e=new wt;return function(t,i,r,n){var o=Pr.barycoordFromPoint(t,i,r,n,e);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Pr.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new wt,t=new wt;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){return(e||new wt).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return Pr.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new Bi).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return Pr.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return Pr.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e=new Bi,t=[new Cr,new Cr,new Cr],i=new wt,r=new wt;return function(n,o){var a=o||new wt,s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(n,i),!0===this.containsPoint(i))a.copy(i);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var c=0;c0){var a=n[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=a.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;ei.far?null:{distance:c,point:f.clone(),object:e}}function v(e,t,i,a,s,c,p,f){r.fromBufferAttribute(a,c),n.fromBufferAttribute(a,p),o.fromBufferAttribute(a,f);var v=g(e,e.material,t,i,r,n,o,d);return v&&(s&&(h.fromBufferAttribute(s,c),l.fromBufferAttribute(s,p),u.fromBufferAttribute(s,f),v.uv=m(d,r,n,o,h,l,u)),v.face=new Ki(c,p,f,Pr.normal(r,n,o)),v.faceIndex=c),v}return function(p,f){var y,x=this.geometry,b=this.material,w=this.matrixWorld;if(void 0!==b&&(null===x.boundingSphere&&x.computeBoundingSphere(),i.copy(x.boundingSphere),i.applyMatrix4(w),!1!==p.ray.intersectsSphere(i)&&(e.getInverse(w),t.copy(p.ray).applyMatrix4(e),null===x.boundingBox||!1!==t.intersectsBox(x.boundingBox))))if(x.isBufferGeometry){var _,M,E,T,S,A=x.index,R=x.attributes.position,L=x.attributes.uv;if(null!==A)for(T=0,S=A.count;T0&&(I=F);for(var B=0,z=U.length;B/gm,function(e,t){var i=xi[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return Qr(i)})}function Jr(e){return e.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(e,t,i,r){for(var n="",o=parseInt(t);o0?e.gammaFactor:1,_=function(e,t,i){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Yr).join("\n")}(r.extensions,o,t),M=function(e){var t=[];for(var i in e){var r=e[i];!1!==r&&t.push("#define "+i+" "+r)}return t.join("\n")}(s),E=a.createProgram();r.isRawShaderMaterial?((f=[M].filter(Yr).join("\n")).length>0&&(f+="\n"),(m=[_,M].filter(Yr).join("\n")).length>0&&(m+="\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,M,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+x,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Yr).join("\n"),m=[_,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,M,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+x,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+u:"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&t.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==se?"#define TONE_MAPPING":"",o.toneMapping!==se?xi.tonemapping_pars_fragment:"",o.toneMapping!==se?function(e,t){var i;switch(t){case ce:i="Linear";break;case he:i="Reinhard";break;case le:i="Uncharted2";break;case ue:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?xi.encodings_pars_fragment:"",o.mapEncoding?qr("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?qr("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?qr("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(g="linearToOutputTexel",v=o.outputEncoding,y=Xr(v),"vec4 "+g+"( vec4 value ) { return LinearTo"+y[0]+y[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Yr).join("\n")),c=Zr(c=Qr(c),o),h=Zr(h=Qr(h),o),r.isShaderMaterial||(c=Jr(c),h=Jr(h));var T=f+c,S=m+h,A=Br(a,a.VERTEX_SHADER,T),R=Br(a,a.FRAGMENT_SHADER,S);a.attachShader(E,A),a.attachShader(E,R),void 0!==r.index0AttributeName?a.bindAttribLocation(E,0,r.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(E,0,"position"),a.linkProgram(E);var L,C,P=a.getProgramInfoLog(E),N=a.getShaderInfoLog(A),I=a.getShaderInfoLog(R),O=!0,D=!0;return!1===a.getProgramParameter(E,a.LINK_STATUS)?(O=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(E,a.VALIDATE_STATUS),"gl.getProgramInfoLog",P,N,I)):""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==N&&""!==I||(D=!1),D&&(this.diagnostics={runnable:O,material:r,programLog:P,vertexShader:{log:N,prefix:f},fragmentShader:{log:I,prefix:m}}),a.deleteShader(A),a.deleteShader(R),this.getUniforms=function(){return void 0===L&&(L=new fi(a,E,e)),L},this.getAttributes=function(){return void 0===C&&(C=function(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=0;n0,maxBones:p,useVertexTexture:i.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numClippingPlanes:c,numClipIntersection:h,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.receiveShadow&&o.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===E,flipSided:t.side===M,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,i){var r=[];if(i.shaderID?r.push(i.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(var a=0;at||e.height>t){var i=t/Math.max(e.width,e.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(e.width*i),r.height=Math.floor(e.height*i),r.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+r.width+"x"+r.height,e),r}return e}function h(e){return vt.isPowerOfTwo(e.width)&&vt.isPowerOfTwo(e.height)}function l(e,t){return e.generateMipmaps&&t&&e.minFilter!==_e&&e.minFilter!==Te}function u(t){return t===_e||t===Me||t===Ee?e.NEAREST:e.LINEAR}function p(t){var i=t.target;i.removeEventListener("dispose",p),function(t){var i=r.get(t);if(t.image&&i.__image__webglTextureCube)e.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture)}r.remove(t)}(i),a.textures--}function d(t){var i=t.target;i.removeEventListener("dispose",d),function(t){var i=r.get(t),n=r.get(t.texture);if(!t)return;void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var o=0;o<6;o++)e.deleteFramebuffer(i.__webglFramebuffer[o]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[o]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer);r.remove(t.texture),r.remove(t)}(i),a.textures--}function f(t,u){var d=r.get(t);if(t.version>0&&d.__version!==t.version){var f=t.image;if(void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==f.complete)return void function(t,r,u){void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener("dispose",p),t.__webglTexture=e.createTexture(),a.textures++);i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment);var d=c(r.image,n.maxTextureSize);(function(e){return e.wrapS!==be||e.wrapT!==be||e.minFilter!==_e&&e.minFilter!==Te})(r)&&!1===h(d)&&(d=function(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=vt.floorPowerOfTwo(e.width),t.height=vt.floorPowerOfTwo(e.height),t.getContext("2d").drawImage(e,0,0,t.width,t.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}(d));var f=h(d),g=o.convert(r.format),v=o.convert(r.type);m(e.TEXTURE_2D,r,f);var y,x=r.mipmaps;if(r.isDepthTexture){var b=e.DEPTH_COMPONENT;if(r.type===Oe){if(!s)throw new Error("Float Depth Texture only supported in WebGL2.0");b=e.DEPTH_COMPONENT32F}else s&&(b=e.DEPTH_COMPONENT16);r.format===Xe&&b===e.DEPTH_COMPONENT&&r.type!==Pe&&r.type!==Ie&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Pe,v=o.convert(r.type)),r.format===qe&&(b=e.DEPTH_STENCIL,r.type!==ze&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=ze,v=o.convert(r.type))),i.texImage2D(e.TEXTURE_2D,0,b,d.width,d.height,0,g,v,null)}else if(r.isDataTexture)if(x.length>0&&f){for(var w=0,_=x.length;w<_;w++)y=x[w],i.texImage2D(e.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);r.generateMipmaps=!1}else i.texImage2D(e.TEXTURE_2D,0,g,d.width,d.height,0,g,v,d.data);else if(r.isCompressedTexture)for(var w=0,_=x.length;w<_;w++)y=x[w],r.format!==Ve&&r.format!==Ge?i.getCompressedTextureFormats().indexOf(g)>-1?i.compressedTexImage2D(e.TEXTURE_2D,w,g,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(e.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);else if(x.length>0&&f){for(var w=0,_=x.length;w<_;w++)y=x[w],i.texImage2D(e.TEXTURE_2D,w,g,g,v,y);r.generateMipmaps=!1}else i.texImage2D(e.TEXTURE_2D,0,g,g,v,d);l(r,f)&&e.generateMipmap(e.TEXTURE_2D);t.__version=r.version,r.onUpdate&&r.onUpdate(r)}(d,t,u);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}}i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_2D,d.__webglTexture)}function m(i,a,s){var c;if(s?(e.texParameteri(i,e.TEXTURE_WRAP_S,o.convert(a.wrapS)),e.texParameteri(i,e.TEXTURE_WRAP_T,o.convert(a.wrapT)),e.texParameteri(i,e.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.wrapS===be&&a.wrapT===be||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),e.texParameteri(i,e.TEXTURE_MAG_FILTER,u(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,u(a.minFilter)),a.minFilter!==_e&&a.minFilter!==Te&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=t.get("EXT_texture_filter_anisotropic")){if(a.type===Oe&&null===t.get("OES_texture_float_linear"))return;if(a.type===De&&null===t.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function g(t,n,a,s){var c=o.convert(n.texture.format),h=o.convert(n.texture.type);i.texImage2D(s,0,c,n.width,n.height,0,c,h,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,a,s,r.get(n.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function v(t,i){e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):i.depthBuffer&&i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,i.width,i.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function y(t){var i=r.get(t),n=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),f(i.depthTexture,0);var n=r.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===Xe)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,n,0);else{if(i.depthTexture.format!==qe)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,n,0)}}(i.__webglFramebuffer,t)}else if(n){i.__webglDepthbuffer=[];for(var o=0;o<6;o++)e.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[o]),i.__webglDepthbuffer[o]=e.createRenderbuffer(),v(i.__webglDepthbuffer[o],t)}else e.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),v(i.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(t,s){var u=r.get(t);if(6===t.image.length)if(t.version>0&&u.__version!==t.version){u.__image__webglTextureCube||(t.addEventListener("dispose",p),u.__image__webglTextureCube=e.createTexture(),a.textures++),i.activeTexture(e.TEXTURE0+s),i.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,f=t.image[0]&&t.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=d||f?f?t.image[v].image:t.image[v]:c(t.image[v],n.maxCubemapSize);var y=h(g[0]),x=o.convert(t.format),b=o.convert(t.type);for(m(e.TEXTURE_CUBE_MAP,t,y),v=0;v<6;v++)if(d)for(var w,_=g[v].mipmaps,M=0,E=_.length;M-1?i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,M,x,w.width,w.height,0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,M,x,w.width,w.height,0,x,b,w.data);else f?i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,g[v].width,g[v].height,0,x,b,g[v].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,b,g[v]);l(t,y)&&e.generateMipmap(e.TEXTURE_CUBE_MAP),u.__version=t.version,t.onUpdate&&t.onUpdate(t)}else i.activeTexture(e.TEXTURE0+s),i.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,n){i.activeTexture(e.TEXTURE0+n),i.bindTexture(e.TEXTURE_CUBE_MAP,r.get(t).__webglTexture)},this.setupRenderTarget=function(t){var n=r.get(t),o=r.get(t.texture);t.addEventListener("dispose",d),o.__webglTexture=e.createTexture(),a.textures++;var s=!0===t.isWebGLRenderTargetCube,c=h(t);if(s){n.__webglFramebuffer=[];for(var u=0;u<6;u++)n.__webglFramebuffer[u]=e.createFramebuffer()}else n.__webglFramebuffer=e.createFramebuffer();if(s){for(i.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture),m(e.TEXTURE_CUBE_MAP,t.texture,c),u=0;u<6;u++)g(n.__webglFramebuffer[u],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+u);l(t.texture,c)&&e.generateMipmap(e.TEXTURE_CUBE_MAP),i.bindTexture(e.TEXTURE_CUBE_MAP,null)}else i.bindTexture(e.TEXTURE_2D,o.__webglTexture),m(e.TEXTURE_2D,t.texture,c),g(n.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),l(t.texture,c)&&e.generateMipmap(e.TEXTURE_2D),i.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&y(t)},this.updateRenderTargetMipmap=function(t){var n=t.texture;if(l(n,h(t))){var o=t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=r.get(n).__webglTexture;i.bindTexture(o,a),e.generateMipmap(o),i.bindTexture(o,null)}}}function tn(e,t,i,r){Qi.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function rn(e){tn.call(this),this.cameras=e||[]}function nn(e,t){return{convert:function(i){var r;if(i===xe)return e.REPEAT;if(i===be)return e.CLAMP_TO_EDGE;if(i===we)return e.MIRRORED_REPEAT;if(i===_e)return e.NEAREST;if(i===Me)return e.NEAREST_MIPMAP_NEAREST;if(i===Ee)return e.NEAREST_MIPMAP_LINEAR;if(i===Te)return e.LINEAR;if(i===Se)return e.LINEAR_MIPMAP_NEAREST;if(i===Ae)return e.LINEAR_MIPMAP_LINEAR;if(i===Re)return e.UNSIGNED_BYTE;if(i===Ue)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Fe)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Be)return e.UNSIGNED_SHORT_5_6_5;if(i===Le)return e.BYTE;if(i===Ce)return e.SHORT;if(i===Pe)return e.UNSIGNED_SHORT;if(i===Ne)return e.INT;if(i===Ie)return e.UNSIGNED_INT;if(i===Oe)return e.FLOAT;if(i===De&&null!==(r=t.get("OES_texture_half_float")))return r.HALF_FLOAT_OES;if(i===ke)return e.ALPHA;if(i===Ge)return e.RGB;if(i===Ve)return e.RGBA;if(i===He)return e.LUMINANCE;if(i===je)return e.LUMINANCE_ALPHA;if(i===Xe)return e.DEPTH_COMPONENT;if(i===qe)return e.DEPTH_STENCIL;if(i===O)return e.FUNC_ADD;if(i===D)return e.FUNC_SUBTRACT;if(i===U)return e.FUNC_REVERSE_SUBTRACT;if(i===z)return e.ZERO;if(i===k)return e.ONE;if(i===G)return e.SRC_COLOR;if(i===V)return e.ONE_MINUS_SRC_COLOR;if(i===H)return e.SRC_ALPHA;if(i===j)return e.ONE_MINUS_SRC_ALPHA;if(i===W)return e.DST_ALPHA;if(i===X)return e.ONE_MINUS_DST_ALPHA;if(i===q)return e.DST_COLOR;if(i===Y)return e.ONE_MINUS_DST_COLOR;if(i===Z)return e.SRC_ALPHA_SATURATE;if((i===Ye||i===Ze||i===Qe||i===Je)&&null!==(r=t.get("WEBGL_compressed_texture_s3tc"))){if(i===Ye)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ze)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Qe)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Je)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((i===Ke||i===$e||i===et||i===tt)&&null!==(r=t.get("WEBGL_compressed_texture_pvrtc"))){if(i===Ke)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===$e)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===et)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===tt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===it&&null!==(r=t.get("WEBGL_compressed_texture_etc1")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((i===F||i===B)&&null!==(r=t.get("EXT_blend_minmax"))){if(i===F)return r.MIN_EXT;if(i===B)return r.MAX_EXT}return i===ze&&null!==(r=t.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function on(e){console.log("THREE.WebGLRenderer",m);var t=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=void 0!==e.context?e.context:null,r=void 0!==e.alpha&&e.alpha,n=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,a=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,c=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,h=[],l=[],u=null,p=[],d=[];this.domElement=t,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=ce,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var f,b,w,_,S,A,O,D,U,F,B,z,k,G,V,H,j,W,X,q=this,Y=!1,Z=null,ne=null,oe=-1,ae="",se=null,he=null,le=new Tt,ue=new Tt,pe=null,de=0,fe=t.width,me=t.height,ge=1,ve=new Tt(0,0,fe,me),ye=new Tt(0,0,fe,me),xe=!1,be=new zi,we=new function(){var e=this,t=null,i=0,r=!1,n=!1,o=new Bi,a=new _t,s={value:null,needsUpdate:!1};function c(){s.value!==t&&(s.value=t,s.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(t,i,r,n){var c=null!==t?t.length:0,h=null;if(0!==c){if(h=s.value,!0!==n||null===h){var l=r+4*c,u=i.matrixWorldInverse;a.getNormalMatrix(u),(null===h||h.length0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==i.precision?i.precision:"highp",a=n(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===i.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=e.getParameter(e.MAX_TEXTURE_SIZE),u=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),d=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),f=e.getParameter(e.MAX_VARYING_VECTORS),m=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=h>0,v=!!t.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==r)return r;var i=t.get("EXT_texture_filter_anisotropic");return r=null!==i?e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:u,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(f,b,e),(_=new function(e,t,i){var r=new function(){var t=!1,i=new Tt,r=null,n=new Tt(0,0,0,0);return{setMask:function(i){r===i||t||(e.colorMask(i,i,i,i),r=i)},setLocked:function(e){t=e},setClear:function(t,r,o,a,s){!0===s&&(t*=a,r*=a,o*=a),i.set(t,r,o,a),!1===n.equals(i)&&(e.clearColor(t,r,o,a),n.copy(i))},reset:function(){t=!1,r=null,n.set(-1,0,0,0)}}},n=new function(){var t=!1,i=null,r=null,n=null;return{setTest:function(t){t?X(e.DEPTH_TEST):q(e.DEPTH_TEST)},setMask:function(r){i===r||t||(e.depthMask(r),i=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case Q:e.depthFunc(e.NEVER);break;case J:e.depthFunc(e.ALWAYS);break;case K:e.depthFunc(e.LESS);break;case $:e.depthFunc(e.LEQUAL);break;case ee:e.depthFunc(e.EQUAL);break;case te:e.depthFunc(e.GEQUAL);break;case ie:e.depthFunc(e.GREATER);break;case re:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);r=t}},setLocked:function(e){t=e},setClear:function(t){n!==t&&(e.clearDepth(t),n=t)},reset:function(){t=!1,i=null,r=null,n=null}}},o=new function(){var t=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,h=null;return{setTest:function(t){t?X(e.STENCIL_TEST):q(e.STENCIL_TEST)},setMask:function(r){i===r||t||(e.stencilMask(r),i=r)},setFunc:function(t,i,a){r===t&&n===i&&o===a||(e.stencilFunc(t,i,a),r=t,n=i,o=a)},setOp:function(t,i,r){a===t&&s===i&&c===r||(e.stencilOp(t,i,r),a=t,s=i,c=r)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,h=null}}},a=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),c=new Uint8Array(a),h=new Uint8Array(a),l={},u=null,p=null,d=null,f=null,m=null,x=null,b=null,w=null,_=null,T=!1,S=null,A=null,O=null,D=null,U=null,F=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),B=parseFloat(/^WebGL\ ([0-9])/.exec(e.getParameter(e.VERSION))[1]),z=parseFloat(B)>=1,k=null,G={},V=new Tt,H=new Tt;function j(t,i,r){var n=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var a=0;a65535?hr:sr)(a,1),t.update(r,e.ELEMENT_ARRAY_BUFFER),n[i.id]=r,r}}}(f,O,Se),U=new function(e,t){var i={};return{update:function(r){var n=t.frame,o=r.geometry,a=e.get(r,o);return i[a.id]!==n&&(o.isGeometry&&a.updateFromObject(r),e.update(a),i[a.id]=n),a},clear:function(){i={}}}}(D,Ae),G=new function(e){var t={},i=new Float32Array(8);return{update:function(r,n,o,a){var s=r.morphTargetInfluences,c=s.length,h=t[n.id];if(void 0===h){h=[];for(var l=0;l=0){var h=n[s];if(void 0!==h){var l=h.normalized,u=h.itemSize,p=O.get(h);if(void 0===p)continue;var d=p.buffer,m=p.type,g=p.bytesPerElement;if(h.isInterleavedBufferAttribute){var v=h.data,y=v.stride,x=h.offset;v&&v.isInstancedInterleavedBuffer?(_.enableAttributeAndDivisor(c,v.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=v.meshPerAttribute*v.count)):_.enableAttribute(c),f.bindBuffer(f.ARRAY_BUFFER,d),f.vertexAttribPointer(c,u,m,l,y*g,(r*y+x)*g)}else h.isInstancedBufferAttribute?(_.enableAttributeAndDivisor(c,h.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=h.meshPerAttribute*h.count)):_.enableAttribute(c),f.bindBuffer(f.ARRAY_BUFFER,d),f.vertexAttribPointer(c,u,m,l,0,r*u*g)}else if(void 0!==a){var w=a[s];if(void 0!==w)switch(w.length){case 2:f.vertexAttrib2fv(c,w);break;case 3:f.vertexAttrib3fv(c,w);break;case 4:f.vertexAttrib4fv(c,w);break;default:f.vertexAttrib1fv(c,w)}}}}_.disableUnusedAttributes()}(r,a,i),null!==l&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.buffer));var m=0;null!==l?m=l.count:void 0!==u&&(m=u.count);var g=i.drawRange.start*p,v=i.drawRange.count*p,y=null!==o?o.start*p:0,x=null!==o?o.count*p:1/0,w=Math.max(g,y),M=Math.min(m,g+v,y+x)-1,E=Math.max(0,M-w+1);if(0!==E){if(n.isMesh)if(!0===r.wireframe)_.setLineWidth(r.wireframeLinewidth*Le()),d.setMode(f.LINES);else switch(n.drawMode){case ot:d.setMode(f.TRIANGLES);break;case at:d.setMode(f.TRIANGLE_STRIP);break;case st:d.setMode(f.TRIANGLE_FAN)}else if(n.isLine){var T=r.linewidth;void 0===T&&(T=1),_.setLineWidth(T*Le()),n.isLineSegments?d.setMode(f.LINES):n.isLineLoop?d.setMode(f.LINE_LOOP):d.setMode(f.LINE_STRIP)}else n.isPoints&&d.setMode(f.POINTS);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&d.renderInstances(i,w,E):d.render(w,E)}},this.compile=function(e,t){h.length=0,l.length=0,e.traverse(function(e){e.isLight&&(h.push(e),e.castShadow&&l.push(e))}),F.setup(h,l,t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var i=0;i=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(u=0;u=0&&e.numSupportedMorphNormals++}var p=r.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=we.numPlanes,r.numIntersection=we.numIntersection,p.clippingPlanes=we.uniform),r.fog=t,r.lightsHash=F.state.hash,e.lights&&(p.ambientLightColor.value=F.state.ambient,p.directionalLights.value=F.state.directional,p.spotLights.value=F.state.spot,p.rectAreaLights.value=F.state.rectArea,p.pointLights.value=F.state.point,p.hemisphereLights.value=F.state.hemi,p.directionalShadowMap.value=F.state.directionalShadowMap,p.directionalShadowMatrix.value=F.state.directionalShadowMatrix,p.spotShadowMap.value=F.state.spotShadowMap,p.spotShadowMatrix.value=F.state.spotShadowMatrix,p.pointShadowMap.value=F.state.pointShadowMap,p.pointShadowMatrix.value=F.state.pointShadowMatrix);var d=r.program.getUniforms(),f=fi.seqWithValue(d.seq,p);r.uniformsList=f}function Ye(e,t,i,r){de=0;var n=S.get(i);if(_e&&(Me||e!==se)){var o=e===se&&i.id===oe;we.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,e,n,o)}!1===i.needsUpdate&&(void 0===n.program?i.needsUpdate=!0:i.fog&&n.fog!==t?i.needsUpdate=!0:i.lights&&n.lightsHash!==F.state.hash?i.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===we.numPlanes&&n.numIntersection===we.numIntersection||(i.needsUpdate=!0)),i.needsUpdate&&(qe(i,t,r),i.needsUpdate=!1);var a,s,c=!1,h=!1,l=!1,u=n.program,p=u.getUniforms(),d=n.shader.uniforms;if(_.useProgram(u.program)&&(c=!0,h=!0,l=!0),i.id!==oe&&(oe=i.id,h=!0),c||e!==se){if(p.setValue(f,"projectionMatrix",e.projectionMatrix),w.logarithmicDepthBuffer&&p.setValue(f,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),se!==(he||e)&&(se=he||e,h=!0,l=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var m=p.map.cameraPosition;void 0!==m&&m.setValue(f,Te.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&p.setValue(f,"viewMatrix",e.matrixWorldInverse)}if(i.skinning){p.setOptional(f,r,"bindMatrix"),p.setOptional(f,r,"bindMatrixInverse");var g=r.skeleton;if(g){var v=g.bones;if(w.floatVertexTextures){if(void 0===g.boneTexture){var y=Math.sqrt(4*v.length);y=vt.ceilPowerOfTwo(y),y=Math.max(y,4);var x=new Float32Array(y*y*4);x.set(g.boneMatrices);var b=new Rt(x,y,y,Ve,Oe);g.boneMatrices=x,g.boneTexture=b,g.boneTextureSize=y}p.setValue(f,"boneTexture",g.boneTexture),p.setValue(f,"boneTextureSize",g.boneTextureSize)}else p.setOptional(f,g,"boneMatrices")}}return h&&(p.setValue(f,"toneMappingExposure",q.toneMappingExposure),p.setValue(f,"toneMappingWhitePoint",q.toneMappingWhitePoint),i.lights&&(s=l,(a=d).ambientLightColor.needsUpdate=s,a.directionalLights.needsUpdate=s,a.pointLights.needsUpdate=s,a.spotLights.needsUpdate=s,a.rectAreaLights.needsUpdate=s,a.hemisphereLights.needsUpdate=s),t&&i.fog&&function(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}(d,t),i.isMeshBasicMaterial?Ze(d,i):i.isMeshLambertMaterial?(Ze(d,i),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(d,i)):i.isMeshPhongMaterial?(Ze(d,i),i.isMeshToonMaterial?function(e,t){Qe(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(d,i):Qe(d,i)):i.isMeshStandardMaterial?(Ze(d,i),i.isMeshPhysicalMaterial?function(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,Je(e,t)}(d,i):Je(d,i)):i.isMeshDepthMaterial?(Ze(d,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(d,i)):i.isMeshDistanceMaterial?(Ze(d,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(d,i)):i.isMeshNormalMaterial?(Ze(d,i),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale);t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale));t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(d,i)):i.isLineBasicMaterial?(function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}(d,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(d,i)):i.isPointsMaterial?function(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*ge,e.scale.value=.5*me,e.map.value=t.map,null!==t.map){if(!0===t.map.matrixAutoUpdate){var i=t.map.offset,r=t.map.repeat,n=t.map.rotation,o=t.map.center;t.map.matrix.setUvTransform(i.x,i.y,r.x,r.y,n,o.x,o.y)}e.uvTransform.value.copy(t.map.matrix)}}(d,i):i.isShadowMaterial&&(d.color.value=i.color,d.opacity.value=i.opacity),void 0!==d.ltcMat&&(d.ltcMat.value=vi.LTC_MAT_TEXTURE),void 0!==d.ltcMag&&(d.ltcMag.value=vi.LTC_MAG_TEXTURE),fi.upload(f,n.uniformsList,d,q)),p.setValue(f,"modelViewMatrix",r.modelViewMatrix),p.setValue(f,"normalMatrix",r.normalMatrix),p.setValue(f,"modelMatrix",r.matrixWorld),u}function Ze(e,t){var i;if(e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap&&(i=t.emissiveMap),void 0!==i){if(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate){var r=i.offset,n=i.repeat,o=i.rotation,a=i.center;i.matrix.setUvTransform(r.x,r.y,n.x,n.y,o,a.x,a.y)}e.uvTransform.value.copy(i.matrix)}}function Qe(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function Je(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}this.animate=function(e){He=e,function(){if(!Ge){var e=Ne.getDevice();e&&e.isPresenting?e.requestAnimationFrame(je):window.requestAnimationFrame(je),Ge=!0}}()},this.render=function(e,t,i,r){if(t&&t.isCamera){if(!Y){ae="",oe=-1,se=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Ne.enabled&&(t=Ne.getCamera(t)),Ee.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),be.setFromMatrix(Ee),h.length=0,l.length=0,p.length=0,d.length=0,Me=this.localClippingEnabled,_e=we.init(this.clippingPlanes,Me,t),(u=z.get(e,t)).init(),function e(t,i,r){if(!1===t.visible)return;var n=t.layers.test(i.layers);if(n)if(t.isLight)h.push(t),t.castShadow&&l.push(t);else if(t.isSprite)t.frustumCulled&&!be.intersectsSprite(t)||p.push(t);else if(t.isLensFlare)d.push(t);else if(t.isImmediateRenderObject)r&&Te.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Ee),u.push(t,null,t.material,Te.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||be.intersectsObject(t))){r&&Te.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Ee);var o=U.update(t),a=t.material;if(Array.isArray(a))for(var s=o.groups,c=0,f=s.length;c=w.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+w.maxTextures),de+=1,e},this.setTexture2D=(ke=!1,function(e,t){e&&e.isWebGLRenderTarget&&(ke||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),ke=!0),e=e.texture),A.setTexture2D(e,t)}),this.setTexture=function(){var e=!1;return function(t,i){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),A.setTexture2D(t,i)}}(),this.setTextureCube=function(){var e=!1;return function(t,i){t&&t.isWebGLRenderTargetCube&&(e||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?A.setTextureCube(t,i):A.setTextureCubeDynamic(t,i)}}(),this.getRenderTarget=function(){return Z},this.setRenderTarget=function(e){Z=e,e&&void 0===S.get(e).__webglFramebuffer&&A.setupRenderTarget(e);var t=null,i=!1;if(e){var r=S.get(e).__webglFramebuffer;e.isWebGLRenderTargetCube?(t=r[e.activeCubeFace],i=!0):t=r,le.copy(e.viewport),ue.copy(e.scissor),pe=e.scissorTest}else le.copy(ve).multiplyScalar(ge),ue.copy(ye).multiplyScalar(ge),pe=xe;if(ne!==t&&(f.bindFramebuffer(f.FRAMEBUFFER,t),ne=t),_.viewport(le),_.scissor(ue),_.setScissorTest(pe),i){var n=S.get(e.texture);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,n.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,i,r,n,o){if(e&&e.isWebGLRenderTarget){var a=S.get(e).__webglFramebuffer;if(a){var s=!1;a!==ne&&(f.bindFramebuffer(f.FRAMEBUFFER,a),s=!0);try{var c=e.texture,h=c.format,l=c.type;if(h!==Ve&&X.convert(h)!==f.getParameter(f.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===Re||X.convert(l)===f.getParameter(f.IMPLEMENTATION_COLOR_READ_TYPE)||l===Oe&&(b.get("OES_texture_float")||b.get("WEBGL_color_buffer_float"))||l===De&&b.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-r&&i>=0&&i<=e.height-n&&f.readPixels(t,i,r,n,X.convert(h),X.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&f.bindFramebuffer(f.FRAMEBUFFER,ne)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function an(e,t){this.name="",this.color=new gi(e),this.density=void 0!==t?t:25e-5}function sn(e,t,i){this.name="",this.color=new gi(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3}function cn(){Zi.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function hn(e,t,i,r,n){Zi.call(this),this.lensFlares=[],this.positionScreen=new wt,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,i,r,n)}function ln(e){Ii.call(this),this.type="SpriteMaterial",this.color=new gi(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function un(e){Zi.call(this),this.type="Sprite",this.material=void 0!==e?e:new ln}function pn(){Zi.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function dn(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,r=this.bones.length;i=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0),requestAnimationFrame(e)})}function En(e,t,i,r,n,o,a,s,c,h,l,u){Et.call(this,null,o,a,s,c,h,r,n,l,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Tn(e,t,i,r,n,o,a,s,c,h){if((h=void 0!==h?h:Xe)!==Xe&&h!==qe)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Xe&&(i=Pe),void 0===i&&h===qe&&(i=ze),Et.call(this,null,r,n,o,a,s,h,i,c),this.image={width:e,height:t},this.magFilter=void 0!==a?a:_e,this.minFilter=void 0!==s?s:_e,this.flipY=!1,this.generateMipmaps=!1}function Sn(e){_r.call(this),this.type="WireframeGeometry";var t,i,r,n,o,a,s,c,h,l,u=[],p=[0,0],d={},f=["a","b","c"];if(e&&e.isGeometry){var m=e.faces;for(t=0,r=m.length;t=0?(u=e(g-1e-5,m,u),p.subVectors(l,u)):(u=e(g+1e-5,m,u),p.subVectors(u,l)),m-1e-5>=0?(u=e(g,m-1e-5,u),d.subVectors(l,u)):(u=e(g,m+1e-5,u),d.subVectors(u,l)),h.crossVectors(p,d).normalize(),s.push(h.x,h.y,h.z),c.push(g,m)}}for(r=0;r.9&&a<.1&&(t<.2&&(o[e+0]+=1),i<.2&&(o[e+2]+=1),r<.2&&(o[e+4]+=1))}}()}(),this.addAttribute("position",new lr(n,3)),this.addAttribute("normal",new lr(n.slice(),3)),this.addAttribute("uv",new lr(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Pn(e,t){tr.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Nn(e,t)),this.mergeVertices()}function Nn(e,t){Cn.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],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function In(e,t){tr.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new On(e,t)),this.mergeVertices()}function On(e,t){Cn.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],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Dn(e,t){tr.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Un(e,t)),this.mergeVertices()}function Un(e,t){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];Cn.call(this,r,[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],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Fn(e,t){tr.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Bn(e,t)),this.mergeVertices()}function Bn(e,t){var i=(1+Math.sqrt(5))/2,r=1/i,n=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];Cn.call(this,n,[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],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function zn(e,t,i,r,n,o){tr.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new kn(e,t,i,r,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function kn(e,t,i,r,n){_r.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},t=t||64,i=i||1,r=r||8,n=n||!1;var o=e.computeFrenetFrames(t,n);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,c=new wt,h=new wt,l=new yt,u=new wt,p=[],d=[],f=[],m=[];function g(n){u=e.getPointAt(n/t,u);var a=o.normals[n],l=o.binormals[n];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);h.x=g*a.x+m*l.x,h.y=g*a.y+m*l.y,h.z=g*a.z+m*l.z,h.normalize(),d.push(h.x,h.y,h.z),c.x=u.x+i*h.x,c.y=u.y+i*h.y,c.z=u.z+i*h.z,p.push(c.x,c.y,c.z)}}!function(){for(a=0;ai)){var r=e.ray.origin.distanceTo(zr);re.far||t.push({distance:r,point:zr.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)}}),pn.prototype=Object.assign(Object.create(Zi.prototype),{constructor:pn,copy:function(e){Zi.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,r=t.length;i1){e.setFromMatrixPosition(i.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);r[0].object.visible=!0;for(var o=1,a=r.length;o=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;oa))p.applyMatrix4(this.matrixWorld),(M=r.ray.origin.distanceTo(p))r.far||n.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}else for(v=0,y=m.length/3-1;va))p.applyMatrix4(this.matrixWorld),(M=r.ray.origin.distanceTo(p))r.far||n.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var w=s.vertices,_=w.length;for(v=0;v<_-1;v+=d){var M;if(!(t.distanceSqToSegment(w[v],w[v+1],p,u)>a))p.applyMatrix4(this.matrixWorld),(M=r.ray.origin.distanceTo(p))r.far||n.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),yn.prototype=Object.assign(Object.create(vn.prototype),{constructor:yn,isLineSegments:!0}),xn.prototype=Object.assign(Object.create(vn.prototype),{constructor:xn,isLineLoop:!0}),bn.prototype=Object.create(Ii.prototype),bn.prototype.constructor=bn,bn.prototype.isPointsMaterial=!0,bn.prototype.copy=function(e){return Ii.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},wn.prototype=Object.assign(Object.create(Zi.prototype),{constructor:wn,isPoints:!0,raycast:function(){var e=new xt,t=new Lr,i=new Fi;return function(r,n){var o=this,a=this.geometry,s=this.matrixWorld,c=r.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),i.copy(a.boundingSphere),i.applyMatrix4(s),i.radius+=c,!1!==r.ray.intersectsSphere(i)){e.getInverse(s),t.copy(r.ray).applyMatrix4(e);var h=c/((this.scale.x+this.scale.y+this.scale.z)/3),l=h*h,u=new wt;if(a.isBufferGeometry){var p=a.index,d=a.attributes.position.array;if(null!==p)for(var f=p.array,m=0,g=f.length;mr.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:c.clone(),index:i,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),_n.prototype=Object.assign(Object.create(Zi.prototype),{constructor:_n}),Mn.prototype=Object.create(Et.prototype),Mn.prototype.constructor=Mn,En.prototype=Object.create(Et.prototype),En.prototype.constructor=En,En.prototype.isCompressedTexture=!0,Tn.prototype=Object.create(Et.prototype),Tn.prototype.constructor=Tn,Tn.prototype.isDepthTexture=!0,Sn.prototype=Object.create(_r.prototype),Sn.prototype.constructor=Sn,An.prototype=Object.create(tr.prototype),An.prototype.constructor=An,Rn.prototype=Object.create(_r.prototype),Rn.prototype.constructor=Rn,Ln.prototype=Object.create(tr.prototype),Ln.prototype.constructor=Ln,Cn.prototype=Object.create(_r.prototype),Cn.prototype.constructor=Cn,Pn.prototype=Object.create(tr.prototype),Pn.prototype.constructor=Pn,Nn.prototype=Object.create(Cn.prototype),Nn.prototype.constructor=Nn,In.prototype=Object.create(tr.prototype),In.prototype.constructor=In,On.prototype=Object.create(Cn.prototype),On.prototype.constructor=On,Dn.prototype=Object.create(tr.prototype),Dn.prototype.constructor=Dn,Un.prototype=Object.create(Cn.prototype),Un.prototype.constructor=Un,Fn.prototype=Object.create(tr.prototype),Fn.prototype.constructor=Fn,Bn.prototype=Object.create(Cn.prototype),Bn.prototype.constructor=Bn,zn.prototype=Object.create(tr.prototype),zn.prototype.constructor=zn,kn.prototype=Object.create(_r.prototype),kn.prototype.constructor=kn,Gn.prototype=Object.create(tr.prototype),Gn.prototype.constructor=Gn,Vn.prototype=Object.create(_r.prototype),Vn.prototype.constructor=Vn,Hn.prototype=Object.create(tr.prototype),Hn.prototype.constructor=Hn,jn.prototype=Object.create(_r.prototype),jn.prototype.constructor=jn;var Wn={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;n=-Number.EPSILON&&_>=-Number.EPSILON&&w>=-Number.EPSILON))return!1;return!0}return function(t,i){var r=t.length;if(r<3)return null;var n,o,a,s=[],c=[],h=[];if(Wn.area(t)>0)for(o=0;o2;){if(u--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?h:s;if(l<=(n=o)&&(n=0),l<=(o=n+1)&&(o=0),l<=(a=o+1)&&(a=0),e(t,n,o,a,l,c)){var p,d,f,m,g;for(p=c[n],d=c[o],f=c[a],s.push([t[p],t[d],t[f]]),h.push([c[n],c[o],c[a]]),m=o,g=o+1;g2&&e[t-1].equals(e[0])&&e.pop()}function r(e,t,i){return e.x!==t.x?e.xNumber.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=h*l-c*u)<0||f>p)return[]}else{if(d>0||d0||fM?[]:y===M?o?[]:[g]:x<=M?[g,v]:[g,w])}function o(e,t,i,r){var n=t.x-e.x,o=t.y-e.y,a=i.x-e.x,s=i.y-e.y,c=r.x-e.x,h=r.y-e.y,l=n*s-o*a,u=n*h-o*c;if(Math.abs(l)>Number.EPSILON){var p=c*s-h*a;return l>0?u>=0&&p>=0:u>=0||p>=0}return u>0}i(e),t.forEach(i);for(var a,s,c,h,l,u,p={},d=e.concat(),f=0,m=t.length;fn&&(s=0);var c=o(r[e],r[a],r[s],i[t]);if(!c)return!1;var h=i.length-1,l=t-1;l<0&&(l=h);var u=t+1;return u>h&&(u=0),!!(c=o(i[t],i[l],i[u],r[e]))}function s(e,t){var i,o;for(i=0;i0)return!0;return!1}var c=[];function h(e,i){var r,o,a,s;for(r=0;r0)return!0;return!1}for(var l,u,p,d,f,m,g,v,y,x,b=[],w=0,_=t.length;w<_;w++)c.push(w);for(var M=0,E=2*c.length;c.length>0;){if(--E<0){console.log('THREE.ShapeUtils: Infinite Loop! Holes left:" + indepHoles.length + ", Probably Hole outside Shape!');break}for(u=M;u=0)break;b[m]=!0}if(l>=0)break}}return r}(e,t),v=Wn.triangulate(g,!1);for(a=0,s=v.length;a0)&&f.push(w,_,E),(c!==i-1||h0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.addAttribute("position",new lr(l,3)),this.addAttribute("normal",new lr(u,3)),this.addAttribute("uv",new lr(p,2))}function so(e,t,i,r,n,o,a){oo.call(this,0,e,t,i,r,n,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function co(e,t,i,r,n,o,a){ao.call(this,0,e,t,i,r,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function ho(e,t,i,r){tr.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new lo(e,t,i,r)),this.mergeVertices()}function lo(e,t,i,r){_r.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,o,a=[],s=[],c=[],h=[],l=new wt,u=new yt;for(s.push(0,0,0),c.push(0,0,1),h.push(.5,.5),o=0,n=3;o<=t;o++,n+=3){var p=i+o/t*r;l.x=e*Math.cos(p),l.y=e*Math.sin(p),s.push(l.x,l.y,l.z),c.push(0,0,1),u.x=(s[n]/e+1)/2,u.y=(s[n+1]/e+1)/2,h.push(u.x,u.y)}for(n=1;n<=t;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new lr(s,3)),this.addAttribute("normal",new lr(c,3)),this.addAttribute("uv",new lr(h,2))}Xn.prototype=Object.create(tr.prototype),Xn.prototype.constructor=Xn,qn.prototype=Object.create(_r.prototype),qn.prototype.constructor=qn,qn.prototype.getArrays=function(){var e=this.getAttribute("position"),t=e?Array.prototype.slice.call(e.array):[],i=this.getAttribute("uv"),r=i?Array.prototype.slice.call(i.array):[],n=this.index;return{position:t,uv:r,index:n?Array.prototype.slice.call(n.array):[]}},qn.prototype.addShapeList=function(e,t){var i=e.length;t.arrays=this.getArrays();for(var r=0;rNumber.EPSILON){var p=Math.sqrt(l),d=Math.sqrt(c*c+h*h),f=t.x-s/p,m=t.y+a/p,g=((i.x-h/d-f)*h-(i.y+c/d-m)*c)/(a*h-s*c),v=(r=f+a*g-e.x)*r+(n=m+s*g-e.y)*n;if(v<=2)return new yt(r,n);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?c>Number.EPSILON&&(y=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(h)&&(y=!0),y?(r=-s,n=a,o=Math.sqrt(l)):(r=a,n=s,o=Math.sqrt(l/2))}return new yt(r/o,n/o)}for(var G=[],V=0,H=C.length,j=H-1,W=V+1;V=0;N--){for(O=N/y,D=g*Math.cos(O*Math.PI/2),I=v*Math.sin(O*Math.PI/2),V=0,H=C.length;V=0;){i=V,(r=V-1)<0&&(r=e.length-1);var n=0,o=w+2*y;for(n=0;n0||0===e.search(/^data\:image\/jpeg/);o.format=i?Ge:Ve,o.needsUpdate=!0,void 0!==t&&t(o)},i,r),o},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Io.prototype=Object.assign(Object.create(Zi.prototype),{constructor:Io,isLight:!0,copy:function(e){return Zi.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=Zi.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Oo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Oo,isHemisphereLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(Do.prototype,{copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),Uo.prototype=Object.assign(Object.create(Do.prototype),{constructor:Uo,isSpotLightShadow:!0,update:function(e){var t=this.camera,i=2*vt.RAD2DEG*e.angle,r=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;i===t.fov&&r===t.aspect&&n===t.far||(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix())}}),Fo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Fo,isSpotLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Bo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Bo,isPointLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),zo.prototype=Object.assign(Object.create(Do.prototype),{constructor:zo}),ko.prototype=Object.assign(Object.create(Io.prototype),{constructor:ko,isDirectionalLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Go.prototype=Object.assign(Object.create(Io.prototype),{constructor:Go,isAmbientLight:!0}),Vo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Vo,isRectAreaLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var t=Io.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}});var Ho,jo={arraySlice:function(e,t,i){return jo.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){for(var t=e.length,i=new Array(t),r=0;r!==t;++r)i[r]=r;return i.sort(function(t,i){return e[t]-e[i]}),i},sortedArray:function(e,t,i){for(var r=e.length,n=new e.constructor(r),o=0,a=0;a!==r;++o)for(var s=i[o]*t,c=0;c!==t;++c)n[a++]=e[s+c];return n},flattenJSON:function(e,t,i,r){for(var n=1,o=e[0];void 0!==o&&void 0===o[r];)o=e[n++];if(void 0!==o){var a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(t.push(o.time),i.push.apply(i,a)),o=e[n++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(t.push(o.time),a.toArray(i,i.length)),o=e[n++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(t.push(o.time),i.push(a)),o=e[n++]}while(void 0!==o)}}};function Wo(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i}function Xo(e,t,i,r){Wo.call(this,e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function qo(e,t,i,r){Wo.call(this,e,t,i,r)}function Yo(e,t,i,r){Wo.call(this,e,t,i,r)}function Zo(e,t,i,r){if(void 0===e)throw new Error("track name is undefined");if(void 0===t||0===t.length)throw new Error("no keyframes in track named "+e);this.name=e,this.times=jo.convertArray(t,this.TimeBufferType),this.values=jo.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()}function Qo(e,t,i,r){Zo.call(this,e,t,i,r)}function Jo(e,t,i,r){Wo.call(this,e,t,i,r)}function Ko(e,t,i,r){Zo.call(this,e,t,i,r)}function $o(e,t,i,r){Zo.call(this,e,t,i,r)}function ea(e,t,i,r){Zo.call(this,e,t,i,r)}function ta(e,t,i){Zo.call(this,e,t,i)}function ia(e,t,i,r){Zo.call(this,e,t,i,r)}function ra(e,t,i,r){Zo.apply(this,e,t,i,r)}function na(e,t,i){this.name=e,this.tracks=i,this.duration=void 0!==t?t:-1,this.uuid=vt.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function oa(e){this.manager=void 0!==e?e:To,this.textures={}}function aa(e){this.manager=void 0!==e?e:To}Object.assign(Wo.prototype,{evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{var o;i:{r:if(!(e=n)break e;var s=t[1];e=(n=t[--i-1]))break t}o=i,i=0}for(;i>>1;et;)--o;if(++o,0!==n||o!==r){n>=o&&(n=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=jo.arraySlice(i,n,o),this.values=jo.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),e=!1);var i=this.times,r=this.values,n=i.length;0===n&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),e=!1);for(var o=null,a=0;a!==n;a++){var s=i[a];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",this,a,s),e=!1;break}if(null!==o&&o>s){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",this,a,s,o),e=!1;break}o=s}if(void 0!==r&&jo.isTypedArray(r)){a=0;for(var c=r.length;a!==c;++a){var h=r[a];if(isNaN(h)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",this,a,h),e=!1;break}}}return e},optimize:function(){for(var e=this.times,t=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,o=e.length-1,a=1;a0){e[n]=e[o];for(f=o*i,m=n*i,p=0;p!==i;++p)t[m+p]=t[f+p];++n}return n!==e.length&&(this.times=jo.arraySlice(e,0,n),this.values=jo.arraySlice(t,0,n*i)),this}},Qo.prototype=Object.assign(Object.create(Ho),{constructor:Qo,ValueTypeName:"vector"}),Jo.prototype=Object.assign(Object.create(Wo.prototype),{constructor:Jo,interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,c=(i-t)/(r-t),h=s+a;s!==h;s+=4)bt.slerpFlat(n,0,o,s-a,o,s,c);return n}}),Ko.prototype=Object.assign(Object.create(Ho),{constructor:Ko,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(e){return new Jo(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),$o.prototype=Object.assign(Object.create(Ho),{constructor:$o,ValueTypeName:"number"}),ea.prototype=Object.assign(Object.create(Ho),{constructor:ea,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ta.prototype=Object.assign(Object.create(Ho),{constructor:ta,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ia.prototype=Object.assign(Object.create(Ho),{constructor:ia,ValueTypeName:"color"}),ra.prototype=Ho,Ho.constructor=ra,Object.assign(ra,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=ra._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var i=[],r=[];jo.flattenJSON(e.keys,i,r,"value"),e.times=i,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)},toJSON:function(e){var t,i=e.constructor;if(void 0!==i.toJSON)t=i.toJSON(e);else{t={name:e.name,times:jo.convertArray(e.times,Array),values:jo.convertArray(e.values,Array)};var r=e.getInterpolation();r!==e.DefaultInterpolation&&(t.interpolation=r)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $o;case"vector":case"vector2":case"vector3":case"vector4":return Qo;case"color":return ia;case"quaternion":return Ko;case"bool":case"boolean":return ta;case"string":return ea}throw new Error("Unsupported typeName: "+e)}}),Object.assign(na,{parse:function(e){for(var t=[],i=e.tracks,r=1/(e.fps||1),n=0,o=i.length;n!==o;++n)t.push(ra.parse(i[n]).scale(r));return new na(e.name,e.duration,t)},toJSON:function(e){for(var t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t},n=0,o=i.length;n!==o;++n)t.push(ra.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(e,t,i,r){for(var n=t.length,o=[],a=0;a1){var h=r[u=c[1]];h||(r[u]=h=[]),h.push(s)}}var l=[];for(var u in r)l.push(na.CreateFromMorphTargetSequence(u,r[u],t,i));return l},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(e,t,i,r,n){if(0!==i.length){var o=[],a=[];jo.flattenJSON(i,o,a,r),0!==o.length&&n.push(new e(t,o,a))}},r=[],n=e.name||"default",o=e.length||-1,a=e.fps||30,s=e.hierarchy||[],c=0;c1?e.skinWeights[r+1]:0,s=i>2?e.skinWeights[r+2]:0,c=i>3?e.skinWeights[r+3]:0;t.skinWeights.push(new Tt(o,a,s,c))}if(e.skinIndices)for(r=0,n=e.skinIndices.length;r1?e.skinIndices[r+1]:0,u=i>2?e.skinIndices[r+2]:0,p=i>3?e.skinIndices[r+3]:0;t.skinIndices.push(new Tt(h,l,u,p))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}(e,i),function(e,t){var i=e.scale;if(void 0!==e.morphTargets)for(var r=0,n=e.morphTargets.length;r0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var l=t.faces,u=e.morphColors[0].colors;for(r=0,n=l.length;r0&&(t.animations=i)}(e,i),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===e.materials||0===e.materials.length?{geometry:i}:{geometry:i,materials:pa.prototype.initMaterials(e.materials,t,this.crossOrigin)}}}()}),Object.assign(fa.prototype,{load:function(e,t,i,r){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var n=this;new Ao(n.manager).load(e,function(i){var o=null;try{o=JSON.parse(i)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?n.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.")},i,r)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var i=this.parseGeometries(e.geometries),r=this.parseImages(e.images,function(){void 0!==t&&t(a)}),n=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,n),a=this.parseObject(e.object,i,o);return e.animations&&(a.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(a),a},parseGeometries:function(e){var t={};if(void 0!==e)for(var i=new da,r=new aa,n=0,o=e.length;n0){var o=new Co(new Eo(t));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=e.length;a0?new mn(s,c):new Nr(s,c);break;case"LOD":n=new pn;break;case"Line":n=new vn(o(t.geometry),a(t.material),t.mode);break;case"LineLoop":n=new xn(o(t.geometry),a(t.material));break;case"LineSegments":n=new yn(o(t.geometry),a(t.material));break;case"PointCloud":case"Points":n=new wn(o(t.geometry),a(t.material));break;case"Sprite":n=new un(a(t.material));break;case"Group":n=new _n;break;default:n=new Zi}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.children)for(var h=t.children,l=0;l0)){c=n;break}c=n-1}if(r[n=c]===i)return n/(o-1);var h=r[n];return(n+(i-h)/(r[n+1]-h))/(o-1)},getTangent:function(e){var t=e-1e-4,i=e+1e-4;t<0&&(t=0),i>1&&(i=1);var r=this.getPoint(t);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var i,r,n,o=new wt,a=[],s=[],c=[],h=new wt,l=new xt;for(i=0;i<=e;i++)r=i/e,a[i]=this.getTangentAt(r),a[i].normalize();s[0]=new wt,c[0]=new wt;var u=Number.MAX_VALUE,p=Math.abs(a[0].x),d=Math.abs(a[0].y),f=Math.abs(a[0].z);for(p<=u&&(u=p,o.set(1,0,0)),d<=u&&(u=d,o.set(0,1,0)),f<=u&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),i=1;i<=e;i++)s[i]=s[i-1].clone(),c[i]=c[i-1].clone(),h.crossVectors(a[i-1],a[i]),h.length()>Number.EPSILON&&(h.normalize(),n=Math.acos(vt.clamp(a[i-1].dot(a[i]),-1,1)),s[i].applyMatrix4(l.makeRotationAxis(h,n))),c[i].crossVectors(a[i],s[i]);if(!0===t)for(n=Math.acos(vt.clamp(s[0].dot(s[e]),-1,1)),n/=e,a[0].dot(h.crossVectors(s[0],s[e]))>0&&(n=-n),i=1;i<=e;i++)s[i].applyMatrix4(l.makeRotationAxis(a[i],n*i)),c[i].crossVectors(a[i],s[i]);return{tangents:a,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),_a.prototype=Object.create(wa.prototype),_a.prototype.constructor=_a,_a.prototype.isLineCurve=!0,_a.prototype.getPoint=function(e,t){var i=t||new yt;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},_a.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},_a.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},_a.prototype.copy=function(e){return wa.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ma.prototype=Object.assign(Object.create(wa.prototype),{constructor:Ma,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new _a(t,e))},getPoint:function(e){for(var t=e*this.getLength(),i=this.getCurveLengths(),r=0;r=t){var n=i[r]-t,o=this.curves[r],a=o.getLength(),s=0===a?0:1-n/a;return o.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.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 e=[],t=0,i=0,r=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(e){wa.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;tr;)n-=r;nr.length-2?r.length-1:o+1],l=r[o>r.length-3?r.length-1:o+2];return i.set(ya(a,s.x,c.x,h.x,l.x),ya(a,s.y,c.y,h.y,l.y)),i},Ta.prototype.copy=function(e){wa.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(e){return Ma.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this}});function Ca(e){Ma.call(this),this.type="Path",this.currentPoint=new yt,e&&this.setFromPoints(e)}function Pa(e){Ca.call(this,e),this.type="Shape",this.holes=[]}function Na(){this.type="ShapePath",this.subPaths=[],this.currentPath=null}function Ia(e){this.type="Font",this.data=e}function Oa(e){this.manager=void 0!==e?e:To}Ca.prototype=La,La.constructor=Ca,Pa.prototype=Object.assign(Object.create(La),{constructor:Pa,getPointsHoles:function(e){for(var t=[],i=0,r=this.holes.length;iNumber.EPSILON){if(h<0&&(a=t[o],c=-c,s=t[n],h=-h),e.ys.y)continue;if(e.y===a.y){if(e.x===a.x)return!0}else{var l=h*(e.x-a.x)-c*(e.y-a.y);if(0===l)return!0;if(l<0)continue;r=!r}}else{if(e.y!==a.y)continue;if(s.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=s.x)return!0}}return r}var n=Wn.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return i(o);var a,s,c,h=[];if(1===o.length)return s=o[0],(c=new Pa).curves=s.curves,h.push(c),h;var l=!n(o[0].getPoints());l=e?!l:l;var u,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)d[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],E=0;E0&&(x||(m=d))}v=0;for(var R=f.length;v0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var o=0;o!==n;++o)e[t+o]=e[i+o]},_slerp:function(e,t,i,r){bt.slerpFlat(e,t,e,t,e,i,r)},_lerp:function(e,t,i,r,n){for(var o=1-r,a=0;a!==n;++a){var s=t+a;e[s]=e[s]*o+e[i+a]*r}}}),Object.assign(as.prototype,{getValue:function(e,t){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}),Object.assign(ss,{Composite:as,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new ss.Composite(e,t,i):new ss(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:(Wa=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),Xa=["material","materials","bones"],function(e){var t=Wa.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){var n=i.nodeName.substring(r+1);-1!==Xa.indexOf(n)&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=function(e){for(var i=0;i=t){var l=t++,u=e[l];i[u.uuid]=h,e[h]=u,i[c]=l,e[l]=s;for(var p=0,d=n;p!==d;++p){var f=r[p],m=f[l],g=f[h];f[h]=m,f[l]=g}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,o=n.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a].uuid,h=r[c];if(void 0!==h)if(delete r[c],h0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(a),h[l].accumulate(r,s)}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var i=this._clip.duration,r=this.loop,n=this._loopCount;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=i)t=i;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{var o=2202===r;if(-1===n&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),t>=i||t<0){var a=Math.floor(t/i);t-=i*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(0===s){var c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&n))return this.time=t,i-t}return this.time=t,t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=e?this.zeroSlopeAtStart?2401:nt:2402,r.endingEnd=t?this.zeroSlopeAtEnd?2401:nt:2402)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=t,a[1]=n+e,s[1]=i,this}}),Object.assign(ls.prototype,i.prototype,{_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,o=e._propertyBindings,a=e._interpolants,s=i.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var l=0;l!==n;++l){var u=r[l],p=u.name,d=h[p];if(void 0!==d)o[l]=d;else{if(void 0!==(d=o[l])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=t&&t._propertyBindings[l].binding.parsedPath;++(d=new os(ss.create(i,p,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),o[l]=d}a[l].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(var n=e._propertyBindings,o=0,a=n.length;o!==a;++o){var s=n[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&t.99999?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(Qa.set(e.z,0,-e.x).normalize(),Za=Math.acos(e.y),this.quaternion.setFromAxisAngle(Qa,Za))}),Bs.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},Bs.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},zs.prototype=Object.create(yn.prototype),zs.prototype.constructor=zs;var Gs=new wt,Vs=new ks,Hs=new ks,js=new ks;function Ws(e,t,i,r){wa.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=i||"centripetal",this.tension=r||.5}function Xs(e,t,i,r){wa.call(this),this.type="CubicBezierCurve3",this.v0=e||new wt,this.v1=t||new wt,this.v2=i||new wt,this.v3=r||new wt}function qs(e,t,i){wa.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new wt,this.v1=t||new wt,this.v2=i||new wt}function Ys(e,t){wa.call(this),this.type="LineCurve3",this.v1=e||new wt,this.v2=t||new wt}function Zs(e,t,i,r,n,o){Ea.call(this,e,t,i,i,r,n,o),this.type="ArcCurve"}Ws.prototype=Object.create(wa.prototype),Ws.prototype.constructor=Ws,Ws.prototype.isCatmullRomCurve3=!0,Ws.prototype.getPoint=function(e,t){var i,r,n,o,a=t||new wt,s=this.points,c=s.length,h=(c-(this.closed?0:1))*e,l=Math.floor(h),u=h-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s.length)+1)*s.length:0===u&&l===c-1&&(l=c-2,u=1),this.closed||l>0?i=s[(l-1)%c]:(Gs.subVectors(s[0],s[1]).add(s[0]),i=Gs),r=s[l%c],n=s[(l+1)%c],this.closed||l+2>5&31)/31,r=(w>>10&31)/31):(t=o,i=a,r=s)}for(var _=1;_<=3;_++){var M=v+12*_;f.push(h.getFloat32(M,!0)),f.push(h.getFloat32(M+4,!0)),f.push(h.getFloat32(M+8,!0)),m.push(y,x,b),u&&n.push(t,i,r)}}return d.addAttribute("position",new rc.BufferAttribute(new Float32Array(f),3)),d.addAttribute("normal",new rc.BufferAttribute(new Float32Array(m),3)),u&&(d.addAttribute("color",new rc.BufferAttribute(new Float32Array(n),3)),d.hasColors=!0,d.alpha=c),d}(t):function(e){for(var t,i=new rc.BufferGeometry,r=/facet([\s\S]*?)endfacet/g,n=0,o=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+o+o+o,"g"),s=new RegExp("normal"+o+o+o,"g"),c=[],h=[],l=new rc.Vector3;null!==(t=r.exec(e));){for(var u=0,p=0,d=t[0];null!==(t=s.exec(d));)l.x=parseFloat(t[1]),l.y=parseFloat(t[2]),l.z=parseFloat(t[3]),p++;for(;null!==(t=a.exec(d));)c.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),h.push(l.x,l.y,l.z),u++;1!==p&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+n),3!==u&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+n),n++}return i.addAttribute("position",new rc.Float32BufferAttribute(c,3)),i.addAttribute("normal",new rc.Float32BufferAttribute(h,3)),i}(function(e){if("string"!=typeof e){var t=new Uint8Array(e);if(void 0!==window.TextDecoder)return(new TextDecoder).decode(t);for(var i="",r=0,n=e.byteLength;r0&&t.push(new rc.VectorKeyframeTrack(r+".position",n,o)),a.length>0&&t.push(new rc.QuaternionKeyframeTrack(r+".quaternion",n,a)),s.length>0&&t.push(new rc.VectorKeyframeTrack(r+".scale",n,s)),t}function b(e,t,i){var r,n,o,a=!0;for(n=0,o=e.length;n=0;){var r=e[t];if(null!==r.value[i])return r;t--}return null}function _(e,t,i){for(;t0&&p.addAttribute("position",new rc.Float32BufferAttribute(n.array,n.stride)),o.array.length>0&&p.addAttribute("normal",new rc.Float32BufferAttribute(o.array,o.stride)),s.array.length>0&&p.addAttribute("color",new rc.Float32BufferAttribute(s.array,s.stride)),a.array.length>0&&p.addAttribute("uv",new rc.Float32BufferAttribute(a.array,a.stride)),c.length>0&&p.addAttribute("skinIndex",new rc.Float32BufferAttribute(c,h)),l.length>0&&p.addAttribute("skinWeight",new rc.Float32BufferAttribute(l,u)),r.data=p,r.type=e[0].type,r.materialKeys=d,r}function ie(e,t,i,r){var n=e.p,o=e.stride,a=e.vcount;function s(e){for(var t=n[e+i]*l,o=t+l;t0&&console.log("THREE.ColladaLoader: Geometry has faces with more than 4 vertices.")}else for(p=0,d=n.length;p=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ce(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},i=0;ir.limits.max||t0){var q=this.msgColor,Y=document.createElement("canvas"),Z=Y.getContext("2d");Z.font="normal 100px sans-serif";var Q=Z.measureText(i.text).width;Y.width=Q,Y.height=150,Z.font="normal 100px sans-serif",Z.fillStyle="rgba("+Math.round(255*q.r)+", "+Math.round(255*q.g)+", "+Math.round(255*q.b)+", "+q.a+")",Z.textAlign="left",Z.textBaseline="middle",Z.fillText(i.text,0,Y.height/2);var J=new rc.Texture(Y);J.needsUpdate=!0;var K=new rc.SpriteMaterial({map:J,useScreenCoordinates:!1}),$=new rc.Sprite(K),ee=i.scale.x;$.scale.set(Q/Y.height*ee,ee,1),this.add($)}break;case fc:var te=null;0===i.color.r&&0===i.color.g&&0===i.color.b&&0===i.color.a||(te=r),this.msgMesh=i.mesh_resource.substr(10);var ie=new Oc({path:t,resource:this.msgMesh,material:te});this.add(ie);break;case mc:var re=new Dc({material:r,vertices:i.points,colors:i.colors});re.scale.set(i.scale.x,i.scale.y,i.scale.z),this.add(re);break;default:console.error("Currently unsupported marker type: "+i.type)}}setPose(e){this.position.x=e.position.x,this.position.y=e.position.y,this.position.z=e.position.z,this.quaternion.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w),this.quaternion.normalize(),this.updateMatrixWorld()}update(e){if(this.setPose(e.pose),e.color.r!==this.msgColor.r||e.color.g!==this.msgColor.g||e.color.b!==this.msgColor.b||e.color.a!==this.msgColor.a){var t=Lc(e.color.r,e.color.g,e.color.b,e.color.a);switch(e.type){case cc:case hc:case pc:break;case nc:case oc:case ac:case sc:case mc:case dc:this.traverse(function(e){e instanceof rc.Mesh&&(e.material=t)});break;case fc:var i=null;0===e.color.r&&0===e.color.g&&0===e.color.b&&0===e.color.a||(i=this.colorMaterial),this.traverse(function(e){e instanceof rc.Mesh&&(e.material=i)});break;case lc:case uc:default:return!1}this.msgColor=e.color}var r=Math.abs(this.msgScale[0]-e.scale.x)>1e-6||Math.abs(this.msgScale[1]-e.scale.y)>1e-6||Math.abs(this.msgScale[2]-e.scale.z)>1e-6;switch(this.msgScale=[e.scale.x,e.scale.y,e.scale.z],e.type){case oc:case ac:case sc:if(r)return!1;break;case dc:if(r||this.text!==e.text)return!1;break;case fc:if(e.mesh_resource.substr(10)!==this.msgMesh)return!1;if(r)return!1;break;case nc:case cc:case hc:case lc:case uc:case pc:case mc:return!1}return!0}dispose(){this.children.forEach(function(e){e instanceof Oc?e.children.forEach(function(t){void 0!==t.material&&t.material.dispose(),t.children.forEach(function(e){void 0!==e.geometry&&e.geometry.dispose(),void 0!==e.material&&e.material.dispose(),t.remove(e)}),e.remove(t)}):(void 0!==e.geometry&&e.geometry.dispose(),void 0!==e.material&&e.material.dispose()),e.parent.remove(e)})}}class Fc extends rc.Object3D{constructor(e){super();var i=this;e=e||{},this.parent=e.parent;var r=e.handle,n=e.message;this.message=n,this.name=n.name,this.camera=e.camera,this.path=e.path||"/",this.loader=e.loader,this.dragging=!1,this.startMousePos=new rc.Vector2;var o=new rc.Quaternion(n.orientation.x,n.orientation.y,n.orientation.z,n.orientation.w);o.normalize();var a=new rc.Vector3(1,0,0);switch(a.applyQuaternion(o),this.currentControlOri=new rc.Quaternion,n.interaction_mode){case Mc:this.addEventListener("mousemove",this.parent.moveAxis.bind(this.parent,this,a)),this.addEventListener("touchmove",this.parent.moveAxis.bind(this.parent,this,a));break;case Tc:this.addEventListener("mousemove",this.parent.rotateAxis.bind(this.parent,this,o));break;case Ec:this.addEventListener("mousemove",this.parent.movePlane.bind(this.parent,this,a));break;case _c:this.addEventListener("click",this.parent.buttonClick.bind(this.parent,this))}function s(e){e.stopPropagation()}n.interaction_mode!==wc&&(this.addEventListener("mousedown",this.parent.startDrag.bind(this.parent,this)),this.addEventListener("mouseup",this.parent.stopDrag.bind(this.parent,this)),this.addEventListener("contextmenu",this.parent.showMenu.bind(this.parent,this)),this.addEventListener("mouseup",function(e){0===i.startMousePos.distanceToSquared(e.mousePos)&&(e.type="contextmenu",i.dispatchEvent(e))}),this.addEventListener("mouseover",s),this.addEventListener("mouseout",s),this.addEventListener("click",s),this.addEventListener("mousedown",function(e){i.startMousePos=e.mousePos}),this.addEventListener("touchstart",function(e){1===e.domEvent.touches.length&&(e.type="mousedown",e.domEvent.button=0,i.dispatchEvent(e))}),this.addEventListener("touchmove",function(e){1===e.domEvent.touches.length&&(e.type="mousemove",e.domEvent.button=0,i.dispatchEvent(e))}),this.addEventListener("touchend",function(e){0===e.domEvent.touches.length&&(e.domEvent.button=0,e.type="mouseup",i.dispatchEvent(e),e.type="click",i.dispatchEvent(e))}));var c=new rc.Quaternion,h=this.parent.position.clone().multiplyScalar(-1);switch(n.orientation_mode){case Sc:c=this.parent.quaternion.clone().inverse();break;case Ac:case Rc:break;default:console.error("Unkown orientation mode: "+n.orientation_mode)}var l=new t.TFClient({ros:r.tfClient.ros,fixedFrame:r.message.header.frame_id,serverName:r.tfClient.serverName});n.markers.forEach(function(e){var r=function(r){var n=new Uc({message:e,path:i.path,loader:i.loader});if(null!==r){var o=new t.Pose({position:n.position,orientation:n.quaternion});o.applyTransform(new t.Transform(r));var a=new Uc({message:e,path:i.path,loader:i.loader});a.position.add(h),a.position.applyQuaternion(c),a.quaternion.multiplyQuaternions(c,a.quaternion);var s=new rc.Vector3(a.position.x,a.position.y,a.position.z),u=new t.Transform({translation:s,orientation:a.quaternion});o.applyTransform(u),n.setPose(o),n.updateMatrixWorld(),l.unsubscribe(e.header.frame_id)}i.add(n)};""!==e.header.frame_id?l.subscribe(e.header.frame_id,r):r(null)})}updateMatrixWorld(e){var t=this.message;switch(t.orientation_mode){case Sc:super.updateMatrixWorld(e),this.currentControlOri.copy(this.quaternion),this.currentControlOri.normalize();break;case Ac:this.quaternion.copy(this.parent.quaternion.clone().inverse()),this.updateMatrix(),this.matrixWorldNeedsUpdate=!0,super.updateMatrixWorld(e),this.currentControlOri.copy(this.quaternion);break;case Rc:this.camera.updateMatrixWorld();var i=(new rc.Matrix4).extractRotation(this.camera.matrixWorld),r=new rc.Matrix4,n=.5*Math.PI,o=new rc.Euler(-n,0,n);r.makeRotationFromEuler(o);var a=new rc.Matrix4;a.getInverse(this.parent.matrixWorld),i.multiplyMatrices(i,r),i.multiplyMatrices(a,i),this.currentControlOri.setFromRotationMatrix(i),t.independent_marker_orientation||(this.quaternion.copy(this.currentControlOri),this.updateMatrix(),this.matrixWorldNeedsUpdate=!0),super.updateMatrixWorld(e);break;default:console.error("Unkown orientation mode: "+t.orientation_mode)}}}class Bc extends rc.EventDispatcher{constructor(e){super();var t,i,r,n=this,o=(e=e||{}).menuEntries,a=e.className||"default-interactive-marker-menu",s=(e.entryClassName,e.overlayClassName||"default-interactive-marker-overlay"),c=e.menuFontSize||"0.8em",h=[];if(h[0]={children:[]},null===document.getElementById("default-interactive-marker-menu-css")){var l=document.createElement("style");l.id="default-interactive-marker-menu-css",l.type="text/css",l.innerHTML=".default-interactive-marker-menu {background-color: #444444;border: 1px solid #888888;border: 1px solid #888888;padding: 0px 0px 0px 0px;color: #FFFFFF;font-family: sans-serif;font-size: "+c+";z-index: 1002;}.default-interactive-marker-menu ul {padding: 0px 0px 5px 0px;margin: 0px;list-style-type: none;}.default-interactive-marker-menu ul li div {-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;padding: 3px 10px 3px 10px;}.default-interactive-marker-menu-entry:hover { background-color: #666666; cursor: pointer;}.default-interactive-marker-menu ul ul { font-style: italic; padding-left: 10px;}.default-interactive-marker-overlay { position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index: 1001; -moz-opacity: 0.0; opacity: .0; filter: alpha(opacity = 0);}",document.getElementsByTagName("head")[0].appendChild(l)}for(this.menuDomElem=document.createElement("div"),this.menuDomElem.style.position="absolute",this.menuDomElem.className=a,this.menuDomElem.addEventListener("contextmenu",function(e){e.preventDefault()}),this.overlayDomElem=document.createElement("div"),this.overlayDomElem.className=s,this.hideListener=this.hide.bind(this),this.overlayDomElem.addEventListener("contextmenu",this.hideListener),this.overlayDomElem.addEventListener("click",this.hideListener),this.overlayDomElem.addEventListener("touchstart",this.hideListener),t=0;t0?(e(s,o[a]),c.addEventListener("click",n.hide.bind(n)),c.addEventListener("touchstart",n.hide.bind(n))):(c.addEventListener("click",p.bind(n,o[a])),c.addEventListener("touchstart",p.bind(n,o[a])),c.className="default-interactive-marker-menu-entry")}}(this.menuDomElem,h[0])}show(e,t){t&&t.preventDefault&&t.preventDefault(),this.controlName=e.name,void 0!==t.domEvent.changedTouches?(this.menuDomElem.style.left=t.domEvent.changedTouches[0].pageX+"px",this.menuDomElem.style.top=t.domEvent.changedTouches[0].pageY+"px"):(this.menuDomElem.style.left=t.domEvent.clientX+"px",this.menuDomElem.style.top=t.domEvent.clientY+"px"),document.body.appendChild(this.overlayDomElem),document.body.appendChild(this.menuDomElem)}hide(e){e&&e.preventDefault&&e.preventDefault(),document.body.removeChild(this.overlayDomElem),document.body.removeChild(this.menuDomElem)}}class zc extends rc.Object3D{constructor(e){super();var t=this,i=(e=e||{}).handle;this.name=i.name;var r=e.camera,n=e.path||"/",o=e.loader;this.dragging=!1,this.onServerSetPose({pose:i.pose}),this.dragStart={position:new rc.Vector3,orientation:new rc.Quaternion,positionWorld:new rc.Vector3,orientationWorld:new rc.Quaternion,event3d:{}},i.controls.forEach(function(e){t.add(new Fc({parent:t,handle:i,message:e,camera:r,path:n,loader:o}))}),i.menuEntries.length>0&&(this.menu=new Bc({menuEntries:i.menuEntries,menuFontSize:i.menuFontSize}),this.menu.addEventListener("menu-select",function(e){t.dispatchEvent(e)}))}showMenu(e,t){this.menu&&this.menu.show(e,t)}moveAxis(e,t,i){if(this.dragging){var r=e.currentControlOri,n=t.clone().applyQuaternion(r),o=this.dragStart.event3d.intersection.point,a=n.clone().applyQuaternion(this.dragStart.orientationWorld.clone()),s=new rc.Ray(o,a),c=Nc(s,i.camera,i.mousePos),h=new rc.Vector3;h.addVectors(this.dragStart.position,n.clone().applyQuaternion(this.dragStart.orientation).multiplyScalar(c)),this.setPosition(e,h),i.stopPropagation()}}movePlane(e,t,i){if(this.dragging){var r=e.currentControlOri,n=t.clone().applyQuaternion(r),o=this.dragStart.event3d.intersection.point,a=n.clone().applyQuaternion(this.dragStart.orientationWorld),s=Cc(i.mouseRay,o,a),c=new rc.Vector3;c.subVectors(s,o),c.add(this.dragStart.positionWorld),this.setPosition(e,c),i.stopPropagation()}}rotateAxis(e,t,i){if(this.dragging){e.updateMatrixWorld();var r=e.currentControlOri.clone().multiply(t.clone()),n=new rc.Vector3(1,0,0).applyQuaternion(r),o=this.dragStart.event3d.intersection.point,a=n.applyQuaternion(this.dragStart.orientationWorld),s=Cc(i.mouseRay,o,a),c=new rc.Ray(this.dragStart.positionWorld,a),h=Cc(c,o,a),l=this.dragStart.orientationWorld.clone().multiply(r).clone().inverse();s.sub(h),s.applyQuaternion(l);var u=this.dragStart.event3d.intersection.point.clone();u.sub(h),u.applyQuaternion(l);var p=Math.atan2(s.y,s.z),d=Math.atan2(u.y,u.z)-p,f=new rc.Quaternion;f.setFromAxisAngle(n,d),this.setOrientation(e,f.multiply(this.dragStart.orientationWorld)),i.stopPropagation()}}feedbackEvent(e,t){this.dispatchEvent({type:e,position:this.position.clone(),orientation:this.quaternion.clone(),controlName:t.name})}startDrag(e,t){if(0===t.domEvent.button){t.stopPropagation(),this.dragging=!0,this.updateMatrixWorld(!0);var i=new rc.Vector3;this.matrixWorld.decompose(this.dragStart.positionWorld,this.dragStart.orientationWorld,i),this.dragStart.position=this.position.clone(),this.dragStart.orientation=this.quaternion.clone(),this.dragStart.event3d=t,this.feedbackEvent("user-mousedown",e)}}stopDrag(e,t){0===t.domEvent.button&&(t.stopPropagation(),this.dragging=!1,this.dragStart.event3d={},this.onServerSetPose(this.bufferedPoseEvent),this.bufferedPoseEvent=void 0,this.feedbackEvent("user-mouseup",e))}buttonClick(e,t){t.stopPropagation(),this.feedbackEvent("user-button-click",e)}setPosition(e,t){this.position.copy(t),this.feedbackEvent("user-pose-change",e)}setOrientation(e,t){t.normalize(),this.quaternion.copy(t),this.feedbackEvent("user-pose-change",e)}onServerSetPose(e){if(void 0!==e)if(this.dragging)this.bufferedPoseEvent=e;else{var t=e.pose;this.position.copy(t.position),this.quaternion.copy(t.orientation),this.updateMatrixWorld(!0)}}dispose(){var e=this;this.children.forEach(function(t){t.children.forEach(function(e){e.dispose(),t.remove(e)}),e.remove(t)})}}var kc,Gc=(function(e,t){!function(t){var i=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=10;function n(){this._events={},this._conf&&o.call(this,this._conf)}function o(e){e?(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),this._events.maxListeners=e.maxListeners!==t?e.maxListeners:r,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this.newListener=e.newListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._events.maxListeners=r}function a(e,t){var i="(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.";this.verboseMemoryLeak?(i+=" Event name: %s.",console.error(i,e,t)):console.error(i,e),console.trace&&console.trace()}function s(e){this._events={},this.newListener=!1,this.verboseMemoryLeak=!1,o.call(this,e)}function c(e,t,i,r){if(!i)return[];var n,o,a,s,h,l,u,p=[],d=t.length,f=t[r],m=t[r+1];if(r===d&&i._listeners){if("function"==typeof i._listeners)return e&&e.push(i._listeners),[i];for(n=0,o=i._listeners.length;n3)for(t=new Array(s),o=0;o3)for(t=new Array(s-1),o=1;o3)for(t=new Array(h),o=1;o3)for(t=new Array(h-1),o=1;o0&&o._listeners.length>this._events.maxListeners&&(o._listeners.warned=!0,a.call(this,o._listeners.length,s))):o._listeners=i,!0;s=e.shift()}return!0}.call(this,e,i),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),this._events[e].push(i),!this._events[e].warned&&this._events.maxListeners>0&&this._events[e].length>this._events.maxListeners&&(this._events[e].warned=!0,a.call(this,this._events[e].length,e))):this._events[e]=i,this)},s.prototype.onAny=function(e){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),this._all.push(e),this},s.prototype.addListener=s.prototype.on,s.prototype.off=function(e,r){if("function"!=typeof r)throw new Error("removeListener only takes instances of Function");var n,o=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();o=c.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],o.push({_listeners:n})}for(var s=0;s0&&e(i[o]),0===Object.keys(a).length&&delete i[o])}}}(this.listenerTree),this},s.prototype.offAny=function(e){var t,i=0,r=0;if(e&&this._all&&this._all.length>0){for(i=0,r=(t=this._all).length;i=8&&(a-=8,t[s++]=o>>>a&255,s%i==0&&(n+=Math.ceil((l-a)/6),(a%=8)>0&&(o=qc.e[e.charAt(n)])));return Math.floor(s/i)}qc.S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qc.e={};for(var Yc=0;Yc<64;Yc++)qc.e[qc.S.charAt(Yc)]=Yc;class Zc extends rc.Object3D{constructor(e){var i=(e=e||{}).urdfModel,r=e.path||"/",n=e.tfClient,o=e.tfPrefix||"",a=e.loader;super();var s=i.links;for(var c in s)for(var h=s[c],l=0;l0?(r=f[0].object,d.intersection=this.lastIntersection=f[0]):r=this.fallbackTarget,r!==this.lastTarget&&e.type.match(/mouse/)){var m=this.notify(r,"mouseover",d);0===m?this.notify(this.lastTarget,"mouseout",d):1===m&&(r=this.fallbackTarget)!==this.lastTarget&&(this.notify(r,"mouseover",d),this.notify(this.lastTarget,"mouseout",d))}r!==this.lastTarget&&e.type.match(/touch/)&&(this.notify(r,e.type,d)?(this.notify(this.lastTarget,"touchleave",d),this.notify(this.lastTarget,"touchend",d)):(r=this.fallbackTarget)!==this.lastTarget&&(this.notify(this.lastTarget,"touchmove",d),this.notify(this.lastTarget,"touchend",d)));this.notify(r,e.type,d),"mousedown"!==e.type&&"touchstart"!==e.type&&"touchmove"!==e.type||(this.dragging=!0),this.lastTarget=r}notify(e,t,i){for(i.type=t,i.cancelBubble=!1,i.continueBubble=!1,i.stopPropagation=function(){i.cancelBubble=!0},i.continuePropagation=function(){i.continueBubble=!0},i.currentTarget=e;i.currentTarget;){if(i.currentTarget.dispatchEvent&&i.currentTarget.dispatchEvent instanceof Function){if(i.currentTarget.dispatchEvent(i),i.cancelBubble)return this.dispatchEvent(i),0;if(i.continueBubble)return 2}i.currentTarget=i.currentTarget.parent}return 1}}class Kc extends rc.EventDispatcher{constructor(e){super();var t=this,i=(e=e||{}).scene;this.camera=e.camera,this.center=new rc.Vector3,this.userZoom=!0,this.userZoomSpeed=e.userZoomSpeed||1,this.userRotate=!0,this.userRotateSpeed=e.userRotateSpeed||1,this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed||2,this.camera.up=new rc.Vector3(0,0,1);var r=1800,n=10,o=new rc.Vector2,a=new rc.Vector2,s=new rc.Vector2,c=new rc.Vector2,h=new rc.Vector2,l=new rc.Vector2,u=new rc.Vector3,p=new rc.Vector3,d=new rc.Vector3,f=new rc.Vector3,m=new Array(2),g=new Array(2);this.phiDelta=0,this.thetaDelta=0,this.scale=1,this.lastPosition=new rc.Vector3;var v={NONE:-1,ROTATE:0,ZOOM:1,MOVE:2},y=v.NONE;function x(e,t,i){var r=new rc.Vector3;new rc.Vector3;r.subVectors(t,e.origin);var n=e.direction.dot(i);if(Math.abs(n)0?t.zoomIn():t.zoomOut(),this.showAxes()}}this.axes=new jc({shaftRadius:.025,headRadius:.07,headLength:.2}),i.add(this.axes),this.axes.traverse(function(e){e.visible=!1}),this.addEventListener("mousedown",function(e){var i=e.domEvent;switch(i.preventDefault(),i.button){case 0:y=v.ROTATE,o.set(i.clientX,i.clientY);break;case 1:y=v.MOVE,p=new rc.Vector3(0,0,1);var r=(new rc.Matrix4).extractRotation(this.camera.matrix);p.applyMatrix4(r),u=t.center.clone(),d=t.camera.position.clone(),f=x(e.mouseRay,u,p);break;case 2:y=v.ZOOM,c.set(i.clientX,i.clientY)}this.showAxes()}),this.addEventListener("mouseup",function(e){t.userRotate&&(y=v.NONE)}),this.addEventListener("mousemove",function(e){var i=e.domEvent;if(y===v.ROTATE)a.set(i.clientX,i.clientY),s.subVectors(a,o),t.rotateLeft(2*Math.PI*s.x/r*t.userRotateSpeed),t.rotateUp(2*Math.PI*s.y/r*t.userRotateSpeed),o.copy(a),this.showAxes();else if(y===v.ZOOM)h.set(i.clientX,i.clientY),l.subVectors(h,c),l.y>0?t.zoomIn():t.zoomOut(),c.copy(h),this.showAxes();else if(y===v.MOVE){var n=x(e.mouseRay,t.center,p);if(!n)return;var m=(new rc.Vector3).subVectors(f.clone(),n.clone());t.center.addVectors(u.clone(),m.clone()),t.camera.position.addVectors(d.clone(),m.clone()),t.update(),t.camera.updateMatrixWorld(),this.showAxes()}}),this.addEventListener("touchstart",function(e){var i=e.domEvent;switch(i.touches.length){case 1:y=v.ROTATE,o.set(i.touches[0].pageX-window.scrollX,i.touches[0].pageY-window.scrollY);break;case 2:y=v.NONE,p=new rc.Vector3(0,0,1);var r=(new rc.Matrix4).extractRotation(this.camera.matrix);p.applyMatrix4(r),u=t.center.clone(),d=t.camera.position.clone(),f=x(e.mouseRay,u,p),m[0]=new rc.Vector2(i.touches[0].pageX,i.touches[0].pageY),m[1]=new rc.Vector2(i.touches[1].pageX,i.touches[1].pageY),g[0]=new rc.Vector2(0,0),g[1]=new rc.Vector2(0,0)}this.showAxes(),i.preventDefault()}),this.addEventListener("touchmove",function(e){var i=e.domEvent;if(y===v.ROTATE)a.set(i.touches[0].pageX-window.scrollX,i.touches[0].pageY-window.scrollY),s.subVectors(a,o),t.rotateLeft(2*Math.PI*s.x/r*t.userRotateSpeed),t.rotateUp(2*Math.PI*s.y/r*t.userRotateSpeed),o.copy(a),this.showAxes();else{if(g[0].set(m[0].x-i.touches[0].pageX,m[0].y-i.touches[0].pageY),g[1].set(m[1].x-i.touches[1].pageX,m[1].y-i.touches[1].pageY),g[0].lengthSq()>n&&g[1].lengthSq()>n&&(m[0].set(i.touches[0].pageX,i.touches[0].pageY),m[1].set(i.touches[1].pageX,i.touches[1].pageY),g[0].dot(g[1])>0&&y!==v.ZOOM?y=v.MOVE:g[0].dot(g[1])<0&&y!==v.MOVE&&(y=v.ZOOM),y===v.ZOOM)){var c=new rc.Vector2;c.subVectors(m[0],m[1]),g[0].dot(c)<0&&g[1].dot(c)>0?t.zoomOut():g[0].dot(c)>0&&g[1].dot(c)<0&&t.zoomIn()}if(y===v.MOVE){var h=x(e.mouseRay,t.center,p);if(!h)return;var l=(new rc.Vector3).subVectors(f.clone(),h.clone());t.center.addVectors(u.clone(),l.clone()),t.camera.position.addVectors(d.clone(),l.clone()),t.update(),t.camera.updateMatrixWorld()}this.showAxes(),i.preventDefault()}}),this.addEventListener("touchend",function(e){var t=e.domEvent;1===t.touches.length&&y!==v.ROTATE?(y=v.ROTATE,o.set(t.touches[0].pageX-window.scrollX,t.touches[0].pageY-window.scrollY)):y=v.NONE}),this.addEventListener("mousewheel",b),this.addEventListener("DOMMouseScroll",b)}showAxes(){var e=this;this.axes.traverse(function(e){e.visible=!0}),this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(function(){e.axes.traverse(function(e){e.visible=!1}),e.hideTimeout=!1},1e3)}rotateLeft(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.thetaDelta-=e}rotateRight(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.thetaDelta+=e}rotateUp(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.phiDelta-=e}rotateDown(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.phiDelta+=e}zoomIn(e){void 0===e&&(e=Math.pow(.95,this.userZoomSpeed)),this.scale/=e}zoomOut(e){void 0===e&&(e=Math.pow(.95,this.userZoomSpeed)),this.scale*=e}update(){var e=this.camera.position,t=e.clone().sub(this.center),i=Math.atan2(t.y,t.x),r=Math.atan2(Math.sqrt(t.y*t.y+t.x*t.x),t.z);this.autoRotate&&this.rotateLeft(2*Math.PI/60/60*this.autoRotateSpeed),i+=this.thetaDelta,r+=this.phiDelta;r=Math.max(1e-6,Math.min(Math.PI-1e-6,r));var n=t.length();t.set(n*Math.sin(r)*Math.cos(i),n*Math.sin(r)*Math.sin(i),n*Math.cos(r)),t.multiplyScalar(this.scale),e.copy(this.center).add(t),this.camera.lookAt(this.center),n=t.length(),this.axes.position.copy(this.center),this.axes.scale.set(.05*n,.05*n,.05*n),this.axes.updateMatrixWorld(!0),this.thetaDelta=0,this.phiDelta=0,this.scale=1,this.lastPosition.distanceTo(this.camera.position)>0&&(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.camera.position))}}return e.REVISION="0.18.0",e.MARKER_ARROW=nc,e.MARKER_CUBE=oc,e.MARKER_SPHERE=ac,e.MARKER_CYLINDER=sc,e.MARKER_LINE_STRIP=cc,e.MARKER_LINE_LIST=hc,e.MARKER_CUBE_LIST=lc,e.MARKER_SPHERE_LIST=uc,e.MARKER_POINTS=pc,e.MARKER_TEXT_VIEW_FACING=dc,e.MARKER_MESH_RESOURCE=fc,e.MARKER_TRIANGLE_LIST=mc,e.INTERACTIVE_MARKER_KEEP_ALIVE=0,e.INTERACTIVE_MARKER_POSE_UPDATE=gc,e.INTERACTIVE_MARKER_MENU_SELECT=vc,e.INTERACTIVE_MARKER_BUTTON_CLICK=yc,e.INTERACTIVE_MARKER_MOUSE_DOWN=xc,e.INTERACTIVE_MARKER_MOUSE_UP=bc,e.INTERACTIVE_MARKER_NONE=wc,e.INTERACTIVE_MARKER_MENU=1,e.INTERACTIVE_MARKER_BUTTON=_c,e.INTERACTIVE_MARKER_MOVE_AXIS=Mc,e.INTERACTIVE_MARKER_MOVE_PLANE=Ec,e.INTERACTIVE_MARKER_ROTATE_AXIS=Tc,e.INTERACTIVE_MARKER_MOVE_ROTATE=6,e.INTERACTIVE_MARKER_INHERIT=Sc,e.INTERACTIVE_MARKER_FIXED=Ac,e.INTERACTIVE_MARKER_VIEW_FACING=Rc,e.makeColorMaterial=Lc,e.intersectPlane=Cc,e.findClosestPoint=Pc,e.closestAxisPoint=Nc,e.DepthCloud=class extends rc.Object3D{constructor(e){super(),e=e||{},this.url=e.url,this.streamType=e.streamType||"vp8",this.f=e.f||526,this.maxDepthPerTile=e.maxDepthPerTile||1,this.pointSize=e.pointSize||3,this.width=e.width||1024,this.height=e.height||1024,this.whiteness=e.whiteness||0,this.varianceThreshold=e.varianceThreshold||16667e-9,this.isMjpeg="mjpeg"===this.streamType.toLowerCase(),this.video=document.createElement(this.isMjpeg?"img":"video"),this.video.addEventListener(this.isMjpeg?"load":"loadedmetadata",this.metaLoaded.bind(this),!1),this.isMjpeg||(this.video.loop=!0),this.video.src=this.url,this.video.crossOrigin="Anonymous",this.video.setAttribute("crossorigin","Anonymous"),this.vertex_shader=["uniform sampler2D map;","","uniform float width;","uniform float height;","uniform float nearClipping, farClipping;","","uniform float pointSize;","uniform float zOffset;","","uniform float focallength;","uniform float maxDepthPerTile;","","varying vec2 vUvP;","varying vec2 colorP;","","varying float depthVariance;","varying float maskVal;","","float sampleDepth(vec2 pos)"," {"," float depth;"," "," vec2 vUv = vec2( pos.x / (width*2.0), pos.y / (height*2.0)+0.5 );"," vec2 vUv2 = vec2( pos.x / (width*2.0)+0.5, pos.y / (height*2.0)+0.5 );"," "," vec4 depthColor = texture2D( map, vUv );"," "," depth = ( depthColor.r + depthColor.g + depthColor.b ) / 3.0 ;"," "," if (depth>0.99)"," {"," vec4 depthColor2 = texture2D( map, vUv2 );"," float depth2 = ( depthColor2.r + depthColor2.g + depthColor2.b ) / 3.0 ;"," depth = 0.99+depth2;"," }"," "," return depth;"," }","","float median(float a, float b, float c)"," {"," float r=a;"," "," if ( (a0.5) || (vUvP.y<0.5) || (vUvP.y>0.0))"," {"," vec2 smp = decodeDepth(vec2(position.x, position.y));"," float depth = smp.x;"," depthVariance = smp.y;"," "," float z = -depth;"," "," pos = vec4("," ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength) * -1.0,"," ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength),"," (- z + zOffset / 1000.0) * maxDepthPerTile,"," 1.0);"," "," vec2 maskP = vec2( position.x / (width*2.0), position.y / (height*2.0) );"," vec4 maskColor = texture2D( map, maskP );"," maskVal = ( maskColor.r + maskColor.g + maskColor.b ) / 3.0 ;"," }"," "," gl_PointSize = pointSize;"," gl_Position = projectionMatrix * modelViewMatrix * pos;"," ","}"].join("\n"),this.fragment_shader=["uniform sampler2D map;","uniform float varianceThreshold;","uniform float whiteness;","","varying vec2 vUvP;","varying vec2 colorP;","","varying float depthVariance;","varying float maskVal;","","","void main() {"," "," vec4 color;"," "," if ( (depthVariance>varianceThreshold) || (maskVal>0.5) ||(vUvP.x<0.0)|| (vUvP.x>0.5) || (vUvP.y<0.5) || (vUvP.y>1.0))"," { "," discard;"," }"," else "," {"," color = texture2D( map, colorP );"," "," float fader = whiteness /100.0;"," "," color.r = color.r * (1.0-fader)+ fader;"," "," color.g = color.g * (1.0-fader)+ fader;"," "," color.b = color.b * (1.0-fader)+ fader;"," "," color.a = 1.0;//smoothstep( 20000.0, -20000.0, gl_FragCoord.z / gl_FragCoord.w );"," }"," "," gl_FragColor = vec4( color.r, color.g, color.b, color.a );"," ","}"].join("\n")}metaLoaded(){this.metaLoaded=!0,this.initStreamer()}initStreamer(){if(this.metaLoaded){this.texture=new rc.Texture(this.video),this.geometry=new rc.Geometry;for(var e=0,t=this.width*this.height;e=this.keep&&(this.sns[0].unsubscribeTf(),this.rootObject.remove(this.sns[0]),this.sns.shift()),this.options.origin=new rc.Vector3(e.pose.pose.position.x,e.pose.pose.position.y,e.pose.pose.position.z);var t=new rc.Quaternion(e.pose.pose.orientation.x,e.pose.pose.orientation.y,e.pose.pose.orientation.z,e.pose.pose.orientation.w);this.options.direction=new rc.Vector3(1,0,0),this.options.direction.applyQuaternion(t),this.options.material=new rc.MeshBasicMaterial({color:this.color});var i=new Ic(this.options);this.sns.push(new Hc({frameID:e.header.frame_id,tfClient:this.tfClient,object:i})),this.rootObject.add(this.sns[this.sns.length-1])}},e.Path=class extends rc.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/path",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new rc.Object3D,this.sn=null,this.line=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new t.Topic({ros:this.ros,name:this.topicName,messageType:"nav_msgs/Path"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn));for(var t=new rc.Geometry,i=0;i=e.range_min&&n<=e.range_max){var o=e.angle_min+r*e.angle_increment;this.points.positions.array[i++]=n*Math.cos(o),this.points.positions.array[i++]=n*Math.sin(o),this.points.positions.array[i++]=0}}this.points.update(i/3)}}},e.Points=Xc,e.PointCloud2=class extends rc.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/points",this.points=new Xc(e),this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new t.Topic({ros:this.ros,name:this.topicName,messageType:"sensor_msgs/PointCloud2"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){if(this.points.setup(e.header.frame_id,e.point_step,e.fields)){var t,i=this.points.pointRatio;e.data.buffer?(this.points.buffer=e.data.buffer,t=e.height*e.width/i):(t=qc(e.data,this.points.buffer,e.point_step,i),i=1);for(var r,n,o=new DataView(this.points.buffer.buffer),a=!e.is_bigendian,s=this.points.fields.x.offset,c=this.points.fields.y.offset,h=this.points.fields.z.offset,l=0;l0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i>=4,e+=n[19===t?3&r|8:r]);return e}),clamp:function(e,t,i){return Math.max(t,Math.min(i,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},lerp:function(e,t,i){return(1-i)*e+i*t},smoothstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*vt.DEG2RAD},radToDeg:function(e){return e*vt.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};function yt(e,t){this.x=e||0,this.y=t||0}function xt(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function bt(e,t,i,r){this._x=e||0,this._y=t||0,this._z=i||0,this._w=void 0!==r?r:1}function wt(e,t,i){this.x=e||0,this.y=t||0,this.z=i||0}function _t(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(yt.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(yt.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:(a=new yt,s=new yt,function(e,t){return a.set(e,e),s.set(t,t),this.clamp(a,s)}),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},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 e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var i=Math.cos(t),r=Math.sin(t),n=this.x-e.x,o=this.y-e.y;return this.x=n*i-o*r+e.x,this.y=n*r+o*i+e.y,this}}),Object.assign(xt.prototype,{isMatrix4:!0,set:function(e,t,i,r,n,o,a,s,c,h,l,u,p,d,f,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=h,g[10]=l,g[14]=u,g[3]=p,g[7]=d,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new xt).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this},copyPosition:function(e){var t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this},extractBasis:function(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this},extractRotation:(d=new wt,function(e){var t=this.elements,i=e.elements,r=1/d.setFromMatrixColumn(e,0).length(),n=1/d.setFromMatrixColumn(e,1).length(),o=1/d.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,this}),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,i=e.x,r=e.y,n=e.z,o=Math.cos(i),a=Math.sin(i),s=Math.cos(r),c=Math.sin(r),h=Math.cos(n),l=Math.sin(n);if("XYZ"===e.order){var u=o*h,p=o*l,d=a*h,f=a*l;t[0]=s*h,t[4]=-s*l,t[8]=c,t[1]=p+d*c,t[5]=u-f*c,t[9]=-a*s,t[2]=f-u*c,t[6]=d+p*c,t[10]=o*s}else if("YXZ"===e.order){var m=s*h,g=s*l,v=c*h,y=c*l;t[0]=m+y*a,t[4]=v*a-g,t[8]=o*c,t[1]=o*l,t[5]=o*h,t[9]=-a,t[2]=g*a-v,t[6]=y+m*a,t[10]=o*s}else if("ZXY"===e.order){m=s*h,g=s*l,v=c*h,y=c*l;t[0]=m-y*a,t[4]=-o*l,t[8]=v+g*a,t[1]=g+v*a,t[5]=o*h,t[9]=y-m*a,t[2]=-o*c,t[6]=a,t[10]=o*s}else if("ZYX"===e.order){u=o*h,p=o*l,d=a*h,f=a*l;t[0]=s*h,t[4]=d*c-p,t[8]=u*c+f,t[1]=s*l,t[5]=f*c+u,t[9]=p*c-d,t[2]=-c,t[6]=a*s,t[10]=o*s}else if("YZX"===e.order){var x=o*s,b=o*c,w=a*s,_=a*c;t[0]=s*h,t[4]=_-x*l,t[8]=w*l+b,t[1]=l,t[5]=o*h,t[9]=-a*h,t[2]=-c*h,t[6]=b*l+w,t[10]=x-_*l}else if("XZY"===e.order){x=o*s,b=o*c,w=a*s,_=a*c;t[0]=s*h,t[4]=-l,t[8]=c*h,t[1]=x*l+_,t[5]=o*h,t[9]=b*l-w,t[2]=w*l-b,t[6]=a*h,t[10]=_*l+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,i=e._x,r=e._y,n=e._z,o=e._w,a=i+i,s=r+r,c=n+n,h=i*a,l=i*s,u=i*c,p=r*s,d=r*c,f=n*c,m=o*a,g=o*s,v=o*c;return t[0]=1-(p+f),t[4]=l-v,t[8]=u+g,t[1]=l+v,t[5]=1-(h+f),t[9]=d-m,t[2]=u-g,t[6]=d+m,t[10]=1-(h+p),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:(l=new wt,u=new wt,p=new wt,function(e,t,i){var r=this.elements;return p.subVectors(e,t),0===p.lengthSq()&&(p.z=1),p.normalize(),l.crossVectors(i,p),0===l.lengthSq()&&(1===Math.abs(i.z)?p.x+=1e-4:p.z+=1e-4,p.normalize(),l.crossVectors(i,p)),l.normalize(),u.crossVectors(p,l),r[0]=l.x,r[4]=u.x,r[8]=p.x,r[1]=l.y,r[5]=u.y,r[9]=p.y,r[2]=l.z,r[6]=u.z,r[10]=p.z,this}),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var i=e.elements,r=t.elements,n=this.elements,o=i[0],a=i[4],s=i[8],c=i[12],h=i[1],l=i[5],u=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],x=i[11],b=i[15],w=r[0],_=r[4],M=r[8],E=r[12],T=r[1],S=r[5],A=r[9],R=r[13],L=r[2],C=r[6],P=r[10],N=r[14],I=r[3],O=r[7],D=r[11],U=r[15];return n[0]=o*w+a*T+s*L+c*I,n[4]=o*_+a*S+s*C+c*O,n[8]=o*M+a*A+s*P+c*D,n[12]=o*E+a*R+s*N+c*U,n[1]=h*w+l*T+u*L+p*I,n[5]=h*_+l*S+u*C+p*O,n[9]=h*M+l*A+u*P+p*D,n[13]=h*E+l*R+u*N+p*U,n[2]=d*w+f*T+m*L+g*I,n[6]=d*_+f*S+m*C+g*O,n[10]=d*M+f*A+m*P+g*D,n[14]=d*E+f*R+m*N+g*U,n[3]=v*w+y*T+x*L+b*I,n[7]=v*_+y*S+x*C+b*O,n[11]=v*M+y*A+x*P+b*D,n[15]=v*E+y*R+x*N+b*U,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new wt;return function(t){for(var i=0,r=t.count;i=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,g*v);m=Math.sin(m*b)/x,a=Math.sin(a*b)/x}var w=a*v;if(s=s*m+u*w,c=c*m+p*w,h=h*m+d*w,l=l*m+f*w,m===1-a){var _=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=_,c*=_,h*=_,l*=_}}e[t]=s,e[t+1]=c,e[t+2]=h,e[t+3]=l}}),Object.defineProperties(bt.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(bt.prototype,{set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var i=e._x,r=e._y,n=e._z,o=e.order,a=Math.cos,s=Math.sin,c=a(i/2),h=a(r/2),l=a(n/2),u=s(i/2),p=s(r/2),d=s(n/2);return"XYZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"YXZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"ZXY"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"ZYX"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"YZX"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l-u*p*d):"XZY"===o&&(this._x=u*h*l-c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l+u*p*d),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,i=e.elements,r=i[0],n=i[4],o=i[8],a=i[1],s=i[5],c=i[9],h=i[2],l=i[6],u=i[10],p=r+s+u;return p>0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(l-c)*t,this._y=(o-h)*t,this._z=(a-n)*t):r>s&&r>u?(t=2*Math.sqrt(1+r-s-u),this._w=(l-c)/t,this._x=.25*t,this._y=(n+a)/t,this._z=(o+h)/t):s>u?(t=2*Math.sqrt(1+s-r-u),this._w=(o-h)/t,this._x=(n+a)/t,this._y=.25*t,this._z=(c+l)/t):(t=2*Math.sqrt(1+u-r-s),this._w=(a-n)/t,this._x=(o+h)/t,this._y=(c+l)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new wt;return function(i,r){return void 0===t&&(t=new wt),(e=i.dot(r)+1)<1e-6?(e=0,Math.abs(i.x)>Math.abs(i.z)?t.set(-i.y,i.x,0):t.set(0,-i.z,i.y)):t.crossVectors(i,r),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var i=e._x,r=e._y,n=e._z,o=e._w,a=t._x,s=t._y,c=t._z,h=t._w;return this._x=i*h+o*a+r*c-n*s,this._y=r*h+o*s+n*a-i*c,this._z=n*h+o*c+i*s-r*a,this._w=o*h-i*a-r*s-n*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var i=this._x,r=this._y,n=this._z,o=this._w,a=o*e._w+i*e._x+r*e._y+n*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=i,this._y=r,this._z=n,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(i+this._x),this._y=.5*(r+this._y),this._z=.5*(n+this._z),this;var c=Math.atan2(s,a),h=Math.sin((1-t)*c)/s,l=Math.sin(t*c)/s;return this._w=o*h+this._w*l,this._x=i*h+this._x*l,this._y=r*h+this._y*l,this._z=n*h+this._z*l,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(wt.prototype,{isVector3:!0,set:function(e,t,i){return this.x=e,this.y=t,this.z=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:(f=new bt,function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(f.setFromEuler(e))}),applyAxisAngle:function(){var e=new bt;return function(t,i){return this.applyQuaternion(e.setFromAxisAngle(t,i))}}(),applyMatrix3:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6]*r,this.y=n[1]*t+n[4]*i+n[7]*r,this.z=n[2]*t+n[5]*i+n[8]*r,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements,o=1/(n[3]*t+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*t+n[4]*i+n[8]*r+n[12])*o,this.y=(n[1]*t+n[5]*i+n[9]*r+n[13])*o,this.z=(n[2]*t+n[6]*i+n[10]*r+n[14])*o,this},applyQuaternion:function(e){var t=this.x,i=this.y,r=this.z,n=e.x,o=e.y,a=e.z,s=e.w,c=s*t+o*r-a*i,h=s*i+a*t-n*r,l=s*r+n*i-o*t,u=-n*t-o*i-a*r;return this.x=c*s+u*-n+h*-a-l*-o,this.y=h*s+u*-o+l*-n-c*-a,this.z=l*s+u*-a+c*-o-h*-n,this},project:function(){var e=new xt;return function(t){return e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e=new xt;return function(t){return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,i=this.y,r=this.z,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r,this.y=n[1]*t+n[5]*i+n[9]*r,this.z=n[2]*t+n[6]*i+n[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new wt,t=new wt;return function(i,r){return e.set(i,i,i),t.set(r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var i=e.x,r=e.y,n=e.z,o=t.x,a=t.y,s=t.z;return this.x=r*s-n*a,this.y=n*o-i*s,this.z=i*a-r*o,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new wt;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new wt;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(vt.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(_t.prototype,{isMatrix3:!0,set:function(e,t,i,r,n,o,a,s,c){var h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=n,h[5]=s,h[6]=i,h[7]=o,h[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new wt;return function(t){for(var i=0,r=t.count;i2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}(r)}),i.image=r.uuid}return t||(e.textures[this.uuid]=i),i},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(e){if(300===this.mapping){if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xe:e.x=e.x-Math.floor(e.x);break;case be:e.x=e.x<0?0:1;break;case we:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case xe:e.y=e.y-Math.floor(e.y);break;case be:e.y=e.y<0?0:1;break;case we:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}}),Object.assign(Tt.prototype,{isVector4:!0,set:function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,i=this.y,r=this.z,n=this.w,o=e.elements;return this.x=o[0]*t+o[4]*i+o[8]*r+o[12]*n,this.y=o[1]*t+o[5]*i+o[9]*r+o[13]*n,this.z=o[2]*t+o[6]*i+o[10]*r+o[14]*n,this.w=o[3]*t+o[7]*i+o[11]*r+o[15]*n,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,i,r,n,o=e.elements,a=o[0],s=o[4],c=o[8],h=o[1],l=o[5],u=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-h)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+h)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(a+l+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(a+1)/2,g=(l+1)/2,v=(f+1)/2,y=(s+h)/4,x=(c+p)/4,b=(u+d)/4;return m>g&&m>v?m<.01?(i=0,r=.707106781,n=.707106781):(r=y/(i=Math.sqrt(m)),n=x/i):g>v?g<.01?(i=.707106781,r=0,n=.707106781):(i=y/(r=Math.sqrt(g)),n=b/r):v<.01?(i=.707106781,r=.707106781,n=0):(i=x/(n=Math.sqrt(v)),r=b/n),this.set(i,r,n,t),this}var w=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(h-s)*(h-s));return Math.abs(w)<.001&&(w=1),this.x=(d-u)/w,this.y=(c-p)/w,this.z=(h-s)/w,this.w=Math.acos((a+l+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(i,r){return void 0===e&&(e=new Tt,t=new Tt),e.set(i,i,i,i),t.set(r,r,r,r),this.clamp(e,t)}}(),clampLength:function(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,i){return this.subVectors(t,e).multiplyScalar(i).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,i){return void 0!==i&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),Object.assign(St.prototype,i.prototype,{isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),At.prototype=Object.create(St.prototype),At.prototype.constructor=At,At.prototype.isWebGLRenderTargetCube=!0,Rt.prototype=Object.create(Et.prototype),Rt.prototype.constructor=Rt,Rt.prototype.isDataTexture=!0,Lt.prototype=Object.create(Et.prototype),Lt.prototype.constructor=Lt,Lt.prototype.isCubeTexture=!0,Object.defineProperty(Lt.prototype,"images",{get:function(){return this.image},set:function(e){this.image=e}});var Ct=new Et,Pt=new Lt;function Nt(){this.seq=[],this.map={}}var It=[],Ot=[],Dt=new Float32Array(16),Ut=new Float32Array(9);function Ft(e,t,i){var r=e[0];if(r<=0||r>0)return e;var n=t*i,o=It[n];if(void 0===o&&(o=new Float32Array(n),It[n]=o),0!==t){r.toArray(o,0);for(var a=1,s=0;a!==t;++a)s+=i,e[a].toArray(o,s)}return o}function Bt(e,t){var i=Ot[t];void 0===i&&(i=new Int32Array(t),Ot[t]=i);for(var r=0;r!==t;++r)i[r]=e.allocTextureUnit();return i}function zt(e,t){e.uniform1f(this.addr,t)}function kt(e,t){e.uniform1i(this.addr,t)}function Gt(e,t){void 0===t.x?e.uniform2fv(this.addr,t):e.uniform2f(this.addr,t.x,t.y)}function Vt(e,t){void 0!==t.x?e.uniform3f(this.addr,t.x,t.y,t.z):void 0!==t.r?e.uniform3f(this.addr,t.r,t.g,t.b):e.uniform3fv(this.addr,t)}function Ht(e,t){void 0===t.x?e.uniform4fv(this.addr,t):e.uniform4f(this.addr,t.x,t.y,t.z,t.w)}function jt(e,t){e.uniformMatrix2fv(this.addr,!1,t.elements||t)}function Wt(e,t){void 0===t.elements?e.uniformMatrix3fv(this.addr,!1,t):(Ut.set(t.elements),e.uniformMatrix3fv(this.addr,!1,Ut))}function Xt(e,t){void 0===t.elements?e.uniformMatrix4fv(this.addr,!1,t):(Dt.set(t.elements),e.uniformMatrix4fv(this.addr,!1,Dt))}function qt(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),i.setTexture2D(t||Ct,r)}function Yt(e,t,i){var r=i.allocTextureUnit();e.uniform1i(this.addr,r),i.setTextureCube(t||Pt,r)}function Zt(e,t){e.uniform2iv(this.addr,t)}function Qt(e,t){e.uniform3iv(this.addr,t)}function Jt(e,t){e.uniform4iv(this.addr,t)}function Kt(e,t){e.uniform1fv(this.addr,t)}function $t(e,t){e.uniform1iv(this.addr,t)}function ei(e,t){e.uniform2fv(this.addr,Ft(t,this.size,2))}function ti(e,t){e.uniform3fv(this.addr,Ft(t,this.size,3))}function ii(e,t){e.uniform4fv(this.addr,Ft(t,this.size,4))}function ri(e,t){e.uniformMatrix2fv(this.addr,!1,Ft(t,this.size,4))}function ni(e,t){e.uniformMatrix3fv(this.addr,!1,Ft(t,this.size,9))}function oi(e,t){e.uniformMatrix4fv(this.addr,!1,Ft(t,this.size,16))}function ai(e,t,i){var r=t.length,n=Bt(i,r);e.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTexture2D(t[o]||Ct,n[o])}function si(e,t,i){var r=t.length,n=Bt(i,r);e.uniform1iv(this.addr,n);for(var o=0;o!==r;++o)i.setTextureCube(t[o]||Pt,n[o])}function ci(e,t,i){this.id=e,this.addr=i,this.setValue=function(e){switch(e){case 5126:return zt;case 35664:return Gt;case 35665:return Vt;case 35666:return Ht;case 35674:return jt;case 35675:return Wt;case 35676:return Xt;case 35678:case 36198:return qt;case 35680:return Yt;case 5124:case 35670:return kt;case 35667:case 35671:return Zt;case 35668:case 35672:return Qt;case 35669:case 35673:return Jt}}(t.type)}function hi(e,t,i){this.id=e,this.addr=i,this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Kt;case 35664:return ei;case 35665:return ti;case 35666:return ii;case 35674:return ri;case 35675:return ni;case 35676:return oi;case 35678:return ai;case 35680:return si;case 5124:case 35670:return $t;case 35667:case 35671:return Zt;case 35668:case 35672:return Qt;case 35669:case 35673:return Jt}}(t.type)}function li(e){this.id=e,Nt.call(this)}li.prototype.setValue=function(e,t){for(var i=this.seq,r=0,n=i.length;r!==n;++r){var o=i[r];o.setValue(e,t[o.id])}};var ui=/([\w\d_]+)(\])?(\[|\.)?/g;function pi(e,t){e.seq.push(t),e.map[t.id]=t}function di(e,t,i){var r=e.name,n=r.length;for(ui.lastIndex=0;;){var o=ui.exec(r),a=ui.lastIndex,s=o[1],c="]"===o[2],h=o[3];if(c&&(s|=0),void 0===h||"["===h&&a+2===n){pi(i,void 0===h?new ci(s,e,t):new hi(s,e,t));break}var l=i.map[s];void 0===l&&pi(i,l=new li(s)),i=l}}function fi(e,t,i){Nt.call(this),this.renderer=i;for(var r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=0;n>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,i){return this.r=e,this.g=t,this.b=i,this},setHSL:function(){function e(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}return function(t,i,r){if(t=vt.euclideanModulo(t,1),i=vt.clamp(i,0,1),r=vt.clamp(r,0,1),0===i)this.r=this.g=this.b=r;else{var n=r<=.5?r*(1+i):r+i-r*i,o=2*r-n;this.r=e(o,n,t+1/3),this.g=e(o,n,t),this.b=e(o,n,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var i;if(i=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(a,s,c)}}}else if(i=/^\#([A-Fa-f0-9]+)$/.exec(e)){var h,l=(h=i[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}e&&e.length>0&&(void 0!==(h=mi[e])?this.setHex(h):console.warn("THREE.Color: Unknown color "+e));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var i=t>0?1/t:1;return this.r=Math.pow(e.r,i),this.g=Math.pow(e.g,i),this.b=Math.pow(e.b,i),this},convertGammaToLinear:function(){var e=this.r,t=this.g,i=this.b;return this.r=e*e,this.g=t*t,this.b=i*i,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){var t,i,r=e||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),c=Math.min(n,o,a),h=(c+s)/2;if(c===s)t=0,i=0;else{var l=s-c;switch(i=h<=.5?l/(s+c):l/(2-s-c),s){case n:t=(o-a)/l+(o 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\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.86267 + (0.49788 + 0.01436 * y ) * y;\n\tfloat b = 3.45068 + (4.18814 + y) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = (x > 0.0) ? v : 0.5 * inversesqrt( 1.0 - x * x ) - 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\tvec3 result = vec3( LTC_ClippedSphereFormFactor( vectorFormFactor ) );\n\treturn result;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\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\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\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}\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\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",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};\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}\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(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\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",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.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\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.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, 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.x, 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 = value.rgb * cLogLuvM;\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 = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",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( 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\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_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\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_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\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",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\n",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\n",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\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",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 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\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\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\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\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars:"uniform vec3 ambientLightColor;\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 ltcMat;\tuniform sampler2D ltcMag;\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\n#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( 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 GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.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(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\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",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)\n",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\n",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\tfloat norm = texture2D( ltcMag, uv ).a;\n\t\tvec4 t = texture2D( ltcMat, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( 1, 0, t.y ),\n\t\t\tvec3( 0, t.z, 0 ),\n\t\t\tvec3( t.w, 0, t.x )\n\t\t);\n\t\treflectedLight.directSpecular += lightColor * material.specularColor * norm * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1 ), 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 clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\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}\n",lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\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\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\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\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\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\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\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 ( NUM_HEMI_LIGHTS > 0 )\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\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\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\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",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\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment:"#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#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\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\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",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}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",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\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\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\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( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, 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( 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 / 9.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\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; 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_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; 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_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; 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}\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 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\n",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\n",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#endif\n",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 gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",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}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_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_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_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\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\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( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\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}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\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#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\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\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\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}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\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 \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#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#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\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\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\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 \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\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + 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}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\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 \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\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}\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\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}\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}\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#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 \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\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}\n",meshphysical_vert:"#define PHYSICAL\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 \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}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\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#endif\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 )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \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\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\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#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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}\n",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},bi={basic:{uniforms:yi.merge([vi.common,vi.specularmap,vi.envmap,vi.aomap,vi.lightmap,vi.fog]),vertexShader:xi.meshbasic_vert,fragmentShader:xi.meshbasic_frag},lambert:{uniforms:yi.merge([vi.common,vi.specularmap,vi.envmap,vi.aomap,vi.lightmap,vi.emissivemap,vi.fog,vi.lights,{emissive:{value:new gi(0)}}]),vertexShader:xi.meshlambert_vert,fragmentShader:xi.meshlambert_frag},phong:{uniforms:yi.merge([vi.common,vi.specularmap,vi.envmap,vi.aomap,vi.lightmap,vi.emissivemap,vi.bumpmap,vi.normalmap,vi.displacementmap,vi.gradientmap,vi.fog,vi.lights,{emissive:{value:new gi(0)},specular:{value:new gi(1118481)},shininess:{value:30}}]),vertexShader:xi.meshphong_vert,fragmentShader:xi.meshphong_frag},standard:{uniforms:yi.merge([vi.common,vi.envmap,vi.aomap,vi.lightmap,vi.emissivemap,vi.bumpmap,vi.normalmap,vi.displacementmap,vi.roughnessmap,vi.metalnessmap,vi.fog,vi.lights,{emissive:{value:new gi(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:xi.meshphysical_vert,fragmentShader:xi.meshphysical_frag},points:{uniforms:yi.merge([vi.points,vi.fog]),vertexShader:xi.points_vert,fragmentShader:xi.points_frag},dashed:{uniforms:yi.merge([vi.common,vi.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:xi.linedashed_vert,fragmentShader:xi.linedashed_frag},depth:{uniforms:yi.merge([vi.common,vi.displacementmap]),vertexShader:xi.depth_vert,fragmentShader:xi.depth_frag},normal:{uniforms:yi.merge([vi.common,vi.bumpmap,vi.normalmap,vi.displacementmap,{opacity:{value:1}}]),vertexShader:xi.normal_vert,fragmentShader:xi.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:xi.cube_vert,fragmentShader:xi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:xi.equirect_vert,fragmentShader:xi.equirect_frag},distanceRGBA:{uniforms:yi.merge([vi.common,vi.displacementmap,{referencePosition:{value:new wt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:xi.distanceRGBA_vert,fragmentShader:xi.distanceRGBA_frag},shadow:{uniforms:yi.merge([vi.lights,vi.fog,{color:{value:new gi(0)},opacity:{value:1}}]),vertexShader:xi.shadow_vert,fragmentShader:xi.shadow_frag}};function wi(e,t){this.min=void 0!==e?e:new yt(1/0,1/0),this.max=void 0!==t?t:new yt(-1/0,-1/0)}function _i(e,t,i,r,n){var o,a,s,c,h,l,u,p;function d(){var e=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),r=new Uint16Array([0,1,2,0,2,3]);o=t.createBuffer(),a=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r,t.STATIC_DRAW),u=t.createTexture(),p=t.createTexture(),i.bindTexture(t.TEXTURE_2D,u),t.texImage2D(t.TEXTURE_2D,0,t.RGB,16,16,0,t.RGB,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),i.bindTexture(t.TEXTURE_2D,p),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,16,16,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),s={vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","\tvUV = uv;","\tvec2 pos = position;","\tif ( renderType == 2 ) {","\t\tvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","\t\tvVisibility = visibility.r / 9.0;","\t\tvVisibility *= 1.0 - visibility.g / 9.0;","\t\tvVisibility *= visibility.b / 9.0;","\t\tvVisibility *= 1.0 - visibility.a / 9.0;","\t\tpos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","\t\tpos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","\t}","\tgl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","\tif ( renderType == 0 ) {","\t\tgl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","\t} else if ( renderType == 1 ) {","\t\tgl_FragColor = texture2D( map, vUV );","\t} else {","\t\tvec4 texture = texture2D( map, vUV );","\t\ttexture.a *= opacity * vVisibility;","\t\tgl_FragColor = texture;","\t\tgl_FragColor.rgb *= color;","\t}","}"].join("\n")},c=function(e){var i=t.createProgram(),r=t.createShader(t.FRAGMENT_SHADER),o=t.createShader(t.VERTEX_SHADER),a="precision "+n.precision+" float;\n";return t.shaderSource(r,a+e.fragmentShader),t.shaderSource(o,a+e.vertexShader),t.compileShader(r),t.compileShader(o),t.attachShader(i,r),t.attachShader(i,o),t.linkProgram(i),i}(s),h={vertex:t.getAttribLocation(c,"position"),uv:t.getAttribLocation(c,"uv")},l={renderType:t.getUniformLocation(c,"renderType"),map:t.getUniformLocation(c,"map"),occlusionMap:t.getUniformLocation(c,"occlusionMap"),opacity:t.getUniformLocation(c,"opacity"),color:t.getUniformLocation(c,"color"),scale:t.getUniformLocation(c,"scale"),rotation:t.getUniformLocation(c,"rotation"),screenPosition:t.getUniformLocation(c,"screenPosition")}}this.render=function(e,n,s,f){if(0!==e.length){var m=new wt,g=f.w/f.z,v=.5*f.z,y=.5*f.w,x=16/f.w,b=new yt(x*g,x),w=new wt(1,1,0),_=new yt(1,1),M=new wi;M.min.set(f.x,f.y),M.max.set(f.x+(f.z-16),f.y+(f.w-16)),void 0===c&&d(),i.useProgram(c),i.initAttributes(),i.enableAttribute(h.vertex),i.enableAttribute(h.uv),i.disableUnusedAttributes(),t.uniform1i(l.occlusionMap,0),t.uniform1i(l.map,1),t.bindBuffer(t.ARRAY_BUFFER,o),t.vertexAttribPointer(h.vertex,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(h.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),i.disable(t.CULL_FACE),i.buffers.depth.setMask(!1);for(var E=0,T=e.length;E.001&&L.scale>.001&&(w.x=L.x,w.y=L.y,w.z=L.z,x=L.size*L.scale/f.w,b.x=x*g,b.y=x,t.uniform3f(l.screenPosition,w.x,w.y,w.z),t.uniform2f(l.scale,b.x,b.y),t.uniform1f(l.rotation,L.rotation),t.uniform1f(l.opacity,L.opacity),t.uniform3f(l.color,L.color.r,L.color.g,L.color.b),i.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst),r.setTexture2D(L.texture,1),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0))}}}i.enable(t.CULL_FACE),i.enable(t.DEPTH_TEST),i.buffers.depth.setMask(!0),i.reset()}}}function Mi(e,t,i,r,n,o,a,s,c){Et.call(this,e,t,i,r,n,o,a,s,c),this.needsUpdate=!0}function Ei(e,t,i,r,n){var o,a,s,c,h,l,u=new wt,p=new bt,d=new wt;function f(){var e=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),i=new Uint16Array([0,1,2,0,2,3]);o=t.createBuffer(),a=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.bufferData(t.ELEMENT_ARRAY_BUFFER,i,t.STATIC_DRAW),s=function(){var e=t.createProgram(),i=t.createShader(t.VERTEX_SHADER),r=t.createShader(t.FRAGMENT_SHADER);return t.shaderSource(i,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float fogDepth;","void main() {","\tvUV = uvOffset + uv * uvScale;","\tvec2 alignedPosition = position * scale;","\tvec2 rotatedPosition;","\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","\tvec4 mvPosition;","\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","\tmvPosition.xy += rotatedPosition;","\tgl_Position = projectionMatrix * mvPosition;","\tfogDepth = - mvPosition.z;","}"].join("\n")),t.shaderSource(r,["precision "+n.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","varying float fogDepth;","void main() {","\tvec4 texture = texture2D( map, vUV );","\tgl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","\tif ( gl_FragColor.a < alphaTest ) discard;","\tif ( fogType > 0 ) {","\t\tfloat fogFactor = 0.0;","\t\tif ( fogType == 1 ) {","\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );","\t\t} else {","\t\t\tconst float LOG2 = 1.442695;","\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );","\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","\t\t}","\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );","\t}","}"].join("\n")),t.compileShader(i),t.compileShader(r),t.attachShader(e,i),t.attachShader(e,r),t.linkProgram(e),e}(),c={position:t.getAttribLocation(s,"position"),uv:t.getAttribLocation(s,"uv")},h={uvOffset:t.getUniformLocation(s,"uvOffset"),uvScale:t.getUniformLocation(s,"uvScale"),rotation:t.getUniformLocation(s,"rotation"),scale:t.getUniformLocation(s,"scale"),color:t.getUniformLocation(s,"color"),map:t.getUniformLocation(s,"map"),opacity:t.getUniformLocation(s,"opacity"),modelViewMatrix:t.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:t.getUniformLocation(s,"projectionMatrix"),fogType:t.getUniformLocation(s,"fogType"),fogDensity:t.getUniformLocation(s,"fogDensity"),fogNear:t.getUniformLocation(s,"fogNear"),fogFar:t.getUniformLocation(s,"fogFar"),fogColor:t.getUniformLocation(s,"fogColor"),fogDepth:t.getUniformLocation(s,"fogDepth"),alphaTest:t.getUniformLocation(s,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var u=r.getContext("2d");u.fillStyle="white",u.fillRect(0,0,8,8),l=new Mi(r)}function m(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}this.render=function(n,g,v){if(0!==n.length){void 0===s&&f(),i.useProgram(s),i.initAttributes(),i.enableAttribute(c.position),i.enableAttribute(c.uv),i.disableUnusedAttributes(),i.disable(t.CULL_FACE),i.enable(t.BLEND),t.bindBuffer(t.ARRAY_BUFFER,o),t.vertexAttribPointer(c.position,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(c.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,a),t.uniformMatrix4fv(h.projectionMatrix,!1,v.projectionMatrix.elements),i.activeTexture(t.TEXTURE0),t.uniform1i(h.map,0);var y=0,x=0,b=g.fog;b?(t.uniform3f(h.fogColor,b.color.r,b.color.g,b.color.b),b.isFog?(t.uniform1f(h.fogNear,b.near),t.uniform1f(h.fogFar,b.far),t.uniform1i(h.fogType,1),y=1,x=1):b.isFogExp2&&(t.uniform1f(h.fogDensity,b.density),t.uniform1i(h.fogType,2),y=2,x=2)):(t.uniform1i(h.fogType,0),y=0,x=0);for(var w=0,_=n.length;w<_;w++){(E=n[w]).modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,E.matrixWorld),E.z=-E.modelViewMatrix.elements[14]}n.sort(m);var M=[];for(w=0,_=n.length;w<_;w++){var E,T=(E=n[w]).material;if(!1!==T.visible){E.onBeforeRender(e,g,v,void 0,T,void 0),t.uniform1f(h.alphaTest,T.alphaTest),t.uniformMatrix4fv(h.modelViewMatrix,!1,E.modelViewMatrix.elements),E.matrixWorld.decompose(u,p,d),M[0]=d.x,M[1]=d.y;var S=0;g.fog&&T.fog&&(S=x),y!==S&&(t.uniform1i(h.fogType,S),y=S),null!==T.map?(t.uniform2f(h.uvOffset,T.map.offset.x,T.map.offset.y),t.uniform2f(h.uvScale,T.map.repeat.x,T.map.repeat.y)):(t.uniform2f(h.uvOffset,0,0),t.uniform2f(h.uvScale,1,1)),t.uniform1f(h.opacity,T.opacity),t.uniform3f(h.color,T.color.r,T.color.g,T.color.b),t.uniform1f(h.rotation,T.rotation),t.uniform2fv(h.scale,M),i.setBlending(T.blending,T.blendEquation,T.blendSrc,T.blendDst,T.blendEquationAlpha,T.blendSrcAlpha,T.blendDstAlpha,T.premultipliedAlpha),i.buffers.depth.setTest(T.depthTest),i.buffers.depth.setMask(T.depthWrite),i.buffers.color.setMask(T.colorWrite),r.setTexture2D(T.map||l,0),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),E.onAfterRender(e,g,v,void 0,T,void 0)}}i.enable(t.CULL_FACE),i.reset()}}}bi.physical={uniforms:yi.merge([bi.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:xi.meshphysical_vert,fragmentShader:xi.meshphysical_frag},Object.assign(wi.prototype,{set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return(t||new yt).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return(t||new yt).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new yt;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Mi.prototype=Object.create(Et.prototype),Mi.prototype.constructor=Mi;var Ti,Si,Ai,Ri,Li,Ci,Pi,Ni=0;function Ii(){Object.defineProperty(this,"id",{value:Ni++}),this.uuid=vt.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=L,this.side=_,this.flatShading=!1,this.vertexColors=T,this.opacity=1,this.transparent=!1,this.blendSrc=H,this.blendDst=j,this.blendEquation=O,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=$,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function Oi(e){Ii.call(this),this.type="MeshDepthMaterial",this.depthPacking=mt,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(e)}function Di(e){Ii.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new wt,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(e)}function Ui(e,t){this.min=void 0!==e?e:new wt(1/0,1/0,1/0),this.max=void 0!==t?t:new wt(-1/0,-1/0,-1/0)}function Fi(e,t){this.center=void 0!==e?e:new wt,this.radius=void 0!==t?t:0}function Bi(e,t){this.normal=void 0!==e?e:new wt(1,0,0),this.constant=void 0!==t?t:0}function zi(e,t,i,r,n,o){this.planes=[void 0!==e?e:new Bi,void 0!==t?t:new Bi,void 0!==i?i:new Bi,void 0!==r?r:new Bi,void 0!==n?n:new Bi,void 0!==o?o:new Bi]}function ki(e,t,i){for(var r=new zi,n=new xt,o=new yt,a=new yt(i,i),s=new wt,c=new wt,h=1,l=2,u=1+(h|l),p=new Array(u),d=new Array(u),f={},m=[new wt(1,0,0),new wt(-1,0,0),new wt(0,0,1),new wt(0,0,-1),new wt(0,1,0),new wt(0,-1,0)],g=[new wt(0,1,0),new wt(0,1,0),new wt(0,1,0),new wt(0,1,0),new wt(0,0,1),new wt(0,0,-1)],v=[new Tt,new Tt,new Tt,new Tt,new Tt,new Tt],y=0;y!==u;++y){var x=0!=(y&h),w=0!=(y&l),T=new Oi({depthPacking:gt,morphTargets:x,skinning:w});p[y]=T;var S=new Di({morphTargets:x,skinning:w});d[y]=S}var A=this;function R(t,i,r,n,o,a){var s=t.geometry,c=null,u=p,m=t.customDepthMaterial;if(r&&(u=d,m=t.customDistanceMaterial),m)c=m;else{var g=!1;i.morphTargets&&(s&&s.isBufferGeometry?g=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0:s&&s.isGeometry&&(g=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===i.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var v=t.isSkinnedMesh&&i.skinning,y=0;g&&(y|=h),v&&(y|=l),c=u[y]}if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){var x=c.uuid,b=i.uuid,w=f[x];void 0===w&&(w={},f[x]=w);var T=w[b];void 0===T&&(T=c.clone(),w[b]=T),c=T}c.visible=i.visible,c.wireframe=i.wireframe;var S=i.side;return A.renderSingleSided&&S==E&&(S=_),A.renderReverseSided&&(S===_?S=M:S===M&&(S=_)),c.side=S,c.clipShadows=i.clipShadows,c.clippingPlanes=i.clippingPlanes,c.clipIntersection=i.clipIntersection,c.wireframeLinewidth=i.wireframeLinewidth,c.linewidth=i.linewidth,r&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(n),c.nearDistance=o,c.farDistance=a),c}function L(i,n,o,a){if(!1!==i.visible){if(i.layers.test(n.layers)&&(i.isMesh||i.isLine||i.isPoints)&&i.castShadow&&(!i.frustumCulled||r.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);var s=t.update(i),h=i.material;if(Array.isArray(h))for(var l=s.groups,u=0,p=l.length;u0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),t){var n=r(e.textures),o=r(e.images);n.length>0&&(i.textures=n),o.length>0&&(i.images=o)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,i=null;if(null!==t){var r=t.length;i=new Array(r);for(var n=0;n!==r;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Oi.prototype=Object.create(Ii.prototype),Oi.prototype.constructor=Oi,Oi.prototype.isMeshDepthMaterial=!0,Oi.prototype.copy=function(e){return Ii.prototype.copy.call(this,e),this.depthPacking=e.depthPacking,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this},Di.prototype=Object.create(Ii.prototype),Di.prototype.constructor=Di,Di.prototype.isMeshDistanceMaterial=!0,Di.prototype.copy=function(e){return Ii.prototype.copy.call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this},Object.assign(Ui.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=e.length;sn&&(n=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(t,i,r),this.max.set(n,o,a),this},setFromBufferAttribute:function(e){for(var t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,a=-1/0,s=0,c=e.count;sn&&(n=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(t,i,r),this.max.set(n,o,a),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,i=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return(t||new wt).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:(Si=new wt,function(e){return this.clampPoint(e.center,Si),Si.distanceToSquared(e.center)<=e.radius*e.radius}),intersectsPlane:function(e){var t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=e.constant&&i>=e.constant},clampPoint:function(e,t){return(t||new wt).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new wt;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new wt;return function(t){var i=t||new Fi;return this.getCenter(i.center),i.radius=.5*this.getSize(e).length(),i}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:(Ti=[new wt,new wt,new wt,new wt,new wt,new wt,new wt,new wt],function(e){return this.isEmpty()?this:(Ti[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ti[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ti[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ti[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ti[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ti[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ti[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ti[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ti),this)}),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(Fi.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:(Ai=new Ui,function(e,t){var i=this.center;void 0!==t?i.copy(t):Ai.setFromPoints(e).getCenter(i);for(var r=0,n=0,o=e.length;nthis.radius*this.radius&&(r.sub(this.center).normalize(),r.multiplyScalar(this.radius).add(this.center)),r},getBoundingBox:function(e){var t=e||new Ui;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(Bi.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new wt,t=new wt;return function(i,r,n){var o=e.subVectors(n,r).cross(t.subVectors(i,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return(t||new wt).copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new wt;return function(t,i){var r=i||new wt,n=t.delta(e),o=this.normal.dot(n);if(0===o)return 0===this.distanceToPoint(t.start)?r.copy(t.start):void 0;var a=-(t.start.dot(this.normal)+this.constant)/o;return a<0||a>1?void 0:r.copy(n).multiplyScalar(a).add(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return(e||new wt).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new wt,t=new _t;return function(i,r){var n=r||t.getNormalMatrix(i),o=this.coplanarPoint(e).applyMatrix4(i),a=this.normal.applyMatrix3(n).normalize();return this.constant=-o.dot(a),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(zi.prototype,{set:function(e,t,i,r,n,o){var a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(r),a[4].copy(n),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,i=0;i<6;i++)t[i].copy(e.planes[i]);return this},setFromMatrix:function(e){var t=this.planes,i=e.elements,r=i[0],n=i[1],o=i[2],a=i[3],s=i[4],c=i[5],h=i[6],l=i[7],u=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],v=i[14],y=i[15];return t[0].setComponents(a-r,l-s,f-u,y-m).normalize(),t[1].setComponents(a+r,l+s,f+u,y+m).normalize(),t[2].setComponents(a+n,l+c,f+p,y+g).normalize(),t[3].setComponents(a-n,l-c,f-p,y-g).normalize(),t[4].setComponents(a-o,l-h,f-d,y-v).normalize(),t[5].setComponents(a+o,l+h,f+d,y+v).normalize(),this},intersectsObject:(Ci=new Fi,function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Ci.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ci)}),intersectsSprite:function(){var e=new Fi;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,i=e.center,r=-e.radius,n=0;n<6;n++){if(t[n].distanceToPoint(i)0?e.min.x:e.max.x,Li.x=r.normal.x>0?e.max.x:e.min.x,Ri.y=r.normal.y>0?e.min.y:e.max.y,Li.y=r.normal.y>0?e.max.y:e.min.y,Ri.z=r.normal.z>0?e.min.z:e.max.z,Li.z=r.normal.z>0?e.max.z:e.min.z;var n=r.distanceToPoint(Ri),o=r.distanceToPoint(Li);if(n<0&&o<0)return!1}return!0}),containsPoint:function(e){for(var t=this.planes,i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}}),Vi.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],Vi.DefaultOrder="XYZ",Object.defineProperties(Vi.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},order:{get:function(){return this._order},set:function(e){this._order=e,this.onChangeCallback()}}}),Object.assign(Vi.prototype,{isEuler:!0,set:function(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._order=r||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,i){var r=vt.clamp,n=e.elements,o=n[0],a=n[4],s=n[8],c=n[1],h=n[5],l=n[9],u=n[2],p=n[6],d=n[10];return"XYZ"===(t=t||this._order)?(this._y=Math.asin(r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,h),this._z=0)):"YXZ"===t?(this._x=Math.asin(-r(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,o),this._z=0)):"ZXY"===t?(this._x=Math.asin(r(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===t?(this._y=Math.asin(-r(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,h))):"YZX"===t?(this._z=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===t?(this._z=Math.asin(-r(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,h),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==i&&this.onChangeCallback(),this},setFromQuaternion:function(){var e=new xt;return function(t,i,r){return e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,i,r)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:(Pi=new bt,function(e){return Pi.setFromEuler(this),this.setFromQuaternion(Pi,e)}),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new wt(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(Hi.prototype,{set:function(e){this.mask=1<1){for(var t=0;t1){for(var t=0;t0){r.children=[];for(a=0;a0&&(i.geometries=c),h.length>0&&(i.materials=h),l.length>0&&(i.textures=l),u.length>0&&(i.images=u)}return i.object=r,i;function p(e){var t=[];for(var i in e){var r=e[i];delete r.metadata,t.push(r)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var i=0;it&&(t=e[i]);return t}Object.assign(tr.prototype,i.prototype,{isGeometry:!0,applyMatrix:function(e){for(var t=(new _t).getNormalMatrix(e),i=0,r=this.vertices.length;i0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,i;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,i,r,n;for(i=0,r=this.faces.length;i0&&(e+=t[i].distanceTo(t[i-1])),this.lineDistances[i]=e},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ui),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new Fi),this.boundingSphere.setFromPoints(this.vertices)},merge:function(e,t,i){if(e&&e.isGeometry){var r,n=this.vertices.length,o=this.vertices,a=e.vertices,s=this.faces,c=e.faces,h=this.faceVertexUvs[0],l=e.faceVertexUvs[0],u=this.colors,p=e.colors;void 0===i&&(i=0),void 0!==t&&(r=(new _t).getNormalMatrix(t));for(var d=0,f=a.length;d=0;i--){var f=p[i];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=d.vertexNormals.length>0,v=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=d.vertexColors.length>0,x=0;if(x=M(x=M(x=M(x=M(x=M(x=M(x=M(x=M(x,0,0),1,!0),2,!1),3,f),4,m),5,g),6,v),7,y),a.push(x),a.push(d.a,d.b,d.c),a.push(d.materialIndex),f){var b=this.faceVertexUvs[0][n];a.push(S(b[0]),S(b[1]),S(b[2]))}if(m&&a.push(E(d.normal)),g){var w=d.vertexNormals;a.push(E(w[0]),E(w[1]),E(w[2]))}if(v&&a.push(T(d.color)),y){var _=d.vertexColors;a.push(T(_[0]),T(_[1]),T(_[2]))}}function M(e,t,i){return i?e|1<0&&(e.data.colors=h),u.length>0&&(e.data.uvs=[u]),e.data.faces=a,e},clone:function(){return(new tr).copy(this)},copy:function(e){var t,i,r,n,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,i=s.length;t0,a=n[1]&&n[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(var h=0;h0){l=[];for(h=0;h0?1:-1,h.push(L.x,L.y,L.z),l.push(y/m),l.push(1-x/g),A+=1}}for(x=0;x1&&i.sort(Ir),r.length>1&&r.sort(Or)}}},e[r]=n),n},dispose:function(){e={}}}}function Ur(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Fr(){var e=new function(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new wt,color:new gi,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new yt};break;case"SpotLight":i={position:new wt,direction:new wt,color:new gi,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new yt};break;case"PointLight":i={position:new wt,color:new gi,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new yt,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new wt,skyColor:new gi,groundColor:new gi};break;case"RectAreaLight":i={color:new gi,position:new wt,halfWidth:new wt,halfHeight:new wt}}return e[t.id]=i,i}}},t={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},i=new wt,r=new xt,n=new xt;return{setup:function(o,a,s){for(var c=0,h=0,l=0,u=0,p=0,d=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v65535?hr:sr)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(t)):(this.attributes[e]=t,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(e,new ir(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,i){this.groups.push({start:e,count:t,materialIndex:void 0!==i?i:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var i=this.attributes.normal;void 0!==i&&((new _t).getNormalMatrix(e).applyToBufferAttribute(i),i.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new xt;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new xt;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new xt;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new xt;return function(t,i,r){return e.makeTranslation(t,i,r),this.applyMatrix(e),this}}(),scale:function(){var e=new xt;return function(t,i,r){return e.makeScale(t,i,r),this.applyMatrix(e),this}}(),lookAt:function(){var e=new Zi;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){this.computeBoundingBox();var e=this.boundingBox.getCenter().negate();return this.translate(e.x,e.y,e.z),e},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var i=new lr(3*t.vertices.length,3),r=new lr(3*t.colors.length,3);if(this.addAttribute("position",i.copyVector3sArray(t.vertices)),this.addAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var n=new lr(t.lineDistances.length,1);this.addAttribute("lineDistance",n.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],i=0,r=e.length;i0){var i=new Float32Array(3*e.normals.length);this.addAttribute("normal",new ir(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.addAttribute("color",new ir(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var n=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new ir(n,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var o=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new ir(o,2).copyVector2sArray(e.uvs2))}if(e.indices.length>0){var a=new(dr(e.indices)>65535?Uint32Array:Uint16Array)(3*e.indices.length);this.setIndex(new ir(a,1).copyIndicesArray(e.indices))}for(var s in this.groups=e.groups,e.morphTargets){for(var c=[],h=e.morphTargets[s],l=0,u=h.length;l0){var f=new lr(4*e.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var m=new lr(4*e.skinWeights.length,4);this.addAttribute("skinWeight",m.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ui);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new Ui,t=new wt;return function(){null===this.boundingSphere&&(this.boundingSphere=new Fi);var i=this.attributes.position;if(i){var r=this.boundingSphere.center;e.setFromBufferAttribute(i),e.getCenter(r);for(var n=0,o=0,a=i.count;o0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new _r).copy(this)},copy:function(e){var t,i,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone());var o=e.attributes;for(t in o){var a=o[t];this.addAttribute(t,a.clone())}var s=e.morphAttributes;for(t in s){var c=[],h=s[t];for(i=0,r=h.length;i0)if(o=h*l-u,s=c*d,(n=h*u-l)>=0)if(o>=-s)if(o<=s){var f=1/d;a=(n*=f)*(n+h*(o*=f)+2*l)+o*(h*n+o+2*u)+p}else o=c,a=-(n=Math.max(0,-(h*o+l)))*n+o*(o+2*u)+p;else o=-c,a=-(n=Math.max(0,-(h*o+l)))*n+o*(o+2*u)+p;else o<=-s?a=-(n=Math.max(0,-(-h*c+l)))*n+(o=n>0?-c:Math.min(Math.max(-c,-u),c))*(o+2*u)+p:o<=s?(n=0,a=(o=Math.min(Math.max(-c,-u),c))*(o+2*u)+p):a=-(n=Math.max(0,-(h*c+l)))*n+(o=n>0?c:Math.min(Math.max(-c,-u),c))*(o+2*u)+p;else o=h>0?-c:c,a=-(n=Math.max(0,-(h*o+l)))*n+o*(o+2*u)+p;return i&&i.copy(this.direction).multiplyScalar(n).add(this.origin),r&&r.copy(gr).multiplyScalar(o).add(mr),a}),intersectSphere:function(){var e=new wt;return function(t,i){e.subVectors(t.center,this.origin);var r=e.dot(this.direction),n=e.dot(e)-r*r,o=t.radius*t.radius;if(n>o)return null;var a=Math.sqrt(o-n),s=r-a,c=r+a;return s<0&&c<0?null:s<0?this.at(c,i):this.at(s,i)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null},intersectPlane:function(e,t){var i=this.distanceToPlane(e);return null===i?null:this.at(i,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var i,r,n,o,a,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(i=(e.min.x-u.x)*c,r=(e.max.x-u.x)*c):(i=(e.max.x-u.x)*c,r=(e.min.x-u.x)*c),h>=0?(n=(e.min.y-u.y)*h,o=(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,o=(e.min.y-u.y)*h),i>o||n>r?null:((n>i||i!=i)&&(i=n),(o=0?(a=(e.min.z-u.z)*l,s=(e.max.z-u.z)*l):(a=(e.max.z-u.z)*l,s=(e.min.z-u.z)*l),i>s||a>r?null:((a>i||i!=i)&&(i=a),(s=0?i:r,t)))},intersectsBox:(fr=new wt,function(e){return null!==this.intersectBox(e,fr)}),intersectTriangle:function(){var e=new wt,t=new wt,i=new wt,r=new wt;return function(n,o,a,s,c){t.subVectors(o,n),i.subVectors(a,n),r.crossVectors(t,i);var h,l=this.direction.dot(r);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}e.subVectors(this.origin,n);var u=h*this.direction.dot(i.crossVectors(e,i));if(u<0)return null;var p=h*this.direction.dot(t.cross(e));if(p<0)return null;if(u+p>l)return null;var d=-h*e.dot(r);return d<0?null:this.at(d/l,c)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(Cr.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return(e||new wt).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return(e||new wt).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){var i=t||new wt;return this.delta(i).multiplyScalar(e).add(this.start)},closestPointToPointParameter:(yr=new wt,xr=new wt,function(e,t){yr.subVectors(e,this.start),xr.subVectors(this.end,this.start);var i=xr.dot(xr),r=xr.dot(yr)/i;return t&&(r=vt.clamp(r,0,1)),r}),closestPointToPoint:function(e,t,i){var r=this.closestPointToPointParameter(e,t),n=i||new wt;return this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Object.assign(Pr,{normal:(br=new wt,function(e,t,i,r){var n=r||new wt;n.subVectors(i,t),br.subVectors(e,t),n.cross(br);var o=n.lengthSq();return o>0?n.multiplyScalar(1/Math.sqrt(o)):n.set(0,0,0)}),barycoordFromPoint:function(){var e=new wt,t=new wt,i=new wt;return function(r,n,o,a,s){e.subVectors(a,n),t.subVectors(o,n),i.subVectors(r,n);var c=e.dot(e),h=e.dot(t),l=e.dot(i),u=t.dot(t),p=t.dot(i),d=c*u-h*h,f=s||new wt;if(0===d)return f.set(-2,-1,-1);var m=1/d,g=(u*l-h*p)*m,v=(c*p-h*l)*m;return f.set(1-g-v,v,g)}}(),containsPoint:function(){var e=new wt;return function(t,i,r,n){var o=Pr.barycoordFromPoint(t,i,r,n,e);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(Pr.prototype,{set:function(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this},setFromPointsAndIndices:function(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new wt,t=new wt;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){return(e||new wt).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return Pr.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new Bi).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return Pr.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return Pr.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e=new Bi,t=[new Cr,new Cr,new Cr],i=new wt,r=new wt;return function(n,o){var a=o||new wt,s=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(n,i),!0===this.containsPoint(i))a.copy(i);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var c=0;c0){var a=n[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=a.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;ei.far?null:{distance:c,point:f.clone(),object:e}}function v(e,t,i,a,s,c,p,f){r.fromBufferAttribute(a,c),n.fromBufferAttribute(a,p),o.fromBufferAttribute(a,f);var v=g(e,e.material,t,i,r,n,o,d);return v&&(s&&(h.fromBufferAttribute(s,c),l.fromBufferAttribute(s,p),u.fromBufferAttribute(s,f),v.uv=m(d,r,n,o,h,l,u)),v.face=new Ki(c,p,f,Pr.normal(r,n,o)),v.faceIndex=c),v}return function(p,f){var y,x=this.geometry,b=this.material,w=this.matrixWorld;if(void 0!==b&&(null===x.boundingSphere&&x.computeBoundingSphere(),i.copy(x.boundingSphere),i.applyMatrix4(w),!1!==p.ray.intersectsSphere(i)&&(e.getInverse(w),t.copy(p.ray).applyMatrix4(e),null===x.boundingBox||!1!==t.intersectsBox(x.boundingBox))))if(x.isBufferGeometry){var _,M,E,T,S,A=x.index,R=x.attributes.position,L=x.attributes.uv;if(null!==A)for(T=0,S=A.count;T0&&(I=F);for(var B=0,z=U.length;B/gm,function(e,t){var i=xi[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return Qr(i)})}function Jr(e){return e.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(e,t,i,r){for(var n="",o=parseInt(t);o0?e.gammaFactor:1,_=function(e,t,i){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.normalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&i.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&i.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&i.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Yr).join("\n")}(r.extensions,o,t),M=function(e){var t=[];for(var i in e){var r=e[i];!1!==r&&t.push("#define "+i+" "+r)}return t.join("\n")}(s),E=a.createProgram();r.isRawShaderMaterial?((f=[M].filter(Yr).join("\n")).length>0&&(f+="\n"),(m=[_,M].filter(Yr).join("\n")).length>0&&(m+="\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,M,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+x,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Yr).join("\n"),m=[_,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+n.name,M,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+x,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+u:"",o.envMap?"#define "+p:"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+o.numClippingPlanes,"#define UNION_CLIPPING_PLANES "+(o.numClippingPlanes-o.numClipIntersection),o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&t.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==se?"#define TONE_MAPPING":"",o.toneMapping!==se?xi.tonemapping_pars_fragment:"",o.toneMapping!==se?function(e,t){var i;switch(t){case ce:i="Linear";break;case he:i="Reinhard";break;case le:i="Uncharted2";break;case ue:i="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+t)}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?xi.encodings_pars_fragment:"",o.mapEncoding?qr("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?qr("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?qr("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(g="linearToOutputTexel",v=o.outputEncoding,y=Xr(v),"vec4 "+g+"( vec4 value ) { return LinearTo"+y[0]+y[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Yr).join("\n")),c=Zr(c=Qr(c),o),h=Zr(h=Qr(h),o),r.isShaderMaterial||(c=Jr(c),h=Jr(h));var T=f+c,S=m+h,A=Br(a,a.VERTEX_SHADER,T),R=Br(a,a.FRAGMENT_SHADER,S);a.attachShader(E,A),a.attachShader(E,R),void 0!==r.index0AttributeName?a.bindAttribLocation(E,0,r.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(E,0,"position"),a.linkProgram(E);var L,C,P=a.getProgramInfoLog(E),N=a.getShaderInfoLog(A),I=a.getShaderInfoLog(R),O=!0,D=!0;return!1===a.getProgramParameter(E,a.LINK_STATUS)?(O=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(E,a.VALIDATE_STATUS),"gl.getProgramInfoLog",P,N,I)):""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==N&&""!==I||(D=!1),D&&(this.diagnostics={runnable:O,material:r,programLog:P,vertexShader:{log:N,prefix:f},fragmentShader:{log:I,prefix:m}}),a.deleteShader(A),a.deleteShader(R),this.getUniforms=function(){return void 0===L&&(L=new fi(a,E,e)),L},this.getAttributes=function(){return void 0===C&&(C=function(e,t){for(var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=0;n0,maxBones:p,useVertexTexture:i.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numClippingPlanes:c,numClipIntersection:h,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.receiveShadow&&o.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===E,flipSided:t.side===M,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,i){var r=[];if(i.shaderID?r.push(i.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var n in t.defines)r.push(n),r.push(t.defines[n]);for(var a=0;at||e.height>t){var i=t/Math.max(e.width,e.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(e.width*i),r.height=Math.floor(e.height*i),r.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+r.width+"x"+r.height,e),r}return e}function h(e){return vt.isPowerOfTwo(e.width)&&vt.isPowerOfTwo(e.height)}function l(e,t){return e.generateMipmaps&&t&&e.minFilter!==_e&&e.minFilter!==Te}function u(t){return t===_e||t===Me||t===Ee?e.NEAREST:e.LINEAR}function p(t){var i=t.target;i.removeEventListener("dispose",p),function(t){var i=r.get(t);if(t.image&&i.__image__webglTextureCube)e.deleteTexture(i.__image__webglTextureCube);else{if(void 0===i.__webglInit)return;e.deleteTexture(i.__webglTexture)}r.remove(t)}(i),a.textures--}function d(t){var i=t.target;i.removeEventListener("dispose",d),function(t){var i=r.get(t),n=r.get(t.texture);if(!t)return;void 0!==n.__webglTexture&&e.deleteTexture(n.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var o=0;o<6;o++)e.deleteFramebuffer(i.__webglFramebuffer[o]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[o]);else e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer);r.remove(t.texture),r.remove(t)}(i),a.textures--}function f(t,u){var d=r.get(t);if(t.version>0&&d.__version!==t.version){var f=t.image;if(void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==f.complete)return void function(t,r,u){void 0===t.__webglInit&&(t.__webglInit=!0,r.addEventListener("dispose",p),t.__webglTexture=e.createTexture(),a.textures++);i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment);var d=c(r.image,n.maxTextureSize);(function(e){return e.wrapS!==be||e.wrapT!==be||e.minFilter!==_e&&e.minFilter!==Te})(r)&&!1===h(d)&&(d=function(e){if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap){var t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return t.width=vt.floorPowerOfTwo(e.width),t.height=vt.floorPowerOfTwo(e.height),t.getContext("2d").drawImage(e,0,0,t.width,t.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+t.width+"x"+t.height,e),t}return e}(d));var f=h(d),g=o.convert(r.format),v=o.convert(r.type);m(e.TEXTURE_2D,r,f);var y,x=r.mipmaps;if(r.isDepthTexture){var b=e.DEPTH_COMPONENT;if(r.type===Oe){if(!s)throw new Error("Float Depth Texture only supported in WebGL2.0");b=e.DEPTH_COMPONENT32F}else s&&(b=e.DEPTH_COMPONENT16);r.format===Xe&&b===e.DEPTH_COMPONENT&&r.type!==Pe&&r.type!==Ie&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Pe,v=o.convert(r.type)),r.format===qe&&(b=e.DEPTH_STENCIL,r.type!==ze&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=ze,v=o.convert(r.type))),i.texImage2D(e.TEXTURE_2D,0,b,d.width,d.height,0,g,v,null)}else if(r.isDataTexture)if(x.length>0&&f){for(var w=0,_=x.length;w<_;w++)y=x[w],i.texImage2D(e.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);r.generateMipmaps=!1}else i.texImage2D(e.TEXTURE_2D,0,g,d.width,d.height,0,g,v,d.data);else if(r.isCompressedTexture)for(var w=0,_=x.length;w<_;w++)y=x[w],r.format!==Ve&&r.format!==Ge?i.getCompressedTextureFormats().indexOf(g)>-1?i.compressedTexImage2D(e.TEXTURE_2D,w,g,y.width,y.height,0,y.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):i.texImage2D(e.TEXTURE_2D,w,g,y.width,y.height,0,g,v,y.data);else if(x.length>0&&f){for(var w=0,_=x.length;w<_;w++)y=x[w],i.texImage2D(e.TEXTURE_2D,w,g,g,v,y);r.generateMipmaps=!1}else i.texImage2D(e.TEXTURE_2D,0,g,g,v,d);l(r,f)&&e.generateMipmap(e.TEXTURE_2D);t.__version=r.version,r.onUpdate&&r.onUpdate(r)}(d,t,u);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}}i.activeTexture(e.TEXTURE0+u),i.bindTexture(e.TEXTURE_2D,d.__webglTexture)}function m(i,a,s){var c;if(s?(e.texParameteri(i,e.TEXTURE_WRAP_S,o.convert(a.wrapS)),e.texParameteri(i,e.TEXTURE_WRAP_T,o.convert(a.wrapT)),e.texParameteri(i,e.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),a.wrapS===be&&a.wrapT===be||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),e.texParameteri(i,e.TEXTURE_MAG_FILTER,u(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,u(a.minFilter)),a.minFilter!==_e&&a.minFilter!==Te&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=t.get("EXT_texture_filter_anisotropic")){if(a.type===Oe&&null===t.get("OES_texture_float_linear"))return;if(a.type===De&&null===t.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(i,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function g(t,n,a,s){var c=o.convert(n.texture.format),h=o.convert(n.texture.type);i.texImage2D(s,0,c,n.width,n.height,0,c,h,null),e.bindFramebuffer(e.FRAMEBUFFER,t),e.framebufferTexture2D(e.FRAMEBUFFER,a,s,r.get(n.texture).__webglTexture,0),e.bindFramebuffer(e.FRAMEBUFFER,null)}function v(t,i){e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)):i.depthBuffer&&i.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,i.width,i.height),e.bindRenderbuffer(e.RENDERBUFFER,null)}function y(t){var i=r.get(t),n=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(n)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(e.FRAMEBUFFER,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),f(i.depthTexture,0);var n=r.get(i.depthTexture).__webglTexture;if(i.depthTexture.format===Xe)e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,n,0);else{if(i.depthTexture.format!==qe)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,n,0)}}(i.__webglFramebuffer,t)}else if(n){i.__webglDepthbuffer=[];for(var o=0;o<6;o++)e.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[o]),i.__webglDepthbuffer[o]=e.createRenderbuffer(),v(i.__webglDepthbuffer[o],t)}else e.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),v(i.__webglDepthbuffer,t);e.bindFramebuffer(e.FRAMEBUFFER,null)}this.setTexture2D=f,this.setTextureCube=function(t,s){var u=r.get(t);if(6===t.image.length)if(t.version>0&&u.__version!==t.version){u.__image__webglTextureCube||(t.addEventListener("dispose",p),u.__image__webglTextureCube=e.createTexture(),a.textures++),i.activeTexture(e.TEXTURE0+s),i.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,f=t.image[0]&&t.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=d||f?f?t.image[v].image:t.image[v]:c(t.image[v],n.maxCubemapSize);var y=h(g[0]),x=o.convert(t.format),b=o.convert(t.type);for(m(e.TEXTURE_CUBE_MAP,t,y),v=0;v<6;v++)if(d)for(var w,_=g[v].mipmaps,M=0,E=_.length;M-1?i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,M,x,w.width,w.height,0,w.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,M,x,w.width,w.height,0,x,b,w.data);else f?i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,g[v].width,g[v].height,0,x,b,g[v].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,b,g[v]);l(t,y)&&e.generateMipmap(e.TEXTURE_CUBE_MAP),u.__version=t.version,t.onUpdate&&t.onUpdate(t)}else i.activeTexture(e.TEXTURE0+s),i.bindTexture(e.TEXTURE_CUBE_MAP,u.__image__webglTextureCube)},this.setTextureCubeDynamic=function(t,n){i.activeTexture(e.TEXTURE0+n),i.bindTexture(e.TEXTURE_CUBE_MAP,r.get(t).__webglTexture)},this.setupRenderTarget=function(t){var n=r.get(t),o=r.get(t.texture);t.addEventListener("dispose",d),o.__webglTexture=e.createTexture(),a.textures++;var s=!0===t.isWebGLRenderTargetCube,c=h(t);if(s){n.__webglFramebuffer=[];for(var u=0;u<6;u++)n.__webglFramebuffer[u]=e.createFramebuffer()}else n.__webglFramebuffer=e.createFramebuffer();if(s){for(i.bindTexture(e.TEXTURE_CUBE_MAP,o.__webglTexture),m(e.TEXTURE_CUBE_MAP,t.texture,c),u=0;u<6;u++)g(n.__webglFramebuffer[u],t,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+u);l(t.texture,c)&&e.generateMipmap(e.TEXTURE_CUBE_MAP),i.bindTexture(e.TEXTURE_CUBE_MAP,null)}else i.bindTexture(e.TEXTURE_2D,o.__webglTexture),m(e.TEXTURE_2D,t.texture,c),g(n.__webglFramebuffer,t,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),l(t.texture,c)&&e.generateMipmap(e.TEXTURE_2D),i.bindTexture(e.TEXTURE_2D,null);t.depthBuffer&&y(t)},this.updateRenderTargetMipmap=function(t){var n=t.texture;if(l(n,h(t))){var o=t.isWebGLRenderTargetCube?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=r.get(n).__webglTexture;i.bindTexture(o,a),e.generateMipmap(o),i.bindTexture(o,null)}}}function tn(e,t,i,r){Qi.call(this),this.type="PerspectiveCamera",this.fov=void 0!==e?e:50,this.zoom=1,this.near=void 0!==i?i:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==t?t:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function rn(e){tn.call(this),this.cameras=e||[]}function nn(e,t){return{convert:function(i){var r;if(i===xe)return e.REPEAT;if(i===be)return e.CLAMP_TO_EDGE;if(i===we)return e.MIRRORED_REPEAT;if(i===_e)return e.NEAREST;if(i===Me)return e.NEAREST_MIPMAP_NEAREST;if(i===Ee)return e.NEAREST_MIPMAP_LINEAR;if(i===Te)return e.LINEAR;if(i===Se)return e.LINEAR_MIPMAP_NEAREST;if(i===Ae)return e.LINEAR_MIPMAP_LINEAR;if(i===Re)return e.UNSIGNED_BYTE;if(i===Ue)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Fe)return e.UNSIGNED_SHORT_5_5_5_1;if(i===Be)return e.UNSIGNED_SHORT_5_6_5;if(i===Le)return e.BYTE;if(i===Ce)return e.SHORT;if(i===Pe)return e.UNSIGNED_SHORT;if(i===Ne)return e.INT;if(i===Ie)return e.UNSIGNED_INT;if(i===Oe)return e.FLOAT;if(i===De&&null!==(r=t.get("OES_texture_half_float")))return r.HALF_FLOAT_OES;if(i===ke)return e.ALPHA;if(i===Ge)return e.RGB;if(i===Ve)return e.RGBA;if(i===He)return e.LUMINANCE;if(i===je)return e.LUMINANCE_ALPHA;if(i===Xe)return e.DEPTH_COMPONENT;if(i===qe)return e.DEPTH_STENCIL;if(i===O)return e.FUNC_ADD;if(i===D)return e.FUNC_SUBTRACT;if(i===U)return e.FUNC_REVERSE_SUBTRACT;if(i===z)return e.ZERO;if(i===k)return e.ONE;if(i===G)return e.SRC_COLOR;if(i===V)return e.ONE_MINUS_SRC_COLOR;if(i===H)return e.SRC_ALPHA;if(i===j)return e.ONE_MINUS_SRC_ALPHA;if(i===W)return e.DST_ALPHA;if(i===X)return e.ONE_MINUS_DST_ALPHA;if(i===q)return e.DST_COLOR;if(i===Y)return e.ONE_MINUS_DST_COLOR;if(i===Z)return e.SRC_ALPHA_SATURATE;if((i===Ye||i===Ze||i===Qe||i===Je)&&null!==(r=t.get("WEBGL_compressed_texture_s3tc"))){if(i===Ye)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Ze)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Qe)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Je)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((i===Ke||i===$e||i===et||i===tt)&&null!==(r=t.get("WEBGL_compressed_texture_pvrtc"))){if(i===Ke)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===$e)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===et)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===tt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===it&&null!==(r=t.get("WEBGL_compressed_texture_etc1")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((i===F||i===B)&&null!==(r=t.get("EXT_blend_minmax"))){if(i===F)return r.MIN_EXT;if(i===B)return r.MAX_EXT}return i===ze&&null!==(r=t.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function on(e){console.log("THREE.WebGLRenderer",m);var t=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),i=void 0!==e.context?e.context:null,r=void 0!==e.alpha&&e.alpha,n=void 0===e.depth||e.depth,o=void 0===e.stencil||e.stencil,a=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,c=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,h=[],l=[],u=null,p=[],d=[];this.domElement=t,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=ce,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var f,b,w,_,S,A,O,D,U,F,B,z,k,G,V,H,j,W,X,q=this,Y=!1,Z=null,ne=null,oe=-1,ae="",se=null,he=null,le=new Tt,ue=new Tt,pe=null,de=0,fe=t.width,me=t.height,ge=1,ve=new Tt(0,0,fe,me),ye=new Tt(0,0,fe,me),xe=!1,be=new zi,we=new function(){var e=this,t=null,i=0,r=!1,n=!1,o=new Bi,a=new _t,s={value:null,needsUpdate:!1};function c(){s.value!==t&&(s.value=t,s.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function h(t,i,r,n){var c=null!==t?t.length:0,h=null;if(0!==c){if(h=s.value,!0!==n||null===h){var l=r+4*c,u=i.matrixWorldInverse;a.getNormalMatrix(u),(null===h||h.length0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==i.precision?i.precision:"highp",a=n(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===i.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=e.getParameter(e.MAX_TEXTURE_SIZE),u=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),p=e.getParameter(e.MAX_VERTEX_ATTRIBS),d=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),f=e.getParameter(e.MAX_VARYING_VECTORS),m=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=h>0,v=!!t.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==r)return r;var i=t.get("EXT_texture_filter_anisotropic");return r=null!==i?e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:n,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:u,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(f,b,e),(_=new function(e,t,i){var r=new function(){var t=!1,i=new Tt,r=null,n=new Tt(0,0,0,0);return{setMask:function(i){r===i||t||(e.colorMask(i,i,i,i),r=i)},setLocked:function(e){t=e},setClear:function(t,r,o,a,s){!0===s&&(t*=a,r*=a,o*=a),i.set(t,r,o,a),!1===n.equals(i)&&(e.clearColor(t,r,o,a),n.copy(i))},reset:function(){t=!1,r=null,n.set(-1,0,0,0)}}},n=new function(){var t=!1,i=null,r=null,n=null;return{setTest:function(t){t?X(e.DEPTH_TEST):q(e.DEPTH_TEST)},setMask:function(r){i===r||t||(e.depthMask(r),i=r)},setFunc:function(t){if(r!==t){if(t)switch(t){case Q:e.depthFunc(e.NEVER);break;case J:e.depthFunc(e.ALWAYS);break;case K:e.depthFunc(e.LESS);break;case $:e.depthFunc(e.LEQUAL);break;case ee:e.depthFunc(e.EQUAL);break;case te:e.depthFunc(e.GEQUAL);break;case ie:e.depthFunc(e.GREATER);break;case re:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);r=t}},setLocked:function(e){t=e},setClear:function(t){n!==t&&(e.clearDepth(t),n=t)},reset:function(){t=!1,i=null,r=null,n=null}}},o=new function(){var t=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,h=null;return{setTest:function(t){t?X(e.STENCIL_TEST):q(e.STENCIL_TEST)},setMask:function(r){i===r||t||(e.stencilMask(r),i=r)},setFunc:function(t,i,a){r===t&&n===i&&o===a||(e.stencilFunc(t,i,a),r=t,n=i,o=a)},setOp:function(t,i,r){a===t&&s===i&&c===r||(e.stencilOp(t,i,r),a=t,s=i,c=r)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,i=null,r=null,n=null,o=null,a=null,s=null,c=null,h=null}}},a=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),c=new Uint8Array(a),h=new Uint8Array(a),l={},u=null,p=null,d=null,f=null,m=null,x=null,b=null,w=null,_=null,T=!1,S=null,A=null,O=null,D=null,U=null,F=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),B=parseFloat(/^WebGL\ ([0-9])/.exec(e.getParameter(e.VERSION))[1]),z=parseFloat(B)>=1,k=null,G={},V=new Tt,H=new Tt;function j(t,i,r){var n=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var a=0;a65535?hr:sr)(a,1),t.update(r,e.ELEMENT_ARRAY_BUFFER),n[i.id]=r,r}}}(f,O,Se),U=new function(e,t){var i={};return{update:function(r){var n=t.frame,o=r.geometry,a=e.get(r,o);return i[a.id]!==n&&(o.isGeometry&&a.updateFromObject(r),e.update(a),i[a.id]=n),a},clear:function(){i={}}}}(D,Ae),G=new function(e){var t={},i=new Float32Array(8);return{update:function(r,n,o,a){var s=r.morphTargetInfluences,c=s.length,h=t[n.id];if(void 0===h){h=[];for(var l=0;l=0){var h=n[s];if(void 0!==h){var l=h.normalized,u=h.itemSize,p=O.get(h);if(void 0===p)continue;var d=p.buffer,m=p.type,g=p.bytesPerElement;if(h.isInterleavedBufferAttribute){var v=h.data,y=v.stride,x=h.offset;v&&v.isInstancedInterleavedBuffer?(_.enableAttributeAndDivisor(c,v.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=v.meshPerAttribute*v.count)):_.enableAttribute(c),f.bindBuffer(f.ARRAY_BUFFER,d),f.vertexAttribPointer(c,u,m,l,y*g,(r*y+x)*g)}else h.isInstancedBufferAttribute?(_.enableAttributeAndDivisor(c,h.meshPerAttribute),void 0===i.maxInstancedCount&&(i.maxInstancedCount=h.meshPerAttribute*h.count)):_.enableAttribute(c),f.bindBuffer(f.ARRAY_BUFFER,d),f.vertexAttribPointer(c,u,m,l,0,r*u*g)}else if(void 0!==a){var w=a[s];if(void 0!==w)switch(w.length){case 2:f.vertexAttrib2fv(c,w);break;case 3:f.vertexAttrib3fv(c,w);break;case 4:f.vertexAttrib4fv(c,w);break;default:f.vertexAttrib1fv(c,w)}}}}_.disableUnusedAttributes()}(r,a,i),null!==l&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,h.buffer));var m=0;null!==l?m=l.count:void 0!==u&&(m=u.count);var g=i.drawRange.start*p,v=i.drawRange.count*p,y=null!==o?o.start*p:0,x=null!==o?o.count*p:1/0,w=Math.max(g,y),M=Math.min(m,g+v,y+x)-1,E=Math.max(0,M-w+1);if(0!==E){if(n.isMesh)if(!0===r.wireframe)_.setLineWidth(r.wireframeLinewidth*Le()),d.setMode(f.LINES);else switch(n.drawMode){case ot:d.setMode(f.TRIANGLES);break;case at:d.setMode(f.TRIANGLE_STRIP);break;case st:d.setMode(f.TRIANGLE_FAN)}else if(n.isLine){var T=r.linewidth;void 0===T&&(T=1),_.setLineWidth(T*Le()),n.isLineSegments?d.setMode(f.LINES):n.isLineLoop?d.setMode(f.LINE_LOOP):d.setMode(f.LINE_STRIP)}else n.isPoints&&d.setMode(f.POINTS);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&d.renderInstances(i,w,E):d.render(w,E)}},this.compile=function(e,t){h.length=0,l.length=0,e.traverse(function(e){e.isLight&&(h.push(e),e.castShadow&&l.push(e))}),F.setup(h,l,t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var i=0;i=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(u=0;u=0&&e.numSupportedMorphNormals++}var p=r.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=we.numPlanes,r.numIntersection=we.numIntersection,p.clippingPlanes=we.uniform),r.fog=t,r.lightsHash=F.state.hash,e.lights&&(p.ambientLightColor.value=F.state.ambient,p.directionalLights.value=F.state.directional,p.spotLights.value=F.state.spot,p.rectAreaLights.value=F.state.rectArea,p.pointLights.value=F.state.point,p.hemisphereLights.value=F.state.hemi,p.directionalShadowMap.value=F.state.directionalShadowMap,p.directionalShadowMatrix.value=F.state.directionalShadowMatrix,p.spotShadowMap.value=F.state.spotShadowMap,p.spotShadowMatrix.value=F.state.spotShadowMatrix,p.pointShadowMap.value=F.state.pointShadowMap,p.pointShadowMatrix.value=F.state.pointShadowMatrix);var d=r.program.getUniforms(),f=fi.seqWithValue(d.seq,p);r.uniformsList=f}function Ye(e,t,i,r){de=0;var n=S.get(i);if(_e&&(Me||e!==se)){var o=e===se&&i.id===oe;we.setState(i.clippingPlanes,i.clipIntersection,i.clipShadows,e,n,o)}!1===i.needsUpdate&&(void 0===n.program?i.needsUpdate=!0:i.fog&&n.fog!==t?i.needsUpdate=!0:i.lights&&n.lightsHash!==F.state.hash?i.needsUpdate=!0:void 0===n.numClippingPlanes||n.numClippingPlanes===we.numPlanes&&n.numIntersection===we.numIntersection||(i.needsUpdate=!0)),i.needsUpdate&&(qe(i,t,r),i.needsUpdate=!1);var a,s,c=!1,h=!1,l=!1,u=n.program,p=u.getUniforms(),d=n.shader.uniforms;if(_.useProgram(u.program)&&(c=!0,h=!0,l=!0),i.id!==oe&&(oe=i.id,h=!0),c||e!==se){if(p.setValue(f,"projectionMatrix",e.projectionMatrix),w.logarithmicDepthBuffer&&p.setValue(f,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),se!==(he||e)&&(se=he||e,h=!0,l=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.envMap){var m=p.map.cameraPosition;void 0!==m&&m.setValue(f,Te.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.skinning)&&p.setValue(f,"viewMatrix",e.matrixWorldInverse)}if(i.skinning){p.setOptional(f,r,"bindMatrix"),p.setOptional(f,r,"bindMatrixInverse");var g=r.skeleton;if(g){var v=g.bones;if(w.floatVertexTextures){if(void 0===g.boneTexture){var y=Math.sqrt(4*v.length);y=vt.ceilPowerOfTwo(y),y=Math.max(y,4);var x=new Float32Array(y*y*4);x.set(g.boneMatrices);var b=new Rt(x,y,y,Ve,Oe);g.boneMatrices=x,g.boneTexture=b,g.boneTextureSize=y}p.setValue(f,"boneTexture",g.boneTexture),p.setValue(f,"boneTextureSize",g.boneTextureSize)}else p.setOptional(f,g,"boneMatrices")}}return h&&(p.setValue(f,"toneMappingExposure",q.toneMappingExposure),p.setValue(f,"toneMappingWhitePoint",q.toneMappingWhitePoint),i.lights&&(s=l,(a=d).ambientLightColor.needsUpdate=s,a.directionalLights.needsUpdate=s,a.pointLights.needsUpdate=s,a.spotLights.needsUpdate=s,a.rectAreaLights.needsUpdate=s,a.hemisphereLights.needsUpdate=s),t&&i.fog&&function(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}(d,t),i.isMeshBasicMaterial?Ze(d,i):i.isMeshLambertMaterial?(Ze(d,i),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(d,i)):i.isMeshPhongMaterial?(Ze(d,i),i.isMeshToonMaterial?function(e,t){Qe(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(d,i):Qe(d,i)):i.isMeshStandardMaterial?(Ze(d,i),i.isMeshPhysicalMaterial?function(e,t){e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness,Je(e,t)}(d,i):Je(d,i)):i.isMeshDepthMaterial?(Ze(d,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(d,i)):i.isMeshDistanceMaterial?(Ze(d,i),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(d,i)):i.isMeshNormalMaterial?(Ze(d,i),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale);t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale));t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(d,i)):i.isLineBasicMaterial?(function(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}(d,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(d,i)):i.isPointsMaterial?function(e,t){if(e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*ge,e.scale.value=.5*me,e.map.value=t.map,null!==t.map){if(!0===t.map.matrixAutoUpdate){var i=t.map.offset,r=t.map.repeat,n=t.map.rotation,o=t.map.center;t.map.matrix.setUvTransform(i.x,i.y,r.x,r.y,n,o.x,o.y)}e.uvTransform.value.copy(t.map.matrix)}}(d,i):i.isShadowMaterial&&(d.color.value=i.color,d.opacity.value=i.opacity),void 0!==d.ltcMat&&(d.ltcMat.value=vi.LTC_MAT_TEXTURE),void 0!==d.ltcMag&&(d.ltcMag.value=vi.LTC_MAG_TEXTURE),fi.upload(f,n.uniformsList,d,q)),p.setValue(f,"modelViewMatrix",r.modelViewMatrix),p.setValue(f,"normalMatrix",r.normalMatrix),p.setValue(f,"modelMatrix",r.matrixWorld),u}function Ze(e,t){var i;if(e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?i=t.map:t.specularMap?i=t.specularMap:t.displacementMap?i=t.displacementMap:t.normalMap?i=t.normalMap:t.bumpMap?i=t.bumpMap:t.roughnessMap?i=t.roughnessMap:t.metalnessMap?i=t.metalnessMap:t.alphaMap?i=t.alphaMap:t.emissiveMap&&(i=t.emissiveMap),void 0!==i){if(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate){var r=i.offset,n=i.repeat,o=i.rotation,a=i.center;i.matrix.setUvTransform(r.x,r.y,n.x,n.y,o,a.x,a.y)}e.uvTransform.value.copy(i.matrix)}}function Qe(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function Je(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale)),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}this.animate=function(e){He=e,function(){if(!Ge){var e=Ne.getDevice();e&&e.isPresenting?e.requestAnimationFrame(je):window.requestAnimationFrame(je),Ge=!0}}()},this.render=function(e,t,i,r){if(t&&t.isCamera){if(!Y){ae="",oe=-1,se=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Ne.enabled&&(t=Ne.getCamera(t)),Ee.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),be.setFromMatrix(Ee),h.length=0,l.length=0,p.length=0,d.length=0,Me=this.localClippingEnabled,_e=we.init(this.clippingPlanes,Me,t),(u=z.get(e,t)).init(),function e(t,i,r){if(!1===t.visible)return;var n=t.layers.test(i.layers);if(n)if(t.isLight)h.push(t),t.castShadow&&l.push(t);else if(t.isSprite)t.frustumCulled&&!be.intersectsSprite(t)||p.push(t);else if(t.isLensFlare)d.push(t);else if(t.isImmediateRenderObject)r&&Te.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Ee),u.push(t,null,t.material,Te.z,null);else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.update(),!t.frustumCulled||be.intersectsObject(t))){r&&Te.setFromMatrixPosition(t.matrixWorld).applyMatrix4(Ee);var o=U.update(t),a=t.material;if(Array.isArray(a))for(var s=o.groups,c=0,f=s.length;c=w.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+w.maxTextures),de+=1,e},this.setTexture2D=(ke=!1,function(e,t){e&&e.isWebGLRenderTarget&&(ke||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),ke=!0),e=e.texture),A.setTexture2D(e,t)}),this.setTexture=function(){var e=!1;return function(t,i){e||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),e=!0),A.setTexture2D(t,i)}}(),this.setTextureCube=function(){var e=!1;return function(t,i){t&&t.isWebGLRenderTargetCube&&(e||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),e=!0),t=t.texture),t&&t.isCubeTexture||Array.isArray(t.image)&&6===t.image.length?A.setTextureCube(t,i):A.setTextureCubeDynamic(t,i)}}(),this.getRenderTarget=function(){return Z},this.setRenderTarget=function(e){Z=e,e&&void 0===S.get(e).__webglFramebuffer&&A.setupRenderTarget(e);var t=null,i=!1;if(e){var r=S.get(e).__webglFramebuffer;e.isWebGLRenderTargetCube?(t=r[e.activeCubeFace],i=!0):t=r,le.copy(e.viewport),ue.copy(e.scissor),pe=e.scissorTest}else le.copy(ve).multiplyScalar(ge),ue.copy(ye).multiplyScalar(ge),pe=xe;if(ne!==t&&(f.bindFramebuffer(f.FRAMEBUFFER,t),ne=t),_.viewport(le),_.scissor(ue),_.setScissorTest(pe),i){var n=S.get(e.texture);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_CUBE_MAP_POSITIVE_X+e.activeCubeFace,n.__webglTexture,e.activeMipMapLevel)}},this.readRenderTargetPixels=function(e,t,i,r,n,o){if(e&&e.isWebGLRenderTarget){var a=S.get(e).__webglFramebuffer;if(a){var s=!1;a!==ne&&(f.bindFramebuffer(f.FRAMEBUFFER,a),s=!0);try{var c=e.texture,h=c.format,l=c.type;if(h!==Ve&&X.convert(h)!==f.getParameter(f.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===Re||X.convert(l)===f.getParameter(f.IMPLEMENTATION_COLOR_READ_TYPE)||l===Oe&&(b.get("OES_texture_float")||b.get("WEBGL_color_buffer_float"))||l===De&&b.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");f.checkFramebufferStatus(f.FRAMEBUFFER)===f.FRAMEBUFFER_COMPLETE?t>=0&&t<=e.width-r&&i>=0&&i<=e.height-n&&f.readPixels(t,i,r,n,X.convert(h),X.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&f.bindFramebuffer(f.FRAMEBUFFER,ne)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")}}function an(e,t){this.name="",this.color=new gi(e),this.density=void 0!==t?t:25e-5}function sn(e,t,i){this.name="",this.color=new gi(e),this.near=void 0!==t?t:1,this.far=void 0!==i?i:1e3}function cn(){Zi.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function hn(e,t,i,r,n){Zi.call(this),this.lensFlares=[],this.positionScreen=new wt,this.customUpdateCallback=void 0,void 0!==e&&this.add(e,t,i,r,n)}function ln(e){Ii.call(this),this.type="SpriteMaterial",this.color=new gi(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function un(e){Zi.call(this),this.type="Sprite",this.material=void 0!==e?e:new ln}function pn(){Zi.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function dn(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var i=0,r=this.bones.length;i=t.HAVE_CURRENT_DATA&&(h.needsUpdate=!0),requestAnimationFrame(e)})}function En(e,t,i,r,n,o,a,s,c,h,l,u){Et.call(this,null,o,a,s,c,h,r,n,l,u),this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function Tn(e,t,i,r,n,o,a,s,c,h){if((h=void 0!==h?h:Xe)!==Xe&&h!==qe)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Xe&&(i=Pe),void 0===i&&h===qe&&(i=ze),Et.call(this,null,r,n,o,a,s,h,i,c),this.image={width:e,height:t},this.magFilter=void 0!==a?a:_e,this.minFilter=void 0!==s?s:_e,this.flipY=!1,this.generateMipmaps=!1}function Sn(e){_r.call(this),this.type="WireframeGeometry";var t,i,r,n,o,a,s,c,h,l,u=[],p=[0,0],d={},f=["a","b","c"];if(e&&e.isGeometry){var m=e.faces;for(t=0,r=m.length;t=0?(u=e(g-1e-5,m,u),p.subVectors(l,u)):(u=e(g+1e-5,m,u),p.subVectors(u,l)),m-1e-5>=0?(u=e(g,m-1e-5,u),d.subVectors(l,u)):(u=e(g,m+1e-5,u),d.subVectors(u,l)),h.crossVectors(p,d).normalize(),s.push(h.x,h.y,h.z),c.push(g,m)}}for(r=0;r.9&&a<.1&&(t<.2&&(o[e+0]+=1),i<.2&&(o[e+2]+=1),r<.2&&(o[e+4]+=1))}}()}(),this.addAttribute("position",new lr(n,3)),this.addAttribute("normal",new lr(n.slice(),3)),this.addAttribute("uv",new lr(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Pn(e,t){tr.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Nn(e,t)),this.mergeVertices()}function Nn(e,t){Cn.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],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function In(e,t){tr.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new On(e,t)),this.mergeVertices()}function On(e,t){Cn.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],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Dn(e,t){tr.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Un(e,t)),this.mergeVertices()}function Un(e,t){var i=(1+Math.sqrt(5))/2,r=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];Cn.call(this,r,[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],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Fn(e,t){tr.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Bn(e,t)),this.mergeVertices()}function Bn(e,t){var i=(1+Math.sqrt(5))/2,r=1/i,n=[-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,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r];Cn.call(this,n,[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],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function zn(e,t,i,r,n,o){tr.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new kn(e,t,i,r,n);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function kn(e,t,i,r,n){_r.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n},t=t||64,i=i||1,r=r||8,n=n||!1;var o=e.computeFrenetFrames(t,n);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,c=new wt,h=new wt,l=new yt,u=new wt,p=[],d=[],f=[],m=[];function g(n){u=e.getPointAt(n/t,u);var a=o.normals[n],l=o.binormals[n];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);h.x=g*a.x+m*l.x,h.y=g*a.y+m*l.y,h.z=g*a.z+m*l.z,h.normalize(),d.push(h.x,h.y,h.z),c.x=u.x+i*h.x,c.y=u.y+i*h.y,c.z=u.z+i*h.z,p.push(c.x,c.y,c.z)}}!function(){for(a=0;ai)){var r=e.ray.origin.distanceTo(zr);re.far||t.push({distance:r,point:zr.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)}}),pn.prototype=Object.assign(Object.create(Zi.prototype),{constructor:pn,copy:function(e){Zi.prototype.copy.call(this,e,!1);for(var t=e.levels,i=0,r=t.length;i1){e.setFromMatrixPosition(i.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var n=e.distanceTo(t);r[0].object.visible=!0;for(var o=1,a=r.length;o=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;oa))p.applyMatrix4(this.matrixWorld),(M=r.ray.origin.distanceTo(p))r.far||n.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}else for(v=0,y=m.length/3-1;va))p.applyMatrix4(this.matrixWorld),(M=r.ray.origin.distanceTo(p))r.far||n.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var w=s.vertices,_=w.length;for(v=0;v<_-1;v+=d){var M;if(!(t.distanceSqToSegment(w[v],w[v+1],p,u)>a))p.applyMatrix4(this.matrixWorld),(M=r.ray.origin.distanceTo(p))r.far||n.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),yn.prototype=Object.assign(Object.create(vn.prototype),{constructor:yn,isLineSegments:!0}),xn.prototype=Object.assign(Object.create(vn.prototype),{constructor:xn,isLineLoop:!0}),bn.prototype=Object.create(Ii.prototype),bn.prototype.constructor=bn,bn.prototype.isPointsMaterial=!0,bn.prototype.copy=function(e){return Ii.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this},wn.prototype=Object.assign(Object.create(Zi.prototype),{constructor:wn,isPoints:!0,raycast:function(){var e=new xt,t=new Lr,i=new Fi;return function(r,n){var o=this,a=this.geometry,s=this.matrixWorld,c=r.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),i.copy(a.boundingSphere),i.applyMatrix4(s),i.radius+=c,!1!==r.ray.intersectsSphere(i)){e.getInverse(s),t.copy(r.ray).applyMatrix4(e);var h=c/((this.scale.x+this.scale.y+this.scale.z)/3),l=h*h,u=new wt;if(a.isBufferGeometry){var p=a.index,d=a.attributes.position.array;if(null!==p)for(var f=p.array,m=0,g=f.length;mr.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:c.clone(),index:i,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),_n.prototype=Object.assign(Object.create(Zi.prototype),{constructor:_n}),Mn.prototype=Object.create(Et.prototype),Mn.prototype.constructor=Mn,En.prototype=Object.create(Et.prototype),En.prototype.constructor=En,En.prototype.isCompressedTexture=!0,Tn.prototype=Object.create(Et.prototype),Tn.prototype.constructor=Tn,Tn.prototype.isDepthTexture=!0,Sn.prototype=Object.create(_r.prototype),Sn.prototype.constructor=Sn,An.prototype=Object.create(tr.prototype),An.prototype.constructor=An,Rn.prototype=Object.create(_r.prototype),Rn.prototype.constructor=Rn,Ln.prototype=Object.create(tr.prototype),Ln.prototype.constructor=Ln,Cn.prototype=Object.create(_r.prototype),Cn.prototype.constructor=Cn,Pn.prototype=Object.create(tr.prototype),Pn.prototype.constructor=Pn,Nn.prototype=Object.create(Cn.prototype),Nn.prototype.constructor=Nn,In.prototype=Object.create(tr.prototype),In.prototype.constructor=In,On.prototype=Object.create(Cn.prototype),On.prototype.constructor=On,Dn.prototype=Object.create(tr.prototype),Dn.prototype.constructor=Dn,Un.prototype=Object.create(Cn.prototype),Un.prototype.constructor=Un,Fn.prototype=Object.create(tr.prototype),Fn.prototype.constructor=Fn,Bn.prototype=Object.create(Cn.prototype),Bn.prototype.constructor=Bn,zn.prototype=Object.create(tr.prototype),zn.prototype.constructor=zn,kn.prototype=Object.create(_r.prototype),kn.prototype.constructor=kn,Gn.prototype=Object.create(tr.prototype),Gn.prototype.constructor=Gn,Vn.prototype=Object.create(_r.prototype),Vn.prototype.constructor=Vn,Hn.prototype=Object.create(tr.prototype),Hn.prototype.constructor=Hn,jn.prototype=Object.create(_r.prototype),jn.prototype.constructor=jn;var Wn={area:function(e){for(var t=e.length,i=0,r=t-1,n=0;n=-Number.EPSILON&&_>=-Number.EPSILON&&w>=-Number.EPSILON))return!1;return!0}return function(t,i){var r=t.length;if(r<3)return null;var n,o,a,s=[],c=[],h=[];if(Wn.area(t)>0)for(o=0;o2;){if(u--<=0)return console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"),i?h:s;if(l<=(n=o)&&(n=0),l<=(o=n+1)&&(o=0),l<=(a=o+1)&&(a=0),e(t,n,o,a,l,c)){var p,d,f,m,g;for(p=c[n],d=c[o],f=c[a],s.push([t[p],t[d],t[f]]),h.push([c[n],c[o],c[a]]),m=o,g=o+1;g2&&e[t-1].equals(e[0])&&e.pop()}function r(e,t,i){return e.x!==t.x?e.xNumber.EPSILON){var f;if(p>0){if(d<0||d>p)return[];if((f=h*l-c*u)<0||f>p)return[]}else{if(d>0||d0||fM?[]:y===M?o?[]:[g]:x<=M?[g,v]:[g,w])}function o(e,t,i,r){var n=t.x-e.x,o=t.y-e.y,a=i.x-e.x,s=i.y-e.y,c=r.x-e.x,h=r.y-e.y,l=n*s-o*a,u=n*h-o*c;if(Math.abs(l)>Number.EPSILON){var p=c*s-h*a;return l>0?u>=0&&p>=0:u>=0||p>=0}return u>0}i(e),t.forEach(i);for(var a,s,c,h,l,u,p={},d=e.concat(),f=0,m=t.length;fn&&(s=0);var c=o(r[e],r[a],r[s],i[t]);if(!c)return!1;var h=i.length-1,l=t-1;l<0&&(l=h);var u=t+1;return u>h&&(u=0),!!(c=o(i[t],i[l],i[u],r[e]))}function s(e,t){var i,o;for(i=0;i0)return!0;return!1}var c=[];function h(e,i){var r,o,a,s;for(r=0;r0)return!0;return!1}for(var l,u,p,d,f,m,g,v,y,x,b=[],w=0,_=t.length;w<_;w++)c.push(w);for(var M=0,E=2*c.length;c.length>0;){if(--E<0){console.log('THREE.ShapeUtils: Infinite Loop! Holes left:" + indepHoles.length + ", Probably Hole outside Shape!');break}for(u=M;u=0)break;b[m]=!0}if(l>=0)break}}return r}(e,t),v=Wn.triangulate(g,!1);for(a=0,s=v.length;a0)&&f.push(w,_,E),(c!==i-1||h0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.addAttribute("position",new lr(l,3)),this.addAttribute("normal",new lr(u,3)),this.addAttribute("uv",new lr(p,2))}function so(e,t,i,r,n,o,a){oo.call(this,0,e,t,i,r,n,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function co(e,t,i,r,n,o,a){ao.call(this,0,e,t,i,r,n,o,a),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:o,thetaLength:a}}function ho(e,t,i,r){tr.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},this.fromBufferGeometry(new lo(e,t,i,r)),this.mergeVertices()}function lo(e,t,i,r){_r.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var n,o,a=[],s=[],c=[],h=[],l=new wt,u=new yt;for(s.push(0,0,0),c.push(0,0,1),h.push(.5,.5),o=0,n=3;o<=t;o++,n+=3){var p=i+o/t*r;l.x=e*Math.cos(p),l.y=e*Math.sin(p),s.push(l.x,l.y,l.z),c.push(0,0,1),u.x=(s[n]/e+1)/2,u.y=(s[n+1]/e+1)/2,h.push(u.x,u.y)}for(n=1;n<=t;n++)a.push(n,n+1,0);this.setIndex(a),this.addAttribute("position",new lr(s,3)),this.addAttribute("normal",new lr(c,3)),this.addAttribute("uv",new lr(h,2))}Xn.prototype=Object.create(tr.prototype),Xn.prototype.constructor=Xn,qn.prototype=Object.create(_r.prototype),qn.prototype.constructor=qn,qn.prototype.getArrays=function(){var e=this.getAttribute("position"),t=e?Array.prototype.slice.call(e.array):[],i=this.getAttribute("uv"),r=i?Array.prototype.slice.call(i.array):[],n=this.index;return{position:t,uv:r,index:n?Array.prototype.slice.call(n.array):[]}},qn.prototype.addShapeList=function(e,t){var i=e.length;t.arrays=this.getArrays();for(var r=0;rNumber.EPSILON){var p=Math.sqrt(l),d=Math.sqrt(c*c+h*h),f=t.x-s/p,m=t.y+a/p,g=((i.x-h/d-f)*h-(i.y+c/d-m)*c)/(a*h-s*c),v=(r=f+a*g-e.x)*r+(n=m+s*g-e.y)*n;if(v<=2)return new yt(r,n);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?c>Number.EPSILON&&(y=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(h)&&(y=!0),y?(r=-s,n=a,o=Math.sqrt(l)):(r=a,n=s,o=Math.sqrt(l/2))}return new yt(r/o,n/o)}for(var G=[],V=0,H=C.length,j=H-1,W=V+1;V=0;N--){for(O=N/y,D=g*Math.cos(O*Math.PI/2),I=v*Math.sin(O*Math.PI/2),V=0,H=C.length;V=0;){i=V,(r=V-1)<0&&(r=e.length-1);var n=0,o=w+2*y;for(n=0;n0||0===e.search(/^data\:image\/jpeg/);o.format=i?Ge:Ve,o.needsUpdate=!0,void 0!==t&&t(o)},i,r),o},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Io.prototype=Object.assign(Object.create(Zi.prototype),{constructor:Io,isLight:!0,copy:function(e){return Zi.prototype.copy.call(this,e),this.color.copy(e.color),this.intensity=e.intensity,this},toJSON:function(e){var t=Zi.prototype.toJSON.call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}),Oo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Oo,isHemisphereLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.groundColor.copy(e.groundColor),this}}),Object.assign(Do.prototype,{copy:function(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var e={};return 0!==this.bias&&(e.bias=this.bias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}),Uo.prototype=Object.assign(Object.create(Do.prototype),{constructor:Uo,isSpotLightShadow:!0,update:function(e){var t=this.camera,i=2*vt.RAD2DEG*e.angle,r=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;i===t.fov&&r===t.aspect&&n===t.far||(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix())}}),Fo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Fo,isSpotLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Bo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Bo,isPointLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}),zo.prototype=Object.assign(Object.create(Do.prototype),{constructor:zo}),ko.prototype=Object.assign(Object.create(Io.prototype),{constructor:ko,isDirectionalLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}),Go.prototype=Object.assign(Object.create(Io.prototype),{constructor:Go,isAmbientLight:!0}),Vo.prototype=Object.assign(Object.create(Io.prototype),{constructor:Vo,isRectAreaLight:!0,copy:function(e){return Io.prototype.copy.call(this,e),this.width=e.width,this.height=e.height,this},toJSON:function(e){var t=Io.prototype.toJSON.call(this,e);return t.object.width=this.width,t.object.height=this.height,t}});var Ho,jo={arraySlice:function(e,t,i){return jo.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)},convertArray:function(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){for(var t=e.length,i=new Array(t),r=0;r!==t;++r)i[r]=r;return i.sort(function(t,i){return e[t]-e[i]}),i},sortedArray:function(e,t,i){for(var r=e.length,n=new e.constructor(r),o=0,a=0;a!==r;++o)for(var s=i[o]*t,c=0;c!==t;++c)n[a++]=e[s+c];return n},flattenJSON:function(e,t,i,r){for(var n=1,o=e[0];void 0!==o&&void 0===o[r];)o=e[n++];if(void 0!==o){var a=o[r];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[r])&&(t.push(o.time),i.push.apply(i,a)),o=e[n++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[r])&&(t.push(o.time),a.toArray(i,i.length)),o=e[n++]}while(void 0!==o);else do{void 0!==(a=o[r])&&(t.push(o.time),i.push(a)),o=e[n++]}while(void 0!==o)}}};function Wo(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i}function Xo(e,t,i,r){Wo.call(this,e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function qo(e,t,i,r){Wo.call(this,e,t,i,r)}function Yo(e,t,i,r){Wo.call(this,e,t,i,r)}function Zo(e,t,i,r){if(void 0===e)throw new Error("track name is undefined");if(void 0===t||0===t.length)throw new Error("no keyframes in track named "+e);this.name=e,this.times=jo.convertArray(t,this.TimeBufferType),this.values=jo.convertArray(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation),this.validate(),this.optimize()}function Qo(e,t,i,r){Zo.call(this,e,t,i,r)}function Jo(e,t,i,r){Wo.call(this,e,t,i,r)}function Ko(e,t,i,r){Zo.call(this,e,t,i,r)}function $o(e,t,i,r){Zo.call(this,e,t,i,r)}function ea(e,t,i,r){Zo.call(this,e,t,i,r)}function ta(e,t,i){Zo.call(this,e,t,i)}function ia(e,t,i,r){Zo.call(this,e,t,i,r)}function ra(e,t,i,r){Zo.apply(this,e,t,i,r)}function na(e,t,i){this.name=e,this.tracks=i,this.duration=void 0!==t?t:-1,this.uuid=vt.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function oa(e){this.manager=void 0!==e?e:To,this.textures={}}function aa(e){this.manager=void 0!==e?e:To}Object.assign(Wo.prototype,{evaluate:function(e){var t=this.parameterPositions,i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{var o;i:{r:if(!(e=n)break e;var s=t[1];e=(n=t[--i-1]))break t}o=i,i=0}for(;i>>1;et;)--o;if(++o,0!==n||o!==r){n>=o&&(n=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=jo.arraySlice(i,n,o),this.values=jo.arraySlice(this.values,n*a,o*a)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrackPrototype: Invalid value size in track.",this),e=!1);var i=this.times,r=this.values,n=i.length;0===n&&(console.error("THREE.KeyframeTrackPrototype: Track is empty.",this),e=!1);for(var o=null,a=0;a!==n;a++){var s=i[a];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrackPrototype: Time is not a valid number.",this,a,s),e=!1;break}if(null!==o&&o>s){console.error("THREE.KeyframeTrackPrototype: Out of order keys.",this,a,s,o),e=!1;break}o=s}if(void 0!==r&&jo.isTypedArray(r)){a=0;for(var c=r.length;a!==c;++a){var h=r[a];if(isNaN(h)){console.error("THREE.KeyframeTrackPrototype: Value is not a valid number.",this,a,h),e=!1;break}}}return e},optimize:function(){for(var e=this.times,t=this.values,i=this.getValueSize(),r=2302===this.getInterpolation(),n=1,o=e.length-1,a=1;a0){e[n]=e[o];for(f=o*i,m=n*i,p=0;p!==i;++p)t[m+p]=t[f+p];++n}return n!==e.length&&(this.times=jo.arraySlice(e,0,n),this.values=jo.arraySlice(t,0,n*i)),this}},Qo.prototype=Object.assign(Object.create(Ho),{constructor:Qo,ValueTypeName:"vector"}),Jo.prototype=Object.assign(Object.create(Wo.prototype),{constructor:Jo,interpolate_:function(e,t,i,r){for(var n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=e*a,c=(i-t)/(r-t),h=s+a;s!==h;s+=4)bt.slerpFlat(n,0,o,s-a,o,s,c);return n}}),Ko.prototype=Object.assign(Object.create(Ho),{constructor:Ko,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(e){return new Jo(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),$o.prototype=Object.assign(Object.create(Ho),{constructor:$o,ValueTypeName:"number"}),ea.prototype=Object.assign(Object.create(Ho),{constructor:ea,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ta.prototype=Object.assign(Object.create(Ho),{constructor:ta,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),ia.prototype=Object.assign(Object.create(Ho),{constructor:ia,ValueTypeName:"color"}),ra.prototype=Ho,Ho.constructor=ra,Object.assign(ra,{parse:function(e){if(void 0===e.type)throw new Error("track type undefined, can not parse");var t=ra._getTrackTypeForValueTypeName(e.type);if(void 0===e.times){var i=[],r=[];jo.flattenJSON(e.keys,i,r,"value"),e.times=i,e.values=r}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)},toJSON:function(e){var t,i=e.constructor;if(void 0!==i.toJSON)t=i.toJSON(e);else{t={name:e.name,times:jo.convertArray(e.times,Array),values:jo.convertArray(e.values,Array)};var r=e.getInterpolation();r!==e.DefaultInterpolation&&(t.interpolation=r)}return t.type=e.ValueTypeName,t},_getTrackTypeForValueTypeName:function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return $o;case"vector":case"vector2":case"vector3":case"vector4":return Qo;case"color":return ia;case"quaternion":return Ko;case"bool":case"boolean":return ta;case"string":return ea}throw new Error("Unsupported typeName: "+e)}}),Object.assign(na,{parse:function(e){for(var t=[],i=e.tracks,r=1/(e.fps||1),n=0,o=i.length;n!==o;++n)t.push(ra.parse(i[n]).scale(r));return new na(e.name,e.duration,t)},toJSON:function(e){for(var t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t},n=0,o=i.length;n!==o;++n)t.push(ra.toJSON(i[n]));return r},CreateFromMorphTargetSequence:function(e,t,i,r){for(var n=t.length,o=[],a=0;a1){var h=r[u=c[1]];h||(r[u]=h=[]),h.push(s)}}var l=[];for(var u in r)l.push(na.CreateFromMorphTargetSequence(u,r[u],t,i));return l},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var i=function(e,t,i,r,n){if(0!==i.length){var o=[],a=[];jo.flattenJSON(i,o,a,r),0!==o.length&&n.push(new e(t,o,a))}},r=[],n=e.name||"default",o=e.length||-1,a=e.fps||30,s=e.hierarchy||[],c=0;c1?e.skinWeights[r+1]:0,s=i>2?e.skinWeights[r+2]:0,c=i>3?e.skinWeights[r+3]:0;t.skinWeights.push(new Tt(o,a,s,c))}if(e.skinIndices)for(r=0,n=e.skinIndices.length;r1?e.skinIndices[r+1]:0,u=i>2?e.skinIndices[r+2]:0,p=i>3?e.skinIndices[r+3]:0;t.skinIndices.push(new Tt(h,l,u,p))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}(e,i),function(e,t){var i=e.scale;if(void 0!==e.morphTargets)for(var r=0,n=e.morphTargets.length;r0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var l=t.faces,u=e.morphColors[0].colors;for(r=0,n=l.length;r0&&(t.animations=i)}(e,i),i.computeFaceNormals(),i.computeBoundingSphere(),void 0===e.materials||0===e.materials.length?{geometry:i}:{geometry:i,materials:pa.prototype.initMaterials(e.materials,t,this.crossOrigin)}}}()}),Object.assign(fa.prototype,{load:function(e,t,i,r){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var n=this;new Ao(n.manager).load(e,function(i){var o=null;try{o=JSON.parse(i)}catch(t){return void 0!==r&&r(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?n.parse(o,t):console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.")},i,r)},setTexturePath:function(e){this.texturePath=e},setCrossOrigin:function(e){this.crossOrigin=e},parse:function(e,t){var i=this.parseGeometries(e.geometries),r=this.parseImages(e.images,function(){void 0!==t&&t(a)}),n=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,n),a=this.parseObject(e.object,i,o);return e.animations&&(a.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(a),a},parseGeometries:function(e){var t={};if(void 0!==e)for(var i=new da,r=new aa,n=0,o=e.length;n0){var o=new Co(new Eo(t));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=e.length;a0?new mn(s,c):new Nr(s,c);break;case"LOD":n=new pn;break;case"Line":n=new vn(o(t.geometry),a(t.material),t.mode);break;case"LineLoop":n=new xn(o(t.geometry),a(t.material));break;case"LineSegments":n=new yn(o(t.geometry),a(t.material));break;case"PointCloud":case"Points":n=new wn(o(t.geometry),a(t.material));break;case"Sprite":n=new un(a(t.material));break;case"Group":n=new _n;break;default:n=new Zi}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(e.fromArray(t.matrix),e.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.children)for(var h=t.children,l=0;l0)){c=n;break}c=n-1}if(r[n=c]===i)return n/(o-1);var h=r[n];return(n+(i-h)/(r[n+1]-h))/(o-1)},getTangent:function(e){var t=e-1e-4,i=e+1e-4;t<0&&(t=0),i>1&&(i=1);var r=this.getPoint(t);return this.getPoint(i).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var i,r,n,o=new wt,a=[],s=[],c=[],h=new wt,l=new xt;for(i=0;i<=e;i++)r=i/e,a[i]=this.getTangentAt(r),a[i].normalize();s[0]=new wt,c[0]=new wt;var u=Number.MAX_VALUE,p=Math.abs(a[0].x),d=Math.abs(a[0].y),f=Math.abs(a[0].z);for(p<=u&&(u=p,o.set(1,0,0)),d<=u&&(u=d,o.set(0,1,0)),f<=u&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),i=1;i<=e;i++)s[i]=s[i-1].clone(),c[i]=c[i-1].clone(),h.crossVectors(a[i-1],a[i]),h.length()>Number.EPSILON&&(h.normalize(),n=Math.acos(vt.clamp(a[i-1].dot(a[i]),-1,1)),s[i].applyMatrix4(l.makeRotationAxis(h,n))),c[i].crossVectors(a[i],s[i]);if(!0===t)for(n=Math.acos(vt.clamp(s[0].dot(s[e]),-1,1)),n/=e,a[0].dot(h.crossVectors(s[0],s[e]))>0&&(n=-n),i=1;i<=e;i++)s[i].applyMatrix4(l.makeRotationAxis(a[i],n*i)),c[i].crossVectors(a[i],s[i]);return{tangents:a,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),_a.prototype=Object.create(wa.prototype),_a.prototype.constructor=_a,_a.prototype.isLineCurve=!0,_a.prototype.getPoint=function(e,t){var i=t||new yt;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i},_a.prototype.getPointAt=function(e,t){return this.getPoint(e,t)},_a.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},_a.prototype.copy=function(e){return wa.prototype.copy.call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this},Ma.prototype=Object.assign(Object.create(wa.prototype),{constructor:Ma,add:function(e){this.curves.push(e)},closePath:function(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new _a(t,e))},getPoint:function(e){for(var t=e*this.getLength(),i=this.getCurveLengths(),r=0;r=t){var n=i[r]-t,o=this.curves[r],a=o.getLength(),s=0===a?0:1-n/a;return o.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.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 e=[],t=0,i=0,r=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},copy:function(e){wa.prototype.copy.call(this,e),this.curves=[];for(var t=0,i=e.curves.length;tr;)n-=r;nr.length-2?r.length-1:o+1],l=r[o>r.length-3?r.length-1:o+2];return i.set(ya(a,s.x,c.x,h.x,l.x),ya(a,s.y,c.y,h.y,l.y)),i},Ta.prototype.copy=function(e){wa.prototype.copy.call(this,e),this.points=[];for(var t=0,i=e.points.length;t0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(e){return Ma.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this}});function Ca(e){Ma.call(this),this.type="Path",this.currentPoint=new yt,e&&this.setFromPoints(e)}function Pa(e){Ca.call(this,e),this.type="Shape",this.holes=[]}function Na(){this.type="ShapePath",this.subPaths=[],this.currentPath=null}function Ia(e){this.type="Font",this.data=e}function Oa(e){this.manager=void 0!==e?e:To}Ca.prototype=La,La.constructor=Ca,Pa.prototype=Object.assign(Object.create(La),{constructor:Pa,getPointsHoles:function(e){for(var t=[],i=0,r=this.holes.length;iNumber.EPSILON){if(h<0&&(a=t[o],c=-c,s=t[n],h=-h),e.ys.y)continue;if(e.y===a.y){if(e.x===a.x)return!0}else{var l=h*(e.x-a.x)-c*(e.y-a.y);if(0===l)return!0;if(l<0)continue;r=!r}}else{if(e.y!==a.y)continue;if(s.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=s.x)return!0}}return r}var n=Wn.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return i(o);var a,s,c,h=[];if(1===o.length)return s=o[0],(c=new Pa).curves=s.curves,h.push(c),h;var l=!n(o[0].getPoints());l=e?!l:l;var u,p,d=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)d[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],E=0;E0&&(x||(m=d))}v=0;for(var R=f.length;v0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var o=0;o!==n;++o)e[t+o]=e[i+o]},_slerp:function(e,t,i,r){bt.slerpFlat(e,t,e,t,e,i,r)},_lerp:function(e,t,i,r,n){for(var o=1-r,a=0;a!==n;++a){var s=t+a;e[s]=e[s]*o+e[i+a]*r}}}),Object.assign(as.prototype,{getValue:function(e,t){this.bind();var i=this._targetGroup.nCachedObjects_,r=this._bindings[i];void 0!==r&&r.getValue(e,t)},setValue:function(e,t){for(var i=this._bindings,r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}),Object.assign(ss,{Composite:as,create:function(e,t,i){return e&&e.isAnimationObjectGroup?new ss.Composite(e,t,i):new ss(e,t,i)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(/[^\w-]/g,"")},parseTrackName:(Wa=new RegExp("^"+/((?:[\w-]+[\/:])*)/.source+/([\w-\.]+)?/.source+/(?:\.([\w-]+)(?:\[(.+)\])?)?/.source+/\.([\w-]+)(?:\[(.+)\])?/.source+"$"),Xa=["material","materials","bones"],function(e){var t=Wa.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){var n=i.nodeName.substring(r+1);-1!==Xa.indexOf(n)&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=n)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=function(e){for(var i=0;i=t){var l=t++,u=e[l];i[u.uuid]=h,e[h]=u,i[c]=l,e[l]=s;for(var p=0,d=n;p!==d;++p){var f=r[p],m=f[l],g=f[h];f[h]=m,f[l]=g}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,i=this.nCachedObjects_,r=this._indicesByUUID,n=this._bindings,o=n.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a].uuid,h=r[c];if(void 0!==h)if(delete r[c],h0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(a),h[l].accumulate(r,s)}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var i=this._weightInterpolant;if(null!==i){var r=i.evaluate(e)[0];t*=r,e>i.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var i=this._timeScaleInterpolant;if(null!==i)t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var i=this._clip.duration,r=this.loop,n=this._loopCount;if(2200===r){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=i)t=i;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{var o=2202===r;if(-1===n&&(e>=0?(n=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),t>=i||t<0){var a=Math.floor(t/i);t-=i*a,n+=Math.abs(a);var s=this.repetitions-n;if(s<0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?i:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(0===s){var c=e<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&n))return this.time=t,i-t}return this.time=t,t},_setEndings:function(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=2401,r.endingEnd=2401):(r.endingStart=e?this.zeroSlopeAtStart?2401:nt:2402,r.endingEnd=t?this.zeroSlopeAtEnd?2401:nt:2402)},_scheduleFading:function(e,t,i){var r=this._mixer,n=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=n,s[0]=t,a[1]=n+e,s[1]=i,this}}),Object.assign(ls.prototype,i.prototype,{_bindAction:function(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,o=e._propertyBindings,a=e._interpolants,s=i.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var l=0;l!==n;++l){var u=r[l],p=u.name,d=h[p];if(void 0!==d)o[l]=d;else{if(void 0!==(d=o[l])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=t&&t._propertyBindings[l].binding.parsedPath;++(d=new os(ss.create(i,p,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),o[l]=d}a[l].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t)}for(var n=e._propertyBindings,o=0,a=n.length;o!==a;++o){var s=n[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,i=0,r=t.length;i!==r;++i){var n=t[i];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&t.99999?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(Qa.set(e.z,0,-e.x).normalize(),Za=Math.acos(e.y),this.quaternion.setFromAxisAngle(Qa,Za))}),Bs.prototype.setLength=function(e,t,i){void 0===t&&(t=.2*e),void 0===i&&(i=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()},Bs.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},zs.prototype=Object.create(yn.prototype),zs.prototype.constructor=zs;var Gs=new wt,Vs=new ks,Hs=new ks,js=new ks;function Ws(e,t,i,r){wa.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=i||"centripetal",this.tension=r||.5}function Xs(e,t,i,r){wa.call(this),this.type="CubicBezierCurve3",this.v0=e||new wt,this.v1=t||new wt,this.v2=i||new wt,this.v3=r||new wt}function qs(e,t,i){wa.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new wt,this.v1=t||new wt,this.v2=i||new wt}function Ys(e,t){wa.call(this),this.type="LineCurve3",this.v1=e||new wt,this.v2=t||new wt}function Zs(e,t,i,r,n,o){Ea.call(this,e,t,i,i,r,n,o),this.type="ArcCurve"}Ws.prototype=Object.create(wa.prototype),Ws.prototype.constructor=Ws,Ws.prototype.isCatmullRomCurve3=!0,Ws.prototype.getPoint=function(e,t){var i,r,n,o,a=t||new wt,s=this.points,c=s.length,h=(c-(this.closed?0:1))*e,l=Math.floor(h),u=h-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s.length)+1)*s.length:0===u&&l===c-1&&(l=c-2,u=1),this.closed||l>0?i=s[(l-1)%c]:(Gs.subVectors(s[0],s[1]).add(s[0]),i=Gs),r=s[l%c],n=s[(l+1)%c],this.closed||l+2>5&31)/31,r=(w>>10&31)/31):(t=o,i=a,r=s)}for(var _=1;_<=3;_++){var M=v+12*_;f.push(h.getFloat32(M,!0)),f.push(h.getFloat32(M+4,!0)),f.push(h.getFloat32(M+8,!0)),m.push(y,x,b),u&&n.push(t,i,r)}}return d.addAttribute("position",new rc.BufferAttribute(new Float32Array(f),3)),d.addAttribute("normal",new rc.BufferAttribute(new Float32Array(m),3)),u&&(d.addAttribute("color",new rc.BufferAttribute(new Float32Array(n),3)),d.hasColors=!0,d.alpha=c),d}(t):function(e){for(var t,i=new rc.BufferGeometry,r=/facet([\s\S]*?)endfacet/g,n=0,o=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,a=new RegExp("vertex"+o+o+o,"g"),s=new RegExp("normal"+o+o+o,"g"),c=[],h=[],l=new rc.Vector3;null!==(t=r.exec(e));){for(var u=0,p=0,d=t[0];null!==(t=s.exec(d));)l.x=parseFloat(t[1]),l.y=parseFloat(t[2]),l.z=parseFloat(t[3]),p++;for(;null!==(t=a.exec(d));)c.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),h.push(l.x,l.y,l.z),u++;1!==p&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+n),3!==u&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+n),n++}return i.addAttribute("position",new rc.Float32BufferAttribute(c,3)),i.addAttribute("normal",new rc.Float32BufferAttribute(h,3)),i}(function(e){if("string"!=typeof e){var t=new Uint8Array(e);if(void 0!==window.TextDecoder)return(new TextDecoder).decode(t);for(var i="",r=0,n=e.byteLength;r0&&t.push(new rc.VectorKeyframeTrack(r+".position",n,o)),a.length>0&&t.push(new rc.QuaternionKeyframeTrack(r+".quaternion",n,a)),s.length>0&&t.push(new rc.VectorKeyframeTrack(r+".scale",n,s)),t}function b(e,t,i){var r,n,o,a=!0;for(n=0,o=e.length;n=0;){var r=e[t];if(null!==r.value[i])return r;t--}return null}function _(e,t,i){for(;t0&&p.addAttribute("position",new rc.Float32BufferAttribute(n.array,n.stride)),o.array.length>0&&p.addAttribute("normal",new rc.Float32BufferAttribute(o.array,o.stride)),s.array.length>0&&p.addAttribute("color",new rc.Float32BufferAttribute(s.array,s.stride)),a.array.length>0&&p.addAttribute("uv",new rc.Float32BufferAttribute(a.array,a.stride)),c.length>0&&p.addAttribute("skinIndex",new rc.Float32BufferAttribute(c,h)),l.length>0&&p.addAttribute("skinWeight",new rc.Float32BufferAttribute(l,u)),r.data=p,r.type=e[0].type,r.materialKeys=d,r}function ie(e,t,i,r){var n=e.p,o=e.stride,a=e.vcount;function s(e){for(var t=n[e+i]*l,o=t+l;t0&&console.log("THREE.ColladaLoader: Geometry has faces with more than 4 vertices.")}else for(p=0,d=n.length;p=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ce(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},i=0;ir.limits.max||t0){var q=this.msgColor,Y=document.createElement("canvas"),Z=Y.getContext("2d");Z.font="normal 100px sans-serif";var Q=Z.measureText(i.text).width;Y.width=Q,Y.height=150,Z.font="normal 100px sans-serif",Z.fillStyle="rgba("+Math.round(255*q.r)+", "+Math.round(255*q.g)+", "+Math.round(255*q.b)+", "+q.a+")",Z.textAlign="left",Z.textBaseline="middle",Z.fillText(i.text,0,Y.height/2);var J=new rc.Texture(Y);J.needsUpdate=!0;var K=new rc.SpriteMaterial({map:J,useScreenCoordinates:!1}),$=new rc.Sprite(K),ee=i.scale.x;$.scale.set(Q/Y.height*ee,ee,1),this.add($)}break;case fc:var te=null;0===i.color.r&&0===i.color.g&&0===i.color.b&&0===i.color.a||(te=r),this.msgMesh=i.mesh_resource.substr(10);var ie=new Uc({path:t,resource:this.msgMesh,material:te});this.add(ie);break;case mc:var re=new Fc({material:r,vertices:i.points,colors:i.colors});re.scale.set(i.scale.x,i.scale.y,i.scale.z),this.add(re);break;default:console.error("Currently unsupported marker type: "+i.type)}}setPose(e){this.position.x=e.position.x,this.position.y=e.position.y,this.position.z=e.position.z,this.quaternion.set(e.orientation.x,e.orientation.y,e.orientation.z,e.orientation.w),this.quaternion.normalize(),this.updateMatrixWorld()}update(e){if(this.setPose(e.pose),e.color.r!==this.msgColor.r||e.color.g!==this.msgColor.g||e.color.b!==this.msgColor.b||e.color.a!==this.msgColor.a){var t=Pc(e.color.r,e.color.g,e.color.b,e.color.a);switch(e.type){case cc:case hc:case pc:break;case nc:case oc:case ac:case sc:case mc:case dc:this.traverse(function(e){e instanceof rc.Mesh&&(e.material=t)});break;case fc:var i=null;0===e.color.r&&0===e.color.g&&0===e.color.b&&0===e.color.a||(i=this.colorMaterial),this.traverse(function(e){e instanceof rc.Mesh&&(e.material=i)});break;case lc:case uc:default:return!1}this.msgColor=e.color}var r=Math.abs(this.msgScale[0]-e.scale.x)>1e-6||Math.abs(this.msgScale[1]-e.scale.y)>1e-6||Math.abs(this.msgScale[2]-e.scale.z)>1e-6;switch(this.msgScale=[e.scale.x,e.scale.y,e.scale.z],e.type){case oc:case ac:case sc:if(r)return!1;break;case dc:if(r||this.text!==e.text)return!1;break;case fc:if(e.mesh_resource.substr(10)!==this.msgMesh)return!1;if(r)return!1;break;case nc:case cc:case hc:case lc:case uc:case pc:case mc:return!1}return!0}dispose(){this.children.forEach(function(e){e instanceof Uc?e.children.forEach(function(t){void 0!==t.material&&t.material.dispose(),t.children.forEach(function(e){void 0!==e.geometry&&e.geometry.dispose(),void 0!==e.material&&e.material.dispose(),t.remove(e)}),e.remove(t)}):(void 0!==e.geometry&&e.geometry.dispose(),void 0!==e.material&&e.material.dispose()),e.parent.remove(e)})}}class zc extends rc.Object3D{constructor(e){super();var i=this;e=e||{},this.parent=e.parent;var r=e.handle,n=e.message;this.message=n,this.name=n.name,this.camera=e.camera,this.path=e.path||"/",this.loader=e.loader,this.dragging=!1,this.startMousePos=new rc.Vector2,this.isShift=!1;var o=new rc.Quaternion(n.orientation.x,n.orientation.y,n.orientation.z,n.orientation.w);o.normalize();var a=new rc.Vector3(1,0,0);switch(a.applyQuaternion(o),this.currentControlOri=new rc.Quaternion,n.interaction_mode){case Ac:case Sc:this.addEventListener("mousemove",this.parent.move3d.bind(this.parent,this,a));case Mc:this.addEventListener("mousemove",this.parent.moveAxis.bind(this.parent,this,a)),this.addEventListener("touchmove",this.parent.moveAxis.bind(this.parent,this,a));break;case Tc:this.addEventListener("mousemove",this.parent.rotateAxis.bind(this.parent,this,o));break;case Ec:this.addEventListener("mousemove",this.parent.movePlane.bind(this.parent,this,a));break;case _c:this.addEventListener("click",this.parent.buttonClick.bind(this.parent,this))}function s(e){e.stopPropagation()}n.interaction_mode!==wc&&(this.addEventListener("mousedown",this.parent.startDrag.bind(this.parent,this)),this.addEventListener("mouseup",this.parent.stopDrag.bind(this.parent,this)),this.addEventListener("contextmenu",this.parent.showMenu.bind(this.parent,this)),this.addEventListener("mouseup",function(e){0===i.startMousePos.distanceToSquared(e.mousePos)&&(e.type="contextmenu",i.dispatchEvent(e))}),this.addEventListener("mouseover",s),this.addEventListener("mouseout",s),this.addEventListener("click",s),this.addEventListener("mousedown",function(e){i.startMousePos=e.mousePos}),this.addEventListener("touchstart",function(e){1===e.domEvent.touches.length&&(e.type="mousedown",e.domEvent.button=0,i.dispatchEvent(e))}),this.addEventListener("touchmove",function(e){1===e.domEvent.touches.length&&(e.type="mousemove",e.domEvent.button=0,i.dispatchEvent(e))}),this.addEventListener("touchend",function(e){0===e.domEvent.touches.length&&(e.domEvent.button=0,e.type="mouseup",i.dispatchEvent(e),e.type="click",i.dispatchEvent(e))}),window.addEventListener("keydown",function(e){16===e.keyCode&&(i.isShift=!0)}),window.addEventListener("keyup",function(e){16===e.keyCode&&(i.isShift=!1)}));var c=new rc.Quaternion,h=this.parent.position.clone().multiplyScalar(-1);switch(n.orientation_mode){case Rc:c=this.parent.quaternion.clone().inverse();break;case Lc:case Cc:break;default:console.error("Unkown orientation mode: "+n.orientation_mode)}var l=new t.TFClient({ros:r.tfClient.ros,fixedFrame:r.message.header.frame_id,serverName:r.tfClient.serverName});n.markers.forEach(function(e){var r=function(r){var n=new Bc({message:e,path:i.path,loader:i.loader});if(null!==r){var o=new t.Pose({position:n.position,orientation:n.quaternion});o.applyTransform(new t.Transform(r));var a=new Bc({message:e,path:i.path,loader:i.loader});a.position.add(h),a.position.applyQuaternion(c),a.quaternion.multiplyQuaternions(c,a.quaternion);var s=new rc.Vector3(a.position.x,a.position.y,a.position.z),u=new t.Transform({translation:s,orientation:a.quaternion});o.applyTransform(u),n.setPose(o),n.updateMatrixWorld(),l.unsubscribe(e.header.frame_id)}i.add(n)};""!==e.header.frame_id?l.subscribe(e.header.frame_id,r):r(null)})}updateMatrixWorld(e){var t=this.message;switch(t.orientation_mode){case Rc:super.updateMatrixWorld(e),this.currentControlOri.copy(this.quaternion),this.currentControlOri.normalize();break;case Lc:this.quaternion.copy(this.parent.quaternion.clone().inverse()),this.updateMatrix(),this.matrixWorldNeedsUpdate=!0,super.updateMatrixWorld(e),this.currentControlOri.copy(this.quaternion);break;case Cc:this.camera.updateMatrixWorld();var i=(new rc.Matrix4).extractRotation(this.camera.matrixWorld),r=new rc.Matrix4,n=.5*Math.PI,o=new rc.Euler(-n,0,n);r.makeRotationFromEuler(o);var a=new rc.Matrix4;a.getInverse(this.parent.matrixWorld),i.multiplyMatrices(i,r),i.multiplyMatrices(a,i),this.currentControlOri.setFromRotationMatrix(i),t.independent_marker_orientation||(this.quaternion.copy(this.currentControlOri),this.updateMatrix(),this.matrixWorldNeedsUpdate=!0),super.updateMatrixWorld(e);break;default:console.error("Unkown orientation mode: "+t.orientation_mode)}}}class kc extends rc.EventDispatcher{constructor(e){super();var t,i,r,n=this,o=(e=e||{}).menuEntries,a=e.className||"default-interactive-marker-menu",s=(e.entryClassName,e.overlayClassName||"default-interactive-marker-overlay"),c=e.menuFontSize||"0.8em",h=[];if(h[0]={children:[]},null===document.getElementById("default-interactive-marker-menu-css")){var l=document.createElement("style");l.id="default-interactive-marker-menu-css",l.type="text/css",l.innerHTML=".default-interactive-marker-menu {background-color: #444444;border: 1px solid #888888;border: 1px solid #888888;padding: 0px 0px 0px 0px;color: #FFFFFF;font-family: sans-serif;font-size: "+c+";z-index: 1002;}.default-interactive-marker-menu ul {padding: 0px 0px 5px 0px;margin: 0px;list-style-type: none;}.default-interactive-marker-menu ul li div {-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;cursor: default;padding: 3px 10px 3px 10px;}.default-interactive-marker-menu-entry:hover { background-color: #666666; cursor: pointer;}.default-interactive-marker-menu ul ul { font-style: italic; padding-left: 10px;}.default-interactive-marker-overlay { position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index: 1001; -moz-opacity: 0.0; opacity: .0; filter: alpha(opacity = 0);}",document.getElementsByTagName("head")[0].appendChild(l)}for(this.menuDomElem=document.createElement("div"),this.menuDomElem.style.position="absolute",this.menuDomElem.className=a,this.menuDomElem.addEventListener("contextmenu",function(e){e.preventDefault()}),this.overlayDomElem=document.createElement("div"),this.overlayDomElem.className=s,this.hideListener=this.hide.bind(this),this.overlayDomElem.addEventListener("contextmenu",this.hideListener),this.overlayDomElem.addEventListener("click",this.hideListener),this.overlayDomElem.addEventListener("touchstart",this.hideListener),t=0;t0?(e(s,o[a]),c.addEventListener("click",n.hide.bind(n)),c.addEventListener("touchstart",n.hide.bind(n))):(c.addEventListener("click",p.bind(n,o[a])),c.addEventListener("touchstart",p.bind(n,o[a])),c.className="default-interactive-marker-menu-entry")}}(this.menuDomElem,h[0])}show(e,t){t&&t.preventDefault&&t.preventDefault(),this.controlName=e.name,void 0!==t.domEvent.changedTouches?(this.menuDomElem.style.left=t.domEvent.changedTouches[0].pageX+"px",this.menuDomElem.style.top=t.domEvent.changedTouches[0].pageY+"px"):(this.menuDomElem.style.left=t.domEvent.clientX+"px",this.menuDomElem.style.top=t.domEvent.clientY+"px"),document.body.appendChild(this.overlayDomElem),document.body.appendChild(this.menuDomElem)}hide(e){e&&e.preventDefault&&e.preventDefault(),document.body.removeChild(this.overlayDomElem),document.body.removeChild(this.menuDomElem)}}class Gc extends rc.Object3D{constructor(e){super();var t=this,i=(e=e||{}).handle;this.name=i.name;var r=e.camera,n=e.path||"/",o=e.loader;this.dragging=!1,this.onServerSetPose({pose:i.pose}),this.dragStart={position:new rc.Vector3,orientation:new rc.Quaternion,positionWorld:new rc.Vector3,orientationWorld:new rc.Quaternion,event3d:{}},i.controls.forEach(function(e){t.add(new zc({parent:t,handle:i,message:e,camera:r,path:n,loader:o}))}),i.menuEntries.length>0&&(this.menu=new kc({menuEntries:i.menuEntries,menuFontSize:i.menuFontSize}),this.menu.addEventListener("menu-select",function(e){t.dispatchEvent(e)}))}showMenu(e,t){this.menu&&this.menu.show(e,t)}moveAxis(e,t,i){if(this.dragging){var r=e.currentControlOri,n=t.clone().applyQuaternion(r),o=this.dragStart.event3d.intersection.point,a=n.clone().applyQuaternion(this.dragStart.orientationWorld.clone()),s=new rc.Ray(o,a),c=Oc(s,i.camera,i.mousePos),h=new rc.Vector3;h.addVectors(this.dragStart.position,n.clone().applyQuaternion(this.dragStart.orientation).multiplyScalar(c)),this.setPosition(e,h),i.stopPropagation()}}move3d(e,t,i){if(this.dragging)if(e.isShift);else{var r=e.camera.getWorldDirection(),n=Math.abs(r.x),o=Math.abs(r.y),a=Math.abs(r.z),s=new rc.Quaternion(1,0,0,1);o>n&&o>a?s=new rc.Quaternion(0,0,1,1):a>n&&a>o&&(s=new rc.Quaternion(0,1,0,1)),s.normalize(),(t=new rc.Vector3(1,0,0)).applyQuaternion(s),this.movePlane(e,t,i)}}movePlane(e,t,i){if(this.dragging){var r=e.currentControlOri,n=t.clone().applyQuaternion(r),o=this.dragStart.event3d.intersection.point,a=n.clone().applyQuaternion(this.dragStart.orientationWorld),s=Nc(i.mouseRay,o,a),c=new rc.Vector3;c.subVectors(s,o),c.add(this.dragStart.positionWorld),this.setPosition(e,c),i.stopPropagation()}}rotateAxis(e,t,i){if(this.dragging){e.updateMatrixWorld();var r=e.currentControlOri.clone().multiply(t.clone()),n=new rc.Vector3(1,0,0).applyQuaternion(r),o=this.dragStart.event3d.intersection.point,a=n.applyQuaternion(this.dragStart.orientationWorld),s=Nc(i.mouseRay,o,a),c=new rc.Ray(this.dragStart.positionWorld,a),h=Nc(c,o,a),l=this.dragStart.orientationWorld.clone().multiply(r).clone().inverse();s.sub(h),s.applyQuaternion(l);var u=this.dragStart.event3d.intersection.point.clone();u.sub(h),u.applyQuaternion(l);var p=Math.atan2(s.y,s.z),d=Math.atan2(u.y,u.z)-p,f=new rc.Quaternion;f.setFromAxisAngle(n,d),this.setOrientation(e,f.multiply(this.dragStart.orientationWorld)),i.stopPropagation()}}feedbackEvent(e,t){this.dispatchEvent({type:e,position:this.position.clone(),orientation:this.quaternion.clone(),controlName:t.name})}startDrag(e,t){if(0===t.domEvent.button){t.stopPropagation(),this.dragging=!0,this.updateMatrixWorld(!0);var i=new rc.Vector3;this.matrixWorld.decompose(this.dragStart.positionWorld,this.dragStart.orientationWorld,i),this.dragStart.position=this.position.clone(),this.dragStart.orientation=this.quaternion.clone(),this.dragStart.event3d=t,this.feedbackEvent("user-mousedown",e)}}stopDrag(e,t){0===t.domEvent.button&&(t.stopPropagation(),this.dragging=!1,this.dragStart.event3d={},this.onServerSetPose(this.bufferedPoseEvent),this.bufferedPoseEvent=void 0,this.feedbackEvent("user-mouseup",e))}buttonClick(e,t){t.stopPropagation(),this.feedbackEvent("user-button-click",e)}setPosition(e,t){this.position.copy(t),this.feedbackEvent("user-pose-change",e)}setOrientation(e,t){t.normalize(),this.quaternion.copy(t),this.feedbackEvent("user-pose-change",e)}onServerSetPose(e){if(void 0!==e)if(this.dragging)this.bufferedPoseEvent=e;else{var t=e.pose;this.position.copy(t.position),this.quaternion.copy(t.orientation),this.updateMatrixWorld(!0)}}dispose(){var e=this;this.children.forEach(function(t){t.children.forEach(function(e){e.dispose(),t.remove(e)}),e.remove(t)})}}var Vc,Hc=(function(e,t){!function(t){var i=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r=10;function n(){this._events={},this._conf&&o.call(this,this._conf)}function o(e){e?(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),this._events.maxListeners=e.maxListeners!==t?e.maxListeners:r,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this.newListener=e.newListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._events.maxListeners=r}function a(e,t){var i="(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.";this.verboseMemoryLeak?(i+=" Event name: %s.",console.error(i,e,t)):console.error(i,e),console.trace&&console.trace()}function s(e){this._events={},this.newListener=!1,this.verboseMemoryLeak=!1,o.call(this,e)}function c(e,t,i,r){if(!i)return[];var n,o,a,s,h,l,u,p=[],d=t.length,f=t[r],m=t[r+1];if(r===d&&i._listeners){if("function"==typeof i._listeners)return e&&e.push(i._listeners),[i];for(n=0,o=i._listeners.length;n3)for(t=new Array(s),o=0;o3)for(t=new Array(s-1),o=1;o3)for(t=new Array(h),o=1;o3)for(t=new Array(h-1),o=1;o0&&o._listeners.length>this._events.maxListeners&&(o._listeners.warned=!0,a.call(this,o._listeners.length,s))):o._listeners=i,!0;s=e.shift()}return!0}.call(this,e,i),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),this._events[e].push(i),!this._events[e].warned&&this._events.maxListeners>0&&this._events[e].length>this._events.maxListeners&&(this._events[e].warned=!0,a.call(this,this._events[e].length,e))):this._events[e]=i,this)},s.prototype.onAny=function(e){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),this._all.push(e),this},s.prototype.addListener=s.prototype.on,s.prototype.off=function(e,r){if("function"!=typeof r)throw new Error("removeListener only takes instances of Function");var n,o=[];if(this.wildcard){var a="string"==typeof e?e.split(this.delimiter):e.slice();o=c.call(this,null,a,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],o.push({_listeners:n})}for(var s=0;s0&&e(i[o]),0===Object.keys(a).length&&delete i[o])}}}(this.listenerTree),this},s.prototype.offAny=function(e){var t,i=0,r=0;if(e&&this._all&&this._all.length>0){for(i=0,r=(t=this._all).length;i=8&&(a-=8,t[s++]=o>>>a&255,s%i==0&&(n+=Math.ceil((l-a)/6),(a%=8)>0&&(o=Zc.e[e.charAt(n)])));return Math.floor(s/i)}Zc.S="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zc.e={};for(var Qc=0;Qc<64;Qc++)Zc.e[Zc.S.charAt(Qc)]=Qc;class Jc extends rc.Object3D{constructor(e){var i=(e=e||{}).urdfModel,r=e.path||"/",n=e.tfClient,o=e.tfPrefix||"",a=e.loader;super();var s=i.links;for(var c in s)for(var h=s[c],l=0;l0?(r=f[0].object,d.intersection=this.lastIntersection=f[0]):r=this.fallbackTarget,r!==this.lastTarget&&e.type.match(/mouse/)){var m=this.notify(r,"mouseover",d);0===m?this.notify(this.lastTarget,"mouseout",d):1===m&&(r=this.fallbackTarget)!==this.lastTarget&&(this.notify(r,"mouseover",d),this.notify(this.lastTarget,"mouseout",d))}r!==this.lastTarget&&e.type.match(/touch/)&&(this.notify(r,e.type,d)?(this.notify(this.lastTarget,"touchleave",d),this.notify(this.lastTarget,"touchend",d)):(r=this.fallbackTarget)!==this.lastTarget&&(this.notify(this.lastTarget,"touchmove",d),this.notify(this.lastTarget,"touchend",d)));this.notify(r,e.type,d),"mousedown"!==e.type&&"touchstart"!==e.type&&"touchmove"!==e.type||(this.dragging=!0),this.lastTarget=r}notify(e,t,i){for(i.type=t,i.cancelBubble=!1,i.continueBubble=!1,i.stopPropagation=function(){i.cancelBubble=!0},i.continuePropagation=function(){i.continueBubble=!0},i.currentTarget=e;i.currentTarget;){if(i.currentTarget.dispatchEvent&&i.currentTarget.dispatchEvent instanceof Function){if(i.currentTarget.dispatchEvent(i),i.cancelBubble)return this.dispatchEvent(i),0;if(i.continueBubble)return 2}i.currentTarget=i.currentTarget.parent}return 1}}class eh extends rc.EventDispatcher{constructor(e){super();var t=this,i=(e=e||{}).scene;this.camera=e.camera,this.center=new rc.Vector3,this.userZoom=!0,this.userZoomSpeed=e.userZoomSpeed||1,this.userRotate=!0,this.userRotateSpeed=e.userRotateSpeed||1,this.autoRotate=e.autoRotate,this.autoRotateSpeed=e.autoRotateSpeed||2,this.camera.up=new rc.Vector3(0,0,1);var r=1800,n=10,o=new rc.Vector2,a=new rc.Vector2,s=new rc.Vector2,c=new rc.Vector2,h=new rc.Vector2,l=new rc.Vector2,u=new rc.Vector3,p=new rc.Vector3,d=new rc.Vector3,f=new rc.Vector3,m=new Array(2),g=new Array(2);this.phiDelta=0,this.thetaDelta=0,this.scale=1,this.lastPosition=new rc.Vector3;var v={NONE:-1,ROTATE:0,ZOOM:1,MOVE:2},y=v.NONE;function x(e,t,i){var r=new rc.Vector3;new rc.Vector3;r.subVectors(t,e.origin);var n=e.direction.dot(i);if(Math.abs(n)0?t.zoomIn():t.zoomOut(),this.showAxes()}}this.axes=new Xc({shaftRadius:.025,headRadius:.07,headLength:.2}),i.add(this.axes),this.axes.traverse(function(e){e.visible=!1}),this.addEventListener("mousedown",function(e){var i=e.domEvent;switch(i.preventDefault(),i.button){case 0:y=v.ROTATE,o.set(i.clientX,i.clientY);break;case 1:y=v.MOVE,p=new rc.Vector3(0,0,1);var r=(new rc.Matrix4).extractRotation(this.camera.matrix);p.applyMatrix4(r),u=t.center.clone(),d=t.camera.position.clone(),f=x(e.mouseRay,u,p);break;case 2:y=v.ZOOM,c.set(i.clientX,i.clientY)}this.showAxes()}),this.addEventListener("mouseup",function(e){t.userRotate&&(y=v.NONE)}),this.addEventListener("mousemove",function(e){var i=e.domEvent;if(y===v.ROTATE)a.set(i.clientX,i.clientY),s.subVectors(a,o),t.rotateLeft(2*Math.PI*s.x/r*t.userRotateSpeed),t.rotateUp(2*Math.PI*s.y/r*t.userRotateSpeed),o.copy(a),this.showAxes();else if(y===v.ZOOM)h.set(i.clientX,i.clientY),l.subVectors(h,c),l.y>0?t.zoomIn():t.zoomOut(),c.copy(h),this.showAxes();else if(y===v.MOVE){var n=x(e.mouseRay,t.center,p);if(!n)return;var m=(new rc.Vector3).subVectors(f.clone(),n.clone());t.center.addVectors(u.clone(),m.clone()),t.camera.position.addVectors(d.clone(),m.clone()),t.update(),t.camera.updateMatrixWorld(),this.showAxes()}}),this.addEventListener("touchstart",function(e){var i=e.domEvent;switch(i.touches.length){case 1:y=v.ROTATE,o.set(i.touches[0].pageX-window.scrollX,i.touches[0].pageY-window.scrollY);break;case 2:y=v.NONE,p=new rc.Vector3(0,0,1);var r=(new rc.Matrix4).extractRotation(this.camera.matrix);p.applyMatrix4(r),u=t.center.clone(),d=t.camera.position.clone(),f=x(e.mouseRay,u,p),m[0]=new rc.Vector2(i.touches[0].pageX,i.touches[0].pageY),m[1]=new rc.Vector2(i.touches[1].pageX,i.touches[1].pageY),g[0]=new rc.Vector2(0,0),g[1]=new rc.Vector2(0,0)}this.showAxes(),i.preventDefault()}),this.addEventListener("touchmove",function(e){var i=e.domEvent;if(y===v.ROTATE)a.set(i.touches[0].pageX-window.scrollX,i.touches[0].pageY-window.scrollY),s.subVectors(a,o),t.rotateLeft(2*Math.PI*s.x/r*t.userRotateSpeed),t.rotateUp(2*Math.PI*s.y/r*t.userRotateSpeed),o.copy(a),this.showAxes();else{if(g[0].set(m[0].x-i.touches[0].pageX,m[0].y-i.touches[0].pageY),g[1].set(m[1].x-i.touches[1].pageX,m[1].y-i.touches[1].pageY),g[0].lengthSq()>n&&g[1].lengthSq()>n&&(m[0].set(i.touches[0].pageX,i.touches[0].pageY),m[1].set(i.touches[1].pageX,i.touches[1].pageY),g[0].dot(g[1])>0&&y!==v.ZOOM?y=v.MOVE:g[0].dot(g[1])<0&&y!==v.MOVE&&(y=v.ZOOM),y===v.ZOOM)){var c=new rc.Vector2;c.subVectors(m[0],m[1]),g[0].dot(c)<0&&g[1].dot(c)>0?t.zoomOut():g[0].dot(c)>0&&g[1].dot(c)<0&&t.zoomIn()}if(y===v.MOVE){var h=x(e.mouseRay,t.center,p);if(!h)return;var l=(new rc.Vector3).subVectors(f.clone(),h.clone());t.center.addVectors(u.clone(),l.clone()),t.camera.position.addVectors(d.clone(),l.clone()),t.update(),t.camera.updateMatrixWorld()}this.showAxes(),i.preventDefault()}}),this.addEventListener("touchend",function(e){var t=e.domEvent;1===t.touches.length&&y!==v.ROTATE?(y=v.ROTATE,o.set(t.touches[0].pageX-window.scrollX,t.touches[0].pageY-window.scrollY)):y=v.NONE}),this.addEventListener("mousewheel",b),this.addEventListener("DOMMouseScroll",b)}showAxes(){var e=this;this.axes.traverse(function(e){e.visible=!0}),this.hideTimeout&&clearTimeout(this.hideTimeout),this.hideTimeout=setTimeout(function(){e.axes.traverse(function(e){e.visible=!1}),e.hideTimeout=!1},1e3)}rotateLeft(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.thetaDelta-=e}rotateRight(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.thetaDelta+=e}rotateUp(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.phiDelta-=e}rotateDown(e){void 0===e&&(e=2*Math.PI/60/60*this.autoRotateSpeed),this.phiDelta+=e}zoomIn(e){void 0===e&&(e=Math.pow(.95,this.userZoomSpeed)),this.scale/=e}zoomOut(e){void 0===e&&(e=Math.pow(.95,this.userZoomSpeed)),this.scale*=e}update(){var e=this.camera.position,t=e.clone().sub(this.center),i=Math.atan2(t.y,t.x),r=Math.atan2(Math.sqrt(t.y*t.y+t.x*t.x),t.z);this.autoRotate&&this.rotateLeft(2*Math.PI/60/60*this.autoRotateSpeed),i+=this.thetaDelta,r+=this.phiDelta;r=Math.max(1e-6,Math.min(Math.PI-1e-6,r));var n=t.length();t.set(n*Math.sin(r)*Math.cos(i),n*Math.sin(r)*Math.sin(i),n*Math.cos(r)),t.multiplyScalar(this.scale),e.copy(this.center).add(t),this.camera.lookAt(this.center),n=t.length(),this.axes.position.copy(this.center),this.axes.scale.set(.05*n,.05*n,.05*n),this.axes.updateMatrixWorld(!0),this.thetaDelta=0,this.phiDelta=0,this.scale=1,this.lastPosition.distanceTo(this.camera.position)>0&&(this.dispatchEvent({type:"change"}),this.lastPosition.copy(this.camera.position))}}return e.REVISION="0.18.0",e.MARKER_ARROW=nc,e.MARKER_CUBE=oc,e.MARKER_SPHERE=ac,e.MARKER_CYLINDER=sc,e.MARKER_LINE_STRIP=cc,e.MARKER_LINE_LIST=hc,e.MARKER_CUBE_LIST=lc,e.MARKER_SPHERE_LIST=uc,e.MARKER_POINTS=pc,e.MARKER_TEXT_VIEW_FACING=dc,e.MARKER_MESH_RESOURCE=fc,e.MARKER_TRIANGLE_LIST=mc,e.INTERACTIVE_MARKER_KEEP_ALIVE=0,e.INTERACTIVE_MARKER_POSE_UPDATE=gc,e.INTERACTIVE_MARKER_MENU_SELECT=vc,e.INTERACTIVE_MARKER_BUTTON_CLICK=yc,e.INTERACTIVE_MARKER_MOUSE_DOWN=xc,e.INTERACTIVE_MARKER_MOUSE_UP=bc,e.INTERACTIVE_MARKER_NONE=wc,e.INTERACTIVE_MARKER_MENU=1,e.INTERACTIVE_MARKER_BUTTON=_c,e.INTERACTIVE_MARKER_MOVE_AXIS=Mc,e.INTERACTIVE_MARKER_MOVE_PLANE=Ec,e.INTERACTIVE_MARKER_ROTATE_AXIS=Tc,e.INTERACTIVE_MARKER_MOVE_ROTATE=6,e.INTERACTIVE_MARKER_MOVE_3D=Sc,e.INTERACTIVE_MARKER_ROTATE_3D=8,e.INTERACTIVE_MARKER_MOVE_ROTATE_3D=Ac,e.INTERACTIVE_MARKER_INHERIT=Rc,e.INTERACTIVE_MARKER_FIXED=Lc,e.INTERACTIVE_MARKER_VIEW_FACING=Cc,e.makeColorMaterial=Pc,e.intersectPlane=Nc,e.findClosestPoint=Ic,e.closestAxisPoint=Oc,e.DepthCloud=class extends rc.Object3D{constructor(e){super(),e=e||{},this.url=e.url,this.streamType=e.streamType||"vp8",this.f=e.f||526,this.maxDepthPerTile=e.maxDepthPerTile||1,this.pointSize=e.pointSize||3,this.width=e.width||1024,this.height=e.height||1024,this.resolutionFactor=Math.max(this.width,this.height)/1024,this.whiteness=e.whiteness||0,this.varianceThreshold=e.varianceThreshold||16667e-9,this.isMjpeg="mjpeg"===this.streamType.toLowerCase(),this.video=document.createElement(this.isMjpeg?"img":"video"),this.video.addEventListener(this.isMjpeg?"load":"loadedmetadata",this.metaLoaded.bind(this),!1),this.isMjpeg||(this.video.loop=!0),this.video.src=this.url,this.video.crossOrigin="Anonymous",this.video.setAttribute("crossorigin","Anonymous"),this.vertex_shader=["uniform sampler2D map;","","uniform float width;","uniform float height;","uniform float nearClipping, farClipping;","","uniform float pointSize;","uniform float zOffset;","","uniform float focallength;","uniform float maxDepthPerTile;","uniform float resolutionFactor;","","varying vec2 vUvP;","varying vec2 colorP;","","varying float depthVariance;","varying float maskVal;","","float sampleDepth(vec2 pos)"," {"," float depth;"," "," vec2 vUv = vec2( pos.x / (width*2.0), pos.y / (height*2.0)+0.5 );"," vec2 vUv2 = vec2( pos.x / (width*2.0)+0.5, pos.y / (height*2.0)+0.5 );"," "," vec4 depthColor = texture2D( map, vUv );"," "," depth = ( depthColor.r + depthColor.g + depthColor.b ) / 3.0 ;"," "," if (depth>0.99)"," {"," vec4 depthColor2 = texture2D( map, vUv2 );"," float depth2 = ( depthColor2.r + depthColor2.g + depthColor2.b ) / 3.0 ;"," depth = 0.99+depth2;"," }"," "," return depth;"," }","","float median(float a, float b, float c)"," {"," float r=a;"," "," if ( (a0.5) || (vUvP.y<0.5) || (vUvP.y>0.0))"," {"," vec2 smp = decodeDepth(vec2(position.x, position.y));"," float depth = smp.x;"," depthVariance = smp.y;"," "," float z = -depth;"," "," pos = vec4("," ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength) * -1.0,"," ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength),"," (- z + zOffset / 1000.0) * maxDepthPerTile,"," 1.0);"," "," vec2 maskP = vec2( position.x / (width*2.0), position.y / (height*2.0) );"," vec4 maskColor = texture2D( map, maskP );"," maskVal = ( maskColor.r + maskColor.g + maskColor.b ) / 3.0 ;"," }"," "," gl_PointSize = pointSize;"," gl_Position = projectionMatrix * modelViewMatrix * pos;"," ","}"].join("\n"),this.fragment_shader=["uniform sampler2D map;","uniform float varianceThreshold;","uniform float whiteness;","","varying vec2 vUvP;","varying vec2 colorP;","","varying float depthVariance;","varying float maskVal;","","","void main() {"," "," vec4 color;"," "," if ( (depthVariance>varianceThreshold) || (maskVal>0.5) ||(vUvP.x<0.0)|| (vUvP.x>0.5) || (vUvP.y<0.5) || (vUvP.y>1.0))"," { "," discard;"," }"," else "," {"," color = texture2D( map, colorP );"," "," float fader = whiteness /100.0;"," "," color.r = color.r * (1.0-fader)+ fader;"," "," color.g = color.g * (1.0-fader)+ fader;"," "," color.b = color.b * (1.0-fader)+ fader;"," "," color.a = 1.0;//smoothstep( 20000.0, -20000.0, gl_FragCoord.z / gl_FragCoord.w );"," }"," "," gl_FragColor = vec4( color.r, color.g, color.b, color.a );"," ","}"].join("\n")}metaLoaded(){this.metaLoaded=!0,this.initStreamer()}initStreamer(){if(this.metaLoaded){this.texture=new rc.Texture(this.video),this.geometry=new rc.Geometry;for(var e=0,t=this.width*this.height;e=this.keep&&(this.sns[0].unsubscribeTf(),this.rootObject.remove(this.sns[0]),this.sns.shift()),this.options.origin=new rc.Vector3(e.pose.pose.position.x,e.pose.pose.position.y,e.pose.pose.position.z);var t=new rc.Quaternion(e.pose.pose.orientation.x,e.pose.pose.orientation.y,e.pose.pose.orientation.z,e.pose.pose.orientation.w);this.options.direction=new rc.Vector3(1,0,0),this.options.direction.applyQuaternion(t),this.options.material=new rc.MeshBasicMaterial({color:this.color});var i=new Dc(this.options);this.sns.push(new Wc({frameID:e.header.frame_id,tfClient:this.tfClient,object:i})),this.rootObject.add(this.sns[this.sns.length-1])}},e.Path=class extends rc.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/path",this.tfClient=e.tfClient,this.color=e.color||13369599,this.rootObject=e.rootObject||new rc.Object3D,this.sn=null,this.line=null,this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new t.Topic({ros:this.ros,name:this.topicName,messageType:"nav_msgs/Path"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){null!==this.sn&&(this.sn.unsubscribeTf(),this.rootObject.remove(this.sn));for(var t=new rc.Geometry,i=0;i=e.range_min&&n<=e.range_max){var o=e.angle_min+r*e.angle_increment;this.points.positions.array[i++]=n*Math.cos(o),this.points.positions.array[i++]=n*Math.sin(o),this.points.positions.array[i++]=0}}this.points.update(i/3)}}},e.Points=Yc,e.PointCloud2=class extends rc.Object3D{constructor(e){super(),e=e||{},this.ros=e.ros,this.topicName=e.topic||"/points",this.points=new Yc(e),this.rosTopic=void 0,this.subscribe()}unsubscribe(){this.rosTopic&&this.rosTopic.unsubscribe()}subscribe(){this.unsubscribe(),this.rosTopic=new t.Topic({ros:this.ros,name:this.topicName,messageType:"sensor_msgs/PointCloud2"}),this.rosTopic.subscribe(this.processMessage.bind(this))}processMessage(e){if(this.points.setup(e.header.frame_id,e.point_step,e.fields)){var t,i=this.points.pointRatio;e.data.buffer?(this.points.buffer=e.data.buffer,t=e.height*e.width/i):(t=Zc(e.data,this.points.buffer,e.point_step,i),i=1);for(var r,n,o=new DataView(this.points.buffer.buffer),a=!e.is_bigendian,s=this.points.fields.x.offset,c=this.points.fields.y.offset,h=this.points.fields.z.offset,l=0;l