diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a169d7d..20dde6c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,13 @@ Minor version by [@jscastro76](https://github.com/jscastro76), some enhancements #### :sparkles: Enhancements - #224 Ignore worker_threads - #223 Can't resolve worker threads - +- #146 Update to Mapbox 2.2 + - #225 Mapbox 2.2: Update Depth calculation keeping compatibility with previous versions + - #226 Mapbox 2.2: Update all the examples (14-buildingshadow & 17-azuremaps not updated) + +#### :pencil: Documentation +- Updated [documentation](/examples/readme.md) (Added a note on the examples updated to Mapbox 2.2.0) + - - - ## 2.2.1 diff --git a/README.md b/README.md index 15ecc30e..8f15ffdc 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![NPM license](http://img.shields.io/npm/l/threebox-plugin.svg?style=flat-square)](https://www.npmjs.org/package/threebox-plugin) ![npm](https://img.shields.io/npm/dt/threebox-plugin?style=social) -A **[*Three.js*](https://threejs.org/) (r127)** plugin for **[*Mapbox GL JS*](https://docs.mapbox.com/mapbox-gl-js/examples/)** and **[*Azure Maps*](https://azure.microsoft.com/en-us/services/azure-maps/)** using the [`CustomLayerInterface`](https://docs.mapbox.com/mapbox-gl-js/api/properties/#customlayerinterface) feature. Provides convenient methods to manage objects in lnglat coordinates, and to synchronize the map and scene cameras. +A **[*Three.js*](https://threejs.org/)** plugin for **[*Mapbox GL JS*](https://docs.mapbox.com/mapbox-gl-js/examples/)** and **[*Azure Maps*](https://azure.microsoft.com/en-us/services/azure-maps/)** using the [`CustomLayerInterface`](https://docs.mapbox.com/mapbox-gl-js/api/properties/#customlayerinterface) feature. Provides convenient methods to manage objects in lnglat coordinates, and to synchronize the map and scene cameras. threebox
@@ -52,8 +52,8 @@ npm i threebox-plugin Only in this fork, there is a list of new features implemented on top of the amazing work from [@peterqliu](https://github.com/peterqliu/threebox/): - Updated to **Three.js r127**. -- Updated to Mapbox-gl-js v1.11.1. -- Updated to Azure Maps v2.0.31. +- Updated to **Mapbox-gl-js v2.2.0**. +- Updated to **Azure Maps v2.0.31**. - [+20 examples](https://github.com/jscastro76/threebox/tree/master/examples) with all the new features. - Support for multiple 3D format objects (FBX, GLTF/GLB, Collada, OBJ/MTL). - Support for 3D extruded shapes from [GeoJson](https://geojson.org/) features or points array. @@ -99,9 +99,9 @@ All the [**Threebox Documentation**](/docs/Threebox.md) has been completely upda ## Compatibility/Dependencies -- **Three.js r127** (already bundled into the Threebox build). If desired, other versions can be swapped in and rebuilt [here](https://github.com/jscastro76/threebox/blob/master/src/three.js), though compatibility is not guaranteed. -- Mapbox-gl-js v1.11.1. -- Azure Maps v2.0.31. +- **Three.js r127**. (already bundled into the Threebox build). If desired, other versions can be swapped in and rebuilt [here](https://github.com/jscastro76/threebox/blob/master/src/three.js), though compatibility is not guaranteed. **(WARNING: v118.3 breaks compatibility in some cases)** +- **Mapbox-gl-js v1.11.1. or v.2.0.1** +- **Azure Maps v2.0.31.**
diff --git a/dist/threebox.js b/dist/threebox.js index b464d007..b728edf5 100755 --- a/dist/threebox.js +++ b/dist/threebox.js @@ -1863,19 +1863,46 @@ CameraSync.prototype = { return; } - // Furthest distance optimized by @jscastro76 const t = this.map.transform; + let farZ = 0; + let furthestDistance = 0; + this.state.fov = t._fov; + this.halfFov = this.state.fov / 2; const groundAngle = Math.PI / 2 + t._pitch; - this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height; - this.state.cameraTranslateZ = new THREE.Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance); - const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.state.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov); const pitchAngle = Math.cos((Math.PI / 2) - t._pitch); //pitch seems to influence heavily the depth calculation and cannot be more than 60 = PI/3 + this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height; + + if (window.mapboxgl && parseFloat(window.mapboxgl.version) >= 2.0) { + // mapbox version >= 2.0 + const worldSize = this.worldSize(t); + const pixelsPerMeter = this.mercatorZfromAltitude(1, t.center.lat) * worldSize; + const fovAboveCenter = this.fovAboveCenter(t); + + // Adjust distance to MSL by the minimum possible elevation visible on screen, + // this way the far plane is pushed further in the case of negative elevation. + const minElevationInPixels = 0; // TODO test with elevation exageration this.elevation ? this.elevation.getMinElevationBelowMSL() * pixelsPerMeter : 0; + const cameraToSeaLevelDistance = ((t._camera.position[2] * worldSize) - minElevationInPixels) / Math.cos(t._pitch); + const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(utils.clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01)); + + // Calculate z distance of the farthest fragment that should be rendered. + furthestDistance = pitchAngle * topHalfSurfaceDistance + cameraToSeaLevelDistance; + + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + const horizonDistance = cameraToSeaLevelDistance * (1 / t._horizonShift); + farZ = Math.min(furthestDistance * 1.01, horizonDistance); + } else { + // mapbox version < 2.0 or azure maps + // Furthest distance optimized by @jscastro76 + const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.state.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov); + + // Calculate z distance of the farthest fragment that should be rendered. + furthestDistance = pitchAngle * topHalfSurfaceDistance + this.state.cameraToCenterDistance; - // Calculate z distance of the farthest fragment that should be rendered. - const furthestDistance = pitchAngle * topHalfSurfaceDistance + this.state.cameraToCenterDistance; + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + farZ = furthestDistance * 1.01; - // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` - const farZ = furthestDistance * 1.01; + } + this.state.cameraTranslateZ = new THREE.Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance); // someday @ansis set further near plane to fix precision for deckgl,so we should fix it to use mapbox-gl v1.3+ correctly // https://github.com/mapbox/mapbox-gl-js/commit/5cf6e5f523611bea61dae155db19a7cb19eb825c#diff-5dddfe9d7b5b4413ee54284bc1f7966d @@ -1913,8 +1940,26 @@ CameraSync.prototype = { .premultiply(scale) .premultiply(translateMap) + // utils.prettyPrintMatrix(this.camera.projectionMatrix.elements); + this.map.fire('CameraSynced', { detail: { nearZ: nearZ, farZ: farZ, pitch: t._pitch, angle: t.angle, furthestDistance: furthestDistance, maxFurthestDistance: this.state.maxFurthestDistance, cameraToCenterDistance: this.cameraToCenterDistance, t: this.map.transform, tbProjMatrix: this.camera.projectionMatrix.elements, tbWorldMatrix: this.world.matrix.elements, cameraSyn: CameraSync } }); + + }, + + worldSize(transform) { + return transform.tileSize * transform.scale; }, + fovAboveCenter(transform) { + return transform._fov * (0.5 + transform.centerOffset.y / transform.height); + }, + + mercatorZfromAltitude(altitude, lat) { + return altitude / this.circumferenceAtLatitude(lat); + }, + + circumferenceAtLatitude(latitude) { + return ThreeboxConstants.EARTH_CIRCUMFERENCE * Math.cos(latitude * Math.PI / 180); + }, calcCameraMatrix(pitch, angle, trz) { const t = this.map.transform; diff --git a/dist/threebox.min.js b/dist/threebox.min.js index 0361adc2..d404a007 100644 --- a/dist/threebox.min.js +++ b/dist/threebox.min.js @@ -1 +1 @@ -!function(){var e,t,n=function(e){var t;return function(n){return t||e(t={exports:{},parent:n},t.exports),t.exports}}((function(e,t){(function(e,n){(function(){var i=N.nextTick,r=(Function.prototype.apply,Array.prototype.slice),a={},o=0;function s(e,t){this._id=e,this._clearFn=t}s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(window,this._id)},t.setImmediate="function"==typeof e?e:function(e){var n=o++,s=!(arguments.length<2)&&r.call(arguments,1);return a[n]=!0,i((function(){a[n]&&(s?e.apply(null,s):e.call(null),t.clearImmediate(n))})),n},t.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this)}).call(this,n({}).setImmediate,n({}).clearImmediate)})),i={exports:{}};e=this,t=function(e){"use strict";const t="127",n=100,i=300,r=301,a=302,o=303,s=304,l=306,c=307,u=1e3,h=1001,d=1002,p=1003,f=1004,m=1005,g=1006,v=1007,y=1008,x=1009,b=1012,w=1014,_=1015,M=1016,S=1020,T=1022,E=1023,A=1026,L=1027,R=33776,C=33777,P=33778,I=33779,D=35840,O=35841,N=35842,F=35843,B=37492,z=37496,H=2300,U=2301,k=2302,G=2400,j=2401,V=2402,W=2500,q=2501,X=3e3,Z=3001,Y=3007,J=3002,K=3004,Q=3005,$=3006,ee=35044,te=35048,ne="300 es";function ie(){}Object.assign(ie.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)},removeEventListener:function(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}},dispatchEvent:function(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+re[e>>16&255]+re[e>>24&255]+"-"+re[255&t]+re[t>>8&255]+"-"+re[t>>16&15|64]+re[t>>24&255]+"-"+re[63&n|128]+re[n>>8&255]+"-"+re[n>>16&255]+re[n>>24&255]+re[255&i]+re[i>>8&255]+re[i>>16&255]+re[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:function(e,t,n){return(1-n)*e+n*t},damp:function(e,t,n,i){return oe.lerp(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(oe.euclideanModulo(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-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())},seededRandom:function(e){return void 0!==e&&(ae=e%2147483647),((ae=16807*ae%2147483647)-1)/2147483646},degToRad:function(e){return e*oe.DEG2RAD},radToDeg:function(e){return e*oe.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))},setQuaternionFromProperEuler:function(e,t,n,i,r){const a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),c=a((t+i)/2),u=o((t+i)/2),h=a((t-i)/2),d=o((t-i)/2),p=a((i-t)/2),f=o((i-t)/2);switch(r){case"XYX":e.set(s*u,l*h,l*d,s*c);break;case"YZY":e.set(l*d,s*u,l*h,s*c);break;case"ZXZ":e.set(l*h,l*d,s*u,s*c);break;case"XZX":e.set(s*u,l*f,l*p,s*c);break;case"YXY":e.set(l*p,s*u,l*f,s*c);break;case"ZYZ":e.set(l*f,l*p,s*u,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class se{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(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(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(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(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(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(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}se.prototype.isVector2=!0;class le{constructor(){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.")}set(e,t,n,i,r,a,o,s,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=o,c[3]=t,c[4]=r,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const 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}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],w=i[5],_=i[8];return r[0]=a*f+o*v+s*b,r[3]=a*m+o*y+s*w,r[6]=a*g+o*x+s*_,r[1]=l*f+c*v+u*b,r[4]=l*m+c*y+u*w,r[7]=l*g+c*x+u*_,r[2]=h*f+d*v+p*b,r[5]=h*m+d*y+p*w,r[8]=h*g+d*x+p*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*a*c-t*o*l-n*r*c+n*o*s+i*r*l-i*a*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=c*a-o*l,h=o*s-c*r,d=l*r-a*s,p=t*u+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(i*l-c*n)*f,e[2]=(o*n-i*a)*f,e[3]=h*f,e[4]=(c*t-i*s)*f,e[5]=(i*r-o*t)*f,e[6]=d*f,e[7]=(n*s-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const s=Math.cos(r),l=Math.sin(r);return this.set(n*s,n*l,-n*(s*a+l*o)+a+e,-i*l,i*s,-i*(-l*a+s*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],a=i[3],o=i[6],s=i[1],l=i[4],c=i[7];return i[0]=t*r+n*s,i[3]=t*a+n*l,i[6]=t*o+n*c,i[1]=-n*r+t*s,i[4]=-n*a+t*l,i[7]=-n*o+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}let ce;le.prototype.isMatrix3=!0;const ue={getDataURL:function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===ce&&(ce=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),ce.width=e.width,ce.height=e.height;const n=ce.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ce}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}};let he=0;class de extends ie{constructor(e=de.DEFAULT_IMAGE,t=de.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,o=1023,s=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:he++}),this.uuid=oe.generateUUID(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=s,this.offset=new se(0,0),this.repeat=new se(1,1),this.center=new se(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new le,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const i=this.image;if(void 0===i.uuid&&(i.uuid=oe.generateUUID()),!t&&void 0===e.images[i.uuid]){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e1)switch(this.wrapS){case u:e.x=e.x-Math.floor(e.x);break;case h:e.x=e.x<0?0:1;break;case d: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 u:e.y=e.y-Math.floor(e.y);break;case h:e.y=e.y<0?0:1;break;case d:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function pe(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ue.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}de.DEFAULT_IMAGE=void 0,de.DEFAULT_MAPPING=i,de.prototype.isTexture=!0;class fe{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(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(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(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(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(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(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(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(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}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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(e){let t,n,i,r;const a=.01,o=e.elements,s=o[0],l=o[4],c=o[8],u=o[1],h=o[5],d=o[9],p=o[2],f=o[6],m=o[10];if(Math.abs(l-u)o&&e>g?eg?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,o=Math.sin(o*a)/r}const r=o*n;if(s=s*e+h*r,l=l*e+d*r,c=c*e+p*r,u=u*e+f*r,e===1-o){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],s=n[i+1],l=n[i+2],c=n[i+3],u=r[a],h=r[a+1],d=r[a+2],p=r[a+3];return e[t]=o*p+c*u+s*d-l*h,e[t+1]=s*p+c*h+l*u-o*d,e[t+2]=l*p+c*d+o*h-s*u,e[t+3]=c*p-o*u-s*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,s=Math.sin,l=o(n/2),c=o(i/2),u=o(r/2),h=s(n/2),d=s(i/2),p=s(r/2);switch(a){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],s=t[9],l=t[2],c=t[6],u=t[10],h=n+o+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-s)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>o&&n>u){const e=2*Math.sqrt(1+n-o-u);this._w=(c-s)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(o>u){const e=2*Math.sqrt(1+o-n-u);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-o);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(oe.clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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(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(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+a*o+i*l-r*s,this._y=i*c+a*s+r*o-n*l,this._z=r*c+a*l+n*s-i*o,this._w=a*c-n*o-i*s-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const s=1-o*o;if(s<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,o),u=Math.sin((1-t)*c)/l,h=Math.sin(t*c)/l;return this._w=a*u+this._w*h,this._x=n*u+this._x*h,this._y=i*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){this.copy(e).slerp(t,n)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}ve.prototype.isQuaternion=!0;class ye{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(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(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(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(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(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(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(be.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(be.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*i-o*n,c=s*n+o*t-r*i,u=s*i+r*n-a*t,h=-r*t-a*n-o*i;return this.x=l*s+h*-r+c*-o-u*-a,this.y=c*s+h*-a+u*-r-l*-o,this.z=u*s+h*-o+l*-a-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(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(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(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(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(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(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(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return xe.copy(this).projectOnVector(e),this.sub(xe)}reflect(e){return this.sub(xe.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(oe.clamp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return void 0!==n&&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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}ye.prototype.isVector3=!0;const xe=new ye,be=new ve;class we{constructor(e=new ye(1/0,1/0,1/0),t=new ye(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,l=e.length;sr&&(r=l),c>a&&(a=c),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,l=e.count;sr&&(r=l),c>a&&(a=c),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(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(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new ye),t.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(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Me),Me.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Pe),Ie.subVectors(this.max,Pe),Te.subVectors(e.a,Pe),Ee.subVectors(e.b,Pe),Ae.subVectors(e.c,Pe),Le.subVectors(Ee,Te),Re.subVectors(Ae,Ee),Ce.subVectors(Te,Ae);let t=[0,-Le.z,Le.y,0,-Re.z,Re.y,0,-Ce.z,Ce.y,Le.z,0,-Le.x,Re.z,0,-Re.x,Ce.z,0,-Ce.x,-Le.y,Le.x,0,-Re.y,Re.x,0,-Ce.y,Ce.x,0];return!!Ne(t,Te,Ee,Ae,Ie)&&!!Ne(t=[1,0,0,0,1,0,0,0,1],Te,Ee,Ae,Ie)&&(De.crossVectors(Le,Re),Ne(t=[De.x,De.y,De.z],Te,Ee,Ae,Ie))}clampPoint(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new ye),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Me.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(Me).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(_e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_e)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}we.prototype.isBox3=!0;const _e=[new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye],Me=new ye,Se=new we,Te=new ye,Ee=new ye,Ae=new ye,Le=new ye,Re=new ye,Ce=new ye,Pe=new ye,Ie=new ye,De=new ye,Oe=new ye;function Ne(e,t,n,i,r){for(let a=0,o=e.length-3;a<=o;a+=3){Oe.fromArray(e,a);const o=r.x*Math.abs(Oe.x)+r.y*Math.abs(Oe.y)+r.z*Math.abs(Oe.z),s=t.dot(Oe),l=n.dot(Oe),c=i.dot(Oe);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>o)return!1}return!0}const Fe=new we,Be=new ye,ze=new ye,He=new ye;class Ue{constructor(e=new ye,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Fe.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new we),this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){He.subVectors(e,this.center);const t=He.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(He.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return ze.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Be.copy(e.center).add(ze)),this.expandByPoint(Be.copy(e.center).sub(ze)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ke=new ye,Ge=new ye,je=new ye,Ve=new ye,We=new ye,qe=new ye,Xe=new ye;class Ze{constructor(e=new ye,t=new ye(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new ye),t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ke)),this}closestPointToPoint(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new ye),t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ke.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ke.copy(this.direction).multiplyScalar(t).add(this.origin),ke.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ge.copy(e).add(t).multiplyScalar(.5),je.copy(t).sub(e).normalize(),Ve.copy(this.origin).sub(Ge);const r=.5*e.distanceTo(t),a=-this.direction.dot(je),o=Ve.dot(this.direction),s=-Ve.dot(je),l=Ve.lengthSq(),c=Math.abs(1-a*a);let u,h,d,p;if(c>0)if(h=a*o-s,p=r*c,(u=a*s-o)>=0)if(h>=-p)if(h<=p){const e=1/c;d=(u*=e)*(u+a*(h*=e)+2*o)+h*(a*u+h+2*s)+l}else h=r,d=-(u=Math.max(0,-(a*h+o)))*u+h*(h+2*s)+l;else h=-r,d=-(u=Math.max(0,-(a*h+o)))*u+h*(h+2*s)+l;else h<=-p?d=-(u=Math.max(0,-(-a*r+o)))*u+(h=u>0?-r:Math.min(Math.max(-r,-s),r))*(h+2*s)+l:h<=p?(u=0,d=(h=Math.min(Math.max(-r,-s),r))*(h+2*s)+l):d=-(u=Math.max(0,-(a*r+o)))*u+(h=u>0?r:Math.min(Math.max(-r,-s),r))*(h+2*s)+l;else h=a>0?-r:r,d=-(u=Math.max(0,-(a*h+o)))*u+h*(h+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(je).multiplyScalar(h).add(Ge),d}intersectSphere(e,t){ke.subVectors(e.center,this.origin);const n=ke.dot(this.direction),i=ke.dot(ke)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),c>=0?(r=(e.min.y-h.y)*c,a=(e.max.y-h.y)*c):(r=(e.max.y-h.y)*c,a=(e.min.y-h.y)*c),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(e.min.z-h.z)*u,s=(e.max.z-h.z)*u):(o=(e.max.z-h.z)*u,s=(e.min.z-h.z)*u),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,ke)}intersectTriangle(e,t,n,i,r){We.subVectors(t,e),qe.subVectors(n,e),Xe.crossVectors(We,qe);let a,o=this.direction.dot(Xe);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ve.subVectors(this.origin,e);const s=a*this.direction.dot(qe.crossVectors(Ve,qe));if(s<0)return null;const l=a*this.direction.dot(We.cross(Ve));if(l<0)return null;if(s+l>o)return null;const c=-a*Ve.dot(Xe);return c<0?null:this.at(c/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Ye{constructor(){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.")}set(e,t,n,i,r,a,o,s,l,c,u,h,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Ye).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Je.setFromMatrixColumn(e,0).length(),r=1/Je.setFromMatrixColumn(e,1).length(),a=1/Je.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*u,i=o*c,r=o*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-o*s,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*s}else if("YXZ"===e.order){const e=s*c,n=s*u,i=l*c,r=l*u;t[0]=e+r*o,t[4]=i*o-n,t[8]=a*l,t[1]=a*u,t[5]=a*c,t[9]=-o,t[2]=n*o-i,t[6]=r+e*o,t[10]=a*s}else if("ZXY"===e.order){const e=s*c,n=s*u,i=l*c,r=l*u;t[0]=e-r*o,t[4]=-a*u,t[8]=i+n*o,t[1]=n+i*o,t[5]=a*c,t[9]=r-e*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){const e=a*c,n=a*u,i=o*c,r=o*u;t[0]=s*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=s*u,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){const e=a*s,n=a*l,i=o*s,r=o*l;t[0]=s*c,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=a*c,t[9]=-o*c,t[2]=-l*c,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=a*s,n=a*l,i=o*s,r=o*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=a*c,t[9]=n*u-i,t[2]=i*u-n,t[6]=o*c,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Qe,e,$e)}lookAt(e,t,n){const i=this.elements;return nt.subVectors(e,t),0===nt.lengthSq()&&(nt.z=1),nt.normalize(),et.crossVectors(n,nt),0===et.lengthSq()&&(1===Math.abs(n.z)?nt.x+=1e-4:nt.z+=1e-4,nt.normalize(),et.crossVectors(n,nt)),et.normalize(),tt.crossVectors(nt,et),i[0]=et.x,i[4]=tt.x,i[8]=nt.x,i[1]=et.y,i[5]=tt.y,i[9]=nt.y,i[2]=et.z,i[6]=tt.z,i[10]=nt.z,this}multiply(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(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],w=i[0],_=i[4],M=i[8],S=i[12],T=i[1],E=i[5],A=i[9],L=i[13],R=i[2],C=i[6],P=i[10],I=i[14],D=i[3],O=i[7],N=i[11],F=i[15];return r[0]=a*w+o*T+s*R+l*D,r[4]=a*_+o*E+s*C+l*O,r[8]=a*M+o*A+s*P+l*N,r[12]=a*S+o*L+s*I+l*F,r[1]=c*w+u*T+h*R+d*D,r[5]=c*_+u*E+h*C+d*O,r[9]=c*M+u*A+h*P+d*N,r[13]=c*S+u*L+h*I+d*F,r[2]=p*w+f*T+m*R+g*D,r[6]=p*_+f*E+m*C+g*O,r[10]=p*M+f*A+m*P+g*N,r[14]=p*S+f*L+m*I+g*F,r[3]=v*w+y*T+x*R+b*D,r[7]=v*_+y*E+x*C+b*O,r[11]=v*M+y*A+x*P+b*N,r[15]=v*S+y*L+x*I+b*F,this}multiplyScalar(e){const 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}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],l=e[13],c=e[2],u=e[6],h=e[10],d=e[14];return e[3]*(+r*s*u-i*l*u-r*o*h+n*l*h+i*o*d-n*s*d)+e[7]*(+t*s*d-t*l*h+r*a*h-i*a*d+i*l*c-r*s*c)+e[11]*(+t*l*u-t*o*d-r*a*u+n*a*d+r*o*c-n*l*c)+e[15]*(-i*o*c-t*s*u+t*o*h+i*a*u-n*a*h+n*s*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=u*m*l-f*h*l+f*s*d-o*m*d-u*s*g+o*h*g,y=p*h*l-c*m*l-p*s*d+a*m*d+c*s*g-a*h*g,x=c*f*l-p*u*l+p*o*d-a*f*d-c*o*g+a*u*g,b=p*u*s-c*f*s-p*o*h+a*f*h+c*o*m-a*u*m,w=t*v+n*y+i*x+r*b;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/w;return e[0]=v*_,e[1]=(f*h*r-u*m*r-f*i*d+n*m*d+u*i*g-n*h*g)*_,e[2]=(o*m*r-f*s*r+f*i*l-n*m*l-o*i*g+n*s*g)*_,e[3]=(u*s*r-o*h*r-u*i*l+n*h*l+o*i*d-n*s*d)*_,e[4]=y*_,e[5]=(c*m*r-p*h*r+p*i*d-t*m*d-c*i*g+t*h*g)*_,e[6]=(p*s*r-a*m*r-p*i*l+t*m*l+a*i*g-t*s*g)*_,e[7]=(a*h*r-c*s*r+c*i*l-t*h*l-a*i*d+t*s*d)*_,e[8]=x*_,e[9]=(p*u*r-c*f*r-p*n*d+t*f*d+c*n*g-t*u*g)*_,e[10]=(a*f*r-p*o*r+p*n*l-t*f*l-a*n*g+t*o*g)*_,e[11]=(c*o*r-a*u*r-c*n*l+t*u*l+a*n*d-t*o*d)*_,e[12]=b*_,e[13]=(c*f*i-p*u*i+p*n*h-t*f*h-c*n*m+t*u*m)*_,e[14]=(p*o*i-a*f*i-p*n*s+t*f*s+a*n*m-t*o*m)*_,e[15]=(a*u*i-c*o*i+c*n*s-t*u*s-a*n*h+t*o*h)*_,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,s=e.z,l=r*a,c=r*o;return this.set(l*a+n,l*o-i*s,l*s+i*o,0,l*o+i*s,c*o+n,c*s-i*a,0,l*s-i*o,c*s+i*a,r*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n){return this.set(1,t,n,0,e,1,n,0,e,t,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,s=t._w,l=r+r,c=a+a,u=o+o,h=r*l,d=r*c,p=r*u,f=a*c,m=a*u,g=o*u,v=s*l,y=s*c,x=s*u,b=n.x,w=n.y,_=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(h+g))*w,i[6]=(m+v)*w,i[7]=0,i[8]=(p+y)*_,i[9]=(m-v)*_,i[10]=(1-(h+f))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Je.set(i[0],i[1],i[2]).length();const a=Je.set(i[4],i[5],i[6]).length(),o=Je.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Ke.copy(this);const s=1/r,l=1/a,c=1/o;return Ke.elements[0]*=s,Ke.elements[1]*=s,Ke.elements[2]*=s,Ke.elements[4]*=l,Ke.elements[5]*=l,Ke.elements[6]*=l,Ke.elements[8]*=c,Ke.elements[9]*=c,Ke.elements[10]*=c,t.setFromRotationMatrix(Ke),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*r/(t-e),l=2*r/(n-i),c=(t+e)/(t-e),u=(n+i)/(n-i),h=-(a+r)/(a-r),d=-2*a*r/(a-r);return o[0]=s,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a){const o=this.elements,s=1/(t-e),l=1/(n-i),c=1/(a-r),u=(t+e)*s,h=(n+i)*l,d=(a+r)*c;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}Ye.prototype.isMatrix4=!0;const Je=new ye,Ke=new Ye,Qe=new ye(0,0,0),$e=new ye(1,1,1),et=new ye,tt=new ye,nt=new ye,it=new Ye,rt=new ve;class at{constructor(e=0,t=0,n=0,i=at.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._order=i||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t,n){const i=oe.clamp,r=e.elements,a=r[0],o=r[4],s=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t=t||this._order){case"XYZ":this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-i(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(i(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-i(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(i(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(s,p));break;case"XZY":this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!1!==n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return it.makeRotationFromQuaternion(e),this.setFromRotationMatrix(it,t,n)}setFromVector3(e,t){return this.set(e.x,e.y,e.z,t||this._order)}reorder(e){return rt.setFromEuler(this),this.setFromQuaternion(rt,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(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(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new ye(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}at.prototype.isEuler=!0,at.DefaultOrder="XYZ",at.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ot{constructor(){this.mask=1}set(e){this.mask=1<1){for(let e=0;e1){for(let e=0;e0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,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(let n=0;n1?null:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new ye),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Mt.getNormalMatrix(e),i=this.coplanarPoint(wt).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}St.prototype.isPlane=!0;const Tt=new ye,Et=new ye,At=new ye,Lt=new ye,Rt=new ye,Ct=new ye,Pt=new ye,It=new ye,Dt=new ye,Ot=new ye;class Nt{constructor(e=new ye,t=new ye,n=new ye){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new ye),i.subVectors(n,t),Tt.subVectors(e,t),i.cross(Tt);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Tt.subVectors(i,t),Et.subVectors(n,t),At.subVectors(e,t);const a=Tt.dot(Tt),o=Tt.dot(Et),s=Tt.dot(At),l=Et.dot(Et),c=Et.dot(At),u=a*l-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new ye),0===u)return r.set(-2,-1,-1);const h=1/u,d=(l*s-o*c)*h,p=(a*c-o*s)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Lt),Lt.x>=0&&Lt.y>=0&&Lt.x+Lt.y<=1}static getUV(e,t,n,i,r,a,o,s){return this.getBarycoord(e,t,n,i,Lt),s.set(0,0),s.addScaledVector(r,Lt.x),s.addScaledVector(a,Lt.y),s.addScaledVector(o,Lt.z),s}static isFrontFacing(e,t,n,i){return Tt.subVectors(n,t),Et.subVectors(e,t),Tt.cross(Et).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Tt.subVectors(this.c,this.b),Et.subVectors(this.a,this.b),.5*Tt.cross(Et).length()}getMidpoint(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new ye),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Nt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new St),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Nt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return Nt.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Nt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Nt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new ye);const n=this.a,i=this.b,r=this.c;let a,o;Rt.subVectors(i,n),Ct.subVectors(r,n),It.subVectors(e,n);const s=Rt.dot(It),l=Ct.dot(It);if(s<=0&&l<=0)return t.copy(n);Dt.subVectors(e,i);const c=Rt.dot(Dt),u=Ct.dot(Dt);if(c>=0&&u<=c)return t.copy(i);const h=s*u-c*l;if(h<=0&&s>=0&&c<=0)return a=s/(s-c),t.copy(n).addScaledVector(Rt,a);Ot.subVectors(e,r);const d=Rt.dot(Ot),p=Ct.dot(Ot);if(p>=0&&d<=p)return t.copy(r);const f=d*l-s*p;if(f<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(Ct,o);const m=c*p-d*u;if(m<=0&&u-c>=0&&d-p>=0)return Pt.subVectors(r,i),o=(u-c)/(u-c+(d-p)),t.copy(i).addScaledVector(Pt,o);const g=1/(m+f+h);return a=f*g,o=h*g,t.copy(n).addScaledVector(Rt,a).addScaledVector(Ct,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Ft=0;function Bt(){Object.defineProperty(this,"id",{value:Ft++}),this.uuid=oe.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=n,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Bt.prototype=Object.assign(Object.create(ie.prototype),{constructor:Bt,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}},toJSON:function(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,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.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Bt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}});const zt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ht={h:0,s:0,l:0},Ut={h:0,s:0,l:0};function kt(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function Gt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function jt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Vt{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=oe.euclideanModulo(e,1),t=oe.clamp(t,0,1),n=oe.clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=kt(r,i,e+1/3),this.g=kt(r,i,e),this.b=kt(r,i,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=n[1],r=n[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(e[1])/360,i=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=zt[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Gt(e.r),this.g=Gt(e.g),this.b=Gt(e.b),this}copyLinearToSRGB(e){return this.r=jt(e.r),this.g=jt(e.g),this.b=jt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});const t=this.r,n=this.g,i=this.b,r=Math.max(t,n,i),a=Math.min(t,n,i);let o,s;const l=(a+r)/2;if(a===r)o=0,s=0;else{const e=r-a;switch(s=l<=.5?e/(r+a):e/(2-r-a),r){case t:o=(n-i)/e+(nt&&(t=e[n]);return t}Object.defineProperty(Zt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Zt.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i65535?tn:$t)(e,1):this.index=e,this},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},hasAttribute:function(e){return void 0!==this.attributes[e]},addGroup:function(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new le).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return un.makeRotationX(e),this.applyMatrix4(un),this},rotateY:function(e){return un.makeRotationY(e),this.applyMatrix4(un),this},rotateZ:function(e){return un.makeRotationZ(e),this.applyMatrix4(un),this},translate:function(e,t,n){return un.makeTranslation(e,t,n),this.applyMatrix4(un),this},scale:function(e,t,n){return un.makeScale(e,t,n),this.applyMatrix4(un),this},lookAt:function(e){return hn.lookAt(e),hn.updateMatrix(),this.applyMatrix4(hn.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(dn).negate(),this.translate(dn.x,dn.y,dn.z),this},setFromPoints:function(e){const t=[];for(let n=0,i=e.length;n0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const s in n){const t=n[s];e.data.attributes[s]=t.toJSON(e.data)}const i={};let r=!1;for(const s in this.morphAttributes){const t=this.morphAttributes[s],n=[];for(let i=0,r=t.length;i0&&(i[s]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e},clone:function(){return(new gn).copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const e=i[l];this.setAttribute(l,e.clone(t))}const r=e.morphAttributes;for(const l in r){const e=[],n=r[l];for(let i=0,r=n.length;in.far?null:{distance:c,point:Dn.clone(),object:e}}(e,t,n,i,bn,wn,_n,In);if(p){s&&(Rn.fromBufferAttribute(s,c),Cn.fromBufferAttribute(s,u),Pn.fromBufferAttribute(s,h),p.uv=Nt.getUV(In,bn,wn,_n,Rn,Cn,Pn,new se)),l&&(Rn.fromBufferAttribute(l,c),Cn.fromBufferAttribute(l,u),Pn.fromBufferAttribute(l,h),p.uv2=Nt.getUV(In,bn,wn,_n,Rn,Cn,Pn,new se));const e={a:c,b:u,c:h,normal:new ye,materialIndex:0};Nt.getNormal(bn,wn,_n,e.normal),p.face=e}return p}On.prototype=Object.assign(Object.create(bt.prototype),{constructor:On,isMesh:!0,copy:function(e){return bt.prototype.copy.call(this,e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),xn.copy(n.boundingSphere),xn.applyMatrix4(r),!1===e.ray.intersectsSphere(xn))return;if(vn.copy(r).invert(),yn.copy(e.ray).applyMatrix4(vn),null!==n.boundingBox&&!1===yn.intersectsBox(n.boundingBox))return;let a;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,u=n.attributes.uv2,h=n.groups,d=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,p=h.length;n0?1:-1,c.push(A.x,A.y,A.z),u.push(s/m),u.push(1-o/g),T+=1}}for(let o=0;o0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)!0===this.extensions[i]&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t},kn.prototype=Object.assign(Object.create(bt.prototype),{constructor:kn,isCamera:!0,copy:function(e,t){return bt.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new ye),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){bt.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(e,t){bt.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),Gn.prototype=Object.assign(Object.create(kn.prototype),{constructor:Gn,isPerspectiveCamera:!0,copy:function(e,t){return kn.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){const t=.5*this.getFilmHeight()/e;this.fov=2*oe.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){const e=Math.tan(.5*oe.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*oe.RAD2DEG*Math.atan(Math.tan(.5*oe.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=this.near;let t=e*Math.tan(.5*oe.DEG2RAD*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/o,i*=a.width/e,n*=a.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=bt.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});class jn extends bt{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new Gn(90,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new ye(1,0,0)),this.add(i);const r=new Gn(90,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new ye(-1,0,0)),this.add(r);const a=new Gn(90,1,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new ye(0,1,0)),this.add(a);const o=new Gn(90,1,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new ye(0,-1,0)),this.add(o);const s=new Gn(90,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new ye(0,0,1)),this.add(s);const l=new Gn(90,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new ye(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,a,o,s,l]=this.children,c=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=h,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=c}}class Vn extends de{constructor(e,t,n,i,a,o,s,l,c,u){super(e=void 0!==e?e:[],t=void 0!==t?t:r,n,i,a,o,s=void 0!==s?s:T,l,c,u),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Vn.prototype.isCubeTexture=!0;class Wn extends me{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),t=t||{},this.texture=new Vn(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=E,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new Fn(5,5,5),i=new Un({name:"CubemapFromEquirect",uniforms:Bn({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});i.uniforms.tEquirect.value=t;const r=new On(n,i),a=t.minFilter;return t.minFilter===y&&(t.minFilter=g),new jn(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}Wn.prototype.isWebGLCubeRenderTarget=!0;class qn extends de{constructor(e,t,n,i,r,a,o,s,l,c,u,h){super(null,a,o,s,l,c,i,r,u,h),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=void 0!==l?l:p,this.minFilter=void 0!==c?c:p,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}qn.prototype.isDataTexture=!0;const Xn=new Ue,Zn=new ye;class Yn{constructor(e=new St,t=new St,n=new St,i=new St,r=new St,a=new St){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(o-i,u-s,f-h,y-m).normalize(),t[1].setComponents(o+i,u+s,f+h,y+m).normalize(),t[2].setComponents(o+r,u+l,f+d,y+g).normalize(),t[3].setComponents(o-r,u-l,f-d,y-g).normalize(),t[4].setComponents(o-a,u-c,f-p,y-v).normalize(),t[5].setComponents(o+a,u+c,f+p,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Xn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Xn)}intersectsSprite(e){return Xn.center.set(0,0,0),Xn.radius=.7071067811865476,Xn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xn)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,Zn.y=i.normal.y>0?e.max.y:e.min.y,Zn.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Zn)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Jn(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Kn(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",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, float faceDirection ) {\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 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\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\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 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 roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\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};\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};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial 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\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#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 * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\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 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\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 ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\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}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\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\tvHighPrecisionZW = gl_Position.zw;\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}",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}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \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}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \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\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * 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\t#include \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}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\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 \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#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\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}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\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}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\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 \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\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}",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 \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\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\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#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\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}",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#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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\t#include \n\t#include \n}",shadow_vert:"#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}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\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}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},ei={common:{diffuse:{value:new Vt(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new le},uv2Transform:{value:new le},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new se(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Vt(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new le}},sprite:{diffuse:{value:new Vt(15658734)},opacity:{value:1},center:{value:new se(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new le}}},ti={basic:{uniforms:zn([ei.common,ei.specularmap,ei.envmap,ei.aomap,ei.lightmap,ei.fog]),vertexShader:$n.meshbasic_vert,fragmentShader:$n.meshbasic_frag},lambert:{uniforms:zn([ei.common,ei.specularmap,ei.envmap,ei.aomap,ei.lightmap,ei.emissivemap,ei.fog,ei.lights,{emissive:{value:new Vt(0)}}]),vertexShader:$n.meshlambert_vert,fragmentShader:$n.meshlambert_frag},phong:{uniforms:zn([ei.common,ei.specularmap,ei.envmap,ei.aomap,ei.lightmap,ei.emissivemap,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.fog,ei.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30}}]),vertexShader:$n.meshphong_vert,fragmentShader:$n.meshphong_frag},standard:{uniforms:zn([ei.common,ei.envmap,ei.aomap,ei.lightmap,ei.emissivemap,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.roughnessmap,ei.metalnessmap,ei.fog,ei.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag},toon:{uniforms:zn([ei.common,ei.aomap,ei.lightmap,ei.emissivemap,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.gradientmap,ei.fog,ei.lights,{emissive:{value:new Vt(0)}}]),vertexShader:$n.meshtoon_vert,fragmentShader:$n.meshtoon_frag},matcap:{uniforms:zn([ei.common,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.fog,{matcap:{value:null}}]),vertexShader:$n.meshmatcap_vert,fragmentShader:$n.meshmatcap_frag},points:{uniforms:zn([ei.points,ei.fog]),vertexShader:$n.points_vert,fragmentShader:$n.points_frag},dashed:{uniforms:zn([ei.common,ei.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$n.linedashed_vert,fragmentShader:$n.linedashed_frag},depth:{uniforms:zn([ei.common,ei.displacementmap]),vertexShader:$n.depth_vert,fragmentShader:$n.depth_frag},normal:{uniforms:zn([ei.common,ei.bumpmap,ei.normalmap,ei.displacementmap,{opacity:{value:1}}]),vertexShader:$n.normal_vert,fragmentShader:$n.normal_frag},sprite:{uniforms:zn([ei.sprite,ei.fog]),vertexShader:$n.sprite_vert,fragmentShader:$n.sprite_frag},background:{uniforms:{uvTransform:{value:new le},t2D:{value:null}},vertexShader:$n.background_vert,fragmentShader:$n.background_frag},cube:{uniforms:zn([ei.envmap,{opacity:{value:1}}]),vertexShader:$n.cube_vert,fragmentShader:$n.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$n.equirect_vert,fragmentShader:$n.equirect_frag},distanceRGBA:{uniforms:zn([ei.common,ei.displacementmap,{referencePosition:{value:new ye},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$n.distanceRGBA_vert,fragmentShader:$n.distanceRGBA_frag},shadow:{uniforms:zn([ei.lights,ei.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:$n.shadow_vert,fragmentShader:$n.shadow_frag}};function ni(e,t,n,i,r){const a=new Vt(0);let o,s,c=0,u=null,h=0,d=null;function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),p(a,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){p(a,c=e)},render:function(n,r,f,m){let g=!0===r.isScene?r.background:null;g&&g.isTexture&&(g=t.get(g));const v=e.xr,y=v.getSession&&v.getSession();y&&"additive"===y.environmentBlendMode&&(g=null),null===g?p(a,c):g&&g.isColor&&(p(g,1),m=!0),(e.autoClear||m)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),g&&(g.isCubeTexture||g.mapping===l)?(void 0===s&&((s=new On(new Fn(1,1,1),new Un({name:"BackgroundCubeMaterial",uniforms:Bn(ti.cube.uniforms),vertexShader:ti.cube.vertexShader,fragmentShader:ti.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s)),s.material.uniforms.envMap.value=g,s.material.uniforms.flipEnvMap.value=g.isCubeTexture&&g._needsFlipEnvMap?-1:1,u===g&&h===g.version&&d===e.toneMapping||(s.material.needsUpdate=!0,u=g,h=g.version,d=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null)):g&&g.isTexture&&(void 0===o&&((o=new On(new Qn(2,2),new Un({name:"BackgroundMaterial",uniforms:Bn(ti.background.uniforms),vertexShader:ti.background.vertexShader,fragmentShader:ti.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),o.material.uniforms.uvTransform.value.copy(g.matrix),u===g&&h===g.version&&d===e.toneMapping||(o.material.needsUpdate=!0,u=g,h=g.version,d=e.toneMapping),n.unshift(o,o.geometry,o.material,0,0,null))}}}function ii(e,t,n,i){const r=e.getParameter(34921),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),o=i.isWebGL2||null!==a,s={},l=d(null);let c=l;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function h(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function d(e){const t=[],n=[],i=[];for(let a=0;a=0){const a=l[t];if(void 0!==a){const t=a.normalized,r=a.itemSize,o=n.get(a);if(void 0===o)continue;const l=o.buffer,c=o.type,u=o.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,o=n.stride,h=a.offset;n&&n.isInstancedInterleavedBuffer?(m(i,n.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)):f(i),e.bindBuffer(34962,l),v(i,r,c,t,o*u,h*u)}else a.isInstancedBufferAttribute?(m(i,a.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=a.meshPerAttribute*a.count)):f(i),e.bindBuffer(34962,l),v(i,r,c,t,0,0)}else if("instanceMatrix"===t){const t=n.get(r.instanceMatrix);if(void 0===t)continue;const a=t.buffer,o=t.type;m(i+0,1),m(i+1,1),m(i+2,1),m(i+3,1),e.bindBuffer(34962,a),e.vertexAttribPointer(i+0,4,o,!1,64,0),e.vertexAttribPointer(i+1,4,o,!1,64,16),e.vertexAttribPointer(i+2,4,o,!1,64,32),e.vertexAttribPointer(i+3,4,o,!1,64,48)}else if("instanceColor"===t){const t=n.get(r.instanceColor);if(void 0===t)continue;const a=t.buffer,o=t.type;m(i,1),e.bindBuffer(34962,a),e.vertexAttribPointer(i,3,o,!1,12,0)}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(i,n);break;case 3:e.vertexAttrib3fv(i,n);break;case 4:e.vertexAttrib4fv(i,n);break;default:e.vertexAttrib1fv(i,n)}}}}g()}(r,l,h,y),null!==x&&e.bindBuffer(34963,n.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){y();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const n in t){const e=t[n];for(const t in e)h(e[t].object),delete e[t];delete t[n]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)h(i[e].object),delete i[e];delete n[e.id]}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:g}}function ri(e,t,n,i){const r=i.isWebGL2;let a;this.setMode=function(e){a=e},this.render=function(t,i){e.drawArrays(a,t,i),n.update(i,a,1)},this.renderInstances=function(i,o,s){if(0===s)return;let l,c;if(r)l=e,c="drawArraysInstanced";else if(c="drawArraysInstancedANGLE",null===(l=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](a,i,o,s),n.update(o,a,s)}}function ai(e,t,n){let i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let o=void 0!==n.precision?n.precision:"highp";const s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const l=!0===n.logarithmicDepthBuffer,c=e.getParameter(34930),u=e.getParameter(35660),h=e.getParameter(3379),d=e.getParameter(34076),p=e.getParameter(34921),f=e.getParameter(36347),m=e.getParameter(36348),g=e.getParameter(36349),v=u>0,y=a||t.has("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:a?e.getParameter(36183):0}}function oi(e){const t=this;let n=null,i=0,r=!1,a=!1;const o=new St,s=new le,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===c||c.length0){const o=e.getRenderTarget(),s=new Wn(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),e.setRenderTarget(o),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}function li(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function ci(e,t,n,i){const r={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const n in s.attributes)t.remove(s.attributes[n]);s.removeEventListener("dispose",o),delete r[s.id];const l=a.get(s);l&&(t.remove(l),a.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let o=0;if(null!==i){const e=i.array;o=i.version;for(let t=0,i=e.length;t65535?tn:$t)(n,1);s.version=o;const l=a.get(e);l&&t.remove(l),a.set(e,s)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",o),r[t.id]=!0,n.memory.geometries++),t},update:function(e){const n=e.attributes;for(const r in n)t.update(n[r],34962);const i=e.morphAttributes;for(const r in i){const e=i[r];for(let n=0,i=e.length;n0)return e;const r=t*n;let a=_i[r];if(void 0===a&&(a=new Float32Array(r),_i[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Li(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n/gm;function Pr(e){return e.replace(Cr,Ir)}function Ir(e,t){const n=$n[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Pr(n)}const Dr=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Or=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Nr(e){return e.replace(Or,Br).replace(Dr,Fr)}function Fr(e,t,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Br(e,t,n,i)}function Br(e,t,n,i){let r="";for(let a=parseInt(t);a0?e.gammaFactor:1,v=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ar).join("\n")}(n),y=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),x=o.createProgram();let b,w,_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((b=[y].filter(Ar).join("\n")).length>0&&(b+="\n"),(w=[v,y].filter(Ar).join("\n")).length>0&&(w+="\n")):(b=[zr(n),"#define SHADER_NAME "+n.shaderName,y,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( 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(Ar).join("\n"),w=[v,zr(n),"#define SHADER_NAME "+n.shaderName,y,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.envMap?"#define "+f:"",n.envMap?"#define "+m:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?$n.tonemapping_pars_fragment:"",0!==n.toneMapping?Er("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",$n.encodings_pars_fragment,n.map?Sr("mapTexelToLinear",n.mapEncoding):"",n.matcap?Sr("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Sr("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Sr("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?Sr("lightMapTexelToLinear",n.lightMapEncoding):"",Tr("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Ar).join("\n")),u=Rr(u=Lr(u=Pr(u),n),n),h=Rr(h=Lr(h=Pr(h),n),n),u=Nr(u),h=Nr(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",b=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+b,w=["#define varying in",n.glslVersion===ne?"":"out highp vec4 pc_fragColor;",n.glslVersion===ne?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+w);const M=_+w+h,S=br(o,35633,_+b+u),T=br(o,35632,M);if(o.attachShader(x,S),o.attachShader(x,T),void 0!==n.index0AttributeName?o.bindAttribLocation(x,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(x,0,"position"),o.linkProgram(x),e.debug.checkShaderErrors){const e=o.getProgramInfoLog(x).trim(),t=o.getShaderInfoLog(S).trim(),n=o.getShaderInfoLog(T).trim();let i=!0,r=!0;if(!1===o.getProgramParameter(x,35714)){i=!1;const t=Mr(o,S,"vertex"),n=Mr(o,T,"fragment");console.error("THREE.WebGLProgram: shader error: ",o.getError(),"35715",o.getProgramParameter(x,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(r=!1);r&&(this.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:b},fragmentShader:{log:n,prefix:w}})}let E,A;return o.deleteShader(S),o.deleteShader(T),this.getUniforms=function(){return void 0===E&&(E=new xr(o,x)),E},this.getAttributes=function(){return void 0===A&&(A=function(e,t){const n={},i=e.getProgramParameter(t,35721);for(let r=0;r0,maxBones:S,useVertexTexture:h,morphTargets:r.morphTargets,morphNormals:r.morphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&g.length>0,shadowMapType:e.shadowMap.type,toneMapping:r.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:s||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:s||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:s||n.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e1&&i.sort(e||Gr),r.length>1&&r.sort(t||jr)}}}function Wr(e){let t=new WeakMap;return{get:function(n,i){let r;return!1===t.has(n)?(r=new Vr(e),t.set(n,[r])):i>=t.get(n).length?(r=new Vr(e),t.get(n).push(r)):r=t.get(n)[i],r},dispose:function(){t=new WeakMap}}}function qr(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new ye,color:new Vt};break;case"SpotLight":n={position:new ye,direction:new ye,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ye,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ye,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":n={color:new Vt,position:new ye,halfWidth:new ye,halfHeight:new ye}}return e[t.id]=n,n}}}let Xr=0;function Zr(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Yr(e,t){const n=new qr,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let l=0;l<9;l++)r.probe.push(new ye);const a=new ye,o=new Ye,s=new Ye;return{setup:function(a){let o=0,s=0,l=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,h=0,d=0,p=0,f=0,m=0,g=0;a.sort(Zr);for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ei.LTC_FLOAT_1,r.rectAreaLTC2=ei.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=ei.LTC_HALF_1,r.rectAreaLTC2=ei.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=s,r.ambient[2]=l;const v=r.hash;v.directionalLength===c&&v.pointLength===u&&v.spotLength===h&&v.rectAreaLength===d&&v.hemiLength===p&&v.numDirectionalShadows===f&&v.numPointShadows===m&&v.numSpotShadows===g||(r.directional.length=c,r.spot.length=h,r.rectArea.length=d,r.point.length=u,r.hemi.length=p,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=m,r.spotShadowMatrix.length=g,v.directionalLength=c,v.pointLength=u,v.spotLength=h,v.rectAreaLength=d,v.hemiLength=p,v.numDirectionalShadows=f,v.numPointShadows=m,v.numSpotShadows=g,r.version=Xr++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let d=0,p=e.length;d=n.get(i).length?(a=new Jr(e,t),n.get(i).push(a)):a=n.get(i)[r],a},dispose:function(){n=new WeakMap}}}class Qr extends Bt{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,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.setValues(e)}copy(e){return super.copy(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}}Qr.prototype.isMeshDepthMaterial=!0;class $r extends Bt{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new ye,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.setValues(e)}copy(e){return super.copy(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}}function ea(e,t,n){let i=new Yn;const r=new se,a=new se,o=new fe,s=[],l=[],c={},u=n.maxTextureSize,h={0:1,1:0,2:2},d=new Un({defines:{SAMPLE_RATE:.25,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new se},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new gn;m.setAttribute("position",new Zt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new On(m,d),y=this;function x(n,i){const r=t.update(v);d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,d,v,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,f,v,null)}function b(e,t,n){const i=e<<0|t<<1|n<<2;let r=s[i];return void 0===r&&(r=new Qr({depthPacking:3201,morphTargets:e,skinning:t}),s[i]=r),r}function w(e,t,n){const i=e<<0|t<<1|n<<2;let r=l[i];return void 0===r&&(r=new $r({morphTargets:e,skinning:t}),l[i]=r),r}function _(t,n,i,r,a,o,s){let l=null,u=b,d=t.customDepthMaterial;if(!0===r.isPointLight&&(u=w,d=t.customDistanceMaterial),void 0===d){let e=!1;!0===i.morphTargets&&(e=n.morphAttributes&&n.morphAttributes.position&&n.morphAttributes.position.length>0);let r=!1;!0===t.isSkinnedMesh&&(!0===i.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t)),l=u(e,r,!0===t.isInstancedMesh)}else l=d;if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){const e=l.uuid,t=i.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let r=n[t];void 0===r&&(r=l.clone(),n[t]=r),l=r}return l.visible=i.visible,l.wireframe=i.wireframe,l.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:h[i.side],l.clipShadows=i.clipShadows,l.clippingPlanes=i.clippingPlanes,l.clipIntersection=i.clipIntersection,l.wireframeLinewidth=i.wireframeLinewidth,l.linewidth=i.linewidth,!0===r.isPointLight&&!0===l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(r.matrixWorld),l.nearDistance=a,l.farDistance=o),l}function M(n,r,a,o,s){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;lu||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/h.x),r.x=a.x*h.x,c.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/h.y),r.y=a.y*h.y,c.mapSize.y=a.y)),null===c.map&&!c.isPointLightShadow&&3===this.type){const e={minFilter:g,magFilter:g,format:E};c.map=new me(r.x,r.y,e),c.map.texture.name=l.name+".shadowMap",c.mapPass=new me(r.x,r.y,e),c.camera.updateProjectionMatrix()}if(null===c.map){const e={minFilter:p,magFilter:p,format:E};c.map=new me(r.x,r.y,e),c.map.texture.name=l.name+".shadowMap",c.camera.updateProjectionMatrix()}e.setRenderTarget(c.map),e.clear();const m=c.getViewportCount();for(let e=0;e=1):-1!==R.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(R)[1]),A=L>=2);let C=null,P={};const I=new fe(0,0,e.canvas.width,e.canvas.height),D=new fe(0,0,e.canvas.width,e.canvas.height);function O(t,n,i){const r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?oe.floorPowerOfTwo:Math.floor,a=i(r*e.width),o=i(r*e.height);void 0===P&&(P=D(a,o));const s=n?D(a,o):P;return s.width=a,s.height=o,s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function N(e){return oe.isPowerOfTwo(e.width)&&oe.isPowerOfTwo(e.height)}function F(e,t){return e.generateMipmaps&&t&&e.minFilter!==p&&e.minFilter!==g}function B(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log2(Math.max(r,a))}function z(n,i,r){if(!1===s)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let a=i;return 6403===i&&(5126===r&&(a=33326),5131===r&&(a=33325),5121===r&&(a=33321)),6407===i&&(5126===r&&(a=34837),5131===r&&(a=34843),5121===r&&(a=32849)),6408===i&&(5126===r&&(a=34836),5131===r&&(a=34842),5121===r&&(a=32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||t.get("EXT_color_buffer_float"),a}function H(e){return e===p||e===f||e===m?9728:9729}function U(t){const n=t.target;n.removeEventListener("dispose",U),function(t){const n=i.get(t);void 0!==n.__webglInit&&(e.deleteTexture(n.__webglTexture),i.remove(t))}(n),n.isVideoTexture&&C.delete(n),o.memory.textures--}function k(t){const n=t.target;n.removeEventListener("dispose",k),function(t){const n=t.texture,r=i.get(t),a=i.get(n);if(t){if(void 0!==a.__webglTexture&&e.deleteTexture(a.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);i.remove(n),i.remove(t)}}(n),o.memory.textures--}let G=0;function j(e,t){const r=i.get(e);if(e.isVideoTexture&&function(e){const t=o.render.frame;C.get(e)!==t&&(C.set(e,t),e.update())}(e),e.version>0&&r.__version!==e.version){const n=e.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void Y(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,r.__webglTexture)}function V(t,r){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,i,r){if(6!==i.image.length)return;Z(t,i),n.activeTexture(33984+r),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const o=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),l=i.image[0]&&i.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=o||l?l?i.image[e].image:i.image[e]:O(i.image[e],!1,!0,c);const h=u[0],d=N(h)||s,p=a.convert(i.format),f=a.convert(i.type),m=z(i.internalFormat,p,f);let g;if(X(34067,i,d),o){for(let e=0;e<6;e++){g=u[e].mipmaps;for(let t=0;t1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function Z(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",U),t.__webglTexture=e.createTexture(),o.memory.textures++)}function Y(t,i,r){let o=3553;i.isDataTexture2DArray&&(o=35866),i.isDataTexture3D&&(o=32879),Z(t,i),n.activeTexture(33984+r),n.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const l=function(e){return!s&&(e.wrapS!==h||e.wrapT!==h||e.minFilter!==p&&e.minFilter!==g)}(i)&&!1===N(i.image),c=O(i.image,l,!1,x),u=N(c)||s,d=a.convert(i.format);let f,m=a.convert(i.type),v=z(i.internalFormat,d,m);X(o,i,u);const y=i.mipmaps;if(i.isDepthTexture)v=6402,s?v=i.type===_?36012:i.type===w?33190:i.type===S?35056:33189:i.type===_&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===A&&6402===v&&i.type!==b&&i.type!==w&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=b,m=a.convert(i.type)),i.format===L&&6402===v&&(v=34041,i.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=S,m=a.convert(i.type))),n.texImage2D(3553,0,v,c.width,c.height,0,d,m,null);else if(i.isDataTexture)if(y.length>0&&u){for(let e=0,t=y.length;e0&&u){for(let e=0,t=y.length;e=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),G+=1,e},this.resetTextureUnits=function(){G=0},this.setTexture2D=j,this.setTexture2DArray=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?Y(r,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?Y(r,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=V,this.setupRenderTarget=function(t){const r=t.texture,l=i.get(t),c=i.get(r);t.addEventListener("dispose",k),c.__webglTexture=e.createTexture(),c.__version=r.version,o.memory.textures++;const u=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultisampleRenderTarget,d=r.isDataTexture3D||r.isDataTexture2DArray,p=N(t)||s;if(!s||r.format!==T||r.type!==_&&r.type!==M||(r.format=E,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),u){l.__webglFramebuffer=[];for(let t=0;t<6;t++)l.__webglFramebuffer[t]=e.createFramebuffer()}else if(l.__webglFramebuffer=e.createFramebuffer(),h)if(s){l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,l.__webglColorRenderbuffer);const i=a.convert(r.format),o=a.convert(r.type),s=z(r.internalFormat,i,o),c=Q(t);e.renderbufferStorageMultisample(36161,c,s,t.width,t.height),n.bindFramebuffer(36160,l.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,l.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(l.__webglDepthRenderbuffer=e.createRenderbuffer(),K(l.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){n.bindTexture(34067,c.__webglTexture),X(34067,r,p);for(let e=0;e<6;e++)J(l.__webglFramebuffer[e],t,36064,34069+e);F(r,p)&&B(34067,r,t.width,t.height),n.bindTexture(34067,null)}else{let e=3553;d&&(s?e=r.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),n.bindTexture(e,c.__webglTexture),X(e,r,p),J(l.__webglFramebuffer,t,36064,e),F(r,p)&&B(3553,r,t.width,t.height),n.bindTexture(3553,null)}t.depthBuffer&&function(t){const r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),j(r.depthTexture,0);const a=i.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===A)e.framebufferTexture2D(36160,36096,3553,a,0);else{if(r.depthTexture.format!==L)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,a,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(36160,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=e.createRenderbuffer(),K(r.__webglDepthbuffer[i],t,!1)}else n.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),K(r.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}(t)},this.updateRenderTargetMipmap=function(e){const t=e.texture;if(F(t,N(e)||s)){const r=e.isWebGLCubeRenderTarget?34067:3553,a=i.get(t).__webglTexture;n.bindTexture(r,a),B(r,t,e.width,e.height),n.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(s){const r=i.get(t);n.bindFramebuffer(36008,r.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,r.__webglFramebuffer);const a=t.width,o=t.height;let s=16384;t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024),e.blitFramebuffer(0,0,a,o,0,0,a,o,s,9728),n.bindFramebuffer(36160,r.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===$&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),$=!0),e=e.texture),j(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===ee&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ee=!0),e=e.texture),V(e,t)}}function ia(e,t,n){const i=n.isWebGL2;return{convert:function(e){let n;if(e===x)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===b)return 5123;if(1013===e)return 5124;if(e===w)return 5125;if(e===_)return 5126;if(e===M)return i?5131:null!==(n=t.get("OES_texture_half_float"))?n.HALF_FLOAT_OES:null;if(1021===e)return 6406;if(e===T)return 6407;if(e===E)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===A)return 6402;if(e===L)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(e===R||e===C||e===P||e===I){if(null===(n=t.get("WEBGL_compressed_texture_s3tc")))return null;if(e===R)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===C)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===P)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===I)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===D||e===O||e===N||e===F){if(null===(n=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===D)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===O)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===N)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===F)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return null!==(n=t.get("WEBGL_compressed_texture_etc1"))?n.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===B||e===z)&&null!==(n=t.get("WEBGL_compressed_texture_etc"))){if(e===B)return n.COMPRESSED_RGB8_ETC2;if(e===z)return n.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?null!==(n=t.get("WEBGL_compressed_texture_astc"))?e:null:36492===e?null!==(n=t.get("EXT_texture_compression_bptc"))?e:null:e===S?i?34042:null!==(n=t.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}$r.prototype.isMeshDistanceMaterial=!0;class ra extends Gn{constructor(e=[]){super(),this.cameras=e}}ra.prototype.isArrayCamera=!0;class aa extends bt{constructor(){super(),this.type="Group"}}function oa(){this._targetRay=null,this._grip=null,this._hand=null}function sa(e,t){const n=this,i=e.state;let r=null,a=1,o=null,s="local-floor",l=null;const c=[],u=new Map,h=new Gn;h.layers.enable(1),h.viewport=new fe;const d=new Gn;d.layers.enable(2),d.viewport=new fe;const p=[h,d],f=new ra;f.layers.enable(1),f.layers.enable(2);let m=null,g=null;function v(e){const t=u.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function y(){u.forEach((function(e,t){e.disconnect(t)})),u.clear(),m=null,g=null,i.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),S.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function x(e){const t=r.inputSources;for(let n=0;n0&&Le(a,e,t),o.length>0&&Le(o,e,t),null!==b&&(J.updateRenderTargetMipmap(b),J.updateMultisampleRenderTarget(b)),!0===e.isScene&&e.onAfterRender(m,e,t),q.buffers.depth.setTest(!0),q.buffers.depth.setMask(!0),q.buffers.color.setMask(!0),q.setPolygonOffset(!1),me.resetDefaultState(),w=-1,S=null,f.pop(),d=f.length>0?f[f.length-1]:null,p.pop(),h=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTarget=function(e,t=0,n=0){b=e,v=t,y=n,e&&void 0===Y.get(e).__webglFramebuffer&&J.setupRenderTarget(e);let i=null,r=!1,a=!1;if(e){const n=e.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(a=!0);const o=Y.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=o[t],r=!0):i=e.isWebGLMultisampleRenderTarget?Y.get(e).__webglMultisampledFramebuffer:o,T.copy(e.viewport),A.copy(e.scissor),L=e.scissorTest}else T.copy(O).multiplyScalar(P).floor(),A.copy(N).multiplyScalar(P).floor(),L=F;if(q.bindFramebuffer(36160,i),q.viewport(T),q.scissor(A),q.setScissorTest(L),r){const i=Y.get(e.texture);ge.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}else if(a){const i=Y.get(e.texture),r=t||0;ge.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,r)}},this.readRenderTargetPixels=function(e,t,n,i,r,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=Y.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){q.bindFramebuffer(36160,s);try{const o=e.texture,s=o.format,l=o.type;if(s!==E&&pe.convert(s)!==ge.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===M&&(V.has("EXT_color_buffer_half_float")||W.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(l===x||pe.convert(l)===ge.getParameter(35738)||l===_&&(W.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ge.checkFramebufferStatus(36160)?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&ge.readPixels(t,n,i,r,pe.convert(s),pe.convert(l),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==b?Y.get(b).__webglFramebuffer:null;q.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i),o=pe.convert(t.format);J.setTexture2D(t,0),ge.copyTexImage2D(3553,n,o,e.x,e.y,r,a,0),q.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,a=t.image.height,o=pe.convert(n.format),s=pe.convert(n.type);J.setTexture2D(n,0),ge.pixelStorei(37440,n.flipY),ge.pixelStorei(37441,n.premultiplyAlpha),ge.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?ge.texSubImage2D(3553,i,e.x,e.y,r,a,o,s,t.image.data):t.isCompressedTexture?ge.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):ge.texSubImage2D(3553,i,e.x,e.y,o,s,t.image),0===i&&n.generateMipmaps&&ge.generateMipmap(3553),q.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(m.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const{width:a,height:o,data:s}=n.image,l=pe.convert(i.format),c=pe.convert(i.type);let u;if(i.isDataTexture3D)J.setTexture3D(i,0),u=32879;else{if(!i.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");J.setTexture2DArray(i,0),u=35866}ge.pixelStorei(37440,i.flipY),ge.pixelStorei(37441,i.premultiplyAlpha),ge.pixelStorei(3317,i.unpackAlignment);const h=ge.getParameter(3314),d=ge.getParameter(32878),p=ge.getParameter(3316),f=ge.getParameter(3315),g=ge.getParameter(32877);ge.pixelStorei(3314,a),ge.pixelStorei(32878,o),ge.pixelStorei(3316,e.min.x),ge.pixelStorei(3315,e.min.y),ge.pixelStorei(32877,e.min.z),ge.texSubImage3D(u,r,t.x,t.y,t.z,e.max.x-e.min.x+1,e.max.y-e.min.y+1,e.max.z-e.min.z+1,l,c,s),ge.pixelStorei(3314,h),ge.pixelStorei(32878,d),ge.pixelStorei(3316,p),ge.pixelStorei(3315,f),ge.pixelStorei(32877,g),0===r&&i.generateMipmaps&&ge.generateMipmap(u),q.unbindTexture()},this.initTexture=function(e){J.setTexture2D(e,0),q.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,q.reset(),me.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}aa.prototype.isGroup=!0,Object.assign(oa.prototype,{constructor:oa,getHandSpace:function(){return null===this._hand&&(this._hand=new aa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new aa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new aa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(e,t,n){let i=null,r=null,a=null;const o=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==o&&null!==(i=t.getPose(e.targetRaySpace,n))&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale)),l&&e.hand){a=!0;for(const a of e.hand.values()){const e=t.getJointPose(a,n);if(void 0===l.joints[a.jointName]){const e=new aa;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[a.jointName]=e,l.add(e)}const i=l.joints[a.jointName];null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=e.radius),i.visible=null!==e}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],o=i.position.distanceTo(r.position),s=.02,c=.005;l.inputState.pinching&&o>s+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&o<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale));return null!==o&&(o.visible=null!==i),null!==s&&(s.visible=null!==r),null!==l&&(l.visible=null!==a),this}}),Object.assign(sa.prototype,ie.prototype);class ua extends ca{}ua.prototype.isWebGL1Renderer=!0;class ha{constructor(e,t=25e-5){this.name="",this.color=new Vt(e),this.density=t}clone(){return new ha(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}ha.prototype.isFogExp2=!0;class da{constructor(e,t=1,n=1e3){this.name="",this.color=new Vt(e),this.near=t,this.far=n}clone(){return new da(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}da.prototype.isFog=!0;class pa extends bt{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.environment&&(t.object.environment=this.environment.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}function fa(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=ee,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=oe.generateUUID()}pa.prototype.isScene=!0,Object.defineProperty(fa.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(fa.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:s,point:xa.clone(),uv:Nt.getUV(xa,Ta,Ea,Aa,La,Ra,Ca,new se),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Ia(e,t,n,i,r,a){_a.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Ma.x=a*_a.x-r*_a.y,Ma.y=r*_a.x+a*_a.y):Ma.copy(_a),e.copy(t),e.x+=Ma.x,e.y+=Ma.y,e.applyMatrix4(Sa)}Pa.prototype.isSprite=!0;const Da=new ye,Oa=new ye;class Na extends bt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Da.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Da);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Da.setFromMatrixPosition(e.matrixWorld),Oa.setFromMatrixPosition(this.matrixWorld);const n=Da.distanceTo(Oa)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;is)continue;h.applyMatrix4(this.matrixWorld);const d=e.ray.origin.distanceTo(h);de.far||t.push({distance:d,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,a.start),o=Math.min(r.count,a.start+a.count)-1;ns)continue;h.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(h);ie.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const ro=new ye,ao=new ye;function oo(e,t){io.call(this,e,t),this.type="LineSegments"}oo.prototype=Object.assign(Object.create(io.prototype),{constructor:oo,isLineSegments:!0,computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}fo.prototype=Object.assign(Object.create(bt.prototype),{constructor:fo,isPoints:!0,copy:function(e){return bt.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ho.copy(n.boundingSphere),ho.applyMatrix4(i),ho.radius+=r,!1===e.ray.intersectsSphere(ho))return;co.copy(i).invert(),uo.copy(e.ray).applyMatrix4(co);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position;if(null!==r)for(let n=Math.max(0,a.start),l=Math.min(r.count,a.start+a.count);n0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});class go extends de{constructor(e,t,n,i,r,a,o,s,l){super(e,t,n,i,r,a,o,s,l),this.format=void 0!==o?o:T,this.minFilter=void 0!==a?a:g,this.magFilter=void 0!==r?r:g,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}go.prototype.isVideoTexture=!0;class vo extends de{constructor(e,t,n,i,r,a,o,s,l,c,u,h){super(null,a,o,s,l,c,i,r,u,h),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}vo.prototype.isCompressedTexture=!0;class yo extends de{constructor(e,t,n,i,r,a,o,s,l){super(e,t,n,i,r,a,o,s,l),this.needsUpdate=!0}}yo.prototype.isCanvasTexture=!0;class xo extends de{constructor(e,t,n,i,r,a,o,s,l,c){if((c=void 0!==c?c:A)!==A&&c!==L)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===A&&(n=b),void 0===n&&c===L&&(n=S),super(null,i,r,a,o,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:p,this.minFilter=void 0!==s?s:p,this.flipY=!1,this.generateMipmaps=!1}}xo.prototype.isDepthTexture=!0;class bo extends gn{constructor(e=1,t=8,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],s=[],l=new ye,c=new se;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let u=0,h=3;u<=t;u++,h+=3){const r=n+u/t*i;l.x=e*Math.cos(r),l.y=e*Math.sin(r),a.push(l.x,l.y,l.z),o.push(0,0,1),c.x=(a[h]/e+1)/2,c.y=(a[h+1]/e+1)/2,s.push(c.x,c.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new rn(a,3)),this.setAttribute("normal",new rn(o,3)),this.setAttribute("uv",new rn(s,2))}}class wo extends gn{constructor(e=1,t=1,n=1,i=8,r=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:s};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],u=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const r=p,a=new se,f=new ye;let v=0;const y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*x,0),h.push(0,x,0),d.push(.5,.5),p++;const b=p;for(let e=0;e<=i;e++){const t=e/i*s+o,n=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*x,f.z=y*n,u.push(f.x,f.y,f.z),h.push(0,x,0),a.x=.5*n+.5,a.y=.5*r*x+.5,d.push(a.x,a.y),p++}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new rn(u,3)),this.setAttribute("normal",new rn(h,3)),this.setAttribute("uv",new rn(d,2))}}class _o extends wo{constructor(e=1,t=1,n=8,i=1,r=!1,a=0,o=2*Math.PI){super(0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}}class Mo extends gn{constructor(e,t,n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function o(e,t,n,i){const r=i+1,a=[];for(let o=0;o<=r;o++){a[o]=[];const i=e.clone().lerp(n,o/r),s=t.clone().lerp(n,o/r),l=r-o;for(let e=0;e<=l;e++)a[o][e]=0===e&&o===r?i:i.clone().lerp(s,e/l)}for(let o=0;o.9&&o<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new rn(r,3)),this.setAttribute("normal",new rn(r.slice(),3)),this.setAttribute("uv",new rn(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}}class So extends Mo{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[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="DodecahedronGeometry",this.parameters={radius:e,detail:t}}}const To=new ye,Eo=new ye,Ao=new ye,Lo=new Nt;class Ro extends gn{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1,!0===e.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const n=Math.pow(10,4),i=Math.cos(oe.DEG2RAD*t),r=e.getIndex(),a=e.getAttribute("position"),o=r?r.count:a.count,s=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let d=0;d0)for(a=t;a=t;a-=i)o=Ko(a,e[a],e[a+1],o);return o&&Wo(o,o.next)&&(Qo(o),o=o.next),o}function Po(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!Wo(i,i.next)&&0!==Vo(i.prev,i,i.next))i=i.next;else{if(Qo(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function Io(e,t,n,i,r,a,o){if(!e)return;!o&&a&&function(e,t,n,i){let r=e;do{null===r.z&&(r.z=Uo(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,a,o,s,l,c=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,c*=2}while(o>1)}(r)}(e,i,r,a);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,a?Oo(e,i,r,a):Do(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),Qo(e),e=l.next,c=l.next;else if((e=l)===c){o?1===o?Io(e=No(Po(e),t,n),t,n,i,r,a,2):2===o&&Fo(e,t,n,i,r,a):Io(Po(e),t,n,i,r,a,1);break}}function Do(e){const t=e.prev,n=e,i=e.next;if(Vo(t,n,i)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Go(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Vo(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Oo(e,t,n,i){const r=e.prev,a=e,o=e.next;if(Vo(r,a,o)>=0)return!1;const s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,u=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,h=Uo(s,l,t,n,i),d=Uo(c,u,t,n,i);let p=e.prevZ,f=e.nextZ;for(;p&&p.z>=h&&f&&f.z<=d;){if(p!==e.prev&&p!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Vo(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Vo(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Vo(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Vo(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function No(e,t,n){let i=e;do{const r=i.prev,a=i.next.next;!Wo(r,a)&&qo(r,i,i.next,a)&&Yo(r,a)&&Yo(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),Qo(i),Qo(i.next),i=e=a),i=i.next}while(i!==e);return Po(i)}function Fo(e,t,n,i,r,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&jo(o,e)){let s=Jo(o,e);return o=Po(o,o.next),s=Po(s,s.next),Io(o,t,n,i,r,a),void Io(s,t,n,i,r,a)}e=e.next}o=o.next}while(o!==e)}function Bo(e,t){return e.x-t.x}function zo(e,t){if(t=function(e,t){let n=t;const i=e.x,r=e.y;let a,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>o){if(o=e,e===i){if(r===n.y)return n;if(r===n.next.y)return n.next}a=n.x=n.x&&n.x>=l&&i!==n.x&&Go(ra.x||n.x===a.x&&Ho(a,n)))&&(a=n,h=u)),n=n.next}while(n!==s);return a}(e,t)){const n=Jo(t,e);Po(t,t.next),Po(n,n.next)}}function Ho(e,t){return Vo(e.prev,e,t.prev)<0&&Vo(t.next,e,e.next)<0}function Uo(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ko(e){let t=e,n=e;do{(t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function jo(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&qo(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Yo(e,t)&&Yo(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(Vo(e.prev,e,t.prev)||Vo(e,t.prev,t))||Wo(e,t)&&Vo(e.prev,e,e.next)>0&&Vo(t.prev,t,t.next)>0)}function Vo(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Wo(e,t){return e.x===t.x&&e.y===t.y}function qo(e,t,n,i){const r=Zo(Vo(e,t,n)),a=Zo(Vo(e,t,i)),o=Zo(Vo(n,i,e)),s=Zo(Vo(n,i,t));return r!==a&&o!==s||!(0!==r||!Xo(e,n,t))||!(0!==a||!Xo(e,i,t))||!(0!==o||!Xo(n,e,i))||!(0!==s||!Xo(n,t,i))}function Xo(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Zo(e){return e>0?1:e<0?-1:0}function Yo(e,t){return Vo(e.prev,e,e.next)<0?Vo(e,t,e.next)>=0&&Vo(e,e.prev,t)>=0:Vo(e,t,e.prev)<0||Vo(e,e.next,t)<0}function Jo(e,t){const n=new $o(e.i,e.x,e.y),i=new $o(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Ko(e,t,n,i){const r=new $o(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Qo(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function $o(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}const es={area:function(e){const t=e.length;let n=0;for(let i=t-1,r=0;r80*n){s=c=e[0],l=u=e[1];for(let t=n;tc&&(c=h),d>u&&(u=d);p=0!==(p=Math.max(c-s,u-l))?1/p:0}return Io(a,o,n,s,l,p),o}(n,i);for(let s=0;s2&&e[t-1].equals(e[0])&&e.pop()}function ns(e,t){for(let n=0;nNumber.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=t.x-s/h,f=t.y+o/h,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(o*c-s*l),g=(i=p+o*m-e.x)*i+(r=f+s*m-e.y)*r;if(g<=2)return new se(i,r);a=Math.sqrt(g/2)}else{let e=!1;o>Number.EPSILON?l>Number.EPSILON&&(e=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(i=-s,r=o,a=Math.sqrt(u)):(i=o,r=s,a=Math.sqrt(u/2))}return new se(i/a,r/a)}const P=[];for(let t=0,n=E.length,i=n-1,r=t+1;t=0;t--){const e=t/p,n=u*Math.cos(e*Math.PI/2),i=h*Math.sin(e*Math.PI/2)+d;for(let t=0,r=E.length;t=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*p;e=0?(e(p-s,i,u),h.subVectors(c,u)):(e(p+s,i,u),h.subVectors(u,c)),i-s>=0?(e(p,i-s,u),d.subVectors(c,u)):(e(p,i+s,u),d.subVectors(u,c)),l.crossVectors(h,d).normalize(),a.push(l.x,l.y,l.z),o.push(p,i)}}for(let f=0;f0)&&d.push(t,i,o),(g!==n-1||s=i)){s.push(e.times[a]);for(let n=0;na.tracks[l].times[0]&&(s=a.tracks[l].times[0]);for(let l=0;l=t.times[h]){const e=h*l+s,n=e+l-s;d=Cs.arraySlice(t.values,e,n)}else{const e=t.createInterpolant(),n=s,i=l-s;e.evaluate(a),d=Cs.arraySlice(e.resultBuffer,n,i)}"quaternion"===i&&(new ve).fromArray(d).normalize().conjugate().toArray(d);const p=r.times.length;for(let e=0;e=r)break e;{const o=t[1];e=(r=t[--n-1]))break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);const e=this.getValueSize();this.times=Cs.arraySlice(n,r,a),this.values=Cs.arraySlice(this.values,r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const t=n[o];if("number"==typeof t&&isNaN(t)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,t),e=!1;break}if(null!==a&&a>t){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,t,a),e=!1;break}a=t}if(void 0!==i&&Cs.isTypedArray(i))for(let o=0,s=i.length;o!==s;++o){const t=i[o];if(isNaN(t)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,t),e=!1;break}}return e}optimize(){const e=Cs.arraySlice(this.times),t=Cs.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===k,r=e.length-1;let a=1;for(let o=1;o0){e[a]=e[r];for(let e=r*n,i=a*n,o=0;o!==n;++o)t[i+o]=t[e+o];++a}return a!==e.length?(this.times=Cs.arraySlice(e,0,a),this.values=Cs.arraySlice(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=Cs.arraySlice(this.times,0),t=Cs.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Ns.prototype.TimeBufferType=Float32Array,Ns.prototype.ValueBufferType=Float32Array,Ns.prototype.DefaultInterpolation=U;class Fs extends Ns{}Fs.prototype.ValueTypeName="bool",Fs.prototype.ValueBufferType=Array,Fs.prototype.DefaultInterpolation=H,Fs.prototype.InterpolantFactoryMethodLinear=void 0,Fs.prototype.InterpolantFactoryMethodSmooth=void 0;class Bs extends Ns{}Bs.prototype.ValueTypeName="color";class zs extends Ns{}function Hs(e,t,n,i){Ps.call(this,e,t,n,i)}zs.prototype.ValueTypeName="number",Hs.prototype=Object.assign(Object.create(Ps.prototype),{constructor:Hs,interpolate_:function(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(i-t);let l=e*o;for(let c=l+o;l!==c;l+=4)ve.slerpFlat(r,0,a,l-o,a,l,s);return r}});class Us extends Ns{InterpolantFactoryMethodLinear(e){return new Hs(this.times,this.values,this.getValueSize(),e)}}Us.prototype.ValueTypeName="quaternion",Us.prototype.DefaultInterpolation=U,Us.prototype.InterpolantFactoryMethodSmooth=void 0;class ks extends Ns{}ks.prototype.ValueTypeName="string",ks.prototype.ValueBufferType=Array,ks.prototype.DefaultInterpolation=H,ks.prototype.InterpolantFactoryMethodLinear=void 0,ks.prototype.InterpolantFactoryMethodSmooth=void 0;class Gs extends Ns{}Gs.prototype.ValueTypeName="vector";class js{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=oe.generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Vs(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(Ns.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o1){const e=n[1];let r=i[e];r||(i[e]=r=[]),r.push(t)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],o=[];Cs.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let c=0;c0||0===e.search(/^data\:image\/jpeg/);r.format=i?T:E,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}),Object.assign(nl.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){const e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)r+=(n=this.getPoint(a/e)).distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let o,s=0,l=r-1;for(;s<=l;)if((o=n[i=Math.floor(s+(l-s)/2)]-a)<0)s=i+1;else{if(!(o>0)){l=i;break}l=i-1}if(n[i=l]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)},getTangent:function(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);const r=this.getPoint(n),a=this.getPoint(i),o=t||(r.isVector2?new se:new ye);return o.copy(a).sub(r).normalize(),o},getTangentAt:function(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)},computeFrenetFrames:function(e,t){const n=new ye,i=[],r=[],a=[],o=new ye,s=new Ye;for(let d=0;d<=e;d++){const t=d/e;i[d]=this.getTangentAt(t,new ye),i[d].normalize()}r[0]=new ye,a[0]=new ye;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(oe.clamp(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(s.makeRotationAxis(o,e))}a[d].crossVectors(i[d],r[d])}if(!0===t){let t=Math.acos(oe.clamp(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}});class il extends nl{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new se,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?o=i[(l-1)%r]:(ol.subVectors(i[0],i[1]).add(i[0]),o=ol);const u=i[l%r],h=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(hl(o,s.x,l.x,c.x,u.x),hl(o,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=t){const e=n[i]-t,r=this.curves[i],a=r.getLength(),o=0===a?0:1-e/a;return r.getPointAt(o)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Sl extends Ml{constructor(e){super(e),this.uuid=oe.generateUUID(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const r in e.uniforms){const t=e.uniforms[r];switch(i.uniforms[r]={},t.type){case"t":i.uniforms[r].value=n(t.value);break;case"c":i.uniforms[r].value=(new Vt).setHex(t.value);break;case"v2":i.uniforms[r].value=(new se).fromArray(t.value);break;case"v3":i.uniforms[r].value=(new ye).fromArray(t.value);break;case"v4":i.uniforms[r].value=(new fe).fromArray(t.value);break;case"m3":i.uniforms[r].value=(new le).fromArray(t.value);break;case"m4":i.uniforms[r].value=(new Ye).fromArray(t.value);break;default:i.uniforms[r].value=t.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(void 0!==e.shading&&(i.flatShading=1===e.shading),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new se).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new se).fromArray(e.clearcoatNormalScale)),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),i}setTextures(e){return this.textures=e,this}}const ql={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;nNumber.EPSILON){if(l<0&&(n=t[a],s=-s,o=t[r],l=-l),e.yo.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return i}const r=es.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return n(a);let o,s,l;const c=[];if(1===a.length)return s=a[0],(l=new Sl).curves=s.curves,c.push(l),c;let u=!r(a[0].getPoints());u=e?!u:u;const h=[],d=[];let p,f,m=[],g=0;d[g]=void 0,m[g]=[];for(let v=0,y=a.length;v1){let e=!1;const t=[];for(let n=0,i=d.length;n0&&(e||(m=h))}for(let v=0,y=d.length;v0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let s=t,l=t+t;s!==l;++s)if(n[s]!==n[s+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){ve.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const a=this._workIndex*r;ve.multiplyQuaternionsFlat(e,a,e,t,e,n),ve.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){const a=1-i;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]+e[n+a]*i}}}const Mc=new RegExp("[\\[\\]\\.:\\/]","g"),Sc="[^\\[\\]\\.:\\/]",Tc="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Ec=/((?:WC+[\/:])*)/.source.replace("WC",Sc),Ac=/(WCOD+)?/.source.replace("WCOD",Tc),Lc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sc),Rc=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sc),Cc=new RegExp("^"+Ec+Ac+Lc+Rc+"$"),Pc=["material","materials","bones"];function Ic(e,t,n){const i=n||Dc.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}function Dc(e,t,n){this.path=t,this.parsedPath=n||Dc.parseTrackName(t),this.node=Dc.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(Ic.prototype,{getValue:function(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)},setValue:function(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)},bind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(Dc,{Composite:Ic,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new Dc.Composite(e,t,n):new Dc(e,t,n)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(Mc,"")},parseTrackName:function(e){const t=Cc.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==Pc.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n},findNode:function(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i=r){const a=r++,c=e[a];t[c.uuid]=l,e[l]=c,t[s]=a,e[a]=o;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o].uuid,l=t[s];if(void 0!==l)if(delete t[s],l0&&(t[o.uuid]=l),e[l]=o,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);i=r.length,n[e]=i,a.push(e),o.push(t),r.push(u);for(let h=c,d=s.length;h!==d;++h){const n=s[h];u[h]=new Dc(n,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];t[e[o]]=n,a[n]=s,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}}Oc.prototype.isAnimationObjectGroup=!0;class Nc{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,o=new Array(a),s={endingStart:G,endingEnd:G};for(let l=0;l!==a;++l){const e=r[l].createInterpolant(null);o[l]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,r=i/n,a=n/i;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,l=o.sampleValues;return s[0]=r,s[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;if(i<0||0===n)return;this._startTime=null,t=n*i}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case q:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case W:default:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const a=2202===n;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=j,i.endingEnd=j):(i.endingStart=e?this.zeroSlopeAtStart?j:G:V,i.endingEnd=t?this.zeroSlopeAtEnd?j:G:V)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}class Fc extends ie{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let u=0;u!==r;++u){const e=i[u],r=e.name;let l=c[r];if(void 0!==l)a[u]=l;else{if(void 0!==(l=a[u])){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,s,r));continue}const i=t&&t._propertyBindings[u].binding.parsedPath;++(l=new _c(Dc.create(n,r,i),e.ValueTypeName,e.getValueSize())).referenceCount,this._addInactiveBinding(l,s,r),a[u]=l}o[u].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,a);const o=this._bindings,s=this._nActiveBindings;for(let l=0;l!==s;++l)o[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(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(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new se),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new se),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return jc.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Vc.prototype.isBox2=!0;const Wc=new ye,qc=new ye;class Xc{constructor(e=new ye,t=new ye){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new ye),e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new ye),e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new ye),this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Wc.subVectors(e,this.start),qc.subVectors(this.end,this.start);const n=qc.dot(qc);let i=qc.dot(Wc)/n;return t&&(i=oe.clamp(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new ye),this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}function Zc(e){bt.call(this),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Zc.prototype=Object.create(bt.prototype),Zc.prototype.constructor=Zc,Zc.prototype.isImmediateRenderObject=!0;const Yc=new ye,Jc=new ye,Kc=new Ye,Qc=new Ye;class $c extends oo{constructor(e){const t=function e(t){const n=[];t&&t.isBone&&n.push(t);for(let i=0;i>16&32768,i=t>>12&2047;const r=t>>23&255;return r<103?n:r>142?(n|=31744,n|=(255==r?0:1)&&8388607&t):r<113?n|=((i|=2048)>>114-r)+(i>>113-r&1):(n|=r-112<<10|i>>1,n+=1&i)}},xu=Math.pow(2,8),bu=[.125,.215,.35,.446,.526,.582],wu=5+bu.length,_u={[X]:0,[Z]:1,[J]:2,[K]:3,[Q]:4,[$]:5,[Y]:6},Mu=new Wt({side:1,depthWrite:!1,depthTest:!1}),Su=new On(new Fn,Mu),Tu=new zl,{_lodPlanes:Eu,_sizeLods:Au,_sigmas:Lu}=function(){const e=[],t=[],n=[];let i=8;for(let r=0;r4?o=bu[r-8+4-1]:0==r&&(o=0),n.push(o);const s=1/(a-1),l=-s/2,c=1+s/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,d=6,p=3,f=2,m=1,g=new Float32Array(p*d*h),v=new Float32Array(f*d*h),y=new Float32Array(m*d*h);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(i,p*d*e),v.set(u,f*d*e);const r=[e,e,e,e,e,e];y.set(r,m*d*e)}const x=new gn;x.setAttribute("position",new Zt(g,p)),x.setAttribute("uv",new Zt(v,f)),x.setAttribute("faceIndex",new Zt(y,m)),e.push(x),i>4&&i--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}(),Ru=new Vt;let Cu=null;const Pu=(1+Math.sqrt(5))/2,Iu=1/Pu,Du=[new ye(1,1,1),new ye(-1,1,1),new ye(1,1,-1),new ye(-1,1,-1),new ye(0,Pu,Iu),new ye(0,Pu,-Iu),new ye(Iu,0,Pu),new ye(-Iu,0,Pu),new ye(Pu,Iu,0),new ye(-Pu,Iu,0)];function Ou(e){const t=Math.max(e.r,e.g,e.b),n=Math.min(Math.max(Math.ceil(Math.log2(t)),-128),127);return e.multiplyScalar(Math.pow(2,-n)),(n+128)/255}function Nu(e){return void 0!==e&&e.type===x&&(e.encoding===X||e.encoding===Z||e.encoding===Y)}function Fu(e){const t=new me(3*xu,3*xu,e);return t.texture.mapping=l,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Bu(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function zu(){const e=new se(1,1);return new bs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:_u[3e3]},outputEncoding:{value:_u[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Hu(){return new bs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:_u[3e3]},outputEncoding:{value:_u[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}nl.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(nl.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Ml.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},iu.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},$c.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Zs.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),ql.extractUrlBase(e)},Zs.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Vc.prototype.center=function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},Vc.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Vc.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Vc.prototype.size=function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},we.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},we.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},we.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},we.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},we.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},Ue.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Yn.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Xc.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},oe.random16=function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},oe.nearestPowerOfTwo=function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),oe.floorPowerOfTwo(e)},oe.nextPowerOfTwo=function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),oe.ceilPowerOfTwo(e)},le.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},le.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},le.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},le.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},le.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},le.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Ye.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},Ye.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Ye.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new ye).setFromMatrixColumn(this,3)},Ye.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},Ye.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},Ye.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},Ye.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},Ye.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},Ye.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},Ye.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},Ye.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},Ye.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},Ye.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},Ye.prototype.makeFrustum=function(e,t,n,i,r,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,i,n,r,a)},Ye.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},St.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},ve.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},ve.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},Ze.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Ze.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},Ze.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Nt.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},Nt.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},Nt.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},Nt.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},Nt.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},Nt.barycoordFromPoint=function(e,t,n,i,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Nt.getBarycoord(e,t,n,i,r)},Nt.normal=function(e,t,n,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Nt.getNormal(e,t,n,i)},Sl.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},Sl.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new is(this,e)},Sl.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new us(this,e)},se.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},se.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},se.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},ye.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},ye.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},ye.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},ye.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},ye.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},ye.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},ye.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},ye.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},ye.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},fe.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},fe.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},bt.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},bt.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},bt.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},bt.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},bt.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(bt.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),On.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(On.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),ka.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(nl.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),Gn.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Tl.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Zt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===te},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(te)}}}),Zt.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?te:ee),this},Zt.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},Zt.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},gn.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},gn.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new Zt(arguments[1],arguments[2])))},gn.prototype.addDrawCall=function(e,t,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},gn.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},gn.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},gn.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},gn.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(gn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(Xl.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(e){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=e}}}),Object.defineProperties(Uc.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(e){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=e}}}),Object.defineProperties(fa.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===te},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),fa.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?te:ee),this},fa.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},is.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},is.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},is.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},pa.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Bc.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(Bt.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Vt}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(_s.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(e){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=e}}}),Object.defineProperties(Un.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),ca.prototype.clearTarget=function(e,t,n,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,n,i)},ca.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},ca.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},ca.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},ca.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},ca.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},ca.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},ca.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},ca.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},ca.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},ca.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},ca.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},ca.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},ca.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},ca.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},ca.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},ca.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},ca.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},ca.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},ca.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},ca.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},ca.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},ca.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},ca.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},ca.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(ca.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?Z:X}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(ea.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(me.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),gc.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new ac).load(e,(function(e){t.setBuffer(e)})),this},wc.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},jn.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},jn.prototype.clear=function(e,t,n,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,n,i)},ue.crossOrigin=void 0,ue.loadTexture=function(e,t,n,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new tl;r.setCrossOrigin(this.crossOrigin);const a=r.load(e,n,void 0,i);return t&&(a.mapping=t),a},ue.loadTextureCube=function(e,t,n,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new $s;r.setCrossOrigin(this.crossOrigin);const a=r.load(e,n,void 0,i);return t&&(a.mapping=t),a},ue.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ue.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const Uu={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t),e.ACESFilmicToneMapping=4,e.AddEquation=n,e.AddOperation=2,e.AdditiveAnimationBlendMode=q,e.AdditiveBlending=2,e.AlphaFormat=1021,e.AlwaysDepth=1,e.AlwaysStencilFunc=519,e.AmbientLight=kl,e.AmbientLightProbe=sc,e.AnimationClip=js,e.AnimationLoader=class extends Zs{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=[];for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{du.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(du,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}},e.Audio=gc,e.AudioAnalyser=wc,e.AudioContext=rc,e.AudioListener=class extends bt{constructor(){super(),this.type="AudioListener",this.context=rc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new uc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(dc,pc,fc),mc.set(0,0,-1).applyQuaternion(pc),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(dc.x,e),t.positionY.linearRampToValueAtTime(dc.y,e),t.positionZ.linearRampToValueAtTime(dc.z,e),t.forwardX.linearRampToValueAtTime(mc.x,e),t.forwardY.linearRampToValueAtTime(mc.y,e),t.forwardZ.linearRampToValueAtTime(mc.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(dc.x,dc.y,dc.z),t.setOrientation(mc.x,mc.y,mc.z,n.x,n.y,n.z)}},e.AudioLoader=ac,e.AxesHelper=mu,e.AxisHelper=function(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new mu(e)},e.BackSide=1,e.BasicDepthPacking=3200,e.BasicShadowMap=0,e.BinaryTextureLoader=function(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new el(e)},e.Bone=Ga,e.BooleanKeyframeTrack=Fs,e.BoundingBoxHelper=function(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new hu(e,t)},e.Box2=Vc,e.Box3=we,e.Box3Helper=class extends oo{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new gn;i.setIndex(new Zt(n,1)),i.setAttribute("position",new rn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Ka({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}},e.BoxBufferGeometry=Fn,e.BoxGeometry=Fn,e.BoxHelper=hu,e.BufferAttribute=Zt,e.BufferGeometry=gn,e.BufferGeometryLoader=Yl,e.ByteType=1010,e.Cache=Ws,e.Camera=kn,e.CameraHelper=class extends oo{constructor(e){const t=new gn,n=new Ka({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={},o=new Vt(16755200),s=new Vt(16711680),l=new Vt(43775),c=new Vt(16777215),u=new Vt(3355443);function h(e,t,n){d(e,n),d(t,n)}function d(e,t){i.push(0,0,0),r.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(i.length/3-1)}h("n1","n2",o),h("n2","n4",o),h("n4","n3",o),h("n3","n1",o),h("f1","f2",o),h("f2","f4",o),h("f4","f3",o),h("f3","f1",o),h("n1","f1",o),h("n2","f2",o),h("n3","f3",o),h("n4","f4",o),h("p","n1",s),h("p","n2",s),h("p","n3",s),h("p","n4",s),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",c),h("p","c",u),h("cn1","cn2",u),h("cn3","cn4",u),h("cf1","cf2",u),h("cf3","cf4",u),t.setAttribute("position",new rn(i,3)),t.setAttribute("color",new rn(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){const e=this.geometry,t=this.pointMap;lu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),cu("c",t,e,lu,0,0,-1),cu("t",t,e,lu,0,0,1),cu("n1",t,e,lu,-1,-1,-1),cu("n2",t,e,lu,1,-1,-1),cu("n3",t,e,lu,-1,1,-1),cu("n4",t,e,lu,1,1,-1),cu("f1",t,e,lu,-1,-1,1),cu("f2",t,e,lu,1,-1,1),cu("f3",t,e,lu,-1,1,1),cu("f4",t,e,lu,1,1,1),cu("u1",t,e,lu,.7,1.1,-1),cu("u2",t,e,lu,-.7,1.1,-1),cu("u3",t,e,lu,0,2,-1),cu("cf1",t,e,lu,-1,0,1),cu("cf2",t,e,lu,1,0,1),cu("cf3",t,e,lu,0,-1,1),cu("cf4",t,e,lu,0,1,1),cu("cn1",t,e,lu,-1,0,-1),cu("cn2",t,e,lu,1,0,-1),cu("cn3",t,e,lu,0,-1,-1),cu("cn4",t,e,lu,0,1,-1),e.getAttribute("position").needsUpdate=!0}},e.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},e.CanvasTexture=yo,e.CatmullRomCurve3=ul,e.CineonToneMapping=3,e.CircleBufferGeometry=bo,e.CircleGeometry=bo,e.ClampToEdgeWrapping=h,e.Clock=uc,e.Color=Vt,e.ColorKeyframeTrack=Bs,e.CompressedTexture=vo,e.CompressedTextureLoader=Ks,e.ConeBufferGeometry=_o,e.ConeGeometry=_o,e.CubeCamera=jn,e.CubeReflectionMapping=r,e.CubeRefractionMapping=a,e.CubeTexture=Vn,e.CubeTextureLoader=$s,e.CubeUVReflectionMapping=l,e.CubeUVRefractionMapping=c,e.CubicBezierCurve=fl,e.CubicBezierCurve3=ml,e.CubicInterpolant=Is,e.CullFaceBack=1,e.CullFaceFront=2,e.CullFaceFrontBack=3,e.CullFaceNone=0,e.Curve=nl,e.CurvePath=_l,e.CustomBlending=5,e.CustomToneMapping=5,e.CylinderBufferGeometry=wo,e.CylinderGeometry=wo,e.Cylindrical=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}},e.DataTexture=qn,e.DataTexture2DArray=gi,e.DataTexture3D=vi,e.DataTextureLoader=el,e.DataUtils=yu,e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=34056,e.DefaultLoadingManager=Xs,e.DepthFormat=A,e.DepthStencilFormat=L,e.DepthTexture=xo,e.DirectionalLight=Ul,e.DirectionalLightHelper=class extends bt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);let i=new gn;i.setAttribute("position",new rn([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Ka({fog:!1,toneMapped:!1});this.lightPlane=new io(i,r),this.add(this.lightPlane),(i=new gn).setAttribute("position",new rn([0,0,0,0,0,1],3)),this.targetLine=new io(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ru.setFromMatrixPosition(this.light.matrixWorld),au.setFromMatrixPosition(this.light.target.matrixWorld),ou.subVectors(au,ru),this.lightPlane.lookAt(au),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(au),this.targetLine.scale.z=ou.length()}},e.DiscreteInterpolant=Os,e.DodecahedronBufferGeometry=So,e.DodecahedronGeometry=So,e.DoubleSide=2,e.DstAlphaFactor=206,e.DstColorFactor=208,e.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new Zt(e,t).setUsage(te)},e.DynamicCopyUsage=35050,e.DynamicDrawUsage=te,e.DynamicReadUsage=35049,e.EdgesGeometry=Ro,e.EdgesHelper=function(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new oo(new Ro(e.geometry),new Ka({color:void 0!==t?t:16777215}))},e.EllipseCurve=il,e.EqualDepth=4,e.EqualStencilFunc=514,e.EquirectangularReflectionMapping=o,e.EquirectangularRefractionMapping=s,e.Euler=at,e.EventDispatcher=ie,e.ExtrudeBufferGeometry=is,e.ExtrudeGeometry=is,e.FaceColors=1,e.FileLoader=Js,e.FlatShading=1,e.Float16BufferAttribute=nn,e.Float32Attribute=function(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new rn(e,t)},e.Float32BufferAttribute=rn,e.Float64Attribute=function(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new an(e,t)},e.Float64BufferAttribute=an,e.FloatType=_,e.Fog=da,e.FogExp2=ha,e.Font=tc,e.FontLoader=class extends Zs{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(e){let n;try{n=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(e.substring(65,e.length-2))}const i=r.parse(n);t&&t(i)}),n,i)}parse(e){return new tc(e)}},e.FrontSide=0,e.Frustum=Yn,e.GLBufferAttribute=Hc,e.GLSL1="100",e.GLSL3=ne,e.GammaEncoding=Y,e.GreaterDepth=6,e.GreaterEqualDepth=5,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=iu,e.Group=aa,e.HalfFloatType=M,e.HemisphereLight=El,e.HemisphereLightHelper=class extends bt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const i=new ss(t);i.rotateY(.5*Math.PI),this.material=new Wt({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),a=new Float32Array(3*r.count);i.setAttribute("color",new Zt(a,3)),this.add(new On(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");tu.copy(this.light.color),nu.copy(this.light.groundColor);for(let e=0,n=t.count;e0){const n=new qs(t);(r=new Qs(n)).setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Cu=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Hu(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=zu(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e2?xu:0,xu,xu),s.setRenderTarget(i),h&&s.render(Su,r),s.render(e,r)}s.toneMapping=u,s.outputEncoding=c,s.autoClear=l}_textureToCubeUV(e,t){const n=this._renderer;e.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Hu()):null==this._equirectShader&&(this._equirectShader=zu());const i=e.isCubeTexture?this._cubemapShader:this._equirectShader,r=new On(Eu[0],i),a=i.uniforms;a.envMap.value=e,e.isCubeTexture||a.texelSize.value.set(1/e.image.width,1/e.image.height),a.inputEncoding.value=_u[e.encoding],a.outputEncoding.value=_u[t.texture.encoding],Bu(t,0,0,3*xu,2*xu),n.setRenderTarget(t),n.render(r,Tu)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let y=0;y<20;++y){const e=y/p,t=Math.exp(-e*e/2);m.push(t),0==y?g+=t:y4?i-8+4:0),3*v,2*v),s.setRenderTarget(t),s.render(c,Tu)}},e.ParametricBufferGeometry=ls,e.ParametricGeometry=ls,e.Particle=function(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Pa(e)},e.ParticleBasicMaterial=function(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new lo(e)},e.ParticleSystem=function(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new fo(e,t)},e.ParticleSystemMaterial=function(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new lo(e)},e.Path=Ml,e.PerspectiveCamera=Gn,e.Plane=St,e.PlaneBufferGeometry=Qn,e.PlaneGeometry=Qn,e.PlaneHelper=class extends io{constructor(e,t=1,n=16776960){const i=n,r=new gn;r.setAttribute("position",new rn([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,0,1,0,0,0],3)),r.computeBoundingSphere(),super(r,new Ka({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=new gn;a.setAttribute("position",new rn([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),a.computeBoundingSphere(),this.add(new On(a,new Wt({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?1:0,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}},e.PointCloud=function(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new fo(e,t)},e.PointCloudMaterial=function(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new lo(e)},e.PointLight=Bl,e.PointLightHelper=class extends On{constructor(e,t,n){super(new hs(t,4,2),new Wt({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},e.Points=fo,e.PointsMaterial=lo,e.PolarGridHelper=class extends oo{constructor(e=10,t=16,n=8,i=64,r=4473924,a=8947848){r=new Vt(r),a=new Vt(a);const o=[],s=[];for(let c=0;c<=t;c++){const n=c/t*(2*Math.PI),i=Math.sin(n)*e,l=Math.cos(n)*e;o.push(0,0,0),o.push(i,0,l);const u=1&c?r:a;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let c=0;c<=n;c++){const t=1&c?r:a,l=e-e/n*c;for(let e=0;e90))return e;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(e){if(e.constructor===Array){for(const t of e)if(!this.Coords(t))return void console.error("Each coordinate in a line must be a valid Coords type");return e}console.error("Line must be an array")},Rotation:function(e){if(e.constructor===Number)e={z:e};else{if(e.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Rotation parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return e},Scale:function(e){if(e.constructor===Number)e={x:e,y:e,z:e};else{if(e.constructor!==Object)return void console.error("Scale must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Scale parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return e}},l=l=c;var u={},h={prettyPrintMatrix:function(e){for(var t=0;t<4;t++){var n=[e[t],e[t+4],e[t+8],e[t+12]];console.log(n.map((function(e){return e.toFixed(4)})))}},makePerspectiveMatrix:function(e,t,n,r){var a=new i.Matrix4,o=1/Math.tan(e/2),s=1/(n-r),l=[o/t,0,0,0,0,o,0,0,0,0,(r+n)*s,-1,0,0,2*r*n*s,0];return a.elements=l,a},makeOrthographicMatrix:function(e,t,n,r,a,o){var s=new i.Matrix4;const l=1/(t-e),c=1/(n-r),u=1/(o-a);var h=[2*l,0,0,0,0,2*c,0,0,0,0,-1*u,0,-(t+e)*l,-(n+r)*c,-a*u,1];return s.elements=h,s},radify:function(e){function t(e){return e=e||0,2*Math.PI*e/360}return"object"==typeof e?e.length>0?e.map((function(e){return t(e)})):[t(e.x),t(e.y),t(e.z)]:t(e)},degreeify:function(e){function t(e){return 360*(e=e||0)/(2*Math.PI)}return"object"==typeof e?[t(e.x),t(e.y),t(e.z)]:t(e)},projectToWorld:function(e){var t=[-r.MERCATOR_A*r.DEG2RAD*e[0]*r.PROJECTION_WORLD_SIZE,-r.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*r.DEG2RAD*e[1]))*r.PROJECTION_WORLD_SIZE];if(e[2]){var n=this.projectedUnitsPerMeter(e[1]);t.push(e[2]*n)}else t.push(0);return new i.Vector3(t[0],t[1],t[2])},projectedUnitsPerMeter:function(e){return Math.abs(r.WORLD_SIZE/Math.cos(r.DEG2RAD*e)/r.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(e){return r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180)},mercatorZfromAltitude:function(e,t){return e/this._circumferenceAtLatitude(t)},_scaleVerticesToMeters:function(e,t){for(var n=this.projectedUnitsPerMeter(e[1]),i=(this.projectToWorld(e),0);i{let{width:n,color:r}=t,a=(new i.BufferGeometry).setFromPoints(e.getPoints(100)),o=new i.LineBasicMaterial({color:r,linewidth:n});return new i.Line(a,o)},curvesToLines:e=>{var t=[16711680,2031360,2490623];return e.map((e,n)=>curveToLine(e,{width:3,color:t[n]||"purple"}))},_validate:function(e,t){e=e||{};var n={};h.extend(n,e);for(let i of Object.keys(t))if(void 0===e[i]){if(null===t[i])return void console.error(i+" is required");n[i]=t[i]}else n[i]=e[i];return n},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};u=u=h;var d={};function p(e,t,n){this.map=e,this.camera=t,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=n||new i.Group,this.world.position.x=this.world.position.y=r.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new i.Matrix4).makeTranslation(r.WORLD_SIZE/2,-r.WORLD_SIZE/2,0),worldSizeRatio:r.TILE_SIZE/r.WORLD_SIZE,worldSize:r.TILE_SIZE*this.map.transform.scale};let a=this;this.map.on("move",(function(){a.updateCamera()})).on("resize",(function(){a.setupCamera()})),this.setupCamera()}p.prototype={setupCamera:function(){this.state.fov=this.map.transform._fov;const e=this.map.transform;this.camera.aspect=e.width/e.height,this.camera.updateProjectionMatrix(),this.halfFov=this.state.fov/2;const t={x:e.width/2,y:e.height/2},n=.5/Math.tan(this.halfFov)*e.height,r=e._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-r,this.state.cameraToCenterDistance=n,this.state.offset=t,this.state.cameraTranslateZ=(new i.Matrix4).makeTranslation(0,0,this.state.cameraToCenterDistance),this.state.maxFurthestDistance=.95*this.state.cameraToCenterDistance*(Math.cos(this.acuteAngle)*Math.sin(this.halfFov)/Math.sin(Math.max(.01,Math.min(Math.PI-.01,this.acuteAngle-this.halfFov)))+1),this.updateCamera()},updateCamera:function(e){if(!this.camera)return void console.log("nocamera");const t=this.map.transform,n=Math.PI/2+t._pitch;this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height,this.state.cameraTranslateZ=(new i.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const r=Math.sin(this.halfFov)*this.state.cameraToCenterDistance/Math.sin(Math.PI-n-this.halfFov),a=Math.cos(Math.PI/2-t._pitch),o=1.01*(a*r+this.state.cameraToCenterDistance),s=t.height/50,l=Math.max(s*a,s),c=t.height,h=t.width;this.camera instanceof i.OrthographicCamera?this.camera.projectionMatrix=u.makeOrthographicMatrix(h/-2,h/2,c/2,c/-2,l,o):this.camera.projectionMatrix=u.makePerspectiveMatrix(this.state.fov,h/c,l,o);let d=this.calcCameraMatrix(t._pitch,t.angle);this.camera.matrixWorld.copy(d);let p=t.scale*this.state.worldSizeRatio,f=new i.Matrix4,m=new i.Matrix4,g=new i.Matrix4;f.makeScale(p,p,p);let v=t.x||t.point.x,y=t.y||t.point.y;m.makeTranslation(-v,y,0),g.makeRotationZ(Math.PI),this.world.matrix=(new i.Matrix4).premultiply(g).premultiply(this.state.translateCenter).premultiply(f).premultiply(m)},calcCameraMatrix(e,t,n){const r=this.map.transform,a=void 0===e?r._pitch:e,o=void 0===t?r.angle:t,s=void 0===n?this.state.cameraTranslateZ:n;return(new i.Matrix4).premultiply(s).premultiply((new i.Matrix4).makeRotationX(a)).premultiply((new i.Matrix4).makeRotationZ(o))}},d=d=p;var f={};!function(){"use strict";var e=Math.PI,t=Math.sin,n=Math.cos,i=Math.tan,r=Math.asin,a=Math.atan2,o=Math.acos,s=e/180;function l(e){return e.valueOf()/864e5-.5+2440588}function c(e){return new Date(864e5*(e+.5-2440588))}function u(e){return l(e)-2451545}var h=23.4397*s;function d(e,r){return a(t(e)*n(h)-i(r)*t(h),n(e))}function p(e,i){return r(t(i)*n(h)+n(i)*t(h)*t(e))}function m(e,r,o){return a(t(e),n(e)*t(r)-i(o)*n(r))}function g(e,i,a){return r(t(i)*t(a)+n(i)*n(a)*n(e))}function v(e,t){return s*(280.16+360.9856235*e)-t}function y(e){return s*(357.5291+.98560028*e)}function x(n){return n+s*(1.9148*t(n)+.02*t(2*n)+3e-4*t(3*n))+102.9372*s+e}function b(e){var t=x(y(e));return{dec:p(t,0),ra:d(t,0)}}var w={getPosition:function(e,t,n){var i=s*-n,r=s*t,a=u(e),o=b(a),l=v(a,i)-o.ra;return{azimuth:m(l,r,o.dec),altitude:g(l,r,o.dec)}},toJulian:function(e){return l(e)}},_=w.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];w.addTime=function(e,t,n){_.push([e,t,n])};function M(t,n,i){return 9e-4+(t+n)/(2*e)+i}function S(e,n,i){return 2451545+e+.0053*t(n)-.0069*t(2*i)}function T(e,i,r,a,s,l,c){return S(M(function(e,i,r){return o((t(e)-t(i)*t(r))/(n(i)*n(r)))}(e,r,a),i,s),l,c)}function E(e){var i=s*(134.963+13.064993*e),r=s*(93.272+13.22935*e),a=s*(218.316+13.176396*e)+6.289*s*t(i),o=5.128*s*t(r),l=385001-20905*n(i);return{ra:d(a,o),dec:p(a,o),dist:l}}function A(e,t){return new Date(e.valueOf()+864e5*t/24)}w.getTimes=function(t,n,i,r){var a,o,l,h,d,f=s*-i,m=s*n,g=function(e){return-2.076*Math.sqrt(e)/60}(r=r||0),v=function(t,n){return Math.round(t-9e-4-n/(2*e))}(u(t),f),b=M(0,f,v),w=y(b),E=x(w),A=p(E,0),L=S(b,w,E),R={solarNoon:c(L),nadir:c(L-.5)};for(a=0,o=_.length;a=0&&(g=d-(y=Math.sqrt(f)/(2*Math.abs(u))),v=d+y,Math.abs(g)<=1&&m++,Math.abs(v)<=1&&m++,g<-1&&(g=v)),1===m?b<0?l=_+g:c=_+g:2===m&&(l=_+(p<0?v:g),c=_+(p<0?g:v)),!l||!c);_+=2)b=o;var M={};return l&&(M.rise=A(r,l)),c&&(M.set=A(r,c)),l||c||(M[p>0?"alwaysUp":"alwaysDown"]=!0),M},f=f=w}();var g={},v={material:"MeshBasicMaterial",color:"black",opacity:1};g=g=function(e){var t;function n(){return new i[v.material]({color:v.color})}return e?((t=(e=u._validate(e,v)).material&&e.material.isMaterial?e.material:e.material||e.color||e.opacity?new i[e.material]({color:e.color,transparent:e.opacity<1}):n()).opacity=e.opacity,e.side&&(t.side=e.side)):t=n(),t};var y={};function x(e){this.map=e,this.enrolledObjects=[],this.previousFrameTime}x.prototype={unenroll:function(e){this.enrolledObjects.splice(this.enrolledObjects.indexOf(e),1)},enroll:function(e){if(e.clock=new i.Clock,e.hasDefaultAnimation=!1,e.defaultAction,e.actions=[],e.mixer,e.animations&&e.animations.length>0){e.hasDefaultAnimation=!0;let n=e.userData.defaultAnimation?e.userData.defaultAnimation:0;e.mixer=new i.AnimationMixer(e),t(n)}function t(t){for(let n=0;ne.animations.length&&console.log("The animation index "+t+" doesn't exist for this object");let i=e.animations[n],r=e.mixer.clipAction(i);e.actions.push(r),t===n?(e.defaultAction=r,r.setEffectiveWeight(1)):r.setEffectiveWeight(0),r.play()}}let n=!1;Object.defineProperty(e,"isPlaying",{get:()=>n,set(t){n!=t&&(n=t,e.dispatchEvent({type:"IsPlayingChanged",detail:e}))}}),this.enrolledObjects.push(e),e.animationQueue=[],e.set=function(t){if(t.duration>0){let n={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,n);let r=t.coords,a=t.rotation,o=t.scale||t.scaleX||t.scaleY||t.scaleZ;if(a){let n=e.rotation;t.startRotation=[n.x,n.y,n.z],t.endState.rotation=u.types.rotation(t.rotation,t.startRotation),t.rotationPerMs=t.endState.rotation.map((function(e,n){return(e-t.startRotation[n])/t.duration}))}if(o){let n=e.scale;t.startScale=[n.x,n.y,n.z],t.endState.scale=u.types.scale(t.scale,t.startScale),t.scalePerMs=t.endState.scale.map((function(e,n){return(e-t.startScale[n])/t.duration}))}r&&(t.pathCurve=new i.CatmullRomCurve3(u.lnglatsToWorld([e.coordinates,t.coords])));let s={type:"set",parameters:t};this.animationQueue.push(s),tb.map.repaint=!0}else this.stop(),t.rotation=u.radify(t.rotation),this._setObject(t);return this},e.animationMethod=null,e.stop=function(t){return e.mixer&&(e.isPlaying=!1,cancelAnimationFrame(e.animationMethod)),this.animationQueue=[],this},e.followPath=function(e,t){let n={type:"followPath",parameters:u._validate(e,b.followPath)};return u.extend(n.parameters,{pathCurve:new i.CatmullRomCurve3(u.lnglatsToWorld(e.path)),start:Date.now(),expiration:Date.now()+n.parameters.duration,cb:t}),this.animationQueue.push(n),tb.map.repaint=!0,this},e._setObject=function(t){e.setScale();let n=t.position,r=t.rotation,a=t.scale,o=t.worldCoordinates,s=t.quaternion,l=t.translate,c=t.worldTranslate;if(n){this.coordinates=n;let e=u.projectToWorld(n);this.position.copy(e)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let e=u.projectToWorld(l);this.position.copy(e),t.position=this.coordinates}if(c){this.translateX(c.x),this.translateY(c.y),this.translateZ(c.z);let e=u.unprojectFromWorld(this.position);this.coordinates=t.position=e}if(r&&(this.rotation.set(r[0],r[1],r[2]),t.rotation=new i.Vector3(r[0],r[1],r[2])),a&&(this.scale.set(a[0],a[1],a[2]),t.scale=this.scale),s&&(this.quaternion.setFromAxisAngle(s[0],s[1]),t.rotation=s[0].multiplyScalar(s[1])),o){this.position.copy(o);let e=u.unprojectFromWorld(o);this.coordinates=t.position=e}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let h={type:"ObjectChanged",detail:{object:this,action:{position:t.position,rotation:t.rotation,scale:t.scale}}};this.dispatchEvent(h)},e.playDefault=function(t){if(e.mixer&&e.hasDefaultAnimation){let n={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,n),e.mixer.timeScale=t.speed||1;let i={type:"playDefault",parameters:t};return this.animationQueue.push(i),tb.map.repaint=!0,this}},e.playAnimation=function(n){e.mixer&&(n.animation&&t(n.animation),e.playDefault(n))},e.pauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!0}))},e.unPauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!1}))},e.deactivateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.stop()}))},e.activateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.play()}))},e.idle=function(){return e.mixer&&e.mixer.update(.01),tb.map.repaint=!0,this}},update:function(e){if(void 0===this.previousFrameTime&&(this.previousFrameTime=e),!this.enrolledObjects)return!1;for(let t=this.enrolledObjects.length-1;t>=0;t--){let n=this.enrolledObjects[t];if(n.animationQueue&&0!==n.animationQueue.length)for(let t=n.animationQueue.length-1;t>=0;t--){let r=n.animationQueue[t];if(!r)continue;let a=r.parameters;if(!a.expiration)return n.animationQueue.splice(t,1),void(n.animationQueue[t]&&(n.animationQueue[t].parameters.start=e));if(e>=a.expiration)a.expiration=!1,"playDefault"===r.type?n.stop():(a.endState&&n._setObject(a.endState),void 0!==a.cb&&a.cb());else{let t=(e-a.start)/a.duration;if("set"===r.type){let e={};a.pathCurve&&(e.worldCoordinates=a.pathCurve.getPoint(t)),a.rotationPerMs&&(e.rotation=a.startRotation.map((function(e,n){return e+a.rotationPerMs[n]*t*a.duration}))),a.scalePerMs&&(e.scale=a.startScale.map((function(e,n){return e+a.scalePerMs[n]*t*a.duration}))),n._setObject(e)}if("followPath"===r.type){let e={worldCoordinates:a.pathCurve.getPointAt(t)};if(a.trackHeading){let n=a.pathCurve.getTangentAt(t).normalize(),r=new i.Vector3(0,0,0),o=new i.Vector3(0,1,0);r.crossVectors(o,n).normalize();let s=Math.acos(o.dot(n));e.quaternion=[r,s]}n._setObject(e)}"playDefault"===r.type&&(n.activateAllActions(),n.isPlaying=!0,n.animationMethod=requestAnimationFrame(this.update),n.mixer.update(n.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=e}};const b={followPath:{path:null,duration:1e3,trackHeading:!0}};y=y=x;var w={};i.CSS2DObject=function(e){i.Object3D.call(this),this.element=e||document.createElement("div"),this.element.style.position="absolute",this.alwaysVisible=!1,Object.defineProperty(this,"layer",{get(){return this.parent&&this.parent.parent?this.parent.parent.layer:null}}),this.dispose=function(){this.remove(),this.element=null},this.remove=function(){this.element instanceof Element&&null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)},this.addEventListener("removed",(function(){this.remove()}))},i.CSS2DObject.prototype=Object.assign(Object.create(i.Object3D.prototype),{constructor:i.CSS2DObject,copy:function(e,t){return i.Object3D.prototype.copy.call(this,e,t),this.element=e.element.cloneNode(!0),this}}),i.CSS2DRenderer=function(){var e,t,n,r,a=this,o=new i.Vector3,s=new i.Matrix4,l=new i.Matrix4,c={objects:new WeakMap,list:new Map};this.cacheList=c.list;var u=document.createElement("div");u.style.overflow="hidden",this.domElement=u,this.getSize=function(){return{width:e,height:t}},this.setSize=function(i,a){n=(e=i)/2,r=(t=a)/2,u.style.width=i+"px",u.style.height=a+"px"},this.renderObject=function(e,t,s){if(e instanceof i.CSS2DObject)if(e.visible){e.onBeforeRender(a,t,s),o.setFromMatrixPosition(e.matrixWorld),o.applyMatrix4(l);var h=e.element,d="translate(-50%,-50%) translate("+(o.x*n+n)+"px,"+(-o.y*r+r)+"px)";h.style.WebkitTransform=d,h.style.MozTransform=d,h.style.oTransform=d,h.style.transform=d,h.style.display=e.visible&&o.z>=-1&&o.z<=1?"":"none";var f={distanceToCameraSquared:p(s,e)};c.objects.set({key:e.uuid},f),c.list.set(e.uuid,e),h.parentNode!==u&&u.appendChild(h),e.onAfterRender(a,t,s)}else c.objects.delete({key:e.uuid}),c.list.delete(e.uuid),e.remove();for(var m=0,g=e.children.length;me.getObjectByName("model")}),Object.defineProperty(e,"animations",{get(){const t=e.model;return t?t.animations:null}}),n.animationManager.enroll(e),e.setCoords=function(t){return e.userData.topMargin&&e.userData.feature&&(t[2]+=((e.userData.feature.properties.height||0)-(e.userData.feature.properties.base_height||e.userData.feature.properties.min_height||0))*(e.userData.topMargin||0)),e.coordinates=t,e.set({position:t}),e},e.setTranslate=function(t){return e.set({translate:t}),e},e.setRotation=function(t){"number"==typeof t&&(t={z:t});var n={x:u.radify(t.x)||e.rotation.x,y:u.radify(t.y)||e.rotation.y,z:u.radify(t.z)||e.rotation.z};e._setObject({rotation:[n.x,n.y,n.z]})},e.calculateAdjustedPosition=function(t,n,i){let r=t.slice(),a=u.unprojectFromWorld(e.modelSize);return i?(r[0]-=0!=n.x?a[0]/n.x:0,r[1]-=0!=n.y?a[1]/n.y:0,r[2]-=0!=n.z?a[2]/n.z:0):(r[0]+=0!=n.x?a[0]/n.x:0,r[1]+=0!=n.y?a[1]/n.y:0,r[2]+=0!=n.z?a[2]/n.z:0),r},e.setRotationAxis=function(t){"number"==typeof t&&(t={z:t});let n=e.modelBox(),r=new M.Vector3(n.max.x,n.max.y,n.min.z);0!=t.x&&i(e,r,new M.Vector3(0,0,1),t.x),0!=t.y&&i(e,r,new M.Vector3(0,0,1),t.y),0!=t.z&&i(e,r,new M.Vector3(0,0,1),t.z)},Object.defineProperty(e,"scaleGroup",{get:()=>e.getObjectByName("scaleGroup")}),Object.defineProperty(e,"boxGroup",{get:()=>e.getObjectByName("boxGroup")}),Object.defineProperty(e,"boundingBox",{get:()=>e.getObjectByName("boxModel")}),Object.defineProperty(e,"boundingBoxShadow",{get:()=>e.getObjectByName("boxShadow")}),e.drawBoundingBox=function(){let t=e.box3(),n=new M.Group;n.name="boxGroup",n.updateMatrixWorld(!0);let i=new M.Box3Helper(t,S.prototype._defaults.colors.yellow);i.name="boxModel",n.add(i),i.layers.disable(0);let r=t.clone();r.max.z=r.min.z;let a=new M.Box3Helper(r,S.prototype._defaults.colors.black);a.name="boxShadow",n.add(a),a.layers.disable(0),n.visible=!1,e.scaleGroup.add(n),e.setBoundingBoxShadowFloor()},e.setBoundingBoxShadowFloor=function(){if(e.boundingBoxShadow){let t=-e.modelHeight,n=e.rotation,i=e.boundingBoxShadow;i.box.max.z=i.box.min.z=t,i.rotation.y=n.y,i.rotation.x=-n.x}},e.setAnchor=function(t){const n=e.box3(),i=n.getCenter(new M.Vector3);switch(e.none={x:0,y:0,z:0},e.center={x:i.x,y:i.y,z:n.min.z},e.bottom={x:i.x,y:n.max.y,z:n.min.z},e.bottomLeft={x:n.max.x,y:n.max.y,z:n.min.z},e.bottomRight={x:n.min.x,y:n.max.y,z:n.min.z},e.top={x:i.x,y:n.min.y,z:n.min.z},e.topLeft={x:n.max.x,y:n.min.y,z:n.min.z},e.topRight={x:n.min.x,y:n.min.y,z:n.min.z},e.left={x:n.max.x,y:i.y,z:n.min.z},e.right={x:n.min.x,y:i.y,z:n.min.z},t){case"center":e.anchor=e.center;break;case"top":e.anchor=e.top;break;case"top-left":e.anchor=e.topLeft;break;case"top-right":e.anchor=e.topRight;break;case"left":e.anchor=e.left;break;case"right":e.anchor=e.right;break;case"bottom":e.anchor=e.bottom;break;case"bottom-left":default:e.anchor=e.bottomLeft;break;case"bottom-right":e.anchor=e.bottomRight;break;case"auto":case"none":e.anchor=e.none}e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)},e.setCenter=function(t){if(t&&(0!=t.x||0!=t.y||0!=t.z)){let n=e.getSize();e.anchor={x:e.anchor.x-n.x*t.x,y:e.anchor.y-n.y*t.y,z:e.anchor.z-n.z*t.z},e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)}},Object.defineProperty(e,"label",{get:()=>e.getObjectByName("label")}),Object.defineProperty(e,"tooltip",{get:()=>e.getObjectByName("tooltip")}),Object.defineProperty(e,"help",{get:()=>e.getObjectByName("help")}),Object.defineProperty(e,"visibility",{get:()=>e.visible,set(t){let n=t;if("visible"==t||1==t)n=!0,e.label&&(e.label.visible=n);else{if("none"!=t&&0!=t)return;n=!1,e.label&&e.label.alwaysVisible&&(e.label.visible=n),e.tooltip&&(e.tooltip.visible=n)}e.visible!=n&&(e.visible=n,e.model&&e.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(n&&e.raycasted?t.layers.enable(0):t.layers.disable(0)),"LineSegments"==t.type&&t.layers.disableAll()})))}}),e.addLabel=function(t,n,i,r){t&&e.drawLabelHTML(t,n,i,r)},e.removeLabel=function(){e.removeCSS2D("label")},e.drawLabelHTML=function(t,i=!1,r=e.anchor,a=.5){let o=n.drawLabelHTML(t,S.prototype._defaults.label.cssClass),s=e.addCSS2D(o,"label",r,a);return s.alwaysVisible=i,s.visible=i,s},e.addTooltip=function(t,n,i,r=!0,a=1){let o=e.addHelp(t,"tooltip",n,i,a);o.visible=!1,o.custom=r},e.removeTooltip=function(){e.removeCSS2D("tooltip")},e.addHelp=function(t,i="help",r=!1,a=e.anchor,o=0){let s=n.drawTooltip(t,r),l=e.addCSS2D(s,i,a,o);return l.visible=!0,l},e.removeHelp=function(){e.removeCSS2D("help")},e.addCSS2D=function(t,n,i=e.anchor,r=1){if(t){const a=e.box3(),o=a.getSize(new M.Vector3);let s={x:a.max.x,y:a.max.y,z:a.min.z};e.removeCSS2D(n);let l=new w.CSS2DObject(t);return l.name=n,l.position.set(.5*-o.x-e.model.position.x-i.x+s.x,.5*-o.y-e.model.position.y-i.y+s.y,o.z*r),l.visible=!1,e.scaleGroup.add(l),l}},e.removeCSS2D=function(t){let n=e.getObjectByName(t);if(n){n.dispose();let t=e.scaleGroup.children;t.splice(t.indexOf(n),1)}},Object.defineProperty(e,"shadowPlane",{get:()=>e.getObjectByName("shadowPlane")});let t=!1;Object.defineProperty(e,"castShadow",{get:()=>t,set(n){if(e.model&&t!==n){if(e.model.traverse((function(e){e.isMesh&&(e.castShadow=!0)})),n){const t=e.modelSize,i=[t.x,t.y,t.z,e.modelHeight],r=10*Math.max(...i),a=new M.PlaneBufferGeometry(r,r),o=new M.ShadowMaterial;o.opacity=.5;let s=new M.Mesh(a,o);s.name="shadowPlane",s.layers.enable(1),s.layers.disable(0),s.receiveShadow=n,e.add(s)}else e.traverse((function(t){t.isMesh&&t.material instanceof M.ShadowMaterial&&e.remove(t)}));t=n}}}),e.setReceiveShadowFloor=function(){if(e.castShadow){let t=e.shadowPlane,n=t.position,i=t.rotation;if(n.z=-e.modelHeight,i.y=e.rotation.y,i.x=-e.rotation.x,"meters"===e.userData.units){const i=e.modelSize,r=[i.x,i.y,i.z,-n.z],a=10*Math.max(...r)/t.geometry.parameters.width;t.scale.set(a,a,a)}}};let r=!1;Object.defineProperty(e,"receiveShadow",{get:()=>r,set(t){e.model&&r!==t&&(e.model.traverse((function(e){e.isMesh&&(e.receiveShadow=!0)})),r=t)}});let a=!1;Object.defineProperty(e,"wireframe",{get:()=>a,set(t){e.model&&a!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let n=[];Array.isArray(e.material)?n=e.material:n.push(e.material);let i=n[0];t?(e.userData.materials=i,e.material=i.clone(),e.material.wireframe=e.material.transparent=t,e.material.opacity=.3):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null),t?(e.layers.disable(0),e.layers.enable(1)):(e.layers.disable(1),e.layers.enable(0))}"LineSegments"==e.type&&e.layers.disableAll()})),a=t,e.dispatchEvent({type:"Wireframed",detail:e}))}});let o=null;Object.defineProperty(e,"color",{get:()=>o,set(t){e.model&&o!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let n=[];Array.isArray(e.material)?n=e.material:n.push(e.material);let i=n[0];t?(e.userData.materials=i,e.material=new M.MeshStandardMaterial,e.material.color.setHex(t)):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null)}})),o=t)}});let s=!1;Object.defineProperty(e,"selected",{get:()=>s,set(t){t?(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.boxGroup&&(e.boundingBox.material=S.prototype._defaults.materials.boxSelectedMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1)),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0)):(e.boxGroup&&e.remove(e.boxGroup),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1),e.removeHelp()),e.tooltip&&(e.tooltip.visible=t),s!=t&&(s=t,e.dispatchEvent({type:"SelectedChange",detail:e}))}});let l=!0;Object.defineProperty(e,"raycasted",{get:()=>l,set(t){e.model&&l!==t&&(e.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(t?(e.layers.disable(1),e.layers.enable(0)):(e.layers.disable(0),e.layers.enable(1)))})),l=t)}});let c=!1;Object.defineProperty(e,"over",{get:()=>c,set(t){t?(e.selected||(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.userData.tooltip&&!e.tooltip&&e.addTooltip(e.uuid,!0,e.anchor,!1),e.boxGroup&&(e.boundingBox.material=S.prototype._defaults.materials.boxOverMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1))),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0),e.dispatchEvent({type:"ObjectMouseOver",detail:e})):(e.selected||(e.boxGroup&&(e.remove(e.boxGroup),e.tooltip&&!e.tooltip.custom&&e.removeTooltip()),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1)),e.dispatchEvent({type:"ObjectMouseOut",detail:e})),e.tooltip&&(e.tooltip.visible=t||e.selected),c=t}}),e.box3=function(){let t;if(e.updateMatrix(),e.updateMatrixWorld(!0,!0),e.model){let n=e.clone(!0),i=e.model.clone();if(t=(new M.Box3).setFromObject(i),e.parent){let r=new M.Matrix4,a=new M.Matrix4;e.matrix.extractRotation(r),a.copy(r).invert(),n.setRotationFromMatrix(a),t=(new M.Box3).setFromObject(i)}}return t},e.modelBox=function(){return e.box3()},e.getSize=function(){return e.box3().getSize(new M.Vector3(0,0,0))};let h=!1;Object.defineProperty(e,"modelSize",{get:()=>h=e.getSize(),set(e){h!=e&&(h=e)}}),Object.defineProperty(e,"modelHeight",{get(){let t=e.coordinates[2]||0;return"scene"===e.userData.units&&(t*=e.unitsPerMeter/e.scale.x),t}}),Object.defineProperty(e,"unitsPerMeter",{get:()=>Number(u.projectedUnitsPerMeter(e.coordinates[1]).toFixed(7))}),Object.defineProperty(e,"fixedZoom",{get:()=>e.userData.fixedZoom,set(t){e.userData.fixedZoom!==t&&(e.userData.fixedZoom=t,e.userData.units=t?"scene":"meters")}}),e.setFixedZoom=function(t){if(null!=e.fixedZoom){t||(t=e.userData.mapScale);let i=(n=e.fixedZoom,Math.pow(2,n));if(i>t){let n=i/t;e.scale.set(n,n,n)}else e.scale.set(1,1,1)}var n},e.setScale=function(t){if("meters"!==e.userData.units||e.fixedZoom)e.fixedZoom?(t&&(e.userData.mapScale=t),e.setFixedZoom(e.userData.mapScale)):e.scale.set(1,1,1);else{let t=e.unitsPerMeter;e.scale.set(t,t,t)}},e.setObjectScale=function(t){e.setScale(t),e.setBoundingBoxShadowFloor(),e.setReceiveShadowFloor()}}e.add=function(t){return e.scaleGroup.add(t),t.position.z=e.coordinates[2]?-e.coordinates[2]:0,t},e.remove=function(t){t&&(t.traverse(e=>{if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()}),e.scaleGroup.remove(t),tb.map.repaint=!0)},e.duplicate=function(t){let i=e.clone(!0);if(i.getObjectByName("model").animations=e.animations,i.userData.feature&&(t&&t.feature&&(i.userData.feature=t.feature),i.userData.feature.properties.uuid=i.uuid),n._addMethods(i),!t||u.equal(t.scale,e.userData.scale))return i.copyAnchor(e),i;{i.userData=t,i.userData.isGeoGroup=!0,i.remove(i.boxGroup);const e=u.types.rotation(t.rotation,[0,0,0]),n=u.types.scale(t.scale,[1,1,1]);return i.model.position.set(0,0,0),i.model.rotation.set(e[0],e[1],e[2]),i.model.scale.set(n[0],n[1],n[2]),i.setAnchor(t.anchor),i.setCenter(t.adjustment),i}},e.copyAnchor=function(t){e.anchor=t.anchor,e.none={x:0,y:0,z:0},e.center=t.center,e.bottom=t.bottom,e.bottomLeft=t.bottomLeft,e.bottomRight=t.bottomRight,e.top=t.top,e.topLeft=t.topLeft,e.topRight=t.topRight,e.left=t.left,e.right=t.right},e.dispose=function(){S.prototype.unenroll(e),e.traverse(e=>{if((!e.parent||"world"!=e.parent.name)&&"threeboxObject"!==e.name){if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()}}),e.children=[]};const r=e=>{e.dispose();for(const n of Object.keys(e)){const t=e[n];t&&"object"==typeof t&&"minFilter"in t&&t.dispose()}let t=e;(t.map||t.alphaMap||t.aoMap||t.bumpMap||t.displacementMap||t.emissiveMap||t.envMap||t.lightMap||t.metalnessMap||t.normalMap||t.roughnessMap)&&(t.map&&t.map.dispose(),t.alphaMap&&t.alphaMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.displacementMap&&t.displacementMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.envMap&&t.envMap.dispose(),t.lightMap&&t.lightMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose())};return e},_makeGroup:function(e,t){let n=new M.Group;n.name="scaleGroup",n.add(e);var i=new M.Group;if(i.userData=t||{},i.userData.isGeoGroup=!0,i.userData.feature&&(i.userData.feature.properties.uuid=i.uuid),n.length)for(o of n)i.add(o);else i.add(n);return i.name="threeboxObject",i},animationManager:new y,drawTooltip:function(e,t=!1){if(e){let n;if(t){let t=document.createElement("div");t.className="mapboxgl-popup-content";let i=document.createElement("strong");i.innerHTML=e,t.appendChild(i);let r=document.createElement("div");r.className="mapboxgl-popup-tip";let a=document.createElement("div");a.className="marker mapboxgl-popup-anchor-bottom",a.appendChild(r),a.appendChild(t),(n=document.createElement("div")).className+="label3D",n.appendChild(a)}else(n=document.createElement("span")).className=this._defaults.tooltip.cssClass,n.innerHTML=e;return n}},drawLabelHTML:function(e,t){let n=document.createElement("div");return n.className+=t,n.innerHTML="string"==typeof e?e:e.outerHTML,n},_defaults:{colors:{red:new M.Color(16711680),yellow:new M.Color(16776960),green:new M.Color(65280),black:new M.Color(0)},materials:{boxNormalMaterial:new M.LineBasicMaterial({color:new M.Color(16711680)}),boxOverMaterial:new M.LineBasicMaterial({color:new M.Color(16776960)}),boxSelectedMaterial:new M.LineBasicMaterial({color:new M.Color(65280)})},line:{geometry:null,color:"black",width:1,opacity:1},label:{htmlElement:null,cssClass:" label3D",alwaysVisible:!1,topMargin:-.5},tooltip:{text:"",cssClass:"toolTip text-xs",mapboxStyle:!1,topMargin:0},sphere:{position:[0,0,0],radius:1,sides:20,units:"scene",material:"MeshBasicMaterial",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},tube:{geometry:null,radius:1,sides:6,units:"scene",material:"MeshBasicMaterial",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0},loadObj:{type:null,obj:null,units:"scene",scale:1,rotation:0,defaultAnimation:0,anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},Object3D:{obj:null,units:"scene",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},extrusion:{coordinates:[[[]]],geometryOptions:{},height:100,materials:null,scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},_=_=S;var T={};T=T=function(e){let t=(e=u._validate(e,_.prototype._defaults.Object3D)).obj;const n=u.types.rotation(e.rotation,[0,0,0]),i=u.types.scale(e.scale,[1,1,1]);t.rotation.set(n[0],n[1],n[2]),t.scale.set(i[0],i[1],i[2]),t.name="model";let r=_.prototype._makeGroup(t,e);return e.obj.name="model",_.prototype._addMethods(r),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r.raycasted=e.raycasted,r.visibility=!0,r};var E={};E=E=function(e){e=u._validate(e,_.prototype._defaults.sphere);let t=new THREE.SphereBufferGeometry(e.radius,e.sides,e.sides),n=g(e),i=new THREE.Mesh(t,n);return new T({obj:i,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var A={};function L(e){e=u._validate(e,_.prototype._defaults.extrusion);let t=L.prototype.buildShape(e.coordinates),n=L.prototype.buildGeometry(t,e.geometryOptions),r=new i.Mesh(n,e.materials);return e.obj=r,new T(e)}L.prototype={buildShape:function(e){if(e[0]instanceof(i.Vector2||i.Vector3))return new i.Shape(e);let t=new i.Shape;for(let n=0;n0?t[t.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var n=this.materials.length-1;n>=0;n--)this.materials[n].groupCount<=0&&this.materials.splice(n,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},n&&n.name&&"function"==typeof n.clone){var i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseNormalIndex:function(e,t){var n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseUVIndex:function(e,t){var n=parseInt(e,10);return 2*(n>=0?n-1:n+t/2)},addVertex:function(e,t,n){var i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){var i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){var i=this.vertices,r=this.object.geometry.normals;o.fromArray(i,e),s.fromArray(i,t),l.fromArray(i,n),u.subVectors(l,s),c.subVectors(o,s),u.cross(c),u.normalize(),r.push(u.x,u.y,u.z),r.push(u.x,u.y,u.z),r.push(u.x,u.y,u.z)},addColor:function(e,t,n){var i=this.colors,r=this.object.geometry.colors;void 0!==i[e]&&r.push(i[e+0],i[e+1],i[e+2]),void 0!==i[t]&&r.push(i[t+0],i[t+1],i[t+2]),void 0!==i[n]&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){var i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){var e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){var t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,o,s,l){var c=this.vertices.length,u=this.parseVertexIndex(e,c),h=this.parseVertexIndex(t,c),d=this.parseVertexIndex(n,c);if(this.addVertex(u,h,d),this.addColor(u,h,d),void 0!==o&&""!==o){var p=this.normals.length;u=this.parseNormalIndex(o,p),h=this.parseNormalIndex(s,p),d=this.parseNormalIndex(l,p),this.addNormal(u,h,d)}else this.addFaceNormal(u,h,d);if(void 0!==i&&""!==i){var f=this.uvs.length;u=this.parseUVIndex(i,f),h=this.parseUVIndex(r,f),d=this.parseUVIndex(a,f),this.addUV(u,h,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";for(var t=this.vertices.length,n=0,i=e.length;n=7?o.colors.push(parseFloat(m[4]),parseFloat(m[5]),parseFloat(m[6])):o.colors.push(void 0,void 0,void 0);break;case"vn":o.normals.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3]));break;case"vt":o.uvs.push(parseFloat(m[1]),parseFloat(m[2]))}}else if("f"===c){for(var g=l.substr(1).trim().split(/\s+/),v=[],y=0,x=g.length;y0){var w=b.split("/");v.push(w)}}var _=v[0];for(y=1,x=v.length-1;y1){var D=u[1].trim().toLowerCase();o.object.smooth="0"!==D&&"off"!==D}else o.object.smooth=!0;(q=o.object.currentMaterial())&&(q.smooth=o.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}o.finalize();var O=new i.Group;if(O.materialLibraries=[].concat(o.materialLibraries),!0==!(1===o.objects.length&&0===o.objects[0].geometry.vertices.length))for(p=0,f=o.objects.length;p0&&J.setAttribute("normal",new i.Float32BufferAttribute(F.normals,3)),F.colors.length>0&&(U=!0,J.setAttribute("color",new i.Float32BufferAttribute(F.colors,3))),!0===F.hasUVIndices&&J.setAttribute("uv",new i.Float32BufferAttribute(F.uvs,2));for(var k,G=[],j=0,V=B.length;j1){for(j=0,V=B.length;j0){var J;q=new i.PointsMaterial({size:1,sizeAttenuation:!1}),(J=new i.BufferGeometry).setAttribute("position",new i.Float32BufferAttribute(o.vertices,3)),o.colors.length>0&&void 0!==o.colors[0]&&(J.setAttribute("color",new i.Float32BufferAttribute(o.colors,3)),q.vertexColors=!0);var K=new i.Points(J,q);O.add(K)}return O}}),d}(),P=P=i.OBJLoader;var I={};i.MTLLoader=function(e){i.Loader.call(this,e)},i.MTLLoader.prototype=Object.assign(Object.create(i.Loader.prototype),{constructor:i.MTLLoader,load:function(e,n,r,a){var o=this,s=""===this.path?i.LoaderUtils.extractUrlBase(e||""):this.path,l=new i.FileLoader(this.manager);l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(i){try{n(o.parse(i,s))}catch(t){a?a(t):console.error(t),o.manager.itemError(e)}}),r,a)},setMaterialOptions:function(e){return this.materialOptions=e,this},parse:function(e,t){for(var n=e.split("\n"),r={},a=/\s+/,o={},s=0;s=0?l.substring(0,c):l;u=u.toLowerCase();var h=c>=0?l.substring(c+1):"";if(h=h.trim(),"newmtl"===u)r={name:h},o[h]=r;else if("ka"===u||"kd"===u||"ks"===u||"ke"===u){var d=h.split(a,3);r[u]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else r[u]=h}}var p=new i.MTLLoader.MaterialCreator(this.resourcePath||t,this.materialOptions);return p.setCrossOrigin(this.crossOrigin),p.setManager(this.manager),p.setMaterials(o),p}}),i.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:i.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:i.RepeatWrapping},i.MTLLoader.MaterialCreator.prototype={constructor:i.MTLLoader.MaterialCreator,crossOrigin:"anonymous",setCrossOrigin:function(e){return this.crossOrigin=e,this},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var n in e){var i=e[n],r={};for(var a in t[n]=r,i){var o=!0,s=i[a],l=a.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(s=[s[0]/255,s[1]/255,s[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===s[0]&&0===s[1]&&0===s[2]&&(o=!1)}o&&(r[l]=s)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){var t=this,n=this.materialsInfo[e],r={name:e,side:this.side};function a(e,n){if(!r[e]){var i,a,o=t.getTextureParams(n,r),s=t.loadTexture((i=t.baseUrl,"string"!=typeof(a=o.url)||""===a?"":/^https?:\/\//i.test(a)?a:i+a));s.repeat.copy(o.scale),s.offset.copy(o.offset),s.wrapS=t.wrap,s.wrapT=t.wrap,r[e]=s}}for(var o in n){var s,l=n[o];if(""!==l)switch(o.toLowerCase()){case"kd":r.color=(new i.Color).fromArray(l);break;case"ks":r.specular=(new i.Color).fromArray(l);break;case"ke":r.emissive=(new i.Color).fromArray(l);break;case"map_kd":a("map",l);break;case"map_ks":a("specularMap",l);break;case"map_ke":a("emissiveMap",l);break;case"norm":a("normalMap",l);break;case"map_bump":case"bump":a("bumpMap",l);break;case"map_d":a("alphaMap",l),r.transparent=!0;break;case"ns":r.shininess=parseFloat(l);break;case"d":(s=parseFloat(l))<1&&(r.opacity=s,r.transparent=!0);break;case"tr":s=parseFloat(l),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(r.opacity=1-s,r.transparent=!0)}}return this.materials[e]=new i.MeshPhongMaterial(r),this.materials[e]},getTextureParams:function(e,t){var n,r={scale:new i.Vector2(1,1),offset:new i.Vector2(0,0)},a=e.split(/\s+/);return(n=a.indexOf("-bm"))>=0&&(t.bumpScale=parseFloat(a[n+1]),a.splice(n,2)),(n=a.indexOf("-s"))>=0&&(r.scale.set(parseFloat(a[n+1]),parseFloat(a[n+2])),a.splice(n,4)),(n=a.indexOf("-o"))>=0&&(r.offset.set(parseFloat(a[n+1]),parseFloat(a[n+2])),a.splice(n,4)),r.url=a.join(" ").trim(),r},loadTexture:function(e,t,n,r,a){var o,s=void 0!==this.manager?this.manager:i.DefaultLoadingManager,l=s.getHandler(e);return null===l&&(l=new i.TextureLoader(s)),l.setCrossOrigin&&l.setCrossOrigin(this.crossOrigin),o=l.load(e,n,r,a),void 0!==t&&(o.mapping=t),o}},I=I=i.MTLLoader;var D,O,N={},F=N={};function B(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function H(e){if(D===setTimeout)return setTimeout(e,0);if((D===B||!D)&&setTimeout)return D=setTimeout,setTimeout(e,0);try{return D(e,0)}catch(t){try{return D.call(null,e,0)}catch(t){return D.call(this,e,0)}}}!function(){try{D="function"==typeof setTimeout?setTimeout:B}catch(t){D=B}try{O="function"==typeof clearTimeout?clearTimeout:z}catch(t){O=z}}();var U,k=[],G=!1,j=-1;function V(){G&&U&&(G=!1,U.length?k=U.concat(k):j=-1,k.length&&W())}function W(){if(!G){var e=H(V);G=!0;for(var n=k.length;n;){for(U=k,k=[];++j1)for(var n=1;n>>1|(21845&v)<<1;g[v]=((65280&(y=(61680&(y=(52428&y)>>>2|(13107&y)<<2))>>>4|(3855&y)<<4))>>>8|(255&y)<<8)>>>1}var x=function(e,t,n){for(var i=e.length,a=0,o=new r(t);a>>c]=u}else for(s=new r(i),a=0;a>>15-e[a]);return s},b=new i(288);for(v=0;v<144;++v)b[v]=8;for(v=144;v<256;++v)b[v]=9;for(v=256;v<280;++v)b[v]=7;for(v=280;v<288;++v)b[v]=8;var w=new i(32);for(v=0;v<32;++v)w[v]=5;var _=x(b,9,0),M=x(b,9,1),S=x(w,5,0),T=x(w,5,1),E=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},A=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},L=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},R=function(e){return(e/8|0)+(7&e&&1)},C=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var o=new(e instanceof r?r:e instanceof a?a:i)(n-t);return o.set(e.subarray(t,n)),o},P=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new i(0);var a=!t||n,c=!n||n.i;n||(n={}),t||(t=new i(3*r));var u=function(e){var n=t.length;if(e>n){var r=new i(Math.max(2*n,e));r.set(t),t=r}},d=n.f||0,p=n.p||0,m=n.b||0,g=n.l,v=n.d,y=n.m,b=n.n,w=8*r;do{if(!g){n.f=d=A(e,p,1);var _=A(e,p+1,3);if(p+=3,!_){var S=e[(k=R(p)+4)-4]|e[k-3]<<8,P=k+S;if(P>r){if(c)throw"unexpected EOF";break}a&&u(m+S),t.set(e.subarray(k,P),m),n.b=m+=S,n.p=p=8*P;continue}if(1==_)g=M,v=T,y=9,b=5;else{if(2!=_)throw"invalid block type";var I=A(e,p,31)+257,D=A(e,p+10,15)+4,O=I+A(e,p+5,31)+1;p+=14;for(var N=new i(O),F=new i(19),B=0;Bw)break;var U=x(F,z,1);for(B=0;B>>4)<16)N[B++]=k;else{var j=0,V=0;for(16==k?(V=3+A(e,p,3),p+=2,j=N[B-1]):17==k?(V=3+A(e,p,7),p+=3):18==k&&(V=11+A(e,p,127),p+=7);V--;)N[B++]=j}}var W=N.subarray(0,I),q=N.subarray(I);y=E(W),b=E(q),g=x(W,y,1),v=x(q,b,1)}if(p>w)throw"unexpected EOF"}a&&u(m+131072);for(var X=(1<>>4;if((p+=15&j)>w)throw"unexpected EOF";if(!j)throw"invalid length/literal";if(J<256)t[m++]=J;else{if(256==J){g=null;break}var K=J-254;J>264&&(K=A(e,p,(1<<(ee=o[B=J-257]))-1)+h[B],p+=ee);var Q=v[L(e,p)&Z],$=Q>>>4;if(!Q)throw"invalid distance";if(p+=15&Q,q=f[$],$>3){var ee=s[$];q+=L(e,p)&(1<w)throw"unexpected EOF";a&&u(m+131072);for(var te=m+K;m>>8},D=function(e,t,n){var i=t/8|0;e[i]|=n<<=7&t,e[i+1]|=n>>>8,e[i+2]|=n>>>16},O=function(e,t){for(var n=[],a=0;af&&(f=s[a].s);var m=new r(f+1),g=N(n[d-1],m,0);if(g>t){a=0;var v=0,y=g-t,x=1<t))break;v+=x-(1<>>=y;v>0;){var w=s[a].s;m[w]=0&&v;--a){var _=s[a].s;m[_]==t&&(--m[_],++v)}g=t}return[new i(m),g]},N=function(e,t,n){return-1==e.s?Math.max(N(e.l,t,n+1),N(e.r,t,n+1)):t[e.s]=n},F=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new r(++t),i=0,a=e[0],o=1,s=function(e){n[i++]=e},l=1;l<=t;++l)if(e[l]==a&&l!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(a),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(a);o=1,a=e[l]}return[n.subarray(0,i),t]},B=function(e,t){for(var n=0,i=0;i>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var a=0;a4&&!k[l[j-1]];--j);var V,W,q,X,Z=p+5<<3,Y=B(a,b)+B(c,w)+u,J=B(a,g)+B(c,M)+u+14+3*j+B(N,k)+(2*N[16]+3*N[17]+7*N[18]);if(Z<=Y&&Z<=J)return z(t,f,e.subarray(d,d+p));if(I(t,f,1+(J15&&(I(t,f,ee[H]>>>5&127),f+=ee[H]>>>12)}}else V=_,W=b,q=S,X=w;for(H=0;H255){var te;D(t,f,V[257+(te=i[H]>>>18&31)]),f+=W[te+257],te>7&&(I(t,f,i[H]>>>23&31),f+=o[te]);var ne=31&i[H];D(t,f,q[ne]),f+=X[ne],ne>3&&(D(t,f,i[H]>>>5&8191),f+=s[ne])}else D(t,f,V[i[H]]),f+=W[i[H]];return D(t,f,V[256]),f+W[256]},U=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),k=new i(0),G=function(e,t,n,l,c,u){var h=e.length,p=new i(l+h+5*(1+Math.ceil(h/7e3))+c),f=p.subarray(l,p.length-c),g=0;if(!t||h<8)for(var v=0;v<=h;v+=65535){var y=v+65535;y>>13,w=8191&x,_=(1<7e3||N>24576)&&W>423){g=H(e,f,0,L,P,I,O,N,B,v-B,g),N=D=O=0,B=v;for(var q=0;q<286;++q)P[q]=0;for(q=0;q<30;++q)I[q]=0}var X=2,Z=0,Y=w,J=j-V&32767;if(W>2&&G==A(v-J))for(var K=Math.min(b,W)-1,Q=Math.min(32767,v),$=Math.min(258,W);J<=Q&&--Y&&j!=V;){if(e[v+X]==e[v+X-J]){for(var ee=0;ee<$&&e[v+ee]==e[v+ee-J];++ee);if(ee>X){if(X=ee,Z=J,ee>K)break;var te=Math.min(J,ee-2),ne=0;for(q=0;qne&&(ne=re,V=ie)}}}J+=(j=V)-(V=M[j])+32768&32767}if(Z){L[N++]=268435456|d[X]<<18|m[Z];var ae=31&d[X],oe=31&m[Z];O+=o[ae]+s[oe],++P[257+ae],++I[oe],F=v+X,++D}else L[N++]=e[v],++P[e[v]]}}g=H(e,f,u,L,P,I,O,N,B,v-B,g),!u&&7&g&&(g=z(f,g+1,k))}return C(p,0,l+R(g)+c)},j=function(){for(var e=new a(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),V=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i>>8;e=n},d:function(){return~e}}},W=function(){var e=1,t=0;return{p:function(n){for(var i=e,r=t,a=n.length,o=0;o!=a;){for(var s=Math.min(o+2655,a);o>16),r=(65535&r)+15*(r>>16)}e=i,t=r},d:function(){return((e%=65521)>>>8<<16|(255&(t%=65521))<<8|t>>>8)+2*((255&e)<<23)}}},q=function(e,t,n,i,r){return G(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!r)},X=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},Y=function(e,t,n){for(var i=e(),r=""+e,a=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o>>=8},fe=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&pe(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var i=0;i<=n.length;++i)e[i+10]=n.charCodeAt(i)}},me=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[n++]);return n+(2&t)},ge=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16)+2*(e[t-1]<<23)},ve=function(e){return 10+(e.filename&&e.filename.length+1||0)},ye=function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)},xe=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function be(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var we=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(q(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}();t.Deflate=we;var _e=function(e,t){ce([ee,function(){return[le,we]}],this,be.call(this,e,t),(function(e){var t=new we(e.data);onmessage=le(t)}),6)};function Me(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[ee],(function(e){return ae(Se(e.data[0],e.data[1]))}),0,n)}function Se(e,t){return q(e,t||{},0,0)}t.AsyncDeflate=_e,t.deflate=Me,t.deflateSync=Se;var Te=function(){function e(e){this.s={},this.p=new i(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new i(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=P(this.p,this.o,this.s);this.ondata(C(n,t,this.s.b),this.d),this.o=C(n,this.s.b-32768),this.s.b=this.o.length,this.p=C(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();t.Inflate=Te;var Ee=function(e){this.ondata=e,ce([$,function(){return[le,Te]}],this,0,(function(){var e=new Te;onmessage=le(e)}),7)};function Ae(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[$],(function(e){return ae(Le(e.data[0],oe(e.data[1])))}),1,n)}function Le(e,t){return P(e,t)}t.AsyncInflate=Ee,t.inflate=Ae,t.inflateSync=Le;var Re=function(){function e(e,t){this.c=V(),this.l=0,this.v=1,we.call(this,e,t)}return e.prototype.push=function(e,t){we.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=q(e,this.o,this.v&&ve(this.o),t&&8,!t);this.v&&(fe(n,this.o),this.v=0),t&&(pe(n,n.length-8,this.c.d()),pe(n,n.length-4,this.l)),this.ondata(n,t)},e}();t.Gzip=Re,t.Compress=Re;var Ce=function(e,t){ce([ee,te,function(){return[le,we,Re]}],this,be.call(this,e,t),(function(e){var t=new Re(e.data);onmessage=le(t)}),8)};function Pe(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[ee,te,function(){return[Ie]}],(function(e){return ae(Ie(e.data[0],e.data[1]))}),2,n)}function Ie(e,t){t||(t={});var n=V(),i=e.length;n.p(e);var r=q(e,t,ve(t),8),a=r.length;return fe(r,t),pe(r,a-8,n.d()),pe(r,a-4,i),r}t.AsyncGzip=Ce,t.AsyncCompress=Ce,t.gzip=Pe,t.compress=Pe,t.gzipSync=Ie,t.compressSync=Ie;var De=function(){function e(e){this.v=1,Te.call(this,e)}return e.prototype.push=function(e,t){if(Te.prototype.e.call(this,e),this.v){var n=this.p.length>3?me(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Te.prototype.c.call(this,t)},e}();t.Gunzip=De;var Oe=function(e){this.ondata=e,ce([$,ne,function(){return[le,Te,De]}],this,0,(function(){var e=new De;onmessage=le(e)}),9)};function Ne(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[$,ne,function(){return[Fe]}],(function(e){return ae(Fe(e.data[0]))}),3,n)}function Fe(e,t){return P(e.subarray(me(e),-8),t||new i(ge(e)))}t.AsyncGunzip=Oe,t.gunzip=Ne,t.gunzipSync=Fe;var Be=function(){function e(e,t){this.c=W(),this.v=1,we.call(this,e,t)}return e.prototype.push=function(e,t){we.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=q(e,this.o,this.v&&2,t&&4,!t);this.v&&(ye(n,this.o),this.v=0),t&&pe(n,n.length-4,this.c.d()),this.ondata(n,t)},e}();t.Zlib=Be;function ze(e,t){t||(t={});var n=W();n.p(e);var i=q(e,t,2,4);return ye(i,t),pe(i,i.length-4,n.d()),i}t.AsyncZlib=function(e,t){ce([ee,ie,function(){return[le,we,Be]}],this,be.call(this,e,t),(function(e){var t=new Be(e.data);onmessage=le(t)}),10)},t.zlib=function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[ee,ie,function(){return[ze]}],(function(e){return ae(ze(e.data[0],e.data[1]))}),4,n)},t.zlibSync=ze;var He=function(){function e(e){this.v=1,Te.call(this,e)}return e.prototype.push=function(e,t){if(Te.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Te.prototype.c.call(this,t)},e}();t.Unzlib=He;var Ue=function(e){this.ondata=e,ce([$,re,function(){return[le,Te,He]}],this,0,(function(){var e=new He;onmessage=le(e)}),11)};function ke(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[$,re,function(){return[Ge]}],(function(e){return ae(Ge(e.data[0],oe(e.data[1])))}),5,n)}function Ge(e,t){return P((xe(e),e.subarray(2,-4)),t)}t.AsyncUnzlib=Ue,t.unzlib=ke,t.unzlibSync=Ge;var je=function(){function e(e){this.G=De,this.I=Te,this.Z=He,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new i(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var r=this,a=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(a):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(a):new this.Z(a),this.s.push(this.p,t),this.p=null}}},e}();t.Decompress=je;var Ve=function(){function e(e){this.G=Oe,this.I=Ee,this.Z=Ue,this.ondata=e}return e.prototype.push=function(e,t){je.prototype.push.call(this,e,t)},e}();t.AsyncDecompress=Ve,t.decompress=function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?Ne(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Ae(e,t,n):ke(e,t,n)},t.decompressSync=function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Fe(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Le(e,t):Ge(e,t)};var We=function(e,t,n,r){for(var a in e){var o=e[a],s=t+a;o instanceof i?n[s]=[o,r]:Array.isArray(o)?n[s]=[o[0],X(r,o[1])]:We(o,s+"/",n,r)}},qe="undefined"!=typeof TextEncoder&&new TextEncoder,Xe="undefined"!=typeof TextDecoder&&new TextDecoder,Ze=0;try{Xe.decode(k,{stream:!0}),Ze=1}catch(n){}var Ye=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return[t,C(e,n-1)];r?3==r?(i=((15&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|i>>10,56320|1023&i)):t+=String.fromCharCode(1&r?(31&i)<<6|63&e[n++]:(15&i)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(i)}},Je=function(){function e(e){this.ondata=e,Ze?this.t=new TextDecoder:this.p=k}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t||(t=!1),this.t)return this.ondata(this.t.decode(e,{stream:!t}),t);var n=new i(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var r=Ye(n),a=r[0],o=r[1];if(t&&o.length)throw"invalid utf-8 data";this.p=o,this.ondata(a,t)},e}();t.DecodeUTF8=Je;var Ke=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";this.ondata(Qe(e),t||!1)},e}();function Qe(e,t){if(t){for(var n=new i(e.length),r=0;r>1)),s=0,l=function(e){o[s++]=e};for(r=0;ro.length){var c=new i(s+8+(a-r<<1));c.set(o),o=c}var u=e.charCodeAt(r);u<128||t?l(u):u<2048?(l(192|u>>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++r))>>>18),l(128|u>>>12&63),l(128|u>>>6&63),l(128|63&u)):(l(224|u>>>12),l(128|u>>>6&63),l(128|63&u))}return C(o,0,s)}function $e(e,t){if(t){for(var n="",i=0;i65535)throw"extra field too long";t+=i+4}return t},at=function(e,t,n,i,r,a,o,s){var l=i.length,c=n.extra,u=s&&s.length,h=rt(c);pe(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==a&&8),e[t++]=r&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(pe(e,t,2*(p<<24)|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),t+=4,null!=a&&(pe(e,t,n.crc),pe(e,t+4,a),pe(e,t+8,n.size)),pe(e,t+12,l),pe(e,t+14,h),t+=16,null!=o&&(pe(e,t,u),pe(e,t+6,n.attrs),pe(e,t+10,o),t+=14),e.set(i,t),t+=l,h)for(var f in c){var m=c[f],g=m.length;pe(e,t,+f),pe(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},ot=function(e,t,n,i,r){pe(e,t,101010256),pe(e,t+8,n),pe(e,t+10,n),pe(e,t+12,i),pe(e,t+16,r)},st=function(){function e(e){this.filename=e,this.c=V(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();t.ZipPassThrough=st;var lt=function(){function e(e,t){var n=this;t||(t={}),st.call(this,e),this.d=new we(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=et(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){st.prototype.push.call(this,e,t)},e}();t.ZipDeflate=lt;var ct=function(){function e(e,t){var n=this;t||(t={}),st.call(this,e),this.d=new _e(t,(function(e,t,i){n.ondata(e,t,i)})),this.compression=8,this.flag=et(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){st.prototype.push.call(this,e,t)},e}();t.AsyncZipDeflate=ct;var ut=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=Qe(e.filename),r=n.length,a=e.comment,o=a&&Qe(a),s=r!=e.filename.length||o&&a.length!=o.length,l=r+rt(e.extra)+30;if(r>65535)throw"filename too long";var c=new i(l);at(c,0,e,n,s);var u=[c],h=function(){for(var e=0,n=u;e65535&&S("filename too long",null),M)if(g<16e4)try{S(null,Se(c,f))}catch(e){S(e,null)}else h.push(Me(c,f,S));else S(null,c)},m=0;m65535)throw"filename too long";var v=h?Se(c,u):c,y=v.length,x=V();x.p(c),r.push(X(u,{size:c.length,crc:x.d(),c:v,f:S,m:f,u:d!=s.length||f&&p.length!=m,o:a,compression:h})),a+=30+d+g+y,o+=76+2*(d+g)+(m||0)+y}for(var b=new i(o+22),w=a,_=o-a,M=0;M0){var r=Math.min(this.c,e.length),a=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(a,!this.c):this.k[0].push(a),(e=e.subarray(r)).length)return this.push(e,t)}else{var o=0,s=0,l=void 0,c=void 0;this.p.length?e.length?((c=new i(this.p.length+e.length)).set(this.p),c.set(e,this.p.length)):c=this.p:c=e;for(var u=c.length,h=this.c,d=h&&this.d,p=function(){var e,t=he(c,s);if(67324752==t){o=1,l=s,f.d=null,f.c=0;var i=ue(c,s+6),r=ue(c,s+8),a=2048&i,d=8&i,p=ue(c,s+26),m=ue(c,s+28);if(u>s+30+p+m){var g=[];f.k.unshift(g),o=2;var v=he(c,s+18),y=he(c,s+22),x=$e(c.subarray(s+30,s+=30+p),!a);4294967295==v?(e=d?[-2]:it(c,s),v=e[0],y=e[1]):d&&(v=-1),s+=m,f.c=v;var b={name:x,compression:r,start:function(){if(!b.ondata)throw"no callback";if(v){var e=n.o[r];if(!e)throw"unknown compression type "+r;var t=v<0?new e(x):new e(x,v,y);t.ondata=function(e,t,n){b.ondata(e,t,n)};for(var i=0,a=g;i=0&&(b.size=v,b.originalSize=y),f.onfile(b)}return"break"}if(h){if(134695760==t)return l=s+=12+(-2==h&&8),o=2,f.c=0,"break";if(33639248==t)return l=s-=4,o=2,f.c=0,"break"}},f=this;s65558)return void t("invalid zip file",null);var s=ue(e,o+8);s||t(null,{});var l=s,c=he(e,o+16),u=4294967295==c;if(u){if(o=he(e,o-12),101075792!=he(e,o))return void t("invalid zip file",null);l=s=he(e,o+32),c=he(e,o+48)}for(var h=function(o){var l=nt(e,c,u),h=l[0],d=l[1],p=l[2],f=l[3],m=l[4],g=tt(e,l[5]);c=m;var v=function(e,n){e?(r(),t(e,null)):(a[f]=n,--s||t(null,a))};if(h)if(8==h){var y=e.subarray(g,g+d);if(d<32e4)try{v(null,Le(y,new i(p)))}catch(e){v(e,null)}else n.push(Ae(y,{size:p},v))}else v("unknown compression type "+h,null);else v(null,C(e,g,g+d))},d=0;d65558)throw"invalid zip file";var r=ue(e,n+8);if(!r)return{};var a=he(e,n+16),o=4294967295==a;if(o){if(n=he(e,n-12),101075792!=he(e,n))throw"invalid zip file";r=he(e,n+32),a=he(e,n+48)}for(var s=0;s=s.length&&s===_(a,0,s.length))e=(new u).parse(t);else{var r=_(t);if(!function(e){var t,n,i=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0;for(var a=0;a0,s="string"==typeof a.Content&&""!==a.Content;if(o||s){var l=this.parseImage(i[r]);n[a.RelativeFilename||a.Filename]=l}}}}for(var c in t){var u=t[c];void 0!==n[u]?t[c]=n[u]:t[c]=t[c].split("\\").pop()}return t},parseImage:function(e){var t,n=e.Content,i=e.RelativeFilename||e.Filename,r=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(r){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof n)return"data:"+t+";base64,"+n;var a=new Uint8Array(n);return window.URL.createObjectURL(new Blob([a],{type:t}))},parseTextures:function(t){var n=new Map;if("Texture"in e.Objects){var i=e.Objects.Texture;for(var r in i){var a=this.parseTexture(i[r],t);n.set(parseInt(r),a)}}return n},parseTexture:function(e,t){var n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;var r=e.WrapModeU,a=e.WrapModeV,o=void 0!==r?r.value:0,s=void 0!==a?a.value:0;if(n.wrapS=0===o?i.RepeatWrapping:i.ClampToEdgeWrapping,n.wrapT=0===s?i.RepeatWrapping:i.ClampToEdgeWrapping,"Scaling"in e){var l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}return n},loadTexture:function(e,t){var r,a,o=this.textureLoader.path,s=n.get(e.id).children;void 0!==s&&s.length>0&&void 0!==t[s[0].ID]&&(0!==(r=t[s[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));var l=e.FileName.slice(-3).toLowerCase();if("tga"===l){var c=this.manager.getHandler(".tga");null===c?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new i.Texture):a=c.load(r)}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new i.Texture):a=this.textureLoader.load(r);return this.textureLoader.setPath(o),a},parseMaterials:function(t){var n=new Map;if("Material"in e.Objects){var i=e.Objects.Material;for(var r in i){var a=this.parseMaterial(i[r],t);null!==a&&n.set(parseInt(r),a)}}return n},parseMaterial:function(e,t){var r=e.id,a=e.attrName,o=e.ShadingModel;if("object"==typeof o&&(o=o.value),!n.has(r))return null;var s,l=this.parseParameters(e,t,r);switch(o.toLowerCase()){case"phong":s=new i.MeshPhongMaterial;break;case"lambert":s=new i.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),s=new i.MeshPhongMaterial}return s.setValues(l),s.name=a,s},parseParameters:function(e,t,r){var a={};e.BumpFactor&&(a.bumpScale=e.BumpFactor.value),e.Diffuse?a.color=(new i.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(a.color=(new i.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(a.displacementScale=e.DisplacementFactor.value),e.Emissive?a.emissive=(new i.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(a.emissive=(new i.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(a.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(a.opacity=parseFloat(e.Opacity.value)),a.opacity<1&&(a.transparent=!0),e.ReflectionFactor&&(a.reflectivity=e.ReflectionFactor.value),e.Shininess&&(a.shininess=e.Shininess.value),e.Specular?a.specular=(new i.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(a.specular=(new i.Color).fromArray(e.SpecularColor.value));var o=this;return n.get(r).children.forEach((function(e){var n=e.relationship;switch(n){case"Bump":a.bumpMap=o.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":a.aoMap=o.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":a.map=o.getTexture(t,e.ID),a.map.encoding=i.sRGBEncoding;break;case"DisplacementColor":a.displacementMap=o.getTexture(t,e.ID);break;case"EmissiveColor":a.emissiveMap=o.getTexture(t,e.ID),a.emissiveMap.encoding=i.sRGBEncoding;break;case"NormalMap":case"Maya|TEX_normal_map":a.normalMap=o.getTexture(t,e.ID);break;case"ReflectionColor":a.envMap=o.getTexture(t,e.ID),a.envMap.mapping=i.EquirectangularReflectionMapping,a.envMap.encoding=i.sRGBEncoding;break;case"SpecularColor":a.specularMap=o.getTexture(t,e.ID),a.specularMap.encoding=i.sRGBEncoding;break;case"TransparentColor":case"TransparencyFactor":a.alphaMap=o.getTexture(t,e.ID),a.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),a},getTexture:function(t,i){return"LayeredTexture"in e.Objects&&i in e.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),i=n.get(i).children[0].ID),t.get(i)},parseDeformers:function(){var t={},i={};if("Deformer"in e.Objects){var r=e.Objects.Deformer;for(var a in r){var o=r[a],s=n.get(parseInt(a));if("Skin"===o.attrType){var l=this.parseSkeleton(s,r);l.ID=a,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),l.geometryID=s.parents[0].ID,t[a]=l}else if("BlendShape"===o.attrType){var c={id:a};c.rawTargets=this.parseMorphTargets(s,r),c.id=a,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),i[a]=c}}}return{skeletons:t,morphTargets:i}},parseSkeleton:function(e,t){var n=[];return e.children.forEach((function(e){var r=t[e.ID];if("Cluster"===r.attrType){var a={ID:e.ID,indices:[],weights:[],transformLink:(new i.Matrix4).fromArray(r.TransformLink.a)};"Indexes"in r&&(a.indices=r.Indexes.a,a.weights=r.Weights.a),n.push(a)}})),{rawBones:n,bones:[]}},parseMorphTargets:function(e,t){for(var i=[],r=0;r1?o=s:s.length>0?o=s[0]:(o=new i.MeshPhongMaterial({color:13421772}),s.push(o)),"color"in a.attributes&&s.forEach((function(e){e.vertexColors=!0})),a.FBX_Deformer?(s.forEach((function(e){e.skinning=!0})),(r=new i.SkinnedMesh(a,o)).normalizeSkinWeights()):r=new i.Mesh(a,o),r},createCurve:function(e,t){var n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),r=new i.LineBasicMaterial({color:3342591,linewidth:1});return new i.Line(n,r)},getTransformData:function(e,t){var n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?b(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n},setLookAtProperties:function(t,a){"LookAtProperty"in a&&n.get(t.ID).children.forEach((function(n){if("LookAtProperty"===n.relationship){var a=e.Objects.Model[n.ID];if("Lcl_Translation"in a){var o=a.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(o),r.add(t.target)):t.lookAt((new i.Vector3).fromArray(o))}}}))},bindSkeleton:function(e,t,r){var a=this.parsePoseNodes();for(var o in e){var s=e[o];n.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){var o=e.ID;n.get(o).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new i.Skeleton(s.bones),a[e.ID])}))}}))}},parsePoseNodes:function(){var t={};if("Pose"in e.Objects){var n=e.Objects.Pose;for(var r in n)if("BindPose"===n[r].attrType){var a=n[r].PoseNode;Array.isArray(a)?a.forEach((function(e){t[e.Node]=(new i.Matrix4).fromArray(e.Matrix.a)})):t[a.Node]=(new i.Matrix4).fromArray(a.Matrix.a)}}return t},createAmbientLight:function(){if("GlobalSettings"in e&&"AmbientColor"in e.GlobalSettings){var t=e.GlobalSettings.AmbientColor.value,n=t[0],a=t[1],o=t[2];if(0!==n||0!==a||0!==o){var s=new i.Color(n,a,o);r.add(new i.AmbientLight(s,1))}}},setupMorphMaterials:function(){var e=this;r.traverse((function(t){t.isMesh&&t.geometry.morphAttributes.position&&t.geometry.morphAttributes.position.length&&(Array.isArray(t.material)?t.material.forEach((function(n,i){e.setupMorphMaterial(t,n,i)})):e.setupMorphMaterial(t,t.material))}))},setupMorphMaterial:function(e,t,n){var i=e.uuid,a=t.uuid,o=!1;if(r.traverse((function(e){e.isMesh&&(Array.isArray(e.material)?e.material.forEach((function(t){t.uuid===a&&e.uuid!==i&&(o=!0)})):e.material.uuid===a&&e.uuid!==i&&(o=!0))})),!0===o){var s=t.clone();s.morphTargets=!0,void 0===n?e.material=s:e.material[n]=s}else t.morphTargets=!0}},s.prototype={constructor:s,parse:function(t){var i=new Map;if("Geometry"in e.Objects){var r=e.Objects.Geometry;for(var a in r){var o=n.get(parseInt(a)),s=this.parseGeometry(o,r[a],t);i.set(parseInt(a),s)}}return i},parseGeometry:function(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}},parseMeshGeometry:function(t,n,i){var r=i.skeletons,a=[],o=t.parents.map((function(t){return e.Objects.Model[t.ID]}));if(0!==o.length){var s=t.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);t.children.forEach((function(e){void 0!==i.morphTargets[e.ID]&&a.push(i.morphTargets[e.ID])}));var l=o[0],c={};"RotationOrder"in l&&(c.eulerOrder=b(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);var u=x(c);return this.genGeometry(n,s,a,u)}},genGeometry:function(e,t,n,r){var a=new i.BufferGeometry;e.attrName&&(a.name=e.attrName);var o=this.parseGeoNode(e,t),s=this.genBuffers(o),l=new i.Float32BufferAttribute(s.vertex,3);if(l.applyMatrix4(r),a.setAttribute("position",l),s.colors.length>0&&a.setAttribute("color",new i.Float32BufferAttribute(s.colors,3)),t&&(a.setAttribute("skinIndex",new i.Uint16BufferAttribute(s.weightsIndices,4)),a.setAttribute("skinWeight",new i.Float32BufferAttribute(s.vertexWeights,4)),a.FBX_Deformer=t),s.normal.length>0){var c=(new i.Matrix3).getNormalMatrix(r),u=new i.Float32BufferAttribute(s.normal,3);u.applyNormalMatrix(c),a.setAttribute("normal",u)}if(s.uvs.forEach((function(e,t){var n="uv"+(t+1).toString();0===t&&(n="uv"),a.setAttribute(n,new i.Float32BufferAttribute(s.uvs[t],2))})),o.material&&"AllSame"!==o.material.mappingType){var h=s.materialIndex[0],d=0;if(s.materialIndex.forEach((function(e,t){e!==h&&(a.addGroup(d,t-d,h),h=e,d=t)})),a.groups.length>0){var p=a.groups[a.groups.length-1],f=p.start+p.count;f!==s.materialIndex.length&&a.addGroup(f,s.materialIndex.length-f,h)}0===a.groups.length&&a.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(a,e,n,r),a},parseGeoNode:function(e,t){var n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];for(var i=0;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n},genBuffers:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,r=!1,a=[],o=[],s=[],l=[],c=[],u=[],h=this;return e.vertexIndices.forEach((function(d,p){var f=!1;d<0&&(d^=-1,f=!0);var m=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){var y=g(p,n,d,e.color);s.push(y[0],y[1],y[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),m.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);var x=[0,0,0,0],b=[0,0,0,0];v.forEach((function(e,t){var n=e,i=m[t];b.forEach((function(e,t,r){if(n>e){r[t]=n,n=e;var a=x[t];x[t]=i,i=a}}))})),m=x,v=b}for(;v.length<4;)v.push(0),m.push(0);for(var w=0;w<4;++w)c.push(v[w]),u.push(m[w])}if(e.normal&&(y=g(p,n,d,e.normal),o.push(y[0],y[1],y[2])),e.material&&"AllSame"!==e.material.mappingType)var _=g(p,n,d,e.material)[0];e.uv&&e.uv.forEach((function(e,t){var i=g(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,f&&(h.genFace(t,e,a,_,o,s,l,c,u,i),n++,i=0,a=[],o=[],s=[],l=[],c=[],u=[])})),t},genFace:function(e,t,n,i,r,a,o,s,l,c){for(var u=2;u1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var s=t.get(o[0].ID);r[a]={name:i[a].attrName,layer:s}}return r},addClip:function(e){var t=[],n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new i.AnimationClip(e.name,-1,t)},generateTracks:function(e){var t=[],n=new i.Vector3,r=new i.Quaternion,a=new i.Vector3;if(e.transform&&e.transform.decompose(n,r,a),n=n.toArray(),r=(new i.Euler).setFromQuaternion(r,e.eulerOrder).toArray(),a=a.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){var o=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==o&&t.push(o)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var s=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==s&&t.push(s)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){var l=this.generateVectorTrack(e.modelName,e.S.curves,a,"scale");void 0!==l&&t.push(l)}if(void 0!==e.DeformPercent){var c=this.generateMorphTrack(e);void 0!==c&&t.push(c)}return t},generateVectorTrack:function(e,t,n,r){var a=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(a,t,n);return new i.VectorKeyframeTrack(e+"."+r,a,o)},generateRotationTrack:function(e,t,n,r,a,o){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(i.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(i.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(i.MathUtils.degToRad));var s=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(s,t,n);void 0!==r&&((r=r.map(i.MathUtils.degToRad)).push(o),r=(new i.Euler).fromArray(r),r=(new i.Quaternion).setFromEuler(r)),void 0!==a&&((a=a.map(i.MathUtils.degToRad)).push(o),a=(new i.Euler).fromArray(a),a=(new i.Quaternion).setFromEuler(a).invert());for(var c=new i.Quaternion,u=new i.Euler,h=[],d=0;d1){for(var n=1,i=t[0],r=1;r=180){for(var a=r/180,o=i/a,s=n+o,l=e.times[t-1],c=(e.times[t]-l)/a,u=l+c,h=[],d=[];u1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}},parseNodeProperty:function(e,t,n){var i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());var a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===i){var o=r.split(",").slice(1),s=parseInt(o[0]),l=parseInt(o[1]),c=r.split(",").slice(3);i="connections",function(e,t){for(var n=0,i=e.length,r=t.length;n=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();var a=e.getUint8(),o=e.getString(a);if(0===i)return null;for(var s=[],l=0;l0?s[0]:"",u=s.length>1?s[1]:"",h=s.length>2?s[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){var d=this.parseNode(e,t);null!==d&&this.parseSubNode(o,n,d)}return n.propertyList=s,"number"==typeof c&&(n.id=c),""!==u&&(n.attrName=u),""!==h&&(n.attrType=h),""!==o&&(n.name=o),n},parseSubNode:function(e,t,n){if(!0===n.singleProperty){var i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if("Connections"===e&&"C"===n.name){var r=[];n.propertyList.forEach((function(e,t){0!==t&&r.push(e)})),void 0===t.connections&&(t.connections=[]),t.connections.push(r)}else if("Properties70"===n.name)Object.keys(n).forEach((function(e){t[e]=n[e]}));else if("Properties70"===e&&"P"===n.name){var a,o=n.propertyList[0],s=n.propertyList[1],l=n.propertyList[2],c=n.propertyList[3];0===o.indexOf("Lcl ")&&(o=o.replace("Lcl ","Lcl_")),0===s.indexOf("Lcl ")&&(s=s.replace("Lcl ","Lcl_")),a="Color"===s||"ColorRGB"===s||"Vector"===s||"Vector3D"===s||0===s.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[o]={type:s,type2:l,flag:c,value:a}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)},parseProperty:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":var n=e.getUint32();return e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}void 0===Z&&console.error("THREE.FBXLoader: External library fflate.min.js required.");var o=new h(Z.unzlibSync(new Uint8Array(e.getArrayBuffer(a))).buffer);switch(t){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}},h.prototype={constructor:h,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1==(1&this.getUint8())},getBooleanArray:function(e){for(var t=[],n=0;n=0&&(t=t.slice(0,r)),i.LoaderUtils.decodeText(new Uint8Array(t))}},d.prototype={constructor:d,add:function(e,t){this[e]=t}};var m=[];function g(e,t,n,i){var r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);var a=r*i.dataSize,o=a+i.dataSize;return function(e,t,n,i){for(var r=n,a=0;r=2.0 are supported."));else{var h=new O(u,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(var p=0;p=0&&void 0===c[y]&&console.warn('THREE.GLTFLoader: Unknown extension "'+y+'".')}}h.setExtensions(l),h.setPlugins(c),h.parse(n,a)}}});var r={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};function a(e){this.parser=e,this.name=r.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function o(){this.name=r.KHR_MATERIALS_UNLIT}function s(e){this.parser=e,this.name=r.KHR_MATERIALS_CLEARCOAT}function l(e){this.parser=e,this.name=r.KHR_MATERIALS_TRANSMISSION}function c(e){this.parser=e,this.name=r.KHR_TEXTURE_BASISU}function u(e){this.parser=e,this.name=r.EXT_TEXTURE_WEBP,this.isSupported=null}function h(e){this.name=r.EXT_MESHOPT_COMPRESSION,this.parser=e}a.prototype._markDefs=function(){for(var e=this.parser,t=this.parser.json.nodes||[],n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a,o)},u.prototype.loadTexture=function(e){var t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;var a=r.extensions[t],o=i.images[a.source],s=n.textureLoader;if(o.uri){var l=n.options.manager.getHandler(o.uri);null!==l&&(s=l)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o,s);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))},u.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported},h.prototype.loadBufferView=function(e){var t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){var i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,a.ready]).then((function(e){var t=i.byteOffset||0,n=i.byteLength||0,r=i.count,o=i.byteStride,s=new ArrayBuffer(r*o),l=new Uint8Array(e[0],t,n);return a.decodeGltfBuffer(new Uint8Array(s),r,o,l,i.mode,i.filter),s}))}return null};var d="glTF",p=1313821514,f=5130562;function m(e){this.name=r.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,12);if(this.header={magic:i.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==d)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var n=this.header.length-12,a=new DataView(e,12),o=0;o",t).replace("#include ",n).replace("#include ",r).replace("#include ",a).replace("#include ",o)},Object.defineProperties(this,{specular:{get:function(){return s.specular.value},set:function(e){s.specular.value=e}},specularMap:{get:function(){return s.specularMap.value},set:function(e){s.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(e){s.glossiness.value=e}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(e){s.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}function x(){return{name:r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return y},extendParams:function(e,t,n){var r=t.extensions[this.name];e.color=new i.Color(1,1,1),e.opacity=1;var a=[];if(Array.isArray(r.diffuseFactor)){var o=r.diffuseFactor;e.color.fromArray(o),e.opacity=o[3]}if(void 0!==r.diffuseTexture&&a.push(n.assignTexture(e,"map",r.diffuseTexture)),e.emissive=new i.Color(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new i.Color(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){var s=r.specularGlossinessTexture;a.push(n.assignTexture(e,"glossinessMap",s)),a.push(n.assignTexture(e,"specularMap",s))}return Promise.all(a)},createMaterial:function(e){var t=new y(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=i.TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}}function b(){this.name=r.KHR_MESH_QUANTIZATION}function w(e,t,n,r){i.Interpolant.call(this,e,t,n,r)}g.prototype.decodePrimitive=function(e,t){var n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},l={};for(var c in a){var u=E[c]||c.toLowerCase();o[u]=a[c]}for(c in e.attributes)if(u=E[c]||c.toLowerCase(),void 0!==a[c]){var h=n.accessors[e.attributes[c]],d=_[h.componentType];l[u]=d,s[u]=!0===h.normalized}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(var n in e.attributes){var i=e.attributes[n],r=s[n];void 0!==r&&(i.normalized=r)}t(e)}),o,l)}))}))},v.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},y.prototype=Object.create(i.MeshStandardMaterial.prototype),y.prototype.constructor=y,y.prototype.copy=function(e){return i.MeshStandardMaterial.prototype.copy.call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this},w.prototype=Object.create(i.Interpolant.prototype),w.prototype.constructor=w,w.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i,a=0;a!==i;a++)t[a]=n[r+a];return t},w.prototype.beforeStart_=w.prototype.copySampleValue_,w.prototype.afterEnd_=w.prototype.copySampleValue_,w.prototype.interpolate_=function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,c=i-t,u=(n-t)/c,h=u*u,d=h*u,p=e*l,f=p-l,m=-2*d+3*h,g=d-h,v=1-m,y=g-h+u,x=0;x!==o;x++){var b=a[f+x+o],w=a[f+x+s]*c,_=a[p+x+o],M=a[p+x]*c;r[x]=v*b+y*w+m*_+g*M}return r};var _={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},M={9728:i.NearestFilter,9729:i.LinearFilter,9984:i.NearestMipmapNearestFilter,9985:i.LinearMipmapNearestFilter,9986:i.NearestMipmapLinearFilter,9987:i.LinearMipmapLinearFilter},S={33071:i.ClampToEdgeWrapping,33648:i.MirroredRepeatWrapping,10497:i.RepeatWrapping},T={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},E={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},A={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},L={CUBICSPLINE:void 0,LINEAR:i.InterpolateLinear,STEP:i.InterpolateDiscrete};function R(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function C(e,t,n){for(var i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function P(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function I(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var n=0,i=t.weights.length;n=2&&o.setY(L,S[E*l+1]),l>=3&&o.setZ(L,S[E*l+2]),l>=4&&o.setW(L,S[E*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o}))},O.prototype.loadTexture=function(e){var t=this.json,n=this.options,i=t.textures[e],r=t.images[i.source],a=this.textureLoader;if(r.uri){var o=n.manager.getHandler(r.uri);null!==o&&(a=o)}return this.loadTextureImage(e,r,a)},O.prototype.loadTextureImage=function(e,t,n){var r=this,a=this.json,o=this.options,s=a.textures[e],l=self.URL||self.webkitURL,c=t.uri,u=!1,h=!0;if("image/jpeg"===t.mimeType&&(h=!1),void 0!==t.bufferView)c=r.getDependency("bufferView",t.bufferView).then((function(e){if("image/png"===t.mimeType){var n=new DataView(e,25,1).getUint8(0,!1);h=6===n||4===n||3===n}u=!0;var i=new Blob([e],{type:t.mimeType});return c=l.createObjectURL(i)}));else if(void 0===t.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return Promise.resolve(c).then((function(e){return new Promise((function(t,r){var a=t;!0===n.isImageBitmapLoader&&(a=function(e){t(new i.CanvasTexture(e))}),n.load(R(e,o.path),a,void 0,r)}))})).then((function(t){!0===u&&l.revokeObjectURL(c),t.flipY=!1,s.name&&(t.name=s.name),h||(t.format=i.RGBFormat);var n=(a.samplers||{})[s.sampler]||{};return t.magFilter=M[n.magFilter]||i.LinearFilter,t.minFilter=M[n.minFilter]||i.LinearMipmapLinearFilter,t.wrapS=S[n.wrapS]||i.RepeatWrapping,t.wrapT=S[n.wrapT]||i.RepeatWrapping,r.associations.set(t,{type:"textures",index:e}),t}))},O.prototype.assignTexture=function(e,t,n){var i=this;return this.getDependency("texture",n.index).then((function(a){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[r.KHR_TEXTURE_TRANSFORM]){var o=void 0!==n.extensions?n.extensions[r.KHR_TEXTURE_TRANSFORM]:void 0;if(o){var s=i.associations.get(a);a=i.extensions[r.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),i.associations.set(a,s)}}e[t]=a}))},O.prototype.assignFinalMaterial=function(e){var t=e.geometry,n=e.material,r=void 0!==t.attributes.tangent,a=void 0!==t.attributes.color,o=void 0===t.attributes.normal,s=!0===e.isSkinnedMesh,l=Object.keys(t.morphAttributes).length>0,c=l&&void 0!==t.morphAttributes.normal;if(e.isPoints){var u="PointsMaterial:"+n.uuid,h=this.cache.get(u);h||(h=new i.PointsMaterial,i.Material.prototype.copy.call(h,n),h.color.copy(n.color),h.map=n.map,h.sizeAttenuation=!1,this.cache.add(u,h)),n=h}else if(e.isLine){u="LineBasicMaterial:"+n.uuid;var d=this.cache.get(u);d||(d=new i.LineBasicMaterial,i.Material.prototype.copy.call(d,n),d.color.copy(n.color),this.cache.add(u,d)),n=d}if(r||a||o||s||l){u="ClonedMaterial:"+n.uuid+":",n.isGLTFSpecularGlossinessMaterial&&(u+="specular-glossiness:"),s&&(u+="skinning:"),r&&(u+="vertex-tangents:"),a&&(u+="vertex-colors:"),o&&(u+="flat-shading:"),l&&(u+="morph-targets:"),c&&(u+="morph-normals:");var p=this.cache.get(u);p||(p=n.clone(),s&&(p.skinning=!0),a&&(p.vertexColors=!0),o&&(p.flatShading=!0),l&&(p.morphTargets=!0),c&&(p.morphNormals=!0),r&&(p.vertexTangents=!0,p.normalScale&&(p.normalScale.y*=-1),p.clearcoatNormalScale&&(p.clearcoatNormalScale.y*=-1)),this.cache.add(u,p),this.associations.set(p,this.associations.get(n))),n=p}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n},O.prototype.getMaterialType=function(){return i.MeshStandardMaterial},O.prototype.loadMaterial=function(e){var t,n=this,a=this.json,o=this.extensions,s=a.materials[e],l={},c=s.extensions||{},u=[];if(c[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var h=o[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=h.getMaterialType(),u.push(h.extendParams(l,s,n))}else if(c[r.KHR_MATERIALS_UNLIT]){var d=o[r.KHR_MATERIALS_UNLIT];t=d.getMaterialType(),u.push(d.extendParams(l,s,n))}else{var p=s.pbrMetallicRoughness||{};if(l.color=new i.Color(1,1,1),l.opacity=1,Array.isArray(p.baseColorFactor)){var f=p.baseColorFactor;l.color.fromArray(f),l.opacity=f[3]}void 0!==p.baseColorTexture&&u.push(n.assignTexture(l,"map",p.baseColorTexture)),l.metalness=void 0!==p.metallicFactor?p.metallicFactor:1,l.roughness=void 0!==p.roughnessFactor?p.roughnessFactor:1,void 0!==p.metallicRoughnessTexture&&(u.push(n.assignTexture(l,"metalnessMap",p.metallicRoughnessTexture)),u.push(n.assignTexture(l,"roughnessMap",p.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,l)}))))}!0===s.doubleSided&&(l.side=i.DoubleSide);var m=s.alphaMode||"OPAQUE";return"BLEND"===m?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,"MASK"===m&&(l.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&t!==i.MeshBasicMaterial&&(u.push(n.assignTexture(l,"normalMap",s.normalTexture)),l.normalScale=new i.Vector2(1,-1),void 0!==s.normalTexture.scale&&l.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&t!==i.MeshBasicMaterial&&(u.push(n.assignTexture(l,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(l.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&t!==i.MeshBasicMaterial&&(l.emissive=(new i.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&t!==i.MeshBasicMaterial&&u.push(n.assignTexture(l,"emissiveMap",s.emissiveTexture)),Promise.all(u).then((function(){var a;return a=t===y?o[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(l):new t(l),s.name&&(a.name=s.name),a.map&&(a.map.encoding=i.sRGBEncoding),a.emissiveMap&&(a.emissiveMap.encoding=i.sRGBEncoding),P(a,s),n.associations.set(a,{type:"materials",index:e}),s.extensions&&C(o,a,s),a}))},O.prototype.createUniqueName=function(e){for(var t=i.PropertyBinding.sanitizeNodeName(e||""),n=t,r=1;this.nodeNamesUsed[n];++r)n=t+"_"+r;return this.nodeNamesUsed[n]=!0,n},O.prototype.loadGeometries=function(e){var t=this,n=this.extensions,a=this.primitiveCache;function o(e){return n[r.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return N(n,e,t)}))}for(var s,l,c=[],u=0,h=e.length;u0&&I(d,o),d.name=n.createUniqueName(o.name||"mesh_"+e),P(d,o),f.extensions&&C(a,d,f),n.assignFinalMaterial(d),c.push(d)}if(1===c.length)return c[0];var g=new i.Group;for(u=0,h=c.length;u1?new i.Group:1===t.length?t[0]:new i.Object3D)!==t[0])for(var l=0,c=t.length;l0&&t.push(new i.VectorKeyframeTrack(r+".position",a,o)),s.length>0&&t.push(new i.QuaternionKeyframeTrack(r+".quaternion",a,s)),l.length>0&&t.push(new i.VectorKeyframeTrack(r+".scale",a,l)),t}function M(e,t,n){var i,r,a,o=!0;for(r=0,a=e.length;r=0;){var i=e[t];if(null!==i.value[n])return i;t--}return null}function T(e,t,n){for(;t>>0));switch(n=n.toLowerCase()){case"tga":t=We;break;default:t=Xe}return t}(n);if(void 0!==a){var o=a.load(n),s=e.extra;if(void 0!==s&&void 0!==s.technique&&!1===l(s.technique)){var c=s.technique;o.wrapS=c.wrapU?i.RepeatWrapping:i.ClampToEdgeWrapping,o.wrapT=c.wrapV?i.RepeatWrapping:i.ClampToEdgeWrapping,o.offset.set(c.offsetU||0,c.offsetV||0),o.repeat.set(c.repeatU||1,c.repeatV||1)}else o.wrapS=i.RepeatWrapping,o.wrapT=i.RepeatWrapping;return o}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",n),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}n.name=e.name||"";var c=a.parameters;for(var u in c){var h=c[u];switch(u){case"diffuse":h.color&&n.color.fromArray(h.color),h.texture&&(n.map=s(h.texture));break;case"specular":h.color&&n.specular&&n.specular.fromArray(h.color),h.texture&&(n.specularMap=s(h.texture));break;case"bump":h.texture&&(n.normalMap=s(h.texture));break;case"ambient":h.texture&&(n.lightMap=s(h.texture));break;case"shininess":h.float&&n.shininess&&(n.shininess=h.float);break;case"emission":h.color&&n.emissive&&n.emissive.fromArray(h.color),h.texture&&(n.emissiveMap=s(h.texture))}}var d=c.transparent,f=c.transparency;if(void 0===f&&d&&(f={float:1}),void 0===d&&f&&(d={opaque:"A_ONE",data:{color:[1,1,1,1]}}),d&&f)if(d.data.texture)n.transparent=!0;else{var m=d.data.color;switch(d.opaque){case"A_ONE":n.opacity=m[3]*f.float;break;case"RGB_ZERO":n.opacity=1-m[0]*f.float;break;case"A_ZERO":n.opacity=1-m[3]*f.float;break;case"RGB_ONE":n.opacity=m[0]*f.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',d.opaque)}n.opacity<1&&(n.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(n.side=i.DoubleSide),n}function Y(e){return p(Ke.materials[e],Z)}function J(e){for(var t=0;t0?l+u:l;t.inputs[h]={id:a,offset:c},t.stride=Math.max(t.stride,c+1),"TEXCOORD"===l&&(t.hasUV=!0);break;case"vcount":t.vcount=o(r.textContent);break;case"p":t.p=o(r.textContent)}}return t}function le(e){for(var t=0,n=0,i=e.length;n0&&t0&&d.setAttribute("position",new i.Float32BufferAttribute(a.array,a.stride)),o.array.length>0&&d.setAttribute("normal",new i.Float32BufferAttribute(o.array,o.stride)),c.array.length>0&&d.setAttribute("color",new i.Float32BufferAttribute(c.array,c.stride)),s.array.length>0&&d.setAttribute("uv",new i.Float32BufferAttribute(s.array,s.stride)),l.array.length>0&&d.setAttribute("uv2",new i.Float32BufferAttribute(l.array,l.stride)),u.length>0&&d.setAttribute("skinIndex",new i.Float32BufferAttribute(u,4)),h.length>0&&d.setAttribute("skinWeight",new i.Float32BufferAttribute(h,4)),r.data=d,r.type=e[0].type,r.materialKeys=p,r}function he(e,t,n,i){var r=e.p,a=e.stride,o=e.vcount;function s(e){for(var t=r[e+n]*c,a=t+c;t4)for(var v=1,y=p-2;v<=y;v++)f=u+a*v,m=u+a*(v+1),s(u+0*a),s(f),s(m);u+=a*p}else for(h=0,d=r.length;h=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ve(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},n=0;nr.limits.max||t{let r=[];switch(e.type){case"mtl":i=i.children[0];break;case"gltf":case"glb":case"dae":r=i.animations,i=i.scene;break;case"fbx":r=i.animations}i.animations=r;const a=u.types.rotation(e.rotation,[0,0,0]),o=u.types.scale(e.scale,[1,1,1]);i.rotation.set(a[0],a[1],a[2]),i.scale.set(o[0],o[1],o[2]),e.normalize&&i.traverse((function(e){if(e.isMesh){let t;"MeshStandardMaterial"==e.material.type?(e.material.metalness&&(e.material.metalness*=.1),e.material.glossiness&&(e.material.glossiness*=.25),t=new THREE.Color(12,12,12)):"MeshPhongMaterial"==e.material.type&&(e.material.shininess=.1,t=new THREE.Color(20,20,20)),e.material.specular&&e.material.specular.isColor&&(e.material.specular=t)}})),i.name="model";let s=_.prototype._makeGroup(i,e);_.prototype._addMethods(s),s.setAnchor(e.anchor),s.setCenter(e.adjustment),s.raycasted=e.raycasted,n(s),t(s),s.setFixedZoom(e.mapScale),s.idle()},()=>null,t=>{console.error("Could not load model file: "+e.obj+" \n "+t.stack),n("Error loading the model")})}),()=>null,e=>{console.warn("No material file found for SymbolLayer3D model "+m)})};var re,ae,oe,se,le={};function ce(e){e=u._validate(e,_.prototype._defaults.line);var t=u.lnglatsToWorld(e.geometry),n=u.normalizeVertices(t),r=u.flattenVectors(n.vertices),a=new i.LineGeometry;a.setPositions(r);let o=new i.LineMaterial({color:e.color,linewidth:e.width,dashed:!1,opacity:e.opacity});return o.resolution.set(window.innerWidth,window.innerHeight),o.isMaterial=!0,o.transparent=!0,o.depthWrite=!1,(ce=new i.Line2(a,o)).position.copy(n.position),ce.computeLineDistances(),ce}le=le=ce,i.LineSegmentsGeometry=function(){i.InstancedBufferGeometry.call(this),this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new i.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new i.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))},i.LineSegmentsGeometry.prototype=Object.assign(Object.create(i.InstancedBufferGeometry.prototype),{constructor:i.LineSegmentsGeometry,isLineSegmentsGeometry:!0,applyMatrix4:function(e){var t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},setPositions:function(e){var t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var n=new i.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new i.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},setColors:function(e){var t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var n=new i.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new i.InterleavedBufferAttribute(n,3,3)),this},fromWireframeGeometry:function(e){return this.setPositions(e.attributes.position.array),this},fromEdgesGeometry:function(e){return this.setPositions(e.attributes.position.array),this},fromMesh:function(e){return this.fromWireframeGeometry(new i.WireframeGeometry(e.geometry)),this},fromLineSegments:function(e){var t=e.geometry;if(!t.isGeometry)return t.isBufferGeometry&&this.setPositions(t.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},computeBoundingBox:(ae=new i.Box3,function(){null===this.boundingBox&&(this.boundingBox=new i.Box3);var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),ae.setFromBufferAttribute(t),this.boundingBox.union(ae))}),computeBoundingSphere:(re=new i.Vector3,function(){null===this.boundingSphere&&(this.boundingSphere=new i.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){var n=this.boundingSphere.center;this.boundingBox.getCenter(n);for(var r=0,a=0,o=e.count;a\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"},i.LineMaterial=function(e){i.ShaderMaterial.call(this,{type:"LineMaterial",uniforms:i.UniformsUtils.clone(i.ShaderLib.line.uniforms),vertexShader:i.ShaderLib.line.vertexShader,fragmentShader:i.ShaderLib.line.fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)},i.LineMaterial.prototype=Object.create(i.ShaderMaterial.prototype),i.LineMaterial.prototype.constructor=i.LineMaterial,i.LineMaterial.prototype.isLineMaterial=!0,i.LineSegments2=function(e,t){void 0===e&&(e=new i.LineSegmentsGeometry),void 0===t&&(t=new i.LineMaterial({color:16777215*Math.random()})),i.Mesh.call(this,e,t),this.type="LineSegments2"},i.LineSegments2.prototype=Object.assign(Object.create(i.Mesh.prototype),{constructor:i.LineSegments2,isLineSegments2:!0,computeLineDistances:(oe=new i.Vector3,se=new i.Vector3,function(){for(var e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.data.count),a=0,o=0,s=t.data.count;ab&&t.z>b)){if(e.z>b){const n=e.z-t.z,i=(e.z-b)/n;e.lerp(t,i)}else if(t.z>b){const n=t.z-e.z,i=(t.z-b)/n;t.lerp(e,i)}e.applyMatrix4(p),t.applyMatrix4(p),e.multiplyScalar(1/e.w),t.multiplyScalar(1/t.w),e.x*=g.x/2,e.y*=g.y/2,t.x*=g.x/2,t.y*=g.y/2,o.start.copy(e),o.start.z=0,o.end.copy(t),o.end.z=0;var S=o.closestPointToPointParameter(r,!0);o.at(S,s);var T=i.MathUtils.lerp(e.z,t.z,S),E=T>=-1&&T<=1,A=r.distanceTo(s)<.5*v;if(E&&A){o.start.fromBufferAttribute(y,_),o.end.fromBufferAttribute(x,_),o.start.applyMatrix4(w),o.end.applyMatrix4(w);var L=new i.Vector3,R=new i.Vector3;h.distanceSqToSegment(o.start,o.end,R,L),c.push({point:R,pointOnLine:L,distance:h.origin.distanceTo(R),object:this,face:null,faceIndex:_,uv:null,uv2:null})}}}}()}),i.Line2=function(e,t){void 0===e&&(e=new i.LineGeometry),void 0===t&&(t=new i.LineMaterial({color:16777215*Math.random()})),i.LineSegments2.call(this,e,t),this.type="Line2"},i.Line2.prototype=Object.assign(Object.create(i.LineSegments2.prototype),{constructor:i.Line2,isLine2:!0}),i.Wireframe=function(e,t){i.Mesh.call(this),this.type="Wireframe",this.geometry=void 0!==e?e:new i.LineSegmentsGeometry,this.material=void 0!==t?t:new i.LineMaterial({color:16777215*Math.random()})},i.Wireframe.prototype=Object.assign(Object.create(i.Mesh.prototype),{constructor:i.Wireframe,isWireframe:!0,computeLineDistances:function(){var e=new i.Vector3,t=new i.Vector3;return function(){for(var n=this.geometry,r=n.attributes.instanceStart,a=n.attributes.instanceEnd,o=new Float32Array(2*r.data.count),s=0,l=0,c=r.data.count;s{n.push(new i.Vector3(e[0],e[1],e[2]))});const r=new i.CatmullRomCurve3(n);let a=new i.TubeGeometry(r,n.length,e.radius,e.sides,!1),o=g(e),s=new i.Mesh(a,o);return new T({obj:s,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var he={};he=he=function(e){this.map=e,this.renderer=new w.CSS2DRenderer,this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.domElement.style.position="absolute",this.renderer.domElement.id="labelCanvas",this.renderer.domElement.style.top=0,this.renderer.domElement.style.zIndex="0",this.map.getCanvasContainer().appendChild(this.renderer.domElement),this.scene,this.camera,this.dispose=function(){this.map.getCanvasContainer().removeChild(this.renderer.domElement),this.renderer.domElement.remove(),this.renderer={}},this.setSize=function(e,t){this.renderer.setSize(e,t)},this.map.on("resize",function(){this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight)}.bind(this)),this.state={reset:function(){}},this.render=async function(e,t){return this.scene=e,this.camera=t,new Promise(n=>{n(this.renderer.render(e,t))})},this.toggleLabels=async function(e,t){return new Promise(n=>{n(this.setVisibility(e,t,this.scene,this.camera,this.renderer))})},this.setVisibility=function(e,t,n,i,r){this.renderer.cacheList.forEach((function(a){a.visible!=t&&a.layer===e&&(t&&a.alwaysVisible||!t)&&(a.visible=t,r.renderObject(a,n,i))}))}};var de={};de=de=class{constructor(e,t){this.id=e.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=e.buildingsLayerId,this.minAltitude=e.minAltitude||.1,this.tb=t}onAdd(e,t){this.map=e;const n=t.createShader(t.VERTEX_SHADER);t.shaderSource(n,"\n\t\t\tuniform mat4 u_matrix;\n\t\t\tuniform float u_height_factor;\n\t\t\tuniform float u_altitude;\n\t\t\tuniform float u_azimuth;\n\t\t\tattribute vec2 a_pos;\n\t\t\tattribute vec4 a_normal_ed;\n\t\t\tattribute lowp vec2 a_base;\n\t\t\tattribute lowp vec2 a_height;\n\t\t\tvoid main() {\n\t\t\t\tfloat base = max(0.0, a_base.x);\n\t\t\t\tfloat height = max(0.0, a_height.x);\n\t\t\t\tfloat t = mod(a_normal_ed.x, 2.0);\n\t\t\t\tvec4 pos = vec4(a_pos, t > 0.0 ? height : base, 1);\n\t\t\t\tfloat len = pos.z * u_height_factor / tan(u_altitude);\n\t\t\t\tpos.x += cos(u_azimuth) * len;\n\t\t\t\tpos.y += sin(u_azimuth) * len;\n\t\t\t\tpos.z = 0.0;\n\t\t\t\tgl_Position = u_matrix * pos;\n\t\t\t}\n\t\t\t"),t.compileShader(n);const i=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(i,"\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.7);\n\t\t\t}\n\t\t\t"),t.compileShader(i),this.program=t.createProgram(),t.attachShader(this.program,n),t.attachShader(this.program,i),t.linkProgram(this.program),t.validateProgram(this.program),this.uMatrix=t.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=t.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=t.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=t.getUniformLocation(this.program,"u_azimuth"),this.aPos=t.getAttribLocation(this.program,"a_pos"),this.aNormal=t.getAttribLocation(this.program,"a_normal_ed"),this.aBase=t.getAttribLocation(this.program,"a_base"),this.aHeight=t.getAttribLocation(this.program,"a_height")}render(e,t){e.useProgram(this.program);const n=this.map.style.sourceCaches.composite,i=n.getVisibleCoordinates().reverse(),r=this.map.getLayer(this.buildingsLayerId),a=this.map.painter.context,{lng:o,lat:s}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[o,s]);e.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),e.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.getExtension("EXT_blend_minmax"),e.disable(e.DEPTH_TEST);for(const c of i){const t=n.getTile(c),i=t.getBucket(r);if(!i)continue;const[o,s]=i.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;e.uniformMatrix4fv(this.uMatrix,!1,c.posMatrix),e.uniform1f(this.uHeightFactor,Math.pow(2,c.overscaledZ)/t.tileSize/8);for(const n of i.segments.get()){const t=a.currentNumAttributes||0,r=2;for(let n=r;n0&&"fill-extrusion"==n[0].layer.type&&void 0!==n[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=n[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(n[0]);else if(this.selectedFeature.id==n[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(n[0])}},this.onMouseMove=function(i){let l,u=c(i);if(this.getCanvasContainer().style.cursor="default",i.originalEvent.altKey&&this.draggedObject){if(!e.tb.enableRotatingObjects)return;t="rotate",this.getCanvasContainer().style.cursor="move",Math.min(n.x,u.x),Math.max(n.x,u.x),Math.min(n.y,u.y),Math.max(n.y,u.y);let i={x:0,y:0,z:Math.round(s[2]+~~((u.x-n.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(i),void this.draggedObject.addHelp("rot: "+i.z+"°")}if(i.originalEvent.shiftKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="translate",this.getCanvasContainer().style.cursor="move";let n=i.lngLat,o=[Number((n.lng+r).toFixed(this.tb.gridStep)),Number((n.lat+a).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(o),void this.draggedObject.addHelp("lng: "+o[0]+"°, lat: "+o[1]+"°")}if(i.originalEvent.ctrlKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="altitude",this.getCanvasContainer().style.cursor="move";let n=i.point.y*this.tb.altitudeStep,r=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-n-o).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(r),void this.draggedObject.addHelp("alt: "+r[2]+"m")}let h=[];if(e.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(i.point)),l="object"==typeof h[0]){let e=fe.prototype.findParent3DObject(h[0]);e&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&e.uuid==this.selectedObject.uuid||(this.overedObject&&this.overedObject.uuid!=e.uuid&&this.outObject(),e.over=!0,this.overedObject=e),this.repaint=!0,i.preventDefault())}else{this.overedObject&&this.outObject();let t=[];e.tb.enableSelectingFeatures&&(t=this.queryRenderedFeatures(i.point)),t.length>0&&(this.outFeature(t[0]),"fill-extrusion"==t[0].layer.type&&void 0!==t[0].id&&(this.selectedFeature&&this.selectedFeature.id==t[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=t[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=e.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(t){(t.originalEvent.shiftKey||t.originalEvent.altKey||t.originalEvent.ctrlKey)&&0===t.originalEvent.button&&this.selectedObject&&(e.tb.enableDraggingObjects||e.tb.enableRotatingObjects)&&(t.preventDefault(),e.getCanvasContainer().style.cursor="move",e.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,n=c(t),l=this.draggedObject.coordinates,s=u.degreeify(this.draggedObject.rotation),r=l[0]-t.lngLat.lng,a=l[1]-t.lngLat.lat,o=-this.draggedObject.modelHeight-t.point.y*this.tb.altitudeStep)},this.onMouseUp=function(e){this.getCanvasContainer().style.cursor="default",this.off("mouseup",this.onMouseUp),this.off("mouseout",this.onMouseUp),this.dragPan.enable(),this.draggedObject&&(this.draggedObject.dispatchEvent({type:"ObjectDragged",detail:{draggedObject:this.draggedObject,draggedAction:t}}),this.draggedObject.removeHelp(),this.draggedObject=null,t=null)},this.onMouseOut=function(e){if(this.overedFeature){let t=this.queryRenderedFeatures(e.point);t.length>0&&this.overedFeature.id!=t[0].id&&(this.getCanvasContainer().style.cursor="default",this.outFeature(t[0]))}},this.onZoom=function(e){this.tb.zoomLayers.forEach(e=>{this.tb.toggleLayer(e)}),this.tb.world.children.filter(e=>null!=e.fixedZoom).forEach(e=>{e.setObjectScale(this.transform.scale)})};let h=!1,d=!1;this.on("click",this.onClick),this.on("mousemove",this.onMouseMove),this.on("mouseout",this.onMouseOut),this.on("mousedown",this.onMouseDown),this.on("zoom",this.onZoom),document.addEventListener("keydown",function(e){17!==e.which&&91!==e.which||(h=!0),16===e.which&&(d=!0);let t=this.selectedObject;if(d&&83===e.which&&t){let e=u.toDecimal;if(t.help)t.removeHelp();else{let n=t.modelSize,i=1;"meters"!==t.userData.units&&((i=u.projectedUnitsPerMeter(t.coordinates[1]))||(i=1),i=e(i,7)),t.addHelp("size(m): "+e(n.x/i,3)+" W, "+e(n.y/i,3)+" L, "+e(n.z/i,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(e){17!=e.which&&91!=e.which||(h=!1),16===e.which&&(d=!1)}.bind(this))}))},get fov(){return this.options.fov},set fov(e){this.camera instanceof i.PerspectiveCamera&&this.options.fov!==e&&(this.map.transform.fov=e,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=e)},get orthographic(){return this.options.orthographic},set orthographic(e){const t=this.map.getCanvas().clientHeight,n=this.map.getCanvas().clientWidth;e?(this.map.transform.fov=0,this.camera=new i.OrthographicCamera(n/-2,n/2,t/2,t/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new i.PerspectiveCamera(this.map.transform.fov,n/t,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new d(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=e},sphere:function(e){return this.setDefaultView(e,this.options),E(e,this.world)},line:le,label:R,tooltip:C,tube:function(e){return this.setDefaultView(e,this.options),ue(e,this.world)},extrusion:function(e){return this.setDefaultView(e,this.options),A(e)},Object3D:function(e){return this.setDefaultView(e,this.options),T(e)},loadObj:async function(e,t){this.setDefaultView(e,this.options);let n=this.objectsCache.get(e.obj);n?n.promise.then(n=>{t(n.duplicate(e))}).catch(t=>{this.objectsCache.delete(e.obj),console.error("Could not load model file: "+e.obj)}):this.objectsCache.set(e.obj,{promise:new Promise(async(n,i)=>{Q(e,t,async e=>{e.duplicate?n(e.duplicate()):i(e)})})})},material:function(e){return g(e)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:u,SunCalc:f,Constants:r,projectToWorld:function(e){return this.utils.projectToWorld(e)},unprojectFromWorld:function(e){return this.utils.unprojectFromWorld(e)},projectedUnitsPerMeter:function(e){return this.utils.projectedUnitsPerMeter(e)},getFeatureCenter:function(e,t,n){return u.getFeatureCenter(e,t,n)},getObjectHeightOnFloor:function(e,t,n){return u.getObjectHeightOnFloor(e,t,n)},queryRenderedFeatures:function(e){let t=new i.Vector2;return t.x=e.x/this.map.transform.width*2-1,t.y=1-e.y/this.map.transform.height*2,this.raycaster.setFromCamera(t,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(e){var t;return e.object.traverseAncestors((function(e){e.parent&&"Group"==e.parent.type&&e.userData.obj&&(t=e)})),t},setLayoutProperty:function(e,t,n){this.map.setLayoutProperty(e,t,n),null==n||"visibility"!==t||this.world.children.forEach((function(t){t.layer===e&&(t.visibility=n)}))},setLayerZoomRange:function(e,t,n){this.map.getLayer(e)&&(this.map.setLayerZoomRange(e,t,n),this.zoomLayers.includes(e)||this.zoomLayers.push(e),this.toggleLayer(e))},setLayerHeigthProperty:function(e,t){let n=this.map.getLayer(e);if(n)if("fill-extrusion"==n.type){let e=this.map.getStyle().sources[n.source].data;e.features.forEach((function(e){e.properties.level=t})),this.map.getSource(n.source).setData(e)}else"custom"==n.type&&this.world.children.forEach((function(n){let i=n.userData.feature;if(i&&i.layer===e){let e=this.tb.getFeatureCenter(i,n,t);n.setCoords(e)}}))},setStyle:function(e,t){this.clear().then(()=>{this.map.setStyle(e,t)})},toggleLayer:function(e,t=!0){let n=this.map.getLayer(e);if(n){if(!t)return void this.toggle(n.id,!1);let e=this.map.getZoom();if(n.minzoom&&e=n.maxzoom)return void this.toggle(n.id,!1);this.toggle(n.id,!0)}},toggle:function(e,t){this.setLayoutProperty(e,"visibility",t?"visible":"none"),this.labelRenderer.toggleLabels(e,t)},update:function(){this.map.repaint&&(this.map.repaint=!1);var e=Date.now();this.objects.animationManager.update(e),this.updateLightHelper(),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this.labelRenderer.render(this.scene,this.camera),!1===this.options.passiveRendering&&this.map.triggerRepaint()},add:function(e,t,n){if(!this.enableTooltips&&e.tooltip&&(e.tooltip.visibility=!1),this.world.add(e),t){e.layer=t,e.source=n;let i=this.map.getLayer(t);if(i){let t=i.visibility,n=void 0===t;e.visibility=!(!n&&"visible"!==t)}}},removeByName:function(e){let t=this.world.getObjectByName(e);t&&this.remove(t)},remove:function(e){this.map.selectedObject&&e.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&e.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),e.dispose&&e.dispose(),this.world.remove(e),e=null},clear:async function(e=null,t=!1){return new Promise((n,i)=>{let r=[];this.world.children.forEach((function(e){r.push(e)}));for(let t=0;t{e.promise.then(e=>{e.dispose(),e=null})}),n("clear")})},removeLayer:function(e){this.clear(e,!0).then(()=>{this.map.removeLayer(e)})},getSunPosition:function(e,t){return f.getPosition(e,t[1],t[0])},getSunTimes:function(e,t){return f.getTimes(e,t[1],t[0],t[2]?t[2]:0)},setBuildingShadows:function(e){if(this.map.getLayer(e.buildingsLayerId)){let t=new de(e,this);this.map.addLayer(t,e.buildingsLayerId)}else console.warn("The layer '"+e.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(e=new Date,t){if(!this.lights.dirLight||!this.options.realSunlight)return void console.warn("To use setSunlight it's required to set realSunlight : true in Threebox initial options.");var n=new Date(e.getTime());if(t?t.lng&&t.lat?this.mapCenter=t:this.mapCenter={lng:t[0],lat:t[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===n.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=n,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(n,[this.mapCenter.lng,this.mapCenter.lat]);let i=this.sunPosition.altitude,a=Math.PI+this.sunPosition.azimuth,o=r.WORLD_SIZE/2,s=Math.sin(i),l=Math.cos(i),c=Math.cos(a)*l,u=Math.sin(a)*l;this.lights.dirLight.position.set(u,c,s),this.lights.dirLight.position.multiplyScalar(o),this.lights.dirLight.intensity=Math.max(s,-.15),this.lights.dirLight.updateMatrixWorld(),this.updateLightHelper(),this.map.loaded()&&this.map.setLight({anchor:"map",position:[1.5,180+180*this.sunPosition.azimuth/Math.PI,90-180*this.sunPosition.altitude/Math.PI],"position-transition":{duration:0},color:`hsl(40, ${50*Math.cos(this.sunPosition.altitude)}%, ${96*Math.sin(this.sunPosition.altitude)}%)`},{duration:0})},updateLightHelper:function(){this.lights.dirLightHelper&&(this.lights.dirLightHelper.position.setFromMatrixPosition(this.lights.dirLight.matrixWorld),this.lights.dirLightHelper.updateMatrix(),this.lights.dirLightHelper.update())},dispose:async function(){return console.log(this.memory()),new Promise(e=>{e(this.clear(null,!0).then(e=>(this.map.remove(),this.map={},this.scene.remove(this.world),this.scene.dispose(),this.world.children=[],this.world=null,this.objectsCache.clear(),this.labelRenderer.dispose(),console.log(this.memory()),this.renderer.dispose(),e)))})},defaultLights:function(){this.lights.ambientLight=new i.AmbientLight(new i.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new i.DirectionalLight(new i.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new i.DirectionalLight(new i.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(e=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new i.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),e&&(this.lights.dirLightHelper=new i.DirectionalLightHelper(this.lights.dirLight,5),this.scene.add(this.lights.dirLightHelper)),this.lights.dirLight.castShadow=!0,this.lights.dirLight.shadow.radius=2,this.lights.dirLight.shadow.mapSize.width=8192,this.lights.dirLight.shadow.mapSize.height=8192,this.lights.dirLight.shadow.camera.top=this.lights.dirLight.shadow.camera.right=1e3,this.lights.dirLight.shadow.camera.bottom=this.lights.dirLight.shadow.camera.left=-1e3,this.lights.dirLight.shadow.camera.near=1,this.lights.dirLight.shadow.camera.visible=!0,this.lights.dirLight.shadow.camera.far=4e8,this.lights.hemiLight=new i.HemisphereLight(new i.Color(16777215),new i.Color(16777215),.6),this.lights.hemiLight.color.setHSL(.661,.96,.12),this.lights.hemiLight.groundColor.setHSL(.11,.96,.14),this.lights.hemiLight.position.set(0,0,50),this.scene.add(this.lights.hemiLight),this.setSunlight()},setDefaultView:function(e,t){e.bbox=(e.bbox||null==e.bbox)&&t.enableSelectingObjects,e.tooltip=(e.tooltip||null==e.tooltip)&&t.enableTooltips,e.mapScale=this.map.transform.scale},memory:function(){return this.renderer.info.memory},programs:function(){return this.renderer.info.programs.length},version:"2.2.2"};var me={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,multiLayer:!1,orthographic:!1,fov:r.FOV_DEGREES};pe=pe=fe,window.Threebox=pe,window.THREE=i}(); \ No newline at end of file +!function(){var e,t,n=function(e){var t;return function(n){return t||e(t={exports:{},parent:n},t.exports),t.exports}}((function(e,t){(function(e,n){(function(){var i=N.nextTick,r=(Function.prototype.apply,Array.prototype.slice),a={},o=0;function s(e,t){this._id=e,this._clearFn=t}s.prototype.unref=s.prototype.ref=function(){},s.prototype.close=function(){this._clearFn.call(window,this._id)},t.setImmediate="function"==typeof e?e:function(e){var n=o++,s=!(arguments.length<2)&&r.call(arguments,1);return a[n]=!0,i((function(){a[n]&&(s?e.apply(null,s):e.call(null),t.clearImmediate(n))})),n},t.clearImmediate="function"==typeof n?n:function(e){delete a[e]}}).call(this)}).call(this,n({}).setImmediate,n({}).clearImmediate)})),i={exports:{}};e=this,t=function(e){"use strict";const t="127",n=100,i=300,r=301,a=302,o=303,s=304,l=306,c=307,u=1e3,h=1001,d=1002,p=1003,f=1004,m=1005,g=1006,v=1007,y=1008,x=1009,b=1012,w=1014,_=1015,M=1016,S=1020,T=1022,E=1023,A=1026,L=1027,R=33776,C=33777,P=33778,I=33779,D=35840,O=35841,N=35842,F=35843,B=37492,z=37496,H=2300,U=2301,k=2302,G=2400,j=2401,V=2402,W=2500,q=2501,X=3e3,Z=3001,Y=3007,J=3002,K=3004,Q=3005,$=3006,ee=35044,te=35048,ne="300 es";function ie(){}Object.assign(ie.prototype,{addEventListener:function(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)},hasEventListener:function(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)},removeEventListener:function(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}},dispatchEvent:function(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+re[e>>16&255]+re[e>>24&255]+"-"+re[255&t]+re[t>>8&255]+"-"+re[t>>16&15|64]+re[t>>24&255]+"-"+re[63&n|128]+re[n>>8&255]+"-"+re[n>>16&255]+re[n>>24&255]+re[255&i]+re[i>>8&255]+re[i>>16&255]+re[i>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:function(e,t,n){return(1-n)*e+n*t},damp:function(e,t,n,i){return oe.lerp(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(oe.euclideanModulo(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-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())},seededRandom:function(e){return void 0!==e&&(ae=e%2147483647),((ae=16807*ae%2147483647)-1)/2147483646},degToRad:function(e){return e*oe.DEG2RAD},radToDeg:function(e){return e*oe.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))},setQuaternionFromProperEuler:function(e,t,n,i,r){const a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),c=a((t+i)/2),u=o((t+i)/2),h=a((t-i)/2),d=o((t-i)/2),p=a((i-t)/2),f=o((i-t)/2);switch(r){case"XYX":e.set(s*u,l*h,l*d,s*c);break;case"YZY":e.set(l*d,s*u,l*h,s*c);break;case"ZXZ":e.set(l*h,l*d,s*u,s*c);break;case"XZX":e.set(s*u,l*f,l*p,s*c);break;case"YXY":e.set(l*p,s*u,l*f,s*c);break;case"ZYZ":e.set(l*f,l*p,s*u,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}};class se{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(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(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(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(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(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(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}se.prototype.isVector2=!0;class le{constructor(){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.")}set(e,t,n,i,r,a,o,s,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=o,c[3]=t,c[4]=r,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const 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}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[3],s=n[6],l=n[1],c=n[4],u=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],w=i[5],_=i[8];return r[0]=a*f+o*v+s*b,r[3]=a*m+o*y+s*w,r[6]=a*g+o*x+s*_,r[1]=l*f+c*v+u*b,r[4]=l*m+c*y+u*w,r[7]=l*g+c*x+u*_,r[2]=h*f+d*v+p*b,r[5]=h*m+d*y+p*w,r[8]=h*g+d*x+p*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*a*c-t*o*l-n*r*c+n*o*s+i*r*l-i*a*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=c*a-o*l,h=o*s-c*r,d=l*r-a*s,p=t*u+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(i*l-c*n)*f,e[2]=(o*n-i*a)*f,e[3]=h*f,e[4]=(c*t-i*s)*f,e[5]=(i*r-o*t)*f,e[6]=d*f,e[7]=(n*s-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,o){const s=Math.cos(r),l=Math.sin(r);return this.set(n*s,n*l,-n*(s*a+l*o)+a+e,-i*l,i*s,-i*(-l*a+s*o)+o+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,r=i[0],a=i[3],o=i[6],s=i[1],l=i[4],c=i[7];return i[0]=t*r+n*s,i[3]=t*a+n*l,i[6]=t*o+n*c,i[1]=-n*r+t*s,i[4]=-n*a+t*l,i[7]=-n*o+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}let ce;le.prototype.isMatrix3=!0;const ue={getDataURL:function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===ce&&(ce=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),ce.width=e.width,ce.height=e.height;const n=ce.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=ce}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}};let he=0;class de extends ie{constructor(e=de.DEFAULT_IMAGE,t=de.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,o=1023,s=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:he++}),this.uuid=oe.generateUUID(),this.name="",this.image=e,this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=s,this.offset=new se(0,0),this.repeat=new se(1,1),this.center=new se(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new le,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.version=0,this.onUpdate=null}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const i=this.image;if(void 0===i.uuid&&(i.uuid=oe.generateUUID()),!t&&void 0===e.images[i.uuid]){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e1)switch(this.wrapS){case u:e.x=e.x-Math.floor(e.x);break;case h:e.x=e.x<0?0:1;break;case d: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 u:e.y=e.y-Math.floor(e.y);break;case h:e.y=e.y<0?0:1;break;case d:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function pe(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?ue.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}de.DEFAULT_IMAGE=void 0,de.DEFAULT_MAPPING=i,de.prototype.isTexture=!0;class fe{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(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(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(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(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(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(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(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(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}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const 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(e){let t,n,i,r;const a=.01,o=e.elements,s=o[0],l=o[4],c=o[8],u=o[1],h=o[5],d=o[9],p=o[2],f=o[6],m=o[10];if(Math.abs(l-u)o&&e>g?eg?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,o=Math.sin(o*a)/r}const r=o*n;if(s=s*e+h*r,l=l*e+d*r,c=c*e+p*r,u=u*e+f*r,e===1-o){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){const o=n[i],s=n[i+1],l=n[i+2],c=n[i+3],u=r[a],h=r[a+1],d=r[a+2],p=r[a+3];return e[t]=o*p+c*u+s*d-l*h,e[t+1]=s*p+c*h+l*u-o*d,e[t+2]=l*p+c*d+o*h-s*u,e[t+3]=c*p-o*u-s*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,r=e._z,a=e._order,o=Math.cos,s=Math.sin,l=o(n/2),c=o(i/2),u=o(r/2),h=s(n/2),d=s(i/2),p=s(r/2);switch(a){case"XYZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"YXZ":this._x=h*c*u+l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"ZXY":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u-h*d*p;break;case"ZYX":this._x=h*c*u-l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u+h*d*p;break;case"YZX":this._x=h*c*u+l*d*p,this._y=l*d*u+h*c*p,this._z=l*c*p-h*d*u,this._w=l*c*u-h*d*p;break;case"XZY":this._x=h*c*u-l*d*p,this._y=l*d*u-h*c*p,this._z=l*c*p+h*d*u,this._w=l*c*u+h*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],o=t[5],s=t[9],l=t[2],c=t[6],u=t[10],h=n+o+u;if(h>0){const e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(c-s)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>o&&n>u){const e=2*Math.sqrt(1+n-o-u);this._w=(c-s)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(o>u){const e=2*Math.sqrt(1+o-n-u);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-o);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(oe.clamp(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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(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(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+a*o+i*l-r*s,this._y=i*c+a*s+r*o-n*l,this._z=r*c+a*l+n*s-i*o,this._w=a*c-n*o-i*s-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const s=1-o*o;if(s<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,o),u=Math.sin((1-t)*c)/l,h=Math.sin(t*c)/l;return this._w=a*u+this._w*h,this._x=n*u+this._x*h,this._y=i*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(e,t,n){this.copy(e).slerp(t,n)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}ve.prototype.isQuaternion=!0;class ye{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(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(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(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(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(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(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(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(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(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(be.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(be.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*i-o*n,c=s*n+o*t-r*i,u=s*i+r*n-a*t,h=-r*t-a*n-o*i;return this.x=l*s+h*-r+c*-o-u*-a,this.y=c*s+h*-a+u*-r-l*-o,this.z=u*s+h*-o+l*-a-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(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(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(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(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){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(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(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(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(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(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return xe.copy(this).projectOnVector(e),this.sub(xe)}reflect(e){return this.sub(xe.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(oe.clamp(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return void 0!==n&&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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}}ye.prototype.isVector3=!0;const xe=new ye,be=new ve;class we{constructor(e=new ye(1/0,1/0,1/0),t=new ye(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,l=e.length;sr&&(r=l),c>a&&(a=c),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0;for(let s=0,l=e.count;sr&&(r=l),c>a&&(a=c),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(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(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new ye),t.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(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Me),Me.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Pe),Ie.subVectors(this.max,Pe),Te.subVectors(e.a,Pe),Ee.subVectors(e.b,Pe),Ae.subVectors(e.c,Pe),Le.subVectors(Ee,Te),Re.subVectors(Ae,Ee),Ce.subVectors(Te,Ae);let t=[0,-Le.z,Le.y,0,-Re.z,Re.y,0,-Ce.z,Ce.y,Le.z,0,-Le.x,Re.z,0,-Re.x,Ce.z,0,-Ce.x,-Le.y,Le.x,0,-Re.y,Re.x,0,-Ce.y,Ce.x,0];return!!Ne(t,Te,Ee,Ae,Ie)&&!!Ne(t=[1,0,0,0,1,0,0,0,1],Te,Ee,Ae,Ie)&&(De.crossVectors(Le,Re),Ne(t=[De.x,De.y,De.z],Te,Ee,Ae,Ie))}clampPoint(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new ye),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Me.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(Me).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(_e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),_e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),_e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),_e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),_e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),_e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),_e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),_e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(_e)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}we.prototype.isBox3=!0;const _e=[new ye,new ye,new ye,new ye,new ye,new ye,new ye,new ye],Me=new ye,Se=new we,Te=new ye,Ee=new ye,Ae=new ye,Le=new ye,Re=new ye,Ce=new ye,Pe=new ye,Ie=new ye,De=new ye,Oe=new ye;function Ne(e,t,n,i,r){for(let a=0,o=e.length-3;a<=o;a+=3){Oe.fromArray(e,a);const o=r.x*Math.abs(Oe.x)+r.y*Math.abs(Oe.y)+r.z*Math.abs(Oe.z),s=t.dot(Oe),l=n.dot(Oe),c=i.dot(Oe);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>o)return!1}return!0}const Fe=new we,Be=new ye,ze=new ye,He=new ye;class Ue{constructor(e=new ye,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):Fe.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new we),this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){He.subVectors(e,this.center);const t=He.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add(He.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return ze.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Be.copy(e.center).add(ze)),this.expandByPoint(Be.copy(e.center).sub(ze)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ke=new ye,Ge=new ye,je=new ye,Ve=new ye,We=new ye,qe=new ye,Xe=new ye;class Ze{constructor(e=new ye,t=new ye(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new ye),t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ke)),this}closestPointToPoint(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new ye),t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ke.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ke.copy(this.direction).multiplyScalar(t).add(this.origin),ke.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Ge.copy(e).add(t).multiplyScalar(.5),je.copy(t).sub(e).normalize(),Ve.copy(this.origin).sub(Ge);const r=.5*e.distanceTo(t),a=-this.direction.dot(je),o=Ve.dot(this.direction),s=-Ve.dot(je),l=Ve.lengthSq(),c=Math.abs(1-a*a);let u,h,d,p;if(c>0)if(h=a*o-s,p=r*c,(u=a*s-o)>=0)if(h>=-p)if(h<=p){const e=1/c;d=(u*=e)*(u+a*(h*=e)+2*o)+h*(a*u+h+2*s)+l}else h=r,d=-(u=Math.max(0,-(a*h+o)))*u+h*(h+2*s)+l;else h=-r,d=-(u=Math.max(0,-(a*h+o)))*u+h*(h+2*s)+l;else h<=-p?d=-(u=Math.max(0,-(-a*r+o)))*u+(h=u>0?-r:Math.min(Math.max(-r,-s),r))*(h+2*s)+l:h<=p?(u=0,d=(h=Math.min(Math.max(-r,-s),r))*(h+2*s)+l):d=-(u=Math.max(0,-(a*r+o)))*u+(h=u>0?r:Math.min(Math.max(-r,-s),r))*(h+2*s)+l;else h=a>0?-r:r,d=-(u=Math.max(0,-(a*h+o)))*u+h*(h+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(je).multiplyScalar(h).add(Ge),d}intersectSphere(e,t){ke.subVectors(e.center,this.origin);const n=ke.dot(this.direction),i=ke.dot(ke)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,o,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),c>=0?(r=(e.min.y-h.y)*c,a=(e.max.y-h.y)*c):(r=(e.max.y-h.y)*c,a=(e.min.y-h.y)*c),n>a||r>i?null:((r>n||n!=n)&&(n=r),(a=0?(o=(e.min.z-h.z)*u,s=(e.max.z-h.z)*u):(o=(e.max.z-h.z)*u,s=(e.min.z-h.z)*u),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,ke)}intersectTriangle(e,t,n,i,r){We.subVectors(t,e),qe.subVectors(n,e),Xe.crossVectors(We,qe);let a,o=this.direction.dot(Xe);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ve.subVectors(this.origin,e);const s=a*this.direction.dot(qe.crossVectors(Ve,qe));if(s<0)return null;const l=a*this.direction.dot(We.cross(Ve));if(l<0)return null;if(s+l>o)return null;const c=-a*Ve.dot(Xe);return c<0?null:this.at(c/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Ye{constructor(){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.")}set(e,t,n,i,r,a,o,s,l,c,u,h,d,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Ye).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Je.setFromMatrixColumn(e,0).length(),r=1/Je.setFromMatrixColumn(e,1).length(),a=1/Je.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),l=Math.sin(i),c=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*u,i=o*c,r=o*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-o*s,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*s}else if("YXZ"===e.order){const e=s*c,n=s*u,i=l*c,r=l*u;t[0]=e+r*o,t[4]=i*o-n,t[8]=a*l,t[1]=a*u,t[5]=a*c,t[9]=-o,t[2]=n*o-i,t[6]=r+e*o,t[10]=a*s}else if("ZXY"===e.order){const e=s*c,n=s*u,i=l*c,r=l*u;t[0]=e-r*o,t[4]=-a*u,t[8]=i+n*o,t[1]=n+i*o,t[5]=a*c,t[9]=r-e*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){const e=a*c,n=a*u,i=o*c,r=o*u;t[0]=s*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=s*u,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){const e=a*s,n=a*l,i=o*s,r=o*l;t[0]=s*c,t[4]=r-e*u,t[8]=i*u+n,t[1]=u,t[5]=a*c,t[9]=-o*c,t[2]=-l*c,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=a*s,n=a*l,i=o*s,r=o*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+r,t[5]=a*c,t[9]=n*u-i,t[2]=i*u-n,t[6]=o*c,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Qe,e,$e)}lookAt(e,t,n){const i=this.elements;return nt.subVectors(e,t),0===nt.lengthSq()&&(nt.z=1),nt.normalize(),et.crossVectors(n,nt),0===et.lengthSq()&&(1===Math.abs(n.z)?nt.x+=1e-4:nt.z+=1e-4,nt.normalize(),et.crossVectors(n,nt)),et.normalize(),tt.crossVectors(nt,et),i[0]=et.x,i[4]=tt.x,i[8]=nt.x,i[1]=et.y,i[5]=tt.y,i[9]=nt.y,i[2]=et.z,i[6]=tt.z,i[10]=nt.z,this}multiply(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(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],c=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],w=i[0],_=i[4],M=i[8],S=i[12],T=i[1],E=i[5],A=i[9],L=i[13],R=i[2],C=i[6],P=i[10],I=i[14],D=i[3],O=i[7],N=i[11],F=i[15];return r[0]=a*w+o*T+s*R+l*D,r[4]=a*_+o*E+s*C+l*O,r[8]=a*M+o*A+s*P+l*N,r[12]=a*S+o*L+s*I+l*F,r[1]=c*w+u*T+h*R+d*D,r[5]=c*_+u*E+h*C+d*O,r[9]=c*M+u*A+h*P+d*N,r[13]=c*S+u*L+h*I+d*F,r[2]=p*w+f*T+m*R+g*D,r[6]=p*_+f*E+m*C+g*O,r[10]=p*M+f*A+m*P+g*N,r[14]=p*S+f*L+m*I+g*F,r[3]=v*w+y*T+x*R+b*D,r[7]=v*_+y*E+x*C+b*O,r[11]=v*M+y*A+x*P+b*N,r[15]=v*S+y*L+x*I+b*F,this}multiplyScalar(e){const 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}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],o=e[5],s=e[9],l=e[13],c=e[2],u=e[6],h=e[10],d=e[14];return e[3]*(+r*s*u-i*l*u-r*o*h+n*l*h+i*o*d-n*s*d)+e[7]*(+t*s*d-t*l*h+r*a*h-i*a*d+i*l*c-r*s*c)+e[11]*(+t*l*u-t*o*d-r*a*u+n*a*d+r*o*c-n*l*c)+e[15]*(-i*o*c-t*s*u+t*o*h+i*a*u-n*a*h+n*s*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=u*m*l-f*h*l+f*s*d-o*m*d-u*s*g+o*h*g,y=p*h*l-c*m*l-p*s*d+a*m*d+c*s*g-a*h*g,x=c*f*l-p*u*l+p*o*d-a*f*d-c*o*g+a*u*g,b=p*u*s-c*f*s-p*o*h+a*f*h+c*o*m-a*u*m,w=t*v+n*y+i*x+r*b;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/w;return e[0]=v*_,e[1]=(f*h*r-u*m*r-f*i*d+n*m*d+u*i*g-n*h*g)*_,e[2]=(o*m*r-f*s*r+f*i*l-n*m*l-o*i*g+n*s*g)*_,e[3]=(u*s*r-o*h*r-u*i*l+n*h*l+o*i*d-n*s*d)*_,e[4]=y*_,e[5]=(c*m*r-p*h*r+p*i*d-t*m*d-c*i*g+t*h*g)*_,e[6]=(p*s*r-a*m*r-p*i*l+t*m*l+a*i*g-t*s*g)*_,e[7]=(a*h*r-c*s*r+c*i*l-t*h*l-a*i*d+t*s*d)*_,e[8]=x*_,e[9]=(p*u*r-c*f*r-p*n*d+t*f*d+c*n*g-t*u*g)*_,e[10]=(a*f*r-p*o*r+p*n*l-t*f*l-a*n*g+t*o*g)*_,e[11]=(c*o*r-a*u*r-c*n*l+t*u*l+a*n*d-t*o*d)*_,e[12]=b*_,e[13]=(c*f*i-p*u*i+p*n*h-t*f*h-c*n*m+t*u*m)*_,e[14]=(p*o*i-a*f*i-p*n*s+t*f*s+a*n*m-t*o*m)*_,e[15]=(a*u*i-c*o*i+c*n*s-t*u*s-a*n*h+t*o*h)*_,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,o=e.y,s=e.z,l=r*a,c=r*o;return this.set(l*a+n,l*o-i*s,l*s+i*o,0,l*o+i*s,c*o+n,c*s-i*a,0,l*s-i*o,c*s+i*a,r*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n){return this.set(1,t,n,0,e,1,n,0,e,t,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,o=t._z,s=t._w,l=r+r,c=a+a,u=o+o,h=r*l,d=r*c,p=r*u,f=a*c,m=a*u,g=o*u,v=s*l,y=s*c,x=s*u,b=n.x,w=n.y,_=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*w,i[5]=(1-(h+g))*w,i[6]=(m+v)*w,i[7]=0,i[8]=(p+y)*_,i[9]=(m-v)*_,i[10]=(1-(h+f))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Je.set(i[0],i[1],i[2]).length();const a=Je.set(i[4],i[5],i[6]).length(),o=Je.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Ke.copy(this);const s=1/r,l=1/a,c=1/o;return Ke.elements[0]*=s,Ke.elements[1]*=s,Ke.elements[2]*=s,Ke.elements[4]*=l,Ke.elements[5]*=l,Ke.elements[6]*=l,Ke.elements[8]*=c,Ke.elements[9]*=c,Ke.elements[10]*=c,t.setFromRotationMatrix(Ke),n.x=r,n.y=a,n.z=o,this}makePerspective(e,t,n,i,r,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const o=this.elements,s=2*r/(t-e),l=2*r/(n-i),c=(t+e)/(t-e),u=(n+i)/(n-i),h=-(a+r)/(a-r),d=-2*a*r/(a-r);return o[0]=s,o[4]=0,o[8]=c,o[12]=0,o[1]=0,o[5]=l,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a){const o=this.elements,s=1/(t-e),l=1/(n-i),c=1/(a-r),u=(t+e)*s,h=(n+i)*l,d=(a+r)*c;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*l,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*c,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}Ye.prototype.isMatrix4=!0;const Je=new ye,Ke=new Ye,Qe=new ye(0,0,0),$e=new ye(1,1,1),et=new ye,tt=new ye,nt=new ye,it=new Ye,rt=new ve;class at{constructor(e=0,t=0,n=0,i=at.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._order=i||this._order,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t,n){const i=oe.clamp,r=e.elements,a=r[0],o=r[4],s=r[8],l=r[1],c=r[5],u=r[9],h=r[2],d=r[6],p=r[10];switch(t=t||this._order){case"XYZ":this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-i(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-h,a),this._z=0);break;case"ZXY":this._x=Math.asin(i(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-i(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(i(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-u,c),this._y=Math.atan2(-h,a)):(this._x=0,this._y=Math.atan2(s,p));break;case"XZY":this._z=Math.asin(-i(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!1!==n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return it.makeRotationFromQuaternion(e),this.setFromRotationMatrix(it,t,n)}setFromVector3(e,t){return this.set(e.x,e.y,e.z,t||this._order)}reorder(e){return rt.setFromEuler(this),this.setFromQuaternion(rt,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(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(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new ye(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}at.prototype.isEuler=!0,at.DefaultOrder="XYZ",at.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ot{constructor(){this.mask=1}set(e){this.mask=1<1){for(let e=0;e1){for(let e=0;e0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,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(let n=0;n1?null:t.copy(n).multiplyScalar(r).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new ye),e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||Mt.getNormalMatrix(e),i=this.coplanarPoint(wt).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}St.prototype.isPlane=!0;const Tt=new ye,Et=new ye,At=new ye,Lt=new ye,Rt=new ye,Ct=new ye,Pt=new ye,It=new ye,Dt=new ye,Ot=new ye;class Nt{constructor(e=new ye,t=new ye,n=new ye){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new ye),i.subVectors(n,t),Tt.subVectors(e,t),i.cross(Tt);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Tt.subVectors(i,t),Et.subVectors(n,t),At.subVectors(e,t);const a=Tt.dot(Tt),o=Tt.dot(Et),s=Tt.dot(At),l=Et.dot(Et),c=Et.dot(At),u=a*l-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new ye),0===u)return r.set(-2,-1,-1);const h=1/u,d=(l*s-o*c)*h,p=(a*c-o*s)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Lt),Lt.x>=0&&Lt.y>=0&&Lt.x+Lt.y<=1}static getUV(e,t,n,i,r,a,o,s){return this.getBarycoord(e,t,n,i,Lt),s.set(0,0),s.addScaledVector(r,Lt.x),s.addScaledVector(a,Lt.y),s.addScaledVector(o,Lt.z),s}static isFrontFacing(e,t,n,i){return Tt.subVectors(n,t),Et.subVectors(e,t),Tt.cross(Et).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Tt.subVectors(this.c,this.b),Et.subVectors(this.a,this.b),.5*Tt.cross(Et).length()}getMidpoint(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new ye),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Nt.getNormal(this.a,this.b,this.c,e)}getPlane(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new St),e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Nt.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return Nt.getUV(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Nt.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Nt.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new ye);const n=this.a,i=this.b,r=this.c;let a,o;Rt.subVectors(i,n),Ct.subVectors(r,n),It.subVectors(e,n);const s=Rt.dot(It),l=Ct.dot(It);if(s<=0&&l<=0)return t.copy(n);Dt.subVectors(e,i);const c=Rt.dot(Dt),u=Ct.dot(Dt);if(c>=0&&u<=c)return t.copy(i);const h=s*u-c*l;if(h<=0&&s>=0&&c<=0)return a=s/(s-c),t.copy(n).addScaledVector(Rt,a);Ot.subVectors(e,r);const d=Rt.dot(Ot),p=Ct.dot(Ot);if(p>=0&&d<=p)return t.copy(r);const f=d*l-s*p;if(f<=0&&l>=0&&p<=0)return o=l/(l-p),t.copy(n).addScaledVector(Ct,o);const m=c*p-d*u;if(m<=0&&u-c>=0&&d-p>=0)return Pt.subVectors(r,i),o=(u-c)/(u-c+(d-p)),t.copy(i).addScaledVector(Pt,o);const g=1/(m+f+h);return a=f*g,o=h*g,t.copy(n).addScaledVector(Rt,a).addScaledVector(Ct,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Ft=0;function Bt(){Object.defineProperty(this,"id",{value:Ft++}),this.uuid=oe.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=n,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=7680,this.stencilZFail=7680,this.stencilZPass=7680,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}Bt.prototype=Object.assign(Object.create(ie.prototype),{constructor:Bt,isMaterial:!0,onBeforeCompile:function(){},customProgramCacheKey:function(){return this.onBeforeCompile.toString()},setValues:function(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}},toJSON:function(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,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.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,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.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Bt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}});const zt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ht={h:0,s:0,l:0},Ut={h:0,s:0,l:0};function kt(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function Gt(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function jt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class Vt{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=oe.euclideanModulo(e,1),t=oe.clamp(t,0,1),n=oe.clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=kt(r,i,e+1/3),this.g=kt(r,i,e),this.b=kt(r,i,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=n[1],r=n[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const n=parseFloat(e[1])/360,i=parseInt(e[2],10)/100,r=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,i,r)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=zt[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyGammaToLinear(e,t=2){return this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this}copyLinearToGamma(e,t=2){const n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this}convertGammaToLinear(e){return this.copyGammaToLinear(this,e),this}convertLinearToGamma(e){return this.copyLinearToGamma(this,e),this}copySRGBToLinear(e){return this.r=Gt(e.r),this.g=Gt(e.g),this.b=Gt(e.b),this}copyLinearToSRGB(e){return this.r=jt(e.r),this.g=jt(e.g),this.b=jt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});const t=this.r,n=this.g,i=this.b,r=Math.max(t,n,i),a=Math.min(t,n,i);let o,s;const l=(a+r)/2;if(a===r)o=0,s=0;else{const e=r-a;switch(s=l<=.5?e/(r+a):e/(2-r-a),r){case t:o=(n-i)/e+(nt&&(t=e[n]);return t}Object.defineProperty(Zt.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Zt.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i65535?tn:$t)(e,1):this.index=e,this},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},hasAttribute:function(e){return void 0!==this.attributes[e]},addGroup:function(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix4:function(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new le).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return un.makeRotationX(e),this.applyMatrix4(un),this},rotateY:function(e){return un.makeRotationY(e),this.applyMatrix4(un),this},rotateZ:function(e){return un.makeRotationZ(e),this.applyMatrix4(un),this},translate:function(e,t,n){return un.makeTranslation(e,t,n),this.applyMatrix4(un),this},scale:function(e,t,n){return un.makeScale(e,t,n),this.applyMatrix4(un),this},lookAt:function(e){return hn.lookAt(e),hn.updateMatrix(),this.applyMatrix4(hn.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(dn).negate(),this.translate(dn.x,dn.y,dn.z),this},setFromPoints:function(e){const t=[];for(let n=0,i=e.length;n0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const s in n){const t=n[s];e.data.attributes[s]=t.toJSON(e.data)}const i={};let r=!1;for(const s in this.morphAttributes){const t=this.morphAttributes[s],n=[];for(let i=0,r=t.length;i0&&(i[s]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e},clone:function(){return(new gn).copy(this)},copy:function(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const l in i){const e=i[l];this.setAttribute(l,e.clone(t))}const r=e.morphAttributes;for(const l in r){const e=[],n=r[l];for(let i=0,r=n.length;in.far?null:{distance:c,point:Dn.clone(),object:e}}(e,t,n,i,bn,wn,_n,In);if(p){s&&(Rn.fromBufferAttribute(s,c),Cn.fromBufferAttribute(s,u),Pn.fromBufferAttribute(s,h),p.uv=Nt.getUV(In,bn,wn,_n,Rn,Cn,Pn,new se)),l&&(Rn.fromBufferAttribute(l,c),Cn.fromBufferAttribute(l,u),Pn.fromBufferAttribute(l,h),p.uv2=Nt.getUV(In,bn,wn,_n,Rn,Cn,Pn,new se));const e={a:c,b:u,c:h,normal:new ye,materialIndex:0};Nt.getNormal(bn,wn,_n,e.normal),p.face=e}return p}On.prototype=Object.assign(Object.create(bt.prototype),{constructor:On,isMesh:!0,copy:function(e){return bt.prototype.copy.call(this,e),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),xn.copy(n.boundingSphere),xn.applyMatrix4(r),!1===e.ray.intersectsSphere(xn))return;if(vn.copy(r).invert(),yn.copy(e.ray).applyMatrix4(vn),null!==n.boundingBox&&!1===yn.intersectsBox(n.boundingBox))return;let a;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,u=n.attributes.uv2,h=n.groups,d=n.drawRange;if(null!==r)if(Array.isArray(i))for(let n=0,p=h.length;n0?1:-1,c.push(A.x,A.y,A.z),u.push(s/m),u.push(1-o/g),T+=1}}for(let o=0;o0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const i in this.extensions)!0===this.extensions[i]&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t},kn.prototype=Object.assign(Object.create(bt.prototype),{constructor:kn,isCamera:!0,copy:function(e,t){return bt.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new ye),this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){bt.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()},updateWorldMatrix:function(e,t){bt.prototype.updateWorldMatrix.call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()},clone:function(){return(new this.constructor).copy(this)}}),Gn.prototype=Object.assign(Object.create(kn.prototype),{constructor:Gn,isPerspectiveCamera:!0,copy:function(e,t){return kn.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){const t=.5*this.getFilmHeight()/e;this.fov=2*oe.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){const e=Math.tan(.5*oe.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*oe.RAD2DEG*Math.atan(Math.tan(.5*oe.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){const e=this.near;let t=e*Math.tan(.5*oe.DEG2RAD*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/o,i*=a.width/e,n*=a.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()},toJSON:function(e){const t=bt.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});class jn extends bt{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new Gn(90,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new ye(1,0,0)),this.add(i);const r=new Gn(90,1,e,t);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new ye(-1,0,0)),this.add(r);const a=new Gn(90,1,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new ye(0,1,0)),this.add(a);const o=new Gn(90,1,e,t);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new ye(0,-1,0)),this.add(o);const s=new Gn(90,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new ye(0,0,1)),this.add(s);const l=new Gn(90,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new ye(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,r,a,o,s,l]=this.children,c=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=h,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=c}}class Vn extends de{constructor(e,t,n,i,a,o,s,l,c,u){super(e=void 0!==e?e:[],t=void 0!==t?t:r,n,i,a,o,s=void 0!==s?s:T,l,c,u),this._needsFlipEnvMap=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}Vn.prototype.isCubeTexture=!0;class Wn extends me{constructor(e,t,n){Number.isInteger(t)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),t=n),super(e,e,t),t=t||{},this.texture=new Vn(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:g,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=E,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n=new Fn(5,5,5),i=new Un({name:"CubemapFromEquirect",uniforms:Bn({tEquirect:{value:null}}),vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",side:1,blending:0});i.uniforms.tEquirect.value=t;const r=new On(n,i),a=t.minFilter;return t.minFilter===y&&(t.minFilter=g),new jn(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}}Wn.prototype.isWebGLCubeRenderTarget=!0;class qn extends de{constructor(e,t,n,i,r,a,o,s,l,c,u,h){super(null,a,o,s,l,c,i,r,u,h),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=void 0!==l?l:p,this.minFilter=void 0!==c?c:p,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}}qn.prototype.isDataTexture=!0;const Xn=new Ue,Zn=new ye;class Yn{constructor(e=new St,t=new St,n=new St,i=new St,r=new St,a=new St){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],l=n[5],c=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return t[0].setComponents(o-i,u-s,f-h,y-m).normalize(),t[1].setComponents(o+i,u+s,f+h,y+m).normalize(),t[2].setComponents(o+r,u+l,f+d,y+g).normalize(),t[3].setComponents(o-r,u-l,f-d,y-g).normalize(),t[4].setComponents(o-a,u-c,f-p,y-v).normalize(),t[5].setComponents(o+a,u+c,f+p,y+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Xn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Xn)}intersectsSprite(e){return Xn.center.set(0,0,0),Xn.radius=.7071067811865476,Xn.applyMatrix4(e.matrixWorld),this.intersectsSphere(Xn)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,Zn.y=i.normal.y>0?e.max.y:e.min.y,Zn.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Zn)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Jn(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Kn(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",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, float faceDirection ) {\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 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\n\t\tvec2 f = fract( uv );\n\t\tuv += 0.5 - f;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x += texelSize;\n\t\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.y += texelSize;\n\t\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tuv.x -= texelSize;\n\t\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\n\t\tvec3 tm = mix( tl, tr, f.x );\n\t\tvec3 bm = mix( bl, br, f.x );\n\t\treturn mix( tm, bm, f.y );\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, 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_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#endif\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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\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\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 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 roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\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};\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};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial 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\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat specularRoughness;\n\tvec3 specularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(\t\t0, 1,\t\t0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\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\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifndef USE_MORPHNORMALS\n\t\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\t\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#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 * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\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 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t\tf.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\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 ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\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}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(\t1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,\t1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,\t1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmissionmap_fragment:"#ifdef USE_TRANSMISSIONMAP\n\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\n#endif",transmissionmap_pars_fragment:"#ifdef USE_TRANSMISSIONMAP\n\tuniform sampler2D transmissionMap;\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\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\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\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\tvHighPrecisionZW = gl_Position.zw;\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}",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}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \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}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \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\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * 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\t#include \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}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\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 \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#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\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}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\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}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\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 \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\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}",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 \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSMISSION\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSMISSION\n\tuniform float transmission;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \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#ifdef TRANSMISSION\n\t\tfloat totalTransmission = transmission;\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\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#ifdef TRANSMISSION\n\t\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\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}",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#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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\t#include \n\t#include \n}",shadow_vert:"#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}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\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}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},ei={common:{diffuse:{value:new Vt(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new le},uv2Transform:{value:new le},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new se(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Vt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Vt(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new le}},sprite:{diffuse:{value:new Vt(15658734)},opacity:{value:1},center:{value:new se(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new le}}},ti={basic:{uniforms:zn([ei.common,ei.specularmap,ei.envmap,ei.aomap,ei.lightmap,ei.fog]),vertexShader:$n.meshbasic_vert,fragmentShader:$n.meshbasic_frag},lambert:{uniforms:zn([ei.common,ei.specularmap,ei.envmap,ei.aomap,ei.lightmap,ei.emissivemap,ei.fog,ei.lights,{emissive:{value:new Vt(0)}}]),vertexShader:$n.meshlambert_vert,fragmentShader:$n.meshlambert_frag},phong:{uniforms:zn([ei.common,ei.specularmap,ei.envmap,ei.aomap,ei.lightmap,ei.emissivemap,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.fog,ei.lights,{emissive:{value:new Vt(0)},specular:{value:new Vt(1118481)},shininess:{value:30}}]),vertexShader:$n.meshphong_vert,fragmentShader:$n.meshphong_frag},standard:{uniforms:zn([ei.common,ei.envmap,ei.aomap,ei.lightmap,ei.emissivemap,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.roughnessmap,ei.metalnessmap,ei.fog,ei.lights,{emissive:{value:new Vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag},toon:{uniforms:zn([ei.common,ei.aomap,ei.lightmap,ei.emissivemap,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.gradientmap,ei.fog,ei.lights,{emissive:{value:new Vt(0)}}]),vertexShader:$n.meshtoon_vert,fragmentShader:$n.meshtoon_frag},matcap:{uniforms:zn([ei.common,ei.bumpmap,ei.normalmap,ei.displacementmap,ei.fog,{matcap:{value:null}}]),vertexShader:$n.meshmatcap_vert,fragmentShader:$n.meshmatcap_frag},points:{uniforms:zn([ei.points,ei.fog]),vertexShader:$n.points_vert,fragmentShader:$n.points_frag},dashed:{uniforms:zn([ei.common,ei.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$n.linedashed_vert,fragmentShader:$n.linedashed_frag},depth:{uniforms:zn([ei.common,ei.displacementmap]),vertexShader:$n.depth_vert,fragmentShader:$n.depth_frag},normal:{uniforms:zn([ei.common,ei.bumpmap,ei.normalmap,ei.displacementmap,{opacity:{value:1}}]),vertexShader:$n.normal_vert,fragmentShader:$n.normal_frag},sprite:{uniforms:zn([ei.sprite,ei.fog]),vertexShader:$n.sprite_vert,fragmentShader:$n.sprite_frag},background:{uniforms:{uvTransform:{value:new le},t2D:{value:null}},vertexShader:$n.background_vert,fragmentShader:$n.background_frag},cube:{uniforms:zn([ei.envmap,{opacity:{value:1}}]),vertexShader:$n.cube_vert,fragmentShader:$n.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$n.equirect_vert,fragmentShader:$n.equirect_frag},distanceRGBA:{uniforms:zn([ei.common,ei.displacementmap,{referencePosition:{value:new ye},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$n.distanceRGBA_vert,fragmentShader:$n.distanceRGBA_frag},shadow:{uniforms:zn([ei.lights,ei.fog,{color:{value:new Vt(0)},opacity:{value:1}}]),vertexShader:$n.shadow_vert,fragmentShader:$n.shadow_frag}};function ni(e,t,n,i,r){const a=new Vt(0);let o,s,c=0,u=null,h=0,d=null;function p(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),p(a,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){p(a,c=e)},render:function(n,r,f,m){let g=!0===r.isScene?r.background:null;g&&g.isTexture&&(g=t.get(g));const v=e.xr,y=v.getSession&&v.getSession();y&&"additive"===y.environmentBlendMode&&(g=null),null===g?p(a,c):g&&g.isColor&&(p(g,1),m=!0),(e.autoClear||m)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),g&&(g.isCubeTexture||g.mapping===l)?(void 0===s&&((s=new On(new Fn(1,1,1),new Un({name:"BackgroundCubeMaterial",uniforms:Bn(ti.cube.uniforms),vertexShader:ti.cube.vertexShader,fragmentShader:ti.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(s)),s.material.uniforms.envMap.value=g,s.material.uniforms.flipEnvMap.value=g.isCubeTexture&&g._needsFlipEnvMap?-1:1,u===g&&h===g.version&&d===e.toneMapping||(s.material.needsUpdate=!0,u=g,h=g.version,d=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null)):g&&g.isTexture&&(void 0===o&&((o=new On(new Qn(2,2),new Un({name:"BackgroundMaterial",uniforms:Bn(ti.background.uniforms),vertexShader:ti.background.vertexShader,fragmentShader:ti.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(o)),o.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),o.material.uniforms.uvTransform.value.copy(g.matrix),u===g&&h===g.version&&d===e.toneMapping||(o.material.needsUpdate=!0,u=g,h=g.version,d=e.toneMapping),n.unshift(o,o.geometry,o.material,0,0,null))}}}function ii(e,t,n,i){const r=e.getParameter(34921),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),o=i.isWebGL2||null!==a,s={},l=d(null);let c=l;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function h(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function d(e){const t=[],n=[],i=[];for(let a=0;a=0){const a=l[t];if(void 0!==a){const t=a.normalized,r=a.itemSize,o=n.get(a);if(void 0===o)continue;const l=o.buffer,c=o.type,u=o.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,o=n.stride,h=a.offset;n&&n.isInstancedInterleavedBuffer?(m(i,n.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)):f(i),e.bindBuffer(34962,l),v(i,r,c,t,o*u,h*u)}else a.isInstancedBufferAttribute?(m(i,a.meshPerAttribute),void 0===s._maxInstanceCount&&(s._maxInstanceCount=a.meshPerAttribute*a.count)):f(i),e.bindBuffer(34962,l),v(i,r,c,t,0,0)}else if("instanceMatrix"===t){const t=n.get(r.instanceMatrix);if(void 0===t)continue;const a=t.buffer,o=t.type;m(i+0,1),m(i+1,1),m(i+2,1),m(i+3,1),e.bindBuffer(34962,a),e.vertexAttribPointer(i+0,4,o,!1,64,0),e.vertexAttribPointer(i+1,4,o,!1,64,16),e.vertexAttribPointer(i+2,4,o,!1,64,32),e.vertexAttribPointer(i+3,4,o,!1,64,48)}else if("instanceColor"===t){const t=n.get(r.instanceColor);if(void 0===t)continue;const a=t.buffer,o=t.type;m(i,1),e.bindBuffer(34962,a),e.vertexAttribPointer(i,3,o,!1,12,0)}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(i,n);break;case 3:e.vertexAttrib3fv(i,n);break;case 4:e.vertexAttrib4fv(i,n);break;default:e.vertexAttrib1fv(i,n)}}}}g()}(r,l,h,y),null!==x&&e.bindBuffer(34963,n.get(x).buffer))},reset:y,resetDefaultState:x,dispose:function(){y();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const n in t){const e=t[n];for(const t in e)h(e[t].object),delete e[t];delete t[n]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)h(i[e].object),delete i[e];delete n[e.id]}},initAttributes:p,enableAttribute:f,disableUnusedAttributes:g}}function ri(e,t,n,i){const r=i.isWebGL2;let a;this.setMode=function(e){a=e},this.render=function(t,i){e.drawArrays(a,t,i),n.update(i,a,1)},this.renderInstances=function(i,o,s){if(0===s)return;let l,c;if(r)l=e,c="drawArraysInstanced";else if(c="drawArraysInstancedANGLE",null===(l=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](a,i,o,s),n.update(o,a,s)}}function ai(e,t,n){let i;function r(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let o=void 0!==n.precision?n.precision:"highp";const s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const l=!0===n.logarithmicDepthBuffer,c=e.getParameter(34930),u=e.getParameter(35660),h=e.getParameter(3379),d=e.getParameter(34076),p=e.getParameter(34921),f=e.getParameter(36347),m=e.getParameter(36348),g=e.getParameter(36349),v=u>0,y=a||t.has("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:a?e.getParameter(36183):0}}function oi(e){const t=this;let n=null,i=0,r=!1,a=!1;const o=new St,s=new le,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;s.getNormalMatrix(r),(null===c||c.length0){const o=e.getRenderTarget(),s=new Wn(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),e.setRenderTarget(o),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}function li(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function ci(e,t,n,i){const r={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const n in s.attributes)t.remove(s.attributes[n]);s.removeEventListener("dispose",o),delete r[s.id];const l=a.get(s);l&&(t.remove(l),a.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,r=e.attributes.position;let o=0;if(null!==i){const e=i.array;o=i.version;for(let t=0,i=e.length;t65535?tn:$t)(n,1);s.version=o;const l=a.get(e);l&&t.remove(l),a.set(e,s)}return{get:function(e,t){return!0===r[t.id]||(t.addEventListener("dispose",o),r[t.id]=!0,n.memory.geometries++),t},update:function(e){const n=e.attributes;for(const r in n)t.update(n[r],34962);const i=e.morphAttributes;for(const r in i){const e=i[r];for(let n=0,i=e.length;n0)return e;const r=t*n;let a=_i[r];if(void 0===a&&(a=new Float32Array(r),_i[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Li(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n/gm;function Pr(e){return e.replace(Cr,Ir)}function Ir(e,t){const n=$n[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Pr(n)}const Dr=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,Or=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Nr(e){return e.replace(Or,Br).replace(Dr,Fr)}function Fr(e,t,n,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Br(e,t,n,i)}function Br(e,t,n,i){let r="";for(let a=parseInt(t);a0?e.gammaFactor:1,v=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ar).join("\n")}(n),y=function(e){const t=[];for(const n in e){const i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}(s),x=o.createProgram();let b,w,_=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?((b=[y].filter(Ar).join("\n")).length>0&&(b+="\n"),(w=[v,y].filter(Ar).join("\n")).length>0&&(w+="\n")):(b=[zr(n),"#define SHADER_NAME "+n.shaderName,y,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+f:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( 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(Ar).join("\n"),w=[v,zr(n),"#define SHADER_NAME "+n.shaderName,y,n.alphaTest?"#define ALPHATEST "+n.alphaTest+(n.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+p:"",n.envMap?"#define "+f:"",n.envMap?"#define "+m:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.sheen?"#define USE_SHEEN":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+d:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?$n.tonemapping_pars_fragment:"",0!==n.toneMapping?Er("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",$n.encodings_pars_fragment,n.map?Sr("mapTexelToLinear",n.mapEncoding):"",n.matcap?Sr("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Sr("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Sr("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.lightMap?Sr("lightMapTexelToLinear",n.lightMapEncoding):"",Tr("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Ar).join("\n")),u=Rr(u=Lr(u=Pr(u),n),n),h=Rr(h=Lr(h=Pr(h),n),n),u=Nr(u),h=Nr(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",b=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+b,w=["#define varying in",n.glslVersion===ne?"":"out highp vec4 pc_fragColor;",n.glslVersion===ne?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+w);const M=_+w+h,S=br(o,35633,_+b+u),T=br(o,35632,M);if(o.attachShader(x,S),o.attachShader(x,T),void 0!==n.index0AttributeName?o.bindAttribLocation(x,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(x,0,"position"),o.linkProgram(x),e.debug.checkShaderErrors){const e=o.getProgramInfoLog(x).trim(),t=o.getShaderInfoLog(S).trim(),n=o.getShaderInfoLog(T).trim();let i=!0,r=!0;if(!1===o.getProgramParameter(x,35714)){i=!1;const t=Mr(o,S,"vertex"),n=Mr(o,T,"fragment");console.error("THREE.WebGLProgram: shader error: ",o.getError(),"35715",o.getProgramParameter(x,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(r=!1);r&&(this.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:b},fragmentShader:{log:n,prefix:w}})}let E,A;return o.deleteShader(S),o.deleteShader(T),this.getUniforms=function(){return void 0===E&&(E=new xr(o,x)),E},this.getAttributes=function(){return void 0===A&&(A=function(e,t){const n={},i=e.getProgramParameter(t,35721);for(let r=0;r0,maxBones:S,useVertexTexture:h,morphTargets:r.morphTargets,morphNormals:r.morphNormals,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&g.length>0,shadowMapType:e.shadowMap.type,toneMapping:r.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,alphaTest:r.alphaTest,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:s||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:s||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:s||n.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.fragmentShader),n.push(t.vertexShader)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);if(!1===t.isRawShaderMaterial){for(let e=0;e1&&i.sort(e||Gr),r.length>1&&r.sort(t||jr)}}}function Wr(e){let t=new WeakMap;return{get:function(n,i){let r;return!1===t.has(n)?(r=new Vr(e),t.set(n,[r])):i>=t.get(n).length?(r=new Vr(e),t.get(n).push(r)):r=t.get(n)[i],r},dispose:function(){t=new WeakMap}}}function qr(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new ye,color:new Vt};break;case"SpotLight":n={position:new ye,direction:new ye,color:new Vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ye,color:new Vt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ye,skyColor:new Vt,groundColor:new Vt};break;case"RectAreaLight":n={color:new Vt,position:new ye,halfWidth:new ye,halfHeight:new ye}}return e[t.id]=n,n}}}let Xr=0;function Zr(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Yr(e,t){const n=new qr,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new se,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let l=0;l<9;l++)r.probe.push(new ye);const a=new ye,o=new Ye,s=new Ye;return{setup:function(a){let o=0,s=0,l=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,h=0,d=0,p=0,f=0,m=0,g=0;a.sort(Zr);for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ei.LTC_FLOAT_1,r.rectAreaLTC2=ei.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=ei.LTC_HALF_1,r.rectAreaLTC2=ei.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=s,r.ambient[2]=l;const v=r.hash;v.directionalLength===c&&v.pointLength===u&&v.spotLength===h&&v.rectAreaLength===d&&v.hemiLength===p&&v.numDirectionalShadows===f&&v.numPointShadows===m&&v.numSpotShadows===g||(r.directional.length=c,r.spot.length=h,r.rectArea.length=d,r.point.length=u,r.hemi.length=p,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=g,r.spotShadowMap.length=g,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=m,r.spotShadowMatrix.length=g,v.directionalLength=c,v.pointLength=u,v.spotLength=h,v.rectAreaLength=d,v.hemiLength=p,v.numDirectionalShadows=f,v.numPointShadows=m,v.numSpotShadows=g,r.version=Xr++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,u=0;const h=t.matrixWorldInverse;for(let d=0,p=e.length;d=n.get(i).length?(a=new Jr(e,t),n.get(i).push(a)):a=n.get(i)[r],a},dispose:function(){n=new WeakMap}}}class Qr extends Bt{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,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.setValues(e)}copy(e){return super.copy(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}}Qr.prototype.isMeshDepthMaterial=!0;class $r extends Bt{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new ye,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.setValues(e)}copy(e){return super.copy(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}}function ea(e,t,n){let i=new Yn;const r=new se,a=new se,o=new fe,s=[],l=[],c={},u=n.maxTextureSize,h={0:1,1:0,2:2},d=new Un({defines:{SAMPLE_RATE:.25,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new se},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean * HALF_SAMPLE_RATE;\n\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new gn;m.setAttribute("position",new Zt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new On(m,d),y=this;function x(n,i){const r=t.update(v);d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,d,v,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,f,v,null)}function b(e,t,n){const i=e<<0|t<<1|n<<2;let r=s[i];return void 0===r&&(r=new Qr({depthPacking:3201,morphTargets:e,skinning:t}),s[i]=r),r}function w(e,t,n){const i=e<<0|t<<1|n<<2;let r=l[i];return void 0===r&&(r=new $r({morphTargets:e,skinning:t}),l[i]=r),r}function _(t,n,i,r,a,o,s){let l=null,u=b,d=t.customDepthMaterial;if(!0===r.isPointLight&&(u=w,d=t.customDistanceMaterial),void 0===d){let e=!1;!0===i.morphTargets&&(e=n.morphAttributes&&n.morphAttributes.position&&n.morphAttributes.position.length>0);let r=!1;!0===t.isSkinnedMesh&&(!0===i.skinning?r=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t)),l=u(e,r,!0===t.isInstancedMesh)}else l=d;if(e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length){const e=l.uuid,t=i.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let r=n[t];void 0===r&&(r=l.clone(),n[t]=r),l=r}return l.visible=i.visible,l.wireframe=i.wireframe,l.side=3===s?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:h[i.side],l.clipShadows=i.clipShadows,l.clippingPlanes=i.clippingPlanes,l.clipIntersection=i.clipIntersection,l.wireframeLinewidth=i.wireframeLinewidth,l.linewidth=i.linewidth,!0===r.isPointLight&&!0===l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(r.matrixWorld),l.nearDistance=a,l.farDistance=o),l}function M(n,r,a,o,s){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;lu||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/h.x),r.x=a.x*h.x,c.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/h.y),r.y=a.y*h.y,c.mapSize.y=a.y)),null===c.map&&!c.isPointLightShadow&&3===this.type){const e={minFilter:g,magFilter:g,format:E};c.map=new me(r.x,r.y,e),c.map.texture.name=l.name+".shadowMap",c.mapPass=new me(r.x,r.y,e),c.camera.updateProjectionMatrix()}if(null===c.map){const e={minFilter:p,magFilter:p,format:E};c.map=new me(r.x,r.y,e),c.map.texture.name=l.name+".shadowMap",c.camera.updateProjectionMatrix()}e.setRenderTarget(c.map),e.clear();const m=c.getViewportCount();for(let e=0;e=1):-1!==R.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(R)[1]),A=L>=2);let C=null,P={};const I=new fe(0,0,e.canvas.width,e.canvas.height),D=new fe(0,0,e.canvas.width,e.canvas.height);function O(t,n,i){const r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?oe.floorPowerOfTwo:Math.floor,a=i(r*e.width),o=i(r*e.height);void 0===P&&(P=D(a,o));const s=n?D(a,o):P;return s.width=a,s.height=o,s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function N(e){return oe.isPowerOfTwo(e.width)&&oe.isPowerOfTwo(e.height)}function F(e,t){return e.generateMipmaps&&t&&e.minFilter!==p&&e.minFilter!==g}function B(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log2(Math.max(r,a))}function z(n,i,r){if(!1===s)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let a=i;return 6403===i&&(5126===r&&(a=33326),5131===r&&(a=33325),5121===r&&(a=33321)),6407===i&&(5126===r&&(a=34837),5131===r&&(a=34843),5121===r&&(a=32849)),6408===i&&(5126===r&&(a=34836),5131===r&&(a=34842),5121===r&&(a=32856)),33325!==a&&33326!==a&&34842!==a&&34836!==a||t.get("EXT_color_buffer_float"),a}function H(e){return e===p||e===f||e===m?9728:9729}function U(t){const n=t.target;n.removeEventListener("dispose",U),function(t){const n=i.get(t);void 0!==n.__webglInit&&(e.deleteTexture(n.__webglTexture),i.remove(t))}(n),n.isVideoTexture&&C.delete(n),o.memory.textures--}function k(t){const n=t.target;n.removeEventListener("dispose",k),function(t){const n=t.texture,r=i.get(t),a=i.get(n);if(t){if(void 0!==a.__webglTexture&&e.deleteTexture(a.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&e.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&e.deleteRenderbuffer(r.__webglDepthRenderbuffer);i.remove(n),i.remove(t)}}(n),o.memory.textures--}let G=0;function j(e,t){const r=i.get(e);if(e.isVideoTexture&&function(e){const t=o.render.frame;C.get(e)!==t&&(C.set(e,t),e.update())}(e),e.version>0&&r.__version!==e.version){const n=e.image;if(void 0===n)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void Y(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,r.__webglTexture)}function V(t,r){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,i,r){if(6!==i.image.length)return;Z(t,i),n.activeTexture(33984+r),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const o=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),l=i.image[0]&&i.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=o||l?l?i.image[e].image:i.image[e]:O(i.image[e],!1,!0,c);const h=u[0],d=N(h)||s,p=a.convert(i.format),f=a.convert(i.type),m=z(i.internalFormat,p,f);let g;if(X(34067,i,d),o){for(let e=0;e<6;e++){g=u[e].mipmaps;for(let t=0;t1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function Z(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",U),t.__webglTexture=e.createTexture(),o.memory.textures++)}function Y(t,i,r){let o=3553;i.isDataTexture2DArray&&(o=35866),i.isDataTexture3D&&(o=32879),Z(t,i),n.activeTexture(33984+r),n.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const l=function(e){return!s&&(e.wrapS!==h||e.wrapT!==h||e.minFilter!==p&&e.minFilter!==g)}(i)&&!1===N(i.image),c=O(i.image,l,!1,x),u=N(c)||s,d=a.convert(i.format);let f,m=a.convert(i.type),v=z(i.internalFormat,d,m);X(o,i,u);const y=i.mipmaps;if(i.isDepthTexture)v=6402,s?v=i.type===_?36012:i.type===w?33190:i.type===S?35056:33189:i.type===_&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===A&&6402===v&&i.type!==b&&i.type!==w&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=b,m=a.convert(i.type)),i.format===L&&6402===v&&(v=34041,i.type!==S&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=S,m=a.convert(i.type))),n.texImage2D(3553,0,v,c.width,c.height,0,d,m,null);else if(i.isDataTexture)if(y.length>0&&u){for(let e=0,t=y.length;e0&&u){for(let e=0,t=y.length;e=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),G+=1,e},this.resetTextureUnits=function(){G=0},this.setTexture2D=j,this.setTexture2DArray=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?Y(r,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(e,t){const r=i.get(e);e.version>0&&r.__version!==e.version?Y(r,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,r.__webglTexture))},this.setTextureCube=V,this.setupRenderTarget=function(t){const r=t.texture,l=i.get(t),c=i.get(r);t.addEventListener("dispose",k),c.__webglTexture=e.createTexture(),c.__version=r.version,o.memory.textures++;const u=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultisampleRenderTarget,d=r.isDataTexture3D||r.isDataTexture2DArray,p=N(t)||s;if(!s||r.format!==T||r.type!==_&&r.type!==M||(r.format=E,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),u){l.__webglFramebuffer=[];for(let t=0;t<6;t++)l.__webglFramebuffer[t]=e.createFramebuffer()}else if(l.__webglFramebuffer=e.createFramebuffer(),h)if(s){l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,l.__webglColorRenderbuffer);const i=a.convert(r.format),o=a.convert(r.type),s=z(r.internalFormat,i,o),c=Q(t);e.renderbufferStorageMultisample(36161,c,s,t.width,t.height),n.bindFramebuffer(36160,l.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,l.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),t.depthBuffer&&(l.__webglDepthRenderbuffer=e.createRenderbuffer(),K(l.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(u){n.bindTexture(34067,c.__webglTexture),X(34067,r,p);for(let e=0;e<6;e++)J(l.__webglFramebuffer[e],t,36064,34069+e);F(r,p)&&B(34067,r,t.width,t.height),n.bindTexture(34067,null)}else{let e=3553;d&&(s?e=r.isDataTexture3D?32879:35866:console.warn("THREE.DataTexture3D and THREE.DataTexture2DArray only supported with WebGL2.")),n.bindTexture(e,c.__webglTexture),X(e,r,p),J(l.__webglFramebuffer,t,36064,e),F(r,p)&&B(3553,r,t.width,t.height),n.bindTexture(3553,null)}t.depthBuffer&&function(t){const r=i.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");i.get(r.depthTexture).__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),j(r.depthTexture,0);const a=i.get(r.depthTexture).__webglTexture;if(r.depthTexture.format===A)e.framebufferTexture2D(36160,36096,3553,a,0);else{if(r.depthTexture.format!==L)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,a,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(36160,r.__webglFramebuffer[i]),r.__webglDepthbuffer[i]=e.createRenderbuffer(),K(r.__webglDepthbuffer[i],t,!1)}else n.bindFramebuffer(36160,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),K(r.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}(t)},this.updateRenderTargetMipmap=function(e){const t=e.texture;if(F(t,N(e)||s)){const r=e.isWebGLCubeRenderTarget?34067:3553,a=i.get(t).__webglTexture;n.bindTexture(r,a),B(r,t,e.width,e.height),n.bindTexture(r,null)}},this.updateMultisampleRenderTarget=function(t){if(t.isWebGLMultisampleRenderTarget)if(s){const r=i.get(t);n.bindFramebuffer(36008,r.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,r.__webglFramebuffer);const a=t.width,o=t.height;let s=16384;t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024),e.blitFramebuffer(0,0,a,o,0,0,a,o,s,9728),n.bindFramebuffer(36160,r.__webglMultisampledFramebuffer)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")},this.safeSetTexture2D=function(e,t){e&&e.isWebGLRenderTarget&&(!1===$&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),$=!0),e=e.texture),j(e,t)},this.safeSetTextureCube=function(e,t){e&&e.isWebGLCubeRenderTarget&&(!1===ee&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),ee=!0),e=e.texture),V(e,t)}}function ia(e,t,n){const i=n.isWebGL2;return{convert:function(e){let n;if(e===x)return 5121;if(1017===e)return 32819;if(1018===e)return 32820;if(1019===e)return 33635;if(1010===e)return 5120;if(1011===e)return 5122;if(e===b)return 5123;if(1013===e)return 5124;if(e===w)return 5125;if(e===_)return 5126;if(e===M)return i?5131:null!==(n=t.get("OES_texture_half_float"))?n.HALF_FLOAT_OES:null;if(1021===e)return 6406;if(e===T)return 6407;if(e===E)return 6408;if(1024===e)return 6409;if(1025===e)return 6410;if(e===A)return 6402;if(e===L)return 34041;if(1028===e)return 6403;if(1029===e)return 36244;if(1030===e)return 33319;if(1031===e)return 33320;if(1032===e)return 36248;if(1033===e)return 36249;if(e===R||e===C||e===P||e===I){if(null===(n=t.get("WEBGL_compressed_texture_s3tc")))return null;if(e===R)return n.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===C)return n.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===P)return n.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===I)return n.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(e===D||e===O||e===N||e===F){if(null===(n=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(e===D)return n.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===O)return n.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===N)return n.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===F)return n.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===e)return null!==(n=t.get("WEBGL_compressed_texture_etc1"))?n.COMPRESSED_RGB_ETC1_WEBGL:null;if((e===B||e===z)&&null!==(n=t.get("WEBGL_compressed_texture_etc"))){if(e===B)return n.COMPRESSED_RGB8_ETC2;if(e===z)return n.COMPRESSED_RGBA8_ETC2_EAC}return 37808===e||37809===e||37810===e||37811===e||37812===e||37813===e||37814===e||37815===e||37816===e||37817===e||37818===e||37819===e||37820===e||37821===e||37840===e||37841===e||37842===e||37843===e||37844===e||37845===e||37846===e||37847===e||37848===e||37849===e||37850===e||37851===e||37852===e||37853===e?null!==(n=t.get("WEBGL_compressed_texture_astc"))?e:null:36492===e?null!==(n=t.get("EXT_texture_compression_bptc"))?e:null:e===S?i?34042:null!==(n=t.get("WEBGL_depth_texture"))?n.UNSIGNED_INT_24_8_WEBGL:null:void 0}}}$r.prototype.isMeshDistanceMaterial=!0;class ra extends Gn{constructor(e=[]){super(),this.cameras=e}}ra.prototype.isArrayCamera=!0;class aa extends bt{constructor(){super(),this.type="Group"}}function oa(){this._targetRay=null,this._grip=null,this._hand=null}function sa(e,t){const n=this,i=e.state;let r=null,a=1,o=null,s="local-floor",l=null;const c=[],u=new Map,h=new Gn;h.layers.enable(1),h.viewport=new fe;const d=new Gn;d.layers.enable(2),d.viewport=new fe;const p=[h,d],f=new ra;f.layers.enable(1),f.layers.enable(2);let m=null,g=null;function v(e){const t=u.get(e.inputSource);t&&t.dispatchEvent({type:e.type,data:e.inputSource})}function y(){u.forEach((function(e,t){e.disconnect(t)})),u.clear(),m=null,g=null,i.bindXRFramebuffer(null),e.setRenderTarget(e.getRenderTarget()),S.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function x(e){const t=r.inputSources;for(let n=0;n0&&Le(a,e,t),o.length>0&&Le(o,e,t),null!==b&&(J.updateRenderTargetMipmap(b),J.updateMultisampleRenderTarget(b)),!0===e.isScene&&e.onAfterRender(m,e,t),q.buffers.depth.setTest(!0),q.buffers.depth.setMask(!0),q.buffers.color.setMask(!0),q.setPolygonOffset(!1),me.resetDefaultState(),w=-1,S=null,f.pop(),d=f.length>0?f[f.length-1]:null,p.pop(),h=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return v},this.getActiveMipmapLevel=function(){return y},this.getRenderTarget=function(){return b},this.setRenderTarget=function(e,t=0,n=0){b=e,v=t,y=n,e&&void 0===Y.get(e).__webglFramebuffer&&J.setupRenderTarget(e);let i=null,r=!1,a=!1;if(e){const n=e.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(a=!0);const o=Y.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=o[t],r=!0):i=e.isWebGLMultisampleRenderTarget?Y.get(e).__webglMultisampledFramebuffer:o,T.copy(e.viewport),A.copy(e.scissor),L=e.scissorTest}else T.copy(O).multiplyScalar(P).floor(),A.copy(N).multiplyScalar(P).floor(),L=F;if(q.bindFramebuffer(36160,i),q.viewport(T),q.scissor(A),q.setScissorTest(L),r){const i=Y.get(e.texture);ge.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}else if(a){const i=Y.get(e.texture),r=t||0;ge.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,r)}},this.readRenderTargetPixels=function(e,t,n,i,r,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=Y.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){q.bindFramebuffer(36160,s);try{const o=e.texture,s=o.format,l=o.type;if(s!==E&&pe.convert(s)!==ge.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===M&&(V.has("EXT_color_buffer_half_float")||W.isWebGL2&&V.has("EXT_color_buffer_float"));if(!(l===x||pe.convert(l)===ge.getParameter(35738)||l===_&&(W.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===ge.checkFramebufferStatus(36160)?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&ge.readPixels(t,n,i,r,pe.convert(s),pe.convert(l),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==b?Y.get(b).__webglFramebuffer:null;q.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i),o=pe.convert(t.format);J.setTexture2D(t,0),ge.copyTexImage2D(3553,n,o,e.x,e.y,r,a,0),q.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,a=t.image.height,o=pe.convert(n.format),s=pe.convert(n.type);J.setTexture2D(n,0),ge.pixelStorei(37440,n.flipY),ge.pixelStorei(37441,n.premultiplyAlpha),ge.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?ge.texSubImage2D(3553,i,e.x,e.y,r,a,o,s,t.image.data):t.isCompressedTexture?ge.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):ge.texSubImage2D(3553,i,e.x,e.y,o,s,t.image),0===i&&n.generateMipmaps&&ge.generateMipmap(3553),q.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(m.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const{width:a,height:o,data:s}=n.image,l=pe.convert(i.format),c=pe.convert(i.type);let u;if(i.isDataTexture3D)J.setTexture3D(i,0),u=32879;else{if(!i.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");J.setTexture2DArray(i,0),u=35866}ge.pixelStorei(37440,i.flipY),ge.pixelStorei(37441,i.premultiplyAlpha),ge.pixelStorei(3317,i.unpackAlignment);const h=ge.getParameter(3314),d=ge.getParameter(32878),p=ge.getParameter(3316),f=ge.getParameter(3315),g=ge.getParameter(32877);ge.pixelStorei(3314,a),ge.pixelStorei(32878,o),ge.pixelStorei(3316,e.min.x),ge.pixelStorei(3315,e.min.y),ge.pixelStorei(32877,e.min.z),ge.texSubImage3D(u,r,t.x,t.y,t.z,e.max.x-e.min.x+1,e.max.y-e.min.y+1,e.max.z-e.min.z+1,l,c,s),ge.pixelStorei(3314,h),ge.pixelStorei(32878,d),ge.pixelStorei(3316,p),ge.pixelStorei(3315,f),ge.pixelStorei(32877,g),0===r&&i.generateMipmaps&&ge.generateMipmap(u),q.unbindTexture()},this.initTexture=function(e){J.setTexture2D(e,0),q.unbindTexture()},this.resetState=function(){v=0,y=0,b=null,q.reset(),me.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}aa.prototype.isGroup=!0,Object.assign(oa.prototype,{constructor:oa,getHandSpace:function(){return null===this._hand&&(this._hand=new aa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},getTargetRaySpace:function(){return null===this._targetRay&&(this._targetRay=new aa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1),this._targetRay},getGripSpace:function(){return null===this._grip&&(this._grip=new aa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1),this._grip},dispatchEvent:function(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this},disconnect:function(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this},update:function(e,t,n){let i=null,r=null,a=null;const o=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState)if(null!==o&&null!==(i=t.getPose(e.targetRaySpace,n))&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale)),l&&e.hand){a=!0;for(const a of e.hand.values()){const e=t.getJointPose(a,n);if(void 0===l.joints[a.jointName]){const e=new aa;e.matrixAutoUpdate=!1,e.visible=!1,l.joints[a.jointName]=e,l.add(e)}const i=l.joints[a.jointName];null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=e.radius),i.visible=null!==e}const i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],o=i.position.distanceTo(r.position),s=.02,c=.005;l.inputState.pinching&&o>s+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&o<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale));return null!==o&&(o.visible=null!==i),null!==s&&(s.visible=null!==r),null!==l&&(l.visible=null!==a),this}}),Object.assign(sa.prototype,ie.prototype);class ua extends ca{}ua.prototype.isWebGL1Renderer=!0;class ha{constructor(e,t=25e-5){this.name="",this.color=new Vt(e),this.density=t}clone(){return new ha(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}ha.prototype.isFogExp2=!0;class da{constructor(e,t=1,n=1e3){this.name="",this.color=new Vt(e),this.near=t,this.far=n}clone(){return new da(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}da.prototype.isFog=!0;class pa extends bt{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.background&&(t.object.background=this.background.toJSON(e)),null!==this.environment&&(t.object.environment=this.environment.toJSON(e)),null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}function fa(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=ee,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=oe.generateUUID()}pa.prototype.isScene=!0,Object.defineProperty(fa.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(fa.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:s,point:xa.clone(),uv:Nt.getUV(xa,Ta,Ea,Aa,La,Ra,Ca,new se),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Ia(e,t,n,i,r,a){_a.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Ma.x=a*_a.x-r*_a.y,Ma.y=r*_a.x+a*_a.y):Ma.copy(_a),e.copy(t),e.x+=Ma.x,e.y+=Ma.y,e.applyMatrix4(Sa)}Pa.prototype.isSprite=!0;const Da=new ye,Oa=new ye;class Na extends bt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){Da.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Da);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Da.setFromMatrixPosition(e.matrixWorld),Oa.setFromMatrixPosition(this.matrixWorld);const n=Da.distanceTo(Oa)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;is)continue;h.applyMatrix4(this.matrixWorld);const d=e.ray.origin.distanceTo(h);de.far||t.push({distance:d,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}else for(let n=Math.max(0,a.start),o=Math.min(r.count,a.start+a.count)-1;ns)continue;h.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(h);ie.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},updateMorphTargets:function(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});const ro=new ye,ao=new ye;function oo(e,t){io.call(this,e,t),this.type="LineSegments"}oo.prototype=Object.assign(Object.create(io.prototype),{constructor:oo,isLineSegments:!0,computeLineDistances:function(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:o})}}fo.prototype=Object.assign(Object.create(bt.prototype),{constructor:fo,isPoints:!0,copy:function(e){return bt.prototype.copy.call(this,e),this.material=e.material,this.geometry=e.geometry,this},raycast:function(e,t){const n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ho.copy(n.boundingSphere),ho.applyMatrix4(i),ho.radius+=r,!1===e.ray.intersectsSphere(ho))return;co.copy(i).invert(),uo.copy(e.ray).applyMatrix4(co);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o;if(n.isBufferGeometry){const r=n.index,o=n.attributes.position;if(null!==r)for(let n=Math.max(0,a.start),l=Math.min(r.count,a.start+a.count);n0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}});class go extends de{constructor(e,t,n,i,r,a,o,s,l){super(e,t,n,i,r,a,o,s,l),this.format=void 0!==o?o:T,this.minFilter=void 0!==a?a:g,this.magFilter=void 0!==r?r:g,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}go.prototype.isVideoTexture=!0;class vo extends de{constructor(e,t,n,i,r,a,o,s,l,c,u,h){super(null,a,o,s,l,c,i,r,u,h),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}vo.prototype.isCompressedTexture=!0;class yo extends de{constructor(e,t,n,i,r,a,o,s,l){super(e,t,n,i,r,a,o,s,l),this.needsUpdate=!0}}yo.prototype.isCanvasTexture=!0;class xo extends de{constructor(e,t,n,i,r,a,o,s,l,c){if((c=void 0!==c?c:A)!==A&&c!==L)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===A&&(n=b),void 0===n&&c===L&&(n=S),super(null,i,r,a,o,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==o?o:p,this.minFilter=void 0!==s?s:p,this.flipY=!1,this.generateMipmaps=!1}}xo.prototype.isDepthTexture=!0;class bo extends gn{constructor(e=1,t=8,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const r=[],a=[],o=[],s=[],l=new ye,c=new se;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let u=0,h=3;u<=t;u++,h+=3){const r=n+u/t*i;l.x=e*Math.cos(r),l.y=e*Math.sin(r),a.push(l.x,l.y,l.z),o.push(0,0,1),c.x=(a[h]/e+1)/2,c.y=(a[h+1]/e+1)/2,s.push(c.x,c.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new rn(a,3)),this.setAttribute("normal",new rn(o,3)),this.setAttribute("uv",new rn(s,2))}}class wo extends gn{constructor(e=1,t=1,n=1,i=8,r=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:s};const l=this;i=Math.floor(i),r=Math.floor(r);const c=[],u=[],h=[],d=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const r=p,a=new se,f=new ye;let v=0;const y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*x,0),h.push(0,x,0),d.push(.5,.5),p++;const b=p;for(let e=0;e<=i;e++){const t=e/i*s+o,n=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*x,f.z=y*n,u.push(f.x,f.y,f.z),h.push(0,x,0),a.x=.5*n+.5,a.y=.5*r*x+.5,d.push(a.x,a.y),p++}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new rn(u,3)),this.setAttribute("normal",new rn(h,3)),this.setAttribute("uv",new rn(d,2))}}class _o extends wo{constructor(e=1,t=1,n=8,i=1,r=!1,a=0,o=2*Math.PI){super(0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}}class Mo extends gn{constructor(e,t,n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function o(e,t,n,i){const r=i+1,a=[];for(let o=0;o<=r;o++){a[o]=[];const i=e.clone().lerp(n,o/r),s=t.clone().lerp(n,o/r),l=r-o;for(let e=0;e<=l;e++)a[o][e]=0===e&&o===r?i:i.clone().lerp(s,e/l)}for(let o=0;o.9&&o<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new rn(r,3)),this.setAttribute("normal",new rn(r.slice(),3)),this.setAttribute("uv",new rn(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}}class So extends Mo{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[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="DodecahedronGeometry",this.parameters={radius:e,detail:t}}}const To=new ye,Eo=new ye,Ao=new ye,Lo=new Nt;class Ro extends gn{constructor(e,t){if(super(),this.type="EdgesGeometry",this.parameters={thresholdAngle:t},t=void 0!==t?t:1,!0===e.isGeometry)return void console.error("THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");const n=Math.pow(10,4),i=Math.cos(oe.DEG2RAD*t),r=e.getIndex(),a=e.getAttribute("position"),o=r?r.count:a.count,s=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let d=0;d0)for(a=t;a=t;a-=i)o=Ko(a,e[a],e[a+1],o);return o&&Wo(o,o.next)&&(Qo(o),o=o.next),o}function Po(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!Wo(i,i.next)&&0!==Vo(i.prev,i,i.next))i=i.next;else{if(Qo(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function Io(e,t,n,i,r,a,o){if(!e)return;!o&&a&&function(e,t,n,i){let r=e;do{null===r.z&&(r.z=Uo(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,a,o,s,l,c=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,c*=2}while(o>1)}(r)}(e,i,r,a);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,a?Oo(e,i,r,a):Do(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),Qo(e),e=l.next,c=l.next;else if((e=l)===c){o?1===o?Io(e=No(Po(e),t,n),t,n,i,r,a,2):2===o&&Fo(e,t,n,i,r,a):Io(Po(e),t,n,i,r,a,1);break}}function Do(e){const t=e.prev,n=e,i=e.next;if(Vo(t,n,i)>=0)return!1;let r=e.next.next;for(;r!==e.prev;){if(Go(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Vo(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Oo(e,t,n,i){const r=e.prev,a=e,o=e.next;if(Vo(r,a,o)>=0)return!1;const s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,u=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,h=Uo(s,l,t,n,i),d=Uo(c,u,t,n,i);let p=e.prevZ,f=e.nextZ;for(;p&&p.z>=h&&f&&f.z<=d;){if(p!==e.prev&&p!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Vo(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Vo(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Vo(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&Go(r.x,r.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Vo(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function No(e,t,n){let i=e;do{const r=i.prev,a=i.next.next;!Wo(r,a)&&qo(r,i,i.next,a)&&Yo(r,a)&&Yo(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),Qo(i),Qo(i.next),i=e=a),i=i.next}while(i!==e);return Po(i)}function Fo(e,t,n,i,r,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&jo(o,e)){let s=Jo(o,e);return o=Po(o,o.next),s=Po(s,s.next),Io(o,t,n,i,r,a),void Io(s,t,n,i,r,a)}e=e.next}o=o.next}while(o!==e)}function Bo(e,t){return e.x-t.x}function zo(e,t){if(t=function(e,t){let n=t;const i=e.x,r=e.y;let a,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){const e=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>o){if(o=e,e===i){if(r===n.y)return n;if(r===n.next.y)return n.next}a=n.x=n.x&&n.x>=l&&i!==n.x&&Go(ra.x||n.x===a.x&&Ho(a,n)))&&(a=n,h=u)),n=n.next}while(n!==s);return a}(e,t)){const n=Jo(t,e);Po(t,t.next),Po(n,n.next)}}function Ho(e,t){return Vo(e.prev,e,t.prev)<0&&Vo(t.next,e,e.next)<0}function Uo(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ko(e){let t=e,n=e;do{(t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function jo(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&qo(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Yo(e,t)&&Yo(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(Vo(e.prev,e,t.prev)||Vo(e,t.prev,t))||Wo(e,t)&&Vo(e.prev,e,e.next)>0&&Vo(t.prev,t,t.next)>0)}function Vo(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Wo(e,t){return e.x===t.x&&e.y===t.y}function qo(e,t,n,i){const r=Zo(Vo(e,t,n)),a=Zo(Vo(e,t,i)),o=Zo(Vo(n,i,e)),s=Zo(Vo(n,i,t));return r!==a&&o!==s||!(0!==r||!Xo(e,n,t))||!(0!==a||!Xo(e,i,t))||!(0!==o||!Xo(n,e,i))||!(0!==s||!Xo(n,t,i))}function Xo(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Zo(e){return e>0?1:e<0?-1:0}function Yo(e,t){return Vo(e.prev,e,e.next)<0?Vo(e,t,e.next)>=0&&Vo(e,e.prev,t)>=0:Vo(e,t,e.prev)<0||Vo(e,e.next,t)<0}function Jo(e,t){const n=new $o(e.i,e.x,e.y),i=new $o(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Ko(e,t,n,i){const r=new $o(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Qo(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function $o(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}const es={area:function(e){const t=e.length;let n=0;for(let i=t-1,r=0;r80*n){s=c=e[0],l=u=e[1];for(let t=n;tc&&(c=h),d>u&&(u=d);p=0!==(p=Math.max(c-s,u-l))?1/p:0}return Io(a,o,n,s,l,p),o}(n,i);for(let s=0;s2&&e[t-1].equals(e[0])&&e.pop()}function ns(e,t){for(let n=0;nNumber.EPSILON){const h=Math.sqrt(u),d=Math.sqrt(l*l+c*c),p=t.x-s/h,f=t.y+o/h,m=((n.x-c/d-p)*c-(n.y+l/d-f)*l)/(o*c-s*l),g=(i=p+o*m-e.x)*i+(r=f+s*m-e.y)*r;if(g<=2)return new se(i,r);a=Math.sqrt(g/2)}else{let e=!1;o>Number.EPSILON?l>Number.EPSILON&&(e=!0):o<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(i=-s,r=o,a=Math.sqrt(u)):(i=o,r=s,a=Math.sqrt(u/2))}return new se(i/a,r/a)}const P=[];for(let t=0,n=E.length,i=n-1,r=t+1;t=0;t--){const e=t/p,n=u*Math.cos(e*Math.PI/2),i=h*Math.sin(e*Math.PI/2)+d;for(let t=0,r=E.length;t=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=s+2*p;e=0?(e(p-s,i,u),h.subVectors(c,u)):(e(p+s,i,u),h.subVectors(u,c)),i-s>=0?(e(p,i-s,u),d.subVectors(c,u)):(e(p,i+s,u),d.subVectors(u,c)),l.crossVectors(h,d).normalize(),a.push(l.x,l.y,l.z),o.push(p,i)}}for(let f=0;f0)&&d.push(t,i,o),(g!==n-1||s=i)){s.push(e.times[a]);for(let n=0;na.tracks[l].times[0]&&(s=a.tracks[l].times[0]);for(let l=0;l=t.times[h]){const e=h*l+s,n=e+l-s;d=Cs.arraySlice(t.values,e,n)}else{const e=t.createInterpolant(),n=s,i=l-s;e.evaluate(a),d=Cs.arraySlice(e.resultBuffer,n,i)}"quaternion"===i&&(new ve).fromArray(d).normalize().conjugate().toArray(d);const p=r.times.length;for(let e=0;e=r)break e;{const o=t[1];e=(r=t[--n-1]))break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);const e=this.getValueSize();this.times=Cs.arraySlice(n,r,a),this.values=Cs.arraySlice(this.values,r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==r;o++){const t=n[o];if("number"==typeof t&&isNaN(t)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,t),e=!1;break}if(null!==a&&a>t){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,t,a),e=!1;break}a=t}if(void 0!==i&&Cs.isTypedArray(i))for(let o=0,s=i.length;o!==s;++o){const t=i[o];if(isNaN(t)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,t),e=!1;break}}return e}optimize(){const e=Cs.arraySlice(this.times),t=Cs.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===k,r=e.length-1;let a=1;for(let o=1;o0){e[a]=e[r];for(let e=r*n,i=a*n,o=0;o!==n;++o)t[i+o]=t[e+o];++a}return a!==e.length?(this.times=Cs.arraySlice(e,0,a),this.values=Cs.arraySlice(t,0,a*n)):(this.times=e,this.values=t),this}clone(){const e=Cs.arraySlice(this.times,0),t=Cs.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Ns.prototype.TimeBufferType=Float32Array,Ns.prototype.ValueBufferType=Float32Array,Ns.prototype.DefaultInterpolation=U;class Fs extends Ns{}Fs.prototype.ValueTypeName="bool",Fs.prototype.ValueBufferType=Array,Fs.prototype.DefaultInterpolation=H,Fs.prototype.InterpolantFactoryMethodLinear=void 0,Fs.prototype.InterpolantFactoryMethodSmooth=void 0;class Bs extends Ns{}Bs.prototype.ValueTypeName="color";class zs extends Ns{}function Hs(e,t,n,i){Ps.call(this,e,t,n,i)}zs.prototype.ValueTypeName="number",Hs.prototype=Object.assign(Object.create(Ps.prototype),{constructor:Hs,interpolate_:function(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(i-t);let l=e*o;for(let c=l+o;l!==c;l+=4)ve.slerpFlat(r,0,a,l-o,a,l,s);return r}});class Us extends Ns{InterpolantFactoryMethodLinear(e){return new Hs(this.times,this.values,this.getValueSize(),e)}}Us.prototype.ValueTypeName="quaternion",Us.prototype.DefaultInterpolation=U,Us.prototype.InterpolantFactoryMethodSmooth=void 0;class ks extends Ns{}ks.prototype.ValueTypeName="string",ks.prototype.ValueBufferType=Array,ks.prototype.DefaultInterpolation=H,ks.prototype.InterpolantFactoryMethodLinear=void 0,ks.prototype.InterpolantFactoryMethodSmooth=void 0;class Gs extends Ns{}Gs.prototype.ValueTypeName="vector";class js{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=oe.generateUUID(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,o=n.length;a!==o;++a)t.push(Vs(n[a]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(Ns.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let o=0;o1){const e=n[1];let r=i[e];r||(i[e]=r=[]),r.push(t)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],o=[];Cs.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.fps||30,o=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let c=0;c0||0===e.search(/^data\:image\/jpeg/);r.format=i?T:E,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}),Object.assign(nl.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){const e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)r+=(n=this.getPoint(a/e)).distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let o,s=0,l=r-1;for(;s<=l;)if((o=n[i=Math.floor(s+(l-s)/2)]-a)<0)s=i+1;else{if(!(o>0)){l=i;break}l=i-1}if(n[i=l]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)},getTangent:function(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);const r=this.getPoint(n),a=this.getPoint(i),o=t||(r.isVector2?new se:new ye);return o.copy(a).sub(r).normalize(),o},getTangentAt:function(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)},computeFrenetFrames:function(e,t){const n=new ye,i=[],r=[],a=[],o=new ye,s=new Ye;for(let d=0;d<=e;d++){const t=d/e;i[d]=this.getTangentAt(t,new ye),i[d].normalize()}r[0]=new ye,a[0]=new ye;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),h=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),h<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),a[d]=a[d-1].clone(),o.crossVectors(i[d-1],i[d]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(oe.clamp(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(s.makeRotationAxis(o,e))}a[d].crossVectors(i[d],r[d])}if(!0===t){let t=Math.acos(oe.clamp(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}});class il extends nl{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,o=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new se,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?o=i[(l-1)%r]:(ol.subVectors(i[0],i[1]).add(i[0]),o=ol);const u=i[l%r],h=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(hl(o,s.x,l.x,c.x,u.x),hl(o,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=t){const e=n[i]-t,r=this.curves[i],a=r.getLength(),o=0===a?0:1-e/a;return r.getPointAt(o)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Sl extends Ml{constructor(e){super(e),this.uuid=oe.generateUUID(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const r in e.uniforms){const t=e.uniforms[r];switch(i.uniforms[r]={},t.type){case"t":i.uniforms[r].value=n(t.value);break;case"c":i.uniforms[r].value=(new Vt).setHex(t.value);break;case"v2":i.uniforms[r].value=(new se).fromArray(t.value);break;case"v3":i.uniforms[r].value=(new ye).fromArray(t.value);break;case"v4":i.uniforms[r].value=(new fe).fromArray(t.value);break;case"m3":i.uniforms[r].value=(new le).fromArray(t.value);break;case"m4":i.uniforms[r].value=(new Ye).fromArray(t.value);break;default:i.uniforms[r].value=t.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const r in e.extensions)i.extensions[r]=e.extensions[r];if(void 0!==e.shading&&(i.flatShading=1===e.shading),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new se).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new se).fromArray(e.clearcoatNormalScale)),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),i}setTextures(e){return this.textures=e,this}}const ql={decodeText:function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;nNumber.EPSILON){if(l<0&&(n=t[a],s=-s,o=t[r],l=-l),e.yo.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return i}const r=es.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return n(a);let o,s,l;const c=[];if(1===a.length)return s=a[0],(l=new Sl).curves=s.curves,c.push(l),c;let u=!r(a[0].getPoints());u=e?!u:u;const h=[],d=[];let p,f,m=[],g=0;d[g]=void 0,m[g]=[];for(let v=0,y=a.length;v1){let e=!1;const t=[];for(let n=0,i=d.length;n0&&(e||(m=h))}for(let v=0,y=d.length;v0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let s=t,l=t+t;s!==l;++s)if(n[s]!==n[s+t]){o.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){ve.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const a=this._workIndex*r;ve.multiplyQuaternionsFlat(e,a,e,t,e,n),ve.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){const a=1-i;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*a+e[n+o]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]+e[n+a]*i}}}const Mc=new RegExp("[\\[\\]\\.:\\/]","g"),Sc="[^\\[\\]\\.:\\/]",Tc="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Ec=/((?:WC+[\/:])*)/.source.replace("WC",Sc),Ac=/(WCOD+)?/.source.replace("WCOD",Tc),Lc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sc),Rc=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sc),Cc=new RegExp("^"+Ec+Ac+Lc+Rc+"$"),Pc=["material","materials","bones"];function Ic(e,t,n){const i=n||Dc.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}function Dc(e,t,n){this.path=t,this.parsedPath=n||Dc.parseTrackName(t),this.node=Dc.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}Object.assign(Ic.prototype,{getValue:function(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)},setValue:function(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)},bind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(Dc,{Composite:Ic,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new Dc.Composite(e,t,n):new Dc(e,t,n)},sanitizeNodeName:function(e){return e.replace(/\s/g,"_").replace(Mc,"")},parseTrackName:function(e){const t=Cc.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==Pc.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n},findNode:function(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i=r){const a=r++,c=e[a];t[c.uuid]=l,e[l]=c,t[s]=a,e[a]=o;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,a=e.length;for(let o=0,s=arguments.length;o!==s;++o){const s=arguments[o].uuid,l=t[s];if(void 0!==l)if(delete t[s],l0&&(t[o.uuid]=l),e[l]=o,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const a=this._paths,o=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);i=r.length,n[e]=i,a.push(e),o.push(t),r.push(u);for(let h=c,d=s.length;h!==d;++h){const n=s[h];u[h]=new Dc(n,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];t[e[o]]=n,a[n]=s,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}}Oc.prototype.isAnimationObjectGroup=!0;class Nc{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,o=new Array(a),s={endingStart:G,endingEnd:G};for(let l=0;l!==a;++l){const e=r[l].createInterpolant(null);o[l]=e,e.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,r=i/n,a=n/i;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,r=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const s=o.parameterPositions,l=o.sampleValues;return s[0]=r,s[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*n;if(i<0||0===n)return;this._startTime=null,t=n*i}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;switch(this.blendMode){case q:for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(o);break;case W:default:for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const a=2202===n;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=j,i.endingEnd=j):(i.endingStart=e?this.zeroSlopeAtStart?j:G:V,i.endingEnd=t?this.zeroSlopeAtEnd?j:G:V)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}class Fc extends ie{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let u=0;u!==r;++u){const e=i[u],r=e.name;let l=c[r];if(void 0!==l)a[u]=l;else{if(void 0!==(l=a[u])){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,s,r));continue}const i=t&&t._propertyBindings[u].binding.parsedPath;++(l=new _c(Dc.create(n,r,i),e.ValueTypeName,e.getValueSize())).referenceCount,this._addInactiveBinding(l,s,r),a[u]=l}o[u].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const 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(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,a);const o=this._bindings,s=this._nActiveBindings;for(let l=0;l!==s;++l)o[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(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(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new se),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new se),t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return jc.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Vc.prototype.isBox2=!0;const Wc=new ye,qc=new ye;class Xc{constructor(e=new ye,t=new ye){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new ye),e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new ye),e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new ye),this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Wc.subVectors(e,this.start),qc.subVectors(this.end,this.start);const n=qc.dot(qc);let i=qc.dot(Wc)/n;return t&&(i=oe.clamp(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new ye),this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}function Zc(e){bt.call(this),this.material=e,this.render=function(){},this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=null,this.normalArray=null,this.colorArray=null,this.uvArray=null,this.count=0}Zc.prototype=Object.create(bt.prototype),Zc.prototype.constructor=Zc,Zc.prototype.isImmediateRenderObject=!0;const Yc=new ye,Jc=new ye,Kc=new Ye,Qc=new Ye;class $c extends oo{constructor(e){const t=function e(t){const n=[];t&&t.isBone&&n.push(t);for(let i=0;i>16&32768,i=t>>12&2047;const r=t>>23&255;return r<103?n:r>142?(n|=31744,n|=(255==r?0:1)&&8388607&t):r<113?n|=((i|=2048)>>114-r)+(i>>113-r&1):(n|=r-112<<10|i>>1,n+=1&i)}},xu=Math.pow(2,8),bu=[.125,.215,.35,.446,.526,.582],wu=5+bu.length,_u={[X]:0,[Z]:1,[J]:2,[K]:3,[Q]:4,[$]:5,[Y]:6},Mu=new Wt({side:1,depthWrite:!1,depthTest:!1}),Su=new On(new Fn,Mu),Tu=new zl,{_lodPlanes:Eu,_sizeLods:Au,_sigmas:Lu}=function(){const e=[],t=[],n=[];let i=8;for(let r=0;r4?o=bu[r-8+4-1]:0==r&&(o=0),n.push(o);const s=1/(a-1),l=-s/2,c=1+s/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,d=6,p=3,f=2,m=1,g=new Float32Array(p*d*h),v=new Float32Array(f*d*h),y=new Float32Array(m*d*h);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(i,p*d*e),v.set(u,f*d*e);const r=[e,e,e,e,e,e];y.set(r,m*d*e)}const x=new gn;x.setAttribute("position",new Zt(g,p)),x.setAttribute("uv",new Zt(v,f)),x.setAttribute("faceIndex",new Zt(y,m)),e.push(x),i>4&&i--}return{_lodPlanes:e,_sizeLods:t,_sigmas:n}}(),Ru=new Vt;let Cu=null;const Pu=(1+Math.sqrt(5))/2,Iu=1/Pu,Du=[new ye(1,1,1),new ye(-1,1,1),new ye(1,1,-1),new ye(-1,1,-1),new ye(0,Pu,Iu),new ye(0,Pu,-Iu),new ye(Iu,0,Pu),new ye(-Iu,0,Pu),new ye(Pu,Iu,0),new ye(-Pu,Iu,0)];function Ou(e){const t=Math.max(e.r,e.g,e.b),n=Math.min(Math.max(Math.ceil(Math.log2(t)),-128),127);return e.multiplyScalar(Math.pow(2,-n)),(n+128)/255}function Nu(e){return void 0!==e&&e.type===x&&(e.encoding===X||e.encoding===Z||e.encoding===Y)}function Fu(e){const t=new me(3*xu,3*xu,e);return t.texture.mapping=l,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Bu(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function zu(){const e=new se(1,1);return new bs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e},inputEncoding:{value:_u[3e3]},outputEncoding:{value:_u[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform vec2 texelSize;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Hu(){return new bs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:_u[3e3]},outputEncoding:{value:_u[3e3]}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\t\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}nl.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(nl.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Ml.prototype.fromPoints=function(e){return console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(e)},iu.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},$c.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Zs.prototype.extractUrlBase=function(e){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),ql.extractUrlBase(e)},Zs.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}},Vc.prototype.center=function(e){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(e)},Vc.prototype.empty=function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Vc.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Vc.prototype.size=function(e){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(e)},we.prototype.center=function(e){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(e)},we.prototype.empty=function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},we.prototype.isIntersectionBox=function(e){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},we.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},we.prototype.size=function(e){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(e)},Ue.prototype.empty=function(){return console.warn("THREE.Sphere: .empty() has been renamed to .isEmpty()."),this.isEmpty()},Yn.prototype.setFromMatrix=function(e){return console.warn("THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix()."),this.setFromProjectionMatrix(e)},Xc.prototype.center=function(e){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(e)},oe.random16=function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},oe.nearestPowerOfTwo=function(e){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),oe.floorPowerOfTwo(e)},oe.nextPowerOfTwo=function(e){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),oe.ceilPowerOfTwo(e)},le.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},le.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},le.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},le.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead."),e.applyMatrix3(this)},le.prototype.applyToVector3Array=function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")},le.prototype.getInverse=function(e){return console.warn("THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},Ye.prototype.extractPosition=function(e){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(e)},Ye.prototype.flattenToArrayOffset=function(e,t){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(e,t)},Ye.prototype.getPosition=function(){return console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),(new ye).setFromMatrixColumn(this,3)},Ye.prototype.setRotationFromQuaternion=function(e){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(e)},Ye.prototype.multiplyToArray=function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},Ye.prototype.multiplyVector3=function(e){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.multiplyVector4=function(e){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.multiplyVector3Array=function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},Ye.prototype.rotateAxis=function(e){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),e.transformDirection(this)},Ye.prototype.crossVector=function(e){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.translate=function(){console.error("THREE.Matrix4: .translate() has been removed.")},Ye.prototype.rotateX=function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},Ye.prototype.rotateY=function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},Ye.prototype.rotateZ=function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},Ye.prototype.rotateByAxis=function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},Ye.prototype.applyToBufferAttribute=function(e){return console.warn("THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead."),e.applyMatrix4(this)},Ye.prototype.applyToVector3Array=function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},Ye.prototype.makeFrustum=function(e,t,n,i,r,a){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(e,t,i,n,r,a)},Ye.prototype.getInverse=function(e){return console.warn("THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead."),this.copy(e).invert()},St.prototype.isIntersectionLine=function(e){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(e)},ve.prototype.multiplyVector3=function(e){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),e.applyQuaternion(this)},ve.prototype.inverse=function(){return console.warn("THREE.Quaternion: .inverse() has been renamed to invert()."),this.invert()},Ze.prototype.isIntersectionBox=function(e){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(e)},Ze.prototype.isIntersectionPlane=function(e){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(e)},Ze.prototype.isIntersectionSphere=function(e){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(e)},Nt.prototype.area=function(){return console.warn("THREE.Triangle: .area() has been renamed to .getArea()."),this.getArea()},Nt.prototype.barycoordFromPoint=function(e,t){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),this.getBarycoord(e,t)},Nt.prototype.midpoint=function(e){return console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint()."),this.getMidpoint(e)},Nt.prototypenormal=function(e){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),this.getNormal(e)},Nt.prototype.plane=function(e){return console.warn("THREE.Triangle: .plane() has been renamed to .getPlane()."),this.getPlane(e)},Nt.barycoordFromPoint=function(e,t,n,i,r){return console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord()."),Nt.getBarycoord(e,t,n,i,r)},Nt.normal=function(e,t,n,i){return console.warn("THREE.Triangle: .normal() has been renamed to .getNormal()."),Nt.getNormal(e,t,n,i)},Sl.prototype.extractAllPoints=function(e){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(e)},Sl.prototype.extrude=function(e){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new is(this,e)},Sl.prototype.makeGeometry=function(e){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new us(this,e)},se.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},se.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},se.prototype.lengthManhattan=function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},ye.prototype.setEulerFromRotationMatrix=function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},ye.prototype.setEulerFromQuaternion=function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},ye.prototype.getPositionFromMatrix=function(e){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(e)},ye.prototype.getScaleFromMatrix=function(e){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(e)},ye.prototype.getColumnFromMatrix=function(e,t){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},ye.prototype.applyProjection=function(e){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(e)},ye.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},ye.prototype.distanceToManhattan=function(e){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(e)},ye.prototype.lengthManhattan=function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},fe.prototype.fromAttribute=function(e,t,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(e,t,n)},fe.prototype.lengthManhattan=function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()},bt.prototype.getChildByName=function(e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(e)},bt.prototype.renderDepth=function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},bt.prototype.translate=function(e,t){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(t,e)},bt.prototype.getWorldRotation=function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")},bt.prototype.applyMatrix=function(e){return console.warn("THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(bt.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(e){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=e}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),On.prototype.setDrawMode=function(){console.error("THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")},Object.defineProperties(On.prototype,{drawMode:{get:function(){return console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode."),0},set:function(){console.error("THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.")}}}),ka.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")},Object.defineProperty(nl.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(e){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=e}}),Gn.prototype.setLens=function(e,t){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==t&&(this.filmGauge=t),this.setFocalLength(e)},Object.defineProperties(Tl.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(e){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=e}},shadowCameraLeft:{set:function(e){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=e}},shadowCameraRight:{set:function(e){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=e}},shadowCameraTop:{set:function(e){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=e}},shadowCameraBottom:{set:function(e){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=e}},shadowCameraNear:{set:function(e){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=e}},shadowCameraFar:{set:function(e){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=e}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(e){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=e}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(e){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=e}},shadowMapHeight:{set:function(e){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=e}}}),Object.defineProperties(Zt.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}},dynamic:{get:function(){return console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.usage===te},set:function(){console.warn("THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead."),this.setUsage(te)}}}),Zt.prototype.setDynamic=function(e){return console.warn("THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?te:ee),this},Zt.prototype.copyIndicesArray=function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},Zt.prototype.setArray=function(){console.error("THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},gn.prototype.addIndex=function(e){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(e)},gn.prototype.addAttribute=function(e,t){return console.warn("THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute()."),t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):this.setAttribute(e,t):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.setAttribute(e,new Zt(arguments[1],arguments[2])))},gn.prototype.addDrawCall=function(e,t,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(e,t)},gn.prototype.clearDrawCalls=function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},gn.prototype.computeOffsets=function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")},gn.prototype.removeAttribute=function(e){return console.warn("THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute()."),this.deleteAttribute(e)},gn.prototype.applyMatrix=function(e){return console.warn("THREE.BufferGeometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)},Object.defineProperties(gn.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(Xl.prototype,{maxInstancedCount:{get:function(){return console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount},set:function(e){console.warn("THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount."),this.instanceCount=e}}}),Object.defineProperties(Uc.prototype,{linePrecision:{get:function(){return console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold},set:function(e){console.warn("THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead."),this.params.Line.threshold=e}}}),Object.defineProperties(fa.prototype,{dynamic:{get:function(){return console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.usage===te},set:function(e){console.warn("THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead."),this.setUsage(e)}}}),fa.prototype.setDynamic=function(e){return console.warn("THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead."),this.setUsage(!0===e?te:ee),this},fa.prototype.setArray=function(){console.error("THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers")},is.prototype.getArrays=function(){console.error("THREE.ExtrudeGeometry: .getArrays() has been removed.")},is.prototype.addShapeList=function(){console.error("THREE.ExtrudeGeometry: .addShapeList() has been removed.")},is.prototype.addShape=function(){console.error("THREE.ExtrudeGeometry: .addShape() has been removed.")},pa.prototype.dispose=function(){console.error("THREE.Scene: .dispose() has been removed.")},Bc.prototype.onUpdate=function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this},Object.defineProperties(Bt.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new Vt}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===e}},stencilMask:{get:function(){return console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask},set:function(e){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead."),this.stencilFuncMask=e}}}),Object.defineProperties(_s.prototype,{transparency:{get:function(){return console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission},set:function(e){console.warn("THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission."),this.transmission=e}}}),Object.defineProperties(Un.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(e){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=e}}}),ca.prototype.clearTarget=function(e,t,n,i){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead."),this.setRenderTarget(e),this.clear(t,n,i)},ca.prototype.animate=function(e){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop()."),this.setAnimationLoop(e)},ca.prototype.getCurrentRenderTarget=function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},ca.prototype.getMaxAnisotropy=function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},ca.prototype.getPrecision=function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},ca.prototype.resetGLState=function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},ca.prototype.supportsFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},ca.prototype.supportsHalfFloatTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},ca.prototype.supportsStandardDerivatives=function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},ca.prototype.supportsCompressedTextureS3TC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},ca.prototype.supportsCompressedTexturePVRTC=function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},ca.prototype.supportsBlendMinMax=function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},ca.prototype.supportsVertexTextures=function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},ca.prototype.supportsInstancedArrays=function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},ca.prototype.enableScissorTest=function(e){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(e)},ca.prototype.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},ca.prototype.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},ca.prototype.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},ca.prototype.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},ca.prototype.setFaceCulling=function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},ca.prototype.allocTextureUnit=function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},ca.prototype.setTexture=function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},ca.prototype.setTexture2D=function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},ca.prototype.setTextureCube=function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},ca.prototype.getActiveMipMapLevel=function(){return console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel()."),this.getActiveMipmapLevel()},Object.defineProperties(ca.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=e}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(e){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=e}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){return console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead."),this.getContext()}},vr:{get:function(){return console.warn("THREE.WebGLRenderer: .vr has been renamed to .xr"),this.xr}},gammaInput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead."),!1},set:function(){console.warn("THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.")}},gammaOutput:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),!1},set:function(e){console.warn("THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead."),this.outputEncoding=!0===e?Z:X}},toneMappingWhitePoint:{get:function(){return console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed."),1},set:function(){console.warn("THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.")}}}),Object.defineProperties(ea.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(me.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=e}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(e){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=e}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=e}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(e){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=e}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(e){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=e}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(e){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=e}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(e){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=e}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(e){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=e}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(e){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=e}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(e){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=e}}}),gc.prototype.load=function(e){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");const t=this;return(new ac).load(e,(function(e){t.setBuffer(e)})),this},wc.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},jn.prototype.updateCubeMap=function(e,t){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(e,t)},jn.prototype.clear=function(e,t,n,i){return console.warn("THREE.CubeCamera: .clear() is now .renderTarget.clear()."),this.renderTarget.clear(e,t,n,i)},ue.crossOrigin=void 0,ue.loadTexture=function(e,t,n,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");const r=new tl;r.setCrossOrigin(this.crossOrigin);const a=r.load(e,n,void 0,i);return t&&(a.mapping=t),a},ue.loadTextureCube=function(e,t,n,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");const r=new $s;r.setCrossOrigin(this.crossOrigin);const a=r.load(e,n,void 0,i);return t&&(a.mapping=t),a},ue.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},ue.loadCompressedTextureCube=function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};const Uu={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js")}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t),e.ACESFilmicToneMapping=4,e.AddEquation=n,e.AddOperation=2,e.AdditiveAnimationBlendMode=q,e.AdditiveBlending=2,e.AlphaFormat=1021,e.AlwaysDepth=1,e.AlwaysStencilFunc=519,e.AmbientLight=kl,e.AmbientLightProbe=sc,e.AnimationClip=js,e.AnimationLoader=class extends Zs{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=[];for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{du.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(du,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}},e.Audio=gc,e.AudioAnalyser=wc,e.AudioContext=rc,e.AudioListener=class extends bt{constructor(){super(),this.type="AudioListener",this.context=rc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new uc}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(dc,pc,fc),mc.set(0,0,-1).applyQuaternion(pc),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(dc.x,e),t.positionY.linearRampToValueAtTime(dc.y,e),t.positionZ.linearRampToValueAtTime(dc.z,e),t.forwardX.linearRampToValueAtTime(mc.x,e),t.forwardY.linearRampToValueAtTime(mc.y,e),t.forwardZ.linearRampToValueAtTime(mc.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(dc.x,dc.y,dc.z),t.setOrientation(mc.x,mc.y,mc.z,n.x,n.y,n.z)}},e.AudioLoader=ac,e.AxesHelper=mu,e.AxisHelper=function(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new mu(e)},e.BackSide=1,e.BasicDepthPacking=3200,e.BasicShadowMap=0,e.BinaryTextureLoader=function(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new el(e)},e.Bone=Ga,e.BooleanKeyframeTrack=Fs,e.BoundingBoxHelper=function(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new hu(e,t)},e.Box2=Vc,e.Box3=we,e.Box3Helper=class extends oo{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new gn;i.setIndex(new Zt(n,1)),i.setAttribute("position",new rn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Ka({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}},e.BoxBufferGeometry=Fn,e.BoxGeometry=Fn,e.BoxHelper=hu,e.BufferAttribute=Zt,e.BufferGeometry=gn,e.BufferGeometryLoader=Yl,e.ByteType=1010,e.Cache=Ws,e.Camera=kn,e.CameraHelper=class extends oo{constructor(e){const t=new gn,n=new Ka({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={},o=new Vt(16755200),s=new Vt(16711680),l=new Vt(43775),c=new Vt(16777215),u=new Vt(3355443);function h(e,t,n){d(e,n),d(t,n)}function d(e,t){i.push(0,0,0),r.push(t.r,t.g,t.b),void 0===a[e]&&(a[e]=[]),a[e].push(i.length/3-1)}h("n1","n2",o),h("n2","n4",o),h("n4","n3",o),h("n3","n1",o),h("f1","f2",o),h("f2","f4",o),h("f4","f3",o),h("f3","f1",o),h("n1","f1",o),h("n2","f2",o),h("n3","f3",o),h("n4","f4",o),h("p","n1",s),h("p","n2",s),h("p","n3",s),h("p","n4",s),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",c),h("p","c",u),h("cn1","cn2",u),h("cn3","cn4",u),h("cf1","cf2",u),h("cf3","cf4",u),t.setAttribute("position",new rn(i,3)),t.setAttribute("color",new rn(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update()}update(){const e=this.geometry,t=this.pointMap;lu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),cu("c",t,e,lu,0,0,-1),cu("t",t,e,lu,0,0,1),cu("n1",t,e,lu,-1,-1,-1),cu("n2",t,e,lu,1,-1,-1),cu("n3",t,e,lu,-1,1,-1),cu("n4",t,e,lu,1,1,-1),cu("f1",t,e,lu,-1,-1,1),cu("f2",t,e,lu,1,-1,1),cu("f3",t,e,lu,-1,1,1),cu("f4",t,e,lu,1,1,1),cu("u1",t,e,lu,.7,1.1,-1),cu("u2",t,e,lu,-.7,1.1,-1),cu("u3",t,e,lu,0,2,-1),cu("cf1",t,e,lu,-1,0,1),cu("cf2",t,e,lu,1,0,1),cu("cf3",t,e,lu,0,-1,1),cu("cf4",t,e,lu,0,1,1),cu("cn1",t,e,lu,-1,0,-1),cu("cn2",t,e,lu,1,0,-1),cu("cn3",t,e,lu,0,-1,-1),cu("cn4",t,e,lu,0,1,-1),e.getAttribute("position").needsUpdate=!0}},e.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")},e.CanvasTexture=yo,e.CatmullRomCurve3=ul,e.CineonToneMapping=3,e.CircleBufferGeometry=bo,e.CircleGeometry=bo,e.ClampToEdgeWrapping=h,e.Clock=uc,e.Color=Vt,e.ColorKeyframeTrack=Bs,e.CompressedTexture=vo,e.CompressedTextureLoader=Ks,e.ConeBufferGeometry=_o,e.ConeGeometry=_o,e.CubeCamera=jn,e.CubeReflectionMapping=r,e.CubeRefractionMapping=a,e.CubeTexture=Vn,e.CubeTextureLoader=$s,e.CubeUVReflectionMapping=l,e.CubeUVRefractionMapping=c,e.CubicBezierCurve=fl,e.CubicBezierCurve3=ml,e.CubicInterpolant=Is,e.CullFaceBack=1,e.CullFaceFront=2,e.CullFaceFrontBack=3,e.CullFaceNone=0,e.Curve=nl,e.CurvePath=_l,e.CustomBlending=5,e.CustomToneMapping=5,e.CylinderBufferGeometry=wo,e.CylinderGeometry=wo,e.Cylindrical=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}},e.DataTexture=qn,e.DataTexture2DArray=gi,e.DataTexture3D=vi,e.DataTextureLoader=el,e.DataUtils=yu,e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=34056,e.DefaultLoadingManager=Xs,e.DepthFormat=A,e.DepthStencilFormat=L,e.DepthTexture=xo,e.DirectionalLight=Ul,e.DirectionalLightHelper=class extends bt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===t&&(t=1);let i=new gn;i.setAttribute("position",new rn([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const r=new Ka({fog:!1,toneMapped:!1});this.lightPlane=new io(i,r),this.add(this.lightPlane),(i=new gn).setAttribute("position",new rn([0,0,0,0,0,1],3)),this.targetLine=new io(i,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){ru.setFromMatrixPosition(this.light.matrixWorld),au.setFromMatrixPosition(this.light.target.matrixWorld),ou.subVectors(au,ru),this.lightPlane.lookAt(au),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(au),this.targetLine.scale.z=ou.length()}},e.DiscreteInterpolant=Os,e.DodecahedronBufferGeometry=So,e.DodecahedronGeometry=So,e.DoubleSide=2,e.DstAlphaFactor=206,e.DstColorFactor=208,e.DynamicBufferAttribute=function(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead."),new Zt(e,t).setUsage(te)},e.DynamicCopyUsage=35050,e.DynamicDrawUsage=te,e.DynamicReadUsage=35049,e.EdgesGeometry=Ro,e.EdgesHelper=function(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new oo(new Ro(e.geometry),new Ka({color:void 0!==t?t:16777215}))},e.EllipseCurve=il,e.EqualDepth=4,e.EqualStencilFunc=514,e.EquirectangularReflectionMapping=o,e.EquirectangularRefractionMapping=s,e.Euler=at,e.EventDispatcher=ie,e.ExtrudeBufferGeometry=is,e.ExtrudeGeometry=is,e.FaceColors=1,e.FileLoader=Js,e.FlatShading=1,e.Float16BufferAttribute=nn,e.Float32Attribute=function(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new rn(e,t)},e.Float32BufferAttribute=rn,e.Float64Attribute=function(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new an(e,t)},e.Float64BufferAttribute=an,e.FloatType=_,e.Fog=da,e.FogExp2=ha,e.Font=tc,e.FontLoader=class extends Zs{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Js(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(e){let n;try{n=JSON.parse(e)}catch(t){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(e.substring(65,e.length-2))}const i=r.parse(n);t&&t(i)}),n,i)}parse(e){return new tc(e)}},e.FrontSide=0,e.Frustum=Yn,e.GLBufferAttribute=Hc,e.GLSL1="100",e.GLSL3=ne,e.GammaEncoding=Y,e.GreaterDepth=6,e.GreaterEqualDepth=5,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=iu,e.Group=aa,e.HalfFloatType=M,e.HemisphereLight=El,e.HemisphereLightHelper=class extends bt{constructor(e,t,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const i=new ss(t);i.rotateY(.5*Math.PI),this.material=new Wt({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=i.getAttribute("position"),a=new Float32Array(3*r.count);i.setAttribute("color",new Zt(a,3)),this.add(new On(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");tu.copy(this.light.color),nu.copy(this.light.groundColor);for(let e=0,n=t.count;e0){const n=new qs(t);(r=new Qs(n)).setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t\n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( inputEncoding == 1 ) {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 2 ) {\n\n\t\t\t\treturn RGBEToLinear( value );\n\n\t\t\t} else if ( inputEncoding == 3 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 7.0 );\n\n\t\t\t} else if ( inputEncoding == 4 ) {\n\n\t\t\t\treturn RGBMToLinear( value, 16.0 );\n\n\t\t\t} else if ( inputEncoding == 5 ) {\n\n\t\t\t\treturn RGBDToLinear( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn GammaToLinear( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 linearToOutputTexel( vec4 value ) {\n\n\t\t\tif ( outputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else if ( outputEncoding == 1 ) {\n\n\t\t\t\treturn LinearTosRGB( value );\n\n\t\t\t} else if ( outputEncoding == 2 ) {\n\n\t\t\t\treturn LinearToRGBE( value );\n\n\t\t\t} else if ( outputEncoding == 3 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 7.0 );\n\n\t\t\t} else if ( outputEncoding == 4 ) {\n\n\t\t\t\treturn LinearToRGBM( value, 16.0 );\n\n\t\t\t} else if ( outputEncoding == 5 ) {\n\n\t\t\t\treturn LinearToRGBD( value, 256.0 );\n\n\t\t\t} else {\n\n\t\t\t\treturn LinearToGamma( value, 2.2 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = linearToOutputTexel( gl_FragColor );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Cu=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e){return this._fromTexture(e)}fromCubemap(e){return this._fromTexture(e)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Hu(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=zu(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e2?xu:0,xu,xu),s.setRenderTarget(i),h&&s.render(Su,r),s.render(e,r)}s.toneMapping=u,s.outputEncoding=c,s.autoClear=l}_textureToCubeUV(e,t){const n=this._renderer;e.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Hu()):null==this._equirectShader&&(this._equirectShader=zu());const i=e.isCubeTexture?this._cubemapShader:this._equirectShader,r=new On(Eu[0],i),a=i.uniforms;a.envMap.value=e,e.isCubeTexture||a.texelSize.value.set(1/e.image.width,1/e.image.height),a.inputEncoding.value=_u[e.encoding],a.outputEncoding.value=_u[t.texture.encoding],Bu(t,0,0,3*xu,2*xu),n.setRenderTarget(t),n.render(r,Tu)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;i20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let y=0;y<20;++y){const e=y/p,t=Math.exp(-e*e/2);m.push(t),0==y?g+=t:y4?i-8+4:0),3*v,2*v),s.setRenderTarget(t),s.render(c,Tu)}},e.ParametricBufferGeometry=ls,e.ParametricGeometry=ls,e.Particle=function(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Pa(e)},e.ParticleBasicMaterial=function(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new lo(e)},e.ParticleSystem=function(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new fo(e,t)},e.ParticleSystemMaterial=function(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new lo(e)},e.Path=Ml,e.PerspectiveCamera=Gn,e.Plane=St,e.PlaneBufferGeometry=Qn,e.PlaneGeometry=Qn,e.PlaneHelper=class extends io{constructor(e,t=1,n=16776960){const i=n,r=new gn;r.setAttribute("position",new rn([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,0,1,0,0,0],3)),r.computeBoundingSphere(),super(r,new Ka({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const a=new gn;a.setAttribute("position",new rn([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),a.computeBoundingSphere(),this.add(new On(a,new Wt({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let t=-this.plane.constant;Math.abs(t)<1e-8&&(t=1e-8),this.scale.set(.5*this.size,.5*this.size,t),this.children[0].material.side=t<0?1:0,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}},e.PointCloud=function(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new fo(e,t)},e.PointCloudMaterial=function(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new lo(e)},e.PointLight=Bl,e.PointLightHelper=class extends On{constructor(e,t,n){super(new hs(t,4,2),new Wt({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.light.updateMatrixWorld(),this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},e.Points=fo,e.PointsMaterial=lo,e.PolarGridHelper=class extends oo{constructor(e=10,t=16,n=8,i=64,r=4473924,a=8947848){r=new Vt(r),a=new Vt(a);const o=[],s=[];for(let c=0;c<=t;c++){const n=c/t*(2*Math.PI),i=Math.sin(n)*e,l=Math.cos(n)*e;o.push(0,0,0),o.push(i,0,l);const u=1&c?r:a;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let c=0;c<=n;c++){const t=1&c?r:a,l=e-e/n*c;for(let e=0;e90))return e;console.error("Latitude must be between -90 and 90")}else console.error("Coords must be an array")},Line:function(e){if(e.constructor===Array){for(const t of e)if(!this.Coords(t))return void console.error("Each coordinate in a line must be a valid Coords type");return e}console.error("Line must be an array")},Rotation:function(e){if(e.constructor===Number)e={z:e};else{if(e.constructor!==Object)return void console.error("Rotation must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Rotation parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual rotation values must be numbers")}}return e},Scale:function(e){if(e.constructor===Number)e={x:e,y:e,z:e};else{if(e.constructor!==Object)return void console.error("Scale must be an object or a number");for(const t of Object.keys(e)){if(!["x","y","z"].includes(t))return void console.error("Scale parameters must be x, y, or z");if(e[t].constructor!==Number)return void console.error("Individual scale values must be numbers")}}return e}},l=l=c;var u={},h={prettyPrintMatrix:function(e){for(var t=0;t<4;t++){var n=[e[t],e[t+4],e[t+8],e[t+12]];console.log(n.map((function(e){return e.toFixed(4)})))}},makePerspectiveMatrix:function(e,t,n,r){var a=new i.Matrix4,o=1/Math.tan(e/2),s=1/(n-r),l=[o/t,0,0,0,0,o,0,0,0,0,(r+n)*s,-1,0,0,2*r*n*s,0];return a.elements=l,a},makeOrthographicMatrix:function(e,t,n,r,a,o){var s=new i.Matrix4;const l=1/(t-e),c=1/(n-r),u=1/(o-a);var h=[2*l,0,0,0,0,2*c,0,0,0,0,-1*u,0,-(t+e)*l,-(n+r)*c,-a*u,1];return s.elements=h,s},radify:function(e){function t(e){return e=e||0,2*Math.PI*e/360}return"object"==typeof e?e.length>0?e.map((function(e){return t(e)})):[t(e.x),t(e.y),t(e.z)]:t(e)},degreeify:function(e){function t(e){return 360*(e=e||0)/(2*Math.PI)}return"object"==typeof e?[t(e.x),t(e.y),t(e.z)]:t(e)},projectToWorld:function(e){var t=[-r.MERCATOR_A*r.DEG2RAD*e[0]*r.PROJECTION_WORLD_SIZE,-r.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*r.DEG2RAD*e[1]))*r.PROJECTION_WORLD_SIZE];if(e[2]){var n=this.projectedUnitsPerMeter(e[1]);t.push(e[2]*n)}else t.push(0);return new i.Vector3(t[0],t[1],t[2])},projectedUnitsPerMeter:function(e){return Math.abs(r.WORLD_SIZE/Math.cos(r.DEG2RAD*e)/r.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(e){return r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180)},mercatorZfromAltitude:function(e,t){return e/this._circumferenceAtLatitude(t)},_scaleVerticesToMeters:function(e,t){for(var n=this.projectedUnitsPerMeter(e[1]),i=(this.projectToWorld(e),0);i{let{width:n,color:r}=t,a=(new i.BufferGeometry).setFromPoints(e.getPoints(100)),o=new i.LineBasicMaterial({color:r,linewidth:n});return new i.Line(a,o)},curvesToLines:e=>{var t=[16711680,2031360,2490623];return e.map((e,n)=>curveToLine(e,{width:3,color:t[n]||"purple"}))},_validate:function(e,t){e=e||{};var n={};h.extend(n,e);for(let i of Object.keys(t))if(void 0===e[i]){if(null===t[i])return void console.error(i+" is required");n[i]=t[i]}else n[i]=e[i];return n},Validator:new l,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};u=u=h;var d={};function p(e,t,n){this.map=e,this.camera=t,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=n||new i.Group,this.world.position.x=this.world.position.y=r.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new i.Matrix4).makeTranslation(r.WORLD_SIZE/2,-r.WORLD_SIZE/2,0),worldSizeRatio:r.TILE_SIZE/r.WORLD_SIZE,worldSize:r.TILE_SIZE*this.map.transform.scale};let a=this;this.map.on("move",(function(){a.updateCamera()})).on("resize",(function(){a.setupCamera()})),this.setupCamera()}p.prototype={setupCamera:function(){this.state.fov=this.map.transform._fov;const e=this.map.transform;this.camera.aspect=e.width/e.height,this.camera.updateProjectionMatrix(),this.halfFov=this.state.fov/2;const t={x:e.width/2,y:e.height/2},n=.5/Math.tan(this.halfFov)*e.height,r=e._maxPitch*Math.PI/180;this.acuteAngle=Math.PI/2-r,this.state.cameraToCenterDistance=n,this.state.offset=t,this.state.cameraTranslateZ=(new i.Matrix4).makeTranslation(0,0,this.state.cameraToCenterDistance),this.state.maxFurthestDistance=.95*this.state.cameraToCenterDistance*(Math.cos(this.acuteAngle)*Math.sin(this.halfFov)/Math.sin(Math.max(.01,Math.min(Math.PI-.01,this.acuteAngle-this.halfFov)))+1),this.updateCamera()},updateCamera:function(e){if(!this.camera)return void console.log("nocamera");const t=this.map.transform;let n=0,r=0;this.state.fov=t._fov,this.halfFov=this.state.fov/2;const a=Math.PI/2+t._pitch,o=Math.cos(Math.PI/2-t._pitch);if(this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*t.height,window.mapboxgl&&parseFloat(window.mapboxgl.version)>=2){const e=this.worldSize(t),i=(this.mercatorZfromAltitude(1,t.center.lat),this.fovAboveCenter(t)),s=0,l=(t._camera.position[2]*e-s)/Math.cos(t._pitch);r=o*(Math.sin(i)*l/Math.sin(u.clamp(Math.PI-a-i,.01,Math.PI-.01)))+l;const c=l*(1/t._horizonShift);n=Math.min(1.01*r,c)}else n=1.01*(r=o*(Math.sin(this.halfFov)*this.state.cameraToCenterDistance/Math.sin(Math.PI-a-this.halfFov))+this.state.cameraToCenterDistance);this.state.cameraTranslateZ=(new i.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const s=t.height/50,l=Math.max(s*o,s),c=t.height,h=t.width;this.camera instanceof i.OrthographicCamera?this.camera.projectionMatrix=u.makeOrthographicMatrix(h/-2,h/2,c/2,c/-2,l,n):this.camera.projectionMatrix=u.makePerspectiveMatrix(this.state.fov,h/c,l,n);let d=this.calcCameraMatrix(t._pitch,t.angle);this.camera.matrixWorld.copy(d);let f=t.scale*this.state.worldSizeRatio,m=new i.Matrix4,g=new i.Matrix4,v=new i.Matrix4;m.makeScale(f,f,f);let y=t.x||t.point.x,x=t.y||t.point.y;g.makeTranslation(-y,x,0),v.makeRotationZ(Math.PI),this.world.matrix=(new i.Matrix4).premultiply(v).premultiply(this.state.translateCenter).premultiply(m).premultiply(g),this.map.fire("CameraSynced",{detail:{nearZ:l,farZ:n,pitch:t._pitch,angle:t.angle,furthestDistance:r,maxFurthestDistance:this.state.maxFurthestDistance,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:p}})},worldSize:e=>e.tileSize*e.scale,fovAboveCenter:e=>e._fov*(.5+e.centerOffset.y/e.height),mercatorZfromAltitude(e,t){return e/this.circumferenceAtLatitude(t)},circumferenceAtLatitude:e=>r.EARTH_CIRCUMFERENCE*Math.cos(e*Math.PI/180),calcCameraMatrix(e,t,n){const r=this.map.transform,a=void 0===e?r._pitch:e,o=void 0===t?r.angle:t,s=void 0===n?this.state.cameraTranslateZ:n;return(new i.Matrix4).premultiply(s).premultiply((new i.Matrix4).makeRotationX(a)).premultiply((new i.Matrix4).makeRotationZ(o))}},d=d=p;var f={};!function(){"use strict";var e=Math.PI,t=Math.sin,n=Math.cos,i=Math.tan,r=Math.asin,a=Math.atan2,o=Math.acos,s=e/180;function l(e){return e.valueOf()/864e5-.5+2440588}function c(e){return new Date(864e5*(e+.5-2440588))}function u(e){return l(e)-2451545}var h=23.4397*s;function d(e,r){return a(t(e)*n(h)-i(r)*t(h),n(e))}function p(e,i){return r(t(i)*n(h)+n(i)*t(h)*t(e))}function m(e,r,o){return a(t(e),n(e)*t(r)-i(o)*n(r))}function g(e,i,a){return r(t(i)*t(a)+n(i)*n(a)*n(e))}function v(e,t){return s*(280.16+360.9856235*e)-t}function y(e){return s*(357.5291+.98560028*e)}function x(n){return n+s*(1.9148*t(n)+.02*t(2*n)+3e-4*t(3*n))+102.9372*s+e}function b(e){var t=x(y(e));return{dec:p(t,0),ra:d(t,0)}}var w={getPosition:function(e,t,n){var i=s*-n,r=s*t,a=u(e),o=b(a),l=v(a,i)-o.ra;return{azimuth:m(l,r,o.dec),altitude:g(l,r,o.dec)}},toJulian:function(e){return l(e)}},_=w.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];w.addTime=function(e,t,n){_.push([e,t,n])};function M(t,n,i){return 9e-4+(t+n)/(2*e)+i}function S(e,n,i){return 2451545+e+.0053*t(n)-.0069*t(2*i)}function T(e,i,r,a,s,l,c){return S(M(function(e,i,r){return o((t(e)-t(i)*t(r))/(n(i)*n(r)))}(e,r,a),i,s),l,c)}function E(e){var i=s*(134.963+13.064993*e),r=s*(93.272+13.22935*e),a=s*(218.316+13.176396*e)+6.289*s*t(i),o=5.128*s*t(r),l=385001-20905*n(i);return{ra:d(a,o),dec:p(a,o),dist:l}}function A(e,t){return new Date(e.valueOf()+864e5*t/24)}w.getTimes=function(t,n,i,r){var a,o,l,h,d,f=s*-i,m=s*n,g=function(e){return-2.076*Math.sqrt(e)/60}(r=r||0),v=function(t,n){return Math.round(t-9e-4-n/(2*e))}(u(t),f),b=M(0,f,v),w=y(b),E=x(w),A=p(E,0),L=S(b,w,E),R={solarNoon:c(L),nadir:c(L-.5)};for(a=0,o=_.length;a=0&&(g=d-(y=Math.sqrt(f)/(2*Math.abs(u))),v=d+y,Math.abs(g)<=1&&m++,Math.abs(v)<=1&&m++,g<-1&&(g=v)),1===m?b<0?l=_+g:c=_+g:2===m&&(l=_+(p<0?v:g),c=_+(p<0?g:v)),!l||!c);_+=2)b=o;var M={};return l&&(M.rise=A(r,l)),c&&(M.set=A(r,c)),l||c||(M[p>0?"alwaysUp":"alwaysDown"]=!0),M},f=f=w}();var g={},v={material:"MeshBasicMaterial",color:"black",opacity:1};g=g=function(e){var t;function n(){return new i[v.material]({color:v.color})}return e?((t=(e=u._validate(e,v)).material&&e.material.isMaterial?e.material:e.material||e.color||e.opacity?new i[e.material]({color:e.color,transparent:e.opacity<1}):n()).opacity=e.opacity,e.side&&(t.side=e.side)):t=n(),t};var y={};function x(e){this.map=e,this.enrolledObjects=[],this.previousFrameTime}x.prototype={unenroll:function(e){this.enrolledObjects.splice(this.enrolledObjects.indexOf(e),1)},enroll:function(e){if(e.clock=new i.Clock,e.hasDefaultAnimation=!1,e.defaultAction,e.actions=[],e.mixer,e.animations&&e.animations.length>0){e.hasDefaultAnimation=!0;let n=e.userData.defaultAnimation?e.userData.defaultAnimation:0;e.mixer=new i.AnimationMixer(e),t(n)}function t(t){for(let n=0;ne.animations.length&&console.log("The animation index "+t+" doesn't exist for this object");let i=e.animations[n],r=e.mixer.clipAction(i);e.actions.push(r),t===n?(e.defaultAction=r,r.setEffectiveWeight(1)):r.setEffectiveWeight(0),r.play()}}let n=!1;Object.defineProperty(e,"isPlaying",{get:()=>n,set(t){n!=t&&(n=t,e.dispatchEvent({type:"IsPlayingChanged",detail:e}))}}),this.enrolledObjects.push(e),e.animationQueue=[],e.set=function(t){if(t.duration>0){let n={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,n);let r=t.coords,a=t.rotation,o=t.scale||t.scaleX||t.scaleY||t.scaleZ;if(a){let n=e.rotation;t.startRotation=[n.x,n.y,n.z],t.endState.rotation=u.types.rotation(t.rotation,t.startRotation),t.rotationPerMs=t.endState.rotation.map((function(e,n){return(e-t.startRotation[n])/t.duration}))}if(o){let n=e.scale;t.startScale=[n.x,n.y,n.z],t.endState.scale=u.types.scale(t.scale,t.startScale),t.scalePerMs=t.endState.scale.map((function(e,n){return(e-t.startScale[n])/t.duration}))}r&&(t.pathCurve=new i.CatmullRomCurve3(u.lnglatsToWorld([e.coordinates,t.coords])));let s={type:"set",parameters:t};this.animationQueue.push(s),tb.map.repaint=!0}else this.stop(),t.rotation=u.radify(t.rotation),this._setObject(t);return this},e.animationMethod=null,e.stop=function(t){return e.mixer&&(e.isPlaying=!1,cancelAnimationFrame(e.animationMethod)),this.animationQueue=[],this},e.followPath=function(e,t){let n={type:"followPath",parameters:u._validate(e,b.followPath)};return u.extend(n.parameters,{pathCurve:new i.CatmullRomCurve3(u.lnglatsToWorld(e.path)),start:Date.now(),expiration:Date.now()+n.parameters.duration,cb:t}),this.animationQueue.push(n),tb.map.repaint=!0,this},e._setObject=function(t){e.setScale();let n=t.position,r=t.rotation,a=t.scale,o=t.worldCoordinates,s=t.quaternion,l=t.translate,c=t.worldTranslate;if(n){this.coordinates=n;let e=u.projectToWorld(n);this.position.copy(e)}if(l){this.coordinates=[this.coordinates[0]+l[0],this.coordinates[1]+l[1],this.coordinates[2]+l[2]];let e=u.projectToWorld(l);this.position.copy(e),t.position=this.coordinates}if(c){this.translateX(c.x),this.translateY(c.y),this.translateZ(c.z);let e=u.unprojectFromWorld(this.position);this.coordinates=t.position=e}if(r&&(this.rotation.set(r[0],r[1],r[2]),t.rotation=new i.Vector3(r[0],r[1],r[2])),a&&(this.scale.set(a[0],a[1],a[2]),t.scale=this.scale),s&&(this.quaternion.setFromAxisAngle(s[0],s[1]),t.rotation=s[0].multiplyScalar(s[1])),o){this.position.copy(o);let e=u.unprojectFromWorld(o);this.coordinates=t.position=e}this.setBoundingBoxShadowFloor(),this.setReceiveShadowFloor(),this.updateMatrixWorld(),tb.map.repaint=!0;let h={type:"ObjectChanged",detail:{object:this,action:{position:t.position,rotation:t.rotation,scale:t.scale}}};this.dispatchEvent(h)},e.playDefault=function(t){if(e.mixer&&e.hasDefaultAnimation){let n={start:Date.now(),expiration:Date.now()+t.duration,endState:{}};u.extend(t,n),e.mixer.timeScale=t.speed||1;let i={type:"playDefault",parameters:t};return this.animationQueue.push(i),tb.map.repaint=!0,this}},e.playAnimation=function(n){e.mixer&&(n.animation&&t(n.animation),e.playDefault(n))},e.pauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!0}))},e.unPauseAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.paused=!1}))},e.deactivateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.stop()}))},e.activateAllActions=function(){e.mixer&&e.actions.forEach((function(e){e.play()}))},e.idle=function(){return e.mixer&&e.mixer.update(.01),tb.map.repaint=!0,this}},update:function(e){if(void 0===this.previousFrameTime&&(this.previousFrameTime=e),!this.enrolledObjects)return!1;for(let t=this.enrolledObjects.length-1;t>=0;t--){let n=this.enrolledObjects[t];if(n.animationQueue&&0!==n.animationQueue.length)for(let t=n.animationQueue.length-1;t>=0;t--){let r=n.animationQueue[t];if(!r)continue;let a=r.parameters;if(!a.expiration)return n.animationQueue.splice(t,1),void(n.animationQueue[t]&&(n.animationQueue[t].parameters.start=e));if(e>=a.expiration)a.expiration=!1,"playDefault"===r.type?n.stop():(a.endState&&n._setObject(a.endState),void 0!==a.cb&&a.cb());else{let t=(e-a.start)/a.duration;if("set"===r.type){let e={};a.pathCurve&&(e.worldCoordinates=a.pathCurve.getPoint(t)),a.rotationPerMs&&(e.rotation=a.startRotation.map((function(e,n){return e+a.rotationPerMs[n]*t*a.duration}))),a.scalePerMs&&(e.scale=a.startScale.map((function(e,n){return e+a.scalePerMs[n]*t*a.duration}))),n._setObject(e)}if("followPath"===r.type){let e={worldCoordinates:a.pathCurve.getPointAt(t)};if(a.trackHeading){let n=a.pathCurve.getTangentAt(t).normalize(),r=new i.Vector3(0,0,0),o=new i.Vector3(0,1,0);r.crossVectors(o,n).normalize();let s=Math.acos(o.dot(n));e.quaternion=[r,s]}n._setObject(e)}"playDefault"===r.type&&(n.activateAllActions(),n.isPlaying=!0,n.animationMethod=requestAnimationFrame(this.update),n.mixer.update(n.clock.getDelta()),tb.map.repaint=!0)}}}this.previousFrameTime=e}};const b={followPath:{path:null,duration:1e3,trackHeading:!0}};y=y=x;var w={};i.CSS2DObject=function(e){i.Object3D.call(this),this.element=e||document.createElement("div"),this.element.style.position="absolute",this.alwaysVisible=!1,Object.defineProperty(this,"layer",{get(){return this.parent&&this.parent.parent?this.parent.parent.layer:null}}),this.dispose=function(){this.remove(),this.element=null},this.remove=function(){this.element instanceof Element&&null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element)},this.addEventListener("removed",(function(){this.remove()}))},i.CSS2DObject.prototype=Object.assign(Object.create(i.Object3D.prototype),{constructor:i.CSS2DObject,copy:function(e,t){return i.Object3D.prototype.copy.call(this,e,t),this.element=e.element.cloneNode(!0),this}}),i.CSS2DRenderer=function(){var e,t,n,r,a=this,o=new i.Vector3,s=new i.Matrix4,l=new i.Matrix4,c={objects:new WeakMap,list:new Map};this.cacheList=c.list;var u=document.createElement("div");u.style.overflow="hidden",this.domElement=u,this.getSize=function(){return{width:e,height:t}},this.setSize=function(i,a){n=(e=i)/2,r=(t=a)/2,u.style.width=i+"px",u.style.height=a+"px"},this.renderObject=function(e,t,s){if(e instanceof i.CSS2DObject)if(e.visible){e.onBeforeRender(a,t,s),o.setFromMatrixPosition(e.matrixWorld),o.applyMatrix4(l);var h=e.element,d="translate(-50%,-50%) translate("+(o.x*n+n)+"px,"+(-o.y*r+r)+"px)";h.style.WebkitTransform=d,h.style.MozTransform=d,h.style.oTransform=d,h.style.transform=d,h.style.display=e.visible&&o.z>=-1&&o.z<=1?"":"none";var f={distanceToCameraSquared:p(s,e)};c.objects.set({key:e.uuid},f),c.list.set(e.uuid,e),h.parentNode!==u&&u.appendChild(h),e.onAfterRender(a,t,s)}else c.objects.delete({key:e.uuid}),c.list.delete(e.uuid),e.remove();for(var m=0,g=e.children.length;me.getObjectByName("model")}),Object.defineProperty(e,"animations",{get(){const t=e.model;return t?t.animations:null}}),n.animationManager.enroll(e),e.setCoords=function(t){return e.userData.topMargin&&e.userData.feature&&(t[2]+=((e.userData.feature.properties.height||0)-(e.userData.feature.properties.base_height||e.userData.feature.properties.min_height||0))*(e.userData.topMargin||0)),e.coordinates=t,e.set({position:t}),e},e.setTranslate=function(t){return e.set({translate:t}),e},e.setRotation=function(t){"number"==typeof t&&(t={z:t});var n={x:u.radify(t.x)||e.rotation.x,y:u.radify(t.y)||e.rotation.y,z:u.radify(t.z)||e.rotation.z};e._setObject({rotation:[n.x,n.y,n.z]})},e.calculateAdjustedPosition=function(t,n,i){let r=t.slice(),a=u.unprojectFromWorld(e.modelSize);return i?(r[0]-=0!=n.x?a[0]/n.x:0,r[1]-=0!=n.y?a[1]/n.y:0,r[2]-=0!=n.z?a[2]/n.z:0):(r[0]+=0!=n.x?a[0]/n.x:0,r[1]+=0!=n.y?a[1]/n.y:0,r[2]+=0!=n.z?a[2]/n.z:0),r},e.setRotationAxis=function(t){"number"==typeof t&&(t={z:t});let n=e.modelBox(),r=new M.Vector3(n.max.x,n.max.y,n.min.z);0!=t.x&&i(e,r,new M.Vector3(0,0,1),t.x),0!=t.y&&i(e,r,new M.Vector3(0,0,1),t.y),0!=t.z&&i(e,r,new M.Vector3(0,0,1),t.z)},Object.defineProperty(e,"scaleGroup",{get:()=>e.getObjectByName("scaleGroup")}),Object.defineProperty(e,"boxGroup",{get:()=>e.getObjectByName("boxGroup")}),Object.defineProperty(e,"boundingBox",{get:()=>e.getObjectByName("boxModel")}),Object.defineProperty(e,"boundingBoxShadow",{get:()=>e.getObjectByName("boxShadow")}),e.drawBoundingBox=function(){let t=e.box3(),n=new M.Group;n.name="boxGroup",n.updateMatrixWorld(!0);let i=new M.Box3Helper(t,S.prototype._defaults.colors.yellow);i.name="boxModel",n.add(i),i.layers.disable(0);let r=t.clone();r.max.z=r.min.z;let a=new M.Box3Helper(r,S.prototype._defaults.colors.black);a.name="boxShadow",n.add(a),a.layers.disable(0),n.visible=!1,e.scaleGroup.add(n),e.setBoundingBoxShadowFloor()},e.setBoundingBoxShadowFloor=function(){if(e.boundingBoxShadow){let t=-e.modelHeight,n=e.rotation,i=e.boundingBoxShadow;i.box.max.z=i.box.min.z=t,i.rotation.y=n.y,i.rotation.x=-n.x}},e.setAnchor=function(t){const n=e.box3(),i=n.getCenter(new M.Vector3);switch(e.none={x:0,y:0,z:0},e.center={x:i.x,y:i.y,z:n.min.z},e.bottom={x:i.x,y:n.max.y,z:n.min.z},e.bottomLeft={x:n.max.x,y:n.max.y,z:n.min.z},e.bottomRight={x:n.min.x,y:n.max.y,z:n.min.z},e.top={x:i.x,y:n.min.y,z:n.min.z},e.topLeft={x:n.max.x,y:n.min.y,z:n.min.z},e.topRight={x:n.min.x,y:n.min.y,z:n.min.z},e.left={x:n.max.x,y:i.y,z:n.min.z},e.right={x:n.min.x,y:i.y,z:n.min.z},t){case"center":e.anchor=e.center;break;case"top":e.anchor=e.top;break;case"top-left":e.anchor=e.topLeft;break;case"top-right":e.anchor=e.topRight;break;case"left":e.anchor=e.left;break;case"right":e.anchor=e.right;break;case"bottom":e.anchor=e.bottom;break;case"bottom-left":default:e.anchor=e.bottomLeft;break;case"bottom-right":e.anchor=e.bottomRight;break;case"auto":case"none":e.anchor=e.none}e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)},e.setCenter=function(t){if(t&&(0!=t.x||0!=t.y||0!=t.z)){let n=e.getSize();e.anchor={x:e.anchor.x-n.x*t.x,y:e.anchor.y-n.y*t.y,z:e.anchor.z-n.z*t.z},e.model.position.set(-e.anchor.x,-e.anchor.y,-e.anchor.z)}},Object.defineProperty(e,"label",{get:()=>e.getObjectByName("label")}),Object.defineProperty(e,"tooltip",{get:()=>e.getObjectByName("tooltip")}),Object.defineProperty(e,"help",{get:()=>e.getObjectByName("help")}),Object.defineProperty(e,"visibility",{get:()=>e.visible,set(t){let n=t;if("visible"==t||1==t)n=!0,e.label&&(e.label.visible=n);else{if("none"!=t&&0!=t)return;n=!1,e.label&&e.label.alwaysVisible&&(e.label.visible=n),e.tooltip&&(e.tooltip.visible=n)}e.visible!=n&&(e.visible=n,e.model&&e.model.traverse((function(t){"Mesh"!=t.type&&"SkinnedMesh"!=t.type||(n&&e.raycasted?t.layers.enable(0):t.layers.disable(0)),"LineSegments"==t.type&&t.layers.disableAll()})))}}),e.addLabel=function(t,n,i,r){t&&e.drawLabelHTML(t,n,i,r)},e.removeLabel=function(){e.removeCSS2D("label")},e.drawLabelHTML=function(t,i=!1,r=e.anchor,a=.5){let o=n.drawLabelHTML(t,S.prototype._defaults.label.cssClass),s=e.addCSS2D(o,"label",r,a);return s.alwaysVisible=i,s.visible=i,s},e.addTooltip=function(t,n,i,r=!0,a=1){let o=e.addHelp(t,"tooltip",n,i,a);o.visible=!1,o.custom=r},e.removeTooltip=function(){e.removeCSS2D("tooltip")},e.addHelp=function(t,i="help",r=!1,a=e.anchor,o=0){let s=n.drawTooltip(t,r),l=e.addCSS2D(s,i,a,o);return l.visible=!0,l},e.removeHelp=function(){e.removeCSS2D("help")},e.addCSS2D=function(t,n,i=e.anchor,r=1){if(t){const a=e.box3(),o=a.getSize(new M.Vector3);let s={x:a.max.x,y:a.max.y,z:a.min.z};e.removeCSS2D(n);let l=new w.CSS2DObject(t);return l.name=n,l.position.set(.5*-o.x-e.model.position.x-i.x+s.x,.5*-o.y-e.model.position.y-i.y+s.y,o.z*r),l.visible=!1,e.scaleGroup.add(l),l}},e.removeCSS2D=function(t){let n=e.getObjectByName(t);if(n){n.dispose();let t=e.scaleGroup.children;t.splice(t.indexOf(n),1)}},Object.defineProperty(e,"shadowPlane",{get:()=>e.getObjectByName("shadowPlane")});let t=!1;Object.defineProperty(e,"castShadow",{get:()=>t,set(n){if(e.model&&t!==n){if(e.model.traverse((function(e){e.isMesh&&(e.castShadow=!0)})),n){const t=e.modelSize,i=[t.x,t.y,t.z,e.modelHeight],r=10*Math.max(...i),a=new M.PlaneBufferGeometry(r,r),o=new M.ShadowMaterial;o.opacity=.5;let s=new M.Mesh(a,o);s.name="shadowPlane",s.layers.enable(1),s.layers.disable(0),s.receiveShadow=n,e.add(s)}else e.traverse((function(t){t.isMesh&&t.material instanceof M.ShadowMaterial&&e.remove(t)}));t=n}}}),e.setReceiveShadowFloor=function(){if(e.castShadow){let t=e.shadowPlane,n=t.position,i=t.rotation;if(n.z=-e.modelHeight,i.y=e.rotation.y,i.x=-e.rotation.x,"meters"===e.userData.units){const i=e.modelSize,r=[i.x,i.y,i.z,-n.z],a=10*Math.max(...r)/t.geometry.parameters.width;t.scale.set(a,a,a)}}};let r=!1;Object.defineProperty(e,"receiveShadow",{get:()=>r,set(t){e.model&&r!==t&&(e.model.traverse((function(e){e.isMesh&&(e.receiveShadow=!0)})),r=t)}});let a=!1;Object.defineProperty(e,"wireframe",{get:()=>a,set(t){e.model&&a!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let n=[];Array.isArray(e.material)?n=e.material:n.push(e.material);let i=n[0];t?(e.userData.materials=i,e.material=i.clone(),e.material.wireframe=e.material.transparent=t,e.material.opacity=.3):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null),t?(e.layers.disable(0),e.layers.enable(1)):(e.layers.disable(1),e.layers.enable(0))}"LineSegments"==e.type&&e.layers.disableAll()})),a=t,e.dispatchEvent({type:"Wireframed",detail:e}))}});let o=null;Object.defineProperty(e,"color",{get:()=>o,set(t){e.model&&o!==t&&(e.model.traverse((function(e){if("Mesh"==e.type||"SkinnedMesh"==e.type){let n=[];Array.isArray(e.material)?n=e.material:n.push(e.material);let i=n[0];t?(e.userData.materials=i,e.material=new M.MeshStandardMaterial,e.material.color.setHex(t)):(e.material.dispose(),e.material=e.userData.materials,e.userData.materials.dispose(),e.userData.materials=null)}})),o=t)}});let s=!1;Object.defineProperty(e,"selected",{get:()=>s,set(t){t?(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.boxGroup&&(e.boundingBox.material=S.prototype._defaults.materials.boxSelectedMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1)),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0)):(e.boxGroup&&e.remove(e.boxGroup),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1),e.removeHelp()),e.tooltip&&(e.tooltip.visible=t),s!=t&&(s=t,e.dispatchEvent({type:"SelectedChange",detail:e}))}});let l=!0;Object.defineProperty(e,"raycasted",{get:()=>l,set(t){e.model&&l!==t&&(e.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(t?(e.layers.disable(1),e.layers.enable(0)):(e.layers.disable(0),e.layers.enable(1)))})),l=t)}});let c=!1;Object.defineProperty(e,"over",{get:()=>c,set(t){t?(e.selected||(e.userData.bbox&&!e.boundingBox&&e.drawBoundingBox(),e.userData.tooltip&&!e.tooltip&&e.addTooltip(e.uuid,!0,e.anchor,!1),e.boxGroup&&(e.boundingBox.material=S.prototype._defaults.materials.boxOverMaterial,e.boundingBox.parent.visible=!0,e.boundingBox.layers.enable(1),e.boundingBoxShadow.layers.enable(1))),e.label&&!e.label.alwaysVisible&&(e.label.visible=!0),e.dispatchEvent({type:"ObjectMouseOver",detail:e})):(e.selected||(e.boxGroup&&(e.remove(e.boxGroup),e.tooltip&&!e.tooltip.custom&&e.removeTooltip()),e.label&&!e.label.alwaysVisible&&(e.label.visible=!1)),e.dispatchEvent({type:"ObjectMouseOut",detail:e})),e.tooltip&&(e.tooltip.visible=t||e.selected),c=t}}),e.box3=function(){let t;if(e.updateMatrix(),e.updateMatrixWorld(!0,!0),e.model){let n=e.clone(!0),i=e.model.clone();if(t=(new M.Box3).setFromObject(i),e.parent){let r=new M.Matrix4,a=new M.Matrix4;e.matrix.extractRotation(r),a.copy(r).invert(),n.setRotationFromMatrix(a),t=(new M.Box3).setFromObject(i)}}return t},e.modelBox=function(){return e.box3()},e.getSize=function(){return e.box3().getSize(new M.Vector3(0,0,0))};let h=!1;Object.defineProperty(e,"modelSize",{get:()=>h=e.getSize(),set(e){h!=e&&(h=e)}}),Object.defineProperty(e,"modelHeight",{get(){let t=e.coordinates[2]||0;return"scene"===e.userData.units&&(t*=e.unitsPerMeter/e.scale.x),t}}),Object.defineProperty(e,"unitsPerMeter",{get:()=>Number(u.projectedUnitsPerMeter(e.coordinates[1]).toFixed(7))}),Object.defineProperty(e,"fixedZoom",{get:()=>e.userData.fixedZoom,set(t){e.userData.fixedZoom!==t&&(e.userData.fixedZoom=t,e.userData.units=t?"scene":"meters")}}),e.setFixedZoom=function(t){if(null!=e.fixedZoom){t||(t=e.userData.mapScale);let i=(n=e.fixedZoom,Math.pow(2,n));if(i>t){let n=i/t;e.scale.set(n,n,n)}else e.scale.set(1,1,1)}var n},e.setScale=function(t){if("meters"!==e.userData.units||e.fixedZoom)e.fixedZoom?(t&&(e.userData.mapScale=t),e.setFixedZoom(e.userData.mapScale)):e.scale.set(1,1,1);else{let t=e.unitsPerMeter;e.scale.set(t,t,t)}},e.setObjectScale=function(t){e.setScale(t),e.setBoundingBoxShadowFloor(),e.setReceiveShadowFloor()}}e.add=function(t){return e.scaleGroup.add(t),t.position.z=e.coordinates[2]?-e.coordinates[2]:0,t},e.remove=function(t){t&&(t.traverse(e=>{if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()}),e.scaleGroup.remove(t),tb.map.repaint=!0)},e.duplicate=function(t){let i=e.clone(!0);if(i.getObjectByName("model").animations=e.animations,i.userData.feature&&(t&&t.feature&&(i.userData.feature=t.feature),i.userData.feature.properties.uuid=i.uuid),n._addMethods(i),!t||u.equal(t.scale,e.userData.scale))return i.copyAnchor(e),i;{i.userData=t,i.userData.isGeoGroup=!0,i.remove(i.boxGroup);const e=u.types.rotation(t.rotation,[0,0,0]),n=u.types.scale(t.scale,[1,1,1]);return i.model.position.set(0,0,0),i.model.rotation.set(e[0],e[1],e[2]),i.model.scale.set(n[0],n[1],n[2]),i.setAnchor(t.anchor),i.setCenter(t.adjustment),i}},e.copyAnchor=function(t){e.anchor=t.anchor,e.none={x:0,y:0,z:0},e.center=t.center,e.bottom=t.bottom,e.bottomLeft=t.bottomLeft,e.bottomRight=t.bottomRight,e.top=t.top,e.topLeft=t.topLeft,e.topRight=t.topRight,e.left=t.left,e.right=t.right},e.dispose=function(){S.prototype.unenroll(e),e.traverse(e=>{if((!e.parent||"world"!=e.parent.name)&&"threeboxObject"!==e.name){if(e.geometry&&e.geometry.dispose(),e.material)if(e.material.isMaterial)r(e.material);else for(const t of e.material)r(t);e.dispose&&e.dispose()}}),e.children=[]};const r=e=>{e.dispose();for(const n of Object.keys(e)){const t=e[n];t&&"object"==typeof t&&"minFilter"in t&&t.dispose()}let t=e;(t.map||t.alphaMap||t.aoMap||t.bumpMap||t.displacementMap||t.emissiveMap||t.envMap||t.lightMap||t.metalnessMap||t.normalMap||t.roughnessMap)&&(t.map&&t.map.dispose(),t.alphaMap&&t.alphaMap.dispose(),t.aoMap&&t.aoMap.dispose(),t.bumpMap&&t.bumpMap.dispose(),t.displacementMap&&t.displacementMap.dispose(),t.emissiveMap&&t.emissiveMap.dispose(),t.envMap&&t.envMap.dispose(),t.lightMap&&t.lightMap.dispose(),t.metalnessMap&&t.metalnessMap.dispose(),t.normalMap&&t.normalMap.dispose(),t.roughnessMap&&t.roughnessMap.dispose())};return e},_makeGroup:function(e,t){let n=new M.Group;n.name="scaleGroup",n.add(e);var i=new M.Group;if(i.userData=t||{},i.userData.isGeoGroup=!0,i.userData.feature&&(i.userData.feature.properties.uuid=i.uuid),n.length)for(o of n)i.add(o);else i.add(n);return i.name="threeboxObject",i},animationManager:new y,drawTooltip:function(e,t=!1){if(e){let n;if(t){let t=document.createElement("div");t.className="mapboxgl-popup-content";let i=document.createElement("strong");i.innerHTML=e,t.appendChild(i);let r=document.createElement("div");r.className="mapboxgl-popup-tip";let a=document.createElement("div");a.className="marker mapboxgl-popup-anchor-bottom",a.appendChild(r),a.appendChild(t),(n=document.createElement("div")).className+="label3D",n.appendChild(a)}else(n=document.createElement("span")).className=this._defaults.tooltip.cssClass,n.innerHTML=e;return n}},drawLabelHTML:function(e,t){let n=document.createElement("div");return n.className+=t,n.innerHTML="string"==typeof e?e:e.outerHTML,n},_defaults:{colors:{red:new M.Color(16711680),yellow:new M.Color(16776960),green:new M.Color(65280),black:new M.Color(0)},materials:{boxNormalMaterial:new M.LineBasicMaterial({color:new M.Color(16711680)}),boxOverMaterial:new M.LineBasicMaterial({color:new M.Color(16776960)}),boxSelectedMaterial:new M.LineBasicMaterial({color:new M.Color(65280)})},line:{geometry:null,color:"black",width:1,opacity:1},label:{htmlElement:null,cssClass:" label3D",alwaysVisible:!1,topMargin:-.5},tooltip:{text:"",cssClass:"toolTip text-xs",mapboxStyle:!1,topMargin:0},sphere:{position:[0,0,0],radius:1,sides:20,units:"scene",material:"MeshBasicMaterial",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},tube:{geometry:null,radius:1,sides:6,units:"scene",material:"MeshBasicMaterial",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0},loadObj:{type:null,obj:null,units:"scene",scale:1,rotation:0,defaultAnimation:0,anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},Object3D:{obj:null,units:"scene",anchor:"bottom-left",bbox:!0,tooltip:!0,raycasted:!0},extrusion:{coordinates:[[[]]],geometryOptions:{},height:100,materials:null,scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},_=_=S;var T={};T=T=function(e){let t=(e=u._validate(e,_.prototype._defaults.Object3D)).obj;const n=u.types.rotation(e.rotation,[0,0,0]),i=u.types.scale(e.scale,[1,1,1]);t.rotation.set(n[0],n[1],n[2]),t.scale.set(i[0],i[1],i[2]),t.name="model";let r=_.prototype._makeGroup(t,e);return e.obj.name="model",_.prototype._addMethods(r),r.setAnchor(e.anchor),r.setCenter(e.adjustment),r.raycasted=e.raycasted,r.visibility=!0,r};var E={};E=E=function(e){e=u._validate(e,_.prototype._defaults.sphere);let t=new THREE.SphereBufferGeometry(e.radius,e.sides,e.sides),n=g(e),i=new THREE.Mesh(t,n);return new T({obj:i,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var A={};function L(e){e=u._validate(e,_.prototype._defaults.extrusion);let t=L.prototype.buildShape(e.coordinates),n=L.prototype.buildGeometry(t,e.geometryOptions),r=new i.Mesh(n,e.materials);return e.obj=r,new T(e)}L.prototype={buildShape:function(e){if(e[0]instanceof(i.Vector2||i.Vector3))return new i.Shape(e);let t=new i.Shape;for(let n=0;n0?t[t.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var n=this.materials.length-1;n>=0;n--)this.materials[n].groupCount<=0&&this.materials.splice(n,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},n&&n.name&&"function"==typeof n.clone){var i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseNormalIndex:function(e,t){var n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseUVIndex:function(e,t){var n=parseInt(e,10);return 2*(n>=0?n-1:n+t/2)},addVertex:function(e,t,n){var i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){var i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){var i=this.vertices,r=this.object.geometry.normals;o.fromArray(i,e),s.fromArray(i,t),l.fromArray(i,n),u.subVectors(l,s),c.subVectors(o,s),u.cross(c),u.normalize(),r.push(u.x,u.y,u.z),r.push(u.x,u.y,u.z),r.push(u.x,u.y,u.z)},addColor:function(e,t,n){var i=this.colors,r=this.object.geometry.colors;void 0!==i[e]&&r.push(i[e+0],i[e+1],i[e+2]),void 0!==i[t]&&r.push(i[t+0],i[t+1],i[t+2]),void 0!==i[n]&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){var i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){var e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){var t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,o,s,l){var c=this.vertices.length,u=this.parseVertexIndex(e,c),h=this.parseVertexIndex(t,c),d=this.parseVertexIndex(n,c);if(this.addVertex(u,h,d),this.addColor(u,h,d),void 0!==o&&""!==o){var p=this.normals.length;u=this.parseNormalIndex(o,p),h=this.parseNormalIndex(s,p),d=this.parseNormalIndex(l,p),this.addNormal(u,h,d)}else this.addFaceNormal(u,h,d);if(void 0!==i&&""!==i){var f=this.uvs.length;u=this.parseUVIndex(i,f),h=this.parseUVIndex(r,f),d=this.parseUVIndex(a,f),this.addUV(u,h,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";for(var t=this.vertices.length,n=0,i=e.length;n=7?o.colors.push(parseFloat(m[4]),parseFloat(m[5]),parseFloat(m[6])):o.colors.push(void 0,void 0,void 0);break;case"vn":o.normals.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3]));break;case"vt":o.uvs.push(parseFloat(m[1]),parseFloat(m[2]))}}else if("f"===c){for(var g=l.substr(1).trim().split(/\s+/),v=[],y=0,x=g.length;y0){var w=b.split("/");v.push(w)}}var _=v[0];for(y=1,x=v.length-1;y1){var D=u[1].trim().toLowerCase();o.object.smooth="0"!==D&&"off"!==D}else o.object.smooth=!0;(q=o.object.currentMaterial())&&(q.smooth=o.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}o.finalize();var O=new i.Group;if(O.materialLibraries=[].concat(o.materialLibraries),!0==!(1===o.objects.length&&0===o.objects[0].geometry.vertices.length))for(p=0,f=o.objects.length;p0&&J.setAttribute("normal",new i.Float32BufferAttribute(F.normals,3)),F.colors.length>0&&(U=!0,J.setAttribute("color",new i.Float32BufferAttribute(F.colors,3))),!0===F.hasUVIndices&&J.setAttribute("uv",new i.Float32BufferAttribute(F.uvs,2));for(var k,G=[],j=0,V=B.length;j1){for(j=0,V=B.length;j0){var J;q=new i.PointsMaterial({size:1,sizeAttenuation:!1}),(J=new i.BufferGeometry).setAttribute("position",new i.Float32BufferAttribute(o.vertices,3)),o.colors.length>0&&void 0!==o.colors[0]&&(J.setAttribute("color",new i.Float32BufferAttribute(o.colors,3)),q.vertexColors=!0);var K=new i.Points(J,q);O.add(K)}return O}}),d}(),P=P=i.OBJLoader;var I={};i.MTLLoader=function(e){i.Loader.call(this,e)},i.MTLLoader.prototype=Object.assign(Object.create(i.Loader.prototype),{constructor:i.MTLLoader,load:function(e,n,r,a){var o=this,s=""===this.path?i.LoaderUtils.extractUrlBase(e||""):this.path,l=new i.FileLoader(this.manager);l.setPath(this.path),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(i){try{n(o.parse(i,s))}catch(t){a?a(t):console.error(t),o.manager.itemError(e)}}),r,a)},setMaterialOptions:function(e){return this.materialOptions=e,this},parse:function(e,t){for(var n=e.split("\n"),r={},a=/\s+/,o={},s=0;s=0?l.substring(0,c):l;u=u.toLowerCase();var h=c>=0?l.substring(c+1):"";if(h=h.trim(),"newmtl"===u)r={name:h},o[h]=r;else if("ka"===u||"kd"===u||"ks"===u||"ke"===u){var d=h.split(a,3);r[u]=[parseFloat(d[0]),parseFloat(d[1]),parseFloat(d[2])]}else r[u]=h}}var p=new i.MTLLoader.MaterialCreator(this.resourcePath||t,this.materialOptions);return p.setCrossOrigin(this.crossOrigin),p.setManager(this.manager),p.setMaterials(o),p}}),i.MTLLoader.MaterialCreator=function(e,t){this.baseUrl=e||"",this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.side=this.options&&this.options.side?this.options.side:i.FrontSide,this.wrap=this.options&&this.options.wrap?this.options.wrap:i.RepeatWrapping},i.MTLLoader.MaterialCreator.prototype={constructor:i.MTLLoader.MaterialCreator,crossOrigin:"anonymous",setCrossOrigin:function(e){return this.crossOrigin=e,this},setManager:function(e){this.manager=e},setMaterials:function(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}},convert:function(e){if(!this.options)return e;var t={};for(var n in e){var i=e[n],r={};for(var a in t[n]=r,i){var o=!0,s=i[a],l=a.toLowerCase();switch(l){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(s=[s[0]/255,s[1]/255,s[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===s[0]&&0===s[1]&&0===s[2]&&(o=!1)}o&&(r[l]=s)}}return t},preload:function(){for(var e in this.materialsInfo)this.create(e)},getIndex:function(e){return this.nameLookup[e]},getAsArray:function(){var e=0;for(var t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray},create:function(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]},createMaterial_:function(e){var t=this,n=this.materialsInfo[e],r={name:e,side:this.side};function a(e,n){if(!r[e]){var i,a,o=t.getTextureParams(n,r),s=t.loadTexture((i=t.baseUrl,"string"!=typeof(a=o.url)||""===a?"":/^https?:\/\//i.test(a)?a:i+a));s.repeat.copy(o.scale),s.offset.copy(o.offset),s.wrapS=t.wrap,s.wrapT=t.wrap,r[e]=s}}for(var o in n){var s,l=n[o];if(""!==l)switch(o.toLowerCase()){case"kd":r.color=(new i.Color).fromArray(l);break;case"ks":r.specular=(new i.Color).fromArray(l);break;case"ke":r.emissive=(new i.Color).fromArray(l);break;case"map_kd":a("map",l);break;case"map_ks":a("specularMap",l);break;case"map_ke":a("emissiveMap",l);break;case"norm":a("normalMap",l);break;case"map_bump":case"bump":a("bumpMap",l);break;case"map_d":a("alphaMap",l),r.transparent=!0;break;case"ns":r.shininess=parseFloat(l);break;case"d":(s=parseFloat(l))<1&&(r.opacity=s,r.transparent=!0);break;case"tr":s=parseFloat(l),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(r.opacity=1-s,r.transparent=!0)}}return this.materials[e]=new i.MeshPhongMaterial(r),this.materials[e]},getTextureParams:function(e,t){var n,r={scale:new i.Vector2(1,1),offset:new i.Vector2(0,0)},a=e.split(/\s+/);return(n=a.indexOf("-bm"))>=0&&(t.bumpScale=parseFloat(a[n+1]),a.splice(n,2)),(n=a.indexOf("-s"))>=0&&(r.scale.set(parseFloat(a[n+1]),parseFloat(a[n+2])),a.splice(n,4)),(n=a.indexOf("-o"))>=0&&(r.offset.set(parseFloat(a[n+1]),parseFloat(a[n+2])),a.splice(n,4)),r.url=a.join(" ").trim(),r},loadTexture:function(e,t,n,r,a){var o,s=void 0!==this.manager?this.manager:i.DefaultLoadingManager,l=s.getHandler(e);return null===l&&(l=new i.TextureLoader(s)),l.setCrossOrigin&&l.setCrossOrigin(this.crossOrigin),o=l.load(e,n,r,a),void 0!==t&&(o.mapping=t),o}},I=I=i.MTLLoader;var D,O,N={},F=N={};function B(){throw new Error("setTimeout has not been defined")}function z(){throw new Error("clearTimeout has not been defined")}function H(e){if(D===setTimeout)return setTimeout(e,0);if((D===B||!D)&&setTimeout)return D=setTimeout,setTimeout(e,0);try{return D(e,0)}catch(t){try{return D.call(null,e,0)}catch(t){return D.call(this,e,0)}}}!function(){try{D="function"==typeof setTimeout?setTimeout:B}catch(t){D=B}try{O="function"==typeof clearTimeout?clearTimeout:z}catch(t){O=z}}();var U,k=[],G=!1,j=-1;function V(){G&&U&&(G=!1,U.length?k=U.concat(k):j=-1,k.length&&W())}function W(){if(!G){var e=H(V);G=!0;for(var n=k.length;n;){for(U=k,k=[];++j1)for(var n=1;n>>1|(21845&v)<<1;g[v]=((65280&(y=(61680&(y=(52428&y)>>>2|(13107&y)<<2))>>>4|(3855&y)<<4))>>>8|(255&y)<<8)>>>1}var x=function(e,t,n){for(var i=e.length,a=0,o=new r(t);a>>c]=u}else for(s=new r(i),a=0;a>>15-e[a]);return s},b=new i(288);for(v=0;v<144;++v)b[v]=8;for(v=144;v<256;++v)b[v]=9;for(v=256;v<280;++v)b[v]=7;for(v=280;v<288;++v)b[v]=8;var w=new i(32);for(v=0;v<32;++v)w[v]=5;var _=x(b,9,0),M=x(b,9,1),S=x(w,5,0),T=x(w,5,1),E=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},A=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},L=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},R=function(e){return(e/8|0)+(7&e&&1)},C=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var o=new(e instanceof r?r:e instanceof a?a:i)(n-t);return o.set(e.subarray(t,n)),o},P=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new i(0);var a=!t||n,c=!n||n.i;n||(n={}),t||(t=new i(3*r));var u=function(e){var n=t.length;if(e>n){var r=new i(Math.max(2*n,e));r.set(t),t=r}},d=n.f||0,p=n.p||0,m=n.b||0,g=n.l,v=n.d,y=n.m,b=n.n,w=8*r;do{if(!g){n.f=d=A(e,p,1);var _=A(e,p+1,3);if(p+=3,!_){var S=e[(k=R(p)+4)-4]|e[k-3]<<8,P=k+S;if(P>r){if(c)throw"unexpected EOF";break}a&&u(m+S),t.set(e.subarray(k,P),m),n.b=m+=S,n.p=p=8*P;continue}if(1==_)g=M,v=T,y=9,b=5;else{if(2!=_)throw"invalid block type";var I=A(e,p,31)+257,D=A(e,p+10,15)+4,O=I+A(e,p+5,31)+1;p+=14;for(var N=new i(O),F=new i(19),B=0;Bw)break;var U=x(F,z,1);for(B=0;B>>4)<16)N[B++]=k;else{var j=0,V=0;for(16==k?(V=3+A(e,p,3),p+=2,j=N[B-1]):17==k?(V=3+A(e,p,7),p+=3):18==k&&(V=11+A(e,p,127),p+=7);V--;)N[B++]=j}}var W=N.subarray(0,I),q=N.subarray(I);y=E(W),b=E(q),g=x(W,y,1),v=x(q,b,1)}if(p>w)throw"unexpected EOF"}a&&u(m+131072);for(var X=(1<>>4;if((p+=15&j)>w)throw"unexpected EOF";if(!j)throw"invalid length/literal";if(J<256)t[m++]=J;else{if(256==J){g=null;break}var K=J-254;J>264&&(K=A(e,p,(1<<(ee=o[B=J-257]))-1)+h[B],p+=ee);var Q=v[L(e,p)&Z],$=Q>>>4;if(!Q)throw"invalid distance";if(p+=15&Q,q=f[$],$>3){var ee=s[$];q+=L(e,p)&(1<w)throw"unexpected EOF";a&&u(m+131072);for(var te=m+K;m>>8},D=function(e,t,n){var i=t/8|0;e[i]|=n<<=7&t,e[i+1]|=n>>>8,e[i+2]|=n>>>16},O=function(e,t){for(var n=[],a=0;af&&(f=s[a].s);var m=new r(f+1),g=N(n[d-1],m,0);if(g>t){a=0;var v=0,y=g-t,x=1<t))break;v+=x-(1<>>=y;v>0;){var w=s[a].s;m[w]=0&&v;--a){var _=s[a].s;m[_]==t&&(--m[_],++v)}g=t}return[new i(m),g]},N=function(e,t,n){return-1==e.s?Math.max(N(e.l,t,n+1),N(e.r,t,n+1)):t[e.s]=n},F=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new r(++t),i=0,a=e[0],o=1,s=function(e){n[i++]=e},l=1;l<=t;++l)if(e[l]==a&&l!=t)++o;else{if(!a&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(a),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(a);o=1,a=e[l]}return[n.subarray(0,i),t]},B=function(e,t){for(var n=0,i=0;i>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var a=0;a4&&!k[l[j-1]];--j);var V,W,q,X,Z=p+5<<3,Y=B(a,b)+B(c,w)+u,J=B(a,g)+B(c,M)+u+14+3*j+B(N,k)+(2*N[16]+3*N[17]+7*N[18]);if(Z<=Y&&Z<=J)return z(t,f,e.subarray(d,d+p));if(I(t,f,1+(J15&&(I(t,f,ee[H]>>>5&127),f+=ee[H]>>>12)}}else V=_,W=b,q=S,X=w;for(H=0;H255){var te;D(t,f,V[257+(te=i[H]>>>18&31)]),f+=W[te+257],te>7&&(I(t,f,i[H]>>>23&31),f+=o[te]);var ne=31&i[H];D(t,f,q[ne]),f+=X[ne],ne>3&&(D(t,f,i[H]>>>5&8191),f+=s[ne])}else D(t,f,V[i[H]]),f+=W[i[H]];return D(t,f,V[256]),f+W[256]},U=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),k=new i(0),G=function(e,t,n,l,c,u){var h=e.length,p=new i(l+h+5*(1+Math.ceil(h/7e3))+c),f=p.subarray(l,p.length-c),g=0;if(!t||h<8)for(var v=0;v<=h;v+=65535){var y=v+65535;y>>13,w=8191&x,_=(1<7e3||N>24576)&&W>423){g=H(e,f,0,L,P,I,O,N,B,v-B,g),N=D=O=0,B=v;for(var q=0;q<286;++q)P[q]=0;for(q=0;q<30;++q)I[q]=0}var X=2,Z=0,Y=w,J=j-V&32767;if(W>2&&G==A(v-J))for(var K=Math.min(b,W)-1,Q=Math.min(32767,v),$=Math.min(258,W);J<=Q&&--Y&&j!=V;){if(e[v+X]==e[v+X-J]){for(var ee=0;ee<$&&e[v+ee]==e[v+ee-J];++ee);if(ee>X){if(X=ee,Z=J,ee>K)break;var te=Math.min(J,ee-2),ne=0;for(q=0;qne&&(ne=re,V=ie)}}}J+=(j=V)-(V=M[j])+32768&32767}if(Z){L[N++]=268435456|d[X]<<18|m[Z];var ae=31&d[X],oe=31&m[Z];O+=o[ae]+s[oe],++P[257+ae],++I[oe],F=v+X,++D}else L[N++]=e[v],++P[e[v]]}}g=H(e,f,u,L,P,I,O,N,B,v-B,g),!u&&7&g&&(g=z(f,g+1,k))}return C(p,0,l+R(g)+c)},j=function(){for(var e=new a(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),V=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i>>8;e=n},d:function(){return~e}}},W=function(){var e=1,t=0;return{p:function(n){for(var i=e,r=t,a=n.length,o=0;o!=a;){for(var s=Math.min(o+2655,a);o>16),r=(65535&r)+15*(r>>16)}e=i,t=r},d:function(){return((e%=65521)>>>8<<16|(255&(t%=65521))<<8|t>>>8)+2*((255&e)<<23)}}},q=function(e,t,n,i,r){return G(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,i,!r)},X=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},Y=function(e,t,n){for(var i=e(),r=""+e,a=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o>>=8},fe=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&pe(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var i=0;i<=n.length;++i)e[i+10]=n.charCodeAt(i)}},me=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var i=(t>>3&1)+(t>>4&1);i>0;i-=!e[n++]);return n+(2&t)},ge=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16)+2*(e[t-1]<<23)},ve=function(e){return 10+(e.filename&&e.filename.length+1||0)},ye=function(e,t){var n=t.level,i=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=i<<6|(i?32-2*i:1)},xe=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function be(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var we=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(q(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}();t.Deflate=we;var _e=function(e,t){ce([ee,function(){return[le,we]}],this,be.call(this,e,t),(function(e){var t=new we(e.data);onmessage=le(t)}),6)};function Me(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[ee],(function(e){return ae(Se(e.data[0],e.data[1]))}),0,n)}function Se(e,t){return q(e,t||{},0,0)}t.AsyncDeflate=_e,t.deflate=Me,t.deflateSync=Se;var Te=function(){function e(e){this.s={},this.p=new i(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new i(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=P(this.p,this.o,this.s);this.ondata(C(n,t,this.s.b),this.d),this.o=C(n,this.s.b-32768),this.s.b=this.o.length,this.p=C(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}();t.Inflate=Te;var Ee=function(e){this.ondata=e,ce([$,function(){return[le,Te]}],this,0,(function(){var e=new Te;onmessage=le(e)}),7)};function Ae(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[$],(function(e){return ae(Le(e.data[0],oe(e.data[1])))}),1,n)}function Le(e,t){return P(e,t)}t.AsyncInflate=Ee,t.inflate=Ae,t.inflateSync=Le;var Re=function(){function e(e,t){this.c=V(),this.l=0,this.v=1,we.call(this,e,t)}return e.prototype.push=function(e,t){we.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=q(e,this.o,this.v&&ve(this.o),t&&8,!t);this.v&&(fe(n,this.o),this.v=0),t&&(pe(n,n.length-8,this.c.d()),pe(n,n.length-4,this.l)),this.ondata(n,t)},e}();t.Gzip=Re,t.Compress=Re;var Ce=function(e,t){ce([ee,te,function(){return[le,we,Re]}],this,be.call(this,e,t),(function(e){var t=new Re(e.data);onmessage=le(t)}),8)};function Pe(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[ee,te,function(){return[Ie]}],(function(e){return ae(Ie(e.data[0],e.data[1]))}),2,n)}function Ie(e,t){t||(t={});var n=V(),i=e.length;n.p(e);var r=q(e,t,ve(t),8),a=r.length;return fe(r,t),pe(r,a-8,n.d()),pe(r,a-4,i),r}t.AsyncGzip=Ce,t.AsyncCompress=Ce,t.gzip=Pe,t.compress=Pe,t.gzipSync=Ie,t.compressSync=Ie;var De=function(){function e(e){this.v=1,Te.call(this,e)}return e.prototype.push=function(e,t){if(Te.prototype.e.call(this,e),this.v){var n=this.p.length>3?me(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Te.prototype.c.call(this,t)},e}();t.Gunzip=De;var Oe=function(e){this.ondata=e,ce([$,ne,function(){return[le,Te,De]}],this,0,(function(){var e=new De;onmessage=le(e)}),9)};function Ne(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[$,ne,function(){return[Fe]}],(function(e){return ae(Fe(e.data[0]))}),3,n)}function Fe(e,t){return P(e.subarray(me(e),-8),t||new i(ge(e)))}t.AsyncGunzip=Oe,t.gunzip=Ne,t.gunzipSync=Fe;var Be=function(){function e(e,t){this.c=W(),this.v=1,we.call(this,e,t)}return e.prototype.push=function(e,t){we.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=q(e,this.o,this.v&&2,t&&4,!t);this.v&&(ye(n,this.o),this.v=0),t&&pe(n,n.length-4,this.c.d()),this.ondata(n,t)},e}();t.Zlib=Be;function ze(e,t){t||(t={});var n=W();n.p(e);var i=q(e,t,2,4);return ye(i,t),pe(i,i.length-4,n.d()),i}t.AsyncZlib=function(e,t){ce([ee,ie,function(){return[le,we,Be]}],this,be.call(this,e,t),(function(e){var t=new Be(e.data);onmessage=le(t)}),10)},t.zlib=function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[ee,ie,function(){return[ze]}],(function(e){return ae(ze(e.data[0],e.data[1]))}),4,n)},t.zlibSync=ze;var He=function(){function e(e){this.v=1,Te.call(this,e)}return e.prototype.push=function(e,t){if(Te.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}Te.prototype.c.call(this,t)},e}();t.Unzlib=He;var Ue=function(e){this.ondata=e,ce([$,re,function(){return[le,Te,He]}],this,0,(function(){var e=new He;onmessage=le(e)}),11)};function ke(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return se(e,t,[$,re,function(){return[Ge]}],(function(e){return ae(Ge(e.data[0],oe(e.data[1])))}),5,n)}function Ge(e,t){return P((xe(e),e.subarray(2,-4)),t)}t.AsyncUnzlib=Ue,t.unzlib=ke,t.unzlibSync=Ge;var je=function(){function e(e){this.G=De,this.I=Te,this.Z=He,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new i(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var r=this,a=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(a):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(a):new this.Z(a),this.s.push(this.p,t),this.p=null}}},e}();t.Decompress=je;var Ve=function(){function e(e){this.G=Oe,this.I=Ee,this.Z=Ue,this.ondata=e}return e.prototype.push=function(e,t){je.prototype.push.call(this,e,t)},e}();t.AsyncDecompress=Ve,t.decompress=function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?Ne(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Ae(e,t,n):ke(e,t,n)},t.decompressSync=function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Fe(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Le(e,t):Ge(e,t)};var We=function(e,t,n,r){for(var a in e){var o=e[a],s=t+a;o instanceof i?n[s]=[o,r]:Array.isArray(o)?n[s]=[o[0],X(r,o[1])]:We(o,s+"/",n,r)}},qe="undefined"!=typeof TextEncoder&&new TextEncoder,Xe="undefined"!=typeof TextDecoder&&new TextDecoder,Ze=0;try{Xe.decode(k,{stream:!0}),Ze=1}catch(n){}var Ye=function(e){for(var t="",n=0;;){var i=e[n++],r=(i>127)+(i>223)+(i>239);if(n+r>e.length)return[t,C(e,n-1)];r?3==r?(i=((15&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|i>>10,56320|1023&i)):t+=String.fromCharCode(1&r?(31&i)<<6|63&e[n++]:(15&i)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(i)}},Je=function(){function e(e){this.ondata=e,Ze?this.t=new TextDecoder:this.p=k}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t||(t=!1),this.t)return this.ondata(this.t.decode(e,{stream:!t}),t);var n=new i(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var r=Ye(n),a=r[0],o=r[1];if(t&&o.length)throw"invalid utf-8 data";this.p=o,this.ondata(a,t)},e}();t.DecodeUTF8=Je;var Ke=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";this.ondata(Qe(e),t||!1)},e}();function Qe(e,t){if(t){for(var n=new i(e.length),r=0;r>1)),s=0,l=function(e){o[s++]=e};for(r=0;ro.length){var c=new i(s+8+(a-r<<1));c.set(o),o=c}var u=e.charCodeAt(r);u<128||t?l(u):u<2048?(l(192|u>>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&e.charCodeAt(++r))>>>18),l(128|u>>>12&63),l(128|u>>>6&63),l(128|63&u)):(l(224|u>>>12),l(128|u>>>6&63),l(128|63&u))}return C(o,0,s)}function $e(e,t){if(t){for(var n="",i=0;i65535)throw"extra field too long";t+=i+4}return t},at=function(e,t,n,i,r,a,o,s){var l=i.length,c=n.extra,u=s&&s.length,h=rt(c);pe(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==a&&8),e[t++]=r&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(pe(e,t,2*(p<<24)|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),t+=4,null!=a&&(pe(e,t,n.crc),pe(e,t+4,a),pe(e,t+8,n.size)),pe(e,t+12,l),pe(e,t+14,h),t+=16,null!=o&&(pe(e,t,u),pe(e,t+6,n.attrs),pe(e,t+10,o),t+=14),e.set(i,t),t+=l,h)for(var f in c){var m=c[f],g=m.length;pe(e,t,+f),pe(e,t+2,g),e.set(m,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},ot=function(e,t,n,i,r){pe(e,t,101010256),pe(e,t+8,n),pe(e,t+10,n),pe(e,t+12,i),pe(e,t+16,r)},st=function(){function e(e){this.filename=e,this.c=V(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();t.ZipPassThrough=st;var lt=function(){function e(e,t){var n=this;t||(t={}),st.call(this,e),this.d=new we(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=et(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){st.prototype.push.call(this,e,t)},e}();t.ZipDeflate=lt;var ct=function(){function e(e,t){var n=this;t||(t={}),st.call(this,e),this.d=new _e(t,(function(e,t,i){n.ondata(e,t,i)})),this.compression=8,this.flag=et(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){st.prototype.push.call(this,e,t)},e}();t.AsyncZipDeflate=ct;var ut=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=Qe(e.filename),r=n.length,a=e.comment,o=a&&Qe(a),s=r!=e.filename.length||o&&a.length!=o.length,l=r+rt(e.extra)+30;if(r>65535)throw"filename too long";var c=new i(l);at(c,0,e,n,s);var u=[c],h=function(){for(var e=0,n=u;e65535&&S("filename too long",null),M)if(g<16e4)try{S(null,Se(c,f))}catch(e){S(e,null)}else h.push(Me(c,f,S));else S(null,c)},m=0;m65535)throw"filename too long";var v=h?Se(c,u):c,y=v.length,x=V();x.p(c),r.push(X(u,{size:c.length,crc:x.d(),c:v,f:S,m:f,u:d!=s.length||f&&p.length!=m,o:a,compression:h})),a+=30+d+g+y,o+=76+2*(d+g)+(m||0)+y}for(var b=new i(o+22),w=a,_=o-a,M=0;M0){var r=Math.min(this.c,e.length),a=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(a,!this.c):this.k[0].push(a),(e=e.subarray(r)).length)return this.push(e,t)}else{var o=0,s=0,l=void 0,c=void 0;this.p.length?e.length?((c=new i(this.p.length+e.length)).set(this.p),c.set(e,this.p.length)):c=this.p:c=e;for(var u=c.length,h=this.c,d=h&&this.d,p=function(){var e,t=he(c,s);if(67324752==t){o=1,l=s,f.d=null,f.c=0;var i=ue(c,s+6),r=ue(c,s+8),a=2048&i,d=8&i,p=ue(c,s+26),m=ue(c,s+28);if(u>s+30+p+m){var g=[];f.k.unshift(g),o=2;var v=he(c,s+18),y=he(c,s+22),x=$e(c.subarray(s+30,s+=30+p),!a);4294967295==v?(e=d?[-2]:it(c,s),v=e[0],y=e[1]):d&&(v=-1),s+=m,f.c=v;var b={name:x,compression:r,start:function(){if(!b.ondata)throw"no callback";if(v){var e=n.o[r];if(!e)throw"unknown compression type "+r;var t=v<0?new e(x):new e(x,v,y);t.ondata=function(e,t,n){b.ondata(e,t,n)};for(var i=0,a=g;i=0&&(b.size=v,b.originalSize=y),f.onfile(b)}return"break"}if(h){if(134695760==t)return l=s+=12+(-2==h&&8),o=2,f.c=0,"break";if(33639248==t)return l=s-=4,o=2,f.c=0,"break"}},f=this;s65558)return void t("invalid zip file",null);var s=ue(e,o+8);s||t(null,{});var l=s,c=he(e,o+16),u=4294967295==c;if(u){if(o=he(e,o-12),101075792!=he(e,o))return void t("invalid zip file",null);l=s=he(e,o+32),c=he(e,o+48)}for(var h=function(o){var l=nt(e,c,u),h=l[0],d=l[1],p=l[2],f=l[3],m=l[4],g=tt(e,l[5]);c=m;var v=function(e,n){e?(r(),t(e,null)):(a[f]=n,--s||t(null,a))};if(h)if(8==h){var y=e.subarray(g,g+d);if(d<32e4)try{v(null,Le(y,new i(p)))}catch(e){v(e,null)}else n.push(Ae(y,{size:p},v))}else v("unknown compression type "+h,null);else v(null,C(e,g,g+d))},d=0;d65558)throw"invalid zip file";var r=ue(e,n+8);if(!r)return{};var a=he(e,n+16),o=4294967295==a;if(o){if(n=he(e,n-12),101075792!=he(e,n))throw"invalid zip file";r=he(e,n+32),a=he(e,n+48)}for(var s=0;s=s.length&&s===_(a,0,s.length))e=(new u).parse(t);else{var r=_(t);if(!function(e){var t,n,i=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],r=0;for(var a=0;a0,s="string"==typeof a.Content&&""!==a.Content;if(o||s){var l=this.parseImage(i[r]);n[a.RelativeFilename||a.Filename]=l}}}}for(var c in t){var u=t[c];void 0!==n[u]?t[c]=n[u]:t[c]=t[c].split("\\").pop()}return t},parseImage:function(e){var t,n=e.Content,i=e.RelativeFilename||e.Filename,r=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(r){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof n)return"data:"+t+";base64,"+n;var a=new Uint8Array(n);return window.URL.createObjectURL(new Blob([a],{type:t}))},parseTextures:function(t){var n=new Map;if("Texture"in e.Objects){var i=e.Objects.Texture;for(var r in i){var a=this.parseTexture(i[r],t);n.set(parseInt(r),a)}}return n},parseTexture:function(e,t){var n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;var r=e.WrapModeU,a=e.WrapModeV,o=void 0!==r?r.value:0,s=void 0!==a?a.value:0;if(n.wrapS=0===o?i.RepeatWrapping:i.ClampToEdgeWrapping,n.wrapT=0===s?i.RepeatWrapping:i.ClampToEdgeWrapping,"Scaling"in e){var l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}return n},loadTexture:function(e,t){var r,a,o=this.textureLoader.path,s=n.get(e.id).children;void 0!==s&&s.length>0&&void 0!==t[s[0].ID]&&(0!==(r=t[s[0].ID]).indexOf("blob:")&&0!==r.indexOf("data:")||this.textureLoader.setPath(void 0));var l=e.FileName.slice(-3).toLowerCase();if("tga"===l){var c=this.manager.getHandler(".tga");null===c?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new i.Texture):a=c.load(r)}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new i.Texture):a=this.textureLoader.load(r);return this.textureLoader.setPath(o),a},parseMaterials:function(t){var n=new Map;if("Material"in e.Objects){var i=e.Objects.Material;for(var r in i){var a=this.parseMaterial(i[r],t);null!==a&&n.set(parseInt(r),a)}}return n},parseMaterial:function(e,t){var r=e.id,a=e.attrName,o=e.ShadingModel;if("object"==typeof o&&(o=o.value),!n.has(r))return null;var s,l=this.parseParameters(e,t,r);switch(o.toLowerCase()){case"phong":s=new i.MeshPhongMaterial;break;case"lambert":s=new i.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),s=new i.MeshPhongMaterial}return s.setValues(l),s.name=a,s},parseParameters:function(e,t,r){var a={};e.BumpFactor&&(a.bumpScale=e.BumpFactor.value),e.Diffuse?a.color=(new i.Color).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(a.color=(new i.Color).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(a.displacementScale=e.DisplacementFactor.value),e.Emissive?a.emissive=(new i.Color).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(a.emissive=(new i.Color).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(a.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(a.opacity=parseFloat(e.Opacity.value)),a.opacity<1&&(a.transparent=!0),e.ReflectionFactor&&(a.reflectivity=e.ReflectionFactor.value),e.Shininess&&(a.shininess=e.Shininess.value),e.Specular?a.specular=(new i.Color).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(a.specular=(new i.Color).fromArray(e.SpecularColor.value));var o=this;return n.get(r).children.forEach((function(e){var n=e.relationship;switch(n){case"Bump":a.bumpMap=o.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":a.aoMap=o.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":a.map=o.getTexture(t,e.ID),a.map.encoding=i.sRGBEncoding;break;case"DisplacementColor":a.displacementMap=o.getTexture(t,e.ID);break;case"EmissiveColor":a.emissiveMap=o.getTexture(t,e.ID),a.emissiveMap.encoding=i.sRGBEncoding;break;case"NormalMap":case"Maya|TEX_normal_map":a.normalMap=o.getTexture(t,e.ID);break;case"ReflectionColor":a.envMap=o.getTexture(t,e.ID),a.envMap.mapping=i.EquirectangularReflectionMapping,a.envMap.encoding=i.sRGBEncoding;break;case"SpecularColor":a.specularMap=o.getTexture(t,e.ID),a.specularMap.encoding=i.sRGBEncoding;break;case"TransparentColor":case"TransparencyFactor":a.alphaMap=o.getTexture(t,e.ID),a.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),a},getTexture:function(t,i){return"LayeredTexture"in e.Objects&&i in e.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),i=n.get(i).children[0].ID),t.get(i)},parseDeformers:function(){var t={},i={};if("Deformer"in e.Objects){var r=e.Objects.Deformer;for(var a in r){var o=r[a],s=n.get(parseInt(a));if("Skin"===o.attrType){var l=this.parseSkeleton(s,r);l.ID=a,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),l.geometryID=s.parents[0].ID,t[a]=l}else if("BlendShape"===o.attrType){var c={id:a};c.rawTargets=this.parseMorphTargets(s,r),c.id=a,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),i[a]=c}}}return{skeletons:t,morphTargets:i}},parseSkeleton:function(e,t){var n=[];return e.children.forEach((function(e){var r=t[e.ID];if("Cluster"===r.attrType){var a={ID:e.ID,indices:[],weights:[],transformLink:(new i.Matrix4).fromArray(r.TransformLink.a)};"Indexes"in r&&(a.indices=r.Indexes.a,a.weights=r.Weights.a),n.push(a)}})),{rawBones:n,bones:[]}},parseMorphTargets:function(e,t){for(var i=[],r=0;r1?o=s:s.length>0?o=s[0]:(o=new i.MeshPhongMaterial({color:13421772}),s.push(o)),"color"in a.attributes&&s.forEach((function(e){e.vertexColors=!0})),a.FBX_Deformer?(s.forEach((function(e){e.skinning=!0})),(r=new i.SkinnedMesh(a,o)).normalizeSkinWeights()):r=new i.Mesh(a,o),r},createCurve:function(e,t){var n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),r=new i.LineBasicMaterial({color:3342591,linewidth:1});return new i.Line(n,r)},getTransformData:function(e,t){var n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?b(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n},setLookAtProperties:function(t,a){"LookAtProperty"in a&&n.get(t.ID).children.forEach((function(n){if("LookAtProperty"===n.relationship){var a=e.Objects.Model[n.ID];if("Lcl_Translation"in a){var o=a.Lcl_Translation.value;void 0!==t.target?(t.target.position.fromArray(o),r.add(t.target)):t.lookAt((new i.Vector3).fromArray(o))}}}))},bindSkeleton:function(e,t,r){var a=this.parsePoseNodes();for(var o in e){var s=e[o];n.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){var o=e.ID;n.get(o).parents.forEach((function(e){r.has(e.ID)&&r.get(e.ID).bind(new i.Skeleton(s.bones),a[e.ID])}))}}))}},parsePoseNodes:function(){var t={};if("Pose"in e.Objects){var n=e.Objects.Pose;for(var r in n)if("BindPose"===n[r].attrType){var a=n[r].PoseNode;Array.isArray(a)?a.forEach((function(e){t[e.Node]=(new i.Matrix4).fromArray(e.Matrix.a)})):t[a.Node]=(new i.Matrix4).fromArray(a.Matrix.a)}}return t},createAmbientLight:function(){if("GlobalSettings"in e&&"AmbientColor"in e.GlobalSettings){var t=e.GlobalSettings.AmbientColor.value,n=t[0],a=t[1],o=t[2];if(0!==n||0!==a||0!==o){var s=new i.Color(n,a,o);r.add(new i.AmbientLight(s,1))}}},setupMorphMaterials:function(){var e=this;r.traverse((function(t){t.isMesh&&t.geometry.morphAttributes.position&&t.geometry.morphAttributes.position.length&&(Array.isArray(t.material)?t.material.forEach((function(n,i){e.setupMorphMaterial(t,n,i)})):e.setupMorphMaterial(t,t.material))}))},setupMorphMaterial:function(e,t,n){var i=e.uuid,a=t.uuid,o=!1;if(r.traverse((function(e){e.isMesh&&(Array.isArray(e.material)?e.material.forEach((function(t){t.uuid===a&&e.uuid!==i&&(o=!0)})):e.material.uuid===a&&e.uuid!==i&&(o=!0))})),!0===o){var s=t.clone();s.morphTargets=!0,void 0===n?e.material=s:e.material[n]=s}else t.morphTargets=!0}},s.prototype={constructor:s,parse:function(t){var i=new Map;if("Geometry"in e.Objects){var r=e.Objects.Geometry;for(var a in r){var o=n.get(parseInt(a)),s=this.parseGeometry(o,r[a],t);i.set(parseInt(a),s)}}return i},parseGeometry:function(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}},parseMeshGeometry:function(t,n,i){var r=i.skeletons,a=[],o=t.parents.map((function(t){return e.Objects.Model[t.ID]}));if(0!==o.length){var s=t.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);t.children.forEach((function(e){void 0!==i.morphTargets[e.ID]&&a.push(i.morphTargets[e.ID])}));var l=o[0],c={};"RotationOrder"in l&&(c.eulerOrder=b(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);var u=x(c);return this.genGeometry(n,s,a,u)}},genGeometry:function(e,t,n,r){var a=new i.BufferGeometry;e.attrName&&(a.name=e.attrName);var o=this.parseGeoNode(e,t),s=this.genBuffers(o),l=new i.Float32BufferAttribute(s.vertex,3);if(l.applyMatrix4(r),a.setAttribute("position",l),s.colors.length>0&&a.setAttribute("color",new i.Float32BufferAttribute(s.colors,3)),t&&(a.setAttribute("skinIndex",new i.Uint16BufferAttribute(s.weightsIndices,4)),a.setAttribute("skinWeight",new i.Float32BufferAttribute(s.vertexWeights,4)),a.FBX_Deformer=t),s.normal.length>0){var c=(new i.Matrix3).getNormalMatrix(r),u=new i.Float32BufferAttribute(s.normal,3);u.applyNormalMatrix(c),a.setAttribute("normal",u)}if(s.uvs.forEach((function(e,t){var n="uv"+(t+1).toString();0===t&&(n="uv"),a.setAttribute(n,new i.Float32BufferAttribute(s.uvs[t],2))})),o.material&&"AllSame"!==o.material.mappingType){var h=s.materialIndex[0],d=0;if(s.materialIndex.forEach((function(e,t){e!==h&&(a.addGroup(d,t-d,h),h=e,d=t)})),a.groups.length>0){var p=a.groups[a.groups.length-1],f=p.start+p.count;f!==s.materialIndex.length&&a.addGroup(f,s.materialIndex.length-f,h)}0===a.groups.length&&a.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(a,e,n,r),a},parseGeoNode:function(e,t){var n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];for(var i=0;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n},genBuffers:function(e){var t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,r=!1,a=[],o=[],s=[],l=[],c=[],u=[],h=this;return e.vertexIndices.forEach((function(d,p){var f=!1;d<0&&(d^=-1,f=!0);var m=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){var y=g(p,n,d,e.color);s.push(y[0],y[1],y[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),m.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);var x=[0,0,0,0],b=[0,0,0,0];v.forEach((function(e,t){var n=e,i=m[t];b.forEach((function(e,t,r){if(n>e){r[t]=n,n=e;var a=x[t];x[t]=i,i=a}}))})),m=x,v=b}for(;v.length<4;)v.push(0),m.push(0);for(var w=0;w<4;++w)c.push(v[w]),u.push(m[w])}if(e.normal&&(y=g(p,n,d,e.normal),o.push(y[0],y[1],y[2])),e.material&&"AllSame"!==e.material.mappingType)var _=g(p,n,d,e.material)[0];e.uv&&e.uv.forEach((function(e,t){var i=g(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,f&&(h.genFace(t,e,a,_,o,s,l,c,u,i),n++,i=0,a=[],o=[],s=[],l=[],c=[],u=[])})),t},genFace:function(e,t,n,i,r,a,o,s,l,c){for(var u=2;u1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");var s=t.get(o[0].ID);r[a]={name:i[a].attrName,layer:s}}return r},addClip:function(e){var t=[],n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new i.AnimationClip(e.name,-1,t)},generateTracks:function(e){var t=[],n=new i.Vector3,r=new i.Quaternion,a=new i.Vector3;if(e.transform&&e.transform.decompose(n,r,a),n=n.toArray(),r=(new i.Euler).setFromQuaternion(r,e.eulerOrder).toArray(),a=a.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){var o=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==o&&t.push(o)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){var s=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==s&&t.push(s)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){var l=this.generateVectorTrack(e.modelName,e.S.curves,a,"scale");void 0!==l&&t.push(l)}if(void 0!==e.DeformPercent){var c=this.generateMorphTrack(e);void 0!==c&&t.push(c)}return t},generateVectorTrack:function(e,t,n,r){var a=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(a,t,n);return new i.VectorKeyframeTrack(e+"."+r,a,o)},generateRotationTrack:function(e,t,n,r,a,o){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(i.MathUtils.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(i.MathUtils.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(i.MathUtils.degToRad));var s=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(s,t,n);void 0!==r&&((r=r.map(i.MathUtils.degToRad)).push(o),r=(new i.Euler).fromArray(r),r=(new i.Quaternion).setFromEuler(r)),void 0!==a&&((a=a.map(i.MathUtils.degToRad)).push(o),a=(new i.Euler).fromArray(a),a=(new i.Quaternion).setFromEuler(a).invert());for(var c=new i.Quaternion,u=new i.Euler,h=[],d=0;d1){for(var n=1,i=t[0],r=1;r=180){for(var a=r/180,o=i/a,s=n+o,l=e.times[t-1],c=(e.times[t]-l)/a,u=l+c,h=[],d=[];u1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}},parseNodeProperty:function(e,t,n){var i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());var a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===i){var o=r.split(",").slice(1),s=parseInt(o[0]),l=parseInt(o[1]),c=r.split(",").slice(3);i="connections",function(e,t){for(var n=0,i=e.length,r=t.length;n=e.size():e.getOffset()+160+16>=e.size()},parseNode:function(e,t){var n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();var a=e.getUint8(),o=e.getString(a);if(0===i)return null;for(var s=[],l=0;l0?s[0]:"",u=s.length>1?s[1]:"",h=s.length>2?s[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){var d=this.parseNode(e,t);null!==d&&this.parseSubNode(o,n,d)}return n.propertyList=s,"number"==typeof c&&(n.id=c),""!==u&&(n.attrName=u),""!==h&&(n.attrType=h),""!==o&&(n.name=o),n},parseSubNode:function(e,t,n){if(!0===n.singleProperty){var i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if("Connections"===e&&"C"===n.name){var r=[];n.propertyList.forEach((function(e,t){0!==t&&r.push(e)})),void 0===t.connections&&(t.connections=[]),t.connections.push(r)}else if("Properties70"===n.name)Object.keys(n).forEach((function(e){t[e]=n[e]}));else if("Properties70"===e&&"P"===n.name){var a,o=n.propertyList[0],s=n.propertyList[1],l=n.propertyList[2],c=n.propertyList[3];0===o.indexOf("Lcl ")&&(o=o.replace("Lcl ","Lcl_")),0===s.indexOf("Lcl ")&&(s=s.replace("Lcl ","Lcl_")),a="Color"===s||"ColorRGB"===s||"Vector"===s||"Vector3D"===s||0===s.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[o]={type:s,type2:l,flag:c,value:a}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)},parseProperty:function(e){var t=e.getString(1);switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":var n=e.getUint32();return e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":var i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(0===r)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}void 0===Z&&console.error("THREE.FBXLoader: External library fflate.min.js required.");var o=new h(Z.unzlibSync(new Uint8Array(e.getArrayBuffer(a))).buffer);switch(t){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}},h.prototype={constructor:h,getOffset:function(){return this.offset},size:function(){return this.dv.buffer.byteLength},skip:function(e){this.offset+=e},getBoolean:function(){return 1==(1&this.getUint8())},getBooleanArray:function(e){for(var t=[],n=0;n=0&&(t=t.slice(0,r)),i.LoaderUtils.decodeText(new Uint8Array(t))}},d.prototype={constructor:d,add:function(e,t){this[e]=t}};var m=[];function g(e,t,n,i){var r;switch(i.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=n;break;case"AllSame":r=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}"IndexToDirect"===i.referenceType&&(r=i.indices[r]);var a=r*i.dataSize,o=a+i.dataSize;return function(e,t,n,i){for(var r=n,a=0;r=2.0 are supported."));else{var h=new O(u,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(var p=0;p=0&&void 0===c[y]&&console.warn('THREE.GLTFLoader: Unknown extension "'+y+'".')}}h.setExtensions(l),h.setPlugins(c),h.parse(n,a)}}});var r={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};function a(e){this.parser=e,this.name=r.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}function o(){this.name=r.KHR_MATERIALS_UNLIT}function s(e){this.parser=e,this.name=r.KHR_MATERIALS_CLEARCOAT}function l(e){this.parser=e,this.name=r.KHR_MATERIALS_TRANSMISSION}function c(e){this.parser=e,this.name=r.KHR_TEXTURE_BASISU}function u(e){this.parser=e,this.name=r.EXT_TEXTURE_WEBP,this.isSupported=null}function h(e){this.name=r.EXT_MESHOPT_COMPRESSION,this.parser=e}a.prototype._markDefs=function(){for(var e=this.parser,t=this.parser.json.nodes||[],n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,a,o)},u.prototype.loadTexture=function(e){var t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;var a=r.extensions[t],o=i.images[a.source],s=n.textureLoader;if(o.uri){var l=n.options.manager.getHandler(o.uri);null!==l&&(s=l)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,o,s);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))},u.prototype.detectSupport=function(){return this.isSupported||(this.isSupported=new Promise((function(e){var t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported},h.prototype.loadBufferView=function(e){var t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){var i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,a.ready]).then((function(e){var t=i.byteOffset||0,n=i.byteLength||0,r=i.count,o=i.byteStride,s=new ArrayBuffer(r*o),l=new Uint8Array(e[0],t,n);return a.decodeGltfBuffer(new Uint8Array(s),r,o,l,i.mode,i.filter),s}))}return null};var d="glTF",p=1313821514,f=5130562;function m(e){this.name=r.KHR_BINARY_GLTF,this.content=null,this.body=null;var t=new DataView(e,0,12);if(this.header={magic:i.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==d)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");for(var n=this.header.length-12,a=new DataView(e,12),o=0;o",t).replace("#include ",n).replace("#include ",r).replace("#include ",a).replace("#include ",o)},Object.defineProperties(this,{specular:{get:function(){return s.specular.value},set:function(e){s.specular.value=e}},specularMap:{get:function(){return s.specularMap.value},set:function(e){s.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return s.glossiness.value},set:function(e){s.glossiness.value=e}},glossinessMap:{get:function(){return s.glossinessMap.value},set:function(e){s.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}function x(){return{name:r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,specularGlossinessParams:["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"],getMaterialType:function(){return y},extendParams:function(e,t,n){var r=t.extensions[this.name];e.color=new i.Color(1,1,1),e.opacity=1;var a=[];if(Array.isArray(r.diffuseFactor)){var o=r.diffuseFactor;e.color.fromArray(o),e.opacity=o[3]}if(void 0!==r.diffuseTexture&&a.push(n.assignTexture(e,"map",r.diffuseTexture)),e.emissive=new i.Color(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new i.Color(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){var s=r.specularGlossinessTexture;a.push(n.assignTexture(e,"glossinessMap",s)),a.push(n.assignTexture(e,"specularMap",s))}return Promise.all(a)},createMaterial:function(e){var t=new y(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=i.TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}}function b(){this.name=r.KHR_MESH_QUANTIZATION}function w(e,t,n,r){i.Interpolant.call(this,e,t,n,r)}g.prototype.decodePrimitive=function(e,t){var n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},l={};for(var c in a){var u=E[c]||c.toLowerCase();o[u]=a[c]}for(c in e.attributes)if(u=E[c]||c.toLowerCase(),void 0!==a[c]){var h=n.accessors[e.attributes[c]],d=_[h.componentType];l[u]=d,s[u]=!0===h.normalized}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(var n in e.attributes){var i=e.attributes[n],r=s[n];void 0!==r&&(i.normalized=r)}t(e)}),o,l)}))}))},v.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},y.prototype=Object.create(i.MeshStandardMaterial.prototype),y.prototype.constructor=y,y.prototype.copy=function(e){return i.MeshStandardMaterial.prototype.copy.call(this,e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this},w.prototype=Object.create(i.Interpolant.prototype),w.prototype.constructor=w,w.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i,a=0;a!==i;a++)t[a]=n[r+a];return t},w.prototype.beforeStart_=w.prototype.copySampleValue_,w.prototype.afterEnd_=w.prototype.copySampleValue_,w.prototype.interpolate_=function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,l=3*o,c=i-t,u=(n-t)/c,h=u*u,d=h*u,p=e*l,f=p-l,m=-2*d+3*h,g=d-h,v=1-m,y=g-h+u,x=0;x!==o;x++){var b=a[f+x+o],w=a[f+x+s]*c,_=a[p+x+o],M=a[p+x]*c;r[x]=v*b+y*w+m*_+g*M}return r};var _={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},M={9728:i.NearestFilter,9729:i.LinearFilter,9984:i.NearestMipmapNearestFilter,9985:i.LinearMipmapNearestFilter,9986:i.NearestMipmapLinearFilter,9987:i.LinearMipmapLinearFilter},S={33071:i.ClampToEdgeWrapping,33648:i.MirroredRepeatWrapping,10497:i.RepeatWrapping},T={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},E={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},A={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},L={CUBICSPLINE:void 0,LINEAR:i.InterpolateLinear,STEP:i.InterpolateDiscrete};function R(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function C(e,t,n){for(var i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function P(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function I(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(var n=0,i=t.weights.length;n=2&&o.setY(L,S[E*l+1]),l>=3&&o.setZ(L,S[E*l+2]),l>=4&&o.setW(L,S[E*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o}))},O.prototype.loadTexture=function(e){var t=this.json,n=this.options,i=t.textures[e],r=t.images[i.source],a=this.textureLoader;if(r.uri){var o=n.manager.getHandler(r.uri);null!==o&&(a=o)}return this.loadTextureImage(e,r,a)},O.prototype.loadTextureImage=function(e,t,n){var r=this,a=this.json,o=this.options,s=a.textures[e],l=self.URL||self.webkitURL,c=t.uri,u=!1,h=!0;if("image/jpeg"===t.mimeType&&(h=!1),void 0!==t.bufferView)c=r.getDependency("bufferView",t.bufferView).then((function(e){if("image/png"===t.mimeType){var n=new DataView(e,25,1).getUint8(0,!1);h=6===n||4===n||3===n}u=!0;var i=new Blob([e],{type:t.mimeType});return c=l.createObjectURL(i)}));else if(void 0===t.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");return Promise.resolve(c).then((function(e){return new Promise((function(t,r){var a=t;!0===n.isImageBitmapLoader&&(a=function(e){t(new i.CanvasTexture(e))}),n.load(R(e,o.path),a,void 0,r)}))})).then((function(t){!0===u&&l.revokeObjectURL(c),t.flipY=!1,s.name&&(t.name=s.name),h||(t.format=i.RGBFormat);var n=(a.samplers||{})[s.sampler]||{};return t.magFilter=M[n.magFilter]||i.LinearFilter,t.minFilter=M[n.minFilter]||i.LinearMipmapLinearFilter,t.wrapS=S[n.wrapS]||i.RepeatWrapping,t.wrapT=S[n.wrapT]||i.RepeatWrapping,r.associations.set(t,{type:"textures",index:e}),t}))},O.prototype.assignTexture=function(e,t,n){var i=this;return this.getDependency("texture",n.index).then((function(a){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[r.KHR_TEXTURE_TRANSFORM]){var o=void 0!==n.extensions?n.extensions[r.KHR_TEXTURE_TRANSFORM]:void 0;if(o){var s=i.associations.get(a);a=i.extensions[r.KHR_TEXTURE_TRANSFORM].extendTexture(a,o),i.associations.set(a,s)}}e[t]=a}))},O.prototype.assignFinalMaterial=function(e){var t=e.geometry,n=e.material,r=void 0!==t.attributes.tangent,a=void 0!==t.attributes.color,o=void 0===t.attributes.normal,s=!0===e.isSkinnedMesh,l=Object.keys(t.morphAttributes).length>0,c=l&&void 0!==t.morphAttributes.normal;if(e.isPoints){var u="PointsMaterial:"+n.uuid,h=this.cache.get(u);h||(h=new i.PointsMaterial,i.Material.prototype.copy.call(h,n),h.color.copy(n.color),h.map=n.map,h.sizeAttenuation=!1,this.cache.add(u,h)),n=h}else if(e.isLine){u="LineBasicMaterial:"+n.uuid;var d=this.cache.get(u);d||(d=new i.LineBasicMaterial,i.Material.prototype.copy.call(d,n),d.color.copy(n.color),this.cache.add(u,d)),n=d}if(r||a||o||s||l){u="ClonedMaterial:"+n.uuid+":",n.isGLTFSpecularGlossinessMaterial&&(u+="specular-glossiness:"),s&&(u+="skinning:"),r&&(u+="vertex-tangents:"),a&&(u+="vertex-colors:"),o&&(u+="flat-shading:"),l&&(u+="morph-targets:"),c&&(u+="morph-normals:");var p=this.cache.get(u);p||(p=n.clone(),s&&(p.skinning=!0),a&&(p.vertexColors=!0),o&&(p.flatShading=!0),l&&(p.morphTargets=!0),c&&(p.morphNormals=!0),r&&(p.vertexTangents=!0,p.normalScale&&(p.normalScale.y*=-1),p.clearcoatNormalScale&&(p.clearcoatNormalScale.y*=-1)),this.cache.add(u,p),this.associations.set(p,this.associations.get(n))),n=p}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n},O.prototype.getMaterialType=function(){return i.MeshStandardMaterial},O.prototype.loadMaterial=function(e){var t,n=this,a=this.json,o=this.extensions,s=a.materials[e],l={},c=s.extensions||{},u=[];if(c[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var h=o[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=h.getMaterialType(),u.push(h.extendParams(l,s,n))}else if(c[r.KHR_MATERIALS_UNLIT]){var d=o[r.KHR_MATERIALS_UNLIT];t=d.getMaterialType(),u.push(d.extendParams(l,s,n))}else{var p=s.pbrMetallicRoughness||{};if(l.color=new i.Color(1,1,1),l.opacity=1,Array.isArray(p.baseColorFactor)){var f=p.baseColorFactor;l.color.fromArray(f),l.opacity=f[3]}void 0!==p.baseColorTexture&&u.push(n.assignTexture(l,"map",p.baseColorTexture)),l.metalness=void 0!==p.metallicFactor?p.metallicFactor:1,l.roughness=void 0!==p.roughnessFactor?p.roughnessFactor:1,void 0!==p.metallicRoughnessTexture&&(u.push(n.assignTexture(l,"metalnessMap",p.metallicRoughnessTexture)),u.push(n.assignTexture(l,"roughnessMap",p.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),u.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,l)}))))}!0===s.doubleSided&&(l.side=i.DoubleSide);var m=s.alphaMode||"OPAQUE";return"BLEND"===m?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,"MASK"===m&&(l.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&t!==i.MeshBasicMaterial&&(u.push(n.assignTexture(l,"normalMap",s.normalTexture)),l.normalScale=new i.Vector2(1,-1),void 0!==s.normalTexture.scale&&l.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&t!==i.MeshBasicMaterial&&(u.push(n.assignTexture(l,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(l.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&t!==i.MeshBasicMaterial&&(l.emissive=(new i.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&t!==i.MeshBasicMaterial&&u.push(n.assignTexture(l,"emissiveMap",s.emissiveTexture)),Promise.all(u).then((function(){var a;return a=t===y?o[r.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(l):new t(l),s.name&&(a.name=s.name),a.map&&(a.map.encoding=i.sRGBEncoding),a.emissiveMap&&(a.emissiveMap.encoding=i.sRGBEncoding),P(a,s),n.associations.set(a,{type:"materials",index:e}),s.extensions&&C(o,a,s),a}))},O.prototype.createUniqueName=function(e){for(var t=i.PropertyBinding.sanitizeNodeName(e||""),n=t,r=1;this.nodeNamesUsed[n];++r)n=t+"_"+r;return this.nodeNamesUsed[n]=!0,n},O.prototype.loadGeometries=function(e){var t=this,n=this.extensions,a=this.primitiveCache;function o(e){return n[r.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return N(n,e,t)}))}for(var s,l,c=[],u=0,h=e.length;u0&&I(d,o),d.name=n.createUniqueName(o.name||"mesh_"+e),P(d,o),f.extensions&&C(a,d,f),n.assignFinalMaterial(d),c.push(d)}if(1===c.length)return c[0];var g=new i.Group;for(u=0,h=c.length;u1?new i.Group:1===t.length?t[0]:new i.Object3D)!==t[0])for(var l=0,c=t.length;l0&&t.push(new i.VectorKeyframeTrack(r+".position",a,o)),s.length>0&&t.push(new i.QuaternionKeyframeTrack(r+".quaternion",a,s)),l.length>0&&t.push(new i.VectorKeyframeTrack(r+".scale",a,l)),t}function M(e,t,n){var i,r,a,o=!0;for(r=0,a=e.length;r=0;){var i=e[t];if(null!==i.value[n])return i;t--}return null}function T(e,t,n){for(;t>>0));switch(n=n.toLowerCase()){case"tga":t=We;break;default:t=Xe}return t}(n);if(void 0!==a){var o=a.load(n),s=e.extra;if(void 0!==s&&void 0!==s.technique&&!1===l(s.technique)){var c=s.technique;o.wrapS=c.wrapU?i.RepeatWrapping:i.ClampToEdgeWrapping,o.wrapT=c.wrapV?i.RepeatWrapping:i.ClampToEdgeWrapping,o.offset.set(c.offsetU||0,c.offsetV||0),o.repeat.set(c.repeatU||1,c.repeatV||1)}else o.wrapS=i.RepeatWrapping,o.wrapT=i.RepeatWrapping;return o}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",n),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}n.name=e.name||"";var c=a.parameters;for(var u in c){var h=c[u];switch(u){case"diffuse":h.color&&n.color.fromArray(h.color),h.texture&&(n.map=s(h.texture));break;case"specular":h.color&&n.specular&&n.specular.fromArray(h.color),h.texture&&(n.specularMap=s(h.texture));break;case"bump":h.texture&&(n.normalMap=s(h.texture));break;case"ambient":h.texture&&(n.lightMap=s(h.texture));break;case"shininess":h.float&&n.shininess&&(n.shininess=h.float);break;case"emission":h.color&&n.emissive&&n.emissive.fromArray(h.color),h.texture&&(n.emissiveMap=s(h.texture))}}var d=c.transparent,f=c.transparency;if(void 0===f&&d&&(f={float:1}),void 0===d&&f&&(d={opaque:"A_ONE",data:{color:[1,1,1,1]}}),d&&f)if(d.data.texture)n.transparent=!0;else{var m=d.data.color;switch(d.opaque){case"A_ONE":n.opacity=m[3]*f.float;break;case"RGB_ZERO":n.opacity=1-m[0]*f.float;break;case"A_ZERO":n.opacity=1-m[3]*f.float;break;case"RGB_ONE":n.opacity=m[0]*f.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',d.opaque)}n.opacity<1&&(n.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(n.side=i.DoubleSide),n}function Y(e){return p(Ke.materials[e],Z)}function J(e){for(var t=0;t0?l+u:l;t.inputs[h]={id:a,offset:c},t.stride=Math.max(t.stride,c+1),"TEXCOORD"===l&&(t.hasUV=!0);break;case"vcount":t.vcount=o(r.textContent);break;case"p":t.p=o(r.textContent)}}return t}function le(e){for(var t=0,n=0,i=e.length;n0&&t0&&d.setAttribute("position",new i.Float32BufferAttribute(a.array,a.stride)),o.array.length>0&&d.setAttribute("normal",new i.Float32BufferAttribute(o.array,o.stride)),c.array.length>0&&d.setAttribute("color",new i.Float32BufferAttribute(c.array,c.stride)),s.array.length>0&&d.setAttribute("uv",new i.Float32BufferAttribute(s.array,s.stride)),l.array.length>0&&d.setAttribute("uv2",new i.Float32BufferAttribute(l.array,l.stride)),u.length>0&&d.setAttribute("skinIndex",new i.Float32BufferAttribute(u,4)),h.length>0&&d.setAttribute("skinWeight",new i.Float32BufferAttribute(h,4)),r.data=d,r.type=e[0].type,r.materialKeys=p,r}function he(e,t,n,i){var r=e.p,a=e.stride,o=e.vcount;function s(e){for(var t=r[e+n]*c,a=t+c;t4)for(var v=1,y=p-2;v<=y;v++)f=u+a*v,m=u+a*(v+1),s(u+0*a),s(f),s(m);u+=a*p}else for(h=0,d=r.length;h=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ve(e){for(var t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]},n=0;nr.limits.max||t{let r=[];switch(e.type){case"mtl":i=i.children[0];break;case"gltf":case"glb":case"dae":r=i.animations,i=i.scene;break;case"fbx":r=i.animations}i.animations=r;const a=u.types.rotation(e.rotation,[0,0,0]),o=u.types.scale(e.scale,[1,1,1]);i.rotation.set(a[0],a[1],a[2]),i.scale.set(o[0],o[1],o[2]),e.normalize&&i.traverse((function(e){if(e.isMesh){let t;"MeshStandardMaterial"==e.material.type?(e.material.metalness&&(e.material.metalness*=.1),e.material.glossiness&&(e.material.glossiness*=.25),t=new THREE.Color(12,12,12)):"MeshPhongMaterial"==e.material.type&&(e.material.shininess=.1,t=new THREE.Color(20,20,20)),e.material.specular&&e.material.specular.isColor&&(e.material.specular=t)}})),i.name="model";let s=_.prototype._makeGroup(i,e);_.prototype._addMethods(s),s.setAnchor(e.anchor),s.setCenter(e.adjustment),s.raycasted=e.raycasted,n(s),t(s),s.setFixedZoom(e.mapScale),s.idle()},()=>null,t=>{console.error("Could not load model file: "+e.obj+" \n "+t.stack),n("Error loading the model")})}),()=>null,e=>{console.warn("No material file found for SymbolLayer3D model "+m)})};var re,ae,oe,se,le={};function ce(e){e=u._validate(e,_.prototype._defaults.line);var t=u.lnglatsToWorld(e.geometry),n=u.normalizeVertices(t),r=u.flattenVectors(n.vertices),a=new i.LineGeometry;a.setPositions(r);let o=new i.LineMaterial({color:e.color,linewidth:e.width,dashed:!1,opacity:e.opacity});return o.resolution.set(window.innerWidth,window.innerHeight),o.isMaterial=!0,o.transparent=!0,o.depthWrite=!1,(ce=new i.Line2(a,o)).position.copy(n.position),ce.computeLineDistances(),ce}le=le=ce,i.LineSegmentsGeometry=function(){i.InstancedBufferGeometry.call(this),this.type="LineSegmentsGeometry",this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute("position",new i.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute("uv",new i.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))},i.LineSegmentsGeometry.prototype=Object.assign(Object.create(i.InstancedBufferGeometry.prototype),{constructor:i.LineSegmentsGeometry,isLineSegmentsGeometry:!0,applyMatrix4:function(e){var t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==t&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},setPositions:function(e){var t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var n=new i.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new i.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},setColors:function(e){var t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));var n=new i.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new i.InterleavedBufferAttribute(n,3,3)),this},fromWireframeGeometry:function(e){return this.setPositions(e.attributes.position.array),this},fromEdgesGeometry:function(e){return this.setPositions(e.attributes.position.array),this},fromMesh:function(e){return this.fromWireframeGeometry(new i.WireframeGeometry(e.geometry)),this},fromLineSegments:function(e){var t=e.geometry;if(!t.isGeometry)return t.isBufferGeometry&&this.setPositions(t.attributes.position.array),this;console.error("THREE.LineSegmentsGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},computeBoundingBox:(ae=new i.Box3,function(){null===this.boundingBox&&(this.boundingBox=new i.Box3);var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;void 0!==e&&void 0!==t&&(this.boundingBox.setFromBufferAttribute(e),ae.setFromBufferAttribute(t),this.boundingBox.union(ae))}),computeBoundingSphere:(re=new i.Vector3,function(){null===this.boundingSphere&&(this.boundingSphere=new i.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(void 0!==e&&void 0!==t){var n=this.boundingSphere.center;this.boundingBox.getCenter(n);for(var r=0,a=0,o=e.count;a\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float dashOffset;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include \n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"},i.LineMaterial=function(e){i.ShaderMaterial.call(this,{type:"LineMaterial",uniforms:i.UniformsUtils.clone(i.ShaderLib.line.uniforms),vertexShader:i.ShaderLib.line.vertexShader,fragmentShader:i.ShaderLib.line.fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)},i.LineMaterial.prototype=Object.create(i.ShaderMaterial.prototype),i.LineMaterial.prototype.constructor=i.LineMaterial,i.LineMaterial.prototype.isLineMaterial=!0,i.LineSegments2=function(e,t){void 0===e&&(e=new i.LineSegmentsGeometry),void 0===t&&(t=new i.LineMaterial({color:16777215*Math.random()})),i.Mesh.call(this,e,t),this.type="LineSegments2"},i.LineSegments2.prototype=Object.assign(Object.create(i.Mesh.prototype),{constructor:i.LineSegments2,isLineSegments2:!0,computeLineDistances:(oe=new i.Vector3,se=new i.Vector3,function(){for(var e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.data.count),a=0,o=0,s=t.data.count;ab&&t.z>b)){if(e.z>b){const n=e.z-t.z,i=(e.z-b)/n;e.lerp(t,i)}else if(t.z>b){const n=t.z-e.z,i=(t.z-b)/n;t.lerp(e,i)}e.applyMatrix4(p),t.applyMatrix4(p),e.multiplyScalar(1/e.w),t.multiplyScalar(1/t.w),e.x*=g.x/2,e.y*=g.y/2,t.x*=g.x/2,t.y*=g.y/2,o.start.copy(e),o.start.z=0,o.end.copy(t),o.end.z=0;var S=o.closestPointToPointParameter(r,!0);o.at(S,s);var T=i.MathUtils.lerp(e.z,t.z,S),E=T>=-1&&T<=1,A=r.distanceTo(s)<.5*v;if(E&&A){o.start.fromBufferAttribute(y,_),o.end.fromBufferAttribute(x,_),o.start.applyMatrix4(w),o.end.applyMatrix4(w);var L=new i.Vector3,R=new i.Vector3;h.distanceSqToSegment(o.start,o.end,R,L),c.push({point:R,pointOnLine:L,distance:h.origin.distanceTo(R),object:this,face:null,faceIndex:_,uv:null,uv2:null})}}}}()}),i.Line2=function(e,t){void 0===e&&(e=new i.LineGeometry),void 0===t&&(t=new i.LineMaterial({color:16777215*Math.random()})),i.LineSegments2.call(this,e,t),this.type="Line2"},i.Line2.prototype=Object.assign(Object.create(i.LineSegments2.prototype),{constructor:i.Line2,isLine2:!0}),i.Wireframe=function(e,t){i.Mesh.call(this),this.type="Wireframe",this.geometry=void 0!==e?e:new i.LineSegmentsGeometry,this.material=void 0!==t?t:new i.LineMaterial({color:16777215*Math.random()})},i.Wireframe.prototype=Object.assign(Object.create(i.Mesh.prototype),{constructor:i.Wireframe,isWireframe:!0,computeLineDistances:function(){var e=new i.Vector3,t=new i.Vector3;return function(){for(var n=this.geometry,r=n.attributes.instanceStart,a=n.attributes.instanceEnd,o=new Float32Array(2*r.data.count),s=0,l=0,c=r.data.count;s{n.push(new i.Vector3(e[0],e[1],e[2]))});const r=new i.CatmullRomCurve3(n);let a=new i.TubeGeometry(r,n.length,e.radius,e.sides,!1),o=g(e),s=new i.Mesh(a,o);return new T({obj:s,units:e.units,anchor:e.anchor,adjustment:e.adjustment,bbox:e.bbox,tooltip:e.tooltip,raycasted:e.raycasted})};var he={};he=he=function(e){this.map=e,this.renderer=new w.CSS2DRenderer,this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight),this.renderer.domElement.style.position="absolute",this.renderer.domElement.id="labelCanvas",this.renderer.domElement.style.top=0,this.renderer.domElement.style.zIndex="0",this.map.getCanvasContainer().appendChild(this.renderer.domElement),this.scene,this.camera,this.dispose=function(){this.map.getCanvasContainer().removeChild(this.renderer.domElement),this.renderer.domElement.remove(),this.renderer={}},this.setSize=function(e,t){this.renderer.setSize(e,t)},this.map.on("resize",function(){this.renderer.setSize(this.map.getCanvas().clientWidth,this.map.getCanvas().clientHeight)}.bind(this)),this.state={reset:function(){}},this.render=async function(e,t){return this.scene=e,this.camera=t,new Promise(n=>{n(this.renderer.render(e,t))})},this.toggleLabels=async function(e,t){return new Promise(n=>{n(this.setVisibility(e,t,this.scene,this.camera,this.renderer))})},this.setVisibility=function(e,t,n,i,r){this.renderer.cacheList.forEach((function(a){a.visible!=t&&a.layer===e&&(t&&a.alwaysVisible||!t)&&(a.visible=t,r.renderObject(a,n,i))}))}};var de={};de=de=class{constructor(e,t){this.id=e.layerId,this.type="custom",this.renderingMode="3d",this.opacity=.5,this.buildingsLayerId=e.buildingsLayerId,this.minAltitude=e.minAltitude||.1,this.tb=t}onAdd(e,t){this.map=e;const n=t.createShader(t.VERTEX_SHADER);t.shaderSource(n,"\n\t\t\tuniform mat4 u_matrix;\n\t\t\tuniform float u_height_factor;\n\t\t\tuniform float u_altitude;\n\t\t\tuniform float u_azimuth;\n\t\t\tattribute vec2 a_pos;\n\t\t\tattribute vec4 a_normal_ed;\n\t\t\tattribute lowp vec2 a_base;\n\t\t\tattribute lowp vec2 a_height;\n\t\t\tvoid main() {\n\t\t\t\tfloat base = max(0.0, a_base.x);\n\t\t\t\tfloat height = max(0.0, a_height.x);\n\t\t\t\tfloat t = mod(a_normal_ed.x, 2.0);\n\t\t\t\tvec4 pos = vec4(a_pos, t > 0.0 ? height : base, 1);\n\t\t\t\tfloat len = pos.z * u_height_factor / tan(u_altitude);\n\t\t\t\tpos.x += cos(u_azimuth) * len;\n\t\t\t\tpos.y += sin(u_azimuth) * len;\n\t\t\t\tpos.z = 0.0;\n\t\t\t\tgl_Position = u_matrix * pos;\n\t\t\t}\n\t\t\t"),t.compileShader(n);const i=t.createShader(t.FRAGMENT_SHADER);t.shaderSource(i,"\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, 0.7);\n\t\t\t}\n\t\t\t"),t.compileShader(i),this.program=t.createProgram(),t.attachShader(this.program,n),t.attachShader(this.program,i),t.linkProgram(this.program),t.validateProgram(this.program),this.uMatrix=t.getUniformLocation(this.program,"u_matrix"),this.uHeightFactor=t.getUniformLocation(this.program,"u_height_factor"),this.uAltitude=t.getUniformLocation(this.program,"u_altitude"),this.uAzimuth=t.getUniformLocation(this.program,"u_azimuth"),this.aPos=t.getAttribLocation(this.program,"a_pos"),this.aNormal=t.getAttribLocation(this.program,"a_normal_ed"),this.aBase=t.getAttribLocation(this.program,"a_base"),this.aHeight=t.getAttribLocation(this.program,"a_height")}render(e,t){e.useProgram(this.program);const n=this.map.style.sourceCaches.composite,i=n.getVisibleCoordinates().reverse(),r=this.map.getLayer(this.buildingsLayerId),a=this.map.painter.context,{lng:o,lat:s}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[o,s]);e.uniform1f(this.uAltitude,l.altitude>this.minAltitude?l.altitude:0),e.uniform1f(this.uAzimuth,l.azimuth+3*Math.PI/2),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA),e.getExtension("EXT_blend_minmax"),e.disable(e.DEPTH_TEST);for(const c of i){const t=n.getTile(c),i=t.getBucket(r);if(!i)continue;const[o,s]=i.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;e.uniformMatrix4fv(this.uMatrix,!1,c.posMatrix),e.uniform1f(this.uHeightFactor,Math.pow(2,c.overscaledZ)/t.tileSize/8);for(const n of i.segments.get()){const t=a.currentNumAttributes||0,r=2;for(let n=r;n0&&"fill-extrusion"==n[0].layer.type&&void 0!==n[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=n[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(n[0]);else if(this.selectedFeature.id==n[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(n[0])}},this.onMouseMove=function(i){let l,u=c(i);if(this.getCanvasContainer().style.cursor="default",i.originalEvent.altKey&&this.draggedObject){if(!e.tb.enableRotatingObjects)return;t="rotate",this.getCanvasContainer().style.cursor="move",Math.min(n.x,u.x),Math.max(n.x,u.x),Math.min(n.y,u.y),Math.max(n.y,u.y);let i={x:0,y:0,z:Math.round(s[2]+~~((u.x-n.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(i),void this.draggedObject.addHelp("rot: "+i.z+"°")}if(i.originalEvent.shiftKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="translate",this.getCanvasContainer().style.cursor="move";let n=i.lngLat,o=[Number((n.lng+r).toFixed(this.tb.gridStep)),Number((n.lat+a).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(o),void this.draggedObject.addHelp("lng: "+o[0]+"°, lat: "+o[1]+"°")}if(i.originalEvent.ctrlKey&&this.draggedObject){if(!e.tb.enableDraggingObjects)return;t="altitude",this.getCanvasContainer().style.cursor="move";let n=i.point.y*this.tb.altitudeStep,r=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-n-o).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(r),void this.draggedObject.addHelp("alt: "+r[2]+"m")}let h=[];if(e.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(i.point)),l="object"==typeof h[0]){let e=fe.prototype.findParent3DObject(h[0]);e&&(this.outFeature(this.overedFeature),this.getCanvasContainer().style.cursor="pointer",this.selectedObject&&e.uuid==this.selectedObject.uuid||(this.overedObject&&this.overedObject.uuid!=e.uuid&&this.outObject(),e.over=!0,this.overedObject=e),this.repaint=!0,i.preventDefault())}else{this.overedObject&&this.outObject();let t=[];e.tb.enableSelectingFeatures&&(t=this.queryRenderedFeatures(i.point)),t.length>0&&(this.outFeature(t[0]),"fill-extrusion"==t[0].layer.type&&void 0!==t[0].id&&(this.selectedFeature&&this.selectedFeature.id==t[0].id||(this.getCanvasContainer().style.cursor="pointer",this.overedFeature=t[0],this.setFeatureState({source:this.overedFeature.source,sourceLayer:this.overedFeature.sourceLayer,id:this.overedFeature.id},{hover:!0}),this.overedFeature=e.queryRenderedFeatures({layers:[this.overedFeature.layer.id],filter:["==",["id"],this.overedFeature.id]})[0],this.addTooltip(this.overedFeature))))}},this.onMouseDown=function(t){(t.originalEvent.shiftKey||t.originalEvent.altKey||t.originalEvent.ctrlKey)&&0===t.originalEvent.button&&this.selectedObject&&(e.tb.enableDraggingObjects||e.tb.enableRotatingObjects)&&(t.preventDefault(),e.getCanvasContainer().style.cursor="move",e.once("mouseup",this.onMouseUp),this.draggedObject=this.selectedObject,n=c(t),l=this.draggedObject.coordinates,s=u.degreeify(this.draggedObject.rotation),r=l[0]-t.lngLat.lng,a=l[1]-t.lngLat.lat,o=-this.draggedObject.modelHeight-t.point.y*this.tb.altitudeStep)},this.onMouseUp=function(e){this.getCanvasContainer().style.cursor="default",this.off("mouseup",this.onMouseUp),this.off("mouseout",this.onMouseUp),this.dragPan.enable(),this.draggedObject&&(this.draggedObject.dispatchEvent({type:"ObjectDragged",detail:{draggedObject:this.draggedObject,draggedAction:t}}),this.draggedObject.removeHelp(),this.draggedObject=null,t=null)},this.onMouseOut=function(e){if(this.overedFeature){let t=this.queryRenderedFeatures(e.point);t.length>0&&this.overedFeature.id!=t[0].id&&(this.getCanvasContainer().style.cursor="default",this.outFeature(t[0]))}},this.onZoom=function(e){this.tb.zoomLayers.forEach(e=>{this.tb.toggleLayer(e)}),this.tb.world.children.filter(e=>null!=e.fixedZoom).forEach(e=>{e.setObjectScale(this.transform.scale)})};let h=!1,d=!1;this.on("click",this.onClick),this.on("mousemove",this.onMouseMove),this.on("mouseout",this.onMouseOut),this.on("mousedown",this.onMouseDown),this.on("zoom",this.onZoom),document.addEventListener("keydown",function(e){17!==e.which&&91!==e.which||(h=!0),16===e.which&&(d=!0);let t=this.selectedObject;if(d&&83===e.which&&t){let e=u.toDecimal;if(t.help)t.removeHelp();else{let n=t.modelSize,i=1;"meters"!==t.userData.units&&((i=u.projectedUnitsPerMeter(t.coordinates[1]))||(i=1),i=e(i,7)),t.addHelp("size(m): "+e(n.x/i,3)+" W, "+e(n.y/i,3)+" L, "+e(n.z/i,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(e){17!=e.which&&91!=e.which||(h=!1),16===e.which&&(d=!1)}.bind(this))}))},get fov(){return this.options.fov},set fov(e){this.camera instanceof i.PerspectiveCamera&&this.options.fov!==e&&(this.map.transform.fov=e,this.camera.fov=this.map.transform.fov,this.cameraSync.setupCamera(),this.map.repaint=!0,this.options.fov=e)},get orthographic(){return this.options.orthographic},set orthographic(e){const t=this.map.getCanvas().clientHeight,n=this.map.getCanvas().clientWidth;e?(this.map.transform.fov=0,this.camera=new i.OrthographicCamera(n/-2,n/2,t/2,t/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new i.PerspectiveCamera(this.map.transform.fov,n/t,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new d(this.map,this.camera,this.world),this.map.repaint=!0,this.options.orthographic=e},sphere:function(e){return this.setDefaultView(e,this.options),E(e,this.world)},line:le,label:R,tooltip:C,tube:function(e){return this.setDefaultView(e,this.options),ue(e,this.world)},extrusion:function(e){return this.setDefaultView(e,this.options),A(e)},Object3D:function(e){return this.setDefaultView(e,this.options),T(e)},loadObj:async function(e,t){this.setDefaultView(e,this.options);let n=this.objectsCache.get(e.obj);n?n.promise.then(n=>{t(n.duplicate(e))}).catch(t=>{this.objectsCache.delete(e.obj),console.error("Could not load model file: "+e.obj)}):this.objectsCache.set(e.obj,{promise:new Promise(async(n,i)=>{Q(e,t,async e=>{e.duplicate?n(e.duplicate()):i(e)})})})},material:function(e){return g(e)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:u,SunCalc:f,Constants:r,projectToWorld:function(e){return this.utils.projectToWorld(e)},unprojectFromWorld:function(e){return this.utils.unprojectFromWorld(e)},projectedUnitsPerMeter:function(e){return this.utils.projectedUnitsPerMeter(e)},getFeatureCenter:function(e,t,n){return u.getFeatureCenter(e,t,n)},getObjectHeightOnFloor:function(e,t,n){return u.getObjectHeightOnFloor(e,t,n)},queryRenderedFeatures:function(e){let t=new i.Vector2;return t.x=e.x/this.map.transform.width*2-1,t.y=1-e.y/this.map.transform.height*2,this.raycaster.setFromCamera(t,this.camera),this.raycaster.intersectObjects(this.world.children,!0)},findParent3DObject:function(e){var t;return e.object.traverseAncestors((function(e){e.parent&&"Group"==e.parent.type&&e.userData.obj&&(t=e)})),t},setLayoutProperty:function(e,t,n){this.map.setLayoutProperty(e,t,n),null==n||"visibility"!==t||this.world.children.forEach((function(t){t.layer===e&&(t.visibility=n)}))},setLayerZoomRange:function(e,t,n){this.map.getLayer(e)&&(this.map.setLayerZoomRange(e,t,n),this.zoomLayers.includes(e)||this.zoomLayers.push(e),this.toggleLayer(e))},setLayerHeigthProperty:function(e,t){let n=this.map.getLayer(e);if(n)if("fill-extrusion"==n.type){let e=this.map.getStyle().sources[n.source].data;e.features.forEach((function(e){e.properties.level=t})),this.map.getSource(n.source).setData(e)}else"custom"==n.type&&this.world.children.forEach((function(n){let i=n.userData.feature;if(i&&i.layer===e){let e=this.tb.getFeatureCenter(i,n,t);n.setCoords(e)}}))},setStyle:function(e,t){this.clear().then(()=>{this.map.setStyle(e,t)})},toggleLayer:function(e,t=!0){let n=this.map.getLayer(e);if(n){if(!t)return void this.toggle(n.id,!1);let e=this.map.getZoom();if(n.minzoom&&e=n.maxzoom)return void this.toggle(n.id,!1);this.toggle(n.id,!0)}},toggle:function(e,t){this.setLayoutProperty(e,"visibility",t?"visible":"none"),this.labelRenderer.toggleLabels(e,t)},update:function(){this.map.repaint&&(this.map.repaint=!1);var e=Date.now();this.objects.animationManager.update(e),this.updateLightHelper(),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this.labelRenderer.render(this.scene,this.camera),!1===this.options.passiveRendering&&this.map.triggerRepaint()},add:function(e,t,n){if(!this.enableTooltips&&e.tooltip&&(e.tooltip.visibility=!1),this.world.add(e),t){e.layer=t,e.source=n;let i=this.map.getLayer(t);if(i){let t=i.visibility,n=void 0===t;e.visibility=!(!n&&"visible"!==t)}}},removeByName:function(e){let t=this.world.getObjectByName(e);t&&this.remove(t)},remove:function(e){this.map.selectedObject&&e.uuid==this.map.selectedObject.uuid&&this.map.unselectObject(),this.map.draggedObject&&e.uuid==this.map.draggedObject.uuid&&(this.map.draggedObject=null),e.dispose&&e.dispose(),this.world.remove(e),e=null},clear:async function(e=null,t=!1){return new Promise((n,i)=>{let r=[];this.world.children.forEach((function(e){r.push(e)}));for(let t=0;t{e.promise.then(e=>{e.dispose(),e=null})}),n("clear")})},removeLayer:function(e){this.clear(e,!0).then(()=>{this.map.removeLayer(e)})},getSunPosition:function(e,t){return f.getPosition(e,t[1],t[0])},getSunTimes:function(e,t){return f.getTimes(e,t[1],t[0],t[2]?t[2]:0)},setBuildingShadows:function(e){if(this.map.getLayer(e.buildingsLayerId)){let t=new de(e,this);this.map.addLayer(t,e.buildingsLayerId)}else console.warn("The layer '"+e.buildingsLayerId+"' does not exist in the map.")},setSunlight:function(e=new Date,t){if(!this.lights.dirLight||!this.options.realSunlight)return void console.warn("To use setSunlight it's required to set realSunlight : true in Threebox initial options.");var n=new Date(e.getTime());if(t?t.lng&&t.lat?this.mapCenter=t:this.mapCenter={lng:t[0],lat:t[1]}:this.mapCenter=this.map.getCenter(),this.lightDateTime&&this.lightDateTime.getTime()===n.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=n,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(n,[this.mapCenter.lng,this.mapCenter.lat]);let i=this.sunPosition.altitude,a=Math.PI+this.sunPosition.azimuth,o=r.WORLD_SIZE/2,s=Math.sin(i),l=Math.cos(i),c=Math.cos(a)*l,u=Math.sin(a)*l;this.lights.dirLight.position.set(u,c,s),this.lights.dirLight.position.multiplyScalar(o),this.lights.dirLight.intensity=Math.max(s,-.15),this.lights.dirLight.updateMatrixWorld(),this.updateLightHelper(),this.map.loaded()&&this.map.setLight({anchor:"map",position:[1.5,180+180*this.sunPosition.azimuth/Math.PI,90-180*this.sunPosition.altitude/Math.PI],"position-transition":{duration:0},color:`hsl(40, ${50*Math.cos(this.sunPosition.altitude)}%, ${96*Math.sin(this.sunPosition.altitude)}%)`},{duration:0})},updateLightHelper:function(){this.lights.dirLightHelper&&(this.lights.dirLightHelper.position.setFromMatrixPosition(this.lights.dirLight.matrixWorld),this.lights.dirLightHelper.updateMatrix(),this.lights.dirLightHelper.update())},dispose:async function(){return console.log(this.memory()),new Promise(e=>{e(this.clear(null,!0).then(e=>(this.map.remove(),this.map={},this.scene.remove(this.world),this.scene.dispose(),this.world.children=[],this.world=null,this.objectsCache.clear(),this.labelRenderer.dispose(),console.log(this.memory()),this.renderer.dispose(),e)))})},defaultLights:function(){this.lights.ambientLight=new i.AmbientLight(new i.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new i.DirectionalLight(new i.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new i.DirectionalLight(new i.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLight.position.set(-30,100,-100),this.scene.add(this.lights.dirLight)},realSunlight:function(e=!1){this.renderer.shadowMap.enabled=!0,this.lights.dirLight=new i.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),e&&(this.lights.dirLightHelper=new i.DirectionalLightHelper(this.lights.dirLight,5),this.scene.add(this.lights.dirLightHelper)),this.lights.dirLight.castShadow=!0,this.lights.dirLight.shadow.radius=2,this.lights.dirLight.shadow.mapSize.width=8192,this.lights.dirLight.shadow.mapSize.height=8192,this.lights.dirLight.shadow.camera.top=this.lights.dirLight.shadow.camera.right=1e3,this.lights.dirLight.shadow.camera.bottom=this.lights.dirLight.shadow.camera.left=-1e3,this.lights.dirLight.shadow.camera.near=1,this.lights.dirLight.shadow.camera.visible=!0,this.lights.dirLight.shadow.camera.far=4e8,this.lights.hemiLight=new i.HemisphereLight(new i.Color(16777215),new i.Color(16777215),.6),this.lights.hemiLight.color.setHSL(.661,.96,.12),this.lights.hemiLight.groundColor.setHSL(.11,.96,.14),this.lights.hemiLight.position.set(0,0,50),this.scene.add(this.lights.hemiLight),this.setSunlight()},setDefaultView:function(e,t){e.bbox=(e.bbox||null==e.bbox)&&t.enableSelectingObjects,e.tooltip=(e.tooltip||null==e.tooltip)&&t.enableTooltips,e.mapScale=this.map.transform.scale},memory:function(){return this.renderer.info.memory},programs:function(){return this.renderer.info.programs.length},version:"2.2.2"};var me={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,multiLayer:!1,orthographic:!1,fov:r.FOV_DEGREES};pe=pe=fe,window.Threebox=pe,window.THREE=i}(); \ No newline at end of file diff --git a/examples/01-basic.html b/examples/01-basic.html index 8acf4d9d..dd062846 100644 --- a/examples/01-basic.html +++ b/examples/01-basic.html @@ -1,9 +1,9 @@ Sphere Example - - - + + + + Threebox Object3D Example + + + + + +
diff --git a/examples/07-alignmentTest.html b/examples/07-alignmentTest.html index df4a8130..08bf826d 100644 --- a/examples/07-alignmentTest.html +++ b/examples/07-alignmentTest.html @@ -2,8 +2,8 @@ Threebox alignment Test - - + + diff --git a/examples/08-3dbuildings.html b/examples/08-3dbuildings.html index d1c4ad00..0b33203e 100644 --- a/examples/08-3dbuildings.html +++ b/examples/08-3dbuildings.html @@ -2,8 +2,8 @@ Threebox display buildings in 3D with auto tooltips - - + + diff --git a/examples/09-raycaster.html b/examples/09-raycaster.html index b73f3738..474bd546 100644 --- a/examples/09-raycaster.html +++ b/examples/09-raycaster.html @@ -1,8 +1,8 @@ Threebox raycaster of Objects3D, 3D models and Fill-extrusions - - + + diff --git a/examples/10-stylechange.html b/examples/10-stylechange.html index 3041c4c2..4085bd18 100644 --- a/examples/10-stylechange.html +++ b/examples/10-stylechange.html @@ -2,8 +2,8 @@ Threebox change map style for Eiffel Tower - - + + diff --git a/examples/11-animation.html b/examples/11-animation.html index 94c26473..271f3acc 100644 --- a/examples/11-animation.html +++ b/examples/11-animation.html @@ -4,8 +4,8 @@ - - + + diff --git a/examples/12-add3dmodel.html b/examples/12-add3dmodel.html index d85ba481..783865ac 100644 --- a/examples/12-add3dmodel.html +++ b/examples/12-add3dmodel.html @@ -1,12 +1,12 @@  - + Add a 3D model with Threebox - - + + diff --git a/examples/18-extrusions.html b/examples/18-extrusions.html index f74d592f..52ba7ec1 100644 --- a/examples/18-extrusions.html +++ b/examples/18-extrusions.html @@ -1,8 +1,8 @@ Threbox extrusions sample - - + + diff --git a/examples/19-fixedzoom.html b/examples/19-fixedzoom.html index 5b1a07be..0c699390 100644 --- a/examples/19-fixedzoom.html +++ b/examples/19-fixedzoom.html @@ -1,23 +1,23 @@ - Threebox fixed zoom - - - - - - + #map { + width: 100%; + height: 100%; + } + diff --git a/examples/20-game.html b/examples/20-game.html index c7890c43..4819ca78 100644 --- a/examples/20-game.html +++ b/examples/20-game.html @@ -1,22 +1,22 @@ - Threebox WASD driving game - - - - - - + diff --git a/examples/README.md b/examples/README.md index c024de30..3e55e84c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,6 +10,7 @@ These are the examples included in Threebox. #### [02-line.html](https://github.com/jscastro76/threebox/blob/master/examples/02-line.html) threebox
- This sample line arcs from a central point to different destinations with no interactions.
+- Updated to Mapbox 2.2.0 - - - - #### [03-tube.html](https://github.com/jscastro76/threebox/blob/master/examples/03-tube.html) @@ -19,27 +20,32 @@ These are the examples included in Threebox. - Enabled built-in dragging mode for 3D objects through `enableDraggingObjects`, 3D object is dragabble, once selected, using [Shift] key for translation and [Ctrl] for altitude. - Enabled built-in rotation mode for 3D objects through `enableRotatingObjects`, 3D objects is rotable on it's vertical axis, once selected, using [Alt] key. - Enabled built-in default Labels on altitude for the 3D object through `enableTooltips`.
+- Updated to Mapbox 2.2.0 - - - - #### [04-mercator.html](https://github.com/jscastro76/threebox/blob/master/examples/04-mercator.html) threebox
- This sample creates 100 spheres duplicated all around the world at the same height, but they look different because the height is calculated based on the latitude. +- Updated to Mapbox 2.2.0 - - - - #### [05-logistics.html](https://github.com/jscastro76/threebox/blob/master/examples/05-logistics.html) threebox
- This sample loads a 3D `.obj` model of a truck that is animated following a path once a point in the map is clicked. - The model is attached to the event `ObjectChanged`. +- Updated to Mapbox 2.2.0 - - - - #### [06-object3d.html](https://github.com/jscastro76/threebox/blob/master/examples/06-object3d.html) threebox
- This sample loads a 3D `.glb` model of a soldier.

+- Updated to Mapbox 2.2.0 - - - - #### [07-alignmentTest.html](https://github.com/jscastro76/threebox/blob/master/examples/07-alignmentTest.html) threebox
- This sample shows camera perspective and depth alignment between fill-extrusion layer and some Object3D created through Threebox.
+- Updated to Mapbox 2.2.0 - - - - #### [08-3dbuildings.html](https://github.com/jscastro76/threebox/blob/master/examples/08-3dbuildings.html) @@ -49,6 +55,7 @@ These are the examples included in Threebox. - Built-in default Labels on altitude for fill-extrusions through `enableTooltips` - Event handler management for Features through `map.on('SelectedFeatureChange', ...)`
- Enables the user to change dynamically the FOV for Perspective camera.
+- Updated to Mapbox 2.2.0 - - - - #### [09-raycaster.html](https://github.com/jscastro76/threebox/blob/master/examples/09-raycaster.html) @@ -59,14 +66,19 @@ These are the examples included in Threebox. - Enabled built-in rotation mode for 3D objects through `enableRotatingObjects`, 3D objects are rotable on it's vertical axis, once selected, using [Alt] key. - Enabled built-in default Labels on altitude both for fill-extrusions and 3D objects through `enableTooltips`.
- Enables the user to change dynamically the FOV for Perspective camera and the option to set an Orthographic camera.
+- Updated to Mapbox 2.2.0 - - - - + #### [10-stylechange.html](https://github.com/jscastro76/threebox/blob/master/examples/10-stylechange.html) threebox
- This sample shows how to change the style without affecting the 3D objects created using the method `tb.setStyle`
+- Updated to Mapbox 2.2.0 - - - - + #### [11-animation.html](https://github.com/jscastro76/threebox/blob/master/examples/11-animation.html) threebox
- This sample is a mix between [05-logistics.html](https://github.com/jscastro76/threebox/blob/master/examples/05-logistics.html) and [09-raycaster.html](https://github.com/jscastro76/threebox/blob/master/examples/09-raycaster.html) samples, and it shows an object can play at the same time an embedded animation and a Threebox animation.
+- Updated to Mapbox 2.2.0 - - - - #### [12-add3dmodel.html](https://github.com/jscastro76/threebox/blob/master/examples/12-add3dmodel.html) @@ -78,6 +90,7 @@ These are the examples included in Threebox. - Enabled built-in shadows for 3D Objects through `castShadow`. - Set the time map lights based on `setSunlight` for today. - Changes automatically the style from sunset to sunrise through `tb.getSunTimes`. +- Updated to Mapbox 2.2.0 - - - - #### [13-eiffel.html](https://github.com/jscastro76/threebox/blob/master/examples/13-eiffel.html) @@ -89,7 +102,7 @@ These are the examples included in Threebox. - Enabled built-in shadows for 3D Objects through `castShadow`. - Set the time map lights based on `setSunlight` for today. - Changes automatically the style from sunset to sunrise through `tb.getSunTimes`. -
+- Updated to Mapbox 2.2.0 - - - - #### [14-buildingshadow.html](https://github.com/jscastro76/threebox/blob/master/examples/14-buildingshadow.html) @@ -104,7 +117,7 @@ These are the examples included in Threebox. threebox
- This sample shows the performance of Threebox creating up to 1000 objects in a single layer.
- Added performance stats indicator.
- +- Updated to Mapbox 2.2.0 - - - - @@ -115,7 +128,7 @@ These are the examples included in Threebox. - Enabled built-in multilayer support through `multiLayer` param, this param will create an embedded internal layer in Threebox that will manage the render with a single call to tb.update so it's not needed in each layer definition. This saves a lot of resources as mapbox render loop only calls once to three.js render. - Each layer can be hidden explicitly with a button, but also each layer has a different zoom range through `tb.setLayoutZoomRange` so the layers will hide depending on zoom level. - Added performance stats indicator.
- +- Updated to Mapbox 2.2.0 - - - - #### [17-azuremaps.html](https://github.com/jscastro76/threebox/blob/master/examples/17-azuremaps.html) @@ -123,7 +136,6 @@ These are the examples included in Threebox. - This sample shows how to create an Azure Maps sample through threebox using the satellite Azure Maps style. - It adds two models, one with the Space Needle in real size and other with a Giant Soldier. - This sample shows how to add real sunlight position and shadows over this two models. - - - - - #### [18-extrusions.html](https://github.com/jscastro76/threebox/blob/master/examples/18-extrusions.html) @@ -131,6 +143,7 @@ These are the examples included in Threebox. - This sample shows how to create extrusions in two different ways. - The first way is to create a star based on an array of Vector2 points. - The second way creates dynamically features from a gesJson file with real complex features from the composite layer. +- Updated to Mapbox 2.2.0 - - - - @@ -139,6 +152,7 @@ These are the examples included in Threebox. - This sample shows how to have a fixed scale for an object at a concrete zoom level. In that way the object with preserve the same visual size when the zoom is lower than the fixed zoom value. - Enables the user to change dynamically to pan the camera to the object movement and change the fixed zoom level.
- The model is attached to the event `ObjectChanged` to call `map.panTo` method from mapbox. +- Updated to Mapbox 2.2.0 - - - - @@ -148,6 +162,7 @@ These are the examples included in Threebox. - This sample shows how to implement an easy driving game experience with WASD controls. - Enables the user to change dynamically to speed, inertia and to activate a fill-extrusion buildings layer; - The model is attached to the event `ObjectChanged` to paint in red the buildings the truck. +- Updated to Mapbox 2.2.0 - - - - diff --git a/src/camera/CameraSync.js b/src/camera/CameraSync.js index 138a0c38..49bc2129 100644 --- a/src/camera/CameraSync.js +++ b/src/camera/CameraSync.js @@ -67,19 +67,46 @@ CameraSync.prototype = { return; } - // Furthest distance optimized by @jscastro76 const t = this.map.transform; + let farZ = 0; + let furthestDistance = 0; + this.state.fov = t._fov; + this.halfFov = this.state.fov / 2; const groundAngle = Math.PI / 2 + t._pitch; - this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height; - this.state.cameraTranslateZ = new THREE.Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance); - const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.state.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov); const pitchAngle = Math.cos((Math.PI / 2) - t._pitch); //pitch seems to influence heavily the depth calculation and cannot be more than 60 = PI/3 + this.cameraToCenterDistance = 0.5 / Math.tan(this.halfFov) * t.height; + + if (window.mapboxgl && parseFloat(window.mapboxgl.version) >= 2.0) { + // mapbox version >= 2.0 + const worldSize = this.worldSize(t); + const pixelsPerMeter = this.mercatorZfromAltitude(1, t.center.lat) * worldSize; + const fovAboveCenter = this.fovAboveCenter(t); + + // Adjust distance to MSL by the minimum possible elevation visible on screen, + // this way the far plane is pushed further in the case of negative elevation. + const minElevationInPixels = 0; // TODO test with elevation exageration this.elevation ? this.elevation.getMinElevationBelowMSL() * pixelsPerMeter : 0; + const cameraToSeaLevelDistance = ((t._camera.position[2] * worldSize) - minElevationInPixels) / Math.cos(t._pitch); + const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(utils.clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01)); + + // Calculate z distance of the farthest fragment that should be rendered. + furthestDistance = pitchAngle * topHalfSurfaceDistance + cameraToSeaLevelDistance; + + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + const horizonDistance = cameraToSeaLevelDistance * (1 / t._horizonShift); + farZ = Math.min(furthestDistance * 1.01, horizonDistance); + } else { + // mapbox version < 2.0 or azure maps + // Furthest distance optimized by @jscastro76 + const topHalfSurfaceDistance = Math.sin(this.halfFov) * this.state.cameraToCenterDistance / Math.sin(Math.PI - groundAngle - this.halfFov); + + // Calculate z distance of the farthest fragment that should be rendered. + furthestDistance = pitchAngle * topHalfSurfaceDistance + this.state.cameraToCenterDistance; - // Calculate z distance of the farthest fragment that should be rendered. - const furthestDistance = pitchAngle * topHalfSurfaceDistance + this.state.cameraToCenterDistance; + // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` + farZ = furthestDistance * 1.01; - // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance` - const farZ = furthestDistance * 1.01; + } + this.state.cameraTranslateZ = new THREE.Matrix4().makeTranslation(0, 0, this.cameraToCenterDistance); // someday @ansis set further near plane to fix precision for deckgl,so we should fix it to use mapbox-gl v1.3+ correctly // https://github.com/mapbox/mapbox-gl-js/commit/5cf6e5f523611bea61dae155db19a7cb19eb825c#diff-5dddfe9d7b5b4413ee54284bc1f7966d @@ -117,8 +144,26 @@ CameraSync.prototype = { .premultiply(scale) .premultiply(translateMap) + // utils.prettyPrintMatrix(this.camera.projectionMatrix.elements); + this.map.fire('CameraSynced', { detail: { nearZ: nearZ, farZ: farZ, pitch: t._pitch, angle: t.angle, furthestDistance: furthestDistance, maxFurthestDistance: this.state.maxFurthestDistance, cameraToCenterDistance: this.cameraToCenterDistance, t: this.map.transform, tbProjMatrix: this.camera.projectionMatrix.elements, tbWorldMatrix: this.world.matrix.elements, cameraSyn: CameraSync } }); + + }, + + worldSize(transform) { + return transform.tileSize * transform.scale; }, + fovAboveCenter(transform) { + return transform._fov * (0.5 + transform.centerOffset.y / transform.height); + }, + + mercatorZfromAltitude(altitude, lat) { + return altitude / this.circumferenceAtLatitude(lat); + }, + + circumferenceAtLatitude(latitude) { + return ThreeboxConstants.EARTH_CIRCUMFERENCE * Math.cos(latitude * Math.PI / 180); + }, calcCameraMatrix(pitch, angle, trz) { const t = this.map.transform;