@tomorrowevening/hermes 0.0.155 → 0.0.157
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/hermes.cjs.js
CHANGED
|
@@ -46,7 +46,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
46
46
|
let props = %s;
|
|
47
47
|
<%s key={someKey} {...props} />`,Ol,ki,p0,ki),dd[ki+Ol]=!0}}return v===s?l0(Ze):o0(Ze),Ze}}function c0(v,G,Y){return pd(v,G,Y,!0)}function h0(v,G,Y){return pd(v,G,Y,!1)}var u0=h0,d0=c0;Sr.Fragment=s,Sr.jsx=u0,Sr.jsxs=d0}()),Sr}var bd;function cx(){return bd||(bd=1,process.env.NODE_ENV==="production"?Da.exports=ox():Da.exports=lx()),Da.exports}var C=cx();function Xh(a){return a.title.search("<")>-1?C.jsx("button",{className:"svg",dangerouslySetInnerHTML:{__html:a.title}}):C.jsx("button",{children:a.title})}const hx=C.jsxs("svg",{className:"closeIcon",width:"14",height:"14",fill:"none",stroke:"#666666",strokeMiterlimit:"10",children:[C.jsx("circle",{cx:"7",cy:"7",r:"6"}),C.jsx("line",{x1:"4",y1:"4",x2:"10",y2:"10"}),C.jsx("line",{x1:"4",y1:"10",x2:"10",y2:"4"})]}),ux=C.jsx("svg",{className:"dragIcon",width:"14",height:"14",fill:"#666666",stroke:"none",children:C.jsx("path",{d:`M10.43,4H3.57C3.26,4,3,4.22,3,4.5v1C3,5.78,3.26,6,3.57,6h6.86C10.74,6,11,5.78,11,5.5v-1\r
|
|
48
48
|
C11,4.22,10.74,4,10.43,4z M10.43,8H3.57C3.26,8,3,8.22,3,8.5v1C3,9.78,3.26,10,3.57,10h6.86C10.74,10,11,9.78,11,9.5v-1\r
|
|
49
|
-
C11,8.22,10.74,8,10.43,8z`})});function am(a){return C.jsx("li",{className:`reorder-item ${a.draggingIndex===a.index?"dragging":""}`,draggable:!0,onDragStart:()=>a.onDragStart(a.index),onDragOver:e=>{e.preventDefault(),a.onDragOver(a.index)},onDragEnd:a.onDragEnd,children:C.jsxs("div",{children:[ux,C.jsx("span",{children:a.title}),C.jsx("button",{className:"closeIcon",onClick:()=>a.onDelete(a.index),children:hx})]})})}function om(a){const[e,t]=W.useState(!1),[s,i]=W.useState(a.options),[n,r]=W.useState(null),o=p=>{a.onDragComplete(p),i(p)},l=p=>{const f=[...s];f.splice(p,1),o(f)},c=p=>{r(p)},h=p=>{if(n===p||n===null)return;const f=[...s],m=f.splice(n,1)[0];f.splice(p,0,m),r(p),i(f)},u=()=>{a.onDragComplete(s),r(null)};let d="dropdown draggable";return a.subdropdown&&(d+=" subdropdown"),C.jsxs("div",{className:d,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[C.jsx(Xh,{title:a.title}),C.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((p,f)=>C.jsx(am,{title:p,index:f,draggingIndex:n,onDelete:l,onDragStart:c,onDragOver:h,onDragEnd:u},p))})]})}function lm(a){const[e,t]=W.useState(!1),s=[];a.options.map((n,r)=>{a.onSelect!==void 0&&(n.onSelect=a.onSelect),s.push(C.jsx(cm,{option:n},r))});let i="dropdown";return a.subdropdown&&(i+=" subdropdown"),C.jsxs("div",{className:i,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[C.jsx(Xh,{title:a.title}),C.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function cm(a){const{option:e}=a,[t,s]=W.useState("");let i;switch(e.type){case"draggable":i=C.jsx(om,{title:e.title,options:e.value,onDragComplete:n=>{e.onDragComplete!==void 0&&e.onDragComplete(n)},subdropdown:!0});break;case"dropdown":i=C.jsx(lm,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":i=C.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return C.jsx("li",{className:t===e.title?"selected":"",children:i},Jf())}function fa(a){const[e,t]=W.useState(a.open!==void 0?a.open:!0),s=!e||a.children===void 0,i=W.useRef(null),n=()=>{a.app.dispatchEvent({type:Q.REMOVE_SCENE,value:a.scene})};return C.jsxs("div",{className:`accordion ${s?"hide":""}`,children:[C.jsxs("button",{className:"toggle",onClick:()=>{const r=!e;a.onToggle!==void 0&&a.onToggle(r),t(r)},children:[C.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),C.jsx("p",{className:"label",children:pa(a.label)})]}),a.onRefresh?C.jsxs(C.Fragment,{children:[C.jsx("button",{className:"visibility",ref:i,onClick:()=>{const o=a.app.components.get("three").getScene(a.scene.uuid);if(o){const l=!o.visible;o.visible=l,i.current.style.opacity=l?"1":"0.25"}}}),C.jsx("button",{className:"refresh",onClick:a.onRefresh}),C.jsx("button",{className:"remove",onClick:n})]}):null,a.button,C.jsx("div",{className:e?"open":"",children:C.jsx("div",{children:a.children})},Math.random())]})}function Zh(a){const e=W.useRef(null),[t,s]=W.useState(!1),i=a.child!==void 0&&a.child.children.length>0,n=[];return a.child!==void 0&&a.child.children.length>0&&a.child.children.map((r,o)=>{n.push(C.jsx(Zh,{app:a.app,child:r,three:a.three},o))}),W.useEffect(()=>{if(a.child){const r=a.three.getScene(a.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",a.child.uuid);o!==void 0&&(e.current.style.opacity=o.visible?"1":"0.25")}else console.log(`Hermes - Can't find Scene: ${a.child.uuid}`)}},[t]),C.jsx(C.Fragment,{children:a.child!==void 0&&C.jsxs("div",{className:"childObject",children:[C.jsxs("div",{className:"child",children:[i?C.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,C.jsx("button",{className:"name",style:{left:i?"20px":"5px"},onClick:()=>{a.child!==void 0&&(a.three.getObject(a.child.uuid),t||s(!0))},children:a.child.name.length>0?`${a.child.name} (${a.child.type})`:`${a.child.type}::${a.child.uuid}`}),C.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(a.child){const r=a.three.getScene(a.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",a.child.uuid);if(o!==void 0){const l="visible",c=!o.visible;e.current.style.opacity=c?"1":"0.25",a.three.updateObject(a.child.uuid,l,c),qe(o,l,c)}else console.log(`Hermes - Couldn't find object: ${a.child.uuid}`,r)}else console.log(`Hermes - Couldn't find object in scene: ${a.child.uuid}, ${a.child.name}`)}}}),C.jsx("div",{className:`icon ${tx(a.child)}`})]}),C.jsx("div",{className:t?"open":"",children:C.jsx("div",{className:"container",children:n})})]},Math.random())})}function hh(a){const e=[];return a.child?.children.map((t,s)=>{e.push(C.jsx(Zh,{app:a.app,child:t,scene:a.scene,three:a.three},s))}),C.jsx("div",{className:`scene ${a.class!==void 0?a.class:""}`,children:e})}function Xr(a){const[e,t]=W.useState(a.defaultValue);return W.useEffect(()=>{let s=!1,i=-1,n=0,r=a.defaultValue,o=!1;const l=p=>{o=p.ctrlKey},c=p=>{s=!0,n=Number(a.input.current?.value),i=p.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=p=>{if(!s)return;const f=a.step!==void 0?a.step:1,m=(p.clientX-i)*f*(o?10:1);r=Number((n+m).toFixed(4)),a.min!==void 0&&(r=Math.max(r,a.min)),a.max!==void 0&&(r=Math.min(r,a.max)),a.onChange!==void 0&&a.onChange(r),t(r)},u=()=>{s=!1,document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u)},d=p=>{const f=Number(p.target.value);a.onChange!==void 0&&a.onChange(f),t(f)};return a.label.current?.addEventListener("mousedown",c,!1),a.sliderRef!==void 0&&a.sliderRef.current?.addEventListener("input",d),document.addEventListener("keydown",l,!1),document.addEventListener("keyup",l,!1),()=>{a.label.current?.removeEventListener("mousedown",c),a.sliderRef!==void 0&&a.sliderRef.current?.removeEventListener("input",d),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u),document.removeEventListener("keydown",l),document.addEventListener("keyup",l,!1)}},[]),e}function cn(a){const e=W.useRef(null),t=W.useRef(null),[s,i]=W.useState(a.value);return Xr({label:a.labelRef,input:e,sliderRef:t,defaultValue:s,min:a.min,max:a.max,step:a.step,onChange:n=>{i(n),a.onChange!==void 0&&a.onChange(a.prop,n)}}),C.jsxs(C.Fragment,{children:[a.type==="number"&&C.jsx("input",{alt:a.alt,className:a.className,ref:e,type:"number",value:s,min:a.min,max:a.max,step:a.step,disabled:a.disabled,onChange:n=>{if(i(n.target.value),n.target.value.length===0)return;const r=Number(n.target.value);isNaN(r)||a.onChange!==void 0&&a.onChange(a.prop,r)}}),a.type==="range"&&C.jsxs(C.Fragment,{children:[C.jsx("input",{type:"text",value:s.toString(),disabled:a.disabled,ref:e,className:"min",onChange:n=>{if(n.target.value.length===0)return;const r=Number(n.target.value);isNaN(r)||(i(r),a.onChange!==void 0&&a.onChange(a.prop,r))}}),C.jsx("input",{disabled:a.disabled,type:"range",value:s,min:a.min,max:a.max,step:a.step,ref:t,onChange:da})]})]})}function dx(a){const e=W.useRef(null),t=W.useRef(null),s=W.useRef(null),i=W.useRef(null),n=W.useRef(null),r=W.useRef(null),o=W.useRef(null),l=W.useRef(null),c=W.useRef(null),h=W.useRef(null),[u,d]=W.useState(a.value.x),[p,f]=W.useState(a.value.y),[m,y]=W.useState({min:Math.min(a.min,Math.min(a.value.x,a.value.y)),max:Math.max(a.max,Math.max(a.value.x,a.value.y))}),[g,_]=W.useState(!1);Xr({label:o,input:e,defaultValue:u,min:m.min,max:m.max,step:.01,onChange:P=>{d(P),a.onChange({target:{value:{x:P,y:p}}})}}),Xr({label:l,input:t,defaultValue:p,min:m.min,max:m.max,step:.01,onChange:P=>{f(P),a.onChange({target:{value:{x:u,y:P}}})}}),Xr({label:c,input:s,defaultValue:m.min,min:m.min-1,max:m.max+1,step:.01,onChange:P=>{y({min:P,max:m.max})}}),Xr({label:h,input:i,defaultValue:m.max,min:m.min-1,max:m.max+1,step:.01,onChange:P=>{y({min:m.min,max:P})}});function b(){g||(window.addEventListener("mousemove",S),window.addEventListener("mouseup",T),_(!0))}function T(){window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",T),_(!1)}function S(P){const z=n.current.getBoundingClientRect(),$=Ti(0,99,P.clientX-z.left)/99,q=1-Ti(0,99,P.clientY-z.top)/99,j=ss(rr(m.min,m.max,$),3),X=ss(rr(m.min,m.max,q),3);a.onChange({target:{value:{x:j,y:X}}}),d(j),f(X)}function M(){const P=Number(s.current.value);y({min:P,max:m.max}),u<P&&d(Ti(P,m.max,u)),p<P&&f(Ti(P,m.max,p))}function w(){const P=Number(i.current.value);y({min:m.min,max:P}),u>P&&d(Ti(m.min,P,u)),p>P&&f(Ti(m.min,P,p))}W.useEffect(()=>{r.current.style.left=`${Uo(m.min,m.max,u)*100}%`,r.current.style.top=`${(1-Uo(m.min,m.max,p))*100}%`},[m,u,p]);const R=a.step!==void 0?a.step:.01;return C.jsxs("div",{className:"vector2",children:[C.jsxs("div",{className:"fields",children:[C.jsxs("div",{children:[C.jsx("label",{ref:o,children:"X"}),C.jsx("input",{ref:e,type:"number",value:u,min:m.min,max:m.max,step:R,onChange:P=>{if(d(P.target.value),P.target.value.length===0)return;const z=Number(P.target.value);isNaN(z)||(a.onChange({target:{value:{x:z,y:p}}}),z<m.min&&y({min:z,max:m.max}))}})]}),C.jsxs("div",{children:[C.jsx("label",{ref:l,children:"Y"}),C.jsx("input",{ref:t,type:"number",value:p,min:m.min,max:m.max,step:R,onChange:P=>{if(f(P.target.value),P.target.value.length===0)return;const z=Number(P.target.value);isNaN(z)||(a.onChange({target:{value:{x:u,y:z}}}),z>m.max&&y({min:m.min,max:z}))}})]}),C.jsxs("div",{children:[C.jsx("label",{ref:c,children:"Min"}),C.jsx("input",{ref:s,type:"number",value:m.min,step:R,onChange:M})]}),C.jsxs("div",{children:[C.jsx("label",{ref:h,children:"Max"}),C.jsx("input",{ref:i,type:"number",value:m.max,step:R,onChange:w})]})]}),C.jsxs("div",{className:"input",ref:n,onMouseDown:b,onMouseUp:T,children:[C.jsx("div",{className:"x"}),C.jsx("div",{className:"y"}),C.jsx("div",{className:"pt",ref:r})]})]})}const mt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Td=1234567;const na=Math.PI/180,ar=180/Math.PI;function Xs(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(mt[a&255]+mt[a>>8&255]+mt[a>>16&255]+mt[a>>24&255]+"-"+mt[e&255]+mt[e>>8&255]+"-"+mt[e>>16&15|64]+mt[e>>24&255]+"-"+mt[t&63|128]+mt[t>>8&255]+"-"+mt[t>>16&255]+mt[t>>24&255]+mt[s&255]+mt[s>>8&255]+mt[s>>16&255]+mt[s>>24&255]).toLowerCase()}function de(a,e,t){return Math.max(e,Math.min(t,a))}function Qh(a,e){return(a%e+e)%e}function Ki(a,e,t,s,i){return s+(a-e)*(i-s)/(t-e)}function px(a,e,t){return a!==e?(t-a)/(e-a):0}function Ni(a,e,t){return(1-t)*a+t*e}function fx(a,e,t,s){return Ni(a,e,1-Math.exp(-t*s))}function mx(a,e=1){return e-Math.abs(Qh(a,e*2)-e)}function gx(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function yx(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function xx(a,e){return a+Math.floor(Math.random()*(e-a+1))}function _x(a,e){return a+Math.random()*(e-a)}function bx(a){return a*(.5-Math.random())}function Tx(a){a!==void 0&&(Td=a);let e=Td+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function zo(a){return a*na}function hm(a){return a*ar}function Sx(a){return(a&a-1)===0&&a!==0}function vx(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function wx(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Ex(a,e,t,s,i){const n=Math.cos,r=Math.sin,o=n(t/2),l=r(t/2),c=n((e+s)/2),h=r((e+s)/2),u=n((e-s)/2),d=r((e-s)/2),p=n((s-e)/2),f=r((s-e)/2);switch(i){case"XYX":a.set(o*h,l*u,l*d,o*c);break;case"YZY":a.set(l*d,o*h,l*u,o*c);break;case"ZXZ":a.set(l*u,l*d,o*h,o*c);break;case"XZX":a.set(o*h,l*f,l*p,o*c);break;case"YXY":a.set(l*p,o*h,l*f,o*c);break;case"ZYZ":a.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function At(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function oe(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}const Mx={DEG2RAD:na,RAD2DEG:ar,generateUUID:Xs,clamp:de,euclideanModulo:Qh,mapLinear:Ki,inverseLerp:px,lerp:Ni,damp:fx,pingpong:mx,smoothstep:gx,smootherstep:yx,randInt:xx,randFloat:_x,randFloatSpread:bx,seededRandom:Tx,degToRad:zo,radToDeg:hm,isPowerOfTwo:Sx,ceilPowerOfTwo:vx,floorPowerOfTwo:wx,setQuaternionFromProperEuler:Ex,normalize:oe,denormalize:At};function Sd(a){const e=a.value.x!==void 0&&a.value.y!==void 0&&a.value.z!==void 0,t=a.value.isEuler!==void 0,s=a.value.elements!==void 0,i=a.step!==void 0?a.step:.01,n=[];if(t){const r=W.useMemo(()=>a.value,[]);["_x","_y","_z"].forEach(l=>{const c=W.useRef(null);n.push(C.jsxs("div",{children:[C.jsx("label",{ref:c,children:l.substring(1).toUpperCase()}),C.jsx(cn,{value:hm(r[l]),type:"number",prop:l,step:.1,labelRef:c,onChange:(h,u)=>{r[h]=zo(u),a.onChange({target:{value:r}})}})]},l))})}else if(e){const r=W.useMemo(()=>a.value,[]),o=(c,h)=>{r[c]=h,a.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const h=W.useRef(null);n.push(C.jsxs("div",{children:[C.jsx("label",{ref:h,children:c.toUpperCase()}),C.jsx(cn,{value:r[c],type:"number",prop:c,step:i,labelRef:h,onChange:o})]},c))})}else if(s){const r=W.useMemo(()=>a.value,[]),o=(l,c)=>{const h=Number(l);r.elements[h]=c,a.onChange({target:{value:r}})};for(let l=0;l<9;l++){const c=W.useRef(null);n.push(C.jsxs("div",{children:[C.jsx("label",{ref:c,children:l+1}),C.jsx(cn,{value:r.elements[l],type:"number",prop:l.toString(),step:i,labelRef:c,onChange:o})]},l.toString()))}}return C.jsx("div",{className:"grid3",children:n},Math.random().toString())}function Cx(a){const e=a.value.x!==void 0,t=a.step!==void 0?a.step:.01,s=[];if(e){const i=W.useMemo(()=>a.value,[]),n=(o,l)=>{i[o]=l,a.onChange({target:{value:i}})};["x","y","z","w"].forEach(o=>{const l=W.useRef(null);s.push(C.jsxs("div",{children:[C.jsx("label",{ref:l,children:o.toUpperCase()}),C.jsx(cn,{value:i[o],type:"number",prop:o,step:t,labelRef:l,onChange:n})]},o))})}else{const i=W.useMemo(()=>a.value,[]),n=(r,o)=>{const l=Number(r);i.elements[l]=o,a.onChange({target:{value:i}})};for(let r=0;r<16;r++){const o=W.useRef(null);s.push(C.jsxs("div",{children:[C.jsx("label",{ref:o,children:r+1}),C.jsx(cn,{value:i.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:n})]},r.toString()))}}return C.jsx("div",{className:"grid4",children:s})}function Ax(a){return!(a==="defaultAttributeValues"||a==="forceSinglePass"||a==="linecap"||a==="linejoin"||a==="linewidth"||a==="normalMapType"||a==="precision"||a==="shadowSide"||a==="uniformsGroups"||a==="uniformsNeedUpdate"||a==="userData"||a==="version"||a==="wireframeLinecap"||a==="wireframeLinejoin"||a==="wireframeLinewidth"||a.slice(0,4)==="clip"||a.slice(0,7)==="polygon"||a.slice(0,7)==="stencil"||a.slice(0,2)==="is")}function Rx(a){switch(a){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return a}function ll(a){switch(a){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return a}function um(a){const e=a.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function Nx(){const a=document.createElement("input");return a.type="file",new Promise((e,t)=>{a.addEventListener("change",function(){if(a.files===null)t();else{const s=a.files[0],i=new FileReader;i.onload=function(n){e(n.target.result)},i.readAsDataURL(s)}}),a.click()})}const Px=[{title:"Front",value:x.FrontSide},{title:"Back",value:x.BackSide},{title:"Double",value:x.DoubleSide}],Dx=[{title:"No Blending",value:x.NoBlending},{title:"Normal",value:x.NormalBlending},{title:"Additive",value:x.AdditiveBlending},{title:"Subtractive",value:x.SubtractiveBlending},{title:"Multiply",value:x.MultiplyBlending},{title:"Custom",value:x.CustomBlending}],Fx=[{title:"Add",value:x.AddEquation},{title:"Subtract",value:x.SubtractEquation},{title:"Reverse Subtract",value:x.ReverseSubtractEquation},{title:"Min",value:x.MinEquation},{title:"Max",value:x.MaxEquation}],Ox=[{title:"Zero",value:x.ZeroFactor},{title:"One",value:x.OneFactor},{title:"Src Color",value:x.SrcColorFactor},{title:"One Minus Src Color",value:x.OneMinusSrcColorFactor},{title:"Src Alpha",value:x.SrcAlphaFactor},{title:"One Minus Src Alpha",value:x.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:x.DstAlphaFactor},{title:"One Minus Dst Alpha",value:x.OneMinusDstAlphaFactor},{title:"Dst Color",value:x.DstColorFactor},{title:"One Minus Dst Color",value:x.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:x.SrcAlphaSaturateFactor},{title:"Constant Color",value:x.ConstantColorFactor},{title:"One Minus Constant Color",value:x.OneMinusConstantColorFactor},{title:"Constant Alpha",value:x.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:x.OneMinusConstantAlphaFactor}],Bx=[{title:"Zero",value:x.ZeroFactor},{title:"One",value:x.OneFactor},{title:"Src Color",value:x.SrcColorFactor},{title:"One Minus Src Color",value:x.OneMinusSrcColorFactor},{title:"Src Alpha",value:x.SrcAlphaFactor},{title:"One Minus Src Alpha",value:x.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:x.DstAlphaFactor},{title:"One Minus Dst Alpha",value:x.OneMinusDstAlphaFactor},{title:"Dst Color",value:x.DstColorFactor},{title:"One Minus Dst Color",value:x.OneMinusDstColorFactor},{title:"Constant Color",value:x.ConstantColorFactor},{title:"One Minus Constant Color",value:x.OneMinusConstantColorFactor},{title:"Constant Alpha",value:x.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:x.OneMinusConstantAlphaFactor}];function vr(a,e){a.needsUpdate=!0,a.type="option",a.options=e}function Ix(a,e,t,s){return{type:"boolean",title:ll(a),prop:a,value:e,needsUpdate:!0,onChange:(i,n)=>{s.updateObject(t.uuid,`material.${a}`,n),s.updateObject(t.uuid,"material.needsUpdate",!0);const r=s.getScene(t.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",t.uuid);qe(o,`material.${a}`,n)}}}}function Lx(a,e,t,s){const i={type:"number",title:ll(a),prop:a,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(n,r)=>{s.updateObject(t.uuid,`material.${a}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);qe(l,`material.${a}`,r)}}};switch(a){case"blending":vr(i,Dx);break;case"blendDst":vr(i,Bx);break;case"blendEquation":vr(i,Fx);break;case"blendSrc":vr(i,Ox);break;case"side":vr(i,Px);break}return um(a)&&(i.value=Number(e),i.type="range",i.min=Math.min(0,i.value),i.max=Math.max(1,i.value),i.step=.01),i}function Ux(a,e,t,s){const i={type:"string",title:ll(a),prop:a,value:e,needsUpdate:!0,onChange:(r,o)=>{s.updateObject(t.uuid,`material.${a}`,o),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const c=l.getObjectByProperty("uuid",t.uuid);qe(c,`material.${a}`,o)}},onKeyDown:r=>{}};return(a==="vertexShader"||a==="fragmentShader")&&(i.type="field",i.disabled=!1,i.latest=i.value,i.onChange=(r,o)=>{i.latest=o,s.updateObject(t.uuid,`material.${a}`,o);const l=s.getScene(t.uuid);if(l!==null){const c=l.getObjectByProperty("uuid",t.uuid);qe(c,`material.${a}`,o)}},i.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);qe(l,"material.needsUpdate",!0)}}}),i}function kx(a){return a.x!==void 0&&a.y!==void 0&&a.z===void 0}function zx(a){return a.x!==void 0&&a.y!==void 0&&a.z!==void 0&&a.w===void 0}function Gx(a){return a.x!==void 0&&a.y!==void 0&&a.z!==void 0&&a.w!==void 0}function uh(a){a.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Zr(a,e,t,s,i="",n=!1){const r=ll(a).split(".")[0].replaceAll("[","").replaceAll("]",""),o=i.length>0?`${i}.${a}`:a,l=typeof e;if(l==="boolean"||l==="string")return{title:r,prop:o,type:l,value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(l==="number"){const c={title:r,prop:o,type:"number",value:e,step:.01,disabled:n,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const d=s.getScene(t.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",t.uuid);qe(p,`material.${o}`,u)}}};return um(r)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:n,onChange:(c,h)=>{const u=new x.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const d=s.getScene(t.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",t.uuid);qe(p,`material.${o}`,u)}}};if(Array.isArray(e)){const c=[];for(const h in e){const u=e[h],d=`[${h.toString()}]`;if(u.value!==void 0){const p=Zr(`${d}.value`,u.value,t,s,o,n);p!==void 0&&c.push(p)}else{const p=Zr(d,u,t,s,o,n);p!==void 0&&c.push(p)}}if(c.length>0)return uh(c),{title:r,items:c}}else{if(kx(e))return{title:r,prop:o,type:"vector2",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(zx(e))return{title:r,prop:o,type:"grid3",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(Gx(e))return{title:r,prop:o,type:"grid4",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(e.isEuler)return{title:r,prop:o,type:"euler",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:n,onChange:(c,h)=>{const u=Rx(a),d=i.length>0?`${i}.${u}`:u;s.createTexture(t.uuid,`material.${d}`,h);const p=s.getScene(t.uuid);if(p!==null){const f=p.getObjectByProperty("uuid",t.uuid);if(f!==void 0){const m=y=>{const g=f.material,_=d.split(".");switch(_.length){case 1:g[_[0]]=y;break;case 2:g[_[0]][_[1]]=y;break;case 3:g[_[0]][_[1]][_[2]]=y;break;case 4:g[_[0]][_[1]][_[2]][_[3]]=y;break;case 5:g[_[0]][_[1]][_[2]][_[3]][_[4]]=y;break}g.needsUpdate=!0};h.src.length>0?rm(h.src).then(y=>{y.offset.set(h.offset[0],h.offset[1]),y.repeat.set(h.repeat[0],h.repeat[1]),m(y)}):m(null)}}}};if(e.elements!==void 0)return{title:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};{const c=[],h=a==="defines"||a==="extensions";try{for(const u in e){const d=e[u];if(d!==void 0)if(d.value!==void 0){const p=Zr(`${u}.value`,d.value,t,s,o,h);p!==void 0&&c.push(p)}else{const p=Zr(u,d,t,s,o,h);p!==void 0&&c.push(p)}}}catch{console.log("Issue cycling through material object:",a,e)}if(c.length>0)return uh(c),{title:r,items:c}}}}}function vd(a,e,t){const s=[];for(const i in a){if(!Ax(i))continue;const n=typeof a[i],r=a[i];if(n==="boolean")s.push(Ix(i,r,e,t));else if(n==="number")s.push(Lx(i,r,e,t));else if(n==="string")s.push(Ux(i,r,e,t));else if(n==="object"){const o=Zr(i,r,e,t);o!==void 0&&s.push(o)}else r!==void 0&&console.log("other:",i,n,r)}return uh(s),s.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const i=t.getScene(e.uuid);if(i!==null){const n=i.getObjectByProperty("uuid",e.uuid);qe(n,"material.needsUpdate",!0)}}}),s}function Vx(a,e,t){function s(){return`${t.app.appID}_material`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=a.material;if(Array.isArray(o)){const l=[],c=o.length;for(let h=0;h<c;h++)l.push(C.jsx(cs,{app:e,title:`Material ${h}`,items:vd(o[h],a,t)},`Material ${h}`));return C.jsx(C.Fragment,{children:l})}else return C.jsx(cs,{app:e,title:"Material",items:vd(o,a,t),expanded:n,onToggle:l=>{r(l)}})}const wd="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function Hx(a){const e=a.step!==void 0?a.step:.01,t=W.useRef(null),s=W.useRef(null),i=W.useRef(null),n=W.useRef(null),r=W.useRef(null),[o]=W.useState(a.value),[l,c]=W.useState(a.value.offset[0]),[h,u]=W.useState(a.value.offset[1]),[d,p]=W.useState(a.value.repeat[0]),[f,m]=W.useState(a.value.repeat[1]);function y(_,b,T,S,M){if(a.onChange!==void 0){const w=a.prop!==void 0?a.prop:a.title;a.onChange(w,{src:_,offset:[b,T],repeat:[S,M]})}}function g(_){const b=t.current.src,T=_.target.value;switch(_.target){case s.current:c(T),y(b,T,h,d,f);break;case i.current:u(T),y(b,l,T,d,f);break;case n.current:p(T),y(b,l,h,T,f);break;case r.current:m(T),y(b,l,h,d,T);break}}return C.jsxs("div",{className:"imageField",children:[C.jsx("img",{alt:a.title,ref:t,onClick:()=>{Nx().then(_=>{t.current.src=_,y(_,l,h,d,f)})},src:o.src.length>0?o.src:wd}),C.jsxs("div",{className:"fields",children:[C.jsxs("div",{children:[C.jsx("label",{children:"Offset:"}),C.jsx("input",{ref:s,type:"number",value:l,step:e,onChange:g}),C.jsx("input",{ref:i,type:"number",value:h,step:e,onChange:g})]}),C.jsxs("div",{children:[C.jsx("label",{children:"Repeat:"}),C.jsx("input",{ref:n,type:"number",value:d,step:e,onChange:g}),C.jsx("input",{ref:r,type:"number",value:f,step:e,onChange:g})]}),C.jsx("button",{onClick:()=>{y("",l,h,d,f),t.current.src=wd},children:"Clear"})]})]})}function Eo(a){let e=a.value;e!==void 0&&(e.isColor!==void 0?e=ah(a.value):a.type==="color"&&(e=ah(new x.Color().setStyle(a.value,x.LinearSRGBColorSpace))));const[t,s]=W.useState(e),i=W.useRef(null),n=c=>{let h=c.target.value;if(a.type==="boolean")h=c.target.checked;else if(a.type==="option"&&(typeof a.value=="number"?h=Number(h):typeof a.value=="boolean"?h=!!h:typeof a.value=="object"&&(h=JSON.parse(h)),a.options!==void 0)){const u=a.options.length;for(let d=0;d<u&&a.options[d].value!==h;d++);}s(h),a.onChange!==void 0&&a.onChange(a.prop!==void 0?a.prop:a.title,h)},r={};a.disabled&&(r.opacity=.8);const o=a.type==="field"||a.type==="string"&&(t.length>100||t.search(`
|
|
49
|
+
C11,8.22,10.74,8,10.43,8z`})});function am(a){return C.jsx("li",{className:`reorder-item ${a.draggingIndex===a.index?"dragging":""}`,draggable:!0,onDragStart:()=>a.onDragStart(a.index),onDragOver:e=>{e.preventDefault(),a.onDragOver(a.index)},onDragEnd:a.onDragEnd,children:C.jsxs("div",{children:[ux,C.jsx("span",{children:a.title}),C.jsx("button",{className:"closeIcon",onClick:()=>a.onDelete(a.index),children:hx})]})})}function om(a){const[e,t]=W.useState(!1),[s,i]=W.useState(a.options),[n,r]=W.useState(null),o=p=>{a.onDragComplete(p),i(p)},l=p=>{const f=[...s];f.splice(p,1),o(f)},c=p=>{r(p)},h=p=>{if(n===p||n===null)return;const f=[...s],m=f.splice(n,1)[0];f.splice(p,0,m),r(p),i(f)},u=()=>{a.onDragComplete(s),r(null)};let d="dropdown draggable";return a.subdropdown&&(d+=" subdropdown"),C.jsxs("div",{className:d,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[C.jsx(Xh,{title:a.title}),C.jsx("ul",{className:"reorder-list",style:{display:e?"block":"none"},children:s.map((p,f)=>C.jsx(am,{title:p,index:f,draggingIndex:n,onDelete:l,onDragStart:c,onDragOver:h,onDragEnd:u},p))})]})}function lm(a){const[e,t]=W.useState(!1),s=[];a.options.map((n,r)=>{a.onSelect!==void 0&&(n.onSelect=a.onSelect),s.push(C.jsx(cm,{option:n},r))});let i="dropdown";return a.subdropdown&&(i+=" subdropdown"),C.jsxs("div",{className:i,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[C.jsx(Xh,{title:a.title}),C.jsx("ul",{style:{visibility:e?"visible":"hidden"},children:s})]})}function cm(a){const{option:e}=a,[t,s]=W.useState("");let i;switch(e.type){case"draggable":i=C.jsx(om,{title:e.title,options:e.value,onDragComplete:n=>{e.onDragComplete!==void 0&&e.onDragComplete(n)},subdropdown:!0});break;case"dropdown":i=C.jsx(lm,{title:e.title,options:e.value,onSelect:e.onSelect,subdropdown:!0});break;case"option":i=C.jsx("button",{onClick:()=>{e.onSelect!==void 0&&e.onSelect(e.value),e.selectable&&(t!==e.title?s(e.title):s(""))},children:e.title});break}return C.jsx("li",{className:t===e.title?"selected":"",children:i},Jf())}function fa(a){const[e,t]=W.useState(a.open!==void 0?a.open:!0),s=!e||a.children===void 0,i=W.useRef(null),n=()=>{a.app.dispatchEvent({type:Q.REMOVE_SCENE,value:a.scene})};return C.jsxs("div",{className:`accordion ${s?"hide":""}`,children:[C.jsxs("button",{className:"toggle",onClick:()=>{const r=!e;a.onToggle!==void 0&&a.onToggle(r),t(r)},children:[C.jsx("p",{className:`status ${e?"open":""}`,children:"Toggle"}),C.jsx("p",{className:"label",children:pa(a.label)})]}),a.onRefresh?C.jsxs(C.Fragment,{children:[C.jsx("button",{className:"visibility",ref:i,onClick:()=>{const o=a.app.components.get("three").getScene(a.scene.uuid);if(o){const l=!o.visible;o.visible=l,i.current.style.opacity=l?"1":"0.25"}}}),C.jsx("button",{className:"refresh",onClick:a.onRefresh}),C.jsx("button",{className:"remove",onClick:n})]}):null,a.button,C.jsx("div",{className:e?"open":"",children:C.jsx("div",{children:a.children})},Math.random())]})}function Zh(a){if(a.child===void 0)return console.log("Hermes - No child attached"),null;const e=W.useRef(null),[t,s]=W.useState(!1),i=a.child.children.length>0,n=[];return a.child.children.length>0&&a.child.children.map((r,o)=>{n.push(C.jsx(Zh,{app:a.app,child:r,three:a.three},o))}),W.useEffect(()=>{if(a.child){const r=a.three.getScene(a.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",a.child.uuid);o!==void 0&&(e.current.style.opacity=o.visible?"1":"0.25")}else console.log(`Hermes - Can't find Scene: ${a.child.uuid}`)}},[t]),C.jsxs("div",{className:"childObject",children:[C.jsxs("div",{className:"child",children:[i?C.jsx("button",{className:"status",style:{backgroundPositionX:t?"-14px":"2px"},onClick:()=>{s(!t)}}):null,C.jsx("button",{className:"name",style:{left:i?"20px":"5px"},onClick:()=>{a.child!==void 0?(a.three.getObject(a.child.uuid),!t&&i&&s(!0)):console.log("Hermes - No child attached...")},children:a.child.name.length>0?`${a.child.name} (${a.child.type})`:`${a.child.type}::${a.child.uuid}`}),C.jsx("button",{className:"visibility",ref:e,onClick:()=>{if(a.child){const r=a.three.getScene(a.child.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",a.child.uuid);if(o!==void 0){const l="visible",c=!o.visible;e.current.style.opacity=c?"1":"0.25",a.three.updateObject(a.child.uuid,l,c),qe(o,l,c)}else console.log(`Hermes - Couldn't find object: ${a.child.uuid}`,r)}else console.log(`Hermes - Couldn't find object in scene: ${a.child.uuid}, ${a.child.name}`)}}}),C.jsx("div",{className:`icon ${tx(a.child)}`})]}),C.jsx("div",{className:t?"open":"",children:C.jsx("div",{className:"container",children:n})})]},Math.random())}function hh(a){const e=[];return a.child?.children.map((t,s)=>{e.push(C.jsx(Zh,{app:a.app,child:t,scene:a.scene,three:a.three},s))}),C.jsx("div",{className:`scene ${a.class!==void 0?a.class:""}`,children:e})}function Xr(a){const[e,t]=W.useState(a.defaultValue);return W.useEffect(()=>{let s=!1,i=-1,n=0,r=a.defaultValue,o=!1;const l=p=>{o=p.ctrlKey},c=p=>{s=!0,n=Number(a.input.current?.value),i=p.clientX,document.addEventListener("mouseup",u,!1),document.addEventListener("mousemove",h,!1),document.addEventListener("contextmenu",u,!1)},h=p=>{if(!s)return;const f=a.step!==void 0?a.step:1,m=(p.clientX-i)*f*(o?10:1);r=Number((n+m).toFixed(4)),a.min!==void 0&&(r=Math.max(r,a.min)),a.max!==void 0&&(r=Math.min(r,a.max)),a.onChange!==void 0&&a.onChange(r),t(r)},u=()=>{s=!1,document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u)},d=p=>{const f=Number(p.target.value);a.onChange!==void 0&&a.onChange(f),t(f)};return a.label.current?.addEventListener("mousedown",c,!1),a.sliderRef!==void 0&&a.sliderRef.current?.addEventListener("input",d),document.addEventListener("keydown",l,!1),document.addEventListener("keyup",l,!1),()=>{a.label.current?.removeEventListener("mousedown",c),a.sliderRef!==void 0&&a.sliderRef.current?.removeEventListener("input",d),document.removeEventListener("mouseup",u),document.removeEventListener("mousemove",h),document.removeEventListener("contextmenu",u),document.removeEventListener("keydown",l),document.addEventListener("keyup",l,!1)}},[]),e}function cn(a){const e=W.useRef(null),t=W.useRef(null),[s,i]=W.useState(a.value);return Xr({label:a.labelRef,input:e,sliderRef:t,defaultValue:s,min:a.min,max:a.max,step:a.step,onChange:n=>{i(n),a.onChange!==void 0&&a.onChange(a.prop,n)}}),C.jsxs(C.Fragment,{children:[a.type==="number"&&C.jsx("input",{alt:a.alt,className:a.className,ref:e,type:"number",value:s,min:a.min,max:a.max,step:a.step,disabled:a.disabled,onChange:n=>{if(i(n.target.value),n.target.value.length===0)return;const r=Number(n.target.value);isNaN(r)||a.onChange!==void 0&&a.onChange(a.prop,r)}}),a.type==="range"&&C.jsxs(C.Fragment,{children:[C.jsx("input",{type:"text",value:s.toString(),disabled:a.disabled,ref:e,className:"min",onChange:n=>{if(n.target.value.length===0)return;const r=Number(n.target.value);isNaN(r)||(i(r),a.onChange!==void 0&&a.onChange(a.prop,r))}}),C.jsx("input",{disabled:a.disabled,type:"range",value:s,min:a.min,max:a.max,step:a.step,ref:t,onChange:da})]})]})}function dx(a){const e=W.useRef(null),t=W.useRef(null),s=W.useRef(null),i=W.useRef(null),n=W.useRef(null),r=W.useRef(null),o=W.useRef(null),l=W.useRef(null),c=W.useRef(null),h=W.useRef(null),[u,d]=W.useState(a.value.x),[p,f]=W.useState(a.value.y),[m,y]=W.useState({min:Math.min(a.min,Math.min(a.value.x,a.value.y)),max:Math.max(a.max,Math.max(a.value.x,a.value.y))}),[g,_]=W.useState(!1);Xr({label:o,input:e,defaultValue:u,min:m.min,max:m.max,step:.01,onChange:P=>{d(P),a.onChange({target:{value:{x:P,y:p}}})}}),Xr({label:l,input:t,defaultValue:p,min:m.min,max:m.max,step:.01,onChange:P=>{f(P),a.onChange({target:{value:{x:u,y:P}}})}}),Xr({label:c,input:s,defaultValue:m.min,min:m.min-1,max:m.max+1,step:.01,onChange:P=>{y({min:P,max:m.max})}}),Xr({label:h,input:i,defaultValue:m.max,min:m.min-1,max:m.max+1,step:.01,onChange:P=>{y({min:m.min,max:P})}});function b(){g||(window.addEventListener("mousemove",S),window.addEventListener("mouseup",T),_(!0))}function T(){window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",T),_(!1)}function S(P){const z=n.current.getBoundingClientRect(),$=Ti(0,99,P.clientX-z.left)/99,q=1-Ti(0,99,P.clientY-z.top)/99,j=ss(rr(m.min,m.max,$),3),X=ss(rr(m.min,m.max,q),3);a.onChange({target:{value:{x:j,y:X}}}),d(j),f(X)}function M(){const P=Number(s.current.value);y({min:P,max:m.max}),u<P&&d(Ti(P,m.max,u)),p<P&&f(Ti(P,m.max,p))}function w(){const P=Number(i.current.value);y({min:m.min,max:P}),u>P&&d(Ti(m.min,P,u)),p>P&&f(Ti(m.min,P,p))}W.useEffect(()=>{r.current.style.left=`${Uo(m.min,m.max,u)*100}%`,r.current.style.top=`${(1-Uo(m.min,m.max,p))*100}%`},[m,u,p]);const R=a.step!==void 0?a.step:.01;return C.jsxs("div",{className:"vector2",children:[C.jsxs("div",{className:"fields",children:[C.jsxs("div",{children:[C.jsx("label",{ref:o,children:"X"}),C.jsx("input",{ref:e,type:"number",value:u,min:m.min,max:m.max,step:R,onChange:P=>{if(d(P.target.value),P.target.value.length===0)return;const z=Number(P.target.value);isNaN(z)||(a.onChange({target:{value:{x:z,y:p}}}),z<m.min&&y({min:z,max:m.max}))}})]}),C.jsxs("div",{children:[C.jsx("label",{ref:l,children:"Y"}),C.jsx("input",{ref:t,type:"number",value:p,min:m.min,max:m.max,step:R,onChange:P=>{if(f(P.target.value),P.target.value.length===0)return;const z=Number(P.target.value);isNaN(z)||(a.onChange({target:{value:{x:u,y:z}}}),z>m.max&&y({min:m.min,max:z}))}})]}),C.jsxs("div",{children:[C.jsx("label",{ref:c,children:"Min"}),C.jsx("input",{ref:s,type:"number",value:m.min,step:R,onChange:M})]}),C.jsxs("div",{children:[C.jsx("label",{ref:h,children:"Max"}),C.jsx("input",{ref:i,type:"number",value:m.max,step:R,onChange:w})]})]}),C.jsxs("div",{className:"input",ref:n,onMouseDown:b,onMouseUp:T,children:[C.jsx("div",{className:"x"}),C.jsx("div",{className:"y"}),C.jsx("div",{className:"pt",ref:r})]})]})}const mt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Td=1234567;const na=Math.PI/180,ar=180/Math.PI;function Xs(){const a=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(mt[a&255]+mt[a>>8&255]+mt[a>>16&255]+mt[a>>24&255]+"-"+mt[e&255]+mt[e>>8&255]+"-"+mt[e>>16&15|64]+mt[e>>24&255]+"-"+mt[t&63|128]+mt[t>>8&255]+"-"+mt[t>>16&255]+mt[t>>24&255]+mt[s&255]+mt[s>>8&255]+mt[s>>16&255]+mt[s>>24&255]).toLowerCase()}function de(a,e,t){return Math.max(e,Math.min(t,a))}function Qh(a,e){return(a%e+e)%e}function Ki(a,e,t,s,i){return s+(a-e)*(i-s)/(t-e)}function px(a,e,t){return a!==e?(t-a)/(e-a):0}function Ni(a,e,t){return(1-t)*a+t*e}function fx(a,e,t,s){return Ni(a,e,1-Math.exp(-t*s))}function mx(a,e=1){return e-Math.abs(Qh(a,e*2)-e)}function gx(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*(3-2*a))}function yx(a,e,t){return a<=e?0:a>=t?1:(a=(a-e)/(t-e),a*a*a*(a*(a*6-15)+10))}function xx(a,e){return a+Math.floor(Math.random()*(e-a+1))}function _x(a,e){return a+Math.random()*(e-a)}function bx(a){return a*(.5-Math.random())}function Tx(a){a!==void 0&&(Td=a);let e=Td+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function zo(a){return a*na}function hm(a){return a*ar}function Sx(a){return(a&a-1)===0&&a!==0}function vx(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function wx(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Ex(a,e,t,s,i){const n=Math.cos,r=Math.sin,o=n(t/2),l=r(t/2),c=n((e+s)/2),h=r((e+s)/2),u=n((e-s)/2),d=r((e-s)/2),p=n((s-e)/2),f=r((s-e)/2);switch(i){case"XYX":a.set(o*h,l*u,l*d,o*c);break;case"YZY":a.set(l*d,o*h,l*u,o*c);break;case"ZXZ":a.set(l*u,l*d,o*h,o*c);break;case"XZX":a.set(o*h,l*f,l*p,o*c);break;case"YXY":a.set(l*p,o*h,l*f,o*c);break;case"ZYZ":a.set(l*f,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function At(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("Invalid component type.")}}function oe(a,e){switch(e.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("Invalid component type.")}}const Mx={DEG2RAD:na,RAD2DEG:ar,generateUUID:Xs,clamp:de,euclideanModulo:Qh,mapLinear:Ki,inverseLerp:px,lerp:Ni,damp:fx,pingpong:mx,smoothstep:gx,smootherstep:yx,randInt:xx,randFloat:_x,randFloatSpread:bx,seededRandom:Tx,degToRad:zo,radToDeg:hm,isPowerOfTwo:Sx,ceilPowerOfTwo:vx,floorPowerOfTwo:wx,setQuaternionFromProperEuler:Ex,normalize:oe,denormalize:At};function Sd(a){const e=a.value.x!==void 0&&a.value.y!==void 0&&a.value.z!==void 0,t=a.value.isEuler!==void 0,s=a.value.elements!==void 0,i=a.step!==void 0?a.step:.01,n=[];if(t){const r=W.useMemo(()=>a.value,[]);["_x","_y","_z"].forEach(l=>{const c=W.useRef(null);n.push(C.jsxs("div",{children:[C.jsx("label",{ref:c,children:l.substring(1).toUpperCase()}),C.jsx(cn,{value:hm(r[l]),type:"number",prop:l,step:.1,labelRef:c,onChange:(h,u)=>{r[h]=zo(u),a.onChange({target:{value:r}})}})]},l))})}else if(e){const r=W.useMemo(()=>a.value,[]),o=(c,h)=>{r[c]=h,a.onChange({target:{value:r}})};["x","y","z"].forEach(c=>{const h=W.useRef(null);n.push(C.jsxs("div",{children:[C.jsx("label",{ref:h,children:c.toUpperCase()}),C.jsx(cn,{value:r[c],type:"number",prop:c,step:i,labelRef:h,onChange:o})]},c))})}else if(s){const r=W.useMemo(()=>a.value,[]),o=(l,c)=>{const h=Number(l);r.elements[h]=c,a.onChange({target:{value:r}})};for(let l=0;l<9;l++){const c=W.useRef(null);n.push(C.jsxs("div",{children:[C.jsx("label",{ref:c,children:l+1}),C.jsx(cn,{value:r.elements[l],type:"number",prop:l.toString(),step:i,labelRef:c,onChange:o})]},l.toString()))}}return C.jsx("div",{className:"grid3",children:n},Math.random().toString())}function Cx(a){const e=a.value.x!==void 0,t=a.step!==void 0?a.step:.01,s=[];if(e){const i=W.useMemo(()=>a.value,[]),n=(o,l)=>{i[o]=l,a.onChange({target:{value:i}})};["x","y","z","w"].forEach(o=>{const l=W.useRef(null);s.push(C.jsxs("div",{children:[C.jsx("label",{ref:l,children:o.toUpperCase()}),C.jsx(cn,{value:i[o],type:"number",prop:o,step:t,labelRef:l,onChange:n})]},o))})}else{const i=W.useMemo(()=>a.value,[]),n=(r,o)=>{const l=Number(r);i.elements[l]=o,a.onChange({target:{value:i}})};for(let r=0;r<16;r++){const o=W.useRef(null);s.push(C.jsxs("div",{children:[C.jsx("label",{ref:o,children:r+1}),C.jsx(cn,{value:i.elements[r],type:"number",prop:r.toString(),step:t,labelRef:o,onChange:n})]},r.toString()))}}return C.jsx("div",{className:"grid4",children:s})}function Ax(a){return!(a==="defaultAttributeValues"||a==="forceSinglePass"||a==="linecap"||a==="linejoin"||a==="linewidth"||a==="normalMapType"||a==="precision"||a==="shadowSide"||a==="uniformsGroups"||a==="uniformsNeedUpdate"||a==="userData"||a==="version"||a==="wireframeLinecap"||a==="wireframeLinejoin"||a==="wireframeLinewidth"||a.slice(0,4)==="clip"||a.slice(0,7)==="polygon"||a.slice(0,7)==="stencil"||a.slice(0,2)==="is")}function Rx(a){switch(a){case"Alpha Map":return"alphaMap";case"Anisotropy Map":return"anisotropyMap";case"AO Map":return"aoMap";case"Bump Map":return"bumpMap";case"Clearcoat Map":return"clearcoatMap";case"Clearcoat Normal Map":return"clearcoatNormalMap";case"Clearcoat Roughness Map":return"clearcoatRoughnessMap";case"Displacement Map":return"displacementMap";case"Emissive Map":return"emissiveMap";case"Gradient Map":return"gradientMap";case"Iridescence Map":return"iridescenceMap";case"Iridescence Thickness Map":return"iridescenceThicknessMap";case"Map":return"map";case"Matcap":return"matcap";case"Normal Map":return"normalMap";case"Roughness Map":return"roughnessMap";case"Sheen Color Map":return"sheenColorMap";case"Sheen Roughness Map":return"sheenRoughnessMap";case"Specular Color Map":return"specularColorMap";case"Specular Map Intensity":return"specularIntensityMap";case"Thickness Map":return"thicknessMap";case"Transmission Map":return"transmissionMap"}return a}function ll(a){switch(a){case"alphaHash":return"Alpha Hash";case"alphaMap":return"Alpha Map";case"alphaToCoverage":return"Alpha To Coverage";case"anisotropy":return"Anisotropy";case"anisotropyMap":return"Anisotropy Map";case"anisotropyRotation":return"Anisotropy Rotation";case"aoMap":return"AO Map";case"aoMapIntensity":return"AO Map Intensity";case"attenuationColor":return"Attenuation Color";case"attenuationDistance":return"Attenuation Distance";case"blendAlpha":return"Blend Alpha";case"blendColor":return"Blend Color";case"blendDst":return"Blend Dst";case"blendDstAlpha":return"Blend Dst Alha";case"blendEquation":return"Blend Equation";case"blendEquationAlpha":return"Blend Equation Alpha";case"blending":return"Blending";case"blendSrc":return"Blend Src";case"blendSrcAlpha":return"Blend Src Alpha";case"bumpMap":return"Bump Map";case"bumpScale":return"Bump Scale";case"clearcoat":return"Clearcoat";case"clearcoatMap":return"Clearcoat Map";case"clearcoatNormalMap":return"Clearcoat Normal Map";case"clearcoatNormalScale":return"Clearcoat Normal Scale";case"clearcoatRoughness":return"Clearcoat Roughness";case"clearcoatRoughnessMap":return"Clearcoat Roughness Map";case"color":return"Color";case"colorWrite":return"Color Write";case"defines":return"Defines";case"depthFunc":return"Depth Func";case"depthTest":return"Depth Test";case"depthWrite":return"Depth Write";case"dispersion":return"Dispersion";case"displacementBias":return"Displacement Bias";case"displacementMap":return"Displacement Map";case"displacementScale":return"Displacement Scale";case"dithering":return"Dithering";case"emissive":return"Emissive";case"emissiveMap":return"Emissive Map";case"emissiveIntensity":return"Emissive Intensity";case"envMap":return"Environment Map";case"envMapIntensity":return"Environment Map Intensity";case"envMapRotation":return"Environment Map Rotation";case"extensions":return"Extensions";case"flatShading":return"Flat Shading";case"fragmentShader":return"Fragment Shader";case"fog":return"Fog";case"glslVersion":return"GLSL Version";case"gradientMap":return"Gradient Map";case"ior":return"IOR";case"iridescence":return"Iridescence";case"iridescenceIOR":return"Iridescence IOR";case"iridescenceMap":return"Iridescence Map";case"iridescenceThicknessMap":return"Iridescence Thickness Map";case"iridescenceThicknessRange":return"Iridescence Thickness Range";case"lights":return"Lights";case"lightMap":return"Light Map";case"lightMapIntensity":return"Light Map Intensity";case"map":return"Map";case"matcap":return"Matcap";case"metalness":return"Metalness";case"metalnessMap":return"Metalness Map";case"name":return"Name";case"normalMap":return"Normal Map";case"normalScale":return"Normal Scale";case"premultipliedAlpha":return"Premultiplied Alpha";case"opacity":return"Opacity";case"reflectivity":return"Reflectivity";case"refractionRatio":return"Refraction Ratio";case"roughness":return"Roughness";case"roughnessMap":return"Roughness Map";case"sheen":return"Sheen";case"sheenColor":return"Sheen Color";case"sheenColorMap":return"Sheen Color Map";case"sheenRoughness":return"Sheen Roughness";case"sheenRoughnessMap":return"Sheen Roughness Map";case"shininess":return"Shininess";case"side":return"Side";case"size":return"Size";case"sizeAttenuation":return"Size Attenuation";case"specular":return"Specular";case"specularColor":return"Specular Color";case"specularColorMap":return"Specular Color Map";case"specularIntensity":return"Specular Intensity";case"specularIntensityMap":return"Specular Map Intensity";case"thickness":return"Thickness";case"thicknessMap":return"Thickness Map";case"toneMapped":return"Tone Mapped";case"transmission":return"Transmission";case"transmissionMap":return"Transmission Map";case"transparent":return"Transparent";case"type":return"Type";case"uuid":return"UUID";case"uniforms":return"Uniforms";case"vertexColors":return"Vertex Colors";case"vertexShader":return"Vertex Shader";case"visible":return"Visible";case"wireframe":return"Wireframe"}return a}function um(a){const e=a.toLowerCase();return e.search("intensity")>-1||e==="anisotropyrotation"||e==="blendalpha"||e==="bumpscale"||e==="clearcoatroughness"||e==="displacementbias"||e==="displacementscale"||e==="metalness"||e==="opacity"||e==="reflectivity"||e==="refractionratio"||e==="roughness"||e==="sheenroughness"}function Nx(){const a=document.createElement("input");return a.type="file",new Promise((e,t)=>{a.addEventListener("change",function(){if(a.files===null)t();else{const s=a.files[0],i=new FileReader;i.onload=function(n){e(n.target.result)},i.readAsDataURL(s)}}),a.click()})}const Px=[{title:"Front",value:x.FrontSide},{title:"Back",value:x.BackSide},{title:"Double",value:x.DoubleSide}],Dx=[{title:"No Blending",value:x.NoBlending},{title:"Normal",value:x.NormalBlending},{title:"Additive",value:x.AdditiveBlending},{title:"Subtractive",value:x.SubtractiveBlending},{title:"Multiply",value:x.MultiplyBlending},{title:"Custom",value:x.CustomBlending}],Fx=[{title:"Add",value:x.AddEquation},{title:"Subtract",value:x.SubtractEquation},{title:"Reverse Subtract",value:x.ReverseSubtractEquation},{title:"Min",value:x.MinEquation},{title:"Max",value:x.MaxEquation}],Ox=[{title:"Zero",value:x.ZeroFactor},{title:"One",value:x.OneFactor},{title:"Src Color",value:x.SrcColorFactor},{title:"One Minus Src Color",value:x.OneMinusSrcColorFactor},{title:"Src Alpha",value:x.SrcAlphaFactor},{title:"One Minus Src Alpha",value:x.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:x.DstAlphaFactor},{title:"One Minus Dst Alpha",value:x.OneMinusDstAlphaFactor},{title:"Dst Color",value:x.DstColorFactor},{title:"One Minus Dst Color",value:x.OneMinusDstColorFactor},{title:"Src Alpha Saturate",value:x.SrcAlphaSaturateFactor},{title:"Constant Color",value:x.ConstantColorFactor},{title:"One Minus Constant Color",value:x.OneMinusConstantColorFactor},{title:"Constant Alpha",value:x.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:x.OneMinusConstantAlphaFactor}],Bx=[{title:"Zero",value:x.ZeroFactor},{title:"One",value:x.OneFactor},{title:"Src Color",value:x.SrcColorFactor},{title:"One Minus Src Color",value:x.OneMinusSrcColorFactor},{title:"Src Alpha",value:x.SrcAlphaFactor},{title:"One Minus Src Alpha",value:x.OneMinusSrcAlphaFactor},{title:"Dst Alpha",value:x.DstAlphaFactor},{title:"One Minus Dst Alpha",value:x.OneMinusDstAlphaFactor},{title:"Dst Color",value:x.DstColorFactor},{title:"One Minus Dst Color",value:x.OneMinusDstColorFactor},{title:"Constant Color",value:x.ConstantColorFactor},{title:"One Minus Constant Color",value:x.OneMinusConstantColorFactor},{title:"Constant Alpha",value:x.ConstantAlphaFactor},{title:"One Minus Constant Alpha",value:x.OneMinusConstantAlphaFactor}];function vr(a,e){a.needsUpdate=!0,a.type="option",a.options=e}function Ix(a,e,t,s){return{type:"boolean",title:ll(a),prop:a,value:e,needsUpdate:!0,onChange:(i,n)=>{s.updateObject(t.uuid,`material.${a}`,n),s.updateObject(t.uuid,"material.needsUpdate",!0);const r=s.getScene(t.uuid);if(r!==null){const o=r.getObjectByProperty("uuid",t.uuid);qe(o,`material.${a}`,n)}}}}function Lx(a,e,t,s){const i={type:"number",title:ll(a),prop:a,value:e,min:void 0,max:void 0,step:.01,needsUpdate:!0,onChange:(n,r)=>{s.updateObject(t.uuid,`material.${a}`,r),s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);qe(l,`material.${a}`,r)}}};switch(a){case"blending":vr(i,Dx);break;case"blendDst":vr(i,Bx);break;case"blendEquation":vr(i,Fx);break;case"blendSrc":vr(i,Ox);break;case"side":vr(i,Px);break}return um(a)&&(i.value=Number(e),i.type="range",i.min=Math.min(0,i.value),i.max=Math.max(1,i.value),i.step=.01),i}function Ux(a,e,t,s){const i={type:"string",title:ll(a),prop:a,value:e,needsUpdate:!0,onChange:(r,o)=>{s.updateObject(t.uuid,`material.${a}`,o),s.updateObject(t.uuid,"material.needsUpdate",!0);const l=s.getScene(t.uuid);if(l!==null){const c=l.getObjectByProperty("uuid",t.uuid);qe(c,`material.${a}`,o)}},onKeyDown:r=>{}};return(a==="vertexShader"||a==="fragmentShader")&&(i.type="field",i.disabled=!1,i.latest=i.value,i.onChange=(r,o)=>{i.latest=o,s.updateObject(t.uuid,`material.${a}`,o);const l=s.getScene(t.uuid);if(l!==null){const c=l.getObjectByProperty("uuid",t.uuid);qe(c,`material.${a}`,o)}},i.onKeyDown=r=>{if(r.key==="Enter"&&(r.altKey||r.metaKey)){s.updateObject(t.uuid,"material.needsUpdate",!0);const o=s.getScene(t.uuid);if(o!==null){const l=o.getObjectByProperty("uuid",t.uuid);qe(l,"material.needsUpdate",!0)}}}),i}function kx(a){return a.x!==void 0&&a.y!==void 0&&a.z===void 0}function zx(a){return a.x!==void 0&&a.y!==void 0&&a.z!==void 0&&a.w===void 0}function Gx(a){return a.x!==void 0&&a.y!==void 0&&a.z!==void 0&&a.w!==void 0}function uh(a){a.sort((e,t)=>e.title<t.title?-1:e.title>t.title?1:0)}function Zr(a,e,t,s,i="",n=!1){const r=ll(a).split(".")[0].replaceAll("[","").replaceAll("]",""),o=i.length>0?`${i}.${a}`:a,l=typeof e;if(l==="boolean"||l==="string")return{title:r,prop:o,type:l,value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(l==="number"){const c={title:r,prop:o,type:"number",value:e,step:.01,disabled:n,onChange:(h,u)=>{s.updateObject(t.uuid,`material.${o}`,u);const d=s.getScene(t.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",t.uuid);qe(p,`material.${o}`,u)}}};return um(r)&&(c.type="range",c.min=0,c.max=1),c}else{if(e.isColor)return{title:r,prop:o,type:"color",value:e,disabled:n,onChange:(c,h)=>{const u=new x.Color(h);s.updateObject(t.uuid,`material.${o}`,u);const d=s.getScene(t.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",t.uuid);qe(p,`material.${o}`,u)}}};if(Array.isArray(e)){const c=[];for(const h in e){const u=e[h],d=`[${h.toString()}]`;if(u.value!==void 0){const p=Zr(`${d}.value`,u.value,t,s,o,n);p!==void 0&&c.push(p)}else{const p=Zr(d,u,t,s,o,n);p!==void 0&&c.push(p)}}if(c.length>0)return uh(c),{title:r,items:c}}else{if(kx(e))return{title:r,prop:o,type:"vector2",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(zx(e))return{title:r,prop:o,type:"grid3",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(Gx(e))return{title:r,prop:o,type:"grid4",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(e.isEuler)return{title:r,prop:o,type:"euler",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};if(e.src!==void 0)return{title:r,type:"image",value:e,disabled:n,onChange:(c,h)=>{const u=Rx(a),d=i.length>0?`${i}.${u}`:u;s.createTexture(t.uuid,`material.${d}`,h);const p=s.getScene(t.uuid);if(p!==null){const f=p.getObjectByProperty("uuid",t.uuid);if(f!==void 0){const m=y=>{const g=f.material,_=d.split(".");switch(_.length){case 1:g[_[0]]=y;break;case 2:g[_[0]][_[1]]=y;break;case 3:g[_[0]][_[1]][_[2]]=y;break;case 4:g[_[0]][_[1]][_[2]][_[3]]=y;break;case 5:g[_[0]][_[1]][_[2]][_[3]][_[4]]=y;break}g.needsUpdate=!0};h.src.length>0?rm(h.src).then(y=>{y.offset.set(h.offset[0],h.offset[1]),y.repeat.set(h.repeat[0],h.repeat[1]),m(y)}):m(null)}}}};if(e.elements!==void 0)return{title:r,prop:o,type:e.elements.length>9?"grid4":"grid3",value:e,disabled:n,onChange:(c,h)=>{s.updateObject(t.uuid,`material.${o}`,h);const u=s.getScene(t.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",t.uuid);qe(d,`material.${o}`,h)}}};{const c=[],h=a==="defines"||a==="extensions";try{for(const u in e){const d=e[u];if(d!==void 0)if(d.value!==void 0){const p=Zr(`${u}.value`,d.value,t,s,o,h);p!==void 0&&c.push(p)}else{const p=Zr(u,d,t,s,o,h);p!==void 0&&c.push(p)}}}catch{console.log("Issue cycling through material object:",a,e)}if(c.length>0)return uh(c),{title:r,items:c}}}}}function vd(a,e,t){const s=[];for(const i in a){if(!Ax(i))continue;const n=typeof a[i],r=a[i];if(n==="boolean")s.push(Ix(i,r,e,t));else if(n==="number")s.push(Lx(i,r,e,t));else if(n==="string")s.push(Ux(i,r,e,t));else if(n==="object"){const o=Zr(i,r,e,t);o!==void 0&&s.push(o)}else r!==void 0&&console.log("other:",i,n,r)}return uh(s),s.push({title:"Update Material",type:"button",onChange:()=>{t.updateObject(e.uuid,"material.needsUpdate",!0);const i=t.getScene(e.uuid);if(i!==null){const n=i.getObjectByProperty("uuid",e.uuid);qe(n,"material.needsUpdate",!0)}}}),s}function Vx(a,e,t){function s(){return`${t.app.appID}_material`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=a.material;if(Array.isArray(o)){const l=[],c=o.length;for(let h=0;h<c;h++)l.push(C.jsx(cs,{app:e,title:`Material ${h}`,items:vd(o[h],a,t)},`Material ${h}`));return C.jsx(C.Fragment,{children:l})}else return C.jsx(cs,{app:e,title:"Material",items:vd(o,a,t),expanded:n,onToggle:l=>{r(l)}})}const wd="data:image/gif;base64,R0lGODlhDgFkAIAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoyMDk3M0NEODAxQjQxMUVGODVGNENDMkUyMUExNDk1NSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoyMDk3M0NEOTAxQjQxMUVGODVGNENDMkUyMUExNDk1NSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE4ODc3Qzg5MDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE4ODc3QzhBMDFCMzExRUY4NUY0Q0MyRTIxQTE0OTU1Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAAA4BZAAAAv+Mj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqTkJAGDQ+dnpuekmGgAKejpKuiZqmprKqoZKGyrbOlqrejub6xvLGyw8TFzcprurGuvqybxq7ETbrItsCz0l7Zpc+6p9/cS967w9/S2FTF0u/mzehK4Oqz3eTl9vf4+fr7/P3+//DzCgwIEECxo8iDChwoUMGzp8CDGixIkUK1q8iDGjxo0XHDt6/AgypMiRJEuaPIkypcqVLFt+KwAAOw==";function Hx(a){const e=a.step!==void 0?a.step:.01,t=W.useRef(null),s=W.useRef(null),i=W.useRef(null),n=W.useRef(null),r=W.useRef(null),[o]=W.useState(a.value),[l,c]=W.useState(a.value.offset[0]),[h,u]=W.useState(a.value.offset[1]),[d,p]=W.useState(a.value.repeat[0]),[f,m]=W.useState(a.value.repeat[1]);function y(_,b,T,S,M){if(a.onChange!==void 0){const w=a.prop!==void 0?a.prop:a.title;a.onChange(w,{src:_,offset:[b,T],repeat:[S,M]})}}function g(_){const b=t.current.src,T=_.target.value;switch(_.target){case s.current:c(T),y(b,T,h,d,f);break;case i.current:u(T),y(b,l,T,d,f);break;case n.current:p(T),y(b,l,h,T,f);break;case r.current:m(T),y(b,l,h,d,T);break}}return C.jsxs("div",{className:"imageField",children:[C.jsx("img",{alt:a.title,ref:t,onClick:()=>{Nx().then(_=>{t.current.src=_,y(_,l,h,d,f)})},src:o.src.length>0?o.src:wd}),C.jsxs("div",{className:"fields",children:[C.jsxs("div",{children:[C.jsx("label",{children:"Offset:"}),C.jsx("input",{ref:s,type:"number",value:l,step:e,onChange:g}),C.jsx("input",{ref:i,type:"number",value:h,step:e,onChange:g})]}),C.jsxs("div",{children:[C.jsx("label",{children:"Repeat:"}),C.jsx("input",{ref:n,type:"number",value:d,step:e,onChange:g}),C.jsx("input",{ref:r,type:"number",value:f,step:e,onChange:g})]}),C.jsx("button",{onClick:()=>{y("",l,h,d,f),t.current.src=wd},children:"Clear"})]})]})}function Eo(a){let e=a.value;e!==void 0&&(e.isColor!==void 0?e=ah(a.value):a.type==="color"&&(e=ah(new x.Color().setStyle(a.value,x.LinearSRGBColorSpace))));const[t,s]=W.useState(e),i=W.useRef(null),n=c=>{let h=c.target.value;if(a.type==="boolean")h=c.target.checked;else if(a.type==="option"&&(typeof a.value=="number"?h=Number(h):typeof a.value=="boolean"?h=!!h:typeof a.value=="object"&&(h=JSON.parse(h)),a.options!==void 0)){const u=a.options.length;for(let d=0;d<u&&a.options[d].value!==h;d++);}s(h),a.onChange!==void 0&&a.onChange(a.prop!==void 0?a.prop:a.title,h)},r={};a.disabled&&(r.opacity=.8);const o=a.type==="field"||a.type==="string"&&(t.length>100||t.search(`
|
|
50
50
|
`)>-1),l=o||a.type==="image"||a.type==="vector2";return C.jsxs("div",{className:`field ${l?"block":""}`,style:r,children:[a.type!=="button"&&C.jsx("label",{ref:i,children:pa(a.title)},"fieldLabel"),a.type==="string"&&!o&&C.jsx("input",{type:"text",disabled:a.disabled,onChange:n,value:t}),(a.type==="field"||a.type==="string"&&o)&&C.jsx("textarea",{cols:50,rows:10,disabled:a.disabled!==void 0?a.disabled:!0,onChange:n,onKeyDown:c=>{a.onKeyDown!==void 0&&a.onKeyDown(c)},value:t}),a.type==="boolean"&&C.jsx("input",{type:"checkbox",disabled:a.disabled,onChange:n,checked:t}),a.type==="number"&&C.jsx(cn,{value:t,type:a.type,prop:a.prop!==void 0?a.prop:a.title,min:a.min,max:a.max,step:a.step,disabled:a.disabled,labelRef:i,onChange:a.onChange}),a.type==="range"&&C.jsx(cn,{value:t,type:a.type,prop:a.prop!==void 0?a.prop:a.title,min:a.min,max:a.max,step:a.step,disabled:a.disabled,labelRef:i,onChange:a.onChange}),a.type==="color"&&C.jsxs(C.Fragment,{children:[C.jsx("input",{type:"text",value:t.toString(),onChange:n,disabled:a.disabled,className:"color"}),C.jsx("input",{type:"color",value:t,onChange:n,disabled:a.disabled})]}),a.type==="button"&&C.jsx("button",{disabled:a.disabled,onClick:()=>{a.onChange!==void 0&&a.onChange(a.prop!==void 0?a.prop:a.title,!0)},children:a.title}),a.type==="image"&&C.jsx(Hx,{title:a.title,prop:a.prop,value:a.value,onChange:a.onChange}),a.type==="option"&&C.jsx(C.Fragment,{children:C.jsx("select",{onChange:n,disabled:a.disabled,defaultValue:a.value,children:a.options?.map((c,h)=>C.jsx("option",{value:c.value,children:pa(c.title)},h))})}),a.type==="vector2"&&C.jsx(dx,{step:a.step,value:t,min:0,max:1,onChange:n}),a.type==="grid3"&&C.jsx(Sd,{step:a.step,value:t,onChange:n}),a.type==="grid4"&&C.jsx(Cx,{step:a.step,value:t,onChange:n}),a.type==="euler"&&C.jsx(Sd,{step:a.step,value:t,onChange:n})]})}function Wx(a){return"items"in a}class cs extends W.Component{subgroupNames=[];subgroupElements=[];valueOverrides=new Map;app;constructor(e){super(e),this.app=e.app,this.state={lastUpdated:Date.now()}}addGroup(e){const t=[];e.items.forEach(n=>{t.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(r,o)=>{e.onUpdate(r,o)}})});const s=W.createRef(),i=C.jsx(cs,{app:this.app,ref:s,title:e.title,expanded:e.expanded,items:t},Math.random());return this.subgroupNames.push(e.title),this.subgroupElements.push(i),this.setState({lastUpdated:Date.now()}),s}removeGroup(e){const t=this.subgroupNames.length;for(let s=0;s<t;s++){const i=this.subgroupNames[s];if(e===i){this.subgroupNames.splice(s,1),this.subgroupElements.splice(s,1),this.setState({lastUpdated:Date.now()});return}}}setField(e,t){this.valueOverrides.set(e,t),this.setState({lastUpdated:Date.now()})}render(){const e=[];return this.props.items.forEach(t=>{if(Wx(t))e.push(C.jsx(cs,{app:this.app,title:pa(t.title),items:t.items},Math.random()));else{const s=this.valueOverrides.get(t.title),i=s!==void 0?s:t.value;e.push(C.jsx(Eo,{title:t.title,prop:t.prop,value:i,type:t.type,min:t.min,max:t.max,step:t.step,disabled:t.disabled,options:t.options,onChange:(n,r)=>{t.onChange!==void 0&&(this.valueOverrides.delete(t.title),t.onChange(n,r))},onKeyDown:n=>{t.onKeyDown!==void 0&&t.onKeyDown(n)}},Math.random()))}}),this.subgroupElements.forEach(t=>e.push(t)),C.jsx(fa,{app:this.app,label:this.props.title,open:this.props.expanded===!0,onToggle:t=>{this.props.onToggle&&this.props?.onToggle(t)},children:e})}}class Re extends W.Component{static instance;static groups=[];static groupsRefs=[];static groupTitles=[];static app;constructor(e){super(e),this.state={lastUpdate:Date.now()},Re.app=e.app,Re.instance=this,Re.app.addEventListener(Q.ADD_GROUP,this.addGroup),Re.app.addEventListener(Q.REMOVE_GROUP,this.removeGroup)}componentWillUnmount(){Re.app.removeEventListener(Q.ADD_GROUP,this.addGroup),Re.app.removeEventListener(Q.REMOVE_GROUP,this.removeGroup)}render(){return C.jsx("div",{className:"customGroups",children:Re.groups},this.state.lastUpdate)}addGroup=e=>{const t=JSON.parse(e.value),s=[];t.items.forEach(i=>{s.push({type:i.type,prop:i.prop,title:i.title!==void 0?i.title:i.prop,value:i.value,min:i.min,max:i.max,step:i.step,options:i.options,disabled:i.disabled,onChange:(n,r)=>{this.props.three.updateGroup(t.title,n,r)}})}),Re.groups.push(C.jsx(cs,{app:Re.app,title:t.title,items:s},Math.random())),Re.groupTitles.push(t.title),this.setState({lastUpdate:Date.now()})};removeGroup=e=>{const t=e.value,s=Re.groupTitles.length;for(let i=0;i<s;i++)if(t===Re.groupTitles[i]){Re.groups.splice(i,1),Re.groupTitles.splice(i,1),this.setState({lastUpdate:Date.now()});return}};static addEditorGroup(e){const t=[];e.items.forEach(n=>{t.push({type:n.type,prop:n.prop,title:n.title!==void 0?n.title:n.prop,value:n.value,min:n.min,max:n.max,step:n.step,options:n.options,disabled:n.disabled,onChange:(r,o)=>{e.onUpdate(r,o)}})});const s=W.createRef(),i=C.jsx(cs,{app:Re.app,ref:s,title:e.title,items:t},Math.random());return Re.groups.push(i),Re.groupsRefs.push(s),Re.groupTitles.push(e.title),s}static removeEditorGroup(e){const t=Re.groupTitles.length;for(let s=0;s<t;s++)if(e===Re.groupTitles[s]){Re.groups.splice(s,1),Re.groupTitles.splice(s,1),Re.instance.setState({lastUpdate:Date.now()});return}}}function Ed(a){switch(a){case"fov":return"FOV";case"zoom":return"Zoom";case"near":return"Near";case"far":return"Far";case"focus":return"Focus";case"aspect":return"Aspect";case"filmGauge":return"Film Gauge";case"filmOffset":return"Film Offset";case"left":return"Left";case"right":return"Right";case"top":return"Top";case"bottom":return"Bottom"}return a}function $x(a,e,t){function s(){return`${t.app.appID}_camera`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=[];if(a.perspectiveCameraInfo!==void 0)for(const l in a.perspectiveCameraInfo)o.push({title:Ed(l),prop:l,type:"number",step:.01,value:a.perspectiveCameraInfo[l],onChange:(c,h)=>{t.updateObject(a.uuid,c,h),t.requestMethod(a.uuid,"updateProjectionMatrix");const u=t.getScene(a.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",a.uuid);d!==void 0&&(qe(d,c,h),d.updateProjectionMatrix())}}});else if(a.orthographicCameraInfo!==void 0)for(const l in a.orthographicCameraInfo)o.push({title:Ed(l),prop:l,type:"number",step:.01,value:a.orthographicCameraInfo[l],onChange:(c,h)=>{t.updateObject(a.uuid,c,h),t.requestMethod(a.uuid,"updateProjectionMatrix");const u=t.getScene(a.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",a.uuid);d!==void 0&&(qe(d,c,h),d.updateProjectionMatrix())}}});return C.jsx(cs,{app:e,title:"Camera",items:o,expanded:n,onToggle:l=>{r(l)}})}class jx{constructor(e,t){this.nodes=e,this.info=t,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,s)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this._animationLoop!==null&&this._animationLoop(t,s)};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class Ss{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let s=0;s<e.length-1;s++)if(t=t.get(e[s]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let s=this.weakMap;for(let i=0;i<e.length-1;i++){const n=e[i];s.has(n)===!1&&s.set(n,new WeakMap),s=s.get(n)}return s.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let s=0;s<e.length-1;s++)if(t=t.get(e[s]),t===void 0)return!1;return t.delete(e[e.length-1])}}const dm="177",qx=0,Yx=1,Xx=2,Zx=0,Qx=1,Mo=3,Zs=0,zt=1,Zn=2,or=0,Qs=1,Go=2,Vo=3,Ho=4,ra=5,_s=100,pm=101,fm=102,Kx=103,Jx=104,Si=200,mm=201,gm=202,ym=203,Wo=204,$o=205,xm=206,_m=207,bm=208,Tm=209,Sm=210,vm=0,wm=1,Em=2,jo=3,Mm=4,Cm=5,Am=6,Rm=7,cl=0,e_=1,t_=2,Qn=0,s_=1,i_=2,n_=3,r_=4,a_=6,o_=7,Kh=300,ma=301,qo=302,Jh=303,eu=304,dh=306,lr=1e3,Ai=1001,cr=1002,ct=1003,Nm=1004,ga=1005,Qt=1006,ph=1007,Ks=1008,Rt=1009,aa=1010,oa=1011,Wn=1012,Mt=1013,Ye=1014,Zt=1015,ns=1016,l_=1017,c_=1018,Pi=1020,Pm=35902,h_=1021,tu=1022,rs=1023,Os=1026,Js=1027,su=1028,iu=1029,ln=1030,nu=1031,u_=1032,ru=1033,kl=33776,Co=33777,Ao=33778,Ro=33779,Md=35840,Cd=35841,Ad=35842,Rd=35843,Nd=36196,fh=37492,mh=37496,gh=37808,yh=37809,xh=37810,_h=37811,bh=37812,Th=37813,Sh=37814,vh=37815,wh=37816,Eh=37817,Mh=37818,Ch=37819,Ah=37820,Rh=37821,zl=36492,d_=36283,Pd=36284,Dd=36285,Fd=36286,Di=0,p_=1,ni="",Yt="srgb",Kn="srgb-linear",Yo="linear",se="srgb",f_=0,Ji=7680,m_=7681,g_=7682,y_=7683,x_=34055,__=34056,b_=5386,T_=512,S_=513,v_=514,w_=515,E_=516,M_=517,C_=518,Nh=519,Dm=512,au=513,Fm=514,Om=515,Bm=516,Im=517,Lm=518,Um=519,Xo=35044,$n=35048,Lt=2e3,Fi=2001;class Vt{constructor(e,t,s,i,n,r,o,l,c){Vt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,s,i,n,r,o,l,c)}set(e,t,s,i,n,r,o,l,c){const h=this.elements;return h[0]=e,h[1]=i,h[2]=o,h[3]=t,h[4]=n,h[5]=l,h[6]=s,h[7]=r,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,n=this.elements,r=s[0],o=s[3],l=s[6],c=s[1],h=s[4],u=s[7],d=s[2],p=s[5],f=s[8],m=i[0],y=i[3],g=i[6],_=i[1],b=i[4],T=i[7],S=i[2],M=i[5],w=i[8];return n[0]=r*m+o*_+l*S,n[3]=r*y+o*b+l*M,n[6]=r*g+o*T+l*w,n[1]=c*m+h*_+u*S,n[4]=c*y+h*b+u*M,n[7]=c*g+h*T+u*w,n[2]=d*m+p*_+f*S,n[5]=d*y+p*b+f*M,n[8]=d*g+p*T+f*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],i=e[2],n=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*r*h-t*o*c-s*n*h+s*o*l+i*n*c-i*r*l}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],n=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*r-o*c,d=o*l-h*n,p=c*n-r*l,f=t*u+s*d+i*p;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/f;return e[0]=u*m,e[1]=(i*c-h*s)*m,e[2]=(o*s-i*r)*m,e[3]=d*m,e[4]=(h*t-i*l)*m,e[5]=(i*n-o*t)*m,e[6]=p*m,e[7]=(s*l-c*t)*m,e[8]=(r*t-s*n)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,i,n,r,o){const l=Math.cos(n),c=Math.sin(n);return this.set(s*l,s*c,-s*(l*r+c*o)+r+e,-i*c,i*l,-i*(-c*r+l*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(Gl.makeScale(e,t)),this}rotate(e){return this.premultiply(Gl.makeRotation(-e)),this}translate(e,t){return this.premultiply(Gl.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let i=0;i<9;i++)if(t[i]!==s[i])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const Gl=new Vt;function km(a){for(let e=a.length-1;e>=0;--e)if(a[e]>=65535)return!0;return!1}function Ph(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function A_(){const a=Ph("canvas");return a.style.display="block",a}const Od={};function ri(a){a in Od||(Od[a]=!0,console.warn(a))}const Bd=new Vt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Id=new Vt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function R_(){const a={enabled:!0,workingColorSpace:Kn,spaces:{},convert:function(i,n,r){return this.enabled===!1||n===r||!n||!r||(this.spaces[n].transfer===se&&(i.r=ei(i.r),i.g=ei(i.g),i.b=ei(i.b)),this.spaces[n].primaries!==this.spaces[r].primaries&&(i.applyMatrix3(this.spaces[n].toXYZ),i.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===se&&(i.r=Jn(i.r),i.g=Jn(i.g),i.b=Jn(i.b))),i},workingToColorSpace:function(i,n){return this.convert(i,this.workingColorSpace,n)},colorSpaceToWorking:function(i,n){return this.convert(i,n,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===ni?Yo:this.spaces[i].transfer},getLuminanceCoefficients:function(i,n=this.workingColorSpace){return i.fromArray(this.spaces[n].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,n,r){return i.copy(this.spaces[n].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,n){return ri("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(i,n)},toWorkingColorSpace:function(i,n){return ri("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(i,n)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],s=[.3127,.329];return a.define({[Kn]:{primaries:e,whitePoint:s,transfer:Yo,toXYZ:Bd,fromXYZ:Id,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Yt},outputColorSpaceConfig:{drawingBufferColorSpace:Yt}},[Yt]:{primaries:e,whitePoint:s,transfer:se,toXYZ:Bd,fromXYZ:Id,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Yt}}}),a}const Le=R_();function ei(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function Jn(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}const zm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ui={h:0,s:0,l:0},Fa={h:0,s:0,l:0};function Vl(a,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?a+(e-a)*6*t:t<1/2?e:t<2/3?a+(e-a)*6*(2/3-t):a}class Se{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(t===void 0&&s===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Yt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Le.colorSpaceToWorking(this,t),this}setRGB(e,t,s,i=Le.workingColorSpace){return this.r=e,this.g=t,this.b=s,Le.colorSpaceToWorking(this,i),this}setHSL(e,t,s,i=Le.workingColorSpace){if(e=Qh(e,1),t=de(t,0,1),s=de(s,0,1),t===0)this.r=this.g=this.b=s;else{const n=s<=.5?s*(1+t):s+t-s*t,r=2*s-n;this.r=Vl(r,n,e+1/3),this.g=Vl(r,n,e),this.b=Vl(r,n,e-1/3)}return Le.colorSpaceToWorking(this,i),this}setStyle(e,t=Yt){function s(n){n!==void 0&&parseFloat(n)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let n;const r=i[1],o=i[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,t);if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setRGB(Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,t);break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(n[4]),this.setHSL(parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(r===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(r===6)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Yt){const s=zm[e.toLowerCase()];return s!==void 0?this.setHex(s,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ei(e.r),this.g=ei(e.g),this.b=ei(e.b),this}copyLinearToSRGB(e){return this.r=Jn(e.r),this.g=Jn(e.g),this.b=Jn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Yt){return Le.workingToColorSpace(gt.copy(this),e),Math.round(de(gt.r*255,0,255))*65536+Math.round(de(gt.g*255,0,255))*256+Math.round(de(gt.b*255,0,255))}getHexString(e=Yt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Le.workingColorSpace){Le.workingToColorSpace(gt.copy(this),t);const s=gt.r,i=gt.g,n=gt.b,r=Math.max(s,i,n),o=Math.min(s,i,n);let l,c;const h=(o+r)/2;if(o===r)l=0,c=0;else{const u=r-o;switch(c=h<=.5?u/(r+o):u/(2-r-o),r){case s:l=(i-n)/u+(i<n?6:0);break;case i:l=(n-s)/u+2;break;case n:l=(s-i)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Le.workingColorSpace){return Le.workingToColorSpace(gt.copy(this),t),e.r=gt.r,e.g=gt.g,e.b=gt.b,e}getStyle(e=Yt){Le.workingToColorSpace(gt.copy(this),e);const t=gt.r,s=gt.g,i=gt.b;return e!==Yt?`color(${e} ${t.toFixed(3)} ${s.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(s*255)},${Math.round(i*255)})`}offsetHSL(e,t,s){return this.getHSL(ui),this.setHSL(ui.h+e,ui.s+t,ui.l+s)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,s){return this.r=e.r+(t.r-e.r)*s,this.g=e.g+(t.g-e.g)*s,this.b=e.b+(t.b-e.b)*s,this}lerpHSL(e,t){this.getHSL(ui),e.getHSL(Fa);const s=Ni(ui.h,Fa.h,t),i=Ni(ui.s,Fa.s,t),n=Ni(ui.l,Fa.l,t);return this.setHSL(s,i,n),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,s=this.g,i=this.b,n=e.elements;return this.r=n[0]*t+n[3]*s+n[6]*i,this.g=n[1]*t+n[4]*s+n[7]*i,this.b=n[2]*t+n[5]*s+n[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const gt=new Se;Se.NAMES=zm;class hl{constructor(e,t,s,i){hl.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,s,i)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let s=0;s<4;s++)this.elements[s]=e[s+t];return this}set(e,t,s,i){const n=this.elements;return n[0]=e,n[2]=t,n[1]=s,n[3]=i,this}}class mr{constructor(e=0,t=0,s=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=s,this._w=i}static slerpFlat(e,t,s,i,n,r,o){let l=s[i+0],c=s[i+1],h=s[i+2],u=s[i+3];const d=n[r+0],p=n[r+1],f=n[r+2],m=n[r+3];if(o===0){e[t+0]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u;return}if(o===1){e[t+0]=d,e[t+1]=p,e[t+2]=f,e[t+3]=m;return}if(u!==m||l!==d||c!==p||h!==f){let y=1-o;const g=l*d+c*p+h*f+u*m,_=g>=0?1:-1,b=1-g*g;if(b>Number.EPSILON){const S=Math.sqrt(b),M=Math.atan2(S,g*_);y=Math.sin(y*M)/S,o=Math.sin(o*M)/S}const T=o*_;if(l=l*y+d*T,c=c*y+p*T,h=h*y+f*T,u=u*y+m*T,y===1-o){const S=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=S,c*=S,h*=S,u*=S}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,s,i,n,r){const o=s[i],l=s[i+1],c=s[i+2],h=s[i+3],u=n[r],d=n[r+1],p=n[r+2],f=n[r+3];return e[t]=o*f+h*u+l*p-c*d,e[t+1]=l*f+h*d+c*u-o*p,e[t+2]=c*f+h*p+o*d-l*u,e[t+3]=h*f-o*u-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e._x,i=e._y,n=e._z,r=e._order,o=Math.cos,l=Math.sin,c=o(s/2),h=o(i/2),u=o(n/2),d=l(s/2),p=l(i/2),f=l(n/2);switch(r){case"XYZ":this._x=d*h*u+c*p*f,this._y=c*p*u-d*h*f,this._z=c*h*f+d*p*u,this._w=c*h*u-d*p*f;break;case"YXZ":this._x=d*h*u+c*p*f,this._y=c*p*u-d*h*f,this._z=c*h*f-d*p*u,this._w=c*h*u+d*p*f;break;case"ZXY":this._x=d*h*u-c*p*f,this._y=c*p*u+d*h*f,this._z=c*h*f+d*p*u,this._w=c*h*u-d*p*f;break;case"ZYX":this._x=d*h*u-c*p*f,this._y=c*p*u+d*h*f,this._z=c*h*f-d*p*u,this._w=c*h*u+d*p*f;break;case"YZX":this._x=d*h*u+c*p*f,this._y=c*p*u+d*h*f,this._z=c*h*f-d*p*u,this._w=c*h*u-d*p*f;break;case"XZY":this._x=d*h*u-c*p*f,this._y=c*p*u-d*h*f,this._z=c*h*f+d*p*u,this._w=c*h*u+d*p*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,i=Math.sin(s);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],i=t[4],n=t[8],r=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=s+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(n-c)*p,this._z=(r-i)*p}else if(s>o&&s>u){const p=2*Math.sqrt(1+s-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(i+r)/p,this._z=(n+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-s-u);this._w=(n-c)/p,this._x=(i+r)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+u-s-o);this._w=(r-i)/p,this._x=(n+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return s<Number.EPSILON?(s=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(de(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(s===0)return this;const i=Math.min(1,t/s);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,i=e._y,n=e._z,r=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=s*h+r*o+i*c-n*l,this._y=i*h+r*l+n*o-s*c,this._z=n*h+r*c+s*l-i*o,this._w=r*h-s*o-i*l-n*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const s=this._x,i=this._y,n=this._z,r=this._w;let o=r*e._w+s*e._x+i*e._y+n*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=r,this._x=s,this._y=i,this._z=n,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-t;return this._w=p*r+t*this._w,this._x=p*s+t*this._x,this._y=p*i+t*this._y,this._z=p*n+t*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-t)*h)/c,d=Math.sin(t*h)/c;return this._w=r*u+this._w*d,this._x=s*u+this._x*d,this._y=i*u+this._y*d,this._z=n*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),n=Math.sqrt(s);return this.set(i*Math.sin(e),i*Math.cos(e),n*Math.sin(t),n*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class N{constructor(e=0,t=0,s=0){N.prototype.isVector3=!0,this.x=e,this.y=t,this.z=s}set(e,t,s){return s===void 0&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ld.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ld.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6]*i,this.y=n[1]*t+n[4]*s+n[7]*i,this.z=n[2]*t+n[5]*s+n[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,n=e.elements,r=1/(n[3]*t+n[7]*s+n[11]*i+n[15]);return this.x=(n[0]*t+n[4]*s+n[8]*i+n[12])*r,this.y=(n[1]*t+n[5]*s+n[9]*i+n[13])*r,this.z=(n[2]*t+n[6]*s+n[10]*i+n[14])*r,this}applyQuaternion(e){const t=this.x,s=this.y,i=this.z,n=e.x,r=e.y,o=e.z,l=e.w,c=2*(r*i-o*s),h=2*(o*t-n*i),u=2*(n*s-r*t);return this.x=t+l*c+r*u-o*h,this.y=s+l*h+o*c-n*u,this.z=i+l*u+n*h-r*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,s=this.y,i=this.z,n=e.elements;return this.x=n[0]*t+n[4]*s+n[8]*i,this.y=n[1]*t+n[5]*s+n[9]*i,this.z=n[2]*t+n[6]*s+n[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=de(this.x,e.x,t.x),this.y=de(this.y,e.y,t.y),this.z=de(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=de(this.x,e,t),this.y=de(this.y,e,t),this.z=de(this.z,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(de(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,i=e.y,n=e.z,r=t.x,o=t.y,l=t.z;return this.x=i*l-n*o,this.y=n*r-s*l,this.z=s*o-i*r,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return Hl.copy(this).projectOnVector(e),this.sub(Hl)}reflect(e){return this.sub(Hl.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(de(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return t*t+s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,s){const i=Math.sin(t)*e;return this.x=i*Math.sin(s),this.y=Math.cos(t)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,s){return this.x=e*Math.sin(t),this.y=s,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Hl=new N,Ld=new mr;class Be{constructor(e,t,s,i,n,r,o,l,c,h,u,d,p,f,m,y){Be.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,s,i,n,r,o,l,c,h,u,d,p,f,m,y)}set(e,t,s,i,n,r,o,l,c,h,u,d,p,f,m,y){const g=this.elements;return g[0]=e,g[4]=t,g[8]=s,g[12]=i,g[1]=n,g[5]=r,g[9]=o,g[13]=l,g[2]=c,g[6]=h,g[10]=u,g[14]=d,g[3]=p,g[7]=f,g[11]=m,g[15]=y,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Be().fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,s){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,s=e.elements,i=1/Sn.setFromMatrixColumn(e,0).length(),n=1/Sn.setFromMatrixColumn(e,1).length(),r=1/Sn.setFromMatrixColumn(e,2).length();return t[0]=s[0]*i,t[1]=s[1]*i,t[2]=s[2]*i,t[3]=0,t[4]=s[4]*n,t[5]=s[5]*n,t[6]=s[6]*n,t[7]=0,t[8]=s[8]*r,t[9]=s[9]*r,t[10]=s[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,s=e.x,i=e.y,n=e.z,r=Math.cos(s),o=Math.sin(s),l=Math.cos(i),c=Math.sin(i),h=Math.cos(n),u=Math.sin(n);if(e.order==="XYZ"){const d=r*h,p=r*u,f=o*h,m=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=p+f*c,t[5]=d-m*c,t[9]=-o*l,t[2]=m-d*c,t[6]=f+p*c,t[10]=r*l}else if(e.order==="YXZ"){const d=l*h,p=l*u,f=c*h,m=c*u;t[0]=d+m*o,t[4]=f*o-p,t[8]=r*c,t[1]=r*u,t[5]=r*h,t[9]=-o,t[2]=p*o-f,t[6]=m+d*o,t[10]=r*l}else if(e.order==="ZXY"){const d=l*h,p=l*u,f=c*h,m=c*u;t[0]=d-m*o,t[4]=-r*u,t[8]=f+p*o,t[1]=p+f*o,t[5]=r*h,t[9]=m-d*o,t[2]=-r*c,t[6]=o,t[10]=r*l}else if(e.order==="ZYX"){const d=r*h,p=r*u,f=o*h,m=o*u;t[0]=l*h,t[4]=f*c-p,t[8]=d*c+m,t[1]=l*u,t[5]=m*c+d,t[9]=p*c-f,t[2]=-c,t[6]=o*l,t[10]=r*l}else if(e.order==="YZX"){const d=r*l,p=r*c,f=o*l,m=o*c;t[0]=l*h,t[4]=m-d*u,t[8]=f*u+p,t[1]=u,t[5]=r*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*u+f,t[10]=d-m*u}else if(e.order==="XZY"){const d=r*l,p=r*c,f=o*l,m=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+m,t[5]=r*h,t[9]=p*u-f,t[2]=f*u-p,t[6]=o*h,t[10]=m*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(N_,e,P_)}lookAt(e,t,s){const i=this.elements;return Ht.subVectors(e,t),Ht.lengthSq()===0&&(Ht.z=1),Ht.normalize(),di.crossVectors(s,Ht),di.lengthSq()===0&&(Math.abs(s.z)===1?Ht.x+=1e-4:Ht.z+=1e-4,Ht.normalize(),di.crossVectors(s,Ht)),di.normalize(),Oa.crossVectors(Ht,di),i[0]=di.x,i[4]=Oa.x,i[8]=Ht.x,i[1]=di.y,i[5]=Oa.y,i[9]=Ht.y,i[2]=di.z,i[6]=Oa.z,i[10]=Ht.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,n=this.elements,r=s[0],o=s[4],l=s[8],c=s[12],h=s[1],u=s[5],d=s[9],p=s[13],f=s[2],m=s[6],y=s[10],g=s[14],_=s[3],b=s[7],T=s[11],S=s[15],M=i[0],w=i[4],R=i[8],P=i[12],z=i[1],$=i[5],q=i[9],j=i[13],X=i[2],Z=i[6],ve=i[10],ue=i[14],ge=i[3],ie=i[7],we=i[11],ke=i[15];return n[0]=r*M+o*z+l*X+c*ge,n[4]=r*w+o*$+l*Z+c*ie,n[8]=r*R+o*q+l*ve+c*we,n[12]=r*P+o*j+l*ue+c*ke,n[1]=h*M+u*z+d*X+p*ge,n[5]=h*w+u*$+d*Z+p*ie,n[9]=h*R+u*q+d*ve+p*we,n[13]=h*P+u*j+d*ue+p*ke,n[2]=f*M+m*z+y*X+g*ge,n[6]=f*w+m*$+y*Z+g*ie,n[10]=f*R+m*q+y*ve+g*we,n[14]=f*P+m*j+y*ue+g*ke,n[3]=_*M+b*z+T*X+S*ge,n[7]=_*w+b*$+T*Z+S*ie,n[11]=_*R+b*q+T*ve+S*we,n[15]=_*P+b*j+T*ue+S*ke,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],i=e[8],n=e[12],r=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],p=e[14],f=e[3],m=e[7],y=e[11],g=e[15];return f*(+n*l*u-i*c*u-n*o*d+s*c*d+i*o*p-s*l*p)+m*(+t*l*p-t*c*d+n*r*d-i*r*p+i*c*h-n*l*h)+y*(+t*c*u-t*o*p-n*r*u+s*r*p+n*o*h-s*c*h)+g*(-i*o*h-t*l*u+t*o*d+i*r*u-s*r*d+s*l*h)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],n=e[3],r=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],y=e[14],g=e[15],_=u*y*c-m*d*c+m*l*p-o*y*p-u*l*g+o*d*g,b=f*d*c-h*y*c-f*l*p+r*y*p+h*l*g-r*d*g,T=h*m*c-f*u*c+f*o*p-r*m*p-h*o*g+r*u*g,S=f*u*l-h*m*l-f*o*d+r*m*d+h*o*y-r*u*y,M=t*_+s*b+i*T+n*S;if(M===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/M;return e[0]=_*w,e[1]=(m*d*n-u*y*n-m*i*p+s*y*p+u*i*g-s*d*g)*w,e[2]=(o*y*n-m*l*n+m*i*c-s*y*c-o*i*g+s*l*g)*w,e[3]=(u*l*n-o*d*n-u*i*c+s*d*c+o*i*p-s*l*p)*w,e[4]=b*w,e[5]=(h*y*n-f*d*n+f*i*p-t*y*p-h*i*g+t*d*g)*w,e[6]=(f*l*n-r*y*n-f*i*c+t*y*c+r*i*g-t*l*g)*w,e[7]=(r*d*n-h*l*n+h*i*c-t*d*c-r*i*p+t*l*p)*w,e[8]=T*w,e[9]=(f*u*n-h*m*n-f*s*p+t*m*p+h*s*g-t*u*g)*w,e[10]=(r*m*n-f*o*n+f*s*c-t*m*c-r*s*g+t*o*g)*w,e[11]=(h*o*n-r*u*n-h*s*c+t*u*c+r*s*p-t*o*p)*w,e[12]=S*w,e[13]=(h*m*i-f*u*i+f*s*d-t*m*d-h*s*y+t*u*y)*w,e[14]=(f*o*i-r*m*i-f*s*l+t*m*l+r*s*y-t*o*y)*w,e[15]=(r*u*i-h*o*i+h*s*l-t*u*l-r*s*d+t*o*d)*w,this}scale(e){const t=this.elements,s=e.x,i=e.y,n=e.z;return t[0]*=s,t[4]*=i,t[8]*=n,t[1]*=s,t[5]*=i,t[9]*=n,t[2]*=s,t[6]*=i,t[10]*=n,t[3]*=s,t[7]*=i,t[11]*=n,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,i))}makeTranslation(e,t,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),i=Math.sin(t),n=1-s,r=e.x,o=e.y,l=e.z,c=n*r,h=n*o;return this.set(c*r+s,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+s,h*l-i*r,0,c*l-i*o,h*l+i*r,n*l*l+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,i,n,r){return this.set(1,s,n,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,s){const i=this.elements,n=t._x,r=t._y,o=t._z,l=t._w,c=n+n,h=r+r,u=o+o,d=n*c,p=n*h,f=n*u,m=r*h,y=r*u,g=o*u,_=l*c,b=l*h,T=l*u,S=s.x,M=s.y,w=s.z;return i[0]=(1-(m+g))*S,i[1]=(p+T)*S,i[2]=(f-b)*S,i[3]=0,i[4]=(p-T)*M,i[5]=(1-(d+g))*M,i[6]=(y+_)*M,i[7]=0,i[8]=(f+b)*w,i[9]=(y-_)*w,i[10]=(1-(d+m))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,s){const i=this.elements;let n=Sn.set(i[0],i[1],i[2]).length();const r=Sn.set(i[4],i[5],i[6]).length(),o=Sn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),e.x=i[12],e.y=i[13],e.z=i[14],ds.copy(this);const c=1/n,h=1/r,u=1/o;return ds.elements[0]*=c,ds.elements[1]*=c,ds.elements[2]*=c,ds.elements[4]*=h,ds.elements[5]*=h,ds.elements[6]*=h,ds.elements[8]*=u,ds.elements[9]*=u,ds.elements[10]*=u,t.setFromRotationMatrix(ds),s.x=n,s.y=r,s.z=o,this}makePerspective(e,t,s,i,n,r,o=Lt){const l=this.elements,c=2*n/(t-e),h=2*n/(s-i),u=(t+e)/(t-e),d=(s+i)/(s-i);let p,f;if(o===Lt)p=-(r+n)/(r-n),f=-2*r*n/(r-n);else if(o===Fi)p=-r/(r-n),f=-r*n/(r-n);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,s,i,n,r,o=Lt){const l=this.elements,c=1/(t-e),h=1/(s-i),u=1/(r-n),d=(t+e)*c,p=(s+i)*h;let f,m;if(o===Lt)f=(r+n)*u,m=-2*u;else if(o===Fi)f=n*u,m=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-p,l[2]=0,l[6]=0,l[10]=m,l[14]=-f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){const t=this.elements,s=e.elements;for(let i=0;i<16;i++)if(t[i]!==s[i])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}}const Sn=new N,ds=new Be,N_=new N(0,0,0),P_=new N(1,1,1),di=new N,Oa=new N,Ht=new N;class ce{constructor(e=0,t=0){ce.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=de(this.x,e.x,t.x),this.y=de(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=de(this.x,e,t),this.y=de(this.y,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(de(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const s=this.dot(e)/t;return Math.acos(de(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),i=Math.sin(t),n=this.x-e.x,r=this.y-e.y;return this.x=n*s-r*i+e.x,this.y=n*i+r*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class me{constructor(e=0,t=0,s=0,i=1){me.prototype.isVector4=!0,this.x=e,this.y=t,this.z=s,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,n=this.w,r=e.elements;return this.x=r[0]*t+r[4]*s+r[8]*i+r[12]*n,this.y=r[1]*t+r[5]*s+r[9]*i+r[13]*n,this.z=r[2]*t+r[6]*s+r[10]*i+r[14]*n,this.w=r[3]*t+r[7]*s+r[11]*i+r[15]*n,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,s,i,n;const l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],f=l[9],m=l[2],y=l[6],g=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-m)<.01&&Math.abs(f-y)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+m)<.1&&Math.abs(f+y)<.1&&Math.abs(c+p+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,T=(p+1)/2,S=(g+1)/2,M=(h+d)/4,w=(u+m)/4,R=(f+y)/4;return b>T&&b>S?b<.01?(s=0,i=.707106781,n=.707106781):(s=Math.sqrt(b),i=M/s,n=w/s):T>S?T<.01?(s=.707106781,i=0,n=.707106781):(i=Math.sqrt(T),s=M/i,n=R/i):S<.01?(s=.707106781,i=.707106781,n=0):(n=Math.sqrt(S),s=w/n,i=R/n),this.set(s,i,n,t),this}let _=Math.sqrt((y-f)*(y-f)+(u-m)*(u-m)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(y-f)/_,this.y=(u-m)/_,this.z=(d-h)/_,this.w=Math.acos((c+p+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=de(this.x,e.x,t.x),this.y=de(this.y,e.y,t.y),this.z=de(this.z,e.z,t.z),this.w=de(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=de(this.x,e,t),this.y=de(this.y,e,t),this.z=de(this.z,e,t),this.w=de(this.w,e,t),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(de(s,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this.w=e.w+(t.w-e.w)*s,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}function ya(a,e=0){let t=3735928559^e,s=1103547991^e;if(a instanceof Array)for(let i=0,n;i<a.length;i++)n=a[i],t=Math.imul(t^n,2654435761),s=Math.imul(s^n,1597334677);else for(let i=0,n;i<a.length;i++)n=a.charCodeAt(i),t=Math.imul(t^n,2654435761),s=Math.imul(s^n,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507),s^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&s)+(t>>>0)}const D_=a=>ya(a),ou=a=>ya(a),Zo=(...a)=>ya(a);function Gm(a,e=!1){const t=[];a.isNode===!0&&(t.push(a.id),a=a.getSelf());for(const{property:s,childNode:i}of Qo(a))t.push(ya(s.slice(0,-4)),i.getCacheKey(e));return ya(t)}function*Qo(a,e=!1){for(const t in a){if(t.startsWith("_")===!0)continue;const s=a[t];if(Array.isArray(s)===!0)for(let i=0;i<s.length;i++){const n=s[i];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:t,index:i,childNode:n})}else if(s&&s.isNode===!0)yield{property:t,childNode:s};else if(typeof s=="object")for(const i in s){const n=s[i];n&&(n.isNode===!0||e&&typeof n.toJSON=="function")&&(yield{property:t,index:i,childNode:n})}}}const F_=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Ud=new WeakMap;function O_(a){return F_.get(a)}function Ko(a){if(a==null)return null;const e=typeof a;return a.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":a.isVector2===!0?"vec2":a.isVector3===!0?"vec3":a.isVector4===!0?"vec4":a.isMatrix2===!0?"mat2":a.isMatrix3===!0?"mat3":a.isMatrix4===!0?"mat4":a.isColor===!0?"color":a instanceof ArrayBuffer?"ArrayBuffer":null}function Vm(a,...e){const t=a?a.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),a==="color"?new Se(...e):t==="vec2"?new ce(...e):t==="vec3"?new N(...e):t==="vec4"?new me(...e):t==="mat2"?new hl(...e):t==="mat3"?new Vt(...e):t==="mat4"?new Be(...e):a==="bool"?e[0]||!1:a==="float"||a==="int"||a==="uint"?e[0]||0:a==="string"?e[0]||"":a==="ArrayBuffer"?I_(e[0]):null}function Hm(a){let e=Ud.get(a);return e===void 0&&(e={},Ud.set(a,e)),e}function B_(a){let e="";const t=new Uint8Array(a);for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return btoa(e)}function I_(a){return Uint8Array.from(atob(a),e=>e.charCodeAt(0)).buffer}let L_=0;function U_(a){const e=Object.keys(a);let t=Object.getPrototypeOf(a);for(;t;){const s=Object.getOwnPropertyDescriptors(t);for(const i in s)if(s[i]!==void 0){const n=s[i];n&&typeof n.get=="function"&&e.push(i)}t=Object.getPrototypeOf(t)}return e}class k_{constructor(e,t,s,i,n,r,o,l,c,h){this.id=L_++,this._nodes=e,this._geometries=t,this.renderer=s,this.object=i,this.material=n,this.scene=r,this.camera=o,this.lightsNode=l,this.context=c,this.geometry=i.geometry,this.version=n.version,this.drawRange=null,this.attributes=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=h,this.clippingContextCacheKey=h!==null?h.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],i=new Set;for(const n of e){const r=n.node&&n.node.attribute?n.node.attribute:t.getAttribute(n.name);if(r===void 0)continue;s.push(r);const o=r.isInterleavedBufferAttribute?r.data:r;i.add(o)}return this.attributes=s,this.vertexBuffers=Array.from(i.values()),s}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:s,group:i,drawRange:n}=this,r=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),o=this.getIndex(),l=o!==null;let c=1;if(s.isInstancedBufferGeometry===!0?c=s.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(r.instanceCount=c,e.isBatchedMesh===!0)return r;let h=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(h=2);let u=n.start*h,d=(n.start+n.count)*h;i!==null&&(u=Math.max(u,i.start*h),d=Math.min(d,(i.start+i.count)*h));const p=s.attributes.position;let f=1/0;l?f=o.count:p!=null&&(f=p.count),u=Math.max(u,0),d=Math.min(d,f);const m=d-u;return m<0||m===1/0?null:(r.vertexCount=m,r.firstVertex=u,r)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const s of Object.keys(e.attributes).sort()){const i=e.attributes[s];t+=s+",",i.data&&(t+=i.data.stride+","),i.offset&&(t+=i.offset+","),i.itemSize&&(t+=i.itemSize+","),i.normalized&&(t+="n,")}for(const s of Object.keys(e.morphAttributes).sort()){const i=e.morphAttributes[s];t+="morph-"+s+",";for(let n=0,r=i.length;n<r;n++){const o=i[n];t+=o.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t}=this;let s=t.customProgramCacheKey();for(const i of U_(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(i))continue;const n=t[i];let r;if(n!==null){const o=typeof n;o==="number"?r=n!==0?"1":"0":o==="object"?(r="{",n.isTexture&&(r+=n.mapping),r+="}"):r=String(n)}else r=String(n);s+=r+","}return s+=this.clippingContextCacheKey+",",e.geometry&&(s+=this.getGeometryCacheKey()),e.skeleton&&(s+=e.skeleton.bones.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(s+=e._colorsTexture.uuid+",")),e.count>1&&(s+=e.uuid+","),s+=e.receiveShadow+",",D_(s)}get needsGeometryUpdate(){return this.geometry.id!==this.object.geometry.id}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Zo(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Zo(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const zi=[];class z_{constructor(e,t,s,i,n,r){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=i,this.bindings=n,this.info=r,this.chainMaps={}}get(e,t,s,i,n,r,o,l){const c=this.getChainMap(l);zi[0]=e,zi[1]=t,zi[2]=r,zi[3]=n;let h=c.get(zi);return h===void 0?(h=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,i,n,r,o,l),c.set(zi,h)):(h.updateClipping(o),h.needsGeometryUpdate&&h.setGeometry(e.geometry),(h.version!==t.version||h.needsUpdate)&&(h.initialCacheKey!==h.getCacheKey()?(h.dispose(),h=this.get(e,t,s,i,n,r,o,l)):h.version=t.version)),zi.length=0,h}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Ss)}dispose(){this.chainMaps={}}createRenderObject(e,t,s,i,n,r,o,l,c,h,u){const d=this.getChainMap(u),p=new k_(e,t,s,i,n,r,o,l,c,h);return p.onDispose=()=>{this.pipelines.delete(p),this.bindings.delete(p),this.nodes.delete(p),d.delete(p.getChainArray())},p}}class Ii{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const as={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Ei=16,G_=211,V_=212;class H_ extends Ii{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const s=this.get(e);if(s.version===void 0)t===as.VERTEX?this.backend.createAttribute(e):t===as.INDEX?this.backend.createIndexAttribute(e):t===as.STORAGE?this.backend.createStorageAttribute(e):t===as.INDIRECT&&this.backend.createIndirectStorageAttribute(e),s.version=this._getBufferAttribute(e).version;else{const i=this._getBufferAttribute(e);(s.version<i.version||i.usage===$n)&&(this.backend.updateAttribute(e),s.version=i.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const js=W_();function W_(){const a=new ArrayBuffer(4),e=new Float32Array(a),t=new Uint32Array(a),s=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(s[l]=0,s[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(s[l]=1024>>-c-14,s[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(s[l]=c+15<<10,s[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(s[l]=31744,s[l|256]=64512,i[l]=24,i[l|256]=24):(s[l]=31744,s[l|256]=64512,i[l]=13,i[l|256]=13)}const n=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;(c&8388608)===0;)c<<=1,h-=8388608;c&=-8388609,h+=947912704,n[l]=c|h}for(let l=1024;l<2048;++l)n[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)r[l]=l<<23;r[31]=1199570944,r[32]=2147483648;for(let l=33;l<63;++l)r[l]=2147483648+(l-32<<23);r[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:s,shiftTable:i,mantissaTable:n,exponentTable:r,offsetTable:o}}function Wt(a){Math.abs(a)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),a=de(a,-65504,65504),js.floatView[0]=a;const e=js.uint32View[0],t=e>>23&511;return js.baseTable[t]+((e&8388607)>>js.shiftTable[t])}function Ba(a){const e=a>>10;return js.uint32View[0]=js.mantissaTable[js.offsetTable[e]+(a&1023)]+js.exponentTable[e],js.floatView[0]}const Qe=new N,Ia=new ce;let $_=0;class os{constructor(e,t,s=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$_++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=s,this.usage=Xo,this.updateRanges=[],this.gpuType=Zt,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,s){e*=this.itemSize,s*=t.itemSize;for(let i=0,n=this.itemSize;i<n;i++)this.array[e+i]=t.array[s+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,s=this.count;t<s;t++)Ia.fromBufferAttribute(this,t),Ia.applyMatrix3(e),this.setXY(t,Ia.x,Ia.y);else if(this.itemSize===3)for(let t=0,s=this.count;t<s;t++)Qe.fromBufferAttribute(this,t),Qe.applyMatrix3(e),this.setXYZ(t,Qe.x,Qe.y,Qe.z);return this}applyMatrix4(e){for(let t=0,s=this.count;t<s;t++)Qe.fromBufferAttribute(this,t),Qe.applyMatrix4(e),this.setXYZ(t,Qe.x,Qe.y,Qe.z);return this}applyNormalMatrix(e){for(let t=0,s=this.count;t<s;t++)Qe.fromBufferAttribute(this,t),Qe.applyNormalMatrix(e),this.setXYZ(t,Qe.x,Qe.y,Qe.z);return this}transformDirection(e){for(let t=0,s=this.count;t<s;t++)Qe.fromBufferAttribute(this,t),Qe.transformDirection(e),this.setXYZ(t,Qe.x,Qe.y,Qe.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let s=this.array[e*this.itemSize+t];return this.normalized&&(s=At(s,this.array)),s}setComponent(e,t,s){return this.normalized&&(s=oe(s,this.array)),this.array[e*this.itemSize+t]=s,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=At(t,this.array)),t}setX(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=At(t,this.array)),t}setY(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=At(t,this.array)),t}setZ(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=At(t,this.array)),t}setW(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,s){return e*=this.itemSize,this.normalized&&(t=oe(t,this.array),s=oe(s,this.array)),this.array[e+0]=t,this.array[e+1]=s,this}setXYZ(e,t,s,i){return e*=this.itemSize,this.normalized&&(t=oe(t,this.array),s=oe(s,this.array),i=oe(i,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=i,this}setXYZW(e,t,s,i,n){return e*=this.itemSize,this.normalized&&(t=oe(t,this.array),s=oe(s,this.array),i=oe(i,this.array),n=oe(n,this.array)),this.array[e+0]=t,this.array[e+1]=s,this.array[e+2]=i,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Xo&&(e.usage=this.usage),e}}class Wm extends os{constructor(e,t,s){super(new Uint16Array(e),t,s)}}class $m extends os{constructor(e,t,s){super(new Uint32Array(e),t,s)}}class jm extends os{constructor(e,t,s){super(new Uint16Array(e),t,s),this.isFloat16BufferAttribute=!0}getX(e){let t=Ba(this.array[e*this.itemSize]);return this.normalized&&(t=At(t,this.array)),t}setX(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize]=Wt(t),this}getY(e){let t=Ba(this.array[e*this.itemSize+1]);return this.normalized&&(t=At(t,this.array)),t}setY(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize+1]=Wt(t),this}getZ(e){let t=Ba(this.array[e*this.itemSize+2]);return this.normalized&&(t=At(t,this.array)),t}setZ(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize+2]=Wt(t),this}getW(e){let t=Ba(this.array[e*this.itemSize+3]);return this.normalized&&(t=At(t,this.array)),t}setW(e,t){return this.normalized&&(t=oe(t,this.array)),this.array[e*this.itemSize+3]=Wt(t),this}setXY(e,t,s){return e*=this.itemSize,this.normalized&&(t=oe(t,this.array),s=oe(s,this.array)),this.array[e+0]=Wt(t),this.array[e+1]=Wt(s),this}setXYZ(e,t,s,i){return e*=this.itemSize,this.normalized&&(t=oe(t,this.array),s=oe(s,this.array),i=oe(i,this.array)),this.array[e+0]=Wt(t),this.array[e+1]=Wt(s),this.array[e+2]=Wt(i),this}setXYZW(e,t,s,i,n){return e*=this.itemSize,this.normalized&&(t=oe(t,this.array),s=oe(s,this.array),i=oe(i,this.array),n=oe(n,this.array)),this.array[e+0]=Wt(t),this.array[e+1]=Wt(s),this.array[e+2]=Wt(i),this.array[e+3]=Wt(n),this}}class Nt extends os{constructor(e,t,s){super(new Float32Array(e),t,s)}}function qm(a){return a.index!==null?a.index.version:a.attributes.position.version}function kd(a){const e=[],t=a.index,s=a.attributes.position;if(t!==null){const n=t.array;for(let r=0,o=n.length;r<o;r+=3){const l=n[r+0],c=n[r+1],h=n[r+2];e.push(l,c,c,h,h,l)}}else{const n=s.array;for(let r=0,o=n.length/3-1;r<o;r+=3){const l=r+0,c=r+1,h=r+2;e.push(l,c,c,h,h,l)}}const i=new(km(e)?$m:Wm)(e,1);return i.version=qm(a),i}class j_ extends Ii{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,s=this.get(t);s.initialized=!0,this.info.memory.geometries++;const i=()=>{this.info.memory.geometries--;const n=t.index,r=e.getAttributes();n!==null&&this.attributes.delete(n);for(const l of r)this.attributes.delete(l);const o=this.wireframes.get(t);o!==void 0&&this.attributes.delete(o),t.removeEventListener("dispose",i)};t.addEventListener("dispose",i)}updateAttributes(e){const t=e.getAttributes();for(const n of t)n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute?this.updateAttribute(n,as.STORAGE):this.updateAttribute(n,as.VERTEX);const s=this.getIndex(e);s!==null&&this.updateAttribute(s,as.INDEX);const i=e.geometry.indirect;i!==null&&this.updateAttribute(i,as.INDIRECT)}updateAttribute(e,t){const s=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,s)):this.attributeCall.get(e.data)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e.data,s),this.attributeCall.set(e,s)):this.attributeCall.get(e)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e,s))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:s}=e;let i=t.index;if(s.wireframe===!0){const n=this.wireframes;let r=n.get(t);r===void 0?(r=kd(t),n.set(t,r)):r.version!==qm(t)&&(this.attributes.delete(r),r=kd(t),n.set(t,r)),i=r}return i}}class q_{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,s){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=s*(t/3):e.isPoints?this.render.points+=s*t:e.isLineSegments?this.render.lines+=s*(t/2):e.isLine?this.render.lines+=s*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class Ym{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Y_ extends Ym{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}}class X_ extends Ym{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Z_=0;class Wl{constructor(e,t,s,i=null,n=null){this.id=Z_++,this.code=e,this.stage=t,this.name=s,this.transforms=i,this.attributes=n,this.usedTimes=0}}class Q_ extends Ii{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:s}=this,i=this.get(e);if(this._needsComputeUpdate(e)){const n=i.pipeline;n&&(n.usedTimes--,n.computeProgram.usedTimes--);const r=this.nodes.getForCompute(e);let o=this.programs.compute.get(r.computeShader);o===void 0&&(n&&n.computeProgram.usedTimes===0&&this._releaseProgram(n.computeProgram),o=new Wl(r.computeShader,"compute",e.name,r.transforms,r.nodeAttributes),this.programs.compute.set(r.computeShader,o),s.createProgram(o));const l=this._getComputeCacheKey(e,o);let c=this.caches.get(l);c===void 0&&(n&&n.usedTimes===0&&this._releasePipeline(n),c=this._getComputePipeline(e,o,l,t)),c.usedTimes++,o.usedTimes++,i.version=e.version,i.pipeline=c}return i.pipeline}getForRender(e,t=null){const{backend:s}=this,i=this.get(e);if(this._needsRenderUpdate(e)){const n=i.pipeline;n&&(n.usedTimes--,n.vertexProgram.usedTimes--,n.fragmentProgram.usedTimes--);const r=e.getNodeBuilderState(),o=e.material?e.material.name:"";let l=this.programs.vertex.get(r.vertexShader);l===void 0&&(n&&n.vertexProgram.usedTimes===0&&this._releaseProgram(n.vertexProgram),l=new Wl(r.vertexShader,"vertex",o),this.programs.vertex.set(r.vertexShader,l),s.createProgram(l));let c=this.programs.fragment.get(r.fragmentShader);c===void 0&&(n&&n.fragmentProgram.usedTimes===0&&this._releaseProgram(n.fragmentProgram),c=new Wl(r.fragmentShader,"fragment",o),this.programs.fragment.set(r.fragmentShader,c),s.createProgram(c));const h=this._getRenderCacheKey(e,l,c);let u=this.caches.get(h);u===void 0?(n&&n.usedTimes===0&&this._releasePipeline(n),u=this._getRenderPipeline(e,l,c,h,t)):e.pipeline=u,u.usedTimes++,l.usedTimes++,c.usedTimes++,i.pipeline=u}return i.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,s,i){s=s||this._getComputeCacheKey(e,t);let n=this.caches.get(s);return n===void 0&&(n=new X_(s,t),this.caches.set(s,n),this.backend.createComputePipeline(n,i)),n}_getRenderPipeline(e,t,s,i,n){i=i||this._getRenderCacheKey(e,t,s);let r=this.caches.get(i);return r===void 0&&(r=new Y_(i,t,s),this.caches.set(i,r),e.pipeline=r,this.backend.createRenderPipeline(e,n)),r}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,s){return t.id+","+s.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,s=e.stage;this.programs[s].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class K_ extends Ii{constructor(e,t,s,i,n,r){super(),this.backend=e,this.textures=s,this.pipelines=n,this.attributes=i,this.nodes=t,this.info=r,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const s of t){const i=this.get(s);i.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),i.bindGroup=s)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const s of t){const i=this.get(s);i.bindGroup===void 0&&(this._init(s),this.backend.createBindings(s,t,0),i.bindGroup=s)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const s=t.attribute,i=s.isIndirectStorageBufferAttribute?as.INDIRECT:as.STORAGE;this.attributes.update(s,i)}}_update(e,t){const{backend:s}=this;let i=!1,n=!0,r=0,o=0;for(const l of e.bindings)if(!(l.isNodeUniformsGroup&&this.nodes.updateGroup(l)===!1)){if(l.isStorageBuffer){const c=l.attribute,h=c.isIndirectStorageBufferAttribute?as.INDIRECT:as.STORAGE;this.attributes.update(c,h)}if(l.isUniformBuffer)l.update()&&s.updateBinding(l);else if(l.isSampler)l.update();else if(l.isSampledTexture){const c=this.textures.get(l.texture);l.needsBindingsUpdate(c.generation)&&(i=!0);const h=l.update(),u=l.texture;h&&this.textures.updateTexture(u);const d=s.get(u);if(d.externalTexture!==void 0||c.isDefaultTexture?n=!1:(r=r*10+u.id,o+=u.version),s.isWebGPUBackend===!0&&d.texture===void 0&&d.externalTexture===void 0&&(console.error("Bindings._update: binding should be available:",l,h,u,l.textureNode.value,i),this.textures.updateTexture(u),i=!0),u.isStorageTexture===!0){const p=this.get(u);l.store===!0?p.needsMipmap=!0:this.textures.needsMipmaps(u)&&p.needsMipmap===!0&&(this.backend.generateMipmaps(u),p.needsMipmap=!1)}}}i===!0&&this.backend.updateBindings(e,t,n?r:0,o)}}function J_(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.z!==e.z?a.z-e.z:a.id-e.id}function zd(a,e){return a.groupOrder!==e.groupOrder?a.groupOrder-e.groupOrder:a.renderOrder!==e.renderOrder?a.renderOrder-e.renderOrder:a.z!==e.z?e.z-a.z:a.id-e.id}function Gd(a){return(a.transmission>0||a.transmissionNode)&&a.side===Zn&&a.forceSinglePass===!1}class eb{constructor(e,t,s){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,s),this.lightsArray=[],this.scene=t,this.camera=s,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,s,i,n,r,o){let l=this.renderItems[this.renderItemsIndex];return l===void 0?(l={id:e.id,object:e,geometry:t,material:s,groupOrder:i,renderOrder:e.renderOrder,z:n,group:r,clippingContext:o},this.renderItems[this.renderItemsIndex]=l):(l.id=e.id,l.object=e,l.geometry=t,l.material=s,l.groupOrder=i,l.renderOrder=e.renderOrder,l.z=n,l.group=r,l.clippingContext=o),this.renderItemsIndex++,l}push(e,t,s,i,n,r,o){const l=this.getNextRenderItem(e,t,s,i,n,r,o);e.occlusionTest===!0&&this.occlusionQueryCount++,s.transparent===!0||s.transmission>0?(Gd(s)&&this.transparentDoublePass.push(l),this.transparent.push(l)):this.opaque.push(l)}unshift(e,t,s,i,n,r,o){const l=this.getNextRenderItem(e,t,s,i,n,r,o);s.transparent===!0||s.transmission>0?(Gd(s)&&this.transparentDoublePass.unshift(l),this.transparent.unshift(l)):this.opaque.unshift(l)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||J_),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||zd),this.transparent.length>1&&this.transparent.sort(t||zd)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const s=this.renderItems[e];if(s.id===null)break;s.id=null,s.object=null,s.geometry=null,s.material=null,s.groupOrder=null,s.renderOrder=null,s.z=null,s.group=null,s.clippingContext=null}}}const wr=[];class tb{constructor(e){this.lighting=e,this.lists=new Ss}get(e,t){const s=this.lists;wr[0]=e,wr[1]=t;let i=s.get(wr);return i===void 0&&(i=new eb(this.lighting,e,t),s.set(wr,i)),wr.length=0,i}dispose(){this.lists=new Ss}}let sb=0;class ib{constructor(){this.id=sb++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new me,this.scissor=!1,this.scissorValue=new me,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return Xm(this)}}function Xm(a){const{textures:e,activeCubeFace:t}=a,s=[t];for(const i of e)s.push(i.id);return ou(s)}let dn=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[e]===void 0&&(s[e]=[]),s[e].indexOf(t)===-1&&s[e].push(t)}hasEventListener(e,t){const s=this._listeners;return s===void 0?!1:s[e]!==void 0&&s[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners;if(s===void 0)return;const i=s[e];if(i!==void 0){const n=i.indexOf(t);n!==-1&&i.splice(n,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const s=t[e.type];if(s!==void 0){e.target=this;const i=s.slice(0);for(let n=0,r=i.length;n<r;n++)i[n].call(this,e);e.target=null}}};const Vd=new Be,Hd=new mr;class hs{constructor(e=0,t=0,s=0,i=hs.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=s,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,i=this._order){return this._x=e,this._y=t,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const i=e.elements,n=i[0],r=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],p=i[10];switch(t){case"XYZ":this._y=Math.asin(de(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-r,n)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-de(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(de(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-de(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(de(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-de(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-h,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,s===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,s){return Vd.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Vd,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Hd.setFromEuler(this),this.setFromQuaternion(Hd,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}hs.DEFAULT_ORDER="XYZ";class nb{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let rb=0;const Wd=new N,vn=new mr,zs=new Be,La=new N,Er=new N,ab=new N,ob=new mr,$d=new N(1,0,0),jd=new N(0,1,0),qd=new N(0,0,1),Yd={type:"added"},lb={type:"removed"},wn={type:"childadded",child:null},$l={type:"childremoved",child:null};class ht extends dn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:rb++}),this.uuid=Xs(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ht.DEFAULT_UP.clone();const e=new N,t=new hs,s=new mr,i=new N(1,1,1);function n(){s.setFromEuler(t,!1)}function r(){t.setFromQuaternion(s,void 0,!1)}t._onChange(n),s._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:s},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Be},normalMatrix:{value:new Vt}}),this.matrix=new Be,this.matrixWorld=new Be,this.matrixAutoUpdate=ht.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new nb,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return vn.setFromAxisAngle(e,t),this.quaternion.multiply(vn),this}rotateOnWorldAxis(e,t){return vn.setFromAxisAngle(e,t),this.quaternion.premultiply(vn),this}rotateX(e){return this.rotateOnAxis($d,e)}rotateY(e){return this.rotateOnAxis(jd,e)}rotateZ(e){return this.rotateOnAxis(qd,e)}translateOnAxis(e,t){return Wd.copy(e).applyQuaternion(this.quaternion),this.position.add(Wd.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($d,e)}translateY(e){return this.translateOnAxis(jd,e)}translateZ(e){return this.translateOnAxis(qd,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(zs.copy(this.matrixWorld).invert())}lookAt(e,t,s){e.isVector3?La.copy(e):La.set(e,t,s);const i=this.parent;this.updateWorldMatrix(!0,!1),Er.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?zs.lookAt(Er,La,this.up):zs.lookAt(La,Er,this.up),this.quaternion.setFromRotationMatrix(zs),i&&(zs.extractRotation(i.matrixWorld),vn.setFromRotationMatrix(zs),this.quaternion.premultiply(vn.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Yd),wn.child=e,this.dispatchEvent(wn),wn.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let s=0;s<arguments.length;s++)this.remove(arguments[s]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(lb),$l.child=e,this.dispatchEvent($l),$l.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),zs.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),zs.multiply(e.parent.matrixWorld)),e.applyMatrix4(zs),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Yd),wn.child=e,this.dispatchEvent(wn),wn.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let s=0,i=this.children.length;s<i;s++){const r=this.children[s].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,s=[]){this[e]===t&&s.push(this);const i=this.children;for(let n=0,r=i.length;n<r;n++)i[n].getObjectsByProperty(e,t,s);return s}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Er,e,ab),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Er,ob,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let s=0,i=t.length;s<i;s++)t[s].updateMatrixWorld(e)}updateWorldMatrix(e,t){const s=this.parent;if(e===!0&&s!==null&&s.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){const i=this.children;for(let n=0,r=i.length;n<r;n++)i[n].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",s={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},s.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function n(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=n(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];n(e.shapes,u)}else n(e.shapes,l)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(n(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(n(e.materials,this.material[l]));i.material=o}else i.material=n(e.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];i.animations.push(n(e.animations,l))}}if(t){const o=r(e.geometries),l=r(e.materials),c=r(e.textures),h=r(e.images),u=r(e.shapes),d=r(e.skeletons),p=r(e.animations),f=r(e.nodes);o.length>0&&(s.geometries=o),l.length>0&&(s.materials=l),c.length>0&&(s.textures=c),h.length>0&&(s.images=h),u.length>0&&(s.shapes=u),d.length>0&&(s.skeletons=d),p.length>0&&(s.animations=p),f.length>0&&(s.nodes=f)}return s.object=i,s;function r(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let s=0;s<e.children.length;s++){const i=e.children[s];this.add(i.clone())}return this}}ht.DEFAULT_UP=new N(0,1,0);ht.DEFAULT_MATRIX_AUTO_UPDATE=!0;ht.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class lu extends ht{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new hs,this.environmentIntensity=1,this.environmentRotation=new hs,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class cu extends ht{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Be,this.projectionMatrix=new Be,this.projectionMatrixInverse=new Be,this.coordinateSystem=Lt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Mr=[],cb=new lu,hb=new cu;class ub{constructor(){this.chainMaps={}}get(e,t,s=null){Mr[0]=e,Mr[1]=t;let i;if(s===null)i="default";else{const o=s.texture.format;i=`${s.textures.length}:${o}:${s.samples}:${s.depthBuffer}:${s.stencilBuffer}`}const n=this._getChainMap(i);let r=n.get(Mr);return r===void 0&&(r=new ib,n.set(Mr,r)),Mr.length=0,s!==null&&(r.sampleCount=s.samples===0?1:s.samples),r}getForClear(e=null){return this.get(cb,hb,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Ss)}dispose(){this.chainMaps={}}}let En;class db{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let s;if(e instanceof HTMLCanvasElement)s=e;else{En===void 0&&(En=Ph("canvas")),En.width=e.width,En.height=e.height;const i=En.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),s=En}return s.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ph("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const i=s.getImageData(0,0,e.width,e.height),n=i.data;for(let r=0;r<n.length;r++)n[r]=ei(n[r]/255)*255;return s.putImageData(i,0,0),t}else if(e.data){const t=e.data.slice(0);for(let s=0;s<t.length;s++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[s]=Math.floor(ei(t[s]/255)*255):t[s]=ei(t[s]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let pb=0;class hu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:pb++}),this.uuid=Xs(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const s={uuid:this.uuid,url:""},i=this.data;if(i!==null){let n;if(Array.isArray(i)){n=[];for(let r=0,o=i.length;r<o;r++)i[r].isDataTexture?n.push(jl(i[r].image)):n.push(jl(i[r]))}else n=jl(i);s.url=n}return t||(e.images[this.uuid]=s),s}}function jl(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?db.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let fb=0;const ql=new N;class Tt extends dn{constructor(e=Tt.DEFAULT_IMAGE,t=Tt.DEFAULT_MAPPING,s=Ai,i=Ai,n=Qt,r=Ks,o=rs,l=Rt,c=Tt.DEFAULT_ANISOTROPY,h=ni){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:fb++}),this.uuid=Xs(),this.name="",this.source=new hu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=s,this.wrapT=i,this.magFilter=n,this.minFilter=r,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new ce(0,0),this.repeat=new ce(1,1),this.center=new ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Vt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ql).x}get height(){return this.source.getSize(ql).y}get depth(){return this.source.getSize(ql).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const s=e[t];if(s===void 0){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${t}' does not exist.`);continue}i&&s&&i.isVector2&&s.isVector2||i&&s&&i.isVector3&&s.isVector3||i&&s&&i.isMatrix3&&s.isMatrix3?i.copy(s):this[t]=s}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const s={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(s.userData=this.userData),t||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Kh)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case lr:e.x=e.x-Math.floor(e.x);break;case Ai:e.x=e.x<0?0:1;break;case cr:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case lr:e.y=e.y-Math.floor(e.y);break;case Ai:e.y=e.y<0?0:1;break;case cr:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Tt.DEFAULT_IMAGE=null;Tt.DEFAULT_MAPPING=Kh;Tt.DEFAULT_ANISOTROPY=1;class Bs extends Tt{constructor(e,t,s=Ye,i,n,r,o=ct,l=ct,c,h=Os,u=1){if(h!==Os&&h!==Js)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,i,n,r,o,l,h,s,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new hu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}const mb=new N;class gb extends Ii{constructor(e,t,s){super(),this.renderer=e,this.backend=t,this.info=s}updateRenderTarget(e,t=0){const s=this.get(e),i=e.samples===0?1:e.samples,n=s.depthTextureMips||(s.depthTextureMips={}),r=e.textures,o=this.getSize(r[0]),l=o.width>>t,c=o.height>>t;let h=e.depthTexture||n[t];const u=e.depthBuffer===!0||e.stencilBuffer===!0;let d=!1;h===void 0&&u&&(h=new Bs,h.format=e.stencilBuffer?Js:Os,h.type=e.stencilBuffer?Pi:Ye,h.image.width=l,h.image.height=c,h.image.depth=o.depth,h.isArrayTexture=e.multiview===!0&&o.depth>1,n[t]=h),(s.width!==o.width||o.height!==s.height)&&(d=!0,h&&(h.needsUpdate=!0,h.image.width=l,h.image.height=c,h.image.depth=h.isArrayTexture?h.image.depth:1)),s.width=o.width,s.height=o.height,s.textures=r,s.depthTexture=h||null,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==i&&(d=!0,h&&(h.needsUpdate=!0),s.sampleCount=i);const p={sampleCount:i};if(e.isXRRenderTarget!==!0){for(let f=0;f<r.length;f++){const m=r[f];d&&(m.needsUpdate=!0),this.updateTexture(m,p)}h&&this.updateTexture(h,p)}if(s.initialized!==!0){s.initialized=!0;const f=()=>{e.removeEventListener("dispose",f);for(let m=0;m<r.length;m++)this._destroyTexture(r[m]);h&&this._destroyTexture(h),this.delete(e)};e.addEventListener("dispose",f)}}updateTexture(e,t={}){const s=this.get(e);if(s.initialized===!0&&s.version===e.version)return;const i=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,n=this.backend;if(i&&s.initialized===!0&&(n.destroySampler(e),n.destroyTexture(e)),e.isFramebufferTexture){const c=this.renderer.getRenderTarget();c?e.type=c.texture.type:e.type=Rt}const{width:r,height:o,depth:l}=this.getSize(e);if(t.width=r,t.height=o,t.depth=l,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,r,o):1,i||e.isStorageTexture===!0)n.createSampler(e),n.createTexture(e,t),s.generation=e.version;else if(s.initialized!==!0&&n.createSampler(e),e.version>0){const h=e.image;if(h===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(h.complete===!1)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const u=[];for(const d of e.images)u.push(d);t.images=u}else t.image=h;(s.isDefaultTexture===void 0||s.isDefaultTexture===!0)&&(n.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),e.source.dataReady===!0&&n.updateTexture(e,t),t.needsMipmaps&&e.mipmaps.length===0&&n.generateMipmaps(e)}}else n.createDefaultTexture(e),s.isDefaultTexture=!0,s.generation=e.version;if(s.initialized!==!0){s.initialized=!0,s.generation=e.version,this.info.memory.textures++;const c=()=>{e.removeEventListener("dispose",c),this._destroyTexture(e)};e.addEventListener("dispose",c)}s.version=e.version}getSize(e,t=mb){let s=e.images?e.images[0]:e.image;return s?(s.image!==void 0&&(s=s.image),t.width=s.width||1,t.height=s.height||1,t.depth=e.isCubeTexture?6:s.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,s){let i;return e.isCompressedTexture?e.mipmaps?i=e.mipmaps.length:i=1:i=Math.floor(Math.log2(Math.max(t,s)))+1,i}needsMipmaps(e){return e.isCompressedTexture===!0||e.generateMipmaps}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class uu extends Se{constructor(e,t,s,i=1){super(e,t,s),this.a=i}set(e,t,s,i=1){return this.a=i,super.set(e,t,s)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}const Ua={VERTEX:"vertex"},he={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Ys={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},yb=["fragment","vertex"],Xd=["setup","analyze","generate"],Zd=[...yb,"compute"],gr=["x","y","z","w"],xb={analyze:"setup",generate:"analyze"};let _b=0;class ae extends dn{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=he.NONE,this.updateBeforeType=he.NONE,this.updateAfterType=he.NONE,this.uuid=Mx.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:_b++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,he.FRAME)}onRenderUpdate(e){return this.onUpdate(e,he.RENDER)}onObjectUpdate(e){return this.onUpdate(e,he.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Qo(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=Zo(Gm(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getMemberType(){return"void"}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let s=0;for(const i of this.getChildren())t["node"+s++]=i;return t.outputNode||null}analyze(e,t=null){const s=e.increaseUsage(this);if(this.parents===!0){const i=e.getDataFromNode(this,"any");i.stages=i.stages||{},i.stages[e.shaderStage]=i.stages[e.shaderStage]||[],i.stages[e.shaderStage].push(t)}if(s===1){const i=e.getNodeProperties(this);for(const n of Object.values(i))n&&n.isNode===!0&&n.build(e,this)}}generate(e,t){const{outputNode:s}=e.getNodeProperties(this);if(s&&s.isNode===!0)return s.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const s=this.getShared(e);if(this!==s)return s.build(e,t);const i=e.getDataFromNode(this);i.buildStages=i.buildStages||{},i.buildStages[e.buildStage]=!0;const n=xb[e.buildStage];if(n&&i.buildStages[n]!==!0){const l=e.getBuildStage();e.setBuildStage(n),this.build(e),e.setBuildStage(l)}e.addNode(this),e.addChain(this);let r=null;const o=e.getBuildStage();if(o==="setup"){this.updateReference(e);const l=e.getNodeProperties(this);if(l.initialized!==!0){l.initialized=!0,l.outputNode=this.setup(e)||l.outputNode||null;for(const c of Object.values(l))if(c&&c.isNode===!0){if(c.parents===!0){const h=e.getNodeProperties(c);h.parents=h.parents||[],h.parents.push(this)}c.build(e)}}r=l.outputNode}else if(o==="analyze")this.analyze(e,t);else if(o==="generate")if(this.generate.length===1){const c=this.getNodeType(e),h=e.getDataFromNode(this);r=h.snippet,r===void 0?h.generated===void 0?(h.generated=!0,r=this.generate(e)||"",h.snippet=r):(console.warn("THREE.Node: Recursion detected.",this),r=""):h.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),r=e.format(r,c,t)}else r=this.generate(e,t)||"";return e.removeChain(this),e.addSequentialNode(this),r}getSerializeChildren(){return Qo(this)}serialize(e){const t=this.getSerializeChildren(),s={};for(const{property:i,index:n,childNode:r}of t)n!==void 0?(s[i]===void 0&&(s[i]=Number.isInteger(n)?[]:{}),s[i][n]=r.toJSON(e.meta).uuid):s[i]=r.toJSON(e.meta).uuid;Object.keys(s).length>0&&(e.inputNodes=s)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const s in e.inputNodes)if(Array.isArray(e.inputNodes[s])){const i=[];for(const n of e.inputNodes[s])i.push(t[n]);this[s]=i}else if(typeof e.inputNodes[s]=="object"){const i={};for(const n in e.inputNodes[s]){const r=e.inputNodes[s][n];i[n]=t[r]}this[s]=i}else{const i=e.inputNodes[s];this[s]=t[i]}}}toJSON(e){const{uuid:t,type:s}=this,i=e===void 0||typeof e=="string";i&&(e={textures:{},images:{},nodes:{}});let n=e.nodes[t];n===void 0&&(n={uuid:t,type:s,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(e.nodes[n.uuid]=n),this.serialize(n),delete n.meta);function r(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}if(i){const o=r(e.textures),l=r(e.images),c=r(e.nodes);o.length>0&&(n.textures=o),l.length>0&&(n.images=l),c.length>0&&(n.nodes=c)}return n}}class it extends ae{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),n=e.getDataFromNode(this);if(n.propertyName!==void 0)return e.format(n.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const r=super.build(e,i),o=e.getVarFromNode(this,null,i),l=e.getPropertyName(o);return e.addLineFlowCode(`${l} = ${r}`,this),n.snippet=r,n.propertyName=l,e.format(n.propertyName,i,t)}}return super.build(e,t)}}class va extends ae{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),s=this.node.build(e),i=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${s}[ ${i} ]`}}class Zm extends ae{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let s=null;for(const i of this.convertTo.split("|"))(s===null||e.getTypeLength(t)===e.getTypeLength(i))&&(s=i);return s}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const s=this.node,i=this.getNodeType(e),n=s.build(e,i);return e.format(n,i,t)}}class bb extends it{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,s)=>t+e.getTypeLength(s.getNodeType(e)),0))}generate(e,t){const s=this.getNodeType(e),i=e.getTypeLength(s),n=this.nodes,r=e.getComponentType(s),o=[];let l=0;for(const h of n){if(l>=i){console.error(`THREE.TSL: Length of parameters exceeds maximum length of function '${s}()' type.`);break}let u=h.getNodeType(e),d=e.getTypeLength(u),p;l+d>i&&(console.error(`THREE.TSL: Length of '${s}()' data exceeds maximum length of output type.`),d=i-l,u=e.getTypeFromLength(d)),l+=d,p=h.build(e,u);const f=e.getComponentType(u);f!==r&&(p=e.format(p,f,r)),o.push(p)}const c=`${e.getType(s)}( ${o.join(", ")} )`;return e.format(c,s,t)}}const Tb=gr.join("");class Qd extends ae{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(gr.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const s=this.node,i=e.getTypeLength(s.getNodeType(e));let n=null;if(i>1){let r=null;this.getVectorLength()>=i&&(r=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const l=s.build(e,r);this.components.length===i&&this.components===Tb.slice(0,this.components.length)?n=e.format(l,r,t):n=e.format(`${l}.${this.components}`,this.getNodeType(e),t)}else n=s.build(e,t);return n}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Sb extends it{static get type(){return"SetNode"}constructor(e,t,s){super(),this.sourceNode=e,this.components=t,this.targetNode=s}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:s,targetNode:i}=this,n=this.getNodeType(e),r=e.getComponentType(i.getNodeType(e)),o=e.getTypeFromLength(s.length,r),l=i.build(e,o),c=t.build(e,n),h=e.getTypeLength(n),u=[];for(let d=0;d<h;d++){const p=gr[d];p===s[0]?(u.push(l),d+=s.length-1):u.push(c+"."+p)}return`${e.getType(n)}( ${u.join(", ")} )`}}class vb extends it{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:s}=this,i=this.getNodeType(e),n=s.build(e),r=e.getVarFromNode(this),o=e.getPropertyName(r);e.addLineFlowCode(o+" = "+n,this);const l=e.getTypeLength(i),c=[];let h=0;for(let u=0;u<l;u++){const d=gr[u];d===t[h]?(c.push("1.0 - "+(o+"."+d)),h++):c.push(o+"."+d)}return`${e.getType(i)}( ${c.join(", ")} )`}}class du extends ae{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?Ko(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=Ko(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=B_(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Vm(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const Kd=/float|u?int/;class li extends du{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const s=this.getNodeType(e);return Kd.test(s)&&Kd.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),s,t)}}class wb extends ae{static get type(){return"MemberNode"}constructor(e,t){super(),this.node=e,this.property=t,this.isMemberNode=!0}getNodeType(e){return this.node.getMemberType(e,this.property)}generate(e){return this.node.build(e)+"."+this.property}}let hr=null;const jn=new Map;function O(a,e){if(jn.has(a)){console.warn(`THREE.TSL: Redefinition of method chaining '${a}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${a} is not a function`);jn.set(a,e)}const Qm=a=>a.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Jd=a=>Qm(a).split("").sort().join(""),Km={setup(a,e){const t=e.shift();return a(pl(t),...e)},get(a,e,t){if(typeof e=="string"&&a[e]===void 0){if(a.isStackNode!==!0&&e==="assign")return(...s)=>(hr.assign(t,...s),t);if(jn.has(e)){const s=jn.get(e);return a.isStackNode?(...i)=>t.add(s(...i)):(...i)=>s(t,...i)}else{if(e==="self")return a;if(e.endsWith("Assign")&&jn.has(e.slice(0,e.length-6))){const s=jn.get(e.slice(0,e.length-6));return a.isStackNode?(...i)=>t.assign(i[0],s(...i)):(...i)=>t.assign(s(t,...i))}else{if(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0)return e=Qm(e),k(new Qd(t,e));if(/^set[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Jd(e.slice(3).toLowerCase()),s=>k(new Sb(a,e,k(s)));if(/^flip[XYZWRGBASTPQ]{1,4}$/.test(e)===!0)return e=Jd(e.slice(4).toLowerCase()),()=>k(new vb(k(a),e));if(e==="width"||e==="height"||e==="depth")return e==="width"?e="x":e==="height"?e="y":e==="depth"&&(e="z"),k(new Qd(a,e));if(/^\d+$/.test(e)===!0)return k(new va(t,new li(Number(e),"uint")));if(/^get$/.test(e)===!0)return s=>k(new wb(t,s))}}}return Reflect.get(a,e,t)},set(a,e,t,s){return typeof e=="string"&&a[e]===void 0&&(/^[xyzwrgbastpq]{1,4}$/.test(e)===!0||e==="width"||e==="height"||e==="depth"||/^\d+$/.test(e)===!0)?(s[e].assign(t),!0):Reflect.set(a,e,t,s)}},Yl=new WeakMap,ep=new WeakMap,Eb=function(a,e=null){const t=Ko(a);if(t==="node"){let s=Yl.get(a);return s===void 0&&(s=new Proxy(a,Km),Yl.set(a,s),Yl.set(s,s)),s}else{if(e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string")return k(Dh(a,e));if(t==="shader")return L(a)}return a},Mb=function(a,e=null){for(const t in a)a[t]=k(a[t],e);return a},Cb=function(a,e=null){const t=a.length;for(let s=0;s<t;s++)a[s]=k(a[s],e);return a},Ab=function(a,e=null,t=null,s=null){const i=h=>k(s!==null?Object.assign(h,s):h);let n,r=e,o,l;function c(h){let u;return r?u=/[a-z]/i.test(r)?r+"()":r:u=a.type,o!==void 0&&h.length<o?(console.error(`THREE.TSL: "${u}" parameter length is less than minimum required.`),h.concat(new Array(o-h.length).fill(0))):l!==void 0&&h.length>l?(console.error(`THREE.TSL: "${u}" parameter length exceeds limit.`),h.slice(0,l)):h}return e===null?n=(...h)=>i(new a(...er(c(h)))):t!==null?(t=k(t),n=(...h)=>i(new a(e,...er(c(h)),t))):n=(...h)=>i(new a(e,...er(c(h)))),n.setParameterLength=(...h)=>(h.length===1?o=l=h[0]:h.length===2&&([o,l]=h),n),n.setName=h=>(r=h,n),n},Rb=function(a,...e){return k(new a(...er(e)))};class Nb extends ae{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,inputNodes:s}=this,i=e.getNodeProperties(t),n=t.namespace&&t.namespace===e.namespace?e.getNamespace("once"):"once";if(i[n])return i[n];let r=null;if(t.layout){let o=ep.get(e.constructor);o===void 0&&(o=new WeakMap,ep.set(e.constructor,o));let l=o.get(t);l===void 0&&(l=k(e.buildFunctionNode(t)),o.set(t,l)),e.addInclude(l),r=k(l.call(s))}else{const o=t.jsFunc,l=s!==null||o.length>1?o(s||[],e):o(e);r=k(l)}return t.once&&(i[n]=r),r}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),s=e.getOutputNamespace();return t[s]=t[s]||this.setupOutput(e),t[s]}build(e,t=null){let s=null;const i=e.getBuildStage(),n=e.getNodeProperties(this),r=e.getOutputNamespace(),o=this.getOutputNode(e);if(i==="setup"){const l=e.getNamespace("initialized");n[l]!==!0&&(n[l]=!0,n[r]=this.getOutputNode(e),n[r].build(e)),s=n[r]}else i==="analyze"?o.build(e,t):i==="generate"&&(s=o.build(e,t)||"");return s}}class Pb extends ae{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1,this.namespace=null}setLayout(e){return this.layout=e,this}call(e=null){return pl(e),k(new Nb(this,e))}setup(){return this.call()}}const Db=[!1,!0],Fb=[0,1,2,3],Ob=[-1,-2],Jm=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],pu=new Map;for(const a of Db)pu.set(a,new li(a));const fu=new Map;for(const a of Fb)fu.set(a,new li(a,"uint"));const mu=new Map([...fu].map(a=>new li(a.value,"int")));for(const a of Ob)mu.set(a,new li(a,"int"));const ul=new Map([...mu].map(a=>new li(a.value)));for(const a of Jm)ul.set(a,new li(a));for(const a of Jm)ul.set(-a,new li(-a));const dl={bool:pu,uint:fu,ints:mu,float:ul},tp=new Map([...pu,...ul]),Dh=(a,e)=>tp.has(a)?tp.get(a):a.isNode===!0?a:new li(a,e),Bb=a=>{try{return a.getNodeType()}catch{return}},nt=function(a,e=null){return(...t)=>{if((t.length===0||!["bool","float","int","uint"].includes(a)&&t.every(i=>typeof i!="object"))&&(t=[Vm(a,...t)]),t.length===1&&e!==null&&e.has(t[0]))return k(e.get(t[0]));if(t.length===1){const i=Dh(t[0],a);return Bb(i)===a?k(i):k(new Zm(i,a))}const s=t.map(i=>Dh(i));return k(new bb(s,a))}},sp=a=>typeof a=="object"&&a!==null?a.value:a,Ib=a=>a!=null?a.nodeType||a.convertTo||(typeof a=="string"?a:null):null;function Qr(a,e){return new Proxy(new Pb(a,e),Km)}const k=(a,e=null)=>Eb(a,e),pl=(a,e=null)=>new Mb(a,e),er=(a,e=null)=>new Cb(a,e),U=(...a)=>new Ab(...a),V=(...a)=>new Rb(...a);let Lb=0;const L=(a,e=null)=>{let t=null;e!==null&&(typeof e=="object"?t=e.return:(typeof e=="string"?t=e:console.error("THREE.TSL: Invalid layout type."),e=null));const s=new Qr(a,t),i=(...n)=>{let r;pl(n),n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)?r=[...n]:r=n[0];const l=s.call(r);return t==="void"&&l.toStack(),l};if(i.shaderNode=s,i.id=s.id,i.getNodeType=(...n)=>s.getNodeType(...n),i.getCacheKey=(...n)=>s.getCacheKey(...n),i.setLayout=n=>(s.setLayout(n),i),i.once=(n=null)=>(s.once=!0,s.namespace=n,i),e!==null){if(typeof e.inputs!="object"){const n={name:"fn"+Lb++,type:t,inputs:[]};for(const r in e)r!=="return"&&n.inputs.push({name:r,type:e[r]});e=n}i.setLayout(e)}return i},Jo=a=>{hr=a},eg=()=>hr,Xe=(...a)=>hr.If(...a);function tg(a){return hr&&hr.add(a),a}O("toStack",tg);const Ub=new nt("color"),B=new nt("float",dl.float),Ue=new nt("int",dl.ints),kb=new nt("uint",dl.uint),gu=new nt("bool",dl.bool),H=new nt("vec2"),$s=new nt("ivec2"),zb=new nt("uvec2"),Gb=new nt("bvec2"),I=new nt("vec3"),Vb=new nt("ivec3"),Hb=new nt("uvec3"),Wb=new nt("bvec3"),re=new nt("vec4"),$b=new nt("ivec4"),jb=new nt("uvec4"),qb=new nt("bvec4"),yu=new nt("mat2"),Pt=new nt("mat3"),tr=new nt("mat4");O("toColor",Ub);O("toFloat",B);O("toInt",Ue);O("toUint",kb);O("toBool",gu);O("toVec2",H);O("toIVec2",$s);O("toUVec2",zb);O("toBVec2",Gb);O("toVec3",I);O("toIVec3",Vb);O("toUVec3",Hb);O("toBVec3",Wb);O("toVec4",re);O("toIVec4",$b);O("toUVec4",jb);O("toBVec4",qb);O("toMat2",yu);O("toMat3",Pt);O("toMat4",tr);const Yb=U(va).setParameterLength(2),Xb=(a,e)=>k(new Zm(k(a),e));O("element",Yb);O("convert",Xb);O("append",a=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),tg(a)));class Zb extends it{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const s=e.getTypeLength(t.node.getNodeType(e));return gr.join("").slice(0,s)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:s}=this,i=e.getNodeProperties(this);i.sourceNode=s,i.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:s,sourceNode:i}=e.getNodeProperties(this),n=this.needsSplitAssign(e),r=s.getNodeType(e),o=s.build(e),l=i.build(e,r),c=i.getNodeType(e),h=e.getDataFromNode(this);let u;if(h.initialized===!0)t!=="void"&&(u=o);else if(n){const d=e.getVarFromNode(this,null,r),p=e.getPropertyName(d);e.addLineFlowCode(`${p} = ${l}`,this);const f=s.node,y=f.node.context({assign:!0}).build(e);for(let g=0;g<f.components.length;g++){const _=f.components[g];e.addLineFlowCode(`${y}.${_} = ${p}[ ${g} ]`,this)}t!=="void"&&(u=o)}else u=`${o} = ${l}`,(t==="void"||c==="void")&&(e.addLineFlowCode(u,this),t!=="void"&&(u=o));return h.initialized=!0,e.format(u,r,t)}}const Qb=U(Zb).setParameterLength(2);O("assign",Qb);class ip extends it{static get type(){return"ArrayNode"}constructor(e,t,s=null){super(e),this.count=t,this.values=s,this.isArrayNode=!0}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const Kb=(...a)=>{let e;if(a.length===1){const t=a[0];e=new ip(null,t.length,t)}else{const t=a[0],s=a[1];e=new ip(t,s)}return k(e)};O("toArray",(a,e)=>Kb(Array(e).fill(a)));class sg extends ae{static get type(){return"UniformGroupNode"}constructor(e,t=!1,s=1){super("string"),this.name=e,this.shared=t,this.order=s,this.isUniformGroup=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const Jb=a=>new sg(a),xu=(a,e=0)=>new sg(a,!0,e),eT=xu("frame"),K=xu("render"),ig=Jb("object");class wa extends du{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=ig}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const s=this.getSelf();return e=e.bind(s),super.onUpdate(i=>{const n=e(i,s);n!==void 0&&(this.value=n)},t)}generate(e,t){const s=this.getNodeType(e),i=this.getUniformHash(e);let n=e.getNodeFromHash(i);n===void 0&&(e.setHashNode(this,i),n=this);const r=n.getInputType(e),o=e.getUniformFromNode(n,r,e.shaderStage,this.name||e.context.label),l=e.getPropertyName(o);return e.context.label!==void 0&&delete e.context.label,e.format(l,s,t)}}const J=(a,e)=>{const t=Ib(e||a),s=a&&a.isNode===!0?a.node&&a.node.value||a.value:a;return k(new wa(s,t))};class Ae extends ae{static get type(){return"PropertyNode"}constructor(e,t=null,s=!1){super(e),this.name=t,this.varying=s,this.isPropertyNode=!0,this.global=!0}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const ng=(a,e)=>k(new Ae(a,e)),el=(a,e)=>k(new Ae(a,e,!0)),Te=V(Ae,"vec4","DiffuseColor"),np=V(Ae,"vec3","EmissiveColor"),qs=V(Ae,"float","Roughness"),tl=V(Ae,"float","Metalness"),Fh=V(Ae,"float","Clearcoat"),sl=V(Ae,"float","ClearcoatRoughness"),qn=V(Ae,"vec3","Sheen"),_u=V(Ae,"float","SheenRoughness"),bu=V(Ae,"float","Iridescence"),rg=V(Ae,"float","IridescenceIOR"),ag=V(Ae,"float","IridescenceThickness"),Oh=V(Ae,"float","AlphaT"),en=V(Ae,"float","Anisotropy"),No=V(Ae,"vec3","AnisotropyT"),sr=V(Ae,"vec3","AnisotropyB"),qt=V(Ae,"color","SpecularColor"),il=V(Ae,"float","SpecularF90"),Bh=V(Ae,"float","Shininess"),la=V(Ae,"vec4","Output"),Xl=V(Ae,"float","dashSize"),rp=V(Ae,"float","gapSize"),Po=V(Ae,"float","IOR"),Ih=V(Ae,"float","Transmission"),og=V(Ae,"float","Thickness"),lg=V(Ae,"float","AttenuationDistance"),cg=V(Ae,"color","AttenuationColor"),hg=V(Ae,"float","Dispersion");class tT extends it{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}generate(e){const t=[],s=this.functionNode,i=s.getInputs(e),n=this.parameters,r=(l,c)=>{const h=c.type,u=h==="pointer";let d;return u?d="&"+l.build(e):d=l.build(e,h),d};if(Array.isArray(n)){if(n.length>i.length)console.error("THREE.TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),n.length=i.length;else if(n.length<i.length)for(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");n.length<i.length;)n.push(B(0));for(let l=0;l<n.length;l++)t.push(r(n[l],i[l]))}else for(const l of i){const c=n[l.name];c!==void 0?t.push(r(c,l)):(console.error(`THREE.TSL: Input '${l.name}' not found in 'Fn()'.`),t.push(r(B(0),l)))}return`${s.build(e,"property")}( ${t.join(", ")} )`}}const sT=(a,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?er(e):pl(e[0]),k(new tT(k(a),e)));O("call",sT);const iT={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class He extends it{static get type(){return"OperatorNode"}constructor(e,t,s,...i){if(super(),i.length>0){let n=new He(e,t,s);for(let r=0;r<i.length-1;r++)n=new He(e,n,i[r]);t=n,s=i[i.length-1]}this.op=e,this.aNode=t,this.bNode=s,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(iT[this.op],t)}getNodeType(e){const t=this.op,s=this.aNode,i=this.bNode,n=s.getNodeType(e),r=i?i.getNodeType(e):null;if(n==="void"||r==="void")return"void";if(t==="%")return n;if(t==="~"||t==="&"||t==="|"||t==="^"||t===">>"||t==="<<")return e.getIntegerType(n);if(t==="!"||t==="&&"||t==="||"||t==="^^")return"bool";if(t==="=="||t==="!="||t==="<"||t===">"||t==="<="||t===">="){const o=Math.max(e.getTypeLength(n),e.getTypeLength(r));return o>1?`bvec${o}`:"bool"}else{if(e.isMatrix(n)){if(r==="float")return n;if(e.isVector(r))return e.getVectorFromMatrix(n);if(e.isMatrix(r))return n}else if(e.isMatrix(r)){if(n==="float")return r;if(e.isVector(n))return e.getVectorFromMatrix(r)}return e.getTypeLength(r)>e.getTypeLength(n)?r:n}}generate(e,t){const s=this.op,{aNode:i,bNode:n}=this,r=this.getNodeType(e);let o=null,l=null;r!=="void"?(o=i.getNodeType(e),l=n?n.getNodeType(e):null,s==="<"||s===">"||s==="<="||s===">="||s==="=="||s==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):s===">>"||s==="<<"?(o=r,l=e.changeComponentType(l,"uint")):s==="%"?(o=r,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=r):e.isMatrix(l)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(l):o=l=r:o=l=r):o=l=r;const c=i.build(e,o),h=n?n.build(e,l):null,u=e.getFunctionOperator(s);if(t!=="void"){const d=e.renderer.coordinateSystem===Lt;if(s==="=="||s==="!="||s==="<"||s===">"||s==="<="||s===">=")return d?e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${h} )`,r,t):e.format(`( ${c} ${s} ${h} )`,r,t):e.format(`( ${c} ${s} ${h} )`,r,t);if(s==="%")return e.isInteger(l)?e.format(`( ${c} % ${h} )`,r,t):e.format(`${this.getOperatorMethod(e,r)}( ${c}, ${h} )`,r,t);if(s==="!"||s==="~")return e.format(`(${s}${c})`,o,t);if(u)return e.format(`${u}( ${c}, ${h} )`,r,t);if(e.isMatrix(o)&&l==="float")return e.format(`( ${h} ${s} ${c} )`,r,t);if(o==="float"&&e.isMatrix(l))return e.format(`${c} ${s} ${h}`,r,t);{let p=`( ${c} ${s} ${h} )`;return!d&&r==="bool"&&e.isVector(o)&&e.isVector(l)&&(p=`all${p}`),e.format(p,r,t)}}else if(o!=="void")return u?e.format(`${u}( ${c}, ${h} )`,r,t):e.isMatrix(o)&&l==="float"?e.format(`${h} ${s} ${c}`,r,t):e.format(`${c} ${s} ${h}`,r,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Dt=U(He,"+").setParameterLength(2,1/0).setName("add"),Ct=U(He,"-").setParameterLength(2,1/0).setName("sub"),pe=U(He,"*").setParameterLength(2,1/0).setName("mul"),Is=U(He,"/").setParameterLength(2,1/0).setName("div"),fl=U(He,"%").setParameterLength(2).setName("mod"),ug=U(He,"==").setParameterLength(2).setName("equal"),nT=U(He,"!=").setParameterLength(2).setName("notEqual"),rT=U(He,"<").setParameterLength(2).setName("lessThan"),aT=U(He,">").setParameterLength(2).setName("greaterThan"),oT=U(He,"<=").setParameterLength(2).setName("lessThanEqual"),lT=U(He,">=").setParameterLength(2).setName("greaterThanEqual"),cT=U(He,"&&").setParameterLength(2,1/0).setName("and"),hT=U(He,"||").setParameterLength(2,1/0).setName("or"),uT=U(He,"!").setParameterLength(1).setName("not"),dT=U(He,"^^").setParameterLength(2).setName("xor"),pT=U(He,"&").setParameterLength(2).setName("bitAnd"),fT=U(He,"~").setParameterLength(2).setName("bitNot"),mT=U(He,"|").setParameterLength(2).setName("bitOr"),gT=U(He,"^").setParameterLength(2).setName("bitXor"),yT=U(He,"<<").setParameterLength(2).setName("shiftLeft"),xT=U(He,">>").setParameterLength(2).setName("shiftRight"),_T=L(([a])=>(a.addAssign(1),a)),bT=L(([a])=>(a.subAssign(1),a)),TT=L(([a])=>{const e=Ue(a).toConst();return a.addAssign(1),e}),ST=L(([a])=>{const e=Ue(a).toConst();return a.subAssign(1),e});O("add",Dt);O("sub",Ct);O("mul",pe);O("div",Is);O("mod",fl);O("equal",ug);O("notEqual",nT);O("lessThan",rT);O("greaterThan",aT);O("lessThanEqual",oT);O("greaterThanEqual",lT);O("and",cT);O("or",hT);O("not",uT);O("xor",dT);O("bitAnd",pT);O("bitNot",fT);O("bitOr",mT);O("bitXor",gT);O("shiftLeft",yT);O("shiftRight",xT);O("incrementBefore",_T);O("decrementBefore",bT);O("increment",TT);O("decrement",ST);const vT=(a,e)=>(console.warn('THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.'),fl(a,e)),wT=(a,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),fl(Ue(a),Ue(e)));O("remainder",vT);O("modInt",wT);class A extends it{static get type(){return"MathNode"}constructor(e,t,s=null,i=null){if(super(),(e===A.MAX||e===A.MIN)&&arguments.length>3){let n=new A(e,t,s);for(let r=2;r<arguments.length-1;r++)n=new A(e,n,arguments[r]);t=n,s=arguments[arguments.length-1],i=null}this.method=e,this.aNode=t,this.bNode=s,this.cNode=i,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,n=e.isMatrix(t)?0:e.getTypeLength(t),r=e.isMatrix(s)?0:e.getTypeLength(s),o=e.isMatrix(i)?0:e.getTypeLength(i);return n>r&&n>o?t:r>o?s:o>n?i:t}getNodeType(e){const t=this.method;return t===A.LENGTH||t===A.DISTANCE||t===A.DOT?"float":t===A.CROSS?"vec3":t===A.ALL||t===A.ANY?"bool":t===A.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:s,method:i}=this;let n=null;if(i===A.ONE_MINUS)n=Ct(1,t);else if(i===A.RECIPROCAL)n=Is(1,t);else if(i===A.DIFFERENCE)n=is(Ct(t,s));else if(i===A.TRANSFORM_DIRECTION){let r=t,o=s;e.isMatrix(r.getNodeType(e))?o=re(I(o),0):r=re(I(r),0);const l=pe(r,o).xyz;n=_a(l)}return n!==null?n:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let i=this.method;const n=this.getNodeType(e),r=this.getInputType(e),o=this.aNode,l=this.bNode,c=this.cNode,h=e.renderer.coordinateSystem;if(i===A.NEGATE)return e.format("( - "+o.build(e,r)+" )",n,t);{const u=[];return i===A.CROSS?u.push(o.build(e,n),l.build(e,n)):h===Lt&&i===A.STEP?u.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":r),l.build(e,r)):h===Lt&&(i===A.MIN||i===A.MAX)?u.push(o.build(e,r),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":r)):i===A.REFRACT?u.push(o.build(e,r),l.build(e,r),c.build(e,"float")):i===A.MIX?u.push(o.build(e,r),l.build(e,r),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":r)):(h===Fi&&i===A.ATAN&&l!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===A.DFDX||i===A.DFDY)&&(console.warn(`THREE.TSL: '${i}' is not supported in the ${e.shaderStage} stage.`),i="/*"+i+"*/"),u.push(o.build(e,r)),l!==null&&u.push(l.build(e,r)),c!==null&&u.push(c.build(e,r))),e.format(`${e.getMethod(i,n)}( ${u.join(", ")} )`,n,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}A.ALL="all";A.ANY="any";A.RADIANS="radians";A.DEGREES="degrees";A.EXP="exp";A.EXP2="exp2";A.LOG="log";A.LOG2="log2";A.SQRT="sqrt";A.INVERSE_SQRT="inversesqrt";A.FLOOR="floor";A.CEIL="ceil";A.NORMALIZE="normalize";A.FRACT="fract";A.SIN="sin";A.COS="cos";A.TAN="tan";A.ASIN="asin";A.ACOS="acos";A.ATAN="atan";A.ABS="abs";A.SIGN="sign";A.LENGTH="length";A.NEGATE="negate";A.ONE_MINUS="oneMinus";A.DFDX="dFdx";A.DFDY="dFdy";A.ROUND="round";A.RECIPROCAL="reciprocal";A.TRUNC="trunc";A.FWIDTH="fwidth";A.TRANSPOSE="transpose";A.BITCAST="bitcast";A.EQUALS="equals";A.MIN="min";A.MAX="max";A.STEP="step";A.REFLECT="reflect";A.DISTANCE="distance";A.DIFFERENCE="difference";A.DOT="dot";A.CROSS="cross";A.POW="pow";A.TRANSFORM_DIRECTION="transformDirection";A.MIX="mix";A.CLAMP="clamp";A.REFRACT="refract";A.SMOOTHSTEP="smoothstep";A.FACEFORWARD="faceforward";const ET=B(1e-6),MT=B(Math.PI),CT=U(A,A.ALL).setParameterLength(1),AT=U(A,A.ANY).setParameterLength(1),RT=U(A,A.RADIANS).setParameterLength(1),NT=U(A,A.DEGREES).setParameterLength(1),dg=U(A,A.EXP).setParameterLength(1),xa=U(A,A.EXP2).setParameterLength(1),pg=U(A,A.LOG).setParameterLength(1),ti=U(A,A.LOG2).setParameterLength(1),Tu=U(A,A.SQRT).setParameterLength(1),PT=U(A,A.INVERSE_SQRT).setParameterLength(1),hn=U(A,A.FLOOR).setParameterLength(1),Su=U(A,A.CEIL).setParameterLength(1),_a=U(A,A.NORMALIZE).setParameterLength(1),Li=U(A,A.FRACT).setParameterLength(1),xs=U(A,A.SIN).setParameterLength(1),vi=U(A,A.COS).setParameterLength(1),DT=U(A,A.TAN).setParameterLength(1),FT=U(A,A.ASIN).setParameterLength(1),fg=U(A,A.ACOS).setParameterLength(1),mg=U(A,A.ATAN).setParameterLength(1,2),is=U(A,A.ABS).setParameterLength(1),nl=U(A,A.SIGN).setParameterLength(1),si=U(A,A.LENGTH).setParameterLength(1),OT=U(A,A.NEGATE).setParameterLength(1),BT=U(A,A.ONE_MINUS).setParameterLength(1),gg=U(A,A.DFDX).setParameterLength(1),yg=U(A,A.DFDY).setParameterLength(1),IT=U(A,A.ROUND).setParameterLength(1),LT=U(A,A.RECIPROCAL).setParameterLength(1),UT=U(A,A.TRUNC).setParameterLength(1),kT=U(A,A.FWIDTH).setParameterLength(1),zT=U(A,A.TRANSPOSE).setParameterLength(1),GT=(a,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),ug(a,e)),ur=U(A,A.MIN).setParameterLength(2,1/0),St=U(A,A.MAX).setParameterLength(2,1/0),xg=U(A,A.STEP).setParameterLength(2),VT=U(A,A.REFLECT).setParameterLength(2),HT=U(A,A.DISTANCE).setParameterLength(2),WT=U(A,A.DIFFERENCE).setParameterLength(2),vu=U(A,A.DOT).setParameterLength(2),_g=U(A,A.CROSS).setParameterLength(2),ml=U(A,A.POW).setParameterLength(2),bg=U(A,A.POW,2).setParameterLength(1),$T=U(A,A.POW,3).setParameterLength(1),jT=U(A,A.POW,4).setParameterLength(1),qT=U(A,A.TRANSFORM_DIRECTION).setParameterLength(2),YT=a=>pe(nl(a),ml(is(a),1/3)),Tg=a=>vu(a,a),ze=U(A,A.MIX).setParameterLength(3),ai=(a,e=0,t=1)=>k(new A(A.CLAMP,k(a),k(e),k(t))),Sg=a=>ai(a),vg=U(A,A.REFRACT).setParameterLength(3),Oi=U(A,A.SMOOTHSTEP).setParameterLength(3),XT=U(A,A.FACEFORWARD).setParameterLength(3),ZT=L(([a])=>{const s=43758.5453,i=vu(a.xy,H(12.9898,78.233)),n=fl(i,MT);return Li(xs(n).mul(s))}),QT=(a,e,t)=>ze(e,t,a),KT=(a,e,t)=>Oi(e,t,a),JT=(a,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),mg(a,e));O("all",CT);O("any",AT);O("equals",GT);O("radians",RT);O("degrees",NT);O("exp",dg);O("exp2",xa);O("log",pg);O("log2",ti);O("sqrt",Tu);O("inverseSqrt",PT);O("floor",hn);O("ceil",Su);O("normalize",_a);O("fract",Li);O("sin",xs);O("cos",vi);O("tan",DT);O("asin",FT);O("acos",fg);O("atan",mg);O("abs",is);O("sign",nl);O("length",si);O("lengthSq",Tg);O("negate",OT);O("oneMinus",BT);O("dFdx",gg);O("dFdy",yg);O("round",IT);O("reciprocal",LT);O("trunc",UT);O("fwidth",kT);O("atan2",JT);O("min",ur);O("max",St);O("step",xg);O("reflect",VT);O("distance",HT);O("dot",vu);O("cross",_g);O("pow",ml);O("pow2",bg);O("pow3",$T);O("pow4",jT);O("transformDirection",qT);O("mix",QT);O("clamp",ai);O("refract",vg);O("smoothstep",KT);O("faceForward",XT);O("difference",WT);O("saturate",Sg);O("cbrt",YT);O("transpose",zT);O("rand",ZT);class eS extends ae{static get type(){return"ConditionalNode"}constructor(e,t,s=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=s}getNodeType(e){const{ifNode:t,elseNode:s}=e.getNodeProperties(this);if(t===void 0)return this.setup(e),this.getNodeType(e);const i=t.getNodeType(e);if(s!==null){const n=s.getNodeType(e);if(e.getTypeLength(n)>e.getTypeLength(i))return n}return i}setup(e){const t=this.condNode.cache(),s=this.ifNode.cache(),i=this.elseNode?this.elseNode.cache():null,n=e.context.nodeBlock;e.getDataFromNode(s).parentNodeBlock=n,i!==null&&(e.getDataFromNode(i).parentNodeBlock=n);const r=e.getNodeProperties(this);r.condNode=t,r.ifNode=s.context({nodeBlock:s}),r.elseNode=i?i.context({nodeBlock:i}):null}generate(e,t){const s=this.getNodeType(e),i=e.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:n,ifNode:r,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,c=t!=="void",h=c?ng(s).build(e):"";i.nodeProperty=h;const u=n.build(e,"bool");e.addFlowCode(`
|
|
51
51
|
${e.tab}if ( ${u} ) {
|
|
52
52
|
|
|
@@ -597,4 +597,4 @@ void main() {
|
|
|
597
597
|
void main() {
|
|
598
598
|
#include <clipping_planes_fragment>
|
|
599
599
|
gl_FragColor = vec4(vec3(vUv, 0.0), 1.0);
|
|
600
|
-
}`;class lN extends x.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:aN,fragmentShader:oN})}}const Qi=new x.Raycaster,yt=new x.Vector3,_i=new x.Vector3,Ve=new x.Quaternion,Hf={X:new x.Vector3(1,0,0),Y:new x.Vector3(0,1,0),Z:new x.Vector3(0,0,1)},ih={type:"change"},Wf={type:"mouseDown",mode:null},$f={type:"mouseUp",mode:null},jf={type:"objectChange"};class cN extends x.Controls{constructor(e,t=null){super(void 0,t);const s=new mN(this);this._root=s;const i=new gN;this._gizmo=i,s.add(i);const n=new yN;this._plane=n,s.add(n);const r=this;function o(b,T){let S=T;Object.defineProperty(r,b,{get:function(){return S!==void 0?S:T},set:function(M){S!==M&&(S=M,n[b]=M,i[b]=M,r.dispatchEvent({type:b+"-changed",value:M}),r.dispatchEvent(ih))}}),r[b]=T,n[b]=T,i[b]=T}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new x.Vector3,c=new x.Vector3,h=new x.Quaternion,u=new x.Quaternion,d=new x.Vector3,p=new x.Quaternion,f=new x.Vector3,m=new x.Vector3,y=new x.Vector3,g=0,_=new x.Vector3;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",y),o("rotationAngle",g),o("eye",_),this._offset=new x.Vector3,this._startNorm=new x.Vector3,this._endNorm=new x.Vector3,this._cameraScale=new x.Vector3,this._parentPosition=new x.Vector3,this._parentQuaternion=new x.Quaternion,this._parentQuaternionInv=new x.Quaternion,this._parentScale=new x.Vector3,this._worldScaleStart=new x.Vector3,this._worldQuaternionInv=new x.Quaternion,this._worldScale=new x.Vector3,this._positionStart=new x.Vector3,this._quaternionStart=new x.Quaternion,this._scaleStart=new x.Vector3,this._getPointer=hN.bind(this),this._onPointerDown=dN.bind(this),this._onPointerHover=uN.bind(this),this._onPointerMove=pN.bind(this),this._onPointerUp=fN.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._gizmo.picker[this.mode],Qi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._plane,Qi,!0);t&&(this.object.updateMatrixWorld(),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(t.point).sub(this.worldPositionStart)),this.dragging=!0,Wf.mode=this.mode,this.dispatchEvent(Wf)}}pointerMove(e){const t=this.axis,s=this.mode,i=this.object;let n=this.space;if(s==="scale"?n="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(n="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Qi.setFromCamera(e,this.camera);const r=nh(this._plane,Qi,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),n==="local"&&t!=="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&&(n==="local"&&(i.position.applyQuaternion(Ve.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),n==="world"&&(i.parent&&i.position.add(yt.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(yt.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),_i.set(o,o,o)}else yt.copy(this.pointStart),_i.copy(this.pointEnd),yt.applyQuaternion(this._worldQuaternionInv),_i.applyQuaternion(this._worldQuaternionInv),_i.divide(yt),t.search("X")===-1&&(_i.x=1),t.search("Y")===-1&&(_i.y=1),t.search("Z")===-1&&(_i.z=1);i.scale.copy(this._scaleStart).multiply(_i),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.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 o=20/this.worldPosition.distanceTo(yt.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(yt.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Hf[t]),yt.copy(Hf[t]),n==="local"&&yt.applyQuaternion(this.worldQuaternion),yt.cross(this.eye),yt.length()===0?l=!0:this.rotationAngle=this._offset.dot(yt.normalize())*o),(t==="E"||l)&&(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),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),n==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ih),this.dispatchEvent(jf)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&($f.mode=this.mode,this.dispatchEvent($f)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ih),this.dispatchEvent(jf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Qi}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function hN(a){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};{const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-(a.clientY-e.top)/e.height*2+1,button:a.button}}}function uN(a){if(this.enabled)switch(a.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(a));break}}function dN(a){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(a.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(a)),this.pointerDown(this._getPointer(a)))}function pN(a){this.enabled&&this.pointerMove(this._getPointer(a))}function fN(a){this.enabled&&(this.domElement.releasePointerCapture(a.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(a)))}function nh(a,e,t){const s=e.intersectObject(a,!0);for(let i=0;i<s.length;i++)if(s[i].object.visible||t)return s[i];return!1}const To=new x.Euler,Fe=new x.Vector3(0,1,0),qf=new x.Vector3(0,0,0),Yf=new x.Matrix4,So=new x.Quaternion,Io=new x.Quaternion,Rs=new x.Vector3,Xf=new x.Matrix4,sa=new x.Vector3(1,0,0),sn=new x.Vector3(0,1,0),ia=new x.Vector3(0,0,1),vo=new x.Vector3,qr=new x.Vector3,Yr=new x.Vector3;class mN extends x.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class gN extends x.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new x.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new x.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const i=t.clone();i.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new x.CylinderGeometry(0,.04,.1,12);m.translate(0,.05,0);const y=new x.BoxGeometry(.08,.08,.08);y.translate(0,.04,0);const g=new x.BufferGeometry;g.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,0,0],3));const _=new x.CylinderGeometry(.0075,.0075,.5,3);_.translate(0,.25,0);function b(Z,ve){const ue=new x.TorusGeometry(Z,.0075,3,64,ve*Math.PI*2);return ue.rotateY(Math.PI/2),ue.rotateX(Math.PI/2),ue}function T(){const Z=new x.BufferGeometry;return Z.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new x.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new x.Mesh(m,r),[0,.5,0]],[new x.Mesh(m,r),[0,-.5,0],[Math.PI,0,0]],[new x.Mesh(_,r)]],Z:[[new x.Mesh(m,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new x.Mesh(_,o),null,[Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.2,0),s)]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new x.Line(T(),i),null,null,null,"helper"]],X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new x.Mesh(b(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new x.Mesh(b(.5,.5),n)]],Y:[[new x.Mesh(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new x.Mesh(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new x.Mesh(b(.75,1),d),null,[0,Math.PI/2,0]]]},P={AXIS:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},z={XYZE:[[new x.Mesh(new x.SphereGeometry(.25,10,8),s)]],X:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new x.Mesh(new x.TorusGeometry(.75,.1,2,24),s)]]},$={X:[[new x.Mesh(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]],[new x.Mesh(y,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(y,r),[0,.5,0]],[new x.Mesh(_,r)],[new x.Mesh(y,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new x.Mesh(y,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(_,o),[0,0,0],[Math.PI/2,0,0]],[new x.Mesh(y,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.1,.1,.1),u.clone())]]},q={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},j={X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function X(Z){const ve=new x.Object3D;for(const ue in Z)for(let ge=Z[ue].length;ge--;){const ie=Z[ue][ge][0].clone(),we=Z[ue][ge][1],ke=Z[ue][ge][2],rt=Z[ue][ge][3],_e=Z[ue][ge][4];ie.name=ue,ie.tag=_e,we&&ie.position.set(we[0],we[1],we[2]),ke&&ie.rotation.set(ke[0],ke[1],ke[2]),rt&&ie.scale.set(rt[0],rt[1],rt[2]),ie.updateMatrix();const at=ie.geometry.clone();at.applyMatrix4(ie.matrix),ie.geometry=at,ie.renderOrder=1/0,ie.position.set(0,0,0),ie.rotation.set(0,0,0),ie.scale.set(1,1,1),ve.add(ie)}return ve}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=X(S)),this.add(this.gizmo.rotate=X(R)),this.add(this.gizmo.scale=X($)),this.add(this.picker.translate=X(M)),this.add(this.picker.rotate=X(z)),this.add(this.picker.scale=X(q)),this.add(this.helper.translate=X(w)),this.add(this.helper.rotate=X(P)),this.add(this.helper.scale=X(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Io;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 i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(o*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(Ve.setFromEuler(To.set(0,0,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(Ve.setFromEuler(To.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),Fe.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Yf.lookAt(qf,Fe,sn)),r.quaternion.multiply(Ve),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),yt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),yt.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(yt),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(So.copy(s),Fe.copy(this.eye).applyQuaternion(Ve.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Yf.lookAt(this.eye,qf,sn)),r.name==="X"&&(Ve.setFromAxisAngle(sa,Math.atan2(-Fe.y,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Y"&&(Ve.setFromAxisAngle(sn,Math.atan2(Fe.x,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Z"&&(Ve.setFromAxisAngle(ia,Math.atan2(Fe.y,Fe.x)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class yN extends x.Mesh{constructor(){super(new x.PlaneGeometry(1e5,1e5,2,2),new x.MeshBasicMaterial({visible:!1,wireframe:!0,side:x.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),vo.copy(sa).applyQuaternion(t==="local"?this.worldQuaternion:Io),qr.copy(sn).applyQuaternion(t==="local"?this.worldQuaternion:Io),Yr.copy(ia).applyQuaternion(t==="local"?this.worldQuaternion:Io),Fe.copy(qr),this.mode){case"translate":case"scale":switch(this.axis){case"X":Fe.copy(this.eye).cross(vo),Rs.copy(vo).cross(Fe);break;case"Y":Fe.copy(this.eye).cross(qr),Rs.copy(qr).cross(Fe);break;case"Z":Fe.copy(this.eye).cross(Yr),Rs.copy(Yr).cross(Fe);break;case"XY":Rs.copy(Yr);break;case"YZ":Rs.copy(vo);break;case"XZ":Fe.copy(Yr),Rs.copy(qr);break;case"XYZ":case"E":Rs.set(0,0,0);break}break;case"rotate":default:Rs.set(0,0,0)}Rs.length()===0?this.quaternion.copy(this.cameraQuaternion):(Xf.lookAt(yt.set(0,0,0),Rs,Fe),this.quaternion.setFromRotationMatrix(Xf)),super.updateMatrixWorld(e)}}class xt extends x.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;app;three;activeCamera;controls=new Map;visibility=new Map;setApp(e,t){this.app=e,this.three=t,this.app.addEventListener(Q.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();ii(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new cN(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:xt.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:xt.DRAG_END})}),t.addEventListener("dragging-changed",i=>{et.instance?.toggleOrbitControls(i.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),ii(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return xt._instance||(xt._instance=new xt),xt._instance}}const xN=new x.BoxGeometry,rh=new x.Vector2;class Lo extends x.Object3D{curve=new x.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new x.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new x.Color(Ni(.5,1,Math.random()),Ni(.5,1,Math.random()),Ni(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new x.LineBasicMaterial({color:s}),this.line=new x.Line(new x.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new x.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new x.Mesh(new x.SphereGeometry(1.5),new x.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new x.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),xt.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([ss(t.position.x,3),ss(t.position.y,3),ss(t.position.z,3)])}),Kf({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,i=new x.Mesh(xN,this.draggedMat);i.name=`point_${s}`,i.position.copy(e),i.scale.setScalar(this._draggableScale),this.draggable.add(i),this._transform?.attach(i);const n=this.points.length>1;return n&&t&&this.updateSpline(),this.line.visible=n,this.updateCurrentPoint(),i};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new x.Vector3,s=this.addPoint(t);this.group.current?.setField("Current Point",s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}ii(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new x.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new x.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};onMouseClick=e=>{if(!et.instance||!et.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=et.instance.currentWindow.current.getBoundingClientRect();rh.x=(e.clientX-s.x)/s.width*2-1,rh.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(rh,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const n=i[0].object;n!==this._transform?.object&&(this._transform?.attach(n),this.group.current?.setField("Current Point",n.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new x.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=xt.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),t.length>0&&this._transform.attach(t[t.length-1]),et.instance?.helpersContainer.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:!0,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:s}],onUpdate:(i,n)=>{switch(i){case"Closed":this.closed=n,this.updateSpline();break;case"Visible":this.visible=n;break;case"Color":this.lineMaterial.color.setStyle(n),this.draggedMat.color.setStyle(n);break;case"Curve":this.curveType=n,this.updateSpline();break;case"Draggable Scale":this.draggableScale=n;break;case"Subdivide":this.subdivide=n,this.updateSpline();break;case"Tension":this.tension=n,this.updateSpline();break;case"New Pt Offset":this.offset=n;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(n));break;case"Show Position":this.curvePos.visible=n;break;case"Show Points":this.draggable.visible=n;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,ii(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(n),this.updateSpline())}break}}}),this.draggable.children.forEach(i=>{this.debugPoint(i)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let wo=0;class zy extends x.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;app;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.app=t,this.app.addEventListener(Q.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=Re.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.app.removeEventListener(Q.ADD_SPLINE,this.onAddSpline),Re.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${wo+1}`,s=new Lo(t,this._camera);return s.addPoints(e),this.addSpline(s),wo++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new x.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(i=>{t.push(new x.Vector3(i[0],i[1],i[2]))});const s=new Lo(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${wo+1}`,i=[];t.points.forEach(r=>{i.push(new x.Vector3(r[0],r[1],r[2]))});const n=new Lo(s,this.camera);n.addPoints(i),this.addSpline(n),wo++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1;if(et.instance){const o=new x.Raycaster;o.setFromCamera(new x.Vector2(i,n),this._camera);const l=o.intersectObjects(et.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.updateLastPoint(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,i){const n=new x.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,c=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,d=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,p=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,f=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let m=e,y=t;h||d?m*=-1:p&&(y*=-1);const g=s/2/l,_=i/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const b=m*g+o.position.x,T=y*_+o.position.y;n.set(b,T,0)}else if(u||d){const b=m*g+o.position.z,T=y*_+o.position.y;n.set(0,T,b)}else if(p||f){const b=m*g+o.position.x,T=y*_+o.position.z;n.set(b,0,T)}return n}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Zf=["Single","Side by Side","Stacked","Quad"],_N="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",bN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",TN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class et extends W.Component{static instance=null;app;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new x.Group;cameraHelpers=new Map;lightHelpers=new Map;grid=new rN;interactionHelper=new x.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new x.MeshDepthMaterial;normalsMaterial=new x.MeshNormalMaterial;uvMaterial=new lN;wireframeMaterial=new x.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;selectedItem=void 0;debugCamera;raycaster=new x.Raycaster;pointer=new x.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.app=e.app,this.app.addEventListener(Q.ADD_RENDERER,this.setupRenderer),this.scene=new x.Scene,this.scene.name=this.scene.uuid="Debug Scene",this.canvasRef=W.createRef(),this.containerRef=W.createRef(),this.tlWindow=W.createRef(),this.trWindow=W.createRef(),this.blWindow=W.createRef(),this.brWindow=W.createRef();const t=e.three.app.appID,s=localStorage,i=s.getItem(`${t}_mode`);this.state={mode:i!==null?i:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const n={Vector2:x.Vector2,Vector3:x.Vector3,Vector4:x.Vector4,Quaternion:x.Quaternion,Matrix4:x.Matrix4,Spherical:x.Spherical,Box3:x.Box3,Sphere:x.Sphere,Raycaster:x.Raycaster};Ds.install({THREE:n}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid.visible=this.gridVisibility,this.saveExpandedGridVisibility(),et.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),xt.instance.setApp(this.props.app,this.props.three),xt.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),Re.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),C.jsxs("div",{className:"multiview",children:[C.jsx("canvas",{ref:this.canvasRef}),C.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&C.jsx(C.Fragment,{children:C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),C.jsx(Zi,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),C.jsx(Zi,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),C.jsxs("div",{className:"settings",children:[C.jsx(al,{title:"View",index:Zf.indexOf(this.state.mode),options:Zf,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),C.jsx(al,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),C.jsx(sh,{name:"cameraHelper",icon:_N,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"lightHelper",icon:bN,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"gridHelper",icon:TN,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.gridVisibility=t,this.saveExpandedGridVisibility(),this.grid.visible=t}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose();const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new x.WebGLRenderer({canvas:t,stencil:!1}),this.grid.visible=!0):s.type==="WebGPURenderer"&&(this.renderer=new mo({canvas:t,stencil:!1}),this.grid.visible=!1),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.resize(),this.props.three.renderer=this.renderer)};setupScene(){this.scene.name="Debug Scene",this.scene.uuid="Debug Scene",this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.grid.position.y=-1,this.scene.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(n,r)=>{const o=new x.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=n,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(n,o),o},t=1e3;e("Top",new x.Vector3(0,t,0)),e("Bottom",new x.Vector3(0,-t,0)),e("Left",new x.Vector3(-t,0,0)),e("Right",new x.Vector3(t,0,0)),e("Front",new x.Vector3(0,0,t)),e("Back",new x.Vector3(0,0,-t)),e("Orthographic",new x.Vector3(t,t,t)),e("UI",new x.Vector3),this.debugCamera=new x.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(s.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){this.splineEditor=new zy(this.currentCamera,this.app),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.app.addEventListener(Q.ADD_SCENE,this.addScene),this.app.addEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.addEventListener(Q.ADD_CAMERA,this.addCamera),this.app.addEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.addEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.app.removeEventListener(Q.ADD_SCENE,this.addScene),this.app.removeEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.removeEventListener(Q.ADD_CAMERA,this.addCamera),this.app.removeEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.removeEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,i=this.height;switch(this.state.mode){case"Side by Side":s=e,i=this.height;break;case"Stacked":s=this.width,i=t;break;case"Quad":s=e,i=t;break}const n=s/i;this.cameras.forEach(r=>{r instanceof x.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=i/2,r.bottom=i/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof x.PerspectiveCamera&&(r.aspect=n,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;s.visible=!1,this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))};addCamera=e=>{const t=e.value,s=`${this.props.three.scene?.name}_${t.name}`,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0){const n=i;this.cameras.set(s,n);const r=new x.CameraHelper(n);r.visible=this.cameraVisibility,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new x.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),i=Math.min(e.clientY,t.y);this.pointer.x=Ki(s,0,t.x,-1,1),this.pointer.y=Ki(i,0,t.y,1,-1);const n=t.x/2,r=t.y/2,o=()=>{s<n?this.pointer.x=Ki(s,0,n,-1,1):this.pointer.x=Ki(s,n,t.x,-1,1)},l=()=>{i<r?this.pointer.y=Ki(i,0,r,1,-1):this.pointer.y=Ki(i,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,i,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new x.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof x.Mesh||this.selectedItem instanceof x.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(zo(45),zo(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem!==void 0&&(this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),xt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=xt.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0))};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Al.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new x.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new x.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new UR(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new x.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new x.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const i=new zR(e,t);switch(i.enableDamping=!0,i.dampingFactor=.2,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(e.name,i)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,i)=>{switch(this.state.mode){case"Quad":t<i?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),xt.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,i=new x.Clock;i.start(),this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=i.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=rr(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,i,n,r){switch(n.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setViewport(e,t,s,i),this.renderer?.setScissor(e,t,s,i),this.renderer instanceof x.WebGLRenderer?this.renderer?.render(this.scene,n):this.renderer instanceof mo&&this.renderer?.renderAsync(this.scene,n)),this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),i=Math.floor(this.height/2);if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const n=this.height-i;this.drawTo(0,n,this.width,i,this.tlCam,e),this.drawTo(0,0,this.width,i,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),i=this.getSceneOverride(this.brRender),n=Math.floor(this.width/2),r=Math.floor(this.height/2);let o=0,l=0;l=this.height-r,o=0,this.drawTo(o,l,n,r,this.tlCam,e),o=n,this.drawTo(o,l,n,r,this.trCam,t),l=0,o=0,this.scene.overrideMaterial=s,this.drawTo(o,l,n,r,this.blCam,s),o=n,this.drawTo(o,l,n,r,this.brCam,i)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class Al extends W.Component{static instance;app;matrix=new x.Matrix4;position=new x.Vector3;rotation=new x.Euler;scale=new x.Vector3;open=!1;constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Al.instance=this}update(){if(et.instance){const e=et.instance.selectedItem;if(e===void 0)return;this.position.x=ss(e.position.x,3),this.position.y=ss(e.position.y,3),this.position.z=ss(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=ss(e.scale.x,3),this.scale.y=ss(e.scale.y,3),this.scale.z=ss(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return C.jsx(cs,{app:this.app,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const i=this.props.three.getScene(this.props.object.uuid);if(i){const n=i.getObjectByProperty("uuid",this.props.object.uuid);qe(n,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function Qf(a){switch(a){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return a}function SN(a,e,t){function s(){return`${t.app.appID}_light`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=[];if(a.lightInfo!==void 0)for(const l in a.lightInfo){const c=a.lightInfo[l];c!==void 0&&(c.isColor!==void 0?o.push({title:Qf(l),prop:l,type:"color",value:c,onChange:(h,u)=>{const d=new x.Color(u);t.updateObject(a.uuid,h,d);const p=t.getScene(a.uuid);if(p!==null){const f=p.getObjectByProperty("uuid",a.uuid);qe(f,h,d)}}}):o.push({title:Qf(l),prop:l,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(h,u)=>{t.updateObject(a.uuid,h,u);const d=t.getScene(a.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",a.uuid);qe(p,h,u)}}}))}return C.jsx(cs,{app:e,title:"Light",items:o,expanded:n,onToggle:l=>{r(l)}})}function vN(a){const e=a.object,t=a.three;function s(){return`${t.app.appID}_animation`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(d){localStorage.setItem(s(),d?"open":"closed")}const o=[],l=[];let c=0;e.animations.forEach(d=>{c=Math.max(c,d.duration),d.duration>0&&l.push({title:d.name,items:[{title:"Duration",type:"number",value:d.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",e.uuid);if(d!==void 0){const p=d.mixer;if(p!==void 0){const m=[{title:"Time Scale",type:"range",value:p.timeScale,step:.01,min:-1,max:2,onChange:(y,g)=>{p.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];m.push({title:"Stop All",type:"button",onChange:()=>{p.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:m}),h=new x.SkeletonHelper(d),et.instance?.scene.add(h)}}}return W.useEffect(()=>()=>{h!==void 0&&ii(h)},[]),C.jsx(cs,{app:a.app,title:"Animation",items:o,expanded:n,onToggle:d=>{r(d)}})}const $h={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let ft={...$h};function Gy(a){const[e,t]=W.useState(-1);W.useEffect(()=>{function r(l){ft={...l.value},t(Date.now())}function o(){ft={...$h},t(Date.now())}return a.app.addEventListener(Q.SET_SCENE,o),a.app.addEventListener(Q.SET_OBJECT,r),()=>{a.app.removeEventListener(Q.SET_SCENE,o),a.app.removeEventListener(Q.SET_OBJECT,r)}},[]);const s=ft.type.toLowerCase(),i=ft.animations.length>0||ft.mixer!==void 0,n=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return C.jsx(fa,{app:a.app,label:"Inspector",button:ft.uuid.length>0?C.jsx("button",{className:"remove",onClick:()=>{xt.instance.remove(ft.name),ft={...$h},t(Date.now())}}):void 0,children:C.jsx("div",{id:"Inspector",className:a.class,children:ft.uuid.length>0&&C.jsxs(C.Fragment,{children:[C.jsxs(C.Fragment,{children:[C.jsx(Eo,{type:"string",title:"Name",prop:"name",value:ft.name,disabled:!0}),C.jsx(Eo,{type:"string",title:"Type",prop:"type",value:ft.type,disabled:!0}),C.jsx(Eo,{type:"string",title:"UUID",prop:"uuid",value:ft.uuid,disabled:!0})]}),C.jsxs(C.Fragment,{children:[C.jsx(Al,{object:ft,app:a.app,three:a.three}),i?C.jsx(vN,{app:a.app,object:ft,three:a.three}):null,s.search("camera")>-1?$x(ft,a.app,a.three):null,s.search("light")>-1?SN(ft,a.app,a.three):null,n?Vx(ft,a.app,a.three):null]})]})},e)},"Inspector")}class wN extends W.Component{app;autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=x.SRGBColorSpace;localClippingEnabled=!1;clearColor=new x.Color(0);clearAlpha=1;toneMapping=x.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),et.instance){const i=et.instance.renderer;i&&(this.autoClear=i.autoClear,this.autoClearColor=i.autoClearColor,this.autoClearDepth=i.autoClearDepth,this.autoClearStencil=i.autoClearStencil,this.clearAlpha=i.getClearAlpha(),this.toneMapping=i.toneMapping,this.toneMappingExposure=i.toneMappingExposure,i instanceof x.WebGLRenderer&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.app.addEventListener(Q.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.app.removeEventListener(Q.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,x.LinearSRGBColorSpace),x.ColorManagement.enabled=t.colorManagement,et.instance){const s=et.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s.localClippingEnabled=this.localClippingEnabled,s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(et.instance){const t=et.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:x.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return C.jsx(cs,{app:this.app,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Clear Management",value:x.ColorManagement.enabled,onChange:(t,s)=>{x.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:x.NoColorSpace},{title:"SRB Color Space",value:x.SRGBColorSpace},{title:"Linear SRB Color Space",value:x.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:x.NoToneMapping},{title:"Linear ",value:x.LinearToneMapping},{title:"Reinhard",value:x.ReinhardToneMapping},{title:"Cineon ",value:x.CineonToneMapping},{title:"ACES Filmic",value:x.ACESFilmicToneMapping},{title:"AgX",value:x.AgXToneMapping},{title:"Neutral",value:x.NeutralToneMapping},{title:"Custom",value:x.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Vy(a){const[e]=W.useState([]),[t]=W.useState([]),[s,i]=W.useState(0),n=l=>{const c=l.value;e.push(c),t.push(C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random())),i(Date.now())},r=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e[h]=c,t[h]=C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random()),i(Date.now());return}},o=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e.splice(h,1),t.splice(h,1),i(Date.now());return}};return W.useEffect(()=>(a.app.addEventListener(Q.ADD_SCENE,n),a.app.addEventListener(Q.REFRESH_SCENE,r),a.app.addEventListener(Q.REMOVE_SCENE,o),()=>{a.app.removeEventListener(Q.ADD_SCENE,n),a.app.removeEventListener(Q.REFRESH_SCENE,r),a.app.removeEventListener(Q.REMOVE_SCENE,o)}),[]),C.jsxs("div",{id:"SidePanel",children:[C.jsx("div",{className:"scenes",children:t},s),C.jsx(Gy,{app:a.app,three:a.three}),C.jsx(wN,{app:a.app,three:a.three}),C.jsx(Re,{app:a.app,three:a.three})]})}function EN(a){return W.useEffect(()=>{function e(o){let l=null;return a.three.scenes.forEach(c=>{o.search(c.uuid)>-1&&(l=c)}),l}const t=o=>{const l=o.value,c=e(l);if(!c){console.log(`Hermes - can't find scene for object: ${l}`,a.three.scenes);return}const h=c.getObjectByProperty("uuid",l);h!==void 0?a.three.setObject(h):console.log(`Hermes - can't find object: ${l}`,c)},s=(o,l,c)=>{const h=e(o);if(!h){console.log(`Hermes - can't find scene to set object: ${o}, ${l}`,a.three.scenes);return}const u=h?.getObjectByProperty("uuid",o);u!==void 0?qe(u,l,c):console.log(`Hermes - can't set object: ${o}`,h)},i=o=>{const l=o.value,{key:c,value:h,uuid:u}=l;s(u,c,h)},n=o=>{const l=o.value,c=e(l.uuid);if(!c){console.log(`Hermes - can't create texture, can't find scene: ${l.uuid}`);return}const h=c?.getObjectByProperty("uuid",l.uuid);if(h!==void 0){const u=d=>{const p=l.key.split(".");switch(p.length){case 1:h[p[0]]=d;break;case 2:h[p[0]][p[1]]=d;break;case 3:h[p[0]][p[1]][p[2]]=d;break;case 4:h[p[0]][p[1]][p[2]][p[3]]=d;break;case 5:h[p[0]][p[1]][p[2]][p[3]][p[4]]=d;break}h.material.needsUpdate=!0};l.value.src.length>0?rm(l.value.src).then(d=>{d.offset.set(l.value.offset[0],l.value.offset[1]),d.repeat.set(l.value.repeat[0],l.value.repeat[1]),u(d)}):u(null)}},r=o=>{const{key:l,uuid:c,value:h,subitem:u}=o.value,p=e(c)?.getObjectByProperty("uuid",c);if(p!==void 0)try{u!==void 0?nx(p,u)[l](h):p[l](h)}catch(f){console.log("Error requesting method:"),console.log(f),console.log(l),console.log(h)}};return a.app.addEventListener(Q.GET_OBJECT,t),a.app.addEventListener(Q.UPDATE_OBJECT,i),a.app.addEventListener(Q.CREATE_TEXTURE,n),a.app.addEventListener(Q.REQUEST_METHOD,r),()=>{a.app.removeEventListener(Q.GET_OBJECT,t),a.app.removeEventListener(Q.UPDATE_OBJECT,i),a.app.removeEventListener(Q.CREATE_TEXTURE,n),a.app.removeEventListener(Q.REQUEST_METHOD,r)}},[]),null}function Hy(a){return C.jsxs("div",{className:"editor",ref:a.ref,style:a.style,children:[C.jsx("div",{className:"header",children:a.header}),a.children,C.jsx("div",{className:"footer",children:a.footer})]})}function MN(a){return C.jsx(Hy,{children:C.jsxs(C.Fragment,{children:[C.jsx(et,{app:a.app,three:a.three,scenes:a.scenes,onSceneResize:a.onSceneResize,onSceneSet:a.onSceneSet,onSceneUpdate:a.onSceneUpdate}),C.jsx(Vy,{app:a.app,three:a.three})]})})}exports.Accordion=fa;exports.AppRunner=q0;exports.Application=j0;exports.BaseRemote=ol;exports.BaseScene=Y0;exports.ChildObject=Zh;exports.ContainerObject=hh;exports.Draggable=om;exports.DraggableItem=am;exports.Dropdown=lm;exports.DropdownItem=cm;exports.Editor=Hy;exports.ElementProxy=W0;exports.ElementProxyReceiver=nm;exports.ExportTexture=Ri;exports.Inspector=Gy;exports.MultiView=et;exports.NavButton=Xh;exports.ProxyManager=$0;exports.QualityType=jh;exports.RemoteComponents=X0;exports.RemoteTheatre=ex;exports.RemoteThree=ax;exports.SceneInspector=EN;exports.SidePanel=Vy;exports.Spline=Lo;exports.SplineEditor=zy;exports.ThreeEditor=MN;exports.ToolEvents=Q;exports.Transform=xt;exports.WebworkerEventHandlers=V0;exports.capitalize=pa;exports.clamp=Ti;exports.clearComposerGroups=F0;exports.colorToHex=ah;exports.copyToClipboard=Kf;exports.cubicBezier=N0;exports.customizeTheatreElements=Q0;exports.damp=w0;exports.defaultTheatreCallback=g0;exports.detectMaxFrameRate=sm;exports.detectSettings=im;exports.dispose=ii;exports.disposeMaterial=qh;exports.disposeTexture=oh;exports.distance=v0;exports.generateCubemap=O0;exports.hierarchyUUID=ko;exports.inspectComposer=D0;exports.isColor=em;exports.map=S0;exports.mix=rr;exports.noop=da;exports.normalize=Uo;exports.parseModelLite=P0;exports.randomID=Jf;exports.resetThreeObjects=lh;exports.round=ss;exports.roundTo=E0;exports.theatreEditorApp=Z0;
|
|
600
|
+
}`;class lN extends x.ShaderMaterial{constructor(){super({defines:{USE_UV:""},vertexShader:aN,fragmentShader:oN})}}const Qi=new x.Raycaster,yt=new x.Vector3,_i=new x.Vector3,Ve=new x.Quaternion,Hf={X:new x.Vector3(1,0,0),Y:new x.Vector3(0,1,0),Z:new x.Vector3(0,0,1)},ih={type:"change"},Wf={type:"mouseDown",mode:null},$f={type:"mouseUp",mode:null},jf={type:"objectChange"};class cN extends x.Controls{constructor(e,t=null){super(void 0,t);const s=new mN(this);this._root=s;const i=new gN;this._gizmo=i,s.add(i);const n=new yN;this._plane=n,s.add(n);const r=this;function o(b,T){let S=T;Object.defineProperty(r,b,{get:function(){return S!==void 0?S:T},set:function(M){S!==M&&(S=M,n[b]=M,i[b]=M,r.dispatchEvent({type:b+"-changed",value:M}),r.dispatchEvent(ih))}}),r[b]=T,n[b]=T,i[b]=T}o("camera",e),o("object",void 0),o("enabled",!0),o("axis",null),o("mode","translate"),o("translationSnap",null),o("rotationSnap",null),o("scaleSnap",null),o("space","world"),o("size",1),o("dragging",!1),o("showX",!0),o("showY",!0),o("showZ",!0),o("minX",-1/0),o("maxX",1/0),o("minY",-1/0),o("maxY",1/0),o("minZ",-1/0),o("maxZ",1/0);const l=new x.Vector3,c=new x.Vector3,h=new x.Quaternion,u=new x.Quaternion,d=new x.Vector3,p=new x.Quaternion,f=new x.Vector3,m=new x.Vector3,y=new x.Vector3,g=0,_=new x.Vector3;o("worldPosition",l),o("worldPositionStart",c),o("worldQuaternion",h),o("worldQuaternionStart",u),o("cameraPosition",d),o("cameraQuaternion",p),o("pointStart",f),o("pointEnd",m),o("rotationAxis",y),o("rotationAngle",g),o("eye",_),this._offset=new x.Vector3,this._startNorm=new x.Vector3,this._endNorm=new x.Vector3,this._cameraScale=new x.Vector3,this._parentPosition=new x.Vector3,this._parentQuaternion=new x.Quaternion,this._parentQuaternionInv=new x.Quaternion,this._parentScale=new x.Vector3,this._worldScaleStart=new x.Vector3,this._worldQuaternionInv=new x.Quaternion,this._worldScale=new x.Vector3,this._positionStart=new x.Vector3,this._quaternionStart=new x.Quaternion,this._scaleStart=new x.Vector3,this._getPointer=hN.bind(this),this._onPointerDown=dN.bind(this),this._onPointerHover=uN.bind(this),this._onPointerMove=pN.bind(this),this._onPointerUp=fN.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._gizmo.picker[this.mode],Qi);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&Qi.setFromCamera(e,this.camera);const t=nh(this._plane,Qi,!0);t&&(this.object.updateMatrixWorld(),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(t.point).sub(this.worldPositionStart)),this.dragging=!0,Wf.mode=this.mode,this.dispatchEvent(Wf)}}pointerMove(e){const t=this.axis,s=this.mode,i=this.object;let n=this.space;if(s==="scale"?n="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(n="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&Qi.setFromCamera(e,this.camera);const r=nh(this._plane,Qi,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),n==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),n==="local"&&t!=="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&&(n==="local"&&(i.position.applyQuaternion(Ve.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),n==="world"&&(i.parent&&i.position.add(yt.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(yt.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(s==="scale"){if(t.search("XYZ")!==-1){let o=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(o*=-1),_i.set(o,o,o)}else yt.copy(this.pointStart),_i.copy(this.pointEnd),yt.applyQuaternion(this._worldQuaternionInv),_i.applyQuaternion(this._worldQuaternionInv),_i.divide(yt),t.search("X")===-1&&(_i.x=1),t.search("Y")===-1&&(_i.y=1),t.search("Z")===-1&&(_i.z=1);i.scale.copy(this._scaleStart).multiply(_i),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.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 o=20/this.worldPosition.distanceTo(yt.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(yt.copy(this.rotationAxis).cross(this.eye))*o):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(Hf[t]),yt.copy(Hf[t]),n==="local"&&yt.applyQuaternion(this.worldQuaternion),yt.cross(this.eye),yt.length()===0?l=!0:this.rotationAngle=this._offset.dot(yt.normalize())*o),(t==="E"||l)&&(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),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),n==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(Ve.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(ih),this.dispatchEvent(jf)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&($f.mode=this.mode,this.dispatchEvent($f)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(ih),this.dispatchEvent(jf),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Qi}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function hN(a){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};{const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-(a.clientY-e.top)/e.height*2+1,button:a.button}}}function uN(a){if(this.enabled)switch(a.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(a));break}}function dN(a){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(a.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(a)),this.pointerDown(this._getPointer(a)))}function pN(a){this.enabled&&this.pointerMove(this._getPointer(a))}function fN(a){this.enabled&&(this.domElement.releasePointerCapture(a.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(a)))}function nh(a,e,t){const s=e.intersectObject(a,!0);for(let i=0;i<s.length;i++)if(s[i].object.visible||t)return s[i];return!1}const To=new x.Euler,Fe=new x.Vector3(0,1,0),qf=new x.Vector3(0,0,0),Yf=new x.Matrix4,So=new x.Quaternion,Io=new x.Quaternion,Rs=new x.Vector3,Xf=new x.Matrix4,sa=new x.Vector3(1,0,0),sn=new x.Vector3(0,1,0),ia=new x.Vector3(0,0,1),vo=new x.Vector3,qr=new x.Vector3,Yr=new x.Vector3;class mN extends x.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class gN extends x.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new x.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new x.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),s=e.clone();s.opacity=.15;const i=t.clone();i.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const o=e.clone();o.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25,e.clone().color.setHex(16776960);const f=e.clone();f.color.setHex(7895160);const m=new x.CylinderGeometry(0,.04,.1,12);m.translate(0,.05,0);const y=new x.BoxGeometry(.08,.08,.08);y.translate(0,.04,0);const g=new x.BufferGeometry;g.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,0,0],3));const _=new x.CylinderGeometry(.0075,.0075,.5,3);_.translate(0,.25,0);function b(Z,ve){const ue=new x.TorusGeometry(Z,.0075,3,64,ve*Math.PI*2);return ue.rotateY(Math.PI/2),ue.rotateX(Math.PI/2),ue}function T(){const Z=new x.BufferGeometry;return Z.setAttribute("position",new x.Float32BufferAttribute([0,0,0,1,1,1],3)),Z}const S={X:[[new x.Mesh(m,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(m,n),[-.5,0,0],[0,0,Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new x.Mesh(m,r),[0,.5,0]],[new x.Mesh(m,r),[0,-.5,0],[Math.PI,0,0]],[new x.Mesh(_,r)]],Z:[[new x.Mesh(m,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(m,o),[0,0,-.5],[-Math.PI/2,0,0]],[new x.Mesh(_,o),null,[Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.1,0),u.clone()),[0,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h.clone()),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.OctahedronGeometry(.2,0),s)]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]]},w={START:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new x.Mesh(new x.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new x.Line(T(),i),null,null,null,"helper"]],X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={XYZE:[[new x.Mesh(b(.5,1),f),null,[0,Math.PI/2,0]]],X:[[new x.Mesh(b(.5,.5),n)]],Y:[[new x.Mesh(b(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new x.Mesh(b(.5,.5),o),null,[0,Math.PI/2,0]]],E:[[new x.Mesh(b(.75,1),d),null,[0,Math.PI/2,0]]]},P={AXIS:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},z={XYZE:[[new x.Mesh(new x.SphereGeometry(.25,10,8),s)]],X:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[Math.PI/2,0,0]]],Z:[[new x.Mesh(new x.TorusGeometry(.5,.1,4,24),s),[0,0,0],[0,0,-Math.PI/2]]],E:[[new x.Mesh(new x.TorusGeometry(.75,.1,2,24),s)]]},$={X:[[new x.Mesh(y,n),[.5,0,0],[0,0,-Math.PI/2]],[new x.Mesh(_,n),[0,0,0],[0,0,-Math.PI/2]],[new x.Mesh(y,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(y,r),[0,.5,0]],[new x.Mesh(_,r)],[new x.Mesh(y,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new x.Mesh(y,o),[0,0,.5],[Math.PI/2,0,0]],[new x.Mesh(_,o),[0,0,0],[Math.PI/2,0,0]],[new x.Mesh(y,o),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.1,.1,.1),u.clone())]]},q={X:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[.3,0,0],[0,0,-Math.PI/2]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,.3,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,-.3,0],[0,0,Math.PI]]],Z:[[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,.3],[Math.PI/2,0,0]],[new x.Mesh(new x.CylinderGeometry(.2,0,.6,4),s),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,.15,0]]],YZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.01),s),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new x.Mesh(new x.BoxGeometry(.2,.2,.2),s),[0,0,0]]]},j={X:[[new x.Line(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new x.Line(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new x.Line(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function X(Z){const ve=new x.Object3D;for(const ue in Z)for(let ge=Z[ue].length;ge--;){const ie=Z[ue][ge][0].clone(),we=Z[ue][ge][1],ke=Z[ue][ge][2],rt=Z[ue][ge][3],_e=Z[ue][ge][4];ie.name=ue,ie.tag=_e,we&&ie.position.set(we[0],we[1],we[2]),ke&&ie.rotation.set(ke[0],ke[1],ke[2]),rt&&ie.scale.set(rt[0],rt[1],rt[2]),ie.updateMatrix();const at=ie.geometry.clone();at.applyMatrix4(ie.matrix),ie.geometry=at,ie.renderOrder=1/0,ie.position.set(0,0,0),ie.rotation.set(0,0,0),ie.scale.set(1,1,1),ve.add(ie)}return ve}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=X(S)),this.add(this.gizmo.rotate=X(R)),this.add(this.gizmo.scale=X($)),this.add(this.picker.translate=X(M)),this.add(this.picker.rotate=X(z)),this.add(this.picker.scale=X(q)),this.add(this.helper.translate=X(w)),this.add(this.helper.rotate=X(P)),this.add(this.helper.scale=X(j)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const s=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:Io;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 i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let n=0;n<i.length;n++){const r=i[n];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let o;if(this.camera.isOrthographicCamera?o=(this.camera.top-this.camera.bottom)/this.camera.zoom:o=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(o*this.size/4),r.tag==="helper"){r.visible=!1,r.name==="AXIS"?(r.visible=!!this.axis,this.axis==="X"&&(Ve.setFromEuler(To.set(0,0,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Y"&&(Ve.setFromEuler(To.set(0,0,Math.PI/2)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="Z"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),r.quaternion.copy(s).multiply(Ve),Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.9&&(r.visible=!1)),this.axis==="XYZE"&&(Ve.setFromEuler(To.set(0,Math.PI/2,0)),Fe.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Yf.lookAt(qf,Fe,sn)),r.quaternion.multiply(Ve),r.visible=this.dragging),this.axis==="E"&&(r.visible=!1)):r.name==="START"?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name==="END"?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name==="DELTA"?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),yt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),yt.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(yt),r.visible=this.dragging):(r.quaternion.copy(s),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(s),this.mode==="translate"||this.mode==="scale"?(r.name==="X"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Y"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="Z"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XY"&&Math.abs(Fe.copy(ia).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="YZ"&&Math.abs(Fe.copy(sa).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name==="XZ"&&Math.abs(Fe.copy(sn).applyQuaternion(s).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):this.mode==="rotate"&&(So.copy(s),Fe.copy(this.eye).applyQuaternion(Ve.copy(s).invert()),r.name.search("E")!==-1&&r.quaternion.setFromRotationMatrix(Yf.lookAt(this.eye,qf,sn)),r.name==="X"&&(Ve.setFromAxisAngle(sa,Math.atan2(-Fe.y,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Y"&&(Ve.setFromAxisAngle(sn,Math.atan2(Fe.x,Fe.z)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve)),r.name==="Z"&&(Ve.setFromAxisAngle(ia,Math.atan2(Fe.y,Fe.x)),Ve.multiplyQuaternions(So,Ve),r.quaternion.copy(Ve))),r.visible=r.visible&&(r.name.indexOf("X")===-1||this.showX),r.visible=r.visible&&(r.name.indexOf("Y")===-1||this.showY),r.visible=r.visible&&(r.name.indexOf("Z")===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}}class yN extends x.Mesh{constructor(){super(new x.PlaneGeometry(1e5,1e5,2,2),new x.MeshBasicMaterial({visible:!1,wireframe:!0,side:x.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),vo.copy(sa).applyQuaternion(t==="local"?this.worldQuaternion:Io),qr.copy(sn).applyQuaternion(t==="local"?this.worldQuaternion:Io),Yr.copy(ia).applyQuaternion(t==="local"?this.worldQuaternion:Io),Fe.copy(qr),this.mode){case"translate":case"scale":switch(this.axis){case"X":Fe.copy(this.eye).cross(vo),Rs.copy(vo).cross(Fe);break;case"Y":Fe.copy(this.eye).cross(qr),Rs.copy(qr).cross(Fe);break;case"Z":Fe.copy(this.eye).cross(Yr),Rs.copy(Yr).cross(Fe);break;case"XY":Rs.copy(Yr);break;case"YZ":Rs.copy(vo);break;case"XZ":Fe.copy(Yr),Rs.copy(qr);break;case"XYZ":case"E":Rs.set(0,0,0);break}break;case"rotate":default:Rs.set(0,0,0)}Rs.length()===0?this.quaternion.copy(this.cameraQuaternion):(Xf.lookAt(yt.set(0,0,0),Rs,Fe),this.quaternion.setFromRotationMatrix(Xf)),super.updateMatrixWorld(e)}}class xt extends x.EventDispatcher{static DRAG_START="Transform::dragStart";static DRAG_END="Transform::dragEnd";static _instance;app;three;activeCamera;controls=new Map;visibility=new Map;setApp(e,t){this.app=e,this.three=t,this.app.addEventListener(Q.SET_SCENE,this.setScene)}clear(){for(const e of this.controls.values()){e.detach(),e.disconnect();const t=e.getHelper();ii(t)}this.controls=new Map,this.visibility=new Map}add(e){let t=this.controls.get(e);if(t===void 0){const s=document.querySelector(".clickable");t=new cN(this.activeCamera,s),t.getHelper().name=e,t.setSize(.5),t.setSpace("local"),this.controls.set(e,t),this.visibility.set(e,!0),t.addEventListener("mouseDown",()=>{this.dispatchEvent({type:xt.DRAG_START})}),t.addEventListener("mouseUp",()=>{this.dispatchEvent({type:xt.DRAG_END})}),t.addEventListener("dragging-changed",i=>{et.instance?.toggleOrbitControls(i.value)})}return t}get(e){return this.controls.get(e)}remove(e){const t=this.get(e);return t===void 0?!1:(t.detach(),t.disconnect(),ii(t.getHelper()),this.controls.delete(e),!0)}enabled(e){this.controls.forEach(t=>{t.enabled=e})}updateCamera(e,t){this.activeCamera=e,this.controls.forEach(s=>{s.camera!==e&&(s.camera=e,e.getWorldPosition(s.cameraPosition),e.getWorldQuaternion(s.cameraQuaternion)),s.domElement!==t&&(s.disconnect(),s.domElement=t,s.connect(t))})}show(){this.controls.forEach(e=>{const t=e.getHelper(),s=this.visibility.get(t.name);s!==void 0&&(t.visible=s)})}hide(){this.controls.forEach(e=>{const t=e.getHelper();this.visibility.set(t.name,t.visible),t.visible=!1})}setScene=()=>{this.clear()};static get instance(){return xt._instance||(xt._instance=new xt),xt._instance}}const xN=new x.BoxGeometry,rh=new x.Vector2;class Lo extends x.Object3D{curve=new x.CatmullRomCurve3;line;draggable;curvePos;tension=.5;closed=!1;subdivide=50;curveType;offset=1;lineMaterial;_camera;_curvePercentage=0;_draggableScale=10;_transform;raycaster;draggedMat=new x.MeshBasicMaterial;parentGroup;group;constructor(e,t){const s=new x.Color(Ni(.5,1,Math.random()),Ni(.5,1,Math.random()),Ni(.5,1,Math.random()));super(),this.name=e,this.lineMaterial=new x.LineBasicMaterial({color:s}),this.line=new x.Line(new x.BufferGeometry,this.lineMaterial),this.line.name="line",this.line.visible=!1,this.add(this.line),this._camera=t,this.curveType="catmullrom",this.draggedMat.color=s,this.draggable=new x.Object3D,this.draggable.name="draggablePoints",this.add(this.draggable),this.curvePos=new x.Mesh(new x.SphereGeometry(1.5),new x.MeshBasicMaterial({color:s})),this.curvePos.name="curvePos",this.curvePos.scale.setScalar(this._draggableScale),this.curvePos.visible=!1,this.add(this.curvePos),this.raycaster=new x.Raycaster,this.raycaster.params.Line.threshold=3,this.enable()}enable(){document.addEventListener("pointerdown",this.onMouseClick)}disable(){document.removeEventListener("pointerdown",this.onMouseClick)}dispose=()=>{this._transform&&(this._transform.removeEventListener("objectChange",this.updateSpline),xt.instance.remove(this.name)),this.disable(),this.parentGroup.removeGroup(this.name)};hideTransform=()=>{this._transform?.detach()};exportSpline=()=>{const e=[];this.draggable.children.forEach(t=>{e.push([ss(t.position.x,3),ss(t.position.y,3),ss(t.position.z,3)])}),Kf({name:this.name,points:e,tension:this.tension,closed:this.closed,subdivide:this.subdivide,type:this.curveType}),console.log("Spline copied!")};showPoints=(e=!0)=>{this.draggable.visible=e};addPoints=(e=[])=>{if(e.length>0){const t=e.length-1;for(let s=0;s<t;s++)this.addPoint(e[s],!1);this.addPoint(e[t])}};addPoint=(e,t=!0)=>{const s=this.draggable.children.length,i=new x.Mesh(xN,this.draggedMat);i.name=`point_${s}`,i.position.copy(e),i.scale.setScalar(this._draggableScale),this.draggable.add(i),this._transform?.attach(i);const n=this.points.length>1;return n&&t&&this.updateSpline(),this.line.visible=n,this.updateCurrentPoint(),i};addNextPt=()=>{const e=this.draggable.children.length,t=e>1?this.draggable.children[e-1].position.clone():new x.Vector3,s=this.addPoint(t);this.group.current?.setField("Current Point",s.position)};removePoint=e=>{if(this._transform?.object===e){this._transform?.detach();const t=this.draggable.children[this.draggable.children.length-1];this._transform?.attach(t),this.group.current?.setField("Current Point",t.position)}ii(e),this.updateSpline()};removePointAt=e=>{const t=this.draggable.children[e];this.removePoint(t)};removeSelectedPt=()=>{this._transform?.object!==void 0&&this.removePoint(this._transform?.object)};updateLastPoint(e){const t=this.draggable.children.length;t>0&&(this.draggable.children[t-1].position.copy(e),this.updateSpline())}updateSpline=()=>{this.points.length<2||(this.curve=new x.CatmullRomCurve3(this.points,this.closed,this.curveType,this.tension),this.line.geometry.dispose(),this.line.geometry=new x.BufferGeometry().setFromPoints(this.curve.getPoints(this.subdivide)),this.curvePos.position.copy(this.getPointAt(this._curvePercentage)))};onMouseClick=e=>{if(!et.instance||!et.instance.currentWindow||this._transform&&!this._transform.getHelper().visible)return;const s=et.instance.currentWindow.current.getBoundingClientRect();rh.x=(e.clientX-s.x)/s.width*2-1,rh.y=-((e.clientY-s.y)/s.height)*2+1,this.raycaster.setFromCamera(rh,this.camera);const i=this.raycaster.intersectObjects(this.draggable.children,!1);if(i.length>0){const n=i[0].object;n!==this._transform?.object&&(this._transform?.attach(n),this.group.current?.setField("Current Point",n.position))}};getPointAt(e){return this.curve.points.length>1?this.curve.getPointAt(e):this.curve.points.length===1?this.curve.points[0]:new x.Vector3}getTangentAt(e){return this.curve.getTangentAt(e)}get points(){const e=[];return this.draggable.children.forEach(t=>{e.push(t.position)}),e}get total(){return this.draggable.children.length}get draggableScale(){return this._draggableScale}set draggableScale(e){this._draggableScale=e,this.draggable.children.forEach(t=>t.scale.setScalar(e)),this.curvePos.scale.setScalar(e)}get camera(){return this._camera}set camera(e){this._camera=e,this._transform!==void 0&&(this._transform.camera=e)}get curvePercentage(){return this._curvePercentage}set curvePercentage(e){this._curvePercentage=e,this.curvePos.position.copy(this.getPointAt(e))}updateCurrentPoint(){if(this._transform?.object&&this.group){const e=this._transform?.object;e.name.search("point")>-1&&this.group.current?.setField("Current Point",e.position)}}onUpdateTransform=()=>{this.updateCurrentPoint(),this.updateSpline()};initDebug(e){const t=this.draggable.children;this.parentGroup=e,this._transform=xt.instance.add(this.name),this._transform.camera=this._camera,this._transform.addEventListener("objectChange",this.onUpdateTransform),t.length>0&&this._transform.attach(t[t.length-1]),et.instance?.helpersContainer.add(this._transform.getHelper());const s=t.length>0?t[t.length-1].position:{x:0,y:0,z:0};this.group=e.addGroup({title:this.name,expanded:!0,items:[{prop:"Closed",type:"boolean",value:this.closed},{prop:"Visible",type:"boolean",value:this.visible},{prop:"Show Position",type:"boolean",value:this.curvePos.visible},{prop:"Show Points",type:"boolean",value:this.draggable.visible},{prop:"Color",type:"color",value:`#${this.draggedMat.color.getHexString()}`},{prop:"Curve",type:"option",options:[{title:"Catmullrom",value:"catmullrom"},{title:"Centripetal",value:"centripetal"},{title:"Chordal",value:"chordal"}]},{prop:"Draggable Scale",type:"range",min:.01,max:100,step:.01,value:this._draggableScale},{prop:"Subdivide",type:"range",min:1,max:1e3,step:1,value:this.subdivide},{prop:"Tension",type:"range",min:0,max:1,step:.01,value:this.tension},{prop:"New Pt Offset",type:"range",min:0,max:10,value:this.offset},{prop:"Curve At",type:"range",min:0,max:1,step:.01,value:0},{prop:"Toggle Transform",type:"button"},{prop:"Add Point",type:"button"},{prop:"Remove Point",type:"button"},{prop:"Export",type:"button"},{prop:"Delete",type:"button"},{prop:"Current Point",type:"grid3",value:s}],onUpdate:(i,n)=>{switch(i){case"Closed":this.closed=n,this.updateSpline();break;case"Visible":this.visible=n;break;case"Color":this.lineMaterial.color.setStyle(n),this.draggedMat.color.setStyle(n);break;case"Curve":this.curveType=n,this.updateSpline();break;case"Draggable Scale":this.draggableScale=n;break;case"Subdivide":this.subdivide=n,this.updateSpline();break;case"Tension":this.tension=n,this.updateSpline();break;case"New Pt Offset":this.offset=n;break;case"Curve At":this.curvePos.position.copy(this.getPointAt(n));break;case"Show Position":this.curvePos.visible=n;break;case"Show Points":this.draggable.visible=n;break;case"Toggle Transform":this._transform&&(this._transform.getHelper().visible=!this._transform.getHelper().visible);break;case"Add Point":this.addNextPt();break;case"Remove Point":this.removeSelectedPt();break;case"Export":this.exportSpline();break;case"Delete":this.parent.currentSpline=null,ii(this);break;case"Current Point":if(this.group.current&&this._transform?.object){const r=this._transform?.object;r.name.search("point")>-1&&(r.position.copy(n),this.updateSpline())}break}}}),this.draggable.children.forEach(i=>{this.debugPoint(i)})}debugPoint=e=>{e.name,e.visible=this.draggable.visible}}let wo=0;class zy extends x.Object3D{defaultScale=10;currentSpline=null;_camera;group=null;app;splineDataText="";constructor(e,t){super(),this.name="Spline Editor",this._camera=e,this.app=t,this.app.addEventListener(Q.ADD_SPLINE,this.onAddSpline)}initDebug(){this.group=Re.addEditorGroup({title:this.name,items:[{type:"field",prop:"Spline Data",value:"",disabled:!1},{type:"button",prop:"Import Spline"},{type:"button",prop:"New Spline"},{type:"boolean",prop:"Show Points",value:!0},{type:"boolean",prop:"Draw Mode",value:!1},{type:"boolean",prop:"Visible",value:this.visible},{type:"range",prop:"Default Scale",min:0,max:50,step:.01,value:this.defaultScale}],onUpdate:(e,t)=>{switch(e){case"New Spline":this.createSpline();break;case"Spline Data":this.splineDataText=t;break;case"Import Spline":this.createSplineFromJSON(JSON.parse(this.splineDataText));break;case"Show Points":this.showPoints(t);break;case"Visible":this.visible=t;break;case"Default Scale":this.defaultScale=t;break;case"Draw Mode":t?this.enableClickToDraw():this.disableClickToDraw();break}}})}dispose(){this.app.removeEventListener(Q.ADD_SPLINE,this.onAddSpline),Re.removeEditorGroup(this.name)}addSpline(e){e.draggableScale=this.defaultScale,e.hideTransform(),this.group?.current!==null&&e.initDebug(this.group.current),this.add(e),this.currentSpline=e}createSpline=(e=[])=>{const t=`Spline ${wo+1}`,s=new Lo(t,this._camera);return s.addPoints(e),this.addSpline(s),wo++,s};createSplineFromArray=e=>{const t=[];return e.forEach(s=>{t.push(new x.Vector3(s[0],s[1],s[2]))}),this.createSpline(t)};createSplineFromCatmullRom=e=>this.createSpline(e.points);createSplineFromJSON=e=>{const t=[];e.points.forEach(i=>{t.push(new x.Vector3(i[0],i[1],i[2]))});const s=new Lo(e.name,this._camera);return s.closed=e.closed,s.subdivide=e.subdivide,s.tension=e.tension,s.type=e.type,s.addPoints(t),s.updateSpline(),this.addSpline(s),s};showPoints=(e=!0)=>{this.children.forEach(t=>{t.showPoints(e)})};onAddSpline=e=>{const t=JSON.parse(e.value),s=`Spline ${wo+1}`,i=[];t.points.forEach(r=>{i.push(new x.Vector3(r[0],r[1],r[2]))});const n=new Lo(s,this.camera);n.addPoints(i),this.addSpline(n),wo++};isMouseDown=!1;enableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.addEventListener("mousedown",this.onClickCanvas),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp)})}disableClickToDraw(){document.querySelectorAll(".clickable").forEach(e=>{e.removeEventListener("mousedown",this.onClickCanvas),e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("mouseup",this.onMouseUp)})}onClickCanvas=e=>{if(e.button!==0)return;if(this._camera.type!=="OrthographicCamera"){console.warn("Spline Editor - 3D Camera not supported in Draw Mode");return}const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1;if(et.instance){const o=new x.Raycaster;o.setFromCamera(new x.Vector2(i,n),this._camera);const l=o.intersectObjects(et.instance.helpersContainer.children,!0);for(let c=0;c<l.length;c++){const h=l[c];if(!(h.object.isLine||h.object.isTransformControlsPlane)&&h.object.isObject3D)return}}this.currentSpline===null&&(this.currentSpline=this.createSpline());const r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.addPoint(r),this.isMouseDown=!0};onMouseMove=e=>{if(!this.isMouseDown)return;const s=e.target.getBoundingClientRect(),i=(e.clientX-s.left)/s.width*2-1,n=-((e.clientY-s.top)/s.height)*2+1,r=this.mouseToSplinePos(i,n,s.width,s.height);this.currentSpline?.updateLastPoint(r)};onMouseUp=()=>{this.isMouseDown=!1};mouseToSplinePos(e,t,s,i){const n=new x.Vector3,r=Math.PI/2,o=this._camera,l=o.zoom,c=o.rotation.x===-6123233995736766e-32&&o.rotation.y===0&&o.rotation.z===0,h=o.rotation.x===-Math.PI&&o.rotation.y===12246467991473532e-32&&o.rotation.z===Math.PI,u=o.rotation.x===-6162975822039155e-48&&o.rotation.y===-r&&o.rotation.z===0,d=o.rotation.x===-6162975822039155e-48&&o.rotation.y===r&&o.rotation.z===0,p=o.rotation.x===-1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0,f=o.rotation.x===1.5707953264174506&&o.rotation.y===0&&o.rotation.z===0;let m=e,y=t;h||d?m*=-1:p&&(y*=-1);const g=s/2/l,_=i/2/l;if(this.currentSpline===null&&(this.currentSpline=this.createSpline()),c||h){const b=m*g+o.position.x,T=y*_+o.position.y;n.set(b,T,0)}else if(u||d){const b=m*g+o.position.z,T=y*_+o.position.y;n.set(0,T,b)}else if(p||f){const b=m*g+o.position.x,T=y*_+o.position.z;n.set(b,0,T)}return n}get camera(){return this._camera}set camera(e){this._camera=e,this.children.forEach(t=>{const s=t;s.camera=e})}}const Zf=["Single","Side by Side","Stacked","Quad"],_N="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC60lEQVRYhe2YT4hNcRTHP48xpmYaNAvRyEQxEhnKQljYsRm9/EmSyJiMFAsMZWNhJYoNIUVJ2VGiyb9ZzIpMpkQSahbGv9GMYWrM+1rc2zjvzvvdd+99rzdvMd+6de75nd+5387vnN/v/G5KEuWMKRNNIB8mCRaKiiL5qQb2ApuBuUAV0Ad0AJeB3sSeJRX6LJbULTf6JTUn9Z+KWMUpPyp/Avoa4CNQZ3Sj/lNpdL/xottR7AjOkHRUUpekN5I6JbVLavDH75lIfZN0UFKTpCWS0pJem/HeJBEMG6yV1ONYtgFJbZJ+GF1jDh+zJb03NuliEuwMkMo4yErS2RA/LcbuYVyCrm1mA7Dal/8Cu4FG4JD/HsTTkCy6a+SVMTPQuc1sBKb78nHghi+/A+YBxwL2lbhRY+ThuARdEVxu5JdGFvACr0otdoZ8Y4+Rn0Sn5sFFsMvI6YB9MzA1YJ8mN8k1wAHzfj4uQVdyrpI0aJL7oqTtkq4FiqPLyCOSbktqlbRL0jlJQ2b8QdwCUZ4qvhRStZL0XFK1pMd57CRvq5mfhKBriRfiFUMY6oD7eOdwPlQAN4G10dfWg+uouwXsiOssAj4AC+JMcEWwvnAuOTEr7gTXPmg34zagOwkbIIOXAo9CbDYBrcBXYN+4UUdy2sRflyS5zVNlfPX7ugpJW5V9nI7mmh+lYU0lCZ2B3TOnAVuAk0BTwC5nuhWro46KauBOQJch5OpRaoIW34GreGf+YZdRqS9NAj4Bp4ClQDvwOWxCqSM4ADQEdKE5XvbXzlITrAVe4TW+M6NMKDXBFLAMuAD0ACfIc7pMZBXXA2cY3/xmodQRHAL2A2+NLtj8ZiEKwUL/z2WMPAJcAVYALWSf8dZuDFGWeBHwKxm3sWYhiGG8Tfo6sA2vSfiSy4GrH3wGrDcfKSSKKf6v1E9yF0XK9Q1XBPuMXMw8HXTonQFwETwNzMFr64v1jzgFHIk9ybHEZYPJo65QlD3Bf2/Q/eaHPiSWAAAAAElFTkSuQmCC",bN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAETklEQVRYhe2YXYhVVRTHf3d0/JhyUrMpFbImM+whSa3Mynww+4AeIgiKoozooQ+KyMyXIAujF6OXqHyI6iEKKYgIP/owsjSFqCkprdDUTEcjbWZ0HHV+Pex1ucfb9Z57Z9REXHA4Z++99l7/s/ZZ/7X2KaiczNLwfwPIk9MA+yunNMAG4DHgV+BvoB3YFff2TPstYEyfrajVroI6Sr1GvahsbJC63HzZq04pmztSvU5tVRuqYRiYg78JeBR4HPg5ntdmxovz9wJfA3uAxuibDLQCA+IqynnAQuBuYCnwMLC1rx48U12U8cZqdWqMDcx4cI16qTpYbVKHqa+ovWUeHKsujn7VL9ULq2HI+wY7gVeBJdGeFu3J4ZUiy/cAXeHRRuAQsC/GC0B3eG4BcH/0tUV7czUAeVsMsBF4Kha9HZgCvAncAuwPnXHA0wFuGLANuDrGuoGDwFxgTqzzQ7RX5FrP2eLsdb76vnogtme6+nE8H1YPlQXHwbi3q9eqn0e7Tb25VrsF68vFY0lb1AGcDTwItGQ8tQM4AIwGmqP/EPAu8A0wElgJfFGzxTo8mKWXu9Rd4ZF96jvqjSbauEC9Sn1O3R463epLaku99voCsFXdkAH3kNpcQW+IiT/bQne3eufxBtioPqP2mKhioXpWzpxb1T8C5Ifh4ZptVoriRmAIKdrI3Lujf3bobAPeJpF0NVkKrAFuI9HTOBIxnxFrF4OgQKKr/dnJlQA+AcwABgOHA4zAamA5cE7orQL+zAEHiWI+A2bFC7aSguheYCgpqAphZz3wSB7AecCICv2TgH8oFRib4gVqka0k0h8CXAxMBW6ooDejFoCvA9OBQUAvKWM0kDz4XUZvNKXtyZMWUl7vBbaQXq457PeEziDgx/KJlQAuIPFdMcEXv5OdYWBP9M8k8VpnDQCvB4aTSrCNJB5cSdrW3tBpIJVnR0qdUTxAfdGUOVTnmwqEanNmqltC/9OgqePKg5eom8PgdvW+oJ9Kupera0O3U50TL3lcAaI+oHaF4R3qa6Z822wq0Saq89T1lmSxOrxeW/Xm4uGkiqQDmECKuKHxHW0HdpMiewSpvGqKeR8Ay0iBsYIjg6261PE2o9Q3Yqv+MqWxO9R1Hl12qs+q49Vlppy82pSr+5xJKsko4AXgHlJ0t5NIeg3wLXAlqZhtIUV8J6nmWwX8QiLjdhL5TwMWkY4R6/rrwYKlMr1Y321QZ/vfwBijPqm+rF4Wc7PjE9QllurGVeoV5gRNHsAm9fnMom3qrKPoTjKdMXaYyrFygEWQ72XWW24qhPu8xcUc2UU6O8wFPjmK7jhgPHAuMJGUGQ6U6WwE5sfzTXGvei7KA9hFOiR9D/wOfFVFt4dS2tpfRe83Ur7/CPiJakfOGgBCypubatArl2r8VfOax/LfzABKtePAzHO/5FgC7KBEzB2kOrDfUm8mOeFySv9+OyFyGmB/5aQH+C9BVKmVCNuMZgAAAABJRU5ErkJggg==",TN="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAQ0lEQVQ4jWP8////fwYqAxYozUhFM/8zkaKYWIWkGEq0b0ZdSjQY5i79TyWagRGaTUdzFEEw6lLqGzqwLoVVJ1StpwA9sBwbUqAh5gAAAABJRU5ErkJggg==";class et extends W.Component{static instance=null;app;scene;renderer;currentScene;scenes=new Map;cameras=new Map;controls=new Map;currentCamera;currentWindow;helpersContainer=new x.Group;cameraHelpers=new Map;lightHelpers=new Map;grid=new rN;interactionHelper=new x.AxesHelper(25);currentTransform;splineEditor;depthMaterial=new x.MeshDepthMaterial;normalsMaterial=new x.MeshNormalMaterial;uvMaterial=new lN;wireframeMaterial=new x.MeshBasicMaterial({opacity:.33,transparent:!0,wireframe:!0});playing=!1;rafID=-1;cameraControlsRafID=-1;width=0;height=0;tlCam=null;trCam=null;blCam=null;brCam=null;tlRender="Renderer";trRender="Renderer";blRender="Renderer";brRender="Renderer";cameraVisibility=!0;lightVisibility=!0;gridVisibility=!0;selectedItem=void 0;debugCamera;raycaster=new x.Raycaster;pointer=new x.Vector2;cameraControls=void 0;canvasRef;containerRef;tlWindow;trWindow;blWindow;brWindow;constructor(e){super(e),this.app=e.app,this.app.addEventListener(Q.ADD_RENDERER,this.setupRenderer),this.scene=new x.Scene,this.scene.name=this.scene.uuid="",this.canvasRef=W.createRef(),this.containerRef=W.createRef(),this.tlWindow=W.createRef(),this.trWindow=W.createRef(),this.blWindow=W.createRef(),this.brWindow=W.createRef();const t=e.three.app.appID,s=localStorage,i=s.getItem(`${t}_mode`);this.state={mode:i!==null?i:"Single",modeOpen:!1,renderModeOpen:!1,interactionMode:"Orbit",interactionModeOpen:!1,lastUpdate:Date.now()},s.setItem(`${t}_mode`,this.state.mode),s.setItem(`${t}_tlCam`,s.getItem(`${t}_tlCam`)!==null?s.getItem(`${t}_tlCam`):"Debug"),s.setItem(`${t}_trCam`,s.getItem(`${t}_trCam`)!==null?s.getItem(`${t}_trCam`):"Orthographic"),s.setItem(`${t}_blCam`,s.getItem(`${t}_blCam`)!==null?s.getItem(`${t}_blCam`):"Front"),s.setItem(`${t}_brCam`,s.getItem(`${t}_brCam`)!==null?s.getItem(`${t}_brCam`):"Top"),s.setItem(`${t}_tlRender`,s.getItem(`${t}_tlRender`)!==null?s.getItem(`${t}_tlRender`):"Renderer"),s.setItem(`${t}_trRender`,s.getItem(`${t}_trRender`)!==null?s.getItem(`${t}_trRender`):"Renderer"),s.setItem(`${t}_blRender`,s.getItem(`${t}_blRender`)!==null?s.getItem(`${t}_blRender`):"Renderer"),s.setItem(`${t}_brRender`,s.getItem(`${t}_brRender`)!==null?s.getItem(`${t}_brRender`):"Renderer");const n={Vector2:x.Vector2,Vector3:x.Vector3,Vector4:x.Vector4,Quaternion:x.Quaternion,Matrix4:x.Matrix4,Spherical:x.Spherical,Box3:x.Box3,Sphere:x.Sphere,Raycaster:x.Raycaster};Ds.install({THREE:n}),this.setupScene(),this.setupTools();const r=localStorage.getItem(this.expandedCameraVisibility);r!==null&&(this.cameraVisibility=r==="open"),this.saveExpandedCameraVisibility();const o=localStorage.getItem(this.expandedLightVisibility);o!==null&&(this.lightVisibility=o==="open"),this.saveExpandedLightVisibility();const l=localStorage.getItem(this.expandedGridVisibility);l!==null&&(this.gridVisibility=l==="open"),this.grid.visible=this.gridVisibility,this.saveExpandedGridVisibility(),et.instance=this}componentDidMount(){this.enable(),this.assignControls(),this.resize(),this.play(),xt.instance.setApp(this.props.app,this.props.three),xt.instance.activeCamera=this.debugCamera}componentDidUpdate(e,t,s){t.mode!==this.state.mode&&(this.assignControls(),this.resize())}componentWillUnmount(){this.disable(),Re.removeEditorGroup("View Settings")}render(){const e=[];return this.cameras.forEach((t,s)=>{e.push(s)}),C.jsxs("div",{className:"multiview",children:[C.jsx("canvas",{ref:this.canvasRef}),C.jsxs("div",{className:`cameras ${this.state.mode==="Single"||this.state.mode==="Stacked"?"single":""}`,ref:this.containerRef,children:[this.state.mode==="Single"&&C.jsx(C.Fragment,{children:C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}})}),(this.state.mode==="Side by Side"||this.state.mode==="Stacked")&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}})]}),this.state.mode==="Quad"&&C.jsxs(C.Fragment,{children:[C.jsx(Zi,{name:"tl",camera:this.tlCam,options:e,ref:this.tlWindow,onSelectCamera:t=>{this.controls.get(this.tlCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.tlCam),this.tlCam=s,localStorage.setItem(`${this.appID}_tlCam`,s.name),this.createControls(s,this.tlWindow.current))},onSelectRenderMode:t=>{this.tlRender=t,localStorage.setItem(`${this.appID}_tlRender`,t)}}),C.jsx(Zi,{name:"tr",camera:this.trCam,options:e,ref:this.trWindow,onSelectCamera:t=>{this.controls.get(this.trCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.trCam),this.trCam=s,localStorage.setItem(`${this.appID}_trCam`,s.name),this.createControls(s,this.trWindow.current))},onSelectRenderMode:t=>{this.trRender=t,localStorage.setItem(`${this.appID}_trRender`,t)}}),C.jsx(Zi,{name:"bl",camera:this.blCam,options:e,ref:this.blWindow,onSelectCamera:t=>{this.controls.get(this.blCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.blCam),this.blCam=s,localStorage.setItem(`${this.appID}_blCam`,s.name),this.createControls(s,this.blWindow.current))},onSelectRenderMode:t=>{this.blRender=t,localStorage.setItem(`${this.appID}_blRender`,t)}}),C.jsx(Zi,{name:"br",camera:this.brCam,options:e,ref:this.brWindow,onSelectCamera:t=>{this.controls.get(this.brCam.name)?.dispose();const s=this.cameras.get(t);s!==void 0&&(this.clearCamera(this.brCam),this.brCam=s,localStorage.setItem(`${this.appID}_brCam`,s.name),this.createControls(s,this.brWindow.current))},onSelectRenderMode:t=>{this.brRender=t,localStorage.setItem(`${this.appID}_brRender`,t)}})]})]}),C.jsxs("div",{className:"settings",children:[C.jsx(al,{title:"View",index:Zf.indexOf(this.state.mode),options:Zf,onSelect:t=>{t!==this.state.mode&&(this.killControls(),this.setState({mode:t}),localStorage.setItem(`${this.appID}_mode`,t))},open:this.state.modeOpen,onToggle:t=>{this.setState({modeOpen:t,renderModeOpen:!1,interactionModeOpen:!1})}}),C.jsx(al,{title:"Interact",index:this.state.interactionMode==="Orbit"?0:1,options:["Orbit Mode","Selection Mode"],onSelect:t=>{this.interactionHelper.visible=t==="Selection Mode",this.setState({interactionMode:this.interactionHelper.visible?"Selection":"Orbit"})},open:this.state.interactionModeOpen,onToggle:t=>{this.setState({modeOpen:!1,renderModeOpen:!1,interactionModeOpen:t})}}),C.jsx(sh,{name:"cameraHelper",icon:_N,selected:this.cameraVisibility,height:24,top:2,onClick:t=>{if(this.cameraVisibility=t,this.saveExpandedCameraVisibility(),this.cameraHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t){const s=this.cameraHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"lightHelper",icon:bN,selected:this.lightVisibility,height:24,top:4,onClick:t=>{if(this.lightVisibility=t,this.saveExpandedLightVisibility(),this.lightHelpers.forEach(s=>{s.visible=t}),this.selectedItem!==void 0&&!t&&this.selectedItem.isLight===!0){const s=this.lightHelpers.get(this.selectedItem.name);s!==void 0&&(s.visible=!0)}}}),C.jsx(sh,{name:"gridHelper",icon:TN,selected:this.gridVisibility,height:21,width:21,onClick:t=>{this.gridVisibility=t,this.saveExpandedGridVisibility(),this.grid.visible=t}})]},this.state.lastUpdate)]})}setupRenderer=e=>{this.renderer&&this.renderer.dispose();const t=this.canvasRef.current;this.props.three.canvas=t;const s=e.value;s.type==="WebGLRenderer"?(this.renderer=new x.WebGLRenderer({canvas:t,stencil:!1}),this.grid.visible=!0):s.type==="WebGPURenderer"&&(this.renderer=new mo({canvas:t,stencil:!1}),this.grid.visible=!1),this.renderer&&(this.renderer.autoClear=!1,this.renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(devicePixelRatio),this.renderer.setClearColor(0),this.resize(),this.props.three.renderer=this.renderer)};setupScene(){this.helpersContainer.name="helpers",this.scene.add(this.helpersContainer),this.grid.position.y=-1,this.scene.add(this.grid),this.interactionHelper.name="interactionHelper",this.interactionHelper.visible=!1,this.helpersContainer.add(this.interactionHelper);const e=(n,r)=>{const o=new x.OrthographicCamera(-100,100,100,-100,0,3e3);return o.name=n,o.position.copy(r),o.lookAt(0,0,0),this.cameras.set(n,o),o},t=1e3;e("Top",new x.Vector3(0,t,0)),e("Bottom",new x.Vector3(0,-t,0)),e("Left",new x.Vector3(-t,0,0)),e("Right",new x.Vector3(t,0,0)),e("Front",new x.Vector3(0,0,t)),e("Back",new x.Vector3(0,0,-t)),e("Orthographic",new x.Vector3(t,t,t)),e("UI",new x.Vector3),this.debugCamera=new x.PerspectiveCamera(60,1,.01,3e3),this.debugCamera.name="Debug",this.debugCamera.position.set(300,300,300),this.debugCamera.lookAt(0,0,0),this.cameras.set("Debug",this.debugCamera),this.currentCamera=this.debugCamera;const s=localStorage,i=this.props.three.app.appID;this.tlCam=this.cameras.get(s.getItem(`${i}_tlCam`)),this.trCam=this.cameras.get(s.getItem(`${i}_trCam`)),this.blCam=this.cameras.get(s.getItem(`${i}_blCam`)),this.brCam=this.cameras.get(s.getItem(`${i}_brCam`)),this.tlCam===void 0&&(this.tlCam=this.cameras.get("Debug")),this.trCam===void 0&&(this.trCam=this.cameras.get("Orthographic")),this.blCam===void 0&&(this.blCam=this.cameras.get("Front")),this.brCam===void 0&&(this.brCam=this.cameras.get("Top"))}setupTools(){this.splineEditor=new zy(this.currentCamera,this.app),this.splineEditor.initDebug(),this.helpersContainer.add(this.splineEditor)}play(){this.playing=!0,this.onUpdate()}pause(){this.playing=!1,cancelAnimationFrame(this.rafID),this.rafID=-1}toggleOrbitControls(e){this.controls.forEach(t=>{t.enabled=!e})}update(){this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.controls.forEach(e=>e.update()),this.cameraHelpers.forEach(e=>e.update()),this.lightHelpers.forEach(e=>{e.update!==void 0&&e.update()}),this.props.onSceneUpdate!==void 0&&this.currentScene!==void 0&&this.props.onSceneUpdate(this.currentScene)}draw(){switch(this.renderer&&(this.renderer instanceof x.WebGLRenderer?this.renderer?.clear():this.renderer instanceof mo&&this.renderer?.clearAsync()),this.state.mode){case"Single":this.drawSingle();break;case"Side by Side":case"Stacked":this.drawDouble();break;case"Quad":this.drawQuad();break}}onUpdate=()=>{this.playing&&(this.update(),this.draw(),this.rafID=requestAnimationFrame(this.onUpdate))};enable(){const e=this.containerRef.current;e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("click",this.onClick),window.addEventListener("keydown",this.onKey),window.addEventListener("resize",this.resize),this.app.addEventListener(Q.ADD_SCENE,this.addScene),this.app.addEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.addEventListener(Q.ADD_CAMERA,this.addCamera),this.app.addEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.addEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}disable(){const e=this.containerRef.current;e.removeEventListener("mousemove",this.onMouseMove),e.removeEventListener("click",this.onClick),window.removeEventListener("keydown",this.onKey),window.removeEventListener("resize",this.resize),this.app.removeEventListener(Q.ADD_SCENE,this.addScene),this.app.removeEventListener(Q.SET_SCENE,this.sceneUpdate),this.app.removeEventListener(Q.ADD_CAMERA,this.addCamera),this.app.removeEventListener(Q.REMOVE_CAMERA,this.removeCamera),this.app.removeEventListener(Q.SET_OBJECT,this.onSetSelectedItem)}resize=()=>{this.width=window.innerWidth-300,this.height=window.innerHeight,this.renderer?.setSize(this.width,this.height);const e=Math.floor(this.width/2),t=Math.floor(this.height/2);this.props.three.resize(this.width,this.height),this.props.onSceneResize!==void 0&&this.currentScene!==void 0&&this.props.onSceneResize(this.currentScene,this.width,this.height);let s=this.width,i=this.height;switch(this.state.mode){case"Side by Side":s=e,i=this.height;break;case"Stacked":s=this.width,i=t;break;case"Quad":s=e,i=t;break}const n=s/i;this.cameras.forEach(r=>{r instanceof x.OrthographicCamera?(r.left=s/-2,r.right=s/2,r.top=i/2,r.bottom=i/-2,r.name==="UI"&&(r.position.x=this.width/2,r.position.y=this.height/-2,r.position.z=100),r.updateProjectionMatrix()):r instanceof x.PerspectiveCamera&&(r.aspect=n,r.updateProjectionMatrix()),this.cameraHelpers.get(r.name)?.update()})};addScene=e=>{const t=this.props.scenes.get(e.value.name);if(t!==void 0){const s=new t;s.visible=!1,this.props.onSceneSet!==void 0&&this.props.onSceneSet(s),this.props.three.scene=s,this.scenes.set(e.value.name,s),this.scene.add(s)}};sceneUpdate=e=>{this.currentScene!==void 0&&(this.currentScene.visible=!1,this.clearLightHelpers());const t=this.scene.getObjectByName(e.value.name);t!==void 0&&(this.currentScene=t,this.currentScene.visible=!0,this.addLightHelpers(this.currentScene))};addCamera=e=>{const t=e.value,s=`${this.props.three.scene?.name}_${t.name}`,i=this.props.three.scene?.getObjectByProperty("uuid",t.uuid);if(i!==void 0){const n=i;this.cameras.set(s,n);const r=new x.CameraHelper(n);r.visible=this.cameraVisibility,this.cameraHelpers.set(s,r),this.helpersContainer.add(r),this.setState({lastUpdate:Date.now()})}};removeCamera=e=>{const t=this.cameraHelpers.get(e.value.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose()),this.cameras.delete(e.value.name),this.setState({lastUpdate:Date.now()})};onMouseMove=e=>{const t=new x.Vector2;this.renderer?.getSize(t);const s=Math.min(e.clientX,t.x),i=Math.min(e.clientY,t.y);this.pointer.x=Ki(s,0,t.x,-1,1),this.pointer.y=Ki(i,0,t.y,1,-1);const n=t.x/2,r=t.y/2,o=()=>{s<n?this.pointer.x=Ki(s,0,n,-1,1):this.pointer.x=Ki(s,n,t.x,-1,1)},l=()=>{i<r?this.pointer.y=Ki(i,0,r,1,-1):this.pointer.y=Ki(i,r,t.y,1,-1)};switch(this.state.mode){case"Quad":o(),l();break;case"Side by Side":o();break;case"Stacked":l(),l();break}if(this.updateCamera(s,i,n,r),this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const c=this.raycaster.intersectObjects(this.currentScene.children);c.length>0&&this.interactionHelper.position.copy(c[0].point)};onClick=e=>{if(this.state.interactionMode==="Orbit"||this.currentScene===void 0)return;const t=new x.Vector2;if(this.renderer.getSize(t),e.clientX>=t.x)return;this.onMouseMove(e);const s=this.raycaster.intersectObjects(this.currentScene.children);s.length>0&&(this.props.three.getObject(s[0].object.uuid),this.interactionHelper.visible=!1,this.setState({interactionMode:"Orbit",lastUpdate:Date.now()}))};onKey=e=>{if(this.selectedItem!==void 0){if(e.ctrlKey){if(this.currentCamera.name==="UI")return;const t=this.controls.get(this.currentCamera.name);e.key==="0"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.selectedItem instanceof x.Mesh||this.selectedItem instanceof x.SkinnedMesh?(this.selectedItem.geometry.computeBoundingBox(),this.cameraControls.fitToBox(this.selectedItem.geometry.boundingBox,!0)):this.cameraControls.fitToSphere(this.selectedItem,!0),this.updateCameraControls(t,!0)):e.key==="1"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,Math.PI*.5,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="2"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(0,0,!0),this.cameraControls.moveTo(this.selectedItem.position.x,0,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="3"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI/2,Math.PI/2,!0),this.cameraControls.moveTo(0,this.selectedItem.position.y,this.selectedItem.position.z,!0),this.updateCameraControls(t)):e.key==="4"?(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(Math.PI,Math.PI/2,!0),this.cameraControls.moveTo(this.selectedItem.position.x,this.selectedItem.position.y,0,!0),this.updateCameraControls(t)):e.key==="5"&&(e.preventDefault(),this.clearControls(),this.cameraControls=new Ds(this.currentCamera,this.currentWindow.current),this.cameraControls.rotateTo(zo(45),zo(45),!0),this.updateCameraControls(t))}else if(this.currentTransform!==void 0)switch(e.key){case"r":this.currentTransform.setMode("rotate");break;case"s":this.currentTransform.setMode("scale");break;case"t":this.currentTransform.setMode("translate");break;case"q":this.currentTransform.setSpace(this.currentTransform.space==="local"?"world":"local");break}}};onSetSelectedItem=e=>{if(this.selectedItem!==void 0&&this.updateSelectedItemHelper(!1),this.selectedItem=this.currentScene.getObjectByProperty("uuid",e.value.uuid),this.selectedItem===void 0){console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);return}this.currentTransform!==void 0&&(this.currentTransform.removeEventListener("objectChange",this.onUpdateTransform),xt.instance.remove(this.currentTransform.getHelper().name)),this.currentTransform=xt.instance.add(e.value.name),this.currentTransform.attach(this.selectedItem),this.helpersContainer.add(this.currentTransform.getHelper()),this.currentTransform.addEventListener("objectChange",this.onUpdateTransform),this.updateSelectedItemHelper(!0)};updateSelectedItemHelper(e){if(this.selectedItem!==void 0)if(this.cameraVisibility){if(this.selectedItem.isLight===!0&&!this.lightVisibility){const t=this.lightHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}else{const t=this.cameraHelpers.get(this.selectedItem.name);t!==void 0&&(t.visible=e)}}onUpdateTransform=()=>{this.selectedItem!==void 0&&(this.props.three.updateObject(this.selectedItem.uuid,"position",this.selectedItem.position),this.props.three.updateObject(this.selectedItem.uuid,"rotation",{x:this.selectedItem.rotation.x,y:this.selectedItem.rotation.y,z:this.selectedItem.rotation.z}),this.props.three.updateObject(this.selectedItem.uuid,"scale",this.selectedItem.scale),Al.instance.update())};clearLightHelpers=()=>{this.lightHelpers.forEach(e=>{this.helpersContainer.remove(e),e.dispose()}),this.lightHelpers.clear()};addLightHelpers=e=>{e.traverse(t=>{if(t.type.search("Light")>-1){let s;switch(t.type){case"DirectionalLight":s=new x.DirectionalLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"HemisphereLight":s=new x.HemisphereLightHelper(t,250),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"RectAreaLight":s=new UR(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"PointLight":s=new x.PointLightHelper(t,100),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break;case"SpotLight":s=new x.SpotLightHelper(t),s.name=`${t.name}Helper`,s.visible=this.lightVisibility,this.lightHelpers.set(t.name,s),this.helpersContainer.add(s);break}}})};createControls(e,t){const s=this.controls.get(e.name);if(s!==void 0&&s.dispose(),this.controls.delete(e.name),e.name==="UI")return;const i=new zR(e,t);switch(i.enableDamping=!0,i.dampingFactor=.2,e.name){case"Top":case"Bottom":case"Left":case"Right":case"Front":case"Back":i.enableRotate=!1;break}this.controls.set(e.name,i)}clearCamera(e){const t=this.cameraHelpers.get(e.name);t!==void 0&&(this.helpersContainer.remove(t),t.dispose(),this.cameraHelpers.delete(e.name));const s=this.controls.get(e.name);s!==void 0&&(s.dispose(),this.controls.delete(e.name))}killControls(){this.controls.forEach((e,t)=>{e.dispose();const s=this.cameraHelpers.get(t);s!==void 0&&(this.helpersContainer.remove(s),s.dispose()),this.cameraHelpers.delete(t),this.controls.delete(t)}),this.controls.clear(),this.cameraHelpers.clear()}assignControls(){switch(this.state.mode){case"Single":this.createControls(this.tlCam,this.tlWindow.current);break;case"Side by Side":case"Stacked":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current);break;case"Quad":this.createControls(this.tlCam,this.tlWindow.current),this.createControls(this.trCam,this.trWindow.current),this.createControls(this.blCam,this.blWindow.current),this.createControls(this.brCam,this.brWindow.current);break}}updateCamera=(e,t,s,i)=>{switch(this.state.mode){case"Quad":t<i?e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam:e<s?this.currentCamera=this.blCam:this.currentCamera=this.brCam;break;case"Side by Side":e<s?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break;case"Single":this.currentCamera=this.tlCam;break;case"Stacked":t<i?this.currentCamera=this.tlCam:this.currentCamera=this.trCam;break}this.splineEditor.camera=this.currentCamera,this.raycaster.setFromCamera(this.pointer,this.currentCamera),this.currentCamera===this.tlCam?this.currentWindow=this.tlWindow:this.currentCamera===this.trCam?this.currentWindow=this.trWindow:this.currentCamera===this.blCam?this.currentWindow=this.blWindow:this.currentCamera===this.brCam&&(this.currentWindow=this.brWindow),xt.instance.updateCamera(this.currentCamera,this.currentWindow.current)};updateCameraControls=(e,t=!1)=>{if(this.selectedItem===void 0)return;cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.cameraControls&&(this.cameraControls.smoothTime=.1);const s=.15,i=new x.Clock;i.start(),this.selectedItem.getWorldPosition(e.target0);const n=()=>{const r=i.getDelta();this.cameraControls&&this.cameraControls.update(r),t&&(e.target.lerp(e.target0,s),e.object.position.lerp(e.position0,s),e.object.zoom=rr(e.object.zoom,e.zoom0,s),e.object.updateProjectionMatrix(),e.dispatchEvent({type:"change"})),i.getElapsedTime()>=.5?(cancelAnimationFrame(this.cameraControlsRafID),this.cameraControlsRafID=-1,this.clearControls()):this.cameraControlsRafID=requestAnimationFrame(n)};n()};clearControls=()=>{this.cameraControls!==void 0&&(this.cameraControls.disconnect(),this.cameraControls.dispose(),this.cameraControls=void 0)};saveExpandedCameraVisibility(){localStorage.setItem(this.expandedCameraVisibility,this.cameraVisibility?"open":"closed")}saveExpandedLightVisibility(){localStorage.setItem(this.expandedLightVisibility,this.lightVisibility?"open":"closed")}saveExpandedGridVisibility(){localStorage.setItem(this.expandedGridVisibility,this.gridVisibility?"open":"closed")}getSceneOverride(e){switch(e){case"Depth":return this.depthMaterial;case"Normals":return this.normalsMaterial;case"Renderer":return null;case"UVs":return this.uvMaterial;case"Wireframe":return this.wireframeMaterial}return null}drawTo(e,t,s,i,n,r){switch(n.name){case"Left":case"Right":this.grid.rotation.z=Math.PI/2;break;case"Front":case"Back":this.grid.rotation.x=Math.PI/2;break}this.scene.overrideMaterial=r,this.renderer&&(this.renderer?.setViewport(e,t,s,i),this.renderer?.setScissor(e,t,s,i),this.renderer instanceof x.WebGLRenderer?this.renderer?.render(this.scene,n):this.renderer instanceof mo&&this.renderer?.renderAsync(this.scene,n)),this.grid.rotation.set(0,0,0)}drawSingle(){const e=this.getSceneOverride(this.tlRender);this.drawTo(0,0,this.width,this.height,this.tlCam,e)}drawDouble=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=Math.floor(this.width/2),i=Math.floor(this.height/2);if(this.state.mode==="Side by Side")this.drawTo(0,0,s,this.height,this.tlCam,e),this.drawTo(s,0,s,this.height,this.trCam,t);else{const n=this.height-i;this.drawTo(0,n,this.width,i,this.tlCam,e),this.drawTo(0,0,this.width,i,this.trCam,t)}};drawQuad=()=>{const e=this.getSceneOverride(this.tlRender),t=this.getSceneOverride(this.trRender),s=this.getSceneOverride(this.blRender),i=this.getSceneOverride(this.brRender),n=Math.floor(this.width/2),r=Math.floor(this.height/2);let o=0,l=0;l=this.height-r,o=0,this.drawTo(o,l,n,r,this.tlCam,e),o=n,this.drawTo(o,l,n,r,this.trCam,t),l=0,o=0,this.scene.overrideMaterial=s,this.drawTo(o,l,n,r,this.blCam,s),o=n,this.drawTo(o,l,n,r,this.brCam,i)};get appID(){return this.props.three.app.appID}get mode(){return this.state.mode}get three(){return this.props.three}get expandedCameraVisibility(){return`${this.appID}_multiviewCameraVisibility`}get expandedLightVisibility(){return`${this.appID}_multiviewLightVisibility`}get expandedGridVisibility(){return`${this.appID}_multiviewGridVisibility`}}class Al extends W.Component{static instance;app;matrix=new x.Matrix4;position=new x.Vector3;rotation=new x.Euler;scale=new x.Vector3;open=!1;constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;this.open=s,this.saveExpanded(),this.state={lastUpdated:0,expanded:s},this.matrix.elements=e.object.matrix,e.object.uuid.length>0&&(this.position.setFromMatrixPosition(this.matrix),this.rotation.setFromRotationMatrix(this.matrix),this.scale.setFromMatrixScale(this.matrix)),Al.instance=this}update(){if(et.instance){const e=et.instance.selectedItem;if(e===void 0)return;this.position.x=ss(e.position.x,3),this.position.y=ss(e.position.y,3),this.position.z=ss(e.position.z,3),this.rotation.copy(e.rotation),this.scale.x=ss(e.scale.x,3),this.scale.y=ss(e.scale.y,3),this.scale.z=ss(e.scale.z,3),this.setState({lastUpdated:Date.now()})}}render(){return C.jsx(cs,{app:this.app,title:"Transform",expanded:this.open,items:[{title:"Position",prop:"position",type:"grid3",step:.1,value:this.position,onChange:this.updateTransform},{title:"Rotation",prop:"rotation",type:"euler",value:this.rotation,onChange:this.updateTransform},{title:"Scale",prop:"scale",type:"grid3",value:this.scale,onChange:this.updateTransform},{title:"Visible",prop:"visible",type:"boolean",value:this.props.object.visible,onChange:this.updateTransform}],onToggle:e=>{this.open=e,this.saveExpanded()}},this.state.lastUpdated)}updateTransform=(e,t)=>{const s=e==="rotation"?{x:t._x,y:t._y,z:t._z}:t;this.props.three.updateObject(this.props.object.uuid,e,s);const i=this.props.three.getScene(this.props.object.uuid);if(i){const n=i.getObjectByProperty("uuid",this.props.object.uuid);qe(n,e,s)}};saveExpanded(){localStorage.setItem(this.expandedName,this.open?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_transform`}}function Qf(a){switch(a){case"color":return"Color";case"intensity":return"Intensity";case"decay":return"Decay";case"distance":return"Distance";case"angle":return"Angle";case"penumbra":return"Penumbra";case"groundColor":return"Ground Color";case"width":return"Width";case"height":return"Height"}return a}function SN(a,e,t){function s(){return`${t.app.appID}_light`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(l){localStorage.setItem(s(),l?"open":"closed")}const o=[];if(a.lightInfo!==void 0)for(const l in a.lightInfo){const c=a.lightInfo[l];c!==void 0&&(c.isColor!==void 0?o.push({title:Qf(l),prop:l,type:"color",value:c,onChange:(h,u)=>{const d=new x.Color(u);t.updateObject(a.uuid,h,d);const p=t.getScene(a.uuid);if(p!==null){const f=p.getObjectByProperty("uuid",a.uuid);qe(f,h,d)}}}):o.push({title:Qf(l),prop:l,type:typeof c,value:c,step:typeof c=="number"?.01:void 0,onChange:(h,u)=>{t.updateObject(a.uuid,h,u);const d=t.getScene(a.uuid);if(d!==null){const p=d.getObjectByProperty("uuid",a.uuid);qe(p,h,u)}}}))}return C.jsx(cs,{app:e,title:"Light",items:o,expanded:n,onToggle:l=>{r(l)}})}function vN(a){const e=a.object,t=a.three;function s(){return`${t.app.appID}_animation`}const i=localStorage.getItem(s()),n=i!==null?i==="open":!1;function r(d){localStorage.setItem(s(),d?"open":"closed")}const o=[],l=[];let c=0;e.animations.forEach(d=>{c=Math.max(c,d.duration),d.duration>0&&l.push({title:d.name,items:[{title:"Duration",type:"number",value:d.duration,disabled:!0},{title:"Blend Mode",type:"option",disabled:!0,options:[{title:"Normal",value:2500},{title:"Additive",value:2501}]}]})}),o.push({title:"Animations",items:l});let h;const u=t.getScene(e.uuid);if(u!==null){const d=u.getObjectByProperty("uuid",e.uuid);if(d!==void 0){const p=d.mixer;if(p!==void 0){const m=[{title:"Time Scale",type:"range",value:p.timeScale,step:.01,min:-1,max:2,onChange:(y,g)=>{p.timeScale=g,t.updateObject(e.uuid,"mixer.timeScale",g)}}];m.push({title:"Stop All",type:"button",onChange:()=>{p.stopAllAction(),t.requestMethod(e.uuid,"stopAllAction",void 0,"mixer")}}),o.push({title:"Mixer",items:m}),h=new x.SkeletonHelper(d),et.instance?.scene.add(h)}}}return W.useEffect(()=>()=>{h!==void 0&&ii(h)},[]),C.jsx(cs,{app:a.app,title:"Animation",items:o,expanded:n,onToggle:d=>{r(d)}})}const $h={name:"",uuid:"",type:"",visible:!1,matrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],animations:[],material:void 0,perspectiveCameraInfo:void 0,orthographicCameraInfo:void 0,lightInfo:void 0,children:[]};let ft={...$h};function Gy(a){const[e,t]=W.useState(-1);W.useEffect(()=>{function r(l){ft={...l.value},t(Date.now())}function o(){ft={...$h},t(Date.now())}return a.app.addEventListener(Q.SET_SCENE,o),a.app.addEventListener(Q.SET_OBJECT,r),()=>{a.app.removeEventListener(Q.SET_SCENE,o),a.app.removeEventListener(Q.SET_OBJECT,r)}},[]);const s=ft.type.toLowerCase(),i=ft.animations.length>0||ft.mixer!==void 0,n=s.search("mesh")>-1||s.search("line")>-1||s.search("points")>-1;return C.jsx(fa,{app:a.app,label:"Inspector",button:ft.uuid.length>0?C.jsx("button",{className:"remove",onClick:()=>{xt.instance.remove(ft.name),ft={...$h},t(Date.now())}}):void 0,children:C.jsx("div",{id:"Inspector",className:a.class,children:ft.uuid.length>0&&C.jsxs(C.Fragment,{children:[C.jsxs(C.Fragment,{children:[C.jsx(Eo,{type:"string",title:"Name",prop:"name",value:ft.name,disabled:!0}),C.jsx(Eo,{type:"string",title:"Type",prop:"type",value:ft.type,disabled:!0}),C.jsx(Eo,{type:"string",title:"UUID",prop:"uuid",value:ft.uuid,disabled:!0})]}),C.jsxs(C.Fragment,{children:[C.jsx(Al,{object:ft,app:a.app,three:a.three}),i?C.jsx(vN,{app:a.app,object:ft,three:a.three}):null,s.search("camera")>-1?$x(ft,a.app,a.three):null,s.search("light")>-1?SN(ft,a.app,a.three):null,n?Vx(ft,a.app,a.three):null]})]})},e)},"Inspector")}class wN extends W.Component{app;autoClear=!0;autoClearColor=!0;autoClearDepth=!0;autoClearStencil=!0;outputColorSpace=x.SRGBColorSpace;localClippingEnabled=!1;clearColor=new x.Color(0);clearAlpha=1;toneMapping=x.NoToneMapping;toneMappingExposure=1;type="";constructor(e){super(e),this.app=e.app;const t=localStorage.getItem(this.expandedName),s=t!==null?t==="open":!1;if(this.state={expanded:s,lastUpdated:Date.now()},this.saveExpanded(s),et.instance){const i=et.instance.renderer;i&&(this.autoClear=i.autoClear,this.autoClearColor=i.autoClearColor,this.autoClearDepth=i.autoClearDepth,this.autoClearStencil=i.autoClearStencil,this.clearAlpha=i.getClearAlpha(),this.toneMapping=i.toneMapping,this.toneMappingExposure=i.toneMappingExposure,i instanceof x.WebGLRenderer&&(this.localClippingEnabled=i.localClippingEnabled,i.getClearColor(this.clearColor)))}this.app.addEventListener(Q.ADD_RENDERER,this.onAddRenderer)}componentwillunmount(){this.app.removeEventListener(Q.ADD_RENDERER,this.onAddRenderer)}onAddRenderer=e=>{const t=e.value;if(this.autoClear=t.autoClear,this.autoClearColor=t.autoClearColor,this.autoClearDepth=t.autoClearDepth,this.autoClearStencil=t.autoClearStencil,this.outputColorSpace=t.outputColorSpace,this.localClippingEnabled=t.localClippingEnabled,this.clearAlpha=t.clearAlpha,this.type=t.type,this.toneMapping=t.toneMapping,this.toneMappingExposure=t.toneMappingExposure,this.clearColor.setStyle(t.clearColor,x.LinearSRGBColorSpace),x.ColorManagement.enabled=t.colorManagement,et.instance){const s=et.instance.renderer;s&&(s.autoClearColor=this.autoClearColor,s.outputColorSpace=this.outputColorSpace,s.localClippingEnabled=this.localClippingEnabled,s.toneMapping=this.toneMapping,s.toneMappingExposure=this.toneMappingExposure,s.setClearColor(t.clearColor,this.clearAlpha))}this.setState({lastUpdated:Date.now()})};render(){const e=()=>{if(et.instance){const t=et.instance.renderer;t&&(t.autoClearColor=this.autoClearColor,t.outputColorSpace=this.outputColorSpace,t.localClippingEnabled=this.localClippingEnabled,t.toneMapping=this.toneMapping,t.toneMappingExposure=this.toneMappingExposure,t.setClearColor(this.clearColor.getStyle(),this.clearAlpha),this.props.three.updateRenderer({autoClear:this.autoClear,autoClearColor:this.autoClearColor,autoClearDepth:this.autoClearDepth,autoClearStencil:this.autoClearStencil,outputColorSpace:this.outputColorSpace,localClippingEnabled:this.localClippingEnabled,clearAlpha:this.clearAlpha,clearColor:this.clearColor.getStyle(),colorManagement:x.ColorManagement.enabled,toneMapping:this.toneMapping,toneMappingExposure:this.toneMappingExposure}))}};return C.jsx(cs,{app:this.app,title:"Renderer",expanded:this.state.expanded,items:[{type:"boolean",title:"Auto Clear",value:this.autoClear,onChange:(t,s)=>{this.autoClear=s}},{type:"boolean",title:"Auto Clear Color",value:this.autoClearColor,onChange:(t,s)=>{this.autoClearColor=s,e()}},{type:"boolean",title:"Auto Clear Depth",value:this.autoClearDepth,onChange:(t,s)=>{this.autoClearDepth=s,e()}},{type:"boolean",title:"Auto Clear Stencil",value:this.autoClearStencil,onChange:(t,s)=>{this.autoClearStencil=s,e()}},{type:"boolean",title:"Local Clipping",value:this.localClippingEnabled,onChange:(t,s)=>{this.localClippingEnabled=s,e()}},{type:"color",title:"Clear Color",value:`#${this.clearColor.getHexString()}`,onChange:(t,s)=>{this.clearColor.setStyle(s),e()}},{type:"range",title:"Clear Alpha",min:0,max:1,step:.01,value:this.clearAlpha,onChange:(t,s)=>{this.clearAlpha=s,e()}},{type:"boolean",title:"Clear Management",value:x.ColorManagement.enabled,onChange:(t,s)=>{x.ColorManagement.enabled=s,e()}},{type:"option",title:"Color Space",value:this.outputColorSpace,options:[{title:"No Color Space",value:x.NoColorSpace},{title:"SRB Color Space",value:x.SRGBColorSpace},{title:"Linear SRB Color Space",value:x.LinearSRGBColorSpace}],onChange:(t,s)=>{this.outputColorSpace=s,e()}},{type:"option",title:"Tone Mapping",value:this.toneMapping,options:[{title:"None ",value:x.NoToneMapping},{title:"Linear ",value:x.LinearToneMapping},{title:"Reinhard",value:x.ReinhardToneMapping},{title:"Cineon ",value:x.CineonToneMapping},{title:"ACES Filmic",value:x.ACESFilmicToneMapping},{title:"AgX",value:x.AgXToneMapping},{title:"Neutral",value:x.NeutralToneMapping},{title:"Custom",value:x.CustomToneMapping}],onChange:(t,s)=>{this.toneMapping=s,e()}},{type:"range",title:"Tone Mapping Exposure",value:this.toneMappingExposure,min:0,max:2,step:.01,onChange:(t,s)=>{this.toneMappingExposure=s,e()}},{type:"string",title:"Type",value:this.type,disabled:!0}],onToggle:t=>{this.setState({expanded:t}),this.saveExpanded(t)}},Math.random())}saveExpanded(e){localStorage.setItem(this.expandedName,e?"open":"closed")}get expandedName(){return`${this.props.three.app.appID}_renderer`}}function Vy(a){const[e]=W.useState([]),[t]=W.useState([]),[s,i]=W.useState(0),n=l=>{const c=l.value;e.push(c),t.push(C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random())),i(Date.now())},r=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e[h]=c,t[h]=C.jsx(fa,{app:a.app,label:`Scene: ${c.name}`,scene:c,open:!0,onRefresh:()=>{a.three.refreshScene(c.name)},children:C.jsx(hh,{app:a.app,child:c,scene:c,three:a.three})},Math.random()),i(Date.now());return}},o=l=>{const c=l.value;for(let h=0;h<e.length;h++)if(c.uuid===e[h].uuid){e.splice(h,1),t.splice(h,1),i(Date.now());return}};return W.useEffect(()=>(a.app.addEventListener(Q.ADD_SCENE,n),a.app.addEventListener(Q.REFRESH_SCENE,r),a.app.addEventListener(Q.REMOVE_SCENE,o),()=>{a.app.removeEventListener(Q.ADD_SCENE,n),a.app.removeEventListener(Q.REFRESH_SCENE,r),a.app.removeEventListener(Q.REMOVE_SCENE,o)}),[]),C.jsxs("div",{id:"SidePanel",children:[C.jsx("div",{className:"scenes",children:t},s),C.jsx(Gy,{app:a.app,three:a.three}),C.jsx(wN,{app:a.app,three:a.three}),C.jsx(Re,{app:a.app,three:a.three})]})}function EN(a){return W.useEffect(()=>{function e(o){let l=null;return a.three.scenes.forEach(c=>{o.search(c.uuid)>-1&&(l=c)}),l}const t=o=>{const l=o.value,c=e(l);if(!c){console.log(`Hermes - can't find scene for object: ${l}`,a.three.scenes);return}const h=c.getObjectByProperty("uuid",l);h!==void 0?a.three.setObject(h):console.log(`Hermes - can't find object: ${l}`,c)},s=(o,l,c)=>{const h=e(o);if(!h){console.log(`Hermes - can't find scene to set object: ${o}, ${l}`,a.three.scenes);return}const u=h?.getObjectByProperty("uuid",o);u!==void 0?qe(u,l,c):console.log(`Hermes - can't set object: ${o}`,h)},i=o=>{const l=o.value,{key:c,value:h,uuid:u}=l;s(u,c,h)},n=o=>{const l=o.value,c=e(l.uuid);if(!c){console.log(`Hermes - can't create texture, can't find scene: ${l.uuid}`);return}const h=c?.getObjectByProperty("uuid",l.uuid);if(h!==void 0){const u=d=>{const p=l.key.split(".");switch(p.length){case 1:h[p[0]]=d;break;case 2:h[p[0]][p[1]]=d;break;case 3:h[p[0]][p[1]][p[2]]=d;break;case 4:h[p[0]][p[1]][p[2]][p[3]]=d;break;case 5:h[p[0]][p[1]][p[2]][p[3]][p[4]]=d;break}h.material.needsUpdate=!0};l.value.src.length>0?rm(l.value.src).then(d=>{d.offset.set(l.value.offset[0],l.value.offset[1]),d.repeat.set(l.value.repeat[0],l.value.repeat[1]),u(d)}):u(null)}},r=o=>{const{key:l,uuid:c,value:h,subitem:u}=o.value,p=e(c)?.getObjectByProperty("uuid",c);if(p!==void 0)try{u!==void 0?nx(p,u)[l](h):p[l](h)}catch(f){console.log("Error requesting method:"),console.log(f),console.log(l),console.log(h)}};return a.app.addEventListener(Q.GET_OBJECT,t),a.app.addEventListener(Q.UPDATE_OBJECT,i),a.app.addEventListener(Q.CREATE_TEXTURE,n),a.app.addEventListener(Q.REQUEST_METHOD,r),()=>{a.app.removeEventListener(Q.GET_OBJECT,t),a.app.removeEventListener(Q.UPDATE_OBJECT,i),a.app.removeEventListener(Q.CREATE_TEXTURE,n),a.app.removeEventListener(Q.REQUEST_METHOD,r)}},[]),null}function Hy(a){return C.jsxs("div",{className:"editor",ref:a.ref,style:a.style,children:[C.jsx("div",{className:"header",children:a.header}),a.children,C.jsx("div",{className:"footer",children:a.footer})]})}function MN(a){return C.jsx(Hy,{children:C.jsxs(C.Fragment,{children:[C.jsx(et,{app:a.app,three:a.three,scenes:a.scenes,onSceneResize:a.onSceneResize,onSceneSet:a.onSceneSet,onSceneUpdate:a.onSceneUpdate}),C.jsx(Vy,{app:a.app,three:a.three})]})})}exports.Accordion=fa;exports.AppRunner=q0;exports.Application=j0;exports.BaseRemote=ol;exports.BaseScene=Y0;exports.ChildObject=Zh;exports.ContainerObject=hh;exports.Draggable=om;exports.DraggableItem=am;exports.Dropdown=lm;exports.DropdownItem=cm;exports.Editor=Hy;exports.ElementProxy=W0;exports.ElementProxyReceiver=nm;exports.ExportTexture=Ri;exports.Inspector=Gy;exports.MultiView=et;exports.NavButton=Xh;exports.ProxyManager=$0;exports.QualityType=jh;exports.RemoteComponents=X0;exports.RemoteTheatre=ex;exports.RemoteThree=ax;exports.SceneInspector=EN;exports.SidePanel=Vy;exports.Spline=Lo;exports.SplineEditor=zy;exports.ThreeEditor=MN;exports.ToolEvents=Q;exports.Transform=xt;exports.WebworkerEventHandlers=V0;exports.capitalize=pa;exports.clamp=Ti;exports.clearComposerGroups=F0;exports.colorToHex=ah;exports.copyToClipboard=Kf;exports.cubicBezier=N0;exports.customizeTheatreElements=Q0;exports.damp=w0;exports.defaultTheatreCallback=g0;exports.detectMaxFrameRate=sm;exports.detectSettings=im;exports.dispose=ii;exports.disposeMaterial=qh;exports.disposeTexture=oh;exports.distance=v0;exports.generateCubemap=O0;exports.hierarchyUUID=ko;exports.inspectComposer=D0;exports.isColor=em;exports.map=S0;exports.mix=rr;exports.noop=da;exports.normalize=Uo;exports.parseModelLite=P0;exports.randomID=Jf;exports.resetThreeObjects=lh;exports.round=ss;exports.roundTo=E0;exports.theatreEditorApp=Z0;
|
package/dist/hermes.es.js
CHANGED
|
@@ -2686,8 +2686,10 @@ function ol(a) {
|
|
|
2686
2686
|
] });
|
|
2687
2687
|
}
|
|
2688
2688
|
function ag(a) {
|
|
2689
|
-
|
|
2690
|
-
|
|
2689
|
+
if (a.child === void 0)
|
|
2690
|
+
return console.log("Hermes - No child attached"), null;
|
|
2691
|
+
const e = Ge(null), [t, s] = Re(!1), i = a.child.children.length > 0, n = [];
|
|
2692
|
+
return a.child.children.length > 0 && a.child.children.map((r, o) => {
|
|
2691
2693
|
n.push(/* @__PURE__ */ C.jsx(ag, { app: a.app, child: r, three: a.three }, o));
|
|
2692
2694
|
}), wn(() => {
|
|
2693
2695
|
if (a.child) {
|
|
@@ -2698,7 +2700,7 @@ function ag(a) {
|
|
|
2698
2700
|
} else
|
|
2699
2701
|
console.log(`Hermes - Can't find Scene: ${a.child.uuid}`);
|
|
2700
2702
|
}
|
|
2701
|
-
}, [t]), /* @__PURE__ */ C.
|
|
2703
|
+
}, [t]), /* @__PURE__ */ C.jsxs("div", { className: "childObject", children: [
|
|
2702
2704
|
/* @__PURE__ */ C.jsxs("div", { className: "child", children: [
|
|
2703
2705
|
i ? /* @__PURE__ */ C.jsx(
|
|
2704
2706
|
"button",
|
|
@@ -2720,7 +2722,7 @@ function ag(a) {
|
|
|
2720
2722
|
left: i ? "20px" : "5px"
|
|
2721
2723
|
},
|
|
2722
2724
|
onClick: () => {
|
|
2723
|
-
a.child !== void 0
|
|
2725
|
+
a.child !== void 0 ? (a.three.getObject(a.child.uuid), !t && i && s(!0)) : console.log("Hermes - No child attached...");
|
|
2724
2726
|
},
|
|
2725
2727
|
children: a.child.name.length > 0 ? `${a.child.name} (${a.child.type})` : `${a.child.type}::${a.child.uuid}`
|
|
2726
2728
|
}
|
|
@@ -2749,7 +2751,7 @@ function ag(a) {
|
|
|
2749
2751
|
/* @__PURE__ */ C.jsx("div", { className: `icon ${E_(a.child)}` })
|
|
2750
2752
|
] }),
|
|
2751
2753
|
/* @__PURE__ */ C.jsx("div", { className: t ? "open" : "", children: /* @__PURE__ */ C.jsx("div", { className: "container", children: n }) })
|
|
2752
|
-
] }, Math.random())
|
|
2754
|
+
] }, Math.random());
|
|
2753
2755
|
}
|
|
2754
2756
|
function ep(a) {
|
|
2755
2757
|
const e = [];
|
|
@@ -43045,7 +43047,7 @@ class ht extends Va {
|
|
|
43045
43047
|
blWindow;
|
|
43046
43048
|
brWindow;
|
|
43047
43049
|
constructor(e) {
|
|
43048
|
-
super(e), this.app = e.app, this.app.addEventListener(K.ADD_RENDERER, this.setupRenderer), this.scene = new yu(), this.scene.name = this.scene.uuid = "
|
|
43050
|
+
super(e), this.app = e.app, this.app.addEventListener(K.ADD_RENDERER, this.setupRenderer), this.scene = new yu(), this.scene.name = this.scene.uuid = "", this.canvasRef = Mi(), this.containerRef = Mi(), this.tlWindow = Mi(), this.trWindow = Mi(), this.blWindow = Mi(), this.brWindow = Mi();
|
|
43049
43051
|
const t = e.three.app.appID, s = localStorage, i = s.getItem(`${t}_mode`);
|
|
43050
43052
|
this.state = {
|
|
43051
43053
|
mode: i !== null ? i : "Single",
|
|
@@ -43323,7 +43325,7 @@ class ht extends Va {
|
|
|
43323
43325
|
}), this.grid.visible = !1), this.renderer && (this.renderer.autoClear = !1, this.renderer.shadowMap.enabled = !0, this.renderer.setPixelRatio(devicePixelRatio), this.renderer.setClearColor(0), this.resize(), this.props.three.renderer = this.renderer);
|
|
43324
43326
|
};
|
|
43325
43327
|
setupScene() {
|
|
43326
|
-
this.
|
|
43328
|
+
this.helpersContainer.name = "helpers", this.scene.add(this.helpersContainer), this.grid.position.y = -1, this.scene.add(this.grid), this.interactionHelper.name = "interactionHelper", this.interactionHelper.visible = !1, this.helpersContainer.add(this.interactionHelper);
|
|
43327
43329
|
const e = (n, r) => {
|
|
43328
43330
|
const o = new Nh(-100, 100, 100, -100, 0, 3e3);
|
|
43329
43331
|
return o.name = n, o.position.copy(r), o.lookAt(0, 0, 0), this.cameras.set(n, o), o;
|
|
@@ -43482,7 +43484,11 @@ class ht extends Va {
|
|
|
43482
43484
|
}
|
|
43483
43485
|
};
|
|
43484
43486
|
onSetSelectedItem = (e) => {
|
|
43485
|
-
this.selectedItem !== void 0 && this.updateSelectedItemHelper(!1), this.selectedItem = this.currentScene.getObjectByProperty("uuid", e.value.uuid), this.selectedItem
|
|
43487
|
+
if (this.selectedItem !== void 0 && this.updateSelectedItemHelper(!1), this.selectedItem = this.currentScene.getObjectByProperty("uuid", e.value.uuid), this.selectedItem === void 0) {
|
|
43488
|
+
console.log(`Hermes - Can't find selected item: ${e.value.uuid}, ${e.value.name}`);
|
|
43489
|
+
return;
|
|
43490
|
+
}
|
|
43491
|
+
this.currentTransform !== void 0 && (this.currentTransform.removeEventListener("objectChange", this.onUpdateTransform), Pt.instance.remove(this.currentTransform.getHelper().name)), this.currentTransform = Pt.instance.add(e.value.name), this.currentTransform.attach(this.selectedItem), this.helpersContainer.add(this.currentTransform.getHelper()), this.currentTransform.addEventListener("objectChange", this.onUpdateTransform), this.updateSelectedItemHelper(!0);
|
|
43486
43492
|
};
|
|
43487
43493
|
updateSelectedItemHelper(e) {
|
|
43488
43494
|
if (this.selectedItem !== void 0)
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"module": "./dist/hermes.esm.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"type": "module",
|
|
10
|
-
"version": "0.0.
|
|
10
|
+
"version": "0.0.157",
|
|
11
11
|
"homepage": "https://github.com/tomorrowevening/hermes#readme",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/tomorrowevening/hermes/issues"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ChildObjectProps } from './types';
|
|
2
|
-
export default function ChildObject(props: ChildObjectProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export default function ChildObject(props: ChildObjectProps): import("react/jsx-runtime").JSX.Element | null;
|