soonspacejs 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as e from"three";import{Vector3 as t,Euler as n,Box3 as i,Quaternion as r,CubeTextureLoader as s,RGBAFormat as o,Color as a,Texture as l,Source as c,LinearEncoding as u,MathUtils as h,DoubleSide as d,BufferAttribute as f,PropertyBinding as p,InterpolateDiscrete as g,Matrix4 as m,Scene as v,InterpolateLinear as y,NearestFilter as w,NearestMipmapNearestFilter as b,NearestMipmapLinearFilter as x,LinearFilter as A,LinearMipmapNearestFilter as T,LinearMipmapLinearFilter as S,ClampToEdgeWrapping as E,RepeatWrapping as D,MirroredRepeatWrapping as C,sRGBEncoding as I,Vector2 as M,Plane as B,Line3 as R,Triangle as P,Sphere as O,BackSide as _,FrontSide as L,Mesh as k,Ray as N,BoxGeometry as U,MeshStandardMaterial as F,PointLight as j,MeshBasicMaterial as z,DataTextureLoader as H,HalfFloatType as G,FloatType as V,DataUtils as Y,ShaderMaterial as W,UniformsUtils as X,Fog as Q,EdgesGeometry as K,LineSegments as Z,LineBasicMaterial as q,Object3D as J,PerspectiveCamera as $,OrthographicCamera as ee,WebGLRenderer as te,PCFSoftShadowMap as ne,Camera as ie,UnsignedByteType as re,MeshNormalMaterial as se,WebGLRenderTarget as oe,DepthTexture as ae,DepthStencilFormat as le,UnsignedInt248Type as ce,UnsignedIntType as ue,Uniform as he,LoadingManager as de,NoBlending as fe,RGBADepthPacking as pe,REVISION as ge,EventDispatcher as me,MeshDepthMaterial as ve,BasicDepthPacking as ye,DataTexture as we,Vector4 as be,BufferGeometry as xe,Material as Ae,LuminanceFormat as Te,RedFormat as Se,RGFormat as Ee,ShaderChunk as De,WebGLCubeRenderTarget as Ce,CubeCamera as Ie,PMREMGenerator as Me,WebGLMultipleRenderTargets as Be,FramebufferTexture as Re,Matrix3 as Pe,TangentSpaceNormalMap as Oe,GLSL3 as _e,VideoTexture as Le,Frustum as ke,MOUSE as Ne,TOUCH as Ue,Spherical as Fe,CanvasTexture as je,PlaneGeometry as ze,Raycaster as He,Clock as Ge,AnimationMixer as Ve,ACESFilmicToneMapping as Ye,AnimationClip as We,NoToneMapping as Xe,LinearToneMapping as Qe,ReinhardToneMapping as Ke,CineonToneMapping as Ze,EquirectangularReflectionMapping as qe,TextureLoader as Je,Sprite as $e,SpriteMaterial as et,SphereGeometry as tt,CircleGeometry as nt,Float32BufferAttribute as it,ShapeGeometry as rt,Shape as st,UniformsLib as ot,UVMapping as at,AmbientLight as lt,DirectionalLight as ct,HemisphereLight as ut,SpotLight as ht,RectAreaLight as dt,Curve as ft,Loader as pt,LoaderUtils as gt,FileLoader as mt,MeshPhongMaterial as vt,MeshLambertMaterial as yt,Group as wt,Bone as bt,SkinnedMesh as xt,Line as At,Skeleton as Tt,Uint16BufferAttribute as St,VectorKeyframeTrack as Et,QuaternionKeyframeTrack as Dt,NumberKeyframeTrack as Ct,TrianglesDrawMode as It,TriangleFanDrawMode as Mt,TriangleStripDrawMode as Bt,MeshPhysicalMaterial as Rt,InstancedMesh as Pt,ImageBitmapLoader as Ot,InterleavedBuffer as _t,InterleavedBufferAttribute as Lt,PointsMaterial as kt,LineLoop as Nt,Points as Ut,Interpolant as Ft,LinearMipMapLinearFilter as jt,ImageLoader as zt,GridHelper as Ht,AxesHelper as Gt,Box3Helper as Vt,DirectionalLightHelper as Yt,HemisphereLightHelper as Wt,SpotLightHelper as Xt,PointLightHelper as Qt,Box2 as Kt}from"three";export*from"three";var Zt,qt="soonspacejs",Jt="2.6.0",$t={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-$t.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*$t.Bounce.In(2*e):.5*$t.Bounce.Out(2*e-1)+.5}}},en="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},tn=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map((function(t){return e._tweens[t]}))},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){void 0===e&&(e=en()),void 0===t&&(t=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],s=!t;r&&!1===r.update(e,s)&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),nn={Linear:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.Linear;return t<0?s(e[0],e[1],i):t>1?s(e[n],e[n-1],n-i):s(e[r],e[r+1>n?n:r+1],i-r)},Bezier:function(e,t){for(var n=0,i=e.length-1,r=Math.pow,s=nn.Utils.Bernstein,o=0;o<=i;o++)n+=r(1-t,i-o)*r(t,o)*e[o]*s(i,o);return n},CatmullRom:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(r=Math.floor(i=n*(1+t))),s(e[(r-1+n)%n],e[r],e[(r+1)%n],e[(r+2)%n],i-r)):t<0?e[0]-(s(e[0],e[0],e[1],e[1],-i)-e[0]):t>1?e[n]-(s(e[n],e[n],e[n-1],e[n-1],i-n)-e[n]):s(e[r?r-1:0],e[r],e[n<r+1?n:r+1],e[n<r+2?n:r+2],i-r)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=nn.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(Zt=[1],function(e){var t=1;if(Zt[e])return Zt[e];for(var n=e;n>1;n--)t*=n;return Zt[e]=t,t}),CatmullRom:function(e,t,n,i,r){var s=.5*(n-e),o=.5*(i-t),a=r*r;return(2*t-2*n+s+o)*(r*a)+(-3*t+3*n-2*s-o)*a+s*r+t}}},rn=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),sn=new tn,on=function(){function e(e,t){void 0===t&&(t=sn),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=$t.Linear.None,this._interpolationFunction=nn.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=rn.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),void 0!==t&&(this._duration=t),this},e.prototype.duration=function(e){return this._duration=e,this},e.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var t in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==e?"string"==typeof e?en()+parseFloat(e):e:en(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},e.prototype._setupProperties=function(e,t,n,i){for(var r in n){var s=e[r],o=Array.isArray(s),a=o?"array":typeof s,l=!o&&Array.isArray(n[r]);if("undefined"!==a&&"function"!==a){if(l){var c=n[r];if(0===c.length)continue;c=c.map(this._handleRelativeValue.bind(this,s)),n[r]=[s].concat(c)}if("object"!==a&&!o||!s||l)void 0===t[r]&&(t[r]=s),o||(t[r]*=1),i[r]=l?n[r].slice().reverse():t[r]||0;else{for(var u in t[r]=o?[]:{},s)t[r][u]=s[u];i[r]=o?[]:{},this._setupProperties(s,t[r],n[r],i[r])}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return void 0===e&&(e=en()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this)),this},e.prototype.resume=function(e){return void 0===e&&(e=en()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return this._group=e,this},e.prototype.delay=function(e){return this._delayTime=e,this},e.prototype.repeat=function(e){return this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return this._yoyo=e,this},e.prototype.easing=function(e){return this._easingFunction=e,this},e.prototype.interpolation=function(e){return this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){if(void 0===e&&(e=en()),void 0===t&&(t=!0),this._isPaused)return!0;var n,i,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e)}if(this._goToEnd=!1,e<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(e-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var s=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,s),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,a=this._chainedTweens.length;o<a;o++)this._chainedTweens[o].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(void 0!==t[r]){var s=t[r]||0,o=n[r],a=Array.isArray(e[r]),l=Array.isArray(o);!a&&l?e[r]=this._interpolationFunction(o,i):"object"==typeof o&&o?this._updateProperties(e[r],s,o,i):"number"==typeof(o=this._handleRelativeValue(s,o))&&(e[r]=s+(o-s)*i)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof n?this._valuesStartRepeat[e]+parseFloat(n):this._valuesEnd[e],this._valuesEnd[e]=t},e}(),an=rn.nextId,ln=sn,cn=ln.getAll.bind(ln),un=ln.removeAll.bind(ln),hn=ln.add.bind(ln),dn=ln.remove.bind(ln),fn=ln.update.bind(ln),pn={Easing:$t,Group:tn,Interpolation:nn,now:en,Sequence:rn,nextId:an,Tween:on,VERSION:"18.6.4",getAll:cn,removeAll:un,add:hn,remove:dn,update:fn};const gn="[soonspacejs]: ",mn="In soonspacejs: ",vn=(e,t)=>{let n="";for(const e in t)n+=`${e}: ${t[e]};`;console.log(`%c${e}`,n)},yn=e=>{console.warn(mn+e)};function wn(e){return e instanceof t?e:new t(e.x,e.y,e.z)}function bn(e){return e instanceof n?e:new n(e.x,e.y,e.z)}function xn(e){return new i(new t(0,0,0),new t(500,500,500)).setFromObject(e)}function An(e,t,n){const i=n.clone();return Math.abs(t[e]-n[e])>Math.PI&&(t[e]>n[e]?i[e]+=2*Math.PI:i[e]-=2*Math.PI),i}function Tn(e,t){const i=An("x",e,t),r=An("y",e,t),s=An("z",e,t);return new n(i.x,r.y,s.z,t.order)}function Sn(e){return Math.PI/180*e}function En(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?{position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)}:{position:e.position.clone(),rotation:e.rotation.clone(),scale:e.scale.clone()}}function Dn(e,t){const n=En(t,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);e.position.copy(n.position),e.rotation.copy(n.rotation),e.scale.copy(n.scale)}function Cn(e){return!!e.visible&&(!e.parent||Cn(e.parent))}class In{constructor(){this.min=null,this.roots=[],this.nodes=new Map}shift(){const e=this.min;if(null===e||this.roots.length<1)return this.min=null,e;this.remove(e),this.roots.length>50&&this.consolidate();let t=1/0;const n=this.roots.length;for(let e=0;e<n;e++){const n=this.roots[e],i=this.getDistance(n);i<t&&(t=i,this.min=n)}return e}consolidate(){const e=[[],[],[],[],[],[],[]],t=e.length-1,n=this.roots.length;for(let i=0;i<n;i++){const n=this.roots[i],r=this.nodes.get(n);r&&r.depth<t&&e[r.depth].push(n)}for(let n=0;n<=t;n++)for(;e[n].length>1;){const i=e[n].shift(),r=e[n].shift(),s=n+1;let o=-1;if(void 0!==i&&void 0!==r){const n=this.nodes.get(i),a=this.nodes.get(r);n&&a&&(n.distance<a.distance?(n.depth=s,n.children.push(r),a.parent=i,s<=t&&e[s].push(i),o=this.roots.indexOf(r)):(a.depth=s,a.children.push(i),n.parent=r,s<=t&&e[s].push(r),o=this.roots.indexOf(i)))}o>-1&&this.roots.splice(o,1)}}add(e,t){if(this.nodes.set(e,{nodeIndex:e,distance:t,depth:0,parent:null,children:[]}),null===this.min)this.min=e;else{const n=this.nodes.get(this.min);n&&t<n.distance&&(this.min=e)}this.roots.push(e)}update(e,t){this.remove(e),this.add(e,t)}remove(e){var t,n;if(!this.nodes.has(e))return;const i=null===(t=this.nodes.get(e))||void 0===t?void 0:t.children;if(i&&i.length>0)for(let t=0;t<i.length;t++){const n=i[t],r=this.nodes.get(n),s=this.nodes.get(e);r&&s&&(r.parent=s.parent),r&&null===r.parent&&this.roots.push(n)}let r=null===(n=this.nodes.get(e))||void 0===n?void 0:n.parent;if(null===r){const t=this.roots.indexOf(e);t>-1&&this.roots.splice(t,1)}else for(;r;){const e=this.nodes.get(r);e&&(e.depth--,r=e.parent)}}getDistance(e){const t=this.nodes.get(e);return t?t.distance:1/0}}function Mn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["px.jpg","nx.jpg","py.jpg","ny.jpg","pz.jpg","nz.jpg"];return new Promise((n=>{(new s).setPath(e).load(t,(e=>{e.format=o,n(e)}))}))}function Bn(e){if(!e)return null;const{colors:t,stops:n,size:i=1024}=e,r=document.createElement("canvas"),s=r.getContext("2d");if(!s)return null;r.width=16,r.height=i;const o=s.createLinearGradient(0,0,0,i),c=new a,u=t.map((e=>c.set(e).getStyle()));for(let e=0,t=u.length-1;e<=t;e++)o.addColorStop(n?n[e]:e/t,u[e]);s.fillStyle=o,s.fillRect(0,0,16,i);const h=new l(r);return h.needsUpdate=!0,h}const Rn=e=>{const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)};function Pn(e){return ji(e)?function(e){return e.map((e=>Pn(e)))}(e):zi(e)?function(e){if(zi(e)){const t={};for(const n in e)t[n]=Pn(e[n]);return t}return e}(e):e}const On=(e,t)=>ji(e)?e.map(t):t(e),_n=e=>On(e,(e=>e.clone())),Ln=e=>On(e,(e=>e.dispose()));var kn=function(e,t){return kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},kn(e,t)};var Nn=function(){return Nn=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Nn.apply(this,arguments)};function Un(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function Fn(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}var jn=Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]};function zn(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hn(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function Gn(e){return this instanceof Gn?(this.v=e,this):new Gn(e)}var Vn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Yn(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Wn(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var Xn=Object.freeze({__proto__:null,get __assign(){return Nn},__asyncDelegator:function(e){var t,n;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(n=!n)?{value:Gn(e[i](t)),done:!1}:r?r(t):t}:r}},__asyncGenerator:function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise((function(n,i){s.push([e,t,n,i])>1||a(e,t)}))})}function a(e,t){try{(n=r[e](t)).value instanceof Gn?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=zn(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){(function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)})(i,r,(t=e[n](t)).done,t.value)}))}}},__await:Gn,__awaiter:Fn,__classPrivateFieldGet:Yn,__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)},__classPrivateFieldSet:Wn,__createBinding:jn,__decorate:function(e,t,n,i){var r,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,n,o):r(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o},__esDecorate:function(e,t,n,i,r,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,l=i.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?i.static?e:e.prototype:null,h=t||(u?Object.getOwnPropertyDescriptor(u,i.name):{}),d=!1,f=n.length-1;f>=0;f--){var p={};for(var g in i)p[g]="access"===g?{}:i[g];for(var g in i.access)p.access[g]=i.access[g];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var m=(0,n[f])("accessor"===l?{get:h.get,set:h.set}:h[c],p);if("accessor"===l){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(a=o(m.get))&&(h.get=a),(a=o(m.set))&&(h.set=a),(a=o(m.init))&&r.push(a)}else(a=o(m))&&("field"===l?r.push(a):h[c]=a)}u&&Object.defineProperty(u,i.name,h),d=!0},__exportStar:function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||jn(t,e,n)},__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}kn(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},__generator:function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&jn(t,e,n);return Vn(t,e),t},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__param:function(e,t){return function(n,i){t(n,i,e)}},__propKey:function(e){return"symbol"==typeof e?e:"".concat(e)},__read:Hn,__rest:Un,__runInitializers:function(e,t,n){for(var i=arguments.length>2,r=0;r<t.length;r++)n=i?t[r].call(e,n):t[r].call(e);return i?n:void 0},__setFunctionName:function(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})},__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Hn(arguments[t]));return e},__spreadArray:function(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},__spreadArrays:function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var i=Array(e),r=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i},__values:zn});const Qn=e=>Fn(void 0,void 0,void 0,(function*(){const t=yield fetch(e);if(200===t.status)return t;throw new Error(`Failed to fetch file: ${e}`)})),Kn=e=>{"function"==typeof requestIdleCallback?requestIdleCallback(e):setTimeout(e)};var Zn=function(){function e(){}return e.prototype.toJson=function(e,t){var n=this.xmlStringToXmlDom(e),i=this.xmlToJson(n);return t?(t.removeLineBreaks&&this.removeLineBreaks(i),t.removeComments&&this.removeCommentProperties(i),t.transformTextOnly&&this.transformTextOnly(i),i):i},e.prototype.xmlStringToXmlDom=function(e){return(new DOMParser).parseFromString(e,"text/xml")},e.prototype.removeLineBreaks=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#text"===n&&Array.isArray(e[n])&&delete e[n],"object"==typeof e[n]&&t.removeLineBreaks(e[n])}))},e.prototype.removeCommentProperties=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#comment"===n&&delete e[n],"object"==typeof e[n]&&t.removeCommentProperties(e[n])}))},e.prototype.transformTextOnly=function(e){var t=this;Object.keys(e).forEach((function(n,i){var r=Object.keys(e[n]).length>1,s=Object.keys(e[n])[0];r||"object"==typeof e[n][s]?t.transformTextOnly(e[n]):"object"==typeof e[n]&&e[n]["#text"]&&(e[n]=e[n]["#text"])}))},e.prototype.xmlToJson=function(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t._attributes={};for(var n=0;n<e.attributes.length;n++){var i=e.attributes.item(n);t._attributes[i.nodeName]=i.nodeValue}}}else 3==e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes.item(r),o=s.nodeName;if(void 0===t[o])t[o]=this.xmlToJson(s);else{if(void 0===t[o].push){var a=t[o];t[o]=[],t[o].push(a)}t[o].push(this.xmlToJson(s))}}return t},e}();function qn(e){return Qn(e).then((e=>e.text())).then((e=>Promise.resolve(function(e){return(new Zn).toJson(e,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(e))))}class Jn{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Ii(e)})),this.register((function(e){return new Mi(e)})),this.register((function(e){return new Pi(e)})),this.register((function(e){return new Oi(e)})),this.register((function(e){return new _i(e)})),this.register((function(e){return new Li(e)})),this.register((function(e){return new Bi(e)})),this.register((function(e){return new Ri(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){const r=new Ci,s=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)s.push(this.pluginCallbacks[e](r));r.setPlugins(s),r.write(e,t,i).catch(n)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,i,r,t)}))}}const $n=0,ei=1,ti=2,ni=3,ii=4,ri=5121,si=5123,oi=5126,ai=5125,li=34962,ci=34963,ui=9728,hi=9729,di=9984,fi=9985,pi=9986,gi=9987,mi=33071,vi=33648,yi=10497,wi={};wi[w]=ui,wi[b]=di,wi[x]=pi,wi[A]=hi,wi[T]=fi,wi[S]=gi,wi[E]=mi,wi[D]=yi,wi[C]=vi;const bi={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},xi=new a;function Ai(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function Ti(e){return 4*Math.ceil(e/4)}function Si(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=Ti(e.byteLength);if(n!==e.byteLength){const i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<n;r++)i[r]=t;return i.buffer}return e}function Ei(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function Di(e,t){if(void 0!==e.toBlob)return new Promise((n=>e.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}class Ci{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const o=i.extensionsUsed,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o);if(l.length>0&&(s.extensionsUsed=l),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=a.size),!0===n.binary){const e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){const n=Si(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=Si((o=JSON.stringify(s),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,r.byteLength,!0),a.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const u=12+a.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,u,!0);const h=new Blob([l,a,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(h),d.onloadend=function(){t(d.result)}}}else if(s.buffers&&s.buffers.length>0){const e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){const n=e.result;s.buffers[0].uri=n,t(s)}}else t(s)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new t;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const i=e.clone(),r=new t;for(let e=0,t=i.count;e<t;e++)r.fromBufferAttribute(i,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),i.setXYZ(e,r.x,r.y,r.z);return n.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let n=!1;const i={};0===t.offset.x&&0===t.offset.y||(i.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(i.rotation=t.rotation,n=!0),1===t.repeat.x&&1===t.repeat.y||(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.encoding===I?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");const i=e?e.image:null,r=t?t.image:null,s=Math.max(i?i.width:0,r?r.width:0),o=Math.max(i?i.height:0,r?r.height:0),a=Ei();a.width=s,a.height=o;const l=a.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,s,o);const h=l.getImageData(0,0,s,o);if(i){l.drawImage(i,0,0,s,o);const t=n(e),r=l.getImageData(0,0,s,o).data;for(let e=2;e<r.length;e+=4)h.data[e]=256*t(r[e]/256)}if(r){l.drawImage(r,0,0,s,o);const e=n(t),i=l.getImageData(0,0,s,o).data;for(let t=1;t<i.length;t+=4)h.data[t]=256*e(i[t]/256)}l.putImageData(h,0,0);const d=(e||t).clone();return d.source=new c(a),d.encoding=u,d}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,r){const s=this.json;let o;s.bufferViews||(s.bufferViews=[]),o=t===ri?1:t===si?2:4;const a=Ti(i*e.itemSize*o),l=new DataView(new ArrayBuffer(a));let c=0;for(let r=n;r<n+i;r++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[r*e.itemSize+n]:(0===n?i=e.getX(r):1===n?i=e.getY(r):2===n?i=e.getZ(r):3===n&&(i=e.getW(r)),!0===e.normalized&&(i=h.normalize(i,e.array))),t===oi?l.setFloat32(c,i,!0):t===ai?l.setUint32(c,i,!0):t===si?l.setUint16(c,i,!0):t===ri&&l.setUint8(c,i),c+=o}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==r&&(u.target=r),r===li&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const e=Si(r.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(e,t,n,i){const r=this.json;let s;if(e.array.constructor===Float32Array)s=oi;else if(e.array.constructor===Uint32Array)s=ai;else if(e.array.constructor===Uint16Array)s=si;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");s=ri}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;const o=function(e,t,n){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+n;r++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=h.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);let a;void 0!==t&&(a=e===t.index?ci:li);const l=this.processBufferView(e,s,n,i,a),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(null!==e){const r=this,s=r.cache,a=r.json,l=r.options,c=r.pending;s.images.has(e)||s.images.set(e,{});const u=s.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);const d={mimeType:i},f=Ei();f.width=Math.min(e.width,l.maxTextureSize),f.height=Math.min(e.height,l.maxTextureSize);const p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==o&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else p.drawImage(e,0,0,f.width,f.height);!0===l.binary?c.push(Di(f,i).then((e=>r.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):void 0!==f.toDataURL?d.uri=f.toDataURL(i):c.push(Di(f,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{d.uri=e})));const g=a.images.push(d)-1;return u[h]=g,g}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:wi[e.magFilter],minFilter:wi[e.minFilter],wrapS:wi[e.wrapS],wrapT:wi[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");const r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(r.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,r)}));const s=n.textures.push(r)-1;return t.textures.set(e,s),s}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(Ai(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t)};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),n=Math.max(t.r,t.g,t.b);if(n>1&&(t.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(i.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===d&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));const s=n.materials.push(i)-1;return t.materials.set(e,s),s}processMesh(e){const t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);const r=i.join(":");if(t.meshes.has(r))return t.meshes.get(r);const s=e.geometry;let o;o=e.isLineSegments?ei:e.isLineLoop?ti:e.isLine?ni:e.isPoints?$n:e.material.wireframe?ei:ii;const a={},l={},c=[],u=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");void 0===d||this.isNormalizedNormalAttribute(d)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let p=null;for(let e in s.attributes){if("morph"===e.slice(0,5))continue;const n=s.attributes[e];e=h[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(n))){l[e]=t.attributes.get(this.getUID(n));continue}p=null;const i=n.array;"JOINTS_0"!==e||i instanceof Uint16Array||i instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new f(new Uint16Array(i),n.itemSize,n.normalized));const r=this.processAccessor(p||n,s);null!==r&&(l[e]=r,t.attributes.set(this.getUID(n),r))}if(void 0!==d&&s.setAttribute("normal",d),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){const a={};let l=!1;for(const e in s.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}const n=s.morphAttributes[e][o],i=e.toUpperCase(),r=s.attributes[e];if(t.attributes.has(this.getUID(n,!0))){a[i]=t.attributes.get(this.getUID(n,!0));continue}const c=n.clone();if(!s.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)0===t&&c.setX(e,n.getX(e)-r.getX(e)),1===t&&c.setY(e,n.getY(e)-r.getY(e)),2===t&&c.setZ(e,n.getZ(e)-r.getZ(e)),3===t&&c.setW(e,n.getW(e)-r.getW(e));a[i]=this.processAccessor(c,s),t.attributes.set(this.getUID(r,!0),a[i])}u.push(a),n.push(e.morphTargetInfluences[o]),void 0!==e.morphTargetDictionary&&i.push(r[o])}a.weights=n,i.length>0&&(a.extras={},a.extras.targetNames=i)}const g=Array.isArray(e.material);if(g&&0===s.groups.length)return null;const m=g?e.material:[e.material],v=g?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=v.length;e<n;e++){const n={mode:o,attributes:l};if(this.serializeUserData(s,n),u.length>0&&(n.targets=u),null!==s.index){let i=this.getUID(s.index);void 0===v[e].start&&void 0===v[e].count||(i+=":"+v[e].start+":"+v[e].count),t.attributes.has(i)?n.indices=t.attributes.get(i):(n.indices=this.processAccessor(s.index,s,v[e].start,v[e].count),t.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=this.processMaterial(m[v[e].materialIndex]);null!==i&&(n.material=i),c.push(n)}a.primitives=c,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,a)}));const y=n.meshes.push(a)-1;return t.meshes.set(r,y),y}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:h.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(e=Jn.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,s=[],o=[];for(let e=0;e<r.length;++e){const n=r[e],a=p.parseTrackName(n.name);let l=p.findNode(t,a.nodeName);const c=bi[a.propertyName];if("bones"===a.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(a.objectIndex):void 0),!l||!c)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',n.name),null;const u=1;let h,d=n.values.length/n.times.length;c===bi.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(h="CUBICSPLINE",d/=3):h=n.getInterpolation()===g?"STEP":"LINEAR",o.push({input:this.processAccessor(new f(n.times,u)),output:this.processAccessor(new f(n.values,d)),interpolation:h}),s.push({sampler:o.length-1,target:{node:i.get(l),path:c}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:s}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],r=e.skeleton;if(void 0===r)return null;const s=e.skeleton.bones[0];if(void 0===s)return null;const o=[],a=new Float32Array(16*r.bones.length),l=new m;for(let t=0;t<r.bones.length;++t)o.push(n.get(r.bones[t])),l.copy(r.boneInverses[t]),l.multiply(e.bindMatrix).toArray(a,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new f(a,16)),joints:o,skeleton:n.get(s)});return i.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const t=e.quaternion.toArray(),n=e.position.toArray(),i=e.scale.toArray();Ai(t,[0,0,0,1])||(r.rotation=t),Ai(n,[0,0,0])||(r.translation=n),Ai(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Ai(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let i=0,r=e.children.length;i<r;i++){const r=e.children[i];if(r.visible||!1===n.onlyVisible){const e=this.processNode(r);null!==e&&t.push(e)}}t.length>0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));const s=t.nodes.push(r)-1;return i.set(e,s),s}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);const r=[];for(let t=0,i=e.children.length;t<i;t++){const i=e.children[t];if(i.visible||!1===n.onlyVisible){const e=this.processNode(i);null!==e&&r.push(e)}}r.length>0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){const t=new v;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const n=[];for(let t=0;t<e.length;t++)e[t]instanceof v?this.processScene(e[t]):n.push(e[t]);n.length>0&&this.processObjects(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class Ii{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const n=this.writer,i=n.json,r=n.extensionsUsed,s={};e.name&&(s.name=e.name),s.color=e.color.toArray(),s.intensity=e.intensity,e.isDirectionalLight?s.type="directional":e.isPointLight?(s.type="point",e.distance>0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const o=i.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}let Mi=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Bi=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:n.processTexture(e.clearcoatMap)};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:n.processTexture(e.clearcoatRoughnessMap)};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:n.processTexture(e.clearcoatNormalMap)};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Ri=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:n.processTexture(e.iridescenceMap)};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:n.processTexture(e.iridescenceThicknessMap)};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Pi=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const t={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Oi=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const t={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},_i=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},Li=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(xi)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){const t={index:n.processTexture(e.specularIntensityMap)};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){const t={index:n.processTexture(e.specularColorMap)};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}};Jn.Utils={insertKeyframe:function(e,t){const n=.001,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),s=new e.ValueBufferType(e.values.length+i),o=e.createInterpolant(new e.ValueBufferType(i));let a;if(0===e.times.length){r[0]=t;for(let e=0;e<i;e++)s[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;r[0]=t,r.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,i),a=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),a=r.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<n)return l;if(e.times[l]<t&&e.times[l+1]>t){r.set(e.times.slice(0,l+1),0),r[l+1]=t,r.set(e.times.slice(l+1),l+2),s.set(e.values.slice(0,(l+1)*i),0),s.set(o.evaluate(t),(l+1)*i),s.set(e.values.slice((l+1)*i),(l+2)*i),a=l+1;break}}return e.times=r,e.values=s,a},mergeMorphTargetTracks:function(e,t){const n=[],i={},r=e.tracks;for(let e=0;e<r.length;++e){let s=r[e];const o=p.parseTrackName(s.name),a=p.findNode(t,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){n.push(s);continue}if(s.createInterpolant!==s.InterpolantFactoryMethodDiscrete&&s.createInterpolant!==s.InterpolantFactoryMethodLinear){if(s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),s=s.clone(),s.setInterpolation(y)}const l=a.morphTargetInfluences.length,c=a.morphTargetDictionary[o.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(void 0===i[a.uuid]){u=s.clone();const e=new u.ValueBufferType(l*u.times.length);for(let t=0;t<u.times.length;t++)e[t*l+c]=u.values[t];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=e,i[a.uuid]=u,n.push(u);continue}const h=s.createInterpolant(new s.ValueBufferType(1));u=i[a.uuid];for(let e=0;e<u.times.length;e++)u.values[e*l+c]=h.evaluate(u.times[e]);for(let e=0;e<s.times.length;e++){const t=this.insertKeyframe(u,s.times[e]);u.values[t*l+c]=s.values[e]}}return e.tracks=n,e}};const ki=Object.prototype.hasOwnProperty,Ni=e=>"String"===Gi(e),Ui=e=>"Boolean"===Gi(e),Fi=e=>"Number"===Gi(e),ji=Array.isArray,zi=e=>"Object"===Gi(e),Hi=e=>"Function"===Gi(e),Gi=e=>Object.prototype.toString.call(e).slice(8,-1),Vi=(e,t,n)=>String.fromCodePoint(...new Uint8Array(e,t,n)),Yi=()=>gn+Math.random().toString(36).substring(7).split("").join("_"),Wi=e=>{var t;const{pathname:n}=new URL(e,location.origin);return null===(t=n.split(".").pop())||void 0===t?void 0:t.toLowerCase()};var Xi=Object.freeze({__proto__:null,IVector3ToEuler:bn,IVector3ToVector3:wn,MinHeap:In,cloneDeep:Pn,cloneMaterials:_n,deg2Euler:Sn,disposeMaterials:Ln,error:e=>{console.error(mn+e)},euler2Deg:function(e){return e/(Math.PI/180)},exportGltf:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((n,i)=>{(new Jn).parse(e,(e=>n(e)),(e=>i(e)),t)}))},fetchFile:Qn,getAsciiString:Vi,getBoundingBox:xn,getCubeTexture:Mn,getExtension:Wi,getSpaceAttributeFromObject:En,getValueType:Gi,gradientTexture:Bn,hasOwn:(e,t)=>ki.call(e,t),idleTask:Kn,isArray:ji,isBoolean:Ui,isDate:e=>"Date"===Gi(e),isFunction:Hi,isNull:e=>"Null"===Gi(e),isNumber:Fi,isObject:zi,isObjectVisible:Cn,isPromise:e=>"Promise"===Gi(e),isString:Ni,isSymbol:e=>"Symbol"===Gi(e),isUndefined:e=>"Undefined"===Gi(e),log:vn,materialHandle:On,parseFilePath:Rn,randomString:Yi,rotationAFix:Tn,rotationAxisFix:An,sleep:e=>new Promise((t=>setTimeout((()=>t()),e))),syncSpaceAttributeToObject:Dn,warn:yn,xmlToJson:qn});const Qi={"Linear.None":$t.Linear.None,"Quadratic.In":$t.Quadratic.In,"Quadratic.Out":$t.Quadratic.Out,"Quadratic.InOut":$t.Quadratic.InOut,"Cubic.In":$t.Cubic.In,"Cubic.Out":$t.Cubic.Out,"Cubic.InOut":$t.Cubic.InOut,"Quartic.In":$t.Quartic.In,"Quartic.Out":$t.Quartic.Out,"Quartic.InOut":$t.Quartic.InOut,"Quintic.In":$t.Quintic.In,"Quintic.Out":$t.Quintic.Out,"Quintic.InOut":$t.Quintic.InOut,"Sinusoidal.In":$t.Sinusoidal.In,"Sinusoidal.Out":$t.Sinusoidal.Out,"Sinusoidal.InOut":$t.Sinusoidal.InOut,"Exponential.In":$t.Exponential.In,"Exponential.Out":$t.Exponential.Out,"Exponential.InOut":$t.Exponential.InOut,"Circular.In":$t.Circular.In,"Circular.Out":$t.Circular.Out,"Circular.InOut":$t.Circular.InOut,"Elastic.In":$t.Elastic.In,"Elastic.Out":$t.Elastic.Out,"Elastic.InOut":$t.Elastic.InOut,"Back.In":$t.Back.In,"Back.Out":$t.Back.Out,"Back.InOut":$t.Back.InOut,"Bounce.In":$t.Bounce.In,"Bounce.Out":$t.Bounce.Out,"Bounce.InOut":$t.Bounce.InOut};function Ki(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return new Promise((o=>{const{duration:a=1e3,delay:l=0,repeat:c=!1,mode:u="Linear.None",yoyo:h=!1}=i,d=Qi[u],f=new on(e).to(t,a).easing(d).delay(l).onUpdate((i=>{e instanceof n&&t instanceof n&&i instanceof n&&(i.order=t.order),null==r||r(i,f)})).onComplete((()=>{f.stop(),o()})).onStart((()=>{null==s||s(f)}));Fi(c)?f.repeat(c):Ui(c)&&c&&f.repeat(1/0),f.yoyo(h),f.start()}))}class Zi{constructor(e,t,n){this.target=e,this.points=t,this.speed=1,this.isPaused=!1,this.index=0,this._tween=null,n&&Object.assign(this,n)}get isPlaying(){var e;return!!(null===(e=this._tween)||void 0===e?void 0:e.isPlaying())}play(){return!this.isPlaying&&(this.isPaused=!1,this._play())}_play(){var e,n;return Fn(this,void 0,void 0,(function*(){if(this.isPaused)return!1;const{points:i,target:r}=this,s=null!==(e=this.speed)&&void 0!==e?e:1,o=this.index;let a=i[o];if(!a)return!0;a.isVector3||(a=new t(a.x,a.y,a.z));const l=r.position.distanceTo(a)/s;yield Ki(r.position,a,{duration:l},this.onUpdate,(e=>{var t;0!==o||this._tween||null===(t=this.onStart)||void 0===t||t.call(this,e),this._tween=e})),null===(n=this.onPoint)||void 0===n||n.call(this,o,a),this.index++,this._tween=null,this._play()}))}pause(){var e;this.isPaused=!0,null===(e=this._tween)||void 0===e||e.stop()}}const qi=0,Ji=1,$i=2,er=2,tr=1.25,nr=1,ir=32,rr=65535,sr=Math.pow(2,-24);class or{constructor(){}}function ar(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function lr(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){const r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function cr(e,t){t.set(e)}function ur(e,t,n){let i,r;for(let s=0;s<3;s++){const o=s+3;i=e[s],r=t[s],n[s]=i<r?i:r,i=e[o],r=t[o],n[o]=i>r?i:r}}function hr(e,t,n){for(let i=0;i<3;i++){const r=t[e+2*i],s=t[e+2*i+1],o=r-s,a=r+s;o<n[i]&&(n[i]=o),a>n[i+3]&&(n[i+3]=a)}}function dr(e){const t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function fr(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,g=-1/0,m=-1/0;const v=null!==r;for(let i=6*t,r=6*(t+n);i<r;i+=6){const t=e[i+0],n=e[i+1],r=t-n,y=t+n;r<s&&(s=r),y>l&&(l=y),v&&t<h&&(h=t),v&&t>p&&(p=t);const w=e[i+2],b=e[i+3],x=w-b,A=w+b;x<o&&(o=x),A>c&&(c=A),v&&w<d&&(d=w),v&&w>g&&(g=w);const T=e[i+4],S=e[i+5],E=T-S,D=T+S;E<a&&(a=E),D>u&&(u=D),v&&T<f&&(f=T),v&&T>m&&(m=T)}i[0]=s,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=u,v&&(r[0]=h,r[1]=d,r[2]=f,r[3]=p,r[4]=g,r[5]=m)}const pr=32,gr=(e,t)=>e.candidate-t.candidate,mr=new Array(pr).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),vr=new Float32Array(6);function yr(e,t){function n(e){d&&d(e/p)}function i(t,r,d){let f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!g&&p>=l&&(g=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=u||p>=l)return n(r+d),t.offset=r,t.count=d,t;const m=function(e,t,n,i,r,s){let o=-1,a=0;if(s===qi)o=lr(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(s===Ji)o=lr(e),-1!==o&&(a=function(e,t,n,i){let r=0;for(let s=t,o=t+n;s<o;s++)r+=e[6*s+2*i];return r/n}(n,i,r,o));else if(s===$i){const s=dr(e);let l=tr*r;const c=6*i,u=6*(i+r);for(let e=0;e<3;e++){const i=t[e],h=(t[e+3]-i)/pr;if(r<pr/4){const t=[...mr];t.length=r;let i=0;for(let r=c;r<u;r+=6,i++){const s=t[i];s.candidate=n[r+2*e],s.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:l}=s;for(let e=0;e<3;e++)l[e]=1/0,l[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;hr(r,n,o)}t.sort(gr);let h=r;for(let e=0;e<h;e++){const n=t[e];for(;e+1<h&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),h--}for(let i=c;i<u;i+=6){const r=n[i+2*e];for(let e=0;e<h;e++){const s=t[e];r>=s.candidate?hr(i,n,s.rightCacheBounds):(hr(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<h;n++){const i=t[n],c=i.count,u=r-i.count,h=i.leftCacheBounds,d=i.rightCacheBounds;let f=0;0!==c&&(f=dr(h)/s);let p=0;0!==u&&(p=dr(d)/s);const g=nr+tr*(f*c+p*u);g<l&&(o=e,l=g,a=i.candidate)}}else{for(let e=0;e<pr;e++){const t=mr[e];t.count=0,t.candidate=i+h+e*h;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<u;t+=6){let r=~~((n[t+2*e]-i)/h);r>=pr&&(r=pr-1);const s=mr[r];s.count++,hr(t,n,s.bounds)}const t=mr[pr-1];cr(t.bounds,t.rightCacheBounds);for(let e=pr-2;e>=0;e--){const t=mr[e],n=mr[e+1];ur(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let t=0;t<pr-1;t++){const n=mr[t],i=n.count,c=n.bounds,u=mr[t+1].rightCacheBounds;0!==i&&(0===d?cr(c,vr):ur(c,vr,vr)),d+=i;let h=0,f=0;0!==d&&(h=dr(vr)/s);const p=r-d;0!==p&&(f=dr(u)/s);const g=nr+tr*(h*d+f*p);g<l&&(o=e,l=g,a=n.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}(t.boundingData,f,o,r,d,h);if(-1===m.axis)return n(r+d),t.offset=r,t.count=d,t;const v=function(e,t,n,i,r){let s=n,o=n+i-1;const a=r.pos,l=2*r.axis;for(;;){for(;s<=o&&t[6*s+l]<a;)s++;for(;s<=o&&t[6*o+l]>=a;)o--;if(!(s<o))return s;for(let n=0;n<3;n++){let i=e[3*s+n];e[3*s+n]=e[3*o+n],e[3*o+n]=i;let r=t[6*s+2*n+0];t[6*s+2*n+0]=t[6*o+2*n+0],t[6*o+2*n+0]=r;let a=t[6*s+2*n+1];t[6*s+2*n+1]=t[6*o+2*n+1],t[6*o+2*n+1]=a}s++,o--}}(a,o,r,d,m);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=m.axis;const e=new or,n=r,a=v-r;t.left=e,e.boundingData=new Float32Array(6),fr(o,n,a,e.boundingData,s),i(e,n,a,s,p+1);const l=new or,c=v,u=d-a;t.right=l,l.boundingData=new Float32Array(6),fr(o,c,u,l.boundingData,s),i(l,c,u,s,p+1)}return t}!function(e,t){if(!e.index){const n=e.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let r;r=n>65535?new Uint32Array(new i(4*n)):new Uint16Array(new i(2*n)),e.setIndex(new f(r,1));for(let e=0;e<n;e++)r[e]=e}}(e,t);const r=new Float32Array(6),s=new Float32Array(6),o=function(e,t){const n=e.attributes.position,i=e.index.array,r=i.length/3,s=new Float32Array(6*r),o=n.normalized,a=n.array,l=n.offset||0;let c=3;n.isInterleavedBufferAttribute&&(c=n.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const r=3*e,h=6*e;let d,f,p;o?(d=i[r+0],f=i[r+1],p=i[r+2]):(d=i[r+0]*c+l,f=i[r+1]*c+l,p=i[r+2]*c+l);for(let e=0;e<3;e++){let i,r,l;o?(i=n[u[e]](d),r=n[u[e]](f),l=n[u[e]](p)):(i=a[d+e],r=a[f+e],l=a[p+e]);let c=i;r<c&&(c=r),l<c&&(c=l);let g=i;r>g&&(g=r),l>g&&(g=l);const m=(g-c)/2,v=2*e;s[h+v+0]=c+m,s[h+v+1]=m+(Math.abs(c)+m)*sr,c<t[e]&&(t[e]=c),g>t[e+3]&&(t[e+3]=g)}}return s}(e,r),a=e.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,p=e.index.count/3;let g=!1;const m=[],v=function(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];const t=[],n=new Set;for(const t of e.groups)n.add(t.start),n.add(t.start+t.count);const i=Array.from(n.values()).sort(((e,t)=>e-t));for(let e=0;e<i.length-1;e++){const n=i[e],r=i[e+1];t.push({offset:n/3,count:(r-n)/3})}return t}(e);if(1===v.length){const e=v[0],t=new or;t.boundingData=r,function(e,t,n,i){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let i=6*t,u=6*(t+n);i<u;i+=6){const t=e[i+0];t<r&&(r=t),t>a&&(a=t);const n=e[i+2];n<s&&(s=n),n>l&&(l=n);const u=e[i+4];u<o&&(o=u),u>c&&(c=u)}i[0]=r,i[1]=s,i[2]=o,i[3]=a,i[4]=l,i[5]=c}(o,e.offset,e.count,s),i(t,e.offset,e.count,s),m.push(t)}else for(let e of v){const t=new or;t.boundingData=new Float32Array(6),fr(o,e.offset,e.count,t.boundingData,s),i(t,e.offset,e.count,s),m.push(t)}return m}class wr{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,s=e.length;r<s;r++){const s=e[r][t];n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=e.dot(s);n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}wr.prototype.setFromBox=function(){const e=new t;return function(t,n){const i=n.min,r=n.max;let s=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let a=0;a<=1;a++)for(let l=0;l<=1;l++){e.x=i.x*n+r.x*(1-n),e.y=i.y*a+r.y*(1-a),e.z=i.z*l+r.z*(1-l);const c=t.dot(e);s=Math.min(c,s),o=Math.max(c,o)}this.min=s,this.max=o}}(),function(){const e=new wr}();const br=function(){const e=new t,n=new t,i=new t;return function(t,r,s){const o=t.start,a=e,l=r.start,c=n;i.subVectors(o,l),e.subVectors(t.end,t.start),n.subVectors(r.end,r.start);const u=i.dot(c),h=c.dot(a),d=c.dot(c),f=i.dot(a),p=a.dot(a)*d-h*h;let g,m;g=0!==p?(u*h-f*d)/p:0,m=(u+g*h)/d,s.x=g,s.y=m}}(),xr=function(){const e=new M,n=new t,i=new t;return function(t,r,s,o){br(t,r,e);let a=e.x,l=e.y;if(a>=0&&a<=1&&l>=0&&l<=1)return t.at(a,s),void r.at(l,o);if(a>=0&&a<=1)return l<0?r.at(0,o):r.at(1,o),void t.closestPointToPoint(o,!0,s);if(l>=0&&l<=1)return a<0?t.at(0,s):t.at(1,s),void r.closestPointToPoint(s,!0,o);{let e,c;e=a<0?t.start:t.end,c=l<0?r.start:r.end;const u=n,h=i;return t.closestPointToPoint(c,!0,n),r.closestPointToPoint(e,!0,i),u.distanceToSquared(c)<=h.distanceToSquared(e)?(s.copy(u),void o.copy(c)):(s.copy(e),void o.copy(h))}}}(),Ar=function(){const e=new t,n=new t,i=new B,r=new R;return function(t,s){const{radius:o,center:a}=t,{a:l,b:c,c:u}=s;r.start=l,r.end=c;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=l,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=c,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const h=s.getPlane(i);if(Math.abs(h.distanceToPoint(a))<=o){const e=h.projectPoint(a,n);if(s.containsPoint(e))return!0}return!1}}(),Tr=1e-15;function Sr(e){return Math.abs(e)<Tr}class Er extends P{constructor(){super(...arguments),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new t)),this.satBounds=new Array(4).fill().map((()=>new wr)),this.points=[this.a,this.b,this.c],this.sphere=new O,this.plane=new B,this.needsUpdate=!0}intersectsSphere(e){return Ar(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,o=r[0],a=s[0];this.getNormal(o),a.setFromPoints(o,i);const l=r[1],c=s[1];l.subVectors(e,t),c.setFromPoints(l,i);const u=r[2],h=s[2];u.subVectors(t,n),h.setFromPoints(u,i);const d=r[3],f=s[3];d.subVectors(n,e),f.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Er.prototype.closestPointToSegment=function(){const e=new t,n=new t,i=new R;return function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const{start:o,end:a}=t,l=this.points;let c,u=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(l[o]),i.end.copy(l[a]),xr(i,t,e,n),c=e.distanceToSquared(n),c<u&&(u=c,r&&r.copy(e),s&&s.copy(n))}return this.closestPointToPoint(o,e),c=o.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(o)),this.closestPointToPoint(a,e),c=a.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(a)),Math.sqrt(u)}}(),Er.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new Array(3),r=new wr,s=new wr,o=new t,a=new t,l=new t,c=new t,u=new R,h=new R,d=new R;return function(t){let f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,p=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const g=this.plane,m=t.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){const e=this.satBounds,a=this.satAxes;i[0]=t.a,i[1]=t.b,i[2]=t.c;for(let t=0;t<4;t++){const n=e[t],s=a[t];if(r.setFromPoints(s,i),n.isSeparated(r))return!1}const l=t.satBounds,c=t.satAxes;n[0]=this.a,n[1]=this.b,n[2]=this.c;for(let e=0;e<4;e++){const t=l[e],i=c[e];if(r.setFromPoints(i,n),t.isSeparated(r))return!1}for(let e=0;e<4;e++){const t=a[e];for(let e=0;e<4;e++){const a=c[e];if(o.crossVectors(t,a),r.setFromPoints(o,n),s.setFromPoints(o,i),r.isSeparated(s))return!1}}return f&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}{const e=this.points;let n=!1,i=0;for(let t=0;t<3;t++){const r=e[t],s=e[(t+1)%3];u.start.copy(r),u.end.copy(s),u.delta(a);const o=n?h.start:h.end,l=Sr(m.distanceToPoint(r));if(Sr(m.normal.dot(a))&&l){h.copy(u),i=2;break}if((m.intersectLine(u,o)||l)&&!Sr(o.distanceTo(s))){if(i++,n)break;n=!0}}if(1===i&&t.containsPoint(h.end))return f&&(f.start.copy(h.end),f.end.copy(h.end)),!0;if(2!==i)return!1;const r=t.points;let s=!1,o=0;for(let e=0;e<3;e++){const t=r[e],n=r[(e+1)%3];u.start.copy(t),u.end.copy(n),u.delta(l);const i=s?d.start:d.end,a=Sr(g.distanceToPoint(t));if(Sr(g.normal.dot(l))&&a){d.copy(u),o=2;break}if((g.intersectLine(u,i)||a)&&!Sr(i.distanceTo(n))){if(o++,s)break;s=!0}}if(1===o&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(2!==o)return!1;if(h.delta(a),d.delta(l),a.dot(l)<0){let e=d.start;d.start=d.end,d.end=e}const p=h.start.dot(a),v=h.end.dot(a),y=d.start.dot(a),w=d.end.dot(a);return(p===w||y===v||v<y!==p<w)&&(f&&(c.subVectors(h.start,d.start),c.dot(a)>0?f.start.copy(h.start):f.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?f.end.copy(h.end):f.end.copy(d.end)),!0)}}}(),Er.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Er.prototype.distanceToTriangle=function(){const e=new t,n=new t,i=["a","b","c"],r=new R,s=new R;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const l=o||a?r:null;if(this.intersectsTriangle(t,l))return(o||a)&&(o&&l.getCenter(o),a&&l.getCenter(a)),0;let c=1/0;for(let n=0;n<3;n++){let r;const s=i[n],l=t[s];this.closestPointToPoint(l,e),r=l.distanceToSquared(e),r<c&&(c=r,o&&o.copy(e),a&&a.copy(l));const u=this[s];t.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<c&&(c=r,o&&o.copy(u),a&&a.copy(e))}for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];r.set(this[u],this[h]);for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];s.set(t[u],t[h]),xr(r,s,e,n);const d=e.distanceToSquared(n);d<c&&(c=d,o&&o.copy(e),a&&a.copy(n))}}return Math.sqrt(c)}}();class Dr{constructor(e,n,i){this.isOrientedBox=!0,this.min=new t,this.max=new t,this.matrix=new m,this.invMatrix=new m,this.points=new Array(8).fill().map((()=>new t)),this.satAxes=new Array(3).fill().map((()=>new t)),this.satBounds=new Array(3).fill().map((()=>new wr)),this.alignedSatBounds=new Array(3).fill().map((()=>new wr)),this.needsUpdate=!1,e&&this.min.copy(e),n&&this.max.copy(n),i&&this.matrix.copy(i)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Dr.prototype.update=function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let o=0;o<=1;o++){const a=i[1*r|2*s|4*o];a.x=r?n.x:t.x,a.y=s?n.y:t.y,a.z=o?n.z:t.z,a.applyMatrix4(e)}const r=this.satBounds,s=this.satAxes,o=i[0];for(let e=0;e<3;e++){const t=s[e],n=r[e],a=i[1<<e];t.subVectors(o,a),n.setFromPoints(t,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Dr.prototype.intersectsBox=function(){const e=new wr;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,s=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,o[0].isSeparated(e))return!1;if(e.min=n.y,e.max=i.y,o[1].isSeparated(e))return!1;if(e.min=n.z,e.max=i.z,o[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const i=s[n],o=r[n];if(e.setFromBox(i,t),o.isSeparated(e))return!1}return!0}}(),Dr.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new wr,r=new wr,s=new t;return function(t){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const o=this.satBounds,a=this.satAxes;n[0]=t.a,n[1]=t.b,n[2]=t.c;for(let e=0;e<3;e++){const t=o[e],r=a[e];if(i.setFromPoints(r,n),t.isSeparated(i))return!1}const l=t.satBounds,c=t.satAxes,u=this.points;for(let e=0;e<3;e++){const t=l[e],n=c[e];if(i.setFromPoints(n,u),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const t=a[e];for(let e=0;e<4;e++){const o=c[e];if(s.crossVectors(t,o),i.setFromPoints(s,n),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}(),Dr.prototype.closestPointToPoint=function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Dr.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Dr.prototype.distanceToBox=function(){const e=["x","y","z"],n=new Array(12).fill().map((()=>new R)),i=new Array(12).fill().map((()=>new R)),r=new t,s=new t;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.needsUpdate&&this.update(),this.intersectsBox(t))return(a||l)&&(t.getCenter(s),this.closestPointToPoint(s,r),t.closestPointToPoint(r,s),a&&a.copy(r),l&&l.copy(s)),0;const c=o*o,u=t.min,h=t.max,d=this.points;let f=1/0;for(let e=0;e<8;e++){const t=d[e];s.copy(t).clamp(u,h);const n=t.distanceToSquared(s);if(n<f&&(f=n,a&&a.copy(t),l&&l.copy(s),n<c))return Math.sqrt(n)}let p=0;for(let t=0;t<3;t++)for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){const o=(t+1)%3,a=(t+2)%3,l=1<<t|r<<o|s<<a,c=d[r<<o|s<<a],f=d[l];n[p].set(c,f);const g=e[t],m=e[o],v=e[a],y=i[p],w=y.start,b=y.end;w[g]=u[g],w[m]=r?u[m]:h[m],w[v]=s?u[v]:h[m],b[g]=h[g],b[m]=r?u[m]:h[m],b[v]=s?u[v]:h[m],p++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){s.x=e?h.x:u.x,s.y=t?h.y:u.y,s.z=n?h.z:u.z,this.closestPointToPoint(s,r);const i=s.distanceToSquared(r);if(i<f&&(f=i,a&&a.copy(r),l&&l.copy(s),i<c))return Math.sqrt(i)}for(let e=0;e<12;e++){const t=n[e];for(let e=0;e<12;e++){const n=i[e];xr(t,n,r,s);const o=r.distanceToSquared(s);if(o<f&&(f=o,a&&a.copy(r),l&&l.copy(s),o<c))return Math.sqrt(o)}}return Math.sqrt(f)}}();const Cr=new t,Ir=new t,Mr=new t,Br=new M,Rr=new M,Pr=new M,Or=new t;function _r(e,n,i,r,s,o,a){Cr.fromBufferAttribute(n,r),Ir.fromBufferAttribute(n,s),Mr.fromBufferAttribute(n,o);const l=function(e,t,n,i,r,s){let o;return o=s===_?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,s!==d,r),null===o?null:{distance:e.origin.distanceTo(r),point:r.clone()}}(e,Cr,Ir,Mr,Or,a);if(l){i&&(Br.fromBufferAttribute(i,r),Rr.fromBufferAttribute(i,s),Pr.fromBufferAttribute(i,o),l.uv=P.getUV(Or,Cr,Ir,Mr,Br,Rr,Pr,new M));const e={a:r,b:s,c:o,normal:new t,materialIndex:0};P.getNormal(Cr,Ir,Mr,e.normal),l.face=e,l.faceIndex=r}return l}function Lr(e,t,n,i,r){const s=3*i,o=e.index.getX(s),a=e.index.getX(s+1),l=e.index.getX(s+2),c=_r(n,e.attributes.position,e.attributes.uv,o,a,l,t);return c?(c.faceIndex=i,r&&r.push(c),c):null}function kr(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e.distance<n.near||e.distance>n.far?null:e)}function Nr(e,t,n,i){const r=e.a,s=e.b,o=e.c;let a=t,l=t+1,c=t+2;n&&(a=n.getX(t),l=n.getX(t+1),c=n.getX(t+2)),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function Ur(e,t,n,i,r,s,o){const a=n.index,l=n.attributes.position;for(let n=e,c=t+e;n<c;n++)if(Nr(o,3*n,a,l),o.needsUpdate=!0,i(o,n,r,s))return!0;return!1}class Fr{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}function jr(e,t){return 65535===t[e+15]}function zr(e,t){return t[e+6]}function Hr(e,t){return t[e+14]}function Gr(e){return e+8}function Vr(e,t){return t[e+6]}const Yr=new i,Wr=new t,Xr=["x","y","z"];function Qr(e,t,n,i,r){let s=2*e,o=ts,a=ns,l=is;if(jr(s,a)){!function(e,t,n,i,r,s){for(let o=i,a=i+r;o<a;o++)Lr(e,t,n,o,s)}(t,n,i,zr(e,l),Hr(s,a),r)}else{const s=Gr(e);Jr(s,o,i,Wr)&&Qr(s,t,n,i,r);const a=Vr(e,l);Jr(a,o,i,Wr)&&Qr(a,t,n,i,r)}}function Kr(e,t,n,i){let r=2*e,s=ts,o=ns,a=is;if(jr(r,o)){return function(e,t,n,i,r){let s=1/0,o=null;for(let a=i,l=i+r;a<l;a++){const i=Lr(e,t,n,a);i&&i.distance<s&&(o=i,s=i.distance)}return o}(t,n,i,zr(e,a),Hr(r,o))}{const r=function(e,t){return t[e+7]}(e,a),o=Xr[r],l=i.direction[o]>=0;let c,u;l?(c=Gr(e),u=Vr(e,a)):(c=Vr(e,a),u=Gr(e));const h=Jr(c,s,i,Wr)?Kr(c,t,n,i):null;if(h){const e=h.point[o];if(l?e<=s[u+r]:e>=s[u+r+3])return h}const d=Jr(u,s,i,Wr)?Kr(u,t,n,i):null;return h&&d?h.distance<=d.distance?h:d:h||d||null}}const Zr=function(){let e,t;const n=[],r=new Fr((()=>new i));return function(){e=r.getPrimitive(),t=r.getPrimitive(),n.push(e,t);const i=s(...arguments);r.releasePrimitive(e),r.releasePrimitive(t),n.pop(),n.pop();const o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),i};function s(n,i,r,o){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;function u(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Gr(e));return zr(e,i)}function h(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Vr(e,i));return zr(e,i)+Hr(t,n)}let d=2*n,f=ts,p=ns,g=is;if(jr(d,p)){const t=zr(n,g),i=Hr(d,p);return ar(n,f,e),o(t,i,!1,c,l+n,e)}{const d=Gr(n),m=Vr(n,g);let v,y,w,b,x=d,A=m;if(a&&(w=e,b=t,ar(x,f,w),ar(A,f,b),v=a(w),y=a(b),y<v)){x=m,A=d;const e=v;v=y,y=e,w=b}w||(w=e,ar(x,f,w));const T=r(w,jr(2*x,p),v,c+1,l+x);let S;if(T===er){const e=u(x);S=o(e,h(x)-e,!0,c+1,l+x,w)}else S=T&&s(x,i,r,o,a,l,c+1);if(S)return!0;b=t,ar(A,f,b);const E=r(b,jr(2*A,p),y,c+1,l+A);let D;if(E===er){const e=u(A);D=o(e,h(A)-e,!0,c+1,l+A,b)}else D=E&&s(A,i,r,o,a,l,c+1);return!!D}}}(),qr=function(){const e=new Er,t=new Er,n=new m,i=new Dr,r=new Dr;return function s(o,a,l,c){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,h=2*o,d=ts,f=ns,p=is;null===u&&(l.boundingBox||l.computeBoundingBox(),i.set(l.boundingBox.min,l.boundingBox.max,c),u=i);if(!jr(h,f)){const e=o+8,t=p[o+6];ar(e,d,Yr);if(u.intersectsBox(Yr)&&s(e,a,l,c,u))return!0;ar(t,d,Yr);return!!(u.intersectsBox(Yr)&&s(t,a,l,c,u))}{const i=a,s=i.index,u=i.attributes.position,g=l.index,m=l.attributes.position,v=zr(o,p),y=Hr(h,f);if(n.copy(c).invert(),l.boundsTree){ar(o,d,r),r.matrix.copy(n),r.needsUpdate=!0;const e=l.boundsTree.shapecast({intersectsBounds:e=>r.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(c),e.b.applyMatrix4(c),e.c.applyMatrix4(c),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);n<i;n+=3)if(Nr(t,n,s,u),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});return e}for(let i=3*v,r=y+3*v;i<r;i+=3){Nr(e,i,s,u),e.a.applyMatrix4(n),e.b.applyMatrix4(n),e.c.applyMatrix4(n),e.needsUpdate=!0;for(let n=0,i=g.count;n<i;n+=3)if(Nr(t,n,g,m),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function Jr(e,t,n,i){return ar(e,t,Yr),n.intersectBox(Yr,i)}const $r=[];let es,ts,ns,is;function rs(e){es&&$r.push(es),es=e,ts=new Float32Array(e),ns=new Uint16Array(e),is=new Uint32Array(e)}function ss(){es=null,ts=null,ns=null,is=null,$r.length&&rs($r.pop())}const os=Symbol("skip tree generation"),as=new i,ls=new i,cs=new m,us=new Dr,hs=new Dr,ds=new t,fs=new t,ps=new t,gs=new t,ms=new t,vs=new i,ys=new Fr((()=>new Er));class ws{static serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),ws.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=n.getIndex();let s;return s=t.cloneBuffers?{roots:i.map((e=>e.slice())),index:r.array.slice()}:{roots:i,index:r.array},s}static deserialize(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),ws.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n={setIndex:!0,...n};const{index:i,roots:r}=e,s=new ws(t,{...n,[os]:!0});if(s._roots=r,n.setIndex){const n=t.getIndex();if(null===n){const n=new f(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return s}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if(t=Object.assign({strategy:qi,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[os]:!1},t),t.useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[os]||(this._roots=function(e,t){const n=yr(e,t);let i,r,s;const o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<n.length;e++){const t=n[e];let u=l(t);const h=new a(ir*u);i=new Float32Array(h),r=new Uint32Array(h),s=new Uint16Array(h),c(0,t),o.push(h)}return o;function l(e){return e.count?1:1+l(e.left)+l(e.right)}function c(e,t){const n=e/4,o=e/2,a=!!t.count,l=t.boundingData;for(let e=0;e<6;e++)i[n+e]=l[e];if(a){const i=t.offset,a=t.count;return r[n+6]=i,s[o+14]=a,s[o+15]=rr,e+ir}{const i=t.left,s=t.right,o=t.splitAxis;let a;if(a=c(e+ir,i),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[n+6]=a/4,a=c(a,s),r[n+7]=o,a}}}(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new i))),this.geometry=e}refit(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&Array.isArray(e)&&(e=new Set(e));const t=this.geometry,n=t.index.array,i=t.attributes.position;let r,s,o,a,l=0;const c=this._roots;for(let e=0,t=c.length;e<t;e++)r=c[e],s=new Uint32Array(r),o=new Uint16Array(r),a=new Float32Array(r),u(0,l),l+=r.byteLength;function u(t,r){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const c=2*t;if(o[c+15]===rr){const e=s[t+6];let r=1/0,l=1/0,u=1/0,h=-1/0,d=-1/0,f=-1/0;for(let t=3*e,s=3*(e+o[c+14]);t<s;t++){const e=n[t],s=i.getX(e),o=i.getY(e),a=i.getZ(e);s<r&&(r=s),s>h&&(h=s),o<l&&(l=o),o>d&&(d=o),a<u&&(u=a),a>f&&(f=a)}return(a[t+0]!==r||a[t+1]!==l||a[t+2]!==u||a[t+3]!==h||a[t+4]!==d||a[t+5]!==f)&&(a[t+0]=r,a[t+1]=l,a[t+2]=u,a[t+3]=h,a[t+4]=d,a[t+5]=f,!0)}{const n=t+8,i=s[t+6],o=n+r,c=i+r;let h=l,d=!1,f=!1;e?h||(d=e.has(o),f=e.has(c),h=!d&&!f):(d=!0,f=!0);const p=h||f;let g=!1;(h||d)&&(g=u(n,r,h));let m=!1;p&&(m=u(i,r,h));const v=g||m;if(v)for(let e=0;e<3;e++){const r=n+e,s=i+e,o=a[r],l=a[r+3],c=a[s],u=a[s+3];a[t+e]=o<c?o:c,a[t+e+3]=l>u?l:u}return v}}}traverse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(s){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const a=2*s,l=r[a+15]===rr;if(l){const t=i[s+6],c=r[a+14];e(o,l,new Float32Array(n,4*s,6),t,c)}else{const r=s+ir/4,a=i[s+6],c=i[s+7];e(o,l,new Float32Array(n,4*s,6),c)||(t(r,o+1),t(a,o+1))}}(0)}raycast(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=[],s=t.isMaterial,o=Array.isArray(t),a=i.groups,l=s?t.side:t;for(let s=0,c=n.length;s<c;s++){const c=o?t[a[s].materialIndex].side:l,u=r.length;if(rs(n[s]),Qr(0,i,c,e,r),ss(),o){const e=a[s].materialIndex;for(let t=u,n=r.length;t<n;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=t.isMaterial,s=Array.isArray(t);let o=null;const a=i.groups,l=r?t.side:t;for(let r=0,c=n.length;r<c;r++){const c=s?t[a[r].materialIndex].side:l;rs(n[r]);const u=Kr(0,i,c,e);ss(),null!=u&&(null==o||u.distance<o.distance)&&(o=u,s&&(u.face.materialIndex=a[r].materialIndex))}return o}intersectsGeometry(e,t){const n=this.geometry;let i=!1;for(const r of this._roots)if(rs(r),i=qr(0,n,e,t),ss(),i)break;return i}shapecast(e,t,n){const i=this.geometry;if(e instanceof Function){if(t){const e=t;t=(t,n,i,r)=>{const s=3*n;return e(t,s,s+1,s+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const r=ys.getPrimitive();let{boundsTraverseOrder:s,intersectsBounds:o,intersectsRange:a,intersectsTriangle:l}=e;if(a&&l){const e=a;a=(t,n,s,o,a)=>!!e(t,n,s,o,a)||Ur(t,n,i,l,s,o,r)}else a||(a=l?(e,t,n,s)=>Ur(e,t,i,l,n,s,r):(e,t,n)=>n);let c=!1,u=0;for(const e of this._roots){if(rs(e),c=Zr(0,i,o,a,s,u),ss(),c)break;u+=e.byteLength}return ys.releasePrimitive(r),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const s=this.geometry.index,o=this.geometry.attributes.position,a=e.geometry.index,l=e.geometry.attributes.position;cs.copy(t).invert();const c=ys.getPrimitive(),u=ys.getPrimitive();if(r){function d(e,n,i,h,d,f,p,g){for(let m=i,v=i+h;m<v;m++){Nr(u,3*m,a,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(Nr(c,3*t,s,o),c.needsUpdate=!0,r(c,u,t,m,d,f,p,g))return!0}return!1}if(i){const f=i;i=function(e,t,n,i,r,s,o,a){return!!f(e,t,n,i,r,s,o,a)||d(e,t,n,i,r,s,o,a)}}else i=d}e.getBoundingBox(ls),ls.applyMatrix4(t);const h=this.shapecast({intersectsBounds:e=>ls.intersectsBox(e),intersectsRange:(t,n,r,s,o,a)=>(as.copy(a),as.applyMatrix4(cs),e.shapecast({intersectsBounds:e=>as.intersectsBox(e),intersectsRange:(e,r,a,l,c)=>i(t,n,e,r,s,o,l,c)}))});return ys.releasePrimitive(c),ys.releasePrimitive(u),h}intersectsBox(e,t){return us.set(e.min,e.max,t),us.needsUpdate=!0,this.shapecast({intersectsBounds:e=>us.intersectsBox(e),intersectsTriangle:e=>us.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1/0;e.boundingBox||e.computeBoundingBox(),us.set(e.boundingBox.min,e.boundingBox.max,t),us.needsUpdate=!0;const o=this.geometry,a=o.attributes.position,l=o.index,c=e.attributes.position,u=e.index,h=ys.getPrimitive(),d=ys.getPrimitive();let f=fs,p=ps,g=null,m=null;i&&(g=gs,m=ms);let v=1/0,y=null,w=null;return cs.copy(t).invert(),hs.matrix.copy(cs),this.shapecast({boundsTraverseOrder:e=>us.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s&&(t&&(hs.min.copy(e.min),hs.max.copy(e.max),hs.needsUpdate=!0),!0),intersectsRange:(n,i)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>hs.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s,intersectsRange:(e,s)=>{for(let o=3*e,b=3*(e+s);o<b;o+=3){Nr(d,o,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let e=3*n,t=3*(n+i);e<t;e+=3){Nr(h,e,l,a),h.needsUpdate=!0;const t=h.distanceToTriangle(d,f,g);if(t<v&&(p.copy(f),m&&m.copy(g),v=t,y=e/3,w=o/3),t<r)return!0}}}});for(let e=0,s=u?u.count:c.count;e<s;e+=3){Nr(d,e,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let t=3*n,s=3*(n+i);t<s;t+=3){Nr(h,t,l,a),h.needsUpdate=!0;const n=h.distanceToTriangle(d,f,g);if(n<v&&(p.copy(f),m&&m.copy(g),v=n,y=t/3,w=e/3),n<r)return!0}}}}),ys.releasePrimitive(h),ys.releasePrimitive(d),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=y,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(cs),p.applyMatrix4(cs),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;const r=n*n,s=i*i;let o=1/0,a=null;if(this.shapecast({boundsTraverseOrder:t=>(ds.copy(e).clamp(t.min,t.max),ds.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n<o&&n<s,intersectsTriangle:(t,n)=>{t.closestPointToPoint(e,ds);const i=e.distanceToSquared(ds);return i<o&&(fs.copy(ds),o=i,a=n),i<r}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(fs):t.point=fs.clone(),t.distance=l,t.faceIndex=a,t}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{ar(0,new Float32Array(t),vs),e.union(vs)})),e}}const bs=new N,xs=new m,As=k.prototype.raycast;class Ts extends v{constructor(){super();const e=new U;e.deleteAttribute("uv");const t=new F({side:_}),n=new F,i=new j(16777215,5,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new k(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new k(e,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const o=new k(e,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const a=new k(e,n);a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),this.add(a);const l=new k(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const c=new k(e,n);c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),this.add(c);const u=new k(e,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const h=new k(e,Ss(50));h.position.set(-16.116,14.37,8.208),h.scale.set(.1,2.428,2.739),this.add(h);const d=new k(e,Ss(50));d.position.set(-16.109,18.021,-8.207),d.scale.set(.1,2.425,2.751),this.add(d);const f=new k(e,Ss(17));f.position.set(14.904,12.198,-1.832),f.scale.set(.15,4.265,6.331),this.add(f);const p=new k(e,Ss(43));p.position.set(-.462,8.89,14.52),p.scale.set(4.38,5.441,.088),this.add(p);const g=new k(e,Ss(20));g.position.set(3.235,11.486,-12.541),g.scale.set(2.5,2,.1),this.add(g);const m=new k(e,Ss(100));m.position.set(0,20,0),m.scale.set(1,.1,1),this.add(m)}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Ss(e){const t=new z;return t.color.setScalar(e),t}class Es extends H{constructor(e){super(e),this.type=G}parse(e){const t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=a.indexOf("\n"))&&s<t&&i<e.byteLength;)o+=a,s+=a.length,i+=128,a+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));return-1<r&&(!1!==n&&(e.pos+=s+r+1),o+a.slice(0,r))},i=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=e[t+0]*s,n[i+1]=e[t+1]*s,n[i+2]=e[t+2]*s,n[i+3]=1},r=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=Y.toHalfFloat(Math.min(e[t+0]*s,65504)),n[i+1]=Y.toHalfFloat(Math.min(e[t+1]*s,65504)),n[i+2]=Y.toHalfFloat(Math.min(e[t+2]*s,65504)),n[i+3]=Y.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const o=function(e){const i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,a={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(a.valid|=1,a.programtype=c[1],a.string+=l+"\n";l=n(e),!1!==l;)if(a.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(a.gamma=parseFloat(c[1])),(c=l.match(r))&&(a.exposure=parseFloat(c[1])),(c=l.match(s))&&(a.valid|=2,a.format=c[1]),(c=l.match(o))&&(a.valid|=4,a.height=parseInt(c[1],10),a.width=parseInt(c[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=l+"\n";return 2&a.valid?4&a.valid?a:t(3,"missing image size specifier"):t(3,"missing format specifier")}(s);if(-1!==o){const e=o.width,n=o.height,a=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const s=new Uint8Array(4*n*i);if(!s.length)return t(4,"unable to allocate buffer space");let o=0,a=0;const l=4*r,c=new Uint8Array(4),u=new Uint8Array(l);let h=i;for(;h>0&&a<e.byteLength;){if(a+4>e.byteLength)return t(1);if(c[0]=e[a++],c[1]=e[a++],c[2]=e[a++],c[3]=e[a++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i<l&&a<e.byteLength;){n=e[a++];const r=n>128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){const t=e[a++];for(let e=0;e<n;e++)u[i++]=t}else u.set(e.subarray(a,a+n),i),i+=n,a+=n}const d=r;for(let e=0;e<d;e++){let t=0;s[o]=u[e+t],t+=r,s[o+1]=u[e+t],t+=r,s[o+2]=u[e+t],t+=r,s[o+3]=u[e+t],o+=4}h--}return s}(s.subarray(s.pos),e,n);if(-1!==a){let t,s,l;switch(this.type){case V:l=a.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)i(a,4*t,e,4*t);t=e,s=V;break;case G:l=a.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)r(a,4*e,n,4*e);t=n,s=G;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:o.string,gamma:o.gamma,exposure:o.exposure,type:s}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,i){return super.load(e,(function(e,n){switch(e.type){case V:case G:e.encoding=u,e.minFilter=A,e.magFilter=A,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}}var Ds=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i<t.children.length;i++)t.children[i].style.display=i===n?"block":"none";e=n}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(n){n.preventDefault(),i(++e%t.children.length)}),!1);var r=(performance||Date).now(),s=r,o=0,a=n(new Ds.Panel("FPS","#0ff","#002")),l=n(new Ds.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Ds.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:n,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){o++;var e=(performance||Date).now();if(l.update(e-r,200),e>=s+1e3&&(a.update(1e3*o/(e-s),100),s=e,o=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Ds.Panel=function(e,t,n){var i=1/0,r=0,s=Math.round,o=s(window.devicePixelRatio||1),a=80*o,l=48*o,c=3*o,u=2*o,h=3*o,d=15*o,f=74*o,p=30*o,g=document.createElement("canvas");g.width=a,g.height=l,g.style.cssText="width:80px;height:48px";var m=g.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,a,l),m.fillStyle=t,m.fillText(e,c,u),m.fillRect(h,d,f,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h,d,f,p),{dom:g,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,a,d),m.fillStyle=t,m.fillText(s(l)+" "+e+" ("+s(i)+"-"+s(r)+")",c,u),m.drawImage(g,h+o,d,f-o,p,h,d,f-o,p),m.fillRect(h+f-o,d,o,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h+f-o,d,o,s((1-l/v)*p))}}};var Cs=Ds;class Is extends k{constructor(){const e=Is.SkyShader,t=new W({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:X.clone(e.uniforms),side:_,depthWrite:!1});super(new U(1,1,1),t),this.isSky=!0}}Is.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new t},up:{value:new t(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\n\t\t}"};var Ms="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Bs(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),n}var Rs={},Ps={},Os=Bs(Xn),_s={},Ls={},ks={},Ns={};Object.defineProperty(Ns,"__esModule",{value:!0});var Us=function(){function e(t,n){if(void 0===n&&(n=null),this.nonEmpty=!1,t||n){if(!t)throw new Error("Parameter head cannot be null.");this.head=t,this.tail=n||e.NIL,this.nonEmpty=!0}else{if(e.NIL)throw new Error("Parameters head and tail are null. Use the NIL element instead.");this.nonEmpty=!1}}return Object.defineProperty(e.prototype,"length",{get:function(){if(!this.nonEmpty)return 0;if(this.tail===e.NIL)return 1;for(var t=0,n=this;n.nonEmpty;)++t,n=n.tail;return t},enumerable:!0,configurable:!0}),e.prototype.prepend=function(t){return new e(t,this)},e.prototype.append=function(t){if(!t)return this;if(!this.nonEmpty)return new e(t);if(this.tail===e.NIL)return new e(t).prepend(this.head);for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;)i=i.tail=new e(r.head),r=r.tail;return i.tail=new e(t),n},e.prototype.insertWithPriority=function(t){if(!this.nonEmpty)return new e(t);var n=t.priority;if(n>this.head.priority)return this.prepend(t);for(var i=new e(this.head),r=i,s=this.tail;s.nonEmpty;){if(n>s.head.priority)return r.tail=s.prepend(t),i;r=r.tail=new e(s.head),s=s.tail}return r.tail=new e(t),i},e.prototype.filterNot=function(t){if(!this.nonEmpty||null==t)return this;if(t===this.head.listener)return this.tail;for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;){if(r.head.listener===t)return i.tail=r.tail,n;i=i.tail=new e(r.head),r=r.tail}return this},e.prototype.contains=function(e){if(!this.nonEmpty)return!1;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return!0;t=t.tail}return!1},e.prototype.find=function(e){if(!this.nonEmpty)return null;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return t.head;t=t.tail}return null},e.prototype.toString=function(){for(var e="",t=this;t.nonEmpty;)e+=t.head+" -> ",t=t.tail;return"[List "+(e+="NIL")+"]"},e.NIL=new e(null,null),e}();Ns.SlotList=Us;var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0});var js=function(){function e(e,t,n,i){void 0===n&&(n=!1),void 0===i&&(i=0),this._enabled=!0,this._once=!1,this._priority=0,this._listener=e,this._once=n,this._signal=t,this._priority=i,this.verifyListener(e)}return e.prototype.execute0=function(){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,this._params):this._listener())},e.prototype.execute1=function(e){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,[e].concat(this._params)):this._listener(e))},e.prototype.execute=function(e){if(this._enabled){this._once&&this.remove(),this._params&&this._params.length&&(e=e.concat(this._params));var t=e.length;0===t?this._listener():1===t?this._listener(e[0]):2===t?this._listener(e[0],e[1]):3===t?this._listener(e[0],e[1],e[2]):this._listener.apply(null,e)}},Object.defineProperty(e.prototype,"listener",{get:function(){return this._listener},set:function(e){if(null==e)throw new Error("Given listener is null.\nDid you want to set enabled to false instead?");this.verifyListener(e),this._listener=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"once",{get:function(){return this._once},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"[Slot listener: "+this._listener+", once: "+this._once+", priority: "+this._priority+", enabled: "+this._enabled+"]"},Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"params",{get:function(){return this._params},set:function(e){this._params=e},enumerable:!0,configurable:!0}),e.prototype.remove=function(){this._signal.remove(this._listener)},e.prototype.verifyListener=function(e){if(null==e)throw new Error("Given listener is null.");if(null==this._signal)throw new Error("Internal signal reference has not been set yet.")},e}();Fs.Slot=js,Object.defineProperty(ks,"__esModule",{value:!0});var zs=Ns,Hs=Fs,Gs=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.slots=zs.SlotList.NIL,this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if(!(this._valueClasses[t]instanceof Object))throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+">."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slots.length},enumerable:!0,configurable:!0}),e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){var t=this.slots.find(e);return t?(this.slots=this.slots.filterNot(e),t):null},e.prototype.removeAll=function(){this.slots=zs.SlotList.NIL},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=this.slots;if(s.nonEmpty)for(;s.nonEmpty;)s.head.execute(e),s=s.tail},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.registrationPossible(e,t)){var n=new Hs.Slot(e,this,t);return this.slots=this.slots.prepend(n),n}return this.slots.find(e)},e.prototype.registrationPossible=function(e,t){if(!this.slots.nonEmpty)return!0;var n=this.slots.find(e);if(!n)return!0;if(n.once!==t)throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.");return!1},e}();ks.OnceSignal=Gs,Object.defineProperty(Ls,"__esModule",{value:!0});var Vs=Os,Ys=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Vs.__extends(t,e),t.prototype.add=function(e){return this.registerListener(e)},t}(ks.OnceSignal);Ls.Signal=Ys,Object.defineProperty(_s,"__esModule",{value:!0});var Ws=Os,Xs=Fs,Qs=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ws.__extends(t,e),t.prototype.addWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!1,t)},t.prototype.addOnceWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!0,t)},t.prototype.registerListener=function(e,t){return void 0===t&&(t=!1),this.registerListenerWithPriority(e,t)},t.prototype.registerListenerWithPriority=function(e,t,n){if(void 0===n&&(n=0),this.registrationPossible(e,t)){var i=new Xs.Slot(e,this,t,n);return this.slots=this.slots.insertWithPriority(i),i}return this.slots.find(e)},t}(Ls.Signal);_s.PrioritySignal=Qs,Object.defineProperty(Ps,"__esModule",{value:!0});var Ks=Os,Zs=function(e){function t(t){void 0===t&&(t=null);for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=this;return n=1===n.length&&n[0]instanceof Array?n[0]:n,(r=e.call(this,n)||this)._target=t,r}return Ks.__extends(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){e!==this._target&&(this.removeAll(),this._target=e)},enumerable:!0,configurable:!0}),t.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(null!==e[r]&&e[r].constructor!==this._valueClasses[r])throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=e[0];s&&(s.target&&(s=s.clone(),e[0]=s),s.target=this.target,s.currentTarget=this.target,s.signal=this);for(var o=this.slots;o.nonEmpty;)o.head.execute(e),o=o.tail;if(s&&s.bubbles)for(var a=this.target;a&&a.hasOwnProperty("parent")&&(null===(a=a.parent).onEventBubbled||(s.currentTarget=a,a.onEventBubbled(s))););},t}(_s.PrioritySignal);Ps.DeluxeSignal=Zs;var qs={};Object.defineProperty(qs,"__esModule",{value:!0});var Js=function(){function e(e){void 0===e&&(e=!1),this._bubbles=e}return Object.defineProperty(e.prototype,"signal",{get:function(){return this._signal},set:function(e){this._signal=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){this._target=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this._currentTarget},set:function(e){this._currentTarget=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bubbles",{get:function(){return this._bubbles},set:function(e){this._bubbles=e},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._bubbles)},e}();qs.GenericEvent=Js;var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.IOnceSignal=Symbol("IOnceSignal");var eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.IPrioritySignal=Symbol("IPrioritySignal");var to={};Object.defineProperty(to,"__esModule",{value:!0}),to.ISignal=Symbol("ISignal");var no={};Object.defineProperty(no,"__esModule",{value:!0}),no.ISlot=Symbol("ISlot");var io={};Object.defineProperty(io,"__esModule",{value:!0});var ro=Fs,so=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if("function"!=typeof this._valueClasses[t])throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+"'>."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slot?1:0},enumerable:!0,configurable:!0}),e.prototype.add=function(e){return this.registerListener(e)},e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){if(this.slot&&this.slot.listener===e){var t=this.slot;return this.slot=null,t}return null},e.prototype.removeAll=function(){this.slot&&this.slot.remove()},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");this.slot&&this.slot.execute(e)},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.slot)throw new Error("You cannot add or addOnce with a listener already added, remove the current listener first.");return this.slot=new ro.Slot(e,this,t)},e}();io.MonoSignal=so;var oo={};Object.defineProperty(oo,"__esModule",{value:!0});var ao=Os,lo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ao.__extends(t,e),t.prototype.addOnce=function(t){var n=e.prototype.addOnce.call(this,t);return this.isDispatched&&(n.execute(this.valueObjects),n.remove()),n},t.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(this.isDispatched)throw new Error("You cannot dispatch() a Promise more than once");this.isDispatched=!0,this.valueObjects=t,e.prototype.dispatch.apply(this,t)},t}(ks.OnceSignal);oo.Promise=lo,Object.defineProperty(Rs,"__esModule",{value:!0});var co=Ps;Rs.DeluxeSignal=co.DeluxeSignal;var uo=qs;Rs.GenericEvent=uo.GenericEvent;var ho=$s;Rs.IOnceSignal=ho.IOnceSignal;var fo=eo;Rs.IPrioritySignal=fo.IPrioritySignal;var po=to;Rs.ISignal=po.ISignal;var go=no;Rs.ISlot=go.ISlot;var mo=io;Rs.MonoSignal=mo.MonoSignal;var vo=ks;Rs.OnceSignal=vo.OnceSignal;var yo=_s;Rs.PrioritySignal=yo.PrioritySignal;var wo=oo;Rs.Promise=wo.Promise;var bo=Ls,xo=Rs.Signal=bo.Signal,Ao=Fs;Rs.Slot=Ao.Slot;var To=Ns;Rs.SlotList=To.SlotList;const So=new v;So.name="Scene";class Eo{constructor(e,t){this.signals=e,this.viewportState=t,this.scene=So.clone(),this.scene.castShadow=!0,this.scene.receiveShadow=!0,this.selectedObjects={edge:[],stroke:[],opacity:[],highlight:[],emissive:[]},this.intersectsList={meshOfModelList:[],poiIconList:[],otherObjList:[],getAll:function(){return[...this.meshOfModelList,...this.poiIconList,...this.otherObjList]}}}addObject(e,t){if(this.viewportState.isDisposed)return this.removeObject(e),void yn("Scene is disposed");t?t.add(e):this.scene.add(e),this._triggerObjectAdded(e),this.signals.objectAdded.dispatch(e)}removeObject(e){function t(e){var t;e.map&&((t=e.map)&&t.isTexture&&t.dispose()),e.dispose()}e.traverse((e=>{if("Mesh"===e.type){const n=e;n.geometry.dispose(),On(n.material,t)}e instanceof Fu&&e.element.remove();const{meshOfModelList:n,poiIconList:i,otherObjList:r}=this.intersectsList,s=n.findIndex((t=>t.uuid===e.uuid)),o=i.findIndex((t=>t.uuid===e.uuid)),a=r.findIndex((t=>t.uuid===e.uuid));s>-1&&this.intersectsList.meshOfModelList.splice(s,1),o>-1&&this.intersectsList.poiIconList.splice(o,1),a>-1&&this.intersectsList.otherObjList.splice(a,1)})),e.removeFromParent(),this.signals.objectRemoved.dispatch(e)}openSceneFog(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:t=13426943,near:n=500,far:i=5e4}=e;this.scene.fog=new Q(t,n,i),this.signals.sceneChanged.dispatch()}closeSceneFog(){this.scene.fog=null,this.signals.sceneChanged.dispatch()}edgeShow(e,t){const n=[],i=e=>{-1===this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid))&&n.push(e)};return ji(e)?e.forEach((e=>i(e))):zi(e)&&i(e),this.selectedObjects.edge=[...this.selectedObjects.edge,...n],this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge,options:t}),Promise.resolve()}unEdgeShow(e){e||(e=[...this.selectedObjects.edge]);const t=e=>{const t=this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.edge.splice(t,1),this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge})),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}strokeShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isOpacityShow:n=!0,color:i=4647927,opacity:r=.2,edgeColor:s=61183,edgeOpacity:o=1}=t,a=e=>{if(-1!==this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid)))return Promise.resolve();if(e.userData.strokeGroup)return Promise.resolve();const t=new Nu({id:e.uuid});return e.traverse((n=>{if(n instanceof k){const i=new K(n.geometry,89),r=new Z(i,new q({color:s,transparent:!0,opacity:o}));Dn(r,n),e.attach(r),t.add(r)}})),e.userData.strokeGroup=t,this.addObject(t,e),this.selectedObjects.stroke.push(e),Promise.resolve()};return n&&this.opacityShow(e,{color:i,opacity:r}),ji(e)?Promise.all(e.map((e=>a(e)))):zi(e)?a(e):Promise.resolve()}unStrokeShow(e){e||(e=[...this.selectedObjects.stroke]);const t=e=>{if(!e.userData.strokeGroup)return Promise.resolve();this.removeObject(e.userData.strokeGroup),Reflect.deleteProperty(e.userData,"strokeGroup");const t=this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.stroke.splice(t,1),this.signals.geometryChanged.dispatch(),this.unOpacityShow(e)),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}opacityShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="#fff",opacity:i=.8}=t;function r(e){return Reflect.construct(e.constructor,[{transparent:!0,depthWrite:!1,side:e.side,color:n,opacity:i}])}const s=e=>(-1!==this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unOpacityShow(e){e||(e=[...this.selectedObjects.opacity]);const t=e=>new Promise((t=>{const n=this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.opacity.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}highlightShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=1}=t;function r(e){e instanceof F&&(e.color=new a(n),e.opacity=i,e.transparent=i<1)}const s=e=>(-1!==this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unHighlightShow(e){e||(e=[...this.selectedObjects.highlight]);const t=e=>new Promise((t=>{const n=this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.highlight.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}emissiveShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=.3,maxOpacity:r=1,minOpacity:s=0,duration:o=1e3}=t;function a(e){e instanceof F&&(e.emissive.set(n),e.emissiveIntensity=i,Ki({emissiveIntensity:r},{emissiveIntensity:s},{duration:o,repeat:!0},(t=>e.emissiveIntensity=t.emissiveIntensity),(t=>e.userData.animation=t)))}const l=e=>(-1!==this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,a)}})),this.selectedObjects.emissive.push(e),this.signals.materialChanged.dispatch()),Promise.resolve());return ji(e)?Promise.all(e.map((e=>l(e)))):zi(e)?l(e):Promise.resolve()}unEmissiveShow(e){function t(e){e.userData.animation&&pn.remove(e.userData.animation)}e||(e=[...this.selectedObjects.emissive]);const n=e=>new Promise((n=>{const i=this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid));-1===i&&n(),this.selectedObjects.emissive.splice(i,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;On(e.material,t),Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),n()}));return ji(e)?Promise.all(e.map((e=>n(e)))):zi(e)?n(e):Promise.resolve()}_triggerObjectAdded(e){if(e instanceof ku)if("Model"===e.stype)e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.meshOfModelList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.meshOfModelList.push(e)}}));else if("Poi"===e.stype){const t=this.intersectsList.poiIconList.findIndex((t=>t.uuid===e.icon.uuid));-1===t&&this.intersectsList.poiIconList.push(e.icon)}else if("BaseMesh"===e.stype){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}else"Group"===e.stype?e.children.forEach((e=>this._triggerObjectAdded(e))):"Object3D"===e.type&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}));else if(e instanceof _u){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}else"Object3D"===e.type&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}))}}class Do extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Do&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let Co,Io;const Mo=new t,Bo=new m,Ro=new m,Po={objects:new WeakMap};function Oo(){const e=new t,n=new t;return function(t,i){return e.setFromMatrixPosition(t.matrixWorld),n.setFromMatrixPosition(i.matrixWorld),e.distanceToSquared(n)}}function _o(e){const t=function(e){const t=[];return e.traverse((function(e){e instanceof Do&&t.push(e)})),t}(e).sort((function(e,t){return Po.objects.get(e).distanceToCameraSquared-Po.objects.get(t).distanceToCameraSquared})),n=t.length;for(let e=0,i=t.length;e<i;e++)t[e].element.style.zIndex=""+(n-e)}class Lo{constructor(e){e||(e=document.createElement("div")),e.style.overflow="hidden",this.domElement=e}setSize(e,t){Co=e/2,Io=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"}renderObject(e,t,n){if(e instanceof Do){Mo.setFromMatrixPosition(e.matrixWorld),Mo.applyMatrix4(Ro);const t=e.element,i="translate(-50%,-100%) translate("+(Mo.x*Co+Co)+"px,"+(-Mo.y*Io+Io)+"px)";t.style.transform=i,t.style.display=Cn(e)&&Mo.z>=-1&&Mo.z<=1?"block":"none";const r={distanceToCameraSquared:Oo()(n,e)};Po.objects.set(e,r),t.parentNode!==this.domElement&&this.domElement.appendChild(t)}for(let i=0,r=e.children.length;i<r;i++)this.renderObject(e.children[i],t,n)}render(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Bo.copy(t.matrixWorldInverse),Ro.multiplyMatrices(t.projectionMatrix,Bo),this.renderObject(e,e,t),_o(e)}}class ko extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof ko&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let No,Uo,Fo,jo;function zo(e){return Math.abs(e)<1e-10?0:e}function Ho(e){const t=e.elements;return"matrix3d("+zo(t[0])+","+zo(-t[1])+","+zo(t[2])+","+zo(t[3])+","+zo(t[4])+","+zo(-t[5])+","+zo(t[6])+","+zo(t[7])+","+zo(t[8])+","+zo(-t[9])+","+zo(t[10])+","+zo(t[11])+","+zo(t[12])+","+zo(-t[13])+","+zo(t[14])+","+zo(t[15])+")"}class Go{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){No=e/2,Uo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,t,n,i){if(e instanceof ko){const t=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+zo(n[0])+","+zo(n[1])+","+zo(n[2])+","+zo(n[3])+","+zo(-n[4])+","+zo(-n[5])+","+zo(-n[6])+","+zo(-n[7])+","+zo(n[8])+","+zo(n[9])+","+zo(n[10])+","+zo(n[11])+","+zo(n[12])+","+zo(n[13])+","+zo(n[14])+","+zo(n[15])+")"}(e.matrixWorld),n=e.element;n.style.transform=t,n.style.display=Cn(e)?"block":"none";const i={style:t,distanceToCameraSquared:0};this.cache.objects.set(e,i),n.parentNode!==this.cameraElement&&this.cameraElement.appendChild(n)}for(let r=0,s=e.children.length;r<s;r++)this.renderObject(e.children[r],t,n,i)}render(e,t){const n=t.projectionMatrix.elements[5]*Uo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+zo(-(t.right+t.left)/2)+"px)"+Ho(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Ho(t.matrixWorldInverse);const r=i+"translate("+No+"px,"+Uo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Vo extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Vo&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}function Yo(e){return Math.abs(e)<1e-10?0:e}function Wo(e){const t=e.elements;return"matrix3d("+Yo(t[0])+","+Yo(-t[1])+","+Yo(t[2])+","+Yo(t[3])+","+Yo(t[4])+","+Yo(-t[5])+","+Yo(t[6])+","+Yo(t[7])+","+Yo(t[8])+","+Yo(-t[9])+","+Yo(t[10])+","+Yo(t[11])+","+Yo(t[12])+","+Yo(-t[13])+","+Yo(t[14])+","+Yo(t[15])+")"}class Xo{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){Fo=e/2,jo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,n,i,r){if(e instanceof Vo){const n=i.quaternion.clone();n.x=-i.quaternion.x,n.z=-i.quaternion.z;const r=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+Yo(n[0])+","+Yo(-n[1])+","+Yo(n[2])+","+Yo(n[3])+","+Yo(n[4])+","+Yo(-n[5])+","+Yo(n[6])+","+Yo(n[7])+","+Yo(n[8])+","+Yo(-n[9])+","+Yo(n[10])+","+Yo(n[11])+","+Yo(n[12])+","+Yo(n[13])+","+Yo(n[14])+","+Yo(n[15])+")"}((new m).compose(e.parent.getWorldPosition(new t(0,0,0)),n,e.parent.scale)),s=e.element;s.style.transform=r,s.style.display=Cn(e)?"block":"none";const o={style:r,distanceToCameraSquared:0};this.cache.objects.set(e,o),s.parentNode!==this.cameraElement&&this.cameraElement.appendChild(s)}for(let t=0,s=e.children.length;t<s;t++)this.renderObject(e.children[t],n,i,r)}render(e,t){const n=t.projectionMatrix.elements[5]*jo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+Yo(-(t.right+t.left)/2)+"px)"+Wo(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Wo(t.matrixWorldInverse);const r=i+"translate("+Fo+"px,"+jo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Qo{constructor(e){this.options=e,this.internalOptions={enableRenderCss2D:!1,enableRenderCss2DHalf:!1,enableRenderCss3D:!1},this.container=this._initContainer(),this.renderer=this._initRenderer(),this.rendererCSS2D=this._initRenderCSS2D(),this.rendererCSS3D=this._initRenderCSS3D(),this.rendererCSS2DHalf=this._initRenderCSS2DHalf(),this.interactiveContainer=this._initInteractiveContainer()}setInternalState(e,t){this.internalOptions[e]=t}getWidth(){return this.renderer.domElement.width}getHeight(){return this.renderer.domElement.height}getMouseRelativeConRatio(e){const t=this.container.getBoundingClientRect();return[(e.offsetX-t.left)/t.width,(e.offsetY-t.top)/t.height]}getMousePoint(e){const t=new M(0,0);return t.fromArray(this.getMouseRelativeConRatio(e)),t}_initContainer(){const e=document.createElement("div");return e.style.position="relative",e.style.width="100%",e.style.height="100%",e}_initRenderer(){const{background:e={},logarithmicDepthBuffer:t}=this.options,{color:n,alpha:i}=e,r=new te({alpha:i,logarithmicDepthBuffer:t,preserveDrawingBuffer:!0,antialias:!1,stencil:!1,depth:!1,powerPreference:"high-performance"}),s=i?0:1,{offsetWidth:o,offsetHeight:a}=this.container;return r.setSize(o,a),r.setClearColor(n||0,s),r.setPixelRatio(self.devicePixelRatio),r.localClippingEnabled=!0,r.sortObjects=!0,r.shadowMap.enabled=!0,r.shadowMap.type=ne,this.container.appendChild(r.domElement),r}_initRenderCSS2D(){const e=new Lo;return e.domElement.id="ssp_view_2DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS3D(){const e=new Go;return e.domElement.id="ssp_view_3DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS2DHalf(){const e=new Xo(this.rendererCSS3D.domElement,this.rendererCSS3D.cameraElement);return e.setSize(this.container.offsetWidth,this.container.offsetHeight),e}_initInteractiveContainer(){return this.rendererCSS3D.domElement}}const Ko=new m,Zo=(e,t)=>{const i=Ko.clone(),r=Ko.clone(),s=Ko.clone();i.makeRotationY(e),r.makeRotationX(t);const o=new n;return s.multiplyMatrices(i,r),o.setFromRotationMatrix(s),o},qo=Zo(-Math.PI/2,-Math.PI/4),Jo=Zo(Math.PI/2,-Math.PI/4),$o=Zo(-Math.PI/4,-Math.PI/4),ea=Zo(Math.PI/4,-Math.PI/4),ta=Zo(1.25*Math.PI,-Math.PI/4),na=Zo(.75*Math.PI,-Math.PI/4),ia={LEFT:new n(0,-Math.PI/2,0),RIGHT:new n(0,Math.PI/2,0),FRONT:new n(0,0,0),BACK:new n(0,Math.PI,0),TOP:new n(-Math.PI/2,0,0),BOTTOM:new n(Math.PI/2,0,0),FRONTTOP:new n(-Math.PI/4,0,0),BACKTOP:new n(Math.PI/4,Math.PI,0),LEFTTOP:new n(qo.x,qo.y,qo.z),RIGHTTOP:new n(Jo.x,Jo.y,Jo.z),LEFTFRONTTOP:new n($o.x,$o.y,$o.z),RIGHTFRONTTOP:new n(ea.x,ea.y,ea.z),LEFTBACKTOP:new n(ta.x,ta.y,ta.z),RIGHTBACKTOP:new n(na.x,na.y,na.z)},ra=e=>Fi(e)?e:e.includes("%")?.01*Number(e.split("%")[0]):isNaN(+e)?0:Number(e),sa=new t,oa=new n,aa=new $(50,1,.1,5e5);aa.position.set(500,1e3,500),aa.lookAt(sa.set(0,0,0)),aa.name="Camera";class la{constructor(e){this.viewport=e,this.mainCamera=aa.clone(),this.mainCamera.name="freeCamera",this.currentCamera=this.mainCamera,this.cameras={}}createCamera(e){const t=aa.clone();return t.name=e,this.cameras[e]=t,t}removeCamera(e){return"fullFreeCamera"!==e&&(delete this.cameras[e],!0)}setCurrentCamera(e){this.currentCamera=this.viewport.camera=e,this.viewport.signals.cameraObjectChange.dispatch()}getMainCamera(){return this.mainCamera}getCameraViewpoint(){if("free"===this.viewport.controls.options.type)return{position:this.currentCamera.position.clone(),rotation:{x:this.currentCamera.rotation.x,y:this.currentCamera.rotation.y,z:this.currentCamera.rotation.z}};{const e=this.viewport.controls.currentControls;return{position:this.currentCamera.position.clone(),target:e.target.clone()}}}setCameraViewpoint(e){if("free"===this.viewport.controls.options.type&&zi(e)){const{position:t,rotation:n}=e;this.currentCamera.position.set(t.x,t.y,t.z),this.currentCamera.rotation.set(n.x,n.y,n.z)}else if(zi(e)){const{position:t,target:n}=e,i=this.viewport.controls.currentControls;this.currentCamera.position.set(t.x,t.y,t.z),i.target.set(n.x,n.y,n.z)}this.viewport.signals.cameraChange.dispatch(this.currentCamera.position.clone())}moveTo(e,t){return Ki(this.currentCamera.position,e,t,(e=>this.viewport.signals.cameraChange.dispatch(e)))}rotateTo(e,t){const n=this.currentCamera.quaternion.clone(),i=(new r).setFromEuler(e);return Ki({t:0},{t:1},t,(e=>{let{t:t}=e;this.currentCamera.quaternion.slerpQuaternions(n,i,t)}))}flyTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(Ni(t)){const e=t.toLocaleUpperCase();"CURRENT"===e?oa.copy(this.currentCamera.rotation):ia[e]&&oa.copy(ia[e])}else t instanceof n?oa.copy(t):zi(t)&&oa.set(t.x,t.y,t.z);oa.copy(Tn(this.currentCamera.rotation,oa.clone())),yield Promise.all([this.moveTo(e,i),this.rotateTo(oa,i)])}))}flyToBoundingBox(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(e.isEmpty())return void yn("target box is empty");const r=this.viewport.controls.options.type,s=new t;if(Ni(n)){if("CURRENT"===n.toLocaleUpperCase())s.copy(this.getMovePosByBBox(e));else{const t=ia[n.toLocaleUpperCase()],i=this.getObjectLabelPos(e,t);s.copy(i)}}else{"orbit"===r&&yn("orbit 控制器不支持 Rotation 类型 的 rotation 参数");const t=bn(n),i=this.getObjectLabelPos(e,t);s.copy(i)}if("orbit"===r){const t=e.getCenter(sa),i=this.viewport.controls.currentControls;i.target.copy(t);const r=new m;r.lookAt(s,t,i.object.up),n=oa.setFromRotationMatrix(r)}yield this.flyTo(s,n,i)}))}flyToObj(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof Gu||e instanceof Fu){const{padding:t=50}=i,r=ra(t);return this.flyToBoundingBox(e.getBoundingBox(r),n,i)}{const{padding:r="30%"}=i,s=xn(e),o=s.getSize(sa);let a=0;if(Ni(r)){const e=Math.max(o.x,o.y,o.z);a=ra(r)*e}else a=r;let l=a,c=a;if(a<0){const e=Math.min(o.x,o.z),t=o.y-1;l=Math.abs(a)>e?-e:a,c=Math.abs(l)>t?-t:l}return 0!==r&&(s.max.add(sa.set(l/2,c/2,l/2)),s.min.sub(sa.set(l/2,c/2,l/2))),s.isEmpty()&&(sa.setFromMatrixPosition(e.matrixWorld),s.setFromCenterAndSize(sa,new t(0,0,0))),this.flyToBoundingBox(s,n,i)}}surroundOnTarget(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{speed:n=1,angle:i=360,onStart:r}=t,s=wn(e),o=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),a=Math.abs(i);return Ki({angle:0},{angle:Math.PI/180*a},{duration:a/360*5e3/n},(e=>{const t=i>0?e.angle:2*Math.PI-e.angle;if(this.currentCamera.position.x=Math.sin(t)*o+s.x,this.currentCamera.position.z=Math.cos(t)*o+s.z,"orbit"===this.viewport.controls.options.type){const e=this.viewport.controls.currentControls;e.target.copy(s),e.update()}else this.currentCamera.lookAt(s)}),r)}surroundOnObject(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(new i).setFromObject(e).getCenter(sa);return this.surroundOnTarget(n,t)}getMovePosByBBox(e){const n=this.currentCamera.position,i=e.getCenter(sa);(new t).subVectors(i,n).normalize();let r=new O;r=e.getBoundingSphere(r);const s=this.currentCamera.fov/2*Math.PI/180,o=Math.sin(s),a=r.radius/o,l=new t;this.currentCamera.getWorldDirection(l);const c=l.clone();return c.multiplyScalar(-a),i.clone().add(c)}getObjectLabelPos(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof ku&&(e=(new i).setFromObject(e)),e.isEmpty())return yn("target box is empty"),new t;const{extendScale:s=1.6,mode:o="scene"}=r;if("scene"===o){const t=e.getCenter(sa),i=e.max.clone().sub(e.min),r=Math.max(i.x,i.y,i.z),o=t.clone(),a=e=>{const t=(s-.5)*Math.abs(r),n=Math.max(t,this.viewport.camera.near);o.add(e.multiplyScalar(n))};let l;return l=Ni(n)?ia[n.toLocaleUpperCase()]:bn(n),a(sa.set(0,0,1).applyEuler(l)),o}return"screen"===o?e.getCenter(sa).clone():new t}}
|
|
1
|
+
import*as e from"three";import{Vector3 as t,Euler as n,Box3 as i,Quaternion as r,CubeTextureLoader as s,RGBAFormat as o,Color as a,Texture as l,Source as c,LinearEncoding as u,MathUtils as h,DoubleSide as d,BufferAttribute as f,PropertyBinding as p,InterpolateDiscrete as g,Matrix4 as m,Scene as v,InterpolateLinear as y,NearestFilter as w,NearestMipmapNearestFilter as b,NearestMipmapLinearFilter as x,LinearFilter as A,LinearMipmapNearestFilter as T,LinearMipmapLinearFilter as S,ClampToEdgeWrapping as E,RepeatWrapping as D,MirroredRepeatWrapping as C,sRGBEncoding as I,Vector2 as M,Plane as B,Line3 as R,Triangle as P,Sphere as O,BackSide as _,FrontSide as L,Mesh as k,Ray as N,BoxGeometry as U,MeshStandardMaterial as F,PointLight as j,MeshBasicMaterial as z,DataTextureLoader as H,HalfFloatType as G,FloatType as V,DataUtils as Y,ShaderMaterial as W,UniformsUtils as X,Fog as Q,EdgesGeometry as K,LineSegments as Z,LineBasicMaterial as q,Object3D as J,PerspectiveCamera as $,OrthographicCamera as ee,WebGLRenderer as te,PCFSoftShadowMap as ne,Camera as ie,UnsignedByteType as re,MeshNormalMaterial as se,WebGLRenderTarget as oe,DepthTexture as ae,DepthStencilFormat as le,UnsignedInt248Type as ce,UnsignedIntType as ue,Uniform as he,LoadingManager as de,NoBlending as fe,RGBADepthPacking as pe,REVISION as ge,EventDispatcher as me,MeshDepthMaterial as ve,BasicDepthPacking as ye,DataTexture as we,Vector4 as be,BufferGeometry as xe,Material as Ae,LuminanceFormat as Te,RedFormat as Se,RGFormat as Ee,ShaderChunk as De,WebGLCubeRenderTarget as Ce,CubeCamera as Ie,PMREMGenerator as Me,WebGLMultipleRenderTargets as Be,FramebufferTexture as Re,Matrix3 as Pe,TangentSpaceNormalMap as Oe,GLSL3 as _e,VideoTexture as Le,Frustum as ke,MOUSE as Ne,TOUCH as Ue,Spherical as Fe,CanvasTexture as je,PlaneGeometry as ze,Raycaster as He,Clock as Ge,AnimationMixer as Ve,ACESFilmicToneMapping as Ye,AnimationClip as We,NoToneMapping as Xe,LinearToneMapping as Qe,ReinhardToneMapping as Ke,CineonToneMapping as Ze,EquirectangularReflectionMapping as qe,TextureLoader as Je,Sprite as $e,SpriteMaterial as et,SphereGeometry as tt,CircleGeometry as nt,Float32BufferAttribute as it,ShapeGeometry as rt,Shape as st,UniformsLib as ot,UVMapping as at,AmbientLight as lt,DirectionalLight as ct,HemisphereLight as ut,SpotLight as ht,RectAreaLight as dt,Curve as ft,Loader as pt,LoaderUtils as gt,FileLoader as mt,MeshPhongMaterial as vt,MeshLambertMaterial as yt,Group as wt,Bone as bt,SkinnedMesh as xt,Line as At,Skeleton as Tt,Uint16BufferAttribute as St,VectorKeyframeTrack as Et,QuaternionKeyframeTrack as Dt,NumberKeyframeTrack as Ct,TrianglesDrawMode as It,TriangleFanDrawMode as Mt,TriangleStripDrawMode as Bt,MeshPhysicalMaterial as Rt,InstancedMesh as Pt,ImageBitmapLoader as Ot,InterleavedBuffer as _t,InterleavedBufferAttribute as Lt,PointsMaterial as kt,LineLoop as Nt,Points as Ut,Interpolant as Ft,LinearMipMapLinearFilter as jt,ImageLoader as zt,GridHelper as Ht,AxesHelper as Gt,Box3Helper as Vt,DirectionalLightHelper as Yt,HemisphereLightHelper as Wt,SpotLightHelper as Xt,PointLightHelper as Qt,Box2 as Kt}from"three";export*from"three";var Zt,qt="soonspacejs",Jt="2.6.1",$t={Linear:{None:function(e){return e}},Quadratic:{In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}},Cubic:{In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}},Quartic:{In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}},Quintic:{In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}},Sinusoidal:{In:function(e){return 1-Math.cos(e*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.cos(Math.PI*e))}},Exponential:{In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}},Circular:{In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}},Elastic:{In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}},Back:{In:function(e){var t=1.70158;return e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}},Bounce:{In:function(e){return 1-$t.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*$t.Bounce.In(2*e):.5*$t.Bounce.Out(2*e-1)+.5}}},en="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},tn=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map((function(t){return e._tweens[t]}))},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){void 0===e&&(e=en()),void 0===t&&(t=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],s=!t;r&&!1===r.update(e,s)&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),nn={Linear:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.Linear;return t<0?s(e[0],e[1],i):t>1?s(e[n],e[n-1],n-i):s(e[r],e[r+1>n?n:r+1],i-r)},Bezier:function(e,t){for(var n=0,i=e.length-1,r=Math.pow,s=nn.Utils.Bernstein,o=0;o<=i;o++)n+=r(1-t,i-o)*r(t,o)*e[o]*s(i,o);return n},CatmullRom:function(e,t){var n=e.length-1,i=n*t,r=Math.floor(i),s=nn.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(r=Math.floor(i=n*(1+t))),s(e[(r-1+n)%n],e[r],e[(r+1)%n],e[(r+2)%n],i-r)):t<0?e[0]-(s(e[0],e[0],e[1],e[1],-i)-e[0]):t>1?e[n]-(s(e[n],e[n],e[n-1],e[n-1],i-n)-e[n]):s(e[r?r-1:0],e[r],e[n<r+1?n:r+1],e[n<r+2?n:r+2],i-r)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=nn.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(Zt=[1],function(e){var t=1;if(Zt[e])return Zt[e];for(var n=e;n>1;n--)t*=n;return Zt[e]=t,t}),CatmullRom:function(e,t,n,i,r){var s=.5*(n-e),o=.5*(i-t),a=r*r;return(2*t-2*n+s+o)*(r*a)+(-3*t+3*n-2*s-o)*a+s*r+t}}},rn=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),sn=new tn,on=function(){function e(e,t){void 0===t&&(t=sn),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=$t.Linear.None,this._interpolationFunction=nn.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=rn.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),void 0!==t&&(this._duration=t),this},e.prototype.duration=function(e){return this._duration=e,this},e.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var t in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==e?"string"==typeof e?en()+parseFloat(e):e:en(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},e.prototype._setupProperties=function(e,t,n,i){for(var r in n){var s=e[r],o=Array.isArray(s),a=o?"array":typeof s,l=!o&&Array.isArray(n[r]);if("undefined"!==a&&"function"!==a){if(l){var c=n[r];if(0===c.length)continue;c=c.map(this._handleRelativeValue.bind(this,s)),n[r]=[s].concat(c)}if("object"!==a&&!o||!s||l)void 0===t[r]&&(t[r]=s),o||(t[r]*=1),i[r]=l?n[r].slice().reverse():t[r]||0;else{for(var u in t[r]=o?[]:{},s)t[r][u]=s[u];i[r]=o?[]:{},this._setupProperties(s,t[r],n[r],i[r])}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return void 0===e&&(e=en()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this)),this},e.prototype.resume=function(e){return void 0===e&&(e=en()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return this._group=e,this},e.prototype.delay=function(e){return this._delayTime=e,this},e.prototype.repeat=function(e){return this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return this._yoyo=e,this},e.prototype.easing=function(e){return this._easingFunction=e,this},e.prototype.interpolation=function(e){return this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){if(void 0===e&&(e=en()),void 0===t&&(t=!0),this._isPaused)return!0;var n,i,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e)}if(this._goToEnd=!1,e<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(e-this._startTime)/this._duration,i=0===this._duration||i>1?1:i;var s=this._easingFunction(i);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,s),this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,a=this._chainedTweens.length;o<a;o++)this._chainedTweens[o].start(this._startTime+this._duration);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(void 0!==t[r]){var s=t[r]||0,o=n[r],a=Array.isArray(e[r]),l=Array.isArray(o);!a&&l?e[r]=this._interpolationFunction(o,i):"object"==typeof o&&o?this._updateProperties(e[r],s,o,i):"number"==typeof(o=this._handleRelativeValue(s,o))&&(e[r]=s+(o-s)*i)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof n?this._valuesStartRepeat[e]+parseFloat(n):this._valuesEnd[e],this._valuesEnd[e]=t},e}(),an=rn.nextId,ln=sn,cn=ln.getAll.bind(ln),un=ln.removeAll.bind(ln),hn=ln.add.bind(ln),dn=ln.remove.bind(ln),fn=ln.update.bind(ln),pn={Easing:$t,Group:tn,Interpolation:nn,now:en,Sequence:rn,nextId:an,Tween:on,VERSION:"18.6.4",getAll:cn,removeAll:un,add:hn,remove:dn,update:fn};const gn="[soonspacejs]: ",mn="In soonspacejs: ",vn=(e,t)=>{let n="";for(const e in t)n+=`${e}: ${t[e]};`;console.log(`%c${e}`,n)},yn=e=>{console.warn(mn+e)};function wn(e){return e instanceof t?e:new t(e.x,e.y,e.z)}function bn(e){return e instanceof n?e:new n(e.x,e.y,e.z)}function xn(e){return new i(new t(0,0,0),new t(500,500,500)).setFromObject(e)}function An(e,t,n){const i=n.clone();return Math.abs(t[e]-n[e])>Math.PI&&(t[e]>n[e]?i[e]+=2*Math.PI:i[e]-=2*Math.PI),i}function Tn(e,t){const i=An("x",e,t),r=An("y",e,t),s=An("z",e,t);return new n(i.x,r.y,s.z,t.order)}function Sn(e){return Math.PI/180*e}function En(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?{position:e.getWorldPosition(new t),rotation:(new n).setFromQuaternion(e.getWorldQuaternion(new r)),scale:e.getWorldScale(new t)}:{position:e.position.clone(),rotation:e.rotation.clone(),scale:e.scale.clone()}}function Dn(e,t){const n=En(t,!(arguments.length>2&&void 0!==arguments[2])||arguments[2]);e.position.copy(n.position),e.rotation.copy(n.rotation),e.scale.copy(n.scale)}function Cn(e){return!!e.visible&&(!e.parent||Cn(e.parent))}class In{constructor(){this.min=null,this.roots=[],this.nodes=new Map}shift(){const e=this.min;if(null===e||this.roots.length<1)return this.min=null,e;this.remove(e),this.roots.length>50&&this.consolidate();let t=1/0;const n=this.roots.length;for(let e=0;e<n;e++){const n=this.roots[e],i=this.getDistance(n);i<t&&(t=i,this.min=n)}return e}consolidate(){const e=[[],[],[],[],[],[],[]],t=e.length-1,n=this.roots.length;for(let i=0;i<n;i++){const n=this.roots[i],r=this.nodes.get(n);r&&r.depth<t&&e[r.depth].push(n)}for(let n=0;n<=t;n++)for(;e[n].length>1;){const i=e[n].shift(),r=e[n].shift(),s=n+1;let o=-1;if(void 0!==i&&void 0!==r){const n=this.nodes.get(i),a=this.nodes.get(r);n&&a&&(n.distance<a.distance?(n.depth=s,n.children.push(r),a.parent=i,s<=t&&e[s].push(i),o=this.roots.indexOf(r)):(a.depth=s,a.children.push(i),n.parent=r,s<=t&&e[s].push(r),o=this.roots.indexOf(i)))}o>-1&&this.roots.splice(o,1)}}add(e,t){if(this.nodes.set(e,{nodeIndex:e,distance:t,depth:0,parent:null,children:[]}),null===this.min)this.min=e;else{const n=this.nodes.get(this.min);n&&t<n.distance&&(this.min=e)}this.roots.push(e)}update(e,t){this.remove(e),this.add(e,t)}remove(e){var t,n;if(!this.nodes.has(e))return;const i=null===(t=this.nodes.get(e))||void 0===t?void 0:t.children;if(i&&i.length>0)for(let t=0;t<i.length;t++){const n=i[t],r=this.nodes.get(n),s=this.nodes.get(e);r&&s&&(r.parent=s.parent),r&&null===r.parent&&this.roots.push(n)}let r=null===(n=this.nodes.get(e))||void 0===n?void 0:n.parent;if(null===r){const t=this.roots.indexOf(e);t>-1&&this.roots.splice(t,1)}else for(;r;){const e=this.nodes.get(r);e&&(e.depth--,r=e.parent)}}getDistance(e){const t=this.nodes.get(e);return t?t.distance:1/0}}function Mn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["px.jpg","nx.jpg","py.jpg","ny.jpg","pz.jpg","nz.jpg"];return new Promise((n=>{(new s).setPath(e).load(t,(e=>{e.format=o,n(e)}))}))}function Bn(e){if(!e)return null;const{colors:t,stops:n,size:i=1024}=e,r=document.createElement("canvas"),s=r.getContext("2d");if(!s)return null;r.width=16,r.height=i;const o=s.createLinearGradient(0,0,0,i),c=new a,u=t.map((e=>c.set(e).getStyle()));for(let e=0,t=u.length-1;e<=t;e++)o.addColorStop(n?n[e]:e/t,u[e]);s.fillStyle=o,s.fillRect(0,0,16,i);const h=new l(r);return h.needsUpdate=!0,h}const Rn=e=>{const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)};function Pn(e){return ji(e)?function(e){return e.map((e=>Pn(e)))}(e):zi(e)?function(e){if(zi(e)){const t={};for(const n in e)t[n]=Pn(e[n]);return t}return e}(e):e}const On=(e,t)=>ji(e)?e.map(t):t(e),_n=e=>On(e,(e=>e.clone())),Ln=e=>On(e,(e=>e.dispose()));var kn=function(e,t){return kn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},kn(e,t)};var Nn=function(){return Nn=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},Nn.apply(this,arguments)};function Un(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function Fn(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}var jn=Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]};function zn(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hn(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,r,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return o}function Gn(e){return this instanceof Gn?(this.v=e,this):new Gn(e)}var Vn=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function Yn(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Wn(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}var Xn=Object.freeze({__proto__:null,get __assign(){return Nn},__asyncDelegator:function(e){var t,n;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(n=!n)?{value:Gn(e[i](t)),done:!1}:r?r(t):t}:r}},__asyncGenerator:function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=n.apply(e,t||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise((function(n,i){s.push([e,t,n,i])>1||a(e,t)}))})}function a(e,t){try{(n=r[e](t)).value instanceof Gn?Promise.resolve(n.value.v).then(l,c):u(s[0][2],n)}catch(e){u(s[0][3],e)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function u(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=zn(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){(function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)})(i,r,(t=e[n](t)).done,t.value)}))}}},__await:Gn,__awaiter:Fn,__classPrivateFieldGet:Yn,__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)},__classPrivateFieldSet:Wn,__createBinding:jn,__decorate:function(e,t,n,i){var r,s=arguments.length,o=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,n,o):r(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o},__esDecorate:function(e,t,n,i,r,s){function o(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var a,l=i.kind,c="getter"===l?"get":"setter"===l?"set":"value",u=!t&&e?i.static?e:e.prototype:null,h=t||(u?Object.getOwnPropertyDescriptor(u,i.name):{}),d=!1,f=n.length-1;f>=0;f--){var p={};for(var g in i)p[g]="access"===g?{}:i[g];for(var g in i.access)p.access[g]=i.access[g];p.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");s.push(o(e||null))};var m=(0,n[f])("accessor"===l?{get:h.get,set:h.set}:h[c],p);if("accessor"===l){if(void 0===m)continue;if(null===m||"object"!=typeof m)throw new TypeError("Object expected");(a=o(m.get))&&(h.get=a),(a=o(m.set))&&(h.set=a),(a=o(m.init))&&r.push(a)}else(a=o(m))&&("field"===l?r.push(a):h[c]=a)}u&&Object.defineProperty(u,i.name,h),d=!0},__exportStar:function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||jn(t,e,n)},__extends:function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}kn(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},__generator:function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,i=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){o.label=a[1];break}if(6===a[0]&&o.label<r[1]){o.label=r[1],r=a;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(a);break}r[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&jn(t,e,n);return Vn(t,e),t},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__param:function(e,t){return function(n,i){t(n,i,e)}},__propKey:function(e){return"symbol"==typeof e?e:"".concat(e)},__read:Hn,__rest:Un,__runInitializers:function(e,t,n){for(var i=arguments.length>2,r=0;r<t.length;r++)n=i?t[r].call(e,n):t[r].call(e);return i?n:void 0},__setFunctionName:function(e,t,n){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:n?"".concat(n," ",t):t})},__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Hn(arguments[t]));return e},__spreadArray:function(e,t,n){if(n||2===arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},__spreadArrays:function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var i=Array(e),r=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,r++)i[r]=s[o];return i},__values:zn});const Qn=e=>Fn(void 0,void 0,void 0,(function*(){const t=yield fetch(e);if(200===t.status)return t;throw new Error(`Failed to fetch file: ${e}`)})),Kn=e=>{"function"==typeof requestIdleCallback?requestIdleCallback(e):setTimeout(e)};var Zn=function(){function e(){}return e.prototype.toJson=function(e,t){var n=this.xmlStringToXmlDom(e),i=this.xmlToJson(n);return t?(t.removeLineBreaks&&this.removeLineBreaks(i),t.removeComments&&this.removeCommentProperties(i),t.transformTextOnly&&this.transformTextOnly(i),i):i},e.prototype.xmlStringToXmlDom=function(e){return(new DOMParser).parseFromString(e,"text/xml")},e.prototype.removeLineBreaks=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#text"===n&&Array.isArray(e[n])&&delete e[n],"object"==typeof e[n]&&t.removeLineBreaks(e[n])}))},e.prototype.removeCommentProperties=function(e){var t=this;Object.keys(e).forEach((function(n,i){"#comment"===n&&delete e[n],"object"==typeof e[n]&&t.removeCommentProperties(e[n])}))},e.prototype.transformTextOnly=function(e){var t=this;Object.keys(e).forEach((function(n,i){var r=Object.keys(e[n]).length>1,s=Object.keys(e[n])[0];r||"object"==typeof e[n][s]?t.transformTextOnly(e[n]):"object"==typeof e[n]&&e[n]["#text"]&&(e[n]=e[n]["#text"])}))},e.prototype.xmlToJson=function(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t._attributes={};for(var n=0;n<e.attributes.length;n++){var i=e.attributes.item(n);t._attributes[i.nodeName]=i.nodeValue}}}else 3==e.nodeType&&(t=e.nodeValue);if(e.hasChildNodes())for(var r=0;r<e.childNodes.length;r++){var s=e.childNodes.item(r),o=s.nodeName;if(void 0===t[o])t[o]=this.xmlToJson(s);else{if(void 0===t[o].push){var a=t[o];t[o]=[],t[o].push(a)}t[o].push(this.xmlToJson(s))}}return t},e}();function qn(e){return Qn(e).then((e=>e.text())).then((e=>Promise.resolve(function(e){return(new Zn).toJson(e,{transformTextOnly:!0,removeComments:!0,removeLineBreaks:!0})}(e))))}class Jn{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Ii(e)})),this.register((function(e){return new Mi(e)})),this.register((function(e){return new Pi(e)})),this.register((function(e){return new Oi(e)})),this.register((function(e){return new _i(e)})),this.register((function(e){return new Li(e)})),this.register((function(e){return new Bi(e)})),this.register((function(e){return new Ri(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){const r=new Ci,s=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)s.push(this.pluginCallbacks[e](r));r.setPlugins(s),r.write(e,t,i).catch(n)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,i,r,t)}))}}const $n=0,ei=1,ti=2,ni=3,ii=4,ri=5121,si=5123,oi=5126,ai=5125,li=34962,ci=34963,ui=9728,hi=9729,di=9984,fi=9985,pi=9986,gi=9987,mi=33071,vi=33648,yi=10497,wi={};wi[w]=ui,wi[b]=di,wi[x]=pi,wi[A]=hi,wi[T]=fi,wi[S]=gi,wi[E]=mi,wi[D]=yi,wi[C]=vi;const bi={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},xi=new a;function Ai(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function Ti(e){return 4*Math.ceil(e/4)}function Si(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=Ti(e.byteLength);if(n!==e.byteLength){const i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<n;r++)i[r]=t;return i.buffer}return e}function Ei(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function Di(e,t){if(void 0!==e.toBlob)return new Promise((n=>e.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}class Ci{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,r=i.buffers,s=i.json;n=i.options;const o=i.extensionsUsed,a=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(o);if(l.length>0&&(s.extensionsUsed=l),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=a.size),!0===n.binary){const e=new FileReader;e.readAsArrayBuffer(a),e.onloadend=function(){const n=Si(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const r=Si((o=JSON.stringify(s),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,r.byteLength,!0),a.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const u=12+a.byteLength+r.byteLength+i.byteLength+n.byteLength;c.setUint32(8,u,!0);const h=new Blob([l,a,r,i,n],{type:"application/octet-stream"}),d=new FileReader;d.readAsArrayBuffer(h),d.onloadend=function(){t(d.result)}}}else if(s.buffers&&s.buffers.length>0){const e=new FileReader;e.readAsDataURL(a),e.onloadend=function(){const n=e.result;s.buffers[0].uri=n,t(s)}}else t(s)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new t;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const i=e.clone(),r=new t;for(let e=0,t=i.count;e<t;e++)r.fromBufferAttribute(i,e),0===r.x&&0===r.y&&0===r.z?r.setX(1):r.normalize(),i.setXYZ(e,r.x,r.y,r.z);return n.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let n=!1;const i={};0===t.offset.x&&0===t.offset.y||(i.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(i.rotation=t.rotation,n=!0),1===t.repeat.x&&1===t.repeat.y||(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.encoding===I?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.");const i=e?e.image:null,r=t?t.image:null,s=Math.max(i?i.width:0,r?r.width:0),o=Math.max(i?i.height:0,r?r.height:0),a=Ei();a.width=s,a.height=o;const l=a.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,s,o);const h=l.getImageData(0,0,s,o);if(i){l.drawImage(i,0,0,s,o);const t=n(e),r=l.getImageData(0,0,s,o).data;for(let e=2;e<r.length;e+=4)h.data[e]=256*t(r[e]/256)}if(r){l.drawImage(r,0,0,s,o);const e=n(t),i=l.getImageData(0,0,s,o).data;for(let t=1;t<i.length;t+=4)h.data[t]=256*e(i[t]/256)}l.putImageData(h,0,0);const d=(e||t).clone();return d.source=new c(a),d.encoding=u,d}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,r){const s=this.json;let o;s.bufferViews||(s.bufferViews=[]),o=t===ri?1:t===si?2:4;const a=Ti(i*e.itemSize*o),l=new DataView(new ArrayBuffer(a));let c=0;for(let r=n;r<n+i;r++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[r*e.itemSize+n]:(0===n?i=e.getX(r):1===n?i=e.getY(r):2===n?i=e.getZ(r):3===n&&(i=e.getW(r)),!0===e.normalized&&(i=h.normalize(i,e.array))),t===oi?l.setFloat32(c,i,!0):t===ai?l.setUint32(c,i,!0):t===si?l.setUint16(c,i,!0):t===ri&&l.setUint8(c,i),c+=o}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==r&&(u.target=r),r===li&&(u.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(u);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const e=Si(r.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(s)-1)}}))}processAccessor(e,t,n,i){const r=this.json;let s;if(e.array.constructor===Float32Array)s=oi;else if(e.array.constructor===Uint32Array)s=ai;else if(e.array.constructor===Uint16Array)s=si;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");s=ri}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;const o=function(e,t,n){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+n;r++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=h.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);let a;void 0!==t&&(a=e===t.index?ci:li);const l=this.processBufferView(e,s,n,i,a),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:s,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(c)-1}processImage(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"image/png";if(null!==e){const r=this,s=r.cache,a=r.json,l=r.options,c=r.pending;s.images.has(e)||s.images.set(e,{});const u=s.images.get(e),h=i+":flipY/"+n.toString();if(void 0!==u[h])return u[h];a.images||(a.images=[]);const d={mimeType:i},f=Ei();f.width=Math.min(e.width,l.maxTextureSize),f.height=Math.min(e.height,l.maxTextureSize);const p=f.getContext("2d");if(!0===n&&(p.translate(0,f.height),p.scale(1,-1)),void 0!==e.data){t!==o&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else p.drawImage(e,0,0,f.width,f.height);!0===l.binary?c.push(Di(f,i).then((e=>r.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):void 0!==f.toDataURL?d.uri=f.toDataURL(i):c.push(Di(f,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{d.uri=e})));const g=a.images.push(d)-1;return u[h]=g,g}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:wi[e.magFilter],minFilter:wi[e.minFilter],wrapS:wi[e.wrapS],wrapT:wi[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");const r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(r.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,r)}));const s=n.textures.push(r)-1;return t.textures.set(e,s),s}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(Ai(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t)};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),n=Math.max(t.r,t.g,t.b);if(n>1&&(t.multiplyScalar(1/n),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(i.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===d&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));const s=n.materials.push(i)-1;return t.materials.set(e,s),s}processMesh(e){const t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);const r=i.join(":");if(t.meshes.has(r))return t.meshes.get(r);const s=e.geometry;let o;o=e.isLineSegments?ei:e.isLineLoop?ti:e.isLine?ni:e.isPoints?$n:e.material.wireframe?ei:ii;const a={},l={},c=[],u=[],h={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");void 0===d||this.isNormalizedNormalAttribute(d)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let p=null;for(let e in s.attributes){if("morph"===e.slice(0,5))continue;const n=s.attributes[e];e=h[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(n))){l[e]=t.attributes.get(this.getUID(n));continue}p=null;const i=n.array;"JOINTS_0"!==e||i instanceof Uint16Array||i instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new f(new Uint16Array(i),n.itemSize,n.normalized));const r=this.processAccessor(p||n,s);null!==r&&(l[e]=r,t.attributes.set(this.getUID(n),r))}if(void 0!==d&&s.setAttribute("normal",d),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let o=0;o<e.morphTargetInfluences.length;++o){const a={};let l=!1;for(const e in s.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}const n=s.morphAttributes[e][o],i=e.toUpperCase(),r=s.attributes[e];if(t.attributes.has(this.getUID(n,!0))){a[i]=t.attributes.get(this.getUID(n,!0));continue}const c=n.clone();if(!s.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)0===t&&c.setX(e,n.getX(e)-r.getX(e)),1===t&&c.setY(e,n.getY(e)-r.getY(e)),2===t&&c.setZ(e,n.getZ(e)-r.getZ(e)),3===t&&c.setW(e,n.getW(e)-r.getW(e));a[i]=this.processAccessor(c,s),t.attributes.set(this.getUID(r,!0),a[i])}u.push(a),n.push(e.morphTargetInfluences[o]),void 0!==e.morphTargetDictionary&&i.push(r[o])}a.weights=n,i.length>0&&(a.extras={},a.extras.targetNames=i)}const g=Array.isArray(e.material);if(g&&0===s.groups.length)return null;const m=g?e.material:[e.material],v=g?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=v.length;e<n;e++){const n={mode:o,attributes:l};if(this.serializeUserData(s,n),u.length>0&&(n.targets=u),null!==s.index){let i=this.getUID(s.index);void 0===v[e].start&&void 0===v[e].count||(i+=":"+v[e].start+":"+v[e].count),t.attributes.has(i)?n.indices=t.attributes.get(i):(n.indices=this.processAccessor(s.index,s,v[e].start,v[e].count),t.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=this.processMaterial(m[v[e].materialIndex]);null!==i&&(n.material=i),c.push(n)}a.primitives=c,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,a)}));const y=n.meshes.push(a)-1;return t.meshes.set(r,y),y}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:h.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const r=(e=Jn.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,s=[],o=[];for(let e=0;e<r.length;++e){const n=r[e],a=p.parseTrackName(n.name);let l=p.findNode(t,a.nodeName);const c=bi[a.propertyName];if("bones"===a.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(a.objectIndex):void 0),!l||!c)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',n.name),null;const u=1;let h,d=n.values.length/n.times.length;c===bi.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(h="CUBICSPLINE",d/=3):h=n.getInterpolation()===g?"STEP":"LINEAR",o.push({input:this.processAccessor(new f(n.times,u)),output:this.processAccessor(new f(n.values,d)),interpolation:h}),s.push({sampler:o.length-1,target:{node:i.get(l),path:c}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:s}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],r=e.skeleton;if(void 0===r)return null;const s=e.skeleton.bones[0];if(void 0===s)return null;const o=[],a=new Float32Array(16*r.bones.length),l=new m;for(let t=0;t<r.bones.length;++t)o.push(n.get(r.bones[t])),l.copy(r.boneInverses[t]),l.multiply(e.bindMatrix).toArray(a,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new f(a,16)),joints:o,skeleton:n.get(s)});return i.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const t=e.quaternion.toArray(),n=e.position.toArray(),i=e.scale.toArray();Ai(t,[0,0,0,1])||(r.rotation=t),Ai(n,[0,0,0])||(r.translation=n),Ai(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Ai(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let i=0,r=e.children.length;i<r;i++){const r=e.children[i];if(r.visible||!1===n.onlyVisible){const e=this.processNode(r);null!==e&&t.push(e)}}t.length>0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));const s=t.nodes.push(r)-1;return i.set(e,s),s}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);const r=[];for(let t=0,i=e.children.length;t<i;t++){const i=e.children[t];if(i.visible||!1===n.onlyVisible){const e=this.processNode(i);null!==e&&r.push(e)}}r.length>0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){const t=new v;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const n=[];for(let t=0;t<e.length;t++)e[t]instanceof v?this.processScene(e[t]):n.push(e[t]);n.length>0&&this.processObjects(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class Ii{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const n=this.writer,i=n.json,r=n.extensionsUsed,s={};e.name&&(s.name=e.name),s.color=e.color.toArray(),s.intensity=e.intensity,e.isDirectionalLight?s.type="directional":e.isPointLight?(s.type="point",e.distance>0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);const o=i.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}let Mi=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},Bi=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:n.processTexture(e.clearcoatMap)};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:n.processTexture(e.clearcoatRoughnessMap)};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:n.processTexture(e.clearcoatNormalMap)};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Ri=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:n.processTexture(e.iridescenceMap)};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:n.processTexture(e.iridescenceThicknessMap)};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Pi=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const t={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},Oi=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const t={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},_i=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;const n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},Li=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(xi)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){const t={index:n.processTexture(e.specularIntensityMap)};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){const t={index:n.processTexture(e.specularColorMap)};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}};Jn.Utils={insertKeyframe:function(e,t){const n=.001,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),s=new e.ValueBufferType(e.values.length+i),o=e.createInterpolant(new e.ValueBufferType(i));let a;if(0===e.times.length){r[0]=t;for(let e=0;e<i;e++)s[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;r[0]=t,r.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,i),a=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),a=r.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<n)return l;if(e.times[l]<t&&e.times[l+1]>t){r.set(e.times.slice(0,l+1),0),r[l+1]=t,r.set(e.times.slice(l+1),l+2),s.set(e.values.slice(0,(l+1)*i),0),s.set(o.evaluate(t),(l+1)*i),s.set(e.values.slice((l+1)*i),(l+2)*i),a=l+1;break}}return e.times=r,e.values=s,a},mergeMorphTargetTracks:function(e,t){const n=[],i={},r=e.tracks;for(let e=0;e<r.length;++e){let s=r[e];const o=p.parseTrackName(s.name),a=p.findNode(t,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){n.push(s);continue}if(s.createInterpolant!==s.InterpolantFactoryMethodDiscrete&&s.createInterpolant!==s.InterpolantFactoryMethodLinear){if(s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),s=s.clone(),s.setInterpolation(y)}const l=a.morphTargetInfluences.length,c=a.morphTargetDictionary[o.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(void 0===i[a.uuid]){u=s.clone();const e=new u.ValueBufferType(l*u.times.length);for(let t=0;t<u.times.length;t++)e[t*l+c]=u.values[t];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=e,i[a.uuid]=u,n.push(u);continue}const h=s.createInterpolant(new s.ValueBufferType(1));u=i[a.uuid];for(let e=0;e<u.times.length;e++)u.values[e*l+c]=h.evaluate(u.times[e]);for(let e=0;e<s.times.length;e++){const t=this.insertKeyframe(u,s.times[e]);u.values[t*l+c]=s.values[e]}}return e.tracks=n,e}};const ki=Object.prototype.hasOwnProperty,Ni=e=>"String"===Gi(e),Ui=e=>"Boolean"===Gi(e),Fi=e=>"Number"===Gi(e),ji=Array.isArray,zi=e=>"Object"===Gi(e),Hi=e=>"Function"===Gi(e),Gi=e=>Object.prototype.toString.call(e).slice(8,-1),Vi=(e,t,n)=>String.fromCodePoint(...new Uint8Array(e,t,n)),Yi=()=>gn+Math.random().toString(36).substring(7).split("").join("_"),Wi=e=>{var t;const{pathname:n}=new URL(e,location.origin);return null===(t=n.split(".").pop())||void 0===t?void 0:t.toLowerCase()};var Xi=Object.freeze({__proto__:null,IVector3ToEuler:bn,IVector3ToVector3:wn,MinHeap:In,cloneDeep:Pn,cloneMaterials:_n,deg2Euler:Sn,disposeMaterials:Ln,error:e=>{console.error(mn+e)},euler2Deg:function(e){return e/(Math.PI/180)},exportGltf:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((n,i)=>{(new Jn).parse(e,(e=>n(e)),(e=>i(e)),t)}))},fetchFile:Qn,getAsciiString:Vi,getBoundingBox:xn,getCubeTexture:Mn,getExtension:Wi,getSpaceAttributeFromObject:En,getValueType:Gi,gradientTexture:Bn,hasOwn:(e,t)=>ki.call(e,t),idleTask:Kn,isArray:ji,isBoolean:Ui,isDate:e=>"Date"===Gi(e),isFunction:Hi,isNull:e=>"Null"===Gi(e),isNumber:Fi,isObject:zi,isObjectVisible:Cn,isPromise:e=>"Promise"===Gi(e),isString:Ni,isSymbol:e=>"Symbol"===Gi(e),isUndefined:e=>"Undefined"===Gi(e),log:vn,materialHandle:On,parseFilePath:Rn,randomString:Yi,rotationAFix:Tn,rotationAxisFix:An,sleep:e=>new Promise((t=>setTimeout((()=>t()),e))),syncSpaceAttributeToObject:Dn,warn:yn,xmlToJson:qn});const Qi={"Linear.None":$t.Linear.None,"Quadratic.In":$t.Quadratic.In,"Quadratic.Out":$t.Quadratic.Out,"Quadratic.InOut":$t.Quadratic.InOut,"Cubic.In":$t.Cubic.In,"Cubic.Out":$t.Cubic.Out,"Cubic.InOut":$t.Cubic.InOut,"Quartic.In":$t.Quartic.In,"Quartic.Out":$t.Quartic.Out,"Quartic.InOut":$t.Quartic.InOut,"Quintic.In":$t.Quintic.In,"Quintic.Out":$t.Quintic.Out,"Quintic.InOut":$t.Quintic.InOut,"Sinusoidal.In":$t.Sinusoidal.In,"Sinusoidal.Out":$t.Sinusoidal.Out,"Sinusoidal.InOut":$t.Sinusoidal.InOut,"Exponential.In":$t.Exponential.In,"Exponential.Out":$t.Exponential.Out,"Exponential.InOut":$t.Exponential.InOut,"Circular.In":$t.Circular.In,"Circular.Out":$t.Circular.Out,"Circular.InOut":$t.Circular.InOut,"Elastic.In":$t.Elastic.In,"Elastic.Out":$t.Elastic.Out,"Elastic.InOut":$t.Elastic.InOut,"Back.In":$t.Back.In,"Back.Out":$t.Back.Out,"Back.InOut":$t.Back.InOut,"Bounce.In":$t.Bounce.In,"Bounce.Out":$t.Bounce.Out,"Bounce.InOut":$t.Bounce.InOut};function Ki(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;return new Promise(((o,a)=>{const{duration:l=1e3,delay:c=0,repeat:u=!1,mode:h="Linear.None",yoyo:d=!1}=i,f=Qi[h],p=new on(e).to(t,l).easing(f).delay(c).onUpdate((i=>{e instanceof n&&t instanceof n&&i instanceof n&&(i.order=t.order),null==r||r(i,p)})).onComplete((()=>{o()})).onStop((()=>{a("animation stop")})).onStart((()=>{null==s||s(p)}));Fi(u)?p.repeat(u):Ui(u)&&u&&p.repeat(1/0),p.yoyo(d),p.start()}))}class Zi{constructor(e,t,n){this.target=e,this.points=t,this.speed=1,this.isPaused=!1,this.index=0,this._tween=null,n&&Object.assign(this,n)}get isPlaying(){var e;return!!(null===(e=this._tween)||void 0===e?void 0:e.isPlaying())}play(){return!this.isPlaying&&(this.isPaused=!1,this._play())}_play(){var e,n;return Fn(this,void 0,void 0,(function*(){if(this.isPaused)return!1;const{points:i,target:r}=this,s=null!==(e=this.speed)&&void 0!==e?e:1,o=this.index;let a=i[o];if(!a)return!0;a.isVector3||(a=new t(a.x,a.y,a.z));const l=r.position.distanceTo(a)/s;yield Ki(r.position,a,{duration:l},this.onUpdate,(e=>{var t;0!==o||this._tween||null===(t=this.onStart)||void 0===t||t.call(this,e),this._tween=e})),null===(n=this.onPoint)||void 0===n||n.call(this,o,a),this.index++,this._tween=null,this._play()}))}pause(){var e;this.isPaused=!0,null===(e=this._tween)||void 0===e||e.stop()}}const qi=0,Ji=1,$i=2,er=2,tr=1.25,nr=1,ir=32,rr=65535,sr=Math.pow(2,-24);class or{constructor(){}}function ar(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function lr(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){const r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function cr(e,t){t.set(e)}function ur(e,t,n){let i,r;for(let s=0;s<3;s++){const o=s+3;i=e[s],r=t[s],n[s]=i<r?i:r,i=e[o],r=t[o],n[o]=i>r?i:r}}function hr(e,t,n){for(let i=0;i<3;i++){const r=t[e+2*i],s=t[e+2*i+1],o=r-s,a=r+s;o<n[i]&&(n[i]=o),a>n[i+3]&&(n[i+3]=a)}}function dr(e){const t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function fr(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,d=1/0,f=1/0,p=-1/0,g=-1/0,m=-1/0;const v=null!==r;for(let i=6*t,r=6*(t+n);i<r;i+=6){const t=e[i+0],n=e[i+1],r=t-n,y=t+n;r<s&&(s=r),y>l&&(l=y),v&&t<h&&(h=t),v&&t>p&&(p=t);const w=e[i+2],b=e[i+3],x=w-b,A=w+b;x<o&&(o=x),A>c&&(c=A),v&&w<d&&(d=w),v&&w>g&&(g=w);const T=e[i+4],S=e[i+5],E=T-S,D=T+S;E<a&&(a=E),D>u&&(u=D),v&&T<f&&(f=T),v&&T>m&&(m=T)}i[0]=s,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=u,v&&(r[0]=h,r[1]=d,r[2]=f,r[3]=p,r[4]=g,r[5]=m)}const pr=32,gr=(e,t)=>e.candidate-t.candidate,mr=new Array(pr).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),vr=new Float32Array(6);function yr(e,t){function n(e){d&&d(e/p)}function i(t,r,d){let f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,p=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!g&&p>=l&&(g=!0,c&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=u||p>=l)return n(r+d),t.offset=r,t.count=d,t;const m=function(e,t,n,i,r,s){let o=-1,a=0;if(s===qi)o=lr(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(s===Ji)o=lr(e),-1!==o&&(a=function(e,t,n,i){let r=0;for(let s=t,o=t+n;s<o;s++)r+=e[6*s+2*i];return r/n}(n,i,r,o));else if(s===$i){const s=dr(e);let l=tr*r;const c=6*i,u=6*(i+r);for(let e=0;e<3;e++){const i=t[e],h=(t[e+3]-i)/pr;if(r<pr/4){const t=[...mr];t.length=r;let i=0;for(let r=c;r<u;r+=6,i++){const s=t[i];s.candidate=n[r+2*e],s.count=0;const{bounds:o,leftCacheBounds:a,rightCacheBounds:l}=s;for(let e=0;e<3;e++)l[e]=1/0,l[e+3]=-1/0,a[e]=1/0,a[e+3]=-1/0,o[e]=1/0,o[e+3]=-1/0;hr(r,n,o)}t.sort(gr);let h=r;for(let e=0;e<h;e++){const n=t[e];for(;e+1<h&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),h--}for(let i=c;i<u;i+=6){const r=n[i+2*e];for(let e=0;e<h;e++){const s=t[e];r>=s.candidate?hr(i,n,s.rightCacheBounds):(hr(i,n,s.leftCacheBounds),s.count++)}}for(let n=0;n<h;n++){const i=t[n],c=i.count,u=r-i.count,h=i.leftCacheBounds,d=i.rightCacheBounds;let f=0;0!==c&&(f=dr(h)/s);let p=0;0!==u&&(p=dr(d)/s);const g=nr+tr*(f*c+p*u);g<l&&(o=e,l=g,a=i.candidate)}}else{for(let e=0;e<pr;e++){const t=mr[e];t.count=0,t.candidate=i+h+e*h;const n=t.bounds;for(let e=0;e<3;e++)n[e]=1/0,n[e+3]=-1/0}for(let t=c;t<u;t+=6){let r=~~((n[t+2*e]-i)/h);r>=pr&&(r=pr-1);const s=mr[r];s.count++,hr(t,n,s.bounds)}const t=mr[pr-1];cr(t.bounds,t.rightCacheBounds);for(let e=pr-2;e>=0;e--){const t=mr[e],n=mr[e+1];ur(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let t=0;t<pr-1;t++){const n=mr[t],i=n.count,c=n.bounds,u=mr[t+1].rightCacheBounds;0!==i&&(0===d?cr(c,vr):ur(c,vr,vr)),d+=i;let h=0,f=0;0!==d&&(h=dr(vr)/s);const p=r-d;0!==p&&(f=dr(u)/s);const g=nr+tr*(h*d+f*p);g<l&&(o=e,l=g,a=n.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}(t.boundingData,f,o,r,d,h);if(-1===m.axis)return n(r+d),t.offset=r,t.count=d,t;const v=function(e,t,n,i,r){let s=n,o=n+i-1;const a=r.pos,l=2*r.axis;for(;;){for(;s<=o&&t[6*s+l]<a;)s++;for(;s<=o&&t[6*o+l]>=a;)o--;if(!(s<o))return s;for(let n=0;n<3;n++){let i=e[3*s+n];e[3*s+n]=e[3*o+n],e[3*o+n]=i;let r=t[6*s+2*n+0];t[6*s+2*n+0]=t[6*o+2*n+0],t[6*o+2*n+0]=r;let a=t[6*s+2*n+1];t[6*s+2*n+1]=t[6*o+2*n+1],t[6*o+2*n+1]=a}s++,o--}}(a,o,r,d,m);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=m.axis;const e=new or,n=r,a=v-r;t.left=e,e.boundingData=new Float32Array(6),fr(o,n,a,e.boundingData,s),i(e,n,a,s,p+1);const l=new or,c=v,u=d-a;t.right=l,l.boundingData=new Float32Array(6),fr(o,c,u,l.boundingData,s),i(l,c,u,s,p+1)}return t}!function(e,t){if(!e.index){const n=e.attributes.position.count,i=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;let r;r=n>65535?new Uint32Array(new i(4*n)):new Uint16Array(new i(2*n)),e.setIndex(new f(r,1));for(let e=0;e<n;e++)r[e]=e}}(e,t);const r=new Float32Array(6),s=new Float32Array(6),o=function(e,t){const n=e.attributes.position,i=e.index.array,r=i.length/3,s=new Float32Array(6*r),o=n.normalized,a=n.array,l=n.offset||0;let c=3;n.isInterleavedBufferAttribute&&(c=n.data.stride);const u=["getX","getY","getZ"];for(let e=0;e<r;e++){const r=3*e,h=6*e;let d,f,p;o?(d=i[r+0],f=i[r+1],p=i[r+2]):(d=i[r+0]*c+l,f=i[r+1]*c+l,p=i[r+2]*c+l);for(let e=0;e<3;e++){let i,r,l;o?(i=n[u[e]](d),r=n[u[e]](f),l=n[u[e]](p)):(i=a[d+e],r=a[f+e],l=a[p+e]);let c=i;r<c&&(c=r),l<c&&(c=l);let g=i;r>g&&(g=r),l>g&&(g=l);const m=(g-c)/2,v=2*e;s[h+v+0]=c+m,s[h+v+1]=m+(Math.abs(c)+m)*sr,c<t[e]&&(t[e]=c),g>t[e+3]&&(t[e+3]=g)}}return s}(e,r),a=e.index.array,l=t.maxDepth,c=t.verbose,u=t.maxLeafTris,h=t.strategy,d=t.onProgress,p=e.index.count/3;let g=!1;const m=[],v=function(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];const t=[],n=new Set;for(const t of e.groups)n.add(t.start),n.add(t.start+t.count);const i=Array.from(n.values()).sort(((e,t)=>e-t));for(let e=0;e<i.length-1;e++){const n=i[e],r=i[e+1];t.push({offset:n/3,count:(r-n)/3})}return t}(e);if(1===v.length){const e=v[0],t=new or;t.boundingData=r,function(e,t,n,i){let r=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let i=6*t,u=6*(t+n);i<u;i+=6){const t=e[i+0];t<r&&(r=t),t>a&&(a=t);const n=e[i+2];n<s&&(s=n),n>l&&(l=n);const u=e[i+4];u<o&&(o=u),u>c&&(c=u)}i[0]=r,i[1]=s,i[2]=o,i[3]=a,i[4]=l,i[5]=c}(o,e.offset,e.count,s),i(t,e.offset,e.count,s),m.push(t)}else for(let e of v){const t=new or;t.boundingData=new Float32Array(6),fr(o,e.offset,e.count,t.boundingData,s),i(t,e.offset,e.count,s),m.push(t)}return m}class wr{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,s=e.length;r<s;r++){const s=e[r][t];n=s<n?s:n,i=s>i?s:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,s=t.length;r<s;r++){const s=t[r],o=e.dot(s);n=o<n?o:n,i=o>i?o:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}wr.prototype.setFromBox=function(){const e=new t;return function(t,n){const i=n.min,r=n.max;let s=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let a=0;a<=1;a++)for(let l=0;l<=1;l++){e.x=i.x*n+r.x*(1-n),e.y=i.y*a+r.y*(1-a),e.z=i.z*l+r.z*(1-l);const c=t.dot(e);s=Math.min(c,s),o=Math.max(c,o)}this.min=s,this.max=o}}(),function(){const e=new wr}();const br=function(){const e=new t,n=new t,i=new t;return function(t,r,s){const o=t.start,a=e,l=r.start,c=n;i.subVectors(o,l),e.subVectors(t.end,t.start),n.subVectors(r.end,r.start);const u=i.dot(c),h=c.dot(a),d=c.dot(c),f=i.dot(a),p=a.dot(a)*d-h*h;let g,m;g=0!==p?(u*h-f*d)/p:0,m=(u+g*h)/d,s.x=g,s.y=m}}(),xr=function(){const e=new M,n=new t,i=new t;return function(t,r,s,o){br(t,r,e);let a=e.x,l=e.y;if(a>=0&&a<=1&&l>=0&&l<=1)return t.at(a,s),void r.at(l,o);if(a>=0&&a<=1)return l<0?r.at(0,o):r.at(1,o),void t.closestPointToPoint(o,!0,s);if(l>=0&&l<=1)return a<0?t.at(0,s):t.at(1,s),void r.closestPointToPoint(s,!0,o);{let e,c;e=a<0?t.start:t.end,c=l<0?r.start:r.end;const u=n,h=i;return t.closestPointToPoint(c,!0,n),r.closestPointToPoint(e,!0,i),u.distanceToSquared(c)<=h.distanceToSquared(e)?(s.copy(u),void o.copy(c)):(s.copy(e),void o.copy(h))}}}(),Ar=function(){const e=new t,n=new t,i=new B,r=new R;return function(t,s){const{radius:o,center:a}=t,{a:l,b:c,c:u}=s;r.start=l,r.end=c;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=l,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;r.start=c,r.end=u;if(r.closestPointToPoint(a,!0,e).distanceTo(a)<=o)return!0;const h=s.getPlane(i);if(Math.abs(h.distanceToPoint(a))<=o){const e=h.projectPoint(a,n);if(s.containsPoint(e))return!0}return!1}}(),Tr=1e-15;function Sr(e){return Math.abs(e)<Tr}class Er extends P{constructor(){super(...arguments),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new t)),this.satBounds=new Array(4).fill().map((()=>new wr)),this.points=[this.a,this.b,this.c],this.sphere=new O,this.plane=new B,this.needsUpdate=!0}intersectsSphere(e){return Ar(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,s=this.satBounds,o=r[0],a=s[0];this.getNormal(o),a.setFromPoints(o,i);const l=r[1],c=s[1];l.subVectors(e,t),c.setFromPoints(l,i);const u=r[2],h=s[2];u.subVectors(t,n),h.setFromPoints(u,i);const d=r[3],f=s[3];d.subVectors(n,e),f.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}}Er.prototype.closestPointToSegment=function(){const e=new t,n=new t,i=new R;return function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const{start:o,end:a}=t,l=this.points;let c,u=1/0;for(let o=0;o<3;o++){const a=(o+1)%3;i.start.copy(l[o]),i.end.copy(l[a]),xr(i,t,e,n),c=e.distanceToSquared(n),c<u&&(u=c,r&&r.copy(e),s&&s.copy(n))}return this.closestPointToPoint(o,e),c=o.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(o)),this.closestPointToPoint(a,e),c=a.distanceToSquared(e),c<u&&(u=c,r&&r.copy(e),s&&s.copy(a)),Math.sqrt(u)}}(),Er.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new Array(3),r=new wr,s=new wr,o=new t,a=new t,l=new t,c=new t,u=new R,h=new R,d=new R;return function(t){let f=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,p=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const g=this.plane,m=t.plane;if(Math.abs(g.normal.dot(m.normal))>1-1e-10){const e=this.satBounds,a=this.satAxes;i[0]=t.a,i[1]=t.b,i[2]=t.c;for(let t=0;t<4;t++){const n=e[t],s=a[t];if(r.setFromPoints(s,i),n.isSeparated(r))return!1}const l=t.satBounds,c=t.satAxes;n[0]=this.a,n[1]=this.b,n[2]=this.c;for(let e=0;e<4;e++){const t=l[e],i=c[e];if(r.setFromPoints(i,n),t.isSeparated(r))return!1}for(let e=0;e<4;e++){const t=a[e];for(let e=0;e<4;e++){const a=c[e];if(o.crossVectors(t,a),r.setFromPoints(o,n),s.setFromPoints(o,i),r.isSeparated(s))return!1}}return f&&(p||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),f.start.set(0,0,0),f.end.set(0,0,0)),!0}{const e=this.points;let n=!1,i=0;for(let t=0;t<3;t++){const r=e[t],s=e[(t+1)%3];u.start.copy(r),u.end.copy(s),u.delta(a);const o=n?h.start:h.end,l=Sr(m.distanceToPoint(r));if(Sr(m.normal.dot(a))&&l){h.copy(u),i=2;break}if((m.intersectLine(u,o)||l)&&!Sr(o.distanceTo(s))){if(i++,n)break;n=!0}}if(1===i&&t.containsPoint(h.end))return f&&(f.start.copy(h.end),f.end.copy(h.end)),!0;if(2!==i)return!1;const r=t.points;let s=!1,o=0;for(let e=0;e<3;e++){const t=r[e],n=r[(e+1)%3];u.start.copy(t),u.end.copy(n),u.delta(l);const i=s?d.start:d.end,a=Sr(g.distanceToPoint(t));if(Sr(g.normal.dot(l))&&a){d.copy(u),o=2;break}if((g.intersectLine(u,i)||a)&&!Sr(i.distanceTo(n))){if(o++,s)break;s=!0}}if(1===o&&this.containsPoint(d.end))return f&&(f.start.copy(d.end),f.end.copy(d.end)),!0;if(2!==o)return!1;if(h.delta(a),d.delta(l),a.dot(l)<0){let e=d.start;d.start=d.end,d.end=e}const p=h.start.dot(a),v=h.end.dot(a),y=d.start.dot(a),w=d.end.dot(a);return(p===w||y===v||v<y!==p<w)&&(f&&(c.subVectors(h.start,d.start),c.dot(a)>0?f.start.copy(h.start):f.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?f.end.copy(h.end):f.end.copy(d.end)),!0)}}}(),Er.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Er.prototype.distanceToTriangle=function(){const e=new t,n=new t,i=["a","b","c"],r=new R,s=new R;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const l=o||a?r:null;if(this.intersectsTriangle(t,l))return(o||a)&&(o&&l.getCenter(o),a&&l.getCenter(a)),0;let c=1/0;for(let n=0;n<3;n++){let r;const s=i[n],l=t[s];this.closestPointToPoint(l,e),r=l.distanceToSquared(e),r<c&&(c=r,o&&o.copy(e),a&&a.copy(l));const u=this[s];t.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<c&&(c=r,o&&o.copy(u),a&&a.copy(e))}for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];r.set(this[u],this[h]);for(let l=0;l<3;l++){const u=i[l],h=i[(l+1)%3];s.set(t[u],t[h]),xr(r,s,e,n);const d=e.distanceToSquared(n);d<c&&(c=d,o&&o.copy(e),a&&a.copy(n))}}return Math.sqrt(c)}}();class Dr{constructor(e,n,i){this.isOrientedBox=!0,this.min=new t,this.max=new t,this.matrix=new m,this.invMatrix=new m,this.points=new Array(8).fill().map((()=>new t)),this.satAxes=new Array(3).fill().map((()=>new t)),this.satBounds=new Array(3).fill().map((()=>new wr)),this.alignedSatBounds=new Array(3).fill().map((()=>new wr)),this.needsUpdate=!1,e&&this.min.copy(e),n&&this.max.copy(n),i&&this.matrix.copy(i)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Dr.prototype.update=function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let r=0;r<=1;r++)for(let s=0;s<=1;s++)for(let o=0;o<=1;o++){const a=i[1*r|2*s|4*o];a.x=r?n.x:t.x,a.y=s?n.y:t.y,a.z=o?n.z:t.z,a.applyMatrix4(e)}const r=this.satBounds,s=this.satAxes,o=i[0];for(let e=0;e<3;e++){const t=s[e],n=r[e],a=i[1<<e];t.subVectors(o,a),n.setFromPoints(t,i)}const a=this.alignedSatBounds;a[0].setFromPointsField(i,"x"),a[1].setFromPointsField(i,"y"),a[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},Dr.prototype.intersectsBox=function(){const e=new wr;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,r=this.satBounds,s=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=i.x,o[0].isSeparated(e))return!1;if(e.min=n.y,e.max=i.y,o[1].isSeparated(e))return!1;if(e.min=n.z,e.max=i.z,o[2].isSeparated(e))return!1;for(let n=0;n<3;n++){const i=s[n],o=r[n];if(e.setFromBox(i,t),o.isSeparated(e))return!1}return!0}}(),Dr.prototype.intersectsTriangle=function(){const e=new Er,n=new Array(3),i=new wr,r=new wr,s=new t;return function(t){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);const o=this.satBounds,a=this.satAxes;n[0]=t.a,n[1]=t.b,n[2]=t.c;for(let e=0;e<3;e++){const t=o[e],r=a[e];if(i.setFromPoints(r,n),t.isSeparated(i))return!1}const l=t.satBounds,c=t.satAxes,u=this.points;for(let e=0;e<3;e++){const t=l[e],n=c[e];if(i.setFromPoints(n,u),t.isSeparated(i))return!1}for(let e=0;e<3;e++){const t=a[e];for(let e=0;e<4;e++){const o=c[e];if(s.crossVectors(t,o),i.setFromPoints(s,n),r.setFromPoints(s,u),i.isSeparated(r))return!1}}return!0}}(),Dr.prototype.closestPointToPoint=function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Dr.prototype.distanceToPoint=function(){const e=new t;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Dr.prototype.distanceToBox=function(){const e=["x","y","z"],n=new Array(12).fill().map((()=>new R)),i=new Array(12).fill().map((()=>new R)),r=new t,s=new t;return function(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(this.needsUpdate&&this.update(),this.intersectsBox(t))return(a||l)&&(t.getCenter(s),this.closestPointToPoint(s,r),t.closestPointToPoint(r,s),a&&a.copy(r),l&&l.copy(s)),0;const c=o*o,u=t.min,h=t.max,d=this.points;let f=1/0;for(let e=0;e<8;e++){const t=d[e];s.copy(t).clamp(u,h);const n=t.distanceToSquared(s);if(n<f&&(f=n,a&&a.copy(t),l&&l.copy(s),n<c))return Math.sqrt(n)}let p=0;for(let t=0;t<3;t++)for(let r=0;r<=1;r++)for(let s=0;s<=1;s++){const o=(t+1)%3,a=(t+2)%3,l=1<<t|r<<o|s<<a,c=d[r<<o|s<<a],f=d[l];n[p].set(c,f);const g=e[t],m=e[o],v=e[a],y=i[p],w=y.start,b=y.end;w[g]=u[g],w[m]=r?u[m]:h[m],w[v]=s?u[v]:h[m],b[g]=h[g],b[m]=r?u[m]:h[m],b[v]=s?u[v]:h[m],p++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){s.x=e?h.x:u.x,s.y=t?h.y:u.y,s.z=n?h.z:u.z,this.closestPointToPoint(s,r);const i=s.distanceToSquared(r);if(i<f&&(f=i,a&&a.copy(r),l&&l.copy(s),i<c))return Math.sqrt(i)}for(let e=0;e<12;e++){const t=n[e];for(let e=0;e<12;e++){const n=i[e];xr(t,n,r,s);const o=r.distanceToSquared(s);if(o<f&&(f=o,a&&a.copy(r),l&&l.copy(s),o<c))return Math.sqrt(o)}}return Math.sqrt(f)}}();const Cr=new t,Ir=new t,Mr=new t,Br=new M,Rr=new M,Pr=new M,Or=new t;function _r(e,n,i,r,s,o,a){Cr.fromBufferAttribute(n,r),Ir.fromBufferAttribute(n,s),Mr.fromBufferAttribute(n,o);const l=function(e,t,n,i,r,s){let o;return o=s===_?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,s!==d,r),null===o?null:{distance:e.origin.distanceTo(r),point:r.clone()}}(e,Cr,Ir,Mr,Or,a);if(l){i&&(Br.fromBufferAttribute(i,r),Rr.fromBufferAttribute(i,s),Pr.fromBufferAttribute(i,o),l.uv=P.getUV(Or,Cr,Ir,Mr,Br,Rr,Pr,new M));const e={a:r,b:s,c:o,normal:new t,materialIndex:0};P.getNormal(Cr,Ir,Mr,e.normal),l.face=e,l.faceIndex=r}return l}function Lr(e,t,n,i,r){const s=3*i,o=e.index.getX(s),a=e.index.getX(s+1),l=e.index.getX(s+2),c=_r(n,e.attributes.position,e.attributes.uv,o,a,l,t);return c?(c.faceIndex=i,r&&r.push(c),c):null}function kr(e,t,n){return null===e?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e.distance<n.near||e.distance>n.far?null:e)}function Nr(e,t,n,i){const r=e.a,s=e.b,o=e.c;let a=t,l=t+1,c=t+2;n&&(a=n.getX(t),l=n.getX(t+1),c=n.getX(t+2)),r.x=i.getX(a),r.y=i.getY(a),r.z=i.getZ(a),s.x=i.getX(l),s.y=i.getY(l),s.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function Ur(e,t,n,i,r,s,o){const a=n.index,l=n.attributes.position;for(let n=e,c=t+e;n<c;n++)if(Nr(o,3*n,a,l),o.needsUpdate=!0,i(o,n,r,s))return!0;return!1}class Fr{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}function jr(e,t){return 65535===t[e+15]}function zr(e,t){return t[e+6]}function Hr(e,t){return t[e+14]}function Gr(e){return e+8}function Vr(e,t){return t[e+6]}const Yr=new i,Wr=new t,Xr=["x","y","z"];function Qr(e,t,n,i,r){let s=2*e,o=ts,a=ns,l=is;if(jr(s,a)){!function(e,t,n,i,r,s){for(let o=i,a=i+r;o<a;o++)Lr(e,t,n,o,s)}(t,n,i,zr(e,l),Hr(s,a),r)}else{const s=Gr(e);Jr(s,o,i,Wr)&&Qr(s,t,n,i,r);const a=Vr(e,l);Jr(a,o,i,Wr)&&Qr(a,t,n,i,r)}}function Kr(e,t,n,i){let r=2*e,s=ts,o=ns,a=is;if(jr(r,o)){return function(e,t,n,i,r){let s=1/0,o=null;for(let a=i,l=i+r;a<l;a++){const i=Lr(e,t,n,a);i&&i.distance<s&&(o=i,s=i.distance)}return o}(t,n,i,zr(e,a),Hr(r,o))}{const r=function(e,t){return t[e+7]}(e,a),o=Xr[r],l=i.direction[o]>=0;let c,u;l?(c=Gr(e),u=Vr(e,a)):(c=Vr(e,a),u=Gr(e));const h=Jr(c,s,i,Wr)?Kr(c,t,n,i):null;if(h){const e=h.point[o];if(l?e<=s[u+r]:e>=s[u+r+3])return h}const d=Jr(u,s,i,Wr)?Kr(u,t,n,i):null;return h&&d?h.distance<=d.distance?h:d:h||d||null}}const Zr=function(){let e,t;const n=[],r=new Fr((()=>new i));return function(){e=r.getPrimitive(),t=r.getPrimitive(),n.push(e,t);const i=s(...arguments);r.releasePrimitive(e),r.releasePrimitive(t),n.pop(),n.pop();const o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),i};function s(n,i,r,o){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;function u(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Gr(e));return zr(e,i)}function h(e){let t=2*e,n=ns,i=is;for(;!jr(t,n);)t=2*(e=Vr(e,i));return zr(e,i)+Hr(t,n)}let d=2*n,f=ts,p=ns,g=is;if(jr(d,p)){const t=zr(n,g),i=Hr(d,p);return ar(n,f,e),o(t,i,!1,c,l+n,e)}{const d=Gr(n),m=Vr(n,g);let v,y,w,b,x=d,A=m;if(a&&(w=e,b=t,ar(x,f,w),ar(A,f,b),v=a(w),y=a(b),y<v)){x=m,A=d;const e=v;v=y,y=e,w=b}w||(w=e,ar(x,f,w));const T=r(w,jr(2*x,p),v,c+1,l+x);let S;if(T===er){const e=u(x);S=o(e,h(x)-e,!0,c+1,l+x,w)}else S=T&&s(x,i,r,o,a,l,c+1);if(S)return!0;b=t,ar(A,f,b);const E=r(b,jr(2*A,p),y,c+1,l+A);let D;if(E===er){const e=u(A);D=o(e,h(A)-e,!0,c+1,l+A,b)}else D=E&&s(A,i,r,o,a,l,c+1);return!!D}}}(),qr=function(){const e=new Er,t=new Er,n=new m,i=new Dr,r=new Dr;return function s(o,a,l,c){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,h=2*o,d=ts,f=ns,p=is;null===u&&(l.boundingBox||l.computeBoundingBox(),i.set(l.boundingBox.min,l.boundingBox.max,c),u=i);if(!jr(h,f)){const e=o+8,t=p[o+6];ar(e,d,Yr);if(u.intersectsBox(Yr)&&s(e,a,l,c,u))return!0;ar(t,d,Yr);return!!(u.intersectsBox(Yr)&&s(t,a,l,c,u))}{const i=a,s=i.index,u=i.attributes.position,g=l.index,m=l.attributes.position,v=zr(o,p),y=Hr(h,f);if(n.copy(c).invert(),l.boundsTree){ar(o,d,r),r.matrix.copy(n),r.needsUpdate=!0;const e=l.boundsTree.shapecast({intersectsBounds:e=>r.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(c),e.b.applyMatrix4(c),e.c.applyMatrix4(c),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);n<i;n+=3)if(Nr(t,n,s,u),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});return e}for(let i=3*v,r=y+3*v;i<r;i+=3){Nr(e,i,s,u),e.a.applyMatrix4(n),e.b.applyMatrix4(n),e.c.applyMatrix4(n),e.needsUpdate=!0;for(let n=0,i=g.count;n<i;n+=3)if(Nr(t,n,g,m),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function Jr(e,t,n,i){return ar(e,t,Yr),n.intersectBox(Yr,i)}const $r=[];let es,ts,ns,is;function rs(e){es&&$r.push(es),es=e,ts=new Float32Array(e),ns=new Uint16Array(e),is=new Uint32Array(e)}function ss(){es=null,ts=null,ns=null,is=null,$r.length&&rs($r.pop())}const os=Symbol("skip tree generation"),as=new i,ls=new i,cs=new m,us=new Dr,hs=new Dr,ds=new t,fs=new t,ps=new t,gs=new t,ms=new t,vs=new i,ys=new Fr((()=>new Er));class ws{static serialize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),ws.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,r=n.getIndex();let s;return s=t.cloneBuffers?{roots:i.map((e=>e.slice())),index:r.array.slice()}:{roots:i,index:r.array},s}static deserialize(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),ws.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n={setIndex:!0,...n};const{index:i,roots:r}=e,s=new ws(t,{...n,[os]:!0});if(s._roots=r,n.setIndex){const n=t.getIndex();if(null===n){const n=new f(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return s}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if(t=Object.assign({strategy:qi,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[os]:!1},t),t.useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[os]||(this._roots=function(e,t){const n=yr(e,t);let i,r,s;const o=[],a=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let e=0;e<n.length;e++){const t=n[e];let u=l(t);const h=new a(ir*u);i=new Float32Array(h),r=new Uint32Array(h),s=new Uint16Array(h),c(0,t),o.push(h)}return o;function l(e){return e.count?1:1+l(e.left)+l(e.right)}function c(e,t){const n=e/4,o=e/2,a=!!t.count,l=t.boundingData;for(let e=0;e<6;e++)i[n+e]=l[e];if(a){const i=t.offset,a=t.count;return r[n+6]=i,s[o+14]=a,s[o+15]=rr,e+ir}{const i=t.left,s=t.right,o=t.splitAxis;let a;if(a=c(e+ir,i),a/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return r[n+6]=a/4,a=c(a,s),r[n+7]=o,a}}}(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new i))),this.geometry=e}refit(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&Array.isArray(e)&&(e=new Set(e));const t=this.geometry,n=t.index.array,i=t.attributes.position;let r,s,o,a,l=0;const c=this._roots;for(let e=0,t=c.length;e<t;e++)r=c[e],s=new Uint32Array(r),o=new Uint16Array(r),a=new Float32Array(r),u(0,l),l+=r.byteLength;function u(t,r){let l=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const c=2*t;if(o[c+15]===rr){const e=s[t+6];let r=1/0,l=1/0,u=1/0,h=-1/0,d=-1/0,f=-1/0;for(let t=3*e,s=3*(e+o[c+14]);t<s;t++){const e=n[t],s=i.getX(e),o=i.getY(e),a=i.getZ(e);s<r&&(r=s),s>h&&(h=s),o<l&&(l=o),o>d&&(d=o),a<u&&(u=a),a>f&&(f=a)}return(a[t+0]!==r||a[t+1]!==l||a[t+2]!==u||a[t+3]!==h||a[t+4]!==d||a[t+5]!==f)&&(a[t+0]=r,a[t+1]=l,a[t+2]=u,a[t+3]=h,a[t+4]=d,a[t+5]=f,!0)}{const n=t+8,i=s[t+6],o=n+r,c=i+r;let h=l,d=!1,f=!1;e?h||(d=e.has(o),f=e.has(c),h=!d&&!f):(d=!0,f=!0);const p=h||f;let g=!1;(h||d)&&(g=u(n,r,h));let m=!1;p&&(m=u(i,r,h));const v=g||m;if(v)for(let e=0;e<3;e++){const r=n+e,s=i+e,o=a[r],l=a[r+3],c=a[s],u=a[s+3];a[t+e]=o<c?o:c,a[t+e+3]=l>u?l:u}return v}}}traverse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(s){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const a=2*s,l=r[a+15]===rr;if(l){const t=i[s+6],c=r[a+14];e(o,l,new Float32Array(n,4*s,6),t,c)}else{const r=s+ir/4,a=i[s+6],c=i[s+7];e(o,l,new Float32Array(n,4*s,6),c)||(t(r,o+1),t(a,o+1))}}(0)}raycast(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=[],s=t.isMaterial,o=Array.isArray(t),a=i.groups,l=s?t.side:t;for(let s=0,c=n.length;s<c;s++){const c=o?t[a[s].materialIndex].side:l,u=r.length;if(rs(n[s]),Qr(0,i,c,e,r),ss(),o){const e=a[s].materialIndex;for(let t=u,n=r.length;t<n;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L;const n=this._roots,i=this.geometry,r=t.isMaterial,s=Array.isArray(t);let o=null;const a=i.groups,l=r?t.side:t;for(let r=0,c=n.length;r<c;r++){const c=s?t[a[r].materialIndex].side:l;rs(n[r]);const u=Kr(0,i,c,e);ss(),null!=u&&(null==o||u.distance<o.distance)&&(o=u,s&&(u.face.materialIndex=a[r].materialIndex))}return o}intersectsGeometry(e,t){const n=this.geometry;let i=!1;for(const r of this._roots)if(rs(r),i=qr(0,n,e,t),ss(),i)break;return i}shapecast(e,t,n){const i=this.geometry;if(e instanceof Function){if(t){const e=t;t=(t,n,i,r)=>{const s=3*n;return e(t,s,s+1,s+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}const r=ys.getPrimitive();let{boundsTraverseOrder:s,intersectsBounds:o,intersectsRange:a,intersectsTriangle:l}=e;if(a&&l){const e=a;a=(t,n,s,o,a)=>!!e(t,n,s,o,a)||Ur(t,n,i,l,s,o,r)}else a||(a=l?(e,t,n,s)=>Ur(e,t,i,l,n,s,r):(e,t,n)=>n);let c=!1,u=0;for(const e of this._roots){if(rs(e),c=Zr(0,i,o,a,s,u),ss(),c)break;u+=e.byteLength}return ys.releasePrimitive(r),c}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n;const s=this.geometry.index,o=this.geometry.attributes.position,a=e.geometry.index,l=e.geometry.attributes.position;cs.copy(t).invert();const c=ys.getPrimitive(),u=ys.getPrimitive();if(r){function d(e,n,i,h,d,f,p,g){for(let m=i,v=i+h;m<v;m++){Nr(u,3*m,a,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(Nr(c,3*t,s,o),c.needsUpdate=!0,r(c,u,t,m,d,f,p,g))return!0}return!1}if(i){const f=i;i=function(e,t,n,i,r,s,o,a){return!!f(e,t,n,i,r,s,o,a)||d(e,t,n,i,r,s,o,a)}}else i=d}e.getBoundingBox(ls),ls.applyMatrix4(t);const h=this.shapecast({intersectsBounds:e=>ls.intersectsBox(e),intersectsRange:(t,n,r,s,o,a)=>(as.copy(a),as.applyMatrix4(cs),e.shapecast({intersectsBounds:e=>as.intersectsBox(e),intersectsRange:(e,r,a,l,c)=>i(t,n,e,r,s,o,l,c)}))});return ys.releasePrimitive(c),ys.releasePrimitive(u),h}intersectsBox(e,t){return us.set(e.min,e.max,t),us.needsUpdate=!0,this.shapecast({intersectsBounds:e=>us.intersectsBox(e),intersectsTriangle:e=>us.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1/0;e.boundingBox||e.computeBoundingBox(),us.set(e.boundingBox.min,e.boundingBox.max,t),us.needsUpdate=!0;const o=this.geometry,a=o.attributes.position,l=o.index,c=e.attributes.position,u=e.index,h=ys.getPrimitive(),d=ys.getPrimitive();let f=fs,p=ps,g=null,m=null;i&&(g=gs,m=ms);let v=1/0,y=null,w=null;return cs.copy(t).invert(),hs.matrix.copy(cs),this.shapecast({boundsTraverseOrder:e=>us.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s&&(t&&(hs.min.copy(e.min),hs.max.copy(e.max),hs.needsUpdate=!0),!0),intersectsRange:(n,i)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>hs.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<s,intersectsRange:(e,s)=>{for(let o=3*e,b=3*(e+s);o<b;o+=3){Nr(d,o,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let e=3*n,t=3*(n+i);e<t;e+=3){Nr(h,e,l,a),h.needsUpdate=!0;const t=h.distanceToTriangle(d,f,g);if(t<v&&(p.copy(f),m&&m.copy(g),v=t,y=e/3,w=o/3),t<r)return!0}}}});for(let e=0,s=u?u.count:c.count;e<s;e+=3){Nr(d,e,u,c),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let t=3*n,s=3*(n+i);t<s;t+=3){Nr(h,t,l,a),h.needsUpdate=!0;const n=h.distanceToTriangle(d,f,g);if(n<v&&(p.copy(f),m&&m.copy(g),v=n,y=t/3,w=e/3),n<r)return!0}}}}),ys.releasePrimitive(h),ys.releasePrimitive(d),v===1/0?null:(n.point?n.point.copy(p):n.point=p.clone(),n.distance=v,n.faceIndex=y,i&&(i.point?i.point.copy(m):i.point=m.clone(),i.point.applyMatrix4(cs),p.applyMatrix4(cs),i.distance=p.sub(i.point).length(),i.faceIndex=w),n)}closestPointToPoint(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;const r=n*n,s=i*i;let o=1/0,a=null;if(this.shapecast({boundsTraverseOrder:t=>(ds.copy(e).clamp(t.min,t.max),ds.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n<o&&n<s,intersectsTriangle:(t,n)=>{t.closestPointToPoint(e,ds);const i=e.distanceToSquared(ds);return i<o&&(fs.copy(ds),o=i,a=n),i<r}}),o===1/0)return null;const l=Math.sqrt(o);return t.point?t.point.copy(fs):t.point=fs.clone(),t.distance=l,t.faceIndex=a,t}getBoundingBox(e){e.makeEmpty();return this._roots.forEach((t=>{ar(0,new Float32Array(t),vs),e.union(vs)})),e}}const bs=new N,xs=new m,As=k.prototype.raycast;class Ts extends v{constructor(){super();const e=new U;e.deleteAttribute("uv");const t=new F({side:_}),n=new F,i=new j(16777215,5,28,2);i.position.set(.418,16.199,.3),this.add(i);const r=new k(e,t);r.position.set(-.757,13.219,.717),r.scale.set(31.713,28.305,28.591),this.add(r);const s=new k(e,n);s.position.set(-10.906,2.009,1.846),s.rotation.set(0,-.195,0),s.scale.set(2.328,7.905,4.651),this.add(s);const o=new k(e,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const a=new k(e,n);a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),this.add(a);const l=new k(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);const c=new k(e,n);c.position.set(2.291,-.756,-2.621),c.rotation.set(0,-.286,0),c.scale.set(1.546,1.552,1.496),this.add(c);const u=new k(e,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const h=new k(e,Ss(50));h.position.set(-16.116,14.37,8.208),h.scale.set(.1,2.428,2.739),this.add(h);const d=new k(e,Ss(50));d.position.set(-16.109,18.021,-8.207),d.scale.set(.1,2.425,2.751),this.add(d);const f=new k(e,Ss(17));f.position.set(14.904,12.198,-1.832),f.scale.set(.15,4.265,6.331),this.add(f);const p=new k(e,Ss(43));p.position.set(-.462,8.89,14.52),p.scale.set(4.38,5.441,.088),this.add(p);const g=new k(e,Ss(20));g.position.set(3.235,11.486,-12.541),g.scale.set(2.5,2,.1),this.add(g);const m=new k(e,Ss(100));m.position.set(0,20,0),m.scale.set(1,.1,1),this.add(m)}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Ss(e){const t=new z;return t.color.setScalar(e),t}class Es extends H{constructor(e){super(e),this.type=G}parse(e){const t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,s=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=a.indexOf("\n"))&&s<t&&i<e.byteLength;)o+=a,s+=a.length,i+=128,a+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));return-1<r&&(!1!==n&&(e.pos+=s+r+1),o+a.slice(0,r))},i=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=e[t+0]*s,n[i+1]=e[t+1]*s,n[i+2]=e[t+2]*s,n[i+3]=1},r=function(e,t,n,i){const r=e[t+3],s=Math.pow(2,r-128)/255;n[i+0]=Y.toHalfFloat(Math.min(e[t+0]*s,65504)),n[i+1]=Y.toHalfFloat(Math.min(e[t+1]*s,65504)),n[i+2]=Y.toHalfFloat(Math.min(e[t+2]*s,65504)),n[i+3]=Y.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;const o=function(e){const i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,a={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(a.valid|=1,a.programtype=c[1],a.string+=l+"\n";l=n(e),!1!==l;)if(a.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(a.gamma=parseFloat(c[1])),(c=l.match(r))&&(a.exposure=parseFloat(c[1])),(c=l.match(s))&&(a.valid|=2,a.format=c[1]),(c=l.match(o))&&(a.valid|=4,a.height=parseInt(c[1],10),a.width=parseInt(c[2],10)),2&a.valid&&4&a.valid)break}else a.comments+=l+"\n";return 2&a.valid?4&a.valid?a:t(3,"missing image size specifier"):t(3,"missing format specifier")}(s);if(-1!==o){const e=o.width,n=o.height,a=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const s=new Uint8Array(4*n*i);if(!s.length)return t(4,"unable to allocate buffer space");let o=0,a=0;const l=4*r,c=new Uint8Array(4),u=new Uint8Array(l);let h=i;for(;h>0&&a<e.byteLength;){if(a+4>e.byteLength)return t(1);if(c[0]=e[a++],c[1]=e[a++],c[2]=e[a++],c[3]=e[a++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i<l&&a<e.byteLength;){n=e[a++];const r=n>128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){const t=e[a++];for(let e=0;e<n;e++)u[i++]=t}else u.set(e.subarray(a,a+n),i),i+=n,a+=n}const d=r;for(let e=0;e<d;e++){let t=0;s[o]=u[e+t],t+=r,s[o+1]=u[e+t],t+=r,s[o+2]=u[e+t],t+=r,s[o+3]=u[e+t],o+=4}h--}return s}(s.subarray(s.pos),e,n);if(-1!==a){let t,s,l;switch(this.type){case V:l=a.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)i(a,4*t,e,4*t);t=e,s=V;break;case G:l=a.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)r(a,4*e,n,4*e);t=n,s=G;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:o.string,gamma:o.gamma,exposure:o.exposure,type:s}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,i){return super.load(e,(function(e,n){switch(e.type){case V:case G:e.encoding=u,e.minFilter=A,e.magFilter=A,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}}var Ds=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i<t.children.length;i++)t.children[i].style.display=i===n?"block":"none";e=n}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(n){n.preventDefault(),i(++e%t.children.length)}),!1);var r=(performance||Date).now(),s=r,o=0,a=n(new Ds.Panel("FPS","#0ff","#002")),l=n(new Ds.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Ds.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:n,showPanel:i,begin:function(){r=(performance||Date).now()},end:function(){o++;var e=(performance||Date).now();if(l.update(e-r,200),e>=s+1e3&&(a.update(1e3*o/(e-s),100),s=e,o=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Ds.Panel=function(e,t,n){var i=1/0,r=0,s=Math.round,o=s(window.devicePixelRatio||1),a=80*o,l=48*o,c=3*o,u=2*o,h=3*o,d=15*o,f=74*o,p=30*o,g=document.createElement("canvas");g.width=a,g.height=l,g.style.cssText="width:80px;height:48px";var m=g.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,a,l),m.fillStyle=t,m.fillText(e,c,u),m.fillRect(h,d,f,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h,d,f,p),{dom:g,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,a,d),m.fillStyle=t,m.fillText(s(l)+" "+e+" ("+s(i)+"-"+s(r)+")",c,u),m.drawImage(g,h+o,d,f-o,p,h,d,f-o,p),m.fillRect(h+f-o,d,o,p),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(h+f-o,d,o,s((1-l/v)*p))}}};var Cs=Ds;class Is extends k{constructor(){const e=Is.SkyShader,t=new W({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:X.clone(e.uniforms),side:_,depthWrite:!1});super(new U(1,1,1),t),this.isSky=!0}}Is.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new t},up:{value:new t(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\n\t\t}"};var Ms="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Bs(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(t,n))}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})})),n}var Rs={},Ps={},Os=Bs(Xn),_s={},Ls={},ks={},Ns={};Object.defineProperty(Ns,"__esModule",{value:!0});var Us=function(){function e(t,n){if(void 0===n&&(n=null),this.nonEmpty=!1,t||n){if(!t)throw new Error("Parameter head cannot be null.");this.head=t,this.tail=n||e.NIL,this.nonEmpty=!0}else{if(e.NIL)throw new Error("Parameters head and tail are null. Use the NIL element instead.");this.nonEmpty=!1}}return Object.defineProperty(e.prototype,"length",{get:function(){if(!this.nonEmpty)return 0;if(this.tail===e.NIL)return 1;for(var t=0,n=this;n.nonEmpty;)++t,n=n.tail;return t},enumerable:!0,configurable:!0}),e.prototype.prepend=function(t){return new e(t,this)},e.prototype.append=function(t){if(!t)return this;if(!this.nonEmpty)return new e(t);if(this.tail===e.NIL)return new e(t).prepend(this.head);for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;)i=i.tail=new e(r.head),r=r.tail;return i.tail=new e(t),n},e.prototype.insertWithPriority=function(t){if(!this.nonEmpty)return new e(t);var n=t.priority;if(n>this.head.priority)return this.prepend(t);for(var i=new e(this.head),r=i,s=this.tail;s.nonEmpty;){if(n>s.head.priority)return r.tail=s.prepend(t),i;r=r.tail=new e(s.head),s=s.tail}return r.tail=new e(t),i},e.prototype.filterNot=function(t){if(!this.nonEmpty||null==t)return this;if(t===this.head.listener)return this.tail;for(var n=new e(this.head),i=n,r=this.tail;r.nonEmpty;){if(r.head.listener===t)return i.tail=r.tail,n;i=i.tail=new e(r.head),r=r.tail}return this},e.prototype.contains=function(e){if(!this.nonEmpty)return!1;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return!0;t=t.tail}return!1},e.prototype.find=function(e){if(!this.nonEmpty)return null;for(var t=this;t.nonEmpty;){if(t.head.listener===e)return t.head;t=t.tail}return null},e.prototype.toString=function(){for(var e="",t=this;t.nonEmpty;)e+=t.head+" -> ",t=t.tail;return"[List "+(e+="NIL")+"]"},e.NIL=new e(null,null),e}();Ns.SlotList=Us;var Fs={};Object.defineProperty(Fs,"__esModule",{value:!0});var js=function(){function e(e,t,n,i){void 0===n&&(n=!1),void 0===i&&(i=0),this._enabled=!0,this._once=!1,this._priority=0,this._listener=e,this._once=n,this._signal=t,this._priority=i,this.verifyListener(e)}return e.prototype.execute0=function(){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,this._params):this._listener())},e.prototype.execute1=function(e){this._enabled&&(this._once&&this.remove(),this._params&&this._params.length?this._listener.apply(null,[e].concat(this._params)):this._listener(e))},e.prototype.execute=function(e){if(this._enabled){this._once&&this.remove(),this._params&&this._params.length&&(e=e.concat(this._params));var t=e.length;0===t?this._listener():1===t?this._listener(e[0]):2===t?this._listener(e[0],e[1]):3===t?this._listener(e[0],e[1],e[2]):this._listener.apply(null,e)}},Object.defineProperty(e.prototype,"listener",{get:function(){return this._listener},set:function(e){if(null==e)throw new Error("Given listener is null.\nDid you want to set enabled to false instead?");this.verifyListener(e),this._listener=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"once",{get:function(){return this._once},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return"[Slot listener: "+this._listener+", once: "+this._once+", priority: "+this._priority+", enabled: "+this._enabled+"]"},Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"params",{get:function(){return this._params},set:function(e){this._params=e},enumerable:!0,configurable:!0}),e.prototype.remove=function(){this._signal.remove(this._listener)},e.prototype.verifyListener=function(e){if(null==e)throw new Error("Given listener is null.");if(null==this._signal)throw new Error("Internal signal reference has not been set yet.")},e}();Fs.Slot=js,Object.defineProperty(ks,"__esModule",{value:!0});var zs=Ns,Hs=Fs,Gs=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.slots=zs.SlotList.NIL,this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if(!(this._valueClasses[t]instanceof Object))throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+">."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slots.length},enumerable:!0,configurable:!0}),e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){var t=this.slots.find(e);return t?(this.slots=this.slots.filterNot(e),t):null},e.prototype.removeAll=function(){this.slots=zs.SlotList.NIL},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=this.slots;if(s.nonEmpty)for(;s.nonEmpty;)s.head.execute(e),s=s.tail},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.registrationPossible(e,t)){var n=new Hs.Slot(e,this,t);return this.slots=this.slots.prepend(n),n}return this.slots.find(e)},e.prototype.registrationPossible=function(e,t){if(!this.slots.nonEmpty)return!0;var n=this.slots.find(e);if(!n)return!0;if(n.once!==t)throw new Error("You cannot addOnce() then add() the same listener without removing the relationship first.");return!1},e}();ks.OnceSignal=Gs,Object.defineProperty(Ls,"__esModule",{value:!0});var Vs=Os,Ys=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Vs.__extends(t,e),t.prototype.add=function(e){return this.registerListener(e)},t}(ks.OnceSignal);Ls.Signal=Ys,Object.defineProperty(_s,"__esModule",{value:!0});var Ws=Os,Xs=Fs,Qs=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ws.__extends(t,e),t.prototype.addWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!1,t)},t.prototype.addOnceWithPriority=function(e,t){return void 0===t&&(t=0),this.registerListenerWithPriority(e,!0,t)},t.prototype.registerListener=function(e,t){return void 0===t&&(t=!1),this.registerListenerWithPriority(e,t)},t.prototype.registerListenerWithPriority=function(e,t,n){if(void 0===n&&(n=0),this.registrationPossible(e,t)){var i=new Xs.Slot(e,this,t,n);return this.slots=this.slots.insertWithPriority(i),i}return this.slots.find(e)},t}(Ls.Signal);_s.PrioritySignal=Qs,Object.defineProperty(Ps,"__esModule",{value:!0});var Ks=Os,Zs=function(e){function t(t){void 0===t&&(t=null);for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=this;return n=1===n.length&&n[0]instanceof Array?n[0]:n,(r=e.call(this,n)||this)._target=t,r}return Ks.__extends(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){e!==this._target&&(this.removeAll(),this._target=e)},enumerable:!0,configurable:!0}),t.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(null!==e[r]&&e[r].constructor!==this._valueClasses[r])throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");var s=e[0];s&&(s.target&&(s=s.clone(),e[0]=s),s.target=this.target,s.currentTarget=this.target,s.signal=this);for(var o=this.slots;o.nonEmpty;)o.head.execute(e),o=o.tail;if(s&&s.bubbles)for(var a=this.target;a&&a.hasOwnProperty("parent")&&(null===(a=a.parent).onEventBubbled||(s.currentTarget=a,a.onEventBubbled(s))););},t}(_s.PrioritySignal);Ps.DeluxeSignal=Zs;var qs={};Object.defineProperty(qs,"__esModule",{value:!0});var Js=function(){function e(e){void 0===e&&(e=!1),this._bubbles=e}return Object.defineProperty(e.prototype,"signal",{get:function(){return this._signal},set:function(e){this._signal=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){this._target=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentTarget",{get:function(){return this._currentTarget},set:function(e){this._currentTarget=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bubbles",{get:function(){return this._bubbles},set:function(e){this._bubbles=e},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._bubbles)},e}();qs.GenericEvent=Js;var $s={};Object.defineProperty($s,"__esModule",{value:!0}),$s.IOnceSignal=Symbol("IOnceSignal");var eo={};Object.defineProperty(eo,"__esModule",{value:!0}),eo.IPrioritySignal=Symbol("IPrioritySignal");var to={};Object.defineProperty(to,"__esModule",{value:!0}),to.ISignal=Symbol("ISignal");var no={};Object.defineProperty(no,"__esModule",{value:!0}),no.ISlot=Symbol("ISlot");var io={};Object.defineProperty(io,"__esModule",{value:!0});var ro=Fs,so=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.valueClasses=1===e.length&&e[0]instanceof Array?e[0]:e}return Object.defineProperty(e.prototype,"valueClasses",{get:function(){return this._valueClasses},set:function(e){this._valueClasses=e?e.slice():[];for(var t=this._valueClasses.length;t--;)if("function"!=typeof this._valueClasses[t])throw new Error("Invalid valueClasses argument: item at index "+t+" should be a Class but was:<"+this._valueClasses[t]+"'>."+this._valueClasses[t])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numListeners",{get:function(){return this.slot?1:0},enumerable:!0,configurable:!0}),e.prototype.add=function(e){return this.registerListener(e)},e.prototype.addOnce=function(e){return this.registerListener(e,!0)},e.prototype.remove=function(e){if(this.slot&&this.slot.listener===e){var t=this.slot;return this.slot=null,t}return null},e.prototype.removeAll=function(){this.slot&&this.slot.remove()},e.prototype.dispatch=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._valueClasses.length,i=e.length;if(i<n)throw new Error("Incorrect number of arguments. Expected at least "+n+" but received "+i+".");for(var r=0;r<n;r++)if(!(null===e[r]||e[r]instanceof this._valueClasses[r]||e[r].constructor===this._valueClasses[r]))throw new Error("Value object <"+e[r]+"> is not an instance of <"+this._valueClasses[r]+">.");this.slot&&this.slot.execute(e)},e.prototype.registerListener=function(e,t){if(void 0===t&&(t=!1),this.slot)throw new Error("You cannot add or addOnce with a listener already added, remove the current listener first.");return this.slot=new ro.Slot(e,this,t)},e}();io.MonoSignal=so;var oo={};Object.defineProperty(oo,"__esModule",{value:!0});var ao=Os,lo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return ao.__extends(t,e),t.prototype.addOnce=function(t){var n=e.prototype.addOnce.call(this,t);return this.isDispatched&&(n.execute(this.valueObjects),n.remove()),n},t.prototype.dispatch=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(this.isDispatched)throw new Error("You cannot dispatch() a Promise more than once");this.isDispatched=!0,this.valueObjects=t,e.prototype.dispatch.apply(this,t)},t}(ks.OnceSignal);oo.Promise=lo,Object.defineProperty(Rs,"__esModule",{value:!0});var co=Ps;Rs.DeluxeSignal=co.DeluxeSignal;var uo=qs;Rs.GenericEvent=uo.GenericEvent;var ho=$s;Rs.IOnceSignal=ho.IOnceSignal;var fo=eo;Rs.IPrioritySignal=fo.IPrioritySignal;var po=to;Rs.ISignal=po.ISignal;var go=no;Rs.ISlot=go.ISlot;var mo=io;Rs.MonoSignal=mo.MonoSignal;var vo=ks;Rs.OnceSignal=vo.OnceSignal;var yo=_s;Rs.PrioritySignal=yo.PrioritySignal;var wo=oo;Rs.Promise=wo.Promise;var bo=Ls,xo=Rs.Signal=bo.Signal,Ao=Fs;Rs.Slot=Ao.Slot;var To=Ns;Rs.SlotList=To.SlotList;const So=new v;So.name="Scene";class Eo{constructor(e,t){this.signals=e,this.viewportState=t,this.scene=So.clone(),this.scene.castShadow=!0,this.scene.receiveShadow=!0,this.selectedObjects={edge:[],stroke:[],opacity:[],highlight:[],emissive:[]},this.intersectsList={meshOfModelList:[],poiIconList:[],otherObjList:[],getAll:function(){return[...this.meshOfModelList,...this.poiIconList,...this.otherObjList]}}}addObject(e,t){if(this.viewportState.isDisposed)return this.removeObject(e),void yn("Scene is disposed");t?t.add(e):this.scene.add(e),this._triggerObjectAdded(e),this.signals.objectAdded.dispatch(e)}removeObject(e){function t(e){var t;e.map&&((t=e.map)&&t.isTexture&&t.dispose()),e.dispose()}e.traverse((e=>{if("Mesh"===e.type){const n=e;n.geometry.dispose(),On(n.material,t)}e instanceof Fu&&e.element.remove();const{meshOfModelList:n,poiIconList:i,otherObjList:r}=this.intersectsList,s=n.findIndex((t=>t.uuid===e.uuid)),o=i.findIndex((t=>t.uuid===e.uuid)),a=r.findIndex((t=>t.uuid===e.uuid));s>-1&&this.intersectsList.meshOfModelList.splice(s,1),o>-1&&this.intersectsList.poiIconList.splice(o,1),a>-1&&this.intersectsList.otherObjList.splice(a,1)})),e.removeFromParent(),this.signals.objectRemoved.dispatch(e)}openSceneFog(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:t=13426943,near:n=500,far:i=5e4}=e;this.scene.fog=new Q(t,n,i),this.signals.sceneChanged.dispatch()}closeSceneFog(){this.scene.fog=null,this.signals.sceneChanged.dispatch()}edgeShow(e,t){const n=[],i=e=>{-1===this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid))&&n.push(e)};return ji(e)?e.forEach((e=>i(e))):zi(e)&&i(e),this.selectedObjects.edge=[...this.selectedObjects.edge,...n],this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge,options:t}),Promise.resolve()}unEdgeShow(e){e||(e=[...this.selectedObjects.edge]);const t=e=>{const t=this.selectedObjects.edge.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.edge.splice(t,1),this.signals.outlineChange.dispatch({objects:this.selectedObjects.edge})),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}strokeShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{isOpacityShow:n=!0,color:i=4647927,opacity:r=.2,edgeColor:s=61183,edgeOpacity:o=1}=t,a=e=>{if(-1!==this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid)))return Promise.resolve();if(e.userData.strokeGroup)return Promise.resolve();const t=new Nu({id:e.uuid});return e.traverse((n=>{if(n instanceof k){const i=new K(n.geometry,89),r=new Z(i,new q({color:s,transparent:!0,opacity:o}));Dn(r,n),e.attach(r),t.add(r)}})),e.userData.strokeGroup=t,this.addObject(t,e),this.selectedObjects.stroke.push(e),Promise.resolve()};return n&&this.opacityShow(e,{color:i,opacity:r}),ji(e)?Promise.all(e.map((e=>a(e)))):zi(e)?a(e):Promise.resolve()}unStrokeShow(e){e||(e=[...this.selectedObjects.stroke]);const t=e=>{if(!e.userData.strokeGroup)return Promise.resolve();this.removeObject(e.userData.strokeGroup),Reflect.deleteProperty(e.userData,"strokeGroup");const t=this.selectedObjects.stroke.findIndex((t=>t.uuid===e.uuid));return-1===t||(this.selectedObjects.stroke.splice(t,1),this.signals.geometryChanged.dispatch(),this.unOpacityShow(e)),Promise.resolve()};return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}opacityShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="#fff",opacity:i=.8}=t;function r(e){return Reflect.construct(e.constructor,[{transparent:!0,depthWrite:!1,side:e.side,color:n,opacity:i}])}const s=e=>(-1!==this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.opacity.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unOpacityShow(e){e||(e=[...this.selectedObjects.opacity]);const t=e=>new Promise((t=>{const n=this.selectedObjects.opacity.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.opacity.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}highlightShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=1}=t;function r(e){e instanceof F&&(e.color=new a(n),e.opacity=i,e.transparent=i<1)}const s=e=>(-1!==this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,r)}})),this.signals.materialChanged.dispatch(),this.selectedObjects.highlight.push(e)),Promise.resolve());return ji(e)?Promise.all(e.map((e=>s(e)))):zi(e)?s(e):Promise.resolve()}unHighlightShow(e){e||(e=[...this.selectedObjects.highlight]);const t=e=>new Promise((t=>{const n=this.selectedObjects.highlight.findIndex((t=>t.uuid===e.uuid));-1===n&&t(),this.selectedObjects.highlight.splice(n,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),t()}));return ji(e)?Promise.all(e.map((e=>t(e)))):zi(e)?t(e):Promise.resolve()}emissiveShow(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{color:n="red",opacity:i=.3,maxOpacity:r=1,minOpacity:s=0,duration:o=1e3}=t;function a(e){e instanceof F&&(e.emissive.set(n),e.emissiveIntensity=i,Ki({emissiveIntensity:r},{emissiveIntensity:s},{duration:o,repeat:!0},(t=>e.emissiveIntensity=t.emissiveIntensity),(t=>e.userData.animation=t)))}const l=e=>(-1!==this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid))||(e.traverse((e=>{if(e instanceof k){if(e.userData.material)return;e.userData.material=e.material,e.material=_n(e.material),On(e.material,a)}})),this.selectedObjects.emissive.push(e),this.signals.materialChanged.dispatch()),Promise.resolve());return ji(e)?Promise.all(e.map((e=>l(e)))):zi(e)?l(e):Promise.resolve()}unEmissiveShow(e){function t(e){e.userData.animation&&pn.remove(e.userData.animation)}e||(e=[...this.selectedObjects.emissive]);const n=e=>new Promise((n=>{const i=this.selectedObjects.emissive.findIndex((t=>t.uuid===e.uuid));-1===i&&n(),this.selectedObjects.emissive.splice(i,1),e.traverse((e=>{if(e instanceof k){if(!e.userData.material)return;On(e.material,t),Ln(e.material),e.material=e.userData.material,Reflect.deleteProperty(e.userData,"material")}})),this.signals.materialChanged.dispatch(),n()}));return ji(e)?Promise.all(e.map((e=>n(e)))):zi(e)?n(e):Promise.resolve()}_triggerObjectAdded(e){if(e instanceof ku)if("Model"===e.stype)e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.meshOfModelList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.meshOfModelList.push(e)}}));else if("Poi"===e.stype){const t=this.intersectsList.poiIconList.findIndex((t=>t.uuid===e.icon.uuid));-1===t&&this.intersectsList.poiIconList.push(e.icon)}else if("BaseMesh"===e.stype){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}else"Group"===e.stype?e.children.forEach((e=>this._triggerObjectAdded(e))):"Object3D"===e.type&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}));else if(e instanceof _u){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}else"Object3D"===e.type&&e.traverse((e=>{if(e instanceof k){const t=this.intersectsList.otherObjList.findIndex((t=>t.uuid===e.uuid));-1===t&&this.intersectsList.otherObjList.push(e)}}))}}class Do extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Do&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let Co,Io;const Mo=new t,Bo=new m,Ro=new m,Po={objects:new WeakMap};function Oo(){const e=new t,n=new t;return function(t,i){return e.setFromMatrixPosition(t.matrixWorld),n.setFromMatrixPosition(i.matrixWorld),e.distanceToSquared(n)}}function _o(e){const t=function(e){const t=[];return e.traverse((function(e){e instanceof Do&&t.push(e)})),t}(e).sort((function(e,t){return Po.objects.get(e).distanceToCameraSquared-Po.objects.get(t).distanceToCameraSquared})),n=t.length;for(let e=0,i=t.length;e<i;e++)t[e].element.style.zIndex=""+(n-e)}class Lo{constructor(e){e||(e=document.createElement("div")),e.style.overflow="hidden",this.domElement=e}setSize(e,t){Co=e/2,Io=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"}renderObject(e,t,n){if(e instanceof Do){Mo.setFromMatrixPosition(e.matrixWorld),Mo.applyMatrix4(Ro);const t=e.element,i="translate(-50%,-100%) translate("+(Mo.x*Co+Co)+"px,"+(-Mo.y*Io+Io)+"px)";t.style.transform=i,t.style.display=Cn(e)&&Mo.z>=-1&&Mo.z<=1?"block":"none";const r={distanceToCameraSquared:Oo()(n,e)};Po.objects.set(e,r),t.parentNode!==this.domElement&&this.domElement.appendChild(t)}for(let i=0,r=e.children.length;i<r;i++)this.renderObject(e.children[i],t,n)}render(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),Bo.copy(t.matrixWorldInverse),Ro.multiplyMatrices(t.projectionMatrix,Bo),this.renderObject(e,e,t),_o(e)}}class ko extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof ko&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}let No,Uo,Fo,jo;function zo(e){return Math.abs(e)<1e-10?0:e}function Ho(e){const t=e.elements;return"matrix3d("+zo(t[0])+","+zo(-t[1])+","+zo(t[2])+","+zo(t[3])+","+zo(t[4])+","+zo(-t[5])+","+zo(t[6])+","+zo(t[7])+","+zo(t[8])+","+zo(-t[9])+","+zo(t[10])+","+zo(t[11])+","+zo(t[12])+","+zo(-t[13])+","+zo(t[14])+","+zo(t[15])+")"}class Go{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){No=e/2,Uo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,t,n,i){if(e instanceof ko){const t=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+zo(n[0])+","+zo(n[1])+","+zo(n[2])+","+zo(n[3])+","+zo(-n[4])+","+zo(-n[5])+","+zo(-n[6])+","+zo(-n[7])+","+zo(n[8])+","+zo(n[9])+","+zo(n[10])+","+zo(n[11])+","+zo(n[12])+","+zo(n[13])+","+zo(n[14])+","+zo(n[15])+")"}(e.matrixWorld),n=e.element;n.style.transform=t,n.style.display=Cn(e)?"block":"none";const i={style:t,distanceToCameraSquared:0};this.cache.objects.set(e,i),n.parentNode!==this.cameraElement&&this.cameraElement.appendChild(n)}for(let r=0,s=e.children.length;r<s;r++)this.renderObject(e.children[r],t,n,i)}render(e,t){const n=t.projectionMatrix.elements[5]*Uo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+zo(-(t.right+t.left)/2)+"px)"+Ho(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Ho(t.matrixWorldInverse);const r=i+"translate("+No+"px,"+Uo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Vo extends J{constructor(e){super(),this.element=e,this.element.style.position="absolute",this.addEventListener("removed",(()=>{this.traverse((function(e){e instanceof Vo&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}}function Yo(e){return Math.abs(e)<1e-10?0:e}function Wo(e){const t=e.elements;return"matrix3d("+Yo(t[0])+","+Yo(-t[1])+","+Yo(t[2])+","+Yo(t[3])+","+Yo(t[4])+","+Yo(-t[5])+","+Yo(t[6])+","+Yo(t[7])+","+Yo(t[8])+","+Yo(-t[9])+","+Yo(t[10])+","+Yo(t[11])+","+Yo(t[12])+","+Yo(-t[13])+","+Yo(t[14])+","+Yo(t[15])+")"}class Xo{constructor(e,t){this.cache={camera:{fov:0,style:""},objects:new WeakMap},e||(e=document.createElement("div")),e.style.overflow="hidden",e.style.pointerEvents="auto",this.domElement=e,t||(t=document.createElement("div")),t.style.transformStyle="preserve-3d",t.style.pointerEvents="auto",t.style.position="absolute",t.style.top="0",e.appendChild(t),this.cameraElement=t}setSize(e,t){Fo=e/2,jo=t/2,this.domElement.style.width=e+"px",this.domElement.style.height=t+"px",this.cameraElement.style.width=e+"px",this.cameraElement.style.height=t+"px"}renderObject(e,n,i,r){if(e instanceof Vo){const n=i.quaternion.clone();n.x=-i.quaternion.x,n.z=-i.quaternion.z;const r=function(e,t){const n=e.elements;return"translateX(-50%)matrix3d("+Yo(n[0])+","+Yo(-n[1])+","+Yo(n[2])+","+Yo(n[3])+","+Yo(n[4])+","+Yo(-n[5])+","+Yo(n[6])+","+Yo(n[7])+","+Yo(n[8])+","+Yo(-n[9])+","+Yo(n[10])+","+Yo(n[11])+","+Yo(n[12])+","+Yo(n[13])+","+Yo(n[14])+","+Yo(n[15])+")"}((new m).compose(e.parent.getWorldPosition(new t(0,0,0)),n,e.parent.scale)),s=e.element;s.style.transform=r,s.style.display=Cn(e)?"block":"none";const o={style:r,distanceToCameraSquared:0};this.cache.objects.set(e,o),s.parentNode!==this.cameraElement&&this.cameraElement.appendChild(s)}for(let t=0,s=e.children.length;t<s;t++)this.renderObject(e.children[t],n,i,r)}render(e,t){const n=t.projectionMatrix.elements[5]*jo;this.cache.camera.fov!==n&&(this.domElement.style.perspective=t instanceof $?n+"px":"",this.cache.camera.fov=n),!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld();let i="";if(t instanceof ee){i+="scale("+n+")translateX("+Yo(-(t.right+t.left)/2)+"px)"+Wo(t.matrixWorldInverse)}else i+="translateZ("+n+"px)"+Wo(t.matrixWorldInverse);const r=i+"translate("+Fo+"px,"+jo+"px)";this.cameraElement.style.transform=r,this.cache.camera.style=r,this.renderObject(e,e,t,i)}}class Qo{constructor(e){this.options=e,this.internalOptions={enableRenderCss2D:!1,enableRenderCss2DHalf:!1,enableRenderCss3D:!1},this.container=this._initContainer(),this.renderer=this._initRenderer(),this.rendererCSS2D=this._initRenderCSS2D(),this.rendererCSS3D=this._initRenderCSS3D(),this.rendererCSS2DHalf=this._initRenderCSS2DHalf(),this.interactiveContainer=this._initInteractiveContainer()}setInternalState(e,t){this.internalOptions[e]=t}getWidth(){return this.renderer.domElement.width}getHeight(){return this.renderer.domElement.height}getMouseRelativeConRatio(e){const t=this.container.getBoundingClientRect();return[(e.offsetX-t.left)/t.width,(e.offsetY-t.top)/t.height]}getMousePoint(e){const t=new M(0,0);return t.fromArray(this.getMouseRelativeConRatio(e)),t}_initContainer(){const e=document.createElement("div");return e.style.position="relative",e.style.width="100%",e.style.height="100%",e}_initRenderer(){const{background:e={},logarithmicDepthBuffer:t}=this.options,{color:n,alpha:i}=e,r=new te({alpha:i,logarithmicDepthBuffer:t,preserveDrawingBuffer:!0,antialias:!1,stencil:!1,depth:!1,powerPreference:"high-performance"}),s=i?0:1,{offsetWidth:o,offsetHeight:a}=this.container;return r.setSize(o,a),r.setClearColor(n||0,s),r.setPixelRatio(self.devicePixelRatio),r.localClippingEnabled=!0,r.sortObjects=!0,r.shadowMap.enabled=!0,r.shadowMap.type=ne,this.container.appendChild(r.domElement),r}_initRenderCSS2D(){const e=new Lo;return e.domElement.id="ssp_view_2DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS3D(){const e=new Go;return e.domElement.id="ssp_view_3DPoi",e.domElement.style.position="absolute",e.domElement.style.top="0",e.domElement.style.width="100%",e.domElement.style.height="100%",e.setSize(this.container.offsetWidth,this.container.offsetHeight),this.container.appendChild(e.domElement),e}_initRenderCSS2DHalf(){const e=new Xo(this.rendererCSS3D.domElement,this.rendererCSS3D.cameraElement);return e.setSize(this.container.offsetWidth,this.container.offsetHeight),e}_initInteractiveContainer(){return this.rendererCSS3D.domElement}}const Ko=new m,Zo=(e,t)=>{const i=Ko.clone(),r=Ko.clone(),s=Ko.clone();i.makeRotationY(e),r.makeRotationX(t);const o=new n;return s.multiplyMatrices(i,r),o.setFromRotationMatrix(s),o},qo=Zo(-Math.PI/2,-Math.PI/4),Jo=Zo(Math.PI/2,-Math.PI/4),$o=Zo(-Math.PI/4,-Math.PI/4),ea=Zo(Math.PI/4,-Math.PI/4),ta=Zo(1.25*Math.PI,-Math.PI/4),na=Zo(.75*Math.PI,-Math.PI/4),ia={LEFT:new n(0,-Math.PI/2,0),RIGHT:new n(0,Math.PI/2,0),FRONT:new n(0,0,0),BACK:new n(0,Math.PI,0),TOP:new n(-Math.PI/2,0,0),BOTTOM:new n(Math.PI/2,0,0),FRONTTOP:new n(-Math.PI/4,0,0),BACKTOP:new n(Math.PI/4,Math.PI,0),LEFTTOP:new n(qo.x,qo.y,qo.z),RIGHTTOP:new n(Jo.x,Jo.y,Jo.z),LEFTFRONTTOP:new n($o.x,$o.y,$o.z),RIGHTFRONTTOP:new n(ea.x,ea.y,ea.z),LEFTBACKTOP:new n(ta.x,ta.y,ta.z),RIGHTBACKTOP:new n(na.x,na.y,na.z)},ra=e=>Fi(e)?e:e.includes("%")?.01*Number(e.split("%")[0]):isNaN(+e)?0:Number(e),sa=new t,oa=new n,aa=new $(50,1,.1,5e5);aa.position.set(500,1e3,500),aa.lookAt(sa.set(0,0,0)),aa.name="Camera";class la{constructor(e){this.viewport=e,this.mainCamera=aa.clone(),this.mainCamera.name="freeCamera",this.currentCamera=this.mainCamera,this.cameras={}}createCamera(e){const t=aa.clone();return t.name=e,this.cameras[e]=t,t}removeCamera(e){return"fullFreeCamera"!==e&&(delete this.cameras[e],!0)}setCurrentCamera(e){this.currentCamera=this.viewport.camera=e,this.viewport.signals.cameraObjectChange.dispatch()}getMainCamera(){return this.mainCamera}getCameraViewpoint(){if("free"===this.viewport.controls.options.type)return{position:this.currentCamera.position.clone(),rotation:{x:this.currentCamera.rotation.x,y:this.currentCamera.rotation.y,z:this.currentCamera.rotation.z}};{const e=this.viewport.controls.currentControls;return{position:this.currentCamera.position.clone(),target:e.target.clone()}}}setCameraViewpoint(e){if("free"===this.viewport.controls.options.type&&zi(e)){const{position:t,rotation:n}=e;this.currentCamera.position.set(t.x,t.y,t.z),this.currentCamera.rotation.set(n.x,n.y,n.z)}else if(zi(e)){const{position:t,target:n}=e,i=this.viewport.controls.currentControls;this.currentCamera.position.set(t.x,t.y,t.z),i.target.set(n.x,n.y,n.z)}this.viewport.signals.cameraChange.dispatch(this.currentCamera.position.clone())}moveTo(e,t){return Ki(this.currentCamera.position,e,t,(e=>this.viewport.signals.cameraChange.dispatch(e)))}rotateTo(e,t){const n=this.currentCamera.quaternion.clone(),i=(new r).setFromEuler(e);return Ki({t:0},{t:1},t,(e=>{let{t:t}=e;this.currentCamera.quaternion.slerpQuaternions(n,i,t)}))}flyTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(Ni(t)){const e=t.toLocaleUpperCase();"CURRENT"===e?oa.copy(this.currentCamera.rotation):ia[e]&&oa.copy(ia[e])}else t instanceof n?oa.copy(t):zi(t)&&oa.set(t.x,t.y,t.z);oa.copy(Tn(this.currentCamera.rotation,oa.clone())),yield Promise.all([this.moveTo(e,i),this.rotateTo(oa,i)])}))}flyToBoundingBox(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2?arguments[2]:void 0;return Fn(this,void 0,void 0,(function*(){if(e.isEmpty())return void yn("target box is empty");const r=this.viewport.controls.options.type,s=new t;if(Ni(n)){if("CURRENT"===n.toLocaleUpperCase())s.copy(this.getMovePosByBBox(e));else{const t=ia[n.toLocaleUpperCase()],i=this.getObjectLabelPos(e,t);s.copy(i)}}else{"orbit"===r&&yn("orbit 控制器不支持 Rotation 类型 的 rotation 参数");const t=bn(n),i=this.getObjectLabelPos(e,t);s.copy(i)}if("orbit"===r){const t=e.getCenter(sa),i=this.viewport.controls.currentControls;i.target.copy(t);const r=new m;r.lookAt(s,t,i.object.up),n=oa.setFromRotationMatrix(r)}yield this.flyTo(s,n,i)}))}flyToObj(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof Gu||e instanceof Fu){const{padding:t=50}=i,r=ra(t);return this.flyToBoundingBox(e.getBoundingBox(r),n,i)}{const{padding:r="30%"}=i,s=xn(e),o=s.getSize(sa);let a=0;if(Ni(r)){const e=Math.max(o.x,o.y,o.z);a=ra(r)*e}else a=r;let l=a,c=a;if(a<0){const e=Math.min(o.x,o.z),t=o.y-1;l=Math.abs(a)>e?-e:a,c=Math.abs(l)>t?-t:l}return 0!==r&&(s.max.add(sa.set(l/2,c/2,l/2)),s.min.sub(sa.set(l/2,c/2,l/2))),s.isEmpty()&&(sa.setFromMatrixPosition(e.matrixWorld),s.setFromCenterAndSize(sa,new t(0,0,0))),this.flyToBoundingBox(s,n,i)}}surroundOnTarget(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{speed:n=1,angle:i=360,onStart:r}=t,s=wn(e),o=s.clone().setY(this.currentCamera.position.y).distanceTo(this.currentCamera.position),a=Math.abs(i);return Ki({angle:0},{angle:Math.PI/180*a},{duration:a/360*5e3/n},(e=>{const t=i>0?e.angle:2*Math.PI-e.angle;if(this.currentCamera.position.x=Math.sin(t)*o+s.x,this.currentCamera.position.z=Math.cos(t)*o+s.z,"orbit"===this.viewport.controls.options.type){const e=this.viewport.controls.currentControls;e.target.copy(s),e.update()}else this.currentCamera.lookAt(s)}),r)}surroundOnObject(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(new i).setFromObject(e).getCenter(sa);return this.surroundOnTarget(n,t)}getMovePosByBBox(e){const n=this.currentCamera.position,i=e.getCenter(sa);(new t).subVectors(i,n).normalize();let r=new O;r=e.getBoundingSphere(r);const s=this.currentCamera.fov/2*Math.PI/180,o=Math.sin(s),a=r.radius/o,l=new t;this.currentCamera.getWorldDirection(l);const c=l.clone();return c.multiplyScalar(-a),i.clone().add(c)}getObjectLabelPos(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"frontTop",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e instanceof ku&&(e=(new i).setFromObject(e)),e.isEmpty())return yn("target box is empty"),new t;const{extendScale:s=1.6,mode:o="scene"}=r;if("scene"===o){const t=e.getCenter(sa),i=e.max.clone().sub(e.min),r=Math.max(i.x,i.y,i.z),o=t.clone(),a=e=>{const t=(s-.5)*Math.abs(r),n=Math.max(t,this.viewport.camera.near);o.add(e.multiplyScalar(n))};let l;return l=Ni(n)?ia[n.toLocaleUpperCase()]:bn(n),a(sa.set(0,0,1).applyEuler(l)),o}return"screen"===o?e.getCenter(sa).clone():new t}}
|
|
2
2
|
/**
|
|
3
3
|
* postprocessing v6.29.3 build Thu Feb 09 2023
|
|
4
4
|
* https://github.com/pmndrs/postprocessing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soonspacejs",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"homepage": "http://www.xwbuilders.com:8800/",
|
|
5
5
|
"description": "soonspacejs 2.x",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"three": ">=0.148.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "7c3d5b68b469b40bce705edf9fc5b25aa23d972c"
|
|
31
31
|
}
|