three-live 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +36 -0
- package/dist/three-author-engine.js +86 -62
- package/dist/three-author.cjs +84 -60
- package/dist/three-author.d.ts +36 -0
- package/dist/three-author.js +83 -59
- package/dist/three-convert.cjs +78 -58
- package/dist/three-convert.d.ts +36 -0
- package/dist/three-convert.js +77 -57
- package/dist/three-live-animation.cjs +8 -9
- package/dist/three-live-animation.d.ts +36 -0
- package/dist/three-live-animation.js +7 -8
- package/dist/three-live-animation.min.js +6 -7
- package/dist/three-live-cad.cjs +3 -4
- package/dist/three-live-cad.d.ts +36 -0
- package/dist/three-live-cad.js +2 -3
- package/dist/three-live-cad.min.js +3 -4
- package/dist/three-live-cli.js +231 -0
- package/dist/three-live-element.cjs +17 -20
- package/dist/three-live-element.d.ts +36 -0
- package/dist/three-live-element.js +16 -19
- package/dist/three-live-full.cjs +110 -86
- package/dist/three-live-full.js +107 -83
- package/dist/three-live-full.min.js +110 -86
- package/dist/three-live-studio.cjs +19 -20
- package/dist/three-live-studio.d.ts +36 -0
- package/dist/three-live-studio.js +18 -19
- package/dist/three-live-studio.min.js +18 -19
- package/dist/three-live-viewer.cjs +17 -20
- package/dist/three-live-viewer.d.ts +36 -0
- package/dist/three-live-viewer.js +16 -19
- package/dist/three-live-viewer.min.js +17 -20
- package/dist/three-live.cjs +87 -63
- package/dist/three-live.js +86 -62
- package/dist/three-live.min.js +86 -62
- package/dist/three-view.cjs +17 -20
- package/dist/three-view.d.ts +36 -0
- package/dist/three-view.js +16 -19
- package/dist/three-xr.cjs +78 -58
- package/dist/three-xr.d.ts +36 -0
- package/dist/three-xr.js +77 -57
- package/package.json +7 -1
package/dist/three-author.js
CHANGED
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
function Zt(n,e,t){let r=[],i=new Map,s=[],o=[],l=[],a=new Map,u=f=>{let E=i.get(f);return E===void 0&&(E=r.length,r.push({op:f}),i.set(f,E)),E},c=f=>{let E=a.get(f);return E===void 0&&(E=l.length,l.push({id:f}),a.set(f,E)),E},h=(f,E={})=>s.push({declaration:u(f),...E})-1,m=(f,E,x)=>o.push({id:f,type:E,value:x})-1,b=f=>({node:f,socket:"value"}),g=t?.interactivity??t?.gltfExtensions?.KHR_interactivity;if(g&&typeof g=="object"){let f=Array.isArray(g.graphs)?g.graphs[g.graph??0]:g;if(f&&Array.isArray(f.nodes)){let E=Array.isArray(f.declarations)?f.declarations:[];for(let x of E)x?.op&&u(x.op);Array.isArray(f.variables)&&o.push(...f.variables);for(let x of f.events||[])x?.id&&c(x.id);for(let x of f.nodes){if(!x||typeof x!="object")continue;let _=x.op||(typeof x.declaration=="number"?E[x.declaration]?.op:"");s.push(_?{...x,declaration:u(_)}:{...x})}}}let d=(f,E,x="translation")=>x==="baseColorFactor"||x==="metallicFactor"||x==="roughnessFactor"?`/materials/${Math.max(0,E)}/pbrMetallicRoughness/${x}`:x==="emissiveFactor"||x==="alphaCutoff"?`/materials/${Math.max(0,E)}/${x}`:x==="visible"?`/nodes/${f}/extensions/KHR_node_visibility/visible`:`/nodes/${f}/${x}`,w=new Map;n.forEach((f,E)=>{typeof f?.name=="string"&&!w.has(f.name)&&w.set(f.name,E)});let C=(f,E)=>typeof f.target=="string"&&w.has(f.target)?w.get(f.target):typeof f.targetNode=="number"?f.targetNode:E,N=f=>{let E=n[f];return(typeof E?.mesh=="number"?e[E.mesh]?.primitives?.[0]?.material:0)??0};for(let f=0;f<n.length;f++){let E=n[f],x=E?.extras?.interactivity;if(!x||typeof x!="object")continue;let _=(typeof E.mesh=="number"?e[E.mesh]?.primitives?.[0]?.material:0)??0,D=M=>{let I=Array.isArray(M)?M:[M],p=[];for(let A=0;A<I.length;A++){let T=I[A];if(!T||typeof T!="object")continue;let R=T.action||"interpolate",F=typeof T.duration=="number"?T.duration:.35;if(R==="toggleTransform"){let P=T.property==="rotation"||T.property==="scale"?T.property:"translation",B=P==="rotation"?E.rotation||[0,0,0,1]:P==="scale"?E.scale||[1,1,1]:E.translation||[0,0,0],k=`/nodes/${f}/${P}`,O=m(`__toggle_${f}_${A}`,"bool",!1),S=h("variable/get",{configuration:{variable:O}}),G=h("math/not",{values:{a:b(S)}}),z=h("variable/set",{configuration:{variable:O},values:{value:b(G)}}),U=h("pointer/interpolate",{configuration:{pointer:k},values:{value:{value:Array.isArray(T.to)?T.to:B},duration:{value:F}}}),H=h("pointer/interpolate",{configuration:{pointer:k},values:{value:{value:Array.isArray(T.from)?T.from:B},duration:{value:F}}});s[z].flows={out:{node:h("flow/branch",{values:{condition:b(S)},flows:{true:{node:U},false:{node:H}}})}},p.push(z)}else if(R==="interpolate"){let P=T.to??T.value;if(P===void 0)continue;let B={value:{value:P},duration:{value:F}};T.from!==void 0&&(B.from={value:T.from}),p.push(h("pointer/interpolate",{configuration:{pointer:typeof T.pointer=="string"?T.pointer:d(C(T,f),N(C(T,f)),T.property)},values:B}))}else if(R==="setProperty"){if(T.value===void 0)continue;p.push(h("pointer/set",{configuration:{pointer:typeof T.pointer=="string"?T.pointer:d(C(T,f),N(C(T,f)),T.property)},values:{value:{value:T.value}}}))}else if(R==="toggleVisibility"){let P=C(T,f),B=m(`__vis_${P}_${A}`,"bool",!0),k=h("variable/get",{configuration:{variable:B}}),O=h("math/not",{values:{a:b(k)}}),S=h("variable/set",{configuration:{variable:B},values:{value:b(O)}});s[S].flows={out:{node:h("pointer/set",{configuration:{pointer:`/nodes/${P}/extensions/KHR_node_visibility/visible`},values:{value:b(k)}})}},p.push(S)}else if(R==="cycleMaterialColor"&&Array.isArray(T.colors)&&T.colors.length>0){let P=typeof T.duration=="number"?T.duration:.25,B=`/materials/${Math.max(0,_)}/pbrMetallicRoughness/baseColorFactor`,k=m(`__color_idx_${f}_${A}`,"int",0),O=h("variable/get",{configuration:{variable:k}}),S=h("math/add",{values:{a:b(O),b:{value:1}}}),G=h("math/rem",{values:{a:b(S),b:{value:T.colors.length}}}),z=h("variable/set",{configuration:{variable:k},values:{value:b(G)}}),U={};for(let H=0;H<T.colors.length;H++){let L=T.colors[H],V=Array.isArray(L)&&L.length>=3?[L[0],L[1],L[2],L[3]??1]:[1,1,1,1];U[String(H)]={node:P>0?h("pointer/interpolate",{configuration:{pointer:B},values:{value:{value:V},duration:{value:P}}}):h("pointer/set",{configuration:{pointer:B},values:{value:{value:V}}})}}s[z].flows={out:{node:h("flow/switch",{values:{selection:b(O)},flows:U})}},p.push(z)}else if(R==="playAnimation")p.push(h("animation/start",{configuration:{animation:T.animation??T.clip??0}}));else if(R==="stopAnimation")p.push(h("animation/stop"));else if(R==="sendEvent"){let P={};for(let[B,k]of Object.entries(T.values||{}))P[B]={value:k};p.push(h("event/send",{configuration:{event:c(String(T.event??T.id??"custom"))},values:P}))}}if(!p.length)return null;if(p.length===1)return p[0];let y={};return p.forEach((A,T)=>{y[String(T)]={node:A}}),h("flow/sequence",{flows:y})},v=(M,I,p)=>{let y=D(I);y!==null&&h(M,{...p?{configuration:p}:{},flows:{out:{node:y}}})};if(x.onSelect&&v("pointer/onSelect",x.onSelect,{nodeIndex:f}),x.onHoverIn&&v("pointer/onHoverIn",x.onHoverIn,{nodeIndex:f}),x.onHoverOut&&v("pointer/onHoverOut",x.onHoverOut,{nodeIndex:f}),x.onStart&&v("event/onStart",x.onStart),x.onReceive&&typeof x.onReceive=="object")for(let[M,I]of Object.entries(x.onReceive))v("event/receive",I,{event:c(M)})}return s.length?{graphs:[{declarations:r,nodes:s,variables:o,events:l}],graph:0}:null}var Jt='SecurityError: Client-modified script compilation (Use Case 1) is disabled by default to satisfy strict CSP and Trusted Types requirements. Use script-src="..." or loadScriptFromSrc(url) for server-generated scripts (Use Case 2), or explicitly opt in via ThreeLiveElement.allowClientScripts = true (or the allow-client-scripts attribute).',Qt="Security Error: client-side scripts require allow-client-scripts opt-in.";var ze="__THREE_LIVE_REGISTRY__";function Q(){let n=typeof globalThis<"u"?globalThis:{};if(!n[ze]){let e={plugins:[],decoders:new Map};try{Object.defineProperty(n,ze,{value:e,writable:!1,configurable:!1,enumerable:!1})}catch{n[ze]=e}}return n[ze]}var ie=Q().plugins;function en(n){let e=Q().plugins;e.some(t=>t.name===n.name)||e.push(n),n.onRegister?.()}function tn(){return Q().plugins}function J(){let n=new Float32Array(16);return n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function Ge(n,e,t,r,i){let s=1/Math.tan(e/2);n.fill(0),n[0]=s/t,n[5]=s,n[11]=-1;let o=1/(r-i);return n[10]=(i+r)*o,n[14]=2*i*r*o,n}function Re(n,e,t,r){let[i,s,o]=e,[l,a,u]=r,[c,h,m]=t,b=i-c,g=s-h,d=o-m,w=Math.hypot(b,g,d);w<=1e-5?(b=0,g=0,d=1):(b/=w,g/=w,d/=w);let C=a*d-u*g,N=u*b-l*d,f=l*g-a*b;w=Math.hypot(C,N,f),w<=1e-5?(C=0,N=0,f=0):(C/=w,N/=w,f/=w);let E=g*f-d*N,x=d*C-b*f,_=b*N-g*C;return w=Math.hypot(E,x,_),w<=1e-5?(E=0,x=0,_=0):(E/=w,x/=w,_/=w),n[0]=C,n[1]=E,n[2]=b,n[3]=0,n[4]=N,n[5]=x,n[6]=g,n[7]=0,n[8]=f,n[9]=_,n[10]=d,n[11]=0,n[12]=-(C*i+N*s+f*o),n[13]=-(E*i+x*s+_*o),n[14]=-(b*i+g*s+d*o),n[15]=1,n}function ee(n,e,t){let r=e[0],i=e[1],s=e[2],o=e[3],l=e[4],a=e[5],u=e[6],c=e[7],h=e[8],m=e[9],b=e[10],g=e[11],d=e[12],w=e[13],C=e[14],N=e[15],f=t[0],E=t[1],x=t[2],_=t[3];return n[0]=f*r+E*l+x*h+_*d,n[1]=f*i+E*a+x*m+_*w,n[2]=f*s+E*u+x*b+_*C,n[3]=f*o+E*c+x*g+_*N,f=t[4],E=t[5],x=t[6],_=t[7],n[4]=f*r+E*l+x*h+_*d,n[5]=f*i+E*a+x*m+_*w,n[6]=f*s+E*u+x*b+_*C,n[7]=f*o+E*c+x*g+_*N,f=t[8],E=t[9],x=t[10],_=t[11],n[8]=f*r+E*l+x*h+_*d,n[9]=f*i+E*a+x*m+_*w,n[10]=f*s+E*u+x*b+_*C,n[11]=f*o+E*c+x*g+_*N,f=t[12],E=t[13],x=t[14],_=t[15],n[12]=f*r+E*l+x*h+_*d,n[13]=f*i+E*a+x*m+_*w,n[14]=f*s+E*u+x*b+_*C,n[15]=f*o+E*c+x*g+_*N,n}function Me(n,e,t,r){let i=e[0],s=e[1],o=e[2],l=e[3],a=i+i,u=s+s,c=o+o,h=i*a,m=i*u,b=i*c,g=s*u,d=s*c,w=o*c,C=l*a,N=l*u,f=l*c,E=r[0],x=r[1],_=r[2];return n[0]=(1-(g+w))*E,n[1]=(m+f)*E,n[2]=(b-N)*E,n[3]=0,n[4]=(m-f)*x,n[5]=(1-(h+w))*x,n[6]=(d+C)*x,n[7]=0,n[8]=(b+N)*_,n[9]=(d-C)*_,n[10]=(1-(h+g))*_,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function me(n,e,t=0){let r=e[0],i=e[1],s=e[2],o=e[4],l=e[5],a=e[6],u=e[8],c=e[9],h=e[10],m=h*l-a*c,b=-h*o+a*u,g=c*o-l*u,d=r*m+i*b+s*g;return!d||t>0&&(!Number.isFinite(d)||Math.abs(d)<=t)||(d=1/d,n[0]=m*d,n[1]=b*d,n[2]=g*d,n[3]=(-h*i+s*c)*d,n[4]=(h*r-s*u)*d,n[5]=(-c*r+i*u)*d,n[6]=(a*i-s*l)*d,n[7]=(-a*r+s*o)*d,n[8]=(l*r-i*o)*d),n}function nn(n,e){let t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],l=e[5],a=e[6],u=e[7],c=e[8],h=e[9],m=e[10],b=e[11],g=e[12],d=e[13],w=e[14],C=e[15],N=t*l-r*o,f=t*a-i*o,E=t*u-s*o,x=r*a-i*l,_=r*u-s*l,D=i*u-s*a,v=c*d-h*g,M=c*w-m*g,I=c*C-b*g,p=h*w-m*d,y=h*C-b*d,A=m*C-b*w,T=N*A-f*y+E*p+x*I-_*M+D*v;return T?(T=1/T,n[0]=(l*A-a*y+u*p)*T,n[1]=(i*y-r*A-s*p)*T,n[2]=(d*D-w*_+C*x)*T,n[3]=(m*_-h*D-b*x)*T,n[4]=(a*I-o*A-u*M)*T,n[5]=(t*A-i*I+s*M)*T,n[6]=(w*E-g*D-C*f)*T,n[7]=(c*D-m*E+b*f)*T,n[8]=(o*y-l*I+u*v)*T,n[9]=(r*I-t*y-s*v)*T,n[10]=(g*_-d*E+C*N)*T,n[11]=(h*E-c*_-b*N)*T,n[12]=(l*M-o*p-a*v)*T,n[13]=(t*p-r*M+i*v)*T,n[14]=(d*f-g*x-w*N)*T,n[15]=(c*x-h*f+m*N)*T,n):null}function ft(n,e,t,r,i){let s=i[0]*e+i[4]*t+i[8]*r+i[12],o=i[1]*e+i[5]*t+i[9]*r+i[13],l=i[2]*e+i[6]*t+i[10]*r+i[14],a=i[3]*e+i[7]*t+i[11]*r+i[15],u=a!==0?1/a:1;n[0]=s*u,n[1]=o*u,n[2]=l*u}function rn(n,e,t,r,i,s,o,l,a,u,c,h,m,b,g,d,w=0){let C=u-o,N=c-l,f=h-a,E=m-o,x=b-l,_=g-a,D=i*_-s*x,v=s*E-r*_,M=r*x-i*E,I=C*D+N*v+f*M;if(I>-1e-7&&I<1e-7)return!1;let p=1/I,y=n-o,A=e-l,T=t-a,R=p*(y*D+A*v+T*M);if(R<-w||R>1+w)return!1;let F=A*f-T*N,P=T*C-y*f,B=y*N-A*C,k=p*(r*F+i*P+s*B);if(k<-w||R+k>1+w)return!1;let O=p*(E*F+x*P+_*B);if(O>1e-4&&O<d.distance){d.distance=O,d.point=[n+r*O,e+i*O,t+s*O];let S=N*_-f*x,G=f*E-C*_,z=C*x-N*E,U=Math.hypot(S,G,z)||1;return d.normal=[S/U,G/U,z/U],!0}return!1}function He(n,e){let t=Array.isArray(n?.nodes)?n.nodes.length:0,r=[];for(let c=0;c<t;c++)r.push(J());if(t===0)return r;let i=new Set;for(let c of n.nodes)if(Array.isArray(c.children))for(let h of c.children)i.add(h);let s=new Set,o=128,l=(c,h,m=0)=>{if(m>o||c<0||c>=t||s.has(c))return;s.add(c);let b=n.nodes[c];if(!b)return;let g=J();if(e&&e[c])g.set(e[c]);else if(b.matrix&&b.matrix.length===16)g.set(b.matrix);else{let w=b.translation||[0,0,0],C=b.rotation||[0,0,0,1],N=b.scale||[1,1,1];Me(g,C,w,N)}let d=r[c];if(h?ee(d,h,g):d.set(g),Array.isArray(b.children))for(let w of b.children)typeof w=="number"&&l(w,d,m+1)},a=[],u=n.scenes&&n.scenes[n.scene!==void 0?n.scene:0];if(u&&Array.isArray(u.nodes))a.push(...u.nodes);else for(let c=0;c<t;c++)i.has(c)||a.push(c);for(let c of a)l(c,null);for(let c=0;c<t;c++)!i.has(c)&&!a.includes(c)&&l(c,null);return r}function Xe(n,e,t,r=!0){let i=[],s=null;try{for(let[o,l]of[[35633,e],[35632,t]]){let a=n.createShader(o);if(!a){if(r)throw new Error("Shader allocation failed");return null}if(i.push(a),n.shaderSource(a,l),n.compileShader(a),n.getShaderParameter&&!n.getShaderParameter(a,35713)){if(r)throw new Error(`Shader compile error: ${n.getShaderInfoLog(a)}`);return null}}if(s=n.createProgram(),!s){if(r)throw new Error("Program allocation failed");return null}for(let o of i)n.attachShader(s,o);if(n.linkProgram(s),n.getProgramParameter&&!n.getProgramParameter(s,35714)){let o=r?n.getProgramInfoLog(s):null;if(n.deleteProgram?.(s),s=null,r)throw new Error(`Program link error: ${o}`);return null}return s}finally{for(let o of i)s&&n.detachShader?.(s,o),n.deleteShader?.(o)}}var On={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};function dt(n,e,t,r){if(!t||t.bufferView===void 0)return null;let i=n.bufferViews?.[t.bufferView];if(!i)return null;let s=Number(t.count??0);if(!Number.isInteger(s)||s<=0)return null;let o=t.componentType??5126,l=On[o];if(!l)throw new RangeError(`glTF accessor has unsupported componentType ${o}`);let a=l*r,u=i.byteStride&&i.byteStride>0?i.byteStride:a,c=(i.byteOffset||0)+(t.byteOffset||0);if(!Number.isInteger(c)||c<0||u<a||c+(s-1)*u+a>e.byteLength)throw new RangeError(`glTF accessor reads past the end of the binary buffer (${e.byteLength} bytes)`);if(o===5126&&u===a&&c%4===0)return new Float32Array(e,c,s*r);let h=new DataView(e),m=t.normalized===!0,b=new Float32Array(s*r);for(let g=0;g<s;g++){let d=c+g*u;for(let w=0;w<r;w++){let C=d+w*l,N;switch(o){case 5126:N=h.getFloat32(C,!0);break;case 5120:N=h.getInt8(C),m&&(N=Math.max(N/127,-1));break;case 5121:N=h.getUint8(C),m&&(N/=255);break;case 5122:N=h.getInt16(C,!0),m&&(N=Math.max(N/32767,-1));break;case 5123:N=h.getUint16(C,!0),m&&(N/=65535);break;default:N=h.getUint32(C,!0),m&&(N/=4294967295)}b[g*r+w]=N}}return b}function sn(n,e){let t=Number(e.offset?.[0]??0)||0,r=Number(e.offset?.[1]??0)||0,i=Number(e.scale?.[0]??1),s=Number(e.scale?.[1]??1),o=Number(e.rotation??0)||0,l=Math.cos(o),a=Math.sin(o),u=(Number.isFinite(i)?i:1)*l,c=(Number.isFinite(i)?i:1)*a,h=-(Number.isFinite(s)?s:1)*a,m=(Number.isFinite(s)?s:1)*l;for(let b=0;b+1<n.length;b+=2){let g=n[b],d=n[b+1];n[b]=u*g+c*d+t,n[b+1]=h*g+m*d+r}}var cn=["neutral","reinhard","none","aces","agx"];function yt(n){let e=String(n??"").trim().toLowerCase();return cn.includes(e)?e:"neutral"}function Bn(n){return cn.indexOf(yt(n))}function Vn(n){return new TextDecoder().decode(n)}var un=Q().decoders;function zn(n,e){un.set(n.toLowerCase(),e)}function _e(n){return un.get(n.toLowerCase())}function ln(n){let e=ArrayBuffer.isView(n)?n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength):n,t=new DataView(e);if(e.byteLength<12)throw new Error(`Invalid GLB buffer size: ${e.byteLength} bytes`);let r=t.getUint32(0,!0);if(r!==1179937895){let m=t.getUint8(0);throw m===123||m===32||m===10||m===13?new Error("[three-live] Multi-file JSON .gltf is not supported for performance reasons. Please pack your asset into a single binary .glb file."):new Error(`Invalid GLB magic: 0x${r.toString(16)}`)}let i=t.getUint32(4,!0);if(i!==2)throw new Error(`Unsupported GLB version: ${i}`);let s=t.getUint32(8,!0),o=12,l=null,a=null;for(;o+8<=s&&o+8<=e.byteLength;){let m=t.getUint32(o,!0),b=t.getUint32(o+4,!0),g=o+8;if(g+m>e.byteLength)throw new Error(`Truncated GLB chunk: required ${g+m} bytes, buffer has ${e.byteLength}`);if(b===1313821514){let d=new Uint8Array(e,g,m),w=Vn(d);l=JSON.parse(w,(C,N)=>C==="__proto__"||C==="constructor"||C==="prototype"?void 0:N)}else b===5130562&&(a=e.slice(g,g+m));o=g+m}if(!l)throw new Error("Missing JSON chunk in GLB");let u=l.extensionsRequired||[];if(u.includes("KHR_draco_mesh_compression")&&!_e("draco"))throw new Error("Model requires KHR_draco_mesh_compression. Register a decoder via ThreeLiveElement.registerDecoder('draco', decoder).");for(let m of["EXT_meshopt_compression","KHR_meshopt_compression"])if(u.includes(m)&&!_e("meshopt"))throw new Error(`Model requires ${m}. Register a decoder via ThreeLiveElement.registerDecoder('meshopt', decoder).`);if(u.includes("KHR_texture_basisu")&&!_e("ktx2"))throw new Error("Model requires KHR_texture_basisu. Register a decoder via ThreeLiveElement.registerDecoder('ktx2', decoder).");let c=a||new ArrayBuffer(0),h={gltf:l,bin:c,animations:[]};for(let m of ie)m.onParseGLB?.(h);return h}function Gn(n){return typeof n=="object"&&n!==null&&"gltf"in n&&typeof n.gltf=="object"&&n.gltf!==null&&"bin"in n&&(n.bin instanceof ArrayBuffer||ArrayBuffer.isView(n.bin))}function Fe(n){if(Gn(n))return n;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return ln(n);throw new TypeError("Invalid 3D model input: expected GLBData ({ gltf, bin }) or binary GLB (ArrayBuffer / ArrayBufferView).")}var mn=`#version 300 es
|
|
16
|
+
*/function zr(e,t,i){let r=[],s=new Map,n=[],o=[],a=[],h=new Map,l=m=>{let p=s.get(m);return p===void 0&&(p=r.length,r.push({op:m}),s.set(m,p)),p},c=m=>{let p=h.get(m);return p===void 0&&(p=a.length,a.push({id:m}),h.set(m,p)),p},f=(m,p={})=>n.push({declaration:l(m),...p})-1,y=(m,p,v)=>o.push({id:m,type:p,value:v})-1,g=m=>({node:m,socket:"value"}),u=i?.interactivity??i?.gltfExtensions?.KHR_interactivity;if(u&&typeof u=="object"){let m=Array.isArray(u.graphs)?u.graphs[u.graph??0]:u;if(m&&Array.isArray(m.nodes)){let p=Array.isArray(m.declarations)?m.declarations:[];for(let v of p)v?.op&&l(v.op);Array.isArray(m.variables)&&o.push(...m.variables);for(let v of m.events||[])v?.id&&c(v.id);for(let v of m.nodes){if(!v||typeof v!="object")continue;let R=v.op||(typeof v.declaration=="number"?p[v.declaration]?.op:"");n.push(R?{...v,declaration:l(R)}:{...v})}}}let b=(m,p,v="translation")=>v==="baseColorFactor"||v==="metallicFactor"||v==="roughnessFactor"?`/materials/${Math.max(0,p)}/pbrMetallicRoughness/${v}`:v==="emissiveFactor"||v==="alphaCutoff"?`/materials/${Math.max(0,p)}/${v}`:v==="visible"?`/nodes/${m}/extensions/KHR_node_visibility/visible`:`/nodes/${m}/${v}`,w=new Map;e.forEach((m,p)=>{typeof m?.name=="string"&&!w.has(m.name)&&w.set(m.name,p)});let M=(m,p)=>typeof m.target=="string"&&w.has(m.target)?w.get(m.target):typeof m.targetNode=="number"?m.targetNode:p,x=m=>{let p=e[m];return(typeof p?.mesh=="number"?t[p.mesh]?.primitives?.[0]?.material:0)??0};for(let m=0;m<e.length;m++){let p=e[m],v=p?.extras?.interactivity;if(!v||typeof v!="object")continue;let R=(typeof p.mesh=="number"?t[p.mesh]?.primitives?.[0]?.material:0)??0,L=N=>{let _=Array.isArray(N)?N:[N],A=[];for(let C=0;C<_.length;C++){let d=_[C];if(!d||typeof d!="object")continue;let k=d.action||"interpolate",$=typeof d.duration=="number"?d.duration:.35;if(k==="toggleTransform"){let S=d.property==="rotation"||d.property==="scale"?d.property:"translation",D=S==="rotation"?p.rotation||[0,0,0,1]:S==="scale"?p.scale||[1,1,1]:p.translation||[0,0,0],T=`/nodes/${m}/${S}`,P=y(`__toggle_${m}_${C}`,"bool",!1),j=f("variable/get",{configuration:{variable:P}}),W=f("math/not",{values:{a:g(j)}}),V=f("variable/set",{configuration:{variable:P},values:{value:g(W)}}),Z=f("pointer/interpolate",{configuration:{pointer:T},values:{value:{value:Array.isArray(d.to)?d.to:D},duration:{value:$}}}),U=f("pointer/interpolate",{configuration:{pointer:T},values:{value:{value:Array.isArray(d.from)?d.from:D},duration:{value:$}}});n[V].flows={out:{node:f("flow/branch",{values:{condition:g(j)},flows:{true:{node:Z},false:{node:U}}})}},A.push(V)}else if(k==="interpolate"){let S=d.to??d.value;if(S===void 0)continue;let D={value:{value:S},duration:{value:$}};d.from!==void 0&&(D.from={value:d.from}),A.push(f("pointer/interpolate",{configuration:{pointer:typeof d.pointer=="string"?d.pointer:b(M(d,m),x(M(d,m)),d.property)},values:D}))}else if(k==="setProperty"){if(d.value===void 0)continue;A.push(f("pointer/set",{configuration:{pointer:typeof d.pointer=="string"?d.pointer:b(M(d,m),x(M(d,m)),d.property)},values:{value:{value:d.value}}}))}else if(k==="toggleVisibility"){let S=M(d,m),D=y(`__vis_${S}_${C}`,"bool",!0),T=f("variable/get",{configuration:{variable:D}}),P=f("math/not",{values:{a:g(T)}}),j=f("variable/set",{configuration:{variable:D},values:{value:g(P)}});n[j].flows={out:{node:f("pointer/set",{configuration:{pointer:`/nodes/${S}/extensions/KHR_node_visibility/visible`},values:{value:g(T)}})}},A.push(j)}else if(k==="cycleMaterialColor"&&Array.isArray(d.colors)&&d.colors.length>0){let S=typeof d.duration=="number"?d.duration:.25,D=`/materials/${Math.max(0,R)}/pbrMetallicRoughness/baseColorFactor`,T=y(`__color_idx_${m}_${C}`,"int",0),P=f("variable/get",{configuration:{variable:T}}),j=f("math/add",{values:{a:g(P),b:{value:1}}}),W=f("math/rem",{values:{a:g(j),b:{value:d.colors.length}}}),V=f("variable/set",{configuration:{variable:T},values:{value:g(W)}}),Z={};for(let U=0;U<d.colors.length;U++){let X=d.colors[U],O=Array.isArray(X)&&X.length>=3?[X[0],X[1],X[2],X[3]??1]:[1,1,1,1];Z[String(U)]={node:S>0?f("pointer/interpolate",{configuration:{pointer:D},values:{value:{value:O},duration:{value:S}}}):f("pointer/set",{configuration:{pointer:D},values:{value:{value:O}}})}}n[V].flows={out:{node:f("flow/switch",{values:{selection:g(P)},flows:Z})}},A.push(V)}else if(k==="playAnimation")A.push(f("animation/start",{configuration:{animation:d.animation??d.clip??0}}));else if(k==="stopAnimation")A.push(f("animation/stop"));else if(k==="sendEvent"){let S={};for(let[D,T]of Object.entries(d.values||{}))S[D]={value:T};A.push(f("event/send",{configuration:{event:c(String(d.event??d.id??"custom"))},values:S}))}}if(!A.length)return null;if(A.length===1)return A[0];let E={};return A.forEach((C,d)=>{E[String(d)]={node:C}}),f("flow/sequence",{flows:E})},I=(N,_,A)=>{let E=L(_);E!==null&&f(N,{...A?{configuration:A}:{},flows:{out:{node:E}}})};if(v.onSelect&&I("pointer/onSelect",v.onSelect,{nodeIndex:m}),v.onHoverIn&&I("pointer/onHoverIn",v.onHoverIn,{nodeIndex:m}),v.onHoverOut&&I("pointer/onHoverOut",v.onHoverOut,{nodeIndex:m}),v.onStart&&I("event/onStart",v.onStart),v.onReceive&&typeof v.onReceive=="object")for(let[N,_]of Object.entries(v.onReceive))I("event/receive",_,{event:c(N)})}return n.length?{graphs:[{declarations:r,nodes:n,variables:o,events:a}],graph:0}:null}var Vr='SecurityError: Client-modified script compilation (Use Case 1) is disabled by default to satisfy strict CSP and Trusted Types requirements. Use script-src="..." or loadScriptFromSrc(url) for server-generated scripts (Use Case 2), or explicitly opt in via ThreeLiveElement.allowClientScripts = true (or the allow-client-scripts attribute).',Or="Security Error: client-side scripts require allow-client-scripts opt-in.",Jt="__THREE_LIVE_REGISTRY__";function ut(){let e=typeof globalThis<"u"?globalThis:{};if(!e[Jt]){let t={plugins:[],decoders:new Map};try{Object.defineProperty(e,Jt,{value:t,writable:!1,configurable:!1,enumerable:!1})}catch{e[Jt]=t}}return e[Jt]}var mt=ut().plugins;function Br(e){let t=ut().plugins;t.some(i=>i.name===e.name)||t.push(e),e.onRegister?.()}function $r(){return ut().plugins}function ht(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function ge(e,t,i,r,s){let n=1/Math.tan(t/2);e.fill(0),e[0]=n/i,e[5]=n,e[11]=-1;let o=1/(r-s);return e[10]=(s+r)*o,e[14]=2*s*r*o,e}function Qt(e,t,i,r){let[s,n,o]=t,[a,h,l]=r,[c,f,y]=i,g=s-c,u=n-f,b=o-y,w=Math.hypot(g,u,b);w<=1e-5?(g=0,u=0,b=1):(g/=w,u/=w,b/=w);let M=h*b-l*u,x=l*g-a*b,m=a*u-h*g;w=Math.hypot(M,x,m),w<=1e-5?(M=0,x=0,m=0):(M/=w,x/=w,m/=w);let p=u*m-b*x,v=b*M-g*m,R=g*x-u*M;return w=Math.hypot(p,v,R),w<=1e-5?(p=0,v=0,R=0):(p/=w,v/=w,R/=w),e[0]=M,e[1]=p,e[2]=g,e[3]=0,e[4]=x,e[5]=v,e[6]=u,e[7]=0,e[8]=m,e[9]=R,e[10]=b,e[11]=0,e[12]=-(M*s+x*n+m*o),e[13]=-(p*s+v*n+R*o),e[14]=-(g*s+u*n+b*o),e[15]=1,e}function dt(e,t,i){let r=t[0],s=t[1],n=t[2],o=t[3],a=t[4],h=t[5],l=t[6],c=t[7],f=t[8],y=t[9],g=t[10],u=t[11],b=t[12],w=t[13],M=t[14],x=t[15],m=i[0],p=i[1],v=i[2],R=i[3];return e[0]=m*r+p*a+v*f+R*b,e[1]=m*s+p*h+v*y+R*w,e[2]=m*n+p*l+v*g+R*M,e[3]=m*o+p*c+v*u+R*x,m=i[4],p=i[5],v=i[6],R=i[7],e[4]=m*r+p*a+v*f+R*b,e[5]=m*s+p*h+v*y+R*w,e[6]=m*n+p*l+v*g+R*M,e[7]=m*o+p*c+v*u+R*x,m=i[8],p=i[9],v=i[10],R=i[11],e[8]=m*r+p*a+v*f+R*b,e[9]=m*s+p*h+v*y+R*w,e[10]=m*n+p*l+v*g+R*M,e[11]=m*o+p*c+v*u+R*x,m=i[12],p=i[13],v=i[14],R=i[15],e[12]=m*r+p*a+v*f+R*b,e[13]=m*s+p*h+v*y+R*w,e[14]=m*n+p*l+v*g+R*M,e[15]=m*o+p*c+v*u+R*x,e}function ye(e,t,i,r){let s=t[0],n=t[1],o=t[2],a=t[3],h=s+s,l=n+n,c=o+o,f=s*h,y=s*l,g=s*c,u=n*l,b=n*c,w=o*c,M=a*h,x=a*l,m=a*c,p=r[0],v=r[1],R=r[2];return e[0]=(1-(u+w))*p,e[1]=(y+m)*p,e[2]=(g-x)*p,e[3]=0,e[4]=(y-m)*v,e[5]=(1-(f+w))*v,e[6]=(b+M)*v,e[7]=0,e[8]=(g+x)*R,e[9]=(b-M)*R,e[10]=(1-(f+u))*R,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function Pt(e,t,i=0){let r=t[0],s=t[1],n=t[2],o=t[4],a=t[5],h=t[6],l=t[8],c=t[9],f=t[10],y=f*a-h*c,g=-f*o+h*l,u=c*o-a*l,b=r*y+s*g+n*u;return!b||i>0&&(!Number.isFinite(b)||Math.abs(b)<=i)||(b=1/b,e[0]=y*b,e[1]=g*b,e[2]=u*b,e[3]=(-f*s+n*c)*b,e[4]=(f*r-n*l)*b,e[5]=(-c*r+s*l)*b,e[6]=(h*s-n*a)*b,e[7]=(-h*r+n*o)*b,e[8]=(a*r-s*o)*b),e}function Gr(e,t){let i=t[0],r=t[1],s=t[2],n=t[3],o=t[4],a=t[5],h=t[6],l=t[7],c=t[8],f=t[9],y=t[10],g=t[11],u=t[12],b=t[13],w=t[14],M=t[15],x=i*a-r*o,m=i*h-s*o,p=i*l-n*o,v=r*h-s*a,R=r*l-n*a,L=s*l-n*h,I=c*b-f*u,N=c*w-y*u,_=c*M-g*u,A=f*w-y*b,E=f*M-g*b,C=y*M-g*w,d=x*C-m*E+p*A+v*_-R*N+L*I;return d?(d=1/d,e[0]=(a*C-h*E+l*A)*d,e[1]=(s*E-r*C-n*A)*d,e[2]=(b*L-w*R+M*v)*d,e[3]=(y*R-f*L-g*v)*d,e[4]=(h*_-o*C-l*N)*d,e[5]=(i*C-s*_+n*N)*d,e[6]=(w*p-u*L-M*m)*d,e[7]=(c*L-y*p+g*m)*d,e[8]=(o*E-a*_+l*I)*d,e[9]=(r*_-i*E-n*I)*d,e[10]=(u*R-b*p+M*x)*d,e[11]=(f*p-c*R-g*x)*d,e[12]=(a*N-o*A-h*I)*d,e[13]=(i*A-r*N+s*I)*d,e[14]=(b*m-u*v-w*x)*d,e[15]=(c*v-f*m+y*x)*d,e):null}function Ye(e,t,i,r,s){let n=s[0]*t+s[4]*i+s[8]*r+s[12],o=s[1]*t+s[5]*i+s[9]*r+s[13],a=s[2]*t+s[6]*i+s[10]*r+s[14],h=s[3]*t+s[7]*i+s[11]*r+s[15],l=h!==0?1/h:1;e[0]=n*l,e[1]=o*l,e[2]=a*l}function Hr(e,t,i,r,s,n,o,a,h,l,c,f,y,g,u,b,w=0){let M=l-o,x=c-a,m=f-h,p=y-o,v=g-a,R=u-h,L=s*R-n*v,I=n*p-r*R,N=r*v-s*p,_=M*L+x*I+m*N;if(_>-1e-7&&_<1e-7)return!1;let A=1/_,E=e-o,C=t-a,d=i-h,k=A*(E*L+C*I+d*N);if(k<-w||k>1+w)return!1;let $=C*m-d*x,S=d*M-E*m,D=E*x-C*M,T=A*(r*$+s*S+n*D);if(T<-w||k+T>1+w)return!1;let P=A*(p*$+v*S+R*D);if(P>1e-4&&P<b.distance){b.distance=P,b.point=[e+r*P,t+s*P,i+n*P];let j=x*R-m*v,W=m*p-M*R,V=M*v-x*p,Z=Math.hypot(j,W,V)||1;return b.normal=[j/Z,W/Z,V/Z],!0}return!1}function jr(e,t){let i=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let c=0;c<i;c++)r.push(ht());if(i===0)return r;let s=new Set;for(let c of e.nodes)if(Array.isArray(c.children))for(let f of c.children)s.add(f);let n=new Set,o=128,a=(c,f,y=0)=>{if(y>o||c<0||c>=i||n.has(c))return;n.add(c);let g=e.nodes[c];if(!g)return;let u=ht();if(t&&t[c])u.set(t[c]);else if(g.matrix&&g.matrix.length===16)u.set(g.matrix);else{let w=g.translation||[0,0,0],M=g.rotation||[0,0,0,1],x=g.scale||[1,1,1];ye(u,M,w,x)}let b=r[c];if(f?dt(b,f,u):b.set(u),Array.isArray(g.children))for(let w of g.children)typeof w=="number"&&a(w,b,y+1)},h=[],l=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(l&&Array.isArray(l.nodes))h.push(...l.nodes);else for(let c=0;c<i;c++)s.has(c)||h.push(c);for(let c of h)a(c,null);for(let c=0;c<i;c++)!s.has(c)&&!h.includes(c)&&a(c,null);return r}var Wr={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};function Ze(e,t,i,r){if(!i||i.bufferView===void 0)return null;let s=e.bufferViews?.[i.bufferView];if(!s)return null;let n=Number(i.count??0);if(!Number.isInteger(n)||n<=0)return null;let o=i.componentType??5126,a=Wr[o];if(!a)throw new RangeError(`glTF accessor has unsupported componentType ${o}`);let h=a*r,l=s.byteStride&&s.byteStride>0?s.byteStride:h,c=(s.byteOffset||0)+(i.byteOffset||0);if(!Number.isInteger(c)||c<0||l<h||c+(n-1)*l+h>t.byteLength)throw new RangeError(`glTF accessor reads past the end of the binary buffer (${t.byteLength} bytes)`);if(o===5126&&l===h&&c%4===0)return new Float32Array(t,c,n*r);let f=new DataView(t),y=i.normalized===!0,g=new Float32Array(n*r);for(let u=0;u<n;u++){let b=c+u*l;for(let w=0;w<r;w++){let M=b+w*a,x;switch(o){case 5126:x=f.getFloat32(M,!0);break;case 5120:x=f.getInt8(M),y&&(x=Math.max(x/127,-1));break;case 5121:x=f.getUint8(M),y&&(x/=255);break;case 5122:x=f.getInt16(M,!0),y&&(x=Math.max(x/32767,-1));break;case 5123:x=f.getUint16(M,!0),y&&(x/=65535);break;default:x=f.getUint32(M,!0),y&&(x/=4294967295)}g[u*r+w]=x}}return g}function Xr(e,t){let i=Number(t.offset?.[0]??0)||0,r=Number(t.offset?.[1]??0)||0,s=Number(t.scale?.[0]??1),n=Number(t.scale?.[1]??1),o=Number(t.rotation??0)||0,a=Math.cos(o),h=Math.sin(o),l=(Number.isFinite(s)?s:1)*a,c=(Number.isFinite(s)?s:1)*h,f=-(Number.isFinite(n)?n:1)*h,y=(Number.isFinite(n)?n:1)*a;for(let g=0;g+1<e.length;g+=2){let u=e[g],b=e[g+1];e[g]=l*u+c*b+i,e[g+1]=f*u+y*b+r}}function be(e,t,i,r=!0){let s=[],n=null;try{for(let[o,a]of[[35633,t],[35632,i]]){let h=e.createShader(o);if(!h){if(r)throw new Error("Shader allocation failed");return null}if(s.push(h),e.shaderSource(h,a),e.compileShader(h),e.getShaderParameter&&!e.getShaderParameter(h,35713)){if(r)throw new Error(`Shader compile error: ${e.getShaderInfoLog(h)}`);return null}}if(n=e.createProgram(),!n){if(r)throw new Error("Program allocation failed");return null}for(let o of s)e.attachShader(n,o);if(e.linkProgram(n),e.getProgramParameter&&!e.getProgramParameter(n,35714)){let o=r?e.getProgramInfoLog(n):null;if(e.deleteProgram?.(n),n=null,r)throw new Error(`Program link error: ${o}`);return null}return n}finally{for(let o of s)n&&e.detachShader?.(n,o),e.deleteShader?.(o)}}var Je=["neutral","reinhard","none","aces","agx"];function xe(e){let t=String(e??"").trim().toLowerCase();return Je.includes(t)?t:"neutral"}function qr(e){return Je.indexOf(xe(e))}function Kr(e){return new TextDecoder().decode(e)}var Qe=ut().decoders;function Yr(e,t){Qe.set(e.toLowerCase(),t)}function Vt(e){return Qe.get(e.toLowerCase())}function ti(e){let t=ArrayBuffer.isView(e)?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e,i=new DataView(t);if(t.byteLength<12)throw new Error(`Invalid GLB buffer size: ${t.byteLength} bytes`);let r=i.getUint32(0,!0);if(r!==1179937895){let y=i.getUint8(0);throw y===123||y===32||y===10||y===13?new Error("[three-live] Multi-file JSON .gltf is not supported for performance reasons. Please pack your asset into a single binary .glb file."):new Error(`Invalid GLB magic: 0x${r.toString(16)}`)}let s=i.getUint32(4,!0);if(s!==2)throw new Error(`Unsupported GLB version: ${s}`);let n=i.getUint32(8,!0),o=12,a=null,h=null;for(;o+8<=n&&o+8<=t.byteLength;){let y=i.getUint32(o,!0),g=i.getUint32(o+4,!0),u=o+8;if(u+y>t.byteLength)throw new Error(`Truncated GLB chunk: required ${u+y} bytes, buffer has ${t.byteLength}`);if(g===1313821514){let b=new Uint8Array(t,u,y),w=Kr(b);a=JSON.parse(w,(M,x)=>M==="__proto__"||M==="constructor"||M==="prototype"?void 0:x)}else g===5130562&&(h=t.slice(u,u+y));o=u+y}if(!a)throw new Error("Missing JSON chunk in GLB");let l=a.extensionsRequired||[];if(l.includes("KHR_draco_mesh_compression")&&!Vt("draco"))throw new Error("Model requires KHR_draco_mesh_compression. Register a decoder via ThreeLiveElement.registerDecoder('draco', decoder).");for(let y of["EXT_meshopt_compression","KHR_meshopt_compression"])if(l.includes(y)&&!Vt("meshopt"))throw new Error(`Model requires ${y}. Register a decoder via ThreeLiveElement.registerDecoder('meshopt', decoder).`);if(l.includes("KHR_texture_basisu")&&!Vt("ktx2"))throw new Error("Model requires KHR_texture_basisu. Register a decoder via ThreeLiveElement.registerDecoder('ktx2', decoder).");let c=h||new ArrayBuffer(0),f={gltf:a,bin:c,animations:[]};for(let y of mt)y.onParseGLB?.(f);return f}function Zr(e){return typeof e=="object"&&e!==null&&"gltf"in e&&typeof e.gltf=="object"&&e.gltf!==null&&"bin"in e&&(e.bin instanceof ArrayBuffer||ArrayBuffer.isView(e.bin))}function te(e){if(Zr(e))return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return ti(e);throw new TypeError("Invalid 3D model input: expected GLBData ({ gltf, bin }) or binary GLB (ArrayBuffer / ArrayBufferView).")}var ei=`#version 300 es
|
|
18
17
|
layout(location=0) in vec3 aPos;
|
|
19
18
|
layout(location=3) in vec3 aOff;
|
|
20
19
|
layout(location=1) in vec3 aNormal;
|
|
@@ -49,7 +48,7 @@ vec2 scaleUV=uUvTransform.zw;
|
|
|
49
48
|
if(scaleUV.x==0.0&&scaleUV.y==0.0)scaleUV=vec2(1.0);
|
|
50
49
|
vUV=aUV*scaleUV+uUvTransform.xy;
|
|
51
50
|
gl_Position=uMVP*vec4(aPosition,1.0);
|
|
52
|
-
}`,
|
|
51
|
+
}`,Jr=`#version 300 es
|
|
53
52
|
precision highp float;
|
|
54
53
|
in vec3 vNormal,vWorldPos;
|
|
55
54
|
in vec2 vUV;
|
|
@@ -66,7 +65,8 @@ uniform float uNormalScale,uOcclusionStrength;
|
|
|
66
65
|
uniform vec2 uViewportSize;
|
|
67
66
|
uniform vec4 uSectionPlane;
|
|
68
67
|
uniform int uToneMapping,uNumDirLights,uNumPointLights,uSectionEnabled;
|
|
69
|
-
uniform vec3 uDirLightDir[2],uDirLightColor[2],uPointLightPos[2],uPointLightColor[2];
|
|
68
|
+
uniform vec3 uDirLightDir[2],uDirLightColor[2],uPointLightPos[2],uPointLightColor[2],uPointLightSpotDir[2];
|
|
69
|
+
uniform vec2 uPointLightSpotCone[2];
|
|
70
70
|
out vec4 fragColor;
|
|
71
71
|
|
|
72
72
|
vec2 envBRDF(float r,float n){
|
|
@@ -157,6 +157,11 @@ if(mode==4)return agxToneMapping(color);
|
|
|
157
157
|
return color;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
vec3 evalLight(vec3 L,vec3 V,vec3 N,vec3 base,float specExp,float specWeight){
|
|
161
|
+
float NoH=max(dot(N,normalize(L+V)),0.0);
|
|
162
|
+
return base*max(dot(N,L),0.0)*0.75+vec3(pow(NoH,specExp)*specWeight+uClearcoat.x*pow(NoH,mix(64.0,512.0,1.0-uClearcoat.y))*0.35);
|
|
163
|
+
}
|
|
164
|
+
|
|
160
165
|
void main(){
|
|
161
166
|
if(uSectionEnabled==1&&dot(vWorldPos,uSectionPlane.xyz)>uSectionPlane.w)discard;
|
|
162
167
|
vec4 base=uBaseColor;
|
|
@@ -194,24 +199,16 @@ float specWeight=mix(0.22*gloss,1.0,metallic);
|
|
|
194
199
|
vec3 directLight=vec3(0.0);
|
|
195
200
|
for(int i=0;i<2;i++){
|
|
196
201
|
if(i>=uNumDirLights)break;
|
|
197
|
-
|
|
198
|
-
float NdotL=max(dot(N,L),0.0);
|
|
199
|
-
vec3 H=normalize(L+V);
|
|
200
|
-
float NoH=max(dot(N,H),0.0);
|
|
201
|
-
float spec=pow(NoH,specExp)*specWeight+uClearcoat.x*pow(NoH,mix(64.0,512.0,1.0-uClearcoat.y))*0.35;
|
|
202
|
-
directLight+=(base.rgb*NdotL*0.75+vec3(spec))*uDirLightColor[i];
|
|
202
|
+
directLight+=evalLight(normalize(uDirLightDir[i]),V,N,base.rgb,specExp,specWeight)*uDirLightColor[i];
|
|
203
203
|
}
|
|
204
204
|
for(int i=0;i<2;i++){
|
|
205
205
|
if(i>=uNumPointLights)break;
|
|
206
206
|
vec3 toLight=uPointLightPos[i]-vWorldPos;
|
|
207
207
|
float dist=length(toLight);
|
|
208
208
|
vec3 L=toLight/max(dist,0.0001);
|
|
209
|
-
float
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
float NoH=max(dot(N,H),0.0);
|
|
213
|
-
float spec=pow(NoH,specExp)*specWeight+uClearcoat.x*pow(NoH,mix(64.0,512.0,1.0-uClearcoat.y))*0.35;
|
|
214
|
-
directLight+=(base.rgb*NdotL*0.75+vec3(spec))*uPointLightColor[i]*atten;
|
|
209
|
+
float spotAtt=clamp((dot(-L,uPointLightSpotDir[i])-uPointLightSpotCone[i].y)/max(uPointLightSpotCone[i].x-uPointLightSpotCone[i].y,0.0001),0.0,1.0);
|
|
210
|
+
spotAtt*=spotAtt;
|
|
211
|
+
directLight+=evalLight(L,V,N,base.rgb,specExp,specWeight)*uPointLightColor[i]*spotAtt/(1.0+0.09*dist+0.032*dist*dist);
|
|
215
212
|
}
|
|
216
213
|
|
|
217
214
|
vec3 R=reflect(-V,N);
|
|
@@ -242,86 +239,113 @@ color=applyToneMapping(color,uToneMapping);
|
|
|
242
239
|
float outAlpha=base.a;
|
|
243
240
|
/*XRD_O*/
|
|
244
241
|
fragColor=vec4(color,outAlpha);
|
|
245
|
-
}
|
|
242
|
+
}`,Qr=`#version 300 es
|
|
246
243
|
layout(location=0) in vec3 aPosition;
|
|
247
244
|
uniform mat4 uMVP;
|
|
248
|
-
void main(){gl_Position=uMVP*vec4(aPosition,1.0);}`,
|
|
245
|
+
void main(){gl_Position=uMVP*vec4(aPosition,1.0);}`,ts=`#version 300 es
|
|
249
246
|
precision highp float;
|
|
250
247
|
uniform vec4 uColorId;
|
|
251
248
|
out vec4 fragColor;
|
|
252
|
-
void main(){fragColor=uColorId;}`;function gt(n,e,t){let r={};for(let i of t)r[i]=n.getUniformLocation(e,i);return r}var on=["uMVP","uModel","uInstanced","uViewProj","uNormalMatrix","uUvTransform","uBaseColor","uMetallic","uRoughness","uClearcoat","uEmissive","uCameraPos","uBaseColorTexture","uHasTexture","uMetallicRoughnessTexture","uHasMetallicRoughnessTexture","uNormalTexture","uHasNormalTexture","uNormalScale","uOcclusionTexture","uHasOcclusionTexture","uOcclusionStrength","uToneMapping","uEnvironmentMap","uHasEnvironmentMap","uAmbientColor","uNumDirLights","uDirLightDir","uDirLightColor","uNumPointLights","uPointLightPos","uPointLightColor","uEnvIntensity","uExposure","uViewportSize","uSectionPlane","uSectionEnabled"];function hn(){let n=Q().xrDepthShader;return{fs:Hn.replace("/*XRD_U*/",n?.uniformsGLSL||"").replace("/*XRD_O*/",n?.occlusionGLSL||""),uniforms:n?[...on,...n.uniformNames]:on}}function $n(n){if(typeof n!="string")return null;let e=n.trim();if(!e||/[\x00-\x1f\x7f]/.test(e))return null;let t=e.toLowerCase();return t.startsWith("data:")?/^data:image\/(png|jpeg|jpg|webp|ktx2|avif)(;|,)/i.test(e)?e:null:t.startsWith("https://")||t.startsWith("blob:")?e:t.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e)||/(^|[\\/])\.\.([\\/]|$)/.test(e)?null:e}function pt(n,e,t,r,i,s,o,l){if(r===void 0||!e.accessors?.[r])return null;let a=dt(e,t,e.accessors[r],s);if(!a)return null;l&&(a=a.slice(),sn(a,l));let u=n.createBuffer();return o.push(u),n.bindBuffer(34962,u),n.bufferData(34962,a,35044),n.enableVertexAttribArray(i),n.vertexAttribPointer(i,s,5126,!1,0,0),a}function bt(n){let e=Number(n);return Number.isFinite(e)?Math.max(0,e):1}function fn(n,e,t){let r=hn(),i=mn,s=r.fs,o=!1;for(let a of ie)if(a.onResolveShader){let u=a.onResolveShader(e,t,i,s);u&&(i=u.vs,s=u.fs,o=!0)}let l=o?Xe(n,i,s):null;return{program:l,uniforms:l?gt(n,l,r.uniforms):null}}function Yn(n,e,t){let r=e.instanceMatrices;if(!r||r.length<16||typeof n.vertexAttribDivisor!="function"||typeof n.drawElementsInstanced!="function")return!1;let i=r.length>>4,s=e.instanceColors,o=new Float32Array(i*20);for(let a=0;a<i;a++)o.set(r.subarray(a*16,a*16+16),a*20),o[a*20+16]=s?s[a*3]:1,o[a*20+17]=s?s[a*3+1]:1,o[a*20+18]=s?s[a*3+2]:1,o[a*20+19]=1;let l=n.createBuffer();t.push(l),n.bindBuffer(34962,l),n.bufferData(34962,o,35044);for(let a=0;a<5;a++)n.enableVertexAttribArray(8+a),n.vertexAttribPointer(8+a,4,5126,!1,80,a*16),n.vertexAttribDivisor(8+a,1);return!0}function jn(n,e){let t=n.materials?.[e?.material];if(!t)return null;let r=[t.pbrMetallicRoughness?.baseColorTexture,t.pbrMetallicRoughness?.metallicRoughnessTexture,t.normalTexture,t.occlusionTexture,t.emissiveTexture];for(let i of r){let s=i?.extensions?.KHR_texture_transform;if(s&&typeof s=="object")return s}return null}var Fr=Object.freeze({maxMeshes:1e3,maxTextures:64,maxVertices:1e6,maxIndices:3e6}),dn=Object.freeze({maxMeshes:1/0,maxTextures:1/0,maxVertices:1/0,maxIndices:1/0});function We(n,e){e.indices?n.drawElements(4,e.indexCount,e.indexType,0):n.drawArrays(4,0,e.indexCount)}function pn(n,e){let t=n?.pbrMetallicRoughness,r=t?.baseColorFactor,i=n?.extensions?.KHR_materials_clearcoat,s=o=>o!==void 0&&e[o.index]?e[o.index]:null;return{baseColor:r?[r[0],r[1],r[2],r[3]??1]:[.8,.8,.8,1],metallic:t?.metallicFactor??.1,roughness:t?.roughnessFactor??.5,clearcoat:i?i.clearcoatFactor??1:0,clearcoatRoughness:Math.max(.04,i?.clearcoatRoughnessFactor??.04),texture:s(t?.baseColorTexture),metallicRoughnessTexture:s(t?.metallicRoughnessTexture),normalTexture:s(n?.normalTexture),normalScale:n?.normalTexture?.scale??1,occlusionTexture:s(n?.occlusionTexture),occlusionStrength:n?.occlusionTexture?.strength??1,isTransmissive:(n?.extensions?.KHR_materials_transmission?.transmissionFactor??0)>0}}function bn(n,e,t){let r=new Set,i=s=>{s&&!r.has(s)&&(r.add(s),n.deleteTexture(s))};for(let s of e)for(let o of s.primitives){if(o.vao&&n.deleteVertexArray(o.vao),o.buffers)for(let a of o.buffers)n.deleteBuffer(a);i(o.texture),i(o.metallicRoughnessTexture),i(o.normalTexture),i(o.occlusionTexture);let l=new Set;o.customProgram&&l.add(o.customProgram);for(let a of o.programCache?.values()??[])a.program&&l.add(a.program);for(let a of l)n.deleteProgram(a)}if(t)for(let s of t)i(s)}function an(n,e,t=dn,r){let i={meshes:[],mesh:null,gpuTextures:[],vao:null,buffers:[]};try{return Kn(n,e,t,r,i)}catch(s){let o=i.mesh&&!i.meshes.includes(i.mesh)?[...i.meshes,i.mesh]:i.meshes;bn(n,o,i.gpuTextures),i.vao&&n.deleteVertexArray(i.vao);for(let l of i.buffers)n.deleteBuffer(l);throw s}}function Kn(n,e,t,r,i){if(!e||!e.gltf)throw new Error("Invalid GLBData passed to buildGpuScene: missing gltf object.");let{gltf:s}=e,o=_e("meshopt");o?.decodeBufferViews&&o.decodeBufferViews(s,e);let l=e.bin,a=[];i.meshes=a;let u=[],c=s.extensions?.KHR_materials_variants;c&&Array.isArray(c.variants)&&c.variants.forEach((y,A)=>{u.push(typeof y?.name=="string"&&y.name?y.name:`Variant_${A}`)});let h=He(s),m=[];if(Array.isArray(s.nodes))for(let y=0;y<s.nodes.length;y++){let A=s.nodes[y];A.mesh!==void 0&&s.meshes&&s.meshes[A.mesh]&&m.push({node:A,nodeIdx:y,meshIdx:A.mesh})}let b=m.length>0?m:(s.meshes||[]).map((y,A)=>({node:y,nodeIdx:-1,meshIdx:A})),g=[];if(Array.isArray(e.lights)&&e.lights.length>0)g.push(...e.lights);else if(s.extensions?.KHR_lights_punctual?.lights){let y=s.extensions.KHR_lights_punctual.lights;for(let A of y){let T=A.type==="directional"?"directional":A.type==="point"?"point":"ambient";g.push({type:T,color:A.color||[1,1,1],intensity:A.intensity!==void 0?A.intensity:1})}}if(g.length===0&&(g.push({type:"ambient",color:[1,1,1],intensity:.35}),g.push({type:"directional",color:[1,1,1],intensity:.85,direction:[.5,1,.8]})),b.length>t.maxMeshes)throw new Error(`SecurityError: GLB scene exceeds host mesh limit (${t.maxMeshes}). Found: ${b.length}`);let d=[];if(i.gpuTextures=d,s.textures&&s.images){if(s.textures.length>t.maxTextures)throw new Error(`SecurityError: GLB scene exceeds host texture limit (${t.maxTextures}). Found: ${s.textures.length}`);for(let y=0;y<s.textures.length;y++){let A=s.textures[y],T=s.images[A.source];if(T){let R=n.createTexture();if(n.bindTexture(3553,R),n.texImage2D(3553,0,6408,1,1,0,6408,5121,new Uint8Array([255,255,255,255])),n.texParameteri(3553,10242,10497),n.texParameteri(3553,10243,10497),n.texParameteri(3553,10241,9729),n.texParameteri(3553,10240,9729),T.bufferView!==void 0){let F=s.bufferViews[T.bufferView],P=l.slice(F.byteOffset||0,(F.byteOffset||0)+F.byteLength),B=new Blob([P],{type:T.mimeType||"image/png"});typeof createImageBitmap=="function"&&createImageBitmap(B).then(k=>{n.bindTexture(3553,R),n.texImage2D(3553,0,6408,6408,5121,k),n.generateMipmap(3553),r?.()}).catch(()=>{})}else if(T.uri){let F=$n(T.uri);if(F){let P=new Image;P.crossOrigin="anonymous",P.referrerPolicy="no-referrer",P.onload=()=>{n.bindTexture(3553,R),n.texImage2D(3553,0,6408,6408,5121,P),n.generateMipmap(3553),r?.()},P.src=F}else console.warn("[Three-Live Security] Blocked unsafe glTF image URI:",T.uri)}d.push(R)}else d.push(null)}}let w=[1/0,1/0,1/0],C=[-1/0,-1/0,-1/0],N=0,f=0;for(let y=0;y<b.length;y++){let A=b[y],T=s.meshes[A.meshIdx],R=A.nodeIdx>=0?h[A.nodeIdx]:J(),F=new Float32Array(9);me(F,R);let P={name:A.node.name||T.name||`Mesh_${A.meshIdx}`,nodeIndex:A.nodeIdx,transform:R,normalMatrix:F,primitives:[],extras:A.node.extras||T.extras};i.mesh=P;let B=A.node?.extensions?.EXT_mesh_gpu_instancing;if(B&&B.attributes&&typeof B.attributes=="object"){let k=B.attributes,O=k.TRANSLATION!==void 0?s.accessors?.[k.TRANSLATION]:null,S=k.ROTATION!==void 0?s.accessors?.[k.ROTATION]:null,G=k.SCALE!==void 0?s.accessors?.[k.SCALE]:null,z=k._COLOR_0!==void 0?s.accessors?.[k._COLOR_0]:null,U=Number(O?.count??S?.count??G?.count??0);if(!Number.isFinite(U)||U<0||U>1e4)throw new Error(`SecurityError: EXT_mesh_gpu_instancing exceeds maximum instance limit (10000). Found: ${U}`);if(U>0){let H=($,q)=>{if(!$||$.bufferView===void 0||!s.bufferViews?.[$.bufferView])return null;let se=$.componentType??5126,ce=ne=>(console.warn(`[three-live] EXT_mesh_gpu_instancing: skipping accessor (${ne})`),null);if(se!==5120&&se!==5121&&se!==5122&&se!==5123&&se!==5126)return ce(`componentType ${se}`);if(!(Number($.count)>=U))return ce(`count ${$.count} < ${U}`);let K=null;try{K=dt(s,l,{...$,count:U},q)}catch{return ce("out of bounds")}return!K||!K.every(Number.isFinite)?ce("non-finite value"):K},L=H(O,3),V=H(S,4),X=H(G,3),W=z?.type==="VEC4"?4:3,Y=H(z,W),re=new Float32Array(U*16),ae=J();for(let $=0;$<U;$++){let q=L?[L[$*3],L[$*3+1],L[$*3+2]]:[0,0,0],se=V?[V[$*4],V[$*4+1],V[$*4+2],V[$*4+3]]:[0,0,0,1],ce=X?[X[$*3],X[$*3+1],X[$*3+2]]:[1,1,1];Me(ae,se,q,ce),re.set(ae,$*16)}if(P.instanceMatrices=re,Y){let $=new Float32Array(U*3);for(let q=0;q<U;q++)$[q*3]=Y[q*W],$[q*3+1]=Y[q*W+1],$[q*3+2]=Y[q*W+2];P.instanceColors=$}}}for(let k of T.primitives||[]){if(k.extensions?.KHR_draco_mesh_compression){let K=_e("draco");K&&K.decodePrimitive(s,k,l)}let O=[],S=n.createVertexArray();i.vao=S,i.buffers=O,n.bindVertexArray(S);let G=Yn(n,P,O),z=s.accessors[k.attributes.POSITION],U=Number(z?.count??0);if(!Number.isFinite(U)||U<0||N+U>t.maxVertices)throw new Error(`SecurityError: GLB scene exceeds host vertex limit (${t.maxVertices}).`);if(N+=U,z?.min&&z?.max){let K=ne=>{for(let Z=0;Z<3;Z++){let oe=ne[12+Z],be=ne[12+Z];for(let Ee=0;Ee<3;Ee++){let Be=ne[Ee*4+Z]*z.min[Ee],Ve=ne[Ee*4+Z]*z.max[Ee];oe+=Be<Ve?Be:Ve,be+=Be>Ve?Be:Ve}oe<w[Z]&&(w[Z]=oe),be>C[Z]&&(C[Z]=be)}};if(P.instanceMatrices&&P.instanceMatrices.length>=16){let ne=P.instanceMatrices.length>>4,Z=J();for(let oe=0;oe<ne;oe++){let be=P.instanceMatrices.subarray(oe*16,oe*16+16);ee(Z,R,be),K(Z)}}else K(R)}let H=pt(n,s,l,k.attributes.POSITION,0,3,O);pt(n,s,l,k.attributes.NORMAL,1,3,O),pt(n,s,l,k.attributes.TEXCOORD_0,2,2,O,jn(s,k));let L=0,V=5123,X=null;if(k.indices!==void 0){let K=s.accessors[k.indices],Z=(s.bufferViews[K.bufferView].byteOffset||0)+(K.byteOffset||0);if(L=Number(K.count??0),!Number.isFinite(L)||L<0||f+L>t.maxIndices)throw new Error(`SecurityError: GLB scene exceeds host index limit (${t.maxIndices}).`);f+=L,V=K.componentType===5125?5125||5125:5123||5123;let oe=n.createBuffer();O.push(oe),n.bindBuffer(34963,oe),K.componentType===5125?(X=new Uint32Array(l,Z,K.count),n.bufferData(34963,X,35044)):K.componentType===5121?(X=Uint16Array.from(new Uint8Array(l,Z,K.count)),n.bufferData(34963,X,35044)):(X=Z%2===0?new Uint16Array(l,Z,K.count):new Uint16Array(l.slice(Z,Z+K.count*2)),n.bufferData(34963,X,35044))}else L=z.count;let W={};for(let K of ie)if(K.onBuildPrimitiveVAO){let ne=K.onBuildPrimitiveVAO(n,S,k,s,l);ne&&(W[K.name]=ne)}n.bindVertexArray(null);let Y=s.materials&&k.material!==void 0?s.materials[k.material]:null,{program:re,uniforms:ae}=fn(n,k,Y),$=pn(Y,d),q=!!(Y?.extensions?.KHR_materials_transmission||W.materials?.isTransmissive),se=k.extensions?.KHR_materials_variants?.mappings,ce=Array.isArray(se)?se.filter(K=>K&&typeof K.material=="number"&&Array.isArray(K.variants)).map(K=>({material:K.material|0,variants:K.variants.map(ne=>Number(ne)|0)})):void 0;P.primitives.push({vao:S,instanced:G,indexCount:L,indexType:V,...$,positions:H,indices:X,buffers:O,materialIndex:k.material,defaultMaterialIndex:k.material,variantMappings:ce,primitiveDef:k,programCache:new Map([[k.material??-1,{program:re,uniforms:ae}]]),pluginData:W,customProgram:re,customUniforms:ae,isTransmissive:q})}a.push(P)}isFinite(w[0])||(w=[-1,-1,-1]),isFinite(C[0])||(C=[1,1,1]);let E=[(w[0]+C[0])/2,(w[1]+C[1])/2,(w[2]+C[2])/2],x=C[0]-w[0],_=C[1]-w[1],D=C[2]-w[2],v=Math.max(Math.hypot(x,_,D)/2,.5),M=[w[0],w[1],w[2]],I=[C[0],C[1],C[2]],p=e.animations;if(!p){for(let y of ie)if(y.onParseGLB?.(e),e.animations){p=e.animations;break}}return p||(p=[]),{meshes:a,bounds:{center:E,radius:v,min:M,max:I},lights:g,animations:p,worldMatrices:h,gpuTextures:d,availableVariants:u}}function Pe(n){let e=n.customTarget||n.bounds.center,t=n.currDistance*Math.cos(n.currPhi);return[e[0]+t*Math.sin(n.currTheta),e[1]+n.currDistance*Math.sin(n.currPhi),e[2]+t*Math.cos(n.currTheta)]}var $e=class{constructor(e,t,r){this.supportsInstanceOffsets=!0;this.meshes=[];this.backdropMeshes=[];this.bounds={center:[0,0,0],radius:1,min:[-1,-1,-1],max:[1,1,1]};this.lights=[];this.modelRootMatrix=J();this.clearColor=[0,0,0,0];this.envIntensity=1;this.exposure=1;this.shadowIntensity=0;this.shadowSoftness=.5;this.toneMapping="neutral";this.environmentTexture=null;this.animations=[];this.currentClip=null;this.animationTime=0;this.isPlayingAnimation=!1;this.autoplay=!1;this.animationName="";this.gpuTextures=[];this.availableVariants=[];this.activeVariantName=null;this.gltf=null;this.worldMatrices=[];this.initialNodeTransforms=[];this.projMatrix=J();this.viewMatrix=J();this.activeViewMatrix=null;this.modelMatrix=J();this.mvpMatrix=J();this.normalMatrix=new Float32Array(9);this.initialTheta=.6;this.initialPhi=.35;this.initialDistance=null;this.customDistance=!1;this.distanceMode="auto";this.initialCustomTarget=null;this.customTarget=null;this.fov=Math.PI/4;this.minTheta=-1/0;this.maxTheta=1/0;this.minPhi=-Math.PI*.48;this.maxPhi=Math.PI*.48;this.minDistanceLimit=null;this.maxDistanceLimit=null;this.activePointers=new Map;this.isPanning=!1;this.targetTheta=.6;this.currTheta=.6;this.targetPhi=.35;this.currPhi=.35;this.targetDistance=3;this.currDistance=3;this.autoRotate=!1;this.autoRotateSpeed=Math.PI/6;this.autoRotateDelay=3e3;this.lastInteractionTime=-1/0;this.turntableRotation=0;this.isPointerDown=!1;this.interactive=!0;this.skyboxTexture=null;this.lastPointerX=0;this.lastPointerY=0;this.totalDragDist=0;this.selectedMeshName="";this.pickFbo=null;this.pickTexture=null;this.pickDepth=null;this.pickFboWidth=0;this.pickFboHeight=0;this.animFrameId=null;this.isVisible=!0;this.xrSessionActive=!1;this.lastTime=0;this.lastReportedTheta=-999;this.lastReportedPhi=-999;this.lastReportedZoom=-999;this.boundPointerDown=null;this.boundPointerMove=null;this.boundPointerUp=null;this.boundWheel=null;this.boundKeyDown=null;this.boundContextMenu=null;this.boundSetCamera=null;this.boundResetCamera=null;this.contextLost=!1;this.lastGlbData=null;this.boundContextLost=null;this.boundContextRestored=null;this.stereoSBS=!1;this.renderErrorReported=!1;this.xrDepthState={enabled:!1,texture:null,uvTransform:J(),rawValueToMeters:.001,format:0};this.container=e;let i,s;if(t&&typeof t.getContext=="function"?(i=t,s=r):(s=t,i=s?.canvas),!i){let a=e.querySelector("canvas");a||(a=document.createElement("canvas"),a.style.width="100%",a.style.height="100%",a.style.display="block",a.style.touchAction="none",e.prepend(a)),i=a}this.canvas=i,this.opts=s||{},this.opts.clearColor&&(this.clearColor=this.opts.clearColor);let o=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.opts.autoRotate!==void 0?this.autoRotate=this.opts.autoRotate&&!o:o&&(this.autoRotate=!1),this.opts.autoRotateSpeed!==void 0&&(this.autoRotateSpeed=this.opts.autoRotateSpeed),this.opts.autoRotateDelay!==void 0&&(this.autoRotateDelay=Math.max(0,Number(this.opts.autoRotateDelay)||0)),this.opts.exposure!==void 0&&(this.exposure=bt(this.opts.exposure)),this.opts.camera&&this.setInitialCamera(this.opts.camera.theta,this.opts.camera.phi,this.opts.camera.distance,this.opts.camera.zoom),this.opts.shadowIntensity!==void 0&&(this.shadowIntensity=Math.max(0,Math.min(1,Number(this.opts.shadowIntensity)||0))),this.opts.shadowSoftness!==void 0&&(this.shadowSoftness=Math.max(0,Math.min(1,Number(this.opts.shadowSoftness)||0))),this.opts.toneMapping!==void 0&&(this.toneMapping=yt(this.opts.toneMapping)),this.opts.autoplay!==void 0&&(this.autoplay=this.opts.autoplay),this.opts.animationName!==void 0&&(this.animationName=this.opts.animationName),this.opts.variantName!==void 0&&(this.activeVariantName=this.opts.variantName||null),this.opts.fieldOfView!==void 0&&(this.fov=this.opts.fieldOfView*Math.PI/180),this.opts.distanceMode!==void 0&&(this.distanceMode=this.opts.distanceMode),this.opts.cameraTarget!==void 0&&(this.setTarget(this.opts.cameraTarget[0],this.opts.cameraTarget[1],this.opts.cameraTarget[2]),this.initialCustomTarget=[...this.opts.cameraTarget]),(this.opts.minCameraOrbit||this.opts.maxCameraOrbit)&&this.setOrbitLimits({minTheta:this.opts.minCameraOrbit?.theta,maxTheta:this.opts.maxCameraOrbit?.theta,minPhi:this.opts.minCameraOrbit?.phi,maxPhi:this.opts.maxCameraOrbit?.phi,minDistance:this.opts.minCameraOrbit?.distance,maxDistance:this.opts.maxCameraOrbit?.distance});let l=i.getContext("webgl2",{antialias:!0,alpha:!0,xrCompatible:!0});if(!l)throw new Error("WebGL2 not supported");this.gl=l,this.initGlState(),this.setupEvents(),this.setupContextLossHandling(),this.opts.environmentImage&&this.setEnvironmentImage(this.opts.environmentImage).catch(()=>{}),typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}static registerDecoder(e,t){zn(e,t)}static getDecoder(e){return _e(e)}setupContextLossHandling(){let e=this.canvas;typeof e?.addEventListener=="function"&&(this.boundContextLost=t=>{t.preventDefault?.(),this.contextLost=!0,this.stop()},this.boundContextRestored=()=>this.restoreContext(),e.addEventListener("webglcontextlost",this.boundContextLost),e.addEventListener("webglcontextrestored",this.boundContextRestored))}initGlState(){let e=this.gl,t=hn();this.renderProg=Xe(e,mn,t.fs),this.pickProg=Xe(e,Xn,Wn),this.uRender=gt(e,this.renderProg,t.uniforms),this.uPick=gt(e,this.pickProg,["uMVP","uColorId"]),this.setupPickingFbo()}restoreContext(){let e=this.gl;this.contextLost=!1,this.initGlState();for(let t of ie)t.onContextRestored?.(e,this);this.meshes=[],this.gpuTextures=[],this.environmentTexture=null,this.lastGlbData&&this.loadGLBData(this.lastGlbData,this.lastLimits),this.opts.environmentImage&&this.setEnvironmentImage(this.opts.environmentImage).catch(()=>{}),typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}setupPickingFbo(){let e=this.gl;if(typeof e.createFramebuffer!="function")return;this.pickFbo=e.createFramebuffer(),this.pickTexture=e.createTexture(),this.pickDepth=e.createRenderbuffer();let t=Math.max(1,this.canvas.width),r=Math.max(1,this.canvas.height);this.pickFboWidth=t,this.pickFboHeight=r,e.bindTexture(3553,this.pickTexture),e.texImage2D(3553,0,6408,t,r,0,6408,5121,null),e.texParameteri(3553,10241,9728),e.texParameteri(3553,10240,9728),e.bindRenderbuffer(36161,this.pickDepth),e.renderbufferStorage(36161,33189,t,r),e.bindFramebuffer(36160,this.pickFbo),e.framebufferTexture2D(36160,36064,3553,this.pickTexture,0),e.framebufferRenderbuffer(36160,36096,36161,this.pickDepth),e.bindFramebuffer(36160,null)}resizePickingFbo(e,t){if(!this.pickFbo)return;let r=this.gl,i=Math.max(1,e),s=Math.max(1,t);this.pickFboWidth=i,this.pickFboHeight=s,r.bindTexture(3553,this.pickTexture),r.texImage2D(3553,0,6408,i,s,0,6408,5121,null),r.bindRenderbuffer(36161,this.pickDepth),r.renderbufferStorage(36161,33189,i,s)}loadGLBData(e,t){this.lastGlbData=e,this.lastLimits=t;let{meshes:r,bounds:i,lights:s,animations:o,worldMatrices:l,gpuTextures:a,availableVariants:u}=an(this.gl,e,t,()=>this.render());if(this.disposeMeshGpuResources(),this.meshes=r,this.bounds=i,this.turntableRotation=0,this.updateTurntableMatrix(),this.lights=s,this.animations=o||[],this.worldMatrices=l||[],this.gpuTextures=a||[],this.availableVariants=u||[],this.gltf=e.gltf,this.activeVariantName&&!this.applyVariantMaterial(this.activeVariantName)&&(this.activeVariantName=null),this.initialNodeTransforms=[],Array.isArray(e.gltf?.nodes))for(let m of e.gltf.nodes)this.initialNodeTransforms.push({t:m.translation?[m.translation[0],m.translation[1],m.translation[2]]:[0,0,0],r:m.rotation?[m.rotation[0],m.rotation[1],m.rotation[2],m.rotation[3]]:[0,0,0,1],s:m.scale?[m.scale[0],m.scale[1],m.scale[2]]:[1,1,1]});this.autoplay&&this.animations.length>0&&this.playAnimation(this.animationName||void 0);for(let m of ie)m.onLoadModel?.(this,this.gltf);this.customDistance||(this.initialDistance=this.distanceMode==="absolute"?3:i.radius*2.5,this.targetDistance=this.initialDistance,this.currDistance=this.initialDistance);let c=e.exposure??e.gltf?.extras?.exposure??e.gltf?.asset?.extras?.exposure;c!==void 0&&(this.exposure=bt(c));let h=e.environmentIntensity??e.gltf?.extras?.environmentIntensity??e.gltf?.asset?.extras?.environmentIntensity;h!==void 0&&(this.envIntensity=Math.max(0,Number(h)||0)),this.container&&typeof this.container.hasAttribute=="function"&&this.container.hasAttribute("poster")&&this.container.removeAttribute("poster"),this.resize(),this.update(0),this.render(),this.animFrameId===null&&typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}loadGLB(e){this.loadGLBData(ln(e))}clearScene(){this.disposeMeshGpuResources(),this.lights=[],this.animations=[],this.currentClip=null,this.isPlayingAnimation=!1,this.worldMatrices=[],this.gltf=null,this.initialNodeTransforms=[],this.turntableRotation=0,this.updateTurntableMatrix(),this.gl&&this.render()}loadModel(e){this.loadGLBData(Fe(e))}setBackdropGLB(e,t){if(this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[],!e){this.update(0),this.render();return}let r=Fe(e),{meshes:i}=an(this.gl,r,dn,()=>this.render());if(t)for(let s of i)s.transform[12]+=t[0],s.transform[13]+=t[1],s.transform[14]+=t[2],me(s.normalMatrix,s.transform);this.backdropMeshes=i,this.update(0),this.render()}setClearColor(e,t,r,i=1){this.clearColor=[e,t,r,i]}updateMeshTransforms(e){for(let t=0;t<this.meshes.length;t++){let r=this.meshes[t],i;e instanceof Map?i=e.get(r.name)??e.get(t):Array.isArray(e)?i=e[t]:e&&typeof e=="object"&&(Object.prototype.hasOwnProperty.call(e,r.name)?i=e[r.name]:Object.prototype.hasOwnProperty.call(e,t)&&(i=e[t])),i&&i.length===16&&(r.transform.set(i),me(r.normalMatrix,r.transform))}}bindLights(e=this.uRender){let t=this.gl,r=[.28,.28,.28],i=[],s=[],o=[],l=[];for(let a of this.lights){let u=a.color||[1,1,1],c=a.intensity!==void 0?a.intensity:1;if(a.type==="ambient")r=[u[0]*c,u[1]*c,u[2]*c];else if(a.type==="directional"&&i.length<6){let h=a.direction||[.5,1,.8];i.push(h[0],h[1],h[2]),s.push(u[0]*c,u[1]*c,u[2]*c)}else if(a.type==="point"&&o.length<6){let h=a.position||[0,0,0];o.push(h[0],h[1],h[2]),l.push(u[0]*c,u[1]*c,u[2]*c)}}i.length===0&&(i.push(.5,1,.8),s.push(1,1,1)),t.uniform3fv(e.uAmbientColor,r),t.uniform1i(e.uNumDirLights,i.length/3),i.length>0&&(t.uniform3fv(e.uDirLightDir,i),t.uniform3fv(e.uDirLightColor,s)),t.uniform1i(e.uNumPointLights,o.length/3),o.length>0&&(t.uniform3fv(e.uPointLightPos,o),t.uniform3fv(e.uPointLightColor,l)),t.uniform1f(e.uEnvIntensity,this.envIntensity)}setExposure(e){this.exposure=bt(e)}getExposure(){return this.exposure}setShadow(e,t){this.shadowIntensity=Math.max(0,Math.min(1,Number(e)||0)),t!==void 0&&(this.shadowSoftness=Math.max(0,Math.min(1,Number(t)||0)))}getShadowIntensity(){return this.shadowIntensity}getShadowSoftness(){return this.shadowSoftness}setToneMapping(e){this.toneMapping=yt(e)}getToneMapping(){return this.toneMapping}async setEnvironmentImage(e){for(let t of ie)if(t.setEnvironmentImage){await t.setEnvironmentImage(this,e);return}}async setSkyboxImage(e){for(let t of ie)if(t.setSkyboxImage){await t.setSkyboxImage(this,e);return}}setInteractive(e){this.interactive=e}isInteractive(){return this.interactive}getCameraOrbit(){let e=this.currTheta,t=this.currPhi,r=this.currDistance;return{theta:e,phi:t,radius:r,toString(){return`${e.toFixed(4)}rad ${t.toFixed(4)}rad ${r.toFixed(4)}m`}}}getCameraTarget(){let e=this.customTarget||this.bounds.center;return{x:e[0],y:e[1],z:e[2],toString(){return`${e[0].toFixed(4)}m ${e[1].toFixed(4)}m ${e[2].toFixed(4)}m`}}}jumpCameraToGoal(){this.currTheta=this.targetTheta,this.currPhi=this.targetPhi,this.currDistance=this.targetDistance,this.update(0),this.render()}getModelMaterials(){let e=this.gltf?.materials?.length?this.gltf.materials:[{name:"DefaultMaterial",pbrMetallicRoughness:{}}];return e.map((t,r)=>{let i=this.meshes.flatMap(c=>c.primitives.filter(h=>h.materialIndex===r||e.length===1&&h.materialIndex===void 0)),s=i[0],o=s?[...s.baseColor]:t.pbrMetallicRoughness?.baseColorFactor||[.8,.8,.8,1],l=s?s.metallic:t.pbrMetallicRoughness?.metallicFactor??.1,a=s?s.roughness:t.pbrMetallicRoughness?.roughnessFactor??.5,u={baseColorFactor:o,metallicFactor:l,roughnessFactor:a,setBaseColorFactor:c=>{let h=[c[0],c[1],c[2],c[3]??1];u.baseColorFactor=h,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.baseColorFactor=h);for(let m of i)m.baseColor=h;this.render()},setMetallicFactor:c=>{u.metallicFactor=c,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.metallicFactor=c);for(let h of i)h.metallic=c;this.render()},setRoughnessFactor:c=>{u.roughnessFactor=c,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=c);for(let h of i)h.roughness=c;this.render()}};return{name:t.name||`Material_${r}`,pbrMetallicRoughness:u}})}playAnimation(e){if(this.animations.length!==0){if(e){let t=this.animations.find(r=>r.name===e);t&&(this.currentClip=t)}else this.currentClip||(this.currentClip=this.animations[0]);this.isPlayingAnimation=!0}}pauseAnimation(){this.isPlayingAnimation=!1}getAvailableAnimations(){return this.animations.map(e=>e.name)}getAvailableVariants(){return[...this.availableVariants]}getVariantName(){return this.activeVariantName}selectVariant(e){let t=this.applyVariantMaterial(e);return t&&this.gl&&this.render(),t}applyVariantMaterial(e){let t=e===null||e==="",r=-1;if(t)this.activeVariantName=null;else{if(r=this.availableVariants.indexOf(e),r<0)return!1;this.activeVariantName=e}let i=this.gltf?.materials;if(!Array.isArray(i))return t;for(let s of this.meshes)for(let o of s.primitives){let l=o.defaultMaterialIndex;if(!t&&Array.isArray(o.variantMappings)){for(let u of o.variantMappings)if(Array.isArray(u.variants)&&u.variants.includes(r)){l=u.material;break}}let a=l!==void 0?i[l]:void 0;o.materialIndex=a?l:void 0,Object.assign(o,pn(a,this.gpuTextures)),this.applyPrimitiveProgram(o,o.materialIndex,a??null)}return!0}applyPrimitiveProgram(e,t,r){if(!this.gl||!e.primitiveDef)return;e.programCache??(e.programCache=new Map);let i=t??-1,s=e.programCache.get(i);s||(s=fn(this.gl,{...e.primitiveDef,material:t},r),e.programCache.set(i,s)),e.customProgram=s.program,e.customUniforms=s.uniforms,e.pluginData&&(e.pluginData.materials=e.isTransmissive?{isTransmissive:!0}:void 0)}setAutoplay(e){this.autoplay=e,e?this.playAnimation(this.animationName||void 0):this.pauseAnimation()}setAnimationName(e){this.animationName=e,(this.isPlayingAnimation||this.autoplay)&&this.playAnimation(e)}evaluateAnimation(e){for(let t of ie)if(t.evaluateAnimation){t.evaluateAnimation(this,e);return}}setTarget(e,t,r){this.customTarget=[e,t,r],this.gl&&(this.meshes.length>0||this.backdropMeshes.length>0)&&(this.update(0),this.render())}getTarget(){return this.customTarget?[...this.customTarget]:null}setFieldOfView(e){let t=Math.max(10,Math.min(90,e));this.fov=t*Math.PI/180}getFieldOfView(){return this.fov*180/Math.PI}setDistanceMode(e){if(this.distanceMode=e,!this.customDistance){let t=this.clampDistance(this.distanceMode==="absolute"?3:this.bounds.radius*2.5);this.initialDistance=t,this.targetDistance=t,this.currDistance=t,this.gl&&(this.meshes.length>0||this.backdropMeshes.length>0)&&(this.update(0),this.render())}}getDistanceMode(){return this.distanceMode}setOrbitLimits(e){e.minTheta!==void 0&&(this.minTheta=e.minTheta*Math.PI/180),e.maxTheta!==void 0&&(this.maxTheta=e.maxTheta*Math.PI/180),e.minPhi!==void 0&&(this.minPhi=Math.max(-Math.PI*.48,e.minPhi*Math.PI/180)),e.maxPhi!==void 0&&(this.maxPhi=Math.min(Math.PI*.48,e.maxPhi*Math.PI/180)),e.minDistance!==void 0&&(this.minDistanceLimit=e.minDistance),e.maxDistance!==void 0&&(this.maxDistanceLimit=e.maxDistance),this.targetTheta=this.clampTheta(this.targetTheta),this.targetPhi=this.clampPhi(this.targetPhi),this.targetDistance=this.clampDistance(this.targetDistance)}getOrbitLimits(){return{minTheta:isFinite(this.minTheta)?this.minTheta*180/Math.PI:void 0,maxTheta:isFinite(this.maxTheta)?this.maxTheta*180/Math.PI:void 0,minPhi:this.minPhi*180/Math.PI,maxPhi:this.maxPhi*180/Math.PI,minDistance:this.minDistanceLimit!==null?this.minDistanceLimit:void 0,maxDistance:this.maxDistanceLimit!==null?this.maxDistanceLimit:void 0}}clampTheta(e){return Math.max(this.minTheta,Math.min(this.maxTheta,e))}clampPhi(e){return Math.max(this.minPhi,Math.min(this.maxPhi,e))}clampDistance(e){let t=this.minDistanceLimit!==null?this.minDistanceLimit:this.bounds?this.bounds.radius*.5:.1,r=this.maxDistanceLimit!==null?this.maxDistanceLimit:this.bounds?this.bounds.radius*8:100;return Math.max(t,Math.min(r,e))}setCamera(e,t,r,i){e!==void 0&&(this.targetTheta=this.clampTheta(e*Math.PI/180)),t!==void 0&&(this.targetPhi=this.clampPhi(t*Math.PI/180)),r!==void 0&&r>0&&(this.targetDistance=this.clampDistance(r)),i!==void 0&&i>0&&(this.targetDistance=this.clampDistance(this.bounds.radius*2.5/i))}setInitialCamera(e,t,r,i){if(e!==void 0&&(this.initialTheta=this.clampTheta(e*Math.PI/180),this.targetTheta=this.initialTheta,this.currTheta=this.initialTheta),t!==void 0&&(this.initialPhi=this.clampPhi(t*Math.PI/180),this.targetPhi=this.initialPhi,this.currPhi=this.initialPhi),r!==void 0&&r>0){let s=this.clampDistance(r);this.initialDistance=s,this.customDistance=!0,this.targetDistance=s,this.currDistance=s}else if(i!==void 0&&i>0){let s=this.clampDistance(this.bounds.radius*2.5/i);this.initialDistance=s,this.customDistance=!0,this.targetDistance=s,this.currDistance=s}else{this.customDistance=!1;let s=this.clampDistance(this.distanceMode==="absolute"?3:this.bounds.radius*2.5);this.initialDistance=s,this.targetDistance=s,this.currDistance=s}this.gl&&(this.meshes.length>0||this.backdropMeshes.length>0)&&(this.update(0),this.render())}resetCamera(){this.targetTheta=this.clampTheta(this.initialTheta),this.targetPhi=this.clampPhi(this.initialPhi),this.initialDistance!==null?this.targetDistance=this.clampDistance(this.initialDistance):this.targetDistance=this.clampDistance(this.bounds.radius*2.5),this.initialCustomTarget?this.customTarget=[...this.initialCustomTarget]:this.customTarget=null,this.turntableRotation=0,this.updateTurntableMatrix()}projectPointToScreen(e,t){let r=J();ee(r,this.projMatrix,this.viewMatrix);let[i,s,o]=e,l=t?t[0]:0,a=t?t[1]:0,u=t?t[2]:0,c=this.modelRootMatrix;c&&(i=c[0]*e[0]+c[4]*e[1]+c[8]*e[2]+c[12],s=c[1]*e[0]+c[5]*e[1]+c[9]*e[2]+c[13],o=c[2]*e[0]+c[6]*e[1]+c[10]*e[2]+c[14],t&&(l=c[0]*t[0]+c[4]*t[1]+c[8]*t[2],a=c[1]*t[0]+c[5]*t[1]+c[9]*t[2],u=c[2]*t[0]+c[6]*t[1]+c[10]*t[2]));let h=r[0]*i+r[4]*s+r[8]*o+r[12],m=r[1]*i+r[5]*s+r[9]*o+r[13],b=r[2]*i+r[6]*s+r[10]*o+r[14],g=r[3]*i+r[7]*s+r[11]*o+r[15];if(g<=1e-4)return{x:0,y:0,z:1,visible:!1};let d=h/g,w=m/g,C=b/g,N=this.canvas.getBoundingClientRect(),f=N.width||this.canvas.clientWidth||this.canvas.width||300,E=N.height||this.canvas.clientHeight||this.canvas.height||150,x=(d*.5+.5)*f,_=(-w*.5+.5)*E,D=d>=-1.1&&d<=1.1&&w>=-1.1&&w<=1.1&&C>=-1&&C<=1;if(D&&t){let[v,M,I]=Pe(this),p=[i-v,s-M,o-I];l*p[0]+a*p[1]+u*p[2]>.05&&(D=!1)}return{x,y:_,z:C,visible:D}}setSelectedMesh(e){this.selectedMeshName=e||""}getSelectedMesh(){return this.selectedMeshName}setupEvents(){let e=this.canvas;this.boundContextMenu=t=>{t.preventDefault()},e.addEventListener("contextmenu",this.boundContextMenu),this.boundPointerDown=t=>{this.interactive&&(this.isPointerDown=!0,this.lastInteractionTime=typeof performance<"u"?performance.now():Date.now(),this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.totalDragDist=0,this.activePointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this.isPanning=t.button===2||t.shiftKey||this.activePointers.size===2,e.setPointerCapture(t.pointerId))},e.addEventListener("pointerdown",this.boundPointerDown),this.boundPointerMove=t=>{if(!this.isPointerDown||!this.interactive)return;this.lastInteractionTime=typeof performance<"u"?performance.now():Date.now();let r=this.activePointers.get(t.pointerId)||{x:this.lastPointerX,y:this.lastPointerY},i=t.clientX-r.x,s=t.clientY-r.y;if(this.activePointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this.lastPointerX=t.clientX,this.lastPointerY=t.clientY,this.totalDragDist+=Math.hypot(i,s),this.isPanning||t.button===2||t.shiftKey||this.activePointers.size===2){let o=[this.viewMatrix[0],this.viewMatrix[4],this.viewMatrix[8]],l=[this.viewMatrix[1],this.viewMatrix[5],this.viewMatrix[9]],a=this.customTarget?[...this.customTarget]:[...this.bounds.center],u=this.currDistance/Math.max(e.clientHeight||300,1)*1.5;a[0]+=(-i*o[0]+s*l[0])*u,a[1]+=(-i*o[1]+s*l[1])*u,a[2]+=(-i*o[2]+s*l[2])*u,this.customTarget=a}else this.targetTheta=this.clampTheta(this.targetTheta-i*.008),this.targetPhi=this.clampPhi(this.targetPhi+s*.008)},e.addEventListener("pointermove",this.boundPointerMove),this.boundPointerUp=t=>{this.lastInteractionTime=typeof performance<"u"?performance.now():Date.now(),this.activePointers.delete(t.pointerId),this.activePointers.size===0?(this.isPointerDown=!1,this.isPanning=!1):this.activePointers.size===1&&(this.isPanning=!1);try{e.releasePointerCapture(t.pointerId)}catch{}if(this.totalDragDist<5&&t.button===0){let r=e.getBoundingClientRect(),i=Math.floor((t.clientX-r.left)*(e.width/Math.max(r.width,1))),s=Math.floor((t.clientY-r.top)*(e.height/Math.max(r.height,1)));this.performMeshPick(i,s,!0)}},e.addEventListener("pointerup",this.boundPointerUp),this.boundWheel=t=>{if(!this.interactive)return;t.preventDefault(),this.lastInteractionTime=typeof performance<"u"?performance.now():Date.now();let r=Math.exp(t.deltaY*.001);this.targetDistance=this.clampDistance(this.targetDistance*r)},e.addEventListener("wheel",this.boundWheel,{passive:!1}),this.boundSetCamera=t=>{let r=t.detail||{};r.reset?this.resetCamera():this.setCamera(r.theta,r.phi,r.distance,r.zoom)},this.container.addEventListener("setCamera",this.boundSetCamera),this.boundResetCamera=()=>{this.resetCamera()},this.container.addEventListener("resetCamera",this.boundResetCamera),e.tabIndex!==void 0&&e.tabIndex<0&&(e.tabIndex=0),e.getAttribute?.("role")||e.setAttribute?.("role","region"),e.getAttribute?.("aria-label")||e.setAttribute?.("aria-label","Interactive 3D model viewport"),this.boundKeyDown=t=>{if(!this.interactive)return;let r=typeof performance<"u"?performance.now():Date.now();switch(t.key){case"ArrowLeft":this.lastInteractionTime=r,this.targetTheta=this.clampTheta(this.targetTheta-.1),t.preventDefault();break;case"ArrowRight":this.lastInteractionTime=r,this.targetTheta=this.clampTheta(this.targetTheta+.1),t.preventDefault();break;case"ArrowUp":this.lastInteractionTime=r,this.targetPhi=this.clampPhi(this.targetPhi+.08),t.preventDefault();break;case"ArrowDown":this.lastInteractionTime=r,this.targetPhi=this.clampPhi(this.targetPhi-.08),t.preventDefault();break;case"+":case"=":{this.lastInteractionTime=r,this.targetDistance=this.clampDistance(this.targetDistance*.9),t.preventDefault();break}case"-":case"_":{this.lastInteractionTime=r,this.targetDistance=this.clampDistance(this.targetDistance*1.1),t.preventDefault();break}case"Home":this.lastInteractionTime=r,this.resetCamera(),t.preventDefault();break}},e.addEventListener("keydown",this.boundKeyDown)}teardownEvents(){let e=this.canvas;this.boundContextLost&&(e.removeEventListener("webglcontextlost",this.boundContextLost),this.boundContextLost=null),this.boundContextRestored&&(e.removeEventListener("webglcontextrestored",this.boundContextRestored),this.boundContextRestored=null),this.boundContextMenu&&(e.removeEventListener("contextmenu",this.boundContextMenu),this.boundContextMenu=null),this.boundPointerDown&&(e.removeEventListener("pointerdown",this.boundPointerDown),this.boundPointerDown=null),this.boundPointerMove&&(e.removeEventListener("pointermove",this.boundPointerMove),this.boundPointerMove=null),this.boundPointerUp&&(e.removeEventListener("pointerup",this.boundPointerUp),this.boundPointerUp=null),this.boundWheel&&(e.removeEventListener("wheel",this.boundWheel),this.boundWheel=null),this.boundKeyDown&&(e.removeEventListener("keydown",this.boundKeyDown),this.boundKeyDown=null),this.boundSetCamera&&(this.container.removeEventListener("setCamera",this.boundSetCamera),this.boundSetCamera=null),this.boundResetCamera&&(this.container.removeEventListener("resetCamera",this.boundResetCamera),this.boundResetCamera=null)}raycastFromScreenPoint(e,t){let r=this.canvas,i=r.getBoundingClientRect(),s=r.width||300,o=r.height||300,l=i.width>0?Math.floor((e-i.left)*(s/i.width)):Math.floor(e),a=i.height>0?Math.floor((t-i.top)*(o/i.height)):Math.floor(t);return this.performMeshPick(l,a,!1)}performMeshPick(e,t,r=!0){if(this.meshes.length===0)return null;let i=this.gl,s=Math.max(1,this.canvas.width||300),o=Math.max(1,this.canvas.height||300);e=this.mapStereoPickX(e,s);let l=J();ee(l,this.projMatrix,this.viewMatrix);let a=[],u=Math.max(0,Math.min(s-1,e)),c=Math.max(0,Math.min(o-1,o-1-t));if(this.pickFbo&&i&&!this.xrSessionActive){(this.pickFboWidth!==s||this.pickFboHeight!==o)&&this.resizePickingFbo(s,o),i.bindFramebuffer(36160,this.pickFbo),i.viewport(0,0,s,o),i.enable(2929),i.clearColor(0,0,0,0),i.clear(16384|256),i.useProgram(this.pickProg);for(let D=0;D<this.meshes.length;D++){let v=this.meshes[D];if(v.visible===!1||v.isPluginMesh)continue;let M=D+1,I=(M&255)/255,p=(M>>8&255)/255,y=(M>>16&255)/255;i.uniform4f(this.uPick.uColorId,I,p,y,1),ee(this.modelMatrix,this.modelRootMatrix,v.transform);let A=v.instanceMatrices;if(A&&A.length>=16){let T=A.length>>4,R=J();for(let F of v.primitives){i.bindVertexArray(F.vao);for(let P=0;P<T;P++)ee(R,this.modelMatrix,A.subarray(P*16,P*16+16)),ee(this.mvpMatrix,l,R),i.uniformMatrix4fv(this.uPick.uMVP,!1,this.mvpMatrix),We(i,F)}}else{ee(this.mvpMatrix,l,this.modelMatrix),i.uniformMatrix4fv(this.uPick.uMVP,!1,this.mvpMatrix);for(let T of v.primitives)i.bindVertexArray(T.vao),We(i,T)}}let x=new Uint8Array(4);i.readPixels(u,c,1,1,6408,5121,x),i.bindFramebuffer(36160,null);let _=x[0]+(x[1]<<8)+(x[2]<<16);_>0&&_<=this.meshes.length&&(a=[this.meshes[_-1]])}a.length===0&&(a=this.meshes.filter(x=>x.visible!==!1));let h=null,m=1/0,b=[0,0,0],g=[0,1,0],[d,w,C]=Pe(this),N=J();for(let x of a){ee(N,this.modelRootMatrix,x.transform);let _=x.instanceMatrices,D=_&&_.length>=16?_.length>>4:1;for(let v=0;v<D;v++){_&&_.length>=16?ee(this.modelMatrix,N,_.subarray(v*16,v*16+16)):this.modelMatrix.set(N),ee(this.mvpMatrix,l,this.modelMatrix);let M=J();if(!nn(M,this.mvpMatrix))continue;let I=(u+.5)/s*2-1,p=(c+.5)/o*2-1,y=[0,0,0],A=[0,0,0];ft(y,I,p,-1,M),ft(A,I,p,1,M);let T=A[0]-y[0],R=A[1]-y[1],F=A[2]-y[2],P=Math.hypot(T,R,F)||1,B=T/P,k=R/P,O=F/P,S={distance:1/0,point:[0,0,0],normal:[0,1,0]};if((z=>{for(let U of x.primitives){if(!U.positions)continue;let H=U.positions,L=U.indices,V=Math.floor(L?L.length/3:H.length/9);for(let X=0;X<V;X++){let W=L?L[X*3]:X*3,Y=L?L[X*3+1]:X*3+1,re=L?L[X*3+2]:X*3+2;rn(y[0],y[1],y[2],B,k,O,H[W*3],H[W*3+1],H[W*3+2],H[Y*3],H[Y*3+1],H[Y*3+2],H[re*3],H[re*3+1],H[re*3+2],S,z)}}})(1e-4),isFinite(S.distance)){let z=S.point[0],U=S.point[1],H=S.point[2],L=this.modelMatrix,V=L[0]*z+L[4]*U+L[8]*H+L[12],X=L[1]*z+L[5]*U+L[9]*H+L[13],W=L[2]*z+L[6]*U+L[10]*H+L[14],Y=V-d,re=X-w,ae=W-C,$=Math.hypot(Y,re,ae);if($<m){me(this.normalMatrix,this.modelMatrix);let q=this.normalMatrix,se=S.normal[0],ce=S.normal[1],K=S.normal[2],ne=q[0]*se+q[3]*ce+q[6]*K,Z=q[1]*se+q[4]*ce+q[7]*K,oe=q[2]*se+q[5]*ce+q[8]*K,be=Math.hypot(ne,Z,oe)||1;ne/=be,Z/=be,oe/=be,ne*Y+Z*re+oe*ae>0&&(ne=-ne,Z=-Z,oe=-oe),h=x,m=Math.round($*1e3)/1e3,b=[Math.round(V*1e3)/1e3,Math.round(X*1e3)/1e3,Math.round(W*1e3)/1e3],g=[Math.round(ne*1e3)/1e3,Math.round(Z*1e3)/1e3,Math.round(oe*1e3)/1e3]}}}}if(!h)return null;let E={meshIndex:this.meshes.indexOf(h),meshName:h.name,nodeIndex:h.nodeIndex,distance:m,hitPoint:b,normal:g,screenX:e,screenY:t};if(r){for(let x of ie)x.onMeshSelect?.(this,E);this.opts.onMeshClick&&this.opts.onMeshClick(E),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("meshClick",{bubbles:!0,detail:E}))}return E}mapStereoPickX(e,t){if(!this.stereoSBS||this.xrSessionActive||t<2)return e;let r=Math.max(1,Math.floor(t*.5)),i=e>=r,s=i?e-r:e,o=i?Math.max(1,t-r):r,l=(s+.5)/o*2-1;return Math.floor((l*.5+1)*.5*t)}setStereoSBS(e){this.stereoSBS=!!e,this.xrSessionActive||(this.syncCameraMatrices(),this.render())}syncCameraMatrices(){let e=Math.max(1,this.canvas.width||1)/Math.max(1,this.canvas.height||1),t=this.backdropMeshes.length>0?Math.max(this.bounds.radius*20,120):Math.max(this.bounds.radius*20,10);Ge(this.projMatrix,this.fov,e,.1,t);let r=this.customTarget||this.bounds.center;Re(this.viewMatrix,Pe(this),r,[0,1,0]),ee(this.mvpMatrix,this.projMatrix,this.viewMatrix),me(this.normalMatrix,this.modelMatrix)}resize(){let e=Math.min((typeof window<"u"?window.devicePixelRatio:1)||1,2),t=this.canvas.getBoundingClientRect(),r=Math.max(1,Math.floor(t.width*e)),i=Math.max(1,Math.floor(t.height*e));this.canvas.width!==r||this.canvas.height!==i?(this.canvas.width=r,this.canvas.height=i,this.resizePickingFbo(r,i),this.xrSessionActive||this.syncCameraMatrices()):!this.xrSessionActive&&this.projMatrix[0]===0&&this.syncCameraMatrices()}getGLContext(){return this.gl}setXRSessionActive(e){let t=this.xrSessionActive;if(this.xrSessionActive=e,t&&!e){this.xrDepthState.enabled=!1;for(let r of ie)r.onXRSessionEnd?.(this);if(this.lastTime=typeof performance<"u"?performance.now():Date.now(),this.updateTurntableMatrix(),this.isVisible)try{this.resize(),this.syncCameraMatrices(),this.render()}catch(r){this.reportRenderError(r)}}}reportRenderError(e){this.renderErrorReported||(this.renderErrorReported=!0,typeof console<"u"&&console.warn("[three-live] render frame failed:",e))}stepXRUpdate(e){for(let t of ie)t.onUpdate?.(this,e)}start(){if(this.animFrameId!==null)return;this.lastTime=typeof performance<"u"?performance.now():Date.now();let e=t=>{if(this.animFrameId===null)return;let r=Math.min(Math.max((t-this.lastTime)/1e3,0),.1);if(this.lastTime=t,this.isVisible&&!this.xrSessionActive)try{this.resize(),this.update(r),this.render()}catch(i){this.reportRenderError(i)}this.animFrameId!==null&&(this.animFrameId=requestAnimationFrame(e))};this.animFrameId=requestAnimationFrame(e)}stop(){this.animFrameId!==null&&(cancelAnimationFrame(this.animFrameId),this.animFrameId=null)}setAutoRotate(e){this.autoRotate=e}getAutoRotate(){return this.autoRotate}setAutoRotateSpeed(e){this.autoRotateSpeed=e}getAutoRotateSpeed(){return this.autoRotateSpeed}setAutoRotateDelay(e){this.autoRotateDelay=Math.max(0,Number(e)||0)}getAutoRotateDelay(){return this.autoRotateDelay}resetTurntableRotation(e=0){this.turntableRotation=Number(e)||0,this.updateTurntableMatrix(),this.render()}updateTurntableMatrix(){let e=Math.cos(this.turntableRotation),t=Math.sin(this.turntableRotation),r=this.bounds.center[0],i=this.bounds.center[2],s=this.modelRootMatrix;s[0]=e,s[1]=0,s[2]=-t,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=t,s[9]=0,s[10]=e,s[11]=0,s[12]=r-(e*r+t*i),s[13]=0,s[14]=i-(-t*r+e*i),s[15]=1}setVisible(e){this.isVisible=e}update(e){for(let o of ie)o.onUpdate?.(this,e);let t=typeof performance<"u"?performance.now():Date.now();if(!this.isPointerDown&&this.autoRotate&&t-this.lastInteractionTime>=this.autoRotateDelay){this.turntableRotation+=this.autoRotateSpeed*e,this.updateTurntableMatrix();for(let o of ie)o.onCameraChange?.(this,this.container)}this.currTheta+=(this.targetTheta-this.currTheta)*.12,this.currPhi+=(this.targetPhi-this.currPhi)*.12,this.currDistance+=(this.targetDistance-this.currDistance)*.12,this.syncCameraMatrices();let r=Math.round((this.currTheta*180/Math.PI%360+360)%360),i=Math.round(this.currPhi*180/Math.PI),s=Math.round(this.bounds.radius*2.5/this.currDistance*100)/100;if(Math.abs(r-this.lastReportedTheta)>=1||Math.abs(i-this.lastReportedPhi)>=1||Math.abs(s-this.lastReportedZoom)>=.02){this.lastReportedTheta=r,this.lastReportedPhi=i,this.lastReportedZoom=s;let o={theta:r,phi:i,zoom:s,distance:Math.round(this.currDistance*100)/100};this.opts.onCameraChange&&this.opts.onCameraChange(o),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("cameraChange",{bubbles:!0,detail:o}))}}renderXRView(e,t,r,i,s=!0,o=0){this.onBeforeRenderXRView&&this.onBeforeRenderXRView(e);let l=e?.transform?.inverse?.matrix||this.viewMatrix,a=e?.projectionMatrix||this.projMatrix,u=e?.transform?.position,c=u?[u.x,u.y,u.z]:[0,1.6,0];t?this.modelRootMatrix.set(t):r&&t&&this.modelRootMatrix.set(t),this.render({viewMatrix:l,projMatrix:a,eyePos:c,viewport:i,eye:e?.eye||"none",clear:o>0?!1:e?.eye!=="right",isAR:s})}render(e){if(this.contextLost)return;if(!e&&this.stereoSBS){let f=Math.max(2,this.canvas.width||2),E=Math.max(1,this.canvas.height||1),x=Math.max(1,Math.floor(f*.5)),_=Math.max(1,f-x),D=this.backdropMeshes.length>0?Math.max(this.bounds.radius*20,120):Math.max(this.bounds.radius*20,10),v=this.customTarget||this.bounds.center,[M,I,p]=Pe(this),y=Math.cos(this.currTheta),A=-Math.sin(this.currTheta),T=.032,R=J(),F=J(),P=[M-y*T,I,p-A*T],B=[v[0]-y*T*.25,v[1],v[2]-A*T*.25];Ge(R,this.fov,x/E,.1,D),Re(F,P,B,[0,1,0]);let k=J(),O=J(),S=[M+y*T,I,p+A*T],G=[v[0]+y*T*.25,v[1],v[2]+A*T*.25];Ge(k,this.fov,_/E,.1,D),Re(O,S,G,[0,1,0]),this.render({viewMatrix:F,projMatrix:R,eyePos:P,viewport:[0,0,x,E],eye:"left",clear:!0,isAR:!1}),this.render({viewMatrix:O,projMatrix:k,eyePos:S,viewport:[x,0,_,E],eye:"right",clear:!1,isAR:!1}),this.gl.viewport(0,0,f,E);return}let t=this.gl,r=0,i=0,s=this.canvas.width,o=this.canvas.height;e?.viewport?(r=e.viewport[0],i=e.viewport[1],s=e.viewport[2],o=e.viewport[3],t.viewport(r,i,s,o)):t.viewport(0,0,this.canvas.width,this.canvas.height),t.enable(2929),(!e||e.clear!==!1)&&(e?.isAR?t.clearColor(0,0,0,0):t.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),t.clear(16384|256));let l=J(),a=e?.viewMatrix??this.viewMatrix;this.activeViewMatrix=a,ee(l,e?.projMatrix??this.projMatrix,a);let u=Q().xrDepthShader,c=Bn(this.toneMapping),[h,m,b]=e?e.eyePos:Pe(this);for(let f of ie)f.onBeforeDrawScene?.(this,t,l,[h,m,b],c);let g=e?.isAR?0:this.backdropMeshes.length;if(this.meshes.length===0&&g===0)return;let d=e?.eye||"none",w=!1,C=g>0?[...this.backdropMeshes,...this.meshes]:this.meshes,N=f=>{for(let E=0;E<C.length;E++){let x=C[E];if(x.visible===!1)continue;let _=this.selectedMeshName!==""&&x.name===this.selectedMeshName;E<g||x.worldSpace===!0||x.name==="__xr_reticle__"?this.modelMatrix.set(x.transform):ee(this.modelMatrix,this.modelRootMatrix,x.transform),ee(this.mvpMatrix,l,this.modelMatrix),me(x.normalMatrix,this.modelMatrix);let D=x.extras?.xr?.stereo||x.userData?.xr?.stereo,v=0,M=0,I=1,p=1;D==="sbs"?(I=.5,v=d==="right"?.5:0):D==="ou"&&(p=.5,M=d==="right"?.5:0);for(let y of x.primitives){let A=!!y.isTransmissive;if(!f&&A){w=!0;continue}if(f&&!A)continue;let T=y.customProgram||this.renderProg,R=y.customUniforms||this.uRender;t.useProgram(T),t.vertexAttrib3f(3,0,0,0),R.uInstanced&&t.uniform1i(R.uInstanced,0),t.uniform1i(R.uToneMapping,c),t.uniform1f(R.uEnvIntensity,this.envIntensity),R.uExposure&&t.uniform1f(R.uExposure,this.exposure),t.uniform3f(R.uCameraPos,h,m,b),t.uniform1f(R.uEmissive,_?1:0),t.uniformMatrix4fv(R.uMVP,!1,this.mvpMatrix),t.uniformMatrix4fv(R.uModel,!1,this.modelMatrix),t.uniformMatrix3fv(R.uNormalMatrix,!1,x.normalMatrix),R.uUvTransform&&t.uniform4f(R.uUvTransform,v,M,I,p),R.uViewportSize&&t.uniform2f(R.uViewportSize,Math.max(1,s),Math.max(1,o)),u?.bind(t,R,this.xrDepthState,a,[r,i,Math.max(1,s),Math.max(1,o)]),this.environmentTexture?(t.activeTexture(33988),t.bindTexture(3553,this.environmentTexture),t.uniform1i(R.uEnvironmentMap,4),t.uniform1i(R.uHasEnvironmentMap,1)):t.uniform1i(R.uHasEnvironmentMap,0),this.bindLights(R),R.uSectionEnabled&&t.uniform1i(R.uSectionEnabled,0);for(let P of ie)P.onBeforeDrawPrimitive?.(t,T,y,x,this.worldMatrices||[],this.gltf);t.uniform4fv(R.uBaseColor,y.baseColor),t.uniform1f(R.uMetallic,y.metallic),t.uniform1f(R.uRoughness,y.roughness),R.uClearcoat&&t.uniform2f(R.uClearcoat,y.clearcoat??0,y.clearcoatRoughness??.04),y.texture?(t.activeTexture(33984),t.bindTexture(3553,y.texture),t.uniform1i(R.uBaseColorTexture,0),t.uniform1i(R.uHasTexture,1)):t.uniform1i(R.uHasTexture,0),y.metallicRoughnessTexture?(t.activeTexture(33985),t.bindTexture(3553,y.metallicRoughnessTexture),t.uniform1i(R.uMetallicRoughnessTexture,1),t.uniform1i(R.uHasMetallicRoughnessTexture,1)):t.uniform1i(R.uHasMetallicRoughnessTexture,0),y.normalTexture?(t.activeTexture(33986),t.bindTexture(3553,y.normalTexture),t.uniform1i(R.uNormalTexture,2),t.uniform1i(R.uHasNormalTexture,1),t.uniform1f(R.uNormalScale,y.normalScale)):t.uniform1i(R.uHasNormalTexture,0),y.occlusionTexture?(t.activeTexture(33987),t.bindTexture(3553,y.occlusionTexture),t.uniform1i(R.uOcclusionTexture,3),t.uniform1i(R.uHasOcclusionTexture,1),t.uniform1f(R.uOcclusionStrength,y.occlusionStrength)):t.uniform1i(R.uHasOcclusionTexture,0),t.bindVertexArray(y.vao);let F=x.instanceMatrices;if(y.instanceCount!==void 0)t.drawElementsInstanced(4,y.indexCount,y.indexType,0,y.instanceCount);else if(F&&F.length>=16&&y.instanced&&R.uInstanced&&R.uViewProj){let P=F.length>>4;t.uniform1i(R.uInstanced,1),t.uniformMatrix4fv(R.uViewProj,!1,l),y.indices?t.drawElementsInstanced(4,y.indexCount,y.indexType,0,P):t.drawArraysInstanced(4,0,y.indexCount,P),t.uniform1i(R.uInstanced,0)}else if(F&&F.length>=16){let P=F.length>>4,B=x.instanceColors,k=J(),O=new Float32Array(9),S=[y.baseColor[0],y.baseColor[1],y.baseColor[2],y.baseColor[3]];for(let G=0;G<P;G++)ee(k,this.modelMatrix,F.subarray(G*16,G*16+16)),ee(this.mvpMatrix,l,k),me(O,k),t.uniformMatrix4fv(R.uMVP,!1,this.mvpMatrix),t.uniformMatrix4fv(R.uModel,!1,k),t.uniformMatrix3fv(R.uNormalMatrix,!1,O),B&&(S[0]=y.baseColor[0]*B[G*3],S[1]=y.baseColor[1]*B[G*3+1],S[2]=y.baseColor[2]*B[G*3+2],S[3]=y.baseColor[3],t.uniform4fv(R.uBaseColor,S)),We(t,y)}else We(t,y)}}};if(N(!1),w){for(let f of ie)f.onBeforeTransmissivePass?.(t,this);N(!0)}for(let f of ie)f.onAfterRender?.(t,this,l,e?.eye??"none",[r,i,s,o],e?.projMatrix??this.projMatrix)}disposeMeshListGpuResources(e,t){bn(this.gl,e,t)}disposeMeshGpuResources(){this.disposeMeshListGpuResources(this.meshes,this.gpuTextures),this.meshes=[],this.gpuTextures=[],this.availableVariants=[]}disposeGpuResources(){let e=this.gl;this.disposeMeshGpuResources(),this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[];for(let t of ie)t.onDestroy?.(e,this);this.environmentTexture&&(e.deleteTexture(this.environmentTexture),this.environmentTexture=null),this.renderProg&&e.deleteProgram(this.renderProg),this.pickProg&&e.deleteProgram(this.pickProg),this.pickFbo&&e.deleteFramebuffer(this.pickFbo),this.pickTexture&&e.deleteTexture(this.pickTexture),this.pickDepth&&e.deleteRenderbuffer(this.pickDepth),this.pickFbo=null,this.pickTexture=null,this.pickDepth=null}dispose(){this.stop(),this.teardownEvents(),this.disposeGpuResources()}destroy(){this.dispose()}};$e.registerPlugin=en,$e.getRegisteredPlugins=tn;function qn(n){return n+3&-4}function Zn(n,e=0){let t=(S,G)=>typeof S=="number"&&Number.isFinite(S)?S:G,r=t(n[e+12],0),i=t(n[e+13],0),s=t(n[e+14],0),o=t(n[e+0],1),l=t(n[e+1],0),a=t(n[e+2],0),u=t(n[e+4],0),c=t(n[e+5],1),h=t(n[e+6],0),m=t(n[e+8],0),b=t(n[e+9],0),g=t(n[e+10],1),d=Math.hypot(o,l,a),w=Math.hypot(u,c,h),C=Math.hypot(m,b,g);o*(c*g-b*h)-u*(l*g-b*a)+m*(l*h-c*a)<0&&(d=-d);let f=Math.abs(d)>1e-8?1/d:0,E=Math.abs(w)>1e-8?1/w:0,x=Math.abs(C)>1e-8?1/C:0,_=o*f,D=l*f,v=a*f,M=u*E,I=c*E,p=h*E,y=m*x,A=b*x,T=g*x,R=_+I+T,F=0,P=0,B=0,k=1;if(R>0){let S=.5/Math.sqrt(R+1);k=.25/S,F=(p-A)*S,P=(y-v)*S,B=(D-M)*S}else if(_>I&&_>T){let S=2*Math.sqrt(Math.max(0,1+_-I-T));S>1e-8&&(k=(p-A)/S,F=.25*S,P=(M+D)/S,B=(y+v)/S)}else if(I>T){let S=2*Math.sqrt(Math.max(0,1+I-_-T));S>1e-8&&(k=(y-v)/S,F=(M+D)/S,P=.25*S,B=(p+A)/S)}else{let S=2*Math.sqrt(Math.max(0,1+T-_-I));S>1e-8&&(k=(D-M)/S,F=(y+v)/S,P=(p+A)/S,B=.25*S)}let O=Math.hypot(F,P,B,k);return O>1e-8&&Number.isFinite(O)?(F/=O,P/=O,B/=O,k/=O):(F=0,P=0,B=0,k=1),{t:[r,i,s],r:[F,P,B,k],s:[d,w,C]}}function Jn(n){let e={};return n.grab&&(e.interactable={mode:typeof n.grab=="string"?n.grab:"2-hand"},e.movable={scaleInZ:!!n.scale,minScale:typeof n.scale=="object"?n.scale.min??.1:.1,maxScale:typeof n.scale=="object"?n.scale.max??10:10}),n.billboard&&(e.billboard={mode:typeof n.billboard=="string"?n.billboard:"capsule"}),n.follow&&(e.follow={target:typeof n.follow=="object"?n.follow.mode??"head":n.follow}),n.anchor&&(e.anchor={plane:n.anchor}),n.physics&&n.physics!=="none"&&(e.rigidbody={type:n.physics}),e}function ke(n,e){n.updateMatrixWorld(!0);let t=[],r=0,i=[],s=[],o=[],l=[],a=new Set,u=[],c=[],h=new Map,m=[],b=[];function g(M){let I=h.get(M);if(I!==void 0)return I;I=c.length,h.set(M,I);let p=M,y=p.color?.r??.8,A=p.color?.g??.8,T=p.color?.b??.8,R=p.opacity??1,F={name:p.name||"",pbrMetallicRoughness:{baseColorFactor:[y,A,T,R],metallicFactor:p.metalness??.1,roughnessFactor:p.roughness??.5},doubleSided:p.side===2||!!p.doubleSided};if(p.emissive&&(p.emissive.r>0||p.emissive.g>0||p.emissive.b>0)){let B=p.emissiveIntensity??1;F.emissiveFactor=[p.emissive.r*B,p.emissive.g*B,p.emissive.b*B]}let P={};return p.clearcoat&&p.clearcoat>0&&(P.KHR_materials_clearcoat={clearcoatFactor:p.clearcoat,clearcoatRoughnessFactor:p.clearcoatRoughness||0}),p.sheen&&p.sheen>0&&(P.KHR_materials_sheen={sheenColorFactor:p.sheenColor?[p.sheenColor.r,p.sheenColor.g,p.sheenColor.b]:[1,1,1],sheenRoughnessFactor:p.sheenRoughness||0}),p.transmission&&p.transmission>0&&(P.KHR_materials_transmission={transmissionFactor:p.transmission}),p.thickness&&p.thickness>0&&(P.KHR_materials_volume={thicknessFactor:p.thickness,attenuationDistance:p.attenuationDistance??1/0,attenuationColor:p.attenuationColor?[p.attenuationColor.r,p.attenuationColor.g,p.attenuationColor.b]:[1,1,1]}),p.ior!==void 0&&p.ior!==1.5&&(P.KHR_materials_ior={ior:p.ior}),p.dispersion&&p.dispersion>0&&(P.KHR_materials_dispersion={dispersion:p.dispersion}),p.iridescence&&p.iridescence>0&&(P.KHR_materials_iridescence={iridescenceFactor:p.iridescence,iridescenceIor:p.iridescenceIOR??1.3}),Object.keys(P).length>0&&(F.extensions=P),c.push(F),I}function d(M,I){let p=new Uint8Array(M.buffer,M.byteOffset,M.byteLength),y=qn(p.byteLength),A=new Uint8Array(y);A.set(p),t.push(A);let T=i.length;return i.push({buffer:0,byteOffset:r,byteLength:p.byteLength,target:I}),r+=y,T}function w(M,I,p,y,A,T,R){let F=d(M,p),P=s.length,B={bufferView:F,byteOffset:0,componentType:y,count:A,type:I};return T&&(B.min=T),R&&(B.max=R),s.push(B),P}n.traverse(M=>{(M.isLight||M.color&&M.intensity!==void 0)&&b.push({type:M.type,color:[M.color.r,M.color.g,M.color.b],intensity:M.intensity,position:[M.position.x,M.position.y,M.position.z]})});let C=[];function N(M){let I={name:M.name||""},p=M.position,y=M.quaternion,A=M.scale;if((p.x||p.y||p.z)&&(I.translation=[p.x,p.y,p.z]),(y.x||y.y||y.z||y.w!==1)&&(I.rotation=[y.x,y.y,y.z,y.w]),(A.x!==1||A.y!==1||A.z!==1)&&(I.scale=[A.x,A.y,A.z]),M.userData&&Object.keys(M.userData).length>0&&(I.extras=JSON.parse(JSON.stringify(M.userData,(R,F)=>{if(!(R==="__proto__"||R==="prototype"||R==="constructor"))return typeof F=="function"?void 0:F})),M.userData.xr)){let R=Jn(M.userData.xr);I.extensions={...I.extensions||{},MOZ_hubs_components:R,ANDROID_xr_scenecore:R},Q().xrTraitSerializer?.gltfNode(I,M.userData.xr),a.add("MOZ_hubs_components").add("ANDROID_xr_scenecore")}if(M.geometry){let R=M.geometry,F=R.attributes.position;if(F&&F.count>0){let P=[1/0,1/0,1/0],B=[-1/0,-1/0,-1/0];for(let U=0;U<F.count;U++){let H=F.getX(U),L=F.getY(U),V=F.getZ(U);H<P[0]&&(P[0]=H),H>B[0]&&(B[0]=H),L<P[1]&&(P[1]=L),L>B[1]&&(B[1]=L),V<P[2]&&(P[2]=V),V>B[2]&&(B[2]=V)}let O={attributes:{POSITION:w(F.array,"VEC3",34962,5126,F.count,P,B)}};if(R.attributes.normal&&(O.attributes.NORMAL=w(R.attributes.normal.array,"VEC3",34962,5126,R.attributes.normal.count)),R.attributes.uv&&(O.attributes.TEXCOORD_0=w(R.attributes.uv.array,"VEC2",34962,5126,R.attributes.uv.count)),R.index){let U=R.index.array instanceof Uint32Array;O.indices=w(R.index.array,"SCALAR",34963,U?5125:5123,R.index.count)}M.material&&(O.material=g(M.material));let S=M.userData?.variants;if(S&&typeof S=="object"){let U=new Map;for(let H of Object.keys(S)){if(!H||H==="__proto__"||H==="constructor"||H==="prototype")continue;let L=S[H];if(!L||typeof L!="object")continue;let V=m.indexOf(H);if(V===-1&&m.length<256&&(V=m.length,m.push(H)),V===-1)continue;let X=g(L),W=U.get(X);W||(W=[],U.set(X,W)),W.push(V)}if(U.size>0){let H=[];for(let[L,V]of U.entries())H.push({material:L,variants:V});O.extensions={...O.extensions||{},KHR_materials_variants:{mappings:H}},a.add("KHR_materials_variants")}}let G=M;if(G.isInstancedMesh&&typeof G.count=="number"&&G.count>0&&G.instanceMatrix?.array){let U=Math.min(1e4,Math.floor(G.count)),H=G.instanceMatrix.array,L=new Float32Array(U*3),V=new Float32Array(U*4),X=new Float32Array(U*3);for(let Y=0;Y<U;Y++){let{t:re,r:ae,s:$}=Zn(H,Y*16);L[Y*3]=re[0],L[Y*3+1]=re[1],L[Y*3+2]=re[2],V[Y*4]=ae[0],V[Y*4+1]=ae[1],V[Y*4+2]=ae[2],V[Y*4+3]=ae[3],X[Y*3]=$[0],X[Y*3+1]=$[1],X[Y*3+2]=$[2]}let W={TRANSLATION:w(L,"VEC3",0,5126,U),ROTATION:w(V,"VEC4",0,5126,U),SCALE:w(X,"VEC3",0,5126,U)};if(G.instanceColor?.array&&G.instanceColor.array.length>=U*3){let Y=new Float32Array(G.instanceColor.array.subarray(0,U*3));W._COLOR_0=w(Y,"VEC3",0,5126,U)}I.extensions={...I.extensions||{},EXT_mesh_gpu_instancing:{attributes:W}},a.add("EXT_mesh_gpu_instancing")}let z=o.length;o.push({primitives:[O],name:M.name,...I.extras?{extras:I.extras}:{}}),I.mesh=z}}let T=l.length;if(l.push(I),u.push(M),M.children.length>0){I.children=[];for(let R of M.children)I.children.push(N(R))}return T}for(let M of n.children)C.push(N(M));let f=e?.animateCallback||e?.animateFn||(typeof n.userData?.animate=="function"?n.userData.animate:typeof n.__animateFn=="function"?n.__animateFn:typeof globalThis.animate=="function"?globalThis.animate:void 0),E=[];if(typeof f=="function"&&u.length>0){let M=e?.duration??4,I=e?.fps??15,p=Math.max(2,Math.round(M*I)+1),y=new Float32Array(p),A=u.map(S=>({px:S.position.x,py:S.position.y,pz:S.position.z,qx:S.quaternion.x,qy:S.quaternion.y,qz:S.quaternion.z,qw:S.quaternion.w,sx:S.scale.x,sy:S.scale.y,sz:S.scale.z})),T=u.map(()=>new Float32Array(p*3)),R=u.map(()=>new Float32Array(p*4)),F=u.map(()=>new Float32Array(p*3));for(let S=0;S<p;S++){let G=S/(p-1)*M;y[S]=G;try{f(G)}catch{}for(let z=0;z<u.length;z++){let U=u[z];T[z][S*3]=U.position.x,T[z][S*3+1]=U.position.y,T[z][S*3+2]=U.position.z,R[z][S*4]=U.quaternion.x,R[z][S*4+1]=U.quaternion.y,R[z][S*4+2]=U.quaternion.z,R[z][S*4+3]=U.quaternion.w,F[z][S*3]=U.scale.x,F[z][S*3+1]=U.scale.y,F[z][S*3+2]=U.scale.z}}for(let S=0;S<u.length;S++){let G=u[S],z=A[S];G.position.set(z.px,z.py,z.pz),G.quaternion.set(z.qx,z.qy,z.qz,z.qw),G.scale.set(z.sx,z.sy,z.sz)}n.updateMatrixWorld(!0);let P=null,B=()=>(P===null&&(P=w(y,"SCALAR",0,5126,p,[0],[M])),P),k=[],O=[];for(let S=0;S<u.length;S++){let G=A[S],z=!1,U=!1,H=!1;for(let L=0;L<p;L++)(Math.abs(T[S][L*3]-G.px)>1e-4||Math.abs(T[S][L*3+1]-G.py)>1e-4||Math.abs(T[S][L*3+2]-G.pz)>1e-4)&&(z=!0),(Math.abs(R[S][L*4]-G.qx)>1e-4||Math.abs(R[S][L*4+1]-G.qy)>1e-4||Math.abs(R[S][L*4+2]-G.qz)>1e-4||Math.abs(R[S][L*4+3]-G.qw)>1e-4)&&(U=!0),(Math.abs(F[S][L*3]-G.sx)>1e-4||Math.abs(F[S][L*3+1]-G.sy)>1e-4||Math.abs(F[S][L*3+2]-G.sz)>1e-4)&&(H=!0);if(z){let L=w(T[S],"VEC3",0,5126,p),V=k.length;k.push({input:B(),interpolation:"LINEAR",output:L}),O.push({sampler:V,target:{node:S,path:"translation"}})}if(U){let L=w(R[S],"VEC4",0,5126,p),V=k.length;k.push({input:B(),interpolation:"LINEAR",output:L}),O.push({sampler:V,target:{node:S,path:"rotation"}})}if(H){let L=w(F[S],"VEC3",0,5126,p),V=k.length;k.push({input:B(),interpolation:"LINEAR",output:L}),O.push({sampler:V,target:{node:S,path:"scale"}})}}O.length>0&&E.push({name:"ProceduralLoop",samplers:k,channels:O})}let x=Zt(l,o,n.userData),_={asset:{version:"2.0",generator:"ThreeLiveConvert",extras:{environmentIntensity:n.environmentIntensity}},scenes:[{nodes:C}],scene:0,nodes:l,meshes:o,materials:c,accessors:s,bufferViews:i,buffers:[{byteLength:r}],...E.length>0?{animations:E}:{},...x||a.size>0?{extensionsUsed:[...x?["KHR_interactivity"]:[],...a]}:{},...x||m.length>0?{extensions:{...x?{KHR_interactivity:x}:{},...m.length>0?{KHR_materials_variants:{variants:m.map(M=>({name:M}))}}:{}}}:{}},D=new Uint8Array(r),v=0;for(let M of t)D.set(M,v),v+=M.byteLength;return{gltf:_,bin:D.buffer,lights:b,environmentIntensity:n.environmentIntensity}}function je(n){return new TextEncoder().encode(n)}function Ke(n,e){let{gltf:t,bin:r}=ke(n,e),i=JSON.stringify(t),s=je(i),o=(4-s.byteLength%4)%4,l=s.byteLength+o,a=20+l+8+r.byteLength,u=new Uint8Array(a),c=new DataView(u.buffer);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0),c.setUint32(8,a,!0),c.setUint32(12,l,!0),c.setUint32(16,1313821514,!0),u.set(s,20);for(let m=0;m<o;m++)u[20+s.byteLength+m]=32;let h=20+l;return c.setUint32(h,r.byteLength,!0),c.setUint32(h+4,5130562,!0),u.set(new Uint8Array(r),h+8),u}function Qn(n,e){n.updateMatrixWorld(!0);let t=[];return n.traverse(r=>{if(r.geometry){let i=r.geometry,s=i.attributes.position;if(!s||s.count===0)return;let o=s.count,l=new Float32Array(o*3),a=r.matrixWorld.elements;for(let v=0;v<o;v++){let M=s.getX(v),I=s.getY(v),p=s.getZ(v);l[v*3]=a[0]*M+a[4]*I+a[8]*p+a[12],l[v*3+1]=a[1]*M+a[5]*I+a[9]*p+a[13],l[v*3+2]=a[2]*M+a[6]*I+a[10]*p+a[14]}let u;if(i.attributes.normal){let v=i.attributes.normal;u=new Float32Array(o*3);let M=new Float32Array(9);me(M,a);for(let I=0;I<o;I++){let p=v.getX(I),y=v.getY(I),A=v.getZ(I),T=M[0]*p+M[3]*y+M[6]*A,R=M[1]*p+M[4]*y+M[7]*A,F=M[2]*p+M[5]*y+M[8]*A,P=Math.hypot(T,R,F)||1;u[I*3]=T/P,u[I*3+1]=R/P,u[I*3+2]=F/P}}let c;if(i.attributes.uv){let v=i.attributes.uv;c=new Float32Array(o*2);for(let M=0;M<o;M++)c[M*2]=v.getX(M),c[M*2+1]=v.getY(M)}let h;if(i.index)h=i.index.array;else{h=o>65535?new Uint32Array(o):new Uint16Array(o);for(let v=0;v<o;v++)h[v]=v}let m="DefaultMaterial",b=[.8,.8,.8],g=.5,d=.1,w=0,C=0,N=1.5,f=1,E=[0,0,0];if(r.material){let v=r.material;m=v.name||`Material_${t.length}`,v.color&&(b=[v.color.r,v.color.g,v.color.b]),typeof v.roughness=="number"&&(g=v.roughness),typeof v.metalness=="number"&&(d=v.metalness),typeof v.clearcoat=="number"&&(w=v.clearcoat),typeof v.clearcoatRoughness=="number"&&(C=v.clearcoatRoughness),typeof v.ior=="number"&&(N=v.ior);let M=typeof v.opacity=="number"?v.opacity:1,I=typeof v.transmission=="number"?v.transmission:0;if(f=M*(1-I),v.emissive&&(v.emissive.r>0||v.emissive.g>0||v.emissive.b>0)){let p=v.emissiveIntensity??1;E=[v.emissive.r*p,v.emissive.g*p,v.emissive.b*p]}}let x,_=e?.animateCallback||e?.animateFn||(typeof n.userData?.animate=="function"?n.userData.animate:typeof n.__animateFn=="function"?n.__animateFn:typeof globalThis.animate=="function"?globalThis.animate:void 0);if(typeof _=="function"){let v=e?.duration??4,M=e?.fps??4,I=Math.max(2,Math.round(v*M)+1),p=[],y=[],A=[],T=[],R=[r.position.x,r.position.y,r.position.z],F=[r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w],P=[r.scale.x,r.scale.y,r.scale.z],B=!1;for(let k=0;k<I;k++){let O=k/(I-1)*v;p.push(O);try{_(O)}catch{}y.push([r.position.x,r.position.y,r.position.z]),A.push([r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w]),T.push([r.scale.x,r.scale.y,r.scale.z]),(Math.abs(r.position.x-R[0])>1e-4||Math.abs(r.position.y-R[1])>1e-4||Math.abs(r.position.z-R[2])>1e-4||Math.abs(r.quaternion.x-F[0])>1e-4||Math.abs(r.quaternion.y-F[1])>1e-4||Math.abs(r.quaternion.z-F[2])>1e-4||Math.abs(r.quaternion.w-F[3])>1e-4||Math.abs(r.scale.x-P[0])>1e-4)&&(B=!0)}r.position.set(R[0],R[1],R[2]),r.quaternion.set(F[0],F[1],F[2],F[3]),r.scale.set(P[0],P[1],P[2]),B&&(x={times:p,translations:y,rotations:A,scales:T})}let D=r;if(D.isInstancedMesh&&typeof D.count=="number"&&D.count>0&&D.instanceMatrix?.array){let v=Math.min(1e3,Math.floor(D.count)),M=D.instanceMatrix.array,I=D.instanceColor?.array,p=r.name||`Mesh_${t.length}`,y=new Float32Array(16),A=new Float32Array(9);for(let T=0;T<v;T++){let R=M.subarray(T*16,(T+1)*16);ee(y,a,R);let F=new Float32Array(o*3);for(let O=0;O<o;O++){let S=s.getX(O),G=s.getY(O),z=s.getZ(O);F[O*3]=y[0]*S+y[4]*G+y[8]*z+y[12],F[O*3+1]=y[1]*S+y[5]*G+y[9]*z+y[13],F[O*3+2]=y[2]*S+y[6]*G+y[10]*z+y[14]}let P;if(i.attributes.normal){let O=i.attributes.normal;P=new Float32Array(o*3),me(A,y);for(let S=0;S<o;S++){let G=O.getX(S),z=O.getY(S),U=O.getZ(S),H=A[0]*G+A[3]*z+A[6]*U,L=A[1]*G+A[4]*z+A[7]*U,V=A[2]*G+A[5]*z+A[8]*U,X=Math.hypot(H,L,V)||1;P[S*3]=H/X,P[S*3+1]=L/X,P[S*3+2]=V/X}}let B=b,k=m;I&&I.length>=(T+1)*3&&(B=[b[0]*I[T*3],b[1]*I[T*3+1],b[2]*I[T*3+2]],k=`${m}_inst_${T}`),t.push({name:`${p}_${T}`,positions:F,indices:h,normals:P,uvs:c,materialName:k,color:B,roughness:g,metallic:d,clearcoat:w,clearcoatRoughness:C,ior:N,opacity:f,emissiveColor:E,xrTraits:r.userData?.xr})}return}t.push({name:r.name||`Mesh_${t.length}`,positions:l,indices:h,normals:u,uvs:c,materialName:m,color:b,roughness:g,metallic:d,clearcoat:w,clearcoatRoughness:C,ior:N,opacity:f,emissiveColor:E,xrTraits:r.userData?.xr,timeSamples:x})}}),t}function xn(n){let e=[],t=n.gltf,r=Q().decoders.get("meshopt");r&&typeof r.decodeBufferViews=="function"&&r.decodeBufferViews(t,n);let i=n.bin,s=i instanceof ArrayBuffer?i:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),o=t.accessors||[],l=t.bufferViews||[],a=t.materials||[],u=t.meshes||[],c=t.nodes||[];function h(g){let d=o[g];if(!d)throw new Error(`Accessor ${g} not found`);let w=l[d.bufferView||0],C=(w.byteOffset||0)+(d.byteOffset||0),N=w.byteLength||0,f=s.slice(C,C+N);return{acc:d,buffer:f}}let m=new Map;if(c.length>0){let g=He(t);for(let d=0;d<g.length;d++)m.set(d,g[d])}function b(g,d,w,C){let N=u[g];if(!N)return;let f=new Float32Array(9);me(f,d);for(let E=0;E<(N.primitives||[]).length;E++){let x=N.primitives[E],_=x.attributes?.POSITION;if(_===void 0)continue;let{acc:D,buffer:v}=h(_),M=new Float32Array(v,0,D.count*3),I=new Float32Array(M.length);for(let L=0;L<D.count;L++){let V=M[L*3],X=M[L*3+1],W=M[L*3+2];I[L*3]=d[0]*V+d[4]*X+d[8]*W+d[12],I[L*3+1]=d[1]*V+d[5]*X+d[9]*W+d[13],I[L*3+2]=d[2]*V+d[6]*X+d[10]*W+d[14]}let p,y=x.attributes?.NORMAL;if(y!==void 0){let{acc:L,buffer:V}=h(y),X=new Float32Array(V,0,L.count*3);p=new Float32Array(X.length);for(let W=0;W<L.count;W++){let Y=X[W*3],re=X[W*3+1],ae=X[W*3+2],$=f[0]*Y+f[3]*re+f[6]*ae,q=f[1]*Y+f[4]*re+f[7]*ae,se=f[2]*Y+f[5]*re+f[8]*ae,ce=Math.hypot($,q,se)||1;p[W*3]=$/ce,p[W*3+1]=q/ce,p[W*3+2]=se/ce}}let A,T=x.attributes?.TEXCOORD_0;if(T!==void 0){let{acc:L,buffer:V}=h(T);A=new Float32Array(V,0,L.count*2)}let R;if(x.indices!==void 0){let{acc:L,buffer:V}=h(x.indices);L.componentType===5125?R=new Uint32Array(V,0,L.count):R=new Uint16Array(V,0,L.count);let X=D.count;for(let W of R)if(W>=X)throw new Error(`SecurityError: Index buffer value (${W}) out of vertex bounds [0, ${X}).`)}else{let L=D.count;R=L>65535?new Uint32Array(L):new Uint16Array(L);for(let V=0;V<L;V++)R[V]=V}let F="DefaultMaterial",P=[.8,.8,.8],B=.5,k=.1,O=0,S=0,G=1.5,z=1,U=[0,0,0];if(x.material!==void 0&&a[x.material]){let L=a[x.material];F=L.name||`Material_${x.material}`;let V=L.pbrMetallicRoughness||{},X=1;Array.isArray(V.baseColorFactor)&&(P=[V.baseColorFactor[0],V.baseColorFactor[1],V.baseColorFactor[2]],typeof V.baseColorFactor[3]=="number"&&(X=V.baseColorFactor[3])),typeof V.roughnessFactor=="number"&&(B=V.roughnessFactor),typeof V.metallicFactor=="number"&&(k=V.metallicFactor),Array.isArray(L.emissiveFactor)&&L.emissiveFactor.length>=3&&(U=[L.emissiveFactor[0],L.emissiveFactor[1],L.emissiveFactor[2]]);let W=L.extensions||{};W.KHR_materials_clearcoat&&(O=W.KHR_materials_clearcoat.clearcoatFactor??0,S=W.KHR_materials_clearcoat.clearcoatRoughnessFactor??0),W.KHR_materials_ior&&typeof W.KHR_materials_ior.ior=="number"&&(G=W.KHR_materials_ior.ior);let Y=W.KHR_materials_transmission?.transmissionFactor??0;z=X*(1-Y)}let H=(N.primitives||[]).length>1?`${w}_p${E}`:w;e.push({name:H,positions:I,indices:R,normals:p,uvs:A,materialName:F,color:P,roughness:B,metallic:k,clearcoat:O,clearcoatRoughness:S,ior:G,opacity:z,emissiveColor:U,xrTraits:C?.xr||N.extras?.xr})}}if(c.length>0)for(let g=0;g<c.length;g++){let d=c[g];if(d.mesh!==void 0&&d.mesh<u.length){let w=m.get(g)||J(),C=d.name||u[d.mesh].name||`Node_${g}`,N=d.extensions?.EXT_mesh_gpu_instancing?.attributes;if(N&&typeof N=="object"){let f=N.TRANSLATION,E=N.ROTATION,x=N.SCALE,_=f!==void 0?(()=>{let{acc:I,buffer:p}=h(f);return new Float32Array(p,0,I.count*3)})():null,D=E!==void 0?(()=>{let{acc:I,buffer:p}=h(E);return new Float32Array(p,0,I.count*4)})():null,v=x!==void 0?(()=>{let{acc:I,buffer:p}=h(x);return new Float32Array(p,0,I.count*3)})():null,M=Math.min(1e3,_?_.length/3:D?D.length/4:v?v.length/3:0);if(M>0){let I=new Float32Array(16),p=new Float32Array(16);for(let y=0;y<M;y++){let A=_?[_[y*3],_[y*3+1],_[y*3+2]]:[0,0,0],T=D?[D[y*4],D[y*4+1],D[y*4+2],D[y*4+3]]:[0,0,0,1],R=v?[v[y*3],v[y*3+1],v[y*3+2]]:[1,1,1];Me(I,T,A,R),ee(p,w,I),b(d.mesh,p,`${C}_${y}`,d.extras)}continue}}b(d.mesh,w,C,d.extras)}}else{let g=J();for(let d=0;d<u.length;d++){let w=u[d].name||`Mesh_${d}`;b(d,g,w,u[d].extras)}}return e}function xt(n,e){if(!n||typeof n!="string")return e;let t=n.replace(/[^A-Za-z0-9_]/g,"_");return/^[0-9]/.test(t)&&(t="_"+t),t||e}function yn(n){return String(n??"").replace(/[\x00-\x1f\x7f]/g,"").replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function j(n){if(!Number.isFinite(n)||Math.abs(n)<1e-7)return"0";let e=Number(n.toFixed(5)).toString();return e.indexOf(".")===-1?`${e}.0`:e}function gn(n){let e=n.length/3,t=new Array(e);for(let r=0;r<e;r++)t[r]=`(${j(n[r*3])}, ${j(n[r*3+1])}, ${j(n[r*3+2])})`;return t.join(", ")}function er(n,e){let t=new Array(e);for(let r=0;r<e;r++)t[r]=`(${j(n[r*2])}, ${j(1-n[r*2+1])})`;return t.join(", ")}function tr(n){return Array.from(n).join(", ")}function vt(n){let e=new Map;for(let a of n){let u=xt(a.materialName,"DefaultMaterial");e.has(u)||e.set(u,{color:a.color||[.8,.8,.8],roughness:a.roughness??.5,metallic:a.metallic??0,clearcoat:a.clearcoat??0,clearcoatRoughness:a.clearcoatRoughness??0,ior:a.ior??1.5,opacity:a.opacity??1,emissiveColor:a.emissiveColor||[0,0,0]})}let t=0,r=null;for(let a of n){if(a.timeSamples&&a.timeSamples.times.length>0){let u=a.timeSamples.times[a.timeSamples.times.length-1];u>t&&(t=u)}a.xrTraits?.anchor&&!r&&(r=a.xrTraits.anchor==="vertical"||a.xrTraits.anchor==="wall"?"vertical":"horizontal")}let i="";t>0&&(i=`startTimeCode = 0
|
|
253
|
-
endTimeCode = ${
|
|
249
|
+
void main(){fragColor=uColorId;}`;function ve(e,t,i){let r={};for(let s of i)r[s]=e.getUniformLocation(t,s);return r}var ii=["uMVP","uModel","uInstanced","uViewProj","uNormalMatrix","uUvTransform","uBaseColor","uMetallic","uRoughness","uClearcoat","uEmissive","uCameraPos","uBaseColorTexture","uHasTexture","uMetallicRoughnessTexture","uHasMetallicRoughnessTexture","uNormalTexture","uHasNormalTexture","uNormalScale","uOcclusionTexture","uHasOcclusionTexture","uOcclusionStrength","uToneMapping","uEnvironmentMap","uHasEnvironmentMap","uAmbientColor","uNumDirLights","uDirLightDir","uDirLightColor","uNumPointLights","uPointLightPos","uPointLightColor","uPointLightSpotDir","uPointLightSpotCone","uEnvIntensity","uExposure","uViewportSize","uSectionPlane","uSectionEnabled"];function ri(){let e=ut().xrDepthShader;return{fs:Jr.replace("/*XRD_U*/",e?.uniformsGLSL||"").replace("/*XRD_O*/",e?.occlusionGLSL||""),uniforms:e?[...ii,...e.uniformNames]:ii}}function es(e){if(typeof e!="string")return null;let t=e.trim();if(!t||/[\x00-\x1f\x7f]/.test(t))return null;let i=t.toLowerCase();return i.startsWith("data:")?/^data:image\/(png|jpeg|jpg|webp|ktx2|avif)(;|,)/i.test(t)?t:null:i.startsWith("https://")||i.startsWith("blob:")?t:i.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(t)||/(^|[\\/])\.\.([\\/]|$)/.test(t)?null:t}function Me(e,t,i,r,s,n,o,a){if(r===void 0||!t.accessors?.[r])return null;let h=Ze(t,i,t.accessors[r],n);if(!h)return null;a&&(h=h.slice(),Xr(h,a));let l=e.createBuffer();return o.push(l),e.bindBuffer(34962,l),e.bufferData(34962,h,35044),e.enableVertexAttribArray(s),e.vertexAttribPointer(s,n,5126,!1,0,0),h}function we(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,t):1}function si(e,t,i){let r=ri(),s=ei,n=r.fs,o=!1;for(let h of mt)if(h.onResolveShader){let l=h.onResolveShader(t,i,s,n);l&&(s=l.vs,n=l.fs,o=!0)}let a=o?be(e,s,n):null;return{program:a,uniforms:a?ve(e,a,r.uniforms):null}}function is(e,t,i){let r=t.instanceMatrices;if(!r||r.length<16||typeof e.vertexAttribDivisor!="function"||typeof e.drawElementsInstanced!="function")return!1;let s=r.length>>4,n=t.instanceColors,o=new Float32Array(s*20);for(let h=0;h<s;h++)o.set(r.subarray(h*16,h*16+16),h*20),o[h*20+16]=n?n[h*3]:1,o[h*20+17]=n?n[h*3+1]:1,o[h*20+18]=n?n[h*3+2]:1,o[h*20+19]=1;let a=e.createBuffer();i.push(a),e.bindBuffer(34962,a),e.bufferData(34962,o,35044);for(let h=0;h<5;h++)e.enableVertexAttribArray(8+h),e.vertexAttribPointer(8+h,4,5126,!1,80,h*16),e.vertexAttribDivisor(8+h,1);return!0}function rs(e,t){let i=e.materials?.[t?.material];if(!i)return null;let r=[i.pbrMetallicRoughness?.baseColorTexture,i.pbrMetallicRoughness?.metallicRoughnessTexture,i.normalTexture,i.occlusionTexture,i.emissiveTexture];for(let s of r){let n=s?.extensions?.KHR_texture_transform;if(n&&typeof n=="object")return n}return null}var Ns=Object.freeze({maxMeshes:1e3,maxTextures:64,maxVertices:1e6,maxIndices:3e6}),ni=Object.freeze({maxMeshes:1/0,maxTextures:1/0,maxVertices:1/0,maxIndices:1/0});function ee(e,t){t.indices?e.drawElements(4,t.indexCount,t.indexType,0):e.drawArrays(4,0,t.indexCount)}function ai(e,t){let i=e?.pbrMetallicRoughness,r=i?.baseColorFactor,s=e?.extensions?.KHR_materials_clearcoat,n=o=>o!==void 0&&t[o.index]?t[o.index]:null;return{baseColor:r?[r[0],r[1],r[2],r[3]??1]:[.8,.8,.8,1],metallic:i?.metallicFactor??.1,roughness:i?.roughnessFactor??.5,clearcoat:s?s.clearcoatFactor??1:0,clearcoatRoughness:Math.max(.04,s?.clearcoatRoughnessFactor??.04),texture:n(i?.baseColorTexture),metallicRoughnessTexture:n(i?.metallicRoughnessTexture),normalTexture:n(e?.normalTexture),normalScale:e?.normalTexture?.scale??1,occlusionTexture:n(e?.occlusionTexture),occlusionStrength:e?.occlusionTexture?.strength??1,isTransmissive:(e?.extensions?.KHR_materials_transmission?.transmissionFactor??0)>0}}function oi(e,t,i){let r=new Set,s=n=>{n&&!r.has(n)&&(r.add(n),e.deleteTexture(n))};for(let n of t)for(let o of n.primitives){if(o.vao&&e.deleteVertexArray(o.vao),o.buffers)for(let h of o.buffers)e.deleteBuffer(h);s(o.texture),s(o.metallicRoughnessTexture),s(o.normalTexture),s(o.occlusionTexture);let a=new Set;o.customProgram&&a.add(o.customProgram);for(let h of o.programCache?.values()??[])h.program&&a.add(h.program);for(let h of a)e.deleteProgram(h)}if(i)for(let n of i)s(n)}function li(e,t,i=ni,r){let s={meshes:[],mesh:null,gpuTextures:[],vao:null,buffers:[]};try{return ss(e,t,i,r,s)}catch(n){let o=s.mesh&&!s.meshes.includes(s.mesh)?[...s.meshes,s.mesh]:s.meshes;oi(e,o,s.gpuTextures),s.vao&&e.deleteVertexArray(s.vao);for(let a of s.buffers)e.deleteBuffer(a);throw n}}function ss(e,t,i,r,s){if(!t||!t.gltf)throw new Error("Invalid GLBData passed to buildGpuScene: missing gltf object.");let{gltf:n}=t,o=Vt("meshopt");o?.decodeBufferViews&&o.decodeBufferViews(n,t);let a=t.bin,h=[];s.meshes=h;let l=[],c=n.extensions?.KHR_materials_variants;c&&Array.isArray(c.variants)&&c.variants.forEach((C,d)=>{l.push(typeof C?.name=="string"&&C.name?C.name:`Variant_${d}`)});let f=jr(n),y=[];if(Array.isArray(n.nodes))for(let C=0;C<n.nodes.length;C++){let d=n.nodes[C];d.mesh!==void 0&&n.meshes&&n.meshes[d.mesh]&&y.push({node:d,nodeIdx:C,meshIdx:d.mesh})}let g=y.length>0?y:(n.meshes||[]).map((C,d)=>({node:C,nodeIdx:-1,meshIdx:d})),u=[],b=Array.isArray(t.lights)&&t.lights.length>0?t.lights:Array.isArray(n.asset?.extras?.lights)&&n.asset.extras.lights.length>0?n.asset.extras.lights:null;if(b)for(let C of b)u.push({...C,type:C.type||C.light_type||"point",innerConeAngle:C.innerConeAngle??C.inner_cone_angle,outerConeAngle:C.outerConeAngle??C.outer_cone_angle});else if(n.extensions?.KHR_lights_punctual?.lights){let C=n.extensions.KHR_lights_punctual.lights;for(let d of C){let k=d.type==="directional"?"directional":d.type==="point"?"point":d.type==="spot"?"spot":"ambient";u.push({type:k,color:d.color||[1,1,1],intensity:d.intensity!==void 0?d.intensity:1})}}if(u.length===0&&(u.push({type:"ambient",color:[1,1,1],intensity:.35}),u.push({type:"directional",color:[1,1,1],intensity:.85,direction:[.5,1,.8]})),g.length>i.maxMeshes)throw new Error(`SecurityError: GLB scene exceeds host mesh limit (${i.maxMeshes}). Found: ${g.length}`);let w=[];if(s.gpuTextures=w,n.textures&&n.images){if(n.textures.length>i.maxTextures)throw new Error(`SecurityError: GLB scene exceeds host texture limit (${i.maxTextures}). Found: ${n.textures.length}`);for(let C=0;C<n.textures.length;C++){let d=n.textures[C],k=n.images[d.source];if(k){let $=e.createTexture();e.bindTexture(3553,$),e.texImage2D(3553,0,6408,1,1,0,6408,5121,new Uint8Array([255,255,255,255])),e.texParameteri(3553,10242,10497),e.texParameteri(3553,10243,10497),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729);let S=D=>{e.bindTexture(3553,$),e.texImage2D(3553,0,6408,6408,5121,D),e.generateMipmap(3553),r?.()};if(k.bufferView!==void 0){let D=n.bufferViews[k.bufferView],T=D.byteOffset||0,P=new Blob([a.slice(T,T+D.byteLength)],{type:k.mimeType||"image/png"});typeof createImageBitmap=="function"&&createImageBitmap(P).then(S).catch(()=>{})}else if(k.uri){let D=es(k.uri);if(D){let T=new Image;T.crossOrigin="anonymous",T.referrerPolicy="no-referrer",T.onload=()=>S(T),T.src=D}else console.warn("[Three-Live Security] Blocked unsafe glTF image URI:",k.uri)}w.push($)}else w.push(null)}}let M=[1/0,1/0,1/0],x=[-1/0,-1/0,-1/0],m=0,p=0;for(let C=0;C<g.length;C++){let d=g[C],k=n.meshes[d.meshIdx],$=d.nodeIdx>=0?f[d.nodeIdx]:ht(),S=new Float32Array(9);Pt(S,$);let D={name:d.node.name||k.name||`Mesh_${d.meshIdx}`,nodeIndex:d.nodeIdx,transform:$,normalMatrix:S,primitives:[],extras:d.node.extras||k.extras,...d.node?.visible===!1||d.node?.extensions?.KHR_node_visibility?.visible===!1?{visible:!1}:{}};s.mesh=D;let T=d.node?.extensions?.EXT_mesh_gpu_instancing;if(T&&T.attributes&&typeof T.attributes=="object"){let P=T.attributes,j=P.TRANSLATION!==void 0?n.accessors?.[P.TRANSLATION]:null,W=P.ROTATION!==void 0?n.accessors?.[P.ROTATION]:null,V=P.SCALE!==void 0?n.accessors?.[P.SCALE]:null,Z=P._COLOR_0!==void 0?n.accessors?.[P._COLOR_0]:null,U=Number(j?.count??W?.count??V?.count??0);if(!Number.isFinite(U)||U<0||U>1e4)throw new Error(`SecurityError: EXT_mesh_gpu_instancing exceeds maximum instance limit (10000). Found: ${U}`);if(U>0){let X=(z,tt)=>{if(!z||z.bufferView===void 0||!n.bufferViews?.[z.bufferView])return null;let et=z.componentType??5126,rt=it=>(console.warn(`[three-live] EXT_mesh_gpu_instancing: skipping accessor (${it})`),null);if(et!==5120&&et!==5121&&et!==5122&&et!==5123&&et!==5126)return rt(`componentType ${et}`);if(!(Number(z.count)>=U))return rt(`count ${z.count} < ${U}`);let J=null;try{J=Ze(n,a,{...z,count:U},tt)}catch{return rt("out of bounds")}return!J||!J.every(Number.isFinite)?rt("non-finite value"):J},O=X(j,3),G=X(W,4),F=X(V,3),H=Z?.type==="VEC4"?4:3,B=X(Z,H),K=new Float32Array(U*16),q=ht();for(let z=0;z<U;z++){let tt=O?[O[z*3],O[z*3+1],O[z*3+2]]:[0,0,0],et=G?[G[z*4],G[z*4+1],G[z*4+2],G[z*4+3]]:[0,0,0,1],rt=F?[F[z*3],F[z*3+1],F[z*3+2]]:[1,1,1];ye(q,et,tt,rt),K.set(q,z*16)}if(D.instanceMatrices=K,B){let z=new Float32Array(U*3);for(let tt=0;tt<U;tt++)z[tt*3]=B[tt*H],z[tt*3+1]=B[tt*H+1],z[tt*3+2]=B[tt*H+2];D.instanceColors=z}}}for(let P of k.primitives||[]){if(P.extensions?.KHR_draco_mesh_compression){let J=Vt("draco");J&&J.decodePrimitive(n,P,a)}let j=[],W=e.createVertexArray();s.vao=W,s.buffers=j,e.bindVertexArray(W);let V=is(e,D,j),Z=n.accessors[P.attributes.POSITION],U=Number(Z?.count??0);if(!Number.isFinite(U)||U<0||m+U>i.maxVertices)throw new Error(`SecurityError: GLB scene exceeds host vertex limit (${i.maxVertices}).`);if(m+=U,Z?.min&&Z?.max){let J=it=>{for(let st=0;st<3;st++){let wt=it[12+st],nt=it[12+st];for(let ot=0;ot<3;ot++){let ct=it[ot*4+st]*Z.min[ot],lt=it[ot*4+st]*Z.max[ot];wt+=ct<lt?ct:lt,nt+=ct>lt?ct:lt}wt<M[st]&&(M[st]=wt),nt>x[st]&&(x[st]=nt)}};if(D.instanceMatrices&&D.instanceMatrices.length>=16){let it=D.instanceMatrices.length>>4,st=ht();for(let wt=0;wt<it;wt++){let nt=D.instanceMatrices.subarray(wt*16,wt*16+16);dt(st,$,nt),J(st)}}else J($)}let X=Me(e,n,a,P.attributes.POSITION,0,3,j);Me(e,n,a,P.attributes.NORMAL,1,3,j),Me(e,n,a,P.attributes.TEXCOORD_0,2,2,j,rs(n,P));let O=0,G=5123,F=null;if(P.indices!==void 0){let J=n.accessors[P.indices],it=(n.bufferViews[J.bufferView].byteOffset||0)+(J.byteOffset||0);if(O=Number(J.count??0),!Number.isFinite(O)||O<0||p+O>i.maxIndices)throw new Error(`SecurityError: GLB scene exceeds host index limit (${i.maxIndices}).`);p+=O,G=J.componentType===5125?5125:5123;let st=e.createBuffer();j.push(st),e.bindBuffer(34963,st),J.componentType===5125?F=new Uint32Array(a,it,J.count):J.componentType===5121?F=Uint16Array.from(new Uint8Array(a,it,J.count)):F=it%2===0?new Uint16Array(a,it,J.count):new Uint16Array(a.slice(it,it+J.count*2)),e.bufferData(34963,F,35044)}else O=Z.count;let H={};for(let J of mt)if(J.onBuildPrimitiveVAO){let it=J.onBuildPrimitiveVAO(e,W,P,n,a);it&&(H[J.name]=it)}e.bindVertexArray(null);let B=n.materials&&P.material!==void 0?n.materials[P.material]:null,{program:K,uniforms:q}=si(e,P,B),z=ai(B,w),tt=!!(B?.extensions?.KHR_materials_transmission||H.materials?.isTransmissive),et=P.extensions?.KHR_materials_variants?.mappings,rt=Array.isArray(et)?et.filter(J=>J&&typeof J.material=="number"&&Array.isArray(J.variants)).map(J=>({material:J.material|0,variants:J.variants.map(it=>Number(it)|0)})):void 0;D.primitives.push({vao:W,instanced:V,indexCount:O,indexType:G,...z,positions:X,indices:F,buffers:j,materialIndex:P.material,defaultMaterialIndex:P.material,variantMappings:rt,primitiveDef:P,programCache:new Map([[P.material??-1,{program:K,uniforms:q}]]),pluginData:H,customProgram:K,customUniforms:q,isTransmissive:tt})}h.push(D)}isFinite(M[0])||(M=[-1,-1,-1]),isFinite(x[0])||(x=[1,1,1]);let v=[(M[0]+x[0])/2,(M[1]+x[1])/2,(M[2]+x[2])/2],R=x[0]-M[0],L=x[1]-M[1],I=x[2]-M[2],N=Math.max(Math.hypot(R,L,I)/2,.5),_=[M[0],M[1],M[2]],A=[x[0],x[1],x[2]],E=t.animations;if(!E){for(let C of mt)if(C.onParseGLB?.(t),t.animations){E=t.animations;break}}return E||(E=[]),{meshes:h,bounds:{center:v,radius:N,min:_,max:A},lights:u,animations:E,worldMatrices:f,gpuTextures:w,availableVariants:l}}function Gt(e){let t=e.customTarget||e.bounds.center,i=e.currDistance*Math.cos(e.currPhi);return[t[0]+i*Math.sin(e.currTheta),t[1]+e.currDistance*Math.sin(e.currPhi),t[2]+i*Math.cos(e.currTheta)]}var hi=class{constructor(e,t,i){this.supportsInstanceOffsets=!0,this.meshes=[],this.backdropMeshes=[],this.bounds={center:[0,0,0],radius:1,min:[-1,-1,-1],max:[1,1,1]},this.lights=[],this.modelRootMatrix=ht(),this.clearColor=[0,0,0,0],this.envIntensity=1,this.exposure=1,this.shadowIntensity=0,this.shadowSoftness=.5,this.toneMapping="neutral",this.environmentTexture=null,this.animations=[],this.currentClip=null,this.animationTime=0,this.isPlayingAnimation=!1,this.autoplay=!1,this.animationName="",this.gpuTextures=[],this.availableVariants=[],this.activeVariantName=null,this.gltf=null,this.worldMatrices=[],this.initialNodeTransforms=[],this.projMatrix=ht(),this.viewMatrix=ht(),this.activeViewMatrix=null,this.modelMatrix=ht(),this.mvpMatrix=ht(),this.normalMatrix=new Float32Array(9),this.initialTheta=.6,this.initialPhi=.35,this.initialDistance=null,this.customDistance=!1,this.distanceMode="auto",this.initialCustomTarget=null,this.customTarget=null,this.fov=Math.PI/4,this.minTheta=-1/0,this.maxTheta=1/0,this.minPhi=-Math.PI*.48,this.maxPhi=Math.PI*.48,this.minDistanceLimit=null,this.maxDistanceLimit=null,this.activePointers=new Map,this.isPanning=!1,this.targetTheta=.6,this.currTheta=.6,this.targetPhi=.35,this.currPhi=.35,this.targetDistance=3,this.currDistance=3,this.autoRotate=!1,this.autoRotateSpeed=Math.PI/6,this.autoRotateDelay=3e3,this.lastInteractionTime=-1/0,this.turntableRotation=0,this.isPointerDown=!1,this.interactive=!0,this.skyboxTexture=null,this.lastPointerX=0,this.lastPointerY=0,this.totalDragDist=0,this.selectedMeshName="",this.pickFbo=null,this.pickTexture=null,this.pickDepth=null,this.pickFboWidth=0,this.pickFboHeight=0,this.animFrameId=null,this.isVisible=!0,this.xrSessionActive=!1,this.lastTime=0,this.lastReportedTheta=-999,this.lastReportedPhi=-999,this.lastReportedZoom=-999,this.boundPointerDown=null,this.boundPointerMove=null,this.boundPointerUp=null,this.boundWheel=null,this.boundKeyDown=null,this.boundContextMenu=null,this.boundSetCamera=null,this.boundResetCamera=null,this.contextLost=!1,this.lastGlbData=null,this.boundContextLost=null,this.boundContextRestored=null,this.stereoSBS=!1,this.renderErrorReported=!1,this.xrDepthState={enabled:!1,texture:null,uvTransform:ht(),rawValueToMeters:.001,format:0},this.container=e;let r,s;if(t&&typeof t.getContext=="function"?(r=t,s=i):(s=t,r=s?.canvas),!r){let a=e.querySelector("canvas");a||(a=document.createElement("canvas"),a.style.width="100%",a.style.height="100%",a.style.display="block",a.style.touchAction="none",e.prepend(a)),r=a}this.canvas=r,this.opts=s||{},this.opts.clearColor&&(this.clearColor=this.opts.clearColor);let n=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.opts.autoRotate!==void 0?this.autoRotate=this.opts.autoRotate&&!n:n&&(this.autoRotate=!1),this.opts.autoRotateSpeed!==void 0&&(this.autoRotateSpeed=this.opts.autoRotateSpeed),this.opts.autoRotateDelay!==void 0&&(this.autoRotateDelay=Math.max(0,Number(this.opts.autoRotateDelay)||0)),this.opts.exposure!==void 0&&(this.exposure=we(this.opts.exposure)),this.opts.camera&&this.setInitialCamera(this.opts.camera.theta,this.opts.camera.phi,this.opts.camera.distance,this.opts.camera.zoom),this.opts.shadowIntensity!==void 0&&(this.shadowIntensity=Math.max(0,Math.min(1,Number(this.opts.shadowIntensity)||0))),this.opts.shadowSoftness!==void 0&&(this.shadowSoftness=Math.max(0,Math.min(1,Number(this.opts.shadowSoftness)||0))),this.opts.toneMapping!==void 0&&(this.toneMapping=xe(this.opts.toneMapping)),this.opts.autoplay!==void 0&&(this.autoplay=this.opts.autoplay),this.opts.animationName!==void 0&&(this.animationName=this.opts.animationName),this.opts.variantName!==void 0&&(this.activeVariantName=this.opts.variantName||null),this.opts.fieldOfView!==void 0&&(this.fov=this.opts.fieldOfView*Math.PI/180),this.opts.distanceMode!==void 0&&(this.distanceMode=this.opts.distanceMode),this.opts.cameraTarget!==void 0&&(this.setTarget(this.opts.cameraTarget[0],this.opts.cameraTarget[1],this.opts.cameraTarget[2]),this.initialCustomTarget=[...this.opts.cameraTarget]),(this.opts.minCameraOrbit||this.opts.maxCameraOrbit)&&this.setOrbitLimits({minTheta:this.opts.minCameraOrbit?.theta,maxTheta:this.opts.maxCameraOrbit?.theta,minPhi:this.opts.minCameraOrbit?.phi,maxPhi:this.opts.maxCameraOrbit?.phi,minDistance:this.opts.minCameraOrbit?.distance,maxDistance:this.opts.maxCameraOrbit?.distance});let o=r.getContext("webgl2",{antialias:!0,alpha:!0,xrCompatible:!0});if(!o)throw new Error("WebGL2 not supported");this.gl=o,this.initGlState(),this.setupEvents(),this.setupContextLossHandling(),this.opts.environmentImage&&this.setEnvironmentImage(this.opts.environmentImage).catch(()=>{}),typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}static registerDecoder(e,t){Yr(e,t)}static getDecoder(e){return Vt(e)}setupContextLossHandling(){let e=this.canvas;typeof e?.addEventListener=="function"&&(this.boundContextLost=t=>{t.preventDefault?.(),this.contextLost=!0,this.stop()},this.boundContextRestored=()=>this.restoreContext(),e.addEventListener("webglcontextlost",this.boundContextLost),e.addEventListener("webglcontextrestored",this.boundContextRestored))}initGlState(){let e=this.gl,t=ri();this.renderProg=be(e,ei,t.fs),this.pickProg=be(e,Qr,ts),this.uRender=ve(e,this.renderProg,t.uniforms),this.uPick=ve(e,this.pickProg,["uMVP","uColorId"]),this.setupPickingFbo()}restoreContext(){let e=this.gl;this.contextLost=!1,this.initGlState();for(let t of mt)t.onContextRestored?.(e,this);this.meshes=[],this.gpuTextures=[],this.environmentTexture=null,this.lastGlbData&&this.loadGLBData(this.lastGlbData,this.lastLimits),this.opts.environmentImage&&this.setEnvironmentImage(this.opts.environmentImage).catch(()=>{}),typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}setupPickingFbo(){let e=this.gl;if(typeof e.createFramebuffer!="function")return;this.pickFbo=e.createFramebuffer(),this.pickTexture=e.createTexture(),this.pickDepth=e.createRenderbuffer();let t=Math.max(1,this.canvas.width),i=Math.max(1,this.canvas.height);this.pickFboWidth=t,this.pickFboHeight=i,e.bindTexture(3553,this.pickTexture),e.texImage2D(3553,0,6408,t,i,0,6408,5121,null),e.texParameteri(3553,10241,9728),e.texParameteri(3553,10240,9728),e.bindRenderbuffer(36161,this.pickDepth),e.renderbufferStorage(36161,33189,t,i),e.bindFramebuffer(36160,this.pickFbo),e.framebufferTexture2D(36160,36064,3553,this.pickTexture,0),e.framebufferRenderbuffer(36160,36096,36161,this.pickDepth),e.bindFramebuffer(36160,null)}resizePickingFbo(e,t){if(!this.pickFbo)return;let i=this.gl,r=Math.max(1,e),s=Math.max(1,t);this.pickFboWidth=r,this.pickFboHeight=s,i.bindTexture(3553,this.pickTexture),i.texImage2D(3553,0,6408,r,s,0,6408,5121,null),i.bindRenderbuffer(36161,this.pickDepth),i.renderbufferStorage(36161,33189,r,s)}loadGLBData(e,t){let{meshes:i,bounds:r,lights:s,animations:n,worldMatrices:o,gpuTextures:a,availableVariants:h}=li(this.gl,e,t,()=>this.render());if(this.lastGlbData=e,this.lastLimits=t,this.disposeMeshGpuResources(),this.currentClip=null,this.isPlayingAnimation=!1,this.animationTime=0,this.meshes=i,this.bounds=r,this.turntableRotation=0,this.updateTurntableMatrix(),this.lights=s,this.animations=n||[],this.worldMatrices=o||[],this.gpuTextures=a||[],this.availableVariants=h||[],this.gltf=e.gltf,this.activeVariantName&&!this.applyVariantMaterial(this.activeVariantName)&&(this.activeVariantName=null),this.initialNodeTransforms=[],Array.isArray(e.gltf?.nodes))for(let f of e.gltf.nodes)this.initialNodeTransforms.push({t:f.translation?[f.translation[0],f.translation[1],f.translation[2]]:[0,0,0],r:f.rotation?[f.rotation[0],f.rotation[1],f.rotation[2],f.rotation[3]]:[0,0,0,1],s:f.scale?[f.scale[0],f.scale[1],f.scale[2]]:[1,1,1]});this.autoplay&&this.animations.length>0&&this.playAnimation(this.animationName||void 0);for(let f of mt)f.onLoadModel?.(this,this.gltf);this.customDistance||(this.initialDistance=this.distanceMode==="absolute"?3:r.radius*2.5,this.targetDistance=this.initialDistance,this.currDistance=this.initialDistance);let l=e.exposure??e.gltf?.extras?.exposure??e.gltf?.asset?.extras?.exposure;l!==void 0&&(this.exposure=we(l));let c=e.environmentIntensity??e.gltf?.extras?.environmentIntensity??e.gltf?.asset?.extras?.environmentIntensity;c!==void 0&&(this.envIntensity=Math.max(0,Number(c)||0)),this.container&&typeof this.container.hasAttribute=="function"&&this.container.hasAttribute("poster")&&this.container.removeAttribute("poster"),this.resize(),this.update(0),this.render(),this.animFrameId===null&&typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}loadGLB(e){this.loadGLBData(ti(e))}clearScene(){this.disposeMeshGpuResources(),this.lights=[],this.animations=[],this.currentClip=null,this.isPlayingAnimation=!1,this.animationTime=0,this.lastGlbData=null;for(let e of mt)e.onClearScene?.(this);this.worldMatrices=[],this.gltf=null,this.initialNodeTransforms=[],this.turntableRotation=0,this.updateTurntableMatrix(),this.gl&&this.render()}loadModel(e){this.loadGLBData(te(e))}setBackdropGLB(e,t){if(this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[],!e){this.update(0),this.render();return}let i=te(e),{meshes:r}=li(this.gl,i,ni,()=>this.render());if(t)for(let s of r)s.transform[12]+=t[0],s.transform[13]+=t[1],s.transform[14]+=t[2],Pt(s.normalMatrix,s.transform);this.backdropMeshes=r,this.update(0),this.render()}setClearColor(e,t,i,r=1){this.clearColor=[e,t,i,r]}updateMeshTransforms(e){for(let t=0;t<this.meshes.length;t++){let i=this.meshes[t],r;e instanceof Map?r=e.get(i.name)??e.get(t):Array.isArray(e)?r=e[t]:e&&typeof e=="object"&&(Object.prototype.hasOwnProperty.call(e,i.name)?r=e[i.name]:Object.prototype.hasOwnProperty.call(e,t)&&(r=e[t])),r&&r.length===16&&(i.transform.set(r),Pt(i.normalMatrix,i.transform))}}bindLights(e=this.uRender){let t=this.gl,i=[.28,.28,.28],r=[],s=[],n=[],o=[],a=[],h=[];for(let l of this.lights){let c=l.color||[1,1,1],f=l.intensity!==void 0?l.intensity:1;if(l.type==="ambient")i=[c[0]*f,c[1]*f,c[2]*f];else if(l.type==="directional"&&r.length<6){let y=l.direction||[.5,1,.8];r.push(y[0],y[1],y[2]),s.push(c[0]*f,c[1]*f,c[2]*f)}else if((l.type==="point"||l.type==="spot")&&n.length<6){let y=l.position||[0,0,0];if(n.push(y[0],y[1],y[2]),o.push(c[0]*f,c[1]*f,c[2]*f),l.type==="spot"){let g=l.direction||[0,-1,0],u=Math.max(.01,Math.min(Math.PI/2,l.outerConeAngle??Math.PI/3)),b=Math.max(0,Math.min(u-1e-4,l.innerConeAngle??0));a.push(g[0],g[1],g[2]),h.push(Math.cos(b),Math.cos(u))}else a.push(0,-1,0),h.push(-2,-3)}}r.length===0&&(r.push(.5,1,.8),s.push(1,1,1)),t.uniform3fv(e.uAmbientColor,i),t.uniform1i(e.uNumDirLights,r.length/3),r.length>0&&(t.uniform3fv(e.uDirLightDir,r),t.uniform3fv(e.uDirLightColor,s)),t.uniform1i(e.uNumPointLights,n.length/3),n.length>0&&(t.uniform3fv(e.uPointLightPos,n),t.uniform3fv(e.uPointLightColor,o),e.uPointLightSpotDir&&t.uniform3fv(e.uPointLightSpotDir,a),e.uPointLightSpotCone&&t.uniform2fv(e.uPointLightSpotCone,h)),t.uniform1f(e.uEnvIntensity,this.envIntensity)}setExposure(e){this.exposure=we(e)}getExposure(){return this.exposure}setShadow(e,t){this.shadowIntensity=Math.max(0,Math.min(1,Number(e)||0)),t!==void 0&&(this.shadowSoftness=Math.max(0,Math.min(1,Number(t)||0)))}getShadowIntensity(){return this.shadowIntensity}getShadowSoftness(){return this.shadowSoftness}setToneMapping(e){this.toneMapping=xe(e)}getToneMapping(){return this.toneMapping}async setEnvironmentImage(e){for(let t of mt)if(t.setEnvironmentImage){await t.setEnvironmentImage(this,e);return}}async setSkyboxImage(e){for(let t of mt)if(t.setSkyboxImage){await t.setSkyboxImage(this,e);return}}setInteractive(e){this.interactive=e}isInteractive(){return this.interactive}getCameraOrbit(){let e=this.currTheta,t=this.currPhi,i=this.currDistance;return{theta:e,phi:t,radius:i,toString(){return`${e.toFixed(4)}rad ${t.toFixed(4)}rad ${i.toFixed(4)}m`}}}getCameraTarget(){let e=this.customTarget||this.bounds.center;return{x:e[0],y:e[1],z:e[2],toString(){return`${e[0].toFixed(4)}m ${e[1].toFixed(4)}m ${e[2].toFixed(4)}m`}}}jumpCameraToGoal(){this.currTheta=this.targetTheta,this.currPhi=this.targetPhi,this.currDistance=this.targetDistance,this.update(0),this.render()}getModelMaterials(){let e=this.gltf?.materials?.length?this.gltf.materials:[{name:"DefaultMaterial",pbrMetallicRoughness:{}}];return e.map((t,i)=>{let r=this.meshes.flatMap(l=>l.primitives.filter(c=>c.materialIndex===i||e.length===1&&c.materialIndex===void 0)),s=r[0],n=s?[...s.baseColor]:t.pbrMetallicRoughness?.baseColorFactor||[.8,.8,.8,1],o=s?s.metallic:t.pbrMetallicRoughness?.metallicFactor??.1,a=s?s.roughness:t.pbrMetallicRoughness?.roughnessFactor??.5,h={baseColorFactor:n,metallicFactor:o,roughnessFactor:a,setBaseColorFactor:l=>{let c=[l[0],l[1],l[2],l[3]??1];h.baseColorFactor=c,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.baseColorFactor=c);for(let f of r)f.baseColor=c;this.render()},setMetallicFactor:l=>{h.metallicFactor=l,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.metallicFactor=l);for(let c of r)c.metallic=l;this.render()},setRoughnessFactor:l=>{h.roughnessFactor=l,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=l);for(let c of r)c.roughness=l;this.render()}};return{name:t.name||`Material_${i}`,pbrMetallicRoughness:h}})}playAnimation(e){if(this.animations.length!==0){if(e){let t=this.animations.find(i=>i.name===e);t&&(this.currentClip=t)}else this.currentClip||(this.currentClip=this.animations[0]);this.isPlayingAnimation=!0}}pauseAnimation(){this.isPlayingAnimation=!1}getAvailableAnimations(){return this.animations.map(e=>e.name)}getAvailableVariants(){return[...this.availableVariants]}getVariantName(){return this.activeVariantName}selectVariant(e){let t=this.applyVariantMaterial(e);return t&&this.gl&&this.render(),t}applyVariantMaterial(e){let t=e===null||e==="",i=-1;if(t)this.activeVariantName=null;else{if(i=this.availableVariants.indexOf(e),i<0)return!1;this.activeVariantName=e}let r=this.gltf?.materials;if(!Array.isArray(r))return t;for(let s of this.meshes)for(let n of s.primitives){let o=n.defaultMaterialIndex;if(!t&&Array.isArray(n.variantMappings)){for(let h of n.variantMappings)if(Array.isArray(h.variants)&&h.variants.includes(i)){o=h.material;break}}let a=o!==void 0?r[o]:void 0;n.materialIndex=a?o:void 0,Object.assign(n,ai(a,this.gpuTextures)),this.applyPrimitiveProgram(n,n.materialIndex,a??null)}return!0}applyPrimitiveProgram(e,t,i){if(!this.gl||!e.primitiveDef)return;e.programCache??(e.programCache=new Map);let r=t??-1,s=e.programCache.get(r);s||(s=si(this.gl,{...e.primitiveDef,material:t},i),e.programCache.set(r,s)),e.customProgram=s.program,e.customUniforms=s.uniforms,e.pluginData&&(e.pluginData.materials=e.isTransmissive?{isTransmissive:!0}:void 0)}setAutoplay(e){this.autoplay=e,e?this.playAnimation(this.animationName||void 0):this.pauseAnimation()}setAnimationName(e){this.animationName=e,(this.isPlayingAnimation||this.autoplay)&&this.playAnimation(e)}evaluateAnimation(e){for(let t of mt)if(t.evaluateAnimation){t.evaluateAnimation(this,e);return}}setTarget(e,t,i){this.customTarget=[e,t,i],this.gl&&(this.meshes.length>0||this.backdropMeshes.length>0)&&(this.update(0),this.render())}getTarget(){return this.customTarget?[...this.customTarget]:null}setFieldOfView(e){let t=Math.max(10,Math.min(90,e));this.fov=t*Math.PI/180}getFieldOfView(){return this.fov*180/Math.PI}setDistanceMode(e){if(this.distanceMode=e,!this.customDistance){let t=this.clampDistance(this.distanceMode==="absolute"?3:this.bounds.radius*2.5);this.initialDistance=t,this.targetDistance=t,this.currDistance=t,this.gl&&(this.meshes.length>0||this.backdropMeshes.length>0)&&(this.update(0),this.render())}}getDistanceMode(){return this.distanceMode}setOrbitLimits(e){e.minTheta!==void 0&&(this.minTheta=e.minTheta*Math.PI/180),e.maxTheta!==void 0&&(this.maxTheta=e.maxTheta*Math.PI/180),e.minPhi!==void 0&&(this.minPhi=Math.max(-Math.PI*.48,e.minPhi*Math.PI/180)),e.maxPhi!==void 0&&(this.maxPhi=Math.min(Math.PI*.48,e.maxPhi*Math.PI/180)),e.minDistance!==void 0&&(this.minDistanceLimit=e.minDistance),e.maxDistance!==void 0&&(this.maxDistanceLimit=e.maxDistance),this.targetTheta=this.clampTheta(this.targetTheta),this.targetPhi=this.clampPhi(this.targetPhi),this.targetDistance=this.clampDistance(this.targetDistance)}getOrbitLimits(){return{minTheta:isFinite(this.minTheta)?this.minTheta*180/Math.PI:void 0,maxTheta:isFinite(this.maxTheta)?this.maxTheta*180/Math.PI:void 0,minPhi:this.minPhi*180/Math.PI,maxPhi:this.maxPhi*180/Math.PI,minDistance:this.minDistanceLimit!==null?this.minDistanceLimit:void 0,maxDistance:this.maxDistanceLimit!==null?this.maxDistanceLimit:void 0}}clampTheta(e){return Math.max(this.minTheta,Math.min(this.maxTheta,e))}clampPhi(e){return Math.max(this.minPhi,Math.min(this.maxPhi,e))}clampDistance(e){let t=this.minDistanceLimit!==null?this.minDistanceLimit:this.bounds?this.bounds.radius*.5:.1,i=this.maxDistanceLimit!==null?this.maxDistanceLimit:this.bounds?this.bounds.radius*8:100;return Math.max(t,Math.min(i,e))}setCamera(e,t,i,r){e!==void 0&&(this.targetTheta=this.clampTheta(e*Math.PI/180)),t!==void 0&&(this.targetPhi=this.clampPhi(t*Math.PI/180)),i!==void 0&&i>0&&(this.targetDistance=this.clampDistance(i)),r!==void 0&&r>0&&(this.targetDistance=this.clampDistance(this.bounds.radius*2.5/r))}setInitialCamera(e,t,i,r){if(e!==void 0&&(this.initialTheta=this.clampTheta(e*Math.PI/180),this.targetTheta=this.initialTheta,this.currTheta=this.initialTheta),t!==void 0&&(this.initialPhi=this.clampPhi(t*Math.PI/180),this.targetPhi=this.initialPhi,this.currPhi=this.initialPhi),i!==void 0&&i>0){let s=this.clampDistance(i);this.initialDistance=s,this.customDistance=!0,this.targetDistance=s,this.currDistance=s}else if(r!==void 0&&r>0){let s=this.clampDistance(this.bounds.radius*2.5/r);this.initialDistance=s,this.customDistance=!0,this.targetDistance=s,this.currDistance=s}else{this.customDistance=!1;let s=this.clampDistance(this.distanceMode==="absolute"?3:this.bounds.radius*2.5);this.initialDistance=s,this.targetDistance=s,this.currDistance=s}this.gl&&(this.meshes.length>0||this.backdropMeshes.length>0)&&(this.update(0),this.render())}resetCamera(){this.targetTheta=this.clampTheta(this.initialTheta),this.targetPhi=this.clampPhi(this.initialPhi),this.initialDistance!==null?this.targetDistance=this.clampDistance(this.initialDistance):this.targetDistance=this.clampDistance(this.bounds.radius*2.5),this.initialCustomTarget?this.customTarget=[...this.initialCustomTarget]:this.customTarget=null,this.turntableRotation=0,this.updateTurntableMatrix()}projectPointToScreen(e,t){let i=ht();dt(i,this.projMatrix,this.viewMatrix);let[r,s,n]=e,o=t?t[0]:0,a=t?t[1]:0,h=t?t[2]:0,l=this.modelRootMatrix;l&&(r=l[0]*e[0]+l[4]*e[1]+l[8]*e[2]+l[12],s=l[1]*e[0]+l[5]*e[1]+l[9]*e[2]+l[13],n=l[2]*e[0]+l[6]*e[1]+l[10]*e[2]+l[14],t&&(o=l[0]*t[0]+l[4]*t[1]+l[8]*t[2],a=l[1]*t[0]+l[5]*t[1]+l[9]*t[2],h=l[2]*t[0]+l[6]*t[1]+l[10]*t[2]));let c=i[0]*r+i[4]*s+i[8]*n+i[12],f=i[1]*r+i[5]*s+i[9]*n+i[13],y=i[2]*r+i[6]*s+i[10]*n+i[14],g=i[3]*r+i[7]*s+i[11]*n+i[15];if(g<=1e-4)return{x:0,y:0,z:1,visible:!1};let u=c/g,b=f/g,w=y/g,M=this.canvas.getBoundingClientRect(),x=M.width||this.canvas.clientWidth||this.canvas.width||300,m=M.height||this.canvas.clientHeight||this.canvas.height||150,p=(u*.5+.5)*x,v=(-b*.5+.5)*m,R=u>=-1.1&&u<=1.1&&b>=-1.1&&b<=1.1&&w>=-1&&w<=1;if(R&&t){let[L,I,N]=Gt(this),_=[r-L,s-I,n-N];o*_[0]+a*_[1]+h*_[2]>.05&&(R=!1)}return{x:p,y:v,z:w,visible:R}}setSelectedMesh(e){this.selectedMeshName=e||""}getSelectedMesh(){return this.selectedMeshName}setupEvents(){let e=this.canvas,t=()=>typeof performance<"u"?performance.now():Date.now();this.boundContextMenu=i=>{i.preventDefault()},e.addEventListener("contextmenu",this.boundContextMenu),this.boundPointerDown=i=>{this.interactive&&(this.isPointerDown=!0,this.lastInteractionTime=t(),this.lastPointerX=i.clientX,this.lastPointerY=i.clientY,this.totalDragDist=0,this.activePointers.set(i.pointerId,{x:i.clientX,y:i.clientY}),this.isPanning=i.button===2||i.shiftKey||this.activePointers.size===2,e.setPointerCapture(i.pointerId))},e.addEventListener("pointerdown",this.boundPointerDown),this.boundPointerMove=i=>{if(!this.isPointerDown||!this.interactive)return;this.lastInteractionTime=t();let r=this.activePointers.get(i.pointerId)||{x:this.lastPointerX,y:this.lastPointerY},s=i.clientX-r.x,n=i.clientY-r.y;if(this.activePointers.set(i.pointerId,{x:i.clientX,y:i.clientY}),this.lastPointerX=i.clientX,this.lastPointerY=i.clientY,this.totalDragDist+=Math.hypot(s,n),this.isPanning||i.button===2||i.shiftKey||this.activePointers.size===2){let o=[this.viewMatrix[0],this.viewMatrix[4],this.viewMatrix[8]],a=[this.viewMatrix[1],this.viewMatrix[5],this.viewMatrix[9]],h=this.customTarget?[...this.customTarget]:[...this.bounds.center],l=this.currDistance/Math.max(e.clientHeight||300,1)*1.5;h[0]+=(-s*o[0]+n*a[0])*l,h[1]+=(-s*o[1]+n*a[1])*l,h[2]+=(-s*o[2]+n*a[2])*l,this.customTarget=h}else this.targetTheta=this.clampTheta(this.targetTheta-s*.008),this.targetPhi=this.clampPhi(this.targetPhi+n*.008)},e.addEventListener("pointermove",this.boundPointerMove),this.boundPointerUp=i=>{this.lastInteractionTime=t(),this.activePointers.delete(i.pointerId),this.activePointers.size===0?(this.isPointerDown=!1,this.isPanning=!1):this.activePointers.size===1&&(this.isPanning=!1);try{e.releasePointerCapture(i.pointerId)}catch{}if(this.totalDragDist<5&&i.button===0){let r=e.getBoundingClientRect(),s=Math.floor((i.clientX-r.left)*(e.width/Math.max(r.width,1))),n=Math.floor((i.clientY-r.top)*(e.height/Math.max(r.height,1)));this.performMeshPick(s,n,!0)}},e.addEventListener("pointerup",this.boundPointerUp),this.boundWheel=i=>{if(!this.interactive)return;i.preventDefault(),this.lastInteractionTime=t();let r=Math.exp(i.deltaY*.001);this.targetDistance=this.clampDistance(this.targetDistance*r)},e.addEventListener("wheel",this.boundWheel,{passive:!1}),this.boundSetCamera=i=>{let r=i.detail||{};r.reset?this.resetCamera():this.setCamera(r.theta,r.phi,r.distance,r.zoom)},this.container.addEventListener("setCamera",this.boundSetCamera),this.boundResetCamera=()=>{this.resetCamera()},this.container.addEventListener("resetCamera",this.boundResetCamera),e.tabIndex!==void 0&&e.tabIndex<0&&(e.tabIndex=0),e.getAttribute?.("role")||e.setAttribute?.("role","region"),e.getAttribute?.("aria-label")||e.setAttribute?.("aria-label","Interactive 3D model viewport"),this.boundKeyDown=i=>{if(this.interactive){switch(i.key){case"ArrowLeft":this.targetTheta=this.clampTheta(this.targetTheta-.1);break;case"ArrowRight":this.targetTheta=this.clampTheta(this.targetTheta+.1);break;case"ArrowUp":this.targetPhi=this.clampPhi(this.targetPhi+.08);break;case"ArrowDown":this.targetPhi=this.clampPhi(this.targetPhi-.08);break;case"+":case"=":this.targetDistance=this.clampDistance(this.targetDistance*.9);break;case"-":case"_":this.targetDistance=this.clampDistance(this.targetDistance*1.1);break;case"Home":this.resetCamera();break;default:return}this.lastInteractionTime=t(),i.preventDefault()}},e.addEventListener("keydown",this.boundKeyDown)}teardownEvents(){let e=(i,r,s)=>{this[s]&&(i.removeEventListener(r,this[s]),this[s]=null)},t=this.canvas;e(t,"webglcontextlost","boundContextLost"),e(t,"webglcontextrestored","boundContextRestored"),e(t,"contextmenu","boundContextMenu"),e(t,"pointerdown","boundPointerDown"),e(t,"pointermove","boundPointerMove"),e(t,"pointerup","boundPointerUp"),e(t,"wheel","boundWheel"),e(t,"keydown","boundKeyDown"),e(this.container,"setCamera","boundSetCamera"),e(this.container,"resetCamera","boundResetCamera")}raycastFromScreenPoint(e,t){let i=this.canvas,r=i.getBoundingClientRect(),s=i.width||300,n=i.height||300,o=r.width>0?Math.floor((e-r.left)*(s/r.width)):Math.floor(e),a=r.height>0?Math.floor((t-r.top)*(n/r.height)):Math.floor(t);return this.performMeshPick(o,a,!1)}performMeshPick(e,t,i=!0){if(this.meshes.length===0)return null;let r=this.gl,s=Math.max(1,this.canvas.width||300),n=Math.max(1,this.canvas.height||300);e=this.mapStereoPickX(e,s);let o=ht();dt(o,this.projMatrix,this.viewMatrix);let a=[],h=Math.max(0,Math.min(s-1,e)),l=Math.max(0,Math.min(n-1,n-1-t));if(this.pickFbo&&r&&!this.xrSessionActive){(this.pickFboWidth!==s||this.pickFboHeight!==n)&&this.resizePickingFbo(s,n),r.bindFramebuffer(36160,this.pickFbo),r.viewport(0,0,s,n),r.enable(2929),r.clearColor(0,0,0,0),r.clear(16640),r.useProgram(this.pickProg);for(let v=0;v<this.meshes.length;v++){let R=this.meshes[v];if(R.visible===!1||R.isPluginMesh)continue;let L=v+1,I=(L&255)/255,N=(L>>8&255)/255,_=(L>>16&255)/255;r.uniform4f(this.uPick.uColorId,I,N,_,1),dt(this.modelMatrix,this.modelRootMatrix,R.transform);let A=R.instanceMatrices;if(A&&A.length>=16){let E=A.length>>4,C=ht();for(let d of R.primitives){r.bindVertexArray(d.vao);for(let k=0;k<E;k++)dt(C,this.modelMatrix,A.subarray(k*16,k*16+16)),dt(this.mvpMatrix,o,C),r.uniformMatrix4fv(this.uPick.uMVP,!1,this.mvpMatrix),ee(r,d)}}else{dt(this.mvpMatrix,o,this.modelMatrix),r.uniformMatrix4fv(this.uPick.uMVP,!1,this.mvpMatrix);for(let E of R.primitives)r.bindVertexArray(E.vao),ee(r,E)}}let m=new Uint8Array(4);r.readPixels(h,l,1,1,6408,5121,m),r.bindFramebuffer(36160,null);let p=m[0]+(m[1]<<8)+(m[2]<<16);p>0&&p<=this.meshes.length&&(a=[this.meshes[p-1]])}a.length===0&&(a=this.meshes.filter(m=>m.visible!==!1));let c=null,f=1/0,y=[0,0,0],g=[0,1,0],[u,b,w]=Gt(this),M=ht();for(let m of a){dt(M,this.modelRootMatrix,m.transform);let p=m.instanceMatrices,v=p&&p.length>=16?p.length>>4:1;for(let R=0;R<v;R++){p&&p.length>=16?dt(this.modelMatrix,M,p.subarray(R*16,R*16+16)):this.modelMatrix.set(M),dt(this.mvpMatrix,o,this.modelMatrix);let L=ht();if(!Gr(L,this.mvpMatrix))continue;let I=(h+.5)/s*2-1,N=(l+.5)/n*2-1,_=[0,0,0],A=[0,0,0];Ye(_,I,N,-1,L),Ye(A,I,N,1,L);let E=A[0]-_[0],C=A[1]-_[1],d=A[2]-_[2],k=Math.hypot(E,C,d)||1,$=E/k,S=C/k,D=d/k,T={distance:1/0,point:[0,0,0],normal:[0,1,0]};if((P=>{for(let j of m.primitives){if(!j.positions)continue;let W=j.positions,V=j.indices,Z=Math.floor(V?V.length/3:W.length/9);for(let U=0;U<Z;U++){let X=V?V[U*3]:U*3,O=V?V[U*3+1]:U*3+1,G=V?V[U*3+2]:U*3+2;Hr(_[0],_[1],_[2],$,S,D,W[X*3],W[X*3+1],W[X*3+2],W[O*3],W[O*3+1],W[O*3+2],W[G*3],W[G*3+1],W[G*3+2],T,P)}}})(1e-4),isFinite(T.distance)){let P=T.point[0],j=T.point[1],W=T.point[2],V=this.modelMatrix,Z=V[0]*P+V[4]*j+V[8]*W+V[12],U=V[1]*P+V[5]*j+V[9]*W+V[13],X=V[2]*P+V[6]*j+V[10]*W+V[14],O=Z-u,G=U-b,F=X-w,H=Math.hypot(O,G,F);if(H<f){Pt(this.normalMatrix,this.modelMatrix);let B=this.normalMatrix,K=T.normal[0],q=T.normal[1],z=T.normal[2],tt=B[0]*K+B[3]*q+B[6]*z,et=B[1]*K+B[4]*q+B[7]*z,rt=B[2]*K+B[5]*q+B[8]*z,J=Math.hypot(tt,et,rt)||1;tt/=J,et/=J,rt/=J,tt*O+et*G+rt*F>0&&(tt=-tt,et=-et,rt=-rt),c=m,f=Math.round(H*1e3)/1e3,y=[Math.round(Z*1e3)/1e3,Math.round(U*1e3)/1e3,Math.round(X*1e3)/1e3],g=[Math.round(tt*1e3)/1e3,Math.round(et*1e3)/1e3,Math.round(rt*1e3)/1e3]}}}}if(!c)return null;let x={meshIndex:this.meshes.indexOf(c),meshName:c.name,nodeIndex:c.nodeIndex,distance:f,hitPoint:y,normal:g,screenX:e,screenY:t};if(i){for(let m of mt)m.onMeshSelect?.(this,x);this.opts.onMeshClick&&this.opts.onMeshClick(x),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("meshClick",{bubbles:!0,detail:x}))}return x}mapStereoPickX(e,t){if(!this.stereoSBS||this.xrSessionActive||t<2)return e;let i=Math.max(1,Math.floor(t*.5)),r=e>=i,s=r?e-i:e,n=r?Math.max(1,t-i):i,o=(s+.5)/n*2-1;return Math.floor((o*.5+1)*.5*t)}setStereoSBS(e){this.stereoSBS=!!e,this.xrSessionActive||(this.syncCameraMatrices(),this.render())}syncCameraMatrices(){let e=Math.max(1,this.canvas.width||1)/Math.max(1,this.canvas.height||1),t=this.backdropMeshes.length>0?Math.max(this.bounds.radius*20,120):Math.max(this.bounds.radius*20,10);ge(this.projMatrix,this.fov,e,.1,t);let i=this.customTarget||this.bounds.center;Qt(this.viewMatrix,Gt(this),i,[0,1,0]),dt(this.mvpMatrix,this.projMatrix,this.viewMatrix),Pt(this.normalMatrix,this.modelMatrix)}resize(){let e=Math.min((typeof window<"u"?window.devicePixelRatio:1)||1,2),t=this.canvas.getBoundingClientRect(),i=Math.max(1,Math.floor(t.width*e)),r=Math.max(1,Math.floor(t.height*e));this.canvas.width!==i||this.canvas.height!==r?(this.canvas.width=i,this.canvas.height=r,this.resizePickingFbo(i,r),this.xrSessionActive||this.syncCameraMatrices()):!this.xrSessionActive&&this.projMatrix[0]===0&&this.syncCameraMatrices()}getGLContext(){return this.gl}setXRSessionActive(e){let t=this.xrSessionActive;if(this.xrSessionActive=e,t&&!e){this.xrDepthState.enabled=!1;for(let i of mt)i.onXRSessionEnd?.(this);if(this.lastTime=typeof performance<"u"?performance.now():Date.now(),this.updateTurntableMatrix(),this.isVisible)try{this.resize(),this.syncCameraMatrices(),this.render()}catch(i){this.reportRenderError(i)}}}reportRenderError(e){this.renderErrorReported||(this.renderErrorReported=!0,typeof console<"u"&&console.warn("[three-live] render frame failed:",e))}stepXRUpdate(e){for(let t of mt)t.onUpdate?.(this,e)}start(){if(this.animFrameId!==null)return;this.lastTime=typeof performance<"u"?performance.now():Date.now();let e=t=>{if(this.animFrameId===null)return;let i=Math.min(Math.max((t-this.lastTime)/1e3,0),.1);if(this.lastTime=t,this.isVisible&&!this.xrSessionActive)try{this.resize(),this.update(i),this.render()}catch(r){this.reportRenderError(r)}this.animFrameId!==null&&(this.animFrameId=requestAnimationFrame(e))};this.animFrameId=requestAnimationFrame(e)}stop(){this.animFrameId!==null&&(cancelAnimationFrame(this.animFrameId),this.animFrameId=null)}setAutoRotate(e){this.autoRotate=e}getAutoRotate(){return this.autoRotate}setAutoRotateSpeed(e){this.autoRotateSpeed=e}getAutoRotateSpeed(){return this.autoRotateSpeed}setAutoRotateDelay(e){this.autoRotateDelay=Math.max(0,Number(e)||0)}getAutoRotateDelay(){return this.autoRotateDelay}resetTurntableRotation(e=0){this.turntableRotation=Number(e)||0,this.updateTurntableMatrix(),this.render()}updateTurntableMatrix(){let e=Math.cos(this.turntableRotation),t=Math.sin(this.turntableRotation),i=this.bounds.center[0],r=this.bounds.center[2],s=this.modelRootMatrix;s[0]=e,s[1]=0,s[2]=-t,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=t,s[9]=0,s[10]=e,s[11]=0,s[12]=i-(e*i+t*r),s[13]=0,s[14]=r-(-t*i+e*r),s[15]=1}setVisible(e){this.isVisible=e}update(e){for(let n of mt)n.onUpdate?.(this,e);let t=typeof performance<"u"?performance.now():Date.now();if(!this.isPointerDown&&this.autoRotate&&t-this.lastInteractionTime>=this.autoRotateDelay){this.turntableRotation+=this.autoRotateSpeed*e,this.updateTurntableMatrix();for(let n of mt)n.onCameraChange?.(this,this.container)}this.currTheta+=(this.targetTheta-this.currTheta)*.12,this.currPhi+=(this.targetPhi-this.currPhi)*.12,this.currDistance+=(this.targetDistance-this.currDistance)*.12,this.syncCameraMatrices();let i=Math.round((this.currTheta*180/Math.PI%360+360)%360),r=Math.round(this.currPhi*180/Math.PI),s=Math.round(this.bounds.radius*2.5/this.currDistance*100)/100;if(Math.abs(i-this.lastReportedTheta)>=1||Math.abs(r-this.lastReportedPhi)>=1||Math.abs(s-this.lastReportedZoom)>=.02){this.lastReportedTheta=i,this.lastReportedPhi=r,this.lastReportedZoom=s;let n={theta:i,phi:r,zoom:s,distance:Math.round(this.currDistance*100)/100};this.opts.onCameraChange&&this.opts.onCameraChange(n),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("cameraChange",{bubbles:!0,detail:n}))}}renderXRView(e,t,i,r,s=!0,n=0){this.onBeforeRenderXRView&&this.onBeforeRenderXRView(e);let o=e?.transform?.inverse?.matrix||this.viewMatrix,a=e?.projectionMatrix||this.projMatrix,h=e?.transform?.position,l=h?[h.x,h.y,h.z]:[0,1.6,0];t?this.modelRootMatrix.set(t):i&&t&&this.modelRootMatrix.set(t),this.render({viewMatrix:o,projMatrix:a,eyePos:l,viewport:r,eye:e?.eye||"none",clear:n>0?!1:e?.eye!=="right",isAR:s})}render(e){if(this.contextLost)return;if(!e&&this.stereoSBS){let x=Math.max(2,this.canvas.width||2),m=Math.max(1,this.canvas.height||1),p=Math.max(1,Math.floor(x*.5)),v=Math.max(1,x-p),R=this.backdropMeshes.length>0?Math.max(this.bounds.radius*20,120):Math.max(this.bounds.radius*20,10),L=this.customTarget||this.bounds.center,[I,N,_]=Gt(this),A=Math.cos(this.currTheta),E=-Math.sin(this.currTheta),C=.032,d=ht(),k=ht(),$=[I-A*C,N,_-E*C],S=[L[0]-A*C*.25,L[1],L[2]-E*C*.25];ge(d,this.fov,p/m,.1,R),Qt(k,$,S,[0,1,0]);let D=ht(),T=ht(),P=[I+A*C,N,_+E*C],j=[L[0]+A*C*.25,L[1],L[2]+E*C*.25];ge(D,this.fov,v/m,.1,R),Qt(T,P,j,[0,1,0]),this.render({viewMatrix:k,projMatrix:d,eyePos:$,viewport:[0,0,p,m],eye:"left",clear:!0,isAR:!1}),this.render({viewMatrix:T,projMatrix:D,eyePos:P,viewport:[p,0,v,m],eye:"right",clear:!1,isAR:!1}),this.gl.viewport(0,0,x,m);return}let t=this.gl,i=0,r=0,s=this.canvas.width,n=this.canvas.height;e?.viewport?(i=e.viewport[0],r=e.viewport[1],s=e.viewport[2],n=e.viewport[3],t.viewport(i,r,s,n)):t.viewport(0,0,this.canvas.width,this.canvas.height),t.enable(2929),(!e||e.clear!==!1)&&(e?.isAR?t.clearColor(0,0,0,0):t.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),t.clear(16640));let o=ht(),a=e?.viewMatrix??this.viewMatrix;this.activeViewMatrix=a,dt(o,e?.projMatrix??this.projMatrix,a);let h=ut().xrDepthShader,l=qr(this.toneMapping),[c,f,y]=e?e.eyePos:Gt(this);for(let x of mt)x.onBeforeDrawScene?.(this,t,o,[c,f,y],l);let g=e?.isAR?0:this.backdropMeshes.length;if(this.meshes.length===0&&g===0)return;let u=e?.eye||"none",b=!1,w=g>0?[...this.backdropMeshes,...this.meshes]:this.meshes,M=x=>{for(let m=0;m<w.length;m++){let p=w[m];if(p.visible===!1)continue;let v=this.selectedMeshName!==""&&p.name===this.selectedMeshName;m<g||p.worldSpace===!0||p.name==="__xr_reticle__"?this.modelMatrix.set(p.transform):dt(this.modelMatrix,this.modelRootMatrix,p.transform),dt(this.mvpMatrix,o,this.modelMatrix),Pt(p.normalMatrix,this.modelMatrix);let R=p.extras?.xr?.stereo||p.userData?.xr?.stereo,L=0,I=0,N=1,_=1;R==="sbs"?(N=.5,L=u==="right"?.5:0):R==="ou"&&(_=.5,I=u==="right"?.5:0);for(let A of p.primitives){let E=!!A.isTransmissive;if(!x&&E){b=!0;continue}if(x&&!E)continue;let C=A.customProgram||this.renderProg,d=A.customUniforms||this.uRender;t.useProgram(C),t.vertexAttrib3f(3,0,0,0),d.uInstanced&&t.uniform1i(d.uInstanced,0),t.uniform1i(d.uToneMapping,l),t.uniform1f(d.uEnvIntensity,this.envIntensity),d.uExposure&&t.uniform1f(d.uExposure,this.exposure),t.uniform3f(d.uCameraPos,c,f,y),t.uniform1f(d.uEmissive,v?1:0),t.uniformMatrix4fv(d.uMVP,!1,this.mvpMatrix),t.uniformMatrix4fv(d.uModel,!1,this.modelMatrix),t.uniformMatrix3fv(d.uNormalMatrix,!1,p.normalMatrix),d.uUvTransform&&t.uniform4f(d.uUvTransform,L,I,N,_),d.uViewportSize&&t.uniform2f(d.uViewportSize,Math.max(1,s),Math.max(1,n)),h?.bind(t,d,this.xrDepthState,a,[i,r,Math.max(1,s),Math.max(1,n)]),this.environmentTexture?(t.activeTexture(33988),t.bindTexture(3553,this.environmentTexture),t.uniform1i(d.uEnvironmentMap,4),t.uniform1i(d.uHasEnvironmentMap,1)):t.uniform1i(d.uHasEnvironmentMap,0),this.bindLights(d),d.uSectionEnabled&&t.uniform1i(d.uSectionEnabled,0);for(let $ of mt)$.onBeforeDrawPrimitive?.(t,C,A,p,this.worldMatrices||[],this.gltf);t.uniform4fv(d.uBaseColor,A.baseColor),t.uniform1f(d.uMetallic,A.metallic),t.uniform1f(d.uRoughness,A.roughness),d.uClearcoat&&t.uniform2f(d.uClearcoat,A.clearcoat??0,A.clearcoatRoughness??.04),A.texture?(t.activeTexture(33984),t.bindTexture(3553,A.texture),t.uniform1i(d.uBaseColorTexture,0),t.uniform1i(d.uHasTexture,1)):t.uniform1i(d.uHasTexture,0),A.metallicRoughnessTexture?(t.activeTexture(33985),t.bindTexture(3553,A.metallicRoughnessTexture),t.uniform1i(d.uMetallicRoughnessTexture,1),t.uniform1i(d.uHasMetallicRoughnessTexture,1)):t.uniform1i(d.uHasMetallicRoughnessTexture,0),A.normalTexture?(t.activeTexture(33986),t.bindTexture(3553,A.normalTexture),t.uniform1i(d.uNormalTexture,2),t.uniform1i(d.uHasNormalTexture,1),t.uniform1f(d.uNormalScale,A.normalScale)):t.uniform1i(d.uHasNormalTexture,0),A.occlusionTexture?(t.activeTexture(33987),t.bindTexture(3553,A.occlusionTexture),t.uniform1i(d.uOcclusionTexture,3),t.uniform1i(d.uHasOcclusionTexture,1),t.uniform1f(d.uOcclusionStrength,A.occlusionStrength)):t.uniform1i(d.uHasOcclusionTexture,0),t.bindVertexArray(A.vao);let k=p.instanceMatrices;if(A.instanceCount!==void 0)t.drawElementsInstanced(4,A.indexCount,A.indexType,0,A.instanceCount);else if(k&&k.length>=16&&A.instanced&&d.uInstanced&&d.uViewProj){let $=k.length>>4;t.uniform1i(d.uInstanced,1),t.uniformMatrix4fv(d.uViewProj,!1,o),A.indices?t.drawElementsInstanced(4,A.indexCount,A.indexType,0,$):t.drawArraysInstanced(4,0,A.indexCount,$),t.uniform1i(d.uInstanced,0)}else if(k&&k.length>=16){let $=k.length>>4,S=p.instanceColors,D=ht(),T=new Float32Array(9),P=[A.baseColor[0],A.baseColor[1],A.baseColor[2],A.baseColor[3]];for(let j=0;j<$;j++)dt(D,this.modelMatrix,k.subarray(j*16,j*16+16)),dt(this.mvpMatrix,o,D),Pt(T,D),t.uniformMatrix4fv(d.uMVP,!1,this.mvpMatrix),t.uniformMatrix4fv(d.uModel,!1,D),t.uniformMatrix3fv(d.uNormalMatrix,!1,T),S&&(P[0]=A.baseColor[0]*S[j*3],P[1]=A.baseColor[1]*S[j*3+1],P[2]=A.baseColor[2]*S[j*3+2],P[3]=A.baseColor[3],t.uniform4fv(d.uBaseColor,P)),ee(t,A)}else ee(t,A)}}};if(M(!1),b){for(let x of mt)x.onBeforeTransmissivePass?.(t,this);M(!0)}for(let x of mt)x.onAfterRender?.(t,this,o,e?.eye??"none",[i,r,s,n],e?.projMatrix??this.projMatrix)}disposeMeshListGpuResources(e,t){oi(this.gl,e,t)}disposeMeshGpuResources(){this.disposeMeshListGpuResources(this.meshes,this.gpuTextures),this.meshes=[],this.gpuTextures=[],this.availableVariants=[]}disposeGpuResources(){let e=this.gl;this.disposeMeshGpuResources(),this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[];for(let t of mt)t.onDestroy?.(e,this);this.environmentTexture&&(e.deleteTexture(this.environmentTexture),this.environmentTexture=null),this.renderProg&&e.deleteProgram(this.renderProg),this.pickProg&&e.deleteProgram(this.pickProg),this.pickFbo&&e.deleteFramebuffer(this.pickFbo),this.pickTexture&&e.deleteTexture(this.pickTexture),this.pickDepth&&e.deleteRenderbuffer(this.pickDepth),this.pickFbo=null,this.pickTexture=null,this.pickDepth=null}dispose(){this.stop(),this.teardownEvents(),this.disposeGpuResources()}destroy(){this.dispose()}};hi.registerPlugin=Br,hi.getRegisteredPlugins=$r;function ns(e){return e+3&-4}var Q=(e,t)=>typeof e=="number"&&Number.isFinite(e)?e:t;function ui(e,t){let i=t,r=1;for(;e.has(i);)i=`${t}_${r++}`;return e.add(i),i}function ci(e,t=0){let[i,r,s,,n,o,a,,h,l,c,,f,y,g]=Array.from({length:15},(T,P)=>Q(e[t+P],P%5===0?1:0)),u=Math.hypot(i,r,s),b=Math.hypot(n,o,a),w=Math.hypot(h,l,c);i*(o*c-l*a)-n*(r*c-l*s)+h*(r*a-o*s)<0&&(u=-u);let M=Math.abs(u)>1e-8?1/u:0,x=Math.abs(b)>1e-8?1/b:0,m=Math.abs(w)>1e-8?1/w:0,p=i*M,v=r*M,R=s*M,L=n*x,I=o*x,N=a*x,_=h*m,A=l*m,E=c*m,C=p+I+E,d=0,k=0,$=0,S=1;if(C>0){let T=.5/Math.sqrt(C+1);S=.25/T,d=(N-A)*T,k=(_-R)*T,$=(v-L)*T}else if(p>I&&p>E){let T=2*Math.sqrt(Math.max(0,1+p-I-E));T>1e-8&&(S=(N-A)/T,d=.25*T,k=(L+v)/T,$=(_+R)/T)}else if(I>E){let T=2*Math.sqrt(Math.max(0,1+I-p-E));T>1e-8&&(S=(_-R)/T,d=(L+v)/T,k=.25*T,$=(N+A)/T)}else{let T=2*Math.sqrt(Math.max(0,1+E-p-I));T>1e-8&&(S=(v-L)/T,d=(_+R)/T,k=(N+A)/T,$=.25*T)}let D=Math.hypot(d,k,$,S);return D>1e-8&&Number.isFinite(D)?(d/=D,k/=D,$/=D,S/=D):(d=0,k=0,$=0,S=1),{t:[f,y,g],r:[d,k,$,S],s:[u,b,w]}}function as(e){let t={};return e.grab&&(t.interactable={mode:typeof e.grab=="string"?e.grab:"2-hand"},t.movable={scaleInZ:!!e.scale,minScale:typeof e.scale=="object"?e.scale.min??.1:.1,maxScale:typeof e.scale=="object"?e.scale.max??10:10}),e.billboard&&(t.billboard={mode:typeof e.billboard=="string"?e.billboard:"capsule"}),e.follow&&(t.follow={target:typeof e.follow=="object"?e.follow.mode??"head":e.follow}),e.anchor&&(t.anchor={plane:e.anchor}),e.physics&&e.physics!=="none"&&(t.rigidbody={type:e.physics}),t}var _t=(e,t,i,r)=>typeof e=="number"&&Number.isFinite(e)?Math.max(t,Math.min(i,e)):r;function mi(e){let t=e?.audioEmitter??e?.spatialAudio??(typeof e?.audio=="object"&&e.audio&&("preset"in e.audio||"distanceModel"in e.audio||"coneInnerAngle"in e.audio||"maxDistance"in e.audio||"volume"in e.audio)?e.audio:typeof e?.audio=="string"&&/^(hum|reactor|wind|beacon|geiger|chimeLoop|machinery|water)$/.test(e.audio)?{preset:e.audio}:void 0);if(!t||typeof t=="object"&&t.enabled===!1)return null;let i=typeof t=="string"?{preset:t}:t,r=typeof i.src=="string"&&!/[\x00-\x20\\%]|^\s*(javascript|data|file|http):/i.test(i.src)?i.src:void 0,s=typeof i.preset=="string"?i.preset:void 0;return!r&&!s?null:{ae:i,src:r,preset:s,volume:_t(i.volume,0,2,.6),loop:typeof i.loop=="boolean"?i.loop:!0,isGlobal:i.type==="global"||i.positional===!1}}function Ht(e,t){return fi(e,t)[0]}function fi(e,t){e.updateMatrixWorld(!0);let i=[],r=0,s=[],n=[],o=[],a=[],h=new Set,l=[],c=[],f=new Map,y=[],g=[],u=[],b=new Map,w=[],M=[];function x(S){let D=f.get(S);if(D!==void 0)return D;D=c.length,f.set(S,D);let T=S,P=T.color?.r??.8,j=T.color?.g??.8,W=T.color?.b??.8,V=T.opacity??1,Z={baseColorFactor:[P,j,W,V],metallicFactor:T.metalness??0,roughnessFactor:T.roughness??.5},U={};if(T.map){let G="";typeof T.map=="string"?G=T.map:typeof T.map.source=="string"?G=T.map.source:typeof T.map.image=="string"&&(G=T.map.image);let F=G.trim(),H=F&&!/[\x00-\x1f\x7f\\]|\.\./.test(F)&&(/^data:image\/(png|jpeg|jpg|webp|ktx2|avif)(;|,)/i.test(F)||!F.startsWith("//")&&!/^[a-z][a-z0-9+.-]*:/i.test(F))?F:null;if(H){let K=b.get(H);if(K===void 0){let q=y.length;y.push({uri:H}),g.length===0&&g.push({magFilter:9729,minFilter:9987,wrapS:10497,wrapT:10497}),K=u.length,u.push({sampler:0,source:q}),b.set(H,K)}Z.baseColorTexture={index:K}}let B=T.map.avgColor;Array.isArray(B)&&B.length>=3&&(U.avgColor=[B[0],B[1],B[2]])}let X={name:T.name||"",pbrMetallicRoughness:Z,doubleSided:T.side===2||!!T.doubleSided,...Object.keys(U).length>0?{extras:U}:{}};if(T.emissive&&(T.emissive.r>0||T.emissive.g>0||T.emissive.b>0)){let G=T.emissiveIntensity??1;X.emissiveFactor=[T.emissive.r*G,T.emissive.g*G,T.emissive.b*G]}let O={};return T.clearcoat&&T.clearcoat>0&&(O.KHR_materials_clearcoat={clearcoatFactor:T.clearcoat,clearcoatRoughnessFactor:T.clearcoatRoughness||0}),T.sheen&&T.sheen>0&&(O.KHR_materials_sheen={sheenColorFactor:T.sheenColor?[T.sheenColor.r,T.sheenColor.g,T.sheenColor.b]:[1,1,1],sheenRoughnessFactor:T.sheenRoughness||0}),T.transmission&&T.transmission>0&&(O.KHR_materials_transmission={transmissionFactor:T.transmission}),T.thickness&&T.thickness>0&&(O.KHR_materials_volume={thicknessFactor:T.thickness,attenuationDistance:T.attenuationDistance??1/0,attenuationColor:T.attenuationColor?[T.attenuationColor.r,T.attenuationColor.g,T.attenuationColor.b]:[1,1,1]}),T.ior!==void 0&&T.ior!==1.5&&(O.KHR_materials_ior={ior:T.ior}),T.dispersion&&T.dispersion>0&&(O.KHR_materials_dispersion={dispersion:T.dispersion}),T.iridescence&&T.iridescence>0&&(O.KHR_materials_iridescence={iridescenceFactor:T.iridescence,iridescenceIor:T.iridescenceIOR??1.3}),Object.keys(O).length>0&&(X.extensions=O),c.push(X),D}function m(S,D){let T=new Uint8Array(S.buffer,S.byteOffset,S.byteLength),P=ns(T.byteLength),j=new Uint8Array(P);j.set(T),i.push(j);let W=s.length;return s.push({buffer:0,byteOffset:r,byteLength:T.byteLength,target:D}),r+=P,W}function p(S,D,T,P,j,W,V){let Z=m(S,T),U=n.length,X={bufferView:Z,byteOffset:0,componentType:P,count:j,type:D};return W&&(X.min=W),V&&(X.max=V),n.push(X),U}e.traverse(S=>{if(S.isLight||S.color&&S.intensity!==void 0){let D=S.matrixWorld?.elements,T=Q(D?D[12]:S.position?.x,0),P=Q(D?D[13]:S.position?.y,0),j=Q(D?D[14]:S.position?.z,0),W=S.target,V=W?.parent?W?.matrixWorld?.elements:void 0,Z=Q(V?V[12]:W?.position?.x,0),U=Q(V?V[13]:W?.position?.y,0),X=Q(V?V[14]:W?.position?.z,0),O=Z-T,G=U-P,F=X-j,H=Math.hypot(O,G,F),B=Math.max(.01,Math.min(Math.PI/2,Q(S.angle,Math.PI/3))),K=Math.max(0,Math.min(1,Q(S.penumbra,0)));M.push({type:S.type,color:[S.color.r,S.color.g,S.color.b],intensity:S.intensity,position:[T,P,j],...S.type==="spot"?{direction:H>1e-6?[O/H,G/H,F/H]:[0,-1,0],outerConeAngle:B,innerConeAngle:Math.max(0,B*(1-K)),range:Math.max(0,Q(S.distance,0))}:S.type==="point"?{range:Math.max(0,Q(S.distance,0))}:{}})}});let v=[],R=new Set([e]),L=[];if(Array.isArray(e.children))for(let S=e.children.length-1;S>=0;S--)L.push({obj:e.children[S],parentKids:v});for(;L.length>0;){let{obj:S,parentKids:D}=L.pop();if(!S||typeof S!="object"||R.has(S))continue;R.add(S),S._bakeAuthorGeometry?.(),ut().materializeDeclarativeGeometry?.(S);let T=!!(S.userData&&(S.userData.xr&&typeof S.userData.xr=="object"&&Object.keys(S.userData.xr).length>0||S.userData.interactivity&&typeof S.userData.interactivity=="object"&&Object.keys(S.userData.interactivity).length>0)),P={name:S.name||(T?`Node_${a.length}`:"")},j=Q(S.position?.x,0),W=Q(S.position?.y,0),V=Q(S.position?.z,0),Z=Q(S.quaternion?.x,0),U=Q(S.quaternion?.y,0),X=Q(S.quaternion?.z,0),O=Q(S.quaternion?.w,1),G=Q(S.scale?.x,1),F=Q(S.scale?.y,1),H=Q(S.scale?.z,1);if((j||W||V)&&(P.translation=[j,W,V]),(Z||U||X||O!==1)&&(P.rotation=[Z,U,X,O]),(G!==1||F!==1||H!==1)&&(P.scale=[G,F,H]),S.visible===!1&&(P.extensions={...P.extensions||{},KHR_node_visibility:{visible:!1}},h.add("KHR_node_visibility")),S.userData&&Object.keys(S.userData).length>0&&(P.extras=JSON.parse(JSON.stringify(S.userData,(q,z)=>{if(!(q==="__proto__"||q==="prototype"||q==="constructor"))return typeof z=="function"?void 0:z})),S.userData.xr)){let q=as(S.userData.xr);P.extensions={...P.extensions||{},MOZ_hubs_components:q,ANDROID_xr_scenecore:q},ut().xrTraitSerializer?.gltfNode(P,S.userData.xr),h.add("MOZ_hubs_components").add("ANDROID_xr_scenecore")}if(S.geometry){let q=S.geometry,z=q.attributes.position;if(z&&z.count>0){let tt=[1/0,1/0,1/0],et=[-1/0,-1/0,-1/0];for(let nt=0;nt<z.count;nt++){let ot=z.getX(nt),ct=z.getY(nt),lt=z.getZ(nt);ot<tt[0]&&(tt[0]=ot),ot>et[0]&&(et[0]=ot),ct<tt[1]&&(tt[1]=ct),ct>et[1]&&(et[1]=ct),lt<tt[2]&&(tt[2]=lt),lt>et[2]&&(et[2]=lt)}let rt={attributes:{POSITION:p(z.array,"VEC3",34962,5126,z.count,tt,et)}};if(q.attributes.normal&&(rt.attributes.NORMAL=p(q.attributes.normal.array,"VEC3",34962,5126,q.attributes.normal.count)),q.attributes.uv&&(rt.attributes.TEXCOORD_0=p(q.attributes.uv.array,"VEC2",34962,5126,q.attributes.uv.count)),q.index){let nt=q.index.array instanceof Uint32Array;rt.indices=p(q.index.array,"SCALAR",34963,nt?5125:5123,q.index.count)}let J=Array.isArray(S.material)?S.material[0]:S.material;J&&(rt.material=x(J));let it=S.userData?.variants;if(it&&typeof it=="object"){let nt=new Map;for(let ot of Object.keys(it)){if(!ot||ot==="__proto__"||ot==="constructor"||ot==="prototype")continue;let ct=it[ot];if(!ct||typeof ct!="object")continue;let lt=w.indexOf(ot);if(lt===-1&&w.length<256&&(lt=w.length,w.push(ot)),lt===-1)continue;let Lt=x(ct),It=nt.get(Lt);It||(It=[],nt.set(Lt,It)),It.push(lt)}if(nt.size>0){let ot=[];for(let[ct,lt]of nt.entries())ot.push({material:ct,variants:lt});rt.extensions={...rt.extensions||{},KHR_materials_variants:{mappings:ot}},h.add("KHR_materials_variants")}}let st=S;if(st.isInstancedMesh&&typeof st.count=="number"&&st.count>0&&st.instanceMatrix?.array){let nt=Math.min(1e4,Math.floor(st.count)),ot=st.instanceMatrix.array,ct=new Float32Array(nt*3),lt=new Float32Array(nt*4),Lt=new Float32Array(nt*3);for(let bt=0;bt<nt;bt++){let{t:pe,r:Zt,s:de}=ci(ot,bt*16);ct[bt*3]=pe[0],ct[bt*3+1]=pe[1],ct[bt*3+2]=pe[2],lt[bt*4]=Zt[0],lt[bt*4+1]=Zt[1],lt[bt*4+2]=Zt[2],lt[bt*4+3]=Zt[3],Lt[bt*3]=de[0],Lt[bt*3+1]=de[1],Lt[bt*3+2]=de[2]}let It={TRANSLATION:p(ct,"VEC3",0,5126,nt),ROTATION:p(lt,"VEC4",0,5126,nt),SCALE:p(Lt,"VEC3",0,5126,nt)};if(st.instanceColor?.array&&st.instanceColor.array.length>=nt*3){let bt=new Float32Array(st.instanceColor.array.subarray(0,nt*3));It._COLOR_0=p(bt,"VEC3",0,5126,nt)}P.extensions={...P.extensions||{},EXT_mesh_gpu_instancing:{attributes:It}},h.add("EXT_mesh_gpu_instancing")}let wt=o.length;o.push({primitives:[rt],name:S.name,...P.extras?{extras:P.extras}:{}}),P.mesh=wt}}let B=a.length;a.push(P),l.push(S),D.push(B);let K=S.children;if(Array.isArray(K)&&K.length>0){let q=[];P.children=q;for(let z=K.length-1;z>=0;z--)L.push({obj:K[z],parentKids:q})}}for(let S=0;S<a.length;S++){let D=a[S];D.children&&D.children.length===0?delete D.children:D.children&&D.children.length>0&&(D.extras?.xr?.lod||D.extensions?.ANDROID_xr_scenecore?.lod||l[S]?.isLOD)&&(D.extensions={...D.extensions||{},MSFT_lod:{ids:[...D.children]}},h.add("MSFT_lod"))}let I=t?.animateCallback||t?.animateFn||(typeof e.userData?.animate=="function"?e.userData.animate:typeof e.__animateFn=="function"?e.__animateFn:typeof globalThis.animate=="function"?globalThis.animate:void 0),N=[];if(typeof I=="function"&&l.length>0){let S=t?.duration??4,D=t?.fps??15,T=Math.max(2,Math.round(S*D)+1),P=new Float32Array(T),j=l.map(F=>[Q(F.position?.x,0),Q(F.position?.y,0),Q(F.position?.z,0),Q(F.quaternion?.x,0),Q(F.quaternion?.y,0),Q(F.quaternion?.z,0),Q(F.quaternion?.w,1),Q(F.scale?.x,1),Q(F.scale?.y,1),Q(F.scale?.z,1)]),W=l.map(()=>new Float32Array(T*3)),V=l.map(()=>new Float32Array(T*4)),Z=l.map(()=>new Float32Array(T*3));for(let F=0;F<T;F++){let H=F/(T-1)*S;P[F]=H;try{I(H)}catch{}for(let B=0;B<l.length;B++){let K=l[B];W[B][F*3]=Q(K.position?.x,0),W[B][F*3+1]=Q(K.position?.y,0),W[B][F*3+2]=Q(K.position?.z,0);let q=Q(K.quaternion?.x,0),z=Q(K.quaternion?.y,0),tt=Q(K.quaternion?.z,0),et=Q(K.quaternion?.w,1),rt=Math.hypot(q,z,tt,et)||1;if(q/=rt,z/=rt,tt/=rt,et/=rt,F>0){let J=(F-1)*4,it=V[B];it[J]*q+it[J+1]*z+it[J+2]*tt+it[J+3]*et<0&&(q=-q,z=-z,tt=-tt,et=-et)}V[B][F*4]=q,V[B][F*4+1]=z,V[B][F*4+2]=tt,V[B][F*4+3]=et,Z[B][F*3]=Q(K.scale?.x,1),Z[B][F*3+1]=Q(K.scale?.y,1),Z[B][F*3+2]=Q(K.scale?.z,1)}}for(let F=0;F<l.length;F++){let H=l[F],B=j[F];H.position?.set(B[0],B[1],B[2]),H.quaternion?.set(B[3],B[4],B[5],B[6]),H.scale?.set(B[7],B[8],B[9])}e.updateMatrixWorld(!0);let U=null,X=()=>(U===null&&(U=p(P,"SCALAR",0,5126,T,[0],[S])),U),O=[],G=[];for(let F=0;F<l.length;F++){let H=j[F],B=(q,z,tt)=>q.some((et,rt)=>Math.abs(et-H[tt+rt%z])>1e-4),K=(q,z,tt,et)=>{q&&G.push({sampler:O.push({input:X(),interpolation:"LINEAR",output:p(z,tt,0,5126,T)})-1,target:{node:F,path:et}})};K(B(W[F],3,0),W[F],"VEC3","translation"),K(B(V[F],4,3),V[F],"VEC4","rotation"),K(B(Z[F],3,7),Z[F],"VEC3","scale")}G.length>0&&N.push({name:"ProceduralLoop",samplers:O,channels:G})}let _=zr(a,o,e.userData),A=[],E=[],C=[];for(let S=0;S<a.length;S++){let D=a[S],T=mi(D.extras?.xr);if(!T)continue;let{ae:P,src:j,preset:W,volume:V,loop:Z,isGlobal:U}=T,X=D.name||`Node_${S}`,O=E.length;E.push({name:`${X}_source`,gain:V,loop:Z,autoPlay:typeof P.autoplay=="boolean"?P.autoplay:!0,...j!==void 0?{audio:A.push({uri:j})-1}:{},...W?{extras:{preset:W,pitch:_t(P.pitch,.25,4,1)}}:{}});let G=C.length,F=_t(P.refDistance,.05,100,1),H=_t(P.coneInnerAngle,0,360,360),B=_t(P.coneOuterAngle,H,360,360);C.push({name:`${X}_emitter`,type:U?"global":"positional",gain:V,sources:[O],...U?{}:{positional:{distanceModel:P.distanceModel==="linear"||P.distanceModel==="exponential"?P.distanceModel:"inverse",refDistance:F,maxDistance:_t(P.maxDistance,F,500,Math.max(F,25)),rolloffFactor:_t(P.rolloffFactor,0,10,1),coneInnerAngle:+(H*Math.PI/180).toFixed(6),coneOuterAngle:+(B*Math.PI/180).toFixed(6),coneOuterGain:_t(P.coneOuterGain,0,1,0)}}}),D.extensions={...D.extensions||{},KHR_audio_emitter:{emitter:G}},h.add("KHR_audio_emitter")}let d={asset:{version:"2.0",generator:"ThreeLiveConvert",extras:{environmentIntensity:e.environmentIntensity}},scenes:[{nodes:v}],scene:0,nodes:a,meshes:o,materials:c,...y.length>0?{images:y}:{},...g.length>0?{samplers:g}:{},...u.length>0?{textures:u}:{},accessors:n,bufferViews:s,buffers:[{byteLength:r}],...N.length>0?{animations:N}:{},..._||h.size>0?{extensionsUsed:[..._?["KHR_interactivity"]:[],...h]}:{},..._||w.length>0||C.length>0?{extensions:{..._?{KHR_interactivity:_}:{},...w.length>0?{KHR_materials_variants:{variants:w.map(S=>({name:S}))}}:{},...C.length>0?{KHR_audio_emitter:{...A.length>0?{audio:A}:{},sources:E,emitters:C}}:{}}}:{}},k=new Uint8Array(r),$=0;for(let S of i)k.set(S,$),$+=S.byteLength;return[{gltf:d,bin:k.buffer,lights:M,environmentIntensity:e.environmentIntensity},l]}function Te(e){return new TextEncoder().encode(e)}function ie(e,t){let{gltf:i,bin:r}=Ht(e,t),s=JSON.stringify(i),n=Te(s),o=(4-n.byteLength%4)%4,a=n.byteLength+o,h=20+a+8+r.byteLength,l=new Uint8Array(h),c=new DataView(l.buffer);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0),c.setUint32(8,h,!0),c.setUint32(12,a,!0),c.setUint32(16,1313821514,!0),l.set(n,20);for(let y=0;y<o;y++)l[20+n.byteLength+y]=32;let f=20+a;return c.setUint32(f,r.byteLength,!0),c.setUint32(f+4,5130562,!0),l.set(new Uint8Array(r),f+8),l}function os(e,t){let[i,r]=fi(e,t);return Se(i,r)}function Se(e,t){let i=[],r=e.gltf,s=ut().decoders.get("meshopt");s&&typeof s.decodeBufferViews=="function"&&s.decodeBufferViews(r,e);let n=e.bin,o=n instanceof ArrayBuffer?n:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),a=r.accessors||[],h=r.bufferViews||[],l=r.materials||[],c=r.meshes||[],f=r.nodes||[],y=new Set,g=l.map((w,M)=>ui(y,re(w?.name,`Material_${M}`)));function u(w){let M=a[w];if(!M)throw new Error(`Accessor ${w} not found`);let x=h[M.bufferView||0],m=(x.byteOffset||0)+(M.byteOffset||0),p=x.byteLength||0;return{acc:M,buffer:o.slice(m,m+p)}}function b(w,M,x,m){let p=[],v=c[w];if(!v)return p;let R=v.primitives||[];for(let L=0;L<R.length;L++){let I=R[L],N=I.attributes?.POSITION;if(N===void 0)continue;let{acc:_,buffer:A}=u(N),E=new Float32Array(A,0,_.count*3),C,d=I.attributes?.NORMAL;if(d!==void 0){let{acc:O,buffer:G}=u(d),F=new Float32Array(G,0,O.count*3);C=new Float32Array(F.length);for(let H=0;H<O.count;H++){let B=F[H*3],K=F[H*3+1],q=F[H*3+2],z=Math.hypot(B,K,q)||1;C[H*3]=B/z,C[H*3+1]=K/z,C[H*3+2]=q/z}}let k,$=I.attributes?.TEXCOORD_0;if($!==void 0){let{acc:O,buffer:G}=u($);k=new Float32Array(G,0,O.count*2)}let S;if(I.indices!==void 0){let{acc:O,buffer:G}=u(I.indices);S=O.componentType===5125?new Uint32Array(G,0,O.count):new Uint16Array(G,0,O.count);let F=_.count;for(let H of S)if(H>=F)throw new Error(`SecurityError: Index buffer value (${H}) out of vertex bounds [0, ${F}).`)}else{let O=_.count;S=O>65535?new Uint32Array(O):new Uint16Array(O);for(let G=0;G<O;G++)S[G]=G}let D="DefaultMaterial",T=[.8,.8,.8],P=.5,j=0,W=0,V=0,Z=1.5,U=1,X=[0,0,0];if(I.material!==void 0&&l[I.material]){let O=l[I.material];D=g[I.material]||`Material_${I.material}`;let G=O.pbrMetallicRoughness||{},F=(q,z)=>Array.isArray(q)&&q.length>=3?[q[0],q[1],q[2]]:z;T=F(G.baseColorFactor,[1,1,1]);let H=O.extras?.avgColor;Array.isArray(H)&&H.length>=3&&(T=[T[0]*H[0],T[1]*H[1],T[2]*H[2]]);let B=Array.isArray(G.baseColorFactor)&&typeof G.baseColorFactor[3]=="number"?G.baseColorFactor[3]:1;typeof G.roughnessFactor=="number"&&(P=G.roughnessFactor),typeof G.metallicFactor=="number"&&(j=G.metallicFactor),X=F(O.emissiveFactor,[0,0,0]);let K=O.extensions||{};K.KHR_materials_clearcoat&&(W=K.KHR_materials_clearcoat.clearcoatFactor??0,V=K.KHR_materials_clearcoat.clearcoatRoughnessFactor??0),typeof K.KHR_materials_ior?.ior=="number"&&(Z=K.KHR_materials_ior.ior),U=B*(1-(K.KHR_materials_transmission?.transmissionFactor??0))}p.push({name:R.length>1?`${M}_p${L}`:M,positions:E,indices:S,normals:C,uvs:k,materialName:D,color:T,roughness:P,metallic:j,clearcoat:W,clearcoatRoughness:V,ior:Z,opacity:U,emissiveColor:X,xrTraits:x||v.extras?.xr,...m?{invisible:!0}:{}})}return p}if(f.length>0){let w=new Float32Array(0),M=new Uint16Array(0),x=(E,C)=>{if(E===void 0)return null;let{acc:d,buffer:k}=u(E);return new Float32Array(k,0,d.count*C)},m=(E,C)=>Array.isArray(E)&&E.length>=3?[Q(E[0],C),Q(E[1],C),Q(E[2],C)]:[C,C,C],p=(E,C,d)=>E&&E.length>=(C+1)*3?[E[C*3],E[C*3+1],E[C*3+2]]:d,v=(E,C,d)=>E&&E.length>=(C+1)*4?[E[C*4],E[C*4+1],E[C*4+2],E[C*4+3]]:d,R=new Map,L=r.animations?.[0];if(L&&Array.isArray(L.channels)&&Array.isArray(L.samplers))for(let E of L.channels){let C=L.samplers[E?.sampler],d=E?.target?.node,k=E?.target?.path;if(!C||typeof d!="number"||C.input===void 0)continue;let $=R.get(d);$||($={input:C.input},R.set(d,$)),k==="translation"?$.t=C.output:k==="rotation"?$.r=C.output:k==="scale"&&($.s=C.output)}let I=r.scenes?.[r.scene??0]?.nodes??[];if(!Array.isArray(I)||I.length===0){let E=new Set;for(let C of f)if(Array.isArray(C?.children))for(let d of C.children)E.add(d);I=[];for(let C=0;C<f.length;C++)E.has(C)||I.push(C);I.length===0&&(I=[0])}let N=new Set,_=[],A=(E,C)=>{if(Array.isArray(E))for(let d=E.length-1;d>=0;d--)_.push({idx:E[d],out:C})};for(A(I,i);_.length>0;){let{idx:E,out:C}=_.pop();if(typeof E!="number"||E<0||E>=f.length||N.has(E))continue;N.add(E);let d=f[E];if(!d)continue;let k=[0,0,0],$=[0,0,0,1],S=[1,1,1];if(Array.isArray(d.matrix)&&d.matrix.length===16){let U=ci(d.matrix);k=U.t,$=U.r,S=U.s}else k=m(d.translation,0),Array.isArray(d.rotation)&&d.rotation.length>=4&&($=[Q(d.rotation[0],0),Q(d.rotation[1],0),Q(d.rotation[2],0),Q(d.rotation[3],1)]),S=m(d.scale,1);let D,T=R.get(E);if(T){let U=x(T.input,1);if(U&&U.length>0){let X=x(T.t,3),O=x(T.r,4),G=x(T.s,3),F=Array.from(U),H=[],B=[],K=[];for(let q=0;q<U.length;q++)H.push(p(X,q,k)),B.push(v(O,q,$)),K.push(p(G,q,S));D={times:F,translations:H,rotations:B,scales:K}}}let P=Array.isArray(d.children)?d.children:[],j=typeof d.mesh=="number"&&d.mesh>=0&&d.mesh<c.length,W=t?.[E]?.userData?.xr??d.extras?.xr;if(!j&&P.length===0&&(d.camera!==void 0||d.extensions?.KHR_lights_punctual||!d.name&&!d.extras&&!W&&!D))continue;let V=(U,X,O)=>({name:U,positions:w,indices:M,isXform:!0,xrTraits:W,timeSamples:D,translation:k,rotation:$,scale:S,children:X,...O?{invisible:!0}:{}}),Z=d.visible===!1||d.extensions?.KHR_node_visibility?.visible===!1||t?.[E]?.visible===!1;if(j){let U=d.name||c[d.mesh]?.name||`Mesh_${E}`,X=b(d.mesh,U,W,Z),O=d.extensions?.EXT_mesh_gpu_instancing?.attributes;if(O&&typeof O=="object"&&X.length>0){let G=x(O.TRANSLATION,3),F=x(O.ROTATION,4),H=x(O.SCALE,3),B=x(O._COLOR_0,3),K=Math.min(1e3,G?G.length/3:F?F.length/4:H?H.length/3:0);if(K>0){let q=[];for(let z=0;z<K;z++){let tt=p(G,z,[0,0,0]),et=v(F,z,[0,0,0,1]),rt=p(H,z,[1,1,1]);for(let J of X){let it=J.color||[.8,.8,.8],st=B&&B.length>=(z+1)*3;q.push({...J,name:`${J.name}_${z}`,materialName:st?`${J.materialName}_inst_${z}`:J.materialName,color:st?[it[0]*B[z*3],it[1]*B[z*3+1],it[2]*B[z*3+2]]:J.color,translation:tt,rotation:et,scale:rt})}}A(P,q),C.push(V(U,q,Z));continue}}if(X.length===1)X[0].translation=k,X[0].rotation=$,X[0].scale=S,X[0].timeSamples=D,P.length>0&&(X[0].children=[],A(P,X[0].children)),C.push(X[0]);else{let G=[...X];A(P,G),C.push(V(U,G,Z))}}else{let U=[];A(P,U),C.push(V(d.name||`Group_${E}`,U,Z))}}}else for(let w=0;w<c.length;w++){let M=c[w].name||`Mesh_${w}`;i.push(...b(w,M,c[w].extras?.xr))}return i}function re(e,t){if(!e||typeof e!="string")return t;let i=e.replace(/[^A-Za-z0-9_]/g,"_");return/^[0-9]/.test(i)&&(i="_"+i),i||t}function Re(e){return String(e??"").replace(/[\x00-\x1f\x7f]/g,"").replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function pt(e){if(!Number.isFinite(e)||Math.abs(e)<1e-7)return"0";let t=Number(e.toFixed(5)).toString();return t.indexOf(".")===-1?`${t}.0`:t}var St=(e,t,i)=>`(${pt(e)}, ${pt(t)}, ${pt(i)})`,pi=(e,t,i,r)=>`(${pt(e)}, ${pt(t)}, ${pt(i)}, ${pt(r)})`;function di(e){let t=e.length/3,i=new Array(t);for(let r=0;r<t;r++)i[r]=St(e[r*3],e[r*3+1],e[r*3+2]);return i.join(", ")}function ls(e,t){let i=new Array(t);for(let r=0;r<t;r++)i[r]=`(${pt(e[r*2])}, ${pt(1-e[r*2+1])})`;return i.join(", ")}function hs(e){return Array.from(e).join(", ")}function Ce(e){let t=new Map,i=0,r=null,s=[...e];for(;s.length>0;){let u=s.pop();if(!u.isXform&&u.positions&&u.positions.length>0){let b=re(u.materialName,"DefaultMaterial");t.has(b)||t.set(b,{color:u.color||[.8,.8,.8],roughness:u.roughness??.5,metallic:u.metallic??0,clearcoat:u.clearcoat??0,clearcoatRoughness:u.clearcoatRoughness??0,ior:u.ior??1.5,opacity:u.opacity??1,emissiveColor:u.emissiveColor||[0,0,0]})}if(u.timeSamples&&u.timeSamples.times.length>0){let b=u.timeSamples.times[u.timeSamples.times.length-1];b>i&&(i=b)}if(u.xrTraits?.anchor&&!r&&(r=u.xrTraits.anchor==="vertical"||u.xrTraits.anchor==="wall"?"vertical":"horizontal"),u.children)for(let b=u.children.length-1;b>=0;b--)s.push(u.children[b])}let n="";i>0&&(n=`startTimeCode = 0
|
|
250
|
+
endTimeCode = ${pt(i)}
|
|
254
251
|
timeCodesPerSecond = 1.0
|
|
255
|
-
`);let
|
|
252
|
+
`);let o="";r&&(o=`uniform token preliminary:anchoring:type = "plane"
|
|
256
253
|
uniform token preliminary:planeAnchoring:alignment = "${r}"
|
|
257
|
-
`);let
|
|
254
|
+
`);let a=`#usda 1.0
|
|
258
255
|
(
|
|
259
256
|
defaultPrim = "Root"
|
|
260
257
|
metersPerUnit = 1.0
|
|
261
258
|
upAxis = "Y"
|
|
262
|
-
${
|
|
259
|
+
${n})
|
|
263
260
|
|
|
264
261
|
def Xform "Root" (
|
|
265
262
|
kind = "component"
|
|
266
263
|
)
|
|
267
264
|
{
|
|
268
|
-
${
|
|
265
|
+
${o}def Scope "Materials"
|
|
269
266
|
{
|
|
270
|
-
`;for(let[
|
|
271
|
-
`,
|
|
272
|
-
`),
|
|
273
|
-
`),
|
|
274
|
-
`),(
|
|
275
|
-
`),
|
|
267
|
+
`;for(let[u,b]of t.entries()){let[w,M,x]=b.color,[m,p,v]=b.emissiveColor,R="";b.clearcoat>0&&(R+=`float inputs:clearcoat = ${pt(b.clearcoat)}
|
|
268
|
+
`,R+=`float inputs:clearcoatRoughness = ${pt(b.clearcoatRoughness)}
|
|
269
|
+
`),b.ior!==1.5&&(R+=`float inputs:ior = ${pt(b.ior)}
|
|
270
|
+
`),b.opacity<1&&(R+=`float inputs:opacity = ${pt(b.opacity)}
|
|
271
|
+
`),(m>0||p>0||v>0)&&(R+=`color3f inputs:emissiveColor = ${St(m,p,v)}
|
|
272
|
+
`),a+=`def Material "${u}"
|
|
276
273
|
{
|
|
277
274
|
def Shader "PBRShader"
|
|
278
275
|
{
|
|
279
276
|
uniform token info:id = "UsdPreviewSurface"
|
|
280
|
-
color3f inputs:diffuseColor =
|
|
281
|
-
float inputs:metallic = ${
|
|
282
|
-
float inputs:roughness = ${
|
|
283
|
-
${
|
|
277
|
+
color3f inputs:diffuseColor = ${St(w,M,x)}
|
|
278
|
+
float inputs:metallic = ${pt(b.metallic)}
|
|
279
|
+
float inputs:roughness = ${pt(b.roughness)}
|
|
280
|
+
${R}token outputs:surface
|
|
284
281
|
}
|
|
285
|
-
token outputs:surface.connect = </Root/Materials/${
|
|
282
|
+
token outputs:surface.connect = </Root/Materials/${u}/PBRShader.outputs:surface>
|
|
286
283
|
}
|
|
287
|
-
`}
|
|
284
|
+
`}a+=`}
|
|
288
285
|
def Scope "Meshes"
|
|
289
286
|
{
|
|
290
|
-
`;let
|
|
287
|
+
`;let h=(u,b,w)=>{let M=[];b&&M.push('"MaterialBindingAPI"');let x=!!(u?.rigidBody&&u.rigidBody!=="none"&&(typeof u.rigidBody!="object"||u.rigidBody.enabled!==!1)),m=!!(u?.physics&&u.physics!=="none"||x);m&&M.push(...x?['"PhysicsBodyAPI"','"PhysicsRigidBodyAPI"','"PhysicsCollisionAPI"','"PhysicsMassAPI"']:['"PhysicsBodyAPI"','"PhysicsCollisionAPI"']);let p=[];if(M.length>0&&p.push(`prepend apiSchemas = [${M.join(", ")}]`),u){let N=ut().xrTraitSerializer?.usdLines(u,Re)??[];if(!N.length)for(let _ of["grab","billboard","follow","anchor","physics"]){let A=_==="follow"&&typeof u.follow=="object"?u.follow.mode??"head":u[_];A!==void 0&&N.push(`string ${_} = "${Re(A)}"`)}N.length>0&&p.push(`customData = {
|
|
291
288
|
dictionary xr = {
|
|
292
|
-
${
|
|
289
|
+
${N.join(`
|
|
293
290
|
`)}
|
|
294
291
|
}
|
|
295
|
-
}`)
|
|
296
|
-
${
|
|
292
|
+
}`)}let v=p.length>0?` (
|
|
293
|
+
${p.join(`
|
|
297
294
|
`)}
|
|
298
|
-
)
|
|
299
|
-
{
|
|
300
|
-
|
|
301
|
-
bool physics:kinematicEnabled = ${D}
|
|
295
|
+
)`:"",R=w?`uniform token visibility = "invisible"
|
|
296
|
+
`:"";if(m){let N=u?.rigidBody??u?.physics,_=N?.body??N?.mode??N;R+=`bool physics:rigidBodyEnabled = true
|
|
297
|
+
bool physics:kinematicEnabled = ${_==="static"||_==="kinematic"}
|
|
302
298
|
bool physics:collisionEnabled = true
|
|
303
|
-
|
|
304
|
-
|
|
299
|
+
`,N?.mass>0&&Number.isFinite(N.mass)&&(R+=`float physics:mass = ${pt(N.mass)}
|
|
300
|
+
`)}let L=mi(u),I=L?`def SpatialAudio "AudioEmitter"
|
|
301
|
+
{
|
|
302
|
+
${L.src?`asset inputs:file = @${Re(L.src)}@
|
|
303
|
+
`:""}uniform token inputs:auralMode = "${L.isGlobal?"nonSpatial":"spatial"}"
|
|
304
|
+
uniform token inputs:playbackMode = "${L.loop?"loopFromStart":"onceFromStart"}"
|
|
305
|
+
double gain = ${pt(L.volume)}
|
|
306
|
+
}
|
|
307
|
+
`:"";return{header:v,body:R,tail:I}},l=u=>{if(u.timeSamples&&u.timeSamples.times.length>0){let p=u.timeSamples,v=(N,_,A)=>p.times.map((E,C)=>`${pt(E)}: ${A(N?.[C]||_)}`).join(", "),R=v(p.translations,[0,0,0],N=>St(N[0],N[1],N[2])),L=v(p.rotations,[0,0,0,1],N=>{let _=Math.hypot(N[0],N[1],N[2],N[3])||1;return pi(N[3]/_,N[0]/_,N[1]/_,N[2]/_)}),I=v(p.scales,[1,1,1],N=>St(N[0],N[1],N[2]));return`double3 xformOp:translate.timeSamples = { ${R} }
|
|
308
|
+
quatf xformOp:orient.timeSamples = { ${L} }
|
|
305
309
|
double3 xformOp:scale.timeSamples = { ${I} }
|
|
306
310
|
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:orient", "xformOp:scale"]
|
|
307
|
-
`}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
`}let b=[],w="",M=u.translation;M&&(Math.abs(M[0])>1e-7||Math.abs(M[1])>1e-7||Math.abs(M[2])>1e-7)&&(w+=`double3 xformOp:translate = ${St(M[0],M[1],M[2])}
|
|
312
|
+
`,b.push('"xformOp:translate"'));let x=u.rotation;if(x){let p=Math.hypot(x[0],x[1],x[2],x[3])||1,v=x[0]/p,R=x[1]/p,L=x[2]/p,I=x[3]/p;(1-Math.abs(I)>1e-7||Math.hypot(v,R,L)>1e-7)&&(w+=`quatf xformOp:orient = ${pi(I,v,R,L)}
|
|
313
|
+
`,b.push('"xformOp:orient"'))}let m=u.scale;return m&&(Math.abs(m[0]-1)>1e-7||Math.abs(m[1]-1)>1e-7||Math.abs(m[2]-1)>1e-7)&&(w+=`float3 xformOp:scale = ${St(m[0],m[1],m[2])}
|
|
314
|
+
`,b.push('"xformOp:scale"')),b.length>0&&(w+=`uniform token[] xformOpOrder = [${b.join(", ")}]
|
|
315
|
+
`),w},c=u=>{let b=u.positions.length/3,w=1/0,M=1/0,x=1/0,m=-1/0,p=-1/0,v=-1/0;for(let _=0;_<b;_++){let A=u.positions[_*3],E=u.positions[_*3+1],C=u.positions[_*3+2];A<w&&(w=A),A>m&&(m=A),E<M&&(M=E),E>p&&(p=E),C<x&&(x=C),C>v&&(v=C)}isFinite(w)||(w=M=x=-1,m=p=v=1);let R=Math.floor(u.indices.length/3),L=re(u.materialName,"DefaultMaterial"),I=R>0?R===1?"3":"3, ".repeat(R-1)+"3":"",N=`float3[] extent = [${St(w,M,x)}, ${St(m,p,v)}]
|
|
316
|
+
int[] faceVertexCounts = [${I}]
|
|
317
|
+
int[] faceVertexIndices = [${hs(u.indices)}]
|
|
318
|
+
point3f[] points = [${di(u.positions)}]
|
|
319
|
+
`;return u.normals&&u.normals.length===u.positions.length&&(N+=`normal3f[] normals = [${di(u.normals)}] (
|
|
312
320
|
interpolation = "vertex"
|
|
313
321
|
)
|
|
314
|
-
`),u.uvs&&u.uvs.length===
|
|
322
|
+
`),u.uvs&&u.uvs.length===b*2&&(N+=`texCoord2f[] primvars:st = [${ls(u.uvs,b)}] (
|
|
315
323
|
interpolation = "vertex"
|
|
316
324
|
)
|
|
317
|
-
`),
|
|
318
|
-
}
|
|
319
|
-
`
|
|
325
|
+
`),N+=`rel material:binding = </Root/Materials/${L}>
|
|
326
|
+
`,N},f=new Set,y=[];for(let u=e.length-1;u>=0;u--)y.push({node:e[u],siblings:f});let g=0;for(;y.length>0;){let u=y.pop();if(u.close){a+=`}
|
|
327
|
+
`;continue}let{node:b,siblings:w}=u,M=!!(b.isXform||b.positions.length===0),x=ui(w,re(b.name,M?`Group_${g}`:`Mesh_${g}`));g++;let m=b.children||[];if(M){let p=h(b.xrTraits,!1,b.invisible);a+=`def Xform "${x}"${p.header}
|
|
328
|
+
{
|
|
329
|
+
${p.body}${l(b)}${p.tail}`,y.push({close:!0});let v=new Set;for(let R=m.length-1;R>=0;R--)y.push({node:m[R],siblings:v})}else if(m.length>0){let p=h(b.xrTraits,!1,b.invisible),v=`${x}_mesh`;a+=`def Xform "${x}"${p.header}
|
|
330
|
+
{
|
|
331
|
+
${p.body}${l(b)}${p.tail}`,a+=`def Mesh "${v}" (
|
|
332
|
+
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
333
|
+
)
|
|
334
|
+
{
|
|
335
|
+
${c(b)}}
|
|
336
|
+
`,y.push({close:!0});let R=new Set([v]);for(let L=m.length-1;L>=0;L--)y.push({node:m[L],siblings:R})}else{let p=h(b.xrTraits,!0,b.invisible);a+=`def Mesh "${x}"${p.header}
|
|
337
|
+
{
|
|
338
|
+
${p.body}${l(b)}${c(b)}${p.tail}}
|
|
339
|
+
`}}return a+=`}
|
|
320
340
|
}
|
|
321
|
-
`,o}function nr(n,e){if(n&&typeof n.traverse=="function"){let i=Qn(n,e);return vt(i)}let t=Fe(n),r=xn(t);return vt(r)}var Ye=null;function rr(n){if(!Ye){Ye=new Uint32Array(256);for(let t=0;t<256;t++){let r=t;for(let i=0;i<8;i++)r=r&1?3988292384^r>>>1:r>>>1;Ye[t]=r}}let e=4294967295;for(let t=0;t<n.length;t++)e=Ye[(e^n[t])&255]^e>>>8;return(e^4294967295)>>>0}function vn(n){let e=[],t=0,r=[];for(let c of n){let h=je(c.filename),m=rr(c.data),b=c.data.length,g=30+h.length,d=t+g,w=0,C=d%64;C!==0&&(w=64-C);let N=new Uint8Array(g+w),f=new DataView(N.buffer);f.setUint32(0,67324752,!0),f.setUint16(4,20,!0),f.setUint16(6,0,!0),f.setUint16(8,0,!0),f.setUint16(10,0,!0),f.setUint16(12,0,!0),f.setUint32(14,m,!0),f.setUint32(18,b,!0),f.setUint32(22,b,!0),f.setUint16(26,h.length,!0),f.setUint16(28,w,!0),N.set(h,30),w>0&&N.fill(0,30+h.length),e.push({offset:t,size:b,crc:m,filenameBytes:h,entry:c}),r.push(N),r.push(c.data),t+=N.length+c.data.length}let i=t;for(let c of e){let h=new Uint8Array(46+c.filenameBytes.length),m=new DataView(h.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,0,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,c.crc,!0),m.setUint32(20,c.size,!0),m.setUint32(24,c.size,!0),m.setUint16(28,c.filenameBytes.length,!0),m.setUint16(30,0,!0),m.setUint16(32,0,!0),m.setUint16(34,0,!0),m.setUint16(36,0,!0),m.setUint32(38,0,!0),m.setUint32(42,c.offset,!0),h.set(c.filenameBytes,46),r.push(h),t+=h.length}let s=t-i,o=new Uint8Array(22),l=new DataView(o.buffer);l.setUint32(0,101010256,!0),l.setUint16(4,0,!0),l.setUint16(6,0,!0),l.setUint16(8,e.length,!0),l.setUint16(10,e.length,!0),l.setUint32(12,s,!0),l.setUint32(16,i,!0),l.setUint16(20,0,!0),r.push(o),t+=22;let a=new Uint8Array(t),u=0;for(let c of r)a.set(c,u),u+=c.length;return a}function Ue(n){let e=nr(n),t=je(e);return vn([{filename:"model.usda",data:t}])}function Mt(n){let e=Fe(n),t=xn(e),r=vt(t),i=je(r);return vn([{filename:"model.usda",data:i}])}function Mn(n){return n&&typeof n.toUSDZ=="function"?n.toUSDZ():n&&typeof n.traverse=="function"?Ue(n):Mt(n)}var wt=class n{constructor(e=0,t=0){this.x=Number(e),this.y=Number(t)}set(e,t){return this.x=Number(e),this.y=Number(t),this}clone(){return new n(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}sub(e){return this.x-=e.x,this.y-=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}},te=class n{constructor(e=0,t=0,r=0){this.x=Number(e),this.y=Number(t),this.z=Number(r)}set(e,t,r){return this.x=Number(e),this.y=Number(t),this.z=Number(r),this}clone(){return new n(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}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}length(){return Math.hypot(this.x,this.y,this.z)}normalize(){let e=this.length();return e>1e-5&&(this.x/=e,this.y/=e,this.z/=e),this}cross(e){let t=this.y*e.z-this.z*e.y,r=this.z*e.x-this.x*e.z,i=this.x*e.y-this.y*e.x;return this.x=t,this.y=r,this.z=i,this}crossVectors(e,t){let r=e.x,i=e.y,s=e.z,o=t.x,l=t.y,a=t.z;return this.x=i*a-s*l,this.y=s*o-r*a,this.z=r*l-i*o,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}distanceTo(e){return Math.hypot(this.x-e.x,this.y-e.y,this.z-e.z)}lerp(e,t){return this.lerpVectors(this,e,t)}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}applyMatrix4(e){let t=this.x,r=this.y,i=this.z,s=e.elements,o=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*o,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*o,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*o,this}},Et=class{constructor(e=0,t=0,r=0,i=1){this.x=Number(e),this.y=Number(t),this.z=Number(r),this.w=Number(i)}set(e,t,r,i){return this.x=Number(e),this.y=Number(t),this.z=Number(r),this.w=Number(i),this}},Qe=class n{constructor(e=0,t=0,r=0,i="XYZ"){this._onChangeCallback=null;this._x=Number(e),this._y=Number(t),this._z=Number(r),this.order=i}get x(){return this._x}set x(e){this._x=Number(e),this._onChangeCallback?.()}get y(){return this._y}set y(e){this._y=Number(e),this._onChangeCallback?.()}get z(){return this._z}set z(e){this._z=Number(e),this._onChangeCallback?.()}set(e,t,r,i=this.order){return this._x=Number(e),this._y=Number(t),this._z=Number(r),this.order=i,this._onChangeCallback?.(),this}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this.order=e.order,this._onChangeCallback?.(),this}clone(){return new n(this._x,this._y,this._z,this.order)}_onChange(e){return this._onChangeCallback=e,this}},et=class n{constructor(e=0,t=0,r=0,i=1){this._onChangeCallback=null;this._x=Number(e),this._y=Number(t),this._z=Number(r),this._w=Number(i)}get x(){return this._x}set x(e){this._x=Number(e),this._onChangeCallback?.()}get y(){return this._y}set y(e){this._y=Number(e),this._onChangeCallback?.()}get z(){return this._z}set z(e){this._z=Number(e),this._onChangeCallback?.()}get w(){return this._w}set w(e){this._w=Number(e),this._onChangeCallback?.()}set(e,t,r,i){return this._x=Number(e),this._y=Number(t),this._z=Number(r),this._w=Number(i),this._onChangeCallback?.(),this}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback?.(),this}clone(){return new n(this._x,this._y,this._z,this._w)}setFromEuler(e,t=!0){let r=e.x,i=e.y,s=e.z,o=Math.cos(r/2),l=Math.cos(i/2),a=Math.cos(s/2),u=Math.sin(r/2),c=Math.sin(i/2),h=Math.sin(s/2);return this._x=u*l*a+o*c*h,this._y=o*c*a-u*l*h,this._z=o*l*h+u*c*a,this._w=o*l*a-u*c*h,t&&this._onChangeCallback?.(),this}setFromAxisAngle(e,t){let r=t/2,i=Math.sin(r);return this.set(e.x*i,e.y*i,e.z*i,Math.cos(r))}normalize(){let e=Math.hypot(this._x,this._y,this._z,this._w);return e===0?this.set(0,0,0,1):this.set(this._x/e,this._y/e,this._z/e,this._w/e)}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-6?(Math.abs(e.x)>Math.abs(e.z)?this.set(-e.y,e.x,0,0):this.set(0,-e.z,e.y,0)).normalize():this.set(e.y*t.z-e.z*t.y,e.z*t.x-e.x*t.z,e.x*t.y-e.y*t.x,r).normalize()}multiply(e){return this.multiplyQuaternions(this,e)}multiplyQuaternions(e,t){let r=e.x,i=e.y,s=e.z,o=e.w,l=t.x,a=t.y,u=t.z,c=t.w;return this._x=r*c+o*l+i*u-s*a,this._y=i*c+o*a+s*l-r*u,this._z=s*c+o*u+r*a-i*l,this._w=o*c-r*l-i*a-s*u,this._onChangeCallback?.(),this}_onChange(e){return this._onChangeCallback=e,this}},Se=class n{constructor(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}identity(){let e=this.elements;return e.fill(0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,this}copy(e){return this.elements.set(e.elements),this}clone(){let e=new n;return e.copy(this),e}compose(e,t,r){return Me(this.elements,[t.x,t.y,t.z,t.w],[e.x,e.y,e.z],[r.x,r.y,r.z]),this}multiply(e){return this.multiplyMatrices(this,e)}multiplyMatrices(e,t){return ee(this.elements,e.elements,t.elements),this}lookAt(e,t,r){return Re(this.elements,[e.x,e.y,e.z],[t.x,t.y,t.z],[r.x,r.y,r.z]),this}makeRotationFromQuaternion(e){let t=new te(0,0,0),r=new te(1,1,1);return this.compose(t,e,r)}makeTranslation(e,t,r){return this.identity(),this.elements[12]=Number(e),this.elements[13]=Number(t),this.elements[14]=Number(r),this}makeScale(e,t,r){return this.identity(),this.elements[0]=Number(e),this.elements[5]=Number(t),this.elements[10]=Number(r),this}},Rt=class{constructor(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1])}identity(){let e=this.elements;return e.fill(0),e[0]=1,e[4]=1,e[8]=1,this}getNormalMatrix(e){return me(this.elements,e.elements),this}},de=class n{constructor(e,t,r){this.r=1;this.g=1;this.b=1;e!==void 0&&(t!==void 0&&r!==void 0?this.setRGB(e,t,r):this.set(e))}set(e){if(typeof e=="number")this.setHex(e);else if(typeof e=="string")if(e.startsWith("#")){let t=parseInt(e.slice(1),16);this.setHex(t)}else e==="red"?this.setRGB(1,0,0):e==="green"?this.setRGB(0,1,0):e==="blue"?this.setRGB(0,0,1):e==="white"?this.setRGB(1,1,1):e==="black"&&this.setRGB(0,0,0);else e&&typeof e=="object"&&"r"in e&&(this.r=Number(e.r),this.g=Number(e.g),this.b=Number(e.b));return this}setHex(e){let t=Math.floor(e);return this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,this}setRGB(e,t,r){return this.r=Number(e),this.g=Number(t),this.b=Number(r),this}getHex(){return Math.round(Math.max(0,Math.min(1,this.r))*255)<<16|Math.round(Math.max(0,Math.min(1,this.g))*255)<<8|Math.round(Math.max(0,Math.min(1,this.b))*255)}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}clone(){return new n(this.r,this.g,this.b)}},ir={degToRad:n=>n*Math.PI/180,radToDeg:n=>n*180/Math.PI,clamp:(n,e,t)=>Math.max(e,Math.min(t,n)),lerp:(n,e,t)=>n+(e-n)*t,generateUUID:()=>Math.random().toString(36).substring(2,15),randFloat:(n,e)=>n+Math.random()*(e-n)},le=class{constructor(e,t){this.needsUpdate=!1;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>16)throw new Error(`SecurityError: BufferAttribute itemSize must be an integer in [1, 16]. Received: ${String(t)}`);Array.isArray(e)?this.array=new Float32Array(e):this.array=e,this.itemSize=t;let r=this.array?this.array.length:0;if(!Number.isFinite(r)||r<0)throw new Error(`SecurityError: BufferAttribute array has a non-finite length: ${String(r)}`);this.count=Math.floor(r/t)}getX(e){return this.array[e*this.itemSize]}getY(e){return this.array[e*this.itemSize+1]}getZ(e){return this.array[e*this.itemSize+2]}setX(e,t){return this.array[e*this.itemSize]=t,this.needsUpdate=!0,this}setY(e,t){return this.array[e*this.itemSize+1]=t,this.needsUpdate=!0,this}setZ(e,t){return this.array[e*this.itemSize+2]=t,this.needsUpdate=!0,this}setXYZ(e,t,r,i){let s=e*this.itemSize;return this.array[s]=t,this.array[s+1]=r,this.array[s+2]=i,this.needsUpdate=!0,this}},_t=class extends le{constructor(e,t){super(e instanceof Float32Array?e:new Float32Array(e),t)}},St=class extends le{constructor(e,t){super(e instanceof Uint16Array?e:new Uint16Array(e),t)}},At=class extends le{constructor(e,t){super(e instanceof Uint32Array?e:new Uint32Array(e),t)}},he=class{constructor(){this.name="";this.attributes={};this.index=null;this.boundingBox=null}setAttribute(e,t){return this.attributes[e]=t,this}getAttribute(e){return this.attributes[e]}setIndex(e){if(e instanceof le)this.index=e;else if(Array.isArray(e)){let t=0;for(let r of e)r>t&&(t=r);this.index=new le(new(t>65535?Uint32Array:Uint16Array)(e),1)}else e&&e.buffer&&(this.index=new le(e,1));return this}computeVertexNormals(){let e=this.attributes.position;if(!e)return this;let t=e.count,r=new Float32Array(t*3),i=new te,s=new te,o=new te,l=new te,a=new te;if(this.index){let u=this.index.array;for(let c=0;c<u.length;c+=3){let h=u[c],m=u[c+1],b=u[c+2];i.set(e.getX(h),e.getY(h),e.getZ(h)),s.set(e.getX(m),e.getY(m),e.getZ(m)),o.set(e.getX(b),e.getY(b),e.getZ(b)),l.subVectors(o,s),a.subVectors(i,s),l.cross(a).normalize();for(let g of[h,m,b])r[g*3]+=l.x,r[g*3+1]+=l.y,r[g*3+2]+=l.z}}else for(let u=0;u<t;u+=3){i.set(e.getX(u),e.getY(u),e.getZ(u)),s.set(e.getX(u+1),e.getY(u+1),e.getZ(u+1)),o.set(e.getX(u+2),e.getY(u+2),e.getZ(u+2)),l.subVectors(o,s),a.subVectors(i,s),l.cross(a).normalize();for(let c=0;c<3;c++)r[(u+c)*3]=l.x,r[(u+c)*3+1]=l.y,r[(u+c)*3+2]=l.z}for(let u=0;u<t;u++){let c=r[u*3],h=r[u*3+1],m=r[u*3+2],b=Math.hypot(c,h,m)||1;r[u*3]=c/b,r[u*3+1]=h/b,r[u*3+2]=m/b}return this.setAttribute("normal",new le(r,3)),this}setFromBuffers(e,t,r,i){this.setAttribute("position",new le(e,3)),this.setAttribute("normal",new le(t,3)),this.setAttribute("uv",new le(r,2)),this.setIndex(i)}computeBoundingBox(){let e=this.attributes.position,t=new te(1/0,1/0,1/0),r=new te(-1/0,-1/0,-1/0);if(e&&e.count>0)for(let i=0;i<e.count;i++){let s=e.getX(i),o=e.getY(i),l=e.getZ(i);s<t.x&&(t.x=s),o<t.y&&(t.y=o),l<t.z&&(t.z=l),s>r.x&&(r.x=s),o>r.y&&(r.y=o),l>r.z&&(r.z=l)}else t.set(0,0,0),r.set(0,0,0);return this.boundingBox={min:t,max:r},this.boundingBox}center(){let e=this.computeBoundingBox(),t=(e.min.x+e.max.x)*.5,r=(e.min.y+e.max.y)*.5,i=(e.min.z+e.max.z)*.5,s=this.attributes.position;if(s&&s.count>0){for(let o=0;o<s.count;o++)s.setXYZ(o,s.getX(o)-t,s.getY(o)-r,s.getZ(o)-i);this.computeBoundingBox()}return this}dispose(){}},tt=class extends he{constructor(e=1,t=1,r=1){super();let i=e/2,s=t/2,o=r/2,l=[-i,-s,o,i,-s,o,i,s,o,-i,s,o,i,-s,-o,-i,-s,-o,-i,s,-o,i,s,-o,-i,s,o,i,s,o,i,s,-o,-i,s,-o,-i,-s,-o,i,-s,-o,i,-s,o,-i,-s,o,i,-s,o,i,-s,-o,i,s,-o,i,s,o,-i,-s,-o,-i,-s,o,-i,s,o,-i,s,-o],a=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0],u=[],c=[];for(let h=0;h<6;h++){let m=h*4;u.push(0,0,1,0,1,1,0,1),c.push(m,m+1,m+2,m,m+2,m+3)}this.setFromBuffers(l,a,u,c)}},Ct=class extends he{constructor(e=1,t=1,r=1,i=1){super(),r=Math.max(1,Math.floor(r)),i=Math.max(1,Math.floor(i));let s=[],o=[],l=[],a=[];for(let u=0;u<=i;u++){let c=u/i;for(let h=0;h<=r;h++){let m=h/r;if(s.push((m-.5)*e,(.5-c)*t,0),o.push(0,0,1),l.push(m,1-c),u>0&&h>0){let b=(r+1)*u+h-1,g=b-(r+1);a.push(g,b,g+1,b,b+1,g+1)}}}this.setFromBuffers(s,o,l,a)}},nt=class extends he{constructor(e=1,t=16,r=12){super(),t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));let i=[],s=[],o=[],l=[];for(let a=0;a<=r;a++){let u=a/r;for(let c=0;c<=t;c++){let h=c/t,m=h*Math.PI*2,b=u*Math.PI,g=-Math.cos(m)*Math.sin(b),d=Math.cos(b),w=Math.sin(m)*Math.sin(b);if(i.push(e*g,e*d,e*w),s.push(g,d,w),o.push(h,1-u),a>0&&c>0){let C=(t+1)*a+c,N=C-(t+1),f=N-1,E=C-1;a!==1&&l.push(N,f,C),a!==r&&l.push(f,E,C)}}}this.setFromBuffers(i,s,o,l)}},Te=class extends he{constructor(e=1,t=1,r=1,i=16){super(),i=Math.max(3,Math.floor(i));let s=[],o=[],l=[],a=[],u=r/2;for(let c=0;c<=1;c++){let h=c,m=c===0?e:t,b=c===0?u:-u;for(let g=0;g<=i;g++){let d=g/i,w=d*Math.PI*2,C=Math.sin(w),N=Math.cos(w);s.push(m*C,b,m*N),o.push(C,0,N),l.push(d,1-h)}}for(let c=0;c<i;c++){let h=c,m=c+i+1,b=c+i+2,g=c+1;a.push(h,m,g,m,b,g)}if(e>0){let c=s.length/3;s.push(0,u,0),o.push(0,1,0),l.push(.5,.5);let h=s.length/3;for(let m=0;m<=i;m++){let b=m/i*Math.PI*2,g=Math.sin(b),d=Math.cos(b);s.push(e*g,u,e*d),o.push(0,1,0),l.push(d*.5+.5,g*.5+.5)}for(let m=0;m<i;m++)a.push(c,h+m,h+m+1)}if(t>0){let c=s.length/3;s.push(0,-u,0),o.push(0,-1,0),l.push(.5,.5);let h=s.length/3;for(let m=0;m<=i;m++){let b=m/i*Math.PI*2,g=Math.sin(b),d=Math.cos(b);s.push(t*g,-u,t*d),o.push(0,-1,0),l.push(d*.5+.5,1-(g*.5+.5))}for(let m=0;m<i;m++)a.push(c,h+m+1,h+m)}this.setFromBuffers(s,o,l,a)}},It=class extends Te{constructor(e=1,t=1,r=16){super(0,e,t,r)}},Dt=class extends he{constructor(e=1,t=.4,r=12,i=48,s=Math.PI*2){super(),r=Math.max(3,Math.floor(r)),i=Math.max(3,Math.floor(i));let o=[],l=[],a=[],u=[];for(let c=0;c<=r;c++){let h=c/r*Math.PI*2,m=Math.cos(h),b=Math.sin(h);for(let g=0;g<=i;g++){let d=g/i*s,w=Math.cos(d),C=Math.sin(d);if(o.push((e+t*m)*w,(e+t*m)*C,t*b),l.push(m*w,m*C,b),a.push(g/i,c/r),c>0&&g>0){let N=(i+1)*c+g-1,f=N-(i+1);u.push(N,f,N+1,f,f+1,N+1)}}}this.setFromBuffers(o,l,a,u)}},Lt=class extends he{constructor(e=1,t=.4,r=64,i=8,s=2,o=3){super(),r=Math.floor(r),i=Math.floor(i);let l=[],a=[],u=[],c=[],h=new te,m=new te,b=new te,g=new te,d=new te;function w(f,E){let x=Math.cos(E),_=Math.sin(E),D=o/s*E,v=e*(2+Math.cos(D))*.5;f.set(v*x,v*_,e*Math.sin(D)*.5)}let C=[];for(let f=0;f<=i;++f){let E=f/i*Math.PI*2;C.push(-t*Math.cos(E),t*Math.sin(E),f/i)}for(let f=0;f<=r;++f){let E=f/r,x=E*s*Math.PI*2;w(h,x),w(m,x+.01),b.subVectors(m,h).normalize(),g.addVectors(h,m).normalize(),d.crossVectors(b,g).normalize(),g.crossVectors(d,b).normalize();for(let _=0;_<=i;++_){let D=_*3,v=C[D],M=C[D+1],I=C[D+2],p=v*g.x+M*d.x,y=v*g.y+M*d.y,A=v*g.z+M*d.z;l.push(h.x+p,h.y+y,h.z+A);let T=Math.hypot(p,y,A)||1;a.push(p/T,y/T,A/T),u.push(E,I)}}let N=i+1;for(let f=1;f<=r;f++){let E=N*(f-1),x=E+N;for(let _=1;_<=i;_++){let D=E+(_-1),v=x+(_-1),M=x+_,I=E+_;c.push(D,v,I,v,M,I)}}this.setFromBuffers(l,a,u,c)}},rt=class{constructor(e=""){this.isTexture=!0;this.wrapS=10497;this.wrapT=10497;this.image=null;this.width=0;this.height=0;this.source=e,e&&typeof e=="object"&&(this.image=e)}dispose(){}},Nt=class{load(e,t){let r=new rt(e);return t?.(r),r}};function ue(n,e){return n!==void 0?Number(n):e}function Tt(n,e){return n!==void 0?!!n:e}var xe=class{constructor(e={}){this.name=e.name||"",this.color=new de(e.color!==void 0?e.color:16777215),this.emissive=new de(e.emissive!==void 0?e.emissive:0),this.emissiveIntensity=ue(e.emissiveIntensity,1),this.roughness=ue(e.roughness,.5),this.metalness=ue(e.metalness,.1),this.opacity=ue(e.opacity,1),this.transparent=Tt(e.transparent,!1),this.wireframe=Tt(e.wireframe,!1),this.side=ue(e.side,2),this.doubleSided=Tt(e.doubleSided,!0),this.map=e.map||null,this.clearcoat=ue(e.clearcoat,0),this.clearcoatRoughness=ue(e.clearcoatRoughness,0),this.sheen=ue(e.sheen,0),this.sheenColor=new de(e.sheenColor!==void 0?e.sheenColor:0),this.sheenRoughness=ue(e.sheenRoughness,0),this.transmission=ue(e.transmission,0),this.thickness=ue(e.thickness,0),this.attenuationColor=new de(e.attenuationColor!==void 0?e.attenuationColor:16777215),this.attenuationDistance=ue(e.attenuationDistance,1/0),this.ior=ue(e.ior,1.5),this.dispersion=ue(e.dispersion,0),this.iridescence=ue(e.iridescence,0),this.iridescenceIOR=ue(e.iridescenceIOR,1.3)}dispose(){}},Ae=class extends xe{},Pt=class extends xe{},Ft=class extends xe{},kt=class extends xe{},Ut=class extends xe{},pe=class n{constructor(){this.name="";this.matrixAutoUpdate=!0;this.visible=!0;this.castShadow=!1;this.receiveShadow=!1;this.parent=null;this.children=[];this.userData={};this.position=new te,this.rotation=new Qe,this.quaternion=new et,this.scale=new te(1,1,1),this.matrix=new Se,this.matrixWorld=new Se,this.rotation._onChange(()=>{this.quaternion.setFromEuler(this.rotation,!1)}),this.quaternion._onChange(()=>{let e=this.quaternion,t=Math.atan2(2*(e.w*e.x+e.y*e.z),1-2*(e.x*e.x+e.y*e.y)),r=Math.asin(Math.max(-1,Math.min(1,2*(e.w*e.y-e.z*e.x)))),i=Math.atan2(2*(e.w*e.z+e.x*e.y),1-2*(e.y*e.y+e.z*e.z));this.rotation.set(t,r,i)})}add(...e){for(let t of e)t&&t instanceof n&&(t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t));return this}remove(...e){for(let t of e){let r=this.children.indexOf(t);r!==-1&&(t.parent=null,this.children.splice(r,1))}return this}traverse(e){e(this);for(let t of this.children)t.traverse(e)}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(e=!1){An(this),(this.matrixAutoUpdate||e)&&this.updateMatrix(),this.parent?this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix);for(let t of this.children)t.updateMatrixWorld(e)}lookAt(e,t,r){let i=typeof e=="object"?e:new te(e,t,r);this.updateMatrixWorld(!0);let s=new Se;s.lookAt(this.position,i,new te(0,1,0));let o=s.elements,l=o[0],a=o[4],u=o[8],c=o[1],h=o[5],m=o[9],b=o[2],g=o[6],d=o[10],w=l+h+d;if(w>0){let C=.5/Math.sqrt(w+1);this.quaternion.set((g-m)*C,(u-b)*C,(c-a)*C,.25/C)}}},Ot=class extends pe{},Ce=class extends pe{constructor(t,r){super();this.isMesh=!0;let i=Array.isArray(r)?r[0]:r;this.geometry=t instanceof he?t:t?(fe("unsupported geometry","BoxGeometry"),new tt(.5,.5,.5)):new he,this.material=i instanceof xe?i:i?(fe("unsupported material","MeshStandardMaterial"),new Ae({color:13421772})):new Ae}};function An(n){let e=Q().materializeDeclarativeGeometry;typeof e=="function"&&e(n)}var it=1e4,st=class extends Ce{constructor(t,r,i=1){super(t,r);this.instanceColor=null;this.isInstancedMesh=!0;let s=Number(i);if(!Number.isFinite(s)||s<0||s>it)throw new RangeError(`SecurityError: InstancedMesh count (${String(i)}) exceeds MAX_INSTANCES_PER_MESH (${it})`);this.count=Math.floor(s);let o=new Float32Array(this.count*16);for(let l=0;l<this.count;l++){let a=l*16;o[a]=1,o[a+5]=1,o[a+10]=1,o[a+15]=1}this.instanceMatrix=new le(o,16)}setMatrixAt(t,r){let i=Math.floor(Number(t));if(!Number.isFinite(i)||i<0||i>=this.count||!r||!r.elements)return;let s=this.instanceMatrix.array,o=i*16;if(!(o+16>s.length))for(let l=0;l<16;l++){let a=Number(r.elements[l]);s[o+l]=Number.isFinite(a)?a:l%5===0?1:0}}getMatrixAt(t,r){let i=Math.floor(Number(t));if(!Number.isFinite(i)||i<0||i>=this.count||!r||!r.elements)return;let s=this.instanceMatrix.array,o=i*16;if(!(o+16>s.length))for(let l=0;l<16;l++)r.elements[l]=s[o+l]}setColorAt(t,r){let i=Math.floor(Number(t));if(!Number.isFinite(i)||i<0||i>=this.count||!r)return;if(!this.instanceColor||this.instanceColor.array.length<this.count*3){let l=new Float32Array(this.count*3);l.fill(1),this.instanceColor=new le(l,3)}let s=this.instanceColor.array,o=i*3;s[o]=Number.isFinite(r.r)?r.r:1,s[o+1]=Number.isFinite(r.g)?r.g:1,s[o+2]=Number.isFinite(r.b)?r.b:1}getColorAt(t,r){let i=Math.floor(Number(t));if(!Number.isFinite(i)||i<0||i>=this.count||!r)return;if(!this.instanceColor||this.instanceColor.array.length<(i+1)*3){r.setRGB(1,1,1);return}let s=this.instanceColor.array,o=i*3;r.setRGB(s[o],s[o+1],s[o+2])}dispose(){}},Ie=class extends pe{constructor(e=16777215,t=1){super(),this.color=new de(e),this.intensity=Number(t),this.type="directional"}},ot=class extends Ie{constructor(e,t){super(e,t),this.type="ambient"}},Bt=class extends Ie{constructor(t,r){super(t,r);this.target=new pe;this.type="directional"}},at=class extends Ie{constructor(t,r,i=0,s=2){super(t,r);this.distance=0;this.decay=2;this.type="point",this.distance=i,this.decay=s}},ct=class extends pe{},Vt=class extends ct{constructor(t=45,r=1,i=.1,s=1e3){super();this.target=new te(0,0,0);this.fov=Number(t),this.aspect=Number(r),this.near=Number(i),this.far=Number(s)}},ut=class extends pe{constructor(){super(...arguments);this.background=null;this.environmentIntensity=1}toCanvas3D(){return ge.validate(this),ke(this)}toGLB(){return ge.validate(this),Ke(this)}toUSDZ(){return ge.validate(this),Ue(this)}getMeshTransforms(){this.updateMatrixWorld(!0);let t=new Map,r=0;return this.traverse(i=>{if(i instanceof Ce){let s=new Float32Array(i.matrixWorld.elements);t.set(r,s),i.name&&t.set(i.name,s),r++}}),t}},Cn=ke,In=Ke,sr=Ue;var ge=class{static validate(e){let t=0,r=0,i=0,s=new Set,o=(a,u,c)=>{throw new Error(`SecurityError: Scene exceeds SECURITY_3D_MAX_${a} (${u}). Found: ${c}`)},l=(a,u)=>{if(!Number.isFinite(u))throw new Error(`SecurityError: Scene reports a non-finite ${a} count (${String(u)}), which cannot be bounds-checked.`);return u};e.traverse(a=>{if(An(a),a instanceof Ce||a.geometry?.attributes?.position?.count){if(i++,i>1e3&&o("MESHES",1e3,i),a instanceof st){let c=l("instance",a.count);(c<0||c>it)&&o("INSTANCES",it,c)}let u=a.geometry;if(u){let c=0;if(u.attributes.position&&(c=l("vertex",u.attributes.position.count),t+=c,t>1e5&&o("VERTICES",1e5,t)),u.index){let h=l("index",u.index.count);r+=h,r>3e5&&o("INDICES",3e5,r);let m=u.index.array;if(m&&c>0){let b=Math.min(h,m.length);for(let g=0;g<b;g++){let d=m[g];if(!Number.isFinite(d)||d<0||d>=c)throw new Error(`SecurityError: Index buffer value (${String(d)}) out of vertex bounds [0, ${c}).`)}}}}if(a.material){let c=a.material;c.map&&s.add(c.map),c.normalMap&&s.add(c.normalMap),c.roughnessMap&&s.add(c.roughnessMap)}}}),s.size>16&&o("TEXTURES",16,s.size);for(let a of s){let u=a,c=u.image,h=Number(c?.width??u.width??0)||0,m=Number(c?.height??u.height??0)||0;(!Number.isFinite(h)||!Number.isFinite(m)||h>2048||m>2048)&&o("TEXTURE_DIMENSION",2048,Math.max(h,m))}}},zt=class{constructor(e={}){this.shadowMap={enabled:!1,type:0};this.capabilities={isWebGL2:!0,maxTextures:16};this.boundViewer=null;this.isSandboxed=!1;this.containerId="";this.hasInitialModelRendered=!1;this.domElement=e.canvas||(typeof document<"u"?document.createElement("canvas"):{}),e.viewer&&(this.boundViewer=e.viewer),e.container?.threeLiveViewer&&(this.boundViewer=e.container.threeLiveViewer),e.canvas?.parentElement?.threeLiveViewer&&(this.boundViewer=e.canvas.parentElement.threeLiveViewer);let t=typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope;this.isSandboxed=e.isSandboxed||t,this.containerId=e.containerId||""}setSize(e,t){return this}setPixelRatio(e){return this}setClearColor(e,t=1){let r=new de(e);return this.boundViewer&&typeof this.boundViewer.setClearColor=="function"&&this.boundViewer.setClearColor(r.r,r.g,r.b,t),this}clear(){return this}dispose(){}render(e,t){if(this.isSandboxed){ge.validate(e);let i=(s,o)=>{typeof self<"u"&&typeof self.postMessage=="function"&&(o&&o.length?self.postMessage(s,o):self.postMessage(s))};if(this.hasInitialModelRendered){let s=e.getMeshTransforms(),o={};for(let[l,a]of s.entries())o[l]=Array.from(a);i({type:"3D_UPDATE_TRANSFORMS",containerId:this.containerId,transforms:o})}else{this.hasInitialModelRendered=!0;let s=Cn(e),o=In(e),l=(s.lights||[]).map(a=>({type:a.type,color:a.color,intensity:a.intensity,position:a.position}));i({type:"3D_MODEL_READY",containerId:this.containerId,glbBuffer:o.buffer,dynamicLights:l,camera:t?{fov:t.fov||60,position:[t.position.x,t.position.y,t.position.z]}:void 0},[o.buffer])}return}let r=this.boundViewer;!r&&this.domElement?.parentElement&&this.domElement.parentElement.threeLiveViewer&&(r=this.domElement.parentElement.threeLiveViewer,this.boundViewer=r),!r&&typeof window<"u"&&(r=window.__three_live_active_viewer__,this.boundViewer=r),r&&typeof r.loadModel=="function"&&(r._hasThreeLiveModelLoaded?typeof r.updateMeshTransforms=="function"&&r.updateMeshTransforms(e.getMeshTransforms()):(r.loadModel(e.toCanvas3D()),r._hasThreeLiveModelLoaded=!0))}};function Tn(){return typeof globalThis<"u"&&typeof globalThis.__three_live_sim_time_ms__=="number"?globalThis.__three_live_sim_time_ms__:typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Gt=class{constructor(e=!0){this.startTime=0;this.oldTime=0;this.elapsedTime=0;this.running=!1;this.autoStart=e,e&&this.start()}start(){this.startTime=Tn(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running&&this.start(),this.running){let t=Tn();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function or(){}var qe=new Proxy(or,{get:(n,e)=>{if(e==="isProxy")return!0;if(!(e==="constructor"||e==="__proto__"||e==="prototype"))return e==="domElement"?typeof document<"u"?document.createElement("canvas"):{}:e==="shadowMap"?{enabled:!1,type:0}:e==="capabilities"?{isWebGL2:!0,maxTextures:16}:e===Symbol.toPrimitive?()=>0:qe},getPrototypeOf:()=>null,setPrototypeOf:()=>!1,apply:()=>qe,construct:()=>qe}),wn=(()=>{try{if(typeof document>"u")return null;let n=document.currentScript;return n?.src?n.src:n?.textContent&&typeof Blob<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(new Blob([n.textContent],{type:"text/javascript"})):null}catch{return null}})();function Le(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"&&location.href?location.href:"https://localhost/"}function we(n,e){if(!n||typeof n!="string")return!1;let t=n.trim();if(!t)return!1;try{let r=new URL(t,Le());return!(r.protocol!=="https:"&&r.protocol!=="http:"&&r.protocol!=="blob:"||e?.requireSameOrigin&&r.protocol!=="blob:"&&typeof location<"u"&&location.origin&&location.origin!=="null"&&r.origin!==location.origin)}catch{return!1}}var En,Oe;function ar(n){if(!we(n))throw new Error(`SecurityError: Refusing to create TrustedScriptURL for disallowed URL "${n}".`);let t=globalThis.trustedTypes;if(!t||typeof t.createPolicy!="function")return n;if(Oe===void 0||En!==t){En=t;try{Oe=t.createPolicy("three-live#worker",{createScriptURL:r=>{if(!we(r))throw new TypeError(`SecurityError: Disallowed Three-Live worker script URL "${r}".`);return r}})}catch{Oe=null}}return Oe?Oe.createScriptURL(n):n}function Wr(n){Q().sandboxEngineSrc=n}function Dn(){let n=Q().sandboxEngineSrc;if(n)return n;if(wn)return wn;try{if(typeof document>"u")return null;let e=Le(),t=Array.from(document.querySelectorAll("script[src]"));for(let r of t){let i=r.src;if(!i)continue;let s=new URL(i,e).pathname;if(/(?:^|\/)(?:three|xr)-live[^/]*\.js$/.test(s)&&we(i,{requireSameOrigin:!0}))return i}}catch{}return null}function cr(){let n=Dn();if(!n)throw new Error("Three-Live could not locate its own bundle URL, which the worker sandbox needs in order to load the THREE runtime. Set it explicitly, e.g. ThreeLiveElement.sandboxEngineSrc = new URL('three-live.min.js', import.meta.url).href. Refusing to execute the script, because unsandboxed host-realm execution is prohibited.");if(!we(n))throw new Error(`SecurityError: Refusing to load sandbox engine from disallowed URL "${n}". Only http:, https:, and blob: URLs are permitted.`);return new URL(n,Le()).href}function $r(n){Q().sandboxIframeSrc=n}function ur(){let n=Q().sandboxIframeSrc;if(n)return n;let e=Dn();if(!e||!we(e))return null;let t=new URL(e,Le());return t.protocol==="blob:"?null:new URL("three-live-sandbox.html",t).href}function lr(){let n=ur();if(!n)throw new Error("Three-Live could not locate three-live-sandbox.html for iframe sandbox execution. Set ThreeLiveElement.sandboxIframeSrc (or ThreeLiveElement.sandboxEngineSrc) explicitly.");if(!we(n))throw new Error(`SecurityError: Refusing to load sandbox iframe from disallowed URL "${n}". Only http:, https:, and blob: URLs are permitted.`);return new URL(n,Le()).href}function Yr(n){Q().allowClientScripts=n}function mr(){return!!Q().allowClientScripts}function hr(n){if(!we(n))throw new Error(`SecurityError: Refusing to load procedural scene script from disallowed URL "${n}". Only http:, https:, and blob: URLs are permitted.`);return new URL(n,Le()).href}var fr=["fetch","XMLHttpRequest","WebSocket","WebSocketStream","WebTransport","EventSource","importScripts","Request","Response","Headers","navigator","WorkerNavigator","WorkerLocation","RTCPeerConnection","RTCDataChannel","FontFace","FontFaceSet","fonts","PerformanceObserver","ReportingObserver","indexedDB","IDBFactory","caches","CacheStorage","Cache","cookieStore","StorageManager","FileSystemHandle","Worker","SharedWorker","ServiceWorker","ServiceWorkerContainer","ServiceWorkerRegistration","registration","clients","BroadcastChannel","MessageChannel","MessagePort","createImageBitmap","OffscreenCanvas","WebAssembly","WorkerGlobalScope","DedicatedWorkerGlobalScope","trustedTypes","TrustedTypePolicyFactory","SharedArrayBuffer","Atomics"];function dr(n,e){let t=self,r=n.nonce,i=n.engineSrc,s=n.allowedScriptUrl,o=n.allowClientScripts,l=n.revoked,a=t.postMessage.bind(t);function u(_){a({type:"ERROR",nonce:r,message:String(_)})}let c=typeof t.importScripts=="function"?t.importScripts.bind(t):null,h=s,m=null;try{let _=i;if(typeof t.trustedTypes<"u"&&t.trustedTypes&&typeof t.trustedTypes.createPolicy=="function")try{let D={createScriptURL:function(M){if(M!==i&&(!s||M!==s))throw new TypeError("Disallowed worker importScripts URL");return M}};o&&(D.createScript=function(M){return String(M)});let v=t.trustedTypes.createPolicy("three-live#worker-boot",D);_=v.createScriptURL(i),s&&(h=v.createScriptURL(s)),o&&typeof v.createScript=="function"&&(m=v.createScript.bind(v))}catch{}c(_)}catch(_){u('Sandbox failed to load the Three-Live engine from "'+i+'". It must be a same-origin (or CORS-enabled) IIFE bundle such as three-live.min.js. Underlying error: '+(_&&_.message||_));return}let b=t.THREE;if(!b||typeof b.Scene!="function"){u('Sandbox loaded "'+i+'" but it did not install a THREE namespace. Point sandboxEngineSrc at an IIFE build (three-live.min.js), not an ES module build.');return}if(Array.isArray(e)){let _=t.__THREE_LIVE_REGISTRY__;for(let D=0;D<e.length;D++)if(typeof e[D]=="function")try{e[D](b,_)}catch{}}for(let _=0;_<l.length;_++){let D=l[_],v=t;for(;v&&v!==Object.prototype;){if(v!==t)try{delete v[D]}catch{}try{Object.defineProperty(v,D,{value:void 0,writable:!1,configurable:!1,enumerable:!1})}catch{}try{v=Object.getPrototypeOf(v)}catch{break}}}let g=Object.freeze({now:function(){return Date.now()}}),d=t;for(;d&&d!==Object.prototype;){if(d!==t)try{delete d.performance}catch{}try{Object.defineProperty(d,"performance",{value:g,writable:!1,configurable:!1,enumerable:!1})}catch{}try{d=Object.getPrototypeOf(d)}catch{break}}let w=["3D_MODEL_READY","3D_UPDATE_TRANSFORMS"],C=!1;function N(_,D){if(_.type==="3D_MODEL_READY"){if(C)return;C=!0}_.nonce=r,D&&D.length?a(_,D):a(_)}let f=function(_,D){if(!_||w.indexOf(_.type)===-1)throw new Error("Sandboxed scripts may only post Three-Live scene messages ("+w.join(", ")+").");N(_,D)},E=t;for(;E&&E!==Object.prototype;){if(E===t||Object.prototype.hasOwnProperty.call(E,"postMessage"))try{Object.defineProperty(E,"postMessage",{value:f,writable:!1,configurable:!1})}catch{}try{E=Object.getPrototypeOf(E)}catch{break}}let x=!1;t.onmessage=function(_){let D=_&&_.data;if(!(!D||D.nonce!==r)&&!(D.type!=="EXECUTE"&&D.type!=="EXECUTE_URL")&&!x){x=!0;try{let v=new b.Scene,M=new b.PerspectiveCamera(60,1,.1,1e3),I=new b.WebGLRenderer({isSandboxed:!0});if(D.type==="EXECUTE_URL"){if(!s||D.scriptUrl!==s||typeof c!="function"){u("SecurityError: Refusing to execute unapproved script URL inside sandbox worker.");return}let p=h||s,y=c;if(c=null,h=null,t.THREE=b,t.scene=v,t.camera=M,t.renderer=I,y(p),typeof t.__THREE_LIVE_SCENE__=="function"){let A=t.__THREE_LIVE_SCENE__(b,v,M,I);A&&typeof A.toGLB=="function"&&(v=A)}else t.scene&&typeof t.scene.toGLB=="function"&&(v=t.scene)}else{if(!o){u("SecurityError: Client-modified script compilation (Use Case 1) is disabled in this sandbox worker.");return}let p=m?(0,eval)(m(`(function (THREE, scene, camera, renderer) {
|
|
341
|
+
`,a}function us(e,t){if(e&&typeof e.traverse=="function"){let s=os(e,t);return Ce(s)}let i=te(e),r=Se(i);return Ce(r)}var se=null;function Ae(e){if(!se){se=new Uint32Array(256);for(let i=0;i<256;i++){let r=i;for(let s=0;s<8;s++)r=r&1?3988292384^r>>>1:r>>>1;se[i]=r}}let t=4294967295;for(let i=0;i<e.length;i++)t=se[(t^e[i])&255]^t>>>8;return(t^4294967295)>>>0}function cs(e){let t=[],i=0,r=[];for(let c of e){let f=Te(c.filename),y=Ae(c.data),g=c.data.length,u=30+f.length,b=(i+u)%64,w=b!==0?64-b:0,M=new Uint8Array(u+w),x=new DataView(M.buffer);x.setUint32(0,67324752,!0),x.setUint16(4,20,!0),x.setUint32(14,y,!0),x.setUint32(18,g,!0),x.setUint32(22,g,!0),x.setUint16(26,f.length,!0),x.setUint16(28,w,!0),M.set(f,30),t.push({offset:i,size:g,crc:y,filenameBytes:f,entry:c}),r.push(M,c.data),i+=M.length+c.data.length}let s=i;for(let c of t){let f=new Uint8Array(46+c.filenameBytes.length),y=new DataView(f.buffer);y.setUint32(0,33639248,!0),y.setUint16(4,20,!0),y.setUint16(6,20,!0),y.setUint32(16,c.crc,!0),y.setUint32(20,c.size,!0),y.setUint32(24,c.size,!0),y.setUint16(28,c.filenameBytes.length,!0),y.setUint32(42,c.offset,!0),f.set(c.filenameBytes,46),r.push(f),i+=f.length}let n=i-s,o=new Uint8Array(22),a=new DataView(o.buffer);a.setUint32(0,101010256,!0),a.setUint16(8,t.length,!0),a.setUint16(10,t.length,!0),a.setUint32(12,n,!0),a.setUint32(16,s,!0),r.push(o),i+=22;let h=new Uint8Array(i),l=0;for(let c of r)h.set(c,l),l+=c.length;return h}var gi=e=>cs([{filename:"model.usda",data:Te(e)}]);function ne(e){return gi(us(e))}function Pe(e){return gi(Ce(Se(te(e))))}function yi(e){return e&&typeof e.toUSDZ=="function"?e.toUSDZ():Pe(e)}var Tt=class _r{constructor(t=0,i=0){this.x=Number(t),this.y=Number(i)}set(t,i){return this.x=Number(t),this.y=Number(i),this}clone(){return new _r(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divideScalar(t){return this.multiplyScalar(t?1/t:0)}setScalar(t){return this.set(t,t)}},Y=class Er{constructor(t=0,i=0,r=0){this.x=Number(t),this.y=Number(i),this.z=Number(r)}set(t,i,r){return this.x=Number(t),this.y=Number(i),this.z=Number(r),this}clone(){return new Er(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addVectors(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subVectors(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}divideScalar(t){return this.multiplyScalar(t?1/t:0)}setScalar(t){return this.set(t,t,t)}addScaledVector(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this}length(){return Math.hypot(this.x,this.y,this.z)}normalize(){let t=this.length();return t>1e-5&&(this.x/=t,this.y/=t,this.z/=t),this}cross(t){let i=this.y*t.z-this.z*t.y,r=this.z*t.x-this.x*t.z,s=this.x*t.y-this.y*t.x;return this.x=i,this.y=r,this.z=s,this}crossVectors(t,i){let r=t.x,s=t.y,n=t.z,o=i.x,a=i.y,h=i.z;return this.x=s*h-n*a,this.y=n*o-r*h,this.z=r*a-s*o,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}distanceTo(t){return Math.hypot(this.x-t.x,this.y-t.y,this.z-t.z)}lerp(t,i){return this.lerpVectors(this,t,i)}lerpVectors(t,i,r){return this.x=t.x+(i.x-t.x)*r,this.y=t.y+(i.y-t.y)*r,this.z=t.z+(i.z-t.z)*r,this}applyMatrix4(t){let i=this.x,r=this.y,s=this.z,n=t.elements,o=1/(n[3]*i+n[7]*r+n[11]*s+n[15]);return this.x=(n[0]*i+n[4]*r+n[8]*s+n[12])*o,this.y=(n[1]*i+n[5]*r+n[9]*s+n[13])*o,this.z=(n[2]*i+n[6]*r+n[10]*s+n[14])*o,this}},bi=class{constructor(e=0,t=0,i=0,r=1){this.x=Number(e),this.y=Number(t),this.z=Number(i),this.w=Number(r)}set(e,t,i,r){return this.x=Number(e),this.y=Number(t),this.z=Number(i),this.w=Number(r),this}},_e=class Nr{constructor(t=0,i=0,r=0,s="XYZ"){this._onChangeCallback=null,this._x=Number(t),this._y=Number(i),this._z=Number(r),this.order=s}get x(){return this._x}set x(t){this._x=Number(t),this._onChangeCallback?.()}get y(){return this._y}set y(t){this._y=Number(t),this._onChangeCallback?.()}get z(){return this._z}set z(t){this._z=Number(t),this._onChangeCallback?.()}set(t,i,r,s=this.order){return this._x=Number(t),this._y=Number(i),this._z=Number(r),this.order=s,this._onChangeCallback?.(),this}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this.order=t.order,this._onChangeCallback?.(),this}clone(){return new Nr(this._x,this._y,this._z,this.order)}_onChange(t){return this._onChangeCallback=t,this}},Ee=class Dr{constructor(t=0,i=0,r=0,s=1){this._onChangeCallback=null,this._x=Number(t),this._y=Number(i),this._z=Number(r),this._w=Number(s)}get x(){return this._x}set x(t){this._x=Number(t),this._onChangeCallback?.()}get y(){return this._y}set y(t){this._y=Number(t),this._onChangeCallback?.()}get z(){return this._z}set z(t){this._z=Number(t),this._onChangeCallback?.()}get w(){return this._w}set w(t){this._w=Number(t),this._onChangeCallback?.()}set(t,i,r,s){return this._x=Number(t),this._y=Number(i),this._z=Number(r),this._w=Number(s),this._onChangeCallback?.(),this}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback?.(),this}clone(){return new Dr(this._x,this._y,this._z,this._w)}setFromEuler(t,i=!0){let r=t.x,s=t.y,n=t.z,o=Math.cos(r/2),a=Math.cos(s/2),h=Math.cos(n/2),l=Math.sin(r/2),c=Math.sin(s/2),f=Math.sin(n/2);return this._x=l*a*h+o*c*f,this._y=o*c*h-l*a*f,this._z=o*a*f+l*c*h,this._w=o*a*h-l*c*f,i&&this._onChangeCallback?.(),this}setFromAxisAngle(t,i){let r=i/2,s=Math.sin(r);return this.set(t.x*s,t.y*s,t.z*s,Math.cos(r))}normalize(){let t=Math.hypot(this._x,this._y,this._z,this._w);return t===0?this.set(0,0,0,1):this.set(this._x/t,this._y/t,this._z/t,this._w/t)}setFromUnitVectors(t,i){let r=t.dot(i)+1;return r<1e-6?(Math.abs(t.x)>Math.abs(t.z)?this.set(-t.y,t.x,0,0):this.set(0,-t.z,t.y,0)).normalize():this.set(t.y*i.z-t.z*i.y,t.z*i.x-t.x*i.z,t.x*i.y-t.y*i.x,r).normalize()}multiply(t){return this.multiplyQuaternions(this,t)}multiplyQuaternions(t,i){let r=t.x,s=t.y,n=t.z,o=t.w,a=i.x,h=i.y,l=i.z,c=i.w;return this._x=r*c+o*a+s*l-n*h,this._y=s*c+o*h+n*a-r*l,this._z=n*c+o*l+r*h-s*a,this._w=o*c-r*a-s*h-n*l,this._onChangeCallback?.(),this}_onChange(t){return this._onChangeCallback=t,this}},Ot=class Lr{constructor(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}identity(){let t=this.elements;return t.fill(0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,this}copy(t){return this.elements.set(t.elements),this}clone(){let t=new Lr;return t.copy(this),t}compose(t,i,r){return ye(this.elements,[i.x,i.y,i.z,i.w],[t.x,t.y,t.z],[r.x,r.y,r.z]),this}multiply(t){return this.multiplyMatrices(this,t)}multiplyMatrices(t,i){return dt(this.elements,t.elements,i.elements),this}lookAt(t,i,r){return Qt(this.elements,[t.x,t.y,t.z],[i.x,i.y,i.z],[r.x,r.y,r.z]),this}makeRotationFromQuaternion(t){let i=new Y(0,0,0),r=new Y(1,1,1);return this.compose(i,t,r)}makeTranslation(t,i,r){return this.identity(),this.elements[12]=Number(t),this.elements[13]=Number(i),this.elements[14]=Number(r),this}makeScale(t,i,r){return this.identity(),this.elements[0]=Number(t),this.elements[5]=Number(i),this.elements[10]=Number(r),this}},xi=class{constructor(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1])}identity(){let e=this.elements;return e.fill(0),e[0]=1,e[4]=1,e[8]=1,this}getNormalMatrix(e){return Pt(this.elements,e.elements),this}},xt=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,ae=e=>e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055,vi={black:0,white:16777215,red:16711680,green:32768,lime:65280,blue:255,yellow:16776960,cyan:65535,aqua:65535,magenta:16711935,fuchsia:16711935,gray:8421504,grey:8421504,silver:12632256,orange:16753920,purple:8388736,pink:16761035,gold:16766720},Rt=class Ir{constructor(t,i,r){this.r=1,this.g=1,this.b=1,t!==void 0&&(i!==void 0&&r!==void 0?this.setRGB(t,i,r):this.set(t))}set(t){return typeof t=="number"?this.setHex(t):typeof t=="string"?this.setStyle(t):(t&&typeof t=="object"&&"r"in t&&(this.r=Number(t.r),this.g=Number(t.g),this.b=Number(t.b)),this)}setStyle(t){let i=t.trim().toLowerCase();if(i[0]==="#"){let r=i.slice(1);r.length===3||r.length===4?r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]:r.length===8&&(r=r.slice(0,6));let s=parseInt(r,16);r.length===6&&!Number.isNaN(s)&&this.setHex(s)}else if(i in vi)this.setHex(vi[i]);else if(i.startsWith("hsl")){let r=/^hsla?\(([^)]+)\)$/.exec(i)?.[1].trim().split(/[\s,/]+/);r&&r.length>=3&&this.setHSL((parseFloat(r[0])||0)/360,(parseFloat(r[1])||0)/100,(parseFloat(r[2])||0)/100)}else{let r=/^rgba?\(([^)]+)\)$/.exec(i)?.[1].trim().split(/[\s,/]+/);if(r&&r.length>=3){let s=n=>xt(Math.max(0,Math.min(1,(parseFloat(n)||0)/(n.endsWith("%")?100:255))));this.setRGB(s(r[0]),s(r[1]),s(r[2]))}}return this}setHSL(t,i,r){if(t=((Number(t)||0)%1+1)%1,i=Math.max(0,Math.min(1,Number(i)||0)),r=Math.max(0,Math.min(1,Number(r)||0)),i===0){let a=xt(r);return this.setRGB(a,a,a)}let s=r<=.5?r*(1+i):r+i-r*i,n=2*r-s,o=a=>(a<0&&(a+=1),a>1&&(a-=1),a<1/6?n+(s-n)*6*a:a<1/2?s:a<2/3?n+(s-n)*6*(2/3-a):n);return this.setRGB(xt(o(t+1/3)),xt(o(t)),xt(o(t-1/3)))}lerp(t,i){let r=Number(i)||0;return this.r+=(t.r-this.r)*r,this.g+=(t.g-this.g)*r,this.b+=(t.b-this.b)*r,this}lerpColors(t,i,r){let s=Number(r)||0;return this.r=t.r+(i.r-t.r)*s,this.g=t.g+(i.g-t.g)*s,this.b=t.b+(i.b-t.b)*s,this}multiplyScalar(t){let i=Number(t)||0;return this.r*=i,this.g*=i,this.b*=i,this}setScalar(t){let i=Number(t)||0;return this.setRGB(i,i,i)}setHex(t){let i=Math.floor(t);return this.r=xt((i>>16&255)/255),this.g=xt((i>>8&255)/255),this.b=xt((i&255)/255),this}setRGB(t,i,r){return this.r=Number(t),this.g=Number(i),this.b=Number(r),this}convertSRGBToLinear(){return this.r=xt(this.r),this.g=xt(this.g),this.b=xt(this.b),this}convertLinearToSRGB(){return this.r=ae(this.r),this.g=ae(this.g),this.b=ae(this.b),this}getHex(){let t=i=>Math.round(ae(Math.max(0,Math.min(1,i)))*255);return t(this.r)<<16|t(this.g)<<8|t(this.b)}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}clone(){return new Ir(this.r,this.g,this.b)}},Mi={degToRad:e=>e*Math.PI/180,radToDeg:e=>e*180/Math.PI,clamp:(e,t,i)=>Math.max(t,Math.min(i,e)),lerp:(e,t,i)=>e+(t-e)*i,generateUUID:()=>Math.random().toString(36).substring(2,15),randFloat:(e,t)=>e+Math.random()*(t-e)},gt=class Fr{constructor(t,i){if(this.needsUpdate=!1,typeof i!="number"||!Number.isInteger(i)||i<1||i>16)throw new Error(`SecurityError: BufferAttribute itemSize must be an integer in [1, 16]. Received: ${String(i)}`);Array.isArray(t)?this.array=new Float32Array(t):this.array=t,this.itemSize=i;let r=this.array?this.array.length:0;if(!Number.isFinite(r)||r<0)throw new Error(`SecurityError: BufferAttribute array has a non-finite length: ${String(r)}`);this.count=Math.floor(r/i)}getX(t){return this.array[t*this.itemSize]}getY(t){return this.array[t*this.itemSize+1]}getZ(t){return this.array[t*this.itemSize+2]}setX(t,i){return this.array[t*this.itemSize]=i,this.needsUpdate=!0,this}setY(t,i){return this.array[t*this.itemSize+1]=i,this.needsUpdate=!0,this}setZ(t,i){return this.array[t*this.itemSize+2]=i,this.needsUpdate=!0,this}setXYZ(t,i,r,s){let n=t*this.itemSize;return this.array[n]=i,this.array[n+1]=r,this.array[n+2]=s,this.needsUpdate=!0,this}setUsage(t){return this}clone(){let t=this.array?.constructor||Float32Array;return new Fr(new t(this.array),this.itemSize)}},wi=class extends gt{constructor(e,t){super(e instanceof Float32Array?e:new Float32Array(e),t)}},Ti=class extends gt{constructor(e,t){super(e instanceof Uint16Array?e:new Uint16Array(e),t)}},Si=class extends gt{constructor(e,t){super(e instanceof Uint32Array?e:new Uint32Array(e),t)}},ft=class kr{constructor(){this.name="",this.attributes={},this.index=null,this.boundingBox=null}setAttribute(t,i){return this.attributes[t]=i,this}getAttribute(t){return this.attributes[t]}setIndex(t){if(t instanceof gt)this.index=t;else if(Array.isArray(t)){let i=0;for(let r of t)r>i&&(i=r);this.index=new gt(new(i>65535?Uint32Array:Uint16Array)(t),1)}else t&&t.buffer&&(this.index=new gt(t,1));return this}computeVertexNormals(){let t=this.attributes.position;if(!t)return this;let i=t.count,r=new Float32Array(i*3),s=new Y,n=new Y,o=new Y,a=new Y,h=new Y,l=this.index?.array,c=l?l.length:i;for(let f=0;f<c;f+=3){let y=l?l[f]:f,g=l?l[f+1]:f+1,u=l?l[f+2]:f+2;s.set(t.getX(y),t.getY(y),t.getZ(y)),n.set(t.getX(g),t.getY(g),t.getZ(g)),o.set(t.getX(u),t.getY(u),t.getZ(u)),a.subVectors(o,n),h.subVectors(s,n),a.cross(h).normalize();for(let b of[y,g,u])r[b*3]+=a.x,r[b*3+1]+=a.y,r[b*3+2]+=a.z}for(let f=0;f<i;f++){let y=r[f*3],g=r[f*3+1],u=r[f*3+2],b=Math.hypot(y,g,u)||1;r[f*3]=y/b,r[f*3+1]=g/b,r[f*3+2]=u/b}return this.setAttribute("normal",new gt(r,3)),this}setFromBuffers(t,i,r,s){this.setAttribute("position",new gt(t,3)),this.setAttribute("normal",new gt(i,3)),this.setAttribute("uv",new gt(r,2)),this.setIndex(s)}setFromPoints(t){let i=[];if(Array.isArray(t))for(let r of t)i.push(Number(r?.x)||0,Number(r?.y)||0,Number(r?.z)||0);return this.setAttribute("position",new gt(i,3))}computeBoundingBox(){let t=this.attributes.position,i=new Y(1/0,1/0,1/0),r=new Y(-1/0,-1/0,-1/0);if(t&&t.count>0)for(let s=0;s<t.count;s++){let n=t.getX(s),o=t.getY(s),a=t.getZ(s);n<i.x&&(i.x=n),o<i.y&&(i.y=o),a<i.z&&(i.z=a),n>r.x&&(r.x=n),o>r.y&&(r.y=o),a>r.z&&(r.z=a)}else i.set(0,0,0),r.set(0,0,0);return this.boundingBox={min:i,max:r},this.boundingBox}center(){let t=this.computeBoundingBox();return this.translate(-(t.min.x+t.max.x)*.5,-(t.min.y+t.max.y)*.5,-(t.min.z+t.max.z)*.5)}_xform(t,i){let r=this.attributes.position;if(r){let s=r.array;for(let n=0;n<s.length;n+=3)t(s,n);r.needsUpdate=!0,i&&this.computeVertexNormals(),this.computeBoundingBox()}return this}translate(t=0,i=0,r=0){return this._xform((s,n)=>{s[n]+=t,s[n+1]+=i,s[n+2]+=r})}scale(t=1,i=1,r=1){return this._xform((s,n)=>{s[n]*=t,s[n+1]*=i,s[n+2]*=r},!0)}_rot(t,i,r){let s=Math.cos(r),n=Math.sin(r);for(let o of[this.attributes.position,this.attributes.normal]){if(!o)continue;let a=o.array;for(let h=0;h<a.length;h+=3){let l=a[h+t],c=a[h+i];a[h+t]=l*s-c*n,a[h+i]=l*n+c*s}o.needsUpdate=!0}return this}rotateX(t){return this._rot(1,2,t)}rotateY(t){return this._rot(2,0,t)}rotateZ(t){return this._rot(0,1,t)}applyMatrix4(t){let i=this.attributes.position;if(i&&t?.elements){let r=new Y;for(let s=0;s<i.count;s++)r.set(i.getX(s),i.getY(s),i.getZ(s)).applyMatrix4(t),i.setXYZ(s,r.x,r.y,r.z);this.computeVertexNormals()}return this}clone(){let t=new kr;t.name=this.name;for(let i of Object.keys(this.attributes))t.attributes[i]=this.attributes[i].clone();return this.index&&(t.index=this.index.clone()),t}dispose(){}},Ne=class extends ft{constructor(e=1,t=1,i=1){super();let r=e/2,s=t/2,n=i/2,o=[-r,-s,n,r,-s,n,r,s,n,-r,s,n,r,-s,-n,-r,-s,-n,-r,s,-n,r,s,-n,-r,s,n,r,s,n,r,s,-n,-r,s,-n,-r,-s,-n,r,-s,-n,r,-s,n,-r,-s,n,r,-s,n,r,-s,-n,r,s,-n,r,s,n,-r,-s,-n,-r,-s,n,-r,s,n,-r,s,-n],a=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0],h=[],l=[];for(let c=0;c<6;c++){let f=c*4;h.push(0,0,1,0,1,1,0,1),l.push(f,f+1,f+2,f,f+2,f+3)}this.setFromBuffers(o,a,h,l)}},Ri=class extends ft{constructor(e=1,t=1,i=1,r=1){super(),i=Math.max(1,Math.floor(i)),r=Math.max(1,Math.floor(r));let s=[],n=[],o=[],a=[];for(let h=0;h<=r;h++){let l=h/r;for(let c=0;c<=i;c++){let f=c/i;if(s.push((f-.5)*e,(.5-l)*t,0),n.push(0,0,1),o.push(f,1-l),h>0&&c>0){let y=(i+1)*h+c-1,g=y-(i+1);a.push(g,y,g+1,y,y+1,g+1)}}}this.setFromBuffers(s,n,o,a)}},Ci=class extends ft{constructor(e=1,t=16,i=12){super(),t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let r=[],s=[],n=[],o=[];for(let a=0;a<=i;a++){let h=a/i;for(let l=0;l<=t;l++){let c=l/t,f=c*Math.PI*2,y=h*Math.PI,g=-Math.cos(f)*Math.sin(y),u=Math.cos(y),b=Math.sin(f)*Math.sin(y);if(r.push(e*g,e*u,e*b),s.push(g,u,b),n.push(c,1-h),a>0&&l>0){let w=(t+1)*a+l,M=w-(t+1),x=M-1,m=w-1;a!==1&&o.push(M,x,w),a!==i&&o.push(x,m,w)}}}this.setFromBuffers(r,s,n,o)}},De=class extends ft{constructor(e=1,t=1,i=1,r=16){super(),r=Math.max(3,Math.floor(r));let s=[],n=[],o=[],a=[],h=i/2;for(let c=0;c<=1;c++){let f=c,y=c===0?e:t,g=c===0?h:-h;for(let u=0;u<=r;u++){let b=u/r,w=b*Math.PI*2,M=Math.sin(w),x=Math.cos(w);s.push(y*M,g,y*x),n.push(M,0,x),o.push(b,1-f)}}for(let c=0;c<r;c++){let f=c,y=c+r+1,g=c+r+2,u=c+1;a.push(f,y,u,y,g,u)}let l=(c,f)=>{if(c<=0)return;let y=f*h,g=s.length/3;s.push(0,y,0),n.push(0,f,0),o.push(.5,.5);let u=s.length/3;for(let b=0;b<=r;b++){let w=b/r*Math.PI*2,M=Math.sin(w),x=Math.cos(w);s.push(c*M,y,c*x),n.push(0,f,0),o.push(x*.5+.5,.5+f*M*.5)}for(let b=0;b<r;b++)a.push(g,u+b+(f>0?0:1),u+b+(f>0?1:0))};l(e,1),l(t,-1),this.setFromBuffers(s,n,o,a)}},Ai=class extends De{constructor(e=1,t=1,i=16){super(0,e,t,i)}},Pi=class extends ft{constructor(e=1,t=.4,i=12,r=48,s=Math.PI*2){super(),i=Math.max(3,Math.floor(i)),r=Math.max(3,Math.floor(r));let n=[],o=[],a=[],h=[];for(let l=0;l<=i;l++){let c=l/i*Math.PI*2,f=Math.cos(c),y=Math.sin(c);for(let g=0;g<=r;g++){let u=g/r*s,b=Math.cos(u),w=Math.sin(u);if(n.push((e+t*f)*b,(e+t*f)*w,t*y),o.push(f*b,f*w,y),a.push(g/r,l/i),l>0&&g>0){let M=(r+1)*l+g-1,x=M-(r+1);h.push(M,x,M+1,x,x+1,M+1)}}}this.setFromBuffers(n,o,a,h)}};function _i(e,t,i,r,s){let n=Math.max(2,Math.min(256,Math.floor(Number(t)||64))),o=Math.max(3,Math.min(64,Math.floor(Number(i)||8))),a=Number(r)||.1,h=[],l=[],c=[],f=[],y=new Y,g=new Y,u=new Y,b=new Y,w=new Y;for(let x=0;x<=n;x++){let m=x/n;s(Math.max(0,m-.001),y),s(Math.min(1,m+.001),g),u.subVectors(g,y).normalize(),x===0&&b.set(Math.abs(u.y)>.9?1:0,Math.abs(u.y)>.9?0:1,0),w.crossVectors(u,b).normalize(),b.crossVectors(w,u).normalize(),s(m,y);for(let p=0;p<=o;p++){let v=p/o*Math.PI*2,R=-a*Math.cos(v),L=a*Math.sin(v),I=R*b.x+L*w.x,N=R*b.y+L*w.y,_=R*b.z+L*w.z;h.push(y.x+I,y.y+N,y.z+_);let A=Math.hypot(I,N,_)||1;l.push(I/A,N/A,_/A),c.push(m,p/o)}}let M=o+1;for(let x=1;x<=n;x++){let m=M*(x-1),p=m+M;for(let v=1;v<=o;v++){let R=m+v-1,L=p+v-1;f.push(R,L,m+v,L,p+v,m+v)}}e.setFromBuffers(h,l,c,f)}var Ei=class extends ft{constructor(e=1,t=.4,i=64,r=8,s=2,n=3){super(),i=Math.floor(i),r=Math.floor(r),_i(this,i,r,t,(o,a)=>{let h=o*s*Math.PI*2,l=n/s*h,c=e*(2+Math.cos(l))*.5;a.set(c*Math.cos(h),c*Math.sin(h),e*Math.sin(l)*.5)})}},Ft=class{getPoint(e,t=new Y){return t}getPointAt(e,t=new Y){return this.getPoint(e,t)}getTangent(e,t=new Y){return t.subVectors(this.getPoint(Math.min(1,e+.001)),this.getPoint(Math.max(0,e-.001))).normalize()}getPoints(e=5){let t=Math.max(1,Math.min(512,Math.floor(Number(e)||5))),i=[];for(let r=0;r<=t;r++)i.push(this.getPoint(r/t));return i}getSpacedPoints(e=5){return this.getPoints(e)}},Ni=class extends Ft{constructor(e=new Y,t=new Y){super(),this.v1=e,this.v2=t}getPoint(e,t=new Y){return t.lerpVectors(this.v1,this.v2,e)}},Di=class extends Ft{constructor(e=new Y,t=new Y,i=new Y){super(),this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Y){return t.lerpVectors(this.v0,this.v1,e).lerp(new Y().lerpVectors(this.v1,this.v2,e),e)}},Li=class extends Ft{constructor(e=new Y,t=new Y,i=new Y,r=new Y){super(),this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Y){let i=new Y().lerpVectors(this.v0,this.v1,e),r=new Y().lerpVectors(this.v1,this.v2,e),s=new Y().lerpVectors(this.v2,this.v3,e);return t.lerpVectors(i.lerp(r,e),r.lerp(s,e),e)}},Ii=class extends Ft{constructor(e=[],t=!1){super(),this.points=Array.isArray(e)?e:[],this.closed=!!t}getPoint(e,t=new Y){let i=this.points,r=i.length;if(!r)return t.set(0,0,0);if(r===1)return t.copy(i[0]);let s=(this.closed?r:r-1)*Math.max(0,Math.min(1,Number(e)||0)),n=Math.floor(s),o=s-n;!this.closed&&n>=r-1&&(n=r-2,o=1);let a=b=>i[this.closed?(b%r+r)%r:Math.max(0,Math.min(r-1,b))],h=a(n-1),l=a(n),c=a(n+1),f=a(n+2),y=o*o,g=y*o,u=(b,w,M,x)=>.5*(2*w+(M-b)*o+(2*b-5*w+4*M-x)*y+(3*w-b-3*M+x)*g);return t.set(u(h.x,l.x,c.x,f.x),u(h.y,l.y,c.y,f.y),u(h.z,l.z,c.z,f.z))}},Le=class extends ft{constructor(e=[new Tt(0,-.5),new Tt(.5,0),new Tt(0,.5)],t=12,i=0,r=Math.PI*2){super();let s=Array.isArray(e)&&e.length>=2?e:[new Tt(.2,0),new Tt(.2,.5)],n=Math.max(3,Math.min(128,Math.floor(Number(t)||12))),o=[],a=[],h=[],l=[],c=s.length;for(let f=0;f<=n;f++){let y=f/n,g=i+y*r,u=Math.sin(g),b=Math.cos(g);for(let w=0;w<c;w++){let M=s[w],x=Number(M?.x)||0,m=Number(M?.y)||0;o.push(x*u,m,x*b);let p=s[Math.max(0,w-1)],v=s[Math.min(c-1,w+1)],R=(Number(v?.x)||0)-(Number(p?.x)||0),L=(Number(v?.y)||0)-(Number(p?.y)||0),I=Math.hypot(L,R)||1;a.push(L/I*u,-R/I,L/I*b),h.push(y,w/(c-1))}}for(let f=0;f<n;f++){let y=f*c;for(let g=0;g<c-1;g++){let u=y+g,b=y+c+g;l.push(u,b,u+1,b,b+1,u+1)}}this.setFromBuffers(o,a,h,l)}},Fi=class extends ft{constructor(e,t=64,i=1,r=8,s=!1){super(),_i(this,t,r,i,(n,o)=>{let a=e?.getPointAt??e?.getPoint;if(typeof a=="function"){let h=a.call(e,n,o);h&&h!==o&&o.copy(h)}else o.set(0,n,0)})}},oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",le=class{constructor(e=""){this.isTexture=!0,this.wrapS=10497,this.wrapT=10497,this.repeat=new Tt(1,1),this.offset=new Tt(0,0),this.image=null,this.width=0,this.height=0,this.source=e,e&&typeof e=="object"&&(this.image=e)}dispose(){}},ki=class extends le{constructor(e=null,t=1,i=1,r=1023,s=1009,n,o=1001,a=1001,h=1003,l=1003,c=1,f=""){super(""),this.isDataTexture=!0,this.avgColor=[1,1,1,1],this.flipY=!1,this.generateMipmaps=!1,this.unpackAlignment=1;let y=Number(t),g=Number(i),u=e&&typeof e.length=="number"?e:null;this.width=y,this.height=g,this.image={data:u,width:y,height:g},this.format=Number(r)||1023,this.type=Number(s)||1009,this.wrapS=Number(o)||1001,this.wrapT=Number(a)||1001,this.magFilter=Number(h)||1003,this.minFilter=Number(l)||1003,this.colorSpace=f||"",this._bake()}get needsUpdate(){return!1}set needsUpdate(e){e&&this._bake()}_bake(){let e=this.image,t=e?.data,i=Number(e?.width??this.width),r=Number(e?.height??this.height);if(!t||!t.length||!(i>0&&r>0)||i>2048||r>2048){this.source="";return}let s=Math.max(1,i|0),n=Math.max(1,r|0),o=s*n,a=this.format,h=a===1021||a===1024||a===1028||t.length===o?1:a===1025||a===1030||t.length===o*2?2:a===1022||t.length===o*3?3:4,l=this.type===1015||this.type===1016||t instanceof Float32Array||t instanceof Float64Array,c=Math.min(s,96),f=Math.min(n,96),y=f*(1+c*4),g=new Uint8Array(68+y),u=new DataView(g.buffer);u.setUint32(0,2303741511),u.setUint32(4,218765834),u.setUint32(8,13),u.setUint32(12,1229472850),u.setUint32(16,c),u.setUint32(20,f),g[24]=8,g[25]=6,u.setUint32(29,Ae(g.subarray(12,29))),u.setUint32(33,y+11),u.setUint32(37,1229209940),g[41]=120,g[42]=1,g[43]=1,u.setUint16(44,y,!0),u.setUint16(46,~y&65535,!0);let b=48,w=1,M=0,x=0,m=0,p=0,v=0,R=_=>{if(!Number.isFinite(_))return 0;let A=l&&_<=1?_*255:_;return A>0?A<255?A+.5|0:255:0};for(let _=0;_<f;_++){let A=_*n/f|0,E=this.flipY?n-1-A:A;g[b++]=0,M+=w;for(let C=0;C<c;C++){let d=(E*s+(C*s/c|0))*h,k=a===1021?255:R(t[d]??0),$=h>=3||a===1030?R(t[d+1]??0):k,S=h>=3?R(t[d+2]??0):a===1030?0:k,D=h===4?R(t[d+3]??255):a===1021?R(t[d]??255):a===1025?R(t[d+1]??255):255;g[b++]=k,w+=k,M+=w,g[b++]=$,w+=$,M+=w,g[b++]=S,w+=S,M+=w,g[b++]=D,w+=D,M+=w,x+=k,m+=$,p+=S,v+=D}w%=65521,M%=65521}u.setUint32(b,(M<<16|w)>>>0),u.setUint32(b+4,Ae(g.subarray(37,b+4))),u.setUint32(b+12,1229278788),u.setUint32(b+16,2923585666);let L=c*f*255,I=this.colorSpace==="srgb-linear";this.avgColor=[I?x/L:xt(x/L),I?m/L:xt(m/L),I?p/L:xt(p/L),v/L];let N=["data:image/png;base64,"];for(let _=0;_<g.length;_+=3){let A=g[_]<<16|(g[_+1]??0)<<8|(g[_+2]??0);N.push(oe[A>>18&63]+oe[A>>12&63]+(_+1<g.length?oe[A>>6&63]:"=")+(_+2<g.length?oe[A&63]:"="))}this.source=N.join("")}},Ui=class{load(e,t){let i=new le(e);return t?.(i),i}};function yt(e,t){return e!==void 0?Number(e):t}function Ie(e,t){return e!==void 0?!!e:t}var Mt=class{constructor(e={}){this.name=e.name||"",this.color=new Rt(e.color!==void 0?e.color:16777215),this.emissive=new Rt(e.emissive!==void 0?e.emissive:0),this.emissiveIntensity=yt(e.emissiveIntensity,1),this.roughness=yt(e.roughness,.5),this.metalness=yt(e.metalness,0),this.opacity=yt(e.opacity,1),this.transparent=Ie(e.transparent,!1),this.wireframe=Ie(e.wireframe,!1),this.side=yt(e.side,2),this.doubleSided=Ie(e.doubleSided,!0),this.map=e.map||null,this.clearcoat=yt(e.clearcoat,0),this.clearcoatRoughness=yt(e.clearcoatRoughness,0),this.sheen=yt(e.sheen,0),this.sheenColor=new Rt(e.sheenColor!==void 0?e.sheenColor:0),this.sheenRoughness=yt(e.sheenRoughness,0),this.transmission=yt(e.transmission,0),this.thickness=yt(e.thickness,0),this.attenuationColor=new Rt(e.attenuationColor!==void 0?e.attenuationColor:16777215),this.attenuationDistance=yt(e.attenuationDistance,1/0),this.ior=yt(e.ior,1.5),this.dispersion=yt(e.dispersion,0),this.iridescence=yt(e.iridescence,0),this.iridescenceIOR=yt(e.iridescenceIOR,1.3)}dispose(){}},jt=class extends Mt{},zi=class extends Mt{},Vi=class extends Mt{},Oi=class extends Mt{},Bi=class extends Mt{},Ct=class Ur{constructor(){this.name="",this.matrixAutoUpdate=!0,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.parent=null,this.children=[],this.userData={},this.position=new Y,this.rotation=new _e,this.quaternion=new Ee,this.scale=new Y(1,1,1),this.matrix=new Ot,this.matrixWorld=new Ot,this.rotation._onChange(()=>{this.quaternion.setFromEuler(this.rotation,!1)}),this.quaternion._onChange(()=>{let t=this.quaternion,i=Math.atan2(2*(t.w*t.x+t.y*t.z),1-2*(t.x*t.x+t.y*t.y)),r=Math.asin(Math.max(-1,Math.min(1,2*(t.w*t.y-t.z*t.x)))),s=Math.atan2(2*(t.w*t.z+t.x*t.y),1-2*(t.y*t.y+t.z*t.z));this.rotation.set(i,r,s)})}add(...t){for(let i of t)i&&i instanceof Ur&&(i.parent&&i.parent.remove(i),i.parent=this,this.children.push(i));return this}remove(...t){for(let i of t){let r=this.children.indexOf(i);r!==-1&&(i.parent=null,this.children.splice(r,1))}return this}traverse(t){let i=new Set,r=[this];for(;r.length>0;){let s=r.pop();if(!s||typeof s!="object"||i.has(s))continue;i.add(s),t(s);let n=s.children;if(Array.isArray(n))for(let o=n.length-1;o>=0;o--)r.push(n[o])}}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale)}updateMatrixWorld(t=!1){this.traverse(i=>{Gi(i),(i.matrixAutoUpdate||t)&&i.updateMatrix?.(),i.parent&&i.parent.matrixWorld?i.matrixWorld?.multiplyMatrices(i.parent.matrixWorld,i.matrix):i.matrix&&i.matrixWorld?.copy(i.matrix)})}lookAt(t,i,r){let s=typeof t=="object"?t:new Y(t,i,r);this.target instanceof Y?this.target.copy(s):this.target?.position instanceof Y&&this.target.position.copy(s),this.updateMatrixWorld(!0);let n=new Ot;n.lookAt(this.position,s,new Y(0,1,0));let o=n.elements,a=o[0],h=o[4],l=o[8],c=o[1],f=o[5],y=o[9],g=o[2],u=o[6],b=o[10],w=a+f+b;if(w>0){let M=.5/Math.sqrt(w+1);this.quaternion.set((u-y)*M,(l-g)*M,(c-h)*M,.25/M)}}translateOnAxis(t,i){let r=t.clone().applyMatrix4(new Ot().makeRotationFromQuaternion(this.quaternion)).multiplyScalar(i);return this.position.add(r),this}translateX(t){return this.translateOnAxis(new Y(1,0,0),t)}translateY(t){return this.translateOnAxis(new Y(0,1,0),t)}translateZ(t){return this.translateOnAxis(new Y(0,0,1),t)}rotateX(t){return this.rotation.x+=t,this}rotateY(t){return this.rotation.y+=t,this}rotateZ(t){return this.rotation.z+=t,this}clone(t=!0){let i=this instanceof $t?new this.constructor(this._sourceGeo||this.geometry,this.material):this instanceof Et?new Et(this.geometry,this.material):new this.constructor;i.name=this.name,i.position.copy(this.position),i.quaternion.copy(this.quaternion),i.scale.copy(this.scale),i.visible=this.visible,i.castShadow=this.castShadow,i.receiveShadow=this.receiveShadow;try{i.userData=JSON.parse(JSON.stringify(this.userData||{}))}catch{i.userData={...this.userData||{}}}if(t)for(let r of this.children)i.add(r.clone(!0));return i}},$i=class extends Ct{},Et=class extends Ct{constructor(e,t){super(),this.isMesh=!0;let i=Array.isArray(t)?t[0]:t;this.geometry=e instanceof ft?e:e?(kt("unsupported geometry","BoxGeometry"),new Ne(.5,.5,.5)):new ft,this.material=i instanceof Mt?i:i?(kt("unsupported material","MeshStandardMaterial"),new jt({color:13421772})):new jt}};function Gi(e){typeof e?._bakeAuthorGeometry=="function"&&e._bakeAuthorGeometry();let t=ut().materializeDeclarativeGeometry;typeof t=="function"&&t(e)}var Wt=1e4,Fe=class extends Et{constructor(e,t,i=1){super(e,t),this.instanceColor=null,this.isInstancedMesh=!0;let r=Number(i);if(!Number.isFinite(r)||r<0||r>Wt)throw new RangeError(`SecurityError: InstancedMesh count (${String(i)}) exceeds MAX_INSTANCES_PER_MESH (${Wt})`);this.count=Math.floor(r);let s=new Float32Array(this.count*16);for(let n=0;n<this.count;n++){let o=n*16;s[o]=1,s[o+5]=1,s[o+10]=1,s[o+15]=1}this.instanceMatrix=new gt(s,16)}setMatrixAt(e,t){let i=Math.floor(Number(e));if(!Number.isFinite(i)||i<0||i>=this.count||!t||!t.elements)return;let r=this.instanceMatrix.array,s=i*16;if(!(s+16>r.length))for(let n=0;n<16;n++){let o=Number(t.elements[n]);r[s+n]=Number.isFinite(o)?o:n%5===0?1:0}}getMatrixAt(e,t){let i=Math.floor(Number(e));if(!Number.isFinite(i)||i<0||i>=this.count||!t||!t.elements)return;let r=this.instanceMatrix.array,s=i*16;if(!(s+16>r.length))for(let n=0;n<16;n++)t.elements[n]=r[s+n]}setColorAt(e,t){let i=Math.floor(Number(e));if(!Number.isFinite(i)||i<0||i>=this.count||!t)return;if(!this.instanceColor||this.instanceColor.array.length<this.count*3){let n=new Float32Array(this.count*3);n.fill(1),this.instanceColor=new gt(n,3)}let r=this.instanceColor.array,s=i*3;r[s]=Number.isFinite(t.r)?t.r:1,r[s+1]=Number.isFinite(t.g)?t.g:1,r[s+2]=Number.isFinite(t.b)?t.b:1}getColorAt(e,t){let i=Math.floor(Number(e));if(!Number.isFinite(i)||i<0||i>=this.count||!t)return;if(!this.instanceColor||this.instanceColor.array.length<(i+1)*3){t.setRGB(1,1,1);return}let r=this.instanceColor.array,s=i*3;t.setRGB(r[s],r[s+1],r[s+2])}dispose(){}},Xt=class extends Ct{constructor(e=16777215,t=1){super(),this.color=new Rt(e),this.intensity=Number(t),this.type="directional"}},ke=class extends Xt{constructor(e,t){super(e,t),this.type="ambient"}},Hi=class extends Xt{constructor(e,t){super(e,t),this.target=new Ct,this.type="directional"}},Ue=class extends Xt{constructor(e,t,i=0,r=2){super(e,t),this.type="point",this.distance=i,this.decay=r}},ze=class extends Ct{},ji=class extends ze{constructor(e=45,t=1,i=.1,r=1e3){super(),this.target=new Y(0,0,0),this.fov=Number(e),this.aspect=Number(t),this.near=Number(i),this.far=Number(r)}},Ve=class extends Ct{constructor(){super(...arguments),this.background=null,this.environmentIntensity=1}toCanvas3D(){return Nt.validate(this),Ht(this)}toGLB(){return Nt.validate(this),ie(this)}toUSDZ(){return Nt.validate(this),ne(this)}getMeshTransforms(){this.updateMatrixWorld(!0);let e=new Map,t=0;return this.traverse(i=>{if(i instanceof Et){let r=new Float32Array(i.matrixWorld.elements);e.set(t,r),i.name&&e.set(i.name,r),t++}}),e}},Oe=Ht,Be=ie,Wi=ne,Nt=class{static validate(e){let t=0,i=0,r=0,s=new Set,n=(a,h,l)=>{throw new Error(`SecurityError: Scene exceeds SECURITY_3D_MAX_${a} (${h}). Found: ${l}`)},o=(a,h)=>{if(!Number.isFinite(h))throw new Error(`SecurityError: Scene reports a non-finite ${a} count (${String(h)}), which cannot be bounds-checked.`);return h};e.traverse(a=>{if(Gi(a),a instanceof Et||a.geometry?.attributes?.position?.count){if(r++,r>1e3&&n("MESHES",1e3,r),a instanceof Fe){let l=o("instance",a.count);(l<0||l>Wt)&&n("INSTANCES",Wt,l)}let h=a.geometry;if(h){let l=0;if(h.attributes.position&&(l=o("vertex",h.attributes.position.count),t+=l,t>1e5&&n("VERTICES",1e5,t)),h.index){let c=o("index",h.index.count);i+=c,i>3e5&&n("INDICES",3e5,i);let f=h.index.array;if(f&&l>0){let y=Math.min(c,f.length);for(let g=0;g<y;g++){let u=f[g];if(!Number.isFinite(u)||u<0||u>=l)throw new Error(`SecurityError: Index buffer value (${String(u)}) out of vertex bounds [0, ${l}).`)}}}}if(a.material){let l=a.material;l.map&&s.add(l.map),l.normalMap&&s.add(l.normalMap),l.roughnessMap&&s.add(l.roughnessMap)}}}),s.size>16&&n("TEXTURES",16,s.size);for(let a of s){let h=a,l=h.image,c=Number(l?.width??h.width??0)||0,f=Number(l?.height??h.height??0)||0;(!Number.isFinite(c)||!Number.isFinite(f)||c>2048||f>2048)&&n("TEXTURE_DIMENSION",2048,Math.max(c,f))}}},Xi=class{constructor(e={}){this.shadowMap={enabled:!1,type:0},this.capabilities={isWebGL2:!0,maxTextures:16},this.boundViewer=null,this.hasInitialModelRendered=!1,this.domElement=e.canvas||(typeof document<"u"?document.createElement("canvas"):{}),e.viewer&&(this.boundViewer=e.viewer),e.container?.threeLiveViewer&&(this.boundViewer=e.container.threeLiveViewer),e.canvas?.parentElement?.threeLiveViewer&&(this.boundViewer=e.canvas.parentElement.threeLiveViewer);let t=typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope;this.isSandboxed=e.isSandboxed||t,this.containerId=e.containerId||""}setSize(e,t){return this}setPixelRatio(e){return this}setClearColor(e,t=1){let i=new Rt(e);return this.boundViewer&&typeof this.boundViewer.setClearColor=="function"&&this.boundViewer.setClearColor(i.r,i.g,i.b,t),this}clear(){return this}dispose(){}render(e,t){if(this.isSandboxed){Nt.validate(e);let r=(s,n)=>{typeof self<"u"&&typeof self.postMessage=="function"&&(n&&n.length?self.postMessage(s,n):self.postMessage(s))};if(this.hasInitialModelRendered){let s=e.getMeshTransforms(),n={};for(let[o,a]of s.entries())n[o]=Array.from(a);r({type:"3D_UPDATE_TRANSFORMS",containerId:this.containerId,transforms:n})}else{this.hasInitialModelRendered=!0;let s=Oe(e),n=Be(e),o=(s.lights||[]).map(a=>({type:a.type,color:a.color,intensity:a.intensity,position:a.position}));r({type:"3D_MODEL_READY",containerId:this.containerId,glbBuffer:n.buffer,dynamicLights:o,camera:t?{fov:t.fov||60,position:[t.position.x,t.position.y,t.position.z]}:void 0},[n.buffer])}return}let i=this.boundViewer;!i&&this.domElement?.parentElement&&this.domElement.parentElement.threeLiveViewer&&(i=this.domElement.parentElement.threeLiveViewer,this.boundViewer=i),!i&&typeof window<"u"&&(i=window.__three_live_active_viewer__,this.boundViewer=i),i&&typeof i.loadModel=="function"&&(i._hasThreeLiveModelLoaded?typeof i.updateMeshTransforms=="function"&&i.updateMeshTransforms(e.getMeshTransforms()):(i.loadModel(e.toCanvas3D()),i._hasThreeLiveModelLoaded=!0))}};function qi(){return typeof globalThis<"u"&&typeof globalThis.__three_live_sim_time_ms__=="number"?globalThis.__three_live_sim_time_ms__:typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Ki=class{constructor(e=!0){this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1,this.autoStart=e,e&&this.start()}start(){this.startTime=qi(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running&&this.start(),this.running){let t=qi();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function ms(){}var qt=new Proxy(ms,{get:(e,t)=>{if(t==="isProxy")return!0;if(!(t==="constructor"||t==="__proto__"||t==="prototype"))return t==="domElement"?typeof document<"u"?document.createElement("canvas"):{}:t==="shadowMap"?{enabled:!1,type:0}:t==="capabilities"?{isWebGL2:!0,maxTextures:16}:t===Symbol.toPrimitive?()=>0:qt},getPrototypeOf:()=>null,setPrototypeOf:()=>!1,apply:()=>qt,construct:()=>qt}),Yi=(()=>{try{if(typeof document>"u")return null;let e=document.currentScript;return e?.src?e.src:e?.textContent&&typeof Blob<"u"&&typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(new Blob([e.textContent],{type:"text/javascript"})):null}catch{return null}})();function he(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"&&location.href?location.href:"https://localhost/"}function Bt(e,t){if(!e||typeof e!="string")return!1;let i=e.trim();if(!i)return!1;try{let r=new URL(i,he());return!(r.protocol!=="https:"&&r.protocol!=="http:"&&r.protocol!=="blob:"||t?.requireSameOrigin&&r.protocol!=="blob:"&&typeof location<"u"&&location.origin&&location.origin!=="null"&&r.origin!==location.origin)}catch{return!1}}var Zi,Kt;function Ji(e){if(!Bt(e))throw new Error(`SecurityError: Refusing to create TrustedScriptURL for disallowed URL "${e}".`);let t=globalThis.trustedTypes;if(!t||typeof t.createPolicy!="function")return e;if(Kt===void 0||Zi!==t){Zi=t;try{Kt=t.createPolicy("three-live#worker",{createScriptURL:i=>{if(!Bt(i))throw new TypeError(`SecurityError: Disallowed Three-Live worker script URL "${i}".`);return i}})}catch{Kt=null}}return Kt?Kt.createScriptURL(e):e}function fs(e){ut().sandboxEngineSrc=e}function $e(){let e=ut().sandboxEngineSrc;if(e)return e;if(Yi)return Yi;try{if(typeof document>"u")return null;let t=he(),i=Array.from(document.querySelectorAll("script[src]"));for(let r of i){let s=r.src;if(!s)continue;let n=new URL(s,t).pathname;if(/(?:^|\/)(?:three|xr)-live[^/]*\.js$/.test(n)&&Bt(s,{requireSameOrigin:!0}))return s}}catch{}return null}function Ge(e,t){if(!Bt(e))throw new Error(`SecurityError: Refusing to load ${t} from disallowed URL "${e}". Only http:, https:, and blob: URLs are permitted.`);return new URL(e,he()).href}function ps(){let e=$e();if(!e)throw new Error("Three-Live could not locate its own bundle URL, which the worker sandbox needs in order to load the THREE runtime. Set it explicitly, e.g. ThreeLiveElement.sandboxEngineSrc = new URL('three-live.min.js', import.meta.url).href. Refusing to execute the script, because unsandboxed host-realm execution is prohibited.");return Ge(e,"sandbox engine")}function ds(e){ut().sandboxIframeSrc=e}function Qi(){let e=ut().sandboxIframeSrc;if(e)return e;let t=$e();if(!t||!Bt(t))return null;let i=new URL(t,he());return i.protocol==="blob:"?null:new URL("three-live-sandbox.html",i).href}function gs(){let e=Qi();if(!e)throw new Error("Three-Live could not locate three-live-sandbox.html for iframe sandbox execution. Set ThreeLiveElement.sandboxIframeSrc (or ThreeLiveElement.sandboxEngineSrc) explicitly.");return Ge(e,"sandbox iframe")}function ys(e){ut().allowClientScripts=e}function tr(){return!!ut().allowClientScripts}function bs(e){return Ge(e,"procedural scene script")}var xs=["fetch","XMLHttpRequest","WebSocket","WebSocketStream","WebTransport","EventSource","importScripts","Request","Response","Headers","navigator","WorkerNavigator","WorkerLocation","RTCPeerConnection","RTCDataChannel","FontFace","FontFaceSet","fonts","PerformanceObserver","ReportingObserver","indexedDB","IDBFactory","caches","CacheStorage","Cache","cookieStore","StorageManager","FileSystemHandle","Worker","SharedWorker","ServiceWorker","ServiceWorkerContainer","ServiceWorkerRegistration","registration","clients","BroadcastChannel","MessageChannel","MessagePort","createImageBitmap","OffscreenCanvas","WebAssembly","WorkerGlobalScope","DedicatedWorkerGlobalScope","trustedTypes","TrustedTypePolicyFactory","SharedArrayBuffer","Atomics"];function vs(e,t){let i=self,r=e.nonce,s=e.engineSrc,n=e.allowedScriptUrl,o=e.allowClientScripts,a=e.revoked,h=i.postMessage.bind(i);function l(m){h({type:"ERROR",nonce:r,message:String(m)})}let c=typeof i.importScripts=="function"?i.importScripts.bind(i):null,f=n,y=null;try{let m=s;if(typeof i.trustedTypes<"u"&&i.trustedTypes&&typeof i.trustedTypes.createPolicy=="function")try{let p={createScriptURL:function(R){if(R!==s&&(!n||R!==n))throw new TypeError("Disallowed worker importScripts URL");return R}};o&&(p.createScript=function(R){return String(R)});let v=i.trustedTypes.createPolicy("three-live#worker-boot",p);m=v.createScriptURL(s),n&&(f=v.createScriptURL(n)),o&&typeof v.createScript=="function"&&(y=v.createScript.bind(v))}catch{}c(m)}catch(m){l('Sandbox failed to load the Three-Live engine from "'+s+'". It must be a same-origin (or CORS-enabled) IIFE bundle such as three-live.min.js. Underlying error: '+(m&&m.message||m));return}let g=i.THREE;if(!g||typeof g.Scene!="function"){l('Sandbox loaded "'+s+'" but it did not install a THREE namespace. Point sandboxEngineSrc at an IIFE build (three-live.min.js), not an ES module build.');return}if(Array.isArray(t)){let m=i.__THREE_LIVE_REGISTRY__;for(let p=0;p<t.length;p++)if(typeof t[p]=="function")try{t[p](g,m)}catch{}}function u(m,p,v){let R=i;for(;R&&R!==Object.prototype;){if(!v&&R!==i)try{delete R[m]}catch{}if(!v||R===i||Object.prototype.hasOwnProperty.call(R,m))try{Object.defineProperty(R,m,v?{value:p,writable:!1,configurable:!1}:{value:p,writable:!1,configurable:!1,enumerable:!1})}catch{}try{R=Object.getPrototypeOf(R)}catch{break}}}for(let m=0;m<a.length;m++)u(a[m],void 0);u("performance",Object.freeze({now:function(){return Date.now()}}));let b=["3D_MODEL_READY","3D_UPDATE_TRANSFORMS"],w=!1;function M(m,p){if(m.type==="3D_MODEL_READY"){if(w)return;w=!0}m.nonce=r,p&&p.length?h(m,p):h(m)}u("postMessage",function(m,p){if(!m||b.indexOf(m.type)===-1)throw new Error("Sandboxed scripts may only post Three-Live scene messages ("+b.join(", ")+").");M(m,p)},!0);let x=!1;i.onmessage=function(m){let p=m&&m.data;if(!(!p||p.nonce!==r)&&!(p.type!=="EXECUTE"&&p.type!=="EXECUTE_URL")&&!x){x=!0;try{let v=new g.Scene,R=new g.PerspectiveCamera(60,1,.1,1e3),L=new g.WebGLRenderer({isSandboxed:!0});if(p.type==="EXECUTE_URL"){if(!n||p.scriptUrl!==n||typeof c!="function"){l("SecurityError: Refusing to execute unapproved script URL inside sandbox worker.");return}let I=f||n,N=c;if(c=null,f=null,i.THREE=g,i.scene=v,i.camera=R,i.renderer=L,N(I),typeof i.__THREE_LIVE_SCENE__=="function"){let _=i.__THREE_LIVE_SCENE__(g,v,R,L);_&&typeof _.toGLB=="function"&&(v=_)}else i.scene&&typeof i.scene.toGLB=="function"&&(v=i.scene)}else{if(!o){l("SecurityError: Client-modified script compilation (Use Case 1) is disabled in this sandbox worker.");return}let I=y?(0,eval)(y(`(function (THREE, scene, camera, renderer) {
|
|
322
342
|
return (function () {
|
|
323
|
-
`+
|
|
343
|
+
`+p.script+`
|
|
344
|
+
;
|
|
345
|
+
return typeof scene === "object" && scene ? scene : undefined;
|
|
324
346
|
})();
|
|
325
347
|
})`)):new Function("THREE","scene","camera","renderer",`return (function () {
|
|
326
|
-
`+
|
|
327
|
-
})();`);m=null;let y=p(b,v,M,I);y&&typeof y.toGLB=="function"&&(v=y)}if(!C){b.SceneQuotaValidator&&b.SceneQuotaValidator.validate(v);let p=v.toGLB(),y=p instanceof ArrayBuffer?p:p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength);N({type:"3D_MODEL_READY",glbBuffer:y},[y])}a({type:"DONE",nonce:r})}catch(v){u(v&&v.message||v)}}},a({type:"READY",nonce:r})}function Ln(n,e,t){let r=t?.allowedScriptUrl??null,i=t?.allowClientScripts??r===null,s={nonce:e,engineSrc:n,allowedScriptUrl:r,allowClientScripts:i,revoked:fr},o=(Q().workerExtensionInstallers??[]).map(l=>`(${l.toString()})`).join(",");return`'use strict';(${dr.toString()})(${JSON.stringify(s)},[${o}]);`}function Nn(n){n.onError?.(new Error("SecurityError: Sandboxed script exceeded SECURITY_3D_SANDBOX_TIMEOUT_MS (3000 ms) and was terminated.")),n.onToast?.("Security Error: script timed out and was stopped.")}var ve=0;function Pn(){try{let n=new Uint32Array(4);return globalThis.crypto?.getRandomValues(n),Array.from(n,t=>t.toString(16).padStart(8,"0")).join("")}catch{return`${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}}function pr(n){try{return new TextEncoder().encode(n).length}catch{return n.length}}var br=1024,yr=256;function Rn(n){if(!Array.isArray(n)&&!(n instanceof Float32Array)||n.length!==16)return!1;for(let e=0;e<16;e++){let t=n[e];if(typeof t!="number"||!Number.isFinite(t))return!1}return!0}function Fn(n,e){if(!n||typeof n!="object")return null;let t=n;if(t.nonce!==e)return null;switch(t.type){case"READY":return{type:"READY"};case"DONE":return{type:"DONE"};case"ERROR":return{type:"ERROR",message:(typeof t.message=="string"?t.message:String(t.message??"Unknown worker error")).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,"").slice(0,br)};case"3D_UPDATE_TRANSFORMS":{let i=t.transforms;if(Array.isArray(i)){if(i.length>1e3)return null;for(let s of i)if(!Rn(s))return null;return{type:"3D_UPDATE_TRANSFORMS",transforms:i}}if(i&&typeof i=="object"){let s=Object.keys(i);if(s.length>1e3)return null;let o=Object.create(null),l=i;for(let a of s){if(a.length>yr||a==="__proto__"||a==="constructor"||a==="prototype")return null;let u=l[a];if(!Rn(u))return null;o[a]=u}return{type:"3D_UPDATE_TRANSFORMS",transforms:o}}return null}case"3D_MODEL_READY":{let i=t.glbBuffer;return!(i instanceof ArrayBuffer)||i.byteLength>16777216?null:{type:"3D_MODEL_READY",payload:i}}default:return null}}function gr(n){let e=pr(n);if(e>1048576)throw new Error(`SecurityError: Script length (${e} bytes) exceeds SECURITY_3D_MAX_SCRIPT_BYTES (1048576).`)}function kn(n,e,t,r){switch(n.type){case"READY":return;case"3D_UPDATE_TRANSFORMS":e.onUpdateTransforms?.(n.transforms);return;case"3D_MODEL_READY":if(r.modelDispatched)return;r.modelDispatched=!0,e.onModelReady(n.payload);return;case"DONE":t();return;case"ERROR":t(),e.onError?.(new Error(`Worker script error: ${n.message}`));return;default:return n}}function xr(n,e,t,r){let i=Pn(),s=Ln(e,i,n.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:n.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),o=document.createElement("iframe");o.setAttribute("sandbox","allow-scripts"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.style.display="none",o.src=t,ve++;let l=!1,a=!1,u={modelDispatched:!1},c,h=()=>{if(l||a)return;let d=o.contentWindow;!d||typeof d.postMessage!="function"||(a=!0,d.postMessage(n.kind==="url"?{type:"SANDBOX_RUN",nonce:i,workerSource:s,scriptUrl:n.scriptUrl}:{type:"SANDBOX_RUN",nonce:i,workerSource:s,script:n.script},"*"))},m=()=>{},b=d=>{if(l||!o.contentWindow||d.source!==o.contentWindow)return;let w=d.data;if(w&&typeof w=="object"&&w.type==="IFRAME_READY"){h();return}let C=Fn(w,i);C&&kn(C,r,m,u)};m=()=>{l||(l=!0,c!==void 0&&clearTimeout(c),ve=Math.max(0,ve-1),typeof globalThis.removeEventListener=="function"&&globalThis.removeEventListener("message",b),typeof o.remove=="function"?o.remove():o.parentNode&&o.parentNode.removeChild(o))},c=setTimeout(()=>{l||(m(),Nn(r))},3e3),typeof globalThis.addEventListener=="function"&&globalThis.addEventListener("message",b),o.onload=()=>{h()},o.onerror=()=>{m(),r.onError?.(new Error(`Sandbox iframe failed to load "${t}". Verify that three-live-sandbox.html is served at that URL.`))};let g=document.body||document.documentElement;if(!g||typeof g.appendChild!="function"){m();let d=new Error("SecurityError: Cannot mount sandbox iframe because document.body is unavailable.");throw r.onError?.(d),d}return g.appendChild(o),{terminate:m}}function _n(n,e,t,r){if(e==="worker"&&typeof Worker>"u")return r("Sandboxed procedural execution requires Web Workers, but Workers are unavailable in this environment. For host security, Three-Live prohibits unsandboxed in-process evaluation.","Security Error: Web Workers unavailable. Script execution aborted.");if(e==="iframe"&&(typeof document>"u"||typeof document.createElement!="function"))return r("Sandboxed iframe execution requires a DOM environment with document.createElement. Refusing to evaluate in the host realm.","Security Error: DOM unavailable for iframe sandbox.");if(ve>=32)return r(`SecurityError: ${ve} sandbox workers are already running, which meets SECURITY_3D_MAX_CONCURRENT_TASKS (32). Refusing to start another.`,"Security Error: too many concurrent sandboxed scripts.");let i;try{i=cr()}catch(m){let b=m instanceof Error?m.message:String(m);return r(b,"Security Error: sandbox engine URL is not configured.")}if(e==="iframe"){let m;try{m=lr()}catch(b){let g=b instanceof Error?b.message:String(b);return r(g,"Security Error: sandbox iframe URL is not configured.")}try{return Promise.resolve(xr(n,i,m,t))}catch(b){return Promise.reject(b)}}let s=Pn(),o=Ln(i,s,n.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:n.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),l;try{let m=new Blob([o],{type:"application/javascript"}),b=URL.createObjectURL(m);try{let g=ar(b);l=new Worker(g)}finally{URL.revokeObjectURL(b)}}catch(m){let b=m instanceof Error?m.message:String(m);return r(`Failed to initialize Web Worker for sandboxed execution (CSP may block blob workers): ${b}`,"Security Error: Failed to start Worker sandbox.")}ve++;let a=!1,u={modelDispatched:!1},c,h=()=>{a||(a=!0,c!==void 0&&clearTimeout(c),ve=Math.max(0,ve-1),l.terminate())};return c=setTimeout(()=>{a||(h(),Nn(t))},3e3),l.onmessage=m=>{let b=Fn(m.data,s);b&&kn(b,t,h,u)},l.onerror=m=>{h(),t.onError?.(new Error(`Worker execution error: ${m.message}`))},n.kind==="url"?l.postMessage({type:"EXECUTE_URL",scriptUrl:n.scriptUrl,nonce:s}):l.postMessage({type:"EXECUTE",script:n.script,nonce:s}),Promise.resolve({terminate:h})}function Sn(n,e){return n==="none"||n==="unsafe-host-realm"?e(`SecurityError: sandbox="${n}" is prohibited. Sandboxing is mandatory for live compilation and cannot be bypassed. Use sandbox="worker" (default) or sandbox="iframe".`,`Security Error: sandbox="${n}" is not permitted.`):n!=="worker"&&n!=="iframe"?e(`SecurityError: Unsupported sandbox mode "${n}". Live compilation requires sandbox="worker" or sandbox="iframe".`,"Security Error: unsupported sandbox mode."):null}var vr={execute(n,e,t,r){let i=(l,a)=>{let u=new Error(l);return t.onError?.(u),a&&t.onToast?.(a),Promise.reject(u)},s=Sn(e,i);if(s)return s;try{gr(n)}catch(l){let a=l instanceof Error?l.message:String(l);return i(a,"Security Error: script exceeds the size limit.")}return r?.allowClientScripts??mr()?_n({kind:"script",script:n},e,t,i):i(Jt,Qt)},executeUrl(n,e,t){let r=(o,l)=>{let a=new Error(o);return t.onError?.(a),l&&t.onToast?.(l),Promise.reject(a)},i=Sn(e,r);if(i)return i;let s;try{s=hr(n)}catch(o){let l=o instanceof Error?o.message:String(o);return r(l,"Security Error: disallowed scene script URL.")}return _n({kind:"url",scriptUrl:s},e,t,r)}},lt=new Set;function fe(n,e){let t=`[three-live] ${n} is unsupported; degraded to ${e}.`;lt.has(t)||(lt.add(t),typeof console<"u"&&typeof console.warn=="function"&&console.warn(t))}function Mr(){return Array.from(lt)}function Tr(){lt.clear()}var mt=class extends Ae{constructor(e={}){fe("ShaderMaterial","MeshStandardMaterial");let t=e.uniforms||{},r=t.color?.value??t.uColor?.value??t.diffuse?.value??e.color;super({color:r!==void 0?r:8421504,opacity:t.opacity?.value??e.opacity??1,transparent:!!e.transparent,wireframe:!!e.wireframe,side:e.side}),this.uniforms=t}},wr=mt,De=class extends nt{constructor(e=1,t=0,r="PolyhedronGeometry"){fe(r,"SphereGeometry");let i=Math.max(4,Math.min(32,4<<Math.min(t,3)));super(e,i,i)}},Ht=class extends De{constructor(e=1,t=0){super(e,t,"IcosahedronGeometry")}},Xt=class extends De{constructor(e=1,t=0){super(e,t,"OctahedronGeometry")}},Wt=class extends De{constructor(e=1,t=0){super(e,t,"DodecahedronGeometry")}},$t=class extends De{constructor(e=1,t=0){super(e,t,"TetrahedronGeometry")}},Yt=class extends Te{constructor(e=1,t=1,r=4,i=8){fe("CapsuleGeometry","CylinderGeometry"),super(e,e,t+e*2,i)}},jt=class extends Te{constructor(e=.5,t=1,r=16){fe("RingGeometry","CylinderGeometry"),super(t,t,.01,Math.max(8,r))}},Kt=class extends Te{constructor(e=1,t=16){fe("CircleGeometry","CylinderGeometry"),super(e,e,.01,Math.max(8,t))}},qt=class extends at{constructor(t,r,i=0,s=Math.PI/3,o=0,l=2){fe("SpotLight","PointLight");super(t,r,i,l);this.target=new pe;this.angle=Math.PI/3;this.penumbra=0;this.angle=s,this.penumbra=o}},ht=class extends ot{constructor(e,t,r){fe("HemisphereLight","AmbientLight"),super(e,r),this.groundColor=new de(t??4473924)}},Er=ht,Un={Vector2:wt,Vector3:te,Vector4:Et,Euler:Qe,Quaternion:et,Matrix4:Se,Matrix3:Rt,Color:de,MathUtils:ir,BufferAttribute:le,Float32BufferAttribute:_t,Uint16BufferAttribute:St,Uint32BufferAttribute:At,BufferGeometry:he,BoxGeometry:tt,PlaneGeometry:Ct,SphereGeometry:nt,CylinderGeometry:Te,ConeGeometry:It,TorusGeometry:Dt,TorusKnotGeometry:Lt,IcosahedronGeometry:Ht,OctahedronGeometry:Xt,DodecahedronGeometry:Wt,TetrahedronGeometry:$t,CapsuleGeometry:Yt,RingGeometry:jt,CircleGeometry:Kt,Texture:rt,TextureLoader:Nt,Material:xe,MeshStandardMaterial:Ae,MeshBasicMaterial:Pt,MeshLambertMaterial:Ft,MeshPhongMaterial:kt,MeshPhysicalMaterial:Ut,ShaderMaterial:mt,RawShaderMaterial:wr,Object3D:pe,Group:Ot,Mesh:Ce,InstancedMesh:st,Light:Ie,AmbientLight:ot,DirectionalLight:Bt,PointLight:at,SpotLight:qt,HemisphereLight:ht,RectAreaLight:Er,Camera:ct,PerspectiveCamera:Vt,Scene:ut,WebGLRenderer:zt,Clock:Gt,SceneQuotaValidator:ge,exportSceneToCanvas3D:Cn,exportSceneToGLB:In,exportSceneToUSDZ:sr,generateUSDZ:Mn,glbToUSDZ:Mt,sceneToCanvas3D:ke,sceneToGLB:Ke,sceneToUSDZ:Ue,authorScriptRunner:vr,getAuthorWarnings:Mr,clearAuthorWarnings:Tr};Object.freeze(ge);Object.freeze(ge.prototype);Object.freeze(ut.prototype);Object.freeze(Un);var Ne=new Proxy(Un,{get:(n,e)=>{if(e in n)return n[e];let t=Q().authorNamespace;return t&&typeof e=="string"&&e in t?t[e]:(typeof e=="string"&&e!=="then"&&e!=="toJSON"&&!e.startsWith("__")&&fe(`THREE.${e}`,"no-op proxy"),qe)},has:(n,e)=>{if(e in n)return!0;let t=Q().authorNamespace;return!!(t&&typeof e=="string"&&e in t)},set:(n,e)=>{throw new TypeError(`Cannot assign to read only property '${String(e)}' of #<THREE>`)},defineProperty:(n,e)=>{throw new TypeError(`Cannot define property '${String(e)}', object is not extensible`)},deleteProperty:(n,e)=>{throw new TypeError(`Cannot delete property '${String(e)}' of #<THREE>`)},setPrototypeOf:()=>{throw new TypeError("#<THREE> is not extensible")}}),Ze=Q();Ze.threeNamespace=Ne;if(Ze.workerExtensionInstallers)for(let n of Ze.workerExtensionInstallers)n(Ne,Ze);var Je={name:"three_author",THREE:Ne},jr=Je,ye=typeof globalThis<"u"?globalThis:typeof window<"u"?window:void 0;typeof ye.THREE>"u"&&(ye.THREE=Ne);typeof ye.requestAnimationFrame!="function"&&(ye.requestAnimationFrame=n=>(typeof n=="function"&&typeof ye.__three_live_raf_cb__!="function"&&(ye.__three_live_raf_cb__=n),ye.__three_live_in_step__||fe("requestAnimationFrame","single-frame static evaluation"),0));typeof ye.cancelAnimationFrame!="function"&&(ye.cancelAnimationFrame=()=>{});if(typeof window<"u"){let n=window;n.ThreeLive=n.ThreeLive||{},n.ThreeLive.THREE=Ne,n.ThreeLivePlugins=n.ThreeLivePlugins||{},n.ThreeLivePlugins.threeAuthor=Je,n.ThreeLivePlugins.three_author=Je,n.ThreeLivePlugins["three-author"]=Je}var Kr=Ne;export{ot as AmbientLight,tt as BoxGeometry,le as BufferAttribute,he as BufferGeometry,ct as Camera,Yt as CapsuleGeometry,Kt as CircleGeometry,Gt as Clock,de as Color,It as ConeGeometry,Te as CylinderGeometry,Bt as DirectionalLight,Wt as DodecahedronGeometry,Qe as Euler,_t as Float32BufferAttribute,Ot as Group,ht as HemisphereLight,Ht as IcosahedronGeometry,st as InstancedMesh,Ie as Light,it as MAX_INSTANCES_PER_MESH,xe as Material,ir as MathUtils,Rt as Matrix3,Se as Matrix4,Ce as Mesh,Pt as MeshBasicMaterial,Ft as MeshLambertMaterial,kt as MeshPhongMaterial,Ut as MeshPhysicalMaterial,Ae as MeshStandardMaterial,pe as Object3D,Xt as OctahedronGeometry,Vt as PerspectiveCamera,Ct as PlaneGeometry,at as PointLight,De as PolyhedronFallbackGeometry,et as Quaternion,wr as RawShaderMaterial,Er as RectAreaLight,jt as RingGeometry,ut as Scene,ge as SceneQuotaValidator,mt as ShaderMaterial,nt as SphereGeometry,qt as SpotLight,Ne as THREE,$t as TetrahedronGeometry,rt as Texture,Nt as TextureLoader,Dt as TorusGeometry,Lt as TorusKnotGeometry,St as Uint16BufferAttribute,At as Uint32BufferAttribute,wt as Vector2,te as Vector3,Et as Vector4,zt as WebGLRenderer,vr as authorScriptRunner,Ln as buildSandboxWorkerSource,Tr as clearAuthorWarnings,Kr as default,Cn as exportSceneToCanvas3D,In as exportSceneToGLB,sr as exportSceneToUSDZ,Mn as generateUSDZ,mr as getAllowClientScripts,Mr as getAuthorWarnings,Dn as getSandboxEngineSrc,ur as getSandboxIframeSrc,Mt as glbToUSDZ,we as isAllowedSandboxEngineUrl,qe as noopProxy,ke as sceneToCanvas3D,Ke as sceneToGLB,Ue as sceneToUSDZ,Yr as setAllowClientScripts,Wr as setSandboxEngineSrc,$r as setSandboxIframeSrc,Je as threeAuthorPlugin,jr as threeMicroPlugin,ar as toTrustedWorkerScriptURL,Fn as validateSandboxWorkerMessage,fe as warnUnsupported};
|
|
348
|
+
`+p.script+`
|
|
349
|
+
;
|
|
350
|
+
return typeof scene === "object" && scene ? scene : undefined;
|
|
351
|
+
})();`);y=null;let N=I(g,v,R,L);N&&typeof N.toGLB=="function"&&(v=N)}if(!w){g.SceneQuotaValidator&&g.SceneQuotaValidator.validate(v);let I=v.toGLB(),N=I instanceof ArrayBuffer?I:I.buffer.slice(I.byteOffset,I.byteOffset+I.byteLength);M({type:"3D_MODEL_READY",glbBuffer:N},[N])}h({type:"DONE",nonce:r})}catch(v){l(v&&v.message||v)}}},h({type:"READY",nonce:r})}function He(e,t,i){let r=i?.allowedScriptUrl??null,s=i?.allowClientScripts??r===null,n={nonce:t,engineSrc:e,allowedScriptUrl:r,allowClientScripts:s,revoked:xs},o=(ut().workerExtensionInstallers??[]).map(a=>`(${a.toString()})`).join(",");return`'use strict';(${vs.toString()})(${JSON.stringify(n)},[${o}]);`}function er(e){e.onError?.(new Error("SecurityError: Sandboxed script exceeded SECURITY_3D_SANDBOX_TIMEOUT_MS (3000 ms) and was terminated.")),e.onToast?.("Security Error: script timed out and was stopped.")}var Dt=0;function ir(){try{let e=new Uint32Array(4);return globalThis.crypto?.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(8,"0")).join("")}catch{return`${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`}}function Ms(e){try{return new TextEncoder().encode(e).length}catch{return e.length}}var ws=1024,Ts=256;function rr(e){if(!Array.isArray(e)&&!(e instanceof Float32Array)||e.length!==16)return!1;for(let t=0;t<16;t++){let i=e[t];if(typeof i!="number"||!Number.isFinite(i))return!1}return!0}function je(e,t){if(!e||typeof e!="object")return null;let i=e;if(i.nonce!==t)return null;switch(i.type){case"READY":return{type:"READY"};case"DONE":return{type:"DONE"};case"ERROR":return{type:"ERROR",message:(typeof i.message=="string"?i.message:String(i.message??"Unknown worker error")).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,"").slice(0,ws)};case"3D_UPDATE_TRANSFORMS":{let r=i.transforms;if(Array.isArray(r)){if(r.length>1e3)return null;for(let s of r)if(!rr(s))return null;return{type:"3D_UPDATE_TRANSFORMS",transforms:r}}if(r&&typeof r=="object"){let s=Object.keys(r);if(s.length>1e3)return null;let n=Object.create(null),o=r;for(let a of s){if(a.length>Ts||a==="__proto__"||a==="constructor"||a==="prototype")return null;let h=o[a];if(!rr(h))return null;n[a]=h}return{type:"3D_UPDATE_TRANSFORMS",transforms:n}}return null}case"3D_MODEL_READY":{let r=i.glbBuffer;return!(r instanceof ArrayBuffer)||r.byteLength>16777216?null:{type:"3D_MODEL_READY",payload:r}}default:return null}}function Ss(e){let t=Ms(e);if(t>1048576)throw new Error(`SecurityError: Script length (${t} bytes) exceeds SECURITY_3D_MAX_SCRIPT_BYTES (1048576).`)}function sr(e,t,i,r){switch(e.type){case"READY":return;case"3D_UPDATE_TRANSFORMS":t.onUpdateTransforms?.(e.transforms);return;case"3D_MODEL_READY":if(r.modelDispatched)return;r.modelDispatched=!0,t.onModelReady(e.payload);return;case"DONE":i();return;case"ERROR":i(),t.onError?.(new Error(`Worker script error: ${e.message}`));return;default:return e}}function Rs(e,t,i,r){let s=ir(),n=He(t,s,e.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:e.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),o=document.createElement("iframe");o.setAttribute("sandbox","allow-scripts"),o.setAttribute("aria-hidden","true"),o.tabIndex=-1,o.style.display="none",o.src=i,Dt++;let a=!1,h=!1,l={modelDispatched:!1},c,f=()=>{if(a||h)return;let b=o.contentWindow;!b||typeof b.postMessage!="function"||(h=!0,b.postMessage(e.kind==="url"?{type:"SANDBOX_RUN",nonce:s,workerSource:n,scriptUrl:e.scriptUrl}:{type:"SANDBOX_RUN",nonce:s,workerSource:n,script:e.script},"*"))},y=()=>{},g=b=>{if(a||!o.contentWindow||b.source!==o.contentWindow)return;let w=b.data;if(w&&typeof w=="object"&&w.type==="IFRAME_READY"){f();return}let M=je(w,s);M&&sr(M,r,y,l)};y=()=>{a||(a=!0,c!==void 0&&clearTimeout(c),Dt=Math.max(0,Dt-1),typeof globalThis.removeEventListener=="function"&&globalThis.removeEventListener("message",g),typeof o.remove=="function"?o.remove():o.parentNode&&o.parentNode.removeChild(o))},c=setTimeout(()=>{a||(y(),er(r))},3e3),typeof globalThis.addEventListener=="function"&&globalThis.addEventListener("message",g),o.onload=()=>{f()},o.onerror=()=>{y(),r.onError?.(new Error(`Sandbox iframe failed to load "${i}". Verify that three-live-sandbox.html is served at that URL.`))};let u=document.body||document.documentElement;if(!u||typeof u.appendChild!="function"){y();let b=new Error("SecurityError: Cannot mount sandbox iframe because document.body is unavailable.");throw r.onError?.(b),b}return u.appendChild(o),{terminate:y}}function nr(e,t,i,r){if(t==="worker"&&typeof Worker>"u")return r("Sandboxed procedural execution requires Web Workers, but Workers are unavailable in this environment. For host security, Three-Live prohibits unsandboxed in-process evaluation.","Security Error: Web Workers unavailable. Script execution aborted.");if(t==="iframe"&&(typeof document>"u"||typeof document.createElement!="function"))return r("Sandboxed iframe execution requires a DOM environment with document.createElement. Refusing to evaluate in the host realm.","Security Error: DOM unavailable for iframe sandbox.");if(Dt>=32)return r(`SecurityError: ${Dt} sandbox workers are already running, which meets SECURITY_3D_MAX_CONCURRENT_TASKS (32). Refusing to start another.`,"Security Error: too many concurrent sandboxed scripts.");let s;try{s=ps()}catch(y){let g=y instanceof Error?y.message:String(y);return r(g,"Security Error: sandbox engine URL is not configured.")}if(t==="iframe"){let y;try{y=gs()}catch(g){let u=g instanceof Error?g.message:String(g);return r(u,"Security Error: sandbox iframe URL is not configured.")}try{return Promise.resolve(Rs(e,s,y,i))}catch(g){return Promise.reject(g)}}let n=ir(),o=He(s,n,e.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:e.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),a;try{let y=new Blob([o],{type:"application/javascript"}),g=URL.createObjectURL(y);try{let u=Ji(g);a=new Worker(u)}finally{URL.revokeObjectURL(g)}}catch(y){let g=y instanceof Error?y.message:String(y);return r(`Failed to initialize Web Worker for sandboxed execution (CSP may block blob workers): ${g}`,"Security Error: Failed to start Worker sandbox.")}Dt++;let h=!1,l={modelDispatched:!1},c,f=()=>{h||(h=!0,c!==void 0&&clearTimeout(c),Dt=Math.max(0,Dt-1),a.terminate())};return c=setTimeout(()=>{h||(f(),er(i))},3e3),a.onmessage=y=>{let g=je(y.data,n);g&&sr(g,i,f,l)},a.onerror=y=>{f(),i.onError?.(new Error(`Worker execution error: ${y.message}`))},e.kind==="url"?a.postMessage({type:"EXECUTE_URL",scriptUrl:e.scriptUrl,nonce:n}):a.postMessage({type:"EXECUTE",script:e.script,nonce:n}),Promise.resolve({terminate:f})}function ar(e,t){return e==="none"||e==="unsafe-host-realm"?t(`SecurityError: sandbox="${e}" is prohibited. Sandboxing is mandatory for live compilation and cannot be bypassed. Use sandbox="worker" (default) or sandbox="iframe".`,`Security Error: sandbox="${e}" is not permitted.`):e!=="worker"&&e!=="iframe"?t(`SecurityError: Unsupported sandbox mode "${e}". Live compilation requires sandbox="worker" or sandbox="iframe".`,"Security Error: unsupported sandbox mode."):null}var or=e=>(t,i)=>{let r=new Error(t);return e.onError?.(r),i&&e.onToast?.(i),Promise.reject(r)},lr={execute(e,t,i,r){let s=or(i),n=ar(t,s);if(n)return n;try{Ss(e)}catch(o){let a=o instanceof Error?o.message:String(o);return s(a,"Security Error: script exceeds the size limit.")}return r?.allowClientScripts??tr()?nr({kind:"script",script:e},t,i,s):s(Vr,Or)},executeUrl(e,t,i){let r=or(i),s=ar(t,r);if(s)return s;let n;try{n=bs(e)}catch(o){let a=o instanceof Error?o.message:String(o);return r(a,"Security Error: disallowed scene script URL.")}return nr({kind:"url",scriptUrl:n},t,i,r)}},ue=new Set;function kt(e,t){let i=`[three-live] ${e} is unsupported; degraded to ${t}.`;ue.has(i)||(ue.add(i),typeof console<"u"&&typeof console.warn=="function"&&console.warn(i))}function hr(){return Array.from(ue)}function ur(){ue.clear()}var We=class extends jt{constructor(e={}){kt("ShaderMaterial","MeshStandardMaterial");let t=e.uniforms||{},i=t.color?.value??t.uColor?.value??t.diffuse?.value??e.color;super({color:i!==void 0?i:8421504,opacity:t.opacity?.value??e.opacity??1,transparent:!!e.transparent,wireframe:!!e.wireframe,side:e.side}),this.uniforms=t}},cr=We,Ut=class extends ft{constructor(e=[],t=[],i=1,r=0){super();let s=Number(i)||1,n=Math.max(0,Math.min(7,Math.floor(Number(r)||0))),o=n+1,a=[],h=[],l=[],c=[],f=new Y,y=new Y,g=new Y,u=(M,x)=>x.set(e[M*3]||0,e[M*3+1]||0,e[M*3+2]||0),b=(M,x)=>{let m=M.clone().normalize();a.push(m.x*s,m.y*s,m.z*s),h.push(x.x,x.y,x.z),l.push(Math.atan2(m.z,-m.x)/(2*Math.PI)+.5,1-Math.acos(Math.max(-1,Math.min(1,m.y)))/Math.PI)},w=(M,x,m)=>{let p=a.length/3,v=n===0?new Y().subVectors(m,x).cross(new Y().subVectors(M,x)).normalize():null;b(M,v||M.clone().normalize()),b(x,v||x.clone().normalize()),b(m,v||m.clone().normalize()),c.push(p,p+1,p+2)};for(let M=0;M<t.length;M+=3){u(t[M],f),u(t[M+1],y),u(t[M+2],g);let x=[];for(let m=0;m<=o;m++){x[m]=[];let p=f.clone().lerp(g,m/o),v=y.clone().lerp(g,m/o),R=o-m;for(let L=0;L<=R;L++)x[m][L]=R===0?p.clone():p.clone().lerp(v,L/R)}for(let m=0;m<o;m++)for(let p=0;p<2*(o-m)-1;p++){let v=p>>1;(p&1)===0?w(x[m][v+1],x[m+1][v],x[m][v]):w(x[m][v+1],x[m+1][v+1],x[m+1][v])}}this.setFromBuffers(a,h,l,c)}},Cs=Ut,mr=class extends Ut{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t)}},ce=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],fr=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],pr=class extends Ut{constructor(e=1,t=0){super(ce,fr,e,t)}},at=(1+Math.sqrt(5))/2,dr=class extends Ut{constructor(e=1,t=0){super([-1,at,0,1,at,0,-1,-at,0,1,-at,0,0,-1,at,0,1,at,0,-1,-at,0,1,-at,at,0,-1,at,0,1,-at,0,-1,-at,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t)}},vt=1/at,gr=class extends Ut{constructor(e=1,t=0){super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-vt,-at,0,-vt,at,0,vt,-at,0,vt,at,-vt,-at,0,-vt,at,0,vt,-at,0,vt,at,0,-at,0,-vt,at,0,-vt,-at,0,vt,at,0,vt],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t)}},yr=class extends Le{constructor(e=1,t=1,i=4,r=8){let s=Math.max(1e-4,Number(e)||1),n=Math.max(0,Number.isFinite(Number(t))?Number(t):1)*.5,o=Math.max(2,Math.min(64,Math.floor(Number(i)||4))),a=[];for(let h=-1;h<=1;h+=2)for(let l=0;l<=o;l++){if(h>0&&l===0&&n===0)continue;let c=(h<0?l/o-1:l/o)*(Math.PI/2);a.push(new Tt(Math.max(0,Math.cos(c)*s),h*n+Math.sin(c)*s))}super(a,Math.max(4,Math.min(128,Math.floor(Number(r)||8))))}},Xe=class extends ft{constructor(e=.5,t=1,i=32,r=1,s=0,n=Math.PI*2){super();let o=Math.max(1e-4,Number(t)||1),a=Number(e),h=Number.isFinite(a)?Math.max(0,a):o*.5,l=Math.max(o,h),c=Math.min(l*.999,Math.min(o,h)),f=Math.max(3,Math.min(256,Math.floor(Number(i)||32))),y=Math.max(1,Math.min(64,Math.floor(Number(r)||1))),g=Number.isFinite(Number(s))?Number(s):0,u=Number.isFinite(Number(n))?Number(n):Math.PI*2,b=[],w=[],M=[],x=[];for(let m=0;m<=y;m++){let p=c+m/y*(l-c);for(let v=0;v<=f;v++){let R=g+v/f*u,L=Math.cos(R),I=Math.sin(R);if(b.push(p*L,p*I,0),w.push(0,0,1),M.push(p/l*L*.5+.5,p/l*I*.5+.5),m<y&&v<f){let N=m*(f+1)+v,_=N+f+1;p>1e-6&&x.push(N,_,N+1),x.push(_,_+1,N+1)}}}this.setFromBuffers(b,w,M,x)}},br=class extends Xe{constructor(e=1,t=32,i=0,r=Math.PI*2){super(0,e,t,1,i,r)}},qe=class extends Mt{constructor(e={}){super({roughness:.35,metalness:.1,side:2,...e});let t=Number(e.size);this.size=Number.isFinite(t)?Math.max(.002,Math.min(2,t)):.05,this.sizeAttenuation=e.sizeAttenuation!==!1,e.emissive===void 0&&(this.emissive=this.color.clone(),this.emissiveIntensity=.35)}},me=class extends Mt{constructor(e={}){super({roughness:.4,metalness:.1,side:2,...e});let t=Number(e.linewidth);this.linewidth=Number.isFinite(t)?Math.max(.5,Math.min(20,t)):1,e.emissive===void 0&&(this.emissive=this.color.clone(),this.emissiveIntensity=.3)}},xr=class extends me{constructor(e={}){super(e),this.dashSize=Number(e.dashSize)||3,this.gapSize=Number(e.gapSize)||1,this.scale=Number(e.scale)||1}};function vr(e,t){let i=e?.attributes?.position;if(!i?.array||i.count<3)return new Float32Array(0);let r=i.array,s=e?.index?.array,n=Math.min(8192,Math.floor((s?s.length:i.count)/3)),o=y=>`${Math.round((r[y*3]||0)*1e4)},${Math.round((r[y*3+1]||0)*1e4)},${Math.round((r[y*3+2]||0)*1e4)}`,a=t===void 0,h=a?1:Math.cos(t*Math.PI/180),l={},c=[],f=(y,g)=>c.push(r[y*3]||0,r[y*3+1]||0,r[y*3+2]||0,r[g*3]||0,r[g*3+1]||0,r[g*3+2]||0);for(let y=0;y<n;y++){let g=s?s[y*3]:y*3,u=s?s[y*3+1]:y*3+1,b=s?s[y*3+2]:y*3+2,w=r[g*3]||0,M=r[g*3+1]||0,x=r[g*3+2]||0,m=(r[u*3]||0)-w,p=(r[u*3+1]||0)-M,v=(r[u*3+2]||0)-x,R=(r[b*3]||0)-w,L=(r[b*3+1]||0)-M,I=(r[b*3+2]||0)-x,N=p*I-v*L,_=v*R-m*I,A=m*L-p*R,E=Math.hypot(N,_,A);if(!a&&E<1e-8)continue;E>0&&(N/=E,_/=E,A/=E);let C=[g,u,b];for(let d=0;d<3;d++){let k=C[d],$=C[(d+1)%3],S=o(k),D=o($);if(S===D)continue;let T=S<D?`${S}|${D}`:`${D}|${S}`,P=l[T];P?P.m||(P.m=1,P.nx*N+P.ny*_+P.nz*A<=h&&f(k,$)):(l[T]={va:k,vb:$,nx:N,ny:_,nz:A,m:a?1:0},a&&f(k,$))}}if(!a){let y=Object.keys(l);for(let g=0;g<y.length;g++){let u=l[y[g]];u&&!u.m&&f(u.va,u.vb)}}return new Float32Array(c)}var Mr=class extends ft{constructor(e){super(),this.setAttribute("position",new gt(vr(e),3)),this.__isSegmentPairs=!0}},wr=class extends ft{constructor(e,t=1){super();let i=Number.isFinite(Number(t))?Number(t):1;this.setAttribute("position",new gt(vr(e,i),3)),this.__isSegmentPairs=!0}};function As(e,t,i=1){let r=new ft;r.__baked=!0;let s=e?.attributes?.position;if(!s?.array||s.count<2)return r;let n=s.array,o=e.index?.array,a=e.__isSegmentPairs?"segments":t,h=o?o.length:s.count,l=Math.min(4096,Math.max(0,a==="segments"?Math.floor(h/2):a==="loop"&&h>=3?h:h-1));if(l===0)return r;e.computeBoundingBox();let c=e.boundingBox,f=c&&c.max.distanceTo(c.min)||1,y=Math.max(.0015,Math.min(.025,f*.003))*(.5+.5*Math.max(.5,Math.min(6,Number(i)||1))),g=[],u=[],b=[],w=[];for(let M=0;M<l;M++){let x=a==="segments"?M*2:M,m=a==="segments"?M*2+1:(M+1)%h,p=o?o[x]:x,v=o?o[m]:m,R=n[p*3]||0,L=n[p*3+1]||0,I=n[p*3+2]||0,N=(n[v*3]||0)-R,_=(n[v*3+1]||0)-L,A=(n[v*3+2]||0)-I,E=Math.hypot(N,_,A);if(E<1e-6)continue;let C=N/E,d=_/E,k=A/E,$=(Math.abs(d)<.9?Math.hypot(k,C):Math.hypot(k,d))||1,S=Math.abs(d)<.9?k/$:0,D=Math.abs(d)<.9?0:-k/$,T=Math.abs(d)<.9?-C/$:d/$,P=d*T-k*D,j=k*S-C*T,W=C*D-d*S,V=g.length/3,Z=[[S,D,T],[P,j,W],[-S,-D,-T],[-P,-j,-W]];for(let U=0;U<2;U++){let X=R+U*N,O=L+U*_,G=I+U*A;for(let F=0;F<4;F++){let H=Z[F];g.push(X+H[0]*y,O+H[1]*y,G+H[2]*y),u.push(H[0],H[1],H[2]),b.push(F/4,U)}}for(let U=0;U<4;U++){let X=(U+1)%4;w.push(V+U,V+X,V+4+X,V+U,V+4+X,V+4+U)}}return g.length>0&&r.setFromBuffers(g,u,b,w),r}function Ps(e,t=.05){let i=new ft;i.__baked=!0;let r=e?.attributes?.position;if(!r?.array||r.count<1)return i;let s=r.array,n=r.count,o=Math.min(n,5e3),a=Math.max(.003,Math.min(.25,(Number(t)||.05)*.6)),h=[],l=[],c=[],f=[];for(let y=0;y<o;y++){let g=n<=5e3?y:Math.floor(y*n/o),u=s[g*3]||0,b=s[g*3+1]||0,w=s[g*3+2]||0,M=y*6;for(let x=0;x<6;x++){let m=ce[x*3],p=ce[x*3+1],v=ce[x*3+2];h.push(u+m*a,b+p*a,w+v*a),l.push(m,p,v),c.push(.5,.5)}for(let x=0;x<24;x++)f.push(M+fr[x])}return i.setFromBuffers(h,l,c,f),i}var $t=class extends Et{constructor(e,t,i="strip"){let r=t&&typeof t=="object"?t:{},s=t instanceof Mt?t:i==="points"?new qe(r):new me(r),n=e instanceof ft?e:new ft;super(n,s),this.isLine=!0,this._lineMode=i,this._sourceGeo=n}computeLineDistances(){return this}_bakeAuthorGeometry(){this.geometry&&!this.geometry.__baked&&(this._sourceGeo=this.geometry);let e=this._lineMode==="points";if(e){let t=this._sourceGeo?.attributes?.color;if(t?.array&&t.count>0&&this.material?.color.r===1&&this.material.color.g===1&&this.material.color.b===1){let i=t.array,r=Math.min(t.count,64),s=0,n=0,o=0;for(let a=0;a<r;a++)s+=i[a*3]||0,n+=i[a*3+1]||0,o+=i[a*3+2]||0;this.material.color.setRGB(s/r,n/r,o/r)}}!this.geometry?.__baked&&this._sourceGeo?.attributes?.position?.count>=(e?1:2)&&(this.geometry=e?Ps(this._sourceGeo,this.material?.size??.05):As(this._sourceGeo,this._lineMode,this.material?.linewidth??1))}},Tr=class extends $t{constructor(e,t){super(e,t,"loop"),this.isLineLoop=!0}},Sr=class extends $t{constructor(e,t){super(e,t,"segments"),this.isLineSegments=!0}},Rr=class extends $t{constructor(e,t){super(e,t,"points"),this.isPoints=!0}},Cr=class extends Ue{constructor(e,t,i=0,r=Math.PI/3,s=0,n=2){super(e,t,i,n),this.target=new Ct,this.type="spot";let o=Number(r);this.angle=Number.isFinite(o)?Math.max(.01,Math.min(Math.PI/2,o)):Math.PI/3;let a=Number(s);this.penumbra=Number.isFinite(a)?Math.max(0,Math.min(1,a)):0}},Ke=class extends ke{constructor(e,t,i){kt("HemisphereLight","AmbientLight"),super(e,i),this.groundColor=new Rt(t??4473924)}},Ar=Ke,Pr={Vector2:Tt,Vector3:Y,Vector4:bi,Euler:_e,Quaternion:Ee,Matrix4:Ot,Matrix3:xi,Color:Rt,MathUtils:Mi,BufferAttribute:gt,Float32BufferAttribute:wi,Uint16BufferAttribute:Ti,Uint32BufferAttribute:Si,BufferGeometry:ft,BoxGeometry:Ne,PlaneGeometry:Ri,SphereGeometry:Ci,CylinderGeometry:De,ConeGeometry:Ai,TorusGeometry:Pi,TorusKnotGeometry:Ei,Curve:Ft,Curve3:Ft,LineCurve3:Ni,QuadraticBezierCurve3:Di,CubicBezierCurve3:Li,CatmullRomCurve3:Ii,LatheGeometry:Le,TubeGeometry:Fi,PolyhedronGeometry:Ut,IcosahedronGeometry:dr,OctahedronGeometry:pr,DodecahedronGeometry:gr,TetrahedronGeometry:mr,CapsuleGeometry:yr,RingGeometry:Xe,CircleGeometry:br,WireframeGeometry:Mr,EdgesGeometry:wr,FrontSide:0,BackSide:1,DoubleSide:2,NoBlending:0,NormalBlending:1,AdditiveBlending:2,MultiplyBlending:4,RepeatWrapping:1e3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002,NearestFilter:1003,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:1005,LinearFilter:1006,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:1008,UnsignedByteType:1009,ByteType:1010,ShortType:1011,UnsignedShortType:1012,IntType:1013,UnsignedIntType:1014,FloatType:1015,HalfFloatType:1016,AlphaFormat:1021,RGBFormat:1022,RGBAFormat:1023,LuminanceFormat:1024,LuminanceAlphaFormat:1025,RedFormat:1028,RGFormat:1030,NoColorSpace:"",SRGBColorSpace:"srgb",LinearSRGBColorSpace:"srgb-linear",StaticDrawUsage:35044,DynamicDrawUsage:35048,ACESFilmicToneMapping:4,PCFSoftShadowMap:2,Texture:le,DataTexture:ki,TextureLoader:Ui,Material:Mt,MeshStandardMaterial:jt,MeshBasicMaterial:zi,MeshLambertMaterial:Vi,MeshPhongMaterial:Oi,MeshPhysicalMaterial:Bi,PointsMaterial:qe,LineBasicMaterial:me,LineDashedMaterial:xr,ShaderMaterial:We,RawShaderMaterial:cr,Object3D:Ct,Group:$i,Mesh:Et,InstancedMesh:Fe,Line:$t,LineLoop:Tr,LineSegments:Sr,Points:Rr,Light:Xt,AmbientLight:ke,DirectionalLight:Hi,PointLight:Ue,SpotLight:Cr,HemisphereLight:Ke,RectAreaLight:Ar,Camera:ze,PerspectiveCamera:ji,Scene:Ve,WebGLRenderer:Xi,Clock:Ki,SceneQuotaValidator:Nt,exportSceneToCanvas3D:Oe,exportSceneToGLB:Be,exportSceneToUSDZ:Wi,generateUSDZ:yi,glbToUSDZ:Pe,sceneToCanvas3D:Ht,sceneToGLB:ie,sceneToUSDZ:ne,authorScriptRunner:lr,getAuthorWarnings:hr,clearAuthorWarnings:ur};Object.freeze(Nt),Object.freeze(Nt.prototype),Object.freeze(Ve.prototype),Object.freeze(Pr);var zt=new Proxy(Pr,{get:(e,t)=>{if(t in e)return e[t];let i=ut().authorNamespace;return i&&typeof t=="string"&&t in i?i[t]:(typeof t=="string"&&t!=="then"&&t!=="toJSON"&&!t.startsWith("__")&&kt(`THREE.${t}`,"no-op proxy"),qt)},has:(e,t)=>{if(t in e)return!0;let i=ut().authorNamespace;return!!(i&&typeof t=="string"&&t in i)},set:(e,t)=>{throw new TypeError(`Cannot assign to read only property '${String(t)}' of #<THREE>`)},defineProperty:(e,t)=>{throw new TypeError(`Cannot define property '${String(t)}', object is not extensible`)},deleteProperty:(e,t)=>{throw new TypeError(`Cannot delete property '${String(t)}' of #<THREE>`)},setPrototypeOf:()=>{throw new TypeError("#<THREE> is not extensible")}}),fe=ut();if(fe.threeNamespace=zt,fe.workerExtensionInstallers)for(let e of fe.workerExtensionInstallers)e(zt,fe);var Yt={name:"three_author",THREE:zt},_s=Yt,At=typeof globalThis<"u"?globalThis:typeof window<"u"?window:void 0;if(typeof At.THREE>"u"&&(At.THREE=zt),typeof At.requestAnimationFrame!="function"&&(At.requestAnimationFrame=e=>(typeof e=="function"&&typeof At.__three_live_raf_cb__!="function"&&(At.__three_live_raf_cb__=e),At.__three_live_in_step__||kt("requestAnimationFrame","single-frame static evaluation"),0)),typeof At.cancelAnimationFrame!="function"&&(At.cancelAnimationFrame=()=>{}),typeof window<"u"){let e=window;e.ThreeLive=e.ThreeLive||{},e.ThreeLive.THREE=zt,e.ThreeLivePlugins=e.ThreeLivePlugins||{},e.ThreeLivePlugins.threeAuthor=Yt,e.ThreeLivePlugins.three_author=Yt,e.ThreeLivePlugins["three-author"]=Yt}var Es=zt;export{ke as AmbientLight,Ne as BoxGeometry,gt as BufferAttribute,ft as BufferGeometry,ze as Camera,yr as CapsuleGeometry,Ii as CatmullRomCurve3,br as CircleGeometry,Ki as Clock,Rt as Color,Ai as ConeGeometry,Li as CubicBezierCurve3,Ft as Curve3,De as CylinderGeometry,ki as DataTexture,Hi as DirectionalLight,gr as DodecahedronGeometry,wr as EdgesGeometry,_e as Euler,wi as Float32BufferAttribute,$i as Group,Ke as HemisphereLight,dr as IcosahedronGeometry,Fe as InstancedMesh,Le as LatheGeometry,Xt as Light,$t as Line,me as LineBasicMaterial,Ni as LineCurve3,xr as LineDashedMaterial,Tr as LineLoop,Sr as LineSegments,Wt as MAX_INSTANCES_PER_MESH,Mt as Material,Mi as MathUtils,xi as Matrix3,Ot as Matrix4,Et as Mesh,zi as MeshBasicMaterial,Vi as MeshLambertMaterial,Oi as MeshPhongMaterial,Bi as MeshPhysicalMaterial,jt as MeshStandardMaterial,Ct as Object3D,pr as OctahedronGeometry,ji as PerspectiveCamera,Ri as PlaneGeometry,Ue as PointLight,Rr as Points,qe as PointsMaterial,Cs as PolyhedronFallbackGeometry,Ut as PolyhedronGeometry,Di as QuadraticBezierCurve3,Ee as Quaternion,cr as RawShaderMaterial,Ar as RectAreaLight,Xe as RingGeometry,Ve as Scene,Nt as SceneQuotaValidator,We as ShaderMaterial,Ci as SphereGeometry,Cr as SpotLight,zt as THREE,mr as TetrahedronGeometry,le as Texture,Ui as TextureLoader,Pi as TorusGeometry,Ei as TorusKnotGeometry,Fi as TubeGeometry,Ti as Uint16BufferAttribute,Si as Uint32BufferAttribute,Tt as Vector2,Y as Vector3,bi as Vector4,Xi as WebGLRenderer,Mr as WireframeGeometry,lr as authorScriptRunner,He as buildSandboxWorkerSource,ur as clearAuthorWarnings,Es as default,Oe as exportSceneToCanvas3D,Be as exportSceneToGLB,Wi as exportSceneToUSDZ,yi as generateUSDZ,tr as getAllowClientScripts,hr as getAuthorWarnings,$e as getSandboxEngineSrc,Qi as getSandboxIframeSrc,Pe as glbToUSDZ,Bt as isAllowedSandboxEngineUrl,qt as noopProxy,Ht as sceneToCanvas3D,ie as sceneToGLB,ne as sceneToUSDZ,ys as setAllowClientScripts,fs as setSandboxEngineSrc,ds as setSandboxIframeSrc,Yt as threeAuthorPlugin,_s as threeMicroPlugin,Ji as toTrustedWorkerScriptURL,je as validateSandboxWorkerMessage,kt as warnUnsupported};
|