@tresjs/cientos 4.1.1 → 4.2.0
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/core/controls/OrbitControls.vue.d.ts +21 -0
- package/dist/trescientos.js +464 -461
- package/dist/trescientos.umd.cjs +22 -22
- package/package.json +1 -1
package/dist/trescientos.umd.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/cientos
|
|
3
|
-
* version: v4.
|
|
3
|
+
* version: v4.2.0
|
|
4
4
|
* (c) 2025
|
|
5
5
|
* description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
(function(
|
|
8
|
+
(function(ne,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("three"),require("vue"),require("@tresjs/core")):typeof define=="function"&&define.amd?define(["exports","three","vue","@tresjs/core"],l):(ne=typeof globalThis<"u"?globalThis:ne||self,l(ne.trescientos={},ne.Three,ne.Vue,ne.TresjsCore))})(this,function(ne,l,u,H){"use strict";var mp=Object.defineProperty;var gp=(ne,l,u)=>l in ne?mp(ne,l,{enumerable:!0,configurable:!0,writable:!0,value:u}):ne[l]=u;var ue=(ne,l,u)=>gp(ne,typeof l!="symbol"?l+"":l,u);function Js(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const Ot=Js(l);function Hs(a){const e=$s(a),t=[];for(const{startFrame:n,endFrame:o,duration:r}of e)if(!(r<=0))if(o<0||n===o){for(let s=0;s<r;s++)t.push(n);continue}else{const s=Math.sign(o-n);for(let i=n;i!==o+s;i+=s)for(let c=0;c<r;c++)t.push(i)}return t}function $s(a){let e="START_FRAME_IN";const t=[];for(const{name:n,value:o,startI:r}of ei(a))e==="START_FRAME_IN"?n==="NUMBER"?(t.push({startFrame:o,endFrame:o,duration:1}),e="START_FRAME_OUT"):Mt("number",n,a,r):e==="START_FRAME_OUT"?n==="COMMA"?e="START_FRAME_IN":n==="HYPHEN"?e="END_FRAME_IN":n==="OPEN_PAREN"?e="DURATION_IN":Mt('",", "-", "("',n,a,r):e==="END_FRAME_IN"?n==="NUMBER"?(t[t.length-1].endFrame=o,e="END_FRAME_OUT"):Mt("number",n,a,r):e==="END_FRAME_OUT"?n==="COMMA"?e="START_FRAME_IN":n==="OPEN_PAREN"?e="DURATION_IN":Mt("',' or '('",n,a,r):e==="DURATION_IN"?n==="NUMBER"?(t[t.length-1].duration=o,e="DURATION_OUT"):Mt("number",n,a,r):e==="DURATION_OUT"?n==="CLOSE_PAREN"?e="NEXT_OR_DONE":Mt('"("',n,a,r):e==="NEXT_OR_DONE"&&(n==="COMMA"?e="START_FRAME_IN":Mt('","',n,a,r));return t}function ei(a){const e=[];for(let t=0;t<a.length;t++){const n=a[t];if("0123456789".includes(n))e.length&&e[e.length-1].name==="NUMBER"?(e[e.length-1].value*=10,e[e.length-1].value+=Number.parseInt(n)):e.push({name:"NUMBER",value:Number.parseInt(n),startI:t});else{if(n===" ")continue;n===","?e.push({name:"COMMA",value:-1,startI:t}):n==="("?e.push({name:"OPEN_PAREN",value:-1,startI:t}):n===")"?e.push({name:"CLOSE_PAREN",value:-1,startI:t}):n==="-"?e.push({name:"HYPHEN",value:-1,startI:t}):ti("0123456789,-()",n,a,t)}}return e}function ti(a,e,t,n){H.useLogger().logError(`Cientos AnimationDefinitionParser: Unexpected character while processing animation definition: expected ${a}, got ${e}.
|
|
9
9
|
${t}
|
|
10
10
|
${Array.from({length:n+1}).join(" ")}^`)}function Mt(a,e,t,n){H.useLogger().logError(`Cientos AnimationDefinitionParser: Syntax error while processing animation definition: expected ${a}, got ${e}.
|
|
11
11
|
${t}
|
|
@@ -13,7 +13,7 @@ ${Array.from({length:n+1}).join(" ")}^`)}const ni=/\d*$/,oi=/_*\d*$/;function ri
|
|
|
13
13
|
`).join("");return H.useLogger().logError(`Cientos Atlas: getAtlasFramesByAnimationName
|
|
14
14
|
The animation name "${e}" does not exist in this atlas.
|
|
15
15
|
Available names:
|
|
16
|
-
${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<=e||t<0||a.frames.length<=t)return H.useLogger().logError(`Cientos Atlas: getFramesByIndex – [${e}, ${t}] is out of bounds.`),[Nn()];const n=[],o=Math.sign(t-e);if(o===0)return[a.frames[e]];for(let r=e;r!==t+o;r+=o)n.push(a.frames[r]);return n}function Yo(a){const e={};for(const t of a)if(si(t.name)!==null){const n=ri(t.name);Object.prototype.hasOwnProperty.call(e,n)?e[n].push(t):e[n]=[t]}for(const t of Object.values(e))t.sort((n,o)=>n.name.localeCompare(o.name));return e}const pi=["scale","position"],mi=["map","alphaTest"],gi=["scale","position"],yi=["side","map","alphaTest","depthWrite","depthTest"],un=.01,_i=u.defineComponent({__name:"component",props:{image:{},atlas:{},definitions:{},fps:{default:30},loop:{type:Boolean,default:!0},animation:{default:0},paused:{type:Boolean,default:!1},reversed:{type:Boolean,default:!1},flipX:{type:Boolean,default:!1},resetOnEnd:{type:Boolean,default:!1},asSprite:{type:Boolean,default:!0},center:{default:()=>[.5,.5]},alphaTest:{default:0},depthTest:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!0}},emits:["frame","end","loop"],async setup(a,{expose:e,emit:t}){let n,o;const r=a,s=t,{invalidate:i}=H.useTresContext();u.watch(r,()=>{i()});const c=u.ref(0),h=u.ref(0),p=u.ref(0),f=u.ref(0),m=u.shallowRef();e({instance:m});const[d,g]=([n,o]=u.withAsyncContext(()=>ii(r.image,r.atlas)),n=await n,o(),n);d.matrixAutoUpdate=!1;let y=Yt(g,r.animation,r.reversed),v=.5,_=.5,A=1,b=Nn(),C=null,L=0,M=!1,P=!0;H.useLoop().onBeforeRender(({delta:S})=>{for(!r.paused&&!M&&(A-=S*r.fps);A<=0;)A++,L++,r.loop?(L>=y.length&&s("loop",y[y.length-1].name),L%=y.length):L>=y.length&&(M=!0,L=r.resetOnEnd?0:y.length-1,s("end",y[y.length-1].name));y[L]!==b&&(b=y[L],C=b.name,w()),P&&(P=!1,d.offset.x=b.offsetX+(r.flipX?b.repeatX:0),d.offset.y=b.offsetY,d.repeat.x=b.repeatX*(r.flipX?-1:1),d.repeat.y=b.repeatY,d.updateMatrix(),p.value=b.width*un,f.value=b.height*un,c.value=(.5-v)*b.width*un,h.value=(.5-_)*b.height*un),C&&(s("frame",C),C=null)});function w(){P=!0}return u.watch(()=>r.animation,(S,x)=>{JSON.stringify(S)!==JSON.stringify(x)&&(y=Yt(g,r.animation,r.reversed),L=0,A=1,M=!1,w())},{immediate:!0}),u.watch(()=>r.reversed,()=>{L=(y.length-L-1)%y.length,y=Yt(g,r.animation,r.reversed),M&&(L=r.resetOnEnd?0:y.length-1),w()}),u.watch(()=>r.paused,()=>{M=!1}),u.watch(()=>r.loop,()=>{M&&r.loop&&(M=!1)}),u.watch(()=>r.resetOnEnd,()=>{M&&(L=r.resetOnEnd?0:y.length-1,w())}),u.watch(()=>r.flipX,w),u.watch(()=>[r.center],()=>{[v,_]=H.normalizeVectorFlexibleParam(r.center),w()},{immediate:!0}),u.watch(()=>[r.definitions],()=>{fi(g,r.definitions),y=Yt(g,r.animation,r.reversed),A=1,L=0,w()},{immediate:!0}),u.onUnmounted(()=>{d.dispose()}),(S,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:m},[r.asSprite?(u.openBlock(),u.createElementBlock("TresSprite",{key:0,scale:[p.value,f.value,1],position:[c.value,h.value,0]},[u.createElementVNode("TresSpriteMaterial",{toneMapped:!1,map:u.unref(d),transparent:!0,alphaTest:r.alphaTest},null,8,mi)],8,pi)):(u.openBlock(),u.createElementBlock("TresMesh",{key:1,scale:[p.value,f.value,1],position:[c.value,h.value,0]},[x[0]||(x[0]=u.createElementVNode("TresPlaneGeometry",{args:[1,1]},null,-1)),u.createElementVNode("TresMeshBasicMaterial",{toneMapped:!1,side:u.unref(l.DoubleSide),map:u.unref(d),transparent:!0,alphaTest:r.alphaTest,depthWrite:r.depthWrite,depthTest:r.depthTest},null,8,yi)],8,gi)),u.renderSlot(S.$slots,"default")],512))}});function hn(a){return u.getCurrentScope()?(u.onScopeDispose(a),!0):!1}function Ge(a){return typeof a=="function"?a():u.unref(a)}const vi=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const xi=Object.prototype.toString,wi=a=>xi.call(a)==="[object Object]",pt=()=>{};function Fn(a,e){function t(...n){return new Promise((o,r)=>{Promise.resolve(a(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(o).catch(r)})}return t}const bi=a=>a();function Mi(a,e={}){let t,n,o=pt;const r=i=>{clearTimeout(i),o(),o=pt};return i=>{const c=Ge(a),h=Ge(e.maxWait);return t&&r(t),c<=0||h!==void 0&&h<=0?(n&&(r(n),n=null),Promise.resolve(i())):new Promise((p,f)=>{o=e.rejectOnCancel?f:p,h&&!n&&(n=setTimeout(()=>{t&&r(t),n=null,p(i())},h)),t=setTimeout(()=>{n&&r(n),n=null,p(i())},c)})}}function Xo(...a){let e=0,t,n=!0,o=pt,r,s,i,c,h;!u.isRef(a[0])&&typeof a[0]=="object"?{delay:s,trailing:i=!0,leading:c=!0,rejectOnCancel:h=!1}=a[0]:[s,i=!0,c=!0,h=!1]=a;const p=()=>{t&&(clearTimeout(t),t=void 0,o(),o=pt)};return m=>{const d=Ge(s),g=Date.now()-e,y=()=>r=m();return p(),d<=0?(e=Date.now(),y()):(g>d&&(c||!n)?(e=Date.now(),y()):i&&(r=new Promise((v,_)=>{o=h?_:v,t=setTimeout(()=>{e=Date.now(),n=!0,v(y()),p()},Math.max(0,d-g))})),!c&&!t&&(t=setTimeout(()=>n=!0,d)),n=!1,r)}}function Si(a){return u.getCurrentInstance()}function Ai(a,e=200,t={}){return Fn(Mi(e,t),a)}function Pi(a,e=200,t=!1,n=!0,o=!1){return Fn(Xo(e,t,n,o),a)}function Ci(a,e,t={}){const{eventFilter:n=bi,...o}=t;return u.watch(a,Fn(n,e),o)}function zn(a,e=!0,t){Si()?u.onMounted(a,t):e?a():u.nextTick(a)}function Ti(a,e,t={}){const{throttle:n=0,trailing:o=!0,leading:r=!0,...s}=t;return Ci(a,e,{...s,eventFilter:Xo(n,o,r)})}const at=vi?window:void 0;function mt(a){var e;const t=Ge(a);return(e=t==null?void 0:t.$el)!=null?e:t}function Ce(...a){let e,t,n,o;if(typeof a[0]=="string"||Array.isArray(a[0])?([t,n,o]=a,e=at):[e,t,n,o]=a,!e)return pt;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const r=[],s=()=>{r.forEach(p=>p()),r.length=0},i=(p,f,m,d)=>(p.addEventListener(f,m,d),()=>p.removeEventListener(f,m,d)),c=u.watch(()=>[mt(e),Ge(o)],([p,f])=>{if(s(),!p)return;const m=wi(f)?{...f}:f;r.push(...t.flatMap(d=>n.map(g=>i(p,d,g,m))))},{immediate:!0,flush:"post"}),h=()=>{c(),s()};return hn(h),h}function Ii(){const a=u.ref(!1),e=u.getCurrentInstance();return e&&u.onMounted(()=>{a.value=!0},e),a}function Eo(a){const e=Ii();return u.computed(()=>(e.value,!!a()))}function Oi(a,e={}){const{window:t=at}=e,n=Eo(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let o;const r=u.ref(!1),s=h=>{r.value=h.matches},i=()=>{o&&("removeEventListener"in o?o.removeEventListener("change",s):o.removeListener(s))},c=u.watchEffect(()=>{n.value&&(i(),o=t.matchMedia(Ge(a)),"addEventListener"in o?o.addEventListener("change",s):o.addListener(s),r.value=o.matches)});return hn(()=>{c(),i(),o=void 0}),r}function Li(a,e,t={}){const{window:n=at,...o}=t;let r;const s=Eo(()=>n&&"ResizeObserver"in n),i=()=>{r&&(r.disconnect(),r=void 0)},c=u.computed(()=>{const f=Ge(a);return Array.isArray(f)?f.map(m=>mt(m)):[mt(f)]}),h=u.watch(c,f=>{if(i(),s.value&&n){r=new ResizeObserver(e);for(const m of f)m&&r.observe(m,o)}},{immediate:!0,flush:"post"}),p=()=>{i(),h()};return hn(p),{isSupported:s,stop:p}}function Di(a,e={width:0,height:0},t={}){const{window:n=at,box:o="content-box"}=t,r=u.computed(()=>{var f,m;return(m=(f=mt(a))==null?void 0:f.namespaceURI)==null?void 0:m.includes("svg")}),s=u.ref(e.width),i=u.ref(e.height),{stop:c}=Li(a,([f])=>{const m=o==="border-box"?f.borderBoxSize:o==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(n&&r.value){const d=mt(a);if(d){const g=d.getBoundingClientRect();s.value=g.width,i.value=g.height}}else if(m){const d=Array.isArray(m)?m:[m];s.value=d.reduce((g,{inlineSize:y})=>g+y,0),i.value=d.reduce((g,{blockSize:y})=>g+y,0)}else s.value=f.contentRect.width,i.value=f.contentRect.height},t);zn(()=>{const f=mt(a);f&&(s.value="offsetWidth"in f?f.offsetWidth:e.width,i.value="offsetHeight"in f?f.offsetHeight:e.height)});const h=u.watch(()=>mt(a),f=>{s.value=f?e.width:0,i.value=f?e.height:0});function p(){c(),h()}return{width:s,height:i,stop:p}}const Zo=1;function ki(a,e={}){const{throttle:t=0,idle:n=200,onStop:o=pt,onScroll:r=pt,offset:s={left:0,right:0,top:0,bottom:0},eventListenerOptions:i={capture:!1,passive:!0},behavior:c="auto",window:h=at,onError:p=P=>{console.error(P)}}=e,f=u.ref(0),m=u.ref(0),d=u.computed({get(){return f.value},set(P){y(P,void 0)}}),g=u.computed({get(){return m.value},set(P){y(void 0,P)}});function y(P,w){var S,x,I,D;if(!h)return;const z=Ge(a);if(!z)return;(I=z instanceof Document?h.document.body:z)==null||I.scrollTo({top:(S=Ge(w))!=null?S:g.value,left:(x=Ge(P))!=null?x:d.value,behavior:Ge(c)});const G=((D=z==null?void 0:z.document)==null?void 0:D.documentElement)||(z==null?void 0:z.documentElement)||z;d!=null&&(f.value=G.scrollLeft),g!=null&&(m.value=G.scrollTop)}const v=u.ref(!1),_=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),A=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),b=P=>{v.value&&(v.value=!1,A.left=!1,A.right=!1,A.top=!1,A.bottom=!1,o(P))},C=Ai(b,t+n),L=P=>{var w;if(!h)return;const S=((w=P==null?void 0:P.document)==null?void 0:w.documentElement)||(P==null?void 0:P.documentElement)||mt(P),{display:x,flexDirection:I}=getComputedStyle(S),D=S.scrollLeft;A.left=D<f.value,A.right=D>f.value;const z=Math.abs(D)<=(s.left||0),G=Math.abs(D)+S.clientWidth>=S.scrollWidth-(s.right||0)-Zo;x==="flex"&&I==="row-reverse"?(_.left=G,_.right=z):(_.left=z,_.right=G),f.value=D;let X=S.scrollTop;P===h.document&&!X&&(X=h.document.body.scrollTop),A.top=X<m.value,A.bottom=X>m.value;const E=Math.abs(X)<=(s.top||0),te=Math.abs(X)+S.clientHeight>=S.scrollHeight-(s.bottom||0)-Zo;x==="flex"&&I==="column-reverse"?(_.top=te,_.bottom=E):(_.top=E,_.bottom=te),m.value=X},M=P=>{var w;if(!h)return;const S=(w=P.target.documentElement)!=null?w:P.target;L(S),v.value=!0,C(P),r(P)};return Ce(a,"scroll",t?Pi(M,t,!0,!1):M,i),zn(()=>{try{const P=Ge(a);if(!P)return;L(P)}catch(P){p(P)}}),Ce(a,"scrollend",b,i),{x:d,y:g,isScrolling:v,arrivedState:_,directions:A,measure(){const P=Ge(a);h&&P&&L(P)}}}const Bi={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function Ui(a={}){const{reactive:e=!1,target:t=at,aliasMap:n=Bi,passive:o=!0,onEventFired:r=pt}=a,s=u.reactive(new Set),i={toJSON(){return{}},current:s},c=e?u.reactive(i):i,h=new Set,p=new Set;function f(y,v){y in c&&(e?c[y]=v:c[y].value=v)}function m(){s.clear();for(const y of p)f(y,!1)}function d(y,v){var _,A;const b=(_=y.key)==null?void 0:_.toLowerCase(),L=[(A=y.code)==null?void 0:A.toLowerCase(),b].filter(Boolean);b&&(v?s.add(b):s.delete(b));for(const M of L)p.add(M),f(M,v);b==="meta"&&!v?(h.forEach(M=>{s.delete(M),f(M,!1)}),h.clear()):typeof y.getModifierState=="function"&&y.getModifierState("Meta")&&v&&[...s,...L].forEach(M=>h.add(M))}Ce(t,"keydown",y=>(d(y,!0),r(y)),{passive:o}),Ce(t,"keyup",y=>(d(y,!1),r(y)),{passive:o}),Ce("blur",m,{passive:!0}),Ce("focus",m,{passive:!0});const g=new Proxy(c,{get(y,v,_){if(typeof v!="string")return Reflect.get(y,v,_);if(v=v.toLowerCase(),v in n&&(v=n[v]),!(v in c))if(/[+_-]/.test(v)){const b=v.split(/[+_-]/g).map(C=>C.trim());c[v]=u.computed(()=>b.every(C=>Ge(g[C])))}else c[v]=u.ref(!1);const A=Reflect.get(y,v,_);return e?Ge(A):A}});return g}const Ni={page:a=>[a.pageX,a.pageY],client:a=>[a.clientX,a.clientY],screen:a=>[a.screenX,a.screenY],movement:a=>a instanceof Touch?null:[a.movementX,a.movementY]};function Fi(a={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:o={x:0,y:0},window:r=at,target:s=r,scroll:i=!0,eventFilter:c}=a;let h=null,p=0,f=0;const m=u.ref(o.x),d=u.ref(o.y),g=u.ref(null),y=typeof e=="function"?e:Ni[e],v=P=>{const w=y(P);h=P,w&&([m.value,d.value]=w,g.value="mouse"),r&&(p=r.scrollX,f=r.scrollY)},_=P=>{if(P.touches.length>0){const w=y(P.touches[0]);w&&([m.value,d.value]=w,g.value="touch")}},A=()=>{if(!h||!r)return;const P=y(h);h instanceof MouseEvent&&P&&(m.value=P[0]+r.scrollX-p,d.value=P[1]+r.scrollY-f)},b=()=>{m.value=o.x,d.value=o.y},C=c?P=>c(()=>v(P),{}):P=>v(P),L=c?P=>c(()=>_(P),{}):P=>_(P),M=c?()=>c(()=>A(),{}):()=>A();if(s){const P={passive:!0};Ce(s,["mousemove","dragover"],C,P),t&&e!=="movement"&&(Ce(s,["touchstart","touchmove"],L,P),n&&Ce(s,"touchend",b,P)),i&&e==="page"&&Ce(r,"scroll",M,{passive:!0})}return{x:m,y:d,sourceType:g}}function zi(a={}){const{window:e=at,behavior:t="auto"}=a;if(!e)return{x:u.ref(0),y:u.ref(0)};const n=u.ref(e.scrollX),o=u.ref(e.scrollY),r=u.computed({get(){return n.value},set(i){scrollTo({left:i,behavior:t})}}),s=u.computed({get(){return o.value},set(i){scrollTo({top:i,behavior:t})}});return Ce(e,"scroll",()=>{n.value=e.scrollX,o.value=e.scrollY},{capture:!1,passive:!0}),{x:r,y:s}}function Ko(a={}){const{window:e=at,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:o=!0,includeScrollbar:r=!0,type:s="inner"}=a,i=u.ref(t),c=u.ref(n),h=()=>{e&&(s==="outer"?(i.value=e.outerWidth,c.value=e.outerHeight):r?(i.value=e.innerWidth,c.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,c.value=e.document.documentElement.clientHeight))};if(h(),zn(h),Ce("resize",h,{passive:!0}),o){const p=Oi("(orientation: portrait)");u.watch(p,()=>h())}return{width:i,height:c}}function Vi(a){let{resolution:e,renderer:t,scene:n,envMap:o,fog:r,near:s,far:i}=a;t=t??H.useTres().renderer,n=n??H.useTres().scene;const c=()=>{e=u.toValue(a.resolution)??255,s=u.toValue(a.near)??.1,i=u.toValue(a.far)??1e3,o=u.toValue(a.envMap)??void 0,r=u.toValue(a.fog)??void 0,t=u.toValue(a.renderer)??t,n=u.toValue(a.scene)??n};u.watchEffect(c);const h=u.computed(()=>new l.WebGLCubeRenderTarget(u.toValue(e)));h.value.texture.type=l.HalfFloatType,hn(()=>{h.value.dispose()});const p=u.computed(()=>new l.CubeCamera(u.toValue(s),u.toValue(i),u.toValue(h))),f=()=>{const m=u.toValue(n),d=m.fog,g=m.background;m.background=u.toValue(o)||g,m.fog=u.toValue(r)||d,p.value.update(u.toValue(t),m),m.fog=d,m.background=g};return u.watchEffect(f),{fbo:h,camera:p,update:f}}const Gi=["object"],Ri=u.defineComponent({__name:"component",props:{frames:{default:1/0},resolution:{},near:{},far:{},envMap:{},fog:{},renderer:{},scene:{}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),{fbo:o,camera:r,update:s}=Vi(t);let i=0;return H.useLoop().onBeforeRender(()=>{n.value&&(t.frames===1/0||i<u.toValue(t.frames))&&(n.value.visible=!1,s(),n.value.visible=!0,n.value&&n.value.traverse(c=>{"material"in c&&typeof c.material=="object"&&c.material&&"envMap"in c.material&&(c.material.envMap=o.value.texture)}),i++)}),e({instance:n,fbo:o,camera:r,update:s}),(c,h)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:n},[u.createElementVNode("primitive",{object:u.unref(r)},null,8,Gi),u.renderSlot(c.$slots,"default")],512))}}),ji=u.defineComponent({__name:"Billboard",props:{autoUpdate:{type:Boolean,default:!0},lockX:{type:Boolean,default:!1},lockY:{type:Boolean,default:!1},lockZ:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=u.shallowRef(new l.Group),o=u.shallowRef(new l.Group),r=new l.Quaternion,s=new l.Euler;function i(c){n.value&&(!c&&(c=H.useTres().camera.value,!c)||(o.value.rotation.copy(s),n.value.updateMatrix(),n.value.updateWorldMatrix(!1,!1),n.value.getWorldQuaternion(r),c.getWorldQuaternion(o.value.quaternion).premultiply(r.invert()),t.lockX&&(o.value.rotation.x=s.x),t.lockY&&(o.value.rotation.y=s.y),t.lockZ&&(o.value.rotation.z=s.z)))}return H.useLoop().onBeforeRender(({camera:c})=>{t.autoUpdate&&i(c)}),e({instance:n,update:i}),(c,h)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outerRef",ref:n},[u.createElementVNode("TresGroup",{ref_key:"innerRef",ref:o},[u.renderSlot(c.$slots,"default")],512)],512))}}),Wi=u.defineComponent({name:"GlobalAudio",props:["src","loop","volume","playbackRate","playTrigger","stopTrigger"],async setup(a,{expose:e,emit:t}){var f;const{camera:n,renderer:o}=H.useTresContext(),r=new l.AudioListener;(f=n.value)==null||f.add(r);const s=new l.Audio(r),i=new l.AudioLoader;e({instance:s}),u.onUnmounted(()=>{s&&s.disconnect()}),u.watch(()=>[a.playbackRate],()=>s.setPlaybackRate(a.playbackRate??1),{immediate:!0}),u.watch(()=>[a.volume],()=>s.setVolume(a.volume??.5),{immediate:!0}),u.watch(()=>[a.loop],()=>s.setLoop(a.loop??!1),{immediate:!0}),u.watch(()=>[a.src],async()=>{const m=await i.loadAsync(a.src);s.setBuffer(m)},{immediate:!0});const h=document.getElementById(a.playTrigger??"")||o.value.domElement;Ce(h,"click",()=>{s.isPlaying?s.pause():s.play(),t("isPlaying",s.isPlaying)});const p=document.getElementById(a.stopTrigger??"");return p&&Ce(p,"click",()=>{s.stop(),t("isPlaying",s.isPlaying)}),null}}),Yi=["color-space","args","attach"],Xi=u.defineComponent({__name:"GradientTexture",props:{stops:{},colors:{},attach:{default:"map"},height:{default:1024},width:{default:16},type:{default:"linear"},innerCircleRadius:{default:0},outerCircleRadius:{default:"auto"}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),o=document.createElement("canvas");function r(i){const c=i.getContext("2d");i.width=t.width,i.height=t.height;let h;if(t.type==="linear")h=c.createLinearGradient(0,0,0,t.height);else{const m=i.width/2,d=i.height/2,g=t.outerCircleRadius!=="auto"?Math.abs(Number(t.outerCircleRadius)):Math.sqrt(m**2+d**2);h=c.createRadialGradient(m,d,Math.abs(t.innerCircleRadius),m,d,g)}const p=new Ot.Color;let f=t.stops.length;for(;f--;)h.addColorStop(t.stops[f],p.set(t.colors[f]).getStyle());c.save(),c.fillStyle=h,c.fillRect(0,0,t.width,t.height),c.restore(),n.value&&(n.value.needsUpdate=!0)}const s=H.useTres().renderer;return u.watch(()=>[t.colors,t.stops,t.height,t.width,t.type,t.innerCircleRadius,t.outerCircleRadius],()=>{r(o)},{immediate:!0}),u.isReactive(t.colors)&&u.watch(t.colors,()=>r(o)),u.isReactive(t.stops)&&u.watch(t.stops,()=>r(o)),e({instance:n}),(i,c)=>(u.openBlock(),u.createElementBlock("TresCanvasTexture",{ref_key:"textureRef",ref:n,"color-space":u.unref(s).outputColorSpace,args:[u.unref(o)],attach:t.attach},null,8,Yi))}});function Vn(a,e,t,n){const o=class extends l.ShaderMaterial{constructor(s={}){const i=Object.entries(a);super({uniforms:i.reduce((c,[h,p])=>{const f=l.UniformsUtils.clone({[h]:{value:p}});return{...c,...f}},{}),vertexShader:e,fragmentShader:t});ue(this,"key","");i.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:h=>this.uniforms[c].value=h})),Object.assign(this,s)}};return o.key=l.MathUtils.generateUUID(),o}const Ei=Vn({color:new l.Color("white"),scale:new l.Vector2(1,1),imageBounds:new l.Vector2(1,1),resolution:1024,map:null,zoom:1,radius:0,grayscale:0,opacity:1},`
|
|
16
|
+
${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<=e||t<0||a.frames.length<=t)return H.useLogger().logError(`Cientos Atlas: getFramesByIndex – [${e}, ${t}] is out of bounds.`),[Nn()];const n=[],o=Math.sign(t-e);if(o===0)return[a.frames[e]];for(let r=e;r!==t+o;r+=o)n.push(a.frames[r]);return n}function Yo(a){const e={};for(const t of a)if(si(t.name)!==null){const n=ri(t.name);Object.prototype.hasOwnProperty.call(e,n)?e[n].push(t):e[n]=[t]}for(const t of Object.values(e))t.sort((n,o)=>n.name.localeCompare(o.name));return e}const pi=["scale","position"],mi=["map","alphaTest"],gi=["scale","position"],yi=["side","map","alphaTest","depthWrite","depthTest"],un=.01,_i=u.defineComponent({__name:"component",props:{image:{},atlas:{},definitions:{},fps:{default:30},loop:{type:Boolean,default:!0},animation:{default:0},paused:{type:Boolean,default:!1},reversed:{type:Boolean,default:!1},flipX:{type:Boolean,default:!1},resetOnEnd:{type:Boolean,default:!1},asSprite:{type:Boolean,default:!0},center:{default:()=>[.5,.5]},alphaTest:{default:0},depthTest:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!0}},emits:["frame","end","loop"],async setup(a,{expose:e,emit:t}){let n,o;const r=a,s=t,{invalidate:i}=H.useTresContext();u.watch(r,()=>{i()});const c=u.ref(0),h=u.ref(0),p=u.ref(0),f=u.ref(0),m=u.shallowRef();e({instance:m});const[d,g]=([n,o]=u.withAsyncContext(()=>ii(r.image,r.atlas)),n=await n,o(),n);d.matrixAutoUpdate=!1;let y=Yt(g,r.animation,r.reversed),v=.5,_=.5,A=1,b=Nn(),C=null,L=0,M=!1,P=!0;H.useLoop().onBeforeRender(({delta:S})=>{for(!r.paused&&!M&&(A-=S*r.fps);A<=0;)A++,L++,r.loop?(L>=y.length&&s("loop",y[y.length-1].name),L%=y.length):L>=y.length&&(M=!0,L=r.resetOnEnd?0:y.length-1,s("end",y[y.length-1].name));y[L]!==b&&(b=y[L],C=b.name,w()),P&&(P=!1,d.offset.x=b.offsetX+(r.flipX?b.repeatX:0),d.offset.y=b.offsetY,d.repeat.x=b.repeatX*(r.flipX?-1:1),d.repeat.y=b.repeatY,d.updateMatrix(),p.value=b.width*un,f.value=b.height*un,c.value=(.5-v)*b.width*un,h.value=(.5-_)*b.height*un),C&&(s("frame",C),C=null)});function w(){P=!0}return u.watch(()=>r.animation,(S,x)=>{JSON.stringify(S)!==JSON.stringify(x)&&(y=Yt(g,r.animation,r.reversed),L=0,A=1,M=!1,w())},{immediate:!0}),u.watch(()=>r.reversed,()=>{L=(y.length-L-1)%y.length,y=Yt(g,r.animation,r.reversed),M&&(L=r.resetOnEnd?0:y.length-1),w()}),u.watch(()=>r.paused,()=>{M=!1}),u.watch(()=>r.loop,()=>{M&&r.loop&&(M=!1)}),u.watch(()=>r.resetOnEnd,()=>{M&&(L=r.resetOnEnd?0:y.length-1,w())}),u.watch(()=>r.flipX,w),u.watch(()=>[r.center],()=>{[v,_]=H.normalizeVectorFlexibleParam(r.center),w()},{immediate:!0}),u.watch(()=>[r.definitions],()=>{fi(g,r.definitions),y=Yt(g,r.animation,r.reversed),A=1,L=0,w()},{immediate:!0}),u.onUnmounted(()=>{d.dispose()}),(S,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:m},[r.asSprite?(u.openBlock(),u.createElementBlock("TresSprite",{key:0,scale:[p.value,f.value,1],position:[c.value,h.value,0]},[u.createElementVNode("TresSpriteMaterial",{toneMapped:!1,map:u.unref(d),transparent:!0,alphaTest:r.alphaTest},null,8,mi)],8,pi)):(u.openBlock(),u.createElementBlock("TresMesh",{key:1,scale:[p.value,f.value,1],position:[c.value,h.value,0]},[x[0]||(x[0]=u.createElementVNode("TresPlaneGeometry",{args:[1,1]},null,-1)),u.createElementVNode("TresMeshBasicMaterial",{toneMapped:!1,side:u.unref(l.DoubleSide),map:u.unref(d),transparent:!0,alphaTest:r.alphaTest,depthWrite:r.depthWrite,depthTest:r.depthTest},null,8,yi)],8,gi)),u.renderSlot(S.$slots,"default")],512))}});function hn(a){return u.getCurrentScope()?(u.onScopeDispose(a),!0):!1}function Ge(a){return typeof a=="function"?a():u.unref(a)}const vi=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const xi=Object.prototype.toString,wi=a=>xi.call(a)==="[object Object]",pt=()=>{};function Fn(a,e){function t(...n){return new Promise((o,r)=>{Promise.resolve(a(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(o).catch(r)})}return t}const bi=a=>a();function Mi(a,e={}){let t,n,o=pt;const r=i=>{clearTimeout(i),o(),o=pt};return i=>{const c=Ge(a),h=Ge(e.maxWait);return t&&r(t),c<=0||h!==void 0&&h<=0?(n&&(r(n),n=null),Promise.resolve(i())):new Promise((p,f)=>{o=e.rejectOnCancel?f:p,h&&!n&&(n=setTimeout(()=>{t&&r(t),n=null,p(i())},h)),t=setTimeout(()=>{n&&r(n),n=null,p(i())},c)})}}function Xo(...a){let e=0,t,n=!0,o=pt,r,s,i,c,h;!u.isRef(a[0])&&typeof a[0]=="object"?{delay:s,trailing:i=!0,leading:c=!0,rejectOnCancel:h=!1}=a[0]:[s,i=!0,c=!0,h=!1]=a;const p=()=>{t&&(clearTimeout(t),t=void 0,o(),o=pt)};return m=>{const d=Ge(s),g=Date.now()-e,y=()=>r=m();return p(),d<=0?(e=Date.now(),y()):(g>d&&(c||!n)?(e=Date.now(),y()):i&&(r=new Promise((v,_)=>{o=h?_:v,t=setTimeout(()=>{e=Date.now(),n=!0,v(y()),p()},Math.max(0,d-g))})),!c&&!t&&(t=setTimeout(()=>n=!0,d)),n=!1,r)}}function Si(a){return u.getCurrentInstance()}function Ai(a,e=200,t={}){return Fn(Mi(e,t),a)}function Pi(a,e=200,t=!1,n=!0,o=!1){return Fn(Xo(e,t,n,o),a)}function Ci(a,e,t={}){const{eventFilter:n=bi,...o}=t;return u.watch(a,Fn(n,e),o)}function zn(a,e=!0,t){Si()?u.onMounted(a,t):e?a():u.nextTick(a)}function Ti(a,e,t={}){const{throttle:n=0,trailing:o=!0,leading:r=!0,...s}=t;return Ci(a,e,{...s,eventFilter:Xo(n,o,r)})}const at=vi?window:void 0;function mt(a){var e;const t=Ge(a);return(e=t==null?void 0:t.$el)!=null?e:t}function Ce(...a){let e,t,n,o;if(typeof a[0]=="string"||Array.isArray(a[0])?([t,n,o]=a,e=at):[e,t,n,o]=a,!e)return pt;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const r=[],s=()=>{r.forEach(p=>p()),r.length=0},i=(p,f,m,d)=>(p.addEventListener(f,m,d),()=>p.removeEventListener(f,m,d)),c=u.watch(()=>[mt(e),Ge(o)],([p,f])=>{if(s(),!p)return;const m=wi(f)?{...f}:f;r.push(...t.flatMap(d=>n.map(g=>i(p,d,g,m))))},{immediate:!0,flush:"post"}),h=()=>{c(),s()};return hn(h),h}function Ii(){const a=u.ref(!1),e=u.getCurrentInstance();return e&&u.onMounted(()=>{a.value=!0},e),a}function Eo(a){const e=Ii();return u.computed(()=>(e.value,!!a()))}function Oi(a,e={}){const{window:t=at}=e,n=Eo(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let o;const r=u.ref(!1),s=h=>{r.value=h.matches},i=()=>{o&&("removeEventListener"in o?o.removeEventListener("change",s):o.removeListener(s))},c=u.watchEffect(()=>{n.value&&(i(),o=t.matchMedia(Ge(a)),"addEventListener"in o?o.addEventListener("change",s):o.addListener(s),r.value=o.matches)});return hn(()=>{c(),i(),o=void 0}),r}function Li(a,e,t={}){const{window:n=at,...o}=t;let r;const s=Eo(()=>n&&"ResizeObserver"in n),i=()=>{r&&(r.disconnect(),r=void 0)},c=u.computed(()=>{const f=Ge(a);return Array.isArray(f)?f.map(m=>mt(m)):[mt(f)]}),h=u.watch(c,f=>{if(i(),s.value&&n){r=new ResizeObserver(e);for(const m of f)m&&r.observe(m,o)}},{immediate:!0,flush:"post"}),p=()=>{i(),h()};return hn(p),{isSupported:s,stop:p}}function Di(a,e={width:0,height:0},t={}){const{window:n=at,box:o="content-box"}=t,r=u.computed(()=>{var f,m;return(m=(f=mt(a))==null?void 0:f.namespaceURI)==null?void 0:m.includes("svg")}),s=u.ref(e.width),i=u.ref(e.height),{stop:c}=Li(a,([f])=>{const m=o==="border-box"?f.borderBoxSize:o==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(n&&r.value){const d=mt(a);if(d){const g=d.getBoundingClientRect();s.value=g.width,i.value=g.height}}else if(m){const d=Array.isArray(m)?m:[m];s.value=d.reduce((g,{inlineSize:y})=>g+y,0),i.value=d.reduce((g,{blockSize:y})=>g+y,0)}else s.value=f.contentRect.width,i.value=f.contentRect.height},t);zn(()=>{const f=mt(a);f&&(s.value="offsetWidth"in f?f.offsetWidth:e.width,i.value="offsetHeight"in f?f.offsetHeight:e.height)});const h=u.watch(()=>mt(a),f=>{s.value=f?e.width:0,i.value=f?e.height:0});function p(){c(),h()}return{width:s,height:i,stop:p}}const Zo=1;function ki(a,e={}){const{throttle:t=0,idle:n=200,onStop:o=pt,onScroll:r=pt,offset:s={left:0,right:0,top:0,bottom:0},eventListenerOptions:i={capture:!1,passive:!0},behavior:c="auto",window:h=at,onError:p=P=>{console.error(P)}}=e,f=u.ref(0),m=u.ref(0),d=u.computed({get(){return f.value},set(P){y(P,void 0)}}),g=u.computed({get(){return m.value},set(P){y(void 0,P)}});function y(P,w){var S,x,I,D;if(!h)return;const z=Ge(a);if(!z)return;(I=z instanceof Document?h.document.body:z)==null||I.scrollTo({top:(S=Ge(w))!=null?S:g.value,left:(x=Ge(P))!=null?x:d.value,behavior:Ge(c)});const G=((D=z==null?void 0:z.document)==null?void 0:D.documentElement)||(z==null?void 0:z.documentElement)||z;d!=null&&(f.value=G.scrollLeft),g!=null&&(m.value=G.scrollTop)}const v=u.ref(!1),_=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),A=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),b=P=>{v.value&&(v.value=!1,A.left=!1,A.right=!1,A.top=!1,A.bottom=!1,o(P))},C=Ai(b,t+n),L=P=>{var w;if(!h)return;const S=((w=P==null?void 0:P.document)==null?void 0:w.documentElement)||(P==null?void 0:P.documentElement)||mt(P),{display:x,flexDirection:I}=getComputedStyle(S),D=S.scrollLeft;A.left=D<f.value,A.right=D>f.value;const z=Math.abs(D)<=(s.left||0),G=Math.abs(D)+S.clientWidth>=S.scrollWidth-(s.right||0)-Zo;x==="flex"&&I==="row-reverse"?(_.left=G,_.right=z):(_.left=z,_.right=G),f.value=D;let E=S.scrollTop;P===h.document&&!E&&(E=h.document.body.scrollTop),A.top=E<m.value,A.bottom=E>m.value;const X=Math.abs(E)<=(s.top||0),oe=Math.abs(E)+S.clientHeight>=S.scrollHeight-(s.bottom||0)-Zo;x==="flex"&&I==="column-reverse"?(_.top=oe,_.bottom=X):(_.top=X,_.bottom=oe),m.value=E},M=P=>{var w;if(!h)return;const S=(w=P.target.documentElement)!=null?w:P.target;L(S),v.value=!0,C(P),r(P)};return Ce(a,"scroll",t?Pi(M,t,!0,!1):M,i),zn(()=>{try{const P=Ge(a);if(!P)return;L(P)}catch(P){p(P)}}),Ce(a,"scrollend",b,i),{x:d,y:g,isScrolling:v,arrivedState:_,directions:A,measure(){const P=Ge(a);h&&P&&L(P)}}}const Bi={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function Ui(a={}){const{reactive:e=!1,target:t=at,aliasMap:n=Bi,passive:o=!0,onEventFired:r=pt}=a,s=u.reactive(new Set),i={toJSON(){return{}},current:s},c=e?u.reactive(i):i,h=new Set,p=new Set;function f(y,v){y in c&&(e?c[y]=v:c[y].value=v)}function m(){s.clear();for(const y of p)f(y,!1)}function d(y,v){var _,A;const b=(_=y.key)==null?void 0:_.toLowerCase(),L=[(A=y.code)==null?void 0:A.toLowerCase(),b].filter(Boolean);b&&(v?s.add(b):s.delete(b));for(const M of L)p.add(M),f(M,v);b==="meta"&&!v?(h.forEach(M=>{s.delete(M),f(M,!1)}),h.clear()):typeof y.getModifierState=="function"&&y.getModifierState("Meta")&&v&&[...s,...L].forEach(M=>h.add(M))}Ce(t,"keydown",y=>(d(y,!0),r(y)),{passive:o}),Ce(t,"keyup",y=>(d(y,!1),r(y)),{passive:o}),Ce("blur",m,{passive:!0}),Ce("focus",m,{passive:!0});const g=new Proxy(c,{get(y,v,_){if(typeof v!="string")return Reflect.get(y,v,_);if(v=v.toLowerCase(),v in n&&(v=n[v]),!(v in c))if(/[+_-]/.test(v)){const b=v.split(/[+_-]/g).map(C=>C.trim());c[v]=u.computed(()=>b.every(C=>Ge(g[C])))}else c[v]=u.ref(!1);const A=Reflect.get(y,v,_);return e?Ge(A):A}});return g}const Ni={page:a=>[a.pageX,a.pageY],client:a=>[a.clientX,a.clientY],screen:a=>[a.screenX,a.screenY],movement:a=>a instanceof Touch?null:[a.movementX,a.movementY]};function Fi(a={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:o={x:0,y:0},window:r=at,target:s=r,scroll:i=!0,eventFilter:c}=a;let h=null,p=0,f=0;const m=u.ref(o.x),d=u.ref(o.y),g=u.ref(null),y=typeof e=="function"?e:Ni[e],v=P=>{const w=y(P);h=P,w&&([m.value,d.value]=w,g.value="mouse"),r&&(p=r.scrollX,f=r.scrollY)},_=P=>{if(P.touches.length>0){const w=y(P.touches[0]);w&&([m.value,d.value]=w,g.value="touch")}},A=()=>{if(!h||!r)return;const P=y(h);h instanceof MouseEvent&&P&&(m.value=P[0]+r.scrollX-p,d.value=P[1]+r.scrollY-f)},b=()=>{m.value=o.x,d.value=o.y},C=c?P=>c(()=>v(P),{}):P=>v(P),L=c?P=>c(()=>_(P),{}):P=>_(P),M=c?()=>c(()=>A(),{}):()=>A();if(s){const P={passive:!0};Ce(s,["mousemove","dragover"],C,P),t&&e!=="movement"&&(Ce(s,["touchstart","touchmove"],L,P),n&&Ce(s,"touchend",b,P)),i&&e==="page"&&Ce(r,"scroll",M,{passive:!0})}return{x:m,y:d,sourceType:g}}function zi(a={}){const{window:e=at,behavior:t="auto"}=a;if(!e)return{x:u.ref(0),y:u.ref(0)};const n=u.ref(e.scrollX),o=u.ref(e.scrollY),r=u.computed({get(){return n.value},set(i){scrollTo({left:i,behavior:t})}}),s=u.computed({get(){return o.value},set(i){scrollTo({top:i,behavior:t})}});return Ce(e,"scroll",()=>{n.value=e.scrollX,o.value=e.scrollY},{capture:!1,passive:!0}),{x:r,y:s}}function Ko(a={}){const{window:e=at,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:o=!0,includeScrollbar:r=!0,type:s="inner"}=a,i=u.ref(t),c=u.ref(n),h=()=>{e&&(s==="outer"?(i.value=e.outerWidth,c.value=e.outerHeight):r?(i.value=e.innerWidth,c.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,c.value=e.document.documentElement.clientHeight))};if(h(),zn(h),Ce("resize",h,{passive:!0}),o){const p=Oi("(orientation: portrait)");u.watch(p,()=>h())}return{width:i,height:c}}function Vi(a){let{resolution:e,renderer:t,scene:n,envMap:o,fog:r,near:s,far:i}=a;t=t??H.useTres().renderer,n=n??H.useTres().scene;const c=()=>{e=u.toValue(a.resolution)??255,s=u.toValue(a.near)??.1,i=u.toValue(a.far)??1e3,o=u.toValue(a.envMap)??void 0,r=u.toValue(a.fog)??void 0,t=u.toValue(a.renderer)??t,n=u.toValue(a.scene)??n};u.watchEffect(c);const h=u.computed(()=>new l.WebGLCubeRenderTarget(u.toValue(e)));h.value.texture.type=l.HalfFloatType,hn(()=>{h.value.dispose()});const p=u.computed(()=>new l.CubeCamera(u.toValue(s),u.toValue(i),u.toValue(h))),f=()=>{const m=u.toValue(n),d=m.fog,g=m.background;m.background=u.toValue(o)||g,m.fog=u.toValue(r)||d,p.value.update(u.toValue(t),m),m.fog=d,m.background=g};return u.watchEffect(f),{fbo:h,camera:p,update:f}}const Gi=["object"],Ri=u.defineComponent({__name:"component",props:{frames:{default:1/0},resolution:{},near:{},far:{},envMap:{},fog:{},renderer:{},scene:{}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),{fbo:o,camera:r,update:s}=Vi(t);let i=0;return H.useLoop().onBeforeRender(()=>{n.value&&(t.frames===1/0||i<u.toValue(t.frames))&&(n.value.visible=!1,s(),n.value.visible=!0,n.value&&n.value.traverse(c=>{"material"in c&&typeof c.material=="object"&&c.material&&"envMap"in c.material&&(c.material.envMap=o.value.texture)}),i++)}),e({instance:n,fbo:o,camera:r,update:s}),(c,h)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:n},[u.createElementVNode("primitive",{object:u.unref(r)},null,8,Gi),u.renderSlot(c.$slots,"default")],512))}}),ji=u.defineComponent({__name:"Billboard",props:{autoUpdate:{type:Boolean,default:!0},lockX:{type:Boolean,default:!1},lockY:{type:Boolean,default:!1},lockZ:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=u.shallowRef(new l.Group),o=u.shallowRef(new l.Group),r=new l.Quaternion,s=new l.Euler;function i(c){n.value&&(!c&&(c=H.useTres().camera.value,!c)||(o.value.rotation.copy(s),n.value.updateMatrix(),n.value.updateWorldMatrix(!1,!1),n.value.getWorldQuaternion(r),c.getWorldQuaternion(o.value.quaternion).premultiply(r.invert()),t.lockX&&(o.value.rotation.x=s.x),t.lockY&&(o.value.rotation.y=s.y),t.lockZ&&(o.value.rotation.z=s.z)))}return H.useLoop().onBeforeRender(({camera:c})=>{t.autoUpdate&&i(c)}),e({instance:n,update:i}),(c,h)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outerRef",ref:n},[u.createElementVNode("TresGroup",{ref_key:"innerRef",ref:o},[u.renderSlot(c.$slots,"default")],512)],512))}}),Wi=u.defineComponent({name:"GlobalAudio",props:["src","loop","volume","playbackRate","playTrigger","stopTrigger"],async setup(a,{expose:e,emit:t}){var f;const{camera:n,renderer:o}=H.useTresContext(),r=new l.AudioListener;(f=n.value)==null||f.add(r);const s=new l.Audio(r),i=new l.AudioLoader;e({instance:s}),u.onUnmounted(()=>{s&&s.disconnect()}),u.watch(()=>[a.playbackRate],()=>s.setPlaybackRate(a.playbackRate??1),{immediate:!0}),u.watch(()=>[a.volume],()=>s.setVolume(a.volume??.5),{immediate:!0}),u.watch(()=>[a.loop],()=>s.setLoop(a.loop??!1),{immediate:!0}),u.watch(()=>[a.src],async()=>{const m=await i.loadAsync(a.src);s.setBuffer(m)},{immediate:!0});const h=document.getElementById(a.playTrigger??"")||o.value.domElement;Ce(h,"click",()=>{s.isPlaying?s.pause():s.play(),t("isPlaying",s.isPlaying)});const p=document.getElementById(a.stopTrigger??"");return p&&Ce(p,"click",()=>{s.stop(),t("isPlaying",s.isPlaying)}),null}}),Yi=["color-space","args","attach"],Xi=u.defineComponent({__name:"GradientTexture",props:{stops:{},colors:{},attach:{default:"map"},height:{default:1024},width:{default:16},type:{default:"linear"},innerCircleRadius:{default:0},outerCircleRadius:{default:"auto"}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),o=document.createElement("canvas");function r(i){const c=i.getContext("2d");i.width=t.width,i.height=t.height;let h;if(t.type==="linear")h=c.createLinearGradient(0,0,0,t.height);else{const m=i.width/2,d=i.height/2,g=t.outerCircleRadius!=="auto"?Math.abs(Number(t.outerCircleRadius)):Math.sqrt(m**2+d**2);h=c.createRadialGradient(m,d,Math.abs(t.innerCircleRadius),m,d,g)}const p=new Ot.Color;let f=t.stops.length;for(;f--;)h.addColorStop(t.stops[f],p.set(t.colors[f]).getStyle());c.save(),c.fillStyle=h,c.fillRect(0,0,t.width,t.height),c.restore(),n.value&&(n.value.needsUpdate=!0)}const s=H.useTres().renderer;return u.watch(()=>[t.colors,t.stops,t.height,t.width,t.type,t.innerCircleRadius,t.outerCircleRadius],()=>{r(o)},{immediate:!0}),u.isReactive(t.colors)&&u.watch(t.colors,()=>r(o)),u.isReactive(t.stops)&&u.watch(t.stops,()=>r(o)),e({instance:n}),(i,c)=>(u.openBlock(),u.createElementBlock("TresCanvasTexture",{ref_key:"textureRef",ref:n,"color-space":u.unref(s).outputColorSpace,args:[u.unref(o)],attach:t.attach},null,8,Yi))}});function Vn(a,e,t,n){const o=class extends l.ShaderMaterial{constructor(s={}){const i=Object.entries(a);super({uniforms:i.reduce((c,[h,p])=>{const f=l.UniformsUtils.clone({[h]:{value:p}});return{...c,...f}},{}),vertexShader:e,fragmentShader:t});ue(this,"key","");i.forEach(([c])=>Object.defineProperty(this,c,{get:()=>this.uniforms[c].value,set:h=>this.uniforms[c].value=h})),Object.assign(this,s)}};return o.key=l.MathUtils.generateUUID(),o}const Ei=Vn({color:new l.Color("white"),scale:new l.Vector2(1,1),imageBounds:new l.Vector2(1,1),resolution:1024,map:null,zoom:1,radius:0,grayscale:0,opacity:1},`
|
|
17
17
|
varying vec2 vUv;
|
|
18
18
|
varying vec2 vPos;
|
|
19
19
|
void main() {
|
|
@@ -87,7 +87,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
|
|
|
87
87
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
88
88
|
#endif
|
|
89
89
|
}
|
|
90
|
-
`})),Lt.uniforms.blitTexture.value=a,Lt.defines.IS_SRGB="colorSpace"in a?a.colorSpace==="srgb":a.encoding===3001,Lt.needsUpdate=!0,dn||(dn=new l.Mesh(Rn,Lt),dn.frustrumCulled=!1);const n=new l.PerspectiveCamera,o=new l.Scene;o.add(dn),t||(t=fn=new l.WebGLRenderer({antialias:!1})),t.setSize(Math.min(a.image.width,e),Math.min(a.image.height,e)),t.clear(),t.render(o,n);const r=new l.Texture(t.domElement);return r.minFilter=a.minFilter,r.magFilter=a.magFilter,r.wrapS=a.wrapS,r.wrapT=a.wrapT,r.name=a.name,fn&&(fn.dispose(),fn=null),r}const Jo={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class Wn{constructor(){this.pluginCallbacks=[],this.register(function(e){return new ua(e)}),this.register(function(e){return new ha(e)}),this.register(function(e){return new pa(e)}),this.register(function(e){return new ma(e)}),this.register(function(e){return new ga(e)}),this.register(function(e){return new ya(e)}),this.register(function(e){return new fa(e)}),this.register(function(e){return new da(e)}),this.register(function(e){return new _a(e)}),this.register(function(e){return new va(e)}),this.register(function(e){return new xa(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,o){const r=new ca,s=[];for(let i=0,c=this.pluginCallbacks.length;i<c;i++)s.push(this.pluginCallbacks[i](r));r.setPlugins(s),r.write(e,t,o).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,o,r,t)})}}ea(Wn,"Utils",{insertKeyframe:function(a,e){const n=a.getValueSize(),o=new a.TimeBufferType(a.times.length+1),r=new a.ValueBufferType(a.values.length+n),s=a.createInterpolant(new a.ValueBufferType(n));let i;if(a.times.length===0){o[0]=e;for(let c=0;c<n;c++)r[c]=0;i=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;o[0]=e,o.set(a.times,1),r.set(s.evaluate(e),0),r.set(a.values,n),i=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;o[o.length-1]=e,o.set(a.times,0),r.set(a.values,0),r.set(s.evaluate(e),a.values.length),i=o.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){o.set(a.times.slice(0,c+1),0),o[c+1]=e,o.set(a.times.slice(c+1),c+2),r.set(a.values.slice(0,(c+1)*n),0),r.set(s.evaluate(e),(c+1)*n),r.set(a.values.slice((c+1)*n),(c+2)*n),i=c+1;break}}return a.times=o,a.values=r,i},mergeMorphTargetTracks:function(a,e){const t=[],n={},o=a.tracks;for(let r=0;r<o.length;++r){let s=o[r];const i=l.PropertyBinding.parseTrackName(s.name),c=l.PropertyBinding.findNode(e,i.nodeName);if(i.propertyName!=="morphTargetInfluences"||i.propertyIndex===void 0){t.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(l.InterpolateLinear)}const h=c.morphTargetInfluences.length,p=c.morphTargetDictionary[i.propertyIndex];if(p===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+i.propertyIndex);let f;if(n[c.uuid]===void 0){f=s.clone();const d=new f.ValueBufferType(h*f.times.length);for(let g=0;g<f.times.length;g++)d[g*h+p]=f.values[g];f.name=(i.nodeName||"")+".morphTargetInfluences",f.values=d,n[c.uuid]=f,t.push(f);continue}const m=s.createInterpolant(new s.ValueBufferType(1));f=n[c.uuid];for(let d=0;d<f.times.length;d++)f.values[d*h+p]=m.evaluate(f.times[d]);for(let d=0;d<s.times.length;d++){const g=this.insertKeyframe(f,s.times[d]);f.values[g*h+p]=s.values[d]}}return a.tracks=t,a}});const we={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Yn="KHR_mesh_quantization",Xe={};Xe[l.NearestFilter]=we.NEAREST,Xe[l.NearestMipmapNearestFilter]=we.NEAREST_MIPMAP_NEAREST,Xe[l.NearestMipmapLinearFilter]=we.NEAREST_MIPMAP_LINEAR,Xe[l.LinearFilter]=we.LINEAR,Xe[l.LinearMipmapNearestFilter]=we.LINEAR_MIPMAP_NEAREST,Xe[l.LinearMipmapLinearFilter]=we.LINEAR_MIPMAP_LINEAR,Xe[l.ClampToEdgeWrapping]=we.CLAMP_TO_EDGE,Xe[l.RepeatWrapping]=we.REPEAT,Xe[l.MirroredRepeatWrapping]=we.MIRRORED_REPEAT;const Ho={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},ta=new l.Color,$o=12,na=1179937895,oa=2,er=8,ra=1313821514,sa=5130562;function Et(a,e){return a.length===e.length&&a.every(function(t,n){return t===e[n]})}function ia(a){return new TextEncoder().encode(a).buffer}function aa(a){return Et(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function la(a,e,t){const n={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let o=e;o<e+t;o++)for(let r=0;r<a.itemSize;r++){let s;a.itemSize>4?s=a.array[o*a.itemSize+r]:(r===0?s=a.getX(o):r===1?s=a.getY(o):r===2?s=a.getZ(o):r===3&&(s=a.getW(o)),a.normalized===!0&&(s=l.MathUtils.normalize(s,a.array))),n.min[r]=Math.min(n.min[r],s),n.max[r]=Math.max(n.max[r],s)}return n}function tr(a){return Math.ceil(a/4)*4}function Xn(a,e=0){const t=tr(a.byteLength);if(t!==a.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(a)),e!==0)for(let o=a.byteLength;o<t;o++)n[o]=e;return n.buffer}return a}function nr(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function or(a,e){if(a.toBlob!==void 0)return new Promise(n=>a.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),a.convertToBlob({type:e,quality:t})}class ca{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},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,n={}){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 o=this,r=o.buffers,s=o.json;n=o.options;const i=o.extensionsUsed,c=o.extensionsRequired,h=new Blob(r,{type:"application/octet-stream"}),p=Object.keys(i),f=Object.keys(c);p.length>0&&(s.extensionsUsed=p),f.length>0&&(s.extensionsRequired=f),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=h.size),n.binary===!0?h.arrayBuffer().then(m=>{const d=Xn(m),g=new DataView(new ArrayBuffer(er));g.setUint32(0,d.byteLength,!0),g.setUint32(4,sa,!0);const y=Xn(ia(JSON.stringify(s)),32),v=new DataView(new ArrayBuffer(er));v.setUint32(0,y.byteLength,!0),v.setUint32(4,ra,!0);const _=new ArrayBuffer($o),A=new DataView(_);A.setUint32(0,na,!0),A.setUint32(4,oa,!0);const b=$o+v.byteLength+y.byteLength+g.byteLength+d.byteLength;A.setUint32(8,b,!0),new Blob([_,v,y,g,d],{type:"application/octet-stream"}).arrayBuffer().then(t)}):s.buffers&&s.buffers.length>0?Qo(h).then(m=>{s.buffers[0].uri=m,t(s)}):t(s)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,o=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const s in r.gltfExtensions)t.extensions[s]=r.gltfExtensions[s],o[s]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const o=new Map;o.set(!0,this.uid++),o.set(!1,this.uid++),this.uids.set(e,o)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new l.Vector3;for(let o=0,r=e.count;o<r;o++)if(Math.abs(n.fromBufferAttribute(e,o).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),o=new l.Vector3;for(let r=0,s=n.count;r<s;r++)o.fromBufferAttribute(n,r),o.x===0&&o.y===0&&o.z===0?o.setX(1):o.normalize(),n.setXYZ(r,o.x,o.y,o.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const o={};(t.offset.x!==0||t.offset.y!==0)&&(o.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(o.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(o.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=o,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(d){return("colorSpace"in d?d.colorSpace==="srgb":d.encoding===3001)?function(y){return y<.04045?y*.0773993808:Math.pow(y*.9478672986+.0521327014,2.4)}:function(y){return y}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof l.CompressedTexture&&(e=jn(e)),t instanceof l.CompressedTexture&&(t=jn(t));const o=e?e.image:null,r=t?t.image:null,s=Math.max(o?o.width:0,r?r.width:0),i=Math.max(o?o.height:0,r?r.height:0),c=nr();c.width=s,c.height=i;const h=c.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,s,i);const p=h.getImageData(0,0,s,i);if(o){h.drawImage(o,0,0,s,i);const d=n(e),g=h.getImageData(0,0,s,i).data;for(let y=2;y<g.length;y+=4)p.data[y]=d(g[y]/256)*256}if(r){h.drawImage(r,0,0,s,i);const d=n(t),g=h.getImageData(0,0,s,i).data;for(let y=1;y<g.length;y+=4)p.data[y]=d(g[y]/256)*256}h.putImageData(p,0,0);const m=(e||t).clone();return m.source=new l.Texture(c).source,"colorSpace"in m?m.colorSpace="":m.encoding=3e3,m.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),m}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,o,r){const s=this.json;s.bufferViews||(s.bufferViews=[]);let i;switch(t){case we.BYTE:case we.UNSIGNED_BYTE:i=1;break;case we.SHORT:case we.UNSIGNED_SHORT:i=2;break;default:i=4}const c=tr(o*e.itemSize*i),h=new DataView(new ArrayBuffer(c));let p=0;for(let d=n;d<n+o;d++)for(let g=0;g<e.itemSize;g++){let y;e.itemSize>4?y=e.array[d*e.itemSize+g]:(g===0?y=e.getX(d):g===1?y=e.getY(d):g===2?y=e.getZ(d):g===3&&(y=e.getW(d)),e.normalized===!0&&(y=l.MathUtils.normalize(y,e.array))),t===we.FLOAT?h.setFloat32(p,y,!0):t===we.INT?h.setInt32(p,y,!0):t===we.UNSIGNED_INT?h.setUint32(p,y,!0):t===we.SHORT?h.setInt16(p,y,!0):t===we.UNSIGNED_SHORT?h.setUint16(p,y,!0):t===we.BYTE?h.setInt8(p,y):t===we.UNSIGNED_BYTE&&h.setUint8(p,y),p+=i}const f={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return r!==void 0&&(f.target=r),r===we.ARRAY_BUFFER&&(f.byteStride=e.itemSize*i),this.byteOffset+=c,s.bufferViews.push(f),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),e.arrayBuffer().then(o=>{const r=Xn(o),s={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};return t.byteOffset+=r.byteLength,n.bufferViews.push(s)-1})}processAccessor(e,t,n,o){const r=this.json,s={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let i;if(e.array.constructor===Float32Array)i=we.FLOAT;else if(e.array.constructor===Int32Array)i=we.INT;else if(e.array.constructor===Uint32Array)i=we.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=we.SHORT;else if(e.array.constructor===Uint16Array)i=we.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=we.BYTE;else if(e.array.constructor===Uint8Array)i=we.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),o===void 0&&(o=e.count),o===0)return null;const c=la(e,n,o);let h;t!==void 0&&(h=e===t.index?we.ELEMENT_ARRAY_BUFFER:we.ARRAY_BUFFER);const p=this.processBufferView(e,i,n,o,h),f={bufferView:p.id,byteOffset:p.byteOffset,componentType:i,count:o,max:c.max,min:c.min,type:s[e.itemSize]};return e.normalized===!0&&(f.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(f)-1}processImage(e,t,n,o="image/png"){if(e!==null){const r=this,s=r.cache,i=r.json,c=r.options,h=r.pending;s.images.has(e)||s.images.set(e,{});const p=s.images.get(e),f=o+":flipY/"+n.toString();if(p[f]!==void 0)return p[f];i.images||(i.images=[]);const m={mimeType:o},d=nr();d.width=Math.min(e.width,c.maxTextureSize),d.height=Math.min(e.height,c.maxTextureSize);const g=d.getContext("2d");if(n===!0&&(g.translate(0,d.height),g.scale(1,-1)),e.data!==void 0){t!==l.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const v=new Uint8ClampedArray(e.height*e.width*4);for(let _=0;_<v.length;_+=4)v[_+0]=e.data[_+0],v[_+1]=e.data[_+1],v[_+2]=e.data[_+2],v[_+3]=e.data[_+3];g.putImageData(new ImageData(v,e.width,e.height),0,0)}else g.drawImage(e,0,0,d.width,d.height);c.binary===!0?h.push(or(d,o).then(v=>r.processBufferViewImage(v)).then(v=>{m.bufferView=v})):d.toDataURL!==void 0?m.uri=d.toDataURL(o):h.push(or(d,o).then(Qo).then(v=>{m.uri=v}));const y=i.images.push(m)-1;return p[f]=y,y}else 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:Xe[e.magFilter],minFilter:Xe[e.minFilter],wrapS:Xe[e.wrapS],wrapT:Xe[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,o=this.cache,r=this.json;if(o.textures.has(e))return o.textures.get(e);r.textures||(r.textures=[]),e instanceof l.CompressedTexture&&(e=jn(e,n.maxTextureSize));let s=e.userData.mimeType;s==="image/webp"&&(s="image/png");const i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(i.name=e.name),this._invokeAll(function(h){h.writeTexture&&h.writeTexture(e,i)});const c=r.textures.push(i)-1;return o.textures.set(e,c),c}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 o={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(Et(r,[1,1,1,1])||(o.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(o.pbrMetallicRoughness.metallicFactor=e.metalness,o.pbrMetallicRoughness.roughnessFactor=e.roughness):(o.pbrMetallicRoughness.metallicFactor=.5,o.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const i=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(i),channel:i.channel};this.applyTextureTransform(c,i),o.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const i={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(i,e.map),o.pbrMetallicRoughness.baseColorTexture=i}if(e.emissive){const i=e.emissive;if(Math.max(i.r,i.g,i.b)>0&&(o.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const h={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(h,e.emissiveMap),o.emissiveTexture=h}}if(e.normalMap){const i={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(i.scale=e.normalScale.x),this.applyTextureTransform(i,e.normalMap),o.normalTexture=i}if(e.aoMap){const i={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(i.strength=e.aoMapIntensity),this.applyTextureTransform(i,e.aoMap),o.occlusionTexture=i}e.transparent?o.alphaMode="BLEND":e.alphaTest>0&&(o.alphaMode="MASK",o.alphaCutoff=e.alphaTest),e.side===l.DoubleSide&&(o.doubleSided=!0),e.name!==""&&(o.name=e.name),this.serializeUserData(e,o),this._invokeAll(function(i){i.writeMaterial&&i.writeMaterial(e,o)});const s=n.materials.push(o)-1;return t.materials.set(e,s),s}processMesh(e){const t=this.cache,n=this.json,o=[e.geometry.uuid];if(Array.isArray(e.material))for(let b=0,C=e.material.length;b<C;b++)o.push(e.material[b].uuid);else o.push(e.material.uuid);const r=o.join(":");if(t.meshes.has(r))return t.meshes.get(r);const s=e.geometry;let i;e.isLineSegments?i=we.LINES:e.isLineLoop?i=we.LINE_LOOP:e.isLine?i=we.LINE_STRIP:e.isPoints?i=we.POINTS:i=e.material.wireframe?we.LINES:we.TRIANGLES;const c={},h={},p=[],f=[],m={...Xt>=152?{uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3"}:{uv:"TEXCOORD_0",uv2:"TEXCOORD_1"},color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");d!==void 0&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let g=null;for(let b in s.attributes){if(b.slice(0,5)==="morph")continue;const C=s.attributes[b];if(b=m[b]||b.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(b)||(b="_"+b),t.attributes.has(this.getUID(C))){h[b]=t.attributes.get(this.getUID(C));continue}g=null;const M=C.array;b==="JOINTS_0"&&!(M instanceof Uint16Array)&&!(M instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),g=new l.BufferAttribute(new Uint16Array(M),C.itemSize,C.normalized));const P=this.processAccessor(g||C,s);P!==null&&(b.startsWith("_")||this.detectMeshQuantization(b,C),h[b]=P,t.attributes.set(this.getUID(C),P))}if(d!==void 0&&s.setAttribute("normal",d),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const b=[],C=[],L={};if(e.morphTargetDictionary!==void 0)for(const M in e.morphTargetDictionary)L[e.morphTargetDictionary[M]]=M;for(let M=0;M<e.morphTargetInfluences.length;++M){const P={};let w=!1;for(const S in s.morphAttributes){if(S!=="position"&&S!=="normal"){w||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),w=!0);continue}const x=s.morphAttributes[S][M],I=S.toUpperCase(),D=s.attributes[S];if(t.attributes.has(this.getUID(x,!0))){P[I]=t.attributes.get(this.getUID(x,!0));continue}const z=x.clone();if(!s.morphTargetsRelative)for(let G=0,X=x.count;G<X;G++)for(let E=0;E<x.itemSize;E++)E===0&&z.setX(G,x.getX(G)-D.getX(G)),E===1&&z.setY(G,x.getY(G)-D.getY(G)),E===2&&z.setZ(G,x.getZ(G)-D.getZ(G)),E===3&&z.setW(G,x.getW(G)-D.getW(G));P[I]=this.processAccessor(z,s),t.attributes.set(this.getUID(D,!0),P[I])}f.push(P),b.push(e.morphTargetInfluences[M]),e.morphTargetDictionary!==void 0&&C.push(L[M])}c.weights=b,C.length>0&&(c.extras={},c.extras.targetNames=C)}const y=Array.isArray(e.material);if(y&&s.groups.length===0)return null;const v=y?e.material:[e.material],_=y?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let b=0,C=_.length;b<C;b++){const L={mode:i,attributes:h};if(this.serializeUserData(s,L),f.length>0&&(L.targets=f),s.index!==null){let P=this.getUID(s.index);(_[b].start!==void 0||_[b].count!==void 0)&&(P+=":"+_[b].start+":"+_[b].count),t.attributes.has(P)?L.indices=t.attributes.get(P):(L.indices=this.processAccessor(s.index,s,_[b].start,_[b].count),t.attributes.set(P,L.indices)),L.indices===null&&delete L.indices}const M=this.processMaterial(v[_[b].materialIndex]);M!==null&&(L.material=M),p.push(L)}c.primitives=p,n.meshes||(n.meshes=[]),this._invokeAll(function(b){b.writeMesh&&b.writeMesh(e,c)});const A=n.meshes.push(c)-1;return t.meshes.set(r,A),A}detectMeshQuantization(e,t){if(this.extensionsUsed[Yn])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");const o=e.split("_",1)[0];Jo[o]&&Jo[o].includes(n)&&(this.extensionsUsed[Yn]=!0,this.extensionsRequired[Yn]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,o={type:n?"orthographic":"perspective"};return n?o.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:o.perspective={aspectRatio:e.aspect,yfov:l.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(o.name=e.type),t.cameras.push(o)-1}processAnimation(e,t){const n=this.json,o=this.nodeMap;n.animations||(n.animations=[]),e=Wn.Utils.mergeMorphTargetTracks(e.clone(),t);const r=e.tracks,s=[],i=[];for(let c=0;c<r.length;++c){const h=r[c],p=l.PropertyBinding.parseTrackName(h.name);let f=l.PropertyBinding.findNode(t,p.nodeName);const m=Ho[p.propertyName];if(p.objectName==="bones"&&(f.isSkinnedMesh===!0?f=f.skeleton.getBoneByName(p.objectIndex):f=void 0),!f||!m)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name),null;const d=1;let g=h.values.length/h.times.length;m===Ho.morphTargetInfluences&&(g/=f.morphTargetInfluences.length);let y;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",g/=3):h.getInterpolation()===l.InterpolateDiscrete?y="STEP":y="LINEAR",i.push({input:this.processAccessor(new l.BufferAttribute(h.times,d)),output:this.processAccessor(new l.BufferAttribute(h.values,g)),interpolation:y}),s.push({sampler:i.length-1,target:{node:o.get(f),path:m}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:i,channels:s}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,o=t.nodes[n.get(e)],r=e.skeleton;if(r===void 0)return null;const s=e.skeleton.bones[0];if(s===void 0)return null;const i=[],c=new Float32Array(r.bones.length*16),h=new l.Matrix4;for(let f=0;f<r.bones.length;++f)i.push(n.get(r.bones[f])),h.copy(r.boneInverses[f]),h.multiply(e.bindMatrix).toArray(c,f*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new l.BufferAttribute(c,16)),joints:i,skeleton:n.get(s)}),o.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,o=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const i=e.quaternion.toArray(),c=e.position.toArray(),h=e.scale.toArray();Et(i,[0,0,0,1])||(r.rotation=i),Et(c,[0,0,0])||(r.translation=c),Et(h,[1,1,1])||(r.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),aa(e.matrix)===!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 i=this.processMesh(e);i!==null&&(r.mesh=i)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const i=[];for(let c=0,h=e.children.length;c<h;c++){const p=e.children[c];if(p.visible||n.onlyVisible===!1){const f=this.processNode(p);f!==null&&i.push(f)}}i.length>0&&(r.children=i)}this._invokeAll(function(i){i.writeNode&&i.writeNode(e,r)});const s=t.nodes.push(r)-1;return o.set(e,s),s}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const o={};e.name!==""&&(o.name=e.name),t.scenes.push(o);const r=[];for(let s=0,i=e.children.length;s<i;s++){const c=e.children[s];if(c.visible||n.onlyVisible===!1){const h=this.processNode(c);h!==null&&r.push(h)}}r.length>0&&(o.nodes=r),this.serializeUserData(e,o)}processObjects(e){const t=new l.Scene;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(o){o.beforeParse&&o.beforeParse(e)});const n=[];for(let o=0;o<e.length;o++)e[o]instanceof l.Scene?this.processScene(e[o]):n.push(e[o]);n.length>0&&this.processObjects(n);for(let o=0;o<this.skins.length;++o)this.processSkin(this.skins[o]);for(let o=0;o<t.animations.length;++o)this.processAnimation(t.animations[o],e[0]);this._invokeAll(function(o){o.afterParse&&o.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class ua{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const n=this.writer,o=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),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&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]||(o.extensions=o.extensions||{},o.extensions[this.name]={lights:[]},r[this.name]=!0);const i=o.extensions[this.name].lights;i.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:i.length-1}}}let ha=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const o=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},o[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},fa=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const s={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(s,e.clearcoatMap),r.clearcoatTexture=s}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const s={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(s,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=s}if(e.clearcoatNormalMap){const s={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(s,e.clearcoatNormalMap),r.clearcoatNormalTexture=s}t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},da=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const s={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(s,e.iridescenceMap),r.iridescenceTexture=s}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const s={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(s,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=s}t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},pa=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const s={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(s,e.transmissionMap),r.transmissionTexture=s}t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},ma=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const s={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(s,e.thicknessMap),r.thicknessTexture=s}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},ga=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const o=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},ya=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(ta)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,o=n.extensionsUsed,r={};if(e.specularIntensityMap){const s={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(s,e.specularIntensityMap),r.specularTexture=s}if(e.specularColorMap){const s={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(s,e.specularColorMap),r.specularColorTexture=s}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},_a=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,o=n.extensionsUsed,r={};if(e.sheenRoughnessMap){const s={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(s,e.sheenRoughnessMap),r.sheenRoughnessTexture=s}if(e.sheenColorMap){const s={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(s,e.sheenColorMap),r.sheenColorTexture=s}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},va=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,o=n.extensionsUsed,r={};if(e.anisotropyMap){const s={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(s,e.anisotropyMap),r.anisotropyTexture=s}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},xa=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const o=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}};var Ze=Uint8Array,gt=Uint16Array,En=Uint32Array,rr=new Ze([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),sr=new Ze([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wa=new Ze([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ir=function(a,e){for(var t=new gt(31),n=0;n<31;++n)t[n]=e+=1<<a[n-1];for(var o=new En(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)o[r]=r-t[n]<<5|n;return[t,o]},ar=ir(rr,2),lr=ar[0],ba=ar[1];lr[28]=258,ba[258]=28;for(var Ma=ir(sr,0),Sa=Ma[0],Zn=new gt(32768),Ie=0;Ie<32768;++Ie){var yt=(Ie&43690)>>>1|(Ie&21845)<<1;yt=(yt&52428)>>>2|(yt&13107)<<2,yt=(yt&61680)>>>4|(yt&3855)<<4,Zn[Ie]=((yt&65280)>>>8|(yt&255)<<8)>>>1}for(var Zt=function(a,e,t){for(var n=a.length,o=0,r=new gt(e);o<n;++o)++r[a[o]-1];var s=new gt(e);for(o=0;o<e;++o)s[o]=s[o-1]+r[o-1]<<1;var i;if(t){i=new gt(1<<e);var c=15-e;for(o=0;o<n;++o)if(a[o])for(var h=o<<4|a[o],p=e-a[o],f=s[a[o]-1]++<<p,m=f|(1<<p)-1;f<=m;++f)i[Zn[f]>>>c]=h}else for(i=new gt(n),o=0;o<n;++o)a[o]&&(i[o]=Zn[s[a[o]-1]++]>>>15-a[o]);return i},Kt=new Ze(288),Ie=0;Ie<144;++Ie)Kt[Ie]=8;for(var Ie=144;Ie<256;++Ie)Kt[Ie]=9;for(var Ie=256;Ie<280;++Ie)Kt[Ie]=7;for(var Ie=280;Ie<288;++Ie)Kt[Ie]=8;for(var cr=new Ze(32),Ie=0;Ie<32;++Ie)cr[Ie]=5;var Aa=Zt(Kt,9,1),Pa=Zt(cr,5,1),Kn=function(a){for(var e=a[0],t=1;t<a.length;++t)a[t]>e&&(e=a[t]);return e},He=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},qn=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},Ca=function(a){return(a/8|0)+(a&7&&1)},Ta=function(a,e,t){(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof gt?gt:a instanceof En?En:Ze)(t-e);return n.set(a.subarray(e,t)),n},Ia=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new Ze(0);var o=!e||t,r=!t||t.i;t||(t={}),e||(e=new Ze(n*3));var s=function(U){var B=e.length;if(U>B){var R=new Ze(Math.max(B*2,U));R.set(e),e=R}},i=t.f||0,c=t.p||0,h=t.b||0,p=t.l,f=t.d,m=t.m,d=t.n,g=n*8;do{if(!p){t.f=i=He(a,c,1);var y=He(a,c+1,3);if(c+=3,y)if(y==1)p=Aa,f=Pa,m=9,d=5;else if(y==2){var b=He(a,c,31)+257,C=He(a,c+10,15)+4,L=b+He(a,c+5,31)+1;c+=14;for(var M=new Ze(L),P=new Ze(19),w=0;w<C;++w)P[wa[w]]=He(a,c+w*3,7);c+=C*3;for(var S=Kn(P),x=(1<<S)-1,I=Zt(P,S,1),w=0;w<L;){var D=I[He(a,c,x)];c+=D&15;var v=D>>>4;if(v<16)M[w++]=v;else{var z=0,G=0;for(v==16?(G=3+He(a,c,3),c+=2,z=M[w-1]):v==17?(G=3+He(a,c,7),c+=3):v==18&&(G=11+He(a,c,127),c+=7);G--;)M[w++]=z}}var X=M.subarray(0,b),E=M.subarray(b);m=Kn(X),d=Kn(E),p=Zt(X,m,1),f=Zt(E,d,1)}else throw"invalid block type";else{var v=Ca(c)+4,_=a[v-4]|a[v-3]<<8,A=v+_;if(A>n){if(r)throw"unexpected EOF";break}o&&s(h+_),e.set(a.subarray(v,A),h),t.b=h+=_,t.p=c=A*8;continue}if(c>g){if(r)throw"unexpected EOF";break}}o&&s(h+131072);for(var te=(1<<m)-1,q=(1<<d)-1,oe=c;;oe=c){var z=p[qn(a,c)&te],ne=z>>>4;if(c+=z&15,c>g){if(r)throw"unexpected EOF";break}if(!z)throw"invalid length/literal";if(ne<256)e[h++]=ne;else if(ne==256){oe=c,p=null;break}else{var ce=ne-254;if(ne>264){var w=ne-257,le=rr[w];ce=He(a,c,(1<<le)-1)+lr[w],c+=le}var de=f[qn(a,c)&q],k=de>>>4;if(!de)throw"invalid distance";c+=de&15;var E=Sa[k];if(k>3){var le=sr[k];E+=qn(a,c)&(1<<le)-1,c+=le}if(c>g){if(r)throw"unexpected EOF";break}o&&s(h+131072);for(var V=h+ce;h<V;h+=4)e[h]=e[h-E],e[h+1]=e[h+1-E],e[h+2]=e[h+2-E],e[h+3]=e[h+3-E];h=V}}t.l=p,t.p=oe,t.b=h,p&&(i=1,t.m=m,t.d=f,t.n=d)}while(!i);return h==e.length?e:Ta(e,0,h)},Oa=new Ze(0),La=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Da(a,e){return Ia((La(a),a.subarray(2,-4)),e)}var ka=typeof TextDecoder<"u"&&new TextDecoder,Ba=0;try{ka.decode(Oa,{stream:!0}),Ba=1}catch{}var Ua=Object.defineProperty,Na=(a,e,t)=>e in a?Ua(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Fa=(a,e,t)=>(Na(a,e+"",t),t);const ur=class extends l.Mesh{constructor(a,e={}){super(a),this.isReflector=!0,this.type="Reflector",this.camera=new l.PerspectiveCamera;const t=this,n=e.color!==void 0?new l.Color(e.color):new l.Color(8355711),o=e.textureWidth||512,r=e.textureHeight||512,s=e.clipBias||0,i=e.shader||ur.ReflectorShader,c=e.multisample!==void 0?e.multisample:4,h=new l.Plane,p=new l.Vector3,f=new l.Vector3,m=new l.Vector3,d=new l.Matrix4,g=new l.Vector3(0,0,-1),y=new l.Vector4,v=new l.Vector3,_=new l.Vector3,A=new l.Vector4,b=new l.Matrix4,C=this.camera,L=new l.WebGLRenderTarget(o,r,{samples:c,type:l.HalfFloatType}),M=new l.ShaderMaterial({uniforms:l.UniformsUtils.clone(i.uniforms),fragmentShader:i.fragmentShader,vertexShader:i.vertexShader});M.uniforms.tDiffuse.value=L.texture,M.uniforms.color.value=n,M.uniforms.textureMatrix.value=b,this.material=M,this.onBeforeRender=function(P,w,S){if(f.setFromMatrixPosition(t.matrixWorld),m.setFromMatrixPosition(S.matrixWorld),d.extractRotation(t.matrixWorld),p.set(0,0,1),p.applyMatrix4(d),v.subVectors(f,m),v.dot(p)>0)return;v.reflect(p).negate(),v.add(f),d.extractRotation(S.matrixWorld),g.set(0,0,-1),g.applyMatrix4(d),g.add(m),_.subVectors(f,g),_.reflect(p).negate(),_.add(f),C.position.copy(v),C.up.set(0,1,0),C.up.applyMatrix4(d),C.up.reflect(p),C.lookAt(_),C.far=S.far,C.updateMatrixWorld(),C.projectionMatrix.copy(S.projectionMatrix),b.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),b.multiply(C.projectionMatrix),b.multiply(C.matrixWorldInverse),b.multiply(t.matrixWorld),h.setFromNormalAndCoplanarPoint(p,f),h.applyMatrix4(C.matrixWorldInverse),y.set(h.normal.x,h.normal.y,h.normal.z,h.constant);const x=C.projectionMatrix;A.x=(Math.sign(y.x)+x.elements[8])/x.elements[0],A.y=(Math.sign(y.y)+x.elements[9])/x.elements[5],A.z=-1,A.w=(1+x.elements[10])/x.elements[14],y.multiplyScalar(2/y.dot(A)),x.elements[2]=y.x,x.elements[6]=y.y,x.elements[10]=y.z+1-s,x.elements[14]=y.w,t.visible=!1;const I=P.getRenderTarget(),D=P.xr.enabled,z=P.shadowMap.autoUpdate,G=P.toneMapping;let X=!1;"outputColorSpace"in P?X=P.outputColorSpace==="srgb":X=P.outputEncoding===3001,P.xr.enabled=!1,P.shadowMap.autoUpdate=!1,"outputColorSpace"in P?P.outputColorSpace="srgb-linear":P.outputEncoding=3e3,P.toneMapping=l.NoToneMapping,P.setRenderTarget(L),P.state.buffers.depth.setMask(!0),P.autoClear===!1&&P.clear(),P.render(w,C),P.xr.enabled=D,P.shadowMap.autoUpdate=z,P.toneMapping=G,"outputColorSpace"in P?P.outputColorSpace=X?"srgb":"srgb-linear":P.outputEncoding=X?3001:3e3,P.setRenderTarget(I);const E=S.viewport;E!==void 0&&P.state.viewport(E),t.visible=!0},this.getRenderTarget=function(){return L},this.dispose=function(){L.dispose(),t.material.dispose()}}};let Qn=ur;Fa(Qn,"ReflectorShader",{uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:`
|
|
90
|
+
`})),Lt.uniforms.blitTexture.value=a,Lt.defines.IS_SRGB="colorSpace"in a?a.colorSpace==="srgb":a.encoding===3001,Lt.needsUpdate=!0,dn||(dn=new l.Mesh(Rn,Lt),dn.frustrumCulled=!1);const n=new l.PerspectiveCamera,o=new l.Scene;o.add(dn),t||(t=fn=new l.WebGLRenderer({antialias:!1})),t.setSize(Math.min(a.image.width,e),Math.min(a.image.height,e)),t.clear(),t.render(o,n);const r=new l.Texture(t.domElement);return r.minFilter=a.minFilter,r.magFilter=a.magFilter,r.wrapS=a.wrapS,r.wrapT=a.wrapT,r.name=a.name,fn&&(fn.dispose(),fn=null),r}const Jo={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class Wn{constructor(){this.pluginCallbacks=[],this.register(function(e){return new ua(e)}),this.register(function(e){return new ha(e)}),this.register(function(e){return new pa(e)}),this.register(function(e){return new ma(e)}),this.register(function(e){return new ga(e)}),this.register(function(e){return new ya(e)}),this.register(function(e){return new fa(e)}),this.register(function(e){return new da(e)}),this.register(function(e){return new _a(e)}),this.register(function(e){return new va(e)}),this.register(function(e){return new xa(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,o){const r=new ca,s=[];for(let i=0,c=this.pluginCallbacks.length;i<c;i++)s.push(this.pluginCallbacks[i](r));r.setPlugins(s),r.write(e,t,o).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,o,r,t)})}}ea(Wn,"Utils",{insertKeyframe:function(a,e){const n=a.getValueSize(),o=new a.TimeBufferType(a.times.length+1),r=new a.ValueBufferType(a.values.length+n),s=a.createInterpolant(new a.ValueBufferType(n));let i;if(a.times.length===0){o[0]=e;for(let c=0;c<n;c++)r[c]=0;i=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;o[0]=e,o.set(a.times,1),r.set(s.evaluate(e),0),r.set(a.values,n),i=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;o[o.length-1]=e,o.set(a.times,0),r.set(a.values,0),r.set(s.evaluate(e),a.values.length),i=o.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){o.set(a.times.slice(0,c+1),0),o[c+1]=e,o.set(a.times.slice(c+1),c+2),r.set(a.values.slice(0,(c+1)*n),0),r.set(s.evaluate(e),(c+1)*n),r.set(a.values.slice((c+1)*n),(c+2)*n),i=c+1;break}}return a.times=o,a.values=r,i},mergeMorphTargetTracks:function(a,e){const t=[],n={},o=a.tracks;for(let r=0;r<o.length;++r){let s=o[r];const i=l.PropertyBinding.parseTrackName(s.name),c=l.PropertyBinding.findNode(e,i.nodeName);if(i.propertyName!=="morphTargetInfluences"||i.propertyIndex===void 0){t.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(l.InterpolateLinear)}const h=c.morphTargetInfluences.length,p=c.morphTargetDictionary[i.propertyIndex];if(p===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+i.propertyIndex);let f;if(n[c.uuid]===void 0){f=s.clone();const d=new f.ValueBufferType(h*f.times.length);for(let g=0;g<f.times.length;g++)d[g*h+p]=f.values[g];f.name=(i.nodeName||"")+".morphTargetInfluences",f.values=d,n[c.uuid]=f,t.push(f);continue}const m=s.createInterpolant(new s.ValueBufferType(1));f=n[c.uuid];for(let d=0;d<f.times.length;d++)f.values[d*h+p]=m.evaluate(f.times[d]);for(let d=0;d<s.times.length;d++){const g=this.insertKeyframe(f,s.times[d]);f.values[g*h+p]=s.values[d]}}return a.tracks=t,a}});const we={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Yn="KHR_mesh_quantization",Xe={};Xe[l.NearestFilter]=we.NEAREST,Xe[l.NearestMipmapNearestFilter]=we.NEAREST_MIPMAP_NEAREST,Xe[l.NearestMipmapLinearFilter]=we.NEAREST_MIPMAP_LINEAR,Xe[l.LinearFilter]=we.LINEAR,Xe[l.LinearMipmapNearestFilter]=we.LINEAR_MIPMAP_NEAREST,Xe[l.LinearMipmapLinearFilter]=we.LINEAR_MIPMAP_LINEAR,Xe[l.ClampToEdgeWrapping]=we.CLAMP_TO_EDGE,Xe[l.RepeatWrapping]=we.REPEAT,Xe[l.MirroredRepeatWrapping]=we.MIRRORED_REPEAT;const Ho={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},ta=new l.Color,$o=12,na=1179937895,oa=2,er=8,ra=1313821514,sa=5130562;function Et(a,e){return a.length===e.length&&a.every(function(t,n){return t===e[n]})}function ia(a){return new TextEncoder().encode(a).buffer}function aa(a){return Et(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function la(a,e,t){const n={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let o=e;o<e+t;o++)for(let r=0;r<a.itemSize;r++){let s;a.itemSize>4?s=a.array[o*a.itemSize+r]:(r===0?s=a.getX(o):r===1?s=a.getY(o):r===2?s=a.getZ(o):r===3&&(s=a.getW(o)),a.normalized===!0&&(s=l.MathUtils.normalize(s,a.array))),n.min[r]=Math.min(n.min[r],s),n.max[r]=Math.max(n.max[r],s)}return n}function tr(a){return Math.ceil(a/4)*4}function Xn(a,e=0){const t=tr(a.byteLength);if(t!==a.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(a)),e!==0)for(let o=a.byteLength;o<t;o++)n[o]=e;return n.buffer}return a}function nr(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function or(a,e){if(a.toBlob!==void 0)return new Promise(n=>a.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),a.convertToBlob({type:e,quality:t})}class ca{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},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,n={}){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 o=this,r=o.buffers,s=o.json;n=o.options;const i=o.extensionsUsed,c=o.extensionsRequired,h=new Blob(r,{type:"application/octet-stream"}),p=Object.keys(i),f=Object.keys(c);p.length>0&&(s.extensionsUsed=p),f.length>0&&(s.extensionsRequired=f),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=h.size),n.binary===!0?h.arrayBuffer().then(m=>{const d=Xn(m),g=new DataView(new ArrayBuffer(er));g.setUint32(0,d.byteLength,!0),g.setUint32(4,sa,!0);const y=Xn(ia(JSON.stringify(s)),32),v=new DataView(new ArrayBuffer(er));v.setUint32(0,y.byteLength,!0),v.setUint32(4,ra,!0);const _=new ArrayBuffer($o),A=new DataView(_);A.setUint32(0,na,!0),A.setUint32(4,oa,!0);const b=$o+v.byteLength+y.byteLength+g.byteLength+d.byteLength;A.setUint32(8,b,!0),new Blob([_,v,y,g,d],{type:"application/octet-stream"}).arrayBuffer().then(t)}):s.buffers&&s.buffers.length>0?Qo(h).then(m=>{s.buffers[0].uri=m,t(s)}):t(s)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,o=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const s in r.gltfExtensions)t.extensions[s]=r.gltfExtensions[s],o[s]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const o=new Map;o.set(!0,this.uid++),o.set(!1,this.uid++),this.uids.set(e,o)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new l.Vector3;for(let o=0,r=e.count;o<r;o++)if(Math.abs(n.fromBufferAttribute(e,o).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),o=new l.Vector3;for(let r=0,s=n.count;r<s;r++)o.fromBufferAttribute(n,r),o.x===0&&o.y===0&&o.z===0?o.setX(1):o.normalize(),n.setXYZ(r,o.x,o.y,o.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const o={};(t.offset.x!==0||t.offset.y!==0)&&(o.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(o.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(o.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=o,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(d){return("colorSpace"in d?d.colorSpace==="srgb":d.encoding===3001)?function(y){return y<.04045?y*.0773993808:Math.pow(y*.9478672986+.0521327014,2.4)}:function(y){return y}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof l.CompressedTexture&&(e=jn(e)),t instanceof l.CompressedTexture&&(t=jn(t));const o=e?e.image:null,r=t?t.image:null,s=Math.max(o?o.width:0,r?r.width:0),i=Math.max(o?o.height:0,r?r.height:0),c=nr();c.width=s,c.height=i;const h=c.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,s,i);const p=h.getImageData(0,0,s,i);if(o){h.drawImage(o,0,0,s,i);const d=n(e),g=h.getImageData(0,0,s,i).data;for(let y=2;y<g.length;y+=4)p.data[y]=d(g[y]/256)*256}if(r){h.drawImage(r,0,0,s,i);const d=n(t),g=h.getImageData(0,0,s,i).data;for(let y=1;y<g.length;y+=4)p.data[y]=d(g[y]/256)*256}h.putImageData(p,0,0);const m=(e||t).clone();return m.source=new l.Texture(c).source,"colorSpace"in m?m.colorSpace="":m.encoding=3e3,m.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),m}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,o,r){const s=this.json;s.bufferViews||(s.bufferViews=[]);let i;switch(t){case we.BYTE:case we.UNSIGNED_BYTE:i=1;break;case we.SHORT:case we.UNSIGNED_SHORT:i=2;break;default:i=4}const c=tr(o*e.itemSize*i),h=new DataView(new ArrayBuffer(c));let p=0;for(let d=n;d<n+o;d++)for(let g=0;g<e.itemSize;g++){let y;e.itemSize>4?y=e.array[d*e.itemSize+g]:(g===0?y=e.getX(d):g===1?y=e.getY(d):g===2?y=e.getZ(d):g===3&&(y=e.getW(d)),e.normalized===!0&&(y=l.MathUtils.normalize(y,e.array))),t===we.FLOAT?h.setFloat32(p,y,!0):t===we.INT?h.setInt32(p,y,!0):t===we.UNSIGNED_INT?h.setUint32(p,y,!0):t===we.SHORT?h.setInt16(p,y,!0):t===we.UNSIGNED_SHORT?h.setUint16(p,y,!0):t===we.BYTE?h.setInt8(p,y):t===we.UNSIGNED_BYTE&&h.setUint8(p,y),p+=i}const f={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return r!==void 0&&(f.target=r),r===we.ARRAY_BUFFER&&(f.byteStride=e.itemSize*i),this.byteOffset+=c,s.bufferViews.push(f),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),e.arrayBuffer().then(o=>{const r=Xn(o),s={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};return t.byteOffset+=r.byteLength,n.bufferViews.push(s)-1})}processAccessor(e,t,n,o){const r=this.json,s={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let i;if(e.array.constructor===Float32Array)i=we.FLOAT;else if(e.array.constructor===Int32Array)i=we.INT;else if(e.array.constructor===Uint32Array)i=we.UNSIGNED_INT;else if(e.array.constructor===Int16Array)i=we.SHORT;else if(e.array.constructor===Uint16Array)i=we.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)i=we.BYTE;else if(e.array.constructor===Uint8Array)i=we.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),o===void 0&&(o=e.count),o===0)return null;const c=la(e,n,o);let h;t!==void 0&&(h=e===t.index?we.ELEMENT_ARRAY_BUFFER:we.ARRAY_BUFFER);const p=this.processBufferView(e,i,n,o,h),f={bufferView:p.id,byteOffset:p.byteOffset,componentType:i,count:o,max:c.max,min:c.min,type:s[e.itemSize]};return e.normalized===!0&&(f.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(f)-1}processImage(e,t,n,o="image/png"){if(e!==null){const r=this,s=r.cache,i=r.json,c=r.options,h=r.pending;s.images.has(e)||s.images.set(e,{});const p=s.images.get(e),f=o+":flipY/"+n.toString();if(p[f]!==void 0)return p[f];i.images||(i.images=[]);const m={mimeType:o},d=nr();d.width=Math.min(e.width,c.maxTextureSize),d.height=Math.min(e.height,c.maxTextureSize);const g=d.getContext("2d");if(n===!0&&(g.translate(0,d.height),g.scale(1,-1)),e.data!==void 0){t!==l.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const v=new Uint8ClampedArray(e.height*e.width*4);for(let _=0;_<v.length;_+=4)v[_+0]=e.data[_+0],v[_+1]=e.data[_+1],v[_+2]=e.data[_+2],v[_+3]=e.data[_+3];g.putImageData(new ImageData(v,e.width,e.height),0,0)}else g.drawImage(e,0,0,d.width,d.height);c.binary===!0?h.push(or(d,o).then(v=>r.processBufferViewImage(v)).then(v=>{m.bufferView=v})):d.toDataURL!==void 0?m.uri=d.toDataURL(o):h.push(or(d,o).then(Qo).then(v=>{m.uri=v}));const y=i.images.push(m)-1;return p[f]=y,y}else 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:Xe[e.magFilter],minFilter:Xe[e.minFilter],wrapS:Xe[e.wrapS],wrapT:Xe[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,o=this.cache,r=this.json;if(o.textures.has(e))return o.textures.get(e);r.textures||(r.textures=[]),e instanceof l.CompressedTexture&&(e=jn(e,n.maxTextureSize));let s=e.userData.mimeType;s==="image/webp"&&(s="image/png");const i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,s)};e.name&&(i.name=e.name),this._invokeAll(function(h){h.writeTexture&&h.writeTexture(e,i)});const c=r.textures.push(i)-1;return o.textures.set(e,c),c}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 o={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(Et(r,[1,1,1,1])||(o.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(o.pbrMetallicRoughness.metallicFactor=e.metalness,o.pbrMetallicRoughness.roughnessFactor=e.roughness):(o.pbrMetallicRoughness.metallicFactor=.5,o.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const i=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(i),channel:i.channel};this.applyTextureTransform(c,i),o.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const i={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(i,e.map),o.pbrMetallicRoughness.baseColorTexture=i}if(e.emissive){const i=e.emissive;if(Math.max(i.r,i.g,i.b)>0&&(o.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const h={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(h,e.emissiveMap),o.emissiveTexture=h}}if(e.normalMap){const i={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(i.scale=e.normalScale.x),this.applyTextureTransform(i,e.normalMap),o.normalTexture=i}if(e.aoMap){const i={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(i.strength=e.aoMapIntensity),this.applyTextureTransform(i,e.aoMap),o.occlusionTexture=i}e.transparent?o.alphaMode="BLEND":e.alphaTest>0&&(o.alphaMode="MASK",o.alphaCutoff=e.alphaTest),e.side===l.DoubleSide&&(o.doubleSided=!0),e.name!==""&&(o.name=e.name),this.serializeUserData(e,o),this._invokeAll(function(i){i.writeMaterial&&i.writeMaterial(e,o)});const s=n.materials.push(o)-1;return t.materials.set(e,s),s}processMesh(e){const t=this.cache,n=this.json,o=[e.geometry.uuid];if(Array.isArray(e.material))for(let b=0,C=e.material.length;b<C;b++)o.push(e.material[b].uuid);else o.push(e.material.uuid);const r=o.join(":");if(t.meshes.has(r))return t.meshes.get(r);const s=e.geometry;let i;e.isLineSegments?i=we.LINES:e.isLineLoop?i=we.LINE_LOOP:e.isLine?i=we.LINE_STRIP:e.isPoints?i=we.POINTS:i=e.material.wireframe?we.LINES:we.TRIANGLES;const c={},h={},p=[],f=[],m={...Xt>=152?{uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3"}:{uv:"TEXCOORD_0",uv2:"TEXCOORD_1"},color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");d!==void 0&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let g=null;for(let b in s.attributes){if(b.slice(0,5)==="morph")continue;const C=s.attributes[b];if(b=m[b]||b.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(b)||(b="_"+b),t.attributes.has(this.getUID(C))){h[b]=t.attributes.get(this.getUID(C));continue}g=null;const M=C.array;b==="JOINTS_0"&&!(M instanceof Uint16Array)&&!(M instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),g=new l.BufferAttribute(new Uint16Array(M),C.itemSize,C.normalized));const P=this.processAccessor(g||C,s);P!==null&&(b.startsWith("_")||this.detectMeshQuantization(b,C),h[b]=P,t.attributes.set(this.getUID(C),P))}if(d!==void 0&&s.setAttribute("normal",d),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const b=[],C=[],L={};if(e.morphTargetDictionary!==void 0)for(const M in e.morphTargetDictionary)L[e.morphTargetDictionary[M]]=M;for(let M=0;M<e.morphTargetInfluences.length;++M){const P={};let w=!1;for(const S in s.morphAttributes){if(S!=="position"&&S!=="normal"){w||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),w=!0);continue}const x=s.morphAttributes[S][M],I=S.toUpperCase(),D=s.attributes[S];if(t.attributes.has(this.getUID(x,!0))){P[I]=t.attributes.get(this.getUID(x,!0));continue}const z=x.clone();if(!s.morphTargetsRelative)for(let G=0,E=x.count;G<E;G++)for(let X=0;X<x.itemSize;X++)X===0&&z.setX(G,x.getX(G)-D.getX(G)),X===1&&z.setY(G,x.getY(G)-D.getY(G)),X===2&&z.setZ(G,x.getZ(G)-D.getZ(G)),X===3&&z.setW(G,x.getW(G)-D.getW(G));P[I]=this.processAccessor(z,s),t.attributes.set(this.getUID(D,!0),P[I])}f.push(P),b.push(e.morphTargetInfluences[M]),e.morphTargetDictionary!==void 0&&C.push(L[M])}c.weights=b,C.length>0&&(c.extras={},c.extras.targetNames=C)}const y=Array.isArray(e.material);if(y&&s.groups.length===0)return null;const v=y?e.material:[e.material],_=y?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let b=0,C=_.length;b<C;b++){const L={mode:i,attributes:h};if(this.serializeUserData(s,L),f.length>0&&(L.targets=f),s.index!==null){let P=this.getUID(s.index);(_[b].start!==void 0||_[b].count!==void 0)&&(P+=":"+_[b].start+":"+_[b].count),t.attributes.has(P)?L.indices=t.attributes.get(P):(L.indices=this.processAccessor(s.index,s,_[b].start,_[b].count),t.attributes.set(P,L.indices)),L.indices===null&&delete L.indices}const M=this.processMaterial(v[_[b].materialIndex]);M!==null&&(L.material=M),p.push(L)}c.primitives=p,n.meshes||(n.meshes=[]),this._invokeAll(function(b){b.writeMesh&&b.writeMesh(e,c)});const A=n.meshes.push(c)-1;return t.meshes.set(r,A),A}detectMeshQuantization(e,t){if(this.extensionsUsed[Yn])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");const o=e.split("_",1)[0];Jo[o]&&Jo[o].includes(n)&&(this.extensionsUsed[Yn]=!0,this.extensionsRequired[Yn]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,o={type:n?"orthographic":"perspective"};return n?o.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:o.perspective={aspectRatio:e.aspect,yfov:l.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(o.name=e.type),t.cameras.push(o)-1}processAnimation(e,t){const n=this.json,o=this.nodeMap;n.animations||(n.animations=[]),e=Wn.Utils.mergeMorphTargetTracks(e.clone(),t);const r=e.tracks,s=[],i=[];for(let c=0;c<r.length;++c){const h=r[c],p=l.PropertyBinding.parseTrackName(h.name);let f=l.PropertyBinding.findNode(t,p.nodeName);const m=Ho[p.propertyName];if(p.objectName==="bones"&&(f.isSkinnedMesh===!0?f=f.skeleton.getBoneByName(p.objectIndex):f=void 0),!f||!m)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name),null;const d=1;let g=h.values.length/h.times.length;m===Ho.morphTargetInfluences&&(g/=f.morphTargetInfluences.length);let y;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",g/=3):h.getInterpolation()===l.InterpolateDiscrete?y="STEP":y="LINEAR",i.push({input:this.processAccessor(new l.BufferAttribute(h.times,d)),output:this.processAccessor(new l.BufferAttribute(h.values,g)),interpolation:y}),s.push({sampler:i.length-1,target:{node:o.get(f),path:m}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:i,channels:s}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,o=t.nodes[n.get(e)],r=e.skeleton;if(r===void 0)return null;const s=e.skeleton.bones[0];if(s===void 0)return null;const i=[],c=new Float32Array(r.bones.length*16),h=new l.Matrix4;for(let f=0;f<r.bones.length;++f)i.push(n.get(r.bones[f])),h.copy(r.boneInverses[f]),h.multiply(e.bindMatrix).toArray(c,f*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new l.BufferAttribute(c,16)),joints:i,skeleton:n.get(s)}),o.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,o=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const i=e.quaternion.toArray(),c=e.position.toArray(),h=e.scale.toArray();Et(i,[0,0,0,1])||(r.rotation=i),Et(c,[0,0,0])||(r.translation=c),Et(h,[1,1,1])||(r.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),aa(e.matrix)===!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 i=this.processMesh(e);i!==null&&(r.mesh=i)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const i=[];for(let c=0,h=e.children.length;c<h;c++){const p=e.children[c];if(p.visible||n.onlyVisible===!1){const f=this.processNode(p);f!==null&&i.push(f)}}i.length>0&&(r.children=i)}this._invokeAll(function(i){i.writeNode&&i.writeNode(e,r)});const s=t.nodes.push(r)-1;return o.set(e,s),s}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const o={};e.name!==""&&(o.name=e.name),t.scenes.push(o);const r=[];for(let s=0,i=e.children.length;s<i;s++){const c=e.children[s];if(c.visible||n.onlyVisible===!1){const h=this.processNode(c);h!==null&&r.push(h)}}r.length>0&&(o.nodes=r),this.serializeUserData(e,o)}processObjects(e){const t=new l.Scene;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(o){o.beforeParse&&o.beforeParse(e)});const n=[];for(let o=0;o<e.length;o++)e[o]instanceof l.Scene?this.processScene(e[o]):n.push(e[o]);n.length>0&&this.processObjects(n);for(let o=0;o<this.skins.length;++o)this.processSkin(this.skins[o]);for(let o=0;o<t.animations.length;++o)this.processAnimation(t.animations[o],e[0]);this._invokeAll(function(o){o.afterParse&&o.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class ua{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const n=this.writer,o=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),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&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]||(o.extensions=o.extensions||{},o.extensions[this.name]={lights:[]},r[this.name]=!0);const i=o.extensions[this.name].lights;i.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:i.length-1}}}let ha=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const o=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},o[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},fa=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const s={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(s,e.clearcoatMap),r.clearcoatTexture=s}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const s={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(s,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=s}if(e.clearcoatNormalMap){const s={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(s,e.clearcoatNormalMap),r.clearcoatNormalTexture=s}t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},da=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const s={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(s,e.iridescenceMap),r.iridescenceTexture=s}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const s={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(s,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=s}t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},pa=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const s={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(s,e.transmissionMap),r.transmissionTexture=s}t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},ma=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,o=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const s={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(s,e.thicknessMap),r.thicknessTexture=s}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},ga=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const o=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},ya=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(ta)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,o=n.extensionsUsed,r={};if(e.specularIntensityMap){const s={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(s,e.specularIntensityMap),r.specularTexture=s}if(e.specularColorMap){const s={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(s,e.specularColorMap),r.specularColorTexture=s}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},_a=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,o=n.extensionsUsed,r={};if(e.sheenRoughnessMap){const s={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(s,e.sheenRoughnessMap),r.sheenRoughnessTexture=s}if(e.sheenColorMap){const s={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(s,e.sheenColorMap),r.sheenColorTexture=s}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},va=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,o=n.extensionsUsed,r={};if(e.anisotropyMap){const s={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(s,e.anisotropyMap),r.anisotropyTexture=s}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}},xa=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const o=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,o[this.name]=!0}};var Ze=Uint8Array,gt=Uint16Array,En=Uint32Array,rr=new Ze([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),sr=new Ze([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wa=new Ze([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ir=function(a,e){for(var t=new gt(31),n=0;n<31;++n)t[n]=e+=1<<a[n-1];for(var o=new En(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)o[r]=r-t[n]<<5|n;return[t,o]},ar=ir(rr,2),lr=ar[0],ba=ar[1];lr[28]=258,ba[258]=28;for(var Ma=ir(sr,0),Sa=Ma[0],Zn=new gt(32768),Ie=0;Ie<32768;++Ie){var yt=(Ie&43690)>>>1|(Ie&21845)<<1;yt=(yt&52428)>>>2|(yt&13107)<<2,yt=(yt&61680)>>>4|(yt&3855)<<4,Zn[Ie]=((yt&65280)>>>8|(yt&255)<<8)>>>1}for(var Zt=function(a,e,t){for(var n=a.length,o=0,r=new gt(e);o<n;++o)++r[a[o]-1];var s=new gt(e);for(o=0;o<e;++o)s[o]=s[o-1]+r[o-1]<<1;var i;if(t){i=new gt(1<<e);var c=15-e;for(o=0;o<n;++o)if(a[o])for(var h=o<<4|a[o],p=e-a[o],f=s[a[o]-1]++<<p,m=f|(1<<p)-1;f<=m;++f)i[Zn[f]>>>c]=h}else for(i=new gt(n),o=0;o<n;++o)a[o]&&(i[o]=Zn[s[a[o]-1]++]>>>15-a[o]);return i},Kt=new Ze(288),Ie=0;Ie<144;++Ie)Kt[Ie]=8;for(var Ie=144;Ie<256;++Ie)Kt[Ie]=9;for(var Ie=256;Ie<280;++Ie)Kt[Ie]=7;for(var Ie=280;Ie<288;++Ie)Kt[Ie]=8;for(var cr=new Ze(32),Ie=0;Ie<32;++Ie)cr[Ie]=5;var Aa=Zt(Kt,9,1),Pa=Zt(cr,5,1),Kn=function(a){for(var e=a[0],t=1;t<a.length;++t)a[t]>e&&(e=a[t]);return e},He=function(a,e,t){var n=e/8|0;return(a[n]|a[n+1]<<8)>>(e&7)&t},qn=function(a,e){var t=e/8|0;return(a[t]|a[t+1]<<8|a[t+2]<<16)>>(e&7)},Ca=function(a){return(a/8|0)+(a&7&&1)},Ta=function(a,e,t){(t==null||t>a.length)&&(t=a.length);var n=new(a instanceof gt?gt:a instanceof En?En:Ze)(t-e);return n.set(a.subarray(e,t)),n},Ia=function(a,e,t){var n=a.length;if(!n||t&&!t.l&&n<5)return e||new Ze(0);var o=!e||t,r=!t||t.i;t||(t={}),e||(e=new Ze(n*3));var s=function(U){var B=e.length;if(U>B){var R=new Ze(Math.max(B*2,U));R.set(e),e=R}},i=t.f||0,c=t.p||0,h=t.b||0,p=t.l,f=t.d,m=t.m,d=t.n,g=n*8;do{if(!p){t.f=i=He(a,c,1);var y=He(a,c+1,3);if(c+=3,y)if(y==1)p=Aa,f=Pa,m=9,d=5;else if(y==2){var b=He(a,c,31)+257,C=He(a,c+10,15)+4,L=b+He(a,c+5,31)+1;c+=14;for(var M=new Ze(L),P=new Ze(19),w=0;w<C;++w)P[wa[w]]=He(a,c+w*3,7);c+=C*3;for(var S=Kn(P),x=(1<<S)-1,I=Zt(P,S,1),w=0;w<L;){var D=I[He(a,c,x)];c+=D&15;var v=D>>>4;if(v<16)M[w++]=v;else{var z=0,G=0;for(v==16?(G=3+He(a,c,3),c+=2,z=M[w-1]):v==17?(G=3+He(a,c,7),c+=3):v==18&&(G=11+He(a,c,127),c+=7);G--;)M[w++]=z}}var E=M.subarray(0,b),X=M.subarray(b);m=Kn(E),d=Kn(X),p=Zt(E,m,1),f=Zt(X,d,1)}else throw"invalid block type";else{var v=Ca(c)+4,_=a[v-4]|a[v-3]<<8,A=v+_;if(A>n){if(r)throw"unexpected EOF";break}o&&s(h+_),e.set(a.subarray(v,A),h),t.b=h+=_,t.p=c=A*8;continue}if(c>g){if(r)throw"unexpected EOF";break}}o&&s(h+131072);for(var oe=(1<<m)-1,q=(1<<d)-1,ee=c;;ee=c){var z=p[qn(a,c)&oe],te=z>>>4;if(c+=z&15,c>g){if(r)throw"unexpected EOF";break}if(!z)throw"invalid length/literal";if(te<256)e[h++]=te;else if(te==256){ee=c,p=null;break}else{var ce=te-254;if(te>264){var w=te-257,le=rr[w];ce=He(a,c,(1<<le)-1)+lr[w],c+=le}var de=f[qn(a,c)&q],k=de>>>4;if(!de)throw"invalid distance";c+=de&15;var X=Sa[k];if(k>3){var le=sr[k];X+=qn(a,c)&(1<<le)-1,c+=le}if(c>g){if(r)throw"unexpected EOF";break}o&&s(h+131072);for(var V=h+ce;h<V;h+=4)e[h]=e[h-X],e[h+1]=e[h+1-X],e[h+2]=e[h+2-X],e[h+3]=e[h+3-X];h=V}}t.l=p,t.p=ee,t.b=h,p&&(i=1,t.m=m,t.d=f,t.n=d)}while(!i);return h==e.length?e:Ta(e,0,h)},Oa=new Ze(0),La=function(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Da(a,e){return Ia((La(a),a.subarray(2,-4)),e)}var ka=typeof TextDecoder<"u"&&new TextDecoder,Ba=0;try{ka.decode(Oa,{stream:!0}),Ba=1}catch{}var Ua=Object.defineProperty,Na=(a,e,t)=>e in a?Ua(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Fa=(a,e,t)=>(Na(a,e+"",t),t);const ur=class extends l.Mesh{constructor(a,e={}){super(a),this.isReflector=!0,this.type="Reflector",this.camera=new l.PerspectiveCamera;const t=this,n=e.color!==void 0?new l.Color(e.color):new l.Color(8355711),o=e.textureWidth||512,r=e.textureHeight||512,s=e.clipBias||0,i=e.shader||ur.ReflectorShader,c=e.multisample!==void 0?e.multisample:4,h=new l.Plane,p=new l.Vector3,f=new l.Vector3,m=new l.Vector3,d=new l.Matrix4,g=new l.Vector3(0,0,-1),y=new l.Vector4,v=new l.Vector3,_=new l.Vector3,A=new l.Vector4,b=new l.Matrix4,C=this.camera,L=new l.WebGLRenderTarget(o,r,{samples:c,type:l.HalfFloatType}),M=new l.ShaderMaterial({uniforms:l.UniformsUtils.clone(i.uniforms),fragmentShader:i.fragmentShader,vertexShader:i.vertexShader});M.uniforms.tDiffuse.value=L.texture,M.uniforms.color.value=n,M.uniforms.textureMatrix.value=b,this.material=M,this.onBeforeRender=function(P,w,S){if(f.setFromMatrixPosition(t.matrixWorld),m.setFromMatrixPosition(S.matrixWorld),d.extractRotation(t.matrixWorld),p.set(0,0,1),p.applyMatrix4(d),v.subVectors(f,m),v.dot(p)>0)return;v.reflect(p).negate(),v.add(f),d.extractRotation(S.matrixWorld),g.set(0,0,-1),g.applyMatrix4(d),g.add(m),_.subVectors(f,g),_.reflect(p).negate(),_.add(f),C.position.copy(v),C.up.set(0,1,0),C.up.applyMatrix4(d),C.up.reflect(p),C.lookAt(_),C.far=S.far,C.updateMatrixWorld(),C.projectionMatrix.copy(S.projectionMatrix),b.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),b.multiply(C.projectionMatrix),b.multiply(C.matrixWorldInverse),b.multiply(t.matrixWorld),h.setFromNormalAndCoplanarPoint(p,f),h.applyMatrix4(C.matrixWorldInverse),y.set(h.normal.x,h.normal.y,h.normal.z,h.constant);const x=C.projectionMatrix;A.x=(Math.sign(y.x)+x.elements[8])/x.elements[0],A.y=(Math.sign(y.y)+x.elements[9])/x.elements[5],A.z=-1,A.w=(1+x.elements[10])/x.elements[14],y.multiplyScalar(2/y.dot(A)),x.elements[2]=y.x,x.elements[6]=y.y,x.elements[10]=y.z+1-s,x.elements[14]=y.w,t.visible=!1;const I=P.getRenderTarget(),D=P.xr.enabled,z=P.shadowMap.autoUpdate,G=P.toneMapping;let E=!1;"outputColorSpace"in P?E=P.outputColorSpace==="srgb":E=P.outputEncoding===3001,P.xr.enabled=!1,P.shadowMap.autoUpdate=!1,"outputColorSpace"in P?P.outputColorSpace="srgb-linear":P.outputEncoding=3e3,P.toneMapping=l.NoToneMapping,P.setRenderTarget(L),P.state.buffers.depth.setMask(!0),P.autoClear===!1&&P.clear(),P.render(w,C),P.xr.enabled=D,P.shadowMap.autoUpdate=z,P.toneMapping=G,"outputColorSpace"in P?P.outputColorSpace=E?"srgb":"srgb-linear":P.outputEncoding=E?3001:3e3,P.setRenderTarget(I);const X=S.viewport;X!==void 0&&P.state.viewport(X),t.visible=!0},this.getRenderTarget=function(){return L},this.dispose=function(){L.dispose(),t.material.dispose()}}};let Qn=ur;Fa(Qn,"ReflectorShader",{uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:`
|
|
91
91
|
uniform mat4 textureMatrix;
|
|
92
92
|
varying vec4 vUv;
|
|
93
93
|
|
|
@@ -332,7 +332,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
|
|
|
332
332
|
#include <tonemapping_fragment>
|
|
333
333
|
#include <${parseInt(l.REVISION.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
334
334
|
#include <fog_fragment>
|
|
335
|
-
}`},
|
|
335
|
+
}`},E=new l.ShaderMaterial({fragmentShader:G.fragmentShader,vertexShader:G.vertexShader,uniforms:l.UniformsUtils.clone(G.uniforms),lights:!0,side:y,fog:v});E.uniforms.mirrorSampler.value=z.texture,E.uniforms.textureMatrix.value=I,E.uniforms.alpha.value=i,E.uniforms.time.value=c,E.uniforms.normalSampler.value=h,E.uniforms.sunColor.value=f,E.uniforms.waterColor.value=m,E.uniforms.sunDirection.value=p,E.uniforms.distortionScale.value=g,E.uniforms.eye.value=d,n.material=E,n.onBeforeRender=function(X,oe,q){if(b.setFromMatrixPosition(n.matrixWorld),C.setFromMatrixPosition(q.matrixWorld),L.extractRotation(n.matrixWorld),A.set(0,0,1),A.applyMatrix4(L),w.subVectors(b,C),w.dot(A)>0)return;w.reflect(A).negate(),w.add(b),L.extractRotation(q.matrixWorld),M.set(0,0,-1),M.applyMatrix4(L),M.add(C),S.subVectors(b,M),S.reflect(A).negate(),S.add(b),D.position.copy(w),D.up.set(0,1,0),D.up.applyMatrix4(L),D.up.reflect(A),D.lookAt(S),D.far=q.far,D.updateMatrixWorld(),D.projectionMatrix.copy(q.projectionMatrix),I.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),I.multiply(D.projectionMatrix),I.multiply(D.matrixWorldInverse),_.setFromNormalAndCoplanarPoint(A,b),_.applyMatrix4(D.matrixWorldInverse),P.set(_.normal.x,_.normal.y,_.normal.z,_.constant);const ee=D.projectionMatrix;x.x=(Math.sign(P.x)+ee.elements[8])/ee.elements[0],x.y=(Math.sign(P.y)+ee.elements[9])/ee.elements[5],x.z=-1,x.w=(1+ee.elements[10])/ee.elements[14],P.multiplyScalar(2/P.dot(x)),ee.elements[2]=P.x,ee.elements[6]=P.y,ee.elements[10]=P.z+1-s,ee.elements[14]=P.w,d.setFromMatrixPosition(q.matrixWorld);const te=X.getRenderTarget(),ce=X.xr.enabled,le=X.shadowMap.autoUpdate;n.visible=!1,X.xr.enabled=!1,X.shadowMap.autoUpdate=!1,X.setRenderTarget(z),X.state.buffers.depth.setMask(!0),X.autoClear===!1&&X.clear(),X.render(oe,D),n.visible=!0,X.xr.enabled=ce,X.shadowMap.autoUpdate=le,X.setRenderTarget(te);const de=q.viewport;de!==void 0&&X.state.viewport(de)}}}var ja=Object.defineProperty,Wa=(a,e,t)=>e in a?ja(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,mr=(a,e,t)=>(Wa(a,typeof e!="symbol"?e+"":e,t),t);const mn={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new l.Vector3},up:{value:new l.Vector3(0,1,0)}},vertexShader:`
|
|
336
336
|
uniform vec3 sunPosition;
|
|
337
337
|
uniform float rayleigh;
|
|
338
338
|
uniform float turbidity;
|
|
@@ -489,7 +489,7 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
|
|
|
489
489
|
#include <${Xt>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
490
490
|
|
|
491
491
|
}
|
|
492
|
-
`},gr=new l.ShaderMaterial({name:"SkyShader",fragmentShader:mn.fragmentShader,vertexShader:mn.vertexShader,uniforms:l.UniformsUtils.clone(mn.uniforms),side:l.BackSide,depthWrite:!1});class Hn extends l.Mesh{constructor(){super(new l.BoxGeometry(1,1,1),gr)}}mr(Hn,"SkyShader",mn),mr(Hn,"material",gr);const Ue=new l.Triangle,gn=new l.Vector3;class Ya{constructor(e){let t=e.geometry;t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;t&&(s=t.getX(r)+t.getX(r+1)+t.getX(r+2)),Ue.a.fromBufferAttribute(e,r),Ue.b.fromBufferAttribute(e,r+1),Ue.c.fromBufferAttribute(e,r+2),s*=Ue.getArea(),n[r/3]=s}this.distribution=new Float32Array(e.count/3);let o=0;for(let r=0;r<n.length;r++)o+=n[r],this.distribution[r]=o;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,n){const o=this.sampleFaceIndex();return this.sampleFace(o,e,t,n)}sampleFaceIndex(){const e=this.distribution[this.distribution.length-1];return this.binarySearch(this.randomFunction()*e)}binarySearch(e){const t=this.distribution;let n=0,o=t.length-1,r=-1;for(;n<=o;){const s=Math.ceil((n+o)/2);if(s===0||t[s-1]<=e&&t[s]>e){r=s;break}else e<t[s]?o=s-1:n=s+1}return r}sampleFace(e,t,n,o){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Ue.a.fromBufferAttribute(this.positionAttribute,e*3),Ue.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ue.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),n!==void 0&&Ue.getNormal(n),o!==void 0&&this.colorAttribute!==void 0&&(Ue.a.fromBufferAttribute(this.colorAttribute,e*3),Ue.b.fromBufferAttribute(this.colorAttribute,e*3+1),Ue.c.fromBufferAttribute(this.colorAttribute,e*3+2),gn.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),o.r=gn.x,o.g=gn.y,o.b=gn.z),this}}var Xa=Object.defineProperty,Ea=(a,e,t)=>e in a?Xa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,J=(a,e,t)=>(Ea(a,typeof e!="symbol"?e+"":e,t),t);class Za extends l.Object3D{constructor(e,t){super(),J(this,"isTransformControls",!0),J(this,"visible",!1),J(this,"domElement"),J(this,"raycaster",new l.Raycaster),J(this,"gizmo"),J(this,"plane"),J(this,"tempVector",new l.Vector3),J(this,"tempVector2",new l.Vector3),J(this,"tempQuaternion",new l.Quaternion),J(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),J(this,"pointStart",new l.Vector3),J(this,"pointEnd",new l.Vector3),J(this,"offset",new l.Vector3),J(this,"rotationAxis",new l.Vector3),J(this,"startNorm",new l.Vector3),J(this,"endNorm",new l.Vector3),J(this,"rotationAngle",0),J(this,"cameraPosition",new l.Vector3),J(this,"cameraQuaternion",new l.Quaternion),J(this,"cameraScale",new l.Vector3),J(this,"parentPosition",new l.Vector3),J(this,"parentQuaternion",new l.Quaternion),J(this,"parentQuaternionInv",new l.Quaternion),J(this,"parentScale",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldScaleStart",new l.Vector3),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"worldQuaternionInv",new l.Quaternion),J(this,"worldScale",new l.Vector3),J(this,"eye",new l.Vector3),J(this,"positionStart",new l.Vector3),J(this,"quaternionStart",new l.Quaternion),J(this,"scaleStart",new l.Vector3),J(this,"camera"),J(this,"object"),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"translationSnap",null),J(this,"rotationSnap",null),J(this,"scaleSnap",null),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"changeEvent",{type:"change"}),J(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),J(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),J(this,"objectChangeEvent",{type:"objectChange"}),J(this,"intersectObjectWithRay",(o,r,s)=>{const i=r.intersectObject(o,!0);for(let c=0;c<i.length;c++)if(i[c].object.visible||s)return i[c];return!1}),J(this,"attach",o=>(this.object=o,this.visible=!0,this)),J(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),J(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),J(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),J(this,"pointerHover",o=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);r?this.axis=r.object.name:this.axis=null}),J(this,"pointerDown",o=>{if(!(this.object===void 0||this.dragging===!0||o.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(r){let s=this.space;if(this.mode==="scale"?s="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(s="world"),s==="local"&&this.mode==="rotate"){const i=this.rotationSnap;this.axis==="X"&&i&&(this.object.rotation.x=Math.round(this.object.rotation.x/i)*i),this.axis==="Y"&&i&&(this.object.rotation.y=Math.round(this.object.rotation.y/i)*i),this.axis==="Z"&&i&&(this.object.rotation.z=Math.round(this.object.rotation.z/i)*i)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(r.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),J(this,"pointerMove",o=>{const r=this.axis,s=this.mode,i=this.object;let c=this.space;if(s==="scale"?c="local":(r==="E"||r==="XYZE"||r==="XYZ")&&(c="world"),i===void 0||r===null||this.dragging===!1||o.button!==-1)return;this.raycaster.setFromCamera(o,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),s==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="local"&&r!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),r.indexOf("X")===-1&&(this.offset.x=0),r.indexOf("Y")===-1&&(this.offset.y=0),r.indexOf("Z")===-1&&(this.offset.z=0),c==="local"&&r!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),i.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(c==="local"&&(i.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.quaternionStart)),c==="world"&&(i.parent&&i.position.add(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld)),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld))));else if(s==="scale"){if(r.search("XYZ")!==-1){let p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),r.search("X")===-1&&(this.tempVector2.x=1),r.search("Y")===-1&&(this.tempVector2.y=1),r.search("Z")===-1&&(this.tempVector2.z=1);i.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(r.search("X")!==-1&&(this.object.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const p=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));r==="E"?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):r==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*p):(r==="X"||r==="Y"||r==="Z")&&(this.rotationAxis.copy(this.unit[r]),this.tempVector.copy(this.unit[r]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*p),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="local"&&r!=="E"&&r!=="XYZE"?(i.quaternion.copy(this.quaternionStart),i.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),i.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),J(this,"pointerUp",o=>{o.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),J(this,"getPointer",o=>{var r;if(this.domElement&&((r=this.domElement.ownerDocument)!=null&&r.pointerLockElement))return{x:0,y:0,button:o.button};{const s=o.changedTouches?o.changedTouches[0]:o,i=this.domElement.getBoundingClientRect();return{x:(s.clientX-i.left)/i.width*2-1,y:-(s.clientY-i.top)/i.height*2+1,button:o.button}}}),J(this,"onPointerHover",o=>{if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(o));break}}),J(this,"onPointerDown",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(o)),this.pointerDown(this.getPointer(o)))}),J(this,"onPointerMove",o=>{this.enabled&&this.pointerMove(this.getPointer(o))}),J(this,"onPointerUp",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(o)))}),J(this,"getMode",()=>this.mode),J(this,"setMode",o=>{this.mode=o}),J(this,"setTranslationSnap",o=>{this.translationSnap=o}),J(this,"setRotationSnap",o=>{this.rotationSnap=o}),J(this,"setScaleSnap",o=>{this.scaleSnap=o}),J(this,"setSize",o=>{this.size=o}),J(this,"setSpace",o=>{this.space=o}),J(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),J(this,"connect",o=>{o===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=o,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),J(this,"dispose",()=>{var o,r,s,i,c,h;(o=this.domElement)==null||o.removeEventListener("pointerdown",this.onPointerDown),(r=this.domElement)==null||r.removeEventListener("pointermove",this.onPointerHover),(i=(s=this.domElement)==null?void 0:s.ownerDocument)==null||i.removeEventListener("pointermove",this.onPointerMove),(h=(c=this.domElement)==null?void 0:c.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(p=>{const f=p;f.geometry&&f.geometry.dispose(),f.material&&f.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Ka,this.add(this.gizmo),this.plane=new qa,this.add(this.plane);const n=(o,r)=>{let s=r;Object.defineProperty(this,o,{get:function(){return s!==void 0?s:r},set:function(i){s!==i&&(s=i,this.plane[o]=i,this.gizmo[o]=i,this.dispatchEvent({type:o+"-changed",value:i}),this.dispatchEvent(this.changeEvent))}}),this[o]=r,this.plane[o]=r,this.gizmo[o]=r};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class Ka extends l.Object3D{constructor(){super(),J(this,"isTransformControlsGizmo",!0),J(this,"type","TransformControlsGizmo"),J(this,"tempVector",new l.Vector3(0,0,0)),J(this,"tempEuler",new l.Euler),J(this,"alignVector",new l.Vector3(0,1,0)),J(this,"zeroVector",new l.Vector3(0,0,0)),J(this,"lookAtMatrix",new l.Matrix4),J(this,"tempQuaternion",new l.Quaternion),J(this,"tempQuaternion2",new l.Quaternion),J(this,"identityQuaternion",new l.Quaternion),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"gizmo"),J(this,"picker"),J(this,"helper"),J(this,"rotationAxis",new l.Vector3),J(this,"cameraPosition",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"camera",null),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"updateMatrixWorld",()=>{let ne=this.space;this.mode==="scale"&&(ne="local");const ce=ne==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let le=[];le=le.concat(this.picker[this.mode].children),le=le.concat(this.gizmo[this.mode].children),le=le.concat(this.helper[this.mode].children);for(let de=0;de<le.length;de++){const k=le[de];k.visible=!0,k.rotation.set(0,0,0),k.position.copy(this.worldPosition);let V;if(this.camera.isOrthographicCamera?V=(this.camera.top-this.camera.bottom)/this.camera.zoom:V=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),k.scale.set(1,1,1).multiplyScalar(V*this.size/7),k.tag==="helper"){k.visible=!1,k.name==="AXIS"?(k.position.copy(this.worldPositionStart),k.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),k.quaternion.multiply(this.tempQuaternion),k.visible=this.dragging),this.axis==="E"&&(k.visible=!1)):k.name==="START"?(k.position.copy(this.worldPositionStart),k.visible=this.dragging):k.name==="END"?(k.position.copy(this.worldPosition),k.visible=this.dragging):k.name==="DELTA"?(k.position.copy(this.worldPositionStart),k.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),k.scale.copy(this.tempVector),k.visible=this.dragging):(k.quaternion.copy(ce),this.dragging?k.position.copy(this.worldPositionStart):k.position.copy(this.worldPosition),this.axis&&(k.visible=this.axis.search(k.name)!==-1));continue}k.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((k.name==="X"||k.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Y"||k.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Z"||k.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.x*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.y*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.z*=-1:k.tag==="bwd"&&(k.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),k.name.search("E")!==-1&&k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),k.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion))),k.visible=k.visible&&(k.name.indexOf("X")===-1||this.showX),k.visible=k.visible&&(k.name.indexOf("Y")===-1||this.showY),k.visible=k.visible&&(k.name.indexOf("Z")===-1||this.showZ),k.visible=k.visible&&(k.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),k.material.tempOpacity=k.material.tempOpacity||k.material.opacity,k.material.tempColor=k.material.tempColor||k.material.color.clone(),k.material.color.copy(k.material.tempColor),k.material.opacity=k.material.tempOpacity,this.enabled?this.axis&&(k.name===this.axis?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(U){return k.name===U})?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):(k.material.opacity*=.25,k.material.color.lerp(new l.Color(1,1,1),.5))):(k.material.opacity*=.5,k.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const o=e.clone();o.opacity=.33;const r=e.clone();r.color.set(16711680);const s=e.clone();s.color.set(65280);const i=e.clone();i.color.set(255);const c=e.clone();c.opacity=.25;const h=c.clone();h.color.set(16776960);const p=c.clone();p.color.set(65535);const f=c.clone();f.color.set(16711935),e.clone().color.set(16776960);const d=t.clone();d.color.set(16711680);const g=t.clone();g.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const _=t.clone();_.color.set(16711935);const A=t.clone();A.color.set(16776960);const b=t.clone();b.color.set(7895160);const C=A.clone();C.opacity=.25;const L=new l.CylinderGeometry(0,.05,.2,12,1,!1),M=new l.BoxGeometry(.125,.125,.125),P=new l.BufferGeometry;P.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const w=(ne,ce)=>{const le=new l.BufferGeometry,de=[];for(let k=0;k<=64*ce;++k)de.push(0,Math.cos(k/32*Math.PI)*ne,Math.sin(k/32*Math.PI)*ne);return le.setAttribute("position",new l.Float32BufferAttribute(de,3)),le},S=()=>{const ne=new l.BufferGeometry;return ne.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),ne},x={X:[[new l.Mesh(L,r),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(L,r),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(P,d)]],Y:[[new l.Mesh(L,s),[0,1,0],null,null,"fwd"],[new l.Mesh(L,s),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(P,g),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(L,i),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(L,i),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(P,y),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new l.Line(P,A),[.18,.3,0],null,[.125,1,1]],[new l.Line(P,A),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(P,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),f.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(P,_),[.18,0,.3],null,[.125,1,1]],[new l.Line(P,_),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},D={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new l.Line(S(),o),null,null,null,"helper"]],X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={X:[[new l.Line(w(1,.5),d)],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(w(1,.5),g),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),s),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(w(1,.5),y),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(w(1.25,1),C),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(w(1,1),b),null,[0,Math.PI/2,0]]]},G={AXIS:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},X={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},E={X:[[new l.Mesh(M,r),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(P,d),null,null,[.8,1,1]]],Y:[[new l.Mesh(M,s),[0,.8,0]],[new l.Line(P,g),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(M,i),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(P,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(M,h),[.85,.85,0],null,[2,2,.2]],[new l.Line(P,A),[.855,.98,0],null,[.125,1,1]],[new l.Line(P,A),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(M,p),[0,.85,.85],null,[.2,2,2]],[new l.Line(P,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(M,f),[.85,0,.85],null,[2,.2,2]],[new l.Line(P,_),[.855,0,.98],null,[.125,1,1]],[new l.Line(P,_),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,0,1.1]]]},te={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(M,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(M,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(M,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},q={X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},oe=ne=>{const ce=new l.Object3D;for(let le in ne)for(let de=ne[le].length;de--;){const k=ne[le][de][0].clone(),V=ne[le][de][1],U=ne[le][de][2],B=ne[le][de][3],R=ne[le][de][4];k.name=le,k.tag=R,V&&k.position.set(V[0],V[1],V[2]),U&&k.rotation.set(U[0],U[1],U[2]),B&&k.scale.set(B[0],B[1],B[2]),k.updateMatrix();const T=k.geometry.clone();T.applyMatrix4(k.matrix),k.geometry=T,k.renderOrder=1/0,k.position.set(0,0,0),k.rotation.set(0,0,0),k.scale.set(1,1,1),ce.add(k)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=oe(x)),this.add(this.gizmo.rotate=oe(z)),this.add(this.gizmo.scale=oe(E)),this.add(this.picker.translate=oe(I)),this.add(this.picker.rotate=oe(X)),this.add(this.picker.scale=oe(te)),this.add(this.helper.translate=oe(D)),this.add(this.helper.rotate=oe(G)),this.add(this.helper.scale=oe(q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class qa extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),J(this,"isTransformControlsPlane",!0),J(this,"type","TransformControlsPlane"),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"tempVector",new l.Vector3),J(this,"dirVector",new l.Vector3),J(this,"alignVector",new l.Vector3),J(this,"tempMatrix",new l.Matrix4),J(this,"identityQuaternion",new l.Quaternion),J(this,"cameraQuaternion",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var Qa=Object.defineProperty,Ja=(a,e,t)=>e in a?Qa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ke=(a,e,t)=>(Ja(a,typeof e!="symbol"?e+"":e,t),t);const Dt=new l.Euler(0,0,0,"YXZ"),kt=new l.Vector3,Ha={type:"change"},$a={type:"lock"},el={type:"unlock"},yr=Math.PI/2;class _r extends l.EventDispatcher{constructor(e,t){super(),ke(this,"camera"),ke(this,"domElement"),ke(this,"isLocked"),ke(this,"minPolarAngle"),ke(this,"maxPolarAngle"),ke(this,"pointerSpeed"),ke(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const o=n.movementX||n.mozMovementX||n.webkitMovementX||0,r=n.movementY||n.mozMovementY||n.webkitMovementY||0;Dt.setFromQuaternion(this.camera.quaternion),Dt.y-=o*.002*this.pointerSpeed,Dt.x-=r*.002*this.pointerSpeed,Dt.x=Math.max(yr-this.maxPolarAngle,Math.min(yr-this.minPolarAngle,Dt.x)),this.camera.quaternion.setFromEuler(Dt),this.dispatchEvent(Ha)}),ke(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent($a),this.isLocked=!0):(this.dispatchEvent(el),this.isLocked=!1))}),ke(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ke(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"dispose",()=>{this.disconnect()}),ke(this,"getObject",()=>this.camera),ke(this,"direction",new l.Vector3(0,0,-1)),ke(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),ke(this,"moveForward",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),kt.crossVectors(this.camera.up,kt),this.camera.position.addScaledVector(kt,n)}),ke(this,"moveRight",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(kt,n)}),ke(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),ke(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var tl=Object.defineProperty,nl=(a,e,t)=>e in a?tl(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,fe=(a,e,t)=>(nl(a,typeof e!="symbol"?e+"":e,t),t);const yn=new l.Ray,vr=new l.Plane,ol=Math.cos(70*(Math.PI/180)),xr=(a,e)=>(a%e+e)%e;class wr extends l.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new l.Vector3),fe(this,"minDistance",0),fe(this,"maxDistance",1/0),fe(this,"minZoom",0),fe(this,"maxZoom",1/0),fe(this,"minPolarAngle",0),fe(this,"maxPolarAngle",Math.PI),fe(this,"minAzimuthAngle",-1/0),fe(this,"maxAzimuthAngle",1/0),fe(this,"enableDamping",!1),fe(this,"dampingFactor",.05),fe(this,"enableZoom",!0),fe(this,"zoomSpeed",1),fe(this,"enableRotate",!0),fe(this,"rotateSpeed",1),fe(this,"enablePan",!0),fe(this,"panSpeed",1),fe(this,"screenSpacePanning",!0),fe(this,"keyPanSpeed",7),fe(this,"zoomToCursor",!1),fe(this,"autoRotate",!1),fe(this,"autoRotateSpeed",2),fe(this,"reverseOrbit",!1),fe(this,"reverseHorizontalOrbit",!1),fe(this,"reverseVerticalOrbit",!1),fe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),fe(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),fe(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),fe(this,"target0"),fe(this,"position0"),fe(this,"zoom0"),fe(this,"_domElementKeyEvents",null),fe(this,"getPolarAngle"),fe(this,"getAzimuthalAngle"),fe(this,"setPolarAngle"),fe(this,"setAzimuthalAngle"),fe(this,"getDistance"),fe(this,"getZoomScale"),fe(this,"listenToKeyEvents"),fe(this,"stopListenToKeyEvents"),fe(this,"saveState"),fe(this,"reset"),fe(this,"update"),fe(this,"connect"),fe(this,"dispose"),fe(this,"dollyIn"),fe(this,"dollyOut"),fe(this,"getScale"),fe(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.phi;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.phi=ae-ge,n.update()},this.setAzimuthalAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.theta;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.theta=ae-ge,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=Z=>{Z.addEventListener("keydown",st),this._domElementKeyEvents=Z},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",st),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(o),n.update(),c=i.NONE},this.update=(()=>{const Z=new l.Vector3,ae=new l.Vector3(0,1,0),ge=new l.Quaternion().setFromUnitVectors(e.up,ae),Me=ge.clone().invert(),Be=new l.Vector3,ht=new l.Quaternion,bt=2*Math.PI;return function(){const Qs=n.object.position;ge.setFromUnitVectors(e.up,ae),Me.copy(ge).invert(),Z.copy(Qs).sub(n.target),Z.applyQuaternion(ge),p.setFromVector3(Z),n.autoRotate&&c===i.NONE&&G(D()),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let ft=n.minAzimuthAngle,dt=n.maxAzimuthAngle;isFinite(ft)&&isFinite(dt)&&(ft<-Math.PI?ft+=bt:ft>Math.PI&&(ft-=bt),dt<-Math.PI?dt+=bt:dt>Math.PI&&(dt-=bt),ft<=dt?p.theta=Math.max(ft,Math.min(dt,p.theta)):p.theta=p.theta>(ft+dt)/2?Math.max(ft,p.theta):Math.min(dt,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.zoomToCursor&&S||n.object.isOrthographicCamera?p.radius=de(p.radius):p.radius=de(p.radius*m),Z.setFromSpherical(p),Z.applyQuaternion(Me),Qs.copy(n.target).add(Z),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),d.set(0,0,0));let an=!1;if(n.zoomToCursor&&S){let ln=null;if(n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const cn=Z.length();ln=de(cn*m);const Un=cn-ln;n.object.position.addScaledVector(P,Un),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const cn=new l.Vector3(w.x,w.y,0);cn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix(),an=!0;const Un=new l.Vector3(w.x,w.y,0);Un.unproject(n.object),n.object.position.sub(Un).add(cn),n.object.updateMatrixWorld(),ln=Z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;ln!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(ln).add(n.object.position):(yn.origin.copy(n.object.position),yn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(yn.direction))<ol?e.lookAt(n.target):(vr.setFromNormalAndCoplanarPoint(n.object.up,n.target),yn.intersectPlane(vr,n.target))))}else n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera&&(an=m!==1,an&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix()));return m=1,S=!1,an||Be.distanceToSquared(n.object.position)>h||8*(1-ht.dot(n.object.quaternion))>h?(n.dispatchEvent(o),Be.copy(n.object.position),ht.copy(n.object.quaternion),an=!1,!0):!1}})(),this.connect=Z=>{n.domElement=Z,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",sn),n.domElement.addEventListener("pointerdown",_e),n.domElement.addEventListener("pointercancel",Pe),n.domElement.addEventListener("wheel",It)},this.dispose=()=>{var Z,ae,ge,Me,Be,ht;n.domElement&&(n.domElement.style.touchAction="auto"),(Z=n.domElement)==null||Z.removeEventListener("contextmenu",sn),(ae=n.domElement)==null||ae.removeEventListener("pointerdown",_e),(ge=n.domElement)==null||ge.removeEventListener("pointercancel",Pe),(Me=n.domElement)==null||Me.removeEventListener("wheel",It),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",Le),(ht=n.domElement)==null||ht.ownerDocument.removeEventListener("pointerup",Pe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",st)};const n=this,o={type:"change"},r={type:"start"},s={type:"end"},i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let c=i.NONE;const h=1e-6,p=new l.Spherical,f=new l.Spherical;let m=1;const d=new l.Vector3,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector3,w=new l.Vector2;let S=!1;const x=[],I={};function D(){return 2*Math.PI/60/60*n.autoRotateSpeed}function z(){return Math.pow(.95,n.zoomSpeed)}function G(Z){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=Z:f.theta-=Z}function X(Z){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=Z:f.phi-=Z}const E=(()=>{const Z=new l.Vector3;return function(ge,Me){Z.setFromMatrixColumn(Me,0),Z.multiplyScalar(-ge),d.add(Z)}})(),te=(()=>{const Z=new l.Vector3;return function(ge,Me){n.screenSpacePanning===!0?Z.setFromMatrixColumn(Me,1):(Z.setFromMatrixColumn(Me,0),Z.crossVectors(n.object.up,Z)),Z.multiplyScalar(ge),d.add(Z)}})(),q=(()=>{const Z=new l.Vector3;return function(ge,Me){const Be=n.domElement;if(Be&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const ht=n.object.position;Z.copy(ht).sub(n.target);let bt=Z.length();bt*=Math.tan(n.object.fov/2*Math.PI/180),E(2*ge*bt/Be.clientHeight,n.object.matrix),te(2*Me*bt/Be.clientHeight,n.object.matrix)}else Be&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(E(ge*(n.object.right-n.object.left)/n.object.zoom/Be.clientWidth,n.object.matrix),te(Me*(n.object.top-n.object.bottom)/n.object.zoom/Be.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function oe(Z){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?m=Z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ne(Z){oe(m/Z)}function ce(Z){oe(m*Z)}function le(Z){if(!n.zoomToCursor||!n.domElement)return;S=!0;const ae=n.domElement.getBoundingClientRect(),ge=Z.clientX-ae.left,Me=Z.clientY-ae.top,Be=ae.width,ht=ae.height;w.x=ge/Be*2-1,w.y=-(Me/ht)*2+1,P.set(w.x,w.y,1).unproject(n.object).sub(n.object.position).normalize()}function de(Z){return Math.max(n.minDistance,Math.min(n.maxDistance,Z))}function k(Z){g.set(Z.clientX,Z.clientY)}function V(Z){le(Z),C.set(Z.clientX,Z.clientY)}function U(Z){_.set(Z.clientX,Z.clientY)}function B(Z){y.set(Z.clientX,Z.clientY),v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),X(2*Math.PI*v.y/ae.clientHeight)),g.copy(y),n.update()}function R(Z){L.set(Z.clientX,Z.clientY),M.subVectors(L,C),M.y>0?ne(z()):M.y<0&&ce(z()),C.copy(L),n.update()}function T(Z){A.set(Z.clientX,Z.clientY),b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A),n.update()}function O(Z){le(Z),Z.deltaY<0?ce(z()):Z.deltaY>0&&ne(z()),n.update()}function N(Z){let ae=!1;switch(Z.code){case n.keys.UP:q(0,n.keyPanSpeed),ae=!0;break;case n.keys.BOTTOM:q(0,-n.keyPanSpeed),ae=!0;break;case n.keys.LEFT:q(n.keyPanSpeed,0),ae=!0;break;case n.keys.RIGHT:q(-n.keyPanSpeed,0),ae=!0;break}ae&&(Z.preventDefault(),n.update())}function K(){if(x.length==1)g.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);g.set(Z,ae)}}function W(){if(x.length==1)_.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);_.set(Z,ae)}}function Y(){const Z=x[0].pageX-x[1].pageX,ae=x[0].pageY-x[1].pageY,ge=Math.sqrt(Z*Z+ae*ae);C.set(0,ge)}function Q(){n.enableZoom&&Y(),n.enablePan&&W()}function re(){n.enableZoom&&Y(),n.enableRotate&&K()}function se(Z){if(x.length==1)y.set(Z.pageX,Z.pageY);else{const ge=jo(Z),Me=.5*(Z.pageX+ge.x),Be=.5*(Z.pageY+ge.y);y.set(Me,Be)}v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),X(2*Math.PI*v.y/ae.clientHeight)),g.copy(y)}function j(Z){if(x.length==1)A.set(Z.pageX,Z.pageY);else{const ae=jo(Z),ge=.5*(Z.pageX+ae.x),Me=.5*(Z.pageY+ae.y);A.set(ge,Me)}b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A)}function F(Z){const ae=jo(Z),ge=Z.pageX-ae.x,Me=Z.pageY-ae.y,Be=Math.sqrt(ge*ge+Me*Me);L.set(0,Be),M.set(0,Math.pow(L.y/C.y,n.zoomSpeed)),ne(M.y),C.copy(L)}function ie(Z){n.enableZoom&&F(Z),n.enablePan&&j(Z)}function he(Z){n.enableZoom&&F(Z),n.enableRotate&&se(Z)}function _e(Z){var ae,ge;n.enabled!==!1&&(x.length===0&&((ae=n.domElement)==null||ae.ownerDocument.addEventListener("pointermove",Le),(ge=n.domElement)==null||ge.ownerDocument.addEventListener("pointerup",Pe)),kn(Z),Z.pointerType==="touch"?Ee(Z):Je(Z))}function Le(Z){n.enabled!==!1&&(Z.pointerType==="touch"?it(Z):wt(Z))}function Pe(Z){var ae,ge,Me;Ro(Z),x.length===0&&((ae=n.domElement)==null||ae.releasePointerCapture(Z.pointerId),(ge=n.domElement)==null||ge.ownerDocument.removeEventListener("pointermove",Le),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Pe)),n.dispatchEvent(s),c=i.NONE}function Je(Z){let ae;switch(Z.button){case 0:ae=n.mouseButtons.LEFT;break;case 1:ae=n.mouseButtons.MIDDLE;break;case 2:ae=n.mouseButtons.RIGHT;break;default:ae=-1}switch(ae){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;V(Z),c=i.DOLLY;break;case l.MOUSE.ROTATE:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enablePan===!1)return;U(Z),c=i.PAN}else{if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}break;case l.MOUSE.PAN:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}else{if(n.enablePan===!1)return;U(Z),c=i.PAN}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function wt(Z){if(n.enabled!==!1)switch(c){case i.ROTATE:if(n.enableRotate===!1)return;B(Z);break;case i.DOLLY:if(n.enableZoom===!1)return;R(Z);break;case i.PAN:if(n.enablePan===!1)return;T(Z);break}}function It(Z){n.enabled===!1||n.enableZoom===!1||c!==i.NONE&&c!==i.ROTATE||(Z.preventDefault(),n.dispatchEvent(r),O(Z),n.dispatchEvent(s))}function st(Z){n.enabled===!1||n.enablePan===!1||N(Z)}function Ee(Z){switch(Bn(Z),x.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;K(),c=i.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;W(),c=i.TOUCH_PAN;break;default:c=i.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Q(),c=i.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;re(),c=i.TOUCH_DOLLY_ROTATE;break;default:c=i.NONE}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function it(Z){switch(Bn(Z),c){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;se(Z),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;j(Z),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ie(Z),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;he(Z),n.update();break;default:c=i.NONE}}function sn(Z){n.enabled!==!1&&Z.preventDefault()}function kn(Z){x.push(Z)}function Ro(Z){delete I[Z.pointerId];for(let ae=0;ae<x.length;ae++)if(x[ae].pointerId==Z.pointerId){x.splice(ae,1);return}}function Bn(Z){let ae=I[Z.pointerId];ae===void 0&&(ae=new l.Vector2,I[Z.pointerId]=ae),ae.set(Z.pageX,Z.pageY)}function jo(Z){const ae=Z.pointerId===x[0].pointerId?x[1]:x[0];return I[ae.pointerId]}this.dollyIn=(Z=z())=>{ce(Z),n.update()},this.dollyOut=(Z=z())=>{ne(Z),n.update()},this.getScale=()=>m,this.setScale=Z=>{oe(Z),n.update()},this.getZoomScale=()=>z(),t!==void 0&&this.connect(t),this.update()}}class rl extends wr{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}function Bt(a){if(typeof TextDecoder<"u")return new TextDecoder().decode(a);let e="";for(let t=0,n=a.length;t<n;t++)e+=String.fromCharCode(a[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const St="srgb",lt="srgb-linear",br=3001,sl=3e3;class il extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new hl(t)}),this.register(function(t){return new fl(t)}),this.register(function(t){return new wl(t)}),this.register(function(t){return new bl(t)}),this.register(function(t){return new Ml(t)}),this.register(function(t){return new pl(t)}),this.register(function(t){return new ml(t)}),this.register(function(t){return new gl(t)}),this.register(function(t){return new yl(t)}),this.register(function(t){return new ul(t)}),this.register(function(t){return new _l(t)}),this.register(function(t){return new dl(t)}),this.register(function(t){return new xl(t)}),this.register(function(t){return new vl(t)}),this.register(function(t){return new ll(t)}),this.register(function(t){return new Sl(t)}),this.register(function(t){return new Al(t)})}load(e,t,n,o){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=l.LoaderUtils.extractUrlBase(e);s=l.LoaderUtils.resolveURL(h,this.path)}else s=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const i=function(h){o?o(h):console.error(h),r.manager.itemError(e),r.manager.itemEnd(e)},c=new l.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{r.parse(h,s,function(p){t(p),r.manager.itemEnd(e)},i)}catch(p){i(p)}},n,i)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,o){let r;const s={},i={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Bt(new Uint8Array(e.slice(0,4)))===Mr){try{s[ve.KHR_BINARY_GLTF]=new Pl(e)}catch(p){o&&o(p);return}r=JSON.parse(s[ve.KHR_BINARY_GLTF].content)}else r=JSON.parse(Bt(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){o&&o(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Vl(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const p=this.pluginCallbacks[h](c);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[p.name]=p,s[p.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const p=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(p){case ve.KHR_MATERIALS_UNLIT:s[p]=new cl;break;case ve.KHR_DRACO_MESH_COMPRESSION:s[p]=new Cl(r,this.dracoLoader);break;case ve.KHR_TEXTURE_TRANSFORM:s[p]=new Tl;break;case ve.KHR_MESH_QUANTIZATION:s[p]=new Il;break;default:f.indexOf(p)>=0&&i[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}c.setExtensions(s),c.setPlugins(i),c.parse(n,o)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,t,o,r)})}}function al(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const ve={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ll{constructor(e){this.parser=e,this.name=ve.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,o=t.length;n<o;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let o=t.cache.get(n);if(o)return o;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const p=new l.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],lt);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new l.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new l.PointLight(p),h.distance=f;break;case"spot":h=new l.SpotLight(p),h.distance=f,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,ct(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),o=Promise.resolve(h),t.cache.add(n,o),o}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(c){return n._getNodeRef(t.cache,i,c)})}}class cl{constructor(){this.name=ve.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const o=[];e.color=new l.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],lt),e.opacity=s[3]}r.baseColorTexture!==void 0&&o.push(n.assignTexture(e,"map",r.baseColorTexture,St))}return Promise.all(o)}}class ul{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class hl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(i,i)}return Promise.all(r)}}class fl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class dl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class pl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=o.extensions[this.name];if(s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],lt)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,St)),s.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ml{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(i[0],i[1],i[2],lt),Promise.all(r)}}class yl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class _l{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(i[0],i[1],i[2],lt),s.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,St)),Promise.all(r)}}class vl{constructor(e){this.parser=e,this.name=ve.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class xl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class wl{constructor(e){this.parser=e,this.name=ve.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,o=n.textures[e];if(!o.extensions||!o.extensions[this.name])return null;const r=o.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class bl{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ml{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Sl{constructor(e){this.name=ve.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const o=n.extensions[this.name],r=this.parser.getDependency("buffer",o.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(i){const c=o.byteOffset||0,h=o.byteLength||0,p=o.count,f=o.byteStride,m=new Uint8Array(i,c,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(p,f,m,o.mode,o.filter).then(function(d){return d.buffer}):s.ready.then(function(){const d=new ArrayBuffer(p*f);return s.decodeGltfBuffer(new Uint8Array(d),p,f,m,o.mode,o.filter),d})})}else return null}}class Al{constructor(e){this.name=ve.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const o=t.meshes[n.mesh];for(const h of o.primitives)if(h.mode!==Ke.TRIANGLES&&h.mode!==Ke.TRIANGLE_STRIP&&h.mode!==Ke.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=n.extensions[this.name].attributes,i=[],c={};for(const h in s)i.push(this.parser.getDependency("accessor",s[h]).then(p=>(c[h]=p,c[h])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(h=>{const p=h.pop(),f=p.isGroup?p.children:[p],m=h[0].count,d=[];for(const g of f){const y=new l.Matrix4,v=new l.Vector3,_=new l.Quaternion,A=new l.Vector3(1,1,1),b=new l.InstancedMesh(g.geometry,g.material,m);for(let C=0;C<m;C++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,C),c.ROTATION&&_.fromBufferAttribute(c.ROTATION,C),c.SCALE&&A.fromBufferAttribute(c.SCALE,C),b.setMatrixAt(C,y.compose(v,_,A));for(const C in c)if(C==="_COLOR_0"){const L=c[C];b.instanceColor=new l.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else C!=="TRANSLATION"&&C!=="ROTATION"&&C!=="SCALE"&&g.geometry.setAttribute(C,c[C]);l.Object3D.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),d.push(b)}return p.isGroup?(p.clear(),p.add(...d),p):d[0]}))}}const Mr="glTF",qt=12,Sr={JSON:1313821514,BIN:5130562};class Pl{constructor(e){this.name=ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qt);if(this.header={magic:Bt(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-qt,o=new DataView(e,qt);let r=0;for(;r<n;){const s=o.getUint32(r,!0);r+=4;const i=o.getUint32(r,!0);if(r+=4,i===Sr.JSON){const c=new Uint8Array(e,qt+r,s);this.content=Bt(c)}else if(i===Sr.BIN){const c=qt+r;this.body=e.slice(c,c+s)}r+=s}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cl{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ve.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,o=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},c={},h={};for(const p in s){const f=eo[p]||p.toLowerCase();i[f]=s[p]}for(const p in e.attributes){const f=eo[p]||p.toLowerCase();if(s[p]!==void 0){const m=n.accessors[e.attributes[p]],d=Ut[m.componentType];h[f]=d.name,c[f]=m.normalized===!0}}return t.getDependency("bufferView",r).then(function(p){return new Promise(function(f,m){o.decodeDracoFile(p,function(d){for(const g in d.attributes){const y=d.attributes[g],v=c[g];v!==void 0&&(y.normalized=v)}f(d)},i,h,lt,m)})})}}class Tl{constructor(){this.name=ve.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Il{constructor(){this.name=ve.KHR_MESH_QUANTIZATION}}class Ar extends l.Interpolant{constructor(e,t,n,o){super(e,t,n,o)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,o=this.valueSize,r=e*o*3+o;for(let s=0;s!==o;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,o){const r=this.resultBuffer,s=this.sampleValues,i=this.valueSize,c=i*2,h=i*3,p=o-t,f=(n-t)/p,m=f*f,d=m*f,g=e*h,y=g-h,v=-2*d+3*m,_=d-m,A=1-v,b=_-m+f;for(let C=0;C!==i;C++){const L=s[y+C+i],M=s[y+C+c]*p,P=s[g+C+i],w=s[g+C]*p;r[C]=A*L+b*M+v*P+_*w}return r}}const Ol=new l.Quaternion;class Ll extends Ar{interpolate_(e,t,n,o){const r=super.interpolate_(e,t,n,o);return Ol.fromArray(r).normalize().toArray(r),r}}const Ke={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ut={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pr={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},Cr={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},$n={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eo={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Xt>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_t={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Dl={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},to={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kl(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),a.DefaultMaterial}function At(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ct(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Bl(a,e,t){let n=!1,o=!1,r=!1;for(let h=0,p=e.length;h<p;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(o=!0),f.COLOR_0!==void 0&&(r=!0),n&&o&&r)break}if(!n&&!o&&!r)return Promise.resolve(a);const s=[],i=[],c=[];for(let h=0,p=e.length;h<p;h++){const f=e[h];if(n){const m=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):a.attributes.position;s.push(m)}if(o){const m=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):a.attributes.normal;i.push(m)}if(r){const m=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):a.attributes.color;c.push(m)}}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c)]).then(function(h){const p=h[0],f=h[1],m=h[2];return n&&(a.morphAttributes.position=p),o&&(a.morphAttributes.normal=f),r&&(a.morphAttributes.color=m),a.morphTargetsRelative=!0,a})}function Ul(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let n=0,o=t.length;n<o;n++)a.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Nl(a){let e;const t=a.extensions&&a.extensions[ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+no(t.attributes):e=a.indices+":"+no(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,o=a.targets.length;n<o;n++)e+=":"+no(a.targets[n]);return e}function no(a){let e="";const t=Object.keys(a).sort();for(let n=0,o=t.length;n<o;n++)e+=t[n]+":"+a[t[n]]+";";return e}function oo(a){switch(a){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Fl(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const zl=new l.Matrix4;class Vl{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new al,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,o=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,o=navigator.userAgent.indexOf("Firefox")>-1,r=o?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||o&&r<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,o=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){const i={scene:s[0][o.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:o.asset,parser:n,userData:{}};return At(r,i,o),ct(i,o),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(i)})).then(function(){for(const c of i.scenes)c.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let o=0,r=t.length;o<r;o++){const s=t[o].joints;for(let i=0,c=s.length;i<c;i++)e[s[i]].isBone=!0}for(let o=0,r=e.length;o<r;o++){const s=e[o];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(n[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const o=n.clone(),r=(s,i)=>{const c=this.associations.get(s);c!=null&&this.associations.set(i,c);for(const[h,p]of s.children.entries())r(p,i.children[h])};return r(n,o),o.name+="_instance_"+e.uses[t]++,o}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const o=e(t[n]);if(o)return o}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let o=this.cache.get(n);if(!o){switch(e){case"scene":o=this.loadScene(t);break;case"node":o=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":o=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":o=this.loadAccessor(t);break;case"bufferView":o=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":o=this.loadBuffer(t);break;case"material":o=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":o=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":o=this.loadSkin(t);break;case"animation":o=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":o=this.loadCamera(t);break;default:if(o=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!o)throw new Error("Unknown type: "+e);break}this.cache.add(n,o)}return o}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,o=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(o.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ve.KHR_BINARY_GLTF].body);const o=this.options;return new Promise(function(r,s){n.load(l.LoaderUtils.resolveURL(t.uri,o.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const o=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+o)})}loadAccessor(e){const t=this,n=this.json,o=this.json.accessors[e];if(o.bufferView===void 0&&o.sparse===void 0){const s=$n[o.type],i=Ut[o.componentType],c=o.normalized===!0,h=new i(o.count*s);return Promise.resolve(new l.BufferAttribute(h,s,c))}const r=[];return o.bufferView!==void 0?r.push(this.getDependency("bufferView",o.bufferView)):r.push(null),o.sparse!==void 0&&(r.push(this.getDependency("bufferView",o.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",o.sparse.values.bufferView))),Promise.all(r).then(function(s){const i=s[0],c=$n[o.type],h=Ut[o.componentType],p=h.BYTES_PER_ELEMENT,f=p*c,m=o.byteOffset||0,d=o.bufferView!==void 0?n.bufferViews[o.bufferView].byteStride:void 0,g=o.normalized===!0;let y,v;if(d&&d!==f){const _=Math.floor(m/d),A="InterleavedBuffer:"+o.bufferView+":"+o.componentType+":"+_+":"+o.count;let b=t.cache.get(A);b||(y=new h(i,_*d,o.count*d/p),b=new l.InterleavedBuffer(y,d/p),t.cache.add(A,b)),v=new l.InterleavedBufferAttribute(b,c,m%d/p,g)}else i===null?y=new h(o.count*c):y=new h(i,m,o.count*c),v=new l.BufferAttribute(y,c,g);if(o.sparse!==void 0){const _=$n.SCALAR,A=Ut[o.sparse.indices.componentType],b=o.sparse.indices.byteOffset||0,C=o.sparse.values.byteOffset||0,L=new A(s[1],b,o.sparse.count*_),M=new h(s[2],C,o.sparse.count*c);i!==null&&(v=new l.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let P=0,w=L.length;P<w;P++){const S=L[P];if(v.setX(S,M[P*c]),c>=2&&v.setY(S,M[P*c+1]),c>=3&&v.setZ(S,M[P*c+2]),c>=4&&v.setW(S,M[P*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r];let i=this.textureLoader;if(s.uri){const c=n.manager.getHandler(s.uri);c!==null&&(i=c)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const o=this,r=this.json,s=r.textures[e],i=r.images[t],c=(i.uri||i.bufferView)+":"+s.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,n).then(function(p){p.flipY=!1,p.name=s.name||i.name||"",p.name===""&&typeof i.uri=="string"&&i.uri.startsWith("data:image/")===!1&&(p.name=i.uri);const m=(r.samplers||{})[s.sampler]||{};return p.magFilter=Pr[m.magFilter]||l.LinearFilter,p.minFilter=Pr[m.minFilter]||l.LinearMipmapLinearFilter,p.wrapS=Cr[m.wrapS]||l.RepeatWrapping,p.wrapT=Cr[m.wrapT]||l.RepeatWrapping,o.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const n=this,o=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const s=o.images[e],i=self.URL||self.webkitURL;let c=s.uri||"",h=!1;if(s.bufferView!==void 0)c=n.getDependency("bufferView",s.bufferView).then(function(f){h=!0;const m=new Blob([f],{type:s.mimeType});return c=i.createObjectURL(m),c});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(f){return new Promise(function(m,d){let g=m;t.isImageBitmapLoader===!0&&(g=function(y){const v=new l.Texture(y);v.needsUpdate=!0,m(v)}),t.load(l.LoaderUtils.resolveURL(f,r.path),g,void 0,d)})}).then(function(f){return h===!0&&i.revokeObjectURL(c),ct(f,s),f.userData.mimeType=s.mimeType||Fl(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=p,p}assignTexture(e,t,n,o){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(s=s.clone(),s.channel=n.texCoord),r.extensions[ve.KHR_TEXTURE_TRANSFORM]){const i=n.extensions!==void 0?n.extensions[ve.KHR_TEXTURE_TRANSFORM]:void 0;if(i){const c=r.associations.get(s);s=r.extensions[ve.KHR_TEXTURE_TRANSFORM].extendTexture(s,i),r.associations.set(s,c)}}return o!==void 0&&(typeof o=="number"&&(o=o===br?St:lt),"colorSpace"in s?s.colorSpace=o:s.encoding=o===St?br:sl),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const o=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const i="PointsMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.PointsMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(i,c)),n=c}else if(e.isLine){const i="LineBasicMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.LineBasicMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(i,c)),n=c}if(o||r||s){let i="ClonedMaterial:"+n.uuid+":";o&&(i+="derivative-tangents:"),r&&(i+="vertex-colors:"),s&&(i+="flat-shading:");let c=this.cache.get(i);c||(c=n.clone(),r&&(c.vertexColors=!0),s&&(c.flatShading=!0),o&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(i,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,o=this.extensions,r=n.materials[e];let s;const i={},c=r.extensions||{},h=[];if(c[ve.KHR_MATERIALS_UNLIT]){const f=o[ve.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),h.push(f.extendParams(i,r,t))}else{const f=r.pbrMetallicRoughness||{};if(i.color=new l.Color(1,1,1),i.opacity=1,Array.isArray(f.baseColorFactor)){const m=f.baseColorFactor;i.color.setRGB(m[0],m[1],m[2],lt),i.opacity=m[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(i,"map",f.baseColorTexture,St)),i.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,i.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(i,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(i,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,i)})))}r.doubleSided===!0&&(i.side=l.DoubleSide);const p=r.alphaMode||to.OPAQUE;if(p===to.BLEND?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,p===to.MASK&&(i.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"normalMap",r.normalTexture)),i.normalScale=new l.Vector2(1,1),r.normalTexture.scale!==void 0)){const f=r.normalTexture.scale;i.normalScale.set(f,f)}if(r.occlusionTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(i.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==l.MeshBasicMaterial){const f=r.emissiveFactor;i.emissive=new l.Color().setRGB(f[0],f[1],f[2],lt)}return r.emissiveTexture!==void 0&&s!==l.MeshBasicMaterial&&h.push(t.assignTexture(i,"emissiveMap",r.emissiveTexture,St)),Promise.all(h).then(function(){const f=new s(i);return r.name&&(f.name=r.name),ct(f,r),t.associations.set(f,{materials:e}),r.extensions&&At(o,f,r),f})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,o=this.primitiveCache;function r(i){return n[ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(i,t).then(function(c){return Tr(c,i,t)})}const s=[];for(let i=0,c=e.length;i<c;i++){const h=e[i],p=Nl(h),f=o[p];if(f)s.push(f.promise);else{let m;h.extensions&&h.extensions[ve.KHR_DRACO_MESH_COMPRESSION]?m=r(h):m=Tr(new l.BufferGeometry,h,t),o[p]={primitive:h,promise:m},s.push(m)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,o=this.extensions,r=n.meshes[e],s=r.primitives,i=[];for(let c=0,h=s.length;c<h;c++){const p=s[c].material===void 0?kl(this.cache):this.getDependency("material",s[c].material);i.push(p)}return i.push(t.loadGeometries(s)),Promise.all(i).then(function(c){const h=c.slice(0,c.length-1),p=c[c.length-1],f=[];for(let d=0,g=p.length;d<g;d++){const y=p[d],v=s[d];let _;const A=h[d];if(v.mode===Ke.TRIANGLES||v.mode===Ke.TRIANGLE_STRIP||v.mode===Ke.TRIANGLE_FAN||v.mode===void 0)_=r.isSkinnedMesh===!0?new l.SkinnedMesh(y,A):new l.Mesh(y,A),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),v.mode===Ke.TRIANGLE_STRIP?_.geometry=qo(_.geometry,l.TriangleStripDrawMode):v.mode===Ke.TRIANGLE_FAN&&(_.geometry=qo(_.geometry,l.TriangleFanDrawMode));else if(v.mode===Ke.LINES)_=new l.LineSegments(y,A);else if(v.mode===Ke.LINE_STRIP)_=new l.Line(y,A);else if(v.mode===Ke.LINE_LOOP)_=new l.LineLoop(y,A);else if(v.mode===Ke.POINTS)_=new l.Points(y,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(_.geometry.morphAttributes).length>0&&Ul(_,r),_.name=t.createUniqueName(r.name||"mesh_"+e),ct(_,r),v.extensions&&At(o,_,v),t.assignFinalMaterial(_),f.push(_)}for(let d=0,g=f.length;d<g;d++)t.associations.set(f[d],{meshes:e,primitives:d});if(f.length===1)return r.extensions&&At(o,f[0],r),f[0];const m=new l.Group;r.extensions&&At(o,m,r),t.associations.set(m,{meshes:e});for(let d=0,g=f.length;d<g;d++)m.add(f[d]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],o=n[n.type];if(!o){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(o.yfov),o.aspectRatio||1,o.znear||1,o.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-o.xmag,o.xmag,o.ymag,-o.ymag,o.znear,o.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ct(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let o=0,r=t.joints.length;o<r;o++)n.push(this._loadNodeShallow(t.joints[o]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(o){const r=o.pop(),s=o,i=[],c=[];for(let h=0,p=s.length;h<p;h++){const f=s[h];if(f){i.push(f);const m=new l.Matrix4;r!==null&&m.fromArray(r.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new l.Skeleton(i,c)})}loadAnimation(e){const t=this.json,n=this,o=t.animations[e],r=o.name?o.name:"animation_"+e,s=[],i=[],c=[],h=[],p=[];for(let f=0,m=o.channels.length;f<m;f++){const d=o.channels[f],g=o.samplers[d.sampler],y=d.target,v=y.node,_=o.parameters!==void 0?o.parameters[g.input]:g.input,A=o.parameters!==void 0?o.parameters[g.output]:g.output;y.node!==void 0&&(s.push(this.getDependency("node",v)),i.push(this.getDependency("accessor",_)),c.push(this.getDependency("accessor",A)),h.push(g),p.push(y))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c),Promise.all(h),Promise.all(p)]).then(function(f){const m=f[0],d=f[1],g=f[2],y=f[3],v=f[4],_=[];for(let A=0,b=m.length;A<b;A++){const C=m[A],L=d[A],M=g[A],P=y[A],w=v[A];if(C===void 0)continue;C.updateMatrix&&C.updateMatrix();const S=n._createAnimationTracks(C,L,M,P,w);if(S)for(let x=0;x<S.length;x++)_.push(S[x])}return new l.AnimationClip(r,void 0,_)})}createNodeMesh(e){const t=this.json,n=this,o=t.nodes[e];return o.mesh===void 0?null:n.getDependency("mesh",o.mesh).then(function(r){const s=n._getNodeRef(n.meshCache,o.mesh,r);return o.weights!==void 0&&s.traverse(function(i){if(i.isMesh)for(let c=0,h=o.weights.length;c<h;c++)i.morphTargetInfluences[c]=o.weights[c]}),s})}loadNode(e){const t=this.json,n=this,o=t.nodes[e],r=n._loadNodeShallow(e),s=[],i=o.children||[];for(let h=0,p=i.length;h<p;h++)s.push(n.getDependency("node",i[h]));const c=o.skin===void 0?Promise.resolve(null):n.getDependency("skin",o.skin);return Promise.all([r,Promise.all(s),c]).then(function(h){const p=h[0],f=h[1],m=h[2];m!==null&&p.traverse(function(d){d.isSkinnedMesh&&d.bind(m,zl)});for(let d=0,g=f.length;d<g;d++)p.add(f[d]);return p})}_loadNodeShallow(e){const t=this.json,n=this.extensions,o=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],s=r.name?o.createUniqueName(r.name):"",i=[],c=o._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&i.push(c),r.camera!==void 0&&i.push(o.getDependency("camera",r.camera).then(function(h){return o._getNodeRef(o.cameraCache,r.camera,h)})),o._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){i.push(h)}),this.nodeCache[e]=Promise.all(i).then(function(h){let p;if(r.isBone===!0?p=new l.Bone:h.length>1?p=new l.Group:h.length===1?p=h[0]:p=new l.Object3D,p!==h[0])for(let f=0,m=h.length;f<m;f++)p.add(h[f]);if(r.name&&(p.userData.name=r.name,p.name=s),ct(p,r),r.extensions&&At(n,p,r),r.matrix!==void 0){const f=new l.Matrix4;f.fromArray(r.matrix),p.applyMatrix4(f)}else r.translation!==void 0&&p.position.fromArray(r.translation),r.rotation!==void 0&&p.quaternion.fromArray(r.rotation),r.scale!==void 0&&p.scale.fromArray(r.scale);return o.associations.has(p)||o.associations.set(p,{}),o.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],o=this,r=new l.Group;n.name&&(r.name=o.createUniqueName(n.name)),ct(r,n),n.extensions&&At(t,r,n);const s=n.nodes||[],i=[];for(let c=0,h=s.length;c<h;c++)i.push(o.getDependency("node",s[c]));return Promise.all(i).then(function(c){for(let p=0,f=c.length;p<f;p++)r.add(c[p]);const h=p=>{const f=new Map;for(const[m,d]of o.associations)(m instanceof l.Material||m instanceof l.Texture)&&f.set(m,d);return p.traverse(m=>{const d=o.associations.get(m);d!=null&&f.set(m,d)}),f};return o.associations=h(r),r})}_createAnimationTracks(e,t,n,o,r){const s=[],i=e.name?e.name:e.uuid,c=[];_t[r.path]===_t.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(i);let h;switch(_t[r.path]){case _t.weights:h=l.NumberKeyframeTrack;break;case _t.rotation:h=l.QuaternionKeyframeTrack;break;case _t.position:case _t.scale:h=l.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=l.NumberKeyframeTrack;break;case 2:case 3:default:h=l.VectorKeyframeTrack;break}break}const p=o.interpolation!==void 0?Dl[o.interpolation]:l.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let m=0,d=c.length;m<d;m++){const g=new h(c[m]+"."+_t[r.path],t.array,f,p);o.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=oo(t.constructor),o=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)o[r]=t[r]*n;t=o}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const o=this instanceof l.QuaternionKeyframeTrack?Ll:Ar;return new o(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Gl(a,e,t){const n=e.attributes,o=new l.Box3;if(n.POSITION!==void 0){const i=t.json.accessors[n.POSITION],c=i.min,h=i.max;if(c!==void 0&&h!==void 0){if(o.set(new l.Vector3(c[0],c[1],c[2]),new l.Vector3(h[0],h[1],h[2])),i.normalized){const p=oo(Ut[i.componentType]);o.min.multiplyScalar(p),o.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const i=new l.Vector3,c=new l.Vector3;for(let h=0,p=r.length;h<p;h++){const f=r[h];if(f.POSITION!==void 0){const m=t.json.accessors[f.POSITION],d=m.min,g=m.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),m.normalized){const y=oo(Ut[m.componentType]);c.multiplyScalar(y)}i.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(i)}a.boundingBox=o;const s=new l.Sphere;o.getCenter(s.center),s.radius=o.min.distanceTo(o.max)/2,a.boundingSphere=s}function Tr(a,e,t){const n=e.attributes,o=[];function r(s,i){return t.getDependency("accessor",s).then(function(c){a.setAttribute(i,c)})}for(const s in n){const i=eo[s]||s.toLowerCase();i in a.attributes||o.push(r(n[s],i))}if(e.indices!==void 0&&!a.index){const s=t.getDependency("accessor",e.indices).then(function(i){a.setIndex(i)});o.push(s)}return ct(a,e),Gl(a,e,t),Promise.all(o).then(function(){return e.targets!==void 0?Bl(a,e.targets,t):a})}const Qt=new l.Vector3;function qe(a,e,t,n,o,r){const s=2*Math.PI*o/4,i=Math.max(r-2*o,0),c=Math.PI/4;Qt.copy(e),Qt[n]=0,Qt.normalize();const h=.5*s/(s+i),p=1-Qt.angleTo(a)/c;return Math.sign(Qt[t])===1?p*h:i/(s+i)+h+h*(1-p)}class Rl extends l.BoxGeometry{constructor(e=1,t=1,n=1,o=2,r=.1){if(o=o*2+1,r=Math.min(e/2,t/2,n/2,r),super(1,1,1,o,o,o),o===1)return;const s=this.toNonIndexed();this.index=null,this.attributes.position=s.attributes.position,this.attributes.normal=s.attributes.normal,this.attributes.uv=s.attributes.uv;const i=new l.Vector3,c=new l.Vector3,h=new l.Vector3(e,t,n).divideScalar(2).subScalar(r),p=this.attributes.position.array,f=this.attributes.normal.array,m=this.attributes.uv.array,d=p.length/6,g=new l.Vector3,y=.5/o;for(let v=0,_=0;v<p.length;v+=3,_+=2)switch(i.fromArray(p,v),c.copy(i),c.x-=Math.sign(c.x)*y,c.y-=Math.sign(c.y)*y,c.z-=Math.sign(c.z)*y,c.normalize(),p[v+0]=h.x*Math.sign(i.x)+c.x*r,p[v+1]=h.y*Math.sign(i.y)+c.y*r,p[v+2]=h.z*Math.sign(i.z)+c.z*r,f[v+0]=c.x,f[v+1]=c.y,f[v+2]=c.z,Math.floor(v/d)){case 0:g.set(1,0,0),m[_+0]=qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 1:g.set(-1,0,0),m[_+0]=1-qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 2:g.set(0,1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=qe(g,c,"z","x",r,n);break;case 3:g.set(0,-1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=1-qe(g,c,"z","x",r,n);break;case 4:g.set(0,0,1),m[_+0]=1-qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break;case 5:g.set(0,0,-1),m[_+0]=qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break}}}class Ir extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:o=8,bevelThickness:r=10,font:s,height:i=50,size:c=100,lineHeight:h=1,letterSpacing:p=0,...f}=t;if(s===void 0)super();else{const m=s.generateShapes(e,c,{lineHeight:h,letterSpacing:p});super(m,{...f,bevelEnabled:n,bevelSize:o,bevelThickness:r,depth:i})}this.type="TextGeometry"}}const jl={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
492
|
+
`},gr=new l.ShaderMaterial({name:"SkyShader",fragmentShader:mn.fragmentShader,vertexShader:mn.vertexShader,uniforms:l.UniformsUtils.clone(mn.uniforms),side:l.BackSide,depthWrite:!1});class Hn extends l.Mesh{constructor(){super(new l.BoxGeometry(1,1,1),gr)}}mr(Hn,"SkyShader",mn),mr(Hn,"material",gr);const Ue=new l.Triangle,gn=new l.Vector3;class Ya{constructor(e){let t=e.geometry;t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let s=1;t&&(s=t.getX(r)+t.getX(r+1)+t.getX(r+2)),Ue.a.fromBufferAttribute(e,r),Ue.b.fromBufferAttribute(e,r+1),Ue.c.fromBufferAttribute(e,r+2),s*=Ue.getArea(),n[r/3]=s}this.distribution=new Float32Array(e.count/3);let o=0;for(let r=0;r<n.length;r++)o+=n[r],this.distribution[r]=o;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,n){const o=this.sampleFaceIndex();return this.sampleFace(o,e,t,n)}sampleFaceIndex(){const e=this.distribution[this.distribution.length-1];return this.binarySearch(this.randomFunction()*e)}binarySearch(e){const t=this.distribution;let n=0,o=t.length-1,r=-1;for(;n<=o;){const s=Math.ceil((n+o)/2);if(s===0||t[s-1]<=e&&t[s]>e){r=s;break}else e<t[s]?o=s-1:n=s+1}return r}sampleFace(e,t,n,o){let r=this.randomFunction(),s=this.randomFunction();return r+s>1&&(r=1-r,s=1-s),Ue.a.fromBufferAttribute(this.positionAttribute,e*3),Ue.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ue.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),n!==void 0&&Ue.getNormal(n),o!==void 0&&this.colorAttribute!==void 0&&(Ue.a.fromBufferAttribute(this.colorAttribute,e*3),Ue.b.fromBufferAttribute(this.colorAttribute,e*3+1),Ue.c.fromBufferAttribute(this.colorAttribute,e*3+2),gn.set(0,0,0).addScaledVector(Ue.a,r).addScaledVector(Ue.b,s).addScaledVector(Ue.c,1-(r+s)),o.r=gn.x,o.g=gn.y,o.b=gn.z),this}}var Xa=Object.defineProperty,Ea=(a,e,t)=>e in a?Xa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,J=(a,e,t)=>(Ea(a,typeof e!="symbol"?e+"":e,t),t);class Za extends l.Object3D{constructor(e,t){super(),J(this,"isTransformControls",!0),J(this,"visible",!1),J(this,"domElement"),J(this,"raycaster",new l.Raycaster),J(this,"gizmo"),J(this,"plane"),J(this,"tempVector",new l.Vector3),J(this,"tempVector2",new l.Vector3),J(this,"tempQuaternion",new l.Quaternion),J(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),J(this,"pointStart",new l.Vector3),J(this,"pointEnd",new l.Vector3),J(this,"offset",new l.Vector3),J(this,"rotationAxis",new l.Vector3),J(this,"startNorm",new l.Vector3),J(this,"endNorm",new l.Vector3),J(this,"rotationAngle",0),J(this,"cameraPosition",new l.Vector3),J(this,"cameraQuaternion",new l.Quaternion),J(this,"cameraScale",new l.Vector3),J(this,"parentPosition",new l.Vector3),J(this,"parentQuaternion",new l.Quaternion),J(this,"parentQuaternionInv",new l.Quaternion),J(this,"parentScale",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldScaleStart",new l.Vector3),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"worldQuaternionInv",new l.Quaternion),J(this,"worldScale",new l.Vector3),J(this,"eye",new l.Vector3),J(this,"positionStart",new l.Vector3),J(this,"quaternionStart",new l.Quaternion),J(this,"scaleStart",new l.Vector3),J(this,"camera"),J(this,"object"),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"translationSnap",null),J(this,"rotationSnap",null),J(this,"scaleSnap",null),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"changeEvent",{type:"change"}),J(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),J(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),J(this,"objectChangeEvent",{type:"objectChange"}),J(this,"intersectObjectWithRay",(o,r,s)=>{const i=r.intersectObject(o,!0);for(let c=0;c<i.length;c++)if(i[c].object.visible||s)return i[c];return!1}),J(this,"attach",o=>(this.object=o,this.visible=!0,this)),J(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),J(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),J(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),J(this,"pointerHover",o=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);r?this.axis=r.object.name:this.axis=null}),J(this,"pointerDown",o=>{if(!(this.object===void 0||this.dragging===!0||o.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(o,this.camera);const r=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(r){let s=this.space;if(this.mode==="scale"?s="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(s="world"),s==="local"&&this.mode==="rotate"){const i=this.rotationSnap;this.axis==="X"&&i&&(this.object.rotation.x=Math.round(this.object.rotation.x/i)*i),this.axis==="Y"&&i&&(this.object.rotation.y=Math.round(this.object.rotation.y/i)*i),this.axis==="Z"&&i&&(this.object.rotation.z=Math.round(this.object.rotation.z/i)*i)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(r.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),J(this,"pointerMove",o=>{const r=this.axis,s=this.mode,i=this.object;let c=this.space;if(s==="scale"?c="local":(r==="E"||r==="XYZE"||r==="XYZ")&&(c="world"),i===void 0||r===null||this.dragging===!1||o.button!==-1)return;this.raycaster.setFromCamera(o,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),s==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="local"&&r!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),r.indexOf("X")===-1&&(this.offset.x=0),r.indexOf("Y")===-1&&(this.offset.y=0),r.indexOf("Z")===-1&&(this.offset.z=0),c==="local"&&r!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),i.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(c==="local"&&(i.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this.quaternionStart)),c==="world"&&(i.parent&&i.position.add(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld)),r.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(this.tempVector.setFromMatrixPosition(i.parent.matrixWorld))));else if(s==="scale"){if(r.search("XYZ")!==-1){let p=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(p*=-1),this.tempVector2.set(p,p,p)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),r.search("X")===-1&&(this.tempVector2.x=1),r.search("Y")===-1&&(this.tempVector2.y=1),r.search("Z")===-1&&(this.tempVector2.z=1);i.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(r.search("X")!==-1&&(this.object.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(s==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const p=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));r==="E"?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):r==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*p):(r==="X"||r==="Y"||r==="Z")&&(this.rotationAxis.copy(this.unit[r]),this.tempVector.copy(this.unit[r]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*p),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="local"&&r!=="E"&&r!=="XYZE"?(i.quaternion.copy(this.quaternionStart),i.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),i.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),J(this,"pointerUp",o=>{o.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),J(this,"getPointer",o=>{var r;if(this.domElement&&((r=this.domElement.ownerDocument)!=null&&r.pointerLockElement))return{x:0,y:0,button:o.button};{const s=o.changedTouches?o.changedTouches[0]:o,i=this.domElement.getBoundingClientRect();return{x:(s.clientX-i.left)/i.width*2-1,y:-(s.clientY-i.top)/i.height*2+1,button:o.button}}}),J(this,"onPointerHover",o=>{if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(o));break}}),J(this,"onPointerDown",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(o)),this.pointerDown(this.getPointer(o)))}),J(this,"onPointerMove",o=>{this.enabled&&this.pointerMove(this.getPointer(o))}),J(this,"onPointerUp",o=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(o)))}),J(this,"getMode",()=>this.mode),J(this,"setMode",o=>{this.mode=o}),J(this,"setTranslationSnap",o=>{this.translationSnap=o}),J(this,"setRotationSnap",o=>{this.rotationSnap=o}),J(this,"setScaleSnap",o=>{this.scaleSnap=o}),J(this,"setSize",o=>{this.size=o}),J(this,"setSpace",o=>{this.space=o}),J(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),J(this,"connect",o=>{o===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=o,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),J(this,"dispose",()=>{var o,r,s,i,c,h;(o=this.domElement)==null||o.removeEventListener("pointerdown",this.onPointerDown),(r=this.domElement)==null||r.removeEventListener("pointermove",this.onPointerHover),(i=(s=this.domElement)==null?void 0:s.ownerDocument)==null||i.removeEventListener("pointermove",this.onPointerMove),(h=(c=this.domElement)==null?void 0:c.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(p=>{const f=p;f.geometry&&f.geometry.dispose(),f.material&&f.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Ka,this.add(this.gizmo),this.plane=new qa,this.add(this.plane);const n=(o,r)=>{let s=r;Object.defineProperty(this,o,{get:function(){return s!==void 0?s:r},set:function(i){s!==i&&(s=i,this.plane[o]=i,this.gizmo[o]=i,this.dispatchEvent({type:o+"-changed",value:i}),this.dispatchEvent(this.changeEvent))}}),this[o]=r,this.plane[o]=r,this.gizmo[o]=r};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class Ka extends l.Object3D{constructor(){super(),J(this,"isTransformControlsGizmo",!0),J(this,"type","TransformControlsGizmo"),J(this,"tempVector",new l.Vector3(0,0,0)),J(this,"tempEuler",new l.Euler),J(this,"alignVector",new l.Vector3(0,1,0)),J(this,"zeroVector",new l.Vector3(0,0,0)),J(this,"lookAtMatrix",new l.Matrix4),J(this,"tempQuaternion",new l.Quaternion),J(this,"tempQuaternion2",new l.Quaternion),J(this,"identityQuaternion",new l.Quaternion),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"gizmo"),J(this,"picker"),J(this,"helper"),J(this,"rotationAxis",new l.Vector3),J(this,"cameraPosition",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"camera",null),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"updateMatrixWorld",()=>{let te=this.space;this.mode==="scale"&&(te="local");const ce=te==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let le=[];le=le.concat(this.picker[this.mode].children),le=le.concat(this.gizmo[this.mode].children),le=le.concat(this.helper[this.mode].children);for(let de=0;de<le.length;de++){const k=le[de];k.visible=!0,k.rotation.set(0,0,0),k.position.copy(this.worldPosition);let V;if(this.camera.isOrthographicCamera?V=(this.camera.top-this.camera.bottom)/this.camera.zoom:V=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),k.scale.set(1,1,1).multiplyScalar(V*this.size/7),k.tag==="helper"){k.visible=!1,k.name==="AXIS"?(k.position.copy(this.worldPositionStart),k.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),k.quaternion.multiply(this.tempQuaternion),k.visible=this.dragging),this.axis==="E"&&(k.visible=!1)):k.name==="START"?(k.position.copy(this.worldPositionStart),k.visible=this.dragging):k.name==="END"?(k.position.copy(this.worldPosition),k.visible=this.dragging):k.name==="DELTA"?(k.position.copy(this.worldPositionStart),k.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),k.scale.copy(this.tempVector),k.visible=this.dragging):(k.quaternion.copy(ce),this.dragging?k.position.copy(this.worldPositionStart):k.position.copy(this.worldPosition),this.axis&&(k.visible=this.axis.search(k.name)!==-1));continue}k.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((k.name==="X"||k.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Y"||k.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Z"||k.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.x*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.y*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.z*=-1:k.tag==="bwd"&&(k.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),k.name.search("E")!==-1&&k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),k.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion))),k.visible=k.visible&&(k.name.indexOf("X")===-1||this.showX),k.visible=k.visible&&(k.name.indexOf("Y")===-1||this.showY),k.visible=k.visible&&(k.name.indexOf("Z")===-1||this.showZ),k.visible=k.visible&&(k.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),k.material.tempOpacity=k.material.tempOpacity||k.material.opacity,k.material.tempColor=k.material.tempColor||k.material.color.clone(),k.material.color.copy(k.material.tempColor),k.material.opacity=k.material.tempOpacity,this.enabled?this.axis&&(k.name===this.axis?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(U){return k.name===U})?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):(k.material.opacity*=.25,k.material.color.lerp(new l.Color(1,1,1),.5))):(k.material.opacity*=.5,k.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const o=e.clone();o.opacity=.33;const r=e.clone();r.color.set(16711680);const s=e.clone();s.color.set(65280);const i=e.clone();i.color.set(255);const c=e.clone();c.opacity=.25;const h=c.clone();h.color.set(16776960);const p=c.clone();p.color.set(65535);const f=c.clone();f.color.set(16711935),e.clone().color.set(16776960);const d=t.clone();d.color.set(16711680);const g=t.clone();g.color.set(65280);const y=t.clone();y.color.set(255);const v=t.clone();v.color.set(65535);const _=t.clone();_.color.set(16711935);const A=t.clone();A.color.set(16776960);const b=t.clone();b.color.set(7895160);const C=A.clone();C.opacity=.25;const L=new l.CylinderGeometry(0,.05,.2,12,1,!1),M=new l.BoxGeometry(.125,.125,.125),P=new l.BufferGeometry;P.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const w=(te,ce)=>{const le=new l.BufferGeometry,de=[];for(let k=0;k<=64*ce;++k)de.push(0,Math.cos(k/32*Math.PI)*te,Math.sin(k/32*Math.PI)*te);return le.setAttribute("position",new l.Float32BufferAttribute(de,3)),le},S=()=>{const te=new l.BufferGeometry;return te.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),te},x={X:[[new l.Mesh(L,r),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(L,r),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(P,d)]],Y:[[new l.Mesh(L,s),[0,1,0],null,null,"fwd"],[new l.Mesh(L,s),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(P,g),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(L,i),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(L,i),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(P,y),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new l.Line(P,A),[.18,.3,0],null,[.125,1,1]],[new l.Line(P,A),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),p.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(P,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),f.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(P,_),[.18,0,.3],null,[.125,1,1]],[new l.Line(P,_),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},D={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),o),null,null,null,"helper"]],DELTA:[[new l.Line(S(),o),null,null,null,"helper"]],X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={X:[[new l.Line(w(1,.5),d)],[new l.Mesh(new l.OctahedronGeometry(.04,0),r),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(w(1,.5),g),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),s),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(w(1,.5),y),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(w(1.25,1),C),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),C),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(w(1,1),b),null,[0,Math.PI/2,0]]]},G={AXIS:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},E={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},X={X:[[new l.Mesh(M,r),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(P,d),null,null,[.8,1,1]]],Y:[[new l.Mesh(M,s),[0,.8,0]],[new l.Line(P,g),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(M,i),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(P,y),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(M,h),[.85,.85,0],null,[2,2,.2]],[new l.Line(P,A),[.855,.98,0],null,[.125,1,1]],[new l.Line(P,A),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(M,p),[0,.85,.85],null,[.2,2,2]],[new l.Line(P,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(P,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(M,f),[.85,0,.85],null,[2,.2,2]],[new l.Line(P,_),[.855,0,.98],null,[.125,1,1]],[new l.Line(P,_),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,0,1.1]]]},oe={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(M,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(M,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(M,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},q={X:[[new l.Line(P,o.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(P,o.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(P,o.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ee=te=>{const ce=new l.Object3D;for(let le in te)for(let de=te[le].length;de--;){const k=te[le][de][0].clone(),V=te[le][de][1],U=te[le][de][2],B=te[le][de][3],R=te[le][de][4];k.name=le,k.tag=R,V&&k.position.set(V[0],V[1],V[2]),U&&k.rotation.set(U[0],U[1],U[2]),B&&k.scale.set(B[0],B[1],B[2]),k.updateMatrix();const T=k.geometry.clone();T.applyMatrix4(k.matrix),k.geometry=T,k.renderOrder=1/0,k.position.set(0,0,0),k.rotation.set(0,0,0),k.scale.set(1,1,1),ce.add(k)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=ee(x)),this.add(this.gizmo.rotate=ee(z)),this.add(this.gizmo.scale=ee(X)),this.add(this.picker.translate=ee(I)),this.add(this.picker.rotate=ee(E)),this.add(this.picker.scale=ee(oe)),this.add(this.helper.translate=ee(D)),this.add(this.helper.rotate=ee(G)),this.add(this.helper.scale=ee(q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class qa extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),J(this,"isTransformControlsPlane",!0),J(this,"type","TransformControlsPlane"),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"tempVector",new l.Vector3),J(this,"dirVector",new l.Vector3),J(this,"alignVector",new l.Vector3),J(this,"tempMatrix",new l.Matrix4),J(this,"identityQuaternion",new l.Quaternion),J(this,"cameraQuaternion",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var Qa=Object.defineProperty,Ja=(a,e,t)=>e in a?Qa(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,ke=(a,e,t)=>(Ja(a,typeof e!="symbol"?e+"":e,t),t);const Dt=new l.Euler(0,0,0,"YXZ"),kt=new l.Vector3,Ha={type:"change"},$a={type:"lock"},el={type:"unlock"},yr=Math.PI/2;class _r extends l.EventDispatcher{constructor(e,t){super(),ke(this,"camera"),ke(this,"domElement"),ke(this,"isLocked"),ke(this,"minPolarAngle"),ke(this,"maxPolarAngle"),ke(this,"pointerSpeed"),ke(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const o=n.movementX||n.mozMovementX||n.webkitMovementX||0,r=n.movementY||n.mozMovementY||n.webkitMovementY||0;Dt.setFromQuaternion(this.camera.quaternion),Dt.y-=o*.002*this.pointerSpeed,Dt.x-=r*.002*this.pointerSpeed,Dt.x=Math.max(yr-this.maxPolarAngle,Math.min(yr-this.minPolarAngle,Dt.x)),this.camera.quaternion.setFromEuler(Dt),this.dispatchEvent(Ha)}),ke(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent($a),this.isLocked=!0):(this.dispatchEvent(el),this.isLocked=!1))}),ke(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ke(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),ke(this,"dispose",()=>{this.disconnect()}),ke(this,"getObject",()=>this.camera),ke(this,"direction",new l.Vector3(0,0,-1)),ke(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),ke(this,"moveForward",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),kt.crossVectors(this.camera.up,kt),this.camera.position.addScaledVector(kt,n)}),ke(this,"moveRight",n=>{kt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(kt,n)}),ke(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),ke(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var tl=Object.defineProperty,nl=(a,e,t)=>e in a?tl(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,fe=(a,e,t)=>(nl(a,typeof e!="symbol"?e+"":e,t),t);const yn=new l.Ray,vr=new l.Plane,ol=Math.cos(70*(Math.PI/180)),xr=(a,e)=>(a%e+e)%e;class wr extends l.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new l.Vector3),fe(this,"minDistance",0),fe(this,"maxDistance",1/0),fe(this,"minZoom",0),fe(this,"maxZoom",1/0),fe(this,"minPolarAngle",0),fe(this,"maxPolarAngle",Math.PI),fe(this,"minAzimuthAngle",-1/0),fe(this,"maxAzimuthAngle",1/0),fe(this,"enableDamping",!1),fe(this,"dampingFactor",.05),fe(this,"enableZoom",!0),fe(this,"zoomSpeed",1),fe(this,"enableRotate",!0),fe(this,"rotateSpeed",1),fe(this,"enablePan",!0),fe(this,"panSpeed",1),fe(this,"screenSpacePanning",!0),fe(this,"keyPanSpeed",7),fe(this,"zoomToCursor",!1),fe(this,"autoRotate",!1),fe(this,"autoRotateSpeed",2),fe(this,"reverseOrbit",!1),fe(this,"reverseHorizontalOrbit",!1),fe(this,"reverseVerticalOrbit",!1),fe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),fe(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),fe(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),fe(this,"target0"),fe(this,"position0"),fe(this,"zoom0"),fe(this,"_domElementKeyEvents",null),fe(this,"getPolarAngle"),fe(this,"getAzimuthalAngle"),fe(this,"setPolarAngle"),fe(this,"setAzimuthalAngle"),fe(this,"getDistance"),fe(this,"getZoomScale"),fe(this,"listenToKeyEvents"),fe(this,"stopListenToKeyEvents"),fe(this,"saveState"),fe(this,"reset"),fe(this,"update"),fe(this,"connect"),fe(this,"dispose"),fe(this,"dollyIn"),fe(this,"dollyOut"),fe(this,"getScale"),fe(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>p.phi,this.getAzimuthalAngle=()=>p.theta,this.setPolarAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.phi;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.phi=ae-ge,n.update()},this.setAzimuthalAngle=Z=>{let ae=xr(Z,2*Math.PI),ge=p.theta;ge<0&&(ge+=2*Math.PI),ae<0&&(ae+=2*Math.PI);let Me=Math.abs(ae-ge);2*Math.PI-Me<Me&&(ae<ge?ae+=2*Math.PI:ge+=2*Math.PI),f.theta=ae-ge,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=Z=>{Z.addEventListener("keydown",st),this._domElementKeyEvents=Z},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",st),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(o),n.update(),c=i.NONE},this.update=(()=>{const Z=new l.Vector3,ae=new l.Vector3(0,1,0),ge=new l.Quaternion().setFromUnitVectors(e.up,ae),Me=ge.clone().invert(),Be=new l.Vector3,ht=new l.Quaternion,bt=2*Math.PI;return function(){const Qs=n.object.position;ge.setFromUnitVectors(e.up,ae),Me.copy(ge).invert(),Z.copy(Qs).sub(n.target),Z.applyQuaternion(ge),p.setFromVector3(Z),n.autoRotate&&c===i.NONE&&G(D()),n.enableDamping?(p.theta+=f.theta*n.dampingFactor,p.phi+=f.phi*n.dampingFactor):(p.theta+=f.theta,p.phi+=f.phi);let ft=n.minAzimuthAngle,dt=n.maxAzimuthAngle;isFinite(ft)&&isFinite(dt)&&(ft<-Math.PI?ft+=bt:ft>Math.PI&&(ft-=bt),dt<-Math.PI?dt+=bt:dt>Math.PI&&(dt-=bt),ft<=dt?p.theta=Math.max(ft,Math.min(dt,p.theta)):p.theta=p.theta>(ft+dt)/2?Math.max(ft,p.theta):Math.min(dt,p.theta)),p.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,p.phi)),p.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(d,n.dampingFactor):n.target.add(d),n.zoomToCursor&&S||n.object.isOrthographicCamera?p.radius=de(p.radius):p.radius=de(p.radius*m),Z.setFromSpherical(p),Z.applyQuaternion(Me),Qs.copy(n.target).add(Z),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,d.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),d.set(0,0,0));let an=!1;if(n.zoomToCursor&&S){let ln=null;if(n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const cn=Z.length();ln=de(cn*m);const Un=cn-ln;n.object.position.addScaledVector(P,Un),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const cn=new l.Vector3(w.x,w.y,0);cn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix(),an=!0;const Un=new l.Vector3(w.x,w.y,0);Un.unproject(n.object),n.object.position.sub(Un).add(cn),n.object.updateMatrixWorld(),ln=Z.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;ln!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(ln).add(n.object.position):(yn.origin.copy(n.object.position),yn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(yn.direction))<ol?e.lookAt(n.target):(vr.setFromNormalAndCoplanarPoint(n.object.up,n.target),yn.intersectPlane(vr,n.target))))}else n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera&&(an=m!==1,an&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/m)),n.object.updateProjectionMatrix()));return m=1,S=!1,an||Be.distanceToSquared(n.object.position)>h||8*(1-ht.dot(n.object.quaternion))>h?(n.dispatchEvent(o),Be.copy(n.object.position),ht.copy(n.object.quaternion),an=!1,!0):!1}})(),this.connect=Z=>{n.domElement=Z,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",sn),n.domElement.addEventListener("pointerdown",_e),n.domElement.addEventListener("pointercancel",Pe),n.domElement.addEventListener("wheel",It)},this.dispose=()=>{var Z,ae,ge,Me,Be,ht;n.domElement&&(n.domElement.style.touchAction="auto"),(Z=n.domElement)==null||Z.removeEventListener("contextmenu",sn),(ae=n.domElement)==null||ae.removeEventListener("pointerdown",_e),(ge=n.domElement)==null||ge.removeEventListener("pointercancel",Pe),(Me=n.domElement)==null||Me.removeEventListener("wheel",It),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",Le),(ht=n.domElement)==null||ht.ownerDocument.removeEventListener("pointerup",Pe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",st)};const n=this,o={type:"change"},r={type:"start"},s={type:"end"},i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let c=i.NONE;const h=1e-6,p=new l.Spherical,f=new l.Spherical;let m=1;const d=new l.Vector3,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector3,w=new l.Vector2;let S=!1;const x=[],I={};function D(){return 2*Math.PI/60/60*n.autoRotateSpeed}function z(){return Math.pow(.95,n.zoomSpeed)}function G(Z){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=Z:f.theta-=Z}function E(Z){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=Z:f.phi-=Z}const X=(()=>{const Z=new l.Vector3;return function(ge,Me){Z.setFromMatrixColumn(Me,0),Z.multiplyScalar(-ge),d.add(Z)}})(),oe=(()=>{const Z=new l.Vector3;return function(ge,Me){n.screenSpacePanning===!0?Z.setFromMatrixColumn(Me,1):(Z.setFromMatrixColumn(Me,0),Z.crossVectors(n.object.up,Z)),Z.multiplyScalar(ge),d.add(Z)}})(),q=(()=>{const Z=new l.Vector3;return function(ge,Me){const Be=n.domElement;if(Be&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const ht=n.object.position;Z.copy(ht).sub(n.target);let bt=Z.length();bt*=Math.tan(n.object.fov/2*Math.PI/180),X(2*ge*bt/Be.clientHeight,n.object.matrix),oe(2*Me*bt/Be.clientHeight,n.object.matrix)}else Be&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(X(ge*(n.object.right-n.object.left)/n.object.zoom/Be.clientWidth,n.object.matrix),oe(Me*(n.object.top-n.object.bottom)/n.object.zoom/Be.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function ee(Z){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?m=Z:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function te(Z){ee(m/Z)}function ce(Z){ee(m*Z)}function le(Z){if(!n.zoomToCursor||!n.domElement)return;S=!0;const ae=n.domElement.getBoundingClientRect(),ge=Z.clientX-ae.left,Me=Z.clientY-ae.top,Be=ae.width,ht=ae.height;w.x=ge/Be*2-1,w.y=-(Me/ht)*2+1,P.set(w.x,w.y,1).unproject(n.object).sub(n.object.position).normalize()}function de(Z){return Math.max(n.minDistance,Math.min(n.maxDistance,Z))}function k(Z){g.set(Z.clientX,Z.clientY)}function V(Z){le(Z),C.set(Z.clientX,Z.clientY)}function U(Z){_.set(Z.clientX,Z.clientY)}function B(Z){y.set(Z.clientX,Z.clientY),v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),E(2*Math.PI*v.y/ae.clientHeight)),g.copy(y),n.update()}function R(Z){L.set(Z.clientX,Z.clientY),M.subVectors(L,C),M.y>0?te(z()):M.y<0&&ce(z()),C.copy(L),n.update()}function T(Z){A.set(Z.clientX,Z.clientY),b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A),n.update()}function O(Z){le(Z),Z.deltaY<0?ce(z()):Z.deltaY>0&&te(z()),n.update()}function N(Z){let ae=!1;switch(Z.code){case n.keys.UP:q(0,n.keyPanSpeed),ae=!0;break;case n.keys.BOTTOM:q(0,-n.keyPanSpeed),ae=!0;break;case n.keys.LEFT:q(n.keyPanSpeed,0),ae=!0;break;case n.keys.RIGHT:q(-n.keyPanSpeed,0),ae=!0;break}ae&&(Z.preventDefault(),n.update())}function K(){if(x.length==1)g.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);g.set(Z,ae)}}function W(){if(x.length==1)_.set(x[0].pageX,x[0].pageY);else{const Z=.5*(x[0].pageX+x[1].pageX),ae=.5*(x[0].pageY+x[1].pageY);_.set(Z,ae)}}function Y(){const Z=x[0].pageX-x[1].pageX,ae=x[0].pageY-x[1].pageY,ge=Math.sqrt(Z*Z+ae*ae);C.set(0,ge)}function Q(){n.enableZoom&&Y(),n.enablePan&&W()}function re(){n.enableZoom&&Y(),n.enableRotate&&K()}function se(Z){if(x.length==1)y.set(Z.pageX,Z.pageY);else{const ge=jo(Z),Me=.5*(Z.pageX+ge.x),Be=.5*(Z.pageY+ge.y);y.set(Me,Be)}v.subVectors(y,g).multiplyScalar(n.rotateSpeed);const ae=n.domElement;ae&&(G(2*Math.PI*v.x/ae.clientHeight),E(2*Math.PI*v.y/ae.clientHeight)),g.copy(y)}function j(Z){if(x.length==1)A.set(Z.pageX,Z.pageY);else{const ae=jo(Z),ge=.5*(Z.pageX+ae.x),Me=.5*(Z.pageY+ae.y);A.set(ge,Me)}b.subVectors(A,_).multiplyScalar(n.panSpeed),q(b.x,b.y),_.copy(A)}function F(Z){const ae=jo(Z),ge=Z.pageX-ae.x,Me=Z.pageY-ae.y,Be=Math.sqrt(ge*ge+Me*Me);L.set(0,Be),M.set(0,Math.pow(L.y/C.y,n.zoomSpeed)),te(M.y),C.copy(L)}function ie(Z){n.enableZoom&&F(Z),n.enablePan&&j(Z)}function he(Z){n.enableZoom&&F(Z),n.enableRotate&&se(Z)}function _e(Z){var ae,ge;n.enabled!==!1&&(x.length===0&&((ae=n.domElement)==null||ae.ownerDocument.addEventListener("pointermove",Le),(ge=n.domElement)==null||ge.ownerDocument.addEventListener("pointerup",Pe)),kn(Z),Z.pointerType==="touch"?Ee(Z):Je(Z))}function Le(Z){n.enabled!==!1&&(Z.pointerType==="touch"?it(Z):wt(Z))}function Pe(Z){var ae,ge,Me;Ro(Z),x.length===0&&((ae=n.domElement)==null||ae.releasePointerCapture(Z.pointerId),(ge=n.domElement)==null||ge.ownerDocument.removeEventListener("pointermove",Le),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Pe)),n.dispatchEvent(s),c=i.NONE}function Je(Z){let ae;switch(Z.button){case 0:ae=n.mouseButtons.LEFT;break;case 1:ae=n.mouseButtons.MIDDLE;break;case 2:ae=n.mouseButtons.RIGHT;break;default:ae=-1}switch(ae){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;V(Z),c=i.DOLLY;break;case l.MOUSE.ROTATE:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enablePan===!1)return;U(Z),c=i.PAN}else{if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}break;case l.MOUSE.PAN:if(Z.ctrlKey||Z.metaKey||Z.shiftKey){if(n.enableRotate===!1)return;k(Z),c=i.ROTATE}else{if(n.enablePan===!1)return;U(Z),c=i.PAN}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function wt(Z){if(n.enabled!==!1)switch(c){case i.ROTATE:if(n.enableRotate===!1)return;B(Z);break;case i.DOLLY:if(n.enableZoom===!1)return;R(Z);break;case i.PAN:if(n.enablePan===!1)return;T(Z);break}}function It(Z){n.enabled===!1||n.enableZoom===!1||c!==i.NONE&&c!==i.ROTATE||(Z.preventDefault(),n.dispatchEvent(r),O(Z),n.dispatchEvent(s))}function st(Z){n.enabled===!1||n.enablePan===!1||N(Z)}function Ee(Z){switch(Bn(Z),x.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;K(),c=i.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;W(),c=i.TOUCH_PAN;break;default:c=i.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;Q(),c=i.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;re(),c=i.TOUCH_DOLLY_ROTATE;break;default:c=i.NONE}break;default:c=i.NONE}c!==i.NONE&&n.dispatchEvent(r)}function it(Z){switch(Bn(Z),c){case i.TOUCH_ROTATE:if(n.enableRotate===!1)return;se(Z),n.update();break;case i.TOUCH_PAN:if(n.enablePan===!1)return;j(Z),n.update();break;case i.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ie(Z),n.update();break;case i.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;he(Z),n.update();break;default:c=i.NONE}}function sn(Z){n.enabled!==!1&&Z.preventDefault()}function kn(Z){x.push(Z)}function Ro(Z){delete I[Z.pointerId];for(let ae=0;ae<x.length;ae++)if(x[ae].pointerId==Z.pointerId){x.splice(ae,1);return}}function Bn(Z){let ae=I[Z.pointerId];ae===void 0&&(ae=new l.Vector2,I[Z.pointerId]=ae),ae.set(Z.pageX,Z.pageY)}function jo(Z){const ae=Z.pointerId===x[0].pointerId?x[1]:x[0];return I[ae.pointerId]}this.dollyIn=(Z=z())=>{ce(Z),n.update()},this.dollyOut=(Z=z())=>{te(Z),n.update()},this.getScale=()=>m,this.setScale=Z=>{ee(Z),n.update()},this.getZoomScale=()=>z(),t!==void 0&&this.connect(t),this.update()}}class rl extends wr{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}function Bt(a){if(typeof TextDecoder<"u")return new TextDecoder().decode(a);let e="";for(let t=0,n=a.length;t<n;t++)e+=String.fromCharCode(a[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const St="srgb",lt="srgb-linear",br=3001,sl=3e3;class il extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new hl(t)}),this.register(function(t){return new fl(t)}),this.register(function(t){return new wl(t)}),this.register(function(t){return new bl(t)}),this.register(function(t){return new Ml(t)}),this.register(function(t){return new pl(t)}),this.register(function(t){return new ml(t)}),this.register(function(t){return new gl(t)}),this.register(function(t){return new yl(t)}),this.register(function(t){return new ul(t)}),this.register(function(t){return new _l(t)}),this.register(function(t){return new dl(t)}),this.register(function(t){return new xl(t)}),this.register(function(t){return new vl(t)}),this.register(function(t){return new ll(t)}),this.register(function(t){return new Sl(t)}),this.register(function(t){return new Al(t)})}load(e,t,n,o){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=l.LoaderUtils.extractUrlBase(e);s=l.LoaderUtils.resolveURL(h,this.path)}else s=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const i=function(h){o?o(h):console.error(h),r.manager.itemError(e),r.manager.itemEnd(e)},c=new l.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{r.parse(h,s,function(p){t(p),r.manager.itemEnd(e)},i)}catch(p){i(p)}},n,i)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,o){let r;const s={},i={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Bt(new Uint8Array(e.slice(0,4)))===Mr){try{s[ve.KHR_BINARY_GLTF]=new Pl(e)}catch(p){o&&o(p);return}r=JSON.parse(s[ve.KHR_BINARY_GLTF].content)}else r=JSON.parse(Bt(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){o&&o(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Vl(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const p=this.pluginCallbacks[h](c);p.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[p.name]=p,s[p.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const p=r.extensionsUsed[h],f=r.extensionsRequired||[];switch(p){case ve.KHR_MATERIALS_UNLIT:s[p]=new cl;break;case ve.KHR_DRACO_MESH_COMPRESSION:s[p]=new Cl(r,this.dracoLoader);break;case ve.KHR_TEXTURE_TRANSFORM:s[p]=new Tl;break;case ve.KHR_MESH_QUANTIZATION:s[p]=new Il;break;default:f.indexOf(p)>=0&&i[p]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+p+'".')}}c.setExtensions(s),c.setPlugins(i),c.parse(n,o)}parseAsync(e,t){const n=this;return new Promise(function(o,r){n.parse(e,t,o,r)})}}function al(){let a={};return{get:function(e){return a[e]},add:function(e,t){a[e]=t},remove:function(e){delete a[e]},removeAll:function(){a={}}}}const ve={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ll{constructor(e){this.parser=e,this.name=ve.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,o=t.length;n<o;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let o=t.cache.get(n);if(o)return o;const r=t.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let h;const p=new l.Color(16777215);c.color!==void 0&&p.setRGB(c.color[0],c.color[1],c.color[2],lt);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new l.DirectionalLight(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new l.PointLight(p),h.distance=f;break;case"spot":h=new l.SpotLight(p),h.distance=f,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,ct(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),o=Promise.resolve(h),t.cache.add(n,o),o}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(c){return n._getNodeRef(t.cache,i,c)})}}class cl{constructor(){this.name=ve.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const o=[];e.color=new l.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],lt),e.opacity=s[3]}r.baseColorTexture!==void 0&&o.push(n.assignTexture(e,"map",r.baseColorTexture,St))}return Promise.all(o)}}class ul{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class hl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const i=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new l.Vector2(i,i)}return Promise.all(r)}}class fl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class dl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class pl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=o.extensions[this.name];if(s.sheenColorFactor!==void 0){const i=s.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],lt)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,St)),s.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ml{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class gl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const i=s.attenuationColor||[1,1,1];return t.attenuationColor=new l.Color().setRGB(i[0],i[1],i[2],lt),Promise.all(r)}}class yl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const o=this.parser.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=o.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class _l{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const i=s.specularColorFactor||[1,1,1];return t.specularColor=new l.Color().setRGB(i[0],i[1],i[2],lt),s.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,St)),Promise.all(r)}}class vl{constructor(e){this.parser=e,this.name=ve.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(r)}}class xl{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,o=n.json.materials[e];if(!o.extensions||!o.extensions[this.name])return Promise.resolve();const r=[],s=o.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class wl{constructor(e){this.parser=e,this.name=ve.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,o=n.textures[e];if(!o.extensions||!o.extensions[this.name])return null;const r=o.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class bl{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Ml{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,o=n.json,r=o.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],i=o.images[s.source];let c=n.textureLoader;if(i.uri){const h=n.options.manager.getHandler(i.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,s.source,c);if(o.extensionsRequired&&o.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Sl{constructor(e){this.name=ve.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const o=n.extensions[this.name],r=this.parser.getDependency("buffer",o.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(i){const c=o.byteOffset||0,h=o.byteLength||0,p=o.count,f=o.byteStride,m=new Uint8Array(i,c,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(p,f,m,o.mode,o.filter).then(function(d){return d.buffer}):s.ready.then(function(){const d=new ArrayBuffer(p*f);return s.decodeGltfBuffer(new Uint8Array(d),p,f,m,o.mode,o.filter),d})})}else return null}}class Al{constructor(e){this.name=ve.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const o=t.meshes[n.mesh];for(const h of o.primitives)if(h.mode!==Ke.TRIANGLES&&h.mode!==Ke.TRIANGLE_STRIP&&h.mode!==Ke.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=n.extensions[this.name].attributes,i=[],c={};for(const h in s)i.push(this.parser.getDependency("accessor",s[h]).then(p=>(c[h]=p,c[h])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(h=>{const p=h.pop(),f=p.isGroup?p.children:[p],m=h[0].count,d=[];for(const g of f){const y=new l.Matrix4,v=new l.Vector3,_=new l.Quaternion,A=new l.Vector3(1,1,1),b=new l.InstancedMesh(g.geometry,g.material,m);for(let C=0;C<m;C++)c.TRANSLATION&&v.fromBufferAttribute(c.TRANSLATION,C),c.ROTATION&&_.fromBufferAttribute(c.ROTATION,C),c.SCALE&&A.fromBufferAttribute(c.SCALE,C),b.setMatrixAt(C,y.compose(v,_,A));for(const C in c)if(C==="_COLOR_0"){const L=c[C];b.instanceColor=new l.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else C!=="TRANSLATION"&&C!=="ROTATION"&&C!=="SCALE"&&g.geometry.setAttribute(C,c[C]);l.Object3D.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),d.push(b)}return p.isGroup?(p.clear(),p.add(...d),p):d[0]}))}}const Mr="glTF",qt=12,Sr={JSON:1313821514,BIN:5130562};class Pl{constructor(e){this.name=ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,qt);if(this.header={magic:Bt(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Mr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-qt,o=new DataView(e,qt);let r=0;for(;r<n;){const s=o.getUint32(r,!0);r+=4;const i=o.getUint32(r,!0);if(r+=4,i===Sr.JSON){const c=new Uint8Array(e,qt+r,s);this.content=Bt(c)}else if(i===Sr.BIN){const c=qt+r;this.body=e.slice(c,c+s)}r+=s}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Cl{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ve.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,o=this.dracoLoader,r=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,i={},c={},h={};for(const p in s){const f=eo[p]||p.toLowerCase();i[f]=s[p]}for(const p in e.attributes){const f=eo[p]||p.toLowerCase();if(s[p]!==void 0){const m=n.accessors[e.attributes[p]],d=Ut[m.componentType];h[f]=d.name,c[f]=m.normalized===!0}}return t.getDependency("bufferView",r).then(function(p){return new Promise(function(f,m){o.decodeDracoFile(p,function(d){for(const g in d.attributes){const y=d.attributes[g],v=c[g];v!==void 0&&(y.normalized=v)}f(d)},i,h,lt,m)})})}}class Tl{constructor(){this.name=ve.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Il{constructor(){this.name=ve.KHR_MESH_QUANTIZATION}}class Ar extends l.Interpolant{constructor(e,t,n,o){super(e,t,n,o)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,o=this.valueSize,r=e*o*3+o;for(let s=0;s!==o;s++)t[s]=n[r+s];return t}interpolate_(e,t,n,o){const r=this.resultBuffer,s=this.sampleValues,i=this.valueSize,c=i*2,h=i*3,p=o-t,f=(n-t)/p,m=f*f,d=m*f,g=e*h,y=g-h,v=-2*d+3*m,_=d-m,A=1-v,b=_-m+f;for(let C=0;C!==i;C++){const L=s[y+C+i],M=s[y+C+c]*p,P=s[g+C+i],w=s[g+C]*p;r[C]=A*L+b*M+v*P+_*w}return r}}const Ol=new l.Quaternion;class Ll extends Ar{interpolate_(e,t,n,o){const r=super.interpolate_(e,t,n,o);return Ol.fromArray(r).normalize().toArray(r),r}}const Ke={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ut={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pr={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},Cr={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},$n={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},eo={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Xt>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},_t={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Dl={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},to={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function kl(a){return a.DefaultMaterial===void 0&&(a.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),a.DefaultMaterial}function At(a,e,t){for(const n in t.extensions)a[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ct(a,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(a.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Bl(a,e,t){let n=!1,o=!1,r=!1;for(let h=0,p=e.length;h<p;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(o=!0),f.COLOR_0!==void 0&&(r=!0),n&&o&&r)break}if(!n&&!o&&!r)return Promise.resolve(a);const s=[],i=[],c=[];for(let h=0,p=e.length;h<p;h++){const f=e[h];if(n){const m=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):a.attributes.position;s.push(m)}if(o){const m=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):a.attributes.normal;i.push(m)}if(r){const m=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):a.attributes.color;c.push(m)}}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c)]).then(function(h){const p=h[0],f=h[1],m=h[2];return n&&(a.morphAttributes.position=p),o&&(a.morphAttributes.normal=f),r&&(a.morphAttributes.color=m),a.morphTargetsRelative=!0,a})}function Ul(a,e){if(a.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)a.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(a.morphTargetInfluences.length===t.length){a.morphTargetDictionary={};for(let n=0,o=t.length;n<o;n++)a.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Nl(a){let e;const t=a.extensions&&a.extensions[ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+no(t.attributes):e=a.indices+":"+no(a.attributes)+":"+a.mode,a.targets!==void 0)for(let n=0,o=a.targets.length;n<o;n++)e+=":"+no(a.targets[n]);return e}function no(a){let e="";const t=Object.keys(a).sort();for(let n=0,o=t.length;n<o;n++)e+=t[n]+":"+a[t[n]]+";";return e}function oo(a){switch(a){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Fl(a){return a.search(/\.jpe?g($|\?)/i)>0||a.search(/^data\:image\/jpeg/)===0?"image/jpeg":a.search(/\.webp($|\?)/i)>0||a.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const zl=new l.Matrix4;class Vl{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new al,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,o=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,o=navigator.userAgent.indexOf("Firefox")>-1,r=o?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||o&&r<98?this.textureLoader=new l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,o=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){const i={scene:s[0][o.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:o.asset,parser:n,userData:{}};return At(r,i,o),ct(i,o),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(i)})).then(function(){for(const c of i.scenes)c.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let o=0,r=t.length;o<r;o++){const s=t[o].joints;for(let i=0,c=s.length;i<c;i++)e[s[i]].isBone=!0}for(let o=0,r=e.length;o<r;o++){const s=e[o];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(n[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const o=n.clone(),r=(s,i)=>{const c=this.associations.get(s);c!=null&&this.associations.set(i,c);for(const[h,p]of s.children.entries())r(p,i.children[h])};return r(n,o),o.name+="_instance_"+e.uses[t]++,o}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const o=e(t[n]);if(o)return o}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let o=0;o<t.length;o++){const r=e(t[o]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let o=this.cache.get(n);if(!o){switch(e){case"scene":o=this.loadScene(t);break;case"node":o=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":o=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":o=this.loadAccessor(t);break;case"bufferView":o=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":o=this.loadBuffer(t);break;case"material":o=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":o=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":o=this.loadSkin(t);break;case"animation":o=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":o=this.loadCamera(t);break;default:if(o=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!o)throw new Error("Unknown type: "+e);break}this.cache.add(n,o)}return o}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,o=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(o.map(function(r,s){return n.getDependency(e,s)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[ve.KHR_BINARY_GLTF].body);const o=this.options;return new Promise(function(r,s){n.load(l.LoaderUtils.resolveURL(t.uri,o.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const o=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+o)})}loadAccessor(e){const t=this,n=this.json,o=this.json.accessors[e];if(o.bufferView===void 0&&o.sparse===void 0){const s=$n[o.type],i=Ut[o.componentType],c=o.normalized===!0,h=new i(o.count*s);return Promise.resolve(new l.BufferAttribute(h,s,c))}const r=[];return o.bufferView!==void 0?r.push(this.getDependency("bufferView",o.bufferView)):r.push(null),o.sparse!==void 0&&(r.push(this.getDependency("bufferView",o.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",o.sparse.values.bufferView))),Promise.all(r).then(function(s){const i=s[0],c=$n[o.type],h=Ut[o.componentType],p=h.BYTES_PER_ELEMENT,f=p*c,m=o.byteOffset||0,d=o.bufferView!==void 0?n.bufferViews[o.bufferView].byteStride:void 0,g=o.normalized===!0;let y,v;if(d&&d!==f){const _=Math.floor(m/d),A="InterleavedBuffer:"+o.bufferView+":"+o.componentType+":"+_+":"+o.count;let b=t.cache.get(A);b||(y=new h(i,_*d,o.count*d/p),b=new l.InterleavedBuffer(y,d/p),t.cache.add(A,b)),v=new l.InterleavedBufferAttribute(b,c,m%d/p,g)}else i===null?y=new h(o.count*c):y=new h(i,m,o.count*c),v=new l.BufferAttribute(y,c,g);if(o.sparse!==void 0){const _=$n.SCALAR,A=Ut[o.sparse.indices.componentType],b=o.sparse.indices.byteOffset||0,C=o.sparse.values.byteOffset||0,L=new A(s[1],b,o.sparse.count*_),M=new h(s[2],C,o.sparse.count*c);i!==null&&(v=new l.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let P=0,w=L.length;P<w;P++){const S=L[P];if(v.setX(S,M[P*c]),c>=2&&v.setY(S,M[P*c+1]),c>=3&&v.setZ(S,M[P*c+2]),c>=4&&v.setW(S,M[P*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r];let i=this.textureLoader;if(s.uri){const c=n.manager.getHandler(s.uri);c!==null&&(i=c)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const o=this,r=this.json,s=r.textures[e],i=r.images[t],c=(i.uri||i.bufferView)+":"+s.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,n).then(function(p){p.flipY=!1,p.name=s.name||i.name||"",p.name===""&&typeof i.uri=="string"&&i.uri.startsWith("data:image/")===!1&&(p.name=i.uri);const m=(r.samplers||{})[s.sampler]||{};return p.magFilter=Pr[m.magFilter]||l.LinearFilter,p.minFilter=Pr[m.minFilter]||l.LinearMipmapLinearFilter,p.wrapS=Cr[m.wrapS]||l.RepeatWrapping,p.wrapT=Cr[m.wrapT]||l.RepeatWrapping,o.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const n=this,o=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const s=o.images[e],i=self.URL||self.webkitURL;let c=s.uri||"",h=!1;if(s.bufferView!==void 0)c=n.getDependency("bufferView",s.bufferView).then(function(f){h=!0;const m=new Blob([f],{type:s.mimeType});return c=i.createObjectURL(m),c});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(c).then(function(f){return new Promise(function(m,d){let g=m;t.isImageBitmapLoader===!0&&(g=function(y){const v=new l.Texture(y);v.needsUpdate=!0,m(v)}),t.load(l.LoaderUtils.resolveURL(f,r.path),g,void 0,d)})}).then(function(f){return h===!0&&i.revokeObjectURL(c),ct(f,s),f.userData.mimeType=s.mimeType||Fl(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=p,p}assignTexture(e,t,n,o){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(s=s.clone(),s.channel=n.texCoord),r.extensions[ve.KHR_TEXTURE_TRANSFORM]){const i=n.extensions!==void 0?n.extensions[ve.KHR_TEXTURE_TRANSFORM]:void 0;if(i){const c=r.associations.get(s);s=r.extensions[ve.KHR_TEXTURE_TRANSFORM].extendTexture(s,i),r.associations.set(s,c)}}return o!==void 0&&(typeof o=="number"&&(o=o===br?St:lt),"colorSpace"in s?s.colorSpace=o:s.encoding=o===St?br:sl),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const o=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const i="PointsMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.PointsMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(i,c)),n=c}else if(e.isLine){const i="LineBasicMaterial:"+n.uuid;let c=this.cache.get(i);c||(c=new l.LineBasicMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(i,c)),n=c}if(o||r||s){let i="ClonedMaterial:"+n.uuid+":";o&&(i+="derivative-tangents:"),r&&(i+="vertex-colors:"),s&&(i+="flat-shading:");let c=this.cache.get(i);c||(c=n.clone(),r&&(c.vertexColors=!0),s&&(c.flatShading=!0),o&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(i,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,o=this.extensions,r=n.materials[e];let s;const i={},c=r.extensions||{},h=[];if(c[ve.KHR_MATERIALS_UNLIT]){const f=o[ve.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),h.push(f.extendParams(i,r,t))}else{const f=r.pbrMetallicRoughness||{};if(i.color=new l.Color(1,1,1),i.opacity=1,Array.isArray(f.baseColorFactor)){const m=f.baseColorFactor;i.color.setRGB(m[0],m[1],m[2],lt),i.opacity=m[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(i,"map",f.baseColorTexture,St)),i.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,i.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(i,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(i,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,i)})))}r.doubleSided===!0&&(i.side=l.DoubleSide);const p=r.alphaMode||to.OPAQUE;if(p===to.BLEND?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,p===to.MASK&&(i.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"normalMap",r.normalTexture)),i.normalScale=new l.Vector2(1,1),r.normalTexture.scale!==void 0)){const f=r.normalTexture.scale;i.normalScale.set(f,f)}if(r.occlusionTexture!==void 0&&s!==l.MeshBasicMaterial&&(h.push(t.assignTexture(i,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(i.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==l.MeshBasicMaterial){const f=r.emissiveFactor;i.emissive=new l.Color().setRGB(f[0],f[1],f[2],lt)}return r.emissiveTexture!==void 0&&s!==l.MeshBasicMaterial&&h.push(t.assignTexture(i,"emissiveMap",r.emissiveTexture,St)),Promise.all(h).then(function(){const f=new s(i);return r.name&&(f.name=r.name),ct(f,r),t.associations.set(f,{materials:e}),r.extensions&&At(o,f,r),f})}createUniqueName(e){const t=l.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,o=this.primitiveCache;function r(i){return n[ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(i,t).then(function(c){return Tr(c,i,t)})}const s=[];for(let i=0,c=e.length;i<c;i++){const h=e[i],p=Nl(h),f=o[p];if(f)s.push(f.promise);else{let m;h.extensions&&h.extensions[ve.KHR_DRACO_MESH_COMPRESSION]?m=r(h):m=Tr(new l.BufferGeometry,h,t),o[p]={primitive:h,promise:m},s.push(m)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,o=this.extensions,r=n.meshes[e],s=r.primitives,i=[];for(let c=0,h=s.length;c<h;c++){const p=s[c].material===void 0?kl(this.cache):this.getDependency("material",s[c].material);i.push(p)}return i.push(t.loadGeometries(s)),Promise.all(i).then(function(c){const h=c.slice(0,c.length-1),p=c[c.length-1],f=[];for(let d=0,g=p.length;d<g;d++){const y=p[d],v=s[d];let _;const A=h[d];if(v.mode===Ke.TRIANGLES||v.mode===Ke.TRIANGLE_STRIP||v.mode===Ke.TRIANGLE_FAN||v.mode===void 0)_=r.isSkinnedMesh===!0?new l.SkinnedMesh(y,A):new l.Mesh(y,A),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),v.mode===Ke.TRIANGLE_STRIP?_.geometry=qo(_.geometry,l.TriangleStripDrawMode):v.mode===Ke.TRIANGLE_FAN&&(_.geometry=qo(_.geometry,l.TriangleFanDrawMode));else if(v.mode===Ke.LINES)_=new l.LineSegments(y,A);else if(v.mode===Ke.LINE_STRIP)_=new l.Line(y,A);else if(v.mode===Ke.LINE_LOOP)_=new l.LineLoop(y,A);else if(v.mode===Ke.POINTS)_=new l.Points(y,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(_.geometry.morphAttributes).length>0&&Ul(_,r),_.name=t.createUniqueName(r.name||"mesh_"+e),ct(_,r),v.extensions&&At(o,_,v),t.assignFinalMaterial(_),f.push(_)}for(let d=0,g=f.length;d<g;d++)t.associations.set(f[d],{meshes:e,primitives:d});if(f.length===1)return r.extensions&&At(o,f[0],r),f[0];const m=new l.Group;r.extensions&&At(o,m,r),t.associations.set(m,{meshes:e});for(let d=0,g=f.length;d<g;d++)m.add(f[d]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],o=n[n.type];if(!o){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new l.PerspectiveCamera(l.MathUtils.radToDeg(o.yfov),o.aspectRatio||1,o.znear||1,o.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-o.xmag,o.xmag,o.ymag,-o.ymag,o.znear,o.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ct(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let o=0,r=t.joints.length;o<r;o++)n.push(this._loadNodeShallow(t.joints[o]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(o){const r=o.pop(),s=o,i=[],c=[];for(let h=0,p=s.length;h<p;h++){const f=s[h];if(f){i.push(f);const m=new l.Matrix4;r!==null&&m.fromArray(r.array,h*16),c.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new l.Skeleton(i,c)})}loadAnimation(e){const t=this.json,n=this,o=t.animations[e],r=o.name?o.name:"animation_"+e,s=[],i=[],c=[],h=[],p=[];for(let f=0,m=o.channels.length;f<m;f++){const d=o.channels[f],g=o.samplers[d.sampler],y=d.target,v=y.node,_=o.parameters!==void 0?o.parameters[g.input]:g.input,A=o.parameters!==void 0?o.parameters[g.output]:g.output;y.node!==void 0&&(s.push(this.getDependency("node",v)),i.push(this.getDependency("accessor",_)),c.push(this.getDependency("accessor",A)),h.push(g),p.push(y))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(c),Promise.all(h),Promise.all(p)]).then(function(f){const m=f[0],d=f[1],g=f[2],y=f[3],v=f[4],_=[];for(let A=0,b=m.length;A<b;A++){const C=m[A],L=d[A],M=g[A],P=y[A],w=v[A];if(C===void 0)continue;C.updateMatrix&&C.updateMatrix();const S=n._createAnimationTracks(C,L,M,P,w);if(S)for(let x=0;x<S.length;x++)_.push(S[x])}return new l.AnimationClip(r,void 0,_)})}createNodeMesh(e){const t=this.json,n=this,o=t.nodes[e];return o.mesh===void 0?null:n.getDependency("mesh",o.mesh).then(function(r){const s=n._getNodeRef(n.meshCache,o.mesh,r);return o.weights!==void 0&&s.traverse(function(i){if(i.isMesh)for(let c=0,h=o.weights.length;c<h;c++)i.morphTargetInfluences[c]=o.weights[c]}),s})}loadNode(e){const t=this.json,n=this,o=t.nodes[e],r=n._loadNodeShallow(e),s=[],i=o.children||[];for(let h=0,p=i.length;h<p;h++)s.push(n.getDependency("node",i[h]));const c=o.skin===void 0?Promise.resolve(null):n.getDependency("skin",o.skin);return Promise.all([r,Promise.all(s),c]).then(function(h){const p=h[0],f=h[1],m=h[2];m!==null&&p.traverse(function(d){d.isSkinnedMesh&&d.bind(m,zl)});for(let d=0,g=f.length;d<g;d++)p.add(f[d]);return p})}_loadNodeShallow(e){const t=this.json,n=this.extensions,o=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],s=r.name?o.createUniqueName(r.name):"",i=[],c=o._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&i.push(c),r.camera!==void 0&&i.push(o.getDependency("camera",r.camera).then(function(h){return o._getNodeRef(o.cameraCache,r.camera,h)})),o._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){i.push(h)}),this.nodeCache[e]=Promise.all(i).then(function(h){let p;if(r.isBone===!0?p=new l.Bone:h.length>1?p=new l.Group:h.length===1?p=h[0]:p=new l.Object3D,p!==h[0])for(let f=0,m=h.length;f<m;f++)p.add(h[f]);if(r.name&&(p.userData.name=r.name,p.name=s),ct(p,r),r.extensions&&At(n,p,r),r.matrix!==void 0){const f=new l.Matrix4;f.fromArray(r.matrix),p.applyMatrix4(f)}else r.translation!==void 0&&p.position.fromArray(r.translation),r.rotation!==void 0&&p.quaternion.fromArray(r.rotation),r.scale!==void 0&&p.scale.fromArray(r.scale);return o.associations.has(p)||o.associations.set(p,{}),o.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],o=this,r=new l.Group;n.name&&(r.name=o.createUniqueName(n.name)),ct(r,n),n.extensions&&At(t,r,n);const s=n.nodes||[],i=[];for(let c=0,h=s.length;c<h;c++)i.push(o.getDependency("node",s[c]));return Promise.all(i).then(function(c){for(let p=0,f=c.length;p<f;p++)r.add(c[p]);const h=p=>{const f=new Map;for(const[m,d]of o.associations)(m instanceof l.Material||m instanceof l.Texture)&&f.set(m,d);return p.traverse(m=>{const d=o.associations.get(m);d!=null&&f.set(m,d)}),f};return o.associations=h(r),r})}_createAnimationTracks(e,t,n,o,r){const s=[],i=e.name?e.name:e.uuid,c=[];_t[r.path]===_t.weights?e.traverse(function(m){m.morphTargetInfluences&&c.push(m.name?m.name:m.uuid)}):c.push(i);let h;switch(_t[r.path]){case _t.weights:h=l.NumberKeyframeTrack;break;case _t.rotation:h=l.QuaternionKeyframeTrack;break;case _t.position:case _t.scale:h=l.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=l.NumberKeyframeTrack;break;case 2:case 3:default:h=l.VectorKeyframeTrack;break}break}const p=o.interpolation!==void 0?Dl[o.interpolation]:l.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let m=0,d=c.length;m<d;m++){const g=new h(c[m]+"."+_t[r.path],t.array,f,p);o.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),s.push(g)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=oo(t.constructor),o=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)o[r]=t[r]*n;t=o}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const o=this instanceof l.QuaternionKeyframeTrack?Ll:Ar;return new o(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Gl(a,e,t){const n=e.attributes,o=new l.Box3;if(n.POSITION!==void 0){const i=t.json.accessors[n.POSITION],c=i.min,h=i.max;if(c!==void 0&&h!==void 0){if(o.set(new l.Vector3(c[0],c[1],c[2]),new l.Vector3(h[0],h[1],h[2])),i.normalized){const p=oo(Ut[i.componentType]);o.min.multiplyScalar(p),o.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const i=new l.Vector3,c=new l.Vector3;for(let h=0,p=r.length;h<p;h++){const f=r[h];if(f.POSITION!==void 0){const m=t.json.accessors[f.POSITION],d=m.min,g=m.max;if(d!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),m.normalized){const y=oo(Ut[m.componentType]);c.multiplyScalar(y)}i.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(i)}a.boundingBox=o;const s=new l.Sphere;o.getCenter(s.center),s.radius=o.min.distanceTo(o.max)/2,a.boundingSphere=s}function Tr(a,e,t){const n=e.attributes,o=[];function r(s,i){return t.getDependency("accessor",s).then(function(c){a.setAttribute(i,c)})}for(const s in n){const i=eo[s]||s.toLowerCase();i in a.attributes||o.push(r(n[s],i))}if(e.indices!==void 0&&!a.index){const s=t.getDependency("accessor",e.indices).then(function(i){a.setIndex(i)});o.push(s)}return ct(a,e),Gl(a,e,t),Promise.all(o).then(function(){return e.targets!==void 0?Bl(a,e.targets,t):a})}const Qt=new l.Vector3;function qe(a,e,t,n,o,r){const s=2*Math.PI*o/4,i=Math.max(r-2*o,0),c=Math.PI/4;Qt.copy(e),Qt[n]=0,Qt.normalize();const h=.5*s/(s+i),p=1-Qt.angleTo(a)/c;return Math.sign(Qt[t])===1?p*h:i/(s+i)+h+h*(1-p)}class Rl extends l.BoxGeometry{constructor(e=1,t=1,n=1,o=2,r=.1){if(o=o*2+1,r=Math.min(e/2,t/2,n/2,r),super(1,1,1,o,o,o),o===1)return;const s=this.toNonIndexed();this.index=null,this.attributes.position=s.attributes.position,this.attributes.normal=s.attributes.normal,this.attributes.uv=s.attributes.uv;const i=new l.Vector3,c=new l.Vector3,h=new l.Vector3(e,t,n).divideScalar(2).subScalar(r),p=this.attributes.position.array,f=this.attributes.normal.array,m=this.attributes.uv.array,d=p.length/6,g=new l.Vector3,y=.5/o;for(let v=0,_=0;v<p.length;v+=3,_+=2)switch(i.fromArray(p,v),c.copy(i),c.x-=Math.sign(c.x)*y,c.y-=Math.sign(c.y)*y,c.z-=Math.sign(c.z)*y,c.normalize(),p[v+0]=h.x*Math.sign(i.x)+c.x*r,p[v+1]=h.y*Math.sign(i.y)+c.y*r,p[v+2]=h.z*Math.sign(i.z)+c.z*r,f[v+0]=c.x,f[v+1]=c.y,f[v+2]=c.z,Math.floor(v/d)){case 0:g.set(1,0,0),m[_+0]=qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 1:g.set(-1,0,0),m[_+0]=1-qe(g,c,"z","y",r,n),m[_+1]=1-qe(g,c,"y","z",r,t);break;case 2:g.set(0,1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=qe(g,c,"z","x",r,n);break;case 3:g.set(0,-1,0),m[_+0]=1-qe(g,c,"x","z",r,e),m[_+1]=1-qe(g,c,"z","x",r,n);break;case 4:g.set(0,0,1),m[_+0]=1-qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break;case 5:g.set(0,0,-1),m[_+0]=qe(g,c,"x","y",r,e),m[_+1]=1-qe(g,c,"y","x",r,t);break}}}class Ir extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:o=8,bevelThickness:r=10,font:s,height:i=50,size:c=100,lineHeight:h=1,letterSpacing:p=0,...f}=t;if(s===void 0)super();else{const m=s.generateShapes(e,c,{lineHeight:h,letterSpacing:p});super(m,{...f,bevelEnabled:n,bevelSize:o,bevelThickness:r,depth:i})}this.type="TextGeometry"}}const jl={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
493
493
|
varying vec2 vUv;
|
|
494
494
|
|
|
495
495
|
void main() {
|
|
@@ -556,10 +556,10 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
|
|
|
556
556
|
}
|
|
557
557
|
`};function Or(a,e,t){const n=t.length-a-1;if(e>=t[n])return n-1;if(e<=t[a])return a;let o=a,r=n,s=Math.floor((o+r)/2);for(;e<t[s]||e>=t[s+1];)e<t[s]?r=s:o=s,s=Math.floor((o+r)/2);return s}function Yl(a,e,t,n){const o=[],r=[],s=[];o[0]=1;for(let i=1;i<=t;++i){r[i]=e-n[a+1-i],s[i]=n[a+i]-e;let c=0;for(let h=0;h<i;++h){const p=s[h+1],f=r[i-h],m=o[h]/(p+f);o[h]=c+p*m,c=f*m}o[i]=c}return o}function Xl(a,e,t,n){const o=Or(a,n,e),r=Yl(o,n,a,e),s=new l.Vector4(0,0,0,0);for(let i=0;i<=a;++i){const c=t[o-a+i],h=r[i],p=c.w*h;s.x+=c.x*p,s.y+=c.y*p,s.z+=c.z*p,s.w+=c.w*h}return s}function El(a,e,t,n,o){const r=[];for(let f=0;f<=t;++f)r[f]=0;const s=[];for(let f=0;f<=n;++f)s[f]=r.slice(0);const i=[];for(let f=0;f<=t;++f)i[f]=r.slice(0);i[0][0]=1;const c=r.slice(0),h=r.slice(0);for(let f=1;f<=t;++f){c[f]=e-o[a+1-f],h[f]=o[a+f]-e;let m=0;for(let d=0;d<f;++d){const g=h[d+1],y=c[f-d];i[f][d]=g+y;const v=i[d][f-1]/i[f][d];i[d][f]=m+g*v,m=y*v}i[f][f]=m}for(let f=0;f<=t;++f)s[0][f]=i[f][t];for(let f=0;f<=t;++f){let m=0,d=1;const g=[];for(let y=0;y<=t;++y)g[y]=r.slice(0);g[0][0]=1;for(let y=1;y<=n;++y){let v=0;const _=f-y,A=t-y;f>=y&&(g[d][0]=g[m][0]/i[A+1][_],v=g[d][0]*i[_][A]);const b=_>=-1?1:-_,C=f-1<=A?y-1:t-f;for(let M=b;M<=C;++M)g[d][M]=(g[m][M]-g[m][M-1])/i[A+1][_+M],v+=g[d][M]*i[_+M][A];f<=A&&(g[d][y]=-g[m][y-1]/i[A+1][f],v+=g[d][y]*i[f][A]),s[y][f]=v;const L=m;m=d,d=L}}let p=t;for(let f=1;f<=n;++f){for(let m=0;m<=t;++m)s[f][m]*=p;p*=t-f}return s}function Zl(a,e,t,n,o){const r=o<a?o:a,s=[],i=Or(a,n,e),c=El(i,n,a,r,e),h=[];for(let p=0;p<t.length;++p){const f=t[p].clone(),m=f.w;f.x*=m,f.y*=m,f.z*=m,h[p]=f}for(let p=0;p<=r;++p){const f=h[i-a].clone().multiplyScalar(c[p][0]);for(let m=1;m<=a;++m)f.add(h[i-a+m].clone().multiplyScalar(c[p][m]));s[p]=f}for(let p=r+1;p<=o+1;++p)s[p]=new l.Vector4(0,0,0);return s}function Kl(a,e){let t=1;for(let o=2;o<=a;++o)t*=o;let n=1;for(let o=2;o<=e;++o)n*=o;for(let o=2;o<=a-e;++o)n*=o;return t/n}function ql(a){const e=a.length,t=[],n=[];for(let r=0;r<e;++r){const s=a[r];t[r]=new l.Vector3(s.x,s.y,s.z),n[r]=s.w}const o=[];for(let r=0;r<e;++r){const s=t[r].clone();for(let i=1;i<=r;++i)s.sub(o[r-i].clone().multiplyScalar(Kl(r,i)*n[i]));o[r]=s.divideScalar(n[0])}return o}function Ql(a,e,t,n,o){const r=Zl(a,e,t,n,o);return ql(r)}class Lr extends l.Curve{constructor(e,t,n,o,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=o||0,this.endKnot=r||this.knots.length-1;for(let s=0;s<n.length;++s){const i=n[s];this.controlPoints[s]=new l.Vector4(i.x,i.y,i.z,i.w)}}getPoint(e,t){const n=t||new l.Vector3,o=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=Xl(this.degree,this.knots,this.controlPoints,o);return r.w!=1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t){const n=t||new l.Vector3,o=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=Ql(this.degree,this.knots,this.controlPoints,o,1);return n.copy(r[1]).normalize(),n}}let xe,De,Re;class Jl extends l.Loader{constructor(e){super(e)}load(e,t,n,o){const r=this,s=r.path===""?l.LoaderUtils.extractUrlBase(e):r.path,i=new l.FileLoader(this.manager);i.setPath(r.path),i.setResponseType("arraybuffer"),i.setRequestHeader(r.requestHeader),i.setWithCredentials(r.withCredentials),i.load(e,function(c){try{t(r.parse(c,s))}catch(h){o?o(h):console.error(h),r.manager.itemError(e)}},n,o)}parse(e,t){if(oc(e))xe=new nc().parse(e);else{const o=Fr(e);if(!rc(o))throw new Error("THREE.FBXLoader: Unknown format.");if(Br(o)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Br(o));xe=new tc().parse(o)}const n=new l.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Hl(n,this.manager).parse(xe)}}class Hl{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){De=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),o=this.parseDeformers(),r=new $l().parse(o);return this.parseScene(o,r,n),Re}parseConnections(){const e=new Map;return"Connections"in xe&&xe.Connections.connections.forEach(function(n){const o=n[0],r=n[1],s=n[2];e.has(o)||e.set(o,{parents:[],children:[]});const i={ID:r,relationship:s};e.get(o).parents.push(i),e.has(r)||e.set(r,{parents:[],children:[]});const c={ID:o,relationship:s};e.get(r).children.push(c)}),e}parseImages(){const e={},t={};if("Video"in xe.Objects){const n=xe.Objects.Video;for(const o in n){const r=n[o],s=parseInt(o);if(e[s]=r.RelativeFilename||r.Filename,"Content"in r){const i=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,c=typeof r.Content=="string"&&r.Content!=="";if(i||c){const h=this.parseImage(n[o]);t[r.RelativeFilename||r.Filename]=h}}}}for(const n in e){const o=e[n];t[o]!==void 0?e[n]=t[o]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,o=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(o){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:console.warn('FBXLoader: Image type "'+o+'" is not supported.');return}if(typeof t=="string")return"data:"+r+";base64,"+t;{const s=new Uint8Array(t);return window.URL.createObjectURL(new Blob([s],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in xe.Objects){const n=xe.Objects.Texture;for(const o in n){const r=this.parseTexture(n[o],e);t.set(parseInt(o),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const o=e.WrapModeU,r=e.WrapModeV,s=o!==void 0?o.value:0,i=r!==void 0?r.value:0;if(n.wrapS=s===0?l.RepeatWrapping:l.ClampToEdgeWrapping,n.wrapT=i===0?l.RepeatWrapping:l.ClampToEdgeWrapping,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}return n}loadTexture(e,t){let n;const o=this.textureLoader.path,r=De.get(e.id).children;r!==void 0&&r.length>0&&t[r[0].ID]!==void 0&&(n=t[r[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let s;const i=e.FileName.slice(-3).toLowerCase();if(i==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new l.Texture):(c.setPath(this.textureLoader.path),s=c.load(n))}else i==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new l.Texture):s=this.textureLoader.load(n);return this.textureLoader.setPath(o),s}parseMaterials(e){const t=new Map;if("Material"in xe.Objects){const n=xe.Objects.Material;for(const o in n){const r=this.parseMaterial(n[o],e);r!==null&&t.set(parseInt(o),r)}}return t}parseMaterial(e,t){const n=e.id,o=e.attrName;let r=e.ShadingModel;if(typeof r=="object"&&(r=r.value),!De.has(n))return null;const s=this.parseParameters(e,t,n);let i;switch(r.toLowerCase()){case"phong":i=new l.MeshPhongMaterial;break;case"lambert":i=new l.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),i=new l.MeshPhongMaterial;break}return i.setValues(s),i.name=o,i}parseParameters(e,t,n){const o={};e.BumpFactor&&(o.bumpScale=e.BumpFactor.value),e.Diffuse?o.color=new l.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(o.color=new l.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(o.displacementScale=e.DisplacementFactor.value),e.Emissive?o.emissive=new l.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(o.emissive=new l.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(o.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(o.opacity=parseFloat(e.Opacity.value)),o.opacity<1&&(o.transparent=!0),e.ReflectionFactor&&(o.reflectivity=e.ReflectionFactor.value),e.Shininess&&(o.shininess=e.Shininess.value),e.Specular?o.specular=new l.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(o.specular=new l.Color().fromArray(e.SpecularColor.value));const r=this;return De.get(n).children.forEach(function(s){const i=s.relationship;switch(i){case"Bump":o.bumpMap=r.getTexture(t,s.ID);break;case"Maya|TEX_ao_map":o.aoMap=r.getTexture(t,s.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=r.getTexture(t,s.ID),o.map!==void 0&&("colorSpace"in o.map?o.map.colorSpace="srgb":o.map.encoding=3001);break;case"DisplacementColor":o.displacementMap=r.getTexture(t,s.ID);break;case"EmissiveColor":o.emissiveMap=r.getTexture(t,s.ID),o.emissiveMap!==void 0&&("colorSpace"in o.emissiveMap?o.emissiveMap.colorSpace="srgb":o.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=r.getTexture(t,s.ID);break;case"ReflectionColor":o.envMap=r.getTexture(t,s.ID),o.envMap!==void 0&&(o.envMap.mapping=l.EquirectangularReflectionMapping,"colorSpace"in o.envMap?o.envMap.colorSpace="srgb":o.envMap.encoding=3001);break;case"SpecularColor":o.specularMap=r.getTexture(t,s.ID),o.specularMap!==void 0&&("colorSpace"in o.specularMap?o.specularMap.colorSpace="srgb":o.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=r.getTexture(t,s.ID),o.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",i);break}}),o}getTexture(e,t){return"LayeredTexture"in xe.Objects&&t in xe.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=De.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in xe.Objects){const n=xe.Objects.Deformer;for(const o in n){const r=n[o],s=De.get(parseInt(o));if(r.attrType==="Skin"){const i=this.parseSkeleton(s,n);i.ID=o,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),i.geometryID=s.parents[0].ID,e[o]=i}else if(r.attrType==="BlendShape"){const i={id:o};i.rawTargets=this.parseMorphTargets(s,n),i.id=o,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[o]=i}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(o){const r=t[o.ID];if(r.attrType!=="Cluster")return;const s={ID:o.ID,indices:[],weights:[],transformLink:new l.Matrix4().fromArray(r.TransformLink.a)};"Indexes"in r&&(s.indices=r.Indexes.a,s.weights=r.Weights.a),n.push(s)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let o=0;o<e.children.length;o++){const r=e.children[o],s=t[r.ID],i={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if(s.attrType!=="BlendShapeChannel")return;i.geoID=De.get(parseInt(r.ID)).children.filter(function(c){return c.relationship===void 0})[0].ID,n.push(i)}return n}parseScene(e,t,n){Re=new l.Group;const o=this.parseModels(e.skeletons,t,n),r=xe.Objects.Model,s=this;o.forEach(function(c){const h=r[c.ID];s.setLookAtProperties(c,h),De.get(c.ID).parents.forEach(function(f){const m=o.get(f.ID);m!==void 0&&m.add(c)}),c.parent===null&&Re.add(c)}),this.bindSkeleton(e.skeletons,t,o),this.createAmbientLight(),Re.traverse(function(c){if(c.userData.transformData){c.parent&&(c.userData.transformData.parentMatrix=c.parent.matrix,c.userData.transformData.parentMatrixWorld=c.parent.matrixWorld);const h=Ur(c.userData.transformData);c.applyMatrix4(h),c.updateWorldMatrix()}});const i=new ec().parse();Re.children.length===1&&Re.children[0].isGroup&&(Re.children[0].animations=i,Re=Re.children[0]),Re.animations=i}parseModels(e,t,n){const o=new Map,r=xe.Objects.Model;for(const s in r){const i=parseInt(s),c=r[s],h=De.get(i);let p=this.buildSkeleton(h,e,i,c.attrName);if(!p){switch(c.attrType){case"Camera":p=this.createCamera(h);break;case"Light":p=this.createLight(h);break;case"Mesh":p=this.createMesh(h,t,n);break;case"NurbsCurve":p=this.createCurve(h,t);break;case"LimbNode":case"Root":p=new l.Bone;break;case"Null":default:p=new l.Group;break}p.name=c.attrName?l.PropertyBinding.sanitizeNodeName(c.attrName):"",p.ID=i}this.getTransformData(p,c),o.set(i,p)}return o}buildSkeleton(e,t,n,o){let r=null;return e.parents.forEach(function(s){for(const i in t){const c=t[i];c.rawBones.forEach(function(h,p){if(h.ID===s.ID){const f=r;r=new l.Bone,r.matrixWorld.copy(h.transformLink),r.name=o?l.PropertyBinding.sanitizeNodeName(o):"",r.ID=n,c.bones[p]=r,f!==null&&r.add(f)}})}}),r}createCamera(e){let t,n;if(e.children.forEach(function(o){const r=xe.Objects.NodeAttribute[o.ID];r!==void 0&&(n=r)}),n===void 0)t=new l.Object3D;else{let o=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(o=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let s=1e3;n.FarPlane!==void 0&&(s=n.FarPlane.value/1e3);let i=window.innerWidth,c=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(i=n.AspectWidth.value,c=n.AspectHeight.value);const h=i/c;let p=45;n.FieldOfView!==void 0&&(p=n.FieldOfView.value);const f=n.FocalLength?n.FocalLength.value:null;switch(o){case 0:t=new l.PerspectiveCamera(p,h,r,s),f!==null&&t.setFocalLength(f);break;case 1:t=new l.OrthographicCamera(-i/2,i/2,c/2,-c/2,r,s);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+o+"."),t=new l.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(o){const r=xe.Objects.NodeAttribute[o.ID];r!==void 0&&(n=r)}),n===void 0)t=new l.Object3D;else{let o;n.LightType===void 0?o=0:o=n.LightType.value;let r=16777215;n.Color!==void 0&&(r=new l.Color().fromArray(n.Color.value));let s=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(s=0);let i=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?i=0:i=n.FarAttenuationEnd.value);const c=1;switch(o){case 0:t=new l.PointLight(r,s,i,c);break;case 1:t=new l.DirectionalLight(r,s);break;case 2:let h=Math.PI/3;n.InnerAngle!==void 0&&(h=l.MathUtils.degToRad(n.InnerAngle.value));let p=0;n.OuterAngle!==void 0&&(p=l.MathUtils.degToRad(n.OuterAngle.value),p=Math.max(p,1)),t=new l.SpotLight(r,s,i,h,p,c);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new l.PointLight(r,s);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let o,r=null,s=null;const i=[];return e.children.forEach(function(c){t.has(c.ID)&&(r=t.get(c.ID)),n.has(c.ID)&&i.push(n.get(c.ID))}),i.length>1?s=i:i.length>0?s=i[0]:(s=new l.MeshPhongMaterial({color:13421772}),i.push(s)),"color"in r.attributes&&i.forEach(function(c){c.vertexColors=!0}),r.FBX_Deformer?(o=new l.SkinnedMesh(r,s),o.normalizeSkinWeights()):o=new l.Mesh(r,s),o}createCurve(e,t){const n=e.children.reduce(function(r,s){return t.has(s.ID)&&(r=t.get(s.ID)),r},null),o=new l.LineBasicMaterial({color:3342591,linewidth:1});return new l.Line(n,o)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Nr(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&De.get(e.ID).children.forEach(function(o){if(o.relationship==="LookAtProperty"){const r=xe.Objects.Model[o.ID];if("Lcl_Translation"in r){const s=r.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(s),Re.add(e.target)):e.lookAt(new l.Vector3().fromArray(s))}}})}bindSkeleton(e,t,n){const o=this.parsePoseNodes();for(const r in e){const s=e[r];De.get(parseInt(s.ID)).parents.forEach(function(c){if(t.has(c.ID)){const h=c.ID;De.get(h).parents.forEach(function(f){n.has(f.ID)&&n.get(f.ID).bind(new l.Skeleton(s.bones),o[f.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in xe.Objects){const t=xe.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const o=t[n].PoseNode;Array.isArray(o)?o.forEach(function(r){e[r.Node]=new l.Matrix4().fromArray(r.Matrix.a)}):e[o.Node]=new l.Matrix4().fromArray(o.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in xe&&"AmbientColor"in xe.GlobalSettings){const e=xe.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],o=e[2];if(t!==0||n!==0||o!==0){const r=new l.Color(t,n,o);Re.add(new l.AmbientLight(r,1))}}}}class $l{parse(e){const t=new Map;if("Geometry"in xe.Objects){const n=xe.Objects.Geometry;for(const o in n){const r=De.get(parseInt(o)),s=this.parseGeometry(r,n[o],e);t.set(parseInt(o),s)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const o=n.skeletons,r=[],s=e.parents.map(function(f){return xe.Objects.Model[f.ID]});if(s.length===0)return;const i=e.children.reduce(function(f,m){return o[m.ID]!==void 0&&(f=o[m.ID]),f},null);e.children.forEach(function(f){n.morphTargets[f.ID]!==void 0&&r.push(n.morphTargets[f.ID])});const c=s[0],h={};"RotationOrder"in c&&(h.eulerOrder=Nr(c.RotationOrder.value)),"InheritType"in c&&(h.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(h.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(h.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(h.scale=c.GeometricScaling.value);const p=Ur(h);return this.genGeometry(t,i,r,p)}genGeometry(e,t,n,o){const r=new l.BufferGeometry;e.attrName&&(r.name=e.attrName);const s=this.parseGeoNode(e,t),i=this.genBuffers(s),c=new l.Float32BufferAttribute(i.vertex,3);if(c.applyMatrix4(o),r.setAttribute("position",c),i.colors.length>0&&r.setAttribute("color",new l.Float32BufferAttribute(i.colors,3)),t&&(r.setAttribute("skinIndex",new l.Uint16BufferAttribute(i.weightsIndices,4)),r.setAttribute("skinWeight",new l.Float32BufferAttribute(i.vertexWeights,4)),r.FBX_Deformer=t),i.normal.length>0){const h=new l.Matrix3().getNormalMatrix(o),p=new l.Float32BufferAttribute(i.normal,3);p.applyNormalMatrix(h),r.setAttribute("normal",p)}if(i.uvs.forEach(function(h,p){Gn==="uv2"&&p++;const f=p===0?"uv":`uv${p}`;r.setAttribute(f,new l.Float32BufferAttribute(i.uvs[p],2))}),s.material&&s.material.mappingType!=="AllSame"){let h=i.materialIndex[0],p=0;if(i.materialIndex.forEach(function(f,m){f!==h&&(r.addGroup(p,m-p,h),h=f,p=m)}),r.groups.length>0){const f=r.groups[r.groups.length-1],m=f.start+f.count;m!==i.materialIndex.length&&r.addGroup(m,i.materialIndex.length-m,h)}r.groups.length===0&&r.addGroup(0,i.materialIndex.length,i.materialIndex[0])}return this.addMorphTargets(r,e,n,o),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let o=0;for(;e.LayerElementUV[o];)e.LayerElementUV[o].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[o])),o++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(o,r){o.indices.forEach(function(s,i){n.weightTable[s]===void 0&&(n.weightTable[s]=[]),n.weightTable[s].push({id:r,weight:o.weights[i]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,o=0,r=!1,s=[],i=[],c=[],h=[],p=[],f=[];const m=this;return e.vertexIndices.forEach(function(d,g){let y,v=!1;d<0&&(d=d^-1,v=!0);let _=[],A=[];if(s.push(d*3,d*3+1,d*3+2),e.color){const b=_n(g,n,d,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[d]!==void 0&&e.weightTable[d].forEach(function(b){A.push(b.weight),_.push(b.id)}),A.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const b=[0,0,0,0],C=[0,0,0,0];A.forEach(function(L,M){let P=L,w=_[M];C.forEach(function(S,x,I){if(P>S){I[x]=P,P=S;const D=b[x];b[x]=w,w=D}})}),_=b,A=C}for(;A.length<4;)A.push(0),_.push(0);for(let b=0;b<4;++b)p.push(A[b]),f.push(_[b])}if(e.normal){const b=_n(g,n,d,e.normal);i.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(y=_n(g,n,d,e.material)[0]),e.uv&&e.uv.forEach(function(b,C){const L=_n(g,n,d,b);h[C]===void 0&&(h[C]=[]),h[C].push(L[0]),h[C].push(L[1])}),o++,v&&(m.genFace(t,e,s,y,i,c,h,p,f,o),n++,o=0,s=[],i=[],c=[],h=[],p=[],f=[])}),t}genFace(e,t,n,o,r,s,i,c,h,p){for(let f=2;f<p;f++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(f-1)*3]]),e.vertex.push(t.vertexPositions[n[(f-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(f-1)*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),t.skeleton&&(e.vertexWeights.push(c[0]),e.vertexWeights.push(c[1]),e.vertexWeights.push(c[2]),e.vertexWeights.push(c[3]),e.vertexWeights.push(c[(f-1)*4]),e.vertexWeights.push(c[(f-1)*4+1]),e.vertexWeights.push(c[(f-1)*4+2]),e.vertexWeights.push(c[(f-1)*4+3]),e.vertexWeights.push(c[f*4]),e.vertexWeights.push(c[f*4+1]),e.vertexWeights.push(c[f*4+2]),e.vertexWeights.push(c[f*4+3]),e.weightsIndices.push(h[0]),e.weightsIndices.push(h[1]),e.weightsIndices.push(h[2]),e.weightsIndices.push(h[3]),e.weightsIndices.push(h[(f-1)*4]),e.weightsIndices.push(h[(f-1)*4+1]),e.weightsIndices.push(h[(f-1)*4+2]),e.weightsIndices.push(h[(f-1)*4+3]),e.weightsIndices.push(h[f*4]),e.weightsIndices.push(h[f*4+1]),e.weightsIndices.push(h[f*4+2]),e.weightsIndices.push(h[f*4+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[(f-1)*3]),e.colors.push(s[(f-1)*3+1]),e.colors.push(s[(f-1)*3+2]),e.colors.push(s[f*3]),e.colors.push(s[f*3+1]),e.colors.push(s[f*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(o),e.materialIndex.push(o),e.materialIndex.push(o)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[(f-1)*3]),e.normal.push(r[(f-1)*3+1]),e.normal.push(r[(f-1)*3+2]),e.normal.push(r[f*3]),e.normal.push(r[f*3+1]),e.normal.push(r[f*3+2])),t.uv&&t.uv.forEach(function(m,d){e.uvs[d]===void 0&&(e.uvs[d]=[]),e.uvs[d].push(i[d][0]),e.uvs[d].push(i[d][1]),e.uvs[d].push(i[d][(f-1)*2]),e.uvs[d].push(i[d][(f-1)*2+1]),e.uvs[d].push(i[d][f*2]),e.uvs[d].push(i[d][f*2+1])})}addMorphTargets(e,t,n,o){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach(function(s){s.rawTargets.forEach(function(i){const c=xe.Objects.Geometry[i.geoID];c!==void 0&&r.genMorphGeometry(e,t,c,o,i.name)})})}genMorphGeometry(e,t,n,o,r){const s=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],i=n.Vertices!==void 0?n.Vertices.a:[],c=n.Indexes!==void 0?n.Indexes.a:[],h=e.attributes.position.count*3,p=new Float32Array(h);for(let g=0;g<c.length;g++){const y=c[g]*3;p[y]=i[g*3],p[y+1]=i[g*3+1],p[y+2]=i[g*3+2]}const f={vertexIndices:s,vertexPositions:p},m=this.genBuffers(f),d=new l.Float32BufferAttribute(m.vertex,3);d.name=r||n.attrName,d.applyMatrix4(o),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,o=e.Normals.a;let r=[];return n==="IndexToDirect"&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:o,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,o=e.UV.a;let r=[];return n==="IndexToDirect"&&(r=e.UVIndex.a),{dataSize:2,buffer:o,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,o=e.Colors.a;let r=[];return n==="IndexToDirect"&&(r=e.ColorIndex.a),{dataSize:4,buffer:o,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const o=e.Materials.a,r=[];for(let s=0;s<o.length;++s)r.push(s);return{dataSize:1,buffer:o,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(Lr===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new l.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new l.BufferGeometry;const n=t-1,o=e.KnotVector.a,r=[],s=e.Points.a;for(let f=0,m=s.length;f<m;f+=4)r.push(new l.Vector4().fromArray(s,f));let i,c;if(e.Form==="Closed")r.push(r[0]);else if(e.Form==="Periodic"){i=n,c=o.length-1-i;for(let f=0;f<n;++f)r.push(r[f])}const p=new Lr(n,o,r,i,c).getPoints(r.length*12);return new l.BufferGeometry().setFromPoints(p)}}class ec{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const o=t[n],r=this.addClip(o);e.push(r)}return e}parseClips(){if(xe.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=xe.Objects.AnimationCurveNode,t=new Map;for(const n in e){const o=e[n];if(o.attrName.match(/S|R|T|DeformPercent/)!==null){const r={id:o.id,attr:o.attrName,curves:{}};t.set(r.id,r)}}return t}parseAnimationCurves(e){const t=xe.Objects.AnimationCurve;for(const n in t){const o={id:t[n].id,times:t[n].KeyTime.a.map(sc),values:t[n].KeyValueFloat.a},r=De.get(o.id);if(r!==void 0){const s=r.parents[0].ID,i=r.parents[0].relationship;i.match(/X/)?e.get(s).curves.x=o:i.match(/Y/)?e.get(s).curves.y=o:i.match(/Z/)?e.get(s).curves.z=o:i.match(/d|DeformPercent/)&&e.has(s)&&(e.get(s).curves.morph=o)}}}parseAnimationLayers(e){const t=xe.Objects.AnimationLayer,n=new Map;for(const o in t){const r=[],s=De.get(parseInt(o));s!==void 0&&(s.children.forEach(function(c,h){if(e.has(c.ID)){const p=e.get(c.ID);if(p.curves.x!==void 0||p.curves.y!==void 0||p.curves.z!==void 0){if(r[h]===void 0){const f=De.get(c.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID;if(f!==void 0){const m=xe.Objects.Model[f.toString()];if(m===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",c);return}const d={modelName:m.attrName?l.PropertyBinding.sanitizeNodeName(m.attrName):"",ID:m.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Re.traverse(function(g){g.ID===m.id&&(d.transform=g.matrix,g.userData.transformData&&(d.eulerOrder=g.userData.transformData.eulerOrder))}),d.transform||(d.transform=new l.Matrix4),"PreRotation"in m&&(d.preRotation=m.PreRotation.value),"PostRotation"in m&&(d.postRotation=m.PostRotation.value),r[h]=d}}r[h]&&(r[h][p.attr]=p)}else if(p.curves.morph!==void 0){if(r[h]===void 0){const f=De.get(c.ID).parents.filter(function(_){return _.relationship!==void 0})[0].ID,m=De.get(f).parents[0].ID,d=De.get(m).parents[0].ID,g=De.get(d).parents[0].ID,y=xe.Objects.Model[g],v={modelName:y.attrName?l.PropertyBinding.sanitizeNodeName(y.attrName):"",morphName:xe.Objects.Deformer[f].attrName};r[h]=v}r[h][p.attr]=p}}}),n.set(parseInt(o),r))}return n}parseAnimStacks(e){const t=xe.Objects.AnimationStack,n={};for(const o in t){const r=De.get(parseInt(o)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(r[0].ID);n[o]={name:t[o].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(o){t=t.concat(n.generateTracks(o))}),new l.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new l.Vector3,o=new l.Quaternion,r=new l.Vector3;if(e.transform&&e.transform.decompose(n,o,r),n=n.toArray(),o=new l.Euler().setFromQuaternion(o,e.eulerOrder).toArray(),r=r.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");s!==void 0&&t.push(s)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const s=this.generateRotationTrack(e.modelName,e.R.curves,o,e.preRotation,e.postRotation,e.eulerOrder);s!==void 0&&t.push(s)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const s=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");s!==void 0&&t.push(s)}if(e.DeformPercent!==void 0){const s=this.generateMorphTrack(e);s!==void 0&&t.push(s)}return t}generateVectorTrack(e,t,n,o){const r=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(r,t,n);return new l.VectorKeyframeTrack(e+"."+o,r,s)}generateRotationTrack(e,t,n,o,r,s){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(l.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(l.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(l.MathUtils.degToRad));const i=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(i,t,n);o!==void 0&&(o=o.map(l.MathUtils.degToRad),o.push(s),o=new l.Euler().fromArray(o),o=new l.Quaternion().setFromEuler(o)),r!==void 0&&(r=r.map(l.MathUtils.degToRad),r.push(s),r=new l.Euler().fromArray(r),r=new l.Quaternion().setFromEuler(r).invert());const h=new l.Quaternion,p=new l.Euler,f=[];for(let m=0;m<c.length;m+=3)p.set(c[m],c[m+1],c[m+2],s),h.setFromEuler(p),o!==void 0&&h.premultiply(o),r!==void 0&&h.multiply(r),h.toArray(f,m/3*4);return new l.QuaternionKeyframeTrack(e+".quaternion",i,f)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(r){return r/100}),o=Re.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+o+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,o){return n-o}),t.length>1){let n=1,o=t[0];for(let r=1;r<t.length;r++){const s=t[r];s!==o&&(t[n]=s,o=s,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const o=n,r=[];let s=-1,i=-1,c=-1;return e.forEach(function(h){if(t.x&&(s=t.x.times.indexOf(h)),t.y&&(i=t.y.times.indexOf(h)),t.z&&(c=t.z.times.indexOf(h)),s!==-1){const p=t.x.values[s];r.push(p),o[0]=p}else r.push(o[0]);if(i!==-1){const p=t.y.values[i];r.push(p),o[1]=p}else r.push(o[1]);if(c!==-1){const p=t.z.values[c];r.push(p),o[2]=p}else r.push(o[2])}),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],o=e.values[t]-n,r=Math.abs(o);if(r>=180){const s=r/180,i=o/s;let c=n+i;const h=e.times[t-1],f=(e.times[t]-h)/s;let m=h+f;const d=[],g=[];for(;m<e.times[t];)d.push(m),m+=f,g.push(c),c+=i;e.times=zr(e.times,t,d),e.values=zr(e.values,t,g)}}}}class tc{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new kr,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(o,r){const s=o.match(/^[\s\t]*;/),i=o.match(/^[\s\t]*$/);if(s||i)return;const c=o.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),h=o.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),p=o.match("^\\t{"+(t.currentIndent-1)+"}}");c?t.parseNodeBegin(o,c):h?t.parseNodeProperty(o,h,n[++r]):p?t.popStack():o.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(o)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),o=t[2].split(",").map(function(c){return c.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:n},s=this.parseNodeAttr(o),i=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,r):n in i?(n==="PoseNode"?i.PoseNode.push(r):i[n].id!==void 0&&(i[n]={},i[n][i[n].id]=i[n]),s.id!==""&&(i[n][s.id]=r)):typeof s.id=="number"?(i[n]={},i[n][s.id]=r):n!=="Properties70"&&(n==="PoseNode"?i[n]=[r]:i[n]=r),typeof s.id=="number"&&(r.id=s.id),s.name!==""&&(r.attrName=s.name),s.type!==""&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",o="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),o=e[2]),{id:t,name:n,type:o}}parseNodeProperty(e,t,n){let o=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();o==="Content"&&r===","&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if(s.name==="Properties70"){this.parseNodeSpecialProperty(e,o,r);return}if(o==="C"){const c=r.split(",").slice(1),h=parseInt(c[0]),p=parseInt(c[1]);let f=r.split(",").slice(3);f=f.map(function(m){return m.trim().replace(/^"/,"")}),o="connections",r=[h,p],ac(r,f),s[o]===void 0&&(s[o]=[])}o==="Node"&&(s.id=r),o in s&&Array.isArray(s[o])?s[o].push(r):o!=="a"?s[o]=r:s.a=r,this.setCurrentProp(s,o),o==="a"&&r.slice(-1)!==","&&(s.a=so(r))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=so(t.a))}parseNodeSpecialProperty(e,t,n){const o=n.split('",').map(function(p){return p.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=o[0],s=o[1],i=o[2],c=o[3];let h=o[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":h=parseFloat(h);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":h=so(h);break}this.getPrevNode()[r]={type:s,type2:i,flag:c,value:h},this.setCurrentProp(this.getPrevNode(),r)}}class nc{parse(e){const t=new Dr(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const o=new kr;for(;!this.endOfContent(t);){const r=this.parseNode(t,n);r!==null&&o.add(r.name,r)}return o}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},o=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),i=e.getString(s);if(o===0)return null;const c=[];for(let m=0;m<r;m++)c.push(this.parseProperty(e));const h=c.length>0?c[0]:"",p=c.length>1?c[1]:"",f=c.length>2?c[2]:"";for(n.singleProperty=r===1&&e.getOffset()===o;o>e.getOffset();){const m=this.parseNode(e,t);m!==null&&this.parseSubNode(i,n,m)}return n.propertyList=c,typeof h=="number"&&(n.id=h),p!==""&&(n.attrName=p),f!==""&&(n.attrType=f),i!==""&&(n.name=i),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const o=n.propertyList[0];Array.isArray(o)?(t[n.name]=n,n.a=o):t[n.name]=o}else if(e==="Connections"&&n.name==="C"){const o=[];n.propertyList.forEach(function(r,s){s!==0&&o.push(r)}),t.connections===void 0&&(t.connections=[]),t.connections.push(o)}else if(n.name==="Properties70")Object.keys(n).forEach(function(r){t[r]=n[r]});else if(e==="Properties70"&&n.name==="P"){let o=n.propertyList[0],r=n.propertyList[1];const s=n.propertyList[2],i=n.propertyList[3];let c;o.indexOf("Lcl ")===0&&(o=o.replace("Lcl ","Lcl_")),r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),r==="Color"||r==="ColorRGB"||r==="Vector"||r==="Vector3D"||r.indexOf("Lcl_")===0?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[o]={type:r,type2:s,flag:i,value:c}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const o=e.getUint32(),r=e.getUint32(),s=e.getUint32();if(r===0)switch(t){case"b":case"c":return e.getBooleanArray(o);case"d":return e.getFloat64Array(o);case"f":return e.getFloat32Array(o);case"i":return e.getInt32Array(o);case"l":return e.getInt64Array(o)}const i=Da(new Uint8Array(e.getArrayBuffer(s))),c=new Dr(i.buffer);switch(t){case"b":case"c":return c.getBooleanArray(o);case"d":return c.getFloat64Array(o);case"f":return c.getFloat32Array(o);case"i":return c.getInt32Array(o);case"l":return c.getInt64Array(o)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Dr{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let o=0;o<e;o++)t[o]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Bt(new Uint8Array(t))}}class kr{add(e,t){this[e]=t}}function oc(a){const e="Kaydara FBX Binary \0";return a.byteLength>=e.length&&e===Fr(a,0,e.length)}function rc(a){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(o){const r=a[o-1];return a=a.slice(t+o),t++,r}for(let o=0;o<e.length;++o)if(n(1)===e[o])return!1;return!0}function Br(a){const e=/FBXVersion: (\d+)/,t=a.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function sc(a){return a/46186158e3}const ic=[];function _n(a,e,t,n){let o;switch(n.mappingType){case"ByPolygonVertex":o=a;break;case"ByPolygon":o=e;break;case"ByVertice":o=t;break;case"AllSame":o=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(o=n.indices[o]);const r=o*n.dataSize,s=r+n.dataSize;return lc(ic,n.buffer,r,s)}const ro=new l.Euler,Nt=new l.Vector3;function Ur(a){const e=new l.Matrix4,t=new l.Matrix4,n=new l.Matrix4,o=new l.Matrix4,r=new l.Matrix4,s=new l.Matrix4,i=new l.Matrix4,c=new l.Matrix4,h=new l.Matrix4,p=new l.Matrix4,f=new l.Matrix4,m=new l.Matrix4,d=a.inheritType?a.inheritType:0;if(a.translation&&e.setPosition(Nt.fromArray(a.translation)),a.preRotation){const x=a.preRotation.map(l.MathUtils.degToRad);x.push(a.eulerOrder),t.makeRotationFromEuler(ro.fromArray(x))}if(a.rotation){const x=a.rotation.map(l.MathUtils.degToRad);x.push(a.eulerOrder),n.makeRotationFromEuler(ro.fromArray(x))}if(a.postRotation){const x=a.postRotation.map(l.MathUtils.degToRad);x.push(a.eulerOrder),o.makeRotationFromEuler(ro.fromArray(x)),o.invert()}a.scale&&r.scale(Nt.fromArray(a.scale)),a.scalingOffset&&i.setPosition(Nt.fromArray(a.scalingOffset)),a.scalingPivot&&s.setPosition(Nt.fromArray(a.scalingPivot)),a.rotationOffset&&c.setPosition(Nt.fromArray(a.rotationOffset)),a.rotationPivot&&h.setPosition(Nt.fromArray(a.rotationPivot)),a.parentMatrixWorld&&(f.copy(a.parentMatrix),p.copy(a.parentMatrixWorld));const g=t.clone().multiply(n).multiply(o),y=new l.Matrix4;y.extractRotation(p);const v=new l.Matrix4;v.copyPosition(p);const _=v.clone().invert().multiply(p),A=y.clone().invert().multiply(_),b=r,C=new l.Matrix4;if(d===0)C.copy(y).multiply(g).multiply(A).multiply(b);else if(d===1)C.copy(y).multiply(A).multiply(g).multiply(b);else{const I=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(f)).clone().invert(),D=A.clone().multiply(I);C.copy(y).multiply(g).multiply(D).multiply(b)}const L=h.clone().invert(),M=s.clone().invert();let P=e.clone().multiply(c).multiply(h).multiply(t).multiply(n).multiply(o).multiply(L).multiply(i).multiply(s).multiply(r).multiply(M);const w=new l.Matrix4().copyPosition(P),S=p.clone().multiply(w);return m.copyPosition(S),P=m.clone().multiply(C),P.premultiply(p.invert()),P}function Nr(a){a=a||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return a===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[a]}function so(a){return a.split(",").map(function(t){return parseFloat(t)})}function Fr(a,e,t){return e===void 0&&(e=0),t===void 0&&(t=a.byteLength),Bt(new Uint8Array(a,e,t))}function ac(a,e){for(let t=0,n=a.length,o=e.length;t<o;t++,n++)a[n]=e[t]}function lc(a,e,t,n){for(let o=t,r=0;o<n;o++,r++)a[r]=e[o];return a}function zr(a,e,t){return a.slice(0,e).concat(t).concat(a.slice(e))}var cc=Object.defineProperty,uc=(a,e,t)=>e in a?cc(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,io=(a,e,t)=>(uc(a,typeof e!="symbol"?e+"":e,t),t);class hc extends l.Loader{constructor(e){super(e)}load(e,t,n,o){const r=new l.FileLoader(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,s=>{if(typeof s!="string")throw new Error("unsupported data type");const i=JSON.parse(s),c=this.parse(i);t&&t(c)},n,o)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new ao(e)}}class ao{constructor(e){io(this,"data"),this.data=e}generateShapes(e,t=100,n){const o=[],r={letterSpacing:0,lineHeight:1,...n},s=fc(e,t,this.data,r);for(let i=0,c=s.length;i<c;i++)Array.prototype.push.apply(o,s[i].toShapes(!1));return o}}io(ao,"isFont"),io(ao,"type");function fc(a,e,t,n){const o=Array.from(a),r=e/t.resolution,s=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*r,i=[];let c=0,h=0;for(let p=0;p<o.length;p++){const f=o[p];if(f===`
|
|
558
558
|
`)c=0,h-=s*n.lineHeight;else{const m=dc(f,r,c,h,t);m&&(c+=m.offsetX+n.letterSpacing,i.push(m.path))}}return i}function dc(a,e,t,n,o){const r=o.glyphs[a]||o.glyphs["?"];if(!r){console.error('THREE.Font: character "'+a+'" does not exists in font family '+o.familyName+".");return}const s=new l.ShapePath;let i,c,h,p,f,m,d,g;if(r.o){const y=r._cachedOutline||(r._cachedOutline=r.o.split(" "));for(let v=0,_=y.length;v<_;)switch(y[v++]){case"m":i=parseInt(y[v++])*e+t,c=parseInt(y[v++])*e+n,s.moveTo(i,c);break;case"l":i=parseInt(y[v++])*e+t,c=parseInt(y[v++])*e+n,s.lineTo(i,c);break;case"q":h=parseInt(y[v++])*e+t,p=parseInt(y[v++])*e+n,f=parseInt(y[v++])*e+t,m=parseInt(y[v++])*e+n,s.quadraticCurveTo(f,m,h,p);break;case"b":h=parseInt(y[v++])*e+t,p=parseInt(y[v++])*e+n,f=parseInt(y[v++])*e+t,m=parseInt(y[v++])*e+n,d=parseInt(y[v++])*e+t,g=parseInt(y[v++])*e+n,s.bezierCurveTo(f,m,d,g,h,p);break}}return{offsetX:r.ha*e,path:s}}class Vr extends l.DataTextureLoader{constructor(e){super(e),this.type=l.HalfFloatType}parse(e){const s=function(w,S){switch(w){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(S||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(S||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(S||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(S||""))}},p=`
|
|
559
|
-
`,f=function(w,S,x){S=S||1024;let D=w.pos,z=-1,G=0,
|
|
560
|
-
`;
|
|
561
|
-
`,
|
|
562
|
-
`;continue}if((E=X.match(x))&&(G.gamma=parseFloat(E[1])),(E=X.match(I))&&(G.exposure=parseFloat(E[1])),(E=X.match(D))&&(G.valid|=2,G.format=E[1]),(E=X.match(z))&&(G.valid|=4,G.height=parseInt(E[1],10),G.width=parseInt(E[2],10)),G.valid&2&&G.valid&4)break}return G.valid&2||s(3,"missing format specifier"),G.valid&4||s(3,"missing image size specifier"),G},d=function(w,S,x){const I=S;if(I<8||I>32767||w[0]!==2||w[1]!==2||w[2]&128)return new Uint8Array(w);I!==(w[2]<<8|w[3])&&s(3,"wrong scanline width");const D=new Uint8Array(4*S*x);D.length||s(4,"unable to allocate buffer space");let z=0,G=0;const X=4*I,E=new Uint8Array(4),te=new Uint8Array(X);let q=x;for(;q>0&&G<w.byteLength;){G+4>w.byteLength&&s(1),E[0]=w[G++],E[1]=w[G++],E[2]=w[G++],E[3]=w[G++],(E[0]!=2||E[1]!=2||(E[2]<<8|E[3])!=I)&&s(3,"bad rgbe scanline format");let oe=0,ne;for(;oe<X&&G<w.byteLength;){ne=w[G++];const le=ne>128;if(le&&(ne-=128),(ne===0||oe+ne>X)&&s(3,"bad scanline data"),le){const de=w[G++];for(let k=0;k<ne;k++)te[oe++]=de}else te.set(w.subarray(G,G+ne),oe),oe+=ne,G+=ne}const ce=I;for(let le=0;le<ce;le++){let de=0;D[z]=te[le+de],de+=I,D[z+1]=te[le+de],de+=I,D[z+2]=te[le+de],de+=I,D[z+3]=te[le+de],z+=4}q--}return D},g=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=w[S+0]*z,x[I+1]=w[S+1]*z,x[I+2]=w[S+2]*z,x[I+3]=1},y=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=l.DataUtils.toHalfFloat(Math.min(w[S+0]*z,65504)),x[I+1]=l.DataUtils.toHalfFloat(Math.min(w[S+1]*z,65504)),x[I+2]=l.DataUtils.toHalfFloat(Math.min(w[S+2]*z,65504)),x[I+3]=l.DataUtils.toHalfFloat(1)},v=new Uint8Array(e);v.pos=0;const _=m(v),A=_.width,b=_.height,C=d(v.subarray(v.pos),A,b);let L,M,P;switch(this.type){case l.FloatType:P=C.length/4;const w=new Float32Array(P*4);for(let x=0;x<P;x++)g(C,x*4,w,x*4);L=w,M=l.FloatType;break;case l.HalfFloatType:P=C.length/4;const S=new Uint16Array(P*4);for(let x=0;x<P;x++)y(C,x*4,S,x*4);L=S,M=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:A,height:b,data:L,header:_.string,gamma:_.gamma,exposure:_.exposure,type:M}}setDataType(e){return this.type=e,this}load(e,t,n,o){function r(s,i){switch(s.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in s?s.colorSpace="srgb-linear":s.encoding=3e3,s.minFilter=l.LinearFilter,s.magFilter=l.LinearFilter,s.generateMipmaps=!1,s.flipY=!0;break}t&&t(s,i)}return super.load(e,r,n,o)}}const pc="srgb";class Jt extends l.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,o){const r=this,s=new l.FileLoader(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(i){try{t(r.parse(i))}catch(c){o?o(c):console.error(c),r.manager.itemError(e)}},n,o)}parse(e){const t=this;function n(k,V){if(k.nodeType!==1)return;const U=C(k);let B=!1,R=null;switch(k.nodeName){case"svg":V=g(k,V);break;case"style":r(k);break;case"g":V=g(k,V);break;case"path":V=g(k,V),k.hasAttribute("d")&&(R=o(k));break;case"rect":V=g(k,V),R=c(k);break;case"polygon":V=g(k,V),R=h(k);break;case"polyline":V=g(k,V),R=p(k);break;case"circle":V=g(k,V),R=f(k);break;case"ellipse":V=g(k,V),R=m(k);break;case"line":V=g(k,V),R=d(k);break;case"defs":B=!0;break;case"use":V=g(k,V);const N=(k.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),K=k.viewportElement.getElementById(N);K?n(K,V):console.warn("SVGLoader: 'use node' references non-existent node id: "+N);break}R&&(V.fill!==void 0&&V.fill!=="none"&&R.color.setStyle(V.fill,pc),M(R,ce),D.push(R),R.userData={node:k,style:V});const T=k.childNodes;for(let O=0;O<T.length;O++){const N=T[O];B&&N.nodeName!=="style"&&N.nodeName!=="defs"||n(N,V)}U&&(G.pop(),G.length>0?ce.copy(G[G.length-1]):ce.identity())}function o(k){const V=new l.ShapePath,U=new l.Vector2,B=new l.Vector2,R=new l.Vector2;let T=!0,O=!1;const N=k.getAttribute("d");if(N===""||N==="none")return null;const K=N.match(/[a-df-z][^a-df-z]*/gi);for(let W=0,Y=K.length;W<Y;W++){const Q=K[W],re=Q.charAt(0),se=Q.slice(1).trim();T===!0&&(O=!0,T=!1);let j;switch(re){case"M":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"H":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"V":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"L":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"C":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(j[F+0],j[F+1],j[F+2],j[F+3],j[F+4],j[F+5]),B.x=j[F+2],B.y=j[F+3],U.x=j[F+4],U.y=j[F+5],F===0&&O===!0&&R.copy(U);break;case"S":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"Q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"T":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,j[F+0],j[F+1]),B.x=he,B.y=_e,U.x=j[F+0],U.y=j[F+1],F===0&&O===!0&&R.copy(U)}break;case"A":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==U.x&&j[F+6]==U.y)continue;const he=U.clone();U.x=j[F+5],U.y=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"m":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"h":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"v":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"l":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"c":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3],U.x+j[F+4],U.y+j[F+5]),B.x=U.x+j[F+2],B.y=U.y+j[F+3],U.x+=j[F+4],U.y+=j[F+5],F===0&&O===!0&&R.copy(U);break;case"s":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"t":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,U.x+j[F+0],U.y+j[F+1]),B.x=he,B.y=_e,U.x=U.x+j[F+0],U.y=U.y+j[F+1],F===0&&O===!0&&R.copy(U)}break;case"a":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==0&&j[F+6]==0)continue;const he=U.clone();U.x+=j[F+5],U.y+=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"Z":case"z":V.currentPath.autoClose=!0,V.currentPath.curves.length>0&&(U.copy(R),V.currentPath.currentPoint.copy(U),T=!0);break;default:console.warn(Q)}O=!1}return V}function r(k){if(!(!k.sheet||!k.sheet.cssRules||!k.sheet.cssRules.length))for(let V=0;V<k.sheet.cssRules.length;V++){const U=k.sheet.cssRules[V];if(U.type!==1)continue;const B=U.selectorText.split(/,/gm).filter(Boolean).map(R=>R.trim());for(let R=0;R<B.length;R++){const T=Object.fromEntries(Object.entries(U.style).filter(([,O])=>O!==""));z[B[R]]=Object.assign(z[B[R]]||{},T)}}}function s(k,V,U,B,R,T,O,N){if(V==0||U==0){k.lineTo(N.x,N.y);return}B=B*Math.PI/180,V=Math.abs(V),U=Math.abs(U);const K=(O.x-N.x)/2,W=(O.y-N.y)/2,Y=Math.cos(B)*K+Math.sin(B)*W,Q=-Math.sin(B)*K+Math.cos(B)*W;let re=V*V,se=U*U;const j=Y*Y,F=Q*Q,ie=j/re+F/se;if(ie>1){const it=Math.sqrt(ie);V=it*V,U=it*U,re=V*V,se=U*U}const he=re*F+se*j,_e=(re*se-he)/he;let Le=Math.sqrt(Math.max(0,_e));R===T&&(Le=-Le);const Pe=Le*V*Q/U,Je=-Le*U*Y/V,wt=Math.cos(B)*Pe-Math.sin(B)*Je+(O.x+N.x)/2,It=Math.sin(B)*Pe+Math.cos(B)*Je+(O.y+N.y)/2,st=i(1,0,(Y-Pe)/V,(Q-Je)/U),Ee=i((Y-Pe)/V,(Q-Je)/U,(-Y-Pe)/V,(-Q-Je)/U)%(Math.PI*2);k.currentPath.absellipse(wt,It,V,U,st,st+Ee,T===0,B)}function i(k,V,U,B){const R=k*U+V*B,T=Math.sqrt(k*k+V*V)*Math.sqrt(U*U+B*B);let O=Math.acos(Math.max(-1,Math.min(1,R/T)));return k*B-V*U<0&&(O=-O),O}function c(k){const V=b(k.getAttribute("x")||0),U=b(k.getAttribute("y")||0),B=b(k.getAttribute("rx")||k.getAttribute("ry")||0),R=b(k.getAttribute("ry")||k.getAttribute("rx")||0),T=b(k.getAttribute("width")),O=b(k.getAttribute("height")),N=1-.551915024494,K=new l.ShapePath;return K.moveTo(V+B,U),K.lineTo(V+T-B,U),(B!==0||R!==0)&&K.bezierCurveTo(V+T-B*N,U,V+T,U+R*N,V+T,U+R),K.lineTo(V+T,U+O-R),(B!==0||R!==0)&&K.bezierCurveTo(V+T,U+O-R*N,V+T-B*N,U+O,V+T-B,U+O),K.lineTo(V+B,U+O),(B!==0||R!==0)&&K.bezierCurveTo(V+B*N,U+O,V,U+O-R*N,V,U+O-R),K.lineTo(V,U+R),(B!==0||R!==0)&&K.bezierCurveTo(V,U+R*N,V+B*N,U,V+B,U),K}function h(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!0,B}function p(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!1,B}function f(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("r")||0),R=new l.Path;R.absarc(V,U,B,0,Math.PI*2);const T=new l.ShapePath;return T.subPaths.push(R),T}function m(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("rx")||0),R=b(k.getAttribute("ry")||0),T=new l.Path;T.absellipse(V,U,B,R,0,Math.PI*2);const O=new l.ShapePath;return O.subPaths.push(T),O}function d(k){const V=b(k.getAttribute("x1")||0),U=b(k.getAttribute("y1")||0),B=b(k.getAttribute("x2")||0),R=b(k.getAttribute("y2")||0),T=new l.ShapePath;return T.moveTo(V,U),T.lineTo(B,R),T.currentPath.autoClose=!1,T}function g(k,V){V=Object.assign({},V);let U={};if(k.hasAttribute("class")){const O=k.getAttribute("class").split(/\s/).filter(Boolean).map(N=>N.trim());for(let N=0;N<O.length;N++)U=Object.assign(U,z["."+O[N]])}k.hasAttribute("id")&&(U=Object.assign(U,z["#"+k.getAttribute("id")]));function B(O,N,K){K===void 0&&(K=function(Y){return Y.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),Y}),k.hasAttribute(O)&&(V[N]=K(k.getAttribute(O))),U[O]&&(V[N]=K(U[O])),k.style&&k.style[O]!==""&&(V[N]=K(k.style[O]))}function R(O){return Math.max(0,Math.min(1,b(O)))}function T(O){return Math.max(0,b(O))}return B("fill","fill"),B("fill-opacity","fillOpacity",R),B("fill-rule","fillRule"),B("opacity","opacity",R),B("stroke","stroke"),B("stroke-opacity","strokeOpacity",R),B("stroke-width","strokeWidth",T),B("stroke-linejoin","strokeLineJoin"),B("stroke-linecap","strokeLineCap"),B("stroke-miterlimit","strokeMiterLimit",T),B("visibility","visibility"),V}function y(k,V){return k-(V-k)}function v(k,V,U){if(typeof k!="string")throw new TypeError("Invalid input: "+typeof k);const B={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},R=0,T=1,O=2,N=3;let K=R,W=!0,Y="",Q="";const re=[];function se(he,_e,Le){const Pe=new SyntaxError('Unexpected character "'+he+'" at index '+_e+".");throw Pe.partial=Le,Pe}function j(){Y!==""&&(Q===""?re.push(Number(Y)):re.push(Number(Y)*Math.pow(10,Number(Q)))),Y="",Q=""}let F;const ie=k.length;for(let he=0;he<ie;he++){if(F=k[he],Array.isArray(V)&&V.includes(re.length%U)&&B.FLAGS.test(F)){K=T,Y=F,j();continue}if(K===R){if(B.WHITESPACE.test(F))continue;if(B.DIGIT.test(F)||B.SIGN.test(F)){K=T,Y=F;continue}if(B.POINT.test(F)){K=O,Y=F;continue}B.COMMA.test(F)&&(W&&se(F,he,re),W=!0)}if(K===T){if(B.DIGIT.test(F)){Y+=F;continue}if(B.POINT.test(F)){Y+=F,K=O;continue}if(B.EXP.test(F)){K=N;continue}B.SIGN.test(F)&&Y.length===1&&B.SIGN.test(Y[0])&&se(F,he,re)}if(K===O){if(B.DIGIT.test(F)){Y+=F;continue}if(B.EXP.test(F)){K=N;continue}B.POINT.test(F)&&Y[Y.length-1]==="."&&se(F,he,re)}if(K===N){if(B.DIGIT.test(F)){Q+=F;continue}if(B.SIGN.test(F)){if(Q===""){Q+=F;continue}Q.length===1&&B.SIGN.test(Q)&&se(F,he,re)}}B.WHITESPACE.test(F)?(j(),K=R,W=!1):B.COMMA.test(F)?(j(),K=R,W=!0):B.SIGN.test(F)?(j(),K=T,Y=F):B.POINT.test(F)?(j(),K=O,Y=F):se(F,he,re)}return j(),re}const _=["mm","cm","in","pt","pc","px"],A={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function b(k){let V="px";if(typeof k=="string"||k instanceof String)for(let B=0,R=_.length;B<R;B++){const T=_[B];if(k.endsWith(T)){V=T,k=k.substring(0,k.length-T.length);break}}let U;return V==="px"&&t.defaultUnit!=="px"?U=A.in[t.defaultUnit]/t.defaultDPI:(U=A[V][t.defaultUnit],U<0&&(U=A[V].in*t.defaultDPI)),U*parseFloat(k)}function C(k){if(!(k.hasAttribute("transform")||k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))))return null;const V=L(k);return G.length>0&&V.premultiply(G[G.length-1]),ce.copy(V),G.push(V),V}function L(k){const V=new l.Matrix3,U=X;if(k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))){const B=b(k.getAttribute("x")),R=b(k.getAttribute("y"));V.translate(B,R)}if(k.hasAttribute("transform")){const B=k.getAttribute("transform").split(")");for(let R=B.length-1;R>=0;R--){const T=B[R].trim();if(T==="")continue;const O=T.indexOf("("),N=T.length;if(O>0&&O<N){const K=T.slice(0,O),W=v(T.slice(O+1));switch(U.identity(),K){case"translate":if(W.length>=1){const Y=W[0];let Q=0;W.length>=2&&(Q=W[1]),U.translate(Y,Q)}break;case"rotate":if(W.length>=1){let Y=0,Q=0,re=0;Y=W[0]*Math.PI/180,W.length>=3&&(Q=W[1],re=W[2]),E.makeTranslation(-Q,-re),te.makeRotation(Y),q.multiplyMatrices(te,E),E.makeTranslation(Q,re),U.multiplyMatrices(E,q)}break;case"scale":if(W.length>=1){const Y=W[0];let Q=Y;W.length>=2&&(Q=W[1]),U.scale(Y,Q)}break;case"skewX":W.length===1&&U.set(1,Math.tan(W[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":W.length===1&&U.set(1,0,0,Math.tan(W[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":W.length===6&&U.set(W[0],W[2],W[4],W[1],W[3],W[5],0,0,1);break}}V.premultiply(U)}}return V}function M(k,V){function U(O){ne.set(O.x,O.y,1).applyMatrix3(V),O.set(ne.x,ne.y)}function B(O){const N=O.xRadius,K=O.yRadius,W=Math.cos(O.aRotation),Y=Math.sin(O.aRotation),Q=new l.Vector3(N*W,N*Y,0),re=new l.Vector3(-K*Y,K*W,0),se=Q.applyMatrix3(V),j=re.applyMatrix3(V),F=X.set(se.x,j.x,0,se.y,j.y,0,0,0,1),ie=E.copy(F).invert(),Le=te.copy(ie).transpose().multiply(ie).elements,Pe=I(Le[0],Le[1],Le[4]),Je=Math.sqrt(Pe.rt1),wt=Math.sqrt(Pe.rt2);if(O.xRadius=1/Je,O.yRadius=1/wt,O.aRotation=Math.atan2(Pe.sn,Pe.cs),!((O.aEndAngle-O.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const st=E.set(Je,0,0,0,wt,0,0,0,1),Ee=te.set(Pe.cs,Pe.sn,0,-Pe.sn,Pe.cs,0,0,0,1),it=st.multiply(Ee).multiply(F),sn=kn=>{const{x:Ro,y:Bn}=new l.Vector3(Math.cos(kn),Math.sin(kn),0).applyMatrix3(it);return Math.atan2(Bn,Ro)};O.aStartAngle=sn(O.aStartAngle),O.aEndAngle=sn(O.aEndAngle),P(V)&&(O.aClockwise=!O.aClockwise)}}function R(O){const N=S(V),K=x(V);O.xRadius*=N,O.yRadius*=K;const W=N>Number.EPSILON?Math.atan2(V.elements[1],V.elements[0]):Math.atan2(-V.elements[3],V.elements[4]);O.aRotation+=W,P(V)&&(O.aStartAngle*=-1,O.aEndAngle*=-1,O.aClockwise=!O.aClockwise)}const T=k.subPaths;for(let O=0,N=T.length;O<N;O++){const W=T[O].curves;for(let Y=0;Y<W.length;Y++){const Q=W[Y];Q.isLineCurve?(U(Q.v1),U(Q.v2)):Q.isCubicBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2),U(Q.v3)):Q.isQuadraticBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2)):Q.isEllipseCurve&&(oe.set(Q.aX,Q.aY),U(oe),Q.aX=oe.x,Q.aY=oe.y,w(V)?B(Q):R(Q))}}}function P(k){const V=k.elements;return V[0]*V[4]-V[1]*V[3]<0}function w(k){const V=k.elements,U=V[0]*V[3]+V[1]*V[4];if(U===0)return!1;const B=S(k),R=x(k);return Math.abs(U/(B*R))>Number.EPSILON}function S(k){const V=k.elements;return Math.sqrt(V[0]*V[0]+V[1]*V[1])}function x(k){const V=k.elements;return Math.sqrt(V[3]*V[3]+V[4]*V[4])}function I(k,V,U){let B,R,T,O,N;const K=k+U,W=k-U,Y=Math.sqrt(W*W+4*V*V);return K>0?(B=.5*(K+Y),N=1/B,R=k*N*U-V*N*V):K<0?R=.5*(K-Y):(B=.5*Y,R=-.5*Y),W>0?T=W+Y:T=W-Y,Math.abs(T)>2*Math.abs(V)?(N=-2*V/T,O=1/Math.sqrt(1+N*N),T=N*O):Math.abs(V)===0?(T=1,O=0):(N=-.5*T/V,T=1/Math.sqrt(1+N*N),O=N*T),W>0&&(N=T,T=-O,O=N),{rt1:B,rt2:R,cs:T,sn:O}}const D=[],z={},G=[],X=new l.Matrix3,E=new l.Matrix3,te=new l.Matrix3,q=new l.Matrix3,oe=new l.Vector2,ne=new l.Vector3,ce=new l.Matrix3,le=new DOMParser().parseFromString(e,"image/svg+xml");return n(le.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:D,xml:le.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},o={loc:n.ORIGIN,t:0};function r(y,v,_,A){const b=y.x,C=v.x,L=_.x,M=A.x,P=y.y,w=v.y,S=_.y,x=A.y,I=(M-L)*(P-S)-(x-S)*(b-L),D=(C-b)*(P-S)-(w-P)*(b-L),z=(x-S)*(C-b)-(M-L)*(w-P),G=I/z,X=D/z;if(z===0&&I!==0||G<=0||G>=1||X<0||X>1)return null;if(I===0&&z===0){for(let E=0;E<2;E++)if(s(E===0?_:A,y,v),o.loc==n.ORIGIN){const te=E===0?_:A;return{x:te.x,y:te.y,t:o.t}}else if(o.loc==n.BETWEEN){const te=+(b+o.t*(C-b)).toPrecision(10),q=+(P+o.t*(w-P)).toPrecision(10);return{x:te,y:q,t:o.t}}return null}else{for(let q=0;q<2;q++)if(s(q===0?_:A,y,v),o.loc==n.ORIGIN){const oe=q===0?_:A;return{x:oe.x,y:oe.y,t:o.t}}const E=+(b+G*(C-b)).toPrecision(10),te=+(P+G*(w-P)).toPrecision(10);return{x:E,y:te,t:G}}}function s(y,v,_){const A=_.x-v.x,b=_.y-v.y,C=y.x-v.x,L=y.y-v.y,M=A*L-C*b;if(y.x===v.x&&y.y===v.y){o.loc=n.ORIGIN,o.t=0;return}if(y.x===_.x&&y.y===_.y){o.loc=n.DESTINATION,o.t=1;return}if(M<-Number.EPSILON){o.loc=n.LEFT;return}if(M>Number.EPSILON){o.loc=n.RIGHT;return}if(A*C<0||b*L<0){o.loc=n.BEHIND;return}if(Math.sqrt(A*A+b*b)<Math.sqrt(C*C+L*L)){o.loc=n.BEYOND;return}let P;A!==0?P=C/A:P=L/b,o.loc=n.BETWEEN,o.t=P}function i(y,v){const _=[],A=[];for(let b=1;b<y.length;b++){const C=y[b-1],L=y[b];for(let M=1;M<v.length;M++){const P=v[M-1],w=v[M],S=r(C,L,P,w);S!==null&&_.find(x=>x.t<=S.t+Number.EPSILON&&x.t>=S.t-Number.EPSILON)===void 0&&(_.push(S),A.push(new l.Vector2(S.x,S.y)))}}return A}function c(y,v,_){const A=new l.Vector2;v.getCenter(A);const b=[];return _.forEach(C=>{C.boundingBox.containsPoint(A)&&i(y,C.points).forEach(M=>{b.push({identifier:C.identifier,isCW:C.isCW,point:M})})}),b.sort((C,L)=>C.point.x-L.point.x),b}function h(y,v,_,A,b){(b==null||b==="")&&(b="nonzero");const C=new l.Vector2;y.boundingBox.getCenter(C);const L=[new l.Vector2(_,C.y),new l.Vector2(A,C.y)],M=c(L,y.boundingBox,v);M.sort((D,z)=>D.point.x-z.point.x);const P=[],w=[];M.forEach(D=>{D.identifier===y.identifier?P.push(D):w.push(D)});const S=P[0].point.x,x=[];let I=0;for(;I<w.length&&w[I].point.x<S;)x.length>0&&x[x.length-1]===w[I].identifier?x.pop():x.push(w[I].identifier),I++;if(x.push(y.identifier),b==="evenodd"){const D=x.length%2===0,z=x[x.length-2];return{identifier:y.identifier,isHole:D,for:z}}else if(b==="nonzero"){let D=!0,z=null,G=null;for(let X=0;X<x.length;X++){const E=x[X];D?(G=v[E].isCW,D=!1,z=E):G!==v[E].isCW&&(G=v[E].isCW,D=!0)}return{identifier:y.identifier,isHole:D,for:z}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let p=999999999,f=-999999999,m=e.subPaths.map(y=>{const v=y.getPoints();let _=-999999999,A=999999999,b=-999999999,C=999999999;for(let L=0;L<v.length;L++){const M=v[L];M.y>_&&(_=M.y),M.y<A&&(A=M.y),M.x>b&&(b=M.x),M.x<C&&(C=M.x)}return f<=b&&(f=b+1),p>=C&&(p=C-1),{curves:y.curves,points:v,isCW:l.ShapeUtils.isClockWise(v),identifier:-1,boundingBox:new l.Box2(new l.Vector2(C,A),new l.Vector2(b,_))}});m=m.filter(y=>y.points.length>1);for(let y=0;y<m.length;y++)m[y].identifier=y;const d=m.map(y=>h(y,m,p,f,e.userData?e.userData.style.fillRule:void 0)),g=[];return m.forEach(y=>{if(!d[y.identifier].isHole){const _=new l.Shape;_.curves=y.curves,d.filter(b=>b.isHole&&b.for===y.identifier).forEach(b=>{const C=m[b.identifier],L=new l.Path;L.curves=C.curves,_.holes.push(L)}),g.push(_)}}),g}static getStrokeStyle(e,t,n,o,r){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",o=o!==void 0?o:"butt",r=r!==void 0?r:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:o,strokeMiterLimit:r}}static pointsToStroke(e,t,n,o){const r=[],s=[],i=[];if(Jt.pointsToStrokeWithBuffers(e,t,n,o,r,s,i)===0)return null;const c=new l.BufferGeometry;return c.setAttribute("position",new l.Float32BufferAttribute(r,3)),c.setAttribute("normal",new l.Float32BufferAttribute(s,3)),c.setAttribute("uv",new l.Float32BufferAttribute(i,2)),c}static pointsToStrokeWithBuffers(e,t,n,o,r,s,i,c){const h=new l.Vector2,p=new l.Vector2,f=new l.Vector2,m=new l.Vector2,d=new l.Vector2,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector2,w=new l.Vector2,S=new l.Vector2;n=n!==void 0?n:12,o=o!==void 0?o:.001,c=c!==void 0?c:0,e=W(e);const x=e.length;if(x<2)return 0;const I=e[0].equals(e[x-1]);let D,z=e[0],G;const X=t.strokeWidth/2,E=1/(x-1);let te=0,q,oe,ne,ce,le=!1,de=0,k=c*3,V=c*2;U(e[0],e[1],h).multiplyScalar(X),v.copy(e[0]).sub(h),_.copy(e[0]).add(h),A.copy(v),b.copy(_);for(let Y=1;Y<x;Y++){D=e[Y],Y===x-1?I?G=e[1]:G=void 0:G=e[Y+1];const Q=h;if(U(z,D,Q),f.copy(Q).multiplyScalar(X),C.copy(D).sub(f),L.copy(D).add(f),q=te+E,oe=!1,G!==void 0){U(D,G,p),f.copy(p).multiplyScalar(X),M.copy(D).sub(f),P.copy(D).add(f),ne=!0,f.subVectors(G,z),Q.dot(f)<0&&(ne=!1),Y===1&&(le=ne),f.subVectors(G,D),f.normalize();const re=Math.abs(Q.dot(f));if(re>Number.EPSILON){const se=X/re;f.multiplyScalar(-se),m.subVectors(D,z),d.copy(m).setLength(se).add(f),w.copy(d).negate();const j=d.length(),F=m.length();m.divideScalar(F),g.subVectors(G,D);const ie=g.length();switch(g.divideScalar(ie),m.dot(w)<F&&g.dot(w)<ie&&(oe=!0),S.copy(d).add(D),w.add(D),ce=!1,oe?ne?(P.copy(w),L.copy(w)):(M.copy(w),C.copy(w)):T(),t.strokeLineJoin){case"bevel":O(ne,oe,q);break;case"round":N(ne,oe),ne?R(D,C,M,q,0):R(D,P,L,q,1);break;case"miter":case"miter-clip":default:const he=X*t.strokeMiterLimit/j;if(he<1)if(t.strokeLineJoin!=="miter-clip"){O(ne,oe,q);break}else N(ne,oe),ne?(g.subVectors(S,C).multiplyScalar(he).add(C),y.subVectors(S,M).multiplyScalar(he).add(M),B(C,q,0),B(g,q,0),B(D,q,.5),B(D,q,.5),B(g,q,0),B(y,q,0),B(D,q,.5),B(y,q,0),B(M,q,0)):(g.subVectors(S,L).multiplyScalar(he).add(L),y.subVectors(S,P).multiplyScalar(he).add(P),B(L,q,1),B(g,q,1),B(D,q,.5),B(D,q,.5),B(g,q,1),B(y,q,1),B(D,q,.5),B(y,q,1),B(P,q,1));else oe?(ne?(B(_,te,1),B(v,te,0),B(S,q,0),B(_,te,1),B(S,q,0),B(w,q,1)):(B(_,te,1),B(v,te,0),B(S,q,1),B(v,te,0),B(w,q,0),B(S,q,1)),ne?M.copy(S):P.copy(S)):ne?(B(C,q,0),B(S,q,0),B(D,q,.5),B(D,q,.5),B(S,q,0),B(M,q,0)):(B(L,q,1),B(S,q,1),B(D,q,.5),B(D,q,.5),B(S,q,1),B(P,q,1)),ce=!0;break}}else T()}else T();!I&&Y===x-1&&K(e[0],A,b,ne,!0,te),te=q,z=D,v.copy(M),_.copy(P)}if(!I)K(D,C,L,ne,!1,q);else if(oe&&r){let Y=S,Q=w;le!==ne&&(Y=w,Q=S),ne?(ce||le)&&(Q.toArray(r,0*3),Q.toArray(r,3*3),ce&&Y.toArray(r,1*3)):(ce||!le)&&(Q.toArray(r,1*3),Q.toArray(r,3*3),ce&&Y.toArray(r,0*3))}return de;function U(Y,Q,re){return re.subVectors(Q,Y),re.set(-re.y,re.x).normalize()}function B(Y,Q,re){r&&(r[k]=Y.x,r[k+1]=Y.y,r[k+2]=0,s&&(s[k]=0,s[k+1]=0,s[k+2]=1),k+=3,i&&(i[V]=Q,i[V+1]=re,V+=2)),de+=3}function R(Y,Q,re,se,j){h.copy(Q).sub(Y).normalize(),p.copy(re).sub(Y).normalize();let F=Math.PI;const ie=h.dot(p);Math.abs(ie)<1&&(F=Math.abs(Math.acos(ie))),F/=n,f.copy(Q);for(let he=0,_e=n-1;he<_e;he++)m.copy(f).rotateAround(Y,F),B(f,se,j),B(m,se,j),B(Y,se,.5),f.copy(m);B(m,se,j),B(re,se,j),B(Y,se,.5)}function T(){B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(L,q,1)}function O(Y,Q,re){Q?Y?(B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(w,q,1),B(C,re,0),B(M,re,0),B(w,re,.5)):(B(_,te,1),B(v,te,0),B(L,q,1),B(v,te,0),B(w,q,0),B(L,q,1),B(L,re,1),B(w,re,0),B(P,re,1)):Y?(B(C,re,0),B(M,re,0),B(D,re,.5)):(B(L,re,1),B(P,re,0),B(D,re,.5))}function N(Y,Q){Q&&(Y?(B(_,te,1),B(v,te,0),B(C,q,0),B(_,te,1),B(C,q,0),B(w,q,1),B(C,te,0),B(D,q,.5),B(w,q,1),B(D,q,.5),B(M,te,0),B(w,q,1)):(B(_,te,1),B(v,te,0),B(L,q,1),B(v,te,0),B(w,q,0),B(L,q,1),B(L,te,1),B(w,q,0),B(D,q,.5),B(D,q,.5),B(w,q,0),B(P,te,1)))}function K(Y,Q,re,se,j,F){switch(t.strokeLineCap){case"round":j?R(Y,re,Q,F,.5):R(Y,Q,re,F,.5);break;case"square":if(j)h.subVectors(Q,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y),se?(f.toArray(r,1*3),m.toArray(r,0*3),m.toArray(r,3*3)):(f.toArray(r,1*3),i[3*2+1]===1?m.toArray(r,3*3):f.toArray(r,3*3),m.toArray(r,0*3));else{h.subVectors(re,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y);const ie=r.length;se?(f.toArray(r,ie-1*3),m.toArray(r,ie-2*3),m.toArray(r,ie-4*3)):(m.toArray(r,ie-2*3),f.toArray(r,ie-1*3),m.toArray(r,ie-4*3))}break}}function W(Y){let Q=!1;for(let se=1,j=Y.length-1;se<j;se++)if(Y[se].distanceTo(Y[se+1])<o){Q=!0;break}if(!Q)return Y;const re=[];re.push(Y[0]);for(let se=1,j=Y.length-1;se<j;se++)Y[se].distanceTo(Y[se+1])>=o&&re.push(Y[se]);return re.push(Y[Y.length-1]),re}}}const lo=new WeakMap;class mc extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,o){const r=new l.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,s=>{const i={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(s,i).then(t).catch(o)},n,o)}decodeDracoFile(e,t,n,o){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:o||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const n=JSON.stringify(t);if(lo.has(e)){const c=lo.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let o;const r=this.workerNextTaskID++,s=e.byteLength,i=this._getWorker(r,s).then(c=>(o=c,new Promise((h,p)=>{o._callbacks[r]={resolve:h,reject:p},o.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return i.catch(()=>!0).then(()=>{o&&r&&this._releaseTask(o,r)}),lo.set(e,{key:n,promise:i}),i}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const o=e.attributes[n],r=o.name,s=o.array,i=o.itemSize;t.setAttribute(r,new l.BufferAttribute(s,i))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((o,r)=>{n.load(e,o,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const o=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=gc.toString(),s=["/* draco decoder */",o,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
559
|
+
`,f=function(w,S,x){S=S||1024;let D=w.pos,z=-1,G=0,E="",X=String.fromCharCode.apply(null,new Uint16Array(w.subarray(D,D+128)));for(;0>(z=X.indexOf(p))&&G<S&&D<w.byteLength;)E+=X,G+=X.length,D+=128,X+=String.fromCharCode.apply(null,new Uint16Array(w.subarray(D,D+128)));return-1<z?(w.pos+=G+z+1,E+X.slice(0,z)):!1},m=function(w){const S=/^#\?(\S+)/,x=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,I=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,D=/^\s*FORMAT=(\S+)\s*$/,z=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,G={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let E,X;for((w.pos>=w.byteLength||!(E=f(w)))&&s(1,"no header found"),(X=E.match(S))||s(3,"bad initial token"),G.valid|=1,G.programtype=X[1],G.string+=E+`
|
|
560
|
+
`;E=f(w),E!==!1;){if(G.string+=E+`
|
|
561
|
+
`,E.charAt(0)==="#"){G.comments+=E+`
|
|
562
|
+
`;continue}if((X=E.match(x))&&(G.gamma=parseFloat(X[1])),(X=E.match(I))&&(G.exposure=parseFloat(X[1])),(X=E.match(D))&&(G.valid|=2,G.format=X[1]),(X=E.match(z))&&(G.valid|=4,G.height=parseInt(X[1],10),G.width=parseInt(X[2],10)),G.valid&2&&G.valid&4)break}return G.valid&2||s(3,"missing format specifier"),G.valid&4||s(3,"missing image size specifier"),G},d=function(w,S,x){const I=S;if(I<8||I>32767||w[0]!==2||w[1]!==2||w[2]&128)return new Uint8Array(w);I!==(w[2]<<8|w[3])&&s(3,"wrong scanline width");const D=new Uint8Array(4*S*x);D.length||s(4,"unable to allocate buffer space");let z=0,G=0;const E=4*I,X=new Uint8Array(4),oe=new Uint8Array(E);let q=x;for(;q>0&&G<w.byteLength;){G+4>w.byteLength&&s(1),X[0]=w[G++],X[1]=w[G++],X[2]=w[G++],X[3]=w[G++],(X[0]!=2||X[1]!=2||(X[2]<<8|X[3])!=I)&&s(3,"bad rgbe scanline format");let ee=0,te;for(;ee<E&&G<w.byteLength;){te=w[G++];const le=te>128;if(le&&(te-=128),(te===0||ee+te>E)&&s(3,"bad scanline data"),le){const de=w[G++];for(let k=0;k<te;k++)oe[ee++]=de}else oe.set(w.subarray(G,G+te),ee),ee+=te,G+=te}const ce=I;for(let le=0;le<ce;le++){let de=0;D[z]=oe[le+de],de+=I,D[z+1]=oe[le+de],de+=I,D[z+2]=oe[le+de],de+=I,D[z+3]=oe[le+de],z+=4}q--}return D},g=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=w[S+0]*z,x[I+1]=w[S+1]*z,x[I+2]=w[S+2]*z,x[I+3]=1},y=function(w,S,x,I){const D=w[S+3],z=Math.pow(2,D-128)/255;x[I+0]=l.DataUtils.toHalfFloat(Math.min(w[S+0]*z,65504)),x[I+1]=l.DataUtils.toHalfFloat(Math.min(w[S+1]*z,65504)),x[I+2]=l.DataUtils.toHalfFloat(Math.min(w[S+2]*z,65504)),x[I+3]=l.DataUtils.toHalfFloat(1)},v=new Uint8Array(e);v.pos=0;const _=m(v),A=_.width,b=_.height,C=d(v.subarray(v.pos),A,b);let L,M,P;switch(this.type){case l.FloatType:P=C.length/4;const w=new Float32Array(P*4);for(let x=0;x<P;x++)g(C,x*4,w,x*4);L=w,M=l.FloatType;break;case l.HalfFloatType:P=C.length/4;const S=new Uint16Array(P*4);for(let x=0;x<P;x++)y(C,x*4,S,x*4);L=S,M=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:A,height:b,data:L,header:_.string,gamma:_.gamma,exposure:_.exposure,type:M}}setDataType(e){return this.type=e,this}load(e,t,n,o){function r(s,i){switch(s.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in s?s.colorSpace="srgb-linear":s.encoding=3e3,s.minFilter=l.LinearFilter,s.magFilter=l.LinearFilter,s.generateMipmaps=!1,s.flipY=!0;break}t&&t(s,i)}return super.load(e,r,n,o)}}const pc="srgb";class Jt extends l.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,o){const r=this,s=new l.FileLoader(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,function(i){try{t(r.parse(i))}catch(c){o?o(c):console.error(c),r.manager.itemError(e)}},n,o)}parse(e){const t=this;function n(k,V){if(k.nodeType!==1)return;const U=C(k);let B=!1,R=null;switch(k.nodeName){case"svg":V=g(k,V);break;case"style":r(k);break;case"g":V=g(k,V);break;case"path":V=g(k,V),k.hasAttribute("d")&&(R=o(k));break;case"rect":V=g(k,V),R=c(k);break;case"polygon":V=g(k,V),R=h(k);break;case"polyline":V=g(k,V),R=p(k);break;case"circle":V=g(k,V),R=f(k);break;case"ellipse":V=g(k,V),R=m(k);break;case"line":V=g(k,V),R=d(k);break;case"defs":B=!0;break;case"use":V=g(k,V);const N=(k.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),K=k.viewportElement.getElementById(N);K?n(K,V):console.warn("SVGLoader: 'use node' references non-existent node id: "+N);break}R&&(V.fill!==void 0&&V.fill!=="none"&&R.color.setStyle(V.fill,pc),M(R,ce),D.push(R),R.userData={node:k,style:V});const T=k.childNodes;for(let O=0;O<T.length;O++){const N=T[O];B&&N.nodeName!=="style"&&N.nodeName!=="defs"||n(N,V)}U&&(G.pop(),G.length>0?ce.copy(G[G.length-1]):ce.identity())}function o(k){const V=new l.ShapePath,U=new l.Vector2,B=new l.Vector2,R=new l.Vector2;let T=!0,O=!1;const N=k.getAttribute("d");if(N===""||N==="none")return null;const K=N.match(/[a-df-z][^a-df-z]*/gi);for(let W=0,Y=K.length;W<Y;W++){const Q=K[W],re=Q.charAt(0),se=Q.slice(1).trim();T===!0&&(O=!0,T=!1);let j;switch(re){case"M":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"H":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"V":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"L":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x=j[F+0],U.y=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"C":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(j[F+0],j[F+1],j[F+2],j[F+3],j[F+4],j[F+5]),B.x=j[F+2],B.y=j[F+3],U.x=j[F+4],U.y=j[F+5],F===0&&O===!0&&R.copy(U);break;case"S":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"Q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(j[F+0],j[F+1],j[F+2],j[F+3]),B.x=j[F+0],B.y=j[F+1],U.x=j[F+2],U.y=j[F+3],F===0&&O===!0&&R.copy(U);break;case"T":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,j[F+0],j[F+1]),B.x=he,B.y=_e,U.x=j[F+0],U.y=j[F+1],F===0&&O===!0&&R.copy(U)}break;case"A":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==U.x&&j[F+6]==U.y)continue;const he=U.clone();U.x=j[F+5],U.y=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"m":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,F===0?V.moveTo(U.x,U.y):V.lineTo(U.x,U.y),F===0&&R.copy(U);break;case"h":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.x+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"v":j=v(se);for(let F=0,ie=j.length;F<ie;F++)U.y+=j[F],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"l":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2)U.x+=j[F+0],U.y+=j[F+1],B.x=U.x,B.y=U.y,V.lineTo(U.x,U.y),F===0&&O===!0&&R.copy(U);break;case"c":j=v(se);for(let F=0,ie=j.length;F<ie;F+=6)V.bezierCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3],U.x+j[F+4],U.y+j[F+5]),B.x=U.x+j[F+2],B.y=U.y+j[F+3],U.x+=j[F+4],U.y+=j[F+5],F===0&&O===!0&&R.copy(U);break;case"s":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.bezierCurveTo(y(U.x,B.x),y(U.y,B.y),U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"q":j=v(se);for(let F=0,ie=j.length;F<ie;F+=4)V.quadraticCurveTo(U.x+j[F+0],U.y+j[F+1],U.x+j[F+2],U.y+j[F+3]),B.x=U.x+j[F+0],B.y=U.y+j[F+1],U.x+=j[F+2],U.y+=j[F+3],F===0&&O===!0&&R.copy(U);break;case"t":j=v(se);for(let F=0,ie=j.length;F<ie;F+=2){const he=y(U.x,B.x),_e=y(U.y,B.y);V.quadraticCurveTo(he,_e,U.x+j[F+0],U.y+j[F+1]),B.x=he,B.y=_e,U.x=U.x+j[F+0],U.y=U.y+j[F+1],F===0&&O===!0&&R.copy(U)}break;case"a":j=v(se,[3,4],7);for(let F=0,ie=j.length;F<ie;F+=7){if(j[F+5]==0&&j[F+6]==0)continue;const he=U.clone();U.x+=j[F+5],U.y+=j[F+6],B.x=U.x,B.y=U.y,s(V,j[F],j[F+1],j[F+2],j[F+3],j[F+4],he,U),F===0&&O===!0&&R.copy(U)}break;case"Z":case"z":V.currentPath.autoClose=!0,V.currentPath.curves.length>0&&(U.copy(R),V.currentPath.currentPoint.copy(U),T=!0);break;default:console.warn(Q)}O=!1}return V}function r(k){if(!(!k.sheet||!k.sheet.cssRules||!k.sheet.cssRules.length))for(let V=0;V<k.sheet.cssRules.length;V++){const U=k.sheet.cssRules[V];if(U.type!==1)continue;const B=U.selectorText.split(/,/gm).filter(Boolean).map(R=>R.trim());for(let R=0;R<B.length;R++){const T=Object.fromEntries(Object.entries(U.style).filter(([,O])=>O!==""));z[B[R]]=Object.assign(z[B[R]]||{},T)}}}function s(k,V,U,B,R,T,O,N){if(V==0||U==0){k.lineTo(N.x,N.y);return}B=B*Math.PI/180,V=Math.abs(V),U=Math.abs(U);const K=(O.x-N.x)/2,W=(O.y-N.y)/2,Y=Math.cos(B)*K+Math.sin(B)*W,Q=-Math.sin(B)*K+Math.cos(B)*W;let re=V*V,se=U*U;const j=Y*Y,F=Q*Q,ie=j/re+F/se;if(ie>1){const it=Math.sqrt(ie);V=it*V,U=it*U,re=V*V,se=U*U}const he=re*F+se*j,_e=(re*se-he)/he;let Le=Math.sqrt(Math.max(0,_e));R===T&&(Le=-Le);const Pe=Le*V*Q/U,Je=-Le*U*Y/V,wt=Math.cos(B)*Pe-Math.sin(B)*Je+(O.x+N.x)/2,It=Math.sin(B)*Pe+Math.cos(B)*Je+(O.y+N.y)/2,st=i(1,0,(Y-Pe)/V,(Q-Je)/U),Ee=i((Y-Pe)/V,(Q-Je)/U,(-Y-Pe)/V,(-Q-Je)/U)%(Math.PI*2);k.currentPath.absellipse(wt,It,V,U,st,st+Ee,T===0,B)}function i(k,V,U,B){const R=k*U+V*B,T=Math.sqrt(k*k+V*V)*Math.sqrt(U*U+B*B);let O=Math.acos(Math.max(-1,Math.min(1,R/T)));return k*B-V*U<0&&(O=-O),O}function c(k){const V=b(k.getAttribute("x")||0),U=b(k.getAttribute("y")||0),B=b(k.getAttribute("rx")||k.getAttribute("ry")||0),R=b(k.getAttribute("ry")||k.getAttribute("rx")||0),T=b(k.getAttribute("width")),O=b(k.getAttribute("height")),N=1-.551915024494,K=new l.ShapePath;return K.moveTo(V+B,U),K.lineTo(V+T-B,U),(B!==0||R!==0)&&K.bezierCurveTo(V+T-B*N,U,V+T,U+R*N,V+T,U+R),K.lineTo(V+T,U+O-R),(B!==0||R!==0)&&K.bezierCurveTo(V+T,U+O-R*N,V+T-B*N,U+O,V+T-B,U+O),K.lineTo(V+B,U+O),(B!==0||R!==0)&&K.bezierCurveTo(V+B*N,U+O,V,U+O-R*N,V,U+O-R),K.lineTo(V,U+R),(B!==0||R!==0)&&K.bezierCurveTo(V,U+R*N,V+B*N,U,V+B,U),K}function h(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!0,B}function p(k){function V(T,O,N){const K=b(O),W=b(N);R===0?B.moveTo(K,W):B.lineTo(K,W),R++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let R=0;return k.getAttribute("points").replace(U,V),B.currentPath.autoClose=!1,B}function f(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("r")||0),R=new l.Path;R.absarc(V,U,B,0,Math.PI*2);const T=new l.ShapePath;return T.subPaths.push(R),T}function m(k){const V=b(k.getAttribute("cx")||0),U=b(k.getAttribute("cy")||0),B=b(k.getAttribute("rx")||0),R=b(k.getAttribute("ry")||0),T=new l.Path;T.absellipse(V,U,B,R,0,Math.PI*2);const O=new l.ShapePath;return O.subPaths.push(T),O}function d(k){const V=b(k.getAttribute("x1")||0),U=b(k.getAttribute("y1")||0),B=b(k.getAttribute("x2")||0),R=b(k.getAttribute("y2")||0),T=new l.ShapePath;return T.moveTo(V,U),T.lineTo(B,R),T.currentPath.autoClose=!1,T}function g(k,V){V=Object.assign({},V);let U={};if(k.hasAttribute("class")){const O=k.getAttribute("class").split(/\s/).filter(Boolean).map(N=>N.trim());for(let N=0;N<O.length;N++)U=Object.assign(U,z["."+O[N]])}k.hasAttribute("id")&&(U=Object.assign(U,z["#"+k.getAttribute("id")]));function B(O,N,K){K===void 0&&(K=function(Y){return Y.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),Y}),k.hasAttribute(O)&&(V[N]=K(k.getAttribute(O))),U[O]&&(V[N]=K(U[O])),k.style&&k.style[O]!==""&&(V[N]=K(k.style[O]))}function R(O){return Math.max(0,Math.min(1,b(O)))}function T(O){return Math.max(0,b(O))}return B("fill","fill"),B("fill-opacity","fillOpacity",R),B("fill-rule","fillRule"),B("opacity","opacity",R),B("stroke","stroke"),B("stroke-opacity","strokeOpacity",R),B("stroke-width","strokeWidth",T),B("stroke-linejoin","strokeLineJoin"),B("stroke-linecap","strokeLineCap"),B("stroke-miterlimit","strokeMiterLimit",T),B("visibility","visibility"),V}function y(k,V){return k-(V-k)}function v(k,V,U){if(typeof k!="string")throw new TypeError("Invalid input: "+typeof k);const B={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},R=0,T=1,O=2,N=3;let K=R,W=!0,Y="",Q="";const re=[];function se(he,_e,Le){const Pe=new SyntaxError('Unexpected character "'+he+'" at index '+_e+".");throw Pe.partial=Le,Pe}function j(){Y!==""&&(Q===""?re.push(Number(Y)):re.push(Number(Y)*Math.pow(10,Number(Q)))),Y="",Q=""}let F;const ie=k.length;for(let he=0;he<ie;he++){if(F=k[he],Array.isArray(V)&&V.includes(re.length%U)&&B.FLAGS.test(F)){K=T,Y=F,j();continue}if(K===R){if(B.WHITESPACE.test(F))continue;if(B.DIGIT.test(F)||B.SIGN.test(F)){K=T,Y=F;continue}if(B.POINT.test(F)){K=O,Y=F;continue}B.COMMA.test(F)&&(W&&se(F,he,re),W=!0)}if(K===T){if(B.DIGIT.test(F)){Y+=F;continue}if(B.POINT.test(F)){Y+=F,K=O;continue}if(B.EXP.test(F)){K=N;continue}B.SIGN.test(F)&&Y.length===1&&B.SIGN.test(Y[0])&&se(F,he,re)}if(K===O){if(B.DIGIT.test(F)){Y+=F;continue}if(B.EXP.test(F)){K=N;continue}B.POINT.test(F)&&Y[Y.length-1]==="."&&se(F,he,re)}if(K===N){if(B.DIGIT.test(F)){Q+=F;continue}if(B.SIGN.test(F)){if(Q===""){Q+=F;continue}Q.length===1&&B.SIGN.test(Q)&&se(F,he,re)}}B.WHITESPACE.test(F)?(j(),K=R,W=!1):B.COMMA.test(F)?(j(),K=R,W=!0):B.SIGN.test(F)?(j(),K=T,Y=F):B.POINT.test(F)?(j(),K=O,Y=F):se(F,he,re)}return j(),re}const _=["mm","cm","in","pt","pc","px"],A={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function b(k){let V="px";if(typeof k=="string"||k instanceof String)for(let B=0,R=_.length;B<R;B++){const T=_[B];if(k.endsWith(T)){V=T,k=k.substring(0,k.length-T.length);break}}let U;return V==="px"&&t.defaultUnit!=="px"?U=A.in[t.defaultUnit]/t.defaultDPI:(U=A[V][t.defaultUnit],U<0&&(U=A[V].in*t.defaultDPI)),U*parseFloat(k)}function C(k){if(!(k.hasAttribute("transform")||k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))))return null;const V=L(k);return G.length>0&&V.premultiply(G[G.length-1]),ce.copy(V),G.push(V),V}function L(k){const V=new l.Matrix3,U=E;if(k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))){const B=b(k.getAttribute("x")),R=b(k.getAttribute("y"));V.translate(B,R)}if(k.hasAttribute("transform")){const B=k.getAttribute("transform").split(")");for(let R=B.length-1;R>=0;R--){const T=B[R].trim();if(T==="")continue;const O=T.indexOf("("),N=T.length;if(O>0&&O<N){const K=T.slice(0,O),W=v(T.slice(O+1));switch(U.identity(),K){case"translate":if(W.length>=1){const Y=W[0];let Q=0;W.length>=2&&(Q=W[1]),U.translate(Y,Q)}break;case"rotate":if(W.length>=1){let Y=0,Q=0,re=0;Y=W[0]*Math.PI/180,W.length>=3&&(Q=W[1],re=W[2]),X.makeTranslation(-Q,-re),oe.makeRotation(Y),q.multiplyMatrices(oe,X),X.makeTranslation(Q,re),U.multiplyMatrices(X,q)}break;case"scale":if(W.length>=1){const Y=W[0];let Q=Y;W.length>=2&&(Q=W[1]),U.scale(Y,Q)}break;case"skewX":W.length===1&&U.set(1,Math.tan(W[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":W.length===1&&U.set(1,0,0,Math.tan(W[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":W.length===6&&U.set(W[0],W[2],W[4],W[1],W[3],W[5],0,0,1);break}}V.premultiply(U)}}return V}function M(k,V){function U(O){te.set(O.x,O.y,1).applyMatrix3(V),O.set(te.x,te.y)}function B(O){const N=O.xRadius,K=O.yRadius,W=Math.cos(O.aRotation),Y=Math.sin(O.aRotation),Q=new l.Vector3(N*W,N*Y,0),re=new l.Vector3(-K*Y,K*W,0),se=Q.applyMatrix3(V),j=re.applyMatrix3(V),F=E.set(se.x,j.x,0,se.y,j.y,0,0,0,1),ie=X.copy(F).invert(),Le=oe.copy(ie).transpose().multiply(ie).elements,Pe=I(Le[0],Le[1],Le[4]),Je=Math.sqrt(Pe.rt1),wt=Math.sqrt(Pe.rt2);if(O.xRadius=1/Je,O.yRadius=1/wt,O.aRotation=Math.atan2(Pe.sn,Pe.cs),!((O.aEndAngle-O.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const st=X.set(Je,0,0,0,wt,0,0,0,1),Ee=oe.set(Pe.cs,Pe.sn,0,-Pe.sn,Pe.cs,0,0,0,1),it=st.multiply(Ee).multiply(F),sn=kn=>{const{x:Ro,y:Bn}=new l.Vector3(Math.cos(kn),Math.sin(kn),0).applyMatrix3(it);return Math.atan2(Bn,Ro)};O.aStartAngle=sn(O.aStartAngle),O.aEndAngle=sn(O.aEndAngle),P(V)&&(O.aClockwise=!O.aClockwise)}}function R(O){const N=S(V),K=x(V);O.xRadius*=N,O.yRadius*=K;const W=N>Number.EPSILON?Math.atan2(V.elements[1],V.elements[0]):Math.atan2(-V.elements[3],V.elements[4]);O.aRotation+=W,P(V)&&(O.aStartAngle*=-1,O.aEndAngle*=-1,O.aClockwise=!O.aClockwise)}const T=k.subPaths;for(let O=0,N=T.length;O<N;O++){const W=T[O].curves;for(let Y=0;Y<W.length;Y++){const Q=W[Y];Q.isLineCurve?(U(Q.v1),U(Q.v2)):Q.isCubicBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2),U(Q.v3)):Q.isQuadraticBezierCurve?(U(Q.v0),U(Q.v1),U(Q.v2)):Q.isEllipseCurve&&(ee.set(Q.aX,Q.aY),U(ee),Q.aX=ee.x,Q.aY=ee.y,w(V)?B(Q):R(Q))}}}function P(k){const V=k.elements;return V[0]*V[4]-V[1]*V[3]<0}function w(k){const V=k.elements,U=V[0]*V[3]+V[1]*V[4];if(U===0)return!1;const B=S(k),R=x(k);return Math.abs(U/(B*R))>Number.EPSILON}function S(k){const V=k.elements;return Math.sqrt(V[0]*V[0]+V[1]*V[1])}function x(k){const V=k.elements;return Math.sqrt(V[3]*V[3]+V[4]*V[4])}function I(k,V,U){let B,R,T,O,N;const K=k+U,W=k-U,Y=Math.sqrt(W*W+4*V*V);return K>0?(B=.5*(K+Y),N=1/B,R=k*N*U-V*N*V):K<0?R=.5*(K-Y):(B=.5*Y,R=-.5*Y),W>0?T=W+Y:T=W-Y,Math.abs(T)>2*Math.abs(V)?(N=-2*V/T,O=1/Math.sqrt(1+N*N),T=N*O):Math.abs(V)===0?(T=1,O=0):(N=-.5*T/V,T=1/Math.sqrt(1+N*N),O=N*T),W>0&&(N=T,T=-O,O=N),{rt1:B,rt2:R,cs:T,sn:O}}const D=[],z={},G=[],E=new l.Matrix3,X=new l.Matrix3,oe=new l.Matrix3,q=new l.Matrix3,ee=new l.Vector2,te=new l.Vector3,ce=new l.Matrix3,le=new DOMParser().parseFromString(e,"image/svg+xml");return n(le.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:D,xml:le.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},o={loc:n.ORIGIN,t:0};function r(y,v,_,A){const b=y.x,C=v.x,L=_.x,M=A.x,P=y.y,w=v.y,S=_.y,x=A.y,I=(M-L)*(P-S)-(x-S)*(b-L),D=(C-b)*(P-S)-(w-P)*(b-L),z=(x-S)*(C-b)-(M-L)*(w-P),G=I/z,E=D/z;if(z===0&&I!==0||G<=0||G>=1||E<0||E>1)return null;if(I===0&&z===0){for(let X=0;X<2;X++)if(s(X===0?_:A,y,v),o.loc==n.ORIGIN){const oe=X===0?_:A;return{x:oe.x,y:oe.y,t:o.t}}else if(o.loc==n.BETWEEN){const oe=+(b+o.t*(C-b)).toPrecision(10),q=+(P+o.t*(w-P)).toPrecision(10);return{x:oe,y:q,t:o.t}}return null}else{for(let q=0;q<2;q++)if(s(q===0?_:A,y,v),o.loc==n.ORIGIN){const ee=q===0?_:A;return{x:ee.x,y:ee.y,t:o.t}}const X=+(b+G*(C-b)).toPrecision(10),oe=+(P+G*(w-P)).toPrecision(10);return{x:X,y:oe,t:G}}}function s(y,v,_){const A=_.x-v.x,b=_.y-v.y,C=y.x-v.x,L=y.y-v.y,M=A*L-C*b;if(y.x===v.x&&y.y===v.y){o.loc=n.ORIGIN,o.t=0;return}if(y.x===_.x&&y.y===_.y){o.loc=n.DESTINATION,o.t=1;return}if(M<-Number.EPSILON){o.loc=n.LEFT;return}if(M>Number.EPSILON){o.loc=n.RIGHT;return}if(A*C<0||b*L<0){o.loc=n.BEHIND;return}if(Math.sqrt(A*A+b*b)<Math.sqrt(C*C+L*L)){o.loc=n.BEYOND;return}let P;A!==0?P=C/A:P=L/b,o.loc=n.BETWEEN,o.t=P}function i(y,v){const _=[],A=[];for(let b=1;b<y.length;b++){const C=y[b-1],L=y[b];for(let M=1;M<v.length;M++){const P=v[M-1],w=v[M],S=r(C,L,P,w);S!==null&&_.find(x=>x.t<=S.t+Number.EPSILON&&x.t>=S.t-Number.EPSILON)===void 0&&(_.push(S),A.push(new l.Vector2(S.x,S.y)))}}return A}function c(y,v,_){const A=new l.Vector2;v.getCenter(A);const b=[];return _.forEach(C=>{C.boundingBox.containsPoint(A)&&i(y,C.points).forEach(M=>{b.push({identifier:C.identifier,isCW:C.isCW,point:M})})}),b.sort((C,L)=>C.point.x-L.point.x),b}function h(y,v,_,A,b){(b==null||b==="")&&(b="nonzero");const C=new l.Vector2;y.boundingBox.getCenter(C);const L=[new l.Vector2(_,C.y),new l.Vector2(A,C.y)],M=c(L,y.boundingBox,v);M.sort((D,z)=>D.point.x-z.point.x);const P=[],w=[];M.forEach(D=>{D.identifier===y.identifier?P.push(D):w.push(D)});const S=P[0].point.x,x=[];let I=0;for(;I<w.length&&w[I].point.x<S;)x.length>0&&x[x.length-1]===w[I].identifier?x.pop():x.push(w[I].identifier),I++;if(x.push(y.identifier),b==="evenodd"){const D=x.length%2===0,z=x[x.length-2];return{identifier:y.identifier,isHole:D,for:z}}else if(b==="nonzero"){let D=!0,z=null,G=null;for(let E=0;E<x.length;E++){const X=x[E];D?(G=v[X].isCW,D=!1,z=X):G!==v[X].isCW&&(G=v[X].isCW,D=!0)}return{identifier:y.identifier,isHole:D,for:z}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let p=999999999,f=-999999999,m=e.subPaths.map(y=>{const v=y.getPoints();let _=-999999999,A=999999999,b=-999999999,C=999999999;for(let L=0;L<v.length;L++){const M=v[L];M.y>_&&(_=M.y),M.y<A&&(A=M.y),M.x>b&&(b=M.x),M.x<C&&(C=M.x)}return f<=b&&(f=b+1),p>=C&&(p=C-1),{curves:y.curves,points:v,isCW:l.ShapeUtils.isClockWise(v),identifier:-1,boundingBox:new l.Box2(new l.Vector2(C,A),new l.Vector2(b,_))}});m=m.filter(y=>y.points.length>1);for(let y=0;y<m.length;y++)m[y].identifier=y;const d=m.map(y=>h(y,m,p,f,e.userData?e.userData.style.fillRule:void 0)),g=[];return m.forEach(y=>{if(!d[y.identifier].isHole){const _=new l.Shape;_.curves=y.curves,d.filter(b=>b.isHole&&b.for===y.identifier).forEach(b=>{const C=m[b.identifier],L=new l.Path;L.curves=C.curves,_.holes.push(L)}),g.push(_)}}),g}static getStrokeStyle(e,t,n,o,r){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",o=o!==void 0?o:"butt",r=r!==void 0?r:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:o,strokeMiterLimit:r}}static pointsToStroke(e,t,n,o){const r=[],s=[],i=[];if(Jt.pointsToStrokeWithBuffers(e,t,n,o,r,s,i)===0)return null;const c=new l.BufferGeometry;return c.setAttribute("position",new l.Float32BufferAttribute(r,3)),c.setAttribute("normal",new l.Float32BufferAttribute(s,3)),c.setAttribute("uv",new l.Float32BufferAttribute(i,2)),c}static pointsToStrokeWithBuffers(e,t,n,o,r,s,i,c){const h=new l.Vector2,p=new l.Vector2,f=new l.Vector2,m=new l.Vector2,d=new l.Vector2,g=new l.Vector2,y=new l.Vector2,v=new l.Vector2,_=new l.Vector2,A=new l.Vector2,b=new l.Vector2,C=new l.Vector2,L=new l.Vector2,M=new l.Vector2,P=new l.Vector2,w=new l.Vector2,S=new l.Vector2;n=n!==void 0?n:12,o=o!==void 0?o:.001,c=c!==void 0?c:0,e=W(e);const x=e.length;if(x<2)return 0;const I=e[0].equals(e[x-1]);let D,z=e[0],G;const E=t.strokeWidth/2,X=1/(x-1);let oe=0,q,ee,te,ce,le=!1,de=0,k=c*3,V=c*2;U(e[0],e[1],h).multiplyScalar(E),v.copy(e[0]).sub(h),_.copy(e[0]).add(h),A.copy(v),b.copy(_);for(let Y=1;Y<x;Y++){D=e[Y],Y===x-1?I?G=e[1]:G=void 0:G=e[Y+1];const Q=h;if(U(z,D,Q),f.copy(Q).multiplyScalar(E),C.copy(D).sub(f),L.copy(D).add(f),q=oe+X,ee=!1,G!==void 0){U(D,G,p),f.copy(p).multiplyScalar(E),M.copy(D).sub(f),P.copy(D).add(f),te=!0,f.subVectors(G,z),Q.dot(f)<0&&(te=!1),Y===1&&(le=te),f.subVectors(G,D),f.normalize();const re=Math.abs(Q.dot(f));if(re>Number.EPSILON){const se=E/re;f.multiplyScalar(-se),m.subVectors(D,z),d.copy(m).setLength(se).add(f),w.copy(d).negate();const j=d.length(),F=m.length();m.divideScalar(F),g.subVectors(G,D);const ie=g.length();switch(g.divideScalar(ie),m.dot(w)<F&&g.dot(w)<ie&&(ee=!0),S.copy(d).add(D),w.add(D),ce=!1,ee?te?(P.copy(w),L.copy(w)):(M.copy(w),C.copy(w)):T(),t.strokeLineJoin){case"bevel":O(te,ee,q);break;case"round":N(te,ee),te?R(D,C,M,q,0):R(D,P,L,q,1);break;case"miter":case"miter-clip":default:const he=E*t.strokeMiterLimit/j;if(he<1)if(t.strokeLineJoin!=="miter-clip"){O(te,ee,q);break}else N(te,ee),te?(g.subVectors(S,C).multiplyScalar(he).add(C),y.subVectors(S,M).multiplyScalar(he).add(M),B(C,q,0),B(g,q,0),B(D,q,.5),B(D,q,.5),B(g,q,0),B(y,q,0),B(D,q,.5),B(y,q,0),B(M,q,0)):(g.subVectors(S,L).multiplyScalar(he).add(L),y.subVectors(S,P).multiplyScalar(he).add(P),B(L,q,1),B(g,q,1),B(D,q,.5),B(D,q,.5),B(g,q,1),B(y,q,1),B(D,q,.5),B(y,q,1),B(P,q,1));else ee?(te?(B(_,oe,1),B(v,oe,0),B(S,q,0),B(_,oe,1),B(S,q,0),B(w,q,1)):(B(_,oe,1),B(v,oe,0),B(S,q,1),B(v,oe,0),B(w,q,0),B(S,q,1)),te?M.copy(S):P.copy(S)):te?(B(C,q,0),B(S,q,0),B(D,q,.5),B(D,q,.5),B(S,q,0),B(M,q,0)):(B(L,q,1),B(S,q,1),B(D,q,.5),B(D,q,.5),B(S,q,1),B(P,q,1)),ce=!0;break}}else T()}else T();!I&&Y===x-1&&K(e[0],A,b,te,!0,oe),oe=q,z=D,v.copy(M),_.copy(P)}if(!I)K(D,C,L,te,!1,q);else if(ee&&r){let Y=S,Q=w;le!==te&&(Y=w,Q=S),te?(ce||le)&&(Q.toArray(r,0*3),Q.toArray(r,3*3),ce&&Y.toArray(r,1*3)):(ce||!le)&&(Q.toArray(r,1*3),Q.toArray(r,3*3),ce&&Y.toArray(r,0*3))}return de;function U(Y,Q,re){return re.subVectors(Q,Y),re.set(-re.y,re.x).normalize()}function B(Y,Q,re){r&&(r[k]=Y.x,r[k+1]=Y.y,r[k+2]=0,s&&(s[k]=0,s[k+1]=0,s[k+2]=1),k+=3,i&&(i[V]=Q,i[V+1]=re,V+=2)),de+=3}function R(Y,Q,re,se,j){h.copy(Q).sub(Y).normalize(),p.copy(re).sub(Y).normalize();let F=Math.PI;const ie=h.dot(p);Math.abs(ie)<1&&(F=Math.abs(Math.acos(ie))),F/=n,f.copy(Q);for(let he=0,_e=n-1;he<_e;he++)m.copy(f).rotateAround(Y,F),B(f,se,j),B(m,se,j),B(Y,se,.5),f.copy(m);B(m,se,j),B(re,se,j),B(Y,se,.5)}function T(){B(_,oe,1),B(v,oe,0),B(C,q,0),B(_,oe,1),B(C,q,0),B(L,q,1)}function O(Y,Q,re){Q?Y?(B(_,oe,1),B(v,oe,0),B(C,q,0),B(_,oe,1),B(C,q,0),B(w,q,1),B(C,re,0),B(M,re,0),B(w,re,.5)):(B(_,oe,1),B(v,oe,0),B(L,q,1),B(v,oe,0),B(w,q,0),B(L,q,1),B(L,re,1),B(w,re,0),B(P,re,1)):Y?(B(C,re,0),B(M,re,0),B(D,re,.5)):(B(L,re,1),B(P,re,0),B(D,re,.5))}function N(Y,Q){Q&&(Y?(B(_,oe,1),B(v,oe,0),B(C,q,0),B(_,oe,1),B(C,q,0),B(w,q,1),B(C,oe,0),B(D,q,.5),B(w,q,1),B(D,q,.5),B(M,oe,0),B(w,q,1)):(B(_,oe,1),B(v,oe,0),B(L,q,1),B(v,oe,0),B(w,q,0),B(L,q,1),B(L,oe,1),B(w,q,0),B(D,q,.5),B(D,q,.5),B(w,q,0),B(P,oe,1)))}function K(Y,Q,re,se,j,F){switch(t.strokeLineCap){case"round":j?R(Y,re,Q,F,.5):R(Y,Q,re,F,.5);break;case"square":if(j)h.subVectors(Q,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y),se?(f.toArray(r,1*3),m.toArray(r,0*3),m.toArray(r,3*3)):(f.toArray(r,1*3),i[3*2+1]===1?m.toArray(r,3*3):f.toArray(r,3*3),m.toArray(r,0*3));else{h.subVectors(re,Y),p.set(h.y,-h.x),f.addVectors(h,p).add(Y),m.subVectors(p,h).add(Y);const ie=r.length;se?(f.toArray(r,ie-1*3),m.toArray(r,ie-2*3),m.toArray(r,ie-4*3)):(m.toArray(r,ie-2*3),f.toArray(r,ie-1*3),m.toArray(r,ie-4*3))}break}}function W(Y){let Q=!1;for(let se=1,j=Y.length-1;se<j;se++)if(Y[se].distanceTo(Y[se+1])<o){Q=!0;break}if(!Q)return Y;const re=[];re.push(Y[0]);for(let se=1,j=Y.length-1;se<j;se++)Y[se].distanceTo(Y[se+1])>=o&&re.push(Y[se]);return re.push(Y[Y.length-1]),re}}}const lo=new WeakMap;class mc extends l.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,o){const r=new l.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,s=>{const i={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(s,i).then(t).catch(o)},n,o)}decodeDracoFile(e,t,n,o){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:o||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const n=JSON.stringify(t);if(lo.has(e)){const c=lo.get(e);if(c.key===n)return c.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let o;const r=this.workerNextTaskID++,s=e.byteLength,i=this._getWorker(r,s).then(c=>(o=c,new Promise((h,p)=>{o._callbacks[r]={resolve:h,reject:p},o.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return i.catch(()=>!0).then(()=>{o&&r&&this._releaseTask(o,r)}),lo.set(e,{key:n,promise:i}),i}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const o=e.attributes[n],r=o.name,s=o.array,i=o.itemSize;t.setAttribute(r,new l.BufferAttribute(s,i))}return t}_loadLibrary(e,t){const n=new l.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((o,r)=>{n.load(e,o,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const o=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=gc.toString(),s=["/* draco decoder */",o,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
563
563
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const o=new Worker(this.workerSourceURL);o._callbacks={},o._taskCosts={},o._taskLoad=0,o.postMessage({type:"init",decoderConfig:this.decoderConfig}),o.onmessage=function(r){const s=r.data;switch(s.type){case"decode":o._callbacks[s.id].resolve(s);break;case"error":o._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(o)}else this.workerPool.sort(function(o,r){return o._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function gc(){let a,e;onmessage=function(s){const i=s.data;switch(i.type){case"init":a=i.decoderConfig,e=new Promise(function(p){a.onModuleLoaded=function(f){p({draco:f})},DracoDecoderModule(a)});break;case"decode":const c=i.buffer,h=i.taskConfig;e.then(p=>{const f=p.draco,m=new f.Decoder,d=new f.DecoderBuffer;d.Init(new Int8Array(c),c.byteLength);try{const g=t(f,m,d,h),y=g.attributes.map(v=>v.array.buffer);g.index&&y.push(g.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:g},y)}catch(g){console.error(g),self.postMessage({type:"error",id:i.id,error:g.message})}finally{f.destroy(d),f.destroy(m)}});break}};function t(s,i,c,h){const p=h.attributeIDs,f=h.attributeTypes;let m,d;const g=i.GetEncodedGeometryType(c);if(g===s.TRIANGULAR_MESH)m=new s.Mesh,d=i.DecodeBufferToMesh(c,m);else if(g===s.POINT_CLOUD)m=new s.PointCloud,d=i.DecodeBufferToPointCloud(c,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!d.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+d.error_msg());const y={index:null,attributes:[]};for(const v in p){const _=self[f[v]];let A,b;if(h.useUniqueIDs)b=p[v],A=i.GetAttributeByUniqueId(m,b);else{if(b=i.GetAttributeId(m,s[p[v]]),b===-1)continue;A=i.GetAttribute(m,b)}y.attributes.push(o(s,i,m,v,_,A))}return g===s.TRIANGULAR_MESH&&(y.index=n(s,i,m)),s.destroy(m),y}function n(s,i,c){const p=c.num_faces()*3,f=p*4,m=s._malloc(f);i.GetTrianglesUInt32Array(c,f,m);const d=new Uint32Array(s.HEAPF32.buffer,m,p).slice();return s._free(m),{array:d,itemSize:1}}function o(s,i,c,h,p,f){const m=f.num_components(),g=c.num_points()*m,y=g*p.BYTES_PER_ELEMENT,v=r(s,p),_=s._malloc(y);i.GetAttributeDataArrayForAllPoints(c,f,v,y,_);const A=new p(s.HEAPF32.buffer,_,g).slice();return s._free(_),{name:h,array:A,itemSize:m}}function r(s,i){switch(i){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}const Gr=new l.Box3,vn=new l.Vector3;class Rr extends l.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new l.Float32BufferAttribute(e,3)),this.setAttribute("uv",new l.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new l.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new l.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new l.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const o=new l.InstancedInterleavedBuffer(n,t*2,1);return this.setAttribute("instanceColorStart",new l.InterleavedBufferAttribute(o,t,0)),this.setAttribute("instanceColorEnd",new l.InterleavedBufferAttribute(o,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new l.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new l.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Gr.setFromBufferAttribute(t),this.boundingBox.union(Gr))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new l.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let o=0;for(let r=0,s=e.count;r<s;r++)vn.fromBufferAttribute(e,r),o=Math.max(o,n.distanceToSquared(vn)),vn.fromBufferAttribute(t,r),o=Math.max(o,n.distanceToSquared(vn));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}class jr extends Rr{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let o=0;o<t;o+=3)n[2*o]=e[o],n[2*o+1]=e[o+1],n[2*o+2]=e[o+2],n[2*o+3]=e[o+3],n[2*o+4]=e[o+4],n[2*o+5]=e[o+5];return super.setPositions(n),this}setColors(e,t=3){const n=e.length-t,o=new Float32Array(2*n);if(t===3)for(let r=0;r<n;r+=t)o[2*r]=e[r],o[2*r+1]=e[r+1],o[2*r+2]=e[r+2],o[2*r+3]=e[r+3],o[2*r+4]=e[r+4],o[2*r+5]=e[r+5];else for(let r=0;r<n;r+=t)o[2*r]=e[r],o[2*r+1]=e[r+1],o[2*r+2]=e[r+2],o[2*r+3]=e[r+3],o[2*r+4]=e[r+4],o[2*r+5]=e[r+5],o[2*r+6]=e[r+6],o[2*r+7]=e[r+7];return super.setColors(o,t),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class co extends l.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:l.UniformsUtils.clone(l.UniformsUtils.merge([l.UniformsLib.common,l.UniformsLib.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new l.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
|
|
564
564
|
#include <common>
|
|
565
565
|
#include <fog_pars_vertex>
|
|
@@ -1008,20 +1008,20 @@ ${t}`),[Nn()]}return a.animations[e]}function Wo(a,e,t){if(e<0||a.frames.length<
|
|
|
1008
1008
|
gl_FragColor = vec4(color, opacity);
|
|
1009
1009
|
#include <tonemapping_fragment>
|
|
1010
1010
|
#include <colorspace_fragment>
|
|
1011
|
-
}`),Yc=u.defineComponent({__name:"component",props:{color:{default:"black"},screenspace:{type:Boolean,default:!1},opacity:{default:1},transparent:{type:Boolean,default:!1},thickness:{default:.05},angle:{default:Math.PI},toneMapped:{type:Boolean,default:!0},polygonOffset:{type:Boolean,default:!1},polygonOffsetFactor:{default:0},renderOrder:{default:0}},setup(a,{expose:e}){const t=a,n=u.shallowRef();e({instance:n});const o=new Wc({...t}),r=new l.Vector2(1,1);let s=0,i=null;function c(f){var d;const m=f.parent;if(!(!m||!m.geometry)&&(s!==t.angle||i!==m.geometry)){s=t.angle,i=m.geometry;let g=(d=f.children)==null?void 0:d[0];g&&(t.angle&&g.geometry.dispose(),f.remove(g)),m.skeleton?(g=new l.SkinnedMesh,g.material=o,g.bind(m.skeleton,m.bindMatrix),f.add(g)):m.isInstancedMesh?(g=new l.InstancedMesh(m.geometry,o,m.count),g.instanceMatrix=m.instanceMatrix,f.add(g)):(g=new l.Mesh,g.material=o,f.add(g)),g.geometry=t.angle?Ji(m.geometry,t.angle):m.geometry}}function h(){o.side=l.BackSide,o.transparent=t.transparent,o.thickness=t.thickness,o.color=H.normalizeColor(t.color),o.opacity=t.opacity,o.size=r,o.screenspace=t.screenspace,o.toneMapped=t.toneMapped,o.polygonOffset=t.polygonOffset,o.polygonOffsetFactor=t.polygonOffsetFactor}const p=H.useTres().sizes;return u.watch(()=>[p.width.value,p.height.value],([f,m])=>{r.set(f,m)}),u.watch(()=>[t.angle],()=>{n.value&&c(n.value)}),u.watch(()=>[t.transparent,t.thickness,t.color,t.opacity,r,t.screenspace,t.toneMapped,t.polygonOffset,t.polygonOffsetFactor],()=>h(),{immediate:!0}),u.onMounted(()=>c(n.value)),u.onUnmounted(()=>{var m;const f=(m=n.value)==null?void 0:m.children[0];f&&(f.geometry.dispose(),o.dispose(),f.removeFromParent())}),(f,m)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:n},null,512))}}),Xc=["args"],Ec=u.defineComponent({__name:"PositionalAudio",props:{ready:{type:Boolean,default:!1},url:{},distance:{default:2},helper:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},autoplay:{type:Boolean,default:!1},innerAngle:{default:360},outerAngle:{default:360},outerGain:{default:0}},emits:["isPlaying"],async setup(a,{expose:e,emit:t}){let n,o;const r=a,s=t,{ready:i,url:c,distance:h,helper:p,loop:f,autoplay:m,innerAngle:d,outerAngle:g,outerGain:y}=u.toRefs(r),{camera:v}=H.useTresContext(),_=u.shallowRef(null),A=u.shallowRef(null),b=u.shallowRef(null),C=u.shallowReactive(new l.AudioListener),L=()=>{var z,G,X;(z=_==null?void 0:_.value)!=null&&z.isPlaying||((G=_==null?void 0:_.value)==null||G.play(),s("isPlaying",(X=_==null?void 0:_.value)==null?void 0:X.isPlaying))},M=()=>{var z,G;(z=_==null?void 0:_.value)!=null&&z.isPlaying&&(_.value.pause(),s("isPlaying",(G=_==null?void 0:_.value)==null?void 0:G.isPlaying))},P=()=>{var z;_.value&&(_.value.stop(),s("isPlaying",(z=_==null?void 0:_.value)==null?void 0:z.isPlaying))},w=()=>{if(!(_!=null&&_.value))return;P();const z=_.value;z.source&&z.disconnect()},S=()=>{var z,G;!(_!=null&&_.value)||!(A!=null&&A.value)||((z=A==null?void 0:A.value)==null||z.dispose(),(G=_==null?void 0:_.value)==null||G.remove(A==null?void 0:A.value))},x=()=>{var z;if(_.value&&(_.value.setBuffer(b.value),_.value.setRefDistance(h.value),_.value.setLoop(f.value),_.value.setDirectionalCone(d.value,g.value,y.value),(z=A==null?void 0:A.value)==null||z.update(),A!=null&&A.value)){const G=A.value.material[0];!G.visible&&g.value!==d.value&&(G.visible=!0)}},I=()=>{var E,te;x();const z=(E=_.value)==null?void 0:E.parent,G=new l.Box3().setFromObject(z),X=(G.max.z-G.min.z)*2;A.value=new wc(_.value,X,32,16),(te=_==null?void 0:_.value)==null||te.add(A.value),A.value.update()},D=()=>{var z;(z=v==null?void 0:v.value)==null||z.remove(C),w(),S()};return e({instance:_,play:L,stop:P,pause:M,dispose:D}),b.value=([n,o]=u.withAsyncContext(()=>H.useLoader(l.AudioLoader,c.value)),n=await n,o(),n),u.watch(_,()=>{_!=null&&_.value&&(p.value&&I(),i.value&&m&&L())}),u.watch(p,()=>{p.value?I():S()}),u.watch(i,()=>{i.value&&x(),m.value&&i.value&&L(),!m.value&&i.value&&P()}),u.watch([h,f,b,d,g,y,m],()=>{x()}),u.onMounted(()=>{var z;(z=v==null?void 0:v.value)==null||z.add(C)}),u.onBeforeUnmount(()=>{D()}),(z,G)=>(u.openBlock(),u.createElementBlock("TresPositionalAudio",u.mergeProps({ref_key:"positionalAudioRef",ref:_,args:[u.unref(C)]},z.$attrs),null,16,Xc))}}),Zc=["args","material-uniforms-color-value"],Kc=u.defineComponent({__name:"Reflector",props:{color:{default:"#333"},textureWidth:{default:512},textureHeight:{default:512},clipBias:{default:0},multisample:{default:4},shader:{default:Qn.ReflectorShader}},setup(a,{expose:e}){const t=a,{extend:n,invalidate:o}=H.useTresContext(),r=u.shallowRef();n({Reflector:Qn});const{color:s,textureWidth:i,textureHeight:c,clipBias:h,multisample:p,shader:f}=u.toRefs(t);return u.watch(t,()=>o()),e({instance:r}),(m,d)=>(u.openBlock(),u.createElementBlock("TresReflector",{ref_key:"reflectorRef",ref:r,args:[void 0,{textureWidth:u.unref(i),textureHeight:u.unref(c),clipBias:u.unref(h),multisample:u.unref(p),shader:u.unref(f)}],"material-uniforms-color-value":u.unref(s)},[u.renderSlot(m.$slots,"default",{},()=>[d[0]||(d[0]=u.createElementVNode("TresPlaneGeometry",{args:[5,5]},null,-1))])],8,Zc))}}),qc=["position-z"],Qc=u.defineComponent({__name:"ScreenSpace",props:{depth:{default:-1}},setup(a,{expose:e}){const t=u.shallowRef();return H.useLoop().onBeforeRender(({camera:n})=>{t.value&&(t.value.quaternion.copy(n.quaternion),t.value.position.copy(n.position))}),e({instance:t}),(n,o)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outerRef",ref:t},[u.createElementVNode("TresGroup",{"position-z":-n.depth},[u.renderSlot(n.$slots,"default")],8,qc)],512))}}),Jc=["args","center"],Hc=u.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,{center:r,font:s,text:i,needUpdates:c,size:h,height:p,curveSegments:f,bevelEnabled:m,bevelThickness:d,bevelSize:g,bevelOffset:y,bevelSegments:v}=u.toRefs(o),{extend:_,invalidate:A}=H.useTresContext();u.watch(o,()=>A()),_({TextGeometry:Ir});const b=new hc,C=u.useSlots(),L=u.computed(()=>{var S;return i!=null&&i.value?i.value:C.default?(S=C.default()[0].children)==null?void 0:S.trim():c.value?"":"TresJS"}),M=u.shallowRef();e({instance:M});const P=([t,n]=u.withAsyncContext(()=>new Promise((S,x)=>{try{typeof s.value=="string"?b.load(s.value,I=>{S(I)}):S(s.value)}catch(I){x(console.error("cientos",I))}})),t=await t,n(),t),w=u.computed(()=>({font:P,size:u.toValue(h),height:u.toValue(p),curveSegments:u.toValue(f),bevelEnabled:u.toValue(m),bevelThickness:u.toValue(d),bevelSize:u.toValue(g),bevelOffset:u.toValue(y),bevelSegments:u.toValue(v)}));return u.watchEffect(()=>{M.value&&c.value&&(M.value.geometry.dispose(),M.value.geometry=new Ir(L.value,w.value),r.value&&M.value.geometry.center())}),(S,x)=>u.unref(s)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:M},[L.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[L.value,w.value],center:u.unref(r)},null,8,Jc)):u.createCommentVNode("",!0),u.renderSlot(S.$slots,"default")],512)):u.createCommentVNode("",!0)}});function $c(a,e){const t=u.ref(e),n=new l.AnimationMixer(t.value),o=u.shallowReactive({});a.forEach(s=>{const i=n.clipAction(s,t.value);o[s.name]=i});const{onBeforeRender:r}=H.useLoop();return r(({delta:s})=>{n.update(s)}),{actions:o,mixer:n}}function eu(a,e=!1){const t=u.reactive({stencilWrite:!0,stencilRef:u.toValue(a),stencilFunc:u.toValue(e)?l.NotEqualStencilFunc:l.EqualStencilFunc,stencilFail:l.KeepStencilOp,stencilZFail:l.KeepStencilOp,stencilZPass:l.KeepStencilOp});return u.watchEffect(()=>{t.stencilRef=u.toValue(a),t.stencilFunc=u.toValue(e)?l.NotEqualStencilFunc:l.EqualStencilFunc}),t}function ns(a){const e=u.ref(null),{height:t,width:n,settings:o,depth:r,autoRender:s=u.ref(!0)}=u.isReactive(a)?u.toRefs(a):u.toRefs(u.reactive(a)),{onBeforeRender:i}=H.useLoop(),{camera:c,renderer:h,scene:p,sizes:f,invalidate:m}=H.useTresContext();return u.watch(()=>[n==null?void 0:n.value,f.width.value,t==null?void 0:t.value,f.height.value],()=>{var d;(d=e.value)==null||d.dispose(),e.value=new l.WebGLRenderTarget((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType,...o==null?void 0:o.value}),r!=null&&r.value&&(e.value.depthTexture=new l.DepthTexture((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,l.FloatType)),m()},{immediate:!0}),i(()=>{s.value&&(h.value.setRenderTarget(e.value),h.value.clear(),h.value.render(p.value,c.value),h.value.setRenderTarget(null))},Number.POSITIVE_INFINITY),u.onBeforeUnmount(()=>{var d;(d=e.value)==null||d.dispose()}),e}const tu=u.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0},autoRender:{type:Boolean,default:!0}},setup(a,{expose:e}){const n=ns(a);return e({instance:n}),()=>{}}}),os=(a,e=16,t,n,o)=>{const r=new Float32Array(e*16),s=u.ref(new l.InterleavedBuffer(r,16));return(()=>{if(!a)return;const c=new Ya(a);n&&c.setWeightAttribute(n),c.build();const h=new l.Vector3,p=new l.Vector3,f=new l.Color,m=new l.Object3D;a.updateMatrixWorld(!0);for(let d=0;d<e;d++)c.sample(h,p,f),typeof o=="function"?o({dummy:m,sampledMesh:a,position:h,normal:p,color:f},d):m.position.copy(h),m.updateMatrix(),t&&t.setMatrixAt(d,m.matrix),m.matrix.toArray(s.value.array,d*16);t&&(t.instanceMatrix.needsUpdate=!0),s.value.needsUpdate=!0})(),{buffer:s}},nu=u.defineComponent({__name:"component",props:{transform:{type:Function},weight:{},count:{},mesh:{},instanceMesh:{}},setup(a,{expose:e}){const t=a,n=u.ref(),o=u.ref(),r=u.ref(),{invalidate:s}=H.useTresContext();return u.watch(t,()=>s()),u.watchEffect(()=>{var i,c;o.value=t.instanceMesh??((i=n.value)==null?void 0:i.children.find(h=>Object.prototype.hasOwnProperty.call(h,"instanceMatrix"))),r.value=t.mesh??((c=n.value)==null?void 0:c.children.find(h=>h.type==="Mesh")),os(r.value,t.count,o.value,t.weight,t.transform)}),e({samplerRef:n}),(i,c)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"samplerRef",ref:n},[u.renderSlot(i.$slots,"default")],512))}}),ou=new Ot.Vector3,ru=new Ot.Vector3,su=new Ot.Vector3,iu=(a,e,t)=>{const n=t.width/2,o=t.height/2;e.updateMatrixWorld(!1);const r=a.project(e);return r.x=r.x*n+n,r.y=-(r.y*o)+o,r},au=(a,e,t,n=1)=>{const o=ou.set(a.x/t.width*2-1,-(a.y/t.height)*2+1,n);return o.unproject(e),o},lu=(a,e,t,n)=>{const o=iu(su.copy(a),t,n);let r=0;for(let s=0;s<2;++s){const i=ru.copy(o).setComponent(s,o.getComponent(s)+e),c=au(i,t,n,i.z);r=Math.max(r,a.distanceTo(c))}return r},cu=u.defineComponent({__name:"ScreenSizer",setup(a,{expose:e}){const t=new l.Vector3,n=u.shallowRef(),o=u.shallowRef(),r=H.useTres().sizes,s=u.computed(()=>({width:r.width.value,height:r.height.value}));return H.useLoop().onBeforeRender(({camera:i})=>{const c=o.value;if(!c)return;const h=lu(c.getWorldPosition(t),1,i,s.value);c.scale.setScalar(h)}),e({instance:n}),(i,c)=>(u.openBlock(),u.createElementBlock("TresObject3D",{ref_key:"outerRef",ref:n},[u.createElementVNode("TresObject3D",{ref_key:"innerRef",ref:o},[u.renderSlot(i.$slots,"default")],512)],512))}}),uu=["color"],hu=u.defineComponent({__name:"Edges",props:{color:{default:"#ff0000"},threshold:{default:15}},setup(a,{expose:e}){const t=a,{color:n,threshold:o}=u.toRefs(t),r=u.shallowRef(),s=u.ref(null),i=u.ref(1);return e({instance:r}),u.watch(()=>[r.value,o.value],()=>{if(r.value){const c=r.value.parent;if(c&&"geometry"in c&&c.geometry instanceof l.BufferGeometry){const h=c.geometry;(h!==s.value||o.value!==i.value)&&(s.value=h,i.value=o.value,r.value.geometry=new l.EdgesGeometry(h,o.value))}}}),(c,h)=>(u.openBlock(),u.createElementBlock("TresLineSegments",u.mergeProps({ref_key:"lineSegmentsRef",ref:r},c.$attrs),[u.renderSlot(c.$slots,"default",{},()=>[u.createElementVNode("TresLineBasicMaterial",{color:u.unref(n)},null,8,uu)])],16))}}),An={sunset:"venice/venice_sunset_1k.hdr",studio:"studio/poly_haven_studio_1k.hdr",city:"city/canary_wharf_1k.hdr",umbrellas:"outdoor/outdoor_umbrellas_1k.hdr",night:"outdoor/satara_night_1k.hdr",forest:"outood/mossy_forest_1k.hdr",snow:"outdoor/snowy_forest_path_01_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",hangar:"indoor/small_hangar_01_1k.hdr",urban:"indoor/abandoned_games_room_02_1k.hdr",modern:"city/modern_buildings_2_1k.hdr",shangai:"city/shanghai_bund_1k.hdr"},fu="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function rs(a,e){const{scene:t,invalidate:n}=H.useTresContext(),{preset:o,blur:r,files:s=u.ref([]),path:i=u.ref(""),background:c}=u.toRefs(a);u.watch(a,()=>{n()});const h=u.ref(null),p=u.computed(()=>Array.isArray(s.value)),f=u.computed(()=>p.value?l.CubeTextureLoader:Vr);return u.watch([s,i],async([m,d])=>{if(m&&m.length>0&&!(o!=null&&o.value)){try{const g=await H.useLoader(f.value,p.value?[...u.unref(m)]:u.unref(m),y=>{d&&y.setPath(u.unref(d))});h.value=Array.isArray(g)?g[0]:g}catch(g){throw new Error(`Failed to load environment map: ${g}`)}h.value&&(h.value.mapping=p.value?l.CubeReflectionMapping:l.EquirectangularReflectionMapping)}},{immediate:!0}),u.watch(h,m=>{t.value&&m&&(t.value.environment=m)},{immediate:!0}),u.watch([c,h],([m,d])=>{if(t.value){const g=e!=null&&e.value?e.value.texture:d;g&&(t.value.background=m?g:null)}},{immediate:!0}),u.watch(()=>r==null?void 0:r.value,m=>{t.value&&m&&(t.value.backgroundBlurriness=m)},{immediate:!0}),u.watch(()=>o==null?void 0:o.value,async m=>{if(m&&m in An){const d=fu,g=An[m];try{const y=await H.useLoader(Vr,g,v=>{d&&v.setPath(d)});h.value=Array.isArray(y)?y[0]:y}catch(y){throw new Error(`Failed to load environment map: ${y}`)}h.value&&(h.value.mapping=l.EquirectangularReflectionMapping),n()}else if(m&&!(m in An))throw new Error(`Preset must be one of: ${Object.keys(An).join(", ")}`)},{immediate:!0}),h}/*!
|
|
1011
|
+
}`),Yc=u.defineComponent({__name:"component",props:{color:{default:"black"},screenspace:{type:Boolean,default:!1},opacity:{default:1},transparent:{type:Boolean,default:!1},thickness:{default:.05},angle:{default:Math.PI},toneMapped:{type:Boolean,default:!0},polygonOffset:{type:Boolean,default:!1},polygonOffsetFactor:{default:0},renderOrder:{default:0}},setup(a,{expose:e}){const t=a,n=u.shallowRef();e({instance:n});const o=new Wc({...t}),r=new l.Vector2(1,1);let s=0,i=null;function c(f){var d;const m=f.parent;if(!(!m||!m.geometry)&&(s!==t.angle||i!==m.geometry)){s=t.angle,i=m.geometry;let g=(d=f.children)==null?void 0:d[0];g&&(t.angle&&g.geometry.dispose(),f.remove(g)),m.skeleton?(g=new l.SkinnedMesh,g.material=o,g.bind(m.skeleton,m.bindMatrix),f.add(g)):m.isInstancedMesh?(g=new l.InstancedMesh(m.geometry,o,m.count),g.instanceMatrix=m.instanceMatrix,f.add(g)):(g=new l.Mesh,g.material=o,f.add(g)),g.geometry=t.angle?Ji(m.geometry,t.angle):m.geometry}}function h(){o.side=l.BackSide,o.transparent=t.transparent,o.thickness=t.thickness,o.color=H.normalizeColor(t.color),o.opacity=t.opacity,o.size=r,o.screenspace=t.screenspace,o.toneMapped=t.toneMapped,o.polygonOffset=t.polygonOffset,o.polygonOffsetFactor=t.polygonOffsetFactor}const p=H.useTres().sizes;return u.watch(()=>[p.width.value,p.height.value],([f,m])=>{r.set(f,m)}),u.watch(()=>[t.angle],()=>{n.value&&c(n.value)}),u.watch(()=>[t.transparent,t.thickness,t.color,t.opacity,r,t.screenspace,t.toneMapped,t.polygonOffset,t.polygonOffsetFactor],()=>h(),{immediate:!0}),u.onMounted(()=>c(n.value)),u.onUnmounted(()=>{var m;const f=(m=n.value)==null?void 0:m.children[0];f&&(f.geometry.dispose(),o.dispose(),f.removeFromParent())}),(f,m)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:n},null,512))}}),Xc=["args"],Ec=u.defineComponent({__name:"PositionalAudio",props:{ready:{type:Boolean,default:!1},url:{},distance:{default:2},helper:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},autoplay:{type:Boolean,default:!1},innerAngle:{default:360},outerAngle:{default:360},outerGain:{default:0}},emits:["isPlaying"],async setup(a,{expose:e,emit:t}){let n,o;const r=a,s=t,{ready:i,url:c,distance:h,helper:p,loop:f,autoplay:m,innerAngle:d,outerAngle:g,outerGain:y}=u.toRefs(r),{camera:v}=H.useTresContext(),_=u.shallowRef(null),A=u.shallowRef(null),b=u.shallowRef(null),C=u.shallowReactive(new l.AudioListener),L=()=>{var z,G,E;(z=_==null?void 0:_.value)!=null&&z.isPlaying||((G=_==null?void 0:_.value)==null||G.play(),s("isPlaying",(E=_==null?void 0:_.value)==null?void 0:E.isPlaying))},M=()=>{var z,G;(z=_==null?void 0:_.value)!=null&&z.isPlaying&&(_.value.pause(),s("isPlaying",(G=_==null?void 0:_.value)==null?void 0:G.isPlaying))},P=()=>{var z;_.value&&(_.value.stop(),s("isPlaying",(z=_==null?void 0:_.value)==null?void 0:z.isPlaying))},w=()=>{if(!(_!=null&&_.value))return;P();const z=_.value;z.source&&z.disconnect()},S=()=>{var z,G;!(_!=null&&_.value)||!(A!=null&&A.value)||((z=A==null?void 0:A.value)==null||z.dispose(),(G=_==null?void 0:_.value)==null||G.remove(A==null?void 0:A.value))},x=()=>{var z;if(_.value&&(_.value.setBuffer(b.value),_.value.setRefDistance(h.value),_.value.setLoop(f.value),_.value.setDirectionalCone(d.value,g.value,y.value),(z=A==null?void 0:A.value)==null||z.update(),A!=null&&A.value)){const G=A.value.material[0];!G.visible&&g.value!==d.value&&(G.visible=!0)}},I=()=>{var X,oe;x();const z=(X=_.value)==null?void 0:X.parent,G=new l.Box3().setFromObject(z),E=(G.max.z-G.min.z)*2;A.value=new wc(_.value,E,32,16),(oe=_==null?void 0:_.value)==null||oe.add(A.value),A.value.update()},D=()=>{var z;(z=v==null?void 0:v.value)==null||z.remove(C),w(),S()};return e({instance:_,play:L,stop:P,pause:M,dispose:D}),b.value=([n,o]=u.withAsyncContext(()=>H.useLoader(l.AudioLoader,c.value)),n=await n,o(),n),u.watch(_,()=>{_!=null&&_.value&&(p.value&&I(),i.value&&m&&L())}),u.watch(p,()=>{p.value?I():S()}),u.watch(i,()=>{i.value&&x(),m.value&&i.value&&L(),!m.value&&i.value&&P()}),u.watch([h,f,b,d,g,y,m],()=>{x()}),u.onMounted(()=>{var z;(z=v==null?void 0:v.value)==null||z.add(C)}),u.onBeforeUnmount(()=>{D()}),(z,G)=>(u.openBlock(),u.createElementBlock("TresPositionalAudio",u.mergeProps({ref_key:"positionalAudioRef",ref:_,args:[u.unref(C)]},z.$attrs),null,16,Xc))}}),Zc=["args","material-uniforms-color-value"],Kc=u.defineComponent({__name:"Reflector",props:{color:{default:"#333"},textureWidth:{default:512},textureHeight:{default:512},clipBias:{default:0},multisample:{default:4},shader:{default:Qn.ReflectorShader}},setup(a,{expose:e}){const t=a,{extend:n,invalidate:o}=H.useTresContext(),r=u.shallowRef();n({Reflector:Qn});const{color:s,textureWidth:i,textureHeight:c,clipBias:h,multisample:p,shader:f}=u.toRefs(t);return u.watch(t,()=>o()),e({instance:r}),(m,d)=>(u.openBlock(),u.createElementBlock("TresReflector",{ref_key:"reflectorRef",ref:r,args:[void 0,{textureWidth:u.unref(i),textureHeight:u.unref(c),clipBias:u.unref(h),multisample:u.unref(p),shader:u.unref(f)}],"material-uniforms-color-value":u.unref(s)},[u.renderSlot(m.$slots,"default",{},()=>[d[0]||(d[0]=u.createElementVNode("TresPlaneGeometry",{args:[5,5]},null,-1))])],8,Zc))}}),qc=["position-z"],Qc=u.defineComponent({__name:"ScreenSpace",props:{depth:{default:-1}},setup(a,{expose:e}){const t=u.shallowRef();return H.useLoop().onBeforeRender(({camera:n})=>{t.value&&(t.value.quaternion.copy(n.quaternion),t.value.position.copy(n.position))}),e({instance:t}),(n,o)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outerRef",ref:t},[u.createElementVNode("TresGroup",{"position-z":-n.depth},[u.renderSlot(n.$slots,"default")],8,qc)],512))}}),Jc=["args","center"],Hc=u.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,{center:r,font:s,text:i,needUpdates:c,size:h,height:p,curveSegments:f,bevelEnabled:m,bevelThickness:d,bevelSize:g,bevelOffset:y,bevelSegments:v}=u.toRefs(o),{extend:_,invalidate:A}=H.useTresContext();u.watch(o,()=>A()),_({TextGeometry:Ir});const b=new hc,C=u.useSlots(),L=u.computed(()=>{var S;return i!=null&&i.value?i.value:C.default?(S=C.default()[0].children)==null?void 0:S.trim():c.value?"":"TresJS"}),M=u.shallowRef();e({instance:M});const P=([t,n]=u.withAsyncContext(()=>new Promise((S,x)=>{try{typeof s.value=="string"?b.load(s.value,I=>{S(I)}):S(s.value)}catch(I){x(console.error("cientos",I))}})),t=await t,n(),t),w=u.computed(()=>({font:P,size:u.toValue(h),height:u.toValue(p),curveSegments:u.toValue(f),bevelEnabled:u.toValue(m),bevelThickness:u.toValue(d),bevelSize:u.toValue(g),bevelOffset:u.toValue(y),bevelSegments:u.toValue(v)}));return u.watchEffect(()=>{M.value&&c.value&&(M.value.geometry.dispose(),M.value.geometry=new Ir(L.value,w.value),r.value&&M.value.geometry.center())}),(S,x)=>u.unref(s)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:M},[L.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[L.value,w.value],center:u.unref(r)},null,8,Jc)):u.createCommentVNode("",!0),u.renderSlot(S.$slots,"default")],512)):u.createCommentVNode("",!0)}});function $c(a,e){const t=u.ref(e),n=new l.AnimationMixer(t.value),o=u.shallowReactive({});a.forEach(s=>{const i=n.clipAction(s,t.value);o[s.name]=i});const{onBeforeRender:r}=H.useLoop();return r(({delta:s})=>{n.update(s)}),{actions:o,mixer:n}}function eu(a,e=!1){const t=u.reactive({stencilWrite:!0,stencilRef:u.toValue(a),stencilFunc:u.toValue(e)?l.NotEqualStencilFunc:l.EqualStencilFunc,stencilFail:l.KeepStencilOp,stencilZFail:l.KeepStencilOp,stencilZPass:l.KeepStencilOp});return u.watchEffect(()=>{t.stencilRef=u.toValue(a),t.stencilFunc=u.toValue(e)?l.NotEqualStencilFunc:l.EqualStencilFunc}),t}function ns(a){const e=u.ref(null),{height:t,width:n,settings:o,depth:r,autoRender:s=u.ref(!0)}=u.isReactive(a)?u.toRefs(a):u.toRefs(u.reactive(a)),{onBeforeRender:i}=H.useLoop(),{camera:c,renderer:h,scene:p,sizes:f,invalidate:m}=H.useTresContext();return u.watch(()=>[n==null?void 0:n.value,f.width.value,t==null?void 0:t.value,f.height.value],()=>{var d;(d=e.value)==null||d.dispose(),e.value=new l.WebGLRenderTarget((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType,...o==null?void 0:o.value}),r!=null&&r.value&&(e.value.depthTexture=new l.DepthTexture((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,l.FloatType)),m()},{immediate:!0}),i(()=>{s.value&&(h.value.setRenderTarget(e.value),h.value.clear(),h.value.render(p.value,c.value),h.value.setRenderTarget(null))},Number.POSITIVE_INFINITY),u.onBeforeUnmount(()=>{var d;(d=e.value)==null||d.dispose()}),e}const tu=u.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0},autoRender:{type:Boolean,default:!0}},setup(a,{expose:e}){const n=ns(a);return e({instance:n}),()=>{}}}),os=(a,e=16,t,n,o)=>{const r=new Float32Array(e*16),s=u.ref(new l.InterleavedBuffer(r,16));return(()=>{if(!a)return;const c=new Ya(a);n&&c.setWeightAttribute(n),c.build();const h=new l.Vector3,p=new l.Vector3,f=new l.Color,m=new l.Object3D;a.updateMatrixWorld(!0);for(let d=0;d<e;d++)c.sample(h,p,f),typeof o=="function"?o({dummy:m,sampledMesh:a,position:h,normal:p,color:f},d):m.position.copy(h),m.updateMatrix(),t&&t.setMatrixAt(d,m.matrix),m.matrix.toArray(s.value.array,d*16);t&&(t.instanceMatrix.needsUpdate=!0),s.value.needsUpdate=!0})(),{buffer:s}},nu=u.defineComponent({__name:"component",props:{transform:{type:Function},weight:{},count:{},mesh:{},instanceMesh:{}},setup(a,{expose:e}){const t=a,n=u.ref(),o=u.ref(),r=u.ref(),{invalidate:s}=H.useTresContext();return u.watch(t,()=>s()),u.watchEffect(()=>{var i,c;o.value=t.instanceMesh??((i=n.value)==null?void 0:i.children.find(h=>Object.prototype.hasOwnProperty.call(h,"instanceMatrix"))),r.value=t.mesh??((c=n.value)==null?void 0:c.children.find(h=>h.type==="Mesh")),os(r.value,t.count,o.value,t.weight,t.transform)}),e({samplerRef:n}),(i,c)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"samplerRef",ref:n},[u.renderSlot(i.$slots,"default")],512))}}),ou=new Ot.Vector3,ru=new Ot.Vector3,su=new Ot.Vector3,iu=(a,e,t)=>{const n=t.width/2,o=t.height/2;e.updateMatrixWorld(!1);const r=a.project(e);return r.x=r.x*n+n,r.y=-(r.y*o)+o,r},au=(a,e,t,n=1)=>{const o=ou.set(a.x/t.width*2-1,-(a.y/t.height)*2+1,n);return o.unproject(e),o},lu=(a,e,t,n)=>{const o=iu(su.copy(a),t,n);let r=0;for(let s=0;s<2;++s){const i=ru.copy(o).setComponent(s,o.getComponent(s)+e),c=au(i,t,n,i.z);r=Math.max(r,a.distanceTo(c))}return r},cu=u.defineComponent({__name:"ScreenSizer",setup(a,{expose:e}){const t=new l.Vector3,n=u.shallowRef(),o=u.shallowRef(),r=H.useTres().sizes,s=u.computed(()=>({width:r.width.value,height:r.height.value}));return H.useLoop().onBeforeRender(({camera:i})=>{const c=o.value;if(!c)return;const h=lu(c.getWorldPosition(t),1,i,s.value);c.scale.setScalar(h)}),e({instance:n}),(i,c)=>(u.openBlock(),u.createElementBlock("TresObject3D",{ref_key:"outerRef",ref:n},[u.createElementVNode("TresObject3D",{ref_key:"innerRef",ref:o},[u.renderSlot(i.$slots,"default")],512)],512))}}),uu=["color"],hu=u.defineComponent({__name:"Edges",props:{color:{default:"#ff0000"},threshold:{default:15}},setup(a,{expose:e}){const t=a,{color:n,threshold:o}=u.toRefs(t),r=u.shallowRef(),s=u.ref(null),i=u.ref(1);return e({instance:r}),u.watch(()=>[r.value,o.value],()=>{if(r.value){const c=r.value.parent;if(c&&"geometry"in c&&c.geometry instanceof l.BufferGeometry){const h=c.geometry;(h!==s.value||o.value!==i.value)&&(s.value=h,i.value=o.value,r.value.geometry=new l.EdgesGeometry(h,o.value))}}}),(c,h)=>(u.openBlock(),u.createElementBlock("TresLineSegments",u.mergeProps({ref_key:"lineSegmentsRef",ref:r},c.$attrs),[u.renderSlot(c.$slots,"default",{},()=>[u.createElementVNode("TresLineBasicMaterial",{color:u.unref(n)},null,8,uu)])],16))}}),An={sunset:"venice/venice_sunset_1k.hdr",studio:"studio/poly_haven_studio_1k.hdr",city:"city/canary_wharf_1k.hdr",umbrellas:"outdoor/outdoor_umbrellas_1k.hdr",night:"outdoor/satara_night_1k.hdr",forest:"outood/mossy_forest_1k.hdr",snow:"outdoor/snowy_forest_path_01_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",hangar:"indoor/small_hangar_01_1k.hdr",urban:"indoor/abandoned_games_room_02_1k.hdr",modern:"city/modern_buildings_2_1k.hdr",shangai:"city/shanghai_bund_1k.hdr"},fu="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function rs(a,e){const{scene:t,invalidate:n}=H.useTresContext(),{preset:o,blur:r,files:s=u.ref([]),path:i=u.ref(""),background:c}=u.toRefs(a);u.watch(a,()=>{n()});const h=u.ref(null),p=u.computed(()=>Array.isArray(s.value)),f=u.computed(()=>p.value?l.CubeTextureLoader:Vr);return u.watch([s,i],async([m,d])=>{if(m&&m.length>0&&!(o!=null&&o.value)){try{const g=await H.useLoader(f.value,p.value?[...u.unref(m)]:u.unref(m),y=>{d&&y.setPath(u.unref(d))});h.value=Array.isArray(g)?g[0]:g}catch(g){throw new Error(`Failed to load environment map: ${g}`)}h.value&&(h.value.mapping=p.value?l.CubeReflectionMapping:l.EquirectangularReflectionMapping)}},{immediate:!0}),u.watch(h,m=>{t.value&&m&&(t.value.environment=m)},{immediate:!0}),u.watch([c,h],([m,d])=>{if(t.value){const g=e!=null&&e.value?e.value.texture:d;g&&(t.value.background=m?g:null)}},{immediate:!0}),u.watch(()=>r==null?void 0:r.value,m=>{t.value&&m&&(t.value.backgroundBlurriness=m)},{immediate:!0}),u.watch(()=>o==null?void 0:o.value,async m=>{if(m&&m in An){const d=fu,g=An[m];try{const y=await H.useLoader(Vr,g,v=>{d&&v.setPath(d)});h.value=Array.isArray(y)?y[0]:y}catch(y){throw new Error(`Failed to load environment map: ${y}`)}h.value&&(h.value.mapping=l.EquirectangularReflectionMapping),n()}else if(m&&!(m in An))throw new Error(`Preset must be one of: ${Object.keys(An).join(", ")}`)},{immediate:!0}),h}/*!
|
|
1012
1012
|
* camera-controls
|
|
1013
1013
|
* https://github.com/yomotsu/camera-controls
|
|
1014
1014
|
* (c) 2017 @yomotsu
|
|
1015
1015
|
* Released under the MIT License.
|
|
1016
|
-
*/const Oe={LEFT:1,RIGHT:2,MIDDLE:4},$=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ft={NONE:0,IN:1,OUT:-1};function Ct(a){return a.isPerspectiveCamera}function vt(a){return a.isOrthographicCamera}const zt=Math.PI*2,ss=Math.PI/2,is=1e-5,Ht=Math.PI/180;function $e(a,e,t){return Math.max(e,Math.min(t,a))}function Te(a,e=is){return Math.abs(a)<e}function Se(a,e,t=is){return Te(a-e,t)}function as(a,e){return Math.round(a/e)*e}function $t(a){return isFinite(a)?a:a<0?-Number.MAX_VALUE:Number.MAX_VALUE}function en(a){return Math.abs(a)<Number.MAX_VALUE?a:a*(1/0)}function Pn(a,e,t,n,o=1/0,r){n=Math.max(1e-4,n);const s=2/n,i=s*r,c=1/(1+i+.48*i*i+.235*i*i*i);let h=a-e;const p=e,f=o*n;h=$e(h,-f,f),e=a-h;const m=(t.value+s*h)*r;t.value=(t.value-s*m)*c;let d=e+(h+m)*c;return p-a>0==d>p&&(d=p,t.value=(d-p)/r),d}function ls(a,e,t,n,o=1/0,r,s){n=Math.max(1e-4,n);const i=2/n,c=i*r,h=1/(1+c+.48*c*c+.235*c*c*c);let p=e.x,f=e.y,m=e.z,d=a.x-p,g=a.y-f,y=a.z-m;const v=p,_=f,A=m,b=o*n,C=b*b,L=d*d+g*g+y*y;if(L>C){const X=Math.sqrt(L);d=d/X*b,g=g/X*b,y=y/X*b}p=a.x-d,f=a.y-g,m=a.z-y;const M=(t.x+i*d)*r,P=(t.y+i*g)*r,w=(t.z+i*y)*r;t.x=(t.x-i*M)*h,t.y=(t.y-i*P)*h,t.z=(t.z-i*w)*h,s.x=p+(d+M)*h,s.y=f+(g+P)*h,s.z=m+(y+w)*h;const S=v-a.x,x=_-a.y,I=A-a.z,D=s.x-v,z=s.y-_,G=s.z-A;return S*D+x*z+I*G>0&&(s.x=v,s.y=_,s.z=A,t.x=(s.x-v)/r,t.y=(s.y-_)/r,t.z=(s.z-A)/r),s}function go(a,e){e.set(0,0),a.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=a.length,e.y/=a.length}function yo(a,e){return vt(a)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class du{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const o=this._listeners[e];if(o!==void 0){const r=o.indexOf(t);r!==-1&&o.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const o=n.slice(0);for(let r=0,s=o.length;r<s;r++)o[r].call(this,e)}}}var _o;const pu="2.9.0",Cn=1/8,mu=/Mac/.test((_o=globalThis==null?void 0:globalThis.navigator)===null||_o===void 0?void 0:_o.platform);let pe,cs,Tn,vo,je,ye,be,Vt,tn,ot,rt,Tt,us,hs,Qe,nn,Gt,fs,xo,ds,wo,bo,In;class Ve extends du{static install(e){pe=e.THREE,cs=Object.freeze(new pe.Vector3(0,0,0)),Tn=Object.freeze(new pe.Vector3(0,1,0)),vo=Object.freeze(new pe.Vector3(0,0,1)),je=new pe.Vector2,ye=new pe.Vector3,be=new pe.Vector3,Vt=new pe.Vector3,tn=new pe.Vector3,ot=new pe.Vector3,rt=new pe.Vector3,Tt=new pe.Vector3,us=new pe.Vector3,hs=new pe.Vector3,Qe=new pe.Spherical,nn=new pe.Spherical,Gt=new pe.Box3,fs=new pe.Box3,xo=new pe.Sphere,ds=new pe.Quaternion,wo=new pe.Quaternion,bo=new pe.Matrix4,In=new pe.Raycaster}static get ACTION(){return $}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=$.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ft.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new pe.Vector3,this._focalOffsetVelocity=new pe.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,A,b)=>{let C,L;if(Ct(this._camera)){const M=ye.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*Ht,w=M.length()*Math.tan(P*.5);C=this.truckSpeed*_*w/this._elementRect.height,L=this.truckSpeed*A*w/this._elementRect.height}else if(vt(this._camera)){const M=this._camera;C=_*(M.right-M.left)/M.zoom/this._elementRect.width,L=A*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-L,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+L,this._focalOffsetEnd.z,!0):this.truck(C,L,!0)},this._rotateInternal=(_,A)=>{const b=zt*this.azimuthRotateSpeed*_/this._elementRect.height,C=zt*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(b,C,!0)},this._dollyInternal=(_,A,b)=>{const C=Math.pow(.95,-_*this.dollySpeed),L=this._sphericalEnd.radius,M=this._sphericalEnd.radius*C,P=$e(M,this.minDistance,this.maxDistance),w=P-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(w,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:P)-L,this._dollyControlCoord.set(A,b)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,A,b)=>{const C=Math.pow(.95,_*this.dollySpeed),L=this._zoom,M=this._zoom*C;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-L,this._dollyControlCoord.set(A,b))},typeof pe>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new pe.Quaternion().setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=$.NONE,this._target=new pe.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new pe.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new pe.Spherical().setFromVector3(ye.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new pe.Vector3,new pe.Vector3,new pe.Vector3,new pe.Vector3],this._updateNearPlaneCorners(),this._boundary=new pe.Box3(new pe.Vector3(-1/0,-1/0,-1/0),new pe.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new pe.Vector2,this.mouseButtons={left:$.ROTATE,middle:$.DOLLY,right:$.TRUCK,wheel:Ct(this._camera)?$.DOLLY:vt(this._camera)?$.ZOOM:$.NONE},this.touches={one:$.TOUCH_ROTATE,two:Ct(this._camera)?$.TOUCH_DOLLY_TRUCK:vt(this._camera)?$.TOUCH_ZOOM_TRUCK:$.NONE,three:$.TOUCH_TRUCK};const n=new pe.Vector2,o=new pe.Vector2,r=new pe.Vector2,s=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),L=_.clientX/C.width,M=_.clientY/C.height;if(L<this._interactiveArea.left||L>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const A=_.pointerType!=="mouse"?null:(_.buttons&Oe.LEFT)===Oe.LEFT?Oe.LEFT:(_.buttons&Oe.MIDDLE)===Oe.MIDDLE?Oe.MIDDLE:(_.buttons&Oe.RIGHT)===Oe.RIGHT?Oe.RIGHT:null;if(A!==null){const C=this._findPointerByMouseButton(A);C&&this._disposePointer(C)}if((_.buttons&Oe.LEFT)===Oe.LEFT&&this._lockedPointer)return;const b={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,m(_)},i=_=>{_.cancelable&&_.preventDefault();const A=_.pointerId,b=this._lockedPointer||this._findPointerById(A);if(b){if(b.clientX=_.clientX,b.clientY=_.clientY,b.deltaX=_.movementX,b.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&Oe.LEFT)===Oe.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);d()}},c=_=>{const A=this._findPointerById(_.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=$.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=$.NONE;g()}};let h=-1;const p=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===$.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),P=_.clientX/M.width,w=_.clientY/M.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===$.ROTATE||this.mouseButtons.wheel===$.TRUCK){const M=performance.now();h-M<1e3&&this._getClientRect(this._elementRect),h=M}const A=mu?-1:-3,b=_.deltaMode===1?_.deltaY/A:_.deltaY/(A*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case $.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case $.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case $.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case $.DOLLY:{this._dollyInternal(-b,C,L),this._isUserControllingDolly=!0;break}case $.ZOOM:{this._zoomInternal(-b,C,L),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ve.ACTION.NONE){const A=_ instanceof PointerEvent?_.pointerId:0,b=this._findPointerById(A);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}_.preventDefault()}},m=_=>{if(!this._enabled)return;if(go(this._activePointers,je),this._getClientRect(this._elementRect),n.copy(je),o.copy(je),this._activePointers.length>=2){const b=je.x-this._activePointers[1].clientX,C=je.y-this._activePointers[1].clientY,L=Math.sqrt(b*b+C*C);r.set(0,L);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,P=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;o.set(M,P)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&Oe.LEFT)===Oe.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&$.DOLLY)===$.DOLLY||(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&$.ZOOM)===$.ZOOM||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,go(this._activePointers,je);const A=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=A?-A.deltaX:o.x-je.x,C=A?-A.deltaY:o.y-je.y;if(o.copy(je),((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,C),this._isUserControllingRotate=!0),(this._state&$.DOLLY)===$.DOLLY||(this._state&$.ZOOM)===$.ZOOM){const L=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,P=this.dollyDragInverted?-1:1;(this._state&$.DOLLY)===$.DOLLY?(this._dollyInternal(P*C*Cn,L,M),this._isUserControllingDolly=!0):(this._zoomInternal(P*C*Cn,L,M),this._isUserControllingZoom=!0)}if((this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE){const L=je.x-this._activePointers[1].clientX,M=je.y-this._activePointers[1].clientY,P=Math.sqrt(L*L+M*M),w=r.y-P;r.set(0,P);const S=this.dollyToCursor?(o.x-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(o.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET?(this._dollyInternal(w*Cn,S,x),this._isUserControllingDolly=!0):(this._zoomInternal(w*Cn,S,x),this._isUserControllingZoom=!0)}((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,C,!1),this._isUserControllingTruck=!0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{go(this._activePointers,je),o.copy(je),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",y),this._domElement.ownerDocument.addEventListener("pointerlockerror",v),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),m())},this.unlockPointer=()=>{var _,A,b;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(A=this._domElement)===null||A===void 0||A.ownerDocument.removeEventListener("pointerlockchange",y),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockerror",v),this.cancel()};const y=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},v=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",s),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",s),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",y),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))},this.cancel=()=>{this._state!==$.NONE&&(this._state=$.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=$e(e.width,0,1),this._interactiveArea.height=$e(e.height,0,1),this._interactiveArea.x=$e(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=$e(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const o=$e(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=$e(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=o,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const s=!n||Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(s)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0,this._dollyToNoClamp($e(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const s=this._collisionTest(),i=Se(s,this._spherical.radius);if(!(n>e)&&i)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,s)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(tn).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=$e(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Se(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),ot.setFromMatrixColumn(this._camera.matrix,0),rt.setFromMatrixColumn(this._camera.matrix,1),ot.multiplyScalar(e),rt.multiplyScalar(-t);const o=ye.copy(ot).add(rt),r=be.copy(this._targetEnd).add(o);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ye.setFromMatrixColumn(this._camera.matrix,0),ye.crossVectors(this._camera.up,ye),ye.multiplyScalar(e);const n=be.copy(this._targetEnd).add(ye);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ye.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ye.x,this._targetEnd.y+ye.y,this._targetEnd.z+ye.z,t)}moveTo(e,t,n,o=!1){this._isUserControllingTruck=!1;const r=ye.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,o||this._target.copy(this._targetEnd);const s=!o||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}lookInDirectionOf(e,t,n,o=!1){const i=ye.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,o)}fitToBox(e,t,{cover:n=!1,paddingLeft:o=0,paddingRight:r=0,paddingBottom:s=0,paddingTop:i=0}={}){const c=[],h=e.isBox3?Gt.copy(e):Gt.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=as(this._sphericalEnd.theta,ss),f=as(this._sphericalEnd.phi,ss);c.push(this.rotateTo(p,f,t));const m=ye.setFromSpherical(this._sphericalEnd).normalize(),d=ds.setFromUnitVectors(m,vo),g=Se(Math.abs(m.y),1);g&&d.multiply(wo.setFromAxisAngle(Tn,p)),d.multiply(this._yAxisUpSpaceInverse);const y=fs.makeEmpty();be.copy(h.min).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setX(h.max.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setY(h.max.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setZ(h.min.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setZ(h.max.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setY(h.min.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setX(h.min.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).applyQuaternion(d),y.expandByPoint(be),y.min.x-=o,y.min.y-=s,y.max.x+=r,y.max.y+=i,d.setFromUnitVectors(vo,m),g&&d.premultiply(wo.invert()),d.premultiply(this._yAxisUpSpace);const v=y.getSize(ye),_=y.getCenter(be).applyQuaternion(d);if(Ct(this._camera)){const A=this.getDistanceToFitBox(v.x,v.y,v.z,n);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.dollyTo(A,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(vt(this._camera)){const A=this._camera,b=A.right-A.left,C=A.top-A.bottom,L=n?Math.max(b/v.x,C/v.y):Math.min(b/v.x,C/v.y);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.zoomTo(L,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],r="isObject3D"in e?Ve.createBoundingSphere(e,xo):xo.copy(e);if(n.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Ct(this._camera)){const s=this.getDistanceToFitSphere(r.radius);n.push(this.dollyTo(s,t))}else if(vt(this._camera)){const s=this._camera.right-this._camera.left,i=this._camera.top-this._camera.bottom,c=2*r.radius,h=Math.min(s/c,i/c);n.push(this.zoomTo(h,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,o,r,s,i=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const c=be.set(o,r,s),h=ye.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(h.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,i||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!i||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,n,o,r,s,i,c,h,p,f,m,d,g=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const y=ye.set(o,r,s),v=be.set(e,t,n);Qe.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const _=Vt.set(p,f,m),A=be.set(i,c,h);nn.setFromVector3(A.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(_,d));const b=nn.theta-Qe.theta,C=nn.phi-Qe.phi,L=nn.radius-Qe.radius;this._sphericalEnd.set(Qe.radius+L*d,Qe.phi+C*d,Qe.theta+b*d),this.normalizeRotations(),this._needsUpdate=!0,g||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!g||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,n,o=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,o)}setTarget(e,t,n,o=!1){const r=this.getPosition(ye),s=this.setLookAt(r.x,r.y,r.z,e,t,n,o);return this._sphericalEnd.phi=$e(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),s}setFocalOffset(e,t,n,o=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,o||this._focalOffset.copy(this._focalOffsetEnd);const r=!o||Se(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Se(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Se(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),ot.setFromMatrixColumn(this._camera.matrixWorldInverse,0),rt.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Tt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const o=ye.set(e,t,n),r=o.distanceTo(this._camera.position),s=o.sub(this._camera.position);ot.multiplyScalar(s.x),rt.multiplyScalar(s.y),Tt.multiplyScalar(s.z),ye.copy(ot).add(rt).add(Tt),ye.z=ye.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ye.x,ye.y,-ye.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,o){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new pe.Vector4,typeof e=="number"?this._viewport.set(e,t,n,o):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,o=!1){if(yo(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,s=this._camera.getEffectiveFOV()*Ht,i=this._camera.aspect;return((o?r>i:r<i)?t:e/i)*.5/Math.tan(s*.5)+n*.5}getDistanceToFitSphere(e){if(yo(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Ht,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,o=1<this._camera.aspect?t:n;return e/Math.sin(o*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new pe.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%zt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zt),this._spherical.theta+=zt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zt)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Se(this._camera.up.x,this._cameraUp0.x)||!Se(this._camera.up.y,this._cameraUp0.y)||!Se(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=be.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,o=this._sphericalEnd.radius-this._spherical.radius,r=us.subVectors(this._targetEnd,this._target),s=hs.subVectors(this._focalOffsetEnd,this._focalOffset),i=this._zoomEnd-this._zoom;if(Te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Pn(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Pn(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(o))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Pn(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(Te(r.x)&&Te(r.y)&&Te(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;ls(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Te(s.x)&&Te(s.y)&&Te(s.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;ls(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Te(i))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Pn(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(Ct(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,m=this._camera,d=this._getCameraDirection(tn),g=ye.copy(d).cross(m.up).normalize();g.lengthSq()===0&&(g.x=1);const y=be.crossVectors(g,d),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*Ht*.5),A=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Vt.copy(this._targetEnd).add(g.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),C=ye.copy(this._targetEnd).lerp(b,A),L=this._lastDollyDirection===Ft.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Ft.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||M)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const w=be.copy(d).multiplyScalar(-f);C.add(w)}this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedDolly-=f,Te(this._changedDolly)&&(this._changedDolly=0)}else if(vt(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,m=this._camera,d=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),g=be.set(0,0,-1).applyQuaternion(m.quaternion),y=Vt.copy(d).add(g.multiplyScalar(-d.dot(m.up))),_=-(this._zoom-f-this._zoom)/this._zoom,A=this._getCameraDirection(tn),b=this._targetEnd.dot(A),C=ye.copy(this._targetEnd).lerp(y,_),L=C.dot(A),M=A.multiplyScalar(L-b);C.sub(M),this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedZoom-=f,Te(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Te(this._focalOffset.x)||!Te(this._focalOffset.y)||!Te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),ot.setFromMatrixColumn(this._camera.matrix,0),rt.setFromMatrixColumn(this._camera.matrix,1),Tt.setFromMatrixColumn(this._camera.matrix,2),ot.multiplyScalar(this._focalOffset.x),rt.multiplyScalar(-this._focalOffset.y),Tt.multiplyScalar(this._focalOffset.z),ye.copy(ot).add(rt).add(Tt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),Te(t,this.restThreshold)&&Te(n,this.restThreshold)&&Te(o,this.restThreshold)&&Te(r.x,this.restThreshold)&&Te(r.y,this.restThreshold)&&Te(r.z,this.restThreshold)&&Te(s.x,this.restThreshold)&&Te(s.y,this.restThreshold)&&Te(s.z,this.restThreshold)&&Te(i,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$t(this.maxDistance),minZoom:this.minZoom,maxZoom:$t(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:$t(this.maxPolarAngle),minAzimuthAngle:$t(this.minAzimuthAngle),maxAzimuthAngle:$t(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:ye.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=en(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=en(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=en(n.maxPolarAngle),this.minAzimuthAngle=en(n.minAzimuthAngle),this.maxAzimuthAngle=en(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Qe.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Qe.theta,Qe.phi,t),this.dollyTo(Qe.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",pu),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const o=t.lengthSq();if(o===0)return e;const r=be.copy(t).add(e),i=this._boundary.clampPoint(r,Vt).sub(r),c=i.lengthSq();if(c===0)return e.add(t);if(c===o)return e;if(n===0)return e.add(t).add(i);{const h=1+n*c/t.dot(i);return e.add(be.copy(t).multiplyScalar(h)).add(i.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ct(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Ht,o=Math.tan(n*.5)*t,r=o*e.aspect;this._nearPlaneCorners[0].set(-r,-o,0),this._nearPlaneCorners[1].set(r,-o,0),this._nearPlaneCorners[2].set(r,o,0),this._nearPlaneCorners[3].set(-r,o,0)}else if(vt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,o=e.right*t,r=e.top*t,s=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(o,r,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(n,s,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||yo(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(tn);bo.lookAt(cs,n,this._camera.up);for(let o=0;o<4;o++){const r=be.copy(this._nearPlaneCorners[o]);r.applyMatrix4(bo);const s=Vt.addVectors(this._target,r);In.set(s,n),In.far=this._spherical.radius+1;const i=In.intersectObjects(this.colliderMeshes);i.length!==0&&i[0].distance<e&&(e=i[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new pe.Sphere){const n=t,o=n.center;Gt.makeEmpty(),e.traverseVisible(s=>{s.isMesh&&Gt.expandByObject(s)}),Gt.getCenter(o);let r=0;return e.traverseVisible(s=>{if(!s.isMesh)return;const i=s,c=i.geometry.clone();c.applyMatrix4(i.matrixWorld);const p=c.attributes.position;for(let f=0,m=p.count;f<m;f++)ye.fromBufferAttribute(p,f),r=Math.max(r,o.distanceToSquared(ye))}),n.radius=Math.sqrt(r),n}}const ps=a=>!!(a&&a.isPerspectiveCamera),ms=a=>!!(a&&a.isOrthographicCamera),gu=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","distance","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args","mouse-buttons","touches"],gs=(a,e)=>({left:Ve.ACTION.ROTATE,middle:Ve.ACTION.DOLLY,right:Ve.ACTION.TRUCK,wheel:ps(a)?Ve.ACTION.DOLLY:ms(a)?Ve.ACTION.ZOOM:Ve.ACTION.NONE,...e}),ys=(a,e)=>({one:Ve.ACTION.TOUCH_ROTATE,two:ps(a)?Ve.ACTION.TOUCH_DOLLY_TRUCK:ms(a)?Ve.ACTION.TOUCH_ZOOM_TRUCK:Ve.ACTION.NONE,three:Ve.ACTION.TOUCH_TRUCK,...e}),yu=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},distance:{default:()=>H.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:Number.POSITIVE_INFINITY},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:Number.POSITIVE_INFINITY},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:Number.POSITIVE_INFINITY},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{default:()=>gs(H.useTresContext().camera.value)},touches:{default:()=>ys(H.useTresContext().camera.value)}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,minPolarAngle:s,maxPolarAngle:i,minAzimuthAngle:c,maxAzimuthAngle:h,distance:p,minDistance:f,maxDistance:m,infinityDolly:d,minZoom:g,maxZoom:y,smoothTime:v,draggingSmoothTime:_,maxSpeed:A,azimuthRotateSpeed:b,polarRotateSpeed:C,dollySpeed:L,dollyDragInverted:M,truckSpeed:P,dollyToCursor:w,dragToOffset:S,verticalDragToForward:x,boundaryFriction:I,restThreshold:D,colliderMeshes:z}=u.toRefs(n),G={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};Ve.install({THREE:G});const{camera:X,renderer:E,extend:te,controls:q,invalidate:oe}=H.useTresContext();u.watch(n,()=>{oe()});const ne=u.computed(()=>gs(n.camera||X.value,n.mouseButtons)),ce=u.computed(()=>ys(n.camera||X.value,n.touches)),le=u.shallowRef(null);te({CameraControls:Ve}),u.watchEffect(()=>{de(),le.value&&r.value?q.value=le.value:q.value=null});function de(){Ce(le.value,"update",()=>{o("change",le.value),oe()}),Ce(le.value,"controlend",()=>o("end",le.value)),Ce(le.value,"controlstart",()=>o("start",le.value))}const{onBeforeRender:k}=H.useLoop();return k(({delta:V,invalidate:U})=>{var B,R;(B=le.value)!=null&&B.enabled&&((R=le.value)==null||R.update(V),U())}),u.onUnmounted(()=>{le.value&&le.value.disconnect()}),e({instance:le}),(V,U)=>(V.camera||u.unref(X))&&(V.domElement||u.unref(E))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:le,"min-polar-angle":u.unref(s),"max-polar-angle":u.unref(i),"min-azimuth-angle":u.unref(c),"max-azimuth-angle":u.unref(h),distance:u.unref(p),"min-distance":u.unref(f),"max-distance":u.unref(m),"infinity-dolly":u.unref(d),"min-zoom":u.unref(g),"max-zoom":u.unref(y),"smooth-time":u.unref(v),"dragging-smooth-time":u.unref(_),"max-speed":u.unref(A),"azimuth-rotate-speed":u.unref(b),"polar-rotate-speed":u.unref(C),"dolly-speed":u.unref(L),"dolly-drag-inverted":u.unref(M),"truck-speed":u.unref(P),"dolly-to-cursor":u.unref(w),"drag-to-offset":u.unref(S),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(I),"rest-threshold":u.unref(D),"collider-meshes":u.unref(z),args:[V.camera||u.unref(X),V.domElement||u.unref(E).domElement],"mouse-buttons":ne.value,touches:ce.value},null,8,gu)):u.createCommentVNode("",!0)}}),_u=u.defineComponent({__name:"KeyboardControls",props:{makeDefault:{type:Boolean,default:!0},camera:{},domElement:{},moveSpeed:{default:.2},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{moveSpeed:r}=u.toRefs(n),{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.ref(0),f=u.ref(0),{KeyW:m,KeyA:d,KeyS:g,KeyD:y,Up:v,Down:_,Left:A,Right:b}=Ui();u.watchEffect(()=>{d.value||A.value?p.value=-r.value:y.value||b.value?p.value=r.value:p.value=0,m.value||v.value?f.value=r.value:g.value||_.value?f.value=-r.value:f.value=0}),e({instance:i});const C=I=>o("isLock",I),L=I=>o("change",I),M=new l.Vector3,P=new l.Vector3,w=new l.Quaternion,S=(I,D)=>{var X;if(!((X=s.value)!=null&&X.position)&&!M)return;const z=s.value,G=I*.001;z==null||z.translateZ(-D),w.set(P.x*G,P.y*G,P.z*G,1).normalize(),z==null||z.quaternion.multiply(w),(p.value||f.value)&&o("change",i.value)},{onBeforeRender:x}=H.useLoop();return x(({delta:I,invalidate:D})=>{var z;i.value instanceof _r&&((z=i.value)!=null&&z.isLocked)&&(S(I,f.value),i.value.moveRight(p.value),D())}),(I,D)=>(u.openBlock(),u.createBlock(u.unref(_s),{selector:I.selector,"make-default":I.makeDefault,camera:I.camera||u.unref(s),"dom-element":I.domElement||u.unref(c).domElement,onIsLock:C,onChange:L},null,8,["selector","make-default","camera","dom-element"]))}}),vu=["args","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","enable-zoom","zoom-speed","enable-rotate","rotate-speed"],xu=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,{autoRotate:o,autoRotateSpeed:r,enableDamping:s,dampingFactor:i,enablePan:c,keyPanSpeed:h,maxAzimuthAngle:p,minAzimuthAngle:f,maxPolarAngle:m,minPolarAngle:d,minDistance:g,maxDistance:y,minZoom:v,maxZoom:_,enableZoom:A,zoomSpeed:b,enableRotate:C,rotateSpeed:L}=u.toRefs(n),{camera:M,renderer:P,extend:w,controls:S,invalidate:x}=H.useTresContext();u.watch(n,()=>{x()});const I=u.shallowRef(null);w({MapControls:rl}),u.watch(S,z=>{z&&n.makeDefault?S.value=z:S.value=null});const{onBeforeRender:D}=H.useLoop();return D(({invalidate:z})=>{I.value&&(s.value||o.value)&&(I.value.update(),z())}),u.onUnmounted(()=>{I.value&&I.value.dispose()}),e({instance:I}),(z,G)=>(z.camera||u.unref(M))&&(z.domElement||u.unref(P))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:I,args:[z.camera||u.unref(M),z.domElement||u.unref(P).domElement],"auto-rotate":u.unref(o),"auto-rotate-speed":u.unref(r),"enable-damping":u.unref(s),"damping-factor":u.unref(i),"enable-pan":u.unref(c),"key-pan-speed":u.unref(h),keys:z.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(f),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(d),"min-distance":u.unref(g),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(_),"enable-zoom":u.unref(A),"zoom-speed":u.unref(b),"enable-rotate":u.unref(C),"rotate-speed":u.unref(L)},null,8,vu)):u.createCommentVNode("",!0)}}),wu=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],bu=u.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,autoRotate:s,autoRotateSpeed:i,enableDamping:c,dampingFactor:h,enablePan:p,keyPanSpeed:f,maxAzimuthAngle:m,minAzimuthAngle:d,maxPolarAngle:g,minPolarAngle:y,minDistance:v,maxDistance:_,minZoom:A,maxZoom:b,enableZoom:C,zoomSpeed:L,enableRotate:M,touches:P,rotateSpeed:w,target:S}=u.toRefs(n),{camera:x,renderer:I,extend:D,controls:z,invalidate:G}=H.useTresContext(),X=u.shallowRef(null);D({OrbitControls:wr}),u.watch(X,q=>{E(),q&&r.value?z.value=q:z.value=null});function E(){Ce(X.value,"change",()=>{o("change",X.value),G()}),Ce(X.value,"start",()=>o("start",X.value)),Ce(X.value,"end",()=>o("end",X.value))}const{onBeforeRender:te}=H.useLoop();return te(({invalidate:q})=>{X.value&&(c.value||s.value)&&(X.value.update(),s.value&&q())}),u.onUnmounted(()=>{X.value&&X.value.dispose()}),e({instance:X}),(q,oe)=>(q.camera||u.unref(x))&&(q.domElement||u.unref(I))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:X,target:u.unref(S),"auto-rotate":u.unref(s),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(c),"damping-factor":u.unref(h),"enable-pan":u.unref(p),"key-pan-speed":u.unref(f),keys:q.keys,"max-azimuth-angle":u.unref(m),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(g),"min-polar-angle":u.unref(y),"min-distance":u.unref(v),"max-distance":u.unref(_),"min-zoom":u.unref(A),"max-zoom":u.unref(b),touches:u.unref(P),"enable-zoom":u.unref(C),"zoom-speed":u.unref(L),"enable-rotate":u.unref(M),"rotate-speed":u.unref(w),args:[q.camera||u.unref(x),q.domElement||u.unref(I).domElement]},null,8,wu)):u.createCommentVNode("",!0)}}),Mu=["args"],_s=u.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{camera:r,renderer:s,extend:i,controls:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(null);let f;i({PointerLockControls:_r});const m=d=>{o("isLock",d)};return u.watch(p,d=>{d&&n.makeDefault?c.value=d:c.value=null,f=document.getElementById(n.selector||"")||s.value.domElement,Ce(f,"click",()=>{p.value&&(p.value.lock(),p.value.addEventListener("lock",()=>m(!0)),p.value.addEventListener("unlock",()=>m(!1)),h())})}),u.onUnmounted(()=>{const d=p.value;d&&(d.removeEventListener("lock",()=>m(!0)),d.removeEventListener("unlock",()=>m(!1)),d.dispose())}),e({instance:c}),(d,g)=>(d.camera||u.unref(r))&&(d.domElement||u.unref(s))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:p,args:[d.camera||u.unref(r),d.domElement||u.unref(s).domElement]},null,8,Mu)):u.createCommentVNode("",!0)}}),Su=u.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(a,{expose:e,emit:t}){const n=a,o=t,{logWarning:r}=H.useLogger();n.smoothScroll<0&&r("SmoothControl must be greater than zero"),n.pages<0&&r("Pages must be greater than zero");const{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(),f=document.createElement("div"),{y:m}=zi(),{x:d,y:g,isScrolling:y}=ki(f),{height:v,width:_}=Ko();let A=0;const b=u.ref(!1),C=u.ref(0),L=u.ref(0),M=u.ref(0),P=n.horizontal?"x":"y",w=u.watch(s,x=>{if(b.value){w();return}A=n.horizontal?(x==null?void 0:x.position.x)||0:(x==null?void 0:x.position.y)||0,b.value=!0},{immediate:!0});u.watch(y,x=>{i.value&&(i.value.enabled=!x)},{immediate:!0}),u.watch(m,x=>{!y.value&&!n.htmlScroll||(L.value=x/v.value/(M.value/v.value-1),C.value=-1*L.value,o("update:modelValue",L.value))}),u.watch(g,x=>{L.value=x/v.value/(M.value/v.value),C.value=-1*L.value,o("update:modelValue",L.value)}),u.watch(d,x=>{L.value=x/_.value/(M.value/_.value-1),C.value=+L.value,o("update:modelValue",L.value)}),u.watch(c,x=>{var D,z;const I=x==null?void 0:x.domElement;if(n.htmlScroll&&(x!=null&&x.domElement))I!=null&&I.style.width&&(I!=null&&I.style.position)&&(I!=null&&I.style.top)&&(I!=null&&I.style.left)&&(I.style.width="100%",I.style.position="fixed",I.style.zIndex=" -99999",I.style.top="0",I.style.left="0"),M.value=document.body.scrollHeight;else{const G=document.createElement("div"),X=document.createElement("div");f.style[n.horizontal?"overflowX":"overflowY"]="auto",f.style[n.horizontal?"overflowY":"overflowX"]="hidden",f.style.position="absolute",f.style.width="100%",f.style.height=" 100%",f.style.top="0",f.style.left="0",f.classList.add("scrollContainer"),G.style.position="sticky",G.style.top="0px",G.style.left="0px",G.style.width="100%",G.style.height="100%",G.style.overflow="hidden",f.appendChild(G),X.style.height=n.horizontal?"100%":`${v.value*n.pages}px`,X.style.width=n.horizontal?`${_.value*n.pages}px`:"100vw",X.style.pointerEvents="none",I.style.position="fixed",I.style.zIndex="0",I!=null&&I.style.width&&(I.style.width="100%"),f.appendChild(X),x!=null&&x.domElement.parentNode&&(x.domElement.parentNode.style.position="relative"),(z=(D=x==null?void 0:x.domElement)==null?void 0:D.parentNode)==null||z.appendChild(f),M.value=n.horizontal?_.value*n.pages:v.value*n.pages}},{immediate:!0});const{onBeforeRender:S}=H.useLoop();return S(({invalidate:x})=>{var I;if((I=s.value)!=null&&I.position){const D=(C.value*n.distance-s.value.position[P]+A)*n.smoothScroll;s.value.position[P]+=D,p.value.children.length>0&&(p.value.position[P]+=D),x()}}),e({instance:p}),(x,I)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:p},[u.renderSlot(x.$slots,"default")],512))}}),Au=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Pu=u.defineComponent({__name:"TransformControls",props:{object:{},camera:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(a,{expose:e,emit:t}){const n=a,o=t,{object:r,mode:s,enabled:i,axis:c,translationSnap:h,rotationSnap:p,scaleSnap:f,space:m,size:d,showX:g,showY:y,showZ:v}=u.toRefs(n),_=u.shallowRef(null),{controls:A,camera:b,renderer:C,extend:L,invalidate:M}=H.useTresContext();u.watch([r,s,i,c,h,p,f,m,d,g,y,v],()=>{M()}),L({TransformControls:Za});const P=()=>{M(),o("change")},w=z=>{A.value&&(A.value.enabled=!z.value),M(),o("dragging",z.value)},S=()=>{M(),o("mouseDown")},x=()=>{M(),o("mouseDown")},I=()=>{M(),o("objectChange")};function D(){Ce(_.value,"change",P),Ce(_.value,"dragging-changed",w),Ce(_.value,"mouseDown",S),Ce(_.value,"mouseUp",x),Ce(_.value,"objectChange",I)}return u.watch(_,z=>{z&&D()}),u.onUnmounted(()=>{_.value&&_.value.dispose()}),e({instance:_}),(z,G)=>{var X;return(z.camera||u.unref(b))&&u.unref(C)?(u.openBlock(),u.createElementBlock("TresTransformControls",{ref_key:"controlsRef",ref:_,key:(X=z.camera||u.unref(b))==null?void 0:X.uuid,object:u.unref(r),args:[z.camera||u.unref(b),u.unref(C).domElement],mode:u.unref(s),enabled:u.unref(i),axis:u.unref(c),"translation-snap":u.unref(h),"rotation-snap":u.unref(p),"scale-snap":u.unref(f),space:u.unref(m),size:u.unref(d),"show-x":u.unref(g),"show-y":u.unref(y),"show-z":u.unref(v),visible:!0},null,8,Au)):u.createCommentVNode("",!0)}}}),Cu=["geometry","render-order"],Tu=u.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(a,{expose:e}){const t=a;class n extends Jt{load(b,C,L,M){const P=Array.isArray(b)?b[0]:b;super.load(P,C,L,M)}}const{src:o,skipStrokes:r,skipFills:s,fillMaterial:i,strokeMaterial:c,fillMeshProps:h,strokeMeshProps:p,depth:f}=u.toRefs(t),m=u.shallowRef(),d=u.shallowRef([]),g=u.shallowRef([]);e({instance:m}),u.watchEffect(async()=>y(o.value).then(A=>g.value=A.paths)),u.watch([s,r,i,c,g],_);async function y(A){const b=A.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${A}`):A;return H.useLoader(n,b)}u.onUnmounted(v);function v(){d.value.forEach(A=>A.geometry.dispose())}function _(){var M,P,w;v();const A=[],[b,C]=(()=>{const S={flat:!1,renderOrder:!1,offsetZ:!0},x={flat:0,renderOrder:0,offsetZ:.025},I=f.value;return typeof I=="number"?[!0,I]:[S[I],x[I]]})();let L=0;for(const S of g.value){const x=((M=S.userData)==null?void 0:M.style)??{},I=Object.assign({color:x.fill,opacity:x.fillOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.fillMaterial);if(!s.value&&x.fill!==void 0&&x.fill!=="none")for(const D of Jt.createShapes(S)){const z=new l.ShapeGeometry(D);z.scale(1,-1,1),C&&z.translate(0,0,L++*C),A.push({geometry:z,material:I,isStroke:!1})}if(!r.value&&x.stroke!==void 0&&x.stroke!=="none"){const D=Object.assign({color:(P=S.userData)==null?void 0:P.style.stroke,opacity:(w=S.userData)==null?void 0:w.style.strokeOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.strokeMaterial);for(const z of S.subPaths){const G=z.getPoints().map(E=>new l.Vector2(E.x,-E.y)),X=Jt.pointsToStroke(G,x||"none");C&&X.translate(0,0,L++*C),A.push({geometry:X,material:D,isStroke:!0})}}}d.value=A}return(A,b)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:m},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(d.value,({geometry:C,material:L,isStroke:M},P)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${P}`,ref_for:!0},M?u.unref(p):u.unref(h),{geometry:C,"render-order":u.unref(f)==="renderOrder"?P:0}),[u.createElementVNode("TresMeshBasicMaterial",u.mergeProps({ref_for:!0},L),null,16)],16,Cu))),128))],512))}});class Iu extends l.Loader{constructor(t){super(t);ue(this,"fbxLoader");this.fbxLoader=new Jl(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.fbxLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.fbxLoader.loadAsync(n)}}const Ou=Iu;async function vs(a){return await H.useLoader(Ou,a)}const Lu=["object"],Du=u.defineComponent({__name:"component",props:{path:{},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const s=([t,n]=u.withAsyncContext(()=>vs(o.path)),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Lu))}});class ku extends l.Loader{constructor(t){super(t);ue(this,"gltfLoader");this.gltfLoader=new il(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.gltfLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.gltfLoader.loadAsync(n)}setDRACOLoader(t){return this.gltfLoader.setDRACOLoader(t)}}const Bu=ku;let xt=null;function Uu(a,e){return t=>{e&&e(t),a.draco&&(xt||(xt=new mc),xt.setDecoderPath(a.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader&&t.setDRACOLoader(xt))}}async function xs(a,e={draco:!1},t){const n=await H.useLoader(Bu,a,Uu(e,t));return xt==null||xt.dispose(),xt=null,n}const Nu=["object"],Fu=u.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const{scene:s}=([t,n]=u.withAsyncContext(()=>xs(o.path,{draco:o.draco,decoderPath:o.decoderPath})),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Nu))}}),ws="[TresJS - Cientos ▲ ■ ♥] ";function zu(a,e){console.error(`${ws} ${a}`,e||"")}function Vu(a){console.warn(`${ws} ${a}`)}function Gu(a,e){}function bs(){return{logError:zu,logWarning:Vu,logMessage:Gu}}let Mo=0;function Ru(){const a=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:n}=bs();return new Promise(o=>{l.DefaultLoadingManager.onStart=()=>{a.value=!1},l.DefaultLoadingManager.onLoad=()=>{a.value=!0},l.DefaultLoadingManager.onProgress=(r,s,i)=>{s===i&&(Mo=i,a.value=!0,t.value.push(r)),e.value=Math.round((s-Mo)/(i-Mo)*100||100)},l.DefaultLoadingManager.onError=r=>{n("Error loading assets",new Error(r)),a.value=!0},o({items:t,hasFinishLoading:a,progress:e})})}async function ju(a,e){const{logError:t}=bs();if(!a)return t("Error no path provided");const{unsuspend:n,start:o,crossOrigin:r,muted:s,loop:i,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((p,f)=>{const m=Object.assign(document.createElement("video"),{src:typeof a=="string"&&a||void 0,crossOrigin:r,loop:i,muted:s,autoplay:!0,...c}),d=new l.VideoTexture(m);return m.addEventListener(n,()=>p(d)),m.addEventListener("error",()=>f(new Error("Error loading video"))),d})}try{const p=await h();return o&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}function on(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function On(a){throw new Error('Could not dynamically require "'+a+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var So={exports:{}},Ms;function Wu(){return Ms||(Ms=1,function(a,e){(function(t){a.exports=t()})(function(){return function t(n,o,r){function s(h,p){if(!o[h]){if(!n[h]){var f=typeof On=="function"&&On;if(!p&&f)return f(h,!0);if(i)return i(h,!0);throw new Error("Cannot find module '"+h+"'")}p=o[h]={exports:{}},n[h][0].call(p.exports,function(m){var d=n[h][1][m];return s(d||m)},p,p.exports,t,n,o,r)}return o[h].exports}for(var i=typeof On=="function"&&On,c=0;c<r.length;c++)s(r[c]);return s}({1:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("crypto");function y(M,P){P=A(M,P);var w;return(w=P.algorithm!=="passthrough"?g.createHash(P.algorithm):new L).write===void 0&&(w.write=w.update,w.end=w.update),C(P,w).dispatch(M),w.update||w.end(""),w.digest?w.digest(P.encoding==="buffer"?void 0:P.encoding):(M=w.read(),P.encoding!=="buffer"?M.toString(P.encoding):M)}(o=n.exports=y).sha1=function(M){return y(M)},o.keys=function(M){return y(M,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},o.MD5=function(M){return y(M,{algorithm:"md5",encoding:"hex"})},o.keysMD5=function(M){return y(M,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var v=g.getHashes?g.getHashes().slice():["sha1","md5"],_=(v.push("passthrough"),["buffer","hex","binary","base64"]);function A(M,P){var w={};if(w.algorithm=(P=P||{}).algorithm||"sha1",w.encoding=P.encoding||"hex",w.excludeValues=!!P.excludeValues,w.algorithm=w.algorithm.toLowerCase(),w.encoding=w.encoding.toLowerCase(),w.ignoreUnknown=P.ignoreUnknown===!0,w.respectType=P.respectType!==!1,w.respectFunctionNames=P.respectFunctionNames!==!1,w.respectFunctionProperties=P.respectFunctionProperties!==!1,w.unorderedArrays=P.unorderedArrays===!0,w.unorderedSets=P.unorderedSets!==!1,w.unorderedObjects=P.unorderedObjects!==!1,w.replacer=P.replacer||void 0,w.excludeKeys=P.excludeKeys||void 0,M===void 0)throw new Error("Object argument required.");for(var S=0;S<v.length;++S)v[S].toLowerCase()===w.algorithm.toLowerCase()&&(w.algorithm=v[S]);if(v.indexOf(w.algorithm)===-1)throw new Error('Algorithm "'+w.algorithm+'" not supported. supported values: '+v.join(", "));if(_.indexOf(w.encoding)===-1&&w.algorithm!=="passthrough")throw new Error('Encoding "'+w.encoding+'" not supported. supported values: '+_.join(", "));return w}function b(M){if(typeof M=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(M))!=null}function C(M,P,w){w=w||[];function S(x){return P.update?P.update(x,"utf8"):P.write(x,"utf8")}return{dispatch:function(x){return this["_"+((x=M.replacer?M.replacer(x):x)===null?"null":typeof x)](x)},_object:function(x){var I,D=Object.prototype.toString.call(x),z=/\[object (.*)\]/i.exec(D);if(z=(z=z?z[1]:"unknown:["+D+"]").toLowerCase(),0<=(D=w.indexOf(x)))return this.dispatch("[CIRCULAR:"+D+"]");if(w.push(x),i!==void 0&&i.isBuffer&&i.isBuffer(x))return S("buffer:"),S(x);if(z==="object"||z==="function"||z==="asyncfunction")return D=Object.keys(x),M.unorderedObjects&&(D=D.sort()),M.respectType===!1||b(x)||D.splice(0,0,"prototype","__proto__","constructor"),M.excludeKeys&&(D=D.filter(function(G){return!M.excludeKeys(G)})),S("object:"+D.length+":"),I=this,D.forEach(function(G){I.dispatch(G),S(":"),M.excludeValues||I.dispatch(x[G]),S(",")});if(!this["_"+z]){if(M.ignoreUnknown)return S("["+z+"]");throw new Error('Unknown object type "'+z+'"')}this["_"+z](x)},_array:function(x,G){G=G!==void 0?G:M.unorderedArrays!==!1;var D=this;if(S("array:"+x.length+":"),!G||x.length<=1)return x.forEach(function(X){return D.dispatch(X)});var z=[],G=x.map(function(X){var E=new L,te=w.slice();return C(M,E,te).dispatch(X),z=z.concat(te.slice(w.length)),E.read().toString()});return w=w.concat(z),G.sort(),this._array(G,!1)},_date:function(x){return S("date:"+x.toJSON())},_symbol:function(x){return S("symbol:"+x.toString())},_error:function(x){return S("error:"+x.toString())},_boolean:function(x){return S("bool:"+x.toString())},_string:function(x){S("string:"+x.length+":"),S(x.toString())},_function:function(x){S("fn:"),b(x)?this.dispatch("[native]"):this.dispatch(x.toString()),M.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(x.name)),M.respectFunctionProperties&&this._object(x)},_number:function(x){return S("number:"+x.toString())},_xml:function(x){return S("xml:"+x.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(x){return S("regex:"+x.toString())},_uint8array:function(x){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint8clampedarray:function(x){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(x))},_int8array:function(x){return S("int8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint16array:function(x){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(x))},_int16array:function(x){return S("int16array:"),this.dispatch(Array.prototype.slice.call(x))},_uint32array:function(x){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(x))},_int32array:function(x){return S("int32array:"),this.dispatch(Array.prototype.slice.call(x))},_float32array:function(x){return S("float32array:"),this.dispatch(Array.prototype.slice.call(x))},_float64array:function(x){return S("float64array:"),this.dispatch(Array.prototype.slice.call(x))},_arraybuffer:function(x){return S("arraybuffer:"),this.dispatch(new Uint8Array(x))},_url:function(x){return S("url:"+x.toString())},_map:function(x){return S("map:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_set:function(x){return S("set:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_file:function(x){return S("file:"),this.dispatch([x.name,x.size,x.type,x.lastModfied])},_blob:function(){if(M.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
1016
|
+
*/const Oe={LEFT:1,RIGHT:2,MIDDLE:4},$=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ft={NONE:0,IN:1,OUT:-1};function Ct(a){return a.isPerspectiveCamera}function vt(a){return a.isOrthographicCamera}const zt=Math.PI*2,ss=Math.PI/2,is=1e-5,Ht=Math.PI/180;function $e(a,e,t){return Math.max(e,Math.min(t,a))}function Te(a,e=is){return Math.abs(a)<e}function Se(a,e,t=is){return Te(a-e,t)}function as(a,e){return Math.round(a/e)*e}function $t(a){return isFinite(a)?a:a<0?-Number.MAX_VALUE:Number.MAX_VALUE}function en(a){return Math.abs(a)<Number.MAX_VALUE?a:a*(1/0)}function Pn(a,e,t,n,o=1/0,r){n=Math.max(1e-4,n);const s=2/n,i=s*r,c=1/(1+i+.48*i*i+.235*i*i*i);let h=a-e;const p=e,f=o*n;h=$e(h,-f,f),e=a-h;const m=(t.value+s*h)*r;t.value=(t.value-s*m)*c;let d=e+(h+m)*c;return p-a>0==d>p&&(d=p,t.value=(d-p)/r),d}function ls(a,e,t,n,o=1/0,r,s){n=Math.max(1e-4,n);const i=2/n,c=i*r,h=1/(1+c+.48*c*c+.235*c*c*c);let p=e.x,f=e.y,m=e.z,d=a.x-p,g=a.y-f,y=a.z-m;const v=p,_=f,A=m,b=o*n,C=b*b,L=d*d+g*g+y*y;if(L>C){const E=Math.sqrt(L);d=d/E*b,g=g/E*b,y=y/E*b}p=a.x-d,f=a.y-g,m=a.z-y;const M=(t.x+i*d)*r,P=(t.y+i*g)*r,w=(t.z+i*y)*r;t.x=(t.x-i*M)*h,t.y=(t.y-i*P)*h,t.z=(t.z-i*w)*h,s.x=p+(d+M)*h,s.y=f+(g+P)*h,s.z=m+(y+w)*h;const S=v-a.x,x=_-a.y,I=A-a.z,D=s.x-v,z=s.y-_,G=s.z-A;return S*D+x*z+I*G>0&&(s.x=v,s.y=_,s.z=A,t.x=(s.x-v)/r,t.y=(s.y-_)/r,t.z=(s.z-A)/r),s}function go(a,e){e.set(0,0),a.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=a.length,e.y/=a.length}function yo(a,e){return vt(a)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class du{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const o=this._listeners[e];if(o!==void 0){const r=o.indexOf(t);r!==-1&&o.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const o=n.slice(0);for(let r=0,s=o.length;r<s;r++)o[r].call(this,e)}}}var _o;const pu="2.9.0",Cn=1/8,mu=/Mac/.test((_o=globalThis==null?void 0:globalThis.navigator)===null||_o===void 0?void 0:_o.platform);let pe,cs,Tn,vo,je,ye,be,Vt,tn,ot,rt,Tt,us,hs,Qe,nn,Gt,fs,xo,ds,wo,bo,In;class Ve extends du{static install(e){pe=e.THREE,cs=Object.freeze(new pe.Vector3(0,0,0)),Tn=Object.freeze(new pe.Vector3(0,1,0)),vo=Object.freeze(new pe.Vector3(0,0,1)),je=new pe.Vector2,ye=new pe.Vector3,be=new pe.Vector3,Vt=new pe.Vector3,tn=new pe.Vector3,ot=new pe.Vector3,rt=new pe.Vector3,Tt=new pe.Vector3,us=new pe.Vector3,hs=new pe.Vector3,Qe=new pe.Spherical,nn=new pe.Spherical,Gt=new pe.Box3,fs=new pe.Box3,xo=new pe.Sphere,ds=new pe.Quaternion,wo=new pe.Quaternion,bo=new pe.Matrix4,In=new pe.Raycaster}static get ACTION(){return $}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=$.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ft.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new pe.Vector3,this._focalOffsetVelocity=new pe.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,A,b)=>{let C,L;if(Ct(this._camera)){const M=ye.copy(this._camera.position).sub(this._target),P=this._camera.getEffectiveFOV()*Ht,w=M.length()*Math.tan(P*.5);C=this.truckSpeed*_*w/this._elementRect.height,L=this.truckSpeed*A*w/this._elementRect.height}else if(vt(this._camera)){const M=this._camera;C=_*(M.right-M.left)/M.zoom/this._elementRect.width,L=A*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-L,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+L,this._focalOffsetEnd.z,!0):this.truck(C,L,!0)},this._rotateInternal=(_,A)=>{const b=zt*this.azimuthRotateSpeed*_/this._elementRect.height,C=zt*this.polarRotateSpeed*A/this._elementRect.height;this.rotate(b,C,!0)},this._dollyInternal=(_,A,b)=>{const C=Math.pow(.95,-_*this.dollySpeed),L=this._sphericalEnd.radius,M=this._sphericalEnd.radius*C,P=$e(M,this.minDistance,this.maxDistance),w=P-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(w,!0),this._dollyToNoClamp(P,!0)):this._dollyToNoClamp(P,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:P)-L,this._dollyControlCoord.set(A,b)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,A,b)=>{const C=Math.pow(.95,_*this.dollySpeed),L=this._zoom,M=this._zoom*C;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-L,this._dollyControlCoord.set(A,b))},typeof pe>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new pe.Quaternion().setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=$.NONE,this._target=new pe.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new pe.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new pe.Spherical().setFromVector3(ye.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new pe.Vector3,new pe.Vector3,new pe.Vector3,new pe.Vector3],this._updateNearPlaneCorners(),this._boundary=new pe.Box3(new pe.Vector3(-1/0,-1/0,-1/0),new pe.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new pe.Vector2,this.mouseButtons={left:$.ROTATE,middle:$.DOLLY,right:$.TRUCK,wheel:Ct(this._camera)?$.DOLLY:vt(this._camera)?$.ZOOM:$.NONE},this.touches={one:$.TOUCH_ROTATE,two:Ct(this._camera)?$.TOUCH_DOLLY_TRUCK:vt(this._camera)?$.TOUCH_ZOOM_TRUCK:$.NONE,three:$.TOUCH_TRUCK};const n=new pe.Vector2,o=new pe.Vector2,r=new pe.Vector2,s=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),L=_.clientX/C.width,M=_.clientY/C.height;if(L<this._interactiveArea.left||L>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const A=_.pointerType!=="mouse"?null:(_.buttons&Oe.LEFT)===Oe.LEFT?Oe.LEFT:(_.buttons&Oe.MIDDLE)===Oe.MIDDLE?Oe.MIDDLE:(_.buttons&Oe.RIGHT)===Oe.RIGHT?Oe.RIGHT:null;if(A!==null){const C=this._findPointerByMouseButton(A);C&&this._disposePointer(C)}if((_.buttons&Oe.LEFT)===Oe.LEFT&&this._lockedPointer)return;const b={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:A};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,m(_)},i=_=>{_.cancelable&&_.preventDefault();const A=_.pointerId,b=this._lockedPointer||this._findPointerById(A);if(b){if(b.clientX=_.clientX,b.clientY=_.clientY,b.deltaX=_.movementX,b.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&Oe.LEFT)===Oe.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);d()}},c=_=>{const A=this._findPointerById(_.pointerId);if(!(A&&A===this._lockedPointer)){if(A&&this._disposePointer(A),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=$.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=$.NONE;g()}};let h=-1;const p=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===$.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),P=_.clientX/M.width,w=_.clientY/M.height;if(P<this._interactiveArea.left||P>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===$.ROTATE||this.mouseButtons.wheel===$.TRUCK){const M=performance.now();h-M<1e3&&this._getClientRect(this._elementRect),h=M}const A=mu?-1:-3,b=_.deltaMode===1?_.deltaY/A:_.deltaY/(A*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case $.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case $.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case $.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case $.DOLLY:{this._dollyInternal(-b,C,L),this._isUserControllingDolly=!0;break}case $.ZOOM:{this._zoomInternal(-b,C,L),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ve.ACTION.NONE){const A=_ instanceof PointerEvent?_.pointerId:0,b=this._findPointerById(A);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}_.preventDefault()}},m=_=>{if(!this._enabled)return;if(go(this._activePointers,je),this._getClientRect(this._elementRect),n.copy(je),o.copy(je),this._activePointers.length>=2){const b=je.x-this._activePointers[1].clientX,C=je.y-this._activePointers[1].clientY,L=Math.sqrt(b*b+C*C);r.set(0,L);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,P=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;o.set(M,P)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&Oe.LEFT)===Oe.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&Oe.MIDDLE)===Oe.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&Oe.RIGHT)===Oe.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&$.DOLLY)===$.DOLLY||(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&$.ZOOM)===$.ZOOM||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,go(this._activePointers,je);const A=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=A?-A.deltaX:o.x-je.x,C=A?-A.deltaY:o.y-je.y;if(o.copy(je),((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,C),this._isUserControllingRotate=!0),(this._state&$.DOLLY)===$.DOLLY||(this._state&$.ZOOM)===$.ZOOM){const L=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,P=this.dollyDragInverted?-1:1;(this._state&$.DOLLY)===$.DOLLY?(this._dollyInternal(P*C*Cn,L,M),this._isUserControllingDolly=!0):(this._zoomInternal(P*C*Cn,L,M),this._isUserControllingZoom=!0)}if((this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE){const L=je.x-this._activePointers[1].clientX,M=je.y-this._activePointers[1].clientY,P=Math.sqrt(L*L+M*M),w=r.y-P;r.set(0,P);const S=this.dollyToCursor?(o.x-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(o.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET?(this._dollyInternal(w*Cn,S,x),this._isUserControllingDolly=!0):(this._zoomInternal(w*Cn,S,x),this._isUserControllingZoom=!0)}((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,C,!1),this._isUserControllingTruck=!0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{go(this._activePointers,je),o.copy(je),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",y),this._domElement.ownerDocument.addEventListener("pointerlockerror",v),this._domElement.ownerDocument.addEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),m())},this.unlockPointer=()=>{var _,A,b;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(_=this._domElement)===null||_===void 0||_.ownerDocument.exitPointerLock(),(A=this._domElement)===null||A===void 0||A.ownerDocument.removeEventListener("pointerlockchange",y),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockerror",v),this.cancel()};const y=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},v=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",s),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",p,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",s),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",p,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",i,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",y),this._domElement.ownerDocument.removeEventListener("pointerlockerror",v))},this.cancel=()=>{this._state!==$.NONE&&(this._state=$.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=$e(e.width,0,1),this._interactiveArea.height=$e(e.height,0,1),this._interactiveArea.x=$e(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=$e(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const o=$e(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=$e(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=o,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const s=!n||Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(s)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0,this._dollyToNoClamp($e(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const s=this._collisionTest(),i=Se(s,this._spherical.radius);if(!(n>e)&&i)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,s)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(tn).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=$e(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Se(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),ot.setFromMatrixColumn(this._camera.matrix,0),rt.setFromMatrixColumn(this._camera.matrix,1),ot.multiplyScalar(e),rt.multiplyScalar(-t);const o=ye.copy(ot).add(rt),r=be.copy(this._targetEnd).add(o);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ye.setFromMatrixColumn(this._camera.matrix,0),ye.crossVectors(this._camera.up,ye),ye.multiplyScalar(e);const n=be.copy(this._targetEnd).add(ye);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ye.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ye.x,this._targetEnd.y+ye.y,this._targetEnd.z+ye.z,t)}moveTo(e,t,n,o=!1){this._isUserControllingTruck=!1;const r=ye.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,o||this._target.copy(this._targetEnd);const s=!o||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}lookInDirectionOf(e,t,n,o=!1){const i=ye.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,o)}fitToBox(e,t,{cover:n=!1,paddingLeft:o=0,paddingRight:r=0,paddingBottom:s=0,paddingTop:i=0}={}){const c=[],h=e.isBox3?Gt.copy(e):Gt.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const p=as(this._sphericalEnd.theta,ss),f=as(this._sphericalEnd.phi,ss);c.push(this.rotateTo(p,f,t));const m=ye.setFromSpherical(this._sphericalEnd).normalize(),d=ds.setFromUnitVectors(m,vo),g=Se(Math.abs(m.y),1);g&&d.multiply(wo.setFromAxisAngle(Tn,p)),d.multiply(this._yAxisUpSpaceInverse);const y=fs.makeEmpty();be.copy(h.min).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setX(h.max.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setY(h.max.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setZ(h.min.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.min).setZ(h.max.z).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setY(h.min.y).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).setX(h.min.x).applyQuaternion(d),y.expandByPoint(be),be.copy(h.max).applyQuaternion(d),y.expandByPoint(be),y.min.x-=o,y.min.y-=s,y.max.x+=r,y.max.y+=i,d.setFromUnitVectors(vo,m),g&&d.premultiply(wo.invert()),d.premultiply(this._yAxisUpSpace);const v=y.getSize(ye),_=y.getCenter(be).applyQuaternion(d);if(Ct(this._camera)){const A=this.getDistanceToFitBox(v.x,v.y,v.z,n);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.dollyTo(A,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(vt(this._camera)){const A=this._camera,b=A.right-A.left,C=A.top-A.bottom,L=n?Math.max(b/v.x,C/v.y):Math.min(b/v.x,C/v.y);c.push(this.moveTo(_.x,_.y,_.z,t)),c.push(this.zoomTo(L,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],r="isObject3D"in e?Ve.createBoundingSphere(e,xo):xo.copy(e);if(n.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),Ct(this._camera)){const s=this.getDistanceToFitSphere(r.radius);n.push(this.dollyTo(s,t))}else if(vt(this._camera)){const s=this._camera.right-this._camera.left,i=this._camera.top-this._camera.bottom,c=2*r.radius,h=Math.min(s/c,i/c);n.push(this.zoomTo(h,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,o,r,s,i=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const c=be.set(o,r,s),h=ye.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(h.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,i||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const p=!i||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(p)}lerpLookAt(e,t,n,o,r,s,i,c,h,p,f,m,d,g=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const y=ye.set(o,r,s),v=be.set(e,t,n);Qe.setFromVector3(v.sub(y).applyQuaternion(this._yAxisUpSpace));const _=Vt.set(p,f,m),A=be.set(i,c,h);nn.setFromVector3(A.sub(_).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(y.lerp(_,d));const b=nn.theta-Qe.theta,C=nn.phi-Qe.phi,L=nn.radius-Qe.radius;this._sphericalEnd.set(Qe.radius+L*d,Qe.phi+C*d,Qe.theta+b*d),this.normalizeRotations(),this._needsUpdate=!0,g||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const M=!g||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(M)}setPosition(e,t,n,o=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,o)}setTarget(e,t,n,o=!1){const r=this.getPosition(ye),s=this.setLookAt(r.x,r.y,r.z,e,t,n,o);return this._sphericalEnd.phi=$e(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),s}setFocalOffset(e,t,n,o=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,o||this._focalOffset.copy(this._focalOffsetEnd);const r=!o||Se(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Se(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Se(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),ot.setFromMatrixColumn(this._camera.matrixWorldInverse,0),rt.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Tt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const o=ye.set(e,t,n),r=o.distanceTo(this._camera.position),s=o.sub(this._camera.position);ot.multiplyScalar(s.x),rt.multiplyScalar(s.y),Tt.multiplyScalar(s.z),ye.copy(ot).add(rt).add(Tt),ye.z=ye.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ye.x,ye.y,-ye.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,o){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new pe.Vector4,typeof e=="number"?this._viewport.set(e,t,n,o):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,o=!1){if(yo(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,s=this._camera.getEffectiveFOV()*Ht,i=this._camera.aspect;return((o?r>i:r<i)?t:e/i)*.5/Math.tan(s*.5)+n*.5}getDistanceToFitSphere(e){if(yo(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Ht,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,o=1<this._camera.aspect?t:n;return e/Math.sin(o*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new pe.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new pe.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%zt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zt),this._spherical.theta+=zt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zt)}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Se(this._camera.up.x,this._cameraUp0.x)||!Se(this._camera.up.y,this._cameraUp0.y)||!Se(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Tn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=be.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,o=this._sphericalEnd.radius-this._spherical.radius,r=us.subVectors(this._targetEnd,this._target),s=hs.subVectors(this._focalOffsetEnd,this._focalOffset),i=this._zoomEnd-this._zoom;if(Te(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Pn(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Pn(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(Te(o))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Pn(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(Te(r.x)&&Te(r.y)&&Te(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;ls(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Te(s.x)&&Te(s.y)&&Te(s.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;ls(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Te(i))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Pn(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(Ct(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,m=this._camera,d=this._getCameraDirection(tn),g=ye.copy(d).cross(m.up).normalize();g.lengthSq()===0&&(g.x=1);const y=be.crossVectors(g,d),v=this._sphericalEnd.radius*Math.tan(m.getEffectiveFOV()*Ht*.5),A=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Vt.copy(this._targetEnd).add(g.multiplyScalar(this._dollyControlCoord.x*v*m.aspect)).add(y.multiplyScalar(this._dollyControlCoord.y*v)),C=ye.copy(this._targetEnd).lerp(b,A),L=this._lastDollyDirection===Ft.IN&&this._spherical.radius<=this.minDistance,M=this._lastDollyDirection===Ft.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||M)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const w=be.copy(d).multiplyScalar(-f);C.add(w)}this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedDolly-=f,Te(this._changedDolly)&&(this._changedDolly=0)}else if(vt(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,m=this._camera,d=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(m.near+m.far)/(m.near-m.far)).unproject(m),g=be.set(0,0,-1).applyQuaternion(m.quaternion),y=Vt.copy(d).add(g.multiplyScalar(-d.dot(m.up))),_=-(this._zoom-f-this._zoom)/this._zoom,A=this._getCameraDirection(tn),b=this._targetEnd.dot(A),C=ye.copy(this._targetEnd).lerp(y,_),L=C.dot(A),M=A.multiplyScalar(L-b);C.sub(M),this._boundary.clampPoint(C,C);const P=be.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(P),this._changedZoom-=f,Te(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Te(this._focalOffset.x)||!Te(this._focalOffset.y)||!Te(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),ot.setFromMatrixColumn(this._camera.matrix,0),rt.setFromMatrixColumn(this._camera.matrix,1),Tt.setFromMatrixColumn(this._camera.matrix,2),ot.multiplyScalar(this._focalOffset.x),rt.multiplyScalar(-this._focalOffset.y),Tt.multiplyScalar(this._focalOffset.z),ye.copy(ot).add(rt).add(Tt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const p=this._needsUpdate;return p&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):p?(this.dispatchEvent({type:"update"}),Te(t,this.restThreshold)&&Te(n,this.restThreshold)&&Te(o,this.restThreshold)&&Te(r.x,this.restThreshold)&&Te(r.y,this.restThreshold)&&Te(r.z,this.restThreshold)&&Te(s.x,this.restThreshold)&&Te(s.y,this.restThreshold)&&Te(s.z,this.restThreshold)&&Te(i,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!p&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=p,this._needsUpdate=!1,p}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:$t(this.maxDistance),minZoom:this.minZoom,maxZoom:$t(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:$t(this.maxPolarAngle),minAzimuthAngle:$t(this.minAzimuthAngle),maxAzimuthAngle:$t(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:ye.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=en(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=en(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=en(n.maxPolarAngle),this.minAzimuthAngle=en(n.minAzimuthAngle),this.maxAzimuthAngle=en(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Qe.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Qe.theta,Qe.phi,t),this.dollyTo(Qe.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",pu),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const o=t.lengthSq();if(o===0)return e;const r=be.copy(t).add(e),i=this._boundary.clampPoint(r,Vt).sub(r),c=i.lengthSq();if(c===0)return e.add(t);if(c===o)return e;if(n===0)return e.add(t).add(i);{const h=1+n*c/t.dot(i);return e.add(be.copy(t).multiplyScalar(h)).add(i.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Ct(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Ht,o=Math.tan(n*.5)*t,r=o*e.aspect;this._nearPlaneCorners[0].set(-r,-o,0),this._nearPlaneCorners[1].set(r,-o,0),this._nearPlaneCorners[2].set(r,o,0),this._nearPlaneCorners[3].set(-r,o,0)}else if(vt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,o=e.right*t,r=e.top*t,s=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(o,r,0),this._nearPlaneCorners[2].set(o,s,0),this._nearPlaneCorners[3].set(n,s,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||yo(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(tn);bo.lookAt(cs,n,this._camera.up);for(let o=0;o<4;o++){const r=be.copy(this._nearPlaneCorners[o]);r.applyMatrix4(bo);const s=Vt.addVectors(this._target,r);In.set(s,n),In.far=this._spherical.radius+1;const i=In.intersectObjects(this.colliderMeshes);i.length!==0&&i[0].distance<e&&(e=i[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new pe.Sphere){const n=t,o=n.center;Gt.makeEmpty(),e.traverseVisible(s=>{s.isMesh&&Gt.expandByObject(s)}),Gt.getCenter(o);let r=0;return e.traverseVisible(s=>{if(!s.isMesh)return;const i=s,c=i.geometry.clone();c.applyMatrix4(i.matrixWorld);const p=c.attributes.position;for(let f=0,m=p.count;f<m;f++)ye.fromBufferAttribute(p,f),r=Math.max(r,o.distanceToSquared(ye))}),n.radius=Math.sqrt(r),n}}const ps=a=>!!(a&&a.isPerspectiveCamera),ms=a=>!!(a&&a.isOrthographicCamera),gu=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","distance","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args","mouse-buttons","touches"],gs=(a,e)=>({left:Ve.ACTION.ROTATE,middle:Ve.ACTION.DOLLY,right:Ve.ACTION.TRUCK,wheel:ps(a)?Ve.ACTION.DOLLY:ms(a)?Ve.ACTION.ZOOM:Ve.ACTION.NONE,...e}),ys=(a,e)=>({one:Ve.ACTION.TOUCH_ROTATE,two:ps(a)?Ve.ACTION.TOUCH_DOLLY_TRUCK:ms(a)?Ve.ACTION.TOUCH_ZOOM_TRUCK:Ve.ACTION.NONE,three:Ve.ACTION.TOUCH_TRUCK,...e}),yu=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},distance:{default:()=>H.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:Number.POSITIVE_INFINITY},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:Number.POSITIVE_INFINITY},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:Number.POSITIVE_INFINITY},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{default:()=>gs(H.useTresContext().camera.value)},touches:{default:()=>ys(H.useTresContext().camera.value)}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,minPolarAngle:s,maxPolarAngle:i,minAzimuthAngle:c,maxAzimuthAngle:h,distance:p,minDistance:f,maxDistance:m,infinityDolly:d,minZoom:g,maxZoom:y,smoothTime:v,draggingSmoothTime:_,maxSpeed:A,azimuthRotateSpeed:b,polarRotateSpeed:C,dollySpeed:L,dollyDragInverted:M,truckSpeed:P,dollyToCursor:w,dragToOffset:S,verticalDragToForward:x,boundaryFriction:I,restThreshold:D,colliderMeshes:z}=u.toRefs(n),G={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};Ve.install({THREE:G});const{camera:E,renderer:X,extend:oe,controls:q,invalidate:ee}=H.useTresContext();u.watch(n,()=>{ee()});const te=u.computed(()=>gs(n.camera||E.value,n.mouseButtons)),ce=u.computed(()=>ys(n.camera||E.value,n.touches)),le=u.shallowRef(null);oe({CameraControls:Ve}),u.watchEffect(()=>{de(),le.value&&r.value?q.value=le.value:q.value=null});function de(){Ce(le.value,"update",()=>{o("change",le.value),ee()}),Ce(le.value,"controlend",()=>o("end",le.value)),Ce(le.value,"controlstart",()=>o("start",le.value))}const{onBeforeRender:k}=H.useLoop();return k(({delta:V,invalidate:U})=>{var B,R;(B=le.value)!=null&&B.enabled&&((R=le.value)==null||R.update(V),U())}),u.onUnmounted(()=>{le.value&&le.value.disconnect()}),e({instance:le}),(V,U)=>(V.camera||u.unref(E))&&(V.domElement||u.unref(X))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:le,"min-polar-angle":u.unref(s),"max-polar-angle":u.unref(i),"min-azimuth-angle":u.unref(c),"max-azimuth-angle":u.unref(h),distance:u.unref(p),"min-distance":u.unref(f),"max-distance":u.unref(m),"infinity-dolly":u.unref(d),"min-zoom":u.unref(g),"max-zoom":u.unref(y),"smooth-time":u.unref(v),"dragging-smooth-time":u.unref(_),"max-speed":u.unref(A),"azimuth-rotate-speed":u.unref(b),"polar-rotate-speed":u.unref(C),"dolly-speed":u.unref(L),"dolly-drag-inverted":u.unref(M),"truck-speed":u.unref(P),"dolly-to-cursor":u.unref(w),"drag-to-offset":u.unref(S),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(I),"rest-threshold":u.unref(D),"collider-meshes":u.unref(z),args:[V.camera||u.unref(E),V.domElement||u.unref(X).domElement],"mouse-buttons":te.value,touches:ce.value},null,8,gu)):u.createCommentVNode("",!0)}}),_u=u.defineComponent({__name:"KeyboardControls",props:{makeDefault:{type:Boolean,default:!0},camera:{},domElement:{},moveSpeed:{default:.2},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{moveSpeed:r}=u.toRefs(n),{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.ref(0),f=u.ref(0),{KeyW:m,KeyA:d,KeyS:g,KeyD:y,Up:v,Down:_,Left:A,Right:b}=Ui();u.watchEffect(()=>{d.value||A.value?p.value=-r.value:y.value||b.value?p.value=r.value:p.value=0,m.value||v.value?f.value=r.value:g.value||_.value?f.value=-r.value:f.value=0}),e({instance:i});const C=I=>o("isLock",I),L=I=>o("change",I),M=new l.Vector3,P=new l.Vector3,w=new l.Quaternion,S=(I,D)=>{var E;if(!((E=s.value)!=null&&E.position)&&!M)return;const z=s.value,G=I*.001;z==null||z.translateZ(-D),w.set(P.x*G,P.y*G,P.z*G,1).normalize(),z==null||z.quaternion.multiply(w),(p.value||f.value)&&o("change",i.value)},{onBeforeRender:x}=H.useLoop();return x(({delta:I,invalidate:D})=>{var z;i.value instanceof _r&&((z=i.value)!=null&&z.isLocked)&&(S(I,f.value),i.value.moveRight(p.value),D())}),(I,D)=>(u.openBlock(),u.createBlock(u.unref(_s),{selector:I.selector,"make-default":I.makeDefault,camera:I.camera||u.unref(s),"dom-element":I.domElement||u.unref(c).domElement,onIsLock:C,onChange:L},null,8,["selector","make-default","camera","dom-element"]))}}),vu=["args","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","enable-zoom","zoom-speed","enable-rotate","rotate-speed"],xu=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,{autoRotate:o,autoRotateSpeed:r,enableDamping:s,dampingFactor:i,enablePan:c,keyPanSpeed:h,maxAzimuthAngle:p,minAzimuthAngle:f,maxPolarAngle:m,minPolarAngle:d,minDistance:g,maxDistance:y,minZoom:v,maxZoom:_,enableZoom:A,zoomSpeed:b,enableRotate:C,rotateSpeed:L}=u.toRefs(n),{camera:M,renderer:P,extend:w,controls:S,invalidate:x}=H.useTresContext();u.watch(n,()=>{x()});const I=u.shallowRef(null);w({MapControls:rl}),u.watch(S,z=>{z&&n.makeDefault?S.value=z:S.value=null});const{onBeforeRender:D}=H.useLoop();return D(({invalidate:z})=>{I.value&&(s.value||o.value)&&(I.value.update(),z())}),u.onUnmounted(()=>{I.value&&I.value.dispose()}),e({instance:I}),(z,G)=>(z.camera||u.unref(M))&&(z.domElement||u.unref(P))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:I,args:[z.camera||u.unref(M),z.domElement||u.unref(P).domElement],"auto-rotate":u.unref(o),"auto-rotate-speed":u.unref(r),"enable-damping":u.unref(s),"damping-factor":u.unref(i),"enable-pan":u.unref(c),"key-pan-speed":u.unref(h),keys:z.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(f),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(d),"min-distance":u.unref(g),"max-distance":u.unref(y),"min-zoom":u.unref(v),"max-zoom":u.unref(_),"enable-zoom":u.unref(A),"zoom-speed":u.unref(b),"enable-rotate":u.unref(C),"rotate-speed":u.unref(L)},null,8,vu)):u.createCommentVNode("",!0)}}),wu=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","mouse-buttons","args"],bu=u.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1},mouseButtons:{default:()=>({LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN})}},emits:["change","start","end"],setup(a,{expose:e,emit:t}){const n=a,o=t,{makeDefault:r,autoRotate:s,autoRotateSpeed:i,enableDamping:c,dampingFactor:h,enablePan:p,keyPanSpeed:f,maxAzimuthAngle:m,minAzimuthAngle:d,maxPolarAngle:g,minPolarAngle:y,minDistance:v,maxDistance:_,minZoom:A,maxZoom:b,enableZoom:C,zoomSpeed:L,enableRotate:M,touches:P,rotateSpeed:w,target:S,mouseButtons:x}=u.toRefs(n),{camera:I,renderer:D,extend:z,controls:G,invalidate:E}=H.useTresContext(),X=u.shallowRef(null);z({OrbitControls:wr}),u.watch(X,ee=>{oe(),ee&&r.value?G.value=ee:G.value=null});function oe(){Ce(X.value,"change",()=>{o("change",X.value),E()}),Ce(X.value,"start",()=>o("start",X.value)),Ce(X.value,"end",()=>o("end",X.value))}const{onBeforeRender:q}=H.useLoop();return q(({invalidate:ee})=>{X.value&&(c.value||s.value)&&(X.value.update(),s.value&&ee())}),u.onUnmounted(()=>{X.value&&X.value.dispose()}),e({instance:X}),(ee,te)=>(ee.camera||u.unref(I))&&(ee.domElement||u.unref(D))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:X,target:u.unref(S),"auto-rotate":u.unref(s),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(c),"damping-factor":u.unref(h),"enable-pan":u.unref(p),"key-pan-speed":u.unref(f),keys:ee.keys,"max-azimuth-angle":u.unref(m),"min-azimuth-angle":u.unref(d),"max-polar-angle":u.unref(g),"min-polar-angle":u.unref(y),"min-distance":u.unref(v),"max-distance":u.unref(_),"min-zoom":u.unref(A),"max-zoom":u.unref(b),touches:u.unref(P),"enable-zoom":u.unref(C),"zoom-speed":u.unref(L),"enable-rotate":u.unref(M),"rotate-speed":u.unref(w),"mouse-buttons":u.unref(x),args:[ee.camera||u.unref(I),ee.domElement||u.unref(D).domElement]},null,8,wu)):u.createCommentVNode("",!0)}}),Mu=["args"],_s=u.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock","change"],setup(a,{expose:e,emit:t}){const n=a,o=t,{camera:r,renderer:s,extend:i,controls:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(null);let f;i({PointerLockControls:_r});const m=d=>{o("isLock",d)};return u.watch(p,d=>{d&&n.makeDefault?c.value=d:c.value=null,f=document.getElementById(n.selector||"")||s.value.domElement,Ce(f,"click",()=>{p.value&&(p.value.lock(),p.value.addEventListener("lock",()=>m(!0)),p.value.addEventListener("unlock",()=>m(!1)),h())})}),u.onUnmounted(()=>{const d=p.value;d&&(d.removeEventListener("lock",()=>m(!0)),d.removeEventListener("unlock",()=>m(!1)),d.dispose())}),e({instance:c}),(d,g)=>(d.camera||u.unref(r))&&(d.domElement||u.unref(s))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:p,args:[d.camera||u.unref(r),d.domElement||u.unref(s).domElement]},null,8,Mu)):u.createCommentVNode("",!0)}}),Su=u.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(a,{expose:e,emit:t}){const n=a,o=t,{logWarning:r}=H.useLogger();n.smoothScroll<0&&r("SmoothControl must be greater than zero"),n.pages<0&&r("Pages must be greater than zero");const{camera:s,controls:i,renderer:c,invalidate:h}=H.useTresContext();u.watch(n,()=>{h()});const p=u.shallowRef(),f=document.createElement("div"),{y:m}=zi(),{x:d,y:g,isScrolling:y}=ki(f),{height:v,width:_}=Ko();let A=0;const b=u.ref(!1),C=u.ref(0),L=u.ref(0),M=u.ref(0),P=n.horizontal?"x":"y",w=u.watch(s,x=>{if(b.value){w();return}A=n.horizontal?(x==null?void 0:x.position.x)||0:(x==null?void 0:x.position.y)||0,b.value=!0},{immediate:!0});u.watch(y,x=>{i.value&&(i.value.enabled=!x)},{immediate:!0}),u.watch(m,x=>{!y.value&&!n.htmlScroll||(L.value=x/v.value/(M.value/v.value-1),C.value=-1*L.value,o("update:modelValue",L.value))}),u.watch(g,x=>{L.value=x/v.value/(M.value/v.value),C.value=-1*L.value,o("update:modelValue",L.value)}),u.watch(d,x=>{L.value=x/_.value/(M.value/_.value-1),C.value=+L.value,o("update:modelValue",L.value)}),u.watch(c,x=>{var D,z;const I=x==null?void 0:x.domElement;if(n.htmlScroll&&(x!=null&&x.domElement))I!=null&&I.style.width&&(I!=null&&I.style.position)&&(I!=null&&I.style.top)&&(I!=null&&I.style.left)&&(I.style.width="100%",I.style.position="fixed",I.style.zIndex=" -99999",I.style.top="0",I.style.left="0"),M.value=document.body.scrollHeight;else{const G=document.createElement("div"),E=document.createElement("div");f.style[n.horizontal?"overflowX":"overflowY"]="auto",f.style[n.horizontal?"overflowY":"overflowX"]="hidden",f.style.position="absolute",f.style.width="100%",f.style.height=" 100%",f.style.top="0",f.style.left="0",f.classList.add("scrollContainer"),G.style.position="sticky",G.style.top="0px",G.style.left="0px",G.style.width="100%",G.style.height="100%",G.style.overflow="hidden",f.appendChild(G),E.style.height=n.horizontal?"100%":`${v.value*n.pages}px`,E.style.width=n.horizontal?`${_.value*n.pages}px`:"100vw",E.style.pointerEvents="none",I.style.position="fixed",I.style.zIndex="0",I!=null&&I.style.width&&(I.style.width="100%"),f.appendChild(E),x!=null&&x.domElement.parentNode&&(x.domElement.parentNode.style.position="relative"),(z=(D=x==null?void 0:x.domElement)==null?void 0:D.parentNode)==null||z.appendChild(f),M.value=n.horizontal?_.value*n.pages:v.value*n.pages}},{immediate:!0});const{onBeforeRender:S}=H.useLoop();return S(({invalidate:x})=>{var I;if((I=s.value)!=null&&I.position){const D=(C.value*n.distance-s.value.position[P]+A)*n.smoothScroll;s.value.position[P]+=D,p.value.children.length>0&&(p.value.position[P]+=D),x()}}),e({instance:p}),(x,I)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:p},[u.renderSlot(x.$slots,"default")],512))}}),Au=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],Pu=u.defineComponent({__name:"TransformControls",props:{object:{},camera:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(a,{expose:e,emit:t}){const n=a,o=t,{object:r,mode:s,enabled:i,axis:c,translationSnap:h,rotationSnap:p,scaleSnap:f,space:m,size:d,showX:g,showY:y,showZ:v}=u.toRefs(n),_=u.shallowRef(null),{controls:A,camera:b,renderer:C,extend:L,invalidate:M}=H.useTresContext();u.watch([r,s,i,c,h,p,f,m,d,g,y,v],()=>{M()}),L({TransformControls:Za});const P=()=>{M(),o("change")},w=z=>{A.value&&(A.value.enabled=!z.value),M(),o("dragging",z.value)},S=()=>{M(),o("mouseDown")},x=()=>{M(),o("mouseDown")},I=()=>{M(),o("objectChange")};function D(){Ce(_.value,"change",P),Ce(_.value,"dragging-changed",w),Ce(_.value,"mouseDown",S),Ce(_.value,"mouseUp",x),Ce(_.value,"objectChange",I)}return u.watch(_,z=>{z&&D()}),u.onUnmounted(()=>{_.value&&_.value.dispose()}),e({instance:_}),(z,G)=>{var E;return(z.camera||u.unref(b))&&u.unref(C)?(u.openBlock(),u.createElementBlock("TresTransformControls",{ref_key:"controlsRef",ref:_,key:(E=z.camera||u.unref(b))==null?void 0:E.uuid,object:u.unref(r),args:[z.camera||u.unref(b),u.unref(C).domElement],mode:u.unref(s),enabled:u.unref(i),axis:u.unref(c),"translation-snap":u.unref(h),"rotation-snap":u.unref(p),"scale-snap":u.unref(f),space:u.unref(m),size:u.unref(d),"show-x":u.unref(g),"show-y":u.unref(y),"show-z":u.unref(v),visible:!0},null,8,Au)):u.createCommentVNode("",!0)}}}),Cu=["geometry","render-order"],Tu=u.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(a,{expose:e}){const t=a;class n extends Jt{load(b,C,L,M){const P=Array.isArray(b)?b[0]:b;super.load(P,C,L,M)}}const{src:o,skipStrokes:r,skipFills:s,fillMaterial:i,strokeMaterial:c,fillMeshProps:h,strokeMeshProps:p,depth:f}=u.toRefs(t),m=u.shallowRef(),d=u.shallowRef([]),g=u.shallowRef([]);e({instance:m}),u.watchEffect(async()=>y(o.value).then(A=>g.value=A.paths)),u.watch([s,r,i,c,g],_);async function y(A){const b=A.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${A}`):A;return H.useLoader(n,b)}u.onUnmounted(v);function v(){d.value.forEach(A=>A.geometry.dispose())}function _(){var M,P,w;v();const A=[],[b,C]=(()=>{const S={flat:!1,renderOrder:!1,offsetZ:!0},x={flat:0,renderOrder:0,offsetZ:.025},I=f.value;return typeof I=="number"?[!0,I]:[S[I],x[I]]})();let L=0;for(const S of g.value){const x=((M=S.userData)==null?void 0:M.style)??{},I=Object.assign({color:x.fill,opacity:x.fillOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.fillMaterial);if(!s.value&&x.fill!==void 0&&x.fill!=="none")for(const D of Jt.createShapes(S)){const z=new l.ShapeGeometry(D);z.scale(1,-1,1),C&&z.translate(0,0,L++*C),A.push({geometry:z,material:I,isStroke:!1})}if(!r.value&&x.stroke!==void 0&&x.stroke!=="none"){const D=Object.assign({color:(P=S.userData)==null?void 0:P.style.stroke,opacity:(w=S.userData)==null?void 0:w.style.strokeOpacity,transparent:!0,side:l.DoubleSide,depthWrite:b},t.strokeMaterial);for(const z of S.subPaths){const G=z.getPoints().map(X=>new l.Vector2(X.x,-X.y)),E=Jt.pointsToStroke(G,x||"none");C&&E.translate(0,0,L++*C),A.push({geometry:E,material:D,isStroke:!0})}}}d.value=A}return(A,b)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:m},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(d.value,({geometry:C,material:L,isStroke:M},P)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${P}`,ref_for:!0},M?u.unref(p):u.unref(h),{geometry:C,"render-order":u.unref(f)==="renderOrder"?P:0}),[u.createElementVNode("TresMeshBasicMaterial",u.mergeProps({ref_for:!0},L),null,16)],16,Cu))),128))],512))}});class Iu extends l.Loader{constructor(t){super(t);ue(this,"fbxLoader");this.fbxLoader=new Jl(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.fbxLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.fbxLoader.loadAsync(n)}}const Ou=Iu;async function vs(a){return await H.useLoader(Ou,a)}const Lu=["object"],Du=u.defineComponent({__name:"component",props:{path:{},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const s=([t,n]=u.withAsyncContext(()=>vs(o.path)),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Lu))}});class ku extends l.Loader{constructor(t){super(t);ue(this,"gltfLoader");this.gltfLoader=new il(t)}load(t,n,o,r){const s=Array.isArray(t)?t[0]:t;this.gltfLoader.load(s,n,o,r)}async loadAsync(t){const n=Array.isArray(t)?t[0]:t;return this.gltfLoader.loadAsync(n)}setDRACOLoader(t){return this.gltfLoader.setDRACOLoader(t)}}const Bu=ku;let xt=null;function Uu(a,e){return t=>{e&&e(t),a.draco&&(xt||(xt=new mc),xt.setDecoderPath(a.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader&&t.setDRACOLoader(xt))}}async function xs(a,e={draco:!1},t){const n=await H.useLoader(Bu,a,Uu(e,t));return xt==null||xt.dispose(),xt=null,n}const Nu=["object"],Fu=u.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref();e({instance:r});const{scene:s}=([t,n]=u.withAsyncContext(()=>xs(o.path,{draco:o.draco,decoderPath:o.decoderPath})),t=await t,n(),t);return(o.castShadow||o.receiveShadow)&&s.traverse(i=>{i.isMesh&&(i.castShadow=o.castShadow,i.receiveShadow=o.receiveShadow)}),(i,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:r,object:u.unref(s)},i.$attrs),null,16,Nu))}}),ws="[TresJS - Cientos ▲ ■ ♥] ";function zu(a,e){console.error(`${ws} ${a}`,e||"")}function Vu(a){console.warn(`${ws} ${a}`)}function Gu(a,e){}function bs(){return{logError:zu,logWarning:Vu,logMessage:Gu}}let Mo=0;function Ru(){const a=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:n}=bs();return new Promise(o=>{l.DefaultLoadingManager.onStart=()=>{a.value=!1},l.DefaultLoadingManager.onLoad=()=>{a.value=!0},l.DefaultLoadingManager.onProgress=(r,s,i)=>{s===i&&(Mo=i,a.value=!0,t.value.push(r)),e.value=Math.round((s-Mo)/(i-Mo)*100||100)},l.DefaultLoadingManager.onError=r=>{n("Error loading assets",new Error(r)),a.value=!0},o({items:t,hasFinishLoading:a,progress:e})})}async function ju(a,e){const{logError:t}=bs();if(!a)return t("Error no path provided");const{unsuspend:n,start:o,crossOrigin:r,muted:s,loop:i,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((p,f)=>{const m=Object.assign(document.createElement("video"),{src:typeof a=="string"&&a||void 0,crossOrigin:r,loop:i,muted:s,autoplay:!0,...c}),d=new l.VideoTexture(m);return m.addEventListener(n,()=>p(d)),m.addEventListener("error",()=>f(new Error("Error loading video"))),d})}try{const p=await h();return o&&p.image&&p.image.play(),p}catch{t("Error loading resource")}}function on(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function On(a){throw new Error('Could not dynamically require "'+a+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var So={exports:{}},Ms;function Wu(){return Ms||(Ms=1,function(a,e){(function(t){a.exports=t()})(function(){return function t(n,o,r){function s(h,p){if(!o[h]){if(!n[h]){var f=typeof On=="function"&&On;if(!p&&f)return f(h,!0);if(i)return i(h,!0);throw new Error("Cannot find module '"+h+"'")}p=o[h]={exports:{}},n[h][0].call(p.exports,function(m){var d=n[h][1][m];return s(d||m)},p,p.exports,t,n,o,r)}return o[h].exports}for(var i=typeof On=="function"&&On,c=0;c<r.length;c++)s(r[c]);return s}({1:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("crypto");function y(M,P){P=A(M,P);var w;return(w=P.algorithm!=="passthrough"?g.createHash(P.algorithm):new L).write===void 0&&(w.write=w.update,w.end=w.update),C(P,w).dispatch(M),w.update||w.end(""),w.digest?w.digest(P.encoding==="buffer"?void 0:P.encoding):(M=w.read(),P.encoding!=="buffer"?M.toString(P.encoding):M)}(o=n.exports=y).sha1=function(M){return y(M)},o.keys=function(M){return y(M,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},o.MD5=function(M){return y(M,{algorithm:"md5",encoding:"hex"})},o.keysMD5=function(M){return y(M,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var v=g.getHashes?g.getHashes().slice():["sha1","md5"],_=(v.push("passthrough"),["buffer","hex","binary","base64"]);function A(M,P){var w={};if(w.algorithm=(P=P||{}).algorithm||"sha1",w.encoding=P.encoding||"hex",w.excludeValues=!!P.excludeValues,w.algorithm=w.algorithm.toLowerCase(),w.encoding=w.encoding.toLowerCase(),w.ignoreUnknown=P.ignoreUnknown===!0,w.respectType=P.respectType!==!1,w.respectFunctionNames=P.respectFunctionNames!==!1,w.respectFunctionProperties=P.respectFunctionProperties!==!1,w.unorderedArrays=P.unorderedArrays===!0,w.unorderedSets=P.unorderedSets!==!1,w.unorderedObjects=P.unorderedObjects!==!1,w.replacer=P.replacer||void 0,w.excludeKeys=P.excludeKeys||void 0,M===void 0)throw new Error("Object argument required.");for(var S=0;S<v.length;++S)v[S].toLowerCase()===w.algorithm.toLowerCase()&&(w.algorithm=v[S]);if(v.indexOf(w.algorithm)===-1)throw new Error('Algorithm "'+w.algorithm+'" not supported. supported values: '+v.join(", "));if(_.indexOf(w.encoding)===-1&&w.algorithm!=="passthrough")throw new Error('Encoding "'+w.encoding+'" not supported. supported values: '+_.join(", "));return w}function b(M){if(typeof M=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(M))!=null}function C(M,P,w){w=w||[];function S(x){return P.update?P.update(x,"utf8"):P.write(x,"utf8")}return{dispatch:function(x){return this["_"+((x=M.replacer?M.replacer(x):x)===null?"null":typeof x)](x)},_object:function(x){var I,D=Object.prototype.toString.call(x),z=/\[object (.*)\]/i.exec(D);if(z=(z=z?z[1]:"unknown:["+D+"]").toLowerCase(),0<=(D=w.indexOf(x)))return this.dispatch("[CIRCULAR:"+D+"]");if(w.push(x),i!==void 0&&i.isBuffer&&i.isBuffer(x))return S("buffer:"),S(x);if(z==="object"||z==="function"||z==="asyncfunction")return D=Object.keys(x),M.unorderedObjects&&(D=D.sort()),M.respectType===!1||b(x)||D.splice(0,0,"prototype","__proto__","constructor"),M.excludeKeys&&(D=D.filter(function(G){return!M.excludeKeys(G)})),S("object:"+D.length+":"),I=this,D.forEach(function(G){I.dispatch(G),S(":"),M.excludeValues||I.dispatch(x[G]),S(",")});if(!this["_"+z]){if(M.ignoreUnknown)return S("["+z+"]");throw new Error('Unknown object type "'+z+'"')}this["_"+z](x)},_array:function(x,G){G=G!==void 0?G:M.unorderedArrays!==!1;var D=this;if(S("array:"+x.length+":"),!G||x.length<=1)return x.forEach(function(E){return D.dispatch(E)});var z=[],G=x.map(function(E){var X=new L,oe=w.slice();return C(M,X,oe).dispatch(E),z=z.concat(oe.slice(w.length)),X.read().toString()});return w=w.concat(z),G.sort(),this._array(G,!1)},_date:function(x){return S("date:"+x.toJSON())},_symbol:function(x){return S("symbol:"+x.toString())},_error:function(x){return S("error:"+x.toString())},_boolean:function(x){return S("bool:"+x.toString())},_string:function(x){S("string:"+x.length+":"),S(x.toString())},_function:function(x){S("fn:"),b(x)?this.dispatch("[native]"):this.dispatch(x.toString()),M.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(x.name)),M.respectFunctionProperties&&this._object(x)},_number:function(x){return S("number:"+x.toString())},_xml:function(x){return S("xml:"+x.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(x){return S("regex:"+x.toString())},_uint8array:function(x){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint8clampedarray:function(x){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(x))},_int8array:function(x){return S("int8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint16array:function(x){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(x))},_int16array:function(x){return S("int16array:"),this.dispatch(Array.prototype.slice.call(x))},_uint32array:function(x){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(x))},_int32array:function(x){return S("int32array:"),this.dispatch(Array.prototype.slice.call(x))},_float32array:function(x){return S("float32array:"),this.dispatch(Array.prototype.slice.call(x))},_float64array:function(x){return S("float64array:"),this.dispatch(Array.prototype.slice.call(x))},_arraybuffer:function(x){return S("arraybuffer:"),this.dispatch(new Uint8Array(x))},_url:function(x){return S("url:"+x.toString())},_map:function(x){return S("map:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_set:function(x){return S("set:"),x=Array.from(x),this._array(x,M.unorderedSets!==!1)},_file:function(x){return S("file:"),this.dispatch([x.name,x.size,x.type,x.lastModfied])},_blob:function(){if(M.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
1017
1017
|
(see https://github.com/puleos/object-hash/issues/26)
|
|
1018
1018
|
Use "options.replacer" or "options.ignoreUnknown"
|
|
1019
|
-
`)},_domwindow:function(){return S("domwindow")},_bigint:function(x){return S("bigint:"+x.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function L(){return{buf:"",write:function(M){this.buf+=M},end:function(M){this.buf+=M},read:function(){return this.buf}}}o.writeToStream=function(M,P,w){return w===void 0&&(w=P,P={}),C(P=A(M,P),w).dispatch(M)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){(function(g){var y=typeof Uint8Array<"u"?Uint8Array:Array,v=43,_=47,A=48,b=97,C=65,L=45,M=95;function P(w){return w=w.charCodeAt(0),w===v||w===L?62:w===_||w===M?63:w<A?-1:w<A+10?w-A+26+26:w<C+26?w-C:w<b+26?w-b+26:void 0}g.toByteArray=function(w){var S,x;if(0<w.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var I=w.length,I=w.charAt(I-2)==="="?2:w.charAt(I-1)==="="?1:0,D=new y(3*w.length/4-I),z=0<I?w.length-4:w.length,G=0;function X
|
|
1020
|
-
list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T[0];if(typeof O!="number")for(W=O=0;W<T.length;W++)O+=T[W].length;for(var N=new v(O),K=0,W=0;W<T.length;W++){var Y=T[W];Y.copy(N,K),K+=Y.length}return N},v.prototype.write=function(T,O,N,K){isFinite(O)?isFinite(N)||(K=N,N=void 0):(se=K,K=O,O=N,N=se),O=Number(O)||0;var W,Y,Q,re,se=this.length-O;switch((!N||se<(N=Number(N)))&&(N=se),K=String(K||"utf8").toLowerCase()){case"hex":W=function(j,F,ie,he){ie=Number(ie)||0;var _e=j.length-ie;(!he||_e<(he=Number(he)))&&(he=_e),R((_e=F.length)%2==0,"Invalid hex string"),_e/2<he&&(he=_e/2);for(var Le=0;Le<he;Le++){var Pe=parseInt(F.substr(2*Le,2),16);R(!isNaN(Pe),"Invalid hex string"),j[ie+Le]=Pe}return v._charsWritten=2*Le,Le}(this,T,O,N);break;case"utf8":case"utf-8":Y=this,Q=O,re=N,W=v._charsWritten=de(ce(T),Y,Q,re);break;case"ascii":case"binary":W=_(this,T,O,N);break;case"base64":Y=this,Q=O,re=N,W=v._charsWritten=de(le(T),Y,Q,re);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":W=A(this,T,O,N);break;default:throw new Error("Unknown encoding")}return W},v.prototype.toString=function(T,O,N){var K,W,Y,Q,re=this;if(T=String(T||"utf8").toLowerCase(),O=Number(O)||0,(N=N!==void 0?Number(N):re.length)===O)return"";switch(T){case"hex":K=function(se,j,F){var ie=se.length;(!j||j<0)&&(j=0),(!F||F<0||ie<F)&&(F=ie);for(var he="",_e=j;_e<F;_e++)he+=ne(se[_e]);return he}(re,O,N);break;case"utf8":case"utf-8":K=function(se,j,F){var ie="",he="";F=Math.min(se.length,F);for(var _e=j;_e<F;_e++)se[_e]<=127?(ie+=k(he)+String.fromCharCode(se[_e]),he=""):he+="%"+se[_e].toString(16);return ie+k(he)}(re,O,N);break;case"ascii":case"binary":K=b(re,O,N);break;case"base64":W=re,Q=N,K=(Y=O)===0&&Q===W.length?g.fromByteArray(W):g.fromByteArray(W.slice(Y,Q));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":K=function(se,j,F){for(var ie=se.slice(j,F),he="",_e=0;_e<ie.length;_e+=2)he+=String.fromCharCode(ie[_e]+256*ie[_e+1]);return he}(re,O,N);break;default:throw new Error("Unknown encoding")}return K},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},v.prototype.copy=function(T,O,N,K){if(O=O||0,(K=K||K===0?K:this.length)!==(N=N||0)&&T.length!==0&&this.length!==0){R(N<=K,"sourceEnd < sourceStart"),R(0<=O&&O<T.length,"targetStart out of bounds"),R(0<=N&&N<this.length,"sourceStart out of bounds"),R(0<=K&&K<=this.length,"sourceEnd out of bounds"),K>this.length&&(K=this.length);var W=(K=T.length-O<K-N?T.length-O+N:K)-N;if(W<100||!v._useTypedArrays)for(var Y=0;Y<W;Y++)T[Y+O]=this[Y+N];else T._set(this.subarray(N,N+W),O)}},v.prototype.slice=function(T,O){var N=this.length;if(T=te(T,N,0),O=te(O,N,N),v._useTypedArrays)return v._augment(this.subarray(T,O));for(var K=O-T,W=new v(K,void 0,!0),Y=0;Y<K;Y++)W[Y]=this[Y+T];return W},v.prototype.get=function(T){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(T)},v.prototype.set=function(T,O){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(T,O)},v.prototype.readUInt8=function(T,O){if(O||(R(T!=null,"missing offset"),R(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return this[T]},v.prototype.readUInt16LE=function(T,O){return C(this,T,!0,O)},v.prototype.readUInt16BE=function(T,O){return C(this,T,!1,O)},v.prototype.readUInt32LE=function(T,O){return L(this,T,!0,O)},v.prototype.readUInt32BE=function(T,O){return L(this,T,!1,O)},v.prototype.readInt8=function(T,O){if(O||(R(T!=null,"missing offset"),R(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return 128&this[T]?-1*(255-this[T]+1):this[T]},v.prototype.readInt16LE=function(T,O){return M(this,T,!0,O)},v.prototype.readInt16BE=function(T,O){return M(this,T,!1,O)},v.prototype.readInt32LE=function(T,O){return P(this,T,!0,O)},v.prototype.readInt32BE=function(T,O){return P(this,T,!1,O)},v.prototype.readFloatLE=function(T,O){return w(this,T,!0,O)},v.prototype.readFloatBE=function(T,O){return w(this,T,!1,O)},v.prototype.readDoubleLE=function(T,O){return S(this,T,!0,O)},v.prototype.readDoubleBE=function(T,O){return S(this,T,!1,O)},v.prototype.writeUInt8=function(T,O,N){N||(R(T!=null,"missing value"),R(O!=null,"missing offset"),R(O<this.length,"trying to write beyond buffer length"),V(T,255)),O>=this.length||(this[O]=T)},v.prototype.writeUInt16LE=function(T,O,N){x(this,T,O,!0,N)},v.prototype.writeUInt16BE=function(T,O,N){x(this,T,O,!1,N)},v.prototype.writeUInt32LE=function(T,O,N){I(this,T,O,!0,N)},v.prototype.writeUInt32BE=function(T,O,N){I(this,T,O,!1,N)},v.prototype.writeInt8=function(T,O,N){N||(R(T!=null,"missing value"),R(O!=null,"missing offset"),R(O<this.length,"Trying to write beyond buffer length"),U(T,127,-128)),O>=this.length||(0<=T?this.writeUInt8(T,O,N):this.writeUInt8(255+T+1,O,N))},v.prototype.writeInt16LE=function(T,O,N){D(this,T,O,!0,N)},v.prototype.writeInt16BE=function(T,O,N){D(this,T,O,!1,N)},v.prototype.writeInt32LE=function(T,O,N){z(this,T,O,!0,N)},v.prototype.writeInt32BE=function(T,O,N){z(this,T,O,!1,N)},v.prototype.writeFloatLE=function(T,O,N){G(this,T,O,!0,N)},v.prototype.writeFloatBE=function(T,O,N){G(this,T,O,!1,N)},v.prototype.writeDoubleLE=function(T,O,N){X(this,T,O,!0,N)},v.prototype.writeDoubleBE=function(T,O,N){X(this,T,O,!1,N)},v.prototype.fill=function(T,O,N){if(O=O||0,N=N||this.length,R(typeof(T=typeof(T=T||0)=="string"?T.charCodeAt(0):T)=="number"&&!isNaN(T),"value is not a number"),R(O<=N,"end < start"),N!==O&&this.length!==0){R(0<=O&&O<this.length,"start out of bounds"),R(0<=N&&N<=this.length,"end out of bounds");for(var K=O;K<N;K++)this[K]=T}},v.prototype.inspect=function(){for(var T=[],O=this.length,N=0;N<O;N++)if(T[N]=ne(this[N]),N===o.INSPECT_MAX_BYTES){T[N+1]="...";break}return"<Buffer "+T.join(" ")+">"},v.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(v._useTypedArrays)return new v(this).buffer;for(var T=new Uint8Array(this.length),O=0,N=T.length;O<N;O+=1)T[O]=this[O];return T.buffer};var E=v.prototype;function te(T,O,N){return typeof T!="number"?N:O<=(T=~~T)?O:0<=T||0<=(T+=O)?T:0}function q(T){return(T=~~Math.ceil(+T))<0?0:T}function oe(T){return(Array.isArray||function(O){return Object.prototype.toString.call(O)==="[object Array]"})(T)}function ne(T){return T<16?"0"+T.toString(16):T.toString(16)}function ce(T){for(var O=[],N=0;N<T.length;N++){var K=T.charCodeAt(N);if(K<=127)O.push(T.charCodeAt(N));else for(var W=N,Y=(55296<=K&&K<=57343&&N++,encodeURIComponent(T.slice(W,N+1)).substr(1).split("%")),Q=0;Q<Y.length;Q++)O.push(parseInt(Y[Q],16))}return O}function le(T){return g.toByteArray(T)}function de(T,O,N,K){for(var W=0;W<K&&!(W+N>=O.length||W>=T.length);W++)O[W+N]=T[W];return W}function k(T){try{return decodeURIComponent(T)}catch{return"�"}}function V(T,O){R(typeof T=="number","cannot write a non-number as a number"),R(0<=T,"specified a negative value for writing an unsigned value"),R(T<=O,"value is larger than maximum value for type"),R(Math.floor(T)===T,"value has a fractional component")}function U(T,O,N){R(typeof T=="number","cannot write a non-number as a number"),R(T<=O,"value larger than maximum allowed value"),R(N<=T,"value smaller than minimum allowed value"),R(Math.floor(T)===T,"value has a fractional component")}function B(T,O,N){R(typeof T=="number","cannot write a non-number as a number"),R(T<=O,"value larger than maximum allowed value"),R(N<=T,"value smaller than minimum allowed value")}function R(T,O){if(!T)throw new Error(O||"Failed assertion")}v._augment=function(T){return T._isBuffer=!0,T._get=T.get,T._set=T.set,T.get=E.get,T.set=E.set,T.write=E.write,T.toString=E.toString,T.toLocaleString=E.toString,T.toJSON=E.toJSON,T.copy=E.copy,T.slice=E.slice,T.readUInt8=E.readUInt8,T.readUInt16LE=E.readUInt16LE,T.readUInt16BE=E.readUInt16BE,T.readUInt32LE=E.readUInt32LE,T.readUInt32BE=E.readUInt32BE,T.readInt8=E.readInt8,T.readInt16LE=E.readInt16LE,T.readInt16BE=E.readInt16BE,T.readInt32LE=E.readInt32LE,T.readInt32BE=E.readInt32BE,T.readFloatLE=E.readFloatLE,T.readFloatBE=E.readFloatBE,T.readDoubleLE=E.readDoubleLE,T.readDoubleBE=E.readDoubleBE,T.writeUInt8=E.writeUInt8,T.writeUInt16LE=E.writeUInt16LE,T.writeUInt16BE=E.writeUInt16BE,T.writeUInt32LE=E.writeUInt32LE,T.writeUInt32BE=E.writeUInt32BE,T.writeInt8=E.writeInt8,T.writeInt16LE=E.writeInt16LE,T.writeInt16BE=E.writeInt16BE,T.writeInt32LE=E.writeInt32LE,T.writeInt32BE=E.writeInt32BE,T.writeFloatLE=E.writeFloatLE,T.writeFloatBE=E.writeFloatBE,T.writeDoubleLE=E.writeDoubleLE,T.writeDoubleBE=E.writeDoubleBE,T.fill=E.fill,T.inspect=E.inspect,T.toArrayBuffer=E.toArrayBuffer,T}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,n,o){(function(r,s,g,c,h,p,f,m,d){var g=t("buffer").Buffer,y=4,v=new g(y);v.fill(0),n.exports={hash:function(_,A,b,C){for(var L=A(function(x,I){x.length%y!=0&&(D=x.length+(y-x.length%y),x=g.concat([x,v],D));for(var D,z=[],G=I?x.readInt32BE:x.readInt32LE,X=0;X<x.length;X+=y)z.push(G.call(x,X));return z}(_=g.isBuffer(_)?_:new g(_),C),8*_.length),A=C,M=new g(b),P=A?M.writeInt32BE:M.writeInt32LE,w=0;w<L.length;w++)P.call(M,L[w],4*w,!0);return M}}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,n,o){(function(r,s,g,c,h,p,f,m,d){var g=t("buffer").Buffer,y=t("./sha"),v=t("./sha256"),_=t("./rng"),A={sha1:y,sha256:v,md5:t("./md5")},b=64,C=new g(b);function L(x,I){var D=A[x=x||"sha1"],z=[];return D||M("algorithm:",x,"is not yet supported"),{update:function(G){return g.isBuffer(G)||(G=new g(G)),z.push(G),G.length,this},digest:function(G){var X=g.concat(z),X=I?function(E,te,q){g.isBuffer(te)||(te=new g(te)),g.isBuffer(q)||(q=new g(q)),te.length>b?te=E(te):te.length<b&&(te=g.concat([te,C],b));for(var oe=new g(b),ne=new g(b),ce=0;ce<b;ce++)oe[ce]=54^te[ce],ne[ce]=92^te[ce];return q=E(g.concat([oe,q])),E(g.concat([ne,q]))}(D,I,X):D(X);return z=null,G?X.toString(G):X}}}function M(){var x=[].slice.call(arguments).join(" ");throw new Error([x,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
1021
|
-
`))}C.fill(0),o.createHash=function(x){return L(x)},o.createHmac=L,o.randomBytes=function(x,I){if(!I||!I.call)return new g(_(x));try{I.call(this,void 0,new g(_(x)))}catch(D){I(D)}};var P,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(x){o[x]=function(){M("sorry,",x,"is not implemented yet")}};for(P in w)S(w[P])}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("./helpers");function y(M,P){M[P>>5]|=128<<P%32,M[14+(P+64>>>9<<4)]=P;for(var w=1732584193,S=-271733879,x=-1732584194,I=271733878,D=0;D<M.length;D+=16){var z=w,G=S,X=x,E=I,w=_(w,S,x,I,M[D+0],7,-680876936),I=_(I,w,S,x,M[D+1],12,-389564586),x=_(x,I,w,S,M[D+2],17,606105819),S=_(S,x,I,w,M[D+3],22,-1044525330);w=_(w,S,x,I,M[D+4],7,-176418897),I=_(I,w,S,x,M[D+5],12,1200080426),x=_(x,I,w,S,M[D+6],17,-1473231341),S=_(S,x,I,w,M[D+7],22,-45705983),w=_(w,S,x,I,M[D+8],7,1770035416),I=_(I,w,S,x,M[D+9],12,-1958414417),x=_(x,I,w,S,M[D+10],17,-42063),S=_(S,x,I,w,M[D+11],22,-1990404162),w=_(w,S,x,I,M[D+12],7,1804603682),I=_(I,w,S,x,M[D+13],12,-40341101),x=_(x,I,w,S,M[D+14],17,-1502002290),w=A(w,S=_(S,x,I,w,M[D+15],22,1236535329),x,I,M[D+1],5,-165796510),I=A(I,w,S,x,M[D+6],9,-1069501632),x=A(x,I,w,S,M[D+11],14,643717713),S=A(S,x,I,w,M[D+0],20,-373897302),w=A(w,S,x,I,M[D+5],5,-701558691),I=A(I,w,S,x,M[D+10],9,38016083),x=A(x,I,w,S,M[D+15],14,-660478335),S=A(S,x,I,w,M[D+4],20,-405537848),w=A(w,S,x,I,M[D+9],5,568446438),I=A(I,w,S,x,M[D+14],9,-1019803690),x=A(x,I,w,S,M[D+3],14,-187363961),S=A(S,x,I,w,M[D+8],20,1163531501),w=A(w,S,x,I,M[D+13],5,-1444681467),I=A(I,w,S,x,M[D+2],9,-51403784),x=A(x,I,w,S,M[D+7],14,1735328473),w=b(w,S=A(S,x,I,w,M[D+12],20,-1926607734),x,I,M[D+5],4,-378558),I=b(I,w,S,x,M[D+8],11,-2022574463),x=b(x,I,w,S,M[D+11],16,1839030562),S=b(S,x,I,w,M[D+14],23,-35309556),w=b(w,S,x,I,M[D+1],4,-1530992060),I=b(I,w,S,x,M[D+4],11,1272893353),x=b(x,I,w,S,M[D+7],16,-155497632),S=b(S,x,I,w,M[D+10],23,-1094730640),w=b(w,S,x,I,M[D+13],4,681279174),I=b(I,w,S,x,M[D+0],11,-358537222),x=b(x,I,w,S,M[D+3],16,-722521979),S=b(S,x,I,w,M[D+6],23,76029189),w=b(w,S,x,I,M[D+9],4,-640364487),I=b(I,w,S,x,M[D+12],11,-421815835),x=b(x,I,w,S,M[D+15],16,530742520),w=C(w,S=b(S,x,I,w,M[D+2],23,-995338651),x,I,M[D+0],6,-198630844),I=C(I,w,S,x,M[D+7],10,1126891415),x=C(x,I,w,S,M[D+14],15,-1416354905),S=C(S,x,I,w,M[D+5],21,-57434055),w=C(w,S,x,I,M[D+12],6,1700485571),I=C(I,w,S,x,M[D+3],10,-1894986606),x=C(x,I,w,S,M[D+10],15,-1051523),S=C(S,x,I,w,M[D+1],21,-2054922799),w=C(w,S,x,I,M[D+8],6,1873313359),I=C(I,w,S,x,M[D+15],10,-30611744),x=C(x,I,w,S,M[D+6],15,-1560198380),S=C(S,x,I,w,M[D+13],21,1309151649),w=C(w,S,x,I,M[D+4],6,-145523070),I=C(I,w,S,x,M[D+11],10,-1120210379),x=C(x,I,w,S,M[D+2],15,718787259),S=C(S,x,I,w,M[D+9],21,-343485551),w=L(w,z),S=L(S,G),x=L(x,X),I=L(I,E)}return Array(w,S,x,I)}function v(M,P,w,S,x,I){return L((P=L(L(P,M),L(S,I)))<<x|P>>>32-x,w)}function _(M,P,w,S,x,I,D){return v(P&w|~P&S,M,P,x,I,D)}function A(M,P,w,S,x,I,D){return v(P&S|w&~S,M,P,x,I,D)}function b(M,P,w,S,x,I,D){return v(P^w^S,M,P,x,I,D)}function C(M,P,w,S,x,I,D){return v(w^(P|~S),M,P,x,I,D)}function L(M,P){var w=(65535&M)+(65535&P);return(M>>16)+(P>>16)+(w>>16)<<16|65535&w}n.exports=function(M){return g.hash(M,y,16)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){n.exports=function(g){for(var y,v=new Array(g),_=0;_<g;_++)!(3&_)&&(y=4294967296*Math.random()),v[_]=y>>>((3&_)<<3)&255;return v}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("./helpers");function y(A,b){A[b>>5]|=128<<24-b%32,A[15+(b+64>>9<<4)]=b;for(var C,L,M,P=Array(80),w=1732584193,S=-271733879,x=-1732584194,I=271733878,D=-1009589776,z=0;z<A.length;z+=16){for(var G=w,X=S,E=x,te=I,q=D,oe=0;oe<80;oe++){P[oe]=oe<16?A[z+oe]:_(P[oe-3]^P[oe-8]^P[oe-14]^P[oe-16],1);var ne=v(v(_(w,5),(ne=S,L=x,M=I,(C=oe)<20?ne&L|~ne&M:!(C<40)&&C<60?ne&L|ne&M|L&M:ne^L^M)),v(v(D,P[oe]),(C=oe)<20?1518500249:C<40?1859775393:C<60?-1894007588:-899497514)),D=I,I=x,x=_(S,30),S=w,w=ne}w=v(w,G),S=v(S,X),x=v(x,E),I=v(I,te),D=v(D,q)}return Array(w,S,x,I,D)}function v(A,b){var C=(65535&A)+(65535&b);return(A>>16)+(b>>16)+(C>>16)<<16|65535&C}function _(A,b){return A<<b|A>>>32-b}n.exports=function(A){return g.hash(A,y,20,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){function g(b,C){var L=(65535&b)+(65535&C);return(b>>16)+(C>>16)+(L>>16)<<16|65535&L}function y(b,C){var L,M=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),P=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),w=new Array(64);b[C>>5]|=128<<24-C%32,b[15+(C+64>>9<<4)]=C;for(var S,x,I=0;I<b.length;I+=16){for(var D=P[0],z=P[1],G=P[2],X=P[3],E=P[4],te=P[5],q=P[6],oe=P[7],ne=0;ne<64;ne++)w[ne]=ne<16?b[ne+I]:g(g(g((x=w[ne-2],_(x,17)^_(x,19)^A(x,10)),w[ne-7]),(x=w[ne-15],_(x,7)^_(x,18)^A(x,3))),w[ne-16]),L=g(g(g(g(oe,_(x=E,6)^_(x,11)^_(x,25)),E&te^~E&q),M[ne]),w[ne]),S=g(_(S=D,2)^_(S,13)^_(S,22),D&z^D&G^z&G),oe=q,q=te,te=E,E=g(X,L),X=G,G=z,z=D,D=g(L,S);P[0]=g(D,P[0]),P[1]=g(z,P[1]),P[2]=g(G,P[2]),P[3]=g(X,P[3]),P[4]=g(E,P[4]),P[5]=g(te,P[5]),P[6]=g(q,P[6]),P[7]=g(oe,P[7])}return P}var v=t("./helpers"),_=function(b,C){return b>>>C|b<<32-C},A=function(b,C){return b>>>C};n.exports=function(b){return v.hash(b,y,32,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){o.read=function(g,y,v,_,I){var b,C,L=8*I-_-1,M=(1<<L)-1,P=M>>1,w=-7,S=v?I-1:0,x=v?-1:1,I=g[y+S];for(S+=x,b=I&(1<<-w)-1,I>>=-w,w+=L;0<w;b=256*b+g[y+S],S+=x,w-=8);for(C=b&(1<<-w)-1,b>>=-w,w+=_;0<w;C=256*C+g[y+S],S+=x,w-=8);if(b===0)b=1-P;else{if(b===M)return C?NaN:1/0*(I?-1:1);C+=Math.pow(2,_),b-=P}return(I?-1:1)*C*Math.pow(2,b-_)},o.write=function(g,y,v,_,A,D){var C,L,M=8*D-A-1,P=(1<<M)-1,w=P>>1,S=A===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=_?0:D-1,I=_?1:-1,D=y<0||y===0&&1/y<0?1:0;for(y=Math.abs(y),isNaN(y)||y===1/0?(L=isNaN(y)?1:0,C=P):(C=Math.floor(Math.log(y)/Math.LN2),y*(_=Math.pow(2,-C))<1&&(C--,_*=2),2<=(y+=1<=C+w?S/_:S*Math.pow(2,1-w))*_&&(C++,_/=2),P<=C+w?(L=0,C=P):1<=C+w?(L=(y*_-1)*Math.pow(2,A),C+=w):(L=y*Math.pow(2,w-1)*Math.pow(2,A),C=0));8<=A;g[v+x]=255&L,x+=I,L/=256,A-=8);for(C=C<<A|L,M+=A;0<M;g[v+x]=255&C,x+=I,C/=256,M-=8);g[v+x-I]|=128*D}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g,y,v;function _(){}(r=n.exports={}).nextTick=(y=typeof window<"u"&&window.setImmediate,v=typeof window<"u"&&window.postMessage&&window.addEventListener,y?function(A){return window.setImmediate(A)}:v?(g=[],window.addEventListener("message",function(A){var b=A.source;b!==window&&b!==null||A.data!=="process-tick"||(A.stopPropagation(),0<g.length&&g.shift()())},!0),function(A){g.push(A),window.postMessage("process-tick","*")}):function(A){setTimeout(A,0)}),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=_,r.addListener=_,r.once=_,r.off=_,r.removeListener=_,r.removeAllListeners=_,r.emit=_,r.binding=function(A){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(A){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(So)),So.exports}var Yu=Wu();const Xu=on(Yu);var Ao,Ss;function As(){return Ss||(Ss=1,Ao=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","uint","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]),Ao}var Po,Ps;function Eu(){return Ps||(Ps=1,Po=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]),Po}var Co,Cs;function Ts(){return Cs||(Cs=1,Co=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]),Co}var To,Is;function Zu(){if(Is)return To;Is=1;var a=As();return To=a.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"]),To}var Io,Os;function Ku(){if(Os)return Io;Os=1;var a=Ts();return a=a.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),Io=a.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"]),Io}var Oo,Ls;function qu(){if(Ls)return Oo;Ls=1,Oo=C;var a=As(),e=Eu(),t=Ts(),n=Zu(),o=Ku(),r=999,s=9999,i=0,c=1,h=2,p=3,f=4,m=5,d=6,g=7,y=8,v=9,_=10,A=11,b=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function C(L){var M=0,P=0,w=r,S,x,I=[],D=[],z=1,G=0,X=0,E=!1,te=!1,q="",oe;L=L||{};var ne=t,ce=a;L.version==="300 es"&&(ne=o,ce=n);for(var le={},de={},M=0;M<ne.length;M++)le[ne[M]]=!0;for(var M=0;M<ce.length;M++)de[ce[M]]=!0;return function(j){return D=[],j!==null?V(j):U()};function k(j){j.length&&D.push({type:b[w],data:j,position:X,line:z,column:G})}function V(j){M=0,j.toString&&(j=j.toString()),q+=j.replace(/\r\n/g,`
|
|
1022
|
-
`),
|
|
1023
|
-
`:G=0,++z;break;default:++G;break}}return P+=M,q=q.slice(M),D}function U(j){return I.length&&k(I.join("")),w=_,k("(eof)"),D}function B(){return I=I.length?[]:I,x==="/"&&S==="*"?(
|
|
1024
|
-
`)&&x!=="\\"?(k(I.join("")),w=r,M):(I.push(S),x=S,M+1)}function O(){return T()}function N(){return S==="/"&&x==="*"?(I.push(S),k(I.join("")),w=r,M+1):(I.push(S),x=S,M+1)}function K(){if(x==="."&&/\d/.test(S))return w=m,M;if(x==="/"&&S==="*")return w=i,M;if(x==="/"&&S==="/")return w=c,M;if(S==="."&&I.length){for(;W(I););return w=m,M}if(S===";"||S===")"||S==="("){if(I.length)for(;W(I););return k(S),w=r,M+1}var j=I.length===2&&S!=="=";if(/[\w_\d\s]/.test(S)||j){for(;W(I););return w=r,M}return I.push(S),x=S,M+1}function W(j){var F=0,ie,he;do{if(ie=e.indexOf(j.slice(0,j.length+F).join("")),he=e[ie],ie===-1){if(F--+j.length>0)continue;he=j.slice(0,1).join("")}return k(he),
|
|
1019
|
+
`)},_domwindow:function(){return S("domwindow")},_bigint:function(x){return S("bigint:"+x.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function L(){return{buf:"",write:function(M){this.buf+=M},end:function(M){this.buf+=M},read:function(){return this.buf}}}o.writeToStream=function(M,P,w){return w===void 0&&(w=P,P={}),C(P=A(M,P),w).dispatch(M)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){(function(g){var y=typeof Uint8Array<"u"?Uint8Array:Array,v=43,_=47,A=48,b=97,C=65,L=45,M=95;function P(w){return w=w.charCodeAt(0),w===v||w===L?62:w===_||w===M?63:w<A?-1:w<A+10?w-A+26+26:w<C+26?w-C:w<b+26?w-b+26:void 0}g.toByteArray=function(w){var S,x;if(0<w.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var I=w.length,I=w.charAt(I-2)==="="?2:w.charAt(I-1)==="="?1:0,D=new y(3*w.length/4-I),z=0<I?w.length-4:w.length,G=0;function E(X){D[G++]=X}for(S=0;S<z;S+=4,0)E((16711680&(x=P(w.charAt(S))<<18|P(w.charAt(S+1))<<12|P(w.charAt(S+2))<<6|P(w.charAt(S+3))))>>16),E((65280&x)>>8),E(255&x);return I==2?E(255&(x=P(w.charAt(S))<<2|P(w.charAt(S+1))>>4)):I==1&&(E((x=P(w.charAt(S))<<10|P(w.charAt(S+1))<<4|P(w.charAt(S+2))>>2)>>8&255),E(255&x)),D},g.fromByteArray=function(w){var S,x,I,D,z=w.length%3,G="";function E(X){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(X)}for(S=0,I=w.length-z;S<I;S+=3)x=(w[S]<<16)+(w[S+1]<<8)+w[S+2],G+=E((D=x)>>18&63)+E(D>>12&63)+E(D>>6&63)+E(63&D);switch(z){case 1:G=(G+=E((x=w[w.length-1])>>2))+E(x<<4&63)+"==";break;case 2:G=(G=(G+=E((x=(w[w.length-2]<<8)+w[w.length-1])>>10))+E(x>>4&63))+E(x<<2&63)+"="}return G}})(o===void 0?this.base64js={}:o)}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,n,o){(function(r,s,v,c,h,p,f,m,d){var g=t("base64-js"),y=t("ieee754");function v(T,O,N){if(!(this instanceof v))return new v(T,O,N);var K,W,Y,Q,re=typeof T;if(O==="base64"&&re=="string")for(T=(Q=T).trim?Q.trim():Q.replace(/^\s+|\s+$/g,"");T.length%4!=0;)T+="=";if(re=="number")K=q(T);else if(re=="string")K=v.byteLength(T,O);else{if(re!="object")throw new Error("First argument needs to be a number, array or string.");K=q(T.length)}if(v._useTypedArrays?W=v._augment(new Uint8Array(K)):((W=this).length=K,W._isBuffer=!0),v._useTypedArrays&&typeof T.byteLength=="number")W._set(T);else if(ee(Q=T)||v.isBuffer(Q)||Q&&typeof Q=="object"&&typeof Q.length=="number")for(Y=0;Y<K;Y++)v.isBuffer(T)?W[Y]=T.readUInt8(Y):W[Y]=T[Y];else if(re=="string")W.write(T,0,O);else if(re=="number"&&!v._useTypedArrays&&!N)for(Y=0;Y<K;Y++)W[Y]=0;return W}function _(T,O,N,K){return v._charsWritten=de(function(W){for(var Y=[],Q=0;Q<W.length;Q++)Y.push(255&W.charCodeAt(Q));return Y}(O),T,N,K)}function A(T,O,N,K){return v._charsWritten=de(function(W){for(var Y,Q,re=[],se=0;se<W.length;se++)Q=W.charCodeAt(se),Y=Q>>8,Q=Q%256,re.push(Q),re.push(Y);return re}(O),T,N,K)}function b(T,O,N){var K="";N=Math.min(T.length,N);for(var W=O;W<N;W++)K+=String.fromCharCode(T[W]);return K}function C(T,O,N,Y){Y||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+1<T.length,"Trying to read beyond buffer length"));var W,Y=T.length;if(!(Y<=O))return N?(W=T[O],O+1<Y&&(W|=T[O+1]<<8)):(W=T[O]<<8,O+1<Y&&(W|=T[O+1])),W}function L(T,O,N,Y){Y||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+3<T.length,"Trying to read beyond buffer length"));var W,Y=T.length;if(!(Y<=O))return N?(O+2<Y&&(W=T[O+2]<<16),O+1<Y&&(W|=T[O+1]<<8),W|=T[O],O+3<Y&&(W+=T[O+3]<<24>>>0)):(O+1<Y&&(W=T[O+1]<<16),O+2<Y&&(W|=T[O+2]<<8),O+3<Y&&(W|=T[O+3]),W+=T[O]<<24>>>0),W}function M(T,O,N,K){if(K||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+1<T.length,"Trying to read beyond buffer length")),!(T.length<=O))return K=C(T,O,N,!0),32768&K?-1*(65535-K+1):K}function P(T,O,N,K){if(K||(R(typeof N=="boolean","missing or invalid endian"),R(O!=null,"missing offset"),R(O+3<T.length,"Trying to read beyond buffer length")),!(T.length<=O))return K=L(T,O,N,!0),2147483648&K?-1*(4294967295-K+1):K}function w(T,O,N,K){return K||(R(typeof N=="boolean","missing or invalid endian"),R(O+3<T.length,"Trying to read beyond buffer length")),y.read(T,O,N,23,4)}function S(T,O,N,K){return K||(R(typeof N=="boolean","missing or invalid endian"),R(O+7<T.length,"Trying to read beyond buffer length")),y.read(T,O,N,52,8)}function x(T,O,N,K,W){if(W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+1<T.length,"trying to write beyond buffer length"),V(O,65535)),W=T.length,!(W<=N))for(var Y=0,Q=Math.min(W-N,2);Y<Q;Y++)T[N+Y]=(O&255<<8*(K?Y:1-Y))>>>8*(K?Y:1-Y)}function I(T,O,N,K,W){if(W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+3<T.length,"trying to write beyond buffer length"),V(O,4294967295)),W=T.length,!(W<=N))for(var Y=0,Q=Math.min(W-N,4);Y<Q;Y++)T[N+Y]=O>>>8*(K?Y:3-Y)&255}function D(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+1<T.length,"Trying to write beyond buffer length"),U(O,32767,-32768)),T.length<=N||x(T,0<=O?O:65535+O+1,N,K,W)}function z(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+3<T.length,"Trying to write beyond buffer length"),U(O,2147483647,-2147483648)),T.length<=N||I(T,0<=O?O:4294967295+O+1,N,K,W)}function G(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+3<T.length,"Trying to write beyond buffer length"),B(O,34028234663852886e22,-34028234663852886e22)),T.length<=N||y.write(T,O,N,K,23,4)}function E(T,O,N,K,W){W||(R(O!=null,"missing value"),R(typeof K=="boolean","missing or invalid endian"),R(N!=null,"missing offset"),R(N+7<T.length,"Trying to write beyond buffer length"),B(O,17976931348623157e292,-17976931348623157e292)),T.length<=N||y.write(T,O,N,K,52,8)}o.Buffer=v,o.SlowBuffer=v,o.INSPECT_MAX_BYTES=50,v.poolSize=8192,v._useTypedArrays=function(){try{var T=new ArrayBuffer(0),O=new Uint8Array(T);return O.foo=function(){return 42},O.foo()===42&&typeof O.subarray=="function"}catch{return!1}}(),v.isEncoding=function(T){switch(String(T).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},v.isBuffer=function(T){return!(T==null||!T._isBuffer)},v.byteLength=function(T,O){var N;switch(T+="",O||"utf8"){case"hex":N=T.length/2;break;case"utf8":case"utf-8":N=ce(T).length;break;case"ascii":case"binary":case"raw":N=T.length;break;case"base64":N=le(T).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":N=2*T.length;break;default:throw new Error("Unknown encoding")}return N},v.concat=function(T,O){if(R(ee(T),`Usage: Buffer.concat(list, [totalLength])
|
|
1020
|
+
list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T[0];if(typeof O!="number")for(W=O=0;W<T.length;W++)O+=T[W].length;for(var N=new v(O),K=0,W=0;W<T.length;W++){var Y=T[W];Y.copy(N,K),K+=Y.length}return N},v.prototype.write=function(T,O,N,K){isFinite(O)?isFinite(N)||(K=N,N=void 0):(se=K,K=O,O=N,N=se),O=Number(O)||0;var W,Y,Q,re,se=this.length-O;switch((!N||se<(N=Number(N)))&&(N=se),K=String(K||"utf8").toLowerCase()){case"hex":W=function(j,F,ie,he){ie=Number(ie)||0;var _e=j.length-ie;(!he||_e<(he=Number(he)))&&(he=_e),R((_e=F.length)%2==0,"Invalid hex string"),_e/2<he&&(he=_e/2);for(var Le=0;Le<he;Le++){var Pe=parseInt(F.substr(2*Le,2),16);R(!isNaN(Pe),"Invalid hex string"),j[ie+Le]=Pe}return v._charsWritten=2*Le,Le}(this,T,O,N);break;case"utf8":case"utf-8":Y=this,Q=O,re=N,W=v._charsWritten=de(ce(T),Y,Q,re);break;case"ascii":case"binary":W=_(this,T,O,N);break;case"base64":Y=this,Q=O,re=N,W=v._charsWritten=de(le(T),Y,Q,re);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":W=A(this,T,O,N);break;default:throw new Error("Unknown encoding")}return W},v.prototype.toString=function(T,O,N){var K,W,Y,Q,re=this;if(T=String(T||"utf8").toLowerCase(),O=Number(O)||0,(N=N!==void 0?Number(N):re.length)===O)return"";switch(T){case"hex":K=function(se,j,F){var ie=se.length;(!j||j<0)&&(j=0),(!F||F<0||ie<F)&&(F=ie);for(var he="",_e=j;_e<F;_e++)he+=te(se[_e]);return he}(re,O,N);break;case"utf8":case"utf-8":K=function(se,j,F){var ie="",he="";F=Math.min(se.length,F);for(var _e=j;_e<F;_e++)se[_e]<=127?(ie+=k(he)+String.fromCharCode(se[_e]),he=""):he+="%"+se[_e].toString(16);return ie+k(he)}(re,O,N);break;case"ascii":case"binary":K=b(re,O,N);break;case"base64":W=re,Q=N,K=(Y=O)===0&&Q===W.length?g.fromByteArray(W):g.fromByteArray(W.slice(Y,Q));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":K=function(se,j,F){for(var ie=se.slice(j,F),he="",_e=0;_e<ie.length;_e+=2)he+=String.fromCharCode(ie[_e]+256*ie[_e+1]);return he}(re,O,N);break;default:throw new Error("Unknown encoding")}return K},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},v.prototype.copy=function(T,O,N,K){if(O=O||0,(K=K||K===0?K:this.length)!==(N=N||0)&&T.length!==0&&this.length!==0){R(N<=K,"sourceEnd < sourceStart"),R(0<=O&&O<T.length,"targetStart out of bounds"),R(0<=N&&N<this.length,"sourceStart out of bounds"),R(0<=K&&K<=this.length,"sourceEnd out of bounds"),K>this.length&&(K=this.length);var W=(K=T.length-O<K-N?T.length-O+N:K)-N;if(W<100||!v._useTypedArrays)for(var Y=0;Y<W;Y++)T[Y+O]=this[Y+N];else T._set(this.subarray(N,N+W),O)}},v.prototype.slice=function(T,O){var N=this.length;if(T=oe(T,N,0),O=oe(O,N,N),v._useTypedArrays)return v._augment(this.subarray(T,O));for(var K=O-T,W=new v(K,void 0,!0),Y=0;Y<K;Y++)W[Y]=this[Y+T];return W},v.prototype.get=function(T){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(T)},v.prototype.set=function(T,O){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(T,O)},v.prototype.readUInt8=function(T,O){if(O||(R(T!=null,"missing offset"),R(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return this[T]},v.prototype.readUInt16LE=function(T,O){return C(this,T,!0,O)},v.prototype.readUInt16BE=function(T,O){return C(this,T,!1,O)},v.prototype.readUInt32LE=function(T,O){return L(this,T,!0,O)},v.prototype.readUInt32BE=function(T,O){return L(this,T,!1,O)},v.prototype.readInt8=function(T,O){if(O||(R(T!=null,"missing offset"),R(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return 128&this[T]?-1*(255-this[T]+1):this[T]},v.prototype.readInt16LE=function(T,O){return M(this,T,!0,O)},v.prototype.readInt16BE=function(T,O){return M(this,T,!1,O)},v.prototype.readInt32LE=function(T,O){return P(this,T,!0,O)},v.prototype.readInt32BE=function(T,O){return P(this,T,!1,O)},v.prototype.readFloatLE=function(T,O){return w(this,T,!0,O)},v.prototype.readFloatBE=function(T,O){return w(this,T,!1,O)},v.prototype.readDoubleLE=function(T,O){return S(this,T,!0,O)},v.prototype.readDoubleBE=function(T,O){return S(this,T,!1,O)},v.prototype.writeUInt8=function(T,O,N){N||(R(T!=null,"missing value"),R(O!=null,"missing offset"),R(O<this.length,"trying to write beyond buffer length"),V(T,255)),O>=this.length||(this[O]=T)},v.prototype.writeUInt16LE=function(T,O,N){x(this,T,O,!0,N)},v.prototype.writeUInt16BE=function(T,O,N){x(this,T,O,!1,N)},v.prototype.writeUInt32LE=function(T,O,N){I(this,T,O,!0,N)},v.prototype.writeUInt32BE=function(T,O,N){I(this,T,O,!1,N)},v.prototype.writeInt8=function(T,O,N){N||(R(T!=null,"missing value"),R(O!=null,"missing offset"),R(O<this.length,"Trying to write beyond buffer length"),U(T,127,-128)),O>=this.length||(0<=T?this.writeUInt8(T,O,N):this.writeUInt8(255+T+1,O,N))},v.prototype.writeInt16LE=function(T,O,N){D(this,T,O,!0,N)},v.prototype.writeInt16BE=function(T,O,N){D(this,T,O,!1,N)},v.prototype.writeInt32LE=function(T,O,N){z(this,T,O,!0,N)},v.prototype.writeInt32BE=function(T,O,N){z(this,T,O,!1,N)},v.prototype.writeFloatLE=function(T,O,N){G(this,T,O,!0,N)},v.prototype.writeFloatBE=function(T,O,N){G(this,T,O,!1,N)},v.prototype.writeDoubleLE=function(T,O,N){E(this,T,O,!0,N)},v.prototype.writeDoubleBE=function(T,O,N){E(this,T,O,!1,N)},v.prototype.fill=function(T,O,N){if(O=O||0,N=N||this.length,R(typeof(T=typeof(T=T||0)=="string"?T.charCodeAt(0):T)=="number"&&!isNaN(T),"value is not a number"),R(O<=N,"end < start"),N!==O&&this.length!==0){R(0<=O&&O<this.length,"start out of bounds"),R(0<=N&&N<=this.length,"end out of bounds");for(var K=O;K<N;K++)this[K]=T}},v.prototype.inspect=function(){for(var T=[],O=this.length,N=0;N<O;N++)if(T[N]=te(this[N]),N===o.INSPECT_MAX_BYTES){T[N+1]="...";break}return"<Buffer "+T.join(" ")+">"},v.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(v._useTypedArrays)return new v(this).buffer;for(var T=new Uint8Array(this.length),O=0,N=T.length;O<N;O+=1)T[O]=this[O];return T.buffer};var X=v.prototype;function oe(T,O,N){return typeof T!="number"?N:O<=(T=~~T)?O:0<=T||0<=(T+=O)?T:0}function q(T){return(T=~~Math.ceil(+T))<0?0:T}function ee(T){return(Array.isArray||function(O){return Object.prototype.toString.call(O)==="[object Array]"})(T)}function te(T){return T<16?"0"+T.toString(16):T.toString(16)}function ce(T){for(var O=[],N=0;N<T.length;N++){var K=T.charCodeAt(N);if(K<=127)O.push(T.charCodeAt(N));else for(var W=N,Y=(55296<=K&&K<=57343&&N++,encodeURIComponent(T.slice(W,N+1)).substr(1).split("%")),Q=0;Q<Y.length;Q++)O.push(parseInt(Y[Q],16))}return O}function le(T){return g.toByteArray(T)}function de(T,O,N,K){for(var W=0;W<K&&!(W+N>=O.length||W>=T.length);W++)O[W+N]=T[W];return W}function k(T){try{return decodeURIComponent(T)}catch{return"�"}}function V(T,O){R(typeof T=="number","cannot write a non-number as a number"),R(0<=T,"specified a negative value for writing an unsigned value"),R(T<=O,"value is larger than maximum value for type"),R(Math.floor(T)===T,"value has a fractional component")}function U(T,O,N){R(typeof T=="number","cannot write a non-number as a number"),R(T<=O,"value larger than maximum allowed value"),R(N<=T,"value smaller than minimum allowed value"),R(Math.floor(T)===T,"value has a fractional component")}function B(T,O,N){R(typeof T=="number","cannot write a non-number as a number"),R(T<=O,"value larger than maximum allowed value"),R(N<=T,"value smaller than minimum allowed value")}function R(T,O){if(!T)throw new Error(O||"Failed assertion")}v._augment=function(T){return T._isBuffer=!0,T._get=T.get,T._set=T.set,T.get=X.get,T.set=X.set,T.write=X.write,T.toString=X.toString,T.toLocaleString=X.toString,T.toJSON=X.toJSON,T.copy=X.copy,T.slice=X.slice,T.readUInt8=X.readUInt8,T.readUInt16LE=X.readUInt16LE,T.readUInt16BE=X.readUInt16BE,T.readUInt32LE=X.readUInt32LE,T.readUInt32BE=X.readUInt32BE,T.readInt8=X.readInt8,T.readInt16LE=X.readInt16LE,T.readInt16BE=X.readInt16BE,T.readInt32LE=X.readInt32LE,T.readInt32BE=X.readInt32BE,T.readFloatLE=X.readFloatLE,T.readFloatBE=X.readFloatBE,T.readDoubleLE=X.readDoubleLE,T.readDoubleBE=X.readDoubleBE,T.writeUInt8=X.writeUInt8,T.writeUInt16LE=X.writeUInt16LE,T.writeUInt16BE=X.writeUInt16BE,T.writeUInt32LE=X.writeUInt32LE,T.writeUInt32BE=X.writeUInt32BE,T.writeInt8=X.writeInt8,T.writeInt16LE=X.writeInt16LE,T.writeInt16BE=X.writeInt16BE,T.writeInt32LE=X.writeInt32LE,T.writeInt32BE=X.writeInt32BE,T.writeFloatLE=X.writeFloatLE,T.writeFloatBE=X.writeFloatBE,T.writeDoubleLE=X.writeDoubleLE,T.writeDoubleBE=X.writeDoubleBE,T.fill=X.fill,T.inspect=X.inspect,T.toArrayBuffer=X.toArrayBuffer,T}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,n,o){(function(r,s,g,c,h,p,f,m,d){var g=t("buffer").Buffer,y=4,v=new g(y);v.fill(0),n.exports={hash:function(_,A,b,C){for(var L=A(function(x,I){x.length%y!=0&&(D=x.length+(y-x.length%y),x=g.concat([x,v],D));for(var D,z=[],G=I?x.readInt32BE:x.readInt32LE,E=0;E<x.length;E+=y)z.push(G.call(x,E));return z}(_=g.isBuffer(_)?_:new g(_),C),8*_.length),A=C,M=new g(b),P=A?M.writeInt32BE:M.writeInt32LE,w=0;w<L.length;w++)P.call(M,L[w],4*w,!0);return M}}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,n,o){(function(r,s,g,c,h,p,f,m,d){var g=t("buffer").Buffer,y=t("./sha"),v=t("./sha256"),_=t("./rng"),A={sha1:y,sha256:v,md5:t("./md5")},b=64,C=new g(b);function L(x,I){var D=A[x=x||"sha1"],z=[];return D||M("algorithm:",x,"is not yet supported"),{update:function(G){return g.isBuffer(G)||(G=new g(G)),z.push(G),G.length,this},digest:function(G){var E=g.concat(z),E=I?function(X,oe,q){g.isBuffer(oe)||(oe=new g(oe)),g.isBuffer(q)||(q=new g(q)),oe.length>b?oe=X(oe):oe.length<b&&(oe=g.concat([oe,C],b));for(var ee=new g(b),te=new g(b),ce=0;ce<b;ce++)ee[ce]=54^oe[ce],te[ce]=92^oe[ce];return q=X(g.concat([ee,q])),X(g.concat([te,q]))}(D,I,E):D(E);return z=null,G?E.toString(G):E}}}function M(){var x=[].slice.call(arguments).join(" ");throw new Error([x,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
1021
|
+
`))}C.fill(0),o.createHash=function(x){return L(x)},o.createHmac=L,o.randomBytes=function(x,I){if(!I||!I.call)return new g(_(x));try{I.call(this,void 0,new g(_(x)))}catch(D){I(D)}};var P,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(x){o[x]=function(){M("sorry,",x,"is not implemented yet")}};for(P in w)S(w[P])}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("./helpers");function y(M,P){M[P>>5]|=128<<P%32,M[14+(P+64>>>9<<4)]=P;for(var w=1732584193,S=-271733879,x=-1732584194,I=271733878,D=0;D<M.length;D+=16){var z=w,G=S,E=x,X=I,w=_(w,S,x,I,M[D+0],7,-680876936),I=_(I,w,S,x,M[D+1],12,-389564586),x=_(x,I,w,S,M[D+2],17,606105819),S=_(S,x,I,w,M[D+3],22,-1044525330);w=_(w,S,x,I,M[D+4],7,-176418897),I=_(I,w,S,x,M[D+5],12,1200080426),x=_(x,I,w,S,M[D+6],17,-1473231341),S=_(S,x,I,w,M[D+7],22,-45705983),w=_(w,S,x,I,M[D+8],7,1770035416),I=_(I,w,S,x,M[D+9],12,-1958414417),x=_(x,I,w,S,M[D+10],17,-42063),S=_(S,x,I,w,M[D+11],22,-1990404162),w=_(w,S,x,I,M[D+12],7,1804603682),I=_(I,w,S,x,M[D+13],12,-40341101),x=_(x,I,w,S,M[D+14],17,-1502002290),w=A(w,S=_(S,x,I,w,M[D+15],22,1236535329),x,I,M[D+1],5,-165796510),I=A(I,w,S,x,M[D+6],9,-1069501632),x=A(x,I,w,S,M[D+11],14,643717713),S=A(S,x,I,w,M[D+0],20,-373897302),w=A(w,S,x,I,M[D+5],5,-701558691),I=A(I,w,S,x,M[D+10],9,38016083),x=A(x,I,w,S,M[D+15],14,-660478335),S=A(S,x,I,w,M[D+4],20,-405537848),w=A(w,S,x,I,M[D+9],5,568446438),I=A(I,w,S,x,M[D+14],9,-1019803690),x=A(x,I,w,S,M[D+3],14,-187363961),S=A(S,x,I,w,M[D+8],20,1163531501),w=A(w,S,x,I,M[D+13],5,-1444681467),I=A(I,w,S,x,M[D+2],9,-51403784),x=A(x,I,w,S,M[D+7],14,1735328473),w=b(w,S=A(S,x,I,w,M[D+12],20,-1926607734),x,I,M[D+5],4,-378558),I=b(I,w,S,x,M[D+8],11,-2022574463),x=b(x,I,w,S,M[D+11],16,1839030562),S=b(S,x,I,w,M[D+14],23,-35309556),w=b(w,S,x,I,M[D+1],4,-1530992060),I=b(I,w,S,x,M[D+4],11,1272893353),x=b(x,I,w,S,M[D+7],16,-155497632),S=b(S,x,I,w,M[D+10],23,-1094730640),w=b(w,S,x,I,M[D+13],4,681279174),I=b(I,w,S,x,M[D+0],11,-358537222),x=b(x,I,w,S,M[D+3],16,-722521979),S=b(S,x,I,w,M[D+6],23,76029189),w=b(w,S,x,I,M[D+9],4,-640364487),I=b(I,w,S,x,M[D+12],11,-421815835),x=b(x,I,w,S,M[D+15],16,530742520),w=C(w,S=b(S,x,I,w,M[D+2],23,-995338651),x,I,M[D+0],6,-198630844),I=C(I,w,S,x,M[D+7],10,1126891415),x=C(x,I,w,S,M[D+14],15,-1416354905),S=C(S,x,I,w,M[D+5],21,-57434055),w=C(w,S,x,I,M[D+12],6,1700485571),I=C(I,w,S,x,M[D+3],10,-1894986606),x=C(x,I,w,S,M[D+10],15,-1051523),S=C(S,x,I,w,M[D+1],21,-2054922799),w=C(w,S,x,I,M[D+8],6,1873313359),I=C(I,w,S,x,M[D+15],10,-30611744),x=C(x,I,w,S,M[D+6],15,-1560198380),S=C(S,x,I,w,M[D+13],21,1309151649),w=C(w,S,x,I,M[D+4],6,-145523070),I=C(I,w,S,x,M[D+11],10,-1120210379),x=C(x,I,w,S,M[D+2],15,718787259),S=C(S,x,I,w,M[D+9],21,-343485551),w=L(w,z),S=L(S,G),x=L(x,E),I=L(I,X)}return Array(w,S,x,I)}function v(M,P,w,S,x,I){return L((P=L(L(P,M),L(S,I)))<<x|P>>>32-x,w)}function _(M,P,w,S,x,I,D){return v(P&w|~P&S,M,P,x,I,D)}function A(M,P,w,S,x,I,D){return v(P&S|w&~S,M,P,x,I,D)}function b(M,P,w,S,x,I,D){return v(P^w^S,M,P,x,I,D)}function C(M,P,w,S,x,I,D){return v(w^(P|~S),M,P,x,I,D)}function L(M,P){var w=(65535&M)+(65535&P);return(M>>16)+(P>>16)+(w>>16)<<16|65535&w}n.exports=function(M){return g.hash(M,y,16)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){n.exports=function(g){for(var y,v=new Array(g),_=0;_<g;_++)!(3&_)&&(y=4294967296*Math.random()),v[_]=y>>>((3&_)<<3)&255;return v}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g=t("./helpers");function y(A,b){A[b>>5]|=128<<24-b%32,A[15+(b+64>>9<<4)]=b;for(var C,L,M,P=Array(80),w=1732584193,S=-271733879,x=-1732584194,I=271733878,D=-1009589776,z=0;z<A.length;z+=16){for(var G=w,E=S,X=x,oe=I,q=D,ee=0;ee<80;ee++){P[ee]=ee<16?A[z+ee]:_(P[ee-3]^P[ee-8]^P[ee-14]^P[ee-16],1);var te=v(v(_(w,5),(te=S,L=x,M=I,(C=ee)<20?te&L|~te&M:!(C<40)&&C<60?te&L|te&M|L&M:te^L^M)),v(v(D,P[ee]),(C=ee)<20?1518500249:C<40?1859775393:C<60?-1894007588:-899497514)),D=I,I=x,x=_(S,30),S=w,w=te}w=v(w,G),S=v(S,E),x=v(x,X),I=v(I,oe),D=v(D,q)}return Array(w,S,x,I,D)}function v(A,b){var C=(65535&A)+(65535&b);return(A>>16)+(b>>16)+(C>>16)<<16|65535&C}function _(A,b){return A<<b|A>>>32-b}n.exports=function(A){return g.hash(A,y,20,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){function g(b,C){var L=(65535&b)+(65535&C);return(b>>16)+(C>>16)+(L>>16)<<16|65535&L}function y(b,C){var L,M=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),P=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),w=new Array(64);b[C>>5]|=128<<24-C%32,b[15+(C+64>>9<<4)]=C;for(var S,x,I=0;I<b.length;I+=16){for(var D=P[0],z=P[1],G=P[2],E=P[3],X=P[4],oe=P[5],q=P[6],ee=P[7],te=0;te<64;te++)w[te]=te<16?b[te+I]:g(g(g((x=w[te-2],_(x,17)^_(x,19)^A(x,10)),w[te-7]),(x=w[te-15],_(x,7)^_(x,18)^A(x,3))),w[te-16]),L=g(g(g(g(ee,_(x=X,6)^_(x,11)^_(x,25)),X&oe^~X&q),M[te]),w[te]),S=g(_(S=D,2)^_(S,13)^_(S,22),D&z^D&G^z&G),ee=q,q=oe,oe=X,X=g(E,L),E=G,G=z,z=D,D=g(L,S);P[0]=g(D,P[0]),P[1]=g(z,P[1]),P[2]=g(G,P[2]),P[3]=g(E,P[3]),P[4]=g(X,P[4]),P[5]=g(oe,P[5]),P[6]=g(q,P[6]),P[7]=g(ee,P[7])}return P}var v=t("./helpers"),_=function(b,C){return b>>>C|b<<32-C},A=function(b,C){return b>>>C};n.exports=function(b){return v.hash(b,y,32,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){o.read=function(g,y,v,_,I){var b,C,L=8*I-_-1,M=(1<<L)-1,P=M>>1,w=-7,S=v?I-1:0,x=v?-1:1,I=g[y+S];for(S+=x,b=I&(1<<-w)-1,I>>=-w,w+=L;0<w;b=256*b+g[y+S],S+=x,w-=8);for(C=b&(1<<-w)-1,b>>=-w,w+=_;0<w;C=256*C+g[y+S],S+=x,w-=8);if(b===0)b=1-P;else{if(b===M)return C?NaN:1/0*(I?-1:1);C+=Math.pow(2,_),b-=P}return(I?-1:1)*C*Math.pow(2,b-_)},o.write=function(g,y,v,_,A,D){var C,L,M=8*D-A-1,P=(1<<M)-1,w=P>>1,S=A===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=_?0:D-1,I=_?1:-1,D=y<0||y===0&&1/y<0?1:0;for(y=Math.abs(y),isNaN(y)||y===1/0?(L=isNaN(y)?1:0,C=P):(C=Math.floor(Math.log(y)/Math.LN2),y*(_=Math.pow(2,-C))<1&&(C--,_*=2),2<=(y+=1<=C+w?S/_:S*Math.pow(2,1-w))*_&&(C++,_/=2),P<=C+w?(L=0,C=P):1<=C+w?(L=(y*_-1)*Math.pow(2,A),C+=w):(L=y*Math.pow(2,w-1)*Math.pow(2,A),C=0));8<=A;g[v+x]=255&L,x+=I,L/=256,A-=8);for(C=C<<A|L,M+=A;0<M;g[v+x]=255&C,x+=I,C/=256,M-=8);g[v+x-I]|=128*D}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,n,o){(function(r,s,i,c,h,p,f,m,d){var g,y,v;function _(){}(r=n.exports={}).nextTick=(y=typeof window<"u"&&window.setImmediate,v=typeof window<"u"&&window.postMessage&&window.addEventListener,y?function(A){return window.setImmediate(A)}:v?(g=[],window.addEventListener("message",function(A){var b=A.source;b!==window&&b!==null||A.data!=="process-tick"||(A.stopPropagation(),0<g.length&&g.shift()())},!0),function(A){g.push(A),window.postMessage("process-tick","*")}):function(A){setTimeout(A,0)}),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=_,r.addListener=_,r.once=_,r.off=_,r.removeListener=_,r.removeAllListeners=_,r.emit=_,r.binding=function(A){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(A){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})}(So)),So.exports}var Yu=Wu();const Xu=on(Yu);var Ao,Ss;function As(){return Ss||(Ss=1,Ao=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","uint","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]),Ao}var Po,Ps;function Eu(){return Ps||(Ps=1,Po=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]),Po}var Co,Cs;function Ts(){return Cs||(Cs=1,Co=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]),Co}var To,Is;function Zu(){if(Is)return To;Is=1;var a=As();return To=a.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"]),To}var Io,Os;function Ku(){if(Os)return Io;Os=1;var a=Ts();return a=a.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),Io=a.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"]),Io}var Oo,Ls;function qu(){if(Ls)return Oo;Ls=1,Oo=C;var a=As(),e=Eu(),t=Ts(),n=Zu(),o=Ku(),r=999,s=9999,i=0,c=1,h=2,p=3,f=4,m=5,d=6,g=7,y=8,v=9,_=10,A=11,b=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function C(L){var M=0,P=0,w=r,S,x,I=[],D=[],z=1,G=0,E=0,X=!1,oe=!1,q="",ee;L=L||{};var te=t,ce=a;L.version==="300 es"&&(te=o,ce=n);for(var le={},de={},M=0;M<te.length;M++)le[te[M]]=!0;for(var M=0;M<ce.length;M++)de[ce[M]]=!0;return function(j){return D=[],j!==null?V(j):U()};function k(j){j.length&&D.push({type:b[w],data:j,position:E,line:z,column:G})}function V(j){M=0,j.toString&&(j=j.toString()),q+=j.replace(/\r\n/g,`
|
|
1022
|
+
`),ee=q.length;for(var F;S=q[M],M<ee;){switch(F=M,w){case i:M=N();break;case c:M=O();break;case h:M=T();break;case p:M=K();break;case f:M=Q();break;case A:M=Y();break;case m:M=re();break;case s:M=se();break;case v:M=R();break;case r:M=B();break}if(F!==M)switch(q[F]){case`
|
|
1023
|
+
`:G=0,++z;break;default:++G;break}}return P+=M,q=q.slice(M),D}function U(j){return I.length&&k(I.join("")),w=_,k("(eof)"),D}function B(){return I=I.length?[]:I,x==="/"&&S==="*"?(E=P+M-1,w=i,x=S,M+1):x==="/"&&S==="/"?(E=P+M-1,w=c,x=S,M+1):S==="#"?(w=h,E=P+M,M):/\s/.test(S)?(w=v,E=P+M,M):(X=/\d/.test(S),oe=/[^\w_]/.test(S),E=P+M,w=X?f:oe?p:s,M)}function R(){return/[^\s]/g.test(S)?(k(I.join("")),w=r,M):(I.push(S),x=S,M+1)}function T(){return(S==="\r"||S===`
|
|
1024
|
+
`)&&x!=="\\"?(k(I.join("")),w=r,M):(I.push(S),x=S,M+1)}function O(){return T()}function N(){return S==="/"&&x==="*"?(I.push(S),k(I.join("")),w=r,M+1):(I.push(S),x=S,M+1)}function K(){if(x==="."&&/\d/.test(S))return w=m,M;if(x==="/"&&S==="*")return w=i,M;if(x==="/"&&S==="/")return w=c,M;if(S==="."&&I.length){for(;W(I););return w=m,M}if(S===";"||S===")"||S==="("){if(I.length)for(;W(I););return k(S),w=r,M+1}var j=I.length===2&&S!=="=";if(/[\w_\d\s]/.test(S)||j){for(;W(I););return w=r,M}return I.push(S),x=S,M+1}function W(j){var F=0,ie,he;do{if(ie=e.indexOf(j.slice(0,j.length+F).join("")),he=e[ie],ie===-1){if(F--+j.length>0)continue;he=j.slice(0,1).join("")}return k(he),E+=he.length,I=I.slice(he.length),I.length}while(!0)}function Y(){return/[^a-fA-F0-9]/.test(S)?(k(I.join("")),w=r,M):(I.push(S),x=S,M+1)}function Q(){return S==="."||/[eE]/.test(S)?(I.push(S),w=m,x=S,M+1):S==="x"&&I.length===1&&I[0]==="0"?(w=A,I.push(S),x=S,M+1):/[^\d]/.test(S)?(k(I.join("")),w=r,M):(I.push(S),x=S,M+1)}function re(){return S==="f"&&(I.push(S),x=S,M+=1),/[eE]/.test(S)||(S==="-"||S==="+")&&/[eE]/.test(x)?(I.push(S),x=S,M+1):/[^\d]/.test(S)?(k(I.join("")),w=r,M):(I.push(S),x=S,M+1)}function se(){if(/[^\d\w_]/.test(S)){var j=I.join("");return de[j]?w=y:le[j]?w=g:w=d,k(I.join("")),w=r,M}return I.push(S),x=S,M+1}}return Oo}var Lo,Ds;function Qu(){if(Ds)return Lo;Ds=1;var a=qu();Lo=e;function e(t,n){var o=a(n),r=[];return r=r.concat(o(t)),r=r.concat(o(null)),r}return Lo}var Ju=Qu();const Hu=on(Ju);var Do,ks;function $u(){if(ks)return Do;ks=1,Do=a;function a(e){for(var t=[],n=0;n<e.length;n++)e[n].type!=="eof"&&t.push(e[n].data);return t.join("")}return Do}var eh=$u();const Bs=on(eh);var ko,Us;function th(){if(Us)return ko;Us=1,ko=a;function a(n){var o=null,r=null,s=0,i=0,c=0,h=0,p=0,f=[],m,d,g;for(m=0,d;m<n.length;m++)if(g=n[m],g.data==="{"){if(s&&s++||(d=v(m,e(")"),e()),d<0)||(h=d,d=v(d,e("("),e(")")),d<0)||(p=d,d=v(d,t),d<0)||n[d].type!=="ident"||(r=n[d].data,d=v(d,t),d<0))continue;s=1,i=m,o=n[d].data,c=d;var y=v(d,t);switch(n[y]&&n[y].data){case"lowp":case"highp":case"mediump":c=y}}else if(s&&g.data==="}"){if(--s)continue;f.push({name:r,type:o,body:[i+1,m],args:[p,h+1],outer:[c,m+1]})}for(m=0;m<n.length;m++)if(g=n[m],g.data===";"){if(d=v(m,e(")"),e()),d<0||(h=d,d=v(d,e("("),e(")")),d<0)||(p=d,d=v(d,t),d<0)||n[d].type!=="ident"||(r=n[d].data,d=v(d,t),d<0)||n[d].type==="operator"||n[d].data==="return")continue;o=n[d].data,f.push({name:r,type:o,body:!1,args:[p,h+1],outer:[d,m+1]})}return f.sort(function(_,A){return _.outer[0]-A.outer[0]});function v(_,A,b){for(var C=_-1;C>=0;C--){if(A(n[C]))return C;if(b&&b(n[C]))return-1}return-1}}function e(n){return function(o){return o.type==="operator"&&(!n||o.data===n)}}function t(n){return n.type!=="whitespace"}return ko}var nh=th();const oh=on(nh);function rh(a,e){if(typeof a!="object"||a===null)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var n=t.call(a,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function Ns(a){var e=rh(a,"string");return typeof e=="symbol"?e:String(e)}function Ae(a,e,t){return e=Ns(e),e in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function Fs(a,e){var t=Object.keys(a);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(a);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(a,o).enumerable})),t.push.apply(t,n)}return t}function Rt(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Fs(Object(t),!0).forEach(function(n){Ae(a,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(t)):Fs(Object(t)).forEach(function(n){Object.defineProperty(a,n,Object.getOwnPropertyDescriptor(t,n))})}return a}function sh(a,e){if(a==null)return{};var t={},n=Object.keys(a),o,r;for(r=0;r<n.length;r++)o=n[r],!(e.indexOf(o)>=0)&&(t[o]=a[o]);return t}function ih(a,e){if(a==null)return{};var t=sh(a,e),n,o;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(a);for(o=0;o<r.length;o++)n=r[o],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(a,n)&&(t[n]=a[n])}return t}function ah(a,e){if(!(a instanceof e))throw new TypeError("Cannot call a class as a function")}function lh(a,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(a,Ns(n.key),n)}}function ch(a,e,t){return e&&lh(a.prototype,e),Object.defineProperty(a,"prototype",{writable:!1}),a}function zs(a){if(a===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function Bo(a,e){return Bo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},Bo(a,e)}function uh(a,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(e&&e.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),e&&Bo(a,e)}function Ln(a){return Ln=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ln(a)}function hh(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function fh(a,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return zs(a)}function dh(a){var e=hh();return function(){var n=Ln(a),o;if(e){var r=Ln(this).constructor;o=Reflect.construct(n,arguments,r)}else o=n.apply(this,arguments);return fh(this,o)}}var me={position:"csm_Position",positionRaw:"csm_PositionRaw",pointSize:"csm_PointSize",fragColor:"csm_FragColor",diffuseColor:"csm_DiffuseColor",normal:"csm_Normal",roughness:"csm_Roughness",metalness:"csm_Metalness",emissive:"csm_Emissive",ao:"csm_AO",bump:"csm_Bump",depthAlpha:"csm_DepthAlpha"},We,jt,ph=(We={},Ae(We,"".concat(me.normal),{"#include <beginnormal_vertex>":`
|
|
1025
1025
|
vec3 objectNormal = `.concat(me.normal,`;
|
|
1026
1026
|
#ifdef USE_TANGENT
|
|
1027
1027
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
@@ -1476,14 +1476,14 @@ void main() {
|
|
|
1476
1476
|
mvPosition.xy += rotatedPosition;
|
|
1477
1477
|
|
|
1478
1478
|
gl_Position = projectionMatrix * mvPosition;
|
|
1479
|
-
}`;const rn=new l.Vector3(0,0,0),Uo=new l.Vector3(0,0,0),Jh=new l.Vector3(0,0,0);function Rs(a,e,t){const n=rn.setFromMatrixPosition(a.matrixWorld);n.project(e);const o=t.width/2,r=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*o+o,-(n.y*r)+r,n.z]}function Hh(a,e){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=t.sub(n),r=e.getWorldDirection(Jh);return o.angleTo(r)>Math.PI/2}function $h(a,e,t,n){const o=rn.setFromMatrixPosition(a.matrixWorld),r=o.clone();r.project(e),t.setFromCamera(new l.Vector2(r.x,r.y),e);const s=t.intersectObjects(n,!0);if(s.length>0){const i=s[0].distance;return o.distanceTo(t.ray.origin)<i}return!0}function ef(a,e){if(e instanceof l.OrthographicCamera)return e.zoom;if(e instanceof l.PerspectiveCamera){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=e.fov*Math.PI/180,r=t.distanceTo(n);return 1/(2*Math.tan(o/2)*r)}else return 1}function tf(a,e,t){if(e instanceof l.PerspectiveCamera||e instanceof l.OrthographicCamera){const n=rn.setFromMatrixPosition(a.matrixWorld),o=Uo.setFromMatrixPosition(e.matrixWorld),r=n.distanceTo(o),s=(t[1]-t[0])/(e.far-e.near),i=t[1]-s*e.far;return Math.round(s*r+i)}}const No=a=>Math.abs(a)<1e-10?0:a;function js(a,e,t=""){let n="matrix3d(";for(let o=0;o!==16;o++)n+=No(e[o]*a.elements[o])+(o!==15?",":")");return t+n}const nf=(a=>e=>js(e,a))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),of=(a=>(e,t)=>js(e,a(t),"translate(-50%,-50%)"))(a=>[1/a,1/a,1/a,1,-1/a,-1/a,-1/a,-1,1/a,1/a,1/a,1,1,1,1,1]),rf=["geometry","material"],sf=u.defineComponent({__name:"HTML",props:{geometry:{default:new l.PlaneGeometry},material:{},as:{default:"div"},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:"auto"},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Object,null,Array,Boolean,String]}},emits:["onOcclude"],setup(a,{expose:e,emit:t}){const n=a,o=t,r=u.useSlots(),s=u.useAttrs(),i=u.ref(),c=u.ref(),{geometry:h,material:p,as:f,transform:m,portal:d,wrapperClass:g,eps:y,distanceFactor:v,fullscreen:_,center:A,pointerEvents:b,sprite:C,occlude:L,zIndexRange:M}=u.toRefs(n),{renderer:P,scene:w,camera:S,raycaster:x,sizes:I}=H.useTresContext(),D=u.computed(()=>document.createElement(f.value)),z=u.ref([0,0,0]),G=u.ref(0),X=u.ref(),E=u.computed(()=>m.value?{position:"absolute",top:0,left:0,width:`${I.width.value}px`,height:`${I.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2}:{position:"absolute",transform:A.value?"translate3d(-50%,-50%,0)":"none",..._.value&&{top:-I.height.value/2,left:-I.width.value/2,width:`${I.width.value}px`,height:`${I.height.value}px`},zIndex:2,...Object.assign({},s.style)}),te=u.computed(()=>({position:"absolute",pointerEvents:b.value})),q=u.ref(null),oe=u.ref(!1),ne=u.computed(()=>(L==null?void 0:L.value)&&(L==null?void 0:L.value)!=="blending"||Array.isArray(L==null?void 0:L.value)&&(L==null?void 0:L.value.length)&&u.isRef(L.value[0]));u.watch(()=>L,({value:V})=>{V==="blending"?(D.value.style.zIndex=`${Math.floor(M.value[0]/2)}`,D.value.style.position="absolute",D.value.style.pointerEvents="none"):(D.value.style.zIndex=null,D.value.style.position=null,D.value.style.pointerEvents=null)}),u.watch(()=>{var V;return[i.value,P.value,I.width.value,I.height.value,(V=r.default)==null?void 0:V.call(r)]},([V,U])=>{var B,R,T,O,N,K;if(V&&U){const W=(d==null?void 0:d.value)||U.domElement;if((B=w.value)==null||B.updateMatrixWorld(),m.value)D.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const Y=Rs(V,S.value,{width:I.width.value,height:I.height.value});D.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${Y[0]}px,${Y[1]}px,0);transform-origin:0 0;`}W&&!D.value.parentNode&&((R=W.parentNode)==null||R.appendChild(D.value)),m.value?X.value=u.createVNode("div",{id:"outer",style:E.value},[u.createVNode("div",{id:"inner",style:te.value},[u.createVNode("div",{key:(T=c.value)==null?void 0:T.uuid,id:w==null?void 0:w.value.uuid,class:s.class,style:s.style},(O=r.default)==null?void 0:O.call(r))])]):X.value=u.createVNode("div",{key:(N=c.value)==null?void 0:N.uuid,id:w==null?void 0:w.value.uuid,style:E.value},(K=r.default)==null?void 0:K.call(r)),u.render(X.value,D.value)}}),u.watchEffect(()=>{g!=null&&g.value&&(D.value.className=g.value)});const ce=u.ref(!0),{onBeforeRender:le}=H.useLoop();le(({invalidate:V})=>{var U,B,R,T,O,N,K;if(V(),i.value&&S.value&&P.value){(U=S.value)==null||U.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const W=m.value?z.value:Rs(i.value,S.value,{width:I.width.value||0,height:I.height.value||0});if(m.value||Math.abs(G.value-S.value.zoom)>y.value||Math.abs(z.value[0]-W[0])>y.value||Math.abs(z.value[1]-W[1])>y.value||Math.abs(z.value[2]-W[2])>y.value){const Y=Hh(i.value,S.value);let Q=!1;ne.value&&(Array.isArray(L==null?void 0:L.value)?Q=L==null?void 0:L.value:(L==null?void 0:L.value)!=="blending"&&(Q=[w.value]));const re=ce.value;if(Q){const F=$h(i.value,S.value,x.value,Q);ce.value=F&&!Y}else ce.value=!Y;re!==ce.value&&(o("onOcclude",!ce.value),D.value.style.display=ce.value?"block":"none");const se=Math.floor(M.value[0]/2),j=L!=null&&L.value?ne.value?[M.value[0],se]:[se-1,0]:M.value;if(D.value.style.zIndex=`${tf(i.value,S.value,j)}`,m.value){const[F,ie]=[I.width.value/2,I.height.value/2],he=S.value.projectionMatrix.elements[5]*ie,{isOrthographicCamera:_e,top:Le,left:Pe,bottom:Je,right:wt}=S.value,It=nf(S.value.matrixWorldInverse),st=_e?`scale(${he})translate(${No(-(wt+Pe)/2)}px,${No((Le+Je)/2)}px)`:`translateZ(${he}px)`;let Ee=i.value.matrixWorld;if(C.value&&(Ee=S.value.matrixWorldInverse.clone().transpose().copyPosition(Ee).scale(i.value.scale),Ee.elements[3]=Ee.elements[7]=Ee.elements[11]=0,Ee.elements[15]=1),D.value.style.width=`${I.width.value}px`,D.value.style.height=`${I.height.value}px`,D.value.style.perspective=_e?"":`${he}px`,(B=X.value)!=null&&B.el&&((R=X.value)!=null&&R.children)&&Array.isArray(X.value.children)){X.value.el.style.transform=`${st}${It}translate(${F}px,${ie}px)`;const it=X.value.children[0];it&&it.el&&(it.el.style.transform=of(Ee,1/(((v==null?void 0:v.value)||10)/400)))}}else{const F=(v==null?void 0:v.value)===void 0?1:ef(i.value,S.value)*(v==null?void 0:v.value);D.value.style.transform=`translate3d(${W[0]}px,${W[1]}px,0) scale(${F})`}}z.value=W,G.value=S.value.zoom}if(!ne.value&&c.value&&!oe.value)if(m.value){if((T=X.value)!=null&&T.el&&((O=X.value)!=null&&O.children)){const W=((N=X.value)==null?void 0:N.children)[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const{isOrthographicCamera:Y}=S.value;if(Y||h)s.scale&&(Array.isArray(s.scale)?s.scale instanceof l.Vector3?c.value.scale.copy(s.scale.clone().divideScalar(1)):c.value.scale.set(1/s.scale[0],1/s.scale[1],1/s.scale[2]):c.value.scale.setScalar(1/s.scale));else{const Q=((v==null?void 0:v.value)||10)/400,re=W.clientWidth*Q,se=W.clientHeight*Q;c.value.scale.set(re,se,1)}oe.value=!0}}}else{const W=D.value.children[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const Q=W.clientWidth*1,re=W.clientHeight*1;c.value.scale.set(Q,re,1),oe.value=!0}q.value.lookAt((K=S.value)==null?void 0:K.position)}});const de=u.computed(()=>({vertexShader:m.value?void 0:Qh,fragmentShader:qh})),k=u.computed(()=>{const V=de.value;return p.value||new l.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader,side:l.DoubleSide})});return u.onUnmounted(()=>{k.value&&k.value.dispose(),D.value.remove()}),e({instance:i}),(V,U)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[u.unref(L)&&!ne.value?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:c,geometry:u.unref(h),material:k.value},null,8,rf)):u.createCommentVNode("",!0)],512))}});var Dn={exports:{}},af=Dn.exports,Ws;function lf(){return Ws||(Ws=1,function(a,e){(function(t,n){a.exports=n()})(af,function(){var t=function(){function n(d){return s.appendChild(d.dom),d}function o(d){for(var g=0;g<s.children.length;g++)s.children[g].style.display=g===d?"block":"none";r=d}var r=0,s=document.createElement("div");s.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.addEventListener("click",function(d){d.preventDefault(),o(++r%s.children.length)},!1);var i=(performance||Date).now(),c=i,h=0,p=n(new t.Panel("FPS","#0ff","#002")),f=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return o(0),{REVISION:16,dom:s,addPanel:n,showPanel:o,begin:function(){i=(performance||Date).now()},end:function(){h++;var d=(performance||Date).now();if(f.update(d-i,200),d>c+1e3&&(p.update(1e3*h/(d-c),100),c=d,h=0,m)){var g=performance.memory;m.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:s,setMode:o}};return t.Panel=function(n,o,r){var s=1/0,i=0,c=Math.round,h=c(window.devicePixelRatio||1),p=80*h,f=48*h,m=3*h,d=2*h,g=3*h,y=15*h,v=74*h,_=30*h,A=document.createElement("canvas");A.width=p,A.height=f,A.style.cssText="width:80px;height:48px";var b=A.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,p,f),b.fillStyle=o,b.fillText(n,m,d),b.fillRect(g,y,v,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g,y,v,_),{dom:A,update:function(C,L){s=Math.min(s,C),i=Math.max(i,C),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,p,y),b.fillStyle=o,b.fillText(c(C)+" "+n+" ("+c(s)+"-"+c(i)+")",m,d),b.drawImage(A,g+h,y,v-h,_,g,y,v-h,_),b.fillRect(g+v-h,y,h,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g+v-h,y,h,c((1-C/L)*_))}}},t})}(Dn)),Dn.exports}var cf=lf();const uf=on(cf),hf=u.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(a,{expose:e}){const t=new uf;e({instance:t});const n=document.body;t.showPanel(a.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeRender:o,onAfterRender:r}=H.useLoop();o(()=>t.begin(),Number.NEGATIVE_INFINITY),r(()=>t.end(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class ff{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.gradient=null,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="90px",this.canvas.style.height="48px",this.canvas.style.position="absolute",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.initializeCanvas()}createGradient(){if(!this.context)throw new Error("No context");const e=this.context.createLinearGradient(0,this.GRAPH_Y,0,this.GRAPH_Y+this.GRAPH_HEIGHT);let t;const n=this.fg;switch(this.fg.toLowerCase()){case"#0ff":t="#006666";break;case"#0f0":t="#006600";break;case"#ff0":t="#666600";break;case"#e1e1e1":t="#666666";break;default:t=this.bg;break}return e.addColorStop(0,t),e.addColorStop(1,n),e}initializeCanvas(){this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.gradient=this.createGradient(),this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillStyle=this.fg,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,o,r=0){if(!this.context||!this.gradient)return;const s=Math.min(1/0,e),i=Math.max(n,e);o=Math.max(o,t),this.context.globalAlpha=1,this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(`${e.toFixed(r)} ${this.name} (${s.toFixed(r)}-${parseFloat(i.toFixed(r))})`,this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT);const c=this.GRAPH_HEIGHT-(1-t/o)*this.GRAPH_HEIGHT;c>0&&(this.context.globalAlpha=1,this.context.fillStyle=this.gradient,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y+this.GRAPH_HEIGHT-c,this.PR,c))}}const Ys=class Wt{constructor({trackGPU:e=!1,logsPerSecond:t=30,samplesLog:n=60,samplesGraph:o=10,precision:r=2,minimal:s=!1,horizontal:i=!0,mode:c=0}={}){this.gl=null,this.ext=null,this.activeQuery=null,this.gpuQueries=[],this.threeRendererPatched=!1,this.frames=0,this.renderCount=0,this.isRunningCPUProfiling=!1,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalGpuDurationCompute=0,this.totalFps=0,this.gpuPanel=null,this.gpuPanelCompute=null,this.averageFps={logs:[],graph:[]},this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.averageGpuCompute={logs:[],graph:[]},this.handleClick=h=>{h.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},this.handleResize=()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)},this.mode=c,this.horizontal=i,this.minimal=s,this.trackGPU=e,this.samplesLog=n,this.samplesGraph=o,this.precision=r,this.logsPerSecond=t,this.dom=document.createElement("div"),this.initializeDOM(),this.beginTime=performance.now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.fpsPanel=this.addPanel(new Wt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new Wt.Panel("CPU","#0f0","#020"),1),this.setupEventListeners()}initializeDOM(){this.dom.style.cssText=`
|
|
1479
|
+
}`;const rn=new l.Vector3(0,0,0),Uo=new l.Vector3(0,0,0),Jh=new l.Vector3(0,0,0);function Rs(a,e,t){const n=rn.setFromMatrixPosition(a.matrixWorld);n.project(e);const o=t.width/2,r=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*o+o,-(n.y*r)+r,n.z]}function Hh(a,e){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=t.sub(n),r=e.getWorldDirection(Jh);return o.angleTo(r)>Math.PI/2}function $h(a,e,t,n){const o=rn.setFromMatrixPosition(a.matrixWorld),r=o.clone();r.project(e),t.setFromCamera(new l.Vector2(r.x,r.y),e);const s=t.intersectObjects(n,!0);if(s.length>0){const i=s[0].distance;return o.distanceTo(t.ray.origin)<i}return!0}function ef(a,e){if(e instanceof l.OrthographicCamera)return e.zoom;if(e instanceof l.PerspectiveCamera){const t=rn.setFromMatrixPosition(a.matrixWorld),n=Uo.setFromMatrixPosition(e.matrixWorld),o=e.fov*Math.PI/180,r=t.distanceTo(n);return 1/(2*Math.tan(o/2)*r)}else return 1}function tf(a,e,t){if(e instanceof l.PerspectiveCamera||e instanceof l.OrthographicCamera){const n=rn.setFromMatrixPosition(a.matrixWorld),o=Uo.setFromMatrixPosition(e.matrixWorld),r=n.distanceTo(o),s=(t[1]-t[0])/(e.far-e.near),i=t[1]-s*e.far;return Math.round(s*r+i)}}const No=a=>Math.abs(a)<1e-10?0:a;function js(a,e,t=""){let n="matrix3d(";for(let o=0;o!==16;o++)n+=No(e[o]*a.elements[o])+(o!==15?",":")");return t+n}const nf=(a=>e=>js(e,a))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),of=(a=>(e,t)=>js(e,a(t),"translate(-50%,-50%)"))(a=>[1/a,1/a,1/a,1,-1/a,-1/a,-1/a,-1,1/a,1/a,1/a,1,1,1,1,1]),rf=["geometry","material"],sf=u.defineComponent({__name:"HTML",props:{geometry:{default:new l.PlaneGeometry},material:{},as:{default:"div"},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:"auto"},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Object,null,Array,Boolean,String]}},emits:["onOcclude"],setup(a,{expose:e,emit:t}){const n=a,o=t,r=u.useSlots(),s=u.useAttrs(),i=u.ref(),c=u.ref(),{geometry:h,material:p,as:f,transform:m,portal:d,wrapperClass:g,eps:y,distanceFactor:v,fullscreen:_,center:A,pointerEvents:b,sprite:C,occlude:L,zIndexRange:M}=u.toRefs(n),{renderer:P,scene:w,camera:S,raycaster:x,sizes:I}=H.useTresContext(),D=u.computed(()=>document.createElement(f.value)),z=u.ref([0,0,0]),G=u.ref(0),E=u.ref(),X=u.computed(()=>m.value?{position:"absolute",top:0,left:0,width:`${I.width.value}px`,height:`${I.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2}:{position:"absolute",transform:A.value?"translate3d(-50%,-50%,0)":"none",..._.value&&{top:-I.height.value/2,left:-I.width.value/2,width:`${I.width.value}px`,height:`${I.height.value}px`},zIndex:2,...Object.assign({},s.style)}),oe=u.computed(()=>({position:"absolute",pointerEvents:b.value})),q=u.ref(null),ee=u.ref(!1),te=u.computed(()=>(L==null?void 0:L.value)&&(L==null?void 0:L.value)!=="blending"||Array.isArray(L==null?void 0:L.value)&&(L==null?void 0:L.value.length)&&u.isRef(L.value[0]));u.watch(()=>L,({value:V})=>{V==="blending"?(D.value.style.zIndex=`${Math.floor(M.value[0]/2)}`,D.value.style.position="absolute",D.value.style.pointerEvents="none"):(D.value.style.zIndex=null,D.value.style.position=null,D.value.style.pointerEvents=null)}),u.watch(()=>{var V;return[i.value,P.value,I.width.value,I.height.value,(V=r.default)==null?void 0:V.call(r)]},([V,U])=>{var B,R,T,O,N,K;if(V&&U){const W=(d==null?void 0:d.value)||U.domElement;if((B=w.value)==null||B.updateMatrixWorld(),m.value)D.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const Y=Rs(V,S.value,{width:I.width.value,height:I.height.value});D.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${Y[0]}px,${Y[1]}px,0);transform-origin:0 0;`}W&&!D.value.parentNode&&((R=W.parentNode)==null||R.appendChild(D.value)),m.value?E.value=u.createVNode("div",{id:"outer",style:X.value},[u.createVNode("div",{id:"inner",style:oe.value},[u.createVNode("div",{key:(T=c.value)==null?void 0:T.uuid,id:w==null?void 0:w.value.uuid,class:s.class,style:s.style},(O=r.default)==null?void 0:O.call(r))])]):E.value=u.createVNode("div",{key:(N=c.value)==null?void 0:N.uuid,id:w==null?void 0:w.value.uuid,style:X.value},(K=r.default)==null?void 0:K.call(r)),u.render(E.value,D.value)}}),u.watchEffect(()=>{g!=null&&g.value&&(D.value.className=g.value)});const ce=u.ref(!0),{onBeforeRender:le}=H.useLoop();le(({invalidate:V})=>{var U,B,R,T,O,N,K;if(V(),i.value&&S.value&&P.value){(U=S.value)==null||U.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const W=m.value?z.value:Rs(i.value,S.value,{width:I.width.value||0,height:I.height.value||0});if(m.value||Math.abs(G.value-S.value.zoom)>y.value||Math.abs(z.value[0]-W[0])>y.value||Math.abs(z.value[1]-W[1])>y.value||Math.abs(z.value[2]-W[2])>y.value){const Y=Hh(i.value,S.value);let Q=!1;te.value&&(Array.isArray(L==null?void 0:L.value)?Q=L==null?void 0:L.value:(L==null?void 0:L.value)!=="blending"&&(Q=[w.value]));const re=ce.value;if(Q){const F=$h(i.value,S.value,x.value,Q);ce.value=F&&!Y}else ce.value=!Y;re!==ce.value&&(o("onOcclude",!ce.value),D.value.style.display=ce.value?"block":"none");const se=Math.floor(M.value[0]/2),j=L!=null&&L.value?te.value?[M.value[0],se]:[se-1,0]:M.value;if(D.value.style.zIndex=`${tf(i.value,S.value,j)}`,m.value){const[F,ie]=[I.width.value/2,I.height.value/2],he=S.value.projectionMatrix.elements[5]*ie,{isOrthographicCamera:_e,top:Le,left:Pe,bottom:Je,right:wt}=S.value,It=nf(S.value.matrixWorldInverse),st=_e?`scale(${he})translate(${No(-(wt+Pe)/2)}px,${No((Le+Je)/2)}px)`:`translateZ(${he}px)`;let Ee=i.value.matrixWorld;if(C.value&&(Ee=S.value.matrixWorldInverse.clone().transpose().copyPosition(Ee).scale(i.value.scale),Ee.elements[3]=Ee.elements[7]=Ee.elements[11]=0,Ee.elements[15]=1),D.value.style.width=`${I.width.value}px`,D.value.style.height=`${I.height.value}px`,D.value.style.perspective=_e?"":`${he}px`,(B=E.value)!=null&&B.el&&((R=E.value)!=null&&R.children)&&Array.isArray(E.value.children)){E.value.el.style.transform=`${st}${It}translate(${F}px,${ie}px)`;const it=E.value.children[0];it&&it.el&&(it.el.style.transform=of(Ee,1/(((v==null?void 0:v.value)||10)/400)))}}else{const F=(v==null?void 0:v.value)===void 0?1:ef(i.value,S.value)*(v==null?void 0:v.value);D.value.style.transform=`translate3d(${W[0]}px,${W[1]}px,0) scale(${F})`}}z.value=W,G.value=S.value.zoom}if(!te.value&&c.value&&!ee.value)if(m.value){if((T=E.value)!=null&&T.el&&((O=E.value)!=null&&O.children)){const W=((N=E.value)==null?void 0:N.children)[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const{isOrthographicCamera:Y}=S.value;if(Y||h)s.scale&&(Array.isArray(s.scale)?s.scale instanceof l.Vector3?c.value.scale.copy(s.scale.clone().divideScalar(1)):c.value.scale.set(1/s.scale[0],1/s.scale[1],1/s.scale[2]):c.value.scale.setScalar(1/s.scale));else{const Q=((v==null?void 0:v.value)||10)/400,re=W.clientWidth*Q,se=W.clientHeight*Q;c.value.scale.set(re,se,1)}ee.value=!0}}}else{const W=D.value.children[0];if(W!=null&&W.clientWidth&&(W!=null&&W.clientHeight)){const Q=W.clientWidth*1,re=W.clientHeight*1;c.value.scale.set(Q,re,1),ee.value=!0}q.value.lookAt((K=S.value)==null?void 0:K.position)}});const de=u.computed(()=>({vertexShader:m.value?void 0:Qh,fragmentShader:qh})),k=u.computed(()=>{const V=de.value;return p.value||new l.ShaderMaterial({vertexShader:V.vertexShader,fragmentShader:V.fragmentShader,side:l.DoubleSide})});return u.onUnmounted(()=>{k.value&&k.value.dispose(),D.value.remove()}),e({instance:i}),(V,U)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[u.unref(L)&&!te.value?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:c,geometry:u.unref(h),material:k.value},null,8,rf)):u.createCommentVNode("",!0)],512))}});var Dn={exports:{}},af=Dn.exports,Ws;function lf(){return Ws||(Ws=1,function(a,e){(function(t,n){a.exports=n()})(af,function(){var t=function(){function n(d){return s.appendChild(d.dom),d}function o(d){for(var g=0;g<s.children.length;g++)s.children[g].style.display=g===d?"block":"none";r=d}var r=0,s=document.createElement("div");s.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.addEventListener("click",function(d){d.preventDefault(),o(++r%s.children.length)},!1);var i=(performance||Date).now(),c=i,h=0,p=n(new t.Panel("FPS","#0ff","#002")),f=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return o(0),{REVISION:16,dom:s,addPanel:n,showPanel:o,begin:function(){i=(performance||Date).now()},end:function(){h++;var d=(performance||Date).now();if(f.update(d-i,200),d>c+1e3&&(p.update(1e3*h/(d-c),100),c=d,h=0,m)){var g=performance.memory;m.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:s,setMode:o}};return t.Panel=function(n,o,r){var s=1/0,i=0,c=Math.round,h=c(window.devicePixelRatio||1),p=80*h,f=48*h,m=3*h,d=2*h,g=3*h,y=15*h,v=74*h,_=30*h,A=document.createElement("canvas");A.width=p,A.height=f,A.style.cssText="width:80px;height:48px";var b=A.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=r,b.fillRect(0,0,p,f),b.fillStyle=o,b.fillText(n,m,d),b.fillRect(g,y,v,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g,y,v,_),{dom:A,update:function(C,L){s=Math.min(s,C),i=Math.max(i,C),b.fillStyle=r,b.globalAlpha=1,b.fillRect(0,0,p,y),b.fillStyle=o,b.fillText(c(C)+" "+n+" ("+c(s)+"-"+c(i)+")",m,d),b.drawImage(A,g+h,y,v-h,_,g,y,v-h,_),b.fillRect(g+v-h,y,h,_),b.fillStyle=r,b.globalAlpha=.9,b.fillRect(g+v-h,y,h,c((1-C/L)*_))}}},t})}(Dn)),Dn.exports}var cf=lf();const uf=on(cf),hf=u.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(a,{expose:e}){const t=new uf;e({instance:t});const n=document.body;t.showPanel(a.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeRender:o,onAfterRender:r}=H.useLoop();o(()=>t.begin(),Number.NEGATIVE_INFINITY),r(()=>t.end(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class ff{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.gradient=null,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width="90px",this.canvas.style.height="48px",this.canvas.style.position="absolute",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.initializeCanvas()}createGradient(){if(!this.context)throw new Error("No context");const e=this.context.createLinearGradient(0,this.GRAPH_Y,0,this.GRAPH_Y+this.GRAPH_HEIGHT);let t;const n=this.fg;switch(this.fg.toLowerCase()){case"#0ff":t="#006666";break;case"#0f0":t="#006600";break;case"#ff0":t="#666600";break;case"#e1e1e1":t="#666666";break;default:t=this.bg;break}return e.addColorStop(0,t),e.addColorStop(1,n),e}initializeCanvas(){this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.gradient=this.createGradient(),this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillStyle=this.fg,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,o,r=0){if(!this.context||!this.gradient)return;const s=Math.min(1/0,e),i=Math.max(n,e);o=Math.max(o,t),this.context.globalAlpha=1,this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(`${e.toFixed(r)} ${this.name} (${s.toFixed(r)}-${parseFloat(i.toFixed(r))})`,this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT);const c=this.GRAPH_HEIGHT-(1-t/o)*this.GRAPH_HEIGHT;c>0&&(this.context.globalAlpha=1,this.context.fillStyle=this.gradient,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y+this.GRAPH_HEIGHT-c,this.PR,c))}}const Ys=class Wt{constructor({trackGPU:e=!1,logsPerSecond:t=30,samplesLog:n=60,samplesGraph:o=10,precision:r=2,minimal:s=!1,horizontal:i=!0,mode:c=0}={}){this.gl=null,this.ext=null,this.activeQuery=null,this.gpuQueries=[],this.threeRendererPatched=!1,this.frames=0,this.renderCount=0,this.isRunningCPUProfiling=!1,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalGpuDurationCompute=0,this.totalFps=0,this.gpuPanel=null,this.gpuPanelCompute=null,this.averageFps={logs:[],graph:[]},this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.averageGpuCompute={logs:[],graph:[]},this.handleClick=h=>{h.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},this.handleResize=()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)},this.mode=c,this.horizontal=i,this.minimal=s,this.trackGPU=e,this.samplesLog=n,this.samplesGraph=o,this.precision=r,this.logsPerSecond=t,this.dom=document.createElement("div"),this.initializeDOM(),this.beginTime=performance.now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.fpsPanel=this.addPanel(new Wt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new Wt.Panel("CPU","#0f0","#020"),1),this.setupEventListeners()}initializeDOM(){this.dom.style.cssText=`
|
|
1480
1480
|
position: fixed;
|
|
1481
1481
|
top: 0;
|
|
1482
1482
|
left: 0;
|
|
1483
1483
|
opacity: 0.9;
|
|
1484
1484
|
z-index: 10000;
|
|
1485
1485
|
${this.minimal?"cursor: pointer;":""}
|
|
1486
|
-
`}setupEventListeners(){this.minimal?(this.dom.addEventListener("click",this.handleClick),this.showPanel(this.mode)):window.addEventListener("resize",this.handleResize)}async init(e){if(!e){console.error('Stats: The "canvas" parameter is undefined.');return}this.handleThreeRenderer(e)||await this.handleWebGPURenderer(e)||this.initializeWebGL(e)}handleThreeRenderer(e){return e.isWebGLRenderer&&!this.threeRendererPatched?(this.patchThreeRenderer(e),this.gl=e.getContext(),this.trackGPU&&this.initializeGPUTracking(),!0):!1}async handleWebGPURenderer(e){return e.isWebGPURenderer?(this.trackGPU&&(e.backend.trackTimestamp=!0,await e.hasFeatureAsync("timestamp-query")&&this.initializeWebGPUPanels()),this.info=e.info,!0):!1}initializeWebGPUPanels(){this.gpuPanel=this.addPanel(new Wt.Panel("GPU","#ff0","#220"),2),this.gpuPanelCompute=this.addPanel(new Wt.Panel("CPT","#e1e1e1","#212121"),3)}initializeWebGL(e){if(e instanceof WebGL2RenderingContext)this.gl=e;else if(e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas){if(this.gl=e.getContext("webgl2"),!this.gl)return console.error("Stats: Unable to obtain WebGL2 context."),!1}else return console.error("Stats: Invalid input type. Expected WebGL2RenderingContext, HTMLCanvasElement, or OffscreenCanvas."),!1;return!0}initializeGPUTracking(){this.gl&&(this.ext=this.gl.getExtension("EXT_disjoint_timer_query_webgl2"),this.ext&&(this.gpuPanel=this.addPanel(new Wt.Panel("GPU","#ff0","#220"),2)))}begin(){this.isRunningCPUProfiling||this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)&&(this.activeQuery&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.activeQuery=this.gl.createQuery(),this.activeQuery&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.activeQuery))}end(){this.renderCount++,this.gl&&this.ext&&this.activeQuery&&(this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.gpuQueries.push({query:this.activeQuery}),this.activeQuery=null)}update(){this.info?this.processWebGPUTimestamps():this.processGpuQueries(),this.endProfiling("cpu-started","cpu-finished","cpu-duration"),this.updateAverages(),this.resetCounters()}processWebGPUTimestamps(){this.totalGpuDuration=this.info.render.timestamp,this.totalGpuDurationCompute=this.info.compute.timestamp,this.addToAverage(this.totalGpuDurationCompute,this.averageGpuCompute)}updateAverages(){this.addToAverage(this.totalCpuDuration,this.averageCpu),this.addToAverage(this.totalGpuDuration,this.averageGpu)}resetCounters(){this.renderCount=0,this.totalCpuDuration===0&&this.beginProfiling("cpu-started"),this.totalCpuDuration=0,this.totalFps=0,this.beginTime=this.endInternal()}resizePanel(e,t){e.canvas.style.position="absolute",this.minimal?e.canvas.style.display="none":(e.canvas.style.display="block",this.horizontal?(e.canvas.style.top="0px",e.canvas.style.left=t*e.WIDTH/e.PR+"px"):(e.canvas.style.left="0px",e.canvas.style.top=t*e.HEIGHT/e.PR+"px"))}addPanel(e,t){return e.canvas&&(this.dom.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t<this.dom.children.length;t++){const n=this.dom.children[t];n.style.display=t===e?"block":"none"}this.mode=e}processGpuQueries(){!this.gl||!this.ext||(this.totalGpuDuration=0,this.gpuQueries.forEach((e,t)=>{if(this.gl){const n=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT_AVAILABLE),o=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(n&&!o){const s=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT)*1e-6;this.totalGpuDuration+=s,this.gl.deleteQuery(e.query),this.gpuQueries.splice(t,1)}}}))}endInternal(){this.frames++;const e=(performance||Date).now(),t=e-this.prevTime;if(e>=this.prevCpuTime+1e3/this.logsPerSecond){const n=Math.round(this.frames*1e3/t);this.addToAverage(n,this.averageFps),this.updatePanel(this.fpsPanel,this.averageFps,0),this.updatePanel(this.msPanel,this.averageCpu,this.precision),this.updatePanel(this.gpuPanel,this.averageGpu,this.precision),this.gpuPanelCompute&&this.updatePanel(this.gpuPanelCompute,this.averageGpuCompute),this.frames=0,this.prevCpuTime=e,this.prevTime=e}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&(window.performance.mark(e),this.isRunningCPUProfiling=!0)}endProfiling(e,t,n){if(window.performance&&t&&this.isRunningCPUProfiling){window.performance.mark(t);const o=performance.measure(n,e,t);this.totalCpuDuration+=o.duration,this.isRunningCPUProfiling=!1}}updatePanel(e,t,n=2){if(t.logs.length>0){let o=0,r=.01;for(let c=0;c<t.logs.length;c++)o+=t.logs[c],t.logs[c]>r&&(r=t.logs[c]);let s=0,i=.01;for(let c=0;c<t.graph.length;c++)s+=t.graph[c],t.graph[c]>i&&(i=t.graph[c]);e&&e.update(o/Math.min(t.logs.length,this.samplesLog),s/Math.min(t.graph.length,this.samplesGraph),r,i,n)}}get domElement(){return this.dom}patchThreeRenderer(e){const t=e.render,n=this;e.render=function(o,r){n.begin(),t.call(this,o,r),n.end()},this.threeRendererPatched=!0}};Ys.Panel=ff;let df=Ys;const pf=u.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],setup(a,{expose:e}){const t=new df({logsPerSecond:a.logsPerSecond,samplesLog:a.samplesLog,samplesGraph:a.samplesGraph,precision:a.precision,horizontal:a.horizontal,minimal:a.minimal,mode:a.mode});e({instance:t});const n=document.body,o=t.dom||t.container;n==null||n.appendChild(o);const{renderer:r}=H.useTresContext(),{onAfterRender:s}=H.useLoop();t.init(r.value),s(()=>t.update(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(o)})}}),{logError:mf}=H.useLogger();async function gf(a,e){const t=new Wn,n=(e==null?void 0:e.fileName)||"scene";t.parse(a,o=>{if(o instanceof ArrayBuffer)_f(o,`${n}.glb`);else{const r=JSON.stringify(o,null,2);yf(r,`${n}.gltf`)}},o=>{mf("An error happened while exporting the GLTF",o)},e)}function yf(a,e){Xs(new Blob([a],{type:"text/plain"}),e)}function _f(a,e){Xs(new Blob([a],{type:"application/octet-stream"}),e)}function Xs(a,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(a),t.download=e,t.click(),t.remove()}const vf=["args"],xf=["color"],wf=u.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext(),{args:o,color:r}=u.toRefs(t);u.watch(o,()=>n());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"boxRef",ref:s},i.$attrs),[u.createElementVNode("TresBoxGeometry",{args:u.unref(o)},null,8,vf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,xf)])],16))}}),bf=["object"],Es=u.defineComponent({__name:"Line2",props:{points:{},vertexColors:{default:null},color:{default:"white"},lineWidth:{default:1},worldUnits:{type:Boolean,default:!1},alphaToCoverage:{type:Boolean,default:!1},dashed:{type:Boolean,default:!1},dashSize:{default:1},gapSize:{default:1},dashScale:{default:1},dashOffset:{default:0}},setup(a,{expose:e}){const t=a;function n(d,g){if(!d||d.length===0)return Array.from({length:g}).fill(H.normalizeColor(t.color));if(d.length===1)return Array.from({length:g}).fill(H.normalizeColor(d[0]));if(d.length===g)return d.map(H.normalizeColor);const y=g-1,v=d.map(H.normalizeColor);closed&&v.push(v[0].clone());const _=[v[0]],A=y/(v.length-1);for(let b=1;b<y;b++){const C=b%A/A,L=Math.floor(b/A);_.push(v[L].clone().lerp(v[L+1],C))}return _.push(v[v.length-1]),_}const o=new co,r=new jr,s=new xc(r,o),{sizes:i,invalidate:c}=H.useTresContext(),h=u.computed(()=>Array.isArray(t.vertexColors));function p(d,g){d.color=H.normalizeColor(g.color),d.linewidth=g.lineWidth,d.alphaToCoverage=g.alphaToCoverage,d.worldUnits=g.worldUnits,d.vertexColors=Array.isArray(g.vertexColors),d.dashed=g.dashed,d.dashScale=g.dashScale,d.dashSize=g.dashSize,d.dashOffset=g.dashOffset,d.gapSize=g.gapSize,d.needsUpdate=!0}function f(d,g,y){const v=g.map(A=>A instanceof l.Vector3?[A.x,A.y,A.z]:A instanceof l.Vector2?[A.x,A.y,0]:Array.isArray(A)&&A.length===2?[A[0],A[1],0]:A).flat();d.setPositions(v.flat());const _=n(y,g.length).map(A=>A.toArray()).flat();d.setColors(_),s.computeLineDistances()}p(o,t),f(r,t.points,t.vertexColors),s.computeLineDistances(),u.watch(()=>[t.color,t.lineWidth,t.alphaToCoverage,t.worldUnits,h,t.dashed,t.dashScale,t.dashSize,t.dashOffset],()=>{p(o,t),c()}),u.watch(()=>[t.points,t.vertexColors],()=>{f(r,t.points,t.vertexColors),c()}),u.watch(()=>[i.height,i.width],()=>{o.resolution=new l.Vector2(i.width.value,i.height.value),c()}),u.onUnmounted(()=>{r.dispose(),o.dispose()});const m=u.shallowRef();return e({instance:m}),(d,g)=>(u.openBlock(),u.createElementBlock("primitive",{ref:m.value,object:u.unref(s)},null,8,bf))}}),Mf=u.defineComponent({__name:"CatmullRomCurve3",props:{segments:{default:20},closed:{type:Boolean,default:!1},curveType:{default:"centripetal"},tension:{default:.5},points:{},vertexColors:{},color:{},lineWidth:{},alphaToCoverage:{type:Boolean},dashed:{type:Boolean},dashSize:{},dashScale:{},dashOffset:{},gapSize:{},worldUnits:{type:Boolean}},setup(a,{expose:e}){const t=a;function n(c,h,p,f){const m=c.map(d=>d instanceof l.Vector3?d:new l.Vector3(...d));return new l.CatmullRomCurve3(m,h,p,f)}function o(c,h){return c.getPoints(h)}const r=u.computed(()=>n(t.points,t.closed,t.curveType,t.tension)),s=u.computed(()=>o(r.value,t.segments)),i=u.shallowRef();return e({instance:i}),(c,h)=>(u.openBlock(),u.createBlock(Es,{ref:i.value,points:s.value,"vertex-colors":t.vertexColors,color:t.color,"line-width":t.lineWidth,"alpha-to-coverage":t.alphaToCoverage,dashed:t.dashed,"dash-size":t.dashSize,"dash-scale":t.dashScale,"dash-offset":t.dashOffset,"gap-size":t.gapSize,"world-units":t.worldUnits},null,8,["points","vertex-colors","color","line-width","alpha-to-coverage","dashed","dash-size","dash-scale","dash-offset","gap-size","world-units"]))}}),Sf=["args"],Af=["color"],Pf=u.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"circleRef",ref:s},i.$attrs),[u.createElementVNode("TresCircleGeometry",{args:u.unref(n)},null,8,Sf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Af)])],16))}}),Cf=["args"],Tf=["color"],If=u.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"coneRef",ref:s},i.$attrs),[u.createElementVNode("TresConeGeometry",{args:u.unref(n)},null,8,Cf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Tf)])],16))}}),Of=["args"],Lf=["color"],Df=u.defineComponent({__name:"Cylinder",props:{args:{default:()=>[1,1,1,32,1,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"cylinderRef",ref:s},i.$attrs),[u.createElementVNode("TresCylinderGeometry",{args:u.unref(n)},null,8,Of),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Lf)])],16))}}),kf=["args"],Bf=["color"],Uf=u.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),r=u.shallowRef(),{invalidate:s}=H.useTresContext();return u.watch(n,()=>s()),e({instance:r}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"dodecahedronRef",ref:r},i.$attrs),[u.createElementVNode("TresDodecahedronGeometry",{args:u.unref(n)},null,8,kf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Bf)])],16))}}),Nf=["args"],Ff=["color"],zf=u.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"icosahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresIcosahedronGeometry",{args:u.unref(n)},null,8,Nf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Ff)])],16))}}),Vf=["args"],Gf=["color"],Rf=u.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"octahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresOctahedronGeometry",{args:u.unref(n)},null,8,Vf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Gf)])],16))}}),jf=["rotation"],Wf=["args"],Yf=["color"],Xf=u.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"planeRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[u.createElementVNode("TresPlaneGeometry",{args:u.unref(n)},null,8,Wf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Yf)])],16,jf))}}),Ef=["args"],Zf=["color"],Kf=u.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"ringRef",ref:s},i.$attrs),[u.createElementVNode("TresRingGeometry",{args:u.unref(n)},null,8,Ef),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Zf)])],16))}}),qf=["args"],Qf=["color"],Jf=u.defineComponent({__name:"RoundedBox",props:{args:{default:()=>[1,1,1,2,.1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r,extend:s}=H.useTresContext();s({RoundedBoxGeometry:Rl}),u.watch(n,()=>r());const i=u.shallowRef();return e({instance:i}),(c,h)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"roundedBoxRef",ref:i},[u.createElementVNode("TresRoundedBoxGeometry",{args:u.unref(n)},null,8,qf),u.renderSlot(c.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Qf)])],512))}}),Hf=["args"],$f=["color"],ed=u.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"sphereRef",ref:s},i.$attrs),[u.createElementVNode("TresSphereGeometry",{args:u.unref(n)},null,8,Hf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,$f)])],16))}}),td=["geometry"],nd=["color"],od=u.defineComponent({__name:"Superformula",props:{widthSegments:{default:32},heightSegments:{default:32},numArmsA:{default:4},expA:{default:()=>[40,1.3,.9]},numArmsB:{default:4},expB:{default:()=>[40,1.3,.9]},color:{default:"white"}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext(),{cos:o,sin:r,abs:s}=Math,i=u.shallowRef(),c=u.shallowRef(t.color);function h(d,g){const y=new l.BufferGeometry,v=d*g,_=new Float32Array(Array.from({length:3*v}).fill(0)),A=new Float32Array(Array.from({length:3*v}).fill(0)),b=[];for(let C=0;C<g-1;C++){for(let S=0;S<d-1;S++){const x=C*d+S,I=x+1,D=x+d,z=I+d;b.push(x,D,I),b.push(D,z,I)}const L=C*d+d-1,M=C*d,P=L+d,w=M+d;b.push(L,P,M),b.push(P,w,M)}return y.setIndex(b),y.setAttribute("position",new l.BufferAttribute(_,3)),y.setAttribute("normal",new l.BufferAttribute(A,3)),y}function p(d,g,y,v,_){return(s(o(g*d*.25))**v+s(r(g*d*.25))**_)**(-1/y)}function f(d,g,y,v,_,A,b,C,L,M,P){const w=2*Math.PI/M,S=-Math.PI,x=Math.PI/(P-1),I=-.5*Math.PI,D=d.getAttribute("position");let z=0,G=0,X=I;for(let E=0;E<P;E++){G=S;for(let te=0;te<M;te++){const q=p(G,g,y,v,_),oe=p(X,A,b,C,L);D.setXYZ(z,q*o(G)*oe*o(X),oe*r(X),q*r(G)*oe*o(X)),z++,G+=w}X+=x}D.needsUpdate=!0,d.computeVertexNormals()}u.watch(()=>t.color,()=>c.value=t.color),u.watch(()=>[t.widthSegments,t.heightSegments],()=>{i.value&&i.value.dispose(),i.value=h(t.widthSegments,t.heightSegments),n()},{immediate:!0}),u.watch(()=>[t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2]],()=>{f(i.value,t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2],t.widthSegments,t.heightSegments),n()},{immediate:!0}),u.onUnmounted(()=>{i.value&&i.value.dispose()});const m=u.shallowRef();return e({instance:m}),(d,g)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"superformulaRef",ref:m},d.$attrs,{geometry:i.value}),[u.renderSlot(d.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:c.value},null,8,nd)])],16,td))}}),rd=["rotation"],sd=["args"],id=["color"],ad=u.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),r=u.shallowRef();return e({instance:r}),(s,i)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tetrahedronRef",ref:r,rotation:[-Math.PI/2,0,0]},s.$attrs),[u.createElementVNode("TresTetrahedronGeometry",{args:u.unref(n)},null,8,sd),u.renderSlot(s.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,id)])],16,rd))}}),ld=["args"],cd=["color"],ud=u.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusGeometry",{args:u.unref(n)},null,8,ld),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,cd)])],16))}}),hd=["args"],fd=["color"],dd=u.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusKnotRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusKnotGeometry",{args:u.unref(n)},null,8,hd),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,fd)])],16))}}),pd=["args"],md=["color"],gd=u.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tubeRef",ref:s},i.$attrs),[u.createElementVNode("TresTubeGeometry",{args:u.unref(n)},null,8,pd),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,md)])],16))}}),yd=u.defineComponent({__name:"Align",props:{top:{type:Boolean},right:{type:Boolean},bottom:{type:Boolean},left:{type:Boolean},front:{type:Boolean},back:{type:Boolean},disable:{type:Boolean},disableX:{type:Boolean},disableY:{type:Boolean},disableZ:{type:Boolean},precise:{type:Boolean,default:!0},onAlign:{},cacheKey:{default:void 0}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),o=u.shallowRef(),r=u.shallowRef(),s=new l.Box3,i=new l.Vector3,c=new l.Sphere;function h(){if(!o.value||!r.value||!n.value)return;o.value.matrixWorld.identity(),s.setFromObject(r.value,t.precise);const d=s.max.x-s.min.x,g=s.max.y-s.min.y,y=s.max.z-s.min.z;s.getCenter(i),s.getBoundingSphere(c);const v=t.top?g/2:t.bottom?-g/2:0,_=t.left?-d/2:t.right?d/2:0,A=t.front?y/2:t.back?-y/2:0;o.value.position.set(t.disable||t.disableX?0:-i.x+_,t.disable||t.disableY?0:-i.y+v,t.disable||t.disableZ?0:-i.z+A),typeof t.onAlign<"u"&&t.onAlign({parent:n.value.parent,container:n.value,width:d,height:g,depth:y,boundingBox:s,boundingSphere:c,center:i,verticalAlignment:v,horizontalAlignment:_,depthAlignment:A})}let p=null,f=null;const m=H.useLoop();return u.watchEffect(()=>{p==null||p(),p=null;const d=u.toValue(t.cacheKey);d===f&&f!==null&&f!==void 0||(f=d,t.cacheKey===null||t.cacheKey===void 0?p=m.onBeforeRender(()=>{h()}).off:h())}),e({instance:n,update:h}),(d,g)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"ref",ref:n},[u.createElementVNode("TresGroup",{ref_key:"outer",ref:o},[u.createElementVNode("TresGroup",{ref_key:"inner",ref:r},[u.renderSlot(d.$slots,"default")],512)],512)],512))}}),_d=["receive-shadow","rotation"],vd=["args"],xd=u.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=h=>h===0?0:2**(10*h-10),{floor:o,segments:r,receiveShadow:s}=u.toRefs(t),i=u.ref(null);u.watch([r,o,i],([h,p,f])=>{if(!f||h===null)return;let m=0;const d=h/h/2,g=f.attributes.position;for(let y=0;y<h+1;y++)for(let v=0;v<h+1;v++)g.setXYZ(m++,y/h-d+(y===0?-p:0),v/h-d,n(y/h));g.needsUpdate=!0,f.computeVertexNormals()});const c=u.shallowRef();return e({instance:c}),(h,p)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"backdropRef",ref:c},h.$attrs),[u.createElementVNode("TresMesh",{"receive-shadow":u.unref(s),rotation:[-Math.PI/2,0,Math.PI/2]},[u.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,u.unref(r),u.unref(r)]},null,8,vd),u.renderSlot(h.$slots,"default",{},()=>[p[0]||(p[0]=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1))])],8,_d)],16))}}),wd=["object"],bd=u.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},blur:{default:1},color:{default:"#000000"},tint:{default:void 0},scale:{default:10},width:{default:1},height:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:Number.POSITIVE_INFINITY},depthWrite:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a;function n(d,g,y){y.blurPlane.visible=!0,y.blurPlane.material=y.horizontalBlurMaterial,y.horizontalBlurMaterial.uniforms.tDiffuse.value=y.renderTarget.texture,y.horizontalBlurMaterial.uniforms.h.value=d/256,g.setRenderTarget(y.renderTargetBlur),g.render(y.blurPlane,y.shadowCamera),y.blurPlane.material=y.verticalBlurMaterial,y.verticalBlurMaterial.uniforms.tDiffuse.value=y.renderTargetBlur.texture,y.verticalBlurMaterial.uniforms.v.value=d/256,g.setRenderTarget(y.renderTarget),g.render(y.blurPlane,y.shadowCamera),y.blurPlane.visible=!1}function o(d,g,y,v){const{renderTarget:_,shadowCamera:A,depthMaterial:b}=v,C=g.background;g.background=null,g.overrideMaterial=b;const L=y.getClearAlpha();y.setClearAlpha(0),y.setRenderTarget(_),y.render(g,A),g.overrideMaterial=null,n(d.blur,y,v),d.smooth&&n(d.blur*.4,y,v),y.setRenderTarget(null),y.setClearAlpha(L),g.background=C}function r(d){const g=new l.Group,y=new l.WebGLRenderTarget(d.resolution,d.resolution);y.texture.generateMipmaps=!1;const v=new l.WebGLRenderTarget(d.resolution,d.resolution);v.texture.generateMipmaps=!1;const _=new l.PlaneGeometry(d.width,d.height).rotateX(Math.PI/2),A=new l.MeshBasicMaterial({map:y.texture,opacity:d.opacity,transparent:!0,depthWrite:d.depthWrite,color:new l.Color(d.color??"black")}),b=new l.Mesh(_,A);g.add(b),b.scale.y=-1;const C=new l.Mesh(_);C.visible=!1,g.add(C);const L=new l.OrthographicCamera(-d.width/2,d.width/2,d.height/2,-d.height/2,0,.3);L.rotation.x=Math.PI/2,g.add(L);const M=new l.MeshDepthMaterial,P=new l.ShaderMaterial(jl);P.depthTest=!1;const w=new l.ShaderMaterial(Wl);return w.depthTest=!1,{renderTarget:y,renderTargetBlur:v,shadowCamera:L,depthMaterial:M,horizontalBlurMaterial:P,verticalBlurMaterial:w,shadowGroup:g,plane:b,blurPlane:C}}function s(d,g){const y=g.shadowCamera;y.left=-d.width/2,y.right=d.width/2,y.top=d.height/2,y.bottom=-d.height/2,y.far=d.far;const v=d.width*(Array.isArray(d.scale)?d.scale[0]:d.scale||1),_=d.height*(Array.isArray(d.scale)?d.scale[1]:d.scale||1);g.shadowGroup.scale.set(v,d.far,_)}function i(d,g){g.renderTarget.dispose(),g.renderTargetBlur.dispose(),g.renderTarget=new l.WebGLRenderTarget(d,d),g.renderTarget.texture.generateMipmaps=!1,g.renderTargetBlur=new l.WebGLRenderTarget(d,d),g.renderTargetBlur.texture.generateMipmaps=!1,g.plane.material.map=g.renderTarget.texture}function c(d,g){g.plane.material.color=new l.Color(d.color??"black"),g.depthMaterial.dispose(),g.depthMaterial=new l.MeshDepthMaterial,g.depthMaterial.onBeforeCompile=function(y){const v=d.tint?new l.Color(d.tint):new l.Color("white"),{r:_,g:A,b}=v,C=y.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",`gl_FragColor = vec4( ${_}, ${A}, ${b}, ( 1.0 - fragCoordZ ) * opacity);`);y.fragmentShader=C}}const{onBeforeRender:h}=H.useLoop(),p=r(t);let f=0;const m=()=>f=f>=t.frames?t.frames-1:f;return h(({renderer:d,scene:g,invalidate:y})=>{f<t.frames&&(f++,o(t,g,d,p),y())}),u.watch(()=>[t.opacity,t.depthWrite,t.blur,t.smooth],()=>{p.plane.material.opacity=t.opacity??1,p.plane.material.depthWrite=t.depthWrite??!1,m()},{immediate:!0}),u.watch(()=>[t.color,t.tint],()=>{c(t,p),m()},{immediate:!0}),u.watch(()=>[t.resolution],()=>{i(t.resolution,p),m()}),u.watch(()=>[t.width,t.height,t.scale,t.far],()=>{s(t,p),m()},{immediate:!0}),u.onUnmounted(()=>{for(const d of Object.values(p))d&&"dispose"in d&&typeof d.dispose=="function"&&d.dispose()}),e({instance:p.shadowGroup}),(d,g)=>(u.openBlock(),u.createElementBlock("primitive",{object:u.unref(p).shadowGroup},null,8,wd))}}),Md=u.defineComponent({__name:"Fit",props:{into:{default:()=>new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5))},precise:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext(),o=u.shallowRef(new l.Group),r=u.shallowRef(new l.Group);function s(h,p){if(o.value.position.set(0,0,0),o.value.updateMatrixWorld(),r.value.scale.set(1,1,1),r.value.updateMatrixWorld(),!r.value.children.length||h===null)return;const{box3:f,use:m}=i(h,p),d=new l.Box3;r.value.children.forEach(A=>d.expandByObject(A,p));const g=d.getSize(new l.Vector3),y=f.getSize(new l.Vector3),v=Math.min(y.x/g.x,y.y/g.y,y.z/g.z);r.value.scale.setScalar(v===Number.POSITIVE_INFINITY?1:v),r.value.updateMatrixWorld();const _=o.value.worldToLocal(d.getCenter(new l.Vector3));if(m.position){const A=o.value.worldToLocal(f.getCenter(new l.Vector3));o.value.position.copy(A.sub(_.multiplyScalar(v)))}else o.value.position.copy(_.sub(_.multiplyScalar(v)));n()}function i(h,p){return typeof h=="number"?h=new l.Vector3(h,h,h):Array.isArray(h)&&(h=new l.Vector3(...h)),h&&"isVector3"in h&&h.isVector3?{box3:new l.Box3(new l.Vector3(0,0,0),h),use:{position:!1}}:h&&"isBox3"in h&&h.isBox3?{box3:h,use:{position:!0}}:h&&"isObject3D"in h&&h.isObject3D?{box3:new l.Box3().setFromObject(h,p??!1),use:{position:!0}}:{box3:new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),use:{position:!0}}}u.watch(()=>[t.into,t.precise],()=>s(t.into,t.precise)),u.onMounted(()=>{s(t.into,t.precise),u.nextTick().then(()=>{s(t.into,t.precise)})});const c=u.shallowRef();return e({instance:c,fit:(h=new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),p=!1)=>{s(h,p)},update:()=>s(t.into,t.precise)}),(h,p)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outer",ref:c},[u.createElementVNode("TresGroup",{ref_key:"middle",ref:o},[u.createElementVNode("TresGroup",{ref_key:"inner",ref:r},[u.renderSlot(h.$slots,"default")],512)],512)],512))}}),Sd=["side","cell-size","section-size","cell-color","section-color","cell-thickness","section-thickness","fade-distance","fade-strength","fade-from","infinite-grid","follow-camera"],Ad=["args"],Pd=u.defineComponent({__name:"Grid",props:{cellSize:{default:.5},cellThickness:{default:.5},cellColor:{default:"#000000"},sectionSize:{default:1},sectionThickness:{default:1},sectionColor:{default:"#0000ff"},followCamera:{type:Boolean,default:!1},infiniteGrid:{type:Boolean,default:!1},fadeDistance:{default:100},fadeStrength:{default:1},fadeFrom:{default:1},side:{default:l.BackSide},args:{}},setup(a){const e=a,t=Vn({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:new l.Color,sectionColor:new l.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new l.Vector3,worldPlanePosition:new l.Vector3},`
|
|
1486
|
+
`}setupEventListeners(){this.minimal?(this.dom.addEventListener("click",this.handleClick),this.showPanel(this.mode)):window.addEventListener("resize",this.handleResize)}async init(e){if(!e){console.error('Stats: The "canvas" parameter is undefined.');return}this.handleThreeRenderer(e)||await this.handleWebGPURenderer(e)||this.initializeWebGL(e)}handleThreeRenderer(e){return e.isWebGLRenderer&&!this.threeRendererPatched?(this.patchThreeRenderer(e),this.gl=e.getContext(),this.trackGPU&&this.initializeGPUTracking(),!0):!1}async handleWebGPURenderer(e){return e.isWebGPURenderer?(this.trackGPU&&(e.backend.trackTimestamp=!0,await e.hasFeatureAsync("timestamp-query")&&this.initializeWebGPUPanels()),this.info=e.info,!0):!1}initializeWebGPUPanels(){this.gpuPanel=this.addPanel(new Wt.Panel("GPU","#ff0","#220"),2),this.gpuPanelCompute=this.addPanel(new Wt.Panel("CPT","#e1e1e1","#212121"),3)}initializeWebGL(e){if(e instanceof WebGL2RenderingContext)this.gl=e;else if(e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas){if(this.gl=e.getContext("webgl2"),!this.gl)return console.error("Stats: Unable to obtain WebGL2 context."),!1}else return console.error("Stats: Invalid input type. Expected WebGL2RenderingContext, HTMLCanvasElement, or OffscreenCanvas."),!1;return!0}initializeGPUTracking(){this.gl&&(this.ext=this.gl.getExtension("EXT_disjoint_timer_query_webgl2"),this.ext&&(this.gpuPanel=this.addPanel(new Wt.Panel("GPU","#ff0","#220"),2)))}begin(){this.isRunningCPUProfiling||this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)&&(this.activeQuery&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.activeQuery=this.gl.createQuery(),this.activeQuery&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.activeQuery))}end(){this.renderCount++,this.gl&&this.ext&&this.activeQuery&&(this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.gpuQueries.push({query:this.activeQuery}),this.activeQuery=null)}update(){this.info?this.processWebGPUTimestamps():this.processGpuQueries(),this.endProfiling("cpu-started","cpu-finished","cpu-duration"),this.updateAverages(),this.resetCounters()}processWebGPUTimestamps(){this.totalGpuDuration=this.info.render.timestamp,this.totalGpuDurationCompute=this.info.compute.timestamp,this.addToAverage(this.totalGpuDurationCompute,this.averageGpuCompute)}updateAverages(){this.addToAverage(this.totalCpuDuration,this.averageCpu),this.addToAverage(this.totalGpuDuration,this.averageGpu)}resetCounters(){this.renderCount=0,this.totalCpuDuration===0&&this.beginProfiling("cpu-started"),this.totalCpuDuration=0,this.totalFps=0,this.beginTime=this.endInternal()}resizePanel(e,t){e.canvas.style.position="absolute",this.minimal?e.canvas.style.display="none":(e.canvas.style.display="block",this.horizontal?(e.canvas.style.top="0px",e.canvas.style.left=t*e.WIDTH/e.PR+"px"):(e.canvas.style.left="0px",e.canvas.style.top=t*e.HEIGHT/e.PR+"px"))}addPanel(e,t){return e.canvas&&(this.dom.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t<this.dom.children.length;t++){const n=this.dom.children[t];n.style.display=t===e?"block":"none"}this.mode=e}processGpuQueries(){!this.gl||!this.ext||(this.totalGpuDuration=0,this.gpuQueries.forEach((e,t)=>{if(this.gl){const n=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT_AVAILABLE),o=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(n&&!o){const s=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT)*1e-6;this.totalGpuDuration+=s,this.gl.deleteQuery(e.query),this.gpuQueries.splice(t,1)}}}))}endInternal(){this.frames++;const e=(performance||Date).now(),t=e-this.prevTime;if(e>=this.prevCpuTime+1e3/this.logsPerSecond){const n=Math.round(this.frames*1e3/t);this.addToAverage(n,this.averageFps),this.updatePanel(this.fpsPanel,this.averageFps,0),this.updatePanel(this.msPanel,this.averageCpu,this.precision),this.updatePanel(this.gpuPanel,this.averageGpu,this.precision),this.gpuPanelCompute&&this.updatePanel(this.gpuPanelCompute,this.averageGpuCompute),this.frames=0,this.prevCpuTime=e,this.prevTime=e}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&(window.performance.mark(e),this.isRunningCPUProfiling=!0)}endProfiling(e,t,n){if(window.performance&&t&&this.isRunningCPUProfiling){window.performance.mark(t);const o=performance.measure(n,e,t);this.totalCpuDuration+=o.duration,this.isRunningCPUProfiling=!1}}updatePanel(e,t,n=2){if(t.logs.length>0){let o=0,r=.01;for(let c=0;c<t.logs.length;c++)o+=t.logs[c],t.logs[c]>r&&(r=t.logs[c]);let s=0,i=.01;for(let c=0;c<t.graph.length;c++)s+=t.graph[c],t.graph[c]>i&&(i=t.graph[c]);e&&e.update(o/Math.min(t.logs.length,this.samplesLog),s/Math.min(t.graph.length,this.samplesGraph),r,i,n)}}get domElement(){return this.dom}patchThreeRenderer(e){const t=e.render,n=this;e.render=function(o,r){n.begin(),t.call(this,o,r),n.end()},this.threeRendererPatched=!0}};Ys.Panel=ff;let df=Ys;const pf=u.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],setup(a,{expose:e}){const t=new df({logsPerSecond:a.logsPerSecond,samplesLog:a.samplesLog,samplesGraph:a.samplesGraph,precision:a.precision,horizontal:a.horizontal,minimal:a.minimal,mode:a.mode});e({instance:t});const n=document.body,o=t.dom||t.container;n==null||n.appendChild(o);const{renderer:r}=H.useTresContext(),{onAfterRender:s}=H.useLoop();t.init(r.value),s(()=>t.update(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(o)})}}),{logError:mf}=H.useLogger();async function gf(a,e){const t=new Wn,n=(e==null?void 0:e.fileName)||"scene";t.parse(a,o=>{if(o instanceof ArrayBuffer)_f(o,`${n}.glb`);else{const r=JSON.stringify(o,null,2);yf(r,`${n}.gltf`)}},o=>{mf("An error happened while exporting the GLTF",o)},e)}function yf(a,e){Xs(new Blob([a],{type:"text/plain"}),e)}function _f(a,e){Xs(new Blob([a],{type:"application/octet-stream"}),e)}function Xs(a,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(a),t.download=e,t.click(),t.remove()}const vf=["args"],xf=["color"],wf=u.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext(),{args:o,color:r}=u.toRefs(t);u.watch(o,()=>n());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"boxRef",ref:s},i.$attrs),[u.createElementVNode("TresBoxGeometry",{args:u.unref(o)},null,8,vf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,xf)])],16))}}),bf=["object"],Es=u.defineComponent({__name:"Line2",props:{points:{},vertexColors:{default:null},color:{default:"white"},lineWidth:{default:1},worldUnits:{type:Boolean,default:!1},alphaToCoverage:{type:Boolean,default:!1},dashed:{type:Boolean,default:!1},dashSize:{default:1},gapSize:{default:1},dashScale:{default:1},dashOffset:{default:0}},setup(a,{expose:e}){const t=a;function n(d,g){if(!d||d.length===0)return Array.from({length:g}).fill(H.normalizeColor(t.color));if(d.length===1)return Array.from({length:g}).fill(H.normalizeColor(d[0]));if(d.length===g)return d.map(H.normalizeColor);const y=g-1,v=d.map(H.normalizeColor);closed&&v.push(v[0].clone());const _=[v[0]],A=y/(v.length-1);for(let b=1;b<y;b++){const C=b%A/A,L=Math.floor(b/A);_.push(v[L].clone().lerp(v[L+1],C))}return _.push(v[v.length-1]),_}const o=new co,r=new jr,s=new xc(r,o),{sizes:i,invalidate:c}=H.useTresContext(),h=u.computed(()=>Array.isArray(t.vertexColors));function p(d,g){d.color=H.normalizeColor(g.color),d.linewidth=g.lineWidth,d.alphaToCoverage=g.alphaToCoverage,d.worldUnits=g.worldUnits,d.vertexColors=Array.isArray(g.vertexColors),d.dashed=g.dashed,d.dashScale=g.dashScale,d.dashSize=g.dashSize,d.dashOffset=g.dashOffset,d.gapSize=g.gapSize,d.needsUpdate=!0}function f(d,g,y){const v=g.map(A=>A instanceof l.Vector3?[A.x,A.y,A.z]:A instanceof l.Vector2?[A.x,A.y,0]:Array.isArray(A)&&A.length===2?[A[0],A[1],0]:A).flat();d.setPositions(v.flat());const _=n(y,g.length).map(A=>A.toArray()).flat();d.setColors(_),s.computeLineDistances()}p(o,t),f(r,t.points,t.vertexColors),s.computeLineDistances(),u.watch(()=>[t.color,t.lineWidth,t.alphaToCoverage,t.worldUnits,h,t.dashed,t.dashScale,t.dashSize,t.dashOffset],()=>{p(o,t),c()}),u.watch(()=>[t.points,t.vertexColors],()=>{f(r,t.points,t.vertexColors),c()}),u.watch(()=>[i.height,i.width],()=>{o.resolution=new l.Vector2(i.width.value,i.height.value),c()}),u.onUnmounted(()=>{r.dispose(),o.dispose()});const m=u.shallowRef();return e({instance:m}),(d,g)=>(u.openBlock(),u.createElementBlock("primitive",{ref:m.value,object:u.unref(s)},null,8,bf))}}),Mf=u.defineComponent({__name:"CatmullRomCurve3",props:{segments:{default:20},closed:{type:Boolean,default:!1},curveType:{default:"centripetal"},tension:{default:.5},points:{},vertexColors:{},color:{},lineWidth:{},alphaToCoverage:{type:Boolean},dashed:{type:Boolean},dashSize:{},dashScale:{},dashOffset:{},gapSize:{},worldUnits:{type:Boolean}},setup(a,{expose:e}){const t=a;function n(c,h,p,f){const m=c.map(d=>d instanceof l.Vector3?d:new l.Vector3(...d));return new l.CatmullRomCurve3(m,h,p,f)}function o(c,h){return c.getPoints(h)}const r=u.computed(()=>n(t.points,t.closed,t.curveType,t.tension)),s=u.computed(()=>o(r.value,t.segments)),i=u.shallowRef();return e({instance:i}),(c,h)=>(u.openBlock(),u.createBlock(Es,{ref:i.value,points:s.value,"vertex-colors":t.vertexColors,color:t.color,"line-width":t.lineWidth,"alpha-to-coverage":t.alphaToCoverage,dashed:t.dashed,"dash-size":t.dashSize,"dash-scale":t.dashScale,"dash-offset":t.dashOffset,"gap-size":t.gapSize,"world-units":t.worldUnits},null,8,["points","vertex-colors","color","line-width","alpha-to-coverage","dashed","dash-size","dash-scale","dash-offset","gap-size","world-units"]))}}),Sf=["args"],Af=["color"],Pf=u.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"circleRef",ref:s},i.$attrs),[u.createElementVNode("TresCircleGeometry",{args:u.unref(n)},null,8,Sf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Af)])],16))}}),Cf=["args"],Tf=["color"],If=u.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"coneRef",ref:s},i.$attrs),[u.createElementVNode("TresConeGeometry",{args:u.unref(n)},null,8,Cf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Tf)])],16))}}),Of=["args"],Lf=["color"],Df=u.defineComponent({__name:"Cylinder",props:{args:{default:()=>[1,1,1,32,1,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"cylinderRef",ref:s},i.$attrs),[u.createElementVNode("TresCylinderGeometry",{args:u.unref(n)},null,8,Of),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Lf)])],16))}}),kf=["args"],Bf=["color"],Uf=u.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),r=u.shallowRef(),{invalidate:s}=H.useTresContext();return u.watch(n,()=>s()),e({instance:r}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"dodecahedronRef",ref:r},i.$attrs),[u.createElementVNode("TresDodecahedronGeometry",{args:u.unref(n)},null,8,kf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Bf)])],16))}}),Nf=["args"],Ff=["color"],zf=u.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"icosahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresIcosahedronGeometry",{args:u.unref(n)},null,8,Nf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Ff)])],16))}}),Vf=["args"],Gf=["color"],Rf=u.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"octahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresOctahedronGeometry",{args:u.unref(n)},null,8,Vf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Gf)])],16))}}),jf=["rotation"],Wf=["args"],Yf=["color"],Xf=u.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"planeRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[u.createElementVNode("TresPlaneGeometry",{args:u.unref(n)},null,8,Wf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Yf)])],16,jf))}}),Ef=["args"],Zf=["color"],Kf=u.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"ringRef",ref:s},i.$attrs),[u.createElementVNode("TresRingGeometry",{args:u.unref(n)},null,8,Ef),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Zf)])],16))}}),qf=["args"],Qf=["color"],Jf=u.defineComponent({__name:"RoundedBox",props:{args:{default:()=>[1,1,1,2,.1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r,extend:s}=H.useTresContext();s({RoundedBoxGeometry:Rl}),u.watch(n,()=>r());const i=u.shallowRef();return e({instance:i}),(c,h)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"roundedBoxRef",ref:i},[u.createElementVNode("TresRoundedBoxGeometry",{args:u.unref(n)},null,8,qf),u.renderSlot(c.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,Qf)])],512))}}),Hf=["args"],$f=["color"],ed=u.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"sphereRef",ref:s},i.$attrs),[u.createElementVNode("TresSphereGeometry",{args:u.unref(n)},null,8,Hf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,$f)])],16))}}),td=["geometry"],nd=["color"],od=u.defineComponent({__name:"Superformula",props:{widthSegments:{default:32},heightSegments:{default:32},numArmsA:{default:4},expA:{default:()=>[40,1.3,.9]},numArmsB:{default:4},expB:{default:()=>[40,1.3,.9]},color:{default:"white"}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext(),{cos:o,sin:r,abs:s}=Math,i=u.shallowRef(),c=u.shallowRef(t.color);function h(d,g){const y=new l.BufferGeometry,v=d*g,_=new Float32Array(Array.from({length:3*v}).fill(0)),A=new Float32Array(Array.from({length:3*v}).fill(0)),b=[];for(let C=0;C<g-1;C++){for(let S=0;S<d-1;S++){const x=C*d+S,I=x+1,D=x+d,z=I+d;b.push(x,D,I),b.push(D,z,I)}const L=C*d+d-1,M=C*d,P=L+d,w=M+d;b.push(L,P,M),b.push(P,w,M)}return y.setIndex(b),y.setAttribute("position",new l.BufferAttribute(_,3)),y.setAttribute("normal",new l.BufferAttribute(A,3)),y}function p(d,g,y,v,_){return(s(o(g*d*.25))**v+s(r(g*d*.25))**_)**(-1/y)}function f(d,g,y,v,_,A,b,C,L,M,P){const w=2*Math.PI/M,S=-Math.PI,x=Math.PI/(P-1),I=-.5*Math.PI,D=d.getAttribute("position");let z=0,G=0,E=I;for(let X=0;X<P;X++){G=S;for(let oe=0;oe<M;oe++){const q=p(G,g,y,v,_),ee=p(E,A,b,C,L);D.setXYZ(z,q*o(G)*ee*o(E),ee*r(E),q*r(G)*ee*o(E)),z++,G+=w}E+=x}D.needsUpdate=!0,d.computeVertexNormals()}u.watch(()=>t.color,()=>c.value=t.color),u.watch(()=>[t.widthSegments,t.heightSegments],()=>{i.value&&i.value.dispose(),i.value=h(t.widthSegments,t.heightSegments),n()},{immediate:!0}),u.watch(()=>[t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2]],()=>{f(i.value,t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2],t.widthSegments,t.heightSegments),n()},{immediate:!0}),u.onUnmounted(()=>{i.value&&i.value.dispose()});const m=u.shallowRef();return e({instance:m}),(d,g)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"superformulaRef",ref:m},d.$attrs,{geometry:i.value}),[u.renderSlot(d.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:c.value},null,8,nd)])],16,td))}}),rd=["rotation"],sd=["args"],id=["color"],ad=u.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),r=u.shallowRef();return e({instance:r}),(s,i)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tetrahedronRef",ref:r,rotation:[-Math.PI/2,0,0]},s.$attrs),[u.createElementVNode("TresTetrahedronGeometry",{args:u.unref(n)},null,8,sd),u.renderSlot(s.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,id)])],16,rd))}}),ld=["args"],cd=["color"],ud=u.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusGeometry",{args:u.unref(n)},null,8,ld),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,cd)])],16))}}),hd=["args"],fd=["color"],dd=u.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusKnotRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusKnotGeometry",{args:u.unref(n)},null,8,hd),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,fd)])],16))}}),pd=["args"],md=["color"],gd=u.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(a,{expose:e}){const t=a,{args:n,color:o}=u.toRefs(t),{invalidate:r}=H.useTresContext();u.watch(n,()=>r());const s=u.shallowRef();return e({instance:s}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tubeRef",ref:s},i.$attrs),[u.createElementVNode("TresTubeGeometry",{args:u.unref(n)},null,8,pd),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(o)},null,8,md)])],16))}}),yd=u.defineComponent({__name:"Align",props:{top:{type:Boolean},right:{type:Boolean},bottom:{type:Boolean},left:{type:Boolean},front:{type:Boolean},back:{type:Boolean},disable:{type:Boolean},disableX:{type:Boolean},disableY:{type:Boolean},disableZ:{type:Boolean},precise:{type:Boolean,default:!0},onAlign:{},cacheKey:{default:void 0}},setup(a,{expose:e}){const t=a,n=u.shallowRef(),o=u.shallowRef(),r=u.shallowRef(),s=new l.Box3,i=new l.Vector3,c=new l.Sphere;function h(){if(!o.value||!r.value||!n.value)return;o.value.matrixWorld.identity(),s.setFromObject(r.value,t.precise);const d=s.max.x-s.min.x,g=s.max.y-s.min.y,y=s.max.z-s.min.z;s.getCenter(i),s.getBoundingSphere(c);const v=t.top?g/2:t.bottom?-g/2:0,_=t.left?-d/2:t.right?d/2:0,A=t.front?y/2:t.back?-y/2:0;o.value.position.set(t.disable||t.disableX?0:-i.x+_,t.disable||t.disableY?0:-i.y+v,t.disable||t.disableZ?0:-i.z+A),typeof t.onAlign<"u"&&t.onAlign({parent:n.value.parent,container:n.value,width:d,height:g,depth:y,boundingBox:s,boundingSphere:c,center:i,verticalAlignment:v,horizontalAlignment:_,depthAlignment:A})}let p=null,f=null;const m=H.useLoop();return u.watchEffect(()=>{p==null||p(),p=null;const d=u.toValue(t.cacheKey);d===f&&f!==null&&f!==void 0||(f=d,t.cacheKey===null||t.cacheKey===void 0?p=m.onBeforeRender(()=>{h()}).off:h())}),e({instance:n,update:h}),(d,g)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"ref",ref:n},[u.createElementVNode("TresGroup",{ref_key:"outer",ref:o},[u.createElementVNode("TresGroup",{ref_key:"inner",ref:r},[u.renderSlot(d.$slots,"default")],512)],512)],512))}}),_d=["receive-shadow","rotation"],vd=["args"],xd=u.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,n=h=>h===0?0:2**(10*h-10),{floor:o,segments:r,receiveShadow:s}=u.toRefs(t),i=u.ref(null);u.watch([r,o,i],([h,p,f])=>{if(!f||h===null)return;let m=0;const d=h/h/2,g=f.attributes.position;for(let y=0;y<h+1;y++)for(let v=0;v<h+1;v++)g.setXYZ(m++,y/h-d+(y===0?-p:0),v/h-d,n(y/h));g.needsUpdate=!0,f.computeVertexNormals()});const c=u.shallowRef();return e({instance:c}),(h,p)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"backdropRef",ref:c},h.$attrs),[u.createElementVNode("TresMesh",{"receive-shadow":u.unref(s),rotation:[-Math.PI/2,0,Math.PI/2]},[u.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,u.unref(r),u.unref(r)]},null,8,vd),u.renderSlot(h.$slots,"default",{},()=>[p[0]||(p[0]=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1))])],8,_d)],16))}}),wd=["object"],bd=u.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},blur:{default:1},color:{default:"#000000"},tint:{default:void 0},scale:{default:10},width:{default:1},height:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:Number.POSITIVE_INFINITY},depthWrite:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a;function n(d,g,y){y.blurPlane.visible=!0,y.blurPlane.material=y.horizontalBlurMaterial,y.horizontalBlurMaterial.uniforms.tDiffuse.value=y.renderTarget.texture,y.horizontalBlurMaterial.uniforms.h.value=d/256,g.setRenderTarget(y.renderTargetBlur),g.render(y.blurPlane,y.shadowCamera),y.blurPlane.material=y.verticalBlurMaterial,y.verticalBlurMaterial.uniforms.tDiffuse.value=y.renderTargetBlur.texture,y.verticalBlurMaterial.uniforms.v.value=d/256,g.setRenderTarget(y.renderTarget),g.render(y.blurPlane,y.shadowCamera),y.blurPlane.visible=!1}function o(d,g,y,v){const{renderTarget:_,shadowCamera:A,depthMaterial:b}=v,C=g.background;g.background=null,g.overrideMaterial=b;const L=y.getClearAlpha();y.setClearAlpha(0),y.setRenderTarget(_),y.render(g,A),g.overrideMaterial=null,n(d.blur,y,v),d.smooth&&n(d.blur*.4,y,v),y.setRenderTarget(null),y.setClearAlpha(L),g.background=C}function r(d){const g=new l.Group,y=new l.WebGLRenderTarget(d.resolution,d.resolution);y.texture.generateMipmaps=!1;const v=new l.WebGLRenderTarget(d.resolution,d.resolution);v.texture.generateMipmaps=!1;const _=new l.PlaneGeometry(d.width,d.height).rotateX(Math.PI/2),A=new l.MeshBasicMaterial({map:y.texture,opacity:d.opacity,transparent:!0,depthWrite:d.depthWrite,color:new l.Color(d.color??"black")}),b=new l.Mesh(_,A);g.add(b),b.scale.y=-1;const C=new l.Mesh(_);C.visible=!1,g.add(C);const L=new l.OrthographicCamera(-d.width/2,d.width/2,d.height/2,-d.height/2,0,.3);L.rotation.x=Math.PI/2,g.add(L);const M=new l.MeshDepthMaterial,P=new l.ShaderMaterial(jl);P.depthTest=!1;const w=new l.ShaderMaterial(Wl);return w.depthTest=!1,{renderTarget:y,renderTargetBlur:v,shadowCamera:L,depthMaterial:M,horizontalBlurMaterial:P,verticalBlurMaterial:w,shadowGroup:g,plane:b,blurPlane:C}}function s(d,g){const y=g.shadowCamera;y.left=-d.width/2,y.right=d.width/2,y.top=d.height/2,y.bottom=-d.height/2,y.far=d.far;const v=d.width*(Array.isArray(d.scale)?d.scale[0]:d.scale||1),_=d.height*(Array.isArray(d.scale)?d.scale[1]:d.scale||1);g.shadowGroup.scale.set(v,d.far,_)}function i(d,g){g.renderTarget.dispose(),g.renderTargetBlur.dispose(),g.renderTarget=new l.WebGLRenderTarget(d,d),g.renderTarget.texture.generateMipmaps=!1,g.renderTargetBlur=new l.WebGLRenderTarget(d,d),g.renderTargetBlur.texture.generateMipmaps=!1,g.plane.material.map=g.renderTarget.texture}function c(d,g){g.plane.material.color=new l.Color(d.color??"black"),g.depthMaterial.dispose(),g.depthMaterial=new l.MeshDepthMaterial,g.depthMaterial.onBeforeCompile=function(y){const v=d.tint?new l.Color(d.tint):new l.Color("white"),{r:_,g:A,b}=v,C=y.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",`gl_FragColor = vec4( ${_}, ${A}, ${b}, ( 1.0 - fragCoordZ ) * opacity);`);y.fragmentShader=C}}const{onBeforeRender:h}=H.useLoop(),p=r(t);let f=0;const m=()=>f=f>=t.frames?t.frames-1:f;return h(({renderer:d,scene:g,invalidate:y})=>{f<t.frames&&(f++,o(t,g,d,p),y())}),u.watch(()=>[t.opacity,t.depthWrite,t.blur,t.smooth],()=>{p.plane.material.opacity=t.opacity??1,p.plane.material.depthWrite=t.depthWrite??!1,m()},{immediate:!0}),u.watch(()=>[t.color,t.tint],()=>{c(t,p),m()},{immediate:!0}),u.watch(()=>[t.resolution],()=>{i(t.resolution,p),m()}),u.watch(()=>[t.width,t.height,t.scale,t.far],()=>{s(t,p),m()},{immediate:!0}),u.onUnmounted(()=>{for(const d of Object.values(p))d&&"dispose"in d&&typeof d.dispose=="function"&&d.dispose()}),e({instance:p.shadowGroup}),(d,g)=>(u.openBlock(),u.createElementBlock("primitive",{object:u.unref(p).shadowGroup},null,8,wd))}}),Md=u.defineComponent({__name:"Fit",props:{into:{default:()=>new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5))},precise:{type:Boolean,default:!1}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext(),o=u.shallowRef(new l.Group),r=u.shallowRef(new l.Group);function s(h,p){if(o.value.position.set(0,0,0),o.value.updateMatrixWorld(),r.value.scale.set(1,1,1),r.value.updateMatrixWorld(),!r.value.children.length||h===null)return;const{box3:f,use:m}=i(h,p),d=new l.Box3;r.value.children.forEach(A=>d.expandByObject(A,p));const g=d.getSize(new l.Vector3),y=f.getSize(new l.Vector3),v=Math.min(y.x/g.x,y.y/g.y,y.z/g.z);r.value.scale.setScalar(v===Number.POSITIVE_INFINITY?1:v),r.value.updateMatrixWorld();const _=o.value.worldToLocal(d.getCenter(new l.Vector3));if(m.position){const A=o.value.worldToLocal(f.getCenter(new l.Vector3));o.value.position.copy(A.sub(_.multiplyScalar(v)))}else o.value.position.copy(_.sub(_.multiplyScalar(v)));n()}function i(h,p){return typeof h=="number"?h=new l.Vector3(h,h,h):Array.isArray(h)&&(h=new l.Vector3(...h)),h&&"isVector3"in h&&h.isVector3?{box3:new l.Box3(new l.Vector3(0,0,0),h),use:{position:!1}}:h&&"isBox3"in h&&h.isBox3?{box3:h,use:{position:!0}}:h&&"isObject3D"in h&&h.isObject3D?{box3:new l.Box3().setFromObject(h,p??!1),use:{position:!0}}:{box3:new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),use:{position:!0}}}u.watch(()=>[t.into,t.precise],()=>s(t.into,t.precise)),u.onMounted(()=>{s(t.into,t.precise),u.nextTick().then(()=>{s(t.into,t.precise)})});const c=u.shallowRef();return e({instance:c,fit:(h=new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),p=!1)=>{s(h,p)},update:()=>s(t.into,t.precise)}),(h,p)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outer",ref:c},[u.createElementVNode("TresGroup",{ref_key:"middle",ref:o},[u.createElementVNode("TresGroup",{ref_key:"inner",ref:r},[u.renderSlot(h.$slots,"default")],512)],512)],512))}}),Sd=["side","cell-size","section-size","cell-color","section-color","cell-thickness","section-thickness","fade-distance","fade-strength","fade-from","infinite-grid","follow-camera"],Ad=["args"],Pd=u.defineComponent({__name:"Grid",props:{cellSize:{default:.5},cellThickness:{default:.5},cellColor:{default:"#000000"},sectionSize:{default:1},sectionThickness:{default:1},sectionColor:{default:"#0000ff"},followCamera:{type:Boolean,default:!1},infiniteGrid:{type:Boolean,default:!1},fadeDistance:{default:100},fadeStrength:{default:1},fadeFrom:{default:1},side:{default:l.BackSide},args:{}},setup(a){const e=a,t=Vn({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:new l.Color,sectionColor:new l.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new l.Vector3,worldPlanePosition:new l.Vector3},`
|
|
1487
1487
|
varying vec3 localPosition;
|
|
1488
1488
|
varying vec4 worldPosition;
|
|
1489
1489
|
|
|
@@ -1543,7 +1543,7 @@ void main() {
|
|
|
1543
1543
|
#include <tonemapping_fragment>
|
|
1544
1544
|
#include <colorspace_fragment>
|
|
1545
1545
|
}
|
|
1546
|
-
`);H.extend({GridMaterial:t});const n=u.shallowRef(new l.Mesh),o=new l.Plane,r=new l.Vector3(0,1,0),s=new l.Vector3(0,0,0);return H.useLoop().onBeforeRender(i=>{o.setFromNormalAndCoplanarPoint(r,s).applyMatrix4(n.value.matrixWorld);const c=n.value.material,h=c.uniforms.worldCamProjPosition,p=c.uniforms.worldPlanePosition;o.projectPoint(i.camera.position,h.value),p.value.set(0,0,0).applyMatrix4(n.value.matrixWorld)}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"ref",ref:n,"frustum-culled":!1},[u.createElementVNode("TresGridMaterial",{transparent:!0,"extensions-derivatives":!0,side:e.side,"cell-size":e.cellSize,"section-size":e.sectionSize,"cell-color":e.cellColor,"section-color":e.sectionColor,"cell-thickness":e.cellThickness,"section-thickness":e.sectionThickness,"fade-distance":e.fadeDistance,"fade-strength":e.fadeStrength,"fade-from":e.fadeFrom,"infinite-grid":e.infiniteGrid,"follow-camera":e.followCamera},null,8,Sd),u.createElementVNode("TresPlaneGeometry",{args:e.args},null,8,Ad)],512))}}),Cd=["rotation-x","args"],Td=u.defineComponent({__name:"Ocean",props:{textureWidth:{default:512},textureHeight:{default:512},waterNormals:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/water-normals/Water_1_M_Normal.jpg"},sunDirection:{default:()=>new l.Vector3},sunColor:{default:16777215},waterColor:{default:7695},distortionScale:{default:3.7},size:{default:1},clipBias:{default:0},alpha:{default:1},side:{default:l.FrontSide}},async setup(a,{expose:e}){let t,n;const o=a,{textureWidth:r,textureHeight:s,waterNormals:i,sunDirection:c,sunColor:h,waterColor:p,distortionScale:f,size:m,clipBias:d,alpha:g,side:y}=u.toRefs(o),{extend:v,scene:_}=H.useTresContext();v({Water:Ra});const A=u.shallowRef(),b=u.shallowRef(),C=_.value.fog!==void 0;e({instance:A}),_.value.traverse(P=>{Object.prototype.hasOwnProperty.call(P,"isSky")&&(b.value=P)}),u.onMounted(async()=>{if(await u.nextTick(),b.value){const P=b.value.material.uniforms.sunPosition.value;A.value.material.uniforms.sunDirection.value.copy(P)}});const{normalMap:L}=([t,n]=u.withAsyncContext(()=>H.useTexture({normalMap:i.value})),t=await t,n(),t);L.wrapS=L.wrapT=l.RepeatWrapping;const{onBeforeRender:M}=H.useLoop();return M(({delta:P,invalidate:w})=>{A.value.material.uniforms.time.value+=P,w()}),(P,w)=>(u.openBlock(),u.createElementBlock("TresWater",{ref_key:"waterRef",ref:A,"rotation-x":-Math.PI/2,args:[void 0,{textureWidth:u.unref(r),textureHeight:u.unref(s),waterNormals:u.unref(L),sunDirection:u.unref(c),sunColor:u.unref(h),waterColor:u.unref(p),distortionScale:u.unref(f),fog:C,size:u.unref(m),clipBias:u.unref(d),alpha:u.unref(g),side:u.unref(y)}]},[u.renderSlot(P.$slots,"default",{},()=>[w[0]||(w[0]=u.createElementVNode("TresPlaneGeometry",{args:[1e4,1e4]},null,-1))])],8,Cd))}}),Id=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Od=["position","velocity"],Ld=u.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(a,{expose:e}){const t=a,{size:n,area:o,color:r,alphaMap:s,map:i,opacity:c,alphaTest:h,depthWrite:p,transparent:f,sizeAttenuation:m,count:d,speed:g,randomness:y}=u.toRefs(t),v=u.shallowRef();let _=[],A=[];const b=()=>{_=new Float32Array(d.value*3);for(let S=0;S<d.value;S++){const x=S*3;_[x]=(Math.random()-.5)*o.value[0],_[x+1]=(Math.random()-.5)*o.value[1],_[x+2]=(Math.random()-.5)*o.value[2]}},C=()=>{A=new Float32Array(d.value*2);for(let S=0;S<d.value*2;S+=2)A[S]=(Math.random()-.5)/5*g.value*y.value,A[S+1]=Math.random()/5*g.value};C(),b(),u.watchEffect(()=>{C(),b()});const L=u.shallowRef(null),M=u.shallowRef(null);u.watchEffect(async()=>{u.watchEffect(async()=>{if(typeof s.value=="string"){const S=await H.useTexture({alphaMap:s.value});L.value=S.alphaMap}else L.value=s.value??null;if(typeof i.value=="string"){const S=await H.useTexture({map:i.value});M.value=S.map}else M.value=i.value??null})});const{onBeforeRender:P}=H.useLoop();P(({invalidate:S})=>{var x,I;if((x=v.value)!=null&&x.attributes.position.array&&((I=v.value)!=null&&I.attributes.position.count)){const D=v.value.attributes.position.array;for(let z=0;z<v.value.attributes.position.count;z++){const G=A[z*2],
|
|
1546
|
+
`);H.extend({GridMaterial:t});const n=u.shallowRef(new l.Mesh),o=new l.Plane,r=new l.Vector3(0,1,0),s=new l.Vector3(0,0,0);return H.useLoop().onBeforeRender(i=>{o.setFromNormalAndCoplanarPoint(r,s).applyMatrix4(n.value.matrixWorld);const c=n.value.material,h=c.uniforms.worldCamProjPosition,p=c.uniforms.worldPlanePosition;o.projectPoint(i.camera.position,h.value),p.value.set(0,0,0).applyMatrix4(n.value.matrixWorld)}),(i,c)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"ref",ref:n,"frustum-culled":!1},[u.createElementVNode("TresGridMaterial",{transparent:!0,"extensions-derivatives":!0,side:e.side,"cell-size":e.cellSize,"section-size":e.sectionSize,"cell-color":e.cellColor,"section-color":e.sectionColor,"cell-thickness":e.cellThickness,"section-thickness":e.sectionThickness,"fade-distance":e.fadeDistance,"fade-strength":e.fadeStrength,"fade-from":e.fadeFrom,"infinite-grid":e.infiniteGrid,"follow-camera":e.followCamera},null,8,Sd),u.createElementVNode("TresPlaneGeometry",{args:e.args},null,8,Ad)],512))}}),Cd=["rotation-x","args"],Td=u.defineComponent({__name:"Ocean",props:{textureWidth:{default:512},textureHeight:{default:512},waterNormals:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/water-normals/Water_1_M_Normal.jpg"},sunDirection:{default:()=>new l.Vector3},sunColor:{default:16777215},waterColor:{default:7695},distortionScale:{default:3.7},size:{default:1},clipBias:{default:0},alpha:{default:1},side:{default:l.FrontSide}},async setup(a,{expose:e}){let t,n;const o=a,{textureWidth:r,textureHeight:s,waterNormals:i,sunDirection:c,sunColor:h,waterColor:p,distortionScale:f,size:m,clipBias:d,alpha:g,side:y}=u.toRefs(o),{extend:v,scene:_}=H.useTresContext();v({Water:Ra});const A=u.shallowRef(),b=u.shallowRef(),C=_.value.fog!==void 0;e({instance:A}),_.value.traverse(P=>{Object.prototype.hasOwnProperty.call(P,"isSky")&&(b.value=P)}),u.onMounted(async()=>{if(await u.nextTick(),b.value){const P=b.value.material.uniforms.sunPosition.value;A.value.material.uniforms.sunDirection.value.copy(P)}});const{normalMap:L}=([t,n]=u.withAsyncContext(()=>H.useTexture({normalMap:i.value})),t=await t,n(),t);L.wrapS=L.wrapT=l.RepeatWrapping;const{onBeforeRender:M}=H.useLoop();return M(({delta:P,invalidate:w})=>{A.value.material.uniforms.time.value+=P,w()}),(P,w)=>(u.openBlock(),u.createElementBlock("TresWater",{ref_key:"waterRef",ref:A,"rotation-x":-Math.PI/2,args:[void 0,{textureWidth:u.unref(r),textureHeight:u.unref(s),waterNormals:u.unref(L),sunDirection:u.unref(c),sunColor:u.unref(h),waterColor:u.unref(p),distortionScale:u.unref(f),fog:C,size:u.unref(m),clipBias:u.unref(d),alpha:u.unref(g),side:u.unref(y)}]},[u.renderSlot(P.$slots,"default",{},()=>[w[0]||(w[0]=u.createElementVNode("TresPlaneGeometry",{args:[1e4,1e4]},null,-1))])],8,Cd))}}),Id=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Od=["position","velocity"],Ld=u.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(a,{expose:e}){const t=a,{size:n,area:o,color:r,alphaMap:s,map:i,opacity:c,alphaTest:h,depthWrite:p,transparent:f,sizeAttenuation:m,count:d,speed:g,randomness:y}=u.toRefs(t),v=u.shallowRef();let _=[],A=[];const b=()=>{_=new Float32Array(d.value*3);for(let S=0;S<d.value;S++){const x=S*3;_[x]=(Math.random()-.5)*o.value[0],_[x+1]=(Math.random()-.5)*o.value[1],_[x+2]=(Math.random()-.5)*o.value[2]}},C=()=>{A=new Float32Array(d.value*2);for(let S=0;S<d.value*2;S+=2)A[S]=(Math.random()-.5)/5*g.value*y.value,A[S+1]=Math.random()/5*g.value};C(),b(),u.watchEffect(()=>{C(),b()});const L=u.shallowRef(null),M=u.shallowRef(null);u.watchEffect(async()=>{u.watchEffect(async()=>{if(typeof s.value=="string"){const S=await H.useTexture({alphaMap:s.value});L.value=S.alphaMap}else L.value=s.value??null;if(typeof i.value=="string"){const S=await H.useTexture({map:i.value});M.value=S.map}else M.value=i.value??null})});const{onBeforeRender:P}=H.useLoop();P(({invalidate:S})=>{var x,I;if((x=v.value)!=null&&x.attributes.position.array&&((I=v.value)!=null&&I.attributes.position.count)){const D=v.value.attributes.position.array;for(let z=0;z<v.value.attributes.position.count;z++){const G=A[z*2],E=A[z*2+1];D[z*3]+=G,D[z*3+1]-=E,(D[z*3]<=-o.value[0]/2||D[z*3]>=o.value[0]/2)&&(D[z*3]=D[z*3]*-1),(D[z*3+1]<=-o.value[1]/2||D[z*3+1]>=o.value[1]/2)&&(D[z*3+1]=D[z*3+1]*-1)}v.value.attributes.position.needsUpdate=!0,S()}});const w=u.shallowRef();return e({instance:w}),(S,x)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"pointsRef",ref:w},[u.createElementVNode("TresPointsMaterial",{size:u.unref(n),color:u.unref(r),"alpha-map":L.value,map:M.value,opacity:u.unref(c),"alpha-test":u.unref(h),"depth-write":u.unref(p),transparent:u.unref(f),"size-attenuation":u.unref(m)},null,8,Id),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:v,position:[u.unref(_),3],velocity:[u.unref(A)]},null,8,Od)],512))}}),Dd=["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mieCoefficient-value","material-uniforms-mieDirectionalG-value","material-uniforms-sunPosition-value","scale"],kd=u.defineComponent({__name:"Sky",props:{turbidity:{default:3.4},rayleigh:{default:3},mieCoefficient:{default:.005},mieDirectionalG:{default:.7},elevation:{default:.6},azimuth:{default:180},distance:{default:45e4}},setup(a,{expose:e}){const t=a,{invalidate:n}=H.useTresContext();u.watch(t,()=>n());const o=u.shallowRef(),r=new Hn,s=u.computed(()=>i(t.azimuth,t.elevation));function i(c,h){const p=l.MathUtils.degToRad(90-h),f=l.MathUtils.degToRad(c);return new l.Vector3().setFromSphericalCoords(1,p,f)}return e({instance:o,sunPosition:s.value}),(c,h)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"skyRef",ref:o,object:u.unref(r),"material-uniforms-turbidity-value":t.turbidity,"material-uniforms-rayleigh-value":t.rayleigh,"material-uniforms-mieCoefficient-value":t.mieCoefficient,"material-uniforms-mieDirectionalG-value":t.mieDirectionalG,"material-uniforms-sunPosition-value":s.value,scale:t.distance},null,8,Dd))}}),Bd=["position"],Ud=["position"],Nd=["scale"],Fd=["map","depth-test","color-space","color","opacity"],zd=u.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(a,{expose:e}){let t,n;const o=a,{width:r,depth:s,segments:i,texture:c,color:h,depthTest:p,opacity:f,speed:m}=u.toRefs(o),d=u.shallowRef(),g=u.shallowRef();e({instance:d});const y=[i].map((M,P)=>({x:r.value/2-Math.random()*r.value,y:r.value/2-Math.random()*r.value,scale:.4+Math.sin((P+1)/i.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*m.value})),v=(M,P)=>M/6*P*f.value,{map:_}=([t,n]=u.withAsyncContext(()=>H.useTexture({map:c.value})),t=await t,n(),t),{renderer:A,camera:b}=H.useTresContext(),C=u.computed(()=>{var M;return(M=A.value)==null?void 0:M.outputColorSpace}),{onBeforeRender:L}=H.useLoop();return L(({invalidate:M})=>{var P,w;d.value&&b.value&&g.value&&((P=g.value)==null||P.children.forEach((S,x)=>{S.rotation.z+=y[x].rotation}),d.value.lookAt((w=b.value)==null?void 0:w.position),M())}),(M,P)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:d},M.$attrs),[u.createElementVNode("TresGroup",{ref_key:"groupRef",ref:g,position:[0,0,u.unref(i)/2*u.unref(s)]},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(u.unref(y),({scale:w,x:S,y:x,density:I},D)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${D}`,position:[S,x,-D*u.unref(s)]},[u.createElementVNode("TresPlaneGeometry",{scale:[w,w,w],rotation:[0,0,0]},null,8,Nd),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(_),"depth-test":u.unref(p),"color-space":C.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:v(w,I)},null,8,Fd)],8,Ud))),128))],8,Bd)],16))}}),Vd=`
|
|
1547
1547
|
return PCSS( shadowMap, shadowCoord );
|
|
1548
1548
|
`,Gd=u.defineComponent({__name:"SoftShadows",props:{size:{default:25},samples:{default:10},focus:{default:0}},setup(a){const e=a,t=({focus:h=0,size:p=25,samples:f=10}={})=>`
|
|
1549
1549
|
#define PENUMBRA_FILTER_SIZE float(${p})
|
|
@@ -1718,4 +1718,4 @@ float PCSS (sampler2D shadowMap, vec4 coords) {
|
|
|
1718
1718
|
gl_FragColor = vColor * texture2D(uMap, gl_PointCoord);
|
|
1719
1719
|
#include <tonemapping_fragment>
|
|
1720
1720
|
#include <${n>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
1721
|
-
}`},h=new l.ShaderMaterial(c),p=new l.Points(void 0,h),f=h.uniforms,m={immediate:!0};[[f.uPixelRatio,H.useTresContext().sizes.aspectRatio],[f.uSize,o.size],[f.uNormalThreshold,o.normalThreshold],[f.uAlpha,o.alpha],[f.uOffset,o.offset],[f.uOffsetNoise,o.offsetNoise],[f.uMixColor,o.mixColor],[f.uMixAlpha,o.mixAlpha],[f.uMixOffset,o.mixOffset],[f.uMixSize,o.mixSize],[f.uMixSurfaceDistance,o.mixSurfaceDistance],[f.uMixNoise,o.mixNoise],[f.uInfoTexture,s]].forEach(([b,C])=>u.watch(C,()=>{b.value=C.value},m)),u.watch([o.noiseScale,o.lifetimeSec],()=>{f.uNoiseScale.value=o.noiseScale.value*o.lifetimeSec.value},m),u.watch([o.lifetimeSec,o.cooldownSec],()=>{f.uCooldownRatio.value=o.cooldownSec.value/o.lifetimeSec.value},m),u.watch(o.map,()=>{typeof o.map.value=="string"?H.useTexture([o.map.value]).then(b=>h.uniforms.uMap.value=b):h.uniforms.uMap.value=o.map.value});const g=new l.Quaternion,y=new l.Vector3;H.useLoop().onBeforeRender(({elapsed:b,invalidate:C})=>{p.getWorldQuaternion(g),y.copy(t.directionalLight?t.directionalLight.position:l.Object3D.DEFAULT_UP).normalize(),y.applyQuaternion(g.invert()),h.uniforms.uNormal.value=y,h.uniforms.uTime.value=b/(t.cooldownSec+t.lifetimeSec),C()});function v(b){return b&&"isObject3D"in b}function _(b){return b&&"isBufferGeometry"in b}u.onMounted(()=>{t.geometry?_(t.geometry)?p.geometry.copy(t.geometry):v(t.geometry)&&"geometry"in t.geometry&&_(t.geometry.geometry)&&p.geometry.copy(t.geometry.geometry):v(p.parent)&&"geometry"in p.parent&&_(p.parent.geometry)?p.geometry.copy(p.parent.geometry):p.geometry=new l.IcosahedronGeometry(1,16),typeof t.map=="string"&&H.useTexture([t.map]).then(b=>h.uniforms.uMap.value=b)}),u.onUnmounted(()=>{var b;(b=h.uniforms.uMap.value)==null||b.dispose(),s.value.dispose(),h.dispose()});const A=u.shallowRef();return e({instance:p}),(b,C)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"sparkleRef",ref:A,object:u.unref(p)},null,8,tp))}}),op=["position","a-scale"],rp=["size","size-attenuation","transparent","alpha-test","alpha-map"],sp=u.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(a,{expose:e}){const t=a,n=u.ref(),o=u.ref(),{radius:r,depth:s,count:i,size:c,sizeAttenuation:h,transparent:p,alphaMap:f,alphaTest:m}=u.toRefs(t),{invalidate:d}=H.useTresContext();u.watch(t,()=>{d()});const g=()=>{let v=r.value+s.value;const _=u.computed(()=>s.value/i.value),A=[],b=Array.from({length:i.value},()=>(.5+.5*Math.random())*4),C=L=>new l.Vector3().setFromSpherical(new l.Spherical(L,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let L=0;L<i.value;L++)v-=_.value*Math.random(),A.push(...C(v));n.value=new Float32Array(A),o.value=new Float32Array(b)};u.watchEffect(()=>{g()});const y=u.shallowRef();return e({instance:y}),(v,_)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:y},[u.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[o.value,1]},null,8,op),u.createElementVNode("TresPointsMaterial",{size:u.unref(c),"size-attenuation":u.unref(h),transparent:u.unref(p),"alpha-test":u.unref(m),"alpha-map":u.unref(f)},null,8,rp)],512))}});class qs extends l.Object3D{constructor(){super();ue(this,"virtualScene",null);this.virtualScene=new l.Scene}add(...t){return this.virtualScene.add(...t),this}dispose(){this.virtualScene.traverse(t=>{t instanceof l.Mesh&&(t.geometry.dispose(),t.material.dispose(),t.material.map&&t.material.map.dispose(),this.virtualScene.remove(t))}),this.virtualScene=null}}const ip=u.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:()=>[]},path:{default:""},preset:{default:void 0},resolution:{default:256},near:{default:1},far:{default:1e3},frames:{default:Number.POSITIVE_INFINITY}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref(null);e({texture:r});const{extend:s,renderer:i,scene:c}=H.useTresContext();s({EnvironmentScene:qs});let h=null;const p=u.ref(null);let f=null;const m=u.ref(null),d=([t,n]=u.withAsyncContext(()=>rs(o,p)),t=await t,n(),t),{onBeforeRender:g}=H.useLoop();let y=1;g(()=>{if(f&&m.value&&p.value&&(o.frames===Number.POSITIVE_INFINITY||y<o.frames)){const _=i.value.autoClear;i.value.autoClear=!0;const A=u.toRaw(m.value).virtualScene;f.update(i.value,A),i.value.autoClear=_,y++}},-1),u.watch([d,m],([_,A])=>{if(_&&(A!=null&&A.virtualScene)){const b=u.toRaw(A).virtualScene;let C=b.children.find(L=>L instanceof l.Mesh&&L.userData.isEnvironment);C||(C=new l.Mesh(new l.BoxGeometry(1,1,1),new l.MeshBasicMaterial({side:l.BackSide})),C.userData.isEnvironment=!0,b.add(C)),b.background=_,b.backgroundBlurriness=o.blur}},{immediate:!0});const v=_=>{_&&(h!=null&&h.length)?(c.value.environment=_.texture,o.background&&(c.value.background=_.texture)):d.value&&(c.value.environment=d.value,o.background&&(c.value.background=d.value))};return u.watch(d,()=>{p.value&&v(p.value)},{immediate:!0,deep:!0}),u.watch(()=>u.useSlots().default,_=>{var A;if(_&&(h=_(),Array.isArray(h)&&h.length>0)){s({EnvironmentScene:qs}),p.value=new l.WebGLCubeRenderTarget(o.resolution),p.value.texture.type=l.HalfFloatType,f=new l.CubeCamera(o.near,o.far,p.value),v(p.value);return}(A=p.value)==null||A.dispose(),p.value=null,v()},{immediate:!0,deep:!0}),r.value=d.value,u.onUnmounted(()=>{var _,A;(_=m.value)==null||_.dispose(),(A=p.value)==null||A.dispose()}),(_,A)=>p.value?(u.openBlock(),u.createElementBlock("TresEnvironmentScene",{key:0,ref_key:"environmentScene",ref:m},[u.renderSlot(_.$slots,"default")],512)):u.createCommentVNode("",!0)}}),ap={key:0,args:[0,1,64]},lp={key:1,args:[.5,1,64]},cp={key:2},up=["tone-mapped","map","side","color"],hp=u.defineComponent({__name:"index",props:{args:{default:null},form:{default:"rect"},toneMapped:{type:Boolean,default:!1},map:{default:null},intensity:{default:1},color:{default:new l.Color(16777215)}},setup(a,{expose:e}){const t=a,n=u.ref(),o=u.ref();return u.watchEffect(()=>{n.value&&(n.value.color.copy(new l.Color(t.color)),n.value.color.multiplyScalar(t.intensity),n.value.needsUpdate=!0)}),e({mesh:o}),(r,s)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"mesh",ref:o},[r.form==="circle"?(u.openBlock(),u.createElementBlock("TresRingGeometry",ap)):r.form==="ring"?(u.openBlock(),u.createElementBlock("TresRingGeometry",lp)):r.form==="rect"?(u.openBlock(),u.createElementBlock("TresPlaneGeometry",cp)):(u.openBlock(),u.createBlock(t.form,{key:3,args:r.args},null,8,["args"])),u.createElementVNode("TresMeshBasicMaterial",{ref_key:"material",ref:n,"tone-mapped":r.toneMapped,map:r.map,side:u.unref(l.DoubleSide),color:r.color},null,8,up)],512))}});function fp(a,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n]);return t}function dp(a,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return a[t]!==void 0}function pp(a){var t,n;let e=a.value;return a.value&&((n=(t=a.value)==null?void 0:t.value)!=null&&n.isMesh)&&(e=a.value.value.position),Array.isArray(a.value)&&(e=new l.Vector3(...e)),e}
|
|
1721
|
+
}`},h=new l.ShaderMaterial(c),p=new l.Points(void 0,h),f=h.uniforms,m={immediate:!0};[[f.uPixelRatio,H.useTresContext().sizes.aspectRatio],[f.uSize,o.size],[f.uNormalThreshold,o.normalThreshold],[f.uAlpha,o.alpha],[f.uOffset,o.offset],[f.uOffsetNoise,o.offsetNoise],[f.uMixColor,o.mixColor],[f.uMixAlpha,o.mixAlpha],[f.uMixOffset,o.mixOffset],[f.uMixSize,o.mixSize],[f.uMixSurfaceDistance,o.mixSurfaceDistance],[f.uMixNoise,o.mixNoise],[f.uInfoTexture,s]].forEach(([b,C])=>u.watch(C,()=>{b.value=C.value},m)),u.watch([o.noiseScale,o.lifetimeSec],()=>{f.uNoiseScale.value=o.noiseScale.value*o.lifetimeSec.value},m),u.watch([o.lifetimeSec,o.cooldownSec],()=>{f.uCooldownRatio.value=o.cooldownSec.value/o.lifetimeSec.value},m),u.watch(o.map,()=>{typeof o.map.value=="string"?H.useTexture([o.map.value]).then(b=>h.uniforms.uMap.value=b):h.uniforms.uMap.value=o.map.value});const g=new l.Quaternion,y=new l.Vector3;H.useLoop().onBeforeRender(({elapsed:b,invalidate:C})=>{p.getWorldQuaternion(g),y.copy(t.directionalLight?t.directionalLight.position:l.Object3D.DEFAULT_UP).normalize(),y.applyQuaternion(g.invert()),h.uniforms.uNormal.value=y,h.uniforms.uTime.value=b/(t.cooldownSec+t.lifetimeSec),C()});function v(b){return b&&"isObject3D"in b}function _(b){return b&&"isBufferGeometry"in b}u.onMounted(()=>{t.geometry?_(t.geometry)?p.geometry.copy(t.geometry):v(t.geometry)&&"geometry"in t.geometry&&_(t.geometry.geometry)&&p.geometry.copy(t.geometry.geometry):v(p.parent)&&"geometry"in p.parent&&_(p.parent.geometry)?p.geometry.copy(p.parent.geometry):p.geometry=new l.IcosahedronGeometry(1,16),typeof t.map=="string"&&H.useTexture([t.map]).then(b=>h.uniforms.uMap.value=b)}),u.onUnmounted(()=>{var b;(b=h.uniforms.uMap.value)==null||b.dispose(),s.value.dispose(),h.dispose()});const A=u.shallowRef();return e({instance:p}),(b,C)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"sparkleRef",ref:A,object:u.unref(p)},null,8,tp))}}),op=["position","a-scale"],rp=["size","size-attenuation","transparent","alpha-test","alpha-map"],sp=u.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(a,{expose:e}){const t=a,n=u.ref(),o=u.ref(),{radius:r,depth:s,count:i,size:c,sizeAttenuation:h,transparent:p,alphaMap:f,alphaTest:m}=u.toRefs(t),{invalidate:d}=H.useTresContext();u.watch(t,()=>{d()});const g=()=>{let v=r.value+s.value;const _=u.computed(()=>s.value/i.value),A=[],b=Array.from({length:i.value},()=>(.5+.5*Math.random())*4),C=L=>new l.Vector3().setFromSpherical(new l.Spherical(L,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let L=0;L<i.value;L++)v-=_.value*Math.random(),A.push(...C(v));n.value=new Float32Array(A),o.value=new Float32Array(b)};u.watchEffect(()=>{g()});const y=u.shallowRef();return e({instance:y}),(v,_)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:y},[u.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[o.value,1]},null,8,op),u.createElementVNode("TresPointsMaterial",{size:u.unref(c),"size-attenuation":u.unref(h),transparent:u.unref(p),"alpha-test":u.unref(m),"alpha-map":u.unref(f)},null,8,rp)],512))}});class qs extends l.Object3D{constructor(){super();ue(this,"virtualScene",null);this.virtualScene=new l.Scene}add(...t){return this.virtualScene.add(...t),this}dispose(){this.virtualScene.traverse(t=>{t instanceof l.Mesh&&(t.geometry.dispose(),t.material.dispose(),t.material.map&&t.material.map.dispose(),this.virtualScene.remove(t))}),this.virtualScene=null}}const ip=u.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:()=>[]},path:{default:""},preset:{default:void 0},resolution:{default:256},near:{default:1},far:{default:1e3},frames:{default:Number.POSITIVE_INFINITY}},async setup(a,{expose:e}){let t,n;const o=a,r=u.ref(null);e({texture:r});const{extend:s,renderer:i,scene:c}=H.useTresContext();s({EnvironmentScene:qs});let h=null;const p=u.ref(null);let f=null;const m=u.ref(null),d=([t,n]=u.withAsyncContext(()=>rs(o,p)),t=await t,n(),t),{onBeforeRender:g}=H.useLoop();let y=1;g(()=>{if(f&&m.value&&p.value&&(o.frames===Number.POSITIVE_INFINITY||y<o.frames)){const _=i.value.autoClear;i.value.autoClear=!0;const A=u.toRaw(m.value).virtualScene;f.update(i.value,A),i.value.autoClear=_,y++}},-1),u.watch([d,m],([_,A])=>{if(_&&(A!=null&&A.virtualScene)){const b=u.toRaw(A).virtualScene;let C=b.children.find(L=>L instanceof l.Mesh&&L.userData.isEnvironment);C||(C=new l.Mesh(new l.BoxGeometry(1,1,1),new l.MeshBasicMaterial({side:l.BackSide})),C.userData.isEnvironment=!0,b.add(C)),b.background=_,b.backgroundBlurriness=o.blur}},{immediate:!0});const v=_=>{_&&(h!=null&&h.length)?(c.value.environment=_.texture,o.background&&(c.value.background=_.texture)):d.value&&(c.value.environment=d.value,o.background&&(c.value.background=d.value))};return u.watch(d,()=>{p.value&&v(p.value)},{immediate:!0,deep:!0}),u.watch(()=>u.useSlots().default,_=>{var A;if(_&&(h=_(),Array.isArray(h)&&h.length>0)){s({EnvironmentScene:qs}),p.value=new l.WebGLCubeRenderTarget(o.resolution),p.value.texture.type=l.HalfFloatType,f=new l.CubeCamera(o.near,o.far,p.value),v(p.value);return}(A=p.value)==null||A.dispose(),p.value=null,v()},{immediate:!0,deep:!0}),r.value=d.value,u.onUnmounted(()=>{var _,A;(_=m.value)==null||_.dispose(),(A=p.value)==null||A.dispose()}),(_,A)=>p.value?(u.openBlock(),u.createElementBlock("TresEnvironmentScene",{key:0,ref_key:"environmentScene",ref:m},[u.renderSlot(_.$slots,"default")],512)):u.createCommentVNode("",!0)}}),ap={key:0,args:[0,1,64]},lp={key:1,args:[.5,1,64]},cp={key:2},up=["tone-mapped","map","side","color"],hp=u.defineComponent({__name:"index",props:{args:{default:null},form:{default:"rect"},toneMapped:{type:Boolean,default:!1},map:{default:null},intensity:{default:1},color:{default:new l.Color(16777215)}},setup(a,{expose:e}){const t=a,n=u.ref(),o=u.ref();return u.watchEffect(()=>{n.value&&(n.value.color.copy(new l.Color(t.color)),n.value.color.multiplyScalar(t.intensity),n.value.needsUpdate=!0)}),e({mesh:o}),(r,s)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"mesh",ref:o},[r.form==="circle"?(u.openBlock(),u.createElementBlock("TresRingGeometry",ap)):r.form==="ring"?(u.openBlock(),u.createElementBlock("TresRingGeometry",lp)):r.form==="rect"?(u.openBlock(),u.createElementBlock("TresPlaneGeometry",cp)):(u.openBlock(),u.createBlock(t.form,{key:3,args:r.args},null,8,["args"])),u.createElementVNode("TresMeshBasicMaterial",{ref_key:"material",ref:n,"tone-mapped":r.toneMapped,map:r.map,side:u.unref(l.DoubleSide),color:r.color},null,8,up)],512))}});function fp(a,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n]);return t}function dp(a,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return a[t]!==void 0}function pp(a){var t,n;let e=a.value;return a.value&&((n=(t=a.value)==null?void 0:t.value)!=null&&n.isMesh)&&(e=a.value.value.position),Array.isArray(a.value)&&(e=new l.Vector3(...e)),e}ne.Align=yd,ne.AnimatedSprite=_i,ne.Backdrop=xd,ne.BakeShadows=Kh,ne.BaseCameraControls=Ve,ne.Billboard=ji,ne.Box=wf,ne.CameraControls=yu,ne.CatmullRomCurve3=Mf,ne.Circle=Pf,ne.Cone=If,ne.ContactShadows=bd,ne.CubeCamera=Ri,ne.CustomShaderMaterial=Dh,ne.Cylinder=Df,ne.Dodecahedron=Uf,ne.Edges=hu,ne.Environment=ip,ne.FBXModel=Du,ne.Fbo=tu,ne.Fit=Md,ne.GLTFModel=Fu,ne.GlobalAudio=Wi,ne.GradientTexture=Xi,ne.Grid=Pd,ne.HolographicMaterial=Bh,ne.Html=sf,ne.Icosahedron=zf,ne.Image=Qi,ne.KeyboardControls=_u,ne.Lensflare=zc,ne.Levioso=Vc,ne.Lightformer=hp,ne.Line2=Es,ne.MapControls=xu,ne.Mask=Rc,ne.MeshDiscardMaterial=Nh,ne.MeshGlassMaterial=zh,ne.MeshReflectionMaterial=Yh,ne.MeshWobbleMaterial=Zh,ne.MouseParallax=jc,ne.Ocean=Td,ne.Octahedron=Rf,ne.OrbitControls=bu,ne.Outline=Yc,ne.Plane=Xf,ne.PointerLockControls=_s,ne.PositionalAudio=Ec,ne.Precipitation=Ld,ne.Reflector=Kc,ne.Ring=Kf,ne.RoundedBox=Jf,ne.SVG=Tu,ne.Sampler=nu,ne.ScreenSizer=cu,ne.ScreenSpace=Qc,ne.ScrollControls=Su,ne.Sky=kd,ne.Smoke=zd,ne.SoftShadows=Gd,ne.Sparkles=np,ne.Sphere=ed,ne.Stars=sp,ne.Stats=hf,ne.StatsGl=pf,ne.Superformula=od,ne.Tetrahedron=ad,ne.Text3D=Hc,ne.Torus=ud,ne.TorusKnot=dd,ne.TransformControls=Pu,ne.Tube=gd,ne.extractBindingPosition=pp,ne.hasSetter=dp,ne.pick=fp,ne.useAnimations=$c,ne.useEnvironment=rs,ne.useFBO=ns,ne.useFBX=vs,ne.useGLTF=xs,ne.useGLTFExporter=gf,ne.useMask=eu,ne.useProgress=Ru,ne.useSurfaceSampler=os,ne.useVideoTexture=ju,Object.defineProperty(ne,Symbol.toStringTag,{value:"Module"})});
|