three-live 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/three-author-engine.js +45 -40
- package/dist/three-author.cjs +32 -27
- package/dist/three-author.d.ts +3 -3
- package/dist/three-author.js +32 -27
- package/dist/three-convert.cjs +43 -38
- package/dist/three-convert.d.ts +3 -3
- package/dist/three-convert.js +42 -37
- package/dist/three-live-animation.cjs +6 -6
- package/dist/three-live-animation.d.ts +3 -3
- package/dist/three-live-animation.js +5 -5
- package/dist/three-live-animation.min.js +6 -6
- package/dist/three-live-element.cjs +12 -7
- package/dist/three-live-element.d.ts +3 -3
- package/dist/three-live-element.js +12 -7
- package/dist/three-live-extras.cjs +13 -13
- package/dist/three-live-extras.d.ts +3 -3
- package/dist/three-live-extras.js +12 -12
- package/dist/three-live-extras.min.js +13 -13
- package/dist/three-live-full.cjs +69 -64
- package/dist/three-live-full.js +69 -64
- package/dist/three-live-full.min.js +69 -64
- package/dist/three-live-viewer.cjs +12 -7
- package/dist/three-live-viewer.d.ts +3 -3
- package/dist/three-live-viewer.js +12 -7
- package/dist/three-live-viewer.min.js +12 -7
- package/dist/three-live.cjs +49 -44
- package/dist/three-live.js +49 -44
- package/dist/three-live.min.js +49 -44
- package/dist/three-view.cjs +12 -7
- package/dist/three-view.d.ts +3 -3
- package/dist/three-view.js +12 -7
- package/dist/three-xr.cjs +44 -39
- package/dist/three-xr.d.ts +3 -3
- package/dist/three-xr.js +44 -39
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
"use strict";var ThreeEngine=(()=>{var Bt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var Zn=Object.getOwnPropertyNames;var Jn=Object.prototype.hasOwnProperty;var Qn=(n,e)=>{for(var t in e)Bt(n,t,{get:e[t],enumerable:!0})},er=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zn(e))!Jn.call(n,i)&&i!==t&&Bt(n,i,{get:()=>e[i],enumerable:!(r=jn(e,i))||r.enumerable});return n};var tr=n=>er(Bt({},"__esModule",{value:!0}),n);var $r={};Qn($r,{AmbientLight:()=>Ye,BoxGeometry:()=>Ge,BufferAttribute:()=>X,BufferGeometry:()=>ce,Camera:()=>Ke,CapsuleGeometry:()=>Ft,CircleGeometry:()=>kt,Clock:()=>Dt,Color:()=>he,ConeGeometry:()=>gt,CylinderGeometry:()=>Ee,DirectionalLight:()=>At,DodecahedronGeometry:()=>Pt,Euler:()=>He,Float32BufferAttribute:()=>dt,Group:()=>St,HemisphereLight:()=>Ze,IcosahedronGeometry:()=>It,Light:()=>Me,Material:()=>me,MathUtils:()=>Ln,Matrix3:()=>ft,Matrix4:()=>ye,Mesh:()=>Pe,MeshBasicMaterial:()=>wt,MeshLambertMaterial:()=>Et,MeshPhongMaterial:()=>Mt,MeshPhysicalMaterial:()=>Rt,MeshStandardMaterial:()=>Se,Object3D:()=>ie,OctahedronGeometry:()=>Lt,PerspectiveCamera:()=>Ue,PlaneGeometry:()=>yt,PointLight:()=>qe,PolyhedronFallbackGeometry:()=>_e,Quaternion:()=>Xe,RawShaderMaterial:()=>Hn,RectAreaLight:()=>Xn,RingGeometry:()=>Nt,Scene:()=>Ae,SceneQuotaValidator:()=>pe,ShaderMaterial:()=>je,SphereGeometry:()=>We,SpotLight:()=>Ot,THREE:()=>Je,TetrahedronGeometry:()=>Ut,Texture:()=>$e,TextureLoader:()=>Tt,TorusGeometry:()=>xt,TorusKnotGeometry:()=>vt,Uint16BufferAttribute:()=>pt,Uint32BufferAttribute:()=>bt,Vector2:()=>ht,Vector3:()=>q,Vector4:()=>mt,WebGLRenderer:()=>_t,authorScriptRunner:()=>zn,buildSandboxWorkerSource:()=>nn,clearAuthorWarnings:()=>on,default:()=>Wr,exportSceneToCanvas3D:()=>Qt,exportSceneToGLB:()=>en,exportSceneToUSDZ:()=>Pn,generateUSDZ:()=>$t,getAllowClientScripts:()=>Nn,getAuthorWarnings:()=>Vn,getSandboxEngineSrc:()=>tn,getSandboxIframeSrc:()=>Fn,glbToUSDZ:()=>ut,isAllowedSandboxEngineUrl:()=>Re,noopProxy:()=>Le,sceneToCanvas3D:()=>Ce,sceneToGLB:()=>Be,sceneToUSDZ:()=>Ie,setAllowClientScripts:()=>Fr,setSandboxEngineSrc:()=>Ir,setSandboxIframeSrc:()=>Pr,threeAuthorPlugin:()=>Ve,threeMicroPlugin:()=>Gr,toTrustedWorkerScriptURL:()=>Un,validateSandboxWorkerMessage:()=>rn,warnUnsupported:()=>oe});function tt(n,e,t){let r=[],i=new Map,o=[],c=[],m=[],u=new Map,a=y=>{let E=i.get(y);return E===void 0&&(E=r.length,r.push({op:y}),i.set(y,E)),E},s=y=>{let E=u.get(y);return E===void 0&&(E=m.length,m.push({id:y}),u.set(y,E)),E},h=(y,E={})=>o.push({declaration:a(y),...E})-1,l=(y,E,g)=>c.push({id:y,type:E,value:g})-1,p=y=>({node:y,socket:"value"}),f=t?.interactivity??t?.gltfExtensions?.KHR_interactivity;if(f&&typeof f=="object"){let y=Array.isArray(f.graphs)?f.graphs[f.graph??0]:f;if(y&&Array.isArray(y.nodes)){let E=Array.isArray(y.declarations)?y.declarations:[];for(let g of E)g?.op&&a(g.op);Array.isArray(y.variables)&&c.push(...y.variables);for(let g of y.events||[])g?.id&&s(g.id);for(let g of y.nodes){if(!g||typeof g!="object")continue;let A=g.op||(typeof g.declaration=="number"?E[g.declaration]?.op:"");o.push(A?{...g,declaration:a(A)}:{...g})}}}let T=(y,E,g="translation")=>g==="baseColorFactor"||g==="metallicFactor"||g==="roughnessFactor"?`/materials/${Math.max(0,E)}/pbrMetallicRoughness/${g}`:g==="emissiveFactor"||g==="alphaCutoff"?`/materials/${Math.max(0,E)}/${g}`:g==="visible"?`/nodes/${y}/extensions/KHR_node_visibility/visible`:`/nodes/${y}/${g}`,M=new Map;n.forEach((y,E)=>{typeof y?.name=="string"&&!M.has(y.name)&&M.set(y.name,E)});let R=(y,E)=>typeof y.target=="string"&&M.has(y.target)?M.get(y.target):typeof y.targetNode=="number"?y.targetNode:E,I=y=>{let E=n[y];return(typeof E?.mesh=="number"?e[E.mesh]?.primitives?.[0]?.material:0)??0};for(let y=0;y<n.length;y++){let E=n[y],g=E?.extras?.interactivity;if(!g||typeof g!="object")continue;let A=(typeof E.mesh=="number"?e[E.mesh]?.primitives?.[0]?.material:0)??0,b=v=>{let _=Array.isArray(v)?v:[v],C=[];for(let S=0;S<_.length;S++){let x=_[S];if(!x||typeof x!="object")continue;let P=x.action||"interpolate",B=typeof x.duration=="number"?x.duration:.35;if(P==="toggleTransform"){let V=x.property==="rotation"||x.property==="scale"?x.property:"translation",k=V==="rotation"?E.rotation||[0,0,0,1]:V==="scale"?E.scale||[1,1,1]:E.translation||[0,0,0],L=`/nodes/${y}/${V}`,U=l(`__toggle_${y}_${S}`,"bool",!1),D=h("variable/get",{configuration:{variable:U}}),O=h("math/not",{values:{a:p(D)}}),N=h("variable/set",{configuration:{variable:U},values:{value:p(O)}}),z=h("pointer/interpolate",{configuration:{pointer:L},values:{value:{value:Array.isArray(x.to)?x.to:k},duration:{value:B}}}),F=h("pointer/interpolate",{configuration:{pointer:L},values:{value:{value:Array.isArray(x.from)?x.from:k},duration:{value:B}}});o[N].flows={out:{node:h("flow/branch",{values:{condition:p(D)},flows:{true:{node:z},false:{node:F}}})}},C.push(N)}else if(P==="interpolate"){let V=x.to??x.value;if(V===void 0)continue;let k={value:{value:V},duration:{value:B}};x.from!==void 0&&(k.from={value:x.from}),C.push(h("pointer/interpolate",{configuration:{pointer:typeof x.pointer=="string"?x.pointer:T(R(x,y),I(R(x,y)),x.property)},values:k}))}else if(P==="setProperty"){if(x.value===void 0)continue;C.push(h("pointer/set",{configuration:{pointer:typeof x.pointer=="string"?x.pointer:T(R(x,y),I(R(x,y)),x.property)},values:{value:{value:x.value}}}))}else if(P==="toggleVisibility"){let V=R(x,y),k=l(`__vis_${V}_${S}`,"bool",!0),L=h("variable/get",{configuration:{variable:k}}),U=h("math/not",{values:{a:p(L)}}),D=h("variable/set",{configuration:{variable:k},values:{value:p(U)}});o[D].flows={out:{node:h("pointer/set",{configuration:{pointer:`/nodes/${V}/extensions/KHR_node_visibility/visible`},values:{value:p(L)}})}},C.push(D)}else if(P==="cycleMaterialColor"&&Array.isArray(x.colors)&&x.colors.length>0){let V=typeof x.duration=="number"?x.duration:.25,k=`/materials/${Math.max(0,A)}/pbrMetallicRoughness/baseColorFactor`,L=l(`__color_idx_${y}_${S}`,"int",0),U=h("variable/get",{configuration:{variable:L}}),D=h("math/add",{values:{a:p(U),b:{value:1}}}),O=h("math/rem",{values:{a:p(D),b:{value:x.colors.length}}}),N=h("variable/set",{configuration:{variable:L},values:{value:p(O)}}),z={};for(let F=0;F<x.colors.length;F++){let H=x.colors[F],Y=Array.isArray(H)&&H.length>=3?[H[0],H[1],H[2],H[3]??1]:[1,1,1,1];z[String(F)]={node:V>0?h("pointer/interpolate",{configuration:{pointer:k},values:{value:{value:Y},duration:{value:V}}}):h("pointer/set",{configuration:{pointer:k},values:{value:{value:Y}}})}}o[N].flows={out:{node:h("flow/switch",{values:{selection:p(U)},flows:z})}},C.push(N)}else if(P==="playAnimation")C.push(h("animation/start",{configuration:{animation:x.animation??x.clip??0}}));else if(P==="stopAnimation")C.push(h("animation/stop"));else if(P==="sendEvent"){let V={};for(let[k,L]of Object.entries(x.values||{}))V[k]={value:L};C.push(h("event/send",{configuration:{event:s(String(x.event??x.id??"custom"))},values:V}))}}if(!C.length)return null;if(C.length===1)return C[0];let d={};return C.forEach((S,x)=>{d[String(x)]={node:S}}),h("flow/sequence",{flows:d})},w=(v,_,C)=>{let d=b(_);d!==null&&h(v,{...C?{configuration:C}:{},flows:{out:{node:d}}})};if(g.onSelect&&w("pointer/onSelect",g.onSelect,{nodeIndex:y}),g.onHoverIn&&w("pointer/onHoverIn",g.onHoverIn,{nodeIndex:y}),g.onHoverOut&&w("pointer/onHoverOut",g.onHoverOut,{nodeIndex:y}),g.onStart&&w("event/onStart",g.onStart),g.onReceive&&typeof g.onReceive=="object")for(let[v,_]of Object.entries(g.onReceive))w("event/receive",_,{event:s(v)})}return o.length?{graphs:[{declarations:r,nodes:o,variables:c,events:m}],graph:0}:null}var sn='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).',an="Security Error: client-side scripts require allow-client-scripts opt-in.";var nt="__THREE_LIVE_REGISTRY__";function j(){let n=typeof globalThis<"u"?globalThis:{};if(!n[nt]){let e={plugins:[],decoders:new Map};try{Object.defineProperty(n,nt,{value:e,writable:!1,configurable:!1,enumerable:!1})}catch{n[nt]=e}}return n[nt]}var Z=j().plugins;function cn(n){let e=j().plugins;e.some(t=>t.name===n.name)||e.push(n)}function un(){return j().plugins}function J(){let n=new Float32Array(16);return n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function ln(n,e,t,r,i){let o=1/Math.tan(e/2);n.fill(0),n[0]=o/t,n[5]=o,n[11]=-1;let c=1/(r-i);return n[10]=(i+r)*c,n[14]=2*i*r*c,n}function rt(n,e,t,r){let[i,o,c]=e,[m,u,a]=r,[s,h,l]=t,p=i-s,f=o-h,T=c-l,M=Math.hypot(p,f,T);M<=1e-5?(p=0,f=0,T=1):(p/=M,f/=M,T/=M);let R=u*T-a*f,I=a*p-m*T,y=m*f-u*p;M=Math.hypot(R,I,y),M<=1e-5?(R=0,I=0,y=0):(R/=M,I/=M,y/=M);let E=f*y-T*I,g=T*R-p*y,A=p*I-f*R;return M=Math.hypot(E,g,A),M<=1e-5?(E=0,g=0,A=0):(E/=M,g/=M,A/=M),n[0]=R,n[1]=E,n[2]=p,n[3]=0,n[4]=I,n[5]=g,n[6]=f,n[7]=0,n[8]=y,n[9]=A,n[10]=T,n[11]=0,n[12]=-(R*i+I*o+y*c),n[13]=-(E*i+g*o+A*c),n[14]=-(p*i+f*o+T*c),n[15]=1,n}function re(n,e,t){let r=e[0],i=e[1],o=e[2],c=e[3],m=e[4],u=e[5],a=e[6],s=e[7],h=e[8],l=e[9],p=e[10],f=e[11],T=e[12],M=e[13],R=e[14],I=e[15],y=t[0],E=t[1],g=t[2],A=t[3];return n[0]=y*r+E*m+g*h+A*T,n[1]=y*i+E*u+g*l+A*M,n[2]=y*o+E*a+g*p+A*R,n[3]=y*c+E*s+g*f+A*I,y=t[4],E=t[5],g=t[6],A=t[7],n[4]=y*r+E*m+g*h+A*T,n[5]=y*i+E*u+g*l+A*M,n[6]=y*o+E*a+g*p+A*R,n[7]=y*c+E*s+g*f+A*I,y=t[8],E=t[9],g=t[10],A=t[11],n[8]=y*r+E*m+g*h+A*T,n[9]=y*i+E*u+g*l+A*M,n[10]=y*o+E*a+g*p+A*R,n[11]=y*c+E*s+g*f+A*I,y=t[12],E=t[13],g=t[14],A=t[15],n[12]=y*r+E*m+g*h+A*T,n[13]=y*i+E*u+g*l+A*M,n[14]=y*o+E*a+g*p+A*R,n[15]=y*c+E*s+g*f+A*I,n}function it(n,e,t,r){let i=e[0],o=e[1],c=e[2],m=e[3],u=i+i,a=o+o,s=c+c,h=i*u,l=i*a,p=i*s,f=o*a,T=o*s,M=c*s,R=m*u,I=m*a,y=m*s,E=r[0],g=r[1],A=r[2];return n[0]=(1-(f+M))*E,n[1]=(l+y)*E,n[2]=(p-I)*E,n[3]=0,n[4]=(l-y)*g,n[5]=(1-(h+M))*g,n[6]=(T+R)*g,n[7]=0,n[8]=(p+I)*A,n[9]=(T-R)*A,n[10]=(1-(h+f))*A,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function ae(n,e){let t=e[0],r=e[1],i=e[2],o=e[4],c=e[5],m=e[6],u=e[8],a=e[9],s=e[10],h=s*c-m*a,l=-s*o+m*u,p=a*o-c*u,f=t*h+r*l+i*p;return f&&(f=1/f,n[0]=h*f,n[1]=(-s*r+i*a)*f,n[2]=(m*r-i*c)*f,n[3]=l*f,n[4]=(s*t-i*u)*f,n[5]=(-m*t+i*o)*f,n[6]=p*f,n[7]=(-a*t+r*u)*f,n[8]=(c*t-r*o)*f),n}function hn(n,e){let t=e[0],r=e[1],i=e[2],o=e[3],c=e[4],m=e[5],u=e[6],a=e[7],s=e[8],h=e[9],l=e[10],p=e[11],f=e[12],T=e[13],M=e[14],R=e[15],I=t*m-r*c,y=t*u-i*c,E=t*a-o*c,g=r*u-i*m,A=r*a-o*m,b=i*a-o*u,w=s*T-h*f,v=s*M-l*f,_=s*R-p*f,C=h*M-l*T,d=h*R-p*T,S=l*R-p*M,x=I*S-y*d+E*C+g*_-A*v+b*w;return x?(x=1/x,n[0]=(m*S-u*d+a*C)*x,n[1]=(i*d-r*S-o*C)*x,n[2]=(T*b-M*A+R*g)*x,n[3]=(l*A-h*b-p*g)*x,n[4]=(u*_-c*S-a*v)*x,n[5]=(t*S-i*_+o*v)*x,n[6]=(M*E-f*b-R*y)*x,n[7]=(s*b-l*E+p*y)*x,n[8]=(c*d-m*_+a*w)*x,n[9]=(r*_-t*d-o*w)*x,n[10]=(f*A-T*E+R*I)*x,n[11]=(h*E-s*A-p*I)*x,n[12]=(m*v-c*C-u*w)*x,n[13]=(t*C-r*v+i*w)*x,n[14]=(T*y-f*g-M*I)*x,n[15]=(s*g-h*y+l*I)*x,n):null}function zt(n,e,t,r,i){let o=i[0]*e+i[4]*t+i[8]*r+i[12],c=i[1]*e+i[5]*t+i[9]*r+i[13],m=i[2]*e+i[6]*t+i[10]*r+i[14],u=i[3]*e+i[7]*t+i[11]*r+i[15],a=u!==0?1/u:1;n[0]=o*a,n[1]=c*a,n[2]=m*a}function mn(n,e,t,r,i,o,c,m,u,a,s,h,l,p,f,T,M=0){let R=a-c,I=s-m,y=h-u,E=l-c,g=p-m,A=f-u,b=i*A-o*g,w=o*E-r*A,v=r*g-i*E,_=R*b+I*w+y*v;if(_>-1e-7&&_<1e-7)return!1;let C=1/_,d=n-c,S=e-m,x=t-u,P=C*(d*b+S*w+x*v);if(P<-M||P>1+M)return!1;let B=S*y-x*I,V=x*R-d*y,k=d*I-S*R,L=C*(r*B+i*V+o*k);if(L<-M||P+L>1+M)return!1;let U=C*(E*B+g*V+A*k);if(U>1e-4&&U<T.distance){T.distance=U,T.point=[n+r*U,e+i*U,t+o*U];let D=I*A-y*g,O=y*E-R*A,N=R*g-I*E,z=Math.hypot(D,O,N)||1;return T.normal=[D/z,O/z,N/z],!0}return!1}function ot(n,e){let t=Array.isArray(n?.nodes)?n.nodes.length:0,r=[];for(let s=0;s<t;s++)r.push(J());if(t===0)return r;let i=new Set;for(let s of n.nodes)if(Array.isArray(s.children))for(let h of s.children)i.add(h);let o=new Set,c=128,m=(s,h,l=0)=>{if(l>c||s<0||s>=t||o.has(s))return;o.add(s);let p=n.nodes[s];if(!p)return;let f=J();if(e&&e[s])f.set(e[s]);else if(p.matrix&&p.matrix.length===16)f.set(p.matrix);else{let M=p.translation||[0,0,0],R=p.rotation||[0,0,0,1],I=p.scale||[1,1,1];it(f,R,M,I)}let T=r[s];if(h?re(T,h,f):T.set(f),Array.isArray(p.children))for(let M of p.children)typeof M=="number"&&m(M,T,l+1)},u=[],a=n.scenes&&n.scenes[n.scene!==void 0?n.scene:0];if(a&&Array.isArray(a.nodes))u.push(...a.nodes);else for(let s=0;s<t;s++)i.has(s)||u.push(s);for(let s of u)m(s,null);for(let s=0;s<t;s++)!i.has(s)&&!u.includes(s)&&m(s,null);return r}function nr(n){return new TextDecoder().decode(n)}var pn=j().decoders;function rr(n,e){pn.set(n.toLowerCase(),e)}function ke(n){return pn.get(n.toLowerCase())}function bn(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 l=t.getUint8(0);throw l===123||l===32||l===10||l===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 o=t.getUint32(8,!0),c=12,m=null,u=null;for(;c+8<=o&&c+8<=e.byteLength;){let l=t.getUint32(c,!0),p=t.getUint32(c+4,!0),f=c+8;if(f+l>e.byteLength)throw new Error(`Truncated GLB chunk: required ${f+l} bytes, buffer has ${e.byteLength}`);if(p===1313821514){let T=new Uint8Array(e,f,l),M=nr(T);m=JSON.parse(M,(R,I)=>R==="__proto__"||R==="constructor"||R==="prototype"?void 0:I)}else p===5130562&&(u=e.slice(f,f+l));c=f+l}if(!m)throw new Error("Missing JSON chunk in GLB");let a=m.extensionsRequired||[];if(a.includes("KHR_draco_mesh_compression")&&!ke("draco"))throw new Error("Model requires KHR_draco_mesh_compression. Register a decoder via ThreeLiveElement.registerDecoder('draco', decoder).");if(a.includes("EXT_meshopt_compression")&&!ke("meshopt"))throw new Error("Model requires EXT_meshopt_compression. Register a decoder via ThreeLiveElement.registerDecoder('meshopt', decoder).");if(a.includes("KHR_texture_basisu")&&!ke("ktx2"))throw new Error("Model requires KHR_texture_basisu. Register a decoder via ThreeLiveElement.registerDecoder('ktx2', decoder).");let s=u||new ArrayBuffer(0),h={gltf:m,bin:s,animations:[]};for(let l of Z)l.onParseGLB?.(h);return h}function ir(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 Oe(n){if(ir(n))return n;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return bn(n);throw new TypeError("Invalid 3D model input: expected GLBData ({ gltf, bin }) or binary GLB (ArrayBuffer / ArrayBufferView).")}var yn=`#version 300 es
|
|
17
|
+
"use strict";var ThreeEngine=(()=>{var zt=Object.defineProperty;var Kn=Object.getOwnPropertyDescriptor;var Zn=Object.getOwnPropertyNames;var Jn=Object.prototype.hasOwnProperty;var Qn=(n,e)=>{for(var t in e)zt(n,t,{get:e[t],enumerable:!0})},er=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Zn(e))!Jn.call(n,i)&&i!==t&&zt(n,i,{get:()=>e[i],enumerable:!(r=Kn(e,i))||r.enumerable});return n};var tr=n=>er(zt({},"__esModule",{value:!0}),n);var $r={};Qn($r,{AmbientLight:()=>qe,BoxGeometry:()=>We,BufferAttribute:()=>X,BufferGeometry:()=>ce,Camera:()=>Ke,CapsuleGeometry:()=>Nt,CircleGeometry:()=>Ot,Clock:()=>Ct,Color:()=>he,ConeGeometry:()=>xt,CylinderGeometry:()=>Ee,DirectionalLight:()=>_t,DodecahedronGeometry:()=>Ut,Euler:()=>Xe,Float32BufferAttribute:()=>pt,Group:()=>At,HemisphereLight:()=>Je,IcosahedronGeometry:()=>Lt,Light:()=>Me,Material:()=>me,MathUtils:()=>Ln,Matrix3:()=>dt,Matrix4:()=>ye,Mesh:()=>Ue,MeshBasicMaterial:()=>Et,MeshLambertMaterial:()=>Mt,MeshPhongMaterial:()=>Rt,MeshPhysicalMaterial:()=>St,MeshStandardMaterial:()=>Se,Object3D:()=>ie,OctahedronGeometry:()=>Pt,PerspectiveCamera:()=>Fe,PlaneGeometry:()=>gt,PointLight:()=>je,PolyhedronFallbackGeometry:()=>_e,Quaternion:()=>Ge,RawShaderMaterial:()=>Hn,RectAreaLight:()=>Xn,RingGeometry:()=>kt,Scene:()=>Ae,SceneQuotaValidator:()=>pe,ShaderMaterial:()=>Ze,SphereGeometry:()=>$e,SpotLight:()=>Bt,THREE:()=>Qe,TetrahedronGeometry:()=>Ft,Texture:()=>Ye,TextureLoader:()=>Tt,TorusGeometry:()=>vt,TorusKnotGeometry:()=>wt,Uint16BufferAttribute:()=>bt,Uint32BufferAttribute:()=>yt,Vector2:()=>mt,Vector3:()=>j,Vector4:()=>ft,WebGLRenderer:()=>Dt,authorScriptRunner:()=>zn,buildSandboxWorkerSource:()=>rn,clearAuthorWarnings:()=>on,default:()=>Wr,exportSceneToCanvas3D:()=>en,exportSceneToGLB:()=>tn,exportSceneToUSDZ:()=>Pn,generateUSDZ:()=>Yt,getAllowClientScripts:()=>Nn,getAuthorWarnings:()=>Vn,getSandboxEngineSrc:()=>nn,getSandboxIframeSrc:()=>Fn,glbToUSDZ:()=>lt,isAllowedSandboxEngineUrl:()=>Re,noopProxy:()=>Pe,sceneToCanvas3D:()=>Ie,sceneToGLB:()=>ze,sceneToUSDZ:()=>Le,setAllowClientScripts:()=>Fr,setSandboxEngineSrc:()=>Ir,setSandboxIframeSrc:()=>Pr,threeAuthorPlugin:()=>He,threeMicroPlugin:()=>Gr,toTrustedWorkerScriptURL:()=>Un,validateSandboxWorkerMessage:()=>sn,warnUnsupported:()=>se});function nt(n,e,t){let r=[],i=new Map,s=[],c=[],m=[],u=new Map,o=b=>{let w=i.get(b);return w===void 0&&(w=r.length,r.push({op:b}),i.set(b,w)),w},a=b=>{let w=u.get(b);return w===void 0&&(w=m.length,m.push({id:b}),u.set(b,w)),w},h=(b,w={})=>s.push({declaration:o(b),...w})-1,l=(b,w,y)=>c.push({id:b,type:w,value:y})-1,d=b=>({node:b,socket:"value"}),f=t?.interactivity??t?.gltfExtensions?.KHR_interactivity;if(f&&typeof f=="object"){let b=Array.isArray(f.graphs)?f.graphs[f.graph??0]:f;if(b&&Array.isArray(b.nodes)){let w=Array.isArray(b.declarations)?b.declarations:[];for(let y of w)y?.op&&o(y.op);Array.isArray(b.variables)&&c.push(...b.variables);for(let y of b.events||[])y?.id&&a(y.id);for(let y of b.nodes){if(!y||typeof y!="object")continue;let R=y.op||(typeof y.declaration=="number"?w[y.declaration]?.op:"");s.push(R?{...y,declaration:o(R)}:{...y})}}}let T=(b,w,y="translation")=>y==="baseColorFactor"||y==="metallicFactor"||y==="roughnessFactor"?`/materials/${Math.max(0,w)}/pbrMetallicRoughness/${y}`:y==="emissiveFactor"||y==="alphaCutoff"?`/materials/${Math.max(0,w)}/${y}`:y==="visible"?`/nodes/${b}/extensions/KHR_node_visibility/visible`:`/nodes/${b}/${y}`,A=new Map;n.forEach((b,w)=>{typeof b?.name=="string"&&!A.has(b.name)&&A.set(b.name,w)});let S=(b,w)=>typeof b.target=="string"&&A.has(b.target)?A.get(b.target):typeof b.targetNode=="number"?b.targetNode:w,L=b=>{let w=n[b];return(typeof w?.mesh=="number"?e[w.mesh]?.primitives?.[0]?.material:0)??0};for(let b=0;b<n.length;b++){let w=n[b],y=w?.extras?.interactivity;if(!y||typeof y!="object")continue;let R=(typeof w.mesh=="number"?e[w.mesh]?.primitives?.[0]?.material:0)??0,p=M=>{let _=Array.isArray(M)?M:[M],I=[];for(let v=0;v<_.length;v++){let x=_[v];if(!x||typeof x!="object")continue;let P=x.action||"interpolate",D=typeof x.duration=="number"?x.duration:.35;if(P==="toggleTransform"){let V=x.property==="rotation"||x.property==="scale"?x.property:"translation",N=V==="rotation"?w.rotation||[0,0,0,1]:V==="scale"?w.scale||[1,1,1]:w.translation||[0,0,0],U=`/nodes/${b}/${V}`,F=l(`__toggle_${b}_${v}`,"bool",!1),C=h("variable/get",{configuration:{variable:F}}),B=h("math/not",{values:{a:d(C)}}),k=h("variable/set",{configuration:{variable:F},values:{value:d(B)}}),z=h("pointer/interpolate",{configuration:{pointer:U},values:{value:{value:Array.isArray(x.to)?x.to:N},duration:{value:D}}}),O=h("pointer/interpolate",{configuration:{pointer:U},values:{value:{value:Array.isArray(x.from)?x.from:N},duration:{value:D}}});s[k].flows={out:{node:h("flow/branch",{values:{condition:d(C)},flows:{true:{node:z},false:{node:O}}})}},I.push(k)}else if(P==="interpolate"){let V=x.to??x.value;if(V===void 0)continue;let N={value:{value:V},duration:{value:D}};x.from!==void 0&&(N.from={value:x.from}),I.push(h("pointer/interpolate",{configuration:{pointer:typeof x.pointer=="string"?x.pointer:T(S(x,b),L(S(x,b)),x.property)},values:N}))}else if(P==="setProperty"){if(x.value===void 0)continue;I.push(h("pointer/set",{configuration:{pointer:typeof x.pointer=="string"?x.pointer:T(S(x,b),L(S(x,b)),x.property)},values:{value:{value:x.value}}}))}else if(P==="toggleVisibility"){let V=S(x,b),N=l(`__vis_${V}_${v}`,"bool",!0),U=h("variable/get",{configuration:{variable:N}}),F=h("math/not",{values:{a:d(U)}}),C=h("variable/set",{configuration:{variable:N},values:{value:d(F)}});s[C].flows={out:{node:h("pointer/set",{configuration:{pointer:`/nodes/${V}/extensions/KHR_node_visibility/visible`},values:{value:d(U)}})}},I.push(C)}else if(P==="cycleMaterialColor"&&Array.isArray(x.colors)&&x.colors.length>0){let V=typeof x.duration=="number"?x.duration:.25,N=`/materials/${Math.max(0,R)}/pbrMetallicRoughness/baseColorFactor`,U=l(`__color_idx_${b}_${v}`,"int",0),F=h("variable/get",{configuration:{variable:U}}),C=h("math/add",{values:{a:d(F),b:{value:1}}}),B=h("math/rem",{values:{a:d(C),b:{value:x.colors.length}}}),k=h("variable/set",{configuration:{variable:U},values:{value:d(B)}}),z={};for(let O=0;O<x.colors.length;O++){let H=x.colors[O],Y=Array.isArray(H)&&H.length>=3?[H[0],H[1],H[2],H[3]??1]:[1,1,1,1];z[String(O)]={node:V>0?h("pointer/interpolate",{configuration:{pointer:N},values:{value:{value:Y},duration:{value:V}}}):h("pointer/set",{configuration:{pointer:N},values:{value:{value:Y}}})}}s[k].flows={out:{node:h("flow/switch",{values:{selection:d(F)},flows:z})}},I.push(k)}else if(P==="playAnimation")I.push(h("animation/start",{configuration:{animation:x.animation??x.clip??0}}));else if(P==="stopAnimation")I.push(h("animation/stop"));else if(P==="sendEvent"){let V={};for(let[N,U]of Object.entries(x.values||{}))V[N]={value:U};I.push(h("event/send",{configuration:{event:a(String(x.event??x.id??"custom"))},values:V}))}}if(!I.length)return null;if(I.length===1)return I[0];let g={};return I.forEach((v,x)=>{g[String(x)]={node:v}}),h("flow/sequence",{flows:g})},E=(M,_,I)=>{let g=p(_);g!==null&&h(M,{...I?{configuration:I}:{},flows:{out:{node:g}}})};if(y.onSelect&&E("pointer/onSelect",y.onSelect,{nodeIndex:b}),y.onHoverIn&&E("pointer/onHoverIn",y.onHoverIn,{nodeIndex:b}),y.onHoverOut&&E("pointer/onHoverOut",y.onHoverOut,{nodeIndex:b}),y.onStart&&E("event/onStart",y.onStart),y.onReceive&&typeof y.onReceive=="object")for(let[M,_]of Object.entries(y.onReceive))E("event/receive",_,{event:a(M)})}return s.length?{graphs:[{declarations:r,nodes:s,variables:c,events:m}],graph:0}:null}var an='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).',cn="Security Error: client-side scripts require allow-client-scripts opt-in.";var rt="__THREE_LIVE_REGISTRY__";function J(){let n=typeof globalThis<"u"?globalThis:{};if(!n[rt]){let e={plugins:[],decoders:new Map};try{Object.defineProperty(n,rt,{value:e,writable:!1,configurable:!1,enumerable:!1})}catch{n[rt]=e}}return n[rt]}var K=J().plugins;function un(n){let e=J().plugins;e.some(t=>t.name===n.name)||e.push(n)}function ln(){return J().plugins}function q(){let n=new Float32Array(16);return n[0]=1,n[5]=1,n[10]=1,n[15]=1,n}function it(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 c=1/(r-i);return n[10]=(i+r)*c,n[14]=2*i*r*c,n}function Ce(n,e,t,r){let[i,s,c]=e,[m,u,o]=r,[a,h,l]=t,d=i-a,f=s-h,T=c-l,A=Math.hypot(d,f,T);A<=1e-5?(d=0,f=0,T=1):(d/=A,f/=A,T/=A);let S=u*T-o*f,L=o*d-m*T,b=m*f-u*d;A=Math.hypot(S,L,b),A<=1e-5?(S=0,L=0,b=0):(S/=A,L/=A,b/=A);let w=f*b-T*L,y=T*S-d*b,R=d*L-f*S;return A=Math.hypot(w,y,R),A<=1e-5?(w=0,y=0,R=0):(w/=A,y/=A,R/=A),n[0]=S,n[1]=w,n[2]=d,n[3]=0,n[4]=L,n[5]=y,n[6]=f,n[7]=0,n[8]=b,n[9]=R,n[10]=T,n[11]=0,n[12]=-(S*i+L*s+b*c),n[13]=-(w*i+y*s+R*c),n[14]=-(d*i+f*s+T*c),n[15]=1,n}function re(n,e,t){let r=e[0],i=e[1],s=e[2],c=e[3],m=e[4],u=e[5],o=e[6],a=e[7],h=e[8],l=e[9],d=e[10],f=e[11],T=e[12],A=e[13],S=e[14],L=e[15],b=t[0],w=t[1],y=t[2],R=t[3];return n[0]=b*r+w*m+y*h+R*T,n[1]=b*i+w*u+y*l+R*A,n[2]=b*s+w*o+y*d+R*S,n[3]=b*c+w*a+y*f+R*L,b=t[4],w=t[5],y=t[6],R=t[7],n[4]=b*r+w*m+y*h+R*T,n[5]=b*i+w*u+y*l+R*A,n[6]=b*s+w*o+y*d+R*S,n[7]=b*c+w*a+y*f+R*L,b=t[8],w=t[9],y=t[10],R=t[11],n[8]=b*r+w*m+y*h+R*T,n[9]=b*i+w*u+y*l+R*A,n[10]=b*s+w*o+y*d+R*S,n[11]=b*c+w*a+y*f+R*L,b=t[12],w=t[13],y=t[14],R=t[15],n[12]=b*r+w*m+y*h+R*T,n[13]=b*i+w*u+y*l+R*A,n[14]=b*s+w*o+y*d+R*S,n[15]=b*c+w*a+y*f+R*L,n}function st(n,e,t,r){let i=e[0],s=e[1],c=e[2],m=e[3],u=i+i,o=s+s,a=c+c,h=i*u,l=i*o,d=i*a,f=s*o,T=s*a,A=c*a,S=m*u,L=m*o,b=m*a,w=r[0],y=r[1],R=r[2];return n[0]=(1-(f+A))*w,n[1]=(l+b)*w,n[2]=(d-L)*w,n[3]=0,n[4]=(l-b)*y,n[5]=(1-(h+A))*y,n[6]=(T+S)*y,n[7]=0,n[8]=(d+L)*R,n[9]=(T-S)*R,n[10]=(1-(h+f))*R,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function ae(n,e){let t=e[0],r=e[1],i=e[2],s=e[4],c=e[5],m=e[6],u=e[8],o=e[9],a=e[10],h=a*c-m*o,l=-a*s+m*u,d=o*s-c*u,f=t*h+r*l+i*d;return f&&(f=1/f,n[0]=h*f,n[1]=(-a*r+i*o)*f,n[2]=(m*r-i*c)*f,n[3]=l*f,n[4]=(a*t-i*u)*f,n[5]=(-m*t+i*s)*f,n[6]=d*f,n[7]=(-o*t+r*u)*f,n[8]=(c*t-r*s)*f),n}function hn(n,e){let t=e[0],r=e[1],i=e[2],s=e[3],c=e[4],m=e[5],u=e[6],o=e[7],a=e[8],h=e[9],l=e[10],d=e[11],f=e[12],T=e[13],A=e[14],S=e[15],L=t*m-r*c,b=t*u-i*c,w=t*o-s*c,y=r*u-i*m,R=r*o-s*m,p=i*o-s*u,E=a*T-h*f,M=a*A-l*f,_=a*S-d*f,I=h*A-l*T,g=h*S-d*T,v=l*S-d*A,x=L*v-b*g+w*I+y*_-R*M+p*E;return x?(x=1/x,n[0]=(m*v-u*g+o*I)*x,n[1]=(i*g-r*v-s*I)*x,n[2]=(T*p-A*R+S*y)*x,n[3]=(l*R-h*p-d*y)*x,n[4]=(u*_-c*v-o*M)*x,n[5]=(t*v-i*_+s*M)*x,n[6]=(A*w-f*p-S*b)*x,n[7]=(a*p-l*w+d*b)*x,n[8]=(c*g-m*_+o*E)*x,n[9]=(r*_-t*g-s*E)*x,n[10]=(f*R-T*w+S*L)*x,n[11]=(h*w-a*R-d*L)*x,n[12]=(m*M-c*I-u*E)*x,n[13]=(t*I-r*M+i*E)*x,n[14]=(T*b-f*y-A*L)*x,n[15]=(a*y-h*b+l*L)*x,n):null}function Vt(n,e,t,r,i){let s=i[0]*e+i[4]*t+i[8]*r+i[12],c=i[1]*e+i[5]*t+i[9]*r+i[13],m=i[2]*e+i[6]*t+i[10]*r+i[14],u=i[3]*e+i[7]*t+i[11]*r+i[15],o=u!==0?1/u:1;n[0]=s*o,n[1]=c*o,n[2]=m*o}function mn(n,e,t,r,i,s,c,m,u,o,a,h,l,d,f,T,A=0){let S=o-c,L=a-m,b=h-u,w=l-c,y=d-m,R=f-u,p=i*R-s*y,E=s*w-r*R,M=r*y-i*w,_=S*p+L*E+b*M;if(_>-1e-7&&_<1e-7)return!1;let I=1/_,g=n-c,v=e-m,x=t-u,P=I*(g*p+v*E+x*M);if(P<-A||P>1+A)return!1;let D=v*b-x*L,V=x*S-g*b,N=g*L-v*S,U=I*(r*D+i*V+s*N);if(U<-A||P+U>1+A)return!1;let F=I*(w*D+y*V+R*N);if(F>1e-4&&F<T.distance){T.distance=F,T.point=[n+r*F,e+i*F,t+s*F];let C=L*R-b*y,B=b*w-S*R,k=S*y-L*w,z=Math.hypot(C,B,k)||1;return T.normal=[C/z,B/z,k/z],!0}return!1}function ot(n,e){let t=Array.isArray(n?.nodes)?n.nodes.length:0,r=[];for(let a=0;a<t;a++)r.push(q());if(t===0)return r;let i=new Set;for(let a of n.nodes)if(Array.isArray(a.children))for(let h of a.children)i.add(h);let s=new Set,c=128,m=(a,h,l=0)=>{if(l>c||a<0||a>=t||s.has(a))return;s.add(a);let d=n.nodes[a];if(!d)return;let f=q();if(e&&e[a])f.set(e[a]);else if(d.matrix&&d.matrix.length===16)f.set(d.matrix);else{let A=d.translation||[0,0,0],S=d.rotation||[0,0,0,1],L=d.scale||[1,1,1];st(f,S,A,L)}let T=r[a];if(h?re(T,h,f):T.set(f),Array.isArray(d.children))for(let A of d.children)typeof A=="number"&&m(A,T,l+1)},u=[],o=n.scenes&&n.scenes[n.scene!==void 0?n.scene:0];if(o&&Array.isArray(o.nodes))u.push(...o.nodes);else for(let a=0;a<t;a++)i.has(a)||u.push(a);for(let a of u)m(a,null);for(let a=0;a<t;a++)!i.has(a)&&!u.includes(a)&&m(a,null);return r}function nr(n){return new TextDecoder().decode(n)}var pn=J().decoders;function rr(n,e){pn.set(n.toLowerCase(),e)}function Oe(n){return pn.get(n.toLowerCase())}function bn(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 l=t.getUint8(0);throw l===123||l===32||l===10||l===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),c=12,m=null,u=null;for(;c+8<=s&&c+8<=e.byteLength;){let l=t.getUint32(c,!0),d=t.getUint32(c+4,!0),f=c+8;if(f+l>e.byteLength)throw new Error(`Truncated GLB chunk: required ${f+l} bytes, buffer has ${e.byteLength}`);if(d===1313821514){let T=new Uint8Array(e,f,l),A=nr(T);m=JSON.parse(A,(S,L)=>S==="__proto__"||S==="constructor"||S==="prototype"?void 0:L)}else d===5130562&&(u=e.slice(f,f+l));c=f+l}if(!m)throw new Error("Missing JSON chunk in GLB");let o=m.extensionsRequired||[];if(o.includes("KHR_draco_mesh_compression")&&!Oe("draco"))throw new Error("Model requires KHR_draco_mesh_compression. Register a decoder via ThreeLiveElement.registerDecoder('draco', decoder).");if(o.includes("EXT_meshopt_compression")&&!Oe("meshopt"))throw new Error("Model requires EXT_meshopt_compression. Register a decoder via ThreeLiveElement.registerDecoder('meshopt', decoder).");if(o.includes("KHR_texture_basisu")&&!Oe("ktx2"))throw new Error("Model requires KHR_texture_basisu. Register a decoder via ThreeLiveElement.registerDecoder('ktx2', decoder).");let a=u||new ArrayBuffer(0),h={gltf:m,bin:a,animations:[]};for(let l of K)l.onParseGLB?.(h);return h}function ir(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 Be(n){if(ir(n))return n;if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))return bn(n);throw new TypeError("Invalid 3D model input: expected GLBData ({ gltf, bin }) or binary GLB (ArrayBuffer / ArrayBufferView).")}var yn=`#version 300 es
|
|
18
18
|
layout(location=0) in vec3 aPosition;
|
|
19
19
|
layout(location=1) in vec3 aNormal;
|
|
20
20
|
layout(location=2) in vec2 aUV;
|
|
@@ -45,6 +45,8 @@ uniform int uHasTexture,uHasMetallicRoughnessTexture,uHasNormalTexture,uHasOcclu
|
|
|
45
45
|
uniform float uNormalScale,uOcclusionStrength,uXrRawValueToMeters;
|
|
46
46
|
uniform mat4 uXrDepthUVTransform;
|
|
47
47
|
uniform vec2 uViewportSize;
|
|
48
|
+
uniform vec4 uViewport;
|
|
49
|
+
uniform vec3 uCameraFwd;
|
|
48
50
|
uniform int uToneMapping,uNumDirLights,uNumPointLights;
|
|
49
51
|
uniform vec3 uDirLightDir[2],uDirLightColor[2],uPointLightPos[2],uPointLightColor[2];
|
|
50
52
|
out vec4 fragColor;
|
|
@@ -195,29 +197,32 @@ color=color*(vec3(1.0)-ccF)+getStudioRadiance(R,uClearcoat.y)*ccF*uEnvIntensity;
|
|
|
195
197
|
color=applyToneMapping(color,uToneMapping);
|
|
196
198
|
float outAlpha=base.a;
|
|
197
199
|
if(uXrDepthEnabled==1){
|
|
198
|
-
vec2 normViewUV=gl_FragCoord.
|
|
200
|
+
vec2 normViewUV=vec2((gl_FragCoord.x-uViewport.x)/max(uViewport.z,1.0),1.0-(gl_FragCoord.y-uViewport.y)/max(uViewport.w,1.0));
|
|
199
201
|
vec2 depthUV=(uXrDepthUVTransform*vec4(normViewUV,0.0,1.0)).xy;
|
|
202
|
+
if(depthUV.x>=0.0&&depthUV.x<=1.0&&depthUV.y>=0.0&&depthUV.y<=1.0){
|
|
200
203
|
vec4 depthSample=texture(uXrDepthTex,depthUV);
|
|
201
|
-
float
|
|
202
|
-
float
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
float rawDepth=uXrDepthFormat==1?depthSample.r:(depthSample.r*255.0+depthSample.a*65280.0);
|
|
205
|
+
float realDepth=rawDepth*uXrRawValueToMeters;
|
|
206
|
+
float virtDepth=dot(uCameraFwd,uCameraFwd)>0.5?dot(vWorldPos-uCameraPos,uCameraFwd):length(uCameraPos-vWorldPos);
|
|
207
|
+
if(rawDepth>0.0&&(uXrDepthFormat==1||rawDepth<65500.0)&&realDepth>0.15&&realDepth<20.0&&virtDepth>realDepth+0.02){
|
|
208
|
+
float occAlpha=1.0-smoothstep(0.0,0.035,virtDepth-realDepth-0.02);
|
|
205
209
|
outAlpha*=occAlpha;
|
|
206
210
|
if(outAlpha<0.01)discard;
|
|
207
211
|
}
|
|
208
212
|
}
|
|
213
|
+
}
|
|
209
214
|
fragColor=vec4(color,outAlpha);
|
|
210
|
-
}`,
|
|
215
|
+
}`,sr=`#version 300 es
|
|
211
216
|
layout(location=0) in vec3 aPosition;
|
|
212
217
|
uniform mat4 uMVP;
|
|
213
|
-
void main(){gl_Position=uMVP*vec4(aPosition,1.0);}`,
|
|
218
|
+
void main(){gl_Position=uMVP*vec4(aPosition,1.0);}`,or=`#version 300 es
|
|
214
219
|
precision highp float;
|
|
215
220
|
uniform vec4 uColorId;
|
|
216
221
|
out vec4 fragColor;
|
|
217
|
-
void main(){fragColor=uColorId;}`;function fn(n,e,t){let r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,35713)){let i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error(`Shader compile error: ${i}`)}return r}function Ht(n,e,t){let r=fn(n,35633,e),i=fn(n,35632,t),o=n.createProgram();if(n.attachShader(o,r),n.attachShader(o,i),n.linkProgram(o),!n.getProgramParameter(o,35714)){let c=n.getProgramInfoLog(o);throw n.deleteProgram(o),new Error(`Program link error: ${c}`)}return o}function Xt(n,e,t){let r={};for(let i of t)r[i]=n.getUniformLocation(e,i);return r}var xn=["uMVP","uModel","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","uXrDepthTex","uXrDepthEnabled","uXrDepthFormat","uXrRawValueToMeters","uXrDepthUVTransform","uViewportSize"];function ar(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 Vt(n,e,t,r,i,o,c){if(r===void 0||!e.accessors?.[r])return null;let m=e.accessors[r],u=e.bufferViews[m.bufferView],a=(u.byteOffset||0)+(m.byteOffset||0),s=u.byteStride&&u.byteStride>o*4?u.byteStride>>2:o,h;if(s===o)h=new Float32Array(t,a,m.count*o);else{h=new Float32Array(m.count*o);let p=new Float32Array(t,u.byteOffset||0,Math.floor(u.byteLength/4)),f=(m.byteOffset||0)>>2;for(let T=0;T<m.count;T++){let M=f+T*s;for(let R=0;R<o;R++)h[T*o+R]=p[M+R]}}let l=n.createBuffer();return c.push(l),n.bindBuffer(34962,l),n.bufferData(34962,h,35044),n.enableVertexAttribArray(i),n.vertexAttribPointer(i,o,5126,!1,0,0),h}var ei=Object.freeze({maxMeshes:1e3,maxTextures:64,maxVertices:1e6,maxIndices:3e6}),vn=Object.freeze({maxMeshes:1/0,maxTextures:1/0,maxVertices:1/0,maxIndices:1/0});function dn(n,e,t=vn,r){if(!e||!e.gltf)throw new Error("Invalid GLBData passed to buildGpuScene: missing gltf object.");let{gltf:i,bin:o}=e,c=[],m=ot(i),u=[];if(Array.isArray(i.nodes))for(let w=0;w<i.nodes.length;w++){let v=i.nodes[w];v.mesh!==void 0&&i.meshes&&i.meshes[v.mesh]&&u.push({node:v,nodeIdx:w,meshIdx:v.mesh})}let a=u.length>0?u:(i.meshes||[]).map((w,v)=>({node:w,nodeIdx:-1,meshIdx:v})),s=[];if(Array.isArray(e.lights)&&e.lights.length>0)s.push(...e.lights);else if(i.extensions?.KHR_lights_punctual?.lights){let w=i.extensions.KHR_lights_punctual.lights;for(let v of w){let _=v.type==="directional"?"directional":v.type==="point"?"point":"ambient";s.push({type:_,color:v.color||[1,1,1],intensity:v.intensity!==void 0?v.intensity:1})}}if(s.length===0&&(s.push({type:"ambient",color:[1,1,1],intensity:.35}),s.push({type:"directional",color:[1,1,1],intensity:.85,direction:[.5,1,.8]})),a.length>t.maxMeshes)throw new Error(`SecurityError: GLB scene exceeds host mesh limit (${t.maxMeshes}). Found: ${a.length}`);let h=[];if(i.textures&&i.images){if(i.textures.length>t.maxTextures)throw new Error(`SecurityError: GLB scene exceeds host texture limit (${t.maxTextures}). Found: ${i.textures.length}`);for(let w=0;w<i.textures.length;w++){let v=i.textures[w],_=i.images[v.source];if(_){let C=n.createTexture();if(n.bindTexture(3553,C),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),_.bufferView!==void 0){let d=i.bufferViews[_.bufferView],S=o.slice(d.byteOffset||0,(d.byteOffset||0)+d.byteLength),x=new Blob([S],{type:_.mimeType||"image/png"});typeof createImageBitmap=="function"&&createImageBitmap(x).then(P=>{n.bindTexture(3553,C),n.texImage2D(3553,0,6408,6408,5121,P),n.generateMipmap(3553),r?.()}).catch(()=>{})}else if(_.uri){let d=ar(_.uri);if(d){let S=new Image;S.crossOrigin="anonymous",S.referrerPolicy="no-referrer",S.onload=()=>{n.bindTexture(3553,C),n.texImage2D(3553,0,6408,6408,5121,S),n.generateMipmap(3553),r?.()},S.src=d}else console.warn("[Three-Live Security] Blocked unsafe glTF image URI:",_.uri)}h.push(C)}else h.push(null)}}let l=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0],f=0,T=0;for(let w=0;w<a.length;w++){let v=a[w],_=i.meshes[v.meshIdx],C=v.nodeIdx>=0?m[v.nodeIdx]:J(),d=new Float32Array(9);ae(d,C);let S={name:v.node.name||_.name||`Mesh_${v.meshIdx}`,nodeIndex:v.nodeIdx,transform:C,normalMatrix:d,primitives:[],extras:v.node.extras||_.extras};for(let x of _.primitives||[]){if(x.extensions?.KHR_draco_mesh_compression){let $=ke("draco");$&&$.decodePrimitive(i,x,o)}let P=[],B=n.createVertexArray();n.bindVertexArray(B);let V=i.accessors[x.attributes.POSITION],k=Number(V?.count??0);if(!Number.isFinite(k)||k<0||f+k>t.maxVertices)throw new Error(`SecurityError: GLB scene exceeds host vertex limit (${t.maxVertices}).`);if(f+=k,V?.min&&V?.max)for(let $=0;$<3;$++){let ue=C[12+$],De=C[12+$];for(let be=0;be<3;be++){let Qe=C[be*4+$]*V.min[be],et=C[be*4+$]*V.max[be];ue+=Qe<et?Qe:et,De+=Qe>et?Qe:et}ue<l[$]&&(l[$]=ue),De>p[$]&&(p[$]=De)}let L=Vt(n,i,o,x.attributes.POSITION,0,3,P);Vt(n,i,o,x.attributes.NORMAL,1,3,P),Vt(n,i,o,x.attributes.TEXCOORD_0,2,2,P);let U=0,D=5123,O=null;if(x.indices!==void 0){let $=i.accessors[x.indices],De=(i.bufferViews[$.bufferView].byteOffset||0)+($.byteOffset||0);if(U=Number($.count??0),!Number.isFinite(U)||U<0||T+U>t.maxIndices)throw new Error(`SecurityError: GLB scene exceeds host index limit (${t.maxIndices}).`);T+=U,D=$.componentType===5125?5125||5125:5123||5123;let be=n.createBuffer();P.push(be),n.bindBuffer(34963,be),$.componentType===5125?(O=new Uint32Array(o,De,$.count),n.bufferData(34963,O,35044)):(O=new Uint16Array(o,De,$.count),n.bufferData(34963,O,35044))}else U=V.count;let N={};for(let $ of Z)if($.onBuildPrimitiveVAO){let ue=$.onBuildPrimitiveVAO(n,B,x,i,o);ue&&(N[$.name]=ue)}n.bindVertexArray(null);let z=i.materials&&x.material!==void 0?i.materials[x.material]:null,F=yn,H=gn,Y=!1;for(let $ of Z)if($.onResolveShader){let ue=$.onResolveShader(x,z,F,H);ue&&(F=ue.vs,H=ue.fs,Y=!0)}let W=Y?Ht(n,F,H):null,fe=W?Xt(n,W,xn):null,ee=z?.pbrMetallicRoughness,ne=ee?.baseColorFactor||[.8,.8,.8,1],ge=ee?.metallicFactor??.1,xe=ee?.roughnessFactor??.5,de=z?.extensions?.KHR_materials_clearcoat,se=de?de.clearcoatFactor??1:0,ve=Math.max(.04,de?.clearcoatRoughnessFactor??.04),Te=ee?.baseColorTexture!==void 0&&h[ee.baseColorTexture.index]?h[ee.baseColorTexture.index]:null,Ne=ee?.metallicRoughnessTexture!==void 0&&h[ee.metallicRoughnessTexture.index]?h[ee.metallicRoughnessTexture.index]:null,Wn=z?.normalTexture!==void 0&&h[z.normalTexture.index]?h[z.normalTexture.index]:null,$n=z?.normalTexture?.scale??1,Yn=z?.occlusionTexture!==void 0&&h[z.occlusionTexture.index]?h[z.occlusionTexture.index]:null,qn=z?.occlusionTexture?.strength??1,Kn=!!(z?.extensions?.KHR_materials_transmission||N.materials?.isTransmissive);S.primitives.push({vao:B,indexCount:U,indexType:D,baseColor:ne,metallic:ge,roughness:xe,clearcoat:se,clearcoatRoughness:ve,positions:L,indices:O,texture:Te,metallicRoughnessTexture:Ne,normalTexture:Wn,occlusionTexture:Yn,normalScale:$n,occlusionStrength:qn,buffers:P,materialIndex:x.material,pluginData:N,customProgram:W,customUniforms:fe,isTransmissive:Kn})}c.push(S)}isFinite(l[0])||(l=[-1,-1,-1]),isFinite(p[0])||(p=[1,1,1]);let M=[(l[0]+p[0])/2,(l[1]+p[1])/2,(l[2]+p[2])/2],R=p[0]-l[0],I=p[1]-l[1],y=p[2]-l[2],E=Math.max(Math.hypot(R,I,y)/2,.5),g=[l[0],l[1],l[2]],A=[p[0],p[1],p[2]],b=e.animations;if(!b){for(let w of Z)if(w.onParseGLB?.(e),e.animations){b=e.animations;break}}return b||(b=[]),{meshes:c,bounds:{center:M,radius:E,min:g,max:A},lights:s,animations:b,worldMatrices:m}}var st=class{constructor(e,t,r){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.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.gltf=null;this.worldMatrices=[];this.initialNodeTransforms=[];this.projMatrix=J();this.viewMatrix=J();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.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.xrDepthState={enabled:!1,texture:null,uvTransform:J(),rawValueToMeters:.001,format:0};this.container=e;let i,o;if(t&&typeof t.getContext=="function"?(i=t,o=r):(o=t,i=o?.canvas),!i){let u=e.querySelector("canvas");u||(u=document.createElement("canvas"),u.style.width="100%",u.style.height="100%",u.style.display="block",u.style.touchAction="none",e.prepend(u)),i=u}this.canvas=i,this.opts=o||{},this.opts.clearColor&&(this.clearColor=this.opts.clearColor);let c=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.opts.autoRotate!==void 0?this.autoRotate=this.opts.autoRotate&&!c:c&&(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.envIntensity=Math.max(0,Number(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=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.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 m=i.getContext("webgl2",{antialias:!0,alpha:!0,xrCompatible:!0});if(!m)throw new Error("WebGL2 not supported");this.gl=m,this.renderProg=Ht(m,yn,gn),this.pickProg=Ht(m,or,sr),this.uRender=Xt(m,this.renderProg,xn),this.uPick=Xt(m,this.pickProg,["uMVP","uColorId"]),this.setupPickingFbo(),this.setupEvents(),this.opts.environmentImage&&this.setEnvironmentImage(this.opts.environmentImage).catch(()=>{}),typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}static registerDecoder(e,t){rr(e,t)}static getDecoder(e){return ke(e)}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),o=Math.max(1,t);this.pickFboWidth=i,this.pickFboHeight=o,r.bindTexture(3553,this.pickTexture),r.texImage2D(3553,0,6408,i,o,0,6408,5121,null),r.bindRenderbuffer(36161,this.pickDepth),r.renderbufferStorage(36161,33189,i,o)}loadGLBData(e,t){let{meshes:r,bounds:i,lights:o,animations:c,worldMatrices:m}=dn(this.gl,e,t,()=>this.render());if(this.disposeMeshGpuResources(),this.meshes=r,this.bounds=i,this.turntableRotation=0,this.updateTurntableMatrix(),this.lights=o,this.animations=c||[],this.worldMatrices=m||[],this.gltf=e.gltf,this.initialNodeTransforms=[],Array.isArray(e.gltf?.nodes))for(let a of e.gltf.nodes)this.initialNodeTransforms.push({t:a.translation?[a.translation[0],a.translation[1],a.translation[2]]:[0,0,0],r:a.rotation?[a.rotation[0],a.rotation[1],a.rotation[2],a.rotation[3]]:[0,0,0,1],s:a.scale?[a.scale[0],a.scale[1],a.scale[2]]:[1,1,1]});this.autoplay&&this.animations.length>0&&this.playAnimation(this.animationName||void 0);for(let a of Z)a.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 u=e.exposure??e.environmentIntensity??e.gltf?.extras?.exposure??e.gltf?.extras?.environmentIntensity??e.gltf?.asset?.extras?.exposure??e.gltf?.asset?.extras?.environmentIntensity;u!==void 0&&(this.envIntensity=Math.max(0,Number(u))),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(bn(e))}loadModel(e){this.loadGLBData(Oe(e))}setBackdropGLB(e,t){if(this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[],!e){this.update(0),this.render();return}let r=Oe(e),{meshes:i}=dn(this.gl,r,vn,()=>this.render());if(t)for(let o of i)o.transform[12]+=t[0],o.transform[13]+=t[1],o.transform[14]+=t[2],ae(o.normalMatrix,o.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),ae(r.normalMatrix,r.transform))}}bindLights(e=this.uRender){let t=this.gl,r=[.28,.28,.28],i=[],o=[],c=[],m=[];for(let u of this.lights){let a=u.color||[1,1,1],s=u.intensity!==void 0?u.intensity:1;if(u.type==="ambient")r=[a[0]*s,a[1]*s,a[2]*s];else if(u.type==="directional"&&i.length<6){let h=u.direction||[.5,1,.8];i.push(h[0],h[1],h[2]),o.push(a[0]*s,a[1]*s,a[2]*s)}else if(u.type==="point"&&c.length<6){let h=u.position||[0,0,0];c.push(h[0],h[1],h[2]),m.push(a[0]*s,a[1]*s,a[2]*s)}}i.length===0&&(i.push(.5,1,.8),o.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,o)),t.uniform1i(e.uNumPointLights,c.length/3),c.length>0&&(t.uniform3fv(e.uPointLightPos,c),t.uniform3fv(e.uPointLightColor,m)),t.uniform1f(e.uEnvIntensity,this.envIntensity)}setExposure(e){this.envIntensity=Math.max(0,Number(e))}getExposure(){return this.envIntensity}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=e}getToneMapping(){return this.toneMapping}async setEnvironmentImage(e){for(let t of Z)if(t.setEnvironmentImage){await t.setEnvironmentImage(this,e);return}}async setSkyboxImage(e){for(let t of Z)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(s=>s.primitives.filter(h=>h.materialIndex===r||e.length===1&&h.materialIndex===void 0)),o=i[0],c=o?[...o.baseColor]:t.pbrMetallicRoughness?.baseColorFactor||[.8,.8,.8,1],m=o?o.metallic:t.pbrMetallicRoughness?.metallicFactor??.1,u=o?o.roughness:t.pbrMetallicRoughness?.roughnessFactor??.5,a={baseColorFactor:c,metallicFactor:m,roughnessFactor:u,setBaseColorFactor:s=>{let h=[s[0],s[1],s[2],s[3]??1];a.baseColorFactor=h,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.baseColorFactor=h);for(let l of i)l.baseColor=h;this.render()},setMetallicFactor:s=>{a.metallicFactor=s,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.metallicFactor=s);for(let h of i)h.metallic=s;this.render()},setRoughnessFactor:s=>{a.roughnessFactor=s,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=s);for(let h of i)h.roughness=s;this.render()}};return{name:t.name||`Material_${r}`,pbrMetallicRoughness:a}})}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)}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 Z)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 o=this.clampDistance(r);this.initialDistance=o,this.customDistance=!0,this.targetDistance=o,this.currDistance=o}else if(i!==void 0&&i>0){let o=this.clampDistance(this.bounds.radius*2.5/i);this.initialDistance=o,this.customDistance=!0,this.targetDistance=o,this.currDistance=o}else{this.customDistance=!1;let o=this.clampDistance(this.distanceMode==="absolute"?3:this.bounds.radius*2.5);this.initialDistance=o,this.targetDistance=o,this.currDistance=o}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();re(r,this.projMatrix,this.viewMatrix);let[i,o,c]=e,m=t?t[0]:0,u=t?t[1]:0,a=t?t[2]:0,s=this.modelRootMatrix;s&&(i=s[0]*e[0]+s[4]*e[1]+s[8]*e[2]+s[12],o=s[1]*e[0]+s[5]*e[1]+s[9]*e[2]+s[13],c=s[2]*e[0]+s[6]*e[1]+s[10]*e[2]+s[14],t&&(m=s[0]*t[0]+s[4]*t[1]+s[8]*t[2],u=s[1]*t[0]+s[5]*t[1]+s[9]*t[2],a=s[2]*t[0]+s[6]*t[1]+s[10]*t[2]));let h=r[0]*i+r[4]*o+r[8]*c+r[12],l=r[1]*i+r[5]*o+r[9]*c+r[13],p=r[2]*i+r[6]*o+r[10]*c+r[14],f=r[3]*i+r[7]*o+r[11]*c+r[15];if(f<=1e-4)return{x:0,y:0,z:1,visible:!1};let T=h/f,M=l/f,R=p/f,I=this.canvas.getBoundingClientRect(),y=I.width||this.canvas.clientWidth||this.canvas.width||300,E=I.height||this.canvas.clientHeight||this.canvas.height||150,g=(T*.5+.5)*y,A=(-M*.5+.5)*E,b=T>=-1.1&&T<=1.1&&M>=-1.1&&M<=1.1&&R>=-1&&R<=1;if(b&&t){let w=this.customTarget||this.bounds.center,v=w[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),_=w[1]+this.currDistance*Math.sin(this.currPhi),C=w[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta),d=[i-v,o-_,c-C];m*d[0]+u*d[1]+a*d[2]>.05&&(b=!1)}return{x:g,y:A,z:R,visible:b}}setSelectedMesh(e){this.selectedMeshName=e||""}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,o=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,o),this.isPanning||t.button===2||t.shiftKey||this.activePointers.size===2){let c=[this.viewMatrix[0],this.viewMatrix[4],this.viewMatrix[8]],m=[this.viewMatrix[1],this.viewMatrix[5],this.viewMatrix[9]],u=this.customTarget?[...this.customTarget]:[...this.bounds.center],a=this.currDistance/Math.max(e.clientHeight||300,1)*1.5;u[0]+=(-i*c[0]+o*m[0])*a,u[1]+=(-i*c[1]+o*m[1])*a,u[2]+=(-i*c[2]+o*m[2])*a,this.customTarget=u}else this.targetTheta=this.clampTheta(this.targetTheta-i*.008),this.targetPhi=this.clampPhi(this.targetPhi+o*.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))),o=Math.floor((t.clientY-r.top)*(e.height/Math.max(r.height,1)));this.performMeshPick(i,o,!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.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(),o=r.width||300,c=r.height||300,m=i.width>0?Math.floor((e-i.left)*(o/i.width)):Math.floor(e),u=i.height>0?Math.floor((t-i.top)*(c/i.height)):Math.floor(t);return this.performMeshPick(m,u,!1)}performMeshPick(e,t,r=!0){if(this.meshes.length===0)return null;let i=this.gl,o=Math.max(1,this.canvas.width||300),c=Math.max(1,this.canvas.height||300),m=J();re(m,this.projMatrix,this.viewMatrix);let u=[],a=Math.max(0,Math.min(o-1,e)),s=Math.max(0,Math.min(c-1,c-1-t));if(this.pickFbo&&i){(this.pickFboWidth!==o||this.pickFboHeight!==c)&&this.resizePickingFbo(o,c),i.bindFramebuffer(36160,this.pickFbo),i.viewport(0,0,o,c),i.enable(2929),i.clearColor(0,0,0,0),i.clear(16384|256),i.useProgram(this.pickProg);for(let b=0;b<this.meshes.length;b++){let w=this.meshes[b];if(w.visible===!1||w.isPluginMesh)continue;let v=b+1,_=(v&255)/255,C=(v>>8&255)/255,d=(v>>16&255)/255;i.uniform4f(this.uPick.uColorId,_,C,d,1),re(this.modelMatrix,this.modelRootMatrix,w.transform),re(this.mvpMatrix,m,this.modelMatrix),i.uniformMatrix4fv(this.uPick.uMVP,!1,this.mvpMatrix);for(let S of w.primitives)i.bindVertexArray(S.vao),i.drawElements(4,S.indexCount,S.indexType,0)}let g=new Uint8Array(4);i.readPixels(a,s,1,1,6408,5121,g),i.bindFramebuffer(36160,null);let A=g[0]+(g[1]<<8)+(g[2]<<16);A>0&&A<=this.meshes.length&&(u=[this.meshes[A-1]])}u.length===0&&(u=this.meshes.filter(g=>g.visible!==!1));let h=null,l=1/0,p=[0,0,0],f=[0,1,0],T=this.customTarget||this.bounds.center,M=T[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),R=T[1]+this.currDistance*Math.sin(this.currPhi),I=T[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta);for(let g of u){re(this.modelMatrix,this.modelRootMatrix,g.transform),re(this.mvpMatrix,m,this.modelMatrix);let A=J();if(!hn(A,this.mvpMatrix))continue;let b=(a+.5)/o*2-1,w=(s+.5)/c*2-1,v=[0,0,0],_=[0,0,0];zt(v,b,w,-1,A),zt(_,b,w,1,A);let C=_[0]-v[0],d=_[1]-v[1],S=_[2]-v[2],x=Math.hypot(C,d,S)||1,P=C/x,B=d/x,V=S/x,k={distance:1/0,point:[0,0,0],normal:[0,1,0]};if((U=>{for(let D of g.primitives){if(!D.positions)continue;let O=D.positions,N=D.indices,z=Math.floor(N?N.length/3:O.length/9);for(let F=0;F<z;F++){let H=N?N[F*3]:F*3,Y=N?N[F*3+1]:F*3+1,W=N?N[F*3+2]:F*3+2;mn(v[0],v[1],v[2],P,B,V,O[H*3],O[H*3+1],O[H*3+2],O[Y*3],O[Y*3+1],O[Y*3+2],O[W*3],O[W*3+1],O[W*3+2],k,U)}}})(1e-4),isFinite(k.distance)){let U=k.point[0],D=k.point[1],O=k.point[2],N=this.modelMatrix,z=N[0]*U+N[4]*D+N[8]*O+N[12],F=N[1]*U+N[5]*D+N[9]*O+N[13],H=N[2]*U+N[6]*D+N[10]*O+N[14],Y=z-M,W=F-R,fe=H-I,ee=Math.hypot(Y,W,fe);if(ee<l){ae(this.normalMatrix,this.modelMatrix);let ne=this.normalMatrix,ge=k.normal[0],xe=k.normal[1],de=k.normal[2],se=ne[0]*ge+ne[3]*xe+ne[6]*de,ve=ne[1]*ge+ne[4]*xe+ne[7]*de,Te=ne[2]*ge+ne[5]*xe+ne[8]*de,Ne=Math.hypot(se,ve,Te)||1;se/=Ne,ve/=Ne,Te/=Ne,se*Y+ve*W+Te*fe>0&&(se=-se,ve=-ve,Te=-Te),h=g,l=Math.round(ee*1e3)/1e3,p=[Math.round(z*1e3)/1e3,Math.round(F*1e3)/1e3,Math.round(H*1e3)/1e3],f=[Math.round(se*1e3)/1e3,Math.round(ve*1e3)/1e3,Math.round(Te*1e3)/1e3]}}}if(!h)return null;let E={meshIndex:this.meshes.indexOf(h),meshName:h.name,nodeIndex:h.nodeIndex,distance:l,hitPoint:p,normal:f,screenX:e,screenY:t};if(r){for(let g of Z)g.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}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))}start(){if(this.animFrameId!==null)return;this.lastTime=performance.now();let e=t=>{let r=Math.min((t-this.lastTime)/1e3,.1);this.lastTime=t,this.isVisible&&(this.resize(),this.update(r),this.render()),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],o=this.modelRootMatrix;o[0]=e,o[1]=0,o[2]=-t,o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=t,o[9]=0,o[10]=e,o[11]=0,o[12]=r-(e*r+t*i),o[13]=0,o[14]=i-(-t*r+e*i),o[15]=1}setVisible(e){this.isVisible=e}update(e){for(let l of Z)l.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 l of Z)l.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;let r=(this.canvas.width||1)/(this.canvas.height||1),i=this.backdropMeshes.length>0?Math.max(this.bounds.radius*20,120):this.bounds.radius*20;ln(this.projMatrix,this.fov,r,.1,i);let o=this.customTarget||this.bounds.center,c=o[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),m=o[1]+this.currDistance*Math.sin(this.currPhi),u=o[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta);rt(this.viewMatrix,[c,m,u],o,[0,1,0]),re(this.mvpMatrix,this.projMatrix,this.viewMatrix),ae(this.normalMatrix,this.modelMatrix);let a=Math.round((this.currTheta*180/Math.PI%360+360)%360),s=Math.round(this.currPhi*180/Math.PI),h=Math.round(this.bounds.radius*2.5/this.currDistance*100)/100;if(Math.abs(a-this.lastReportedTheta)>=1||Math.abs(s-this.lastReportedPhi)>=1||Math.abs(h-this.lastReportedZoom)>=.02){this.lastReportedTheta=a,this.lastReportedPhi=s,this.lastReportedZoom=h;let l={theta:a,phi:s,zoom:h,distance:Math.round(this.currDistance*100)/100};this.opts.onCameraChange&&this.opts.onCameraChange(l),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("cameraChange",{bubbles:!0,detail:l}))}}renderXRView(e,t,r,i){this.onBeforeRenderXRView&&this.onBeforeRenderXRView(e);let o=e?.transform?.inverse?.matrix||this.viewMatrix,c=e?.projectionMatrix||this.projMatrix,m=e?.transform?.position,u=m?[m.x,m.y,m.z]:[0,1.6,0];r&&t&&this.modelRootMatrix.set(t),this.render({viewMatrix:o,projMatrix:c,eyePos:u,viewport:i,eye:e?.eye||"none",clear:e?.eye!=="right"})}render(e){let t=this.gl,r=this.canvas.width,i=this.canvas.height;e?.viewport?(t.viewport(e.viewport[0],e.viewport[1],e.viewport[2],e.viewport[3]),r=e.viewport[2],i=e.viewport[3]):t.viewport(0,0,this.canvas.width,this.canvas.height),t.enable(2929),(!e||e.clear!==!1)&&(t.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),t.clear(16384|256));let o=J();re(o,e?.projMatrix??this.projMatrix,e?.viewMatrix??this.viewMatrix);let c=this.toneMapping==="reinhard"?1:this.toneMapping==="none"?2:0,m=this.customTarget||this.bounds.center,u=e?e.eyePos[0]:m[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),a=e?e.eyePos[1]:m[1]+this.currDistance*Math.sin(this.currPhi),s=e?e.eyePos[2]:m[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta);for(let M of Z)M.onBeforeDrawScene?.(this,t,o,[u,a,s],c);if(this.meshes.length===0&&this.backdropMeshes.length===0)return;let h=e?.eye||"none",l=!1,p=this.backdropMeshes.length,f=p>0?[...this.backdropMeshes,...this.meshes]:this.meshes,T=M=>{for(let R=0;R<f.length;R++){let I=f[R];if(I.visible===!1)continue;let y=this.selectedMeshName!==""&&I.name===this.selectedMeshName;R<p?this.modelMatrix.set(I.transform):re(this.modelMatrix,this.modelRootMatrix,I.transform),re(this.mvpMatrix,o,this.modelMatrix),ae(I.normalMatrix,this.modelMatrix);let E=I.extras?.xr?.stereo||I.userData?.xr?.stereo,g=0,A=0,b=1,w=1;E==="sbs"?(b=.5,g=h==="right"?.5:0):E==="ou"&&(w=.5,A=h==="right"?.5:0);for(let v of I.primitives){let _=!!v.isTransmissive;if(!M&&_){l=!0;continue}if(M&&!_)continue;let C=v.customProgram||this.renderProg,d=v.customUniforms||this.uRender;t.useProgram(C),t.uniform1i(d.uToneMapping,c),t.uniform1f(d.uEnvIntensity,this.envIntensity),t.uniform3f(d.uCameraPos,u,a,s),t.uniform1f(d.uEmissive,y?1:0),t.uniformMatrix4fv(d.uMVP,!1,this.mvpMatrix),t.uniformMatrix4fv(d.uModel,!1,this.modelMatrix),t.uniformMatrix3fv(d.uNormalMatrix,!1,I.normalMatrix),d.uUvTransform&&t.uniform4f(d.uUvTransform,g,A,b,w),d.uViewportSize&&t.uniform2f(d.uViewportSize,Math.max(1,r),Math.max(1,i)),this.xrDepthState.enabled&&this.xrDepthState.texture?(t.activeTexture(33989),t.bindTexture(3553,this.xrDepthState.texture),d.uXrDepthTex&&t.uniform1i(d.uXrDepthTex,5),d.uXrDepthEnabled&&t.uniform1i(d.uXrDepthEnabled,1),d.uXrDepthFormat&&t.uniform1i(d.uXrDepthFormat,this.xrDepthState.format||0),d.uXrRawValueToMeters&&t.uniform1f(d.uXrRawValueToMeters,this.xrDepthState.rawValueToMeters),d.uXrDepthUVTransform&&t.uniformMatrix4fv(d.uXrDepthUVTransform,!1,this.xrDepthState.uvTransform)):d.uXrDepthEnabled&&t.uniform1i(d.uXrDepthEnabled,0),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);for(let S of Z)S.onBeforeDrawPrimitive?.(t,C,v,I,this.worldMatrices||[],this.gltf);t.uniform4fv(d.uBaseColor,v.baseColor),t.uniform1f(d.uMetallic,v.metallic),t.uniform1f(d.uRoughness,v.roughness),d.uClearcoat&&t.uniform2f(d.uClearcoat,v.clearcoat??0,v.clearcoatRoughness??.04),v.texture?(t.activeTexture(33984),t.bindTexture(3553,v.texture),t.uniform1i(d.uBaseColorTexture,0),t.uniform1i(d.uHasTexture,1)):t.uniform1i(d.uHasTexture,0),v.metallicRoughnessTexture?(t.activeTexture(33985),t.bindTexture(3553,v.metallicRoughnessTexture),t.uniform1i(d.uMetallicRoughnessTexture,1),t.uniform1i(d.uHasMetallicRoughnessTexture,1)):t.uniform1i(d.uHasMetallicRoughnessTexture,0),v.normalTexture?(t.activeTexture(33986),t.bindTexture(3553,v.normalTexture),t.uniform1i(d.uNormalTexture,2),t.uniform1i(d.uHasNormalTexture,1),t.uniform1f(d.uNormalScale,v.normalScale)):t.uniform1i(d.uHasNormalTexture,0),v.occlusionTexture?(t.activeTexture(33987),t.bindTexture(3553,v.occlusionTexture),t.uniform1i(d.uOcclusionTexture,3),t.uniform1i(d.uHasOcclusionTexture,1),t.uniform1f(d.uOcclusionStrength,v.occlusionStrength)):t.uniform1i(d.uHasOcclusionTexture,0),t.bindVertexArray(v.vao),t.drawElements(4,v.indexCount,v.indexType,0)}}};if(T(!1),l){for(let M of Z)M.onBeforeTransmissivePass?.(t,this);T(!0)}for(let M of Z)M.onAfterRender?.(t,this,o)}disposeMeshListGpuResources(e){let t=this.gl;for(let r of e)for(let i of r.primitives){if(i.vao&&t.deleteVertexArray(i.vao),i.buffers)for(let o of i.buffers)t.deleteBuffer(o);i.texture&&t.deleteTexture(i.texture),i.metallicRoughnessTexture&&t.deleteTexture(i.metallicRoughnessTexture),i.normalTexture&&t.deleteTexture(i.normalTexture),i.occlusionTexture&&t.deleteTexture(i.occlusionTexture),i.customProgram&&t.deleteProgram(i.customProgram)}}disposeMeshGpuResources(){this.disposeMeshListGpuResources(this.meshes),this.meshes=[]}disposeGpuResources(){let e=this.gl;this.disposeMeshGpuResources(),this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[];for(let t of Z)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()}};st.registerPlugin=cn,st.getRegisteredPlugins=un;function cr(n){return n+3&-4}function ur(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 Ce(n,e){n.updateMatrixWorld(!0);let t=[],r=0,i=[],o=[],c=[],m=[],u=new Set,a=[],s=[],h=new Map,l=[];function p(b,w){let v=new Uint8Array(b.buffer,b.byteOffset,b.byteLength),_=cr(v.byteLength),C=new Uint8Array(_);C.set(v),t.push(C);let d=i.length;return i.push({buffer:0,byteOffset:r,byteLength:v.byteLength,target:w}),r+=_,d}function f(b,w,v,_,C,d,S){let x=p(b,v),P=o.length,B={bufferView:x,byteOffset:0,componentType:_,count:C,type:w};return d&&(B.min=d),S&&(B.max=S),o.push(B),P}n.traverse(b=>{(b.isLight||b.color&&b.intensity!==void 0)&&l.push({type:b.type,color:[b.color.r,b.color.g,b.color.b],intensity:b.intensity,position:[b.position.x,b.position.y,b.position.z]})});let T=[];function M(b){let w={name:b.name||""},v=b.position,_=b.quaternion,C=b.scale;if((v.x||v.y||v.z)&&(w.translation=[v.x,v.y,v.z]),(_.x||_.y||_.z||_.w!==1)&&(w.rotation=[_.x,_.y,_.z,_.w]),(C.x!==1||C.y!==1||C.z!==1)&&(w.scale=[C.x,C.y,C.z]),b.userData&&Object.keys(b.userData).length>0&&(w.extras=JSON.parse(JSON.stringify(b.userData,(S,x)=>{if(!(S==="__proto__"||S==="prototype"||S==="constructor"))return typeof x=="function"?void 0:x})),b.userData.xr)){let S=ur(b.userData.xr);w.extensions={...w.extensions||{},MOZ_hubs_components:S,ANDROID_xr_scenecore:S},j().xrTraitSerializer?.gltfNode(w,b.userData.xr),u.add("MOZ_hubs_components").add("ANDROID_xr_scenecore")}if(b.geometry){let S=b.geometry,x=S.attributes.position;if(x&&x.count>0){let P=[1/0,1/0,1/0],B=[-1/0,-1/0,-1/0];for(let U=0;U<x.count;U++){let D=x.getX(U),O=x.getY(U),N=x.getZ(U);D<P[0]&&(P[0]=D),D>B[0]&&(B[0]=D),O<P[1]&&(P[1]=O),O>B[1]&&(B[1]=O),N<P[2]&&(P[2]=N),N>B[2]&&(B[2]=N)}let k={attributes:{POSITION:f(x.array,"VEC3",34962,5126,x.count,P,B)}};if(S.attributes.normal&&(k.attributes.NORMAL=f(S.attributes.normal.array,"VEC3",34962,5126,S.attributes.normal.count)),S.attributes.uv&&(k.attributes.TEXCOORD_0=f(S.attributes.uv.array,"VEC2",34962,5126,S.attributes.uv.count)),S.index){let U=S.index.array instanceof Uint32Array;k.indices=f(S.index.array,"SCALAR",34963,U?5125:5123,S.index.count)}if(b.material){let U=h.get(b.material);if(U===void 0){U=s.length,h.set(b.material,U);let D=b.material,O={name:D.name||"",pbrMetallicRoughness:{baseColorFactor:[D.color.r,D.color.g,D.color.b,D.opacity],metallicFactor:D.metalness,roughnessFactor:D.roughness},doubleSided:D.side===2||D.doubleSided};if(D.emissive&&(D.emissive.r>0||D.emissive.g>0||D.emissive.b>0)){let z=D.emissiveIntensity??1;O.emissiveFactor=[D.emissive.r*z,D.emissive.g*z,D.emissive.b*z]}let N={};D.clearcoat>0&&(N.KHR_materials_clearcoat={clearcoatFactor:D.clearcoat,clearcoatRoughnessFactor:D.clearcoatRoughness||0}),D.sheen>0&&(N.KHR_materials_sheen={sheenColorFactor:D.sheenColor?[D.sheenColor.r,D.sheenColor.g,D.sheenColor.b]:[1,1,1],sheenRoughnessFactor:D.sheenRoughness||0}),D.transmission>0&&(N.KHR_materials_transmission={transmissionFactor:D.transmission}),D.thickness>0&&(N.KHR_materials_volume={thicknessFactor:D.thickness,attenuationDistance:D.attenuationDistance??1/0,attenuationColor:D.attenuationColor?[D.attenuationColor.r,D.attenuationColor.g,D.attenuationColor.b]:[1,1,1]}),D.ior!==void 0&&D.ior!==1.5&&(N.KHR_materials_ior={ior:D.ior}),D.dispersion>0&&(N.KHR_materials_dispersion={dispersion:D.dispersion}),D.iridescence>0&&(N.KHR_materials_iridescence={iridescenceFactor:D.iridescence,iridescenceIor:D.iridescenceIOR??1.3}),Object.keys(N).length>0&&(O.extensions=N),s.push(O)}k.material=U}let L=c.length;c.push({primitives:[k],name:b.name,...w.extras?{extras:w.extras}:{}}),w.mesh=L}}let d=m.length;if(m.push(w),a.push(b),b.children.length>0){w.children=[];for(let S of b.children)w.children.push(M(S))}return d}for(let b of n.children)T.push(M(b));let R=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),I=[];if(typeof R=="function"&&a.length>0){let b=e?.duration??4,w=e?.fps??15,v=Math.max(2,Math.round(b*w)+1),_=new Float32Array(v),C=a.map(L=>({px:L.position.x,py:L.position.y,pz:L.position.z,qx:L.quaternion.x,qy:L.quaternion.y,qz:L.quaternion.z,qw:L.quaternion.w,sx:L.scale.x,sy:L.scale.y,sz:L.scale.z})),d=a.map(()=>new Float32Array(v*3)),S=a.map(()=>new Float32Array(v*4)),x=a.map(()=>new Float32Array(v*3));for(let L=0;L<v;L++){let U=L/(v-1)*b;_[L]=U;try{R(U)}catch{}for(let D=0;D<a.length;D++){let O=a[D];d[D][L*3]=O.position.x,d[D][L*3+1]=O.position.y,d[D][L*3+2]=O.position.z,S[D][L*4]=O.quaternion.x,S[D][L*4+1]=O.quaternion.y,S[D][L*4+2]=O.quaternion.z,S[D][L*4+3]=O.quaternion.w,x[D][L*3]=O.scale.x,x[D][L*3+1]=O.scale.y,x[D][L*3+2]=O.scale.z}}for(let L=0;L<a.length;L++){let U=a[L],D=C[L];U.position.set(D.px,D.py,D.pz),U.quaternion.set(D.qx,D.qy,D.qz,D.qw),U.scale.set(D.sx,D.sy,D.sz)}n.updateMatrixWorld(!0);let P=null,B=()=>(P===null&&(P=f(_,"SCALAR",0,5126,v,[0],[b])),P),V=[],k=[];for(let L=0;L<a.length;L++){let U=C[L],D=!1,O=!1,N=!1;for(let z=0;z<v;z++)(Math.abs(d[L][z*3]-U.px)>1e-4||Math.abs(d[L][z*3+1]-U.py)>1e-4||Math.abs(d[L][z*3+2]-U.pz)>1e-4)&&(D=!0),(Math.abs(S[L][z*4]-U.qx)>1e-4||Math.abs(S[L][z*4+1]-U.qy)>1e-4||Math.abs(S[L][z*4+2]-U.qz)>1e-4||Math.abs(S[L][z*4+3]-U.qw)>1e-4)&&(O=!0),(Math.abs(x[L][z*3]-U.sx)>1e-4||Math.abs(x[L][z*3+1]-U.sy)>1e-4||Math.abs(x[L][z*3+2]-U.sz)>1e-4)&&(N=!0);if(D){let z=f(d[L],"VEC3",0,5126,v),F=V.length;V.push({input:B(),interpolation:"LINEAR",output:z}),k.push({sampler:F,target:{node:L,path:"translation"}})}if(O){let z=f(S[L],"VEC4",0,5126,v),F=V.length;V.push({input:B(),interpolation:"LINEAR",output:z}),k.push({sampler:F,target:{node:L,path:"rotation"}})}if(N){let z=f(x[L],"VEC3",0,5126,v),F=V.length;V.push({input:B(),interpolation:"LINEAR",output:z}),k.push({sampler:F,target:{node:L,path:"scale"}})}}k.length>0&&I.push({name:"ProceduralLoop",samplers:V,channels:k})}let y=tt(m,c,n.userData),E={asset:{version:"2.0",generator:"ThreeLiveConvert",extras:{environmentIntensity:n.environmentIntensity}},scenes:[{nodes:T}],scene:0,nodes:m,meshes:c,materials:s,accessors:o,bufferViews:i,buffers:[{byteLength:r}],...I.length>0?{animations:I}:{},...y||u.size>0?{extensionsUsed:[...y?["KHR_interactivity"]:[],...u]}:{},...y?{extensions:{KHR_interactivity:y}}:{}},g=new Uint8Array(r),A=0;for(let b of t)g.set(b,A),A+=b.byteLength;return{gltf:E,bin:g.buffer,lights:l,environmentIntensity:n.environmentIntensity}}function ct(n){return new TextEncoder().encode(n)}function Be(n,e){let{gltf:t,bin:r}=Ce(n,e),i=JSON.stringify(t),o=ct(i),c=(4-o.byteLength%4)%4,m=o.byteLength+c,u=20+m+8+r.byteLength,a=new Uint8Array(u),s=new DataView(a.buffer);s.setUint32(0,1179937895,!0),s.setUint32(4,2,!0),s.setUint32(8,u,!0),s.setUint32(12,m,!0),s.setUint32(16,1313821514,!0),a.set(o,20);for(let l=0;l<c;l++)a[20+o.byteLength+l]=32;let h=20+m;return s.setUint32(h,r.byteLength,!0),s.setUint32(h+4,5130562,!0),a.set(new Uint8Array(r),h+8),a}function lr(n,e){n.updateMatrixWorld(!0);let t=[];return n.traverse(r=>{if(r.geometry){let i=r.geometry,o=i.attributes.position;if(!o||o.count===0)return;let c=o.count,m=new Float32Array(c*3),u=r.matrixWorld.elements;for(let b=0;b<c;b++){let w=o.getX(b),v=o.getY(b),_=o.getZ(b);m[b*3]=u[0]*w+u[4]*v+u[8]*_+u[12],m[b*3+1]=u[1]*w+u[5]*v+u[9]*_+u[13],m[b*3+2]=u[2]*w+u[6]*v+u[10]*_+u[14]}let a;if(i.attributes.normal){let b=i.attributes.normal;a=new Float32Array(c*3);let w=new Float32Array(9);ae(w,u);for(let v=0;v<c;v++){let _=b.getX(v),C=b.getY(v),d=b.getZ(v),S=w[0]*_+w[3]*C+w[6]*d,x=w[1]*_+w[4]*C+w[7]*d,P=w[2]*_+w[5]*C+w[8]*d,B=Math.hypot(S,x,P)||1;a[v*3]=S/B,a[v*3+1]=x/B,a[v*3+2]=P/B}}let s;if(i.attributes.uv){let b=i.attributes.uv;s=new Float32Array(c*2);for(let w=0;w<c;w++)s[w*2]=b.getX(w),s[w*2+1]=b.getY(w)}let h;if(i.index)h=i.index.array;else{h=c>65535?new Uint32Array(c):new Uint16Array(c);for(let b=0;b<c;b++)h[b]=b}let l="DefaultMaterial",p=[.8,.8,.8],f=.5,T=.1,M=0,R=0,I=1.5,y=1,E=[0,0,0];if(r.material){let b=r.material;l=b.name||`Material_${t.length}`,b.color&&(p=[b.color.r,b.color.g,b.color.b]),typeof b.roughness=="number"&&(f=b.roughness),typeof b.metalness=="number"&&(T=b.metalness),typeof b.clearcoat=="number"&&(M=b.clearcoat),typeof b.clearcoatRoughness=="number"&&(R=b.clearcoatRoughness),typeof b.ior=="number"&&(I=b.ior);let w=typeof b.opacity=="number"?b.opacity:1,v=typeof b.transmission=="number"?b.transmission:0;if(y=w*(1-v),b.emissive&&(b.emissive.r>0||b.emissive.g>0||b.emissive.b>0)){let _=b.emissiveIntensity??1;E=[b.emissive.r*_,b.emissive.g*_,b.emissive.b*_]}}let g,A=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 A=="function"){let b=e?.duration??4,w=e?.fps??4,v=Math.max(2,Math.round(b*w)+1),_=[],C=[],d=[],S=[],x=[r.position.x,r.position.y,r.position.z],P=[r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w],B=[r.scale.x,r.scale.y,r.scale.z],V=!1;for(let k=0;k<v;k++){let L=k/(v-1)*b;_.push(L);try{A(L)}catch{}C.push([r.position.x,r.position.y,r.position.z]),d.push([r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w]),S.push([r.scale.x,r.scale.y,r.scale.z]),(Math.abs(r.position.x-x[0])>1e-4||Math.abs(r.position.y-x[1])>1e-4||Math.abs(r.position.z-x[2])>1e-4||Math.abs(r.quaternion.x-P[0])>1e-4||Math.abs(r.quaternion.y-P[1])>1e-4||Math.abs(r.quaternion.z-P[2])>1e-4||Math.abs(r.quaternion.w-P[3])>1e-4||Math.abs(r.scale.x-B[0])>1e-4)&&(V=!0)}r.position.set(x[0],x[1],x[2]),r.quaternion.set(P[0],P[1],P[2],P[3]),r.scale.set(B[0],B[1],B[2]),V&&(g={times:_,translations:C,rotations:d,scales:S})}t.push({name:r.name||`Mesh_${t.length}`,positions:m,indices:h,normals:a,uvs:s,materialName:l,color:p,roughness:f,metallic:T,clearcoat:M,clearcoatRoughness:R,ior:I,opacity:y,emissiveColor:E,xrTraits:r.userData?.xr,timeSamples:g})}}),t}function En(n){let e=[],t=n.gltf,r=n.bin,i=r instanceof ArrayBuffer?r:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),o=t.accessors||[],c=t.bufferViews||[],m=t.materials||[],u=t.meshes||[],a=t.nodes||[];function s(p){let f=o[p];if(!f)throw new Error(`Accessor ${p} not found`);let T=c[f.bufferView||0],M=(T.byteOffset||0)+(f.byteOffset||0),R=T.byteLength||0,I=i.slice(M,M+R);return{acc:f,buffer:I}}let h=new Map;if(a.length>0){let p=ot(t);for(let f=0;f<p.length;f++)h.set(f,p[f])}function l(p,f,T,M){let R=u[p];if(!R)return;let I=new Float32Array(9);ae(I,f);for(let y=0;y<(R.primitives||[]).length;y++){let E=R.primitives[y],g=E.attributes?.POSITION;if(g===void 0)continue;let{acc:A,buffer:b}=s(g),w=new Float32Array(b,0,A.count*3),v=new Float32Array(w.length);for(let F=0;F<A.count;F++){let H=w[F*3],Y=w[F*3+1],W=w[F*3+2];v[F*3]=f[0]*H+f[4]*Y+f[8]*W+f[12],v[F*3+1]=f[1]*H+f[5]*Y+f[9]*W+f[13],v[F*3+2]=f[2]*H+f[6]*Y+f[10]*W+f[14]}let _,C=E.attributes?.NORMAL;if(C!==void 0){let{acc:F,buffer:H}=s(C),Y=new Float32Array(H,0,F.count*3);_=new Float32Array(Y.length);for(let W=0;W<F.count;W++){let fe=Y[W*3],ee=Y[W*3+1],ne=Y[W*3+2],ge=I[0]*fe+I[3]*ee+I[6]*ne,xe=I[1]*fe+I[4]*ee+I[7]*ne,de=I[2]*fe+I[5]*ee+I[8]*ne,se=Math.hypot(ge,xe,de)||1;_[W*3]=ge/se,_[W*3+1]=xe/se,_[W*3+2]=de/se}}let d,S=E.attributes?.TEXCOORD_0;if(S!==void 0){let{acc:F,buffer:H}=s(S);d=new Float32Array(H,0,F.count*2)}let x;if(E.indices!==void 0){let{acc:F,buffer:H}=s(E.indices);F.componentType===5125?x=new Uint32Array(H,0,F.count):x=new Uint16Array(H,0,F.count);let Y=A.count;for(let W of x)if(W>=Y)throw new Error(`SecurityError: Index buffer value (${W}) out of vertex bounds [0, ${Y}).`)}else{let F=A.count;x=F>65535?new Uint32Array(F):new Uint16Array(F);for(let H=0;H<F;H++)x[H]=H}let P="DefaultMaterial",B=[.8,.8,.8],V=.5,k=.1,L=0,U=0,D=1.5,O=1,N=[0,0,0];if(E.material!==void 0&&m[E.material]){let F=m[E.material];P=F.name||`Material_${E.material}`;let H=F.pbrMetallicRoughness||{},Y=1;Array.isArray(H.baseColorFactor)&&(B=[H.baseColorFactor[0],H.baseColorFactor[1],H.baseColorFactor[2]],typeof H.baseColorFactor[3]=="number"&&(Y=H.baseColorFactor[3])),typeof H.roughnessFactor=="number"&&(V=H.roughnessFactor),typeof H.metallicFactor=="number"&&(k=H.metallicFactor),Array.isArray(F.emissiveFactor)&&F.emissiveFactor.length>=3&&(N=[F.emissiveFactor[0],F.emissiveFactor[1],F.emissiveFactor[2]]);let W=F.extensions||{};W.KHR_materials_clearcoat&&(L=W.KHR_materials_clearcoat.clearcoatFactor??0,U=W.KHR_materials_clearcoat.clearcoatRoughnessFactor??0),W.KHR_materials_ior&&typeof W.KHR_materials_ior.ior=="number"&&(D=W.KHR_materials_ior.ior);let fe=W.KHR_materials_transmission?.transmissionFactor??0;O=Y*(1-fe)}let z=(R.primitives||[]).length>1?`${T}_p${y}`:T;e.push({name:z,positions:v,indices:x,normals:_,uvs:d,materialName:P,color:B,roughness:V,metallic:k,clearcoat:L,clearcoatRoughness:U,ior:D,opacity:O,emissiveColor:N,xrTraits:M?.xr||R.extras?.xr})}}if(a.length>0)for(let p=0;p<a.length;p++){let f=a[p];if(f.mesh!==void 0&&f.mesh<u.length){let T=h.get(p)||J(),M=f.name||u[f.mesh].name||`Node_${p}`;l(f.mesh,T,M,f.extras)}}else{let p=J();for(let f=0;f<u.length;f++){let T=u[f].name||`Mesh_${f}`;l(f,p,T,u[f].extras)}}return e}function Gt(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 Tn(n){return String(n??"").replace(/[\x00-\x1f\x7f]/g,"").replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function G(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 wn(n){{let r=globalThis.__three_live_native_format_usda_points__;if(typeof r=="function")return r(n)}let e=n.length/3,t=new Array(e);for(let r=0;r<e;r++)t[r]=`(${G(n[r*3])}, ${G(n[r*3+1])}, ${G(n[r*3+2])})`;return t.join(", ")}function hr(n,e){{let r=globalThis.__three_live_native_format_usda_uvs__;if(typeof r=="function")return r(n)}let t=new Array(e);for(let r=0;r<e;r++)t[r]=`(${G(n[r*2])}, ${G(1-n[r*2+1])})`;return t.join(", ")}function mr(n){{let e=globalThis.__three_live_native_format_usda_ints__;if(typeof e=="function")return e(n)}return Array.from(n).join(", ")}function Wt(n){let e=new Map;for(let u of n){let a=Gt(u.materialName,"DefaultMaterial");e.has(a)||e.set(a,{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]})}let t=0,r=null;for(let u of n){if(u.timeSamples&&u.timeSamples.times.length>0){let a=u.timeSamples.times[u.timeSamples.times.length-1];a>t&&(t=a)}u.xrTraits?.anchor&&!r&&(r=u.xrTraits.anchor==="vertical"||u.xrTraits.anchor==="wall"?"vertical":"horizontal")}let i="";t>0&&(i=`startTimeCode = 0
|
|
222
|
+
void main(){fragColor=uColorId;}`;function fn(n,e,t){let r=n.createShader(e);if(n.shaderSource(r,t),n.compileShader(r),!n.getShaderParameter(r,35713)){let i=n.getShaderInfoLog(r);throw n.deleteShader(r),new Error(`Shader compile error: ${i}`)}return r}function Xt(n,e,t){let r=fn(n,35633,e),i=fn(n,35632,t),s=n.createProgram();if(n.attachShader(s,r),n.attachShader(s,i),n.linkProgram(s),!n.getProgramParameter(s,35714)){let c=n.getProgramInfoLog(s);throw n.deleteProgram(s),new Error(`Program link error: ${c}`)}return s}function Gt(n,e,t){let r={};for(let i of t)r[i]=n.getUniformLocation(e,i);return r}var xn=["uMVP","uModel","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","uXrDepthTex","uXrDepthEnabled","uXrDepthFormat","uXrRawValueToMeters","uXrDepthUVTransform","uViewportSize","uViewport","uCameraFwd"];function ar(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 Ht(n,e,t,r,i,s,c){if(r===void 0||!e.accessors?.[r])return null;let m=e.accessors[r],u=e.bufferViews[m.bufferView],o=(u.byteOffset||0)+(m.byteOffset||0),a=u.byteStride&&u.byteStride>s*4?u.byteStride>>2:s,h;if(a===s)h=new Float32Array(t,o,m.count*s);else{h=new Float32Array(m.count*s);let d=new Float32Array(t,u.byteOffset||0,Math.floor(u.byteLength/4)),f=(m.byteOffset||0)>>2;for(let T=0;T<m.count;T++){let A=f+T*a;for(let S=0;S<s;S++)h[T*s+S]=d[A+S]}}let l=n.createBuffer();return c.push(l),n.bindBuffer(34962,l),n.bufferData(34962,h,35044),n.enableVertexAttribArray(i),n.vertexAttribPointer(i,s,5126,!1,0,0),h}var ei=Object.freeze({maxMeshes:1e3,maxTextures:64,maxVertices:1e6,maxIndices:3e6}),vn=Object.freeze({maxMeshes:1/0,maxTextures:1/0,maxVertices:1/0,maxIndices:1/0});function dn(n,e,t=vn,r){if(!e||!e.gltf)throw new Error("Invalid GLBData passed to buildGpuScene: missing gltf object.");let{gltf:i,bin:s}=e,c=[],m=ot(i),u=[];if(Array.isArray(i.nodes))for(let E=0;E<i.nodes.length;E++){let M=i.nodes[E];M.mesh!==void 0&&i.meshes&&i.meshes[M.mesh]&&u.push({node:M,nodeIdx:E,meshIdx:M.mesh})}let o=u.length>0?u:(i.meshes||[]).map((E,M)=>({node:E,nodeIdx:-1,meshIdx:M})),a=[];if(Array.isArray(e.lights)&&e.lights.length>0)a.push(...e.lights);else if(i.extensions?.KHR_lights_punctual?.lights){let E=i.extensions.KHR_lights_punctual.lights;for(let M of E){let _=M.type==="directional"?"directional":M.type==="point"?"point":"ambient";a.push({type:_,color:M.color||[1,1,1],intensity:M.intensity!==void 0?M.intensity:1})}}if(a.length===0&&(a.push({type:"ambient",color:[1,1,1],intensity:.35}),a.push({type:"directional",color:[1,1,1],intensity:.85,direction:[.5,1,.8]})),o.length>t.maxMeshes)throw new Error(`SecurityError: GLB scene exceeds host mesh limit (${t.maxMeshes}). Found: ${o.length}`);let h=[];if(i.textures&&i.images){if(i.textures.length>t.maxTextures)throw new Error(`SecurityError: GLB scene exceeds host texture limit (${t.maxTextures}). Found: ${i.textures.length}`);for(let E=0;E<i.textures.length;E++){let M=i.textures[E],_=i.images[M.source];if(_){let I=n.createTexture();if(n.bindTexture(3553,I),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),_.bufferView!==void 0){let g=i.bufferViews[_.bufferView],v=s.slice(g.byteOffset||0,(g.byteOffset||0)+g.byteLength),x=new Blob([v],{type:_.mimeType||"image/png"});typeof createImageBitmap=="function"&&createImageBitmap(x).then(P=>{n.bindTexture(3553,I),n.texImage2D(3553,0,6408,6408,5121,P),n.generateMipmap(3553),r?.()}).catch(()=>{})}else if(_.uri){let g=ar(_.uri);if(g){let v=new Image;v.crossOrigin="anonymous",v.referrerPolicy="no-referrer",v.onload=()=>{n.bindTexture(3553,I),n.texImage2D(3553,0,6408,6408,5121,v),n.generateMipmap(3553),r?.()},v.src=g}else console.warn("[Three-Live Security] Blocked unsafe glTF image URI:",_.uri)}h.push(I)}else h.push(null)}}let l=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0],f=0,T=0;for(let E=0;E<o.length;E++){let M=o[E],_=i.meshes[M.meshIdx],I=M.nodeIdx>=0?m[M.nodeIdx]:q(),g=new Float32Array(9);ae(g,I);let v={name:M.node.name||_.name||`Mesh_${M.meshIdx}`,nodeIndex:M.nodeIdx,transform:I,normalMatrix:g,primitives:[],extras:M.node.extras||_.extras};for(let x of _.primitives||[]){if(x.extensions?.KHR_draco_mesh_compression){let $=Oe("draco");$&&$.decodePrimitive(i,x,s)}let P=[],D=n.createVertexArray();n.bindVertexArray(D);let V=i.accessors[x.attributes.POSITION],N=Number(V?.count??0);if(!Number.isFinite(N)||N<0||f+N>t.maxVertices)throw new Error(`SecurityError: GLB scene exceeds host vertex limit (${t.maxVertices}).`);if(f+=N,V?.min&&V?.max)for(let $=0;$<3;$++){let ue=I[12+$],De=I[12+$];for(let be=0;be<3;be++){let et=I[be*4+$]*V.min[be],tt=I[be*4+$]*V.max[be];ue+=et<tt?et:tt,De+=et>tt?et:tt}ue<l[$]&&(l[$]=ue),De>d[$]&&(d[$]=De)}let U=Ht(n,i,s,x.attributes.POSITION,0,3,P);Ht(n,i,s,x.attributes.NORMAL,1,3,P),Ht(n,i,s,x.attributes.TEXCOORD_0,2,2,P);let F=0,C=5123,B=null;if(x.indices!==void 0){let $=i.accessors[x.indices],De=(i.bufferViews[$.bufferView].byteOffset||0)+($.byteOffset||0);if(F=Number($.count??0),!Number.isFinite(F)||F<0||T+F>t.maxIndices)throw new Error(`SecurityError: GLB scene exceeds host index limit (${t.maxIndices}).`);T+=F,C=$.componentType===5125?5125||5125:5123||5123;let be=n.createBuffer();P.push(be),n.bindBuffer(34963,be),$.componentType===5125?(B=new Uint32Array(s,De,$.count),n.bufferData(34963,B,35044)):(B=new Uint16Array(s,De,$.count),n.bufferData(34963,B,35044))}else F=V.count;let k={};for(let $ of K)if($.onBuildPrimitiveVAO){let ue=$.onBuildPrimitiveVAO(n,D,x,i,s);ue&&(k[$.name]=ue)}n.bindVertexArray(null);let z=i.materials&&x.material!==void 0?i.materials[x.material]:null,O=yn,H=gn,Y=!1;for(let $ of K)if($.onResolveShader){let ue=$.onResolveShader(x,z,O,H);ue&&(O=ue.vs,H=ue.fs,Y=!0)}let W=Y?Xt(n,O,H):null,fe=W?Gt(n,W,xn):null,ee=z?.pbrMetallicRoughness,ne=ee?.baseColorFactor||[.8,.8,.8,1],ge=ee?.metallicFactor??.1,xe=ee?.roughnessFactor??.5,de=z?.extensions?.KHR_materials_clearcoat,oe=de?de.clearcoatFactor??1:0,ve=Math.max(.04,de?.clearcoatRoughnessFactor??.04),we=ee?.baseColorTexture!==void 0&&h[ee.baseColorTexture.index]?h[ee.baseColorTexture.index]:null,ke=ee?.metallicRoughnessTexture!==void 0&&h[ee.metallicRoughnessTexture.index]?h[ee.metallicRoughnessTexture.index]:null,Wn=z?.normalTexture!==void 0&&h[z.normalTexture.index]?h[z.normalTexture.index]:null,$n=z?.normalTexture?.scale??1,Yn=z?.occlusionTexture!==void 0&&h[z.occlusionTexture.index]?h[z.occlusionTexture.index]:null,qn=z?.occlusionTexture?.strength??1,jn=!!(z?.extensions?.KHR_materials_transmission||k.materials?.isTransmissive);v.primitives.push({vao:D,indexCount:F,indexType:C,baseColor:ne,metallic:ge,roughness:xe,clearcoat:oe,clearcoatRoughness:ve,positions:U,indices:B,texture:we,metallicRoughnessTexture:ke,normalTexture:Wn,occlusionTexture:Yn,normalScale:$n,occlusionStrength:qn,buffers:P,materialIndex:x.material,pluginData:k,customProgram:W,customUniforms:fe,isTransmissive:jn})}c.push(v)}isFinite(l[0])||(l=[-1,-1,-1]),isFinite(d[0])||(d=[1,1,1]);let A=[(l[0]+d[0])/2,(l[1]+d[1])/2,(l[2]+d[2])/2],S=d[0]-l[0],L=d[1]-l[1],b=d[2]-l[2],w=Math.max(Math.hypot(S,L,b)/2,.5),y=[l[0],l[1],l[2]],R=[d[0],d[1],d[2]],p=e.animations;if(!p){for(let E of K)if(E.onParseGLB?.(e),e.animations){p=e.animations;break}}return p||(p=[]),{meshes:c,bounds:{center:A,radius:w,min:y,max:R},lights:a,animations:p,worldMatrices:m}}var at=class{constructor(e,t,r){this.meshes=[];this.backdropMeshes=[];this.bounds={center:[0,0,0],radius:1,min:[-1,-1,-1],max:[1,1,1]};this.lights=[];this.modelRootMatrix=q();this.clearColor=[0,0,0,0];this.envIntensity=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.gltf=null;this.worldMatrices=[];this.initialNodeTransforms=[];this.projMatrix=q();this.viewMatrix=q();this.modelMatrix=q();this.mvpMatrix=q();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.stereoSBS=!1;this.renderErrorReported=!1;this.xrDepthState={enabled:!1,texture:null,uvTransform:q(),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 u=e.querySelector("canvas");u||(u=document.createElement("canvas"),u.style.width="100%",u.style.height="100%",u.style.display="block",u.style.touchAction="none",e.prepend(u)),i=u}this.canvas=i,this.opts=s||{},this.opts.clearColor&&(this.clearColor=this.opts.clearColor);let c=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.opts.autoRotate!==void 0?this.autoRotate=this.opts.autoRotate&&!c:c&&(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.envIntensity=Math.max(0,Number(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=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.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 m=i.getContext("webgl2",{antialias:!0,alpha:!0,xrCompatible:!0});if(!m)throw new Error("WebGL2 not supported");this.gl=m,this.renderProg=Xt(m,yn,gn),this.pickProg=Xt(m,sr,or),this.uRender=Gt(m,this.renderProg,xn),this.uPick=Gt(m,this.pickProg,["uMVP","uColorId"]),this.setupPickingFbo(),this.setupEvents(),this.opts.environmentImage&&this.setEnvironmentImage(this.opts.environmentImage).catch(()=>{}),typeof requestAnimationFrame<"u"&&this.opts.autoStart!==!1&&this.start()}static registerDecoder(e,t){rr(e,t)}static getDecoder(e){return Oe(e)}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){let{meshes:r,bounds:i,lights:s,animations:c,worldMatrices:m}=dn(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=c||[],this.worldMatrices=m||[],this.gltf=e.gltf,this.initialNodeTransforms=[],Array.isArray(e.gltf?.nodes))for(let o of e.gltf.nodes)this.initialNodeTransforms.push({t:o.translation?[o.translation[0],o.translation[1],o.translation[2]]:[0,0,0],r:o.rotation?[o.rotation[0],o.rotation[1],o.rotation[2],o.rotation[3]]:[0,0,0,1],s:o.scale?[o.scale[0],o.scale[1],o.scale[2]]:[1,1,1]});this.autoplay&&this.animations.length>0&&this.playAnimation(this.animationName||void 0);for(let o of K)o.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 u=e.exposure??e.environmentIntensity??e.gltf?.extras?.exposure??e.gltf?.extras?.environmentIntensity??e.gltf?.asset?.extras?.exposure??e.gltf?.asset?.extras?.environmentIntensity;u!==void 0&&(this.envIntensity=Math.max(0,Number(u))),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(bn(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(Be(e))}setBackdropGLB(e,t){if(this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[],!e){this.update(0),this.render();return}let r=Be(e),{meshes:i}=dn(this.gl,r,vn,()=>this.render());if(t)for(let s of i)s.transform[12]+=t[0],s.transform[13]+=t[1],s.transform[14]+=t[2],ae(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),ae(r.normalMatrix,r.transform))}}bindLights(e=this.uRender){let t=this.gl,r=[.28,.28,.28],i=[],s=[],c=[],m=[];for(let u of this.lights){let o=u.color||[1,1,1],a=u.intensity!==void 0?u.intensity:1;if(u.type==="ambient")r=[o[0]*a,o[1]*a,o[2]*a];else if(u.type==="directional"&&i.length<6){let h=u.direction||[.5,1,.8];i.push(h[0],h[1],h[2]),s.push(o[0]*a,o[1]*a,o[2]*a)}else if(u.type==="point"&&c.length<6){let h=u.position||[0,0,0];c.push(h[0],h[1],h[2]),m.push(o[0]*a,o[1]*a,o[2]*a)}}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,c.length/3),c.length>0&&(t.uniform3fv(e.uPointLightPos,c),t.uniform3fv(e.uPointLightColor,m)),t.uniform1f(e.uEnvIntensity,this.envIntensity)}setExposure(e){this.envIntensity=Math.max(0,Number(e))}getExposure(){return this.envIntensity}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=e}getToneMapping(){return this.toneMapping}async setEnvironmentImage(e){for(let t of K)if(t.setEnvironmentImage){await t.setEnvironmentImage(this,e);return}}async setSkyboxImage(e){for(let t of K)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(a=>a.primitives.filter(h=>h.materialIndex===r||e.length===1&&h.materialIndex===void 0)),s=i[0],c=s?[...s.baseColor]:t.pbrMetallicRoughness?.baseColorFactor||[.8,.8,.8,1],m=s?s.metallic:t.pbrMetallicRoughness?.metallicFactor??.1,u=s?s.roughness:t.pbrMetallicRoughness?.roughnessFactor??.5,o={baseColorFactor:c,metallicFactor:m,roughnessFactor:u,setBaseColorFactor:a=>{let h=[a[0],a[1],a[2],a[3]??1];o.baseColorFactor=h,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.baseColorFactor=h);for(let l of i)l.baseColor=h;this.render()},setMetallicFactor:a=>{o.metallicFactor=a,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.metallicFactor=a);for(let h of i)h.metallic=a;this.render()},setRoughnessFactor:a=>{o.roughnessFactor=a,t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=a);for(let h of i)h.roughness=a;this.render()}};return{name:t.name||`Material_${r}`,pbrMetallicRoughness:o}})}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)}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 K)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=q();re(r,this.projMatrix,this.viewMatrix);let[i,s,c]=e,m=t?t[0]:0,u=t?t[1]:0,o=t?t[2]:0,a=this.modelRootMatrix;a&&(i=a[0]*e[0]+a[4]*e[1]+a[8]*e[2]+a[12],s=a[1]*e[0]+a[5]*e[1]+a[9]*e[2]+a[13],c=a[2]*e[0]+a[6]*e[1]+a[10]*e[2]+a[14],t&&(m=a[0]*t[0]+a[4]*t[1]+a[8]*t[2],u=a[1]*t[0]+a[5]*t[1]+a[9]*t[2],o=a[2]*t[0]+a[6]*t[1]+a[10]*t[2]));let h=r[0]*i+r[4]*s+r[8]*c+r[12],l=r[1]*i+r[5]*s+r[9]*c+r[13],d=r[2]*i+r[6]*s+r[10]*c+r[14],f=r[3]*i+r[7]*s+r[11]*c+r[15];if(f<=1e-4)return{x:0,y:0,z:1,visible:!1};let T=h/f,A=l/f,S=d/f,L=this.canvas.getBoundingClientRect(),b=L.width||this.canvas.clientWidth||this.canvas.width||300,w=L.height||this.canvas.clientHeight||this.canvas.height||150,y=(T*.5+.5)*b,R=(-A*.5+.5)*w,p=T>=-1.1&&T<=1.1&&A>=-1.1&&A<=1.1&&S>=-1&&S<=1;if(p&&t){let E=this.customTarget||this.bounds.center,M=E[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),_=E[1]+this.currDistance*Math.sin(this.currPhi),I=E[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta),g=[i-M,s-_,c-I];m*g[0]+u*g[1]+o*g[2]>.05&&(p=!1)}return{x:y,y:R,z:S,visible:p}}setSelectedMesh(e){this.selectedMeshName=e||""}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 c=[this.viewMatrix[0],this.viewMatrix[4],this.viewMatrix[8]],m=[this.viewMatrix[1],this.viewMatrix[5],this.viewMatrix[9]],u=this.customTarget?[...this.customTarget]:[...this.bounds.center],o=this.currDistance/Math.max(e.clientHeight||300,1)*1.5;u[0]+=(-i*c[0]+s*m[0])*o,u[1]+=(-i*c[1]+s*m[1])*o,u[2]+=(-i*c[2]+s*m[2])*o,this.customTarget=u}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.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,c=r.height||300,m=i.width>0?Math.floor((e-i.left)*(s/i.width)):Math.floor(e),u=i.height>0?Math.floor((t-i.top)*(c/i.height)):Math.floor(t);return this.performMeshPick(m,u,!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),c=Math.max(1,this.canvas.height||300);e=this.mapStereoPickX(e,s);let m=q();re(m,this.projMatrix,this.viewMatrix);let u=[],o=Math.max(0,Math.min(s-1,e)),a=Math.max(0,Math.min(c-1,c-1-t));if(this.pickFbo&&i&&!this.xrSessionActive){(this.pickFboWidth!==s||this.pickFboHeight!==c)&&this.resizePickingFbo(s,c),i.bindFramebuffer(36160,this.pickFbo),i.viewport(0,0,s,c),i.enable(2929),i.clearColor(0,0,0,0),i.clear(16384|256),i.useProgram(this.pickProg);for(let p=0;p<this.meshes.length;p++){let E=this.meshes[p];if(E.visible===!1||E.isPluginMesh)continue;let M=p+1,_=(M&255)/255,I=(M>>8&255)/255,g=(M>>16&255)/255;i.uniform4f(this.uPick.uColorId,_,I,g,1),re(this.modelMatrix,this.modelRootMatrix,E.transform),re(this.mvpMatrix,m,this.modelMatrix),i.uniformMatrix4fv(this.uPick.uMVP,!1,this.mvpMatrix);for(let v of E.primitives)i.bindVertexArray(v.vao),i.drawElements(4,v.indexCount,v.indexType,0)}let y=new Uint8Array(4);i.readPixels(o,a,1,1,6408,5121,y),i.bindFramebuffer(36160,null);let R=y[0]+(y[1]<<8)+(y[2]<<16);R>0&&R<=this.meshes.length&&(u=[this.meshes[R-1]])}u.length===0&&(u=this.meshes.filter(y=>y.visible!==!1));let h=null,l=1/0,d=[0,0,0],f=[0,1,0],T=this.customTarget||this.bounds.center,A=T[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),S=T[1]+this.currDistance*Math.sin(this.currPhi),L=T[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta);for(let y of u){re(this.modelMatrix,this.modelRootMatrix,y.transform),re(this.mvpMatrix,m,this.modelMatrix);let R=q();if(!hn(R,this.mvpMatrix))continue;let p=(o+.5)/s*2-1,E=(a+.5)/c*2-1,M=[0,0,0],_=[0,0,0];Vt(M,p,E,-1,R),Vt(_,p,E,1,R);let I=_[0]-M[0],g=_[1]-M[1],v=_[2]-M[2],x=Math.hypot(I,g,v)||1,P=I/x,D=g/x,V=v/x,N={distance:1/0,point:[0,0,0],normal:[0,1,0]};if((F=>{for(let C of y.primitives){if(!C.positions)continue;let B=C.positions,k=C.indices,z=Math.floor(k?k.length/3:B.length/9);for(let O=0;O<z;O++){let H=k?k[O*3]:O*3,Y=k?k[O*3+1]:O*3+1,W=k?k[O*3+2]:O*3+2;mn(M[0],M[1],M[2],P,D,V,B[H*3],B[H*3+1],B[H*3+2],B[Y*3],B[Y*3+1],B[Y*3+2],B[W*3],B[W*3+1],B[W*3+2],N,F)}}})(1e-4),isFinite(N.distance)){let F=N.point[0],C=N.point[1],B=N.point[2],k=this.modelMatrix,z=k[0]*F+k[4]*C+k[8]*B+k[12],O=k[1]*F+k[5]*C+k[9]*B+k[13],H=k[2]*F+k[6]*C+k[10]*B+k[14],Y=z-A,W=O-S,fe=H-L,ee=Math.hypot(Y,W,fe);if(ee<l){ae(this.normalMatrix,this.modelMatrix);let ne=this.normalMatrix,ge=N.normal[0],xe=N.normal[1],de=N.normal[2],oe=ne[0]*ge+ne[3]*xe+ne[6]*de,ve=ne[1]*ge+ne[4]*xe+ne[7]*de,we=ne[2]*ge+ne[5]*xe+ne[8]*de,ke=Math.hypot(oe,ve,we)||1;oe/=ke,ve/=ke,we/=ke,oe*Y+ve*W+we*fe>0&&(oe=-oe,ve=-ve,we=-we),h=y,l=Math.round(ee*1e3)/1e3,d=[Math.round(z*1e3)/1e3,Math.round(O*1e3)/1e3,Math.round(H*1e3)/1e3],f=[Math.round(oe*1e3)/1e3,Math.round(ve*1e3)/1e3,Math.round(we*1e3)/1e3]}}}if(!h)return null;let w={meshIndex:this.meshes.indexOf(h),meshName:h.name,nodeIndex:h.nodeIndex,distance:l,hitPoint:d,normal:f,screenX:e,screenY:t};if(r){for(let y of K)y.onMeshSelect?.(this,w);this.opts.onMeshClick&&this.opts.onMeshClick(w),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("meshClick",{bubbles:!0,detail:w}))}return w}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,c=i?Math.max(1,t-r):r,m=(s+.5)/c*2-1;return Math.floor((m*.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);it(this.projMatrix,this.fov,e,.1,t);let r=this.customTarget||this.bounds.center,i=r[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),s=r[1]+this.currDistance*Math.sin(this.currPhi),c=r[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta);Ce(this.viewMatrix,[i,s,c],r,[0,1,0]),re(this.mvpMatrix,this.projMatrix,this.viewMatrix),ae(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 K)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 K)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 c of K)c.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 c of K)c.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 c={theta:r,phi:i,zoom:s,distance:Math.round(this.currDistance*100)/100};this.opts.onCameraChange&&this.opts.onCameraChange(c),typeof CustomEvent<"u"&&typeof this.container.dispatchEvent=="function"&&this.container.dispatchEvent(new CustomEvent("cameraChange",{bubbles:!0,detail:c}))}}renderXRView(e,t,r,i,s=!0,c=0){this.onBeforeRenderXRView&&this.onBeforeRenderXRView(e);let m=e?.transform?.inverse?.matrix||this.viewMatrix,u=e?.projectionMatrix||this.projMatrix,o=e?.transform?.position,a=o?[o.x,o.y,o.z]:[0,1.6,0];t?this.modelRootMatrix.set(t):r&&t&&this.modelRootMatrix.set(t),this.render({viewMatrix:m,projMatrix:u,eyePos:a,viewport:i,eye:e?.eye||"none",clear:c>0?!1:e?.eye!=="right",isAR:s})}render(e){if(!e&&this.stereoSBS){let w=Math.max(2,this.canvas.width||2),y=Math.max(1,this.canvas.height||1),R=Math.max(1,Math.floor(w*.5)),p=Math.max(1,w-R),E=this.backdropMeshes.length>0?Math.max(this.bounds.radius*20,120):Math.max(this.bounds.radius*20,10),M=this.customTarget||this.bounds.center,_=M[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),I=M[1]+this.currDistance*Math.sin(this.currPhi),g=M[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta),v=Math.cos(this.currTheta),x=-Math.sin(this.currTheta),P=.032,D=q(),V=q(),N=[_-v*P,I,g-x*P],U=[M[0]-v*P*.25,M[1],M[2]-x*P*.25];it(D,this.fov,R/y,.1,E),Ce(V,N,U,[0,1,0]);let F=q(),C=q(),B=[_+v*P,I,g+x*P],k=[M[0]+v*P*.25,M[1],M[2]+x*P*.25];it(F,this.fov,p/y,.1,E),Ce(C,B,k,[0,1,0]),this.render({viewMatrix:V,projMatrix:D,eyePos:N,viewport:[0,0,R,y],eye:"left",clear:!0,isAR:!1}),this.render({viewMatrix:C,projMatrix:F,eyePos:B,viewport:[R,0,p,y],eye:"right",clear:!1,isAR:!1}),this.gl.viewport(0,0,w,y);return}let t=this.gl,r=0,i=0,s=this.canvas.width,c=this.canvas.height;e?.viewport?(r=e.viewport[0],i=e.viewport[1],s=e.viewport[2],c=e.viewport[3],t.viewport(r,i,s,c)):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 m=q(),u=e?.viewMatrix??this.viewMatrix;re(m,e?.projMatrix??this.projMatrix,u);let o=[-u[2],-u[6],-u[10]],a=this.toneMapping==="reinhard"?1:this.toneMapping==="none"?2:0,h=this.customTarget||this.bounds.center,l=e?e.eyePos[0]:h[0]+this.currDistance*Math.cos(this.currPhi)*Math.sin(this.currTheta),d=e?e.eyePos[1]:h[1]+this.currDistance*Math.sin(this.currPhi),f=e?e.eyePos[2]:h[2]+this.currDistance*Math.cos(this.currPhi)*Math.cos(this.currTheta);for(let w of K)w.onBeforeDrawScene?.(this,t,m,[l,d,f],a);let T=e?.isAR?0:this.backdropMeshes.length;if(this.meshes.length===0&&T===0)return;let A=e?.eye||"none",S=!1,L=T>0?[...this.backdropMeshes,...this.meshes]:this.meshes,b=w=>{for(let y=0;y<L.length;y++){let R=L[y];if(R.visible===!1)continue;let p=this.selectedMeshName!==""&&R.name===this.selectedMeshName;y<T||R.worldSpace===!0||R.name==="__xr_reticle__"?this.modelMatrix.set(R.transform):re(this.modelMatrix,this.modelRootMatrix,R.transform),re(this.mvpMatrix,m,this.modelMatrix),ae(R.normalMatrix,this.modelMatrix);let E=R.extras?.xr?.stereo||R.userData?.xr?.stereo,M=0,_=0,I=1,g=1;E==="sbs"?(I=.5,M=A==="right"?.5:0):E==="ou"&&(g=.5,_=A==="right"?.5:0);for(let v of R.primitives){let x=!!v.isTransmissive;if(!w&&x){S=!0;continue}if(w&&!x)continue;let P=v.customProgram||this.renderProg,D=v.customUniforms||this.uRender;t.useProgram(P),t.uniform1i(D.uToneMapping,a),t.uniform1f(D.uEnvIntensity,this.envIntensity),t.uniform3f(D.uCameraPos,l,d,f),D.uCameraFwd&&t.uniform3f(D.uCameraFwd,o[0],o[1],o[2]),t.uniform1f(D.uEmissive,p?1:0),t.uniformMatrix4fv(D.uMVP,!1,this.mvpMatrix),t.uniformMatrix4fv(D.uModel,!1,this.modelMatrix),t.uniformMatrix3fv(D.uNormalMatrix,!1,R.normalMatrix),D.uUvTransform&&t.uniform4f(D.uUvTransform,M,_,I,g),D.uViewportSize&&t.uniform2f(D.uViewportSize,Math.max(1,s),Math.max(1,c)),D.uViewport&&t.uniform4f(D.uViewport,r,i,Math.max(1,s),Math.max(1,c)),this.xrDepthState.enabled&&this.xrDepthState.texture?(t.activeTexture(33989),t.bindTexture(3553,this.xrDepthState.texture),D.uXrDepthTex&&t.uniform1i(D.uXrDepthTex,5),D.uXrDepthEnabled&&t.uniform1i(D.uXrDepthEnabled,1),D.uXrDepthFormat&&t.uniform1i(D.uXrDepthFormat,this.xrDepthState.format||0),D.uXrRawValueToMeters&&t.uniform1f(D.uXrRawValueToMeters,this.xrDepthState.rawValueToMeters),D.uXrDepthUVTransform&&t.uniformMatrix4fv(D.uXrDepthUVTransform,!1,this.xrDepthState.uvTransform)):D.uXrDepthEnabled&&t.uniform1i(D.uXrDepthEnabled,0),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);for(let V of K)V.onBeforeDrawPrimitive?.(t,P,v,R,this.worldMatrices||[],this.gltf);t.uniform4fv(D.uBaseColor,v.baseColor),t.uniform1f(D.uMetallic,v.metallic),t.uniform1f(D.uRoughness,v.roughness),D.uClearcoat&&t.uniform2f(D.uClearcoat,v.clearcoat??0,v.clearcoatRoughness??.04),v.texture?(t.activeTexture(33984),t.bindTexture(3553,v.texture),t.uniform1i(D.uBaseColorTexture,0),t.uniform1i(D.uHasTexture,1)):t.uniform1i(D.uHasTexture,0),v.metallicRoughnessTexture?(t.activeTexture(33985),t.bindTexture(3553,v.metallicRoughnessTexture),t.uniform1i(D.uMetallicRoughnessTexture,1),t.uniform1i(D.uHasMetallicRoughnessTexture,1)):t.uniform1i(D.uHasMetallicRoughnessTexture,0),v.normalTexture?(t.activeTexture(33986),t.bindTexture(3553,v.normalTexture),t.uniform1i(D.uNormalTexture,2),t.uniform1i(D.uHasNormalTexture,1),t.uniform1f(D.uNormalScale,v.normalScale)):t.uniform1i(D.uHasNormalTexture,0),v.occlusionTexture?(t.activeTexture(33987),t.bindTexture(3553,v.occlusionTexture),t.uniform1i(D.uOcclusionTexture,3),t.uniform1i(D.uHasOcclusionTexture,1),t.uniform1f(D.uOcclusionStrength,v.occlusionStrength)):t.uniform1i(D.uHasOcclusionTexture,0),t.bindVertexArray(v.vao),t.drawElements(4,v.indexCount,v.indexType,0)}}};if(b(!1),S){for(let w of K)w.onBeforeTransmissivePass?.(t,this);b(!0)}for(let w of K)w.onAfterRender?.(t,this,m)}disposeMeshListGpuResources(e){let t=this.gl;for(let r of e)for(let i of r.primitives){if(i.vao&&t.deleteVertexArray(i.vao),i.buffers)for(let s of i.buffers)t.deleteBuffer(s);i.texture&&t.deleteTexture(i.texture),i.metallicRoughnessTexture&&t.deleteTexture(i.metallicRoughnessTexture),i.normalTexture&&t.deleteTexture(i.normalTexture),i.occlusionTexture&&t.deleteTexture(i.occlusionTexture),i.customProgram&&t.deleteProgram(i.customProgram)}}disposeMeshGpuResources(){this.disposeMeshListGpuResources(this.meshes),this.meshes=[]}disposeGpuResources(){let e=this.gl;this.disposeMeshGpuResources(),this.disposeMeshListGpuResources(this.backdropMeshes),this.backdropMeshes=[];for(let t of K)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()}};at.registerPlugin=un,at.getRegisteredPlugins=ln;function cr(n){return n+3&-4}function ur(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 Ie(n,e){n.updateMatrixWorld(!0);let t=[],r=0,i=[],s=[],c=[],m=[],u=new Set,o=[],a=[],h=new Map,l=[];function d(p,E){let M=new Uint8Array(p.buffer,p.byteOffset,p.byteLength),_=cr(M.byteLength),I=new Uint8Array(_);I.set(M),t.push(I);let g=i.length;return i.push({buffer:0,byteOffset:r,byteLength:M.byteLength,target:E}),r+=_,g}function f(p,E,M,_,I,g,v){let x=d(p,M),P=s.length,D={bufferView:x,byteOffset:0,componentType:_,count:I,type:E};return g&&(D.min=g),v&&(D.max=v),s.push(D),P}n.traverse(p=>{(p.isLight||p.color&&p.intensity!==void 0)&&l.push({type:p.type,color:[p.color.r,p.color.g,p.color.b],intensity:p.intensity,position:[p.position.x,p.position.y,p.position.z]})});let T=[];function A(p){let E={name:p.name||""},M=p.position,_=p.quaternion,I=p.scale;if((M.x||M.y||M.z)&&(E.translation=[M.x,M.y,M.z]),(_.x||_.y||_.z||_.w!==1)&&(E.rotation=[_.x,_.y,_.z,_.w]),(I.x!==1||I.y!==1||I.z!==1)&&(E.scale=[I.x,I.y,I.z]),p.userData&&Object.keys(p.userData).length>0&&(E.extras=JSON.parse(JSON.stringify(p.userData,(v,x)=>{if(!(v==="__proto__"||v==="prototype"||v==="constructor"))return typeof x=="function"?void 0:x})),p.userData.xr)){let v=ur(p.userData.xr);E.extensions={...E.extensions||{},MOZ_hubs_components:v,ANDROID_xr_scenecore:v},J().xrTraitSerializer?.gltfNode(E,p.userData.xr),u.add("MOZ_hubs_components").add("ANDROID_xr_scenecore")}if(p.geometry){let v=p.geometry,x=v.attributes.position;if(x&&x.count>0){let P=[1/0,1/0,1/0],D=[-1/0,-1/0,-1/0];for(let F=0;F<x.count;F++){let C=x.getX(F),B=x.getY(F),k=x.getZ(F);C<P[0]&&(P[0]=C),C>D[0]&&(D[0]=C),B<P[1]&&(P[1]=B),B>D[1]&&(D[1]=B),k<P[2]&&(P[2]=k),k>D[2]&&(D[2]=k)}let N={attributes:{POSITION:f(x.array,"VEC3",34962,5126,x.count,P,D)}};if(v.attributes.normal&&(N.attributes.NORMAL=f(v.attributes.normal.array,"VEC3",34962,5126,v.attributes.normal.count)),v.attributes.uv&&(N.attributes.TEXCOORD_0=f(v.attributes.uv.array,"VEC2",34962,5126,v.attributes.uv.count)),v.index){let F=v.index.array instanceof Uint32Array;N.indices=f(v.index.array,"SCALAR",34963,F?5125:5123,v.index.count)}if(p.material){let F=h.get(p.material);if(F===void 0){F=a.length,h.set(p.material,F);let C=p.material,B={name:C.name||"",pbrMetallicRoughness:{baseColorFactor:[C.color.r,C.color.g,C.color.b,C.opacity],metallicFactor:C.metalness,roughnessFactor:C.roughness},doubleSided:C.side===2||C.doubleSided};if(C.emissive&&(C.emissive.r>0||C.emissive.g>0||C.emissive.b>0)){let z=C.emissiveIntensity??1;B.emissiveFactor=[C.emissive.r*z,C.emissive.g*z,C.emissive.b*z]}let k={};C.clearcoat>0&&(k.KHR_materials_clearcoat={clearcoatFactor:C.clearcoat,clearcoatRoughnessFactor:C.clearcoatRoughness||0}),C.sheen>0&&(k.KHR_materials_sheen={sheenColorFactor:C.sheenColor?[C.sheenColor.r,C.sheenColor.g,C.sheenColor.b]:[1,1,1],sheenRoughnessFactor:C.sheenRoughness||0}),C.transmission>0&&(k.KHR_materials_transmission={transmissionFactor:C.transmission}),C.thickness>0&&(k.KHR_materials_volume={thicknessFactor:C.thickness,attenuationDistance:C.attenuationDistance??1/0,attenuationColor:C.attenuationColor?[C.attenuationColor.r,C.attenuationColor.g,C.attenuationColor.b]:[1,1,1]}),C.ior!==void 0&&C.ior!==1.5&&(k.KHR_materials_ior={ior:C.ior}),C.dispersion>0&&(k.KHR_materials_dispersion={dispersion:C.dispersion}),C.iridescence>0&&(k.KHR_materials_iridescence={iridescenceFactor:C.iridescence,iridescenceIor:C.iridescenceIOR??1.3}),Object.keys(k).length>0&&(B.extensions=k),a.push(B)}N.material=F}let U=c.length;c.push({primitives:[N],name:p.name,...E.extras?{extras:E.extras}:{}}),E.mesh=U}}let g=m.length;if(m.push(E),o.push(p),p.children.length>0){E.children=[];for(let v of p.children)E.children.push(A(v))}return g}for(let p of n.children)T.push(A(p));let S=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),L=[];if(typeof S=="function"&&o.length>0){let p=e?.duration??4,E=e?.fps??15,M=Math.max(2,Math.round(p*E)+1),_=new Float32Array(M),I=o.map(U=>({px:U.position.x,py:U.position.y,pz:U.position.z,qx:U.quaternion.x,qy:U.quaternion.y,qz:U.quaternion.z,qw:U.quaternion.w,sx:U.scale.x,sy:U.scale.y,sz:U.scale.z})),g=o.map(()=>new Float32Array(M*3)),v=o.map(()=>new Float32Array(M*4)),x=o.map(()=>new Float32Array(M*3));for(let U=0;U<M;U++){let F=U/(M-1)*p;_[U]=F;try{S(F)}catch{}for(let C=0;C<o.length;C++){let B=o[C];g[C][U*3]=B.position.x,g[C][U*3+1]=B.position.y,g[C][U*3+2]=B.position.z,v[C][U*4]=B.quaternion.x,v[C][U*4+1]=B.quaternion.y,v[C][U*4+2]=B.quaternion.z,v[C][U*4+3]=B.quaternion.w,x[C][U*3]=B.scale.x,x[C][U*3+1]=B.scale.y,x[C][U*3+2]=B.scale.z}}for(let U=0;U<o.length;U++){let F=o[U],C=I[U];F.position.set(C.px,C.py,C.pz),F.quaternion.set(C.qx,C.qy,C.qz,C.qw),F.scale.set(C.sx,C.sy,C.sz)}n.updateMatrixWorld(!0);let P=null,D=()=>(P===null&&(P=f(_,"SCALAR",0,5126,M,[0],[p])),P),V=[],N=[];for(let U=0;U<o.length;U++){let F=I[U],C=!1,B=!1,k=!1;for(let z=0;z<M;z++)(Math.abs(g[U][z*3]-F.px)>1e-4||Math.abs(g[U][z*3+1]-F.py)>1e-4||Math.abs(g[U][z*3+2]-F.pz)>1e-4)&&(C=!0),(Math.abs(v[U][z*4]-F.qx)>1e-4||Math.abs(v[U][z*4+1]-F.qy)>1e-4||Math.abs(v[U][z*4+2]-F.qz)>1e-4||Math.abs(v[U][z*4+3]-F.qw)>1e-4)&&(B=!0),(Math.abs(x[U][z*3]-F.sx)>1e-4||Math.abs(x[U][z*3+1]-F.sy)>1e-4||Math.abs(x[U][z*3+2]-F.sz)>1e-4)&&(k=!0);if(C){let z=f(g[U],"VEC3",0,5126,M),O=V.length;V.push({input:D(),interpolation:"LINEAR",output:z}),N.push({sampler:O,target:{node:U,path:"translation"}})}if(B){let z=f(v[U],"VEC4",0,5126,M),O=V.length;V.push({input:D(),interpolation:"LINEAR",output:z}),N.push({sampler:O,target:{node:U,path:"rotation"}})}if(k){let z=f(x[U],"VEC3",0,5126,M),O=V.length;V.push({input:D(),interpolation:"LINEAR",output:z}),N.push({sampler:O,target:{node:U,path:"scale"}})}}N.length>0&&L.push({name:"ProceduralLoop",samplers:V,channels:N})}let b=nt(m,c,n.userData),w={asset:{version:"2.0",generator:"ThreeLiveConvert",extras:{environmentIntensity:n.environmentIntensity}},scenes:[{nodes:T}],scene:0,nodes:m,meshes:c,materials:a,accessors:s,bufferViews:i,buffers:[{byteLength:r}],...L.length>0?{animations:L}:{},...b||u.size>0?{extensionsUsed:[...b?["KHR_interactivity"]:[],...u]}:{},...b?{extensions:{KHR_interactivity:b}}:{}},y=new Uint8Array(r),R=0;for(let p of t)y.set(p,R),R+=p.byteLength;return{gltf:w,bin:y.buffer,lights:l,environmentIntensity:n.environmentIntensity}}function ut(n){return new TextEncoder().encode(n)}function ze(n,e){let{gltf:t,bin:r}=Ie(n,e),i=JSON.stringify(t),s=ut(i),c=(4-s.byteLength%4)%4,m=s.byteLength+c,u=20+m+8+r.byteLength,o=new Uint8Array(u),a=new DataView(o.buffer);a.setUint32(0,1179937895,!0),a.setUint32(4,2,!0),a.setUint32(8,u,!0),a.setUint32(12,m,!0),a.setUint32(16,1313821514,!0),o.set(s,20);for(let l=0;l<c;l++)o[20+s.byteLength+l]=32;let h=20+m;return a.setUint32(h,r.byteLength,!0),a.setUint32(h+4,5130562,!0),o.set(new Uint8Array(r),h+8),o}function lr(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 c=s.count,m=new Float32Array(c*3),u=r.matrixWorld.elements;for(let p=0;p<c;p++){let E=s.getX(p),M=s.getY(p),_=s.getZ(p);m[p*3]=u[0]*E+u[4]*M+u[8]*_+u[12],m[p*3+1]=u[1]*E+u[5]*M+u[9]*_+u[13],m[p*3+2]=u[2]*E+u[6]*M+u[10]*_+u[14]}let o;if(i.attributes.normal){let p=i.attributes.normal;o=new Float32Array(c*3);let E=new Float32Array(9);ae(E,u);for(let M=0;M<c;M++){let _=p.getX(M),I=p.getY(M),g=p.getZ(M),v=E[0]*_+E[3]*I+E[6]*g,x=E[1]*_+E[4]*I+E[7]*g,P=E[2]*_+E[5]*I+E[8]*g,D=Math.hypot(v,x,P)||1;o[M*3]=v/D,o[M*3+1]=x/D,o[M*3+2]=P/D}}let a;if(i.attributes.uv){let p=i.attributes.uv;a=new Float32Array(c*2);for(let E=0;E<c;E++)a[E*2]=p.getX(E),a[E*2+1]=p.getY(E)}let h;if(i.index)h=i.index.array;else{h=c>65535?new Uint32Array(c):new Uint16Array(c);for(let p=0;p<c;p++)h[p]=p}let l="DefaultMaterial",d=[.8,.8,.8],f=.5,T=.1,A=0,S=0,L=1.5,b=1,w=[0,0,0];if(r.material){let p=r.material;l=p.name||`Material_${t.length}`,p.color&&(d=[p.color.r,p.color.g,p.color.b]),typeof p.roughness=="number"&&(f=p.roughness),typeof p.metalness=="number"&&(T=p.metalness),typeof p.clearcoat=="number"&&(A=p.clearcoat),typeof p.clearcoatRoughness=="number"&&(S=p.clearcoatRoughness),typeof p.ior=="number"&&(L=p.ior);let E=typeof p.opacity=="number"?p.opacity:1,M=typeof p.transmission=="number"?p.transmission:0;if(b=E*(1-M),p.emissive&&(p.emissive.r>0||p.emissive.g>0||p.emissive.b>0)){let _=p.emissiveIntensity??1;w=[p.emissive.r*_,p.emissive.g*_,p.emissive.b*_]}}let y,R=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 R=="function"){let p=e?.duration??4,E=e?.fps??4,M=Math.max(2,Math.round(p*E)+1),_=[],I=[],g=[],v=[],x=[r.position.x,r.position.y,r.position.z],P=[r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w],D=[r.scale.x,r.scale.y,r.scale.z],V=!1;for(let N=0;N<M;N++){let U=N/(M-1)*p;_.push(U);try{R(U)}catch{}I.push([r.position.x,r.position.y,r.position.z]),g.push([r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w]),v.push([r.scale.x,r.scale.y,r.scale.z]),(Math.abs(r.position.x-x[0])>1e-4||Math.abs(r.position.y-x[1])>1e-4||Math.abs(r.position.z-x[2])>1e-4||Math.abs(r.quaternion.x-P[0])>1e-4||Math.abs(r.quaternion.y-P[1])>1e-4||Math.abs(r.quaternion.z-P[2])>1e-4||Math.abs(r.quaternion.w-P[3])>1e-4||Math.abs(r.scale.x-D[0])>1e-4)&&(V=!0)}r.position.set(x[0],x[1],x[2]),r.quaternion.set(P[0],P[1],P[2],P[3]),r.scale.set(D[0],D[1],D[2]),V&&(y={times:_,translations:I,rotations:g,scales:v})}t.push({name:r.name||`Mesh_${t.length}`,positions:m,indices:h,normals:o,uvs:a,materialName:l,color:d,roughness:f,metallic:T,clearcoat:A,clearcoatRoughness:S,ior:L,opacity:b,emissiveColor:w,xrTraits:r.userData?.xr,timeSamples:y})}}),t}function En(n){let e=[],t=n.gltf,r=n.bin,i=r instanceof ArrayBuffer?r:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),s=t.accessors||[],c=t.bufferViews||[],m=t.materials||[],u=t.meshes||[],o=t.nodes||[];function a(d){let f=s[d];if(!f)throw new Error(`Accessor ${d} not found`);let T=c[f.bufferView||0],A=(T.byteOffset||0)+(f.byteOffset||0),S=T.byteLength||0,L=i.slice(A,A+S);return{acc:f,buffer:L}}let h=new Map;if(o.length>0){let d=ot(t);for(let f=0;f<d.length;f++)h.set(f,d[f])}function l(d,f,T,A){let S=u[d];if(!S)return;let L=new Float32Array(9);ae(L,f);for(let b=0;b<(S.primitives||[]).length;b++){let w=S.primitives[b],y=w.attributes?.POSITION;if(y===void 0)continue;let{acc:R,buffer:p}=a(y),E=new Float32Array(p,0,R.count*3),M=new Float32Array(E.length);for(let O=0;O<R.count;O++){let H=E[O*3],Y=E[O*3+1],W=E[O*3+2];M[O*3]=f[0]*H+f[4]*Y+f[8]*W+f[12],M[O*3+1]=f[1]*H+f[5]*Y+f[9]*W+f[13],M[O*3+2]=f[2]*H+f[6]*Y+f[10]*W+f[14]}let _,I=w.attributes?.NORMAL;if(I!==void 0){let{acc:O,buffer:H}=a(I),Y=new Float32Array(H,0,O.count*3);_=new Float32Array(Y.length);for(let W=0;W<O.count;W++){let fe=Y[W*3],ee=Y[W*3+1],ne=Y[W*3+2],ge=L[0]*fe+L[3]*ee+L[6]*ne,xe=L[1]*fe+L[4]*ee+L[7]*ne,de=L[2]*fe+L[5]*ee+L[8]*ne,oe=Math.hypot(ge,xe,de)||1;_[W*3]=ge/oe,_[W*3+1]=xe/oe,_[W*3+2]=de/oe}}let g,v=w.attributes?.TEXCOORD_0;if(v!==void 0){let{acc:O,buffer:H}=a(v);g=new Float32Array(H,0,O.count*2)}let x;if(w.indices!==void 0){let{acc:O,buffer:H}=a(w.indices);O.componentType===5125?x=new Uint32Array(H,0,O.count):x=new Uint16Array(H,0,O.count);let Y=R.count;for(let W of x)if(W>=Y)throw new Error(`SecurityError: Index buffer value (${W}) out of vertex bounds [0, ${Y}).`)}else{let O=R.count;x=O>65535?new Uint32Array(O):new Uint16Array(O);for(let H=0;H<O;H++)x[H]=H}let P="DefaultMaterial",D=[.8,.8,.8],V=.5,N=.1,U=0,F=0,C=1.5,B=1,k=[0,0,0];if(w.material!==void 0&&m[w.material]){let O=m[w.material];P=O.name||`Material_${w.material}`;let H=O.pbrMetallicRoughness||{},Y=1;Array.isArray(H.baseColorFactor)&&(D=[H.baseColorFactor[0],H.baseColorFactor[1],H.baseColorFactor[2]],typeof H.baseColorFactor[3]=="number"&&(Y=H.baseColorFactor[3])),typeof H.roughnessFactor=="number"&&(V=H.roughnessFactor),typeof H.metallicFactor=="number"&&(N=H.metallicFactor),Array.isArray(O.emissiveFactor)&&O.emissiveFactor.length>=3&&(k=[O.emissiveFactor[0],O.emissiveFactor[1],O.emissiveFactor[2]]);let W=O.extensions||{};W.KHR_materials_clearcoat&&(U=W.KHR_materials_clearcoat.clearcoatFactor??0,F=W.KHR_materials_clearcoat.clearcoatRoughnessFactor??0),W.KHR_materials_ior&&typeof W.KHR_materials_ior.ior=="number"&&(C=W.KHR_materials_ior.ior);let fe=W.KHR_materials_transmission?.transmissionFactor??0;B=Y*(1-fe)}let z=(S.primitives||[]).length>1?`${T}_p${b}`:T;e.push({name:z,positions:M,indices:x,normals:_,uvs:g,materialName:P,color:D,roughness:V,metallic:N,clearcoat:U,clearcoatRoughness:F,ior:C,opacity:B,emissiveColor:k,xrTraits:A?.xr||S.extras?.xr})}}if(o.length>0)for(let d=0;d<o.length;d++){let f=o[d];if(f.mesh!==void 0&&f.mesh<u.length){let T=h.get(d)||q(),A=f.name||u[f.mesh].name||`Node_${d}`;l(f.mesh,T,A,f.extras)}}else{let d=q();for(let f=0;f<u.length;f++){let T=u[f].name||`Mesh_${f}`;l(f,d,T,u[f].extras)}}return e}function Wt(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 wn(n){return String(n??"").replace(/[\x00-\x1f\x7f]/g,"").replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function G(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 Tn(n){{let r=globalThis.__three_live_native_format_usda_points__;if(typeof r=="function")return r(n)}let e=n.length/3,t=new Array(e);for(let r=0;r<e;r++)t[r]=`(${G(n[r*3])}, ${G(n[r*3+1])}, ${G(n[r*3+2])})`;return t.join(", ")}function hr(n,e){{let r=globalThis.__three_live_native_format_usda_uvs__;if(typeof r=="function")return r(n)}let t=new Array(e);for(let r=0;r<e;r++)t[r]=`(${G(n[r*2])}, ${G(1-n[r*2+1])})`;return t.join(", ")}function mr(n){{let e=globalThis.__three_live_native_format_usda_ints__;if(typeof e=="function")return e(n)}return Array.from(n).join(", ")}function $t(n){let e=new Map;for(let u of n){let o=Wt(u.materialName,"DefaultMaterial");e.has(o)||e.set(o,{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]})}let t=0,r=null;for(let u of n){if(u.timeSamples&&u.timeSamples.times.length>0){let o=u.timeSamples.times[u.timeSamples.times.length-1];o>t&&(t=o)}u.xrTraits?.anchor&&!r&&(r=u.xrTraits.anchor==="vertical"||u.xrTraits.anchor==="wall"?"vertical":"horizontal")}let i="";t>0&&(i=`startTimeCode = 0
|
|
218
223
|
endTimeCode = ${G(t)}
|
|
219
224
|
timeCodesPerSecond = 1.0
|
|
220
|
-
`);let
|
|
225
|
+
`);let s="";r&&(s=`uniform token preliminary:anchoring:type = "plane"
|
|
221
226
|
uniform token preliminary:planeAnchoring:alignment = "${r}"
|
|
222
227
|
`);let c=`#usda 1.0
|
|
223
228
|
(
|
|
@@ -230,63 +235,63 @@ def Xform "Root" (
|
|
|
230
235
|
kind = "component"
|
|
231
236
|
)
|
|
232
237
|
{
|
|
233
|
-
${
|
|
238
|
+
${s}def Scope "Materials"
|
|
234
239
|
{
|
|
235
|
-
`;for(let[u,
|
|
236
|
-
`,
|
|
237
|
-
`),
|
|
238
|
-
`),
|
|
239
|
-
`),(
|
|
240
|
+
`;for(let[u,o]of e.entries()){let[a,h,l]=o.color,[d,f,T]=o.emissiveColor,A="";o.clearcoat>0&&(A+=`float inputs:clearcoat = ${G(o.clearcoat)}
|
|
241
|
+
`,A+=`float inputs:clearcoatRoughness = ${G(o.clearcoatRoughness)}
|
|
242
|
+
`),o.ior!==1.5&&(A+=`float inputs:ior = ${G(o.ior)}
|
|
243
|
+
`),o.opacity<1&&(A+=`float inputs:opacity = ${G(o.opacity)}
|
|
244
|
+
`),(d>0||f>0||T>0)&&(A+=`color3f inputs:emissiveColor = (${G(d)}, ${G(f)}, ${G(T)})
|
|
240
245
|
`),c+=`def Material "${u}"
|
|
241
246
|
{
|
|
242
247
|
def Shader "PBRShader"
|
|
243
248
|
{
|
|
244
249
|
uniform token info:id = "UsdPreviewSurface"
|
|
245
|
-
color3f inputs:diffuseColor = (${G(
|
|
246
|
-
float inputs:metallic = ${G(
|
|
247
|
-
float inputs:roughness = ${G(
|
|
248
|
-
${
|
|
250
|
+
color3f inputs:diffuseColor = (${G(a)}, ${G(h)}, ${G(l)})
|
|
251
|
+
float inputs:metallic = ${G(o.metallic)}
|
|
252
|
+
float inputs:roughness = ${G(o.roughness)}
|
|
253
|
+
${A}token outputs:surface
|
|
249
254
|
}
|
|
250
255
|
token outputs:surface.connect = </Root/Materials/${u}/PBRShader.outputs:surface>
|
|
251
256
|
}
|
|
252
257
|
`}c+=`}
|
|
253
258
|
def Scope "Meshes"
|
|
254
259
|
{
|
|
255
|
-
`;let m=new Set;for(let u=0;u<n.length;u++){let
|
|
260
|
+
`;let m=new Set;for(let u=0;u<n.length;u++){let o=n[u],a=o.positions.length/3,h=1/0,l=1/0,d=1/0,f=-1/0,T=-1/0,A=-1/0;for(let p=0;p<a;p++){let E=o.positions[p*3],M=o.positions[p*3+1],_=o.positions[p*3+2];E<h&&(h=E),E>f&&(f=E),M<l&&(l=M),M>T&&(T=M),_<d&&(d=_),_>A&&(A=_)}isFinite(h)||(h=l=d=-1,f=T=A=1);let S=Math.floor(o.indices.length/3),L=Wt(o.materialName,"DefaultMaterial"),b=Wt(o.name,`Mesh_${u}`);m.has(b)&&(b=`${b}_${u}`),m.add(b);let w=S>0?S===1?"3":"3, ".repeat(S-1)+"3":"",y=o.xrTraits,R="";if(y){let p=[];y.physics&&y.physics!=="none"&&p.push('prepend apiSchemas = ["PhysicsBodyAPI", "PhysicsCollisionAPI"]');let E=J().xrTraitSerializer?.usdLines(y,wn)??[];if(!E.length)for(let M of["grab","billboard","follow","anchor","physics"]){let _=M==="follow"&&typeof y.follow=="object"?y.follow.mode??"head":y[M];_!==void 0&&E.push(`string ${M} = "${wn(_)}"`)}E.length>0&&p.push(`customData = {
|
|
256
261
|
dictionary xr = {
|
|
257
|
-
${
|
|
262
|
+
${E.join(`
|
|
258
263
|
`)}
|
|
259
264
|
}
|
|
260
|
-
}`),
|
|
261
|
-
${
|
|
265
|
+
}`),p.length>0&&(R=` (
|
|
266
|
+
${p.join(`
|
|
262
267
|
`)}
|
|
263
|
-
)`)}if(c+=`def Mesh "${
|
|
268
|
+
)`)}if(c+=`def Mesh "${b}"${R}
|
|
264
269
|
{
|
|
265
|
-
`,
|
|
266
|
-
bool physics:kinematicEnabled = ${
|
|
270
|
+
`,y?.physics&&y.physics!=="none"){let p=y.physics==="static"?"true":"false";c+=`bool physics:rigidBodyEnabled = true
|
|
271
|
+
bool physics:kinematicEnabled = ${p}
|
|
267
272
|
bool physics:collisionEnabled = true
|
|
268
|
-
`}if(
|
|
269
|
-
quatf xformOp:orient.timeSamples = { ${
|
|
273
|
+
`}if(o.timeSamples&&o.timeSamples.times.length>0){let p=o.timeSamples,E=p.times.map((I,g)=>{let v=p.translations?.[g]||[0,0,0];return`${G(I)}: (${G(v[0])}, ${G(v[1])}, ${G(v[2])})`}).join(", "),M=p.times.map((I,g)=>{let v=p.rotations?.[g]||[0,0,0,1];return`${G(I)}: (${G(v[3])}, ${G(v[0])}, ${G(v[1])}, ${G(v[2])})`}).join(", "),_=p.times.map((I,g)=>{let v=p.scales?.[g]||[1,1,1];return`${G(I)}: (${G(v[0])}, ${G(v[1])}, ${G(v[2])})`}).join(", ");c+=`double3 xformOp:translate.timeSamples = { ${E} }
|
|
274
|
+
quatf xformOp:orient.timeSamples = { ${M} }
|
|
270
275
|
double3 xformOp:scale.timeSamples = { ${_} }
|
|
271
276
|
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:orient", "xformOp:scale"]
|
|
272
|
-
`}c+=`float3[] extent = [(${G(h)}, ${G(l)}, ${G(
|
|
273
|
-
int[] faceVertexCounts = [${
|
|
274
|
-
int[] faceVertexIndices = [${mr(
|
|
275
|
-
point3f[] points = [${
|
|
276
|
-
`,
|
|
277
|
+
`}c+=`float3[] extent = [(${G(h)}, ${G(l)}, ${G(d)}), (${G(f)}, ${G(T)}, ${G(A)})]
|
|
278
|
+
int[] faceVertexCounts = [${w}]
|
|
279
|
+
int[] faceVertexIndices = [${mr(o.indices)}]
|
|
280
|
+
point3f[] points = [${Tn(o.positions)}]
|
|
281
|
+
`,o.normals&&o.normals.length===o.positions.length&&(c+=`normal3f[] normals = [${Tn(o.normals)}] (
|
|
277
282
|
interpolation = "vertex"
|
|
278
283
|
)
|
|
279
|
-
`),
|
|
284
|
+
`),o.uvs&&o.uvs.length===a*2&&(c+=`texCoord2f[] primvars:st = [${hr(o.uvs,a)}] (
|
|
280
285
|
interpolation = "vertex"
|
|
281
286
|
)
|
|
282
|
-
`),c+=`rel material:binding = </Root/Materials/${
|
|
287
|
+
`),c+=`rel material:binding = </Root/Materials/${L}>
|
|
283
288
|
}
|
|
284
289
|
`}return c+=`}
|
|
285
290
|
}
|
|
286
|
-
`,c}function fr(n,e){if(n&&typeof n.traverse=="function"){let i=lr(n,e);return Wt(i)}let t=Oe(n),r=En(t);return Wt(r)}var at=null;function dr(n){{let t=globalThis.__three_live_native_crc32__;if(typeof t=="function")return t(n)}if(!at){at=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;at[t]=r}}let e=4294967295;for(let t=0;t<n.length;t++)e=at[(e^n[t])&255]^e>>>8;return(e^4294967295)>>>0}function Mn(n){{let s=globalThis.__three_live_native_build_usdz_zip__;if(typeof s=="function")return s(n)}let e=[],t=0,r=[];for(let s of n){let h=ct(s.filename),l=dr(s.data),p=s.data.length,f=30+h.length,T=t+f,M=0,R=T%64;R!==0&&(M=64-R);let I=new Uint8Array(f+M),y=new DataView(I.buffer);y.setUint32(0,67324752,!0),y.setUint16(4,20,!0),y.setUint16(6,0,!0),y.setUint16(8,0,!0),y.setUint16(10,0,!0),y.setUint16(12,0,!0),y.setUint32(14,l,!0),y.setUint32(18,p,!0),y.setUint32(22,p,!0),y.setUint16(26,h.length,!0),y.setUint16(28,M,!0),I.set(h,30),M>0&&I.fill(0,30+h.length),e.push({offset:t,size:p,crc:l,filenameBytes:h,entry:s}),r.push(I),r.push(s.data),t+=I.length+s.data.length}let i=t;for(let s of e){let h=new Uint8Array(46+s.filenameBytes.length),l=new DataView(h.buffer);l.setUint32(0,33639248,!0),l.setUint16(4,20,!0),l.setUint16(6,20,!0),l.setUint16(8,0,!0),l.setUint16(10,0,!0),l.setUint16(12,0,!0),l.setUint16(14,0,!0),l.setUint32(16,s.crc,!0),l.setUint32(20,s.size,!0),l.setUint32(24,s.size,!0),l.setUint16(28,s.filenameBytes.length,!0),l.setUint16(30,0,!0),l.setUint16(32,0,!0),l.setUint16(34,0,!0),l.setUint16(36,0,!0),l.setUint32(38,0,!0),l.setUint32(42,s.offset,!0),h.set(s.filenameBytes,46),r.push(h),t+=h.length}let o=t-i,c=new Uint8Array(22),m=new DataView(c.buffer);m.setUint32(0,101010256,!0),m.setUint16(4,0,!0),m.setUint16(6,0,!0),m.setUint16(8,e.length,!0),m.setUint16(10,e.length,!0),m.setUint32(12,o,!0),m.setUint32(16,i,!0),m.setUint16(20,0,!0),r.push(c),t+=22;let u=new Uint8Array(t),a=0;for(let s of r)u.set(s,a),a+=s.length;return u}function Ie(n){let e=fr(n),t=ct(e);return Mn([{filename:"model.usda",data:t}])}function ut(n){let e=Oe(n),t=En(e),r=Wt(t),i=ct(r);return Mn([{filename:"model.usda",data:i}])}function $t(n){return n&&typeof n.toUSDZ=="function"?n.toUSDZ():n&&typeof n.traverse=="function"?Ie(n):ut(n)}function Q(n,e,t,r){let i=typeof n=="number"&&Number.isFinite(n)?n:r;return Math.max(e,Math.min(t,i))}function qt(n){return Array.isArray(n)&&n.length>=3&&Number.isFinite(n[0])&&Number.isFinite(n[1])&&Number.isFinite(n[2])}function le(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Kt(n,e=256){return typeof n=="string"&&n.length>0?n.slice(0,e):void 0}function pr(n){let e=le(n);if(!e||e.lazy===!1)return null;let t=e.mode==="hand-left"||e.mode==="hand-right"?e.mode:"head",r=t!=="head";return{mode:t,lazy:!0,distance:Q(e.distance,.1,10,r?.15:1),deadzoneDeg:Q(e.deadzoneDeg,0,90,r?0:15),stiffness:Q(e.stiffness,.5,40,6),height:Q(e.height,-2,2,r?.12:-.1),faceUser:e.faceUser!==!1,snapOnStart:e.snapOnStart!==!1}}function br(n){let e=le(n);if(!e)return null;let t=e.target;return{target:qt(t)?[t[0],t[1],t[2]]:typeof t=="string"&&t.length>0&&t.length<=256?t:[0,0,0],radius:Q(e.radius,.01,50,.5),speed:Q(e.speed,-20,20,.5),height:Q(e.height,-10,10,0),phase:Q(e.phase,-1e6,1e6,0),faceCenter:e.faceCenter===!0}}function yr(n){if(!n)return null;let e=le(n)??{},t=Q(e.minScale,.001,1e3,.1),r=Q(e.maxScale,t,1e3,Math.max(t,10));return{rotateAxis:e.rotateAxis==="none"?"none":"y",minScale:t,maxScale:r}}var gr=2e3,xr={rain:600,snow:400,sparks:300,confetti:300};function vr(n){let e=le(n);if(!e)return null;let t=e.preset==="snow"||e.preset==="sparks"||e.preset==="confetti"?e.preset:"rain",r=e.area,i=c=>Q(c,.05,50,2),o=qt(r)?[i(r[0]),i(r[1]),i(r[2])]:typeof r=="number"?[i(r),i(r),i(r)]:[2,2,2];return{preset:t,count:Math.round(Q(e.count,1,gr,xr[t])),area:o,speed:Q(e.speed,.05,10,1)}}var Tr=4e3;function wr(n){if(!n)return null;let e=le(n)??{};return{prompt:Kt(e.prompt,Tr)??"What is this?",holdMs:Q(e.holdMs,100,5e3,600)}}function Er(n){if(!n)return null;let e=le(n)??{};return{planes:e.planes!==!1,meshes:e.meshes===!0,reticle:e.reticle===!0,objects:e.objects===!0}}function Yt(n){let e=Kt(n,4096)?.trim();if(!(!e||/[\x00-\x20\\%]/.test(e))){if(/^https:\/\/[^/]/i.test(e))return e;if(!(e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e)))return e.split(/[/?#]/).includes("..")?void 0:e}}function Mr(n){if(typeof n=="string"){let r=Yt(n);return r?{src:r,refDistance:1,loop:!1}:null}let e=le(n),t=Yt(e?.src);return!e||!t?null:{src:t,refDistance:Q(e.refDistance,.01,1e3,1),loop:e.loop===!0}}var Rr=new Set(["horizontal","vertical","floor","wall","table"]),Sr=new Set(["capsule","cylindrical","spherical"]);function lt(n){let e=le(n);if(!e)return null;let t=Array.isArray(e.traits)?e.traits:[],r=y=>t.includes(y),i={},o=e.grab;o==="1-hand"||o==="2-hand"?i.grab=o:(o===!0||e.grabbable===!0||r("grab"))&&(i.grab="2-hand"),i.grab&&(i.grabbable=!0);let c=e.scale??e.scalable;if(c||r("scale")){let y=le(c)??{},E=Q(y.min,.001,1e3,.05);i.scale={min:E,max:Q(y.max,E,1e3,Math.max(E,5))},i.scalable=!0}let m=e.billboard;typeof m=="string"&&Sr.has(m)?i.billboard=m:(m===!0||r("billboard"))&&(i.billboard="capsule");let u=e.follow,a=typeof u=="string"?u:le(u)?.mode;if(typeof u=="string"?u:le(u)?.lazy===!1)i.follow=a==="hand-left"||a==="hand-right"?a:"head";else{let y=pr(u);y&&(i.follow=y)}let s=e.anchor;typeof s=="string"&&Rr.has(s)&&(i.anchor=s),(e.physics==="dynamic"||e.physics==="static")&&(i.physics=e.physics);let h=br(e.orbit);h&&(i.orbit=h);let l=yr(e.handles);l&&(i.handles=l);let p=vr(e.particles);p&&(i.particles=p);let f=wr(e.holdToAsk);f&&(i.holdToAsk=f);let T=Er(e.worldUnderstanding);T&&(i.worldUnderstanding=T);let M=Yt(e.splatUrl);M&&(i.splatUrl=M);let R=Kt(e.spatialSlot);R&&(i.spatialSlot=R);let I=Mr(e.audio);return I&&(i.audio=I),e.pointerEvents==="none"&&(i.pointerEvents="none"),Object.keys(i).length>0?i:null}function jt(n){let e={};return n.grab&&(e.interactable={mode:n.grab},e.movable={systemMovable:!0,scaleInZ:!!n.scale,minScale:n.scale?.min??.05,maxScale:n.scale?.max??5}),n.billboard&&(e.billboard={mode:n.billboard}),typeof n.follow=="string"?e.follow={target:n.follow,lazy:!1}:n.follow&&(e.follow={target:n.follow.mode,lazy:!0,distance:n.follow.distance,deadzoneDeg:n.follow.deadzoneDeg,stiffness:n.follow.stiffness,height:n.follow.height,faceUser:n.follow.faceUser}),n.anchor&&(e.anchor={planeType:n.anchor==="vertical"||n.anchor==="wall"?"VERTICAL":"HORIZONTAL",semanticType:n.anchor.toUpperCase()}),n.physics&&(e.rigidbody={type:n.physics}),n.orbit&&(e.orbit={...n.orbit}),n.handles&&(e.resizable={...n.handles}),n.particles&&(e.particles={...n.particles}),n.holdToAsk&&(e.holdToAsk={...n.holdToAsk}),n.worldUnderstanding&&(e.worldUnderstanding={...n.worldUnderstanding}),n.splatUrl&&(e.splat={url:n.splatUrl}),n.spatialSlot&&(e.spatialPanel={slot:n.spatialSlot}),n.audio&&(e.spatialAudio={...n.audio}),e}function Ar(n){let e={},t=(r,i)=>{for(let[o,c]of Object.entries(i)){let m=r+o[0].toUpperCase()+o.slice(1);typeof c=="string"||typeof c=="number"||typeof c=="boolean"?e[m]=c:qt(c)&&(e[m]=[c[0],c[1],c[2]])}};return n.grab&&(e.grab=n.grab),n.scale&&t("scale",n.scale),n.billboard&&(e.billboard=n.billboard),typeof n.follow=="string"?e.follow=n.follow:n.follow&&(e.follow=n.follow.mode,t("follow",{...n.follow,mode:void 0})),n.anchor&&(e.anchor=n.anchor),n.physics&&(e.physics=n.physics),n.orbit&&t("orbit",n.orbit),n.handles&&(e.handles=!0,t("handles",n.handles)),n.particles&&t("particles",n.particles),n.holdToAsk&&(e.holdToAsk=!0,t("holdToAsk",n.holdToAsk)),n.worldUnderstanding&&t("worldUnderstanding",n.worldUnderstanding),n.splatUrl&&(e.splatUrl=n.splatUrl),n.spatialSlot&&(e.spatialSlot=n.spatialSlot),n.audio&&t("audio",n.audio),n.pointerEvents&&(e.pointerEvents=n.pointerEvents),e}function _r(n,e){let t=lt(e);t&&(n.extras={...n.extras,xr:{...n.extras?.xr,...t}},n.extensions={...n.extensions,MOZ_hubs_components:Zt(t),ANDROID_xr_scenecore:jt(t)})}function Zt(n){let e={};return n.grab&&(e.grabbable={cursor:!0,hand:!0}),n.billboard&&(e.billboard={onlyY:n.billboard!=="spherical"}),e}function Dr(n,e){let t=lt(n),r=[];if(!t)return r;for(let[i,o]of Object.entries(Ar(t)))/^[A-Za-z][A-Za-z0-9]{0,63}$/.test(i)&&(typeof o=="boolean"?r.push(`bool ${i} = ${o}`):typeof o=="number"?Number.isFinite(o)&&r.push(`double ${i} = ${o}`):typeof o=="string"?r.push(`string ${i} = "${e(o)}"`):o.length===3&&o.every(c=>Number.isFinite(c))&&r.push(`double3 ${i} = (${o.join(", ")})`));return r}function Rn(){try{Object.defineProperty(j(),"xrTraitSerializer",{value:Object.freeze({gltfNode:_r,usdLines:Dr}),writable:!1,configurable:!1,enumerable:!0})}catch{}}var ht=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}},q=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,o=e.z,c=t.x,m=t.y,u=t.z;return this.x=i*u-o*m,this.y=o*c-r*u,this.z=r*m-i*c,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)}applyMatrix4(e){let t=this.x,r=this.y,i=this.z,o=e.elements,c=1/(o[3]*t+o[7]*r+o[11]*i+o[15]);return this.x=(o[0]*t+o[4]*r+o[8]*i+o[12])*c,this.y=(o[1]*t+o[5]*r+o[9]*i+o[13])*c,this.z=(o[2]*t+o[6]*r+o[10]*i+o[14])*c,this}},mt=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}},He=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}},Xe=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,o=e.z,c=Math.cos(r/2),m=Math.cos(i/2),u=Math.cos(o/2),a=Math.sin(r/2),s=Math.sin(i/2),h=Math.sin(o/2);return this._x=a*m*u+c*s*h,this._y=c*s*u-a*m*h,this._z=c*m*h+a*s*u,this._w=c*m*u-a*s*h,t&&this._onChangeCallback?.(),this}setFromAxisAngle(e,t){let r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback?.(),this}multiply(e){return this.multiplyQuaternions(this,e)}multiplyQuaternions(e,t){let r=e.x,i=e.y,o=e.z,c=e.w,m=t.x,u=t.y,a=t.z,s=t.w;return this._x=r*s+c*m+i*a-o*u,this._y=i*s+c*u+o*m-r*a,this._z=o*s+c*a+r*u-i*m,this._w=c*s-r*m-i*u-o*a,this._onChangeCallback?.(),this}_onChange(e){return this._onChangeCallback=e,this}},ye=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 it(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 re(this.elements,e.elements,t.elements),this}lookAt(e,t,r){return rt(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 q(0,0,0),r=new q(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}},ft=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 ae(this.elements,e.elements),this}},he=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)}},Ln={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)},X=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 o=e*this.itemSize;return this.array[o]=t,this.array[o+1]=r,this.array[o+2]=i,this.needsUpdate=!0,this}},dt=class extends X{constructor(e,t){super(e instanceof Float32Array?e:new Float32Array(e),t)}},pt=class extends X{constructor(e,t){super(e instanceof Uint16Array?e:new Uint16Array(e),t)}},bt=class extends X{constructor(e,t){super(e instanceof Uint32Array?e:new Uint32Array(e),t)}},ce=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 X)this.index=e;else if(Array.isArray(e)){let t=0;for(let i=0;i<e.length;i++)e[i]>t&&(t=e[i]);let r=t>65535?new Uint32Array(e):new Uint16Array(e);this.index=new X(r,1)}else e&&e.buffer&&(this.index=new X(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 q,o=new q,c=new q,m=new q,u=new q;if(this.index){let a=this.index.array;for(let s=0;s<a.length;s+=3){let h=a[s],l=a[s+1],p=a[s+2];i.set(e.getX(h),e.getY(h),e.getZ(h)),o.set(e.getX(l),e.getY(l),e.getZ(l)),c.set(e.getX(p),e.getY(p),e.getZ(p)),m.subVectors(c,o),u.subVectors(i,o),m.cross(u).normalize();for(let f of[h,l,p])r[f*3]+=m.x,r[f*3+1]+=m.y,r[f*3+2]+=m.z}}else for(let a=0;a<t;a+=3){i.set(e.getX(a),e.getY(a),e.getZ(a)),o.set(e.getX(a+1),e.getY(a+1),e.getZ(a+1)),c.set(e.getX(a+2),e.getY(a+2),e.getZ(a+2)),m.subVectors(c,o),u.subVectors(i,o),m.cross(u).normalize();for(let s=0;s<3;s++)r[(a+s)*3]=m.x,r[(a+s)*3+1]=m.y,r[(a+s)*3+2]=m.z}for(let a=0;a<t;a++){let s=r[a*3],h=r[a*3+1],l=r[a*3+2],p=Math.hypot(s,h,l)||1;r[a*3]=s/p,r[a*3+1]=h/p,r[a*3+2]=l/p}return this.setAttribute("normal",new X(r,3)),this}setFromBuffers(e,t,r,i){this.setAttribute("position",new X(e instanceof Float32Array?e:new Float32Array(e),3)),this.setAttribute("normal",new X(t instanceof Float32Array?t:new Float32Array(t),3)),this.setAttribute("uv",new X(r instanceof Float32Array?r:new Float32Array(r),2)),this.setIndex(i)}dispose(){}},Ge=class extends ce{constructor(e=1,t=1,r=1){super();{let h=globalThis.__three_live_native_box__;if(typeof h=="function"){let l=h(e,t,r);this.setFromBuffers(l.positions,l.normals,l.uvs,l.indices);return}}let i=e/2,o=t/2,c=r/2,m=[-i,-o,c,i,-o,c,i,o,c,-i,o,c,i,-o,-c,-i,-o,-c,-i,o,-c,i,o,-c,-i,o,c,i,o,c,i,o,-c,-i,o,-c,-i,-o,-c,i,-o,-c,i,-o,c,-i,-o,c,i,-o,c,i,-o,-c,i,o,-c,i,o,c,-i,-o,-c,-i,-o,c,-i,o,c,-i,o,-c],u=[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],a=[0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1],s=[];for(let h=0;h<6;h++){let l=h*4;s.push(l,l+1,l+2,l,l+2,l+3)}this.setAttribute("position",new X(new Float32Array(m),3)),this.setAttribute("normal",new X(new Float32Array(u),3)),this.setAttribute("uv",new X(new Float32Array(a),2)),this.setIndex(s)}},yt=class extends ce{constructor(e=1,t=1){super();let r=e/2,i=t/2,o=[-r,i,0,r,i,0,-r,-i,0,r,-i,0],c=[0,0,1,0,0,1,0,0,1,0,0,1],m=[0,1,1,1,0,0,1,0],u=[0,2,1,2,3,1];this.setAttribute("position",new X(new Float32Array(o),3)),this.setAttribute("normal",new X(new Float32Array(c),3)),this.setAttribute("uv",new X(new Float32Array(m),2)),this.setIndex(u)}},We=class extends ce{constructor(e=1,t=16,r=12){super(),t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));{let a=globalThis.__three_live_native_sphere__;if(typeof a=="function"){let s=a(e,t,r);this.setAttribute("position",new X(s.positions,3)),this.setAttribute("normal",new X(s.normals,3)),this.setAttribute("uv",new X(s.uvs,2)),this.setIndex(s.indices);return}}let i=[],o=[],c=[],m=[],u=[];for(let a=0;a<=r;a++){let s=[],h=a/r;for(let l=0;l<=t;l++){let p=l/t,f=p*Math.PI*2,T=h*Math.PI,M=-e*Math.cos(f)*Math.sin(T),R=e*Math.cos(T),I=e*Math.sin(f)*Math.sin(T);i.push(M,R,I);let y=Math.hypot(M,R,I)||1;o.push(M/y,R/y,I/y),c.push(p,1-h),s.push(i.length/3-1)}u.push(s)}for(let a=0;a<r;a++)for(let s=0;s<t;s++){let h=u[a][s+1],l=u[a][s],p=u[a+1][s],f=u[a+1][s+1];a!==0&&m.push(h,l,f),a!==r-1&&m.push(l,p,f)}this.setAttribute("position",new X(new Float32Array(i),3)),this.setAttribute("normal",new X(new Float32Array(o),3)),this.setAttribute("uv",new X(new Float32Array(c),2)),this.setIndex(m)}},Ee=class extends ce{constructor(e=1,t=1,r=1,i=16){super(),i=Math.max(3,Math.floor(i));{let s=globalThis.__three_live_native_cylinder__;if(typeof s=="function"){let h=s(e,t,r,i);this.setAttribute("position",new X(h.positions,3)),this.setAttribute("normal",new X(h.normals,3)),this.setAttribute("uv",new X(h.uvs,2)),this.setIndex(h.indices);return}}let o=[],c=[],m=[],u=[],a=r/2;for(let s=0;s<=1;s++){let h=s,l=s===0?e:t,p=s===0?a:-a;for(let f=0;f<=i;f++){let T=f/i,M=T*Math.PI*2,R=Math.sin(M),I=Math.cos(M);o.push(l*R,p,l*I),c.push(R,0,I),m.push(T,1-h)}}for(let s=0;s<i;s++){let h=s,l=s+i+1,p=s+i+2,f=s+1;u.push(h,l,f,l,p,f)}if(e>0){let s=o.length/3;o.push(0,a,0),c.push(0,1,0),m.push(.5,.5);let h=o.length/3;for(let l=0;l<=i;l++){let p=l/i*Math.PI*2,f=Math.sin(p),T=Math.cos(p);o.push(e*f,a,e*T),c.push(0,1,0),m.push(T*.5+.5,f*.5+.5)}for(let l=0;l<i;l++)u.push(s,h+l,h+l+1)}if(t>0){let s=o.length/3;o.push(0,-a,0),c.push(0,-1,0),m.push(.5,.5);let h=o.length/3;for(let l=0;l<=i;l++){let p=l/i*Math.PI*2,f=Math.sin(p),T=Math.cos(p);o.push(t*f,-a,t*T),c.push(0,-1,0),m.push(T*.5+.5,1-(f*.5+.5))}for(let l=0;l<i;l++)u.push(s,h+l+1,h+l)}this.setAttribute("position",new X(new Float32Array(o),3)),this.setAttribute("normal",new X(new Float32Array(c),3)),this.setAttribute("uv",new X(new Float32Array(m),2)),this.setIndex(u)}},gt=class extends Ee{constructor(e=1,t=1,r=16){super(0,e,t,r)}},xt=class extends ce{constructor(e=1,t=.4,r=12,i=32){super(),r=Math.max(3,Math.floor(r)),i=Math.max(3,Math.floor(i));let o=[],c=[],m=[],u=[];for(let a=0;a<=r;a++){let s=a/r*Math.PI*2;for(let h=0;h<=i;h++){let l=h/i*Math.PI*2,p=(e+t*Math.cos(s))*Math.cos(l),f=(e+t*Math.cos(s))*Math.sin(l),T=t*Math.sin(s);o.push(p,f,T);let M=e*Math.cos(l),R=e*Math.sin(l),I=p-M,y=f-R,E=T,g=Math.hypot(I,y,E)||1;c.push(I/g,y/g,E/g),m.push(h/i,a/r)}}for(let a=1;a<=r;a++)for(let s=1;s<=i;s++){let h=(i+1)*a+s-1,l=(i+1)*(a-1)+s-1,p=(i+1)*(a-1)+s,f=(i+1)*a+s;u.push(h,l,f,l,p,f)}this.setAttribute("position",new X(new Float32Array(o),3)),this.setAttribute("normal",new X(new Float32Array(c),3)),this.setAttribute("uv",new X(new Float32Array(m),2)),this.setIndex(u)}},vt=class extends ce{constructor(e=1,t=.4,r=64,i=8,o=2,c=3){super(),r=Math.floor(r),i=Math.floor(i);{let y=globalThis.__three_live_native_torus_knot__;if(typeof y=="function"){let E=y(e,t,r,i,o,c);this.setAttribute("position",new X(E.positions,3)),this.setAttribute("normal",new X(E.normals,3)),this.setAttribute("uv",new X(E.uvs,2)),this.setIndex(E.indices);return}}let m=[],u=[],a=[],s=[],h=new q,l=new q,p=new q,f=new q,T=new q;function M(y,E){let g=Math.cos(E),A=Math.sin(E),b=c/o*E,w=e*(2+Math.cos(b))*.5;y.set(w*g,w*A,e*Math.sin(b)*.5)}let R=[];for(let y=0;y<=i;++y){let E=y/i*Math.PI*2;R.push(-t*Math.cos(E),t*Math.sin(E),y/i)}for(let y=0;y<=r;++y){let E=y/r,g=E*o*Math.PI*2;M(h,g),M(l,g+.01),p.subVectors(l,h).normalize(),f.addVectors(h,l).normalize(),T.crossVectors(p,f).normalize(),f.crossVectors(T,p).normalize();for(let A=0;A<=i;++A){let b=A*3,w=R[b],v=R[b+1],_=R[b+2],C=w*f.x+v*T.x,d=w*f.y+v*T.y,S=w*f.z+v*T.z;m.push(h.x+C,h.y+d,h.z+S);let x=Math.hypot(C,d,S)||1;u.push(C/x,d/x,S/x),a.push(E,_)}}let I=i+1;for(let y=1;y<=r;y++){let E=I*(y-1),g=E+I;for(let A=1;A<=i;A++){let b=E+(A-1),w=g+(A-1),v=g+A,_=E+A;s.push(b,w,_,w,v,_)}}this.setAttribute("position",new X(new Float32Array(m),3)),this.setAttribute("normal",new X(new Float32Array(u),3)),this.setAttribute("uv",new X(new Float32Array(a),2)),this.setIndex(s)}},$e=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(){}},Tt=class{load(e,t){let r=new $e(e);return t?.(r),r}};function te(n,e){return n!==void 0?Number(n):e}function Jt(n,e){return n!==void 0?!!n:e}var me=class{constructor(e={}){this.name=e.name||"",this.color=new he(e.color!==void 0?e.color:16777215),this.emissive=new he(e.emissive!==void 0?e.emissive:0),this.emissiveIntensity=te(e.emissiveIntensity,1),this.roughness=te(e.roughness,.5),this.metalness=te(e.metalness,.1),this.opacity=te(e.opacity,1),this.transparent=Jt(e.transparent,!1),this.wireframe=Jt(e.wireframe,!1),this.side=te(e.side,2),this.doubleSided=Jt(e.doubleSided,!0),this.map=e.map||null,this.clearcoat=te(e.clearcoat,0),this.clearcoatRoughness=te(e.clearcoatRoughness,0),this.sheen=te(e.sheen,0),this.sheenColor=new he(e.sheenColor!==void 0?e.sheenColor:0),this.sheenRoughness=te(e.sheenRoughness,0),this.transmission=te(e.transmission,0),this.thickness=te(e.thickness,0),this.attenuationColor=new he(e.attenuationColor!==void 0?e.attenuationColor:16777215),this.attenuationDistance=te(e.attenuationDistance,1/0),this.ior=te(e.ior,1.5),this.dispersion=te(e.dispersion,0),this.iridescence=te(e.iridescence,0),this.iridescenceIOR=te(e.iridescenceIOR,1.3)}dispose(){}},Se=class extends me{},wt=class extends me{},Et=class extends me{},Mt=class extends me{},Rt=class extends me{},ie=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 q,this.rotation=new He,this.quaternion=new Xe,this.scale=new q(1,1,1),this.matrix=new ye,this.matrixWorld=new ye,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){(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 q(e,t,r);this.updateMatrixWorld(!0);let o=new ye;o.lookAt(this.position,i,new q(0,1,0));let c=o.elements,m=c[0],u=c[4],a=c[8],s=c[1],h=c[5],l=c[9],p=c[2],f=c[6],T=c[10],M=m+h+T;if(M>0){let R=.5/Math.sqrt(M+1);this.quaternion.set((f-l)*R,(a-p)*R,(s-u)*R,.25/R)}}},St=class extends ie{},Pe=class extends ie{constructor(t,r){super();this.isMesh=!0;let i=Array.isArray(r)?r[0]:r;this.geometry=t instanceof ce?t:t?(oe("unsupported geometry","BoxGeometry"),new Ge(.5,.5,.5)):new ce,this.material=i instanceof me?i:i?(oe("unsupported material","MeshStandardMaterial"),new Se({color:13421772})):new Se}},Me=class extends ie{constructor(e=16777215,t=1){super(),this.color=new he(e),this.intensity=Number(t),this.type="directional"}},Ye=class extends Me{constructor(e,t){super(e,t),this.type="ambient"}},At=class extends Me{constructor(t,r){super(t,r);this.target=new ie;this.type="directional"}},qe=class extends Me{constructor(t,r,i=0,o=2){super(t,r);this.distance=0;this.decay=2;this.type="point",this.distance=i,this.decay=o}},Ke=class extends ie{},Ue=class extends Ke{constructor(t=45,r=1,i=.1,o=1e3){super();this.target=new q(0,0,0);this.fov=Number(t),this.aspect=Number(r),this.near=Number(i),this.far=Number(o)}},Ae=class extends ie{constructor(){super(...arguments);this.background=null;this.environmentIntensity=1}toCanvas3D(){return pe.validate(this),Ce(this)}toGLB(){return pe.validate(this),Be(this)}toUSDZ(){return pe.validate(this),Ie(this)}getMeshTransforms(){this.updateMatrixWorld(!0);let t=new Map,r=0;return this.traverse(i=>{if(i instanceof Pe){let o=new Float32Array(i.matrixWorld.elements);t.set(r,o),i.name&&t.set(i.name,o),r++}}),t}},Qt=Ce,en=Be,Pn=Ie;var pe=class{static validate(e){let t=0,r=0,i=0,o=new Set,c=(u,a,s)=>{throw new Error(`SecurityError: Scene exceeds SECURITY_3D_MAX_${u} (${a}). Found: ${s}`)},m=(u,a)=>{if(!Number.isFinite(a))throw new Error(`SecurityError: Scene reports a non-finite ${u} count (${String(a)}), which cannot be bounds-checked.`);return a};e.traverse(u=>{if(u instanceof Pe){i++,i>1e3&&c("MESHES",1e3,i);let a=u.geometry;if(a){let s=0;if(a.attributes.position&&(s=m("vertex",a.attributes.position.count),t+=s,t>1e5&&c("VERTICES",1e5,t)),a.index){let h=m("index",a.index.count);r+=h,r>3e5&&c("INDICES",3e5,r);let l=a.index.array;if(l&&s>0){let p=Math.min(h,l.length);for(let f=0;f<p;f++){let T=l[f];if(!Number.isFinite(T)||T<0||T>=s)throw new Error(`SecurityError: Index buffer value (${String(T)}) out of vertex bounds [0, ${s}).`)}}}}if(u.material){let s=u.material;s.map&&o.add(s.map),s.normalMap&&o.add(s.normalMap),s.roughnessMap&&o.add(s.roughnessMap)}}}),o.size>16&&c("TEXTURES",16,o.size);for(let u of o){let a=u,s=a.image,h=Number(s?.width??a.width??0)||0,l=Number(s?.height??a.height??0)||0;(!Number.isFinite(h)||!Number.isFinite(l)||h>2048||l>2048)&&c("TEXTURE_DIMENSION",2048,Math.max(h,l))}}},_t=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 he(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){pe.validate(e);let i=(o,c)=>{typeof self<"u"&&typeof self.postMessage=="function"&&(c&&c.length?self.postMessage(o,c):self.postMessage(o))};if(this.hasInitialModelRendered){let o=e.getMeshTransforms(),c={};for(let[m,u]of o.entries())c[m]=Array.from(u);i({type:"3D_UPDATE_TRANSFORMS",containerId:this.containerId,transforms:c})}else{this.hasInitialModelRendered=!0;let o=Qt(e),c=en(e),m=(o.lights||[]).map(u=>({type:u.type,color:u.color,intensity:u.intensity,position:u.position}));i({type:"3D_MODEL_READY",containerId:this.containerId,glbBuffer:c.buffer,dynamicLights:m,camera:t?{fov:t.fov||60,position:[t.position.x,t.position.y,t.position.z]}:void 0},[c.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 Sn(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Dt=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=Sn(),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=Sn();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Cr(){}var Le=new Proxy(Cr,{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:Le},getPrototypeOf:()=>null,setPrototypeOf:()=>!1,apply:()=>Le,construct:()=>Le}),An=(()=>{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 Fe(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"&&location.href?location.href:"https://localhost/"}function Re(n,e){if(!n||typeof n!="string")return!1;let t=n.trim();if(!t)return!1;try{let r=new URL(t,Fe());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 _n,ze;function Un(n){if(!Re(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(ze===void 0||_n!==t){_n=t;try{ze=t.createPolicy("three-live#worker",{createScriptURL:r=>{if(!Re(r))throw new TypeError(`SecurityError: Disallowed Three-Live worker script URL "${r}".`);return r}})}catch{ze=null}}return ze?ze.createScriptURL(n):n}function Ir(n){j().sandboxEngineSrc=n}function tn(){let n=j().sandboxEngineSrc;if(n)return n;if(An)return An;try{if(typeof document>"u")return null;let e=Fe(),t=Array.from(document.querySelectorAll("script[src]"));for(let r of t){let i=r.src;if(!i)continue;let o=new URL(i,e).pathname;if(/(?:^|\/)(?:three|xr)-live[^/]*\.js$/.test(o)&&Re(i,{requireSameOrigin:!0}))return i}}catch{}return null}function Lr(){let n=tn();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(!Re(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,Fe()).href}function Pr(n){j().sandboxIframeSrc=n}function Fn(){let n=j().sandboxIframeSrc;if(n)return n;let e=tn();if(!e||!Re(e))return null;let t=new URL(e,Fe());return t.protocol==="blob:"?null:new URL("three-live-sandbox.html",t).href}function Ur(){let n=Fn();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(!Re(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,Fe()).href}function Fr(n){j().allowClientScripts=n}function Nn(){return!!j().allowClientScripts}function Nr(n){if(!Re(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,Fe()).href}var kr=["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 Or(n){let e=self,t=n.nonce,r=n.engineSrc,i=n.allowedScriptUrl,o=n.allowClientScripts,c=n.revoked,m=e.postMessage.bind(e);function u(g){m({type:"ERROR",nonce:t,message:String(g)})}let a=typeof e.importScripts=="function"?e.importScripts.bind(e):null,s=i,h=null;try{let g=r;if(typeof e.trustedTypes<"u"&&e.trustedTypes&&typeof e.trustedTypes.createPolicy=="function")try{let A={createScriptURL:function(w){if(w!==r&&(!i||w!==i))throw new TypeError("Disallowed worker importScripts URL");return w}};o&&(A.createScript=function(w){return String(w)});let b=e.trustedTypes.createPolicy("three-live#worker-boot",A);g=b.createScriptURL(r),i&&(s=b.createScriptURL(i)),o&&typeof b.createScript=="function"&&(h=b.createScript.bind(b))}catch{}a(g)}catch(g){u('Sandbox failed to load the Three-Live engine from "'+r+'". It must be a same-origin (or CORS-enabled) IIFE bundle such as three-live.min.js. Underlying error: '+(g&&g.message||g));return}let l=e.THREE;if(!l||typeof l.Scene!="function"){u('Sandbox loaded "'+r+'" but it did not install a THREE namespace. Point sandboxEngineSrc at an IIFE build (three-live.min.js), not an ES module build.');return}for(let g=0;g<c.length;g++){let A=c[g],b=e;for(;b&&b!==Object.prototype;){if(b!==e)try{delete b[A]}catch{}try{Object.defineProperty(b,A,{value:void 0,writable:!1,configurable:!1,enumerable:!1})}catch{}try{b=Object.getPrototypeOf(b)}catch{break}}}let p=Object.freeze({now:function(){return Date.now()}}),f=e;for(;f&&f!==Object.prototype;){if(f!==e)try{delete f.performance}catch{}try{Object.defineProperty(f,"performance",{value:p,writable:!1,configurable:!1,enumerable:!1})}catch{}try{f=Object.getPrototypeOf(f)}catch{break}}let T=["3D_MODEL_READY","3D_UPDATE_TRANSFORMS"],M=!1;function R(g,A){if(g.type==="3D_MODEL_READY"){if(M)return;M=!0}g.nonce=t,A&&A.length?m(g,A):m(g)}let I=function(g,A){if(!g||T.indexOf(g.type)===-1)throw new Error("Sandboxed scripts may only post Three-Live scene messages ("+T.join(", ")+").");R(g,A)},y=e;for(;y&&y!==Object.prototype;){if(y===e||Object.prototype.hasOwnProperty.call(y,"postMessage"))try{Object.defineProperty(y,"postMessage",{value:I,writable:!1,configurable:!1})}catch{}try{y=Object.getPrototypeOf(y)}catch{break}}let E=!1;e.onmessage=function(g){let A=g&&g.data;if(!(!A||A.nonce!==t)&&!(A.type!=="EXECUTE"&&A.type!=="EXECUTE_URL")&&!E){E=!0;try{let b=new l.Scene,w=new l.PerspectiveCamera(60,1,.1,1e3),v=new l.WebGLRenderer({isSandboxed:!0});if(A.type==="EXECUTE_URL"){if(!i||A.scriptUrl!==i||typeof a!="function"){u("SecurityError: Refusing to execute unapproved script URL inside sandbox worker.");return}let _=s||i,C=a;if(a=null,s=null,e.THREE=l,e.scene=b,e.camera=w,e.renderer=v,C(_),typeof e.__THREE_LIVE_SCENE__=="function"){let d=e.__THREE_LIVE_SCENE__(l,b,w,v);d&&typeof d.toGLB=="function"&&(b=d)}else e.scene&&typeof e.scene.toGLB=="function"&&(b=e.scene)}else{if(!o){u("SecurityError: Client-modified script compilation (Use Case 1) is disabled in this sandbox worker.");return}let _=h?(0,eval)(h(`(function (THREE, scene, camera, renderer) {
|
|
291
|
+
`,c}function fr(n,e){if(n&&typeof n.traverse=="function"){let i=lr(n,e);return $t(i)}let t=Be(n),r=En(t);return $t(r)}var ct=null;function dr(n){{let t=globalThis.__three_live_native_crc32__;if(typeof t=="function")return t(n)}if(!ct){ct=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;ct[t]=r}}let e=4294967295;for(let t=0;t<n.length;t++)e=ct[(e^n[t])&255]^e>>>8;return(e^4294967295)>>>0}function Mn(n){{let a=globalThis.__three_live_native_build_usdz_zip__;if(typeof a=="function")return a(n)}let e=[],t=0,r=[];for(let a of n){let h=ut(a.filename),l=dr(a.data),d=a.data.length,f=30+h.length,T=t+f,A=0,S=T%64;S!==0&&(A=64-S);let L=new Uint8Array(f+A),b=new DataView(L.buffer);b.setUint32(0,67324752,!0),b.setUint16(4,20,!0),b.setUint16(6,0,!0),b.setUint16(8,0,!0),b.setUint16(10,0,!0),b.setUint16(12,0,!0),b.setUint32(14,l,!0),b.setUint32(18,d,!0),b.setUint32(22,d,!0),b.setUint16(26,h.length,!0),b.setUint16(28,A,!0),L.set(h,30),A>0&&L.fill(0,30+h.length),e.push({offset:t,size:d,crc:l,filenameBytes:h,entry:a}),r.push(L),r.push(a.data),t+=L.length+a.data.length}let i=t;for(let a of e){let h=new Uint8Array(46+a.filenameBytes.length),l=new DataView(h.buffer);l.setUint32(0,33639248,!0),l.setUint16(4,20,!0),l.setUint16(6,20,!0),l.setUint16(8,0,!0),l.setUint16(10,0,!0),l.setUint16(12,0,!0),l.setUint16(14,0,!0),l.setUint32(16,a.crc,!0),l.setUint32(20,a.size,!0),l.setUint32(24,a.size,!0),l.setUint16(28,a.filenameBytes.length,!0),l.setUint16(30,0,!0),l.setUint16(32,0,!0),l.setUint16(34,0,!0),l.setUint16(36,0,!0),l.setUint32(38,0,!0),l.setUint32(42,a.offset,!0),h.set(a.filenameBytes,46),r.push(h),t+=h.length}let s=t-i,c=new Uint8Array(22),m=new DataView(c.buffer);m.setUint32(0,101010256,!0),m.setUint16(4,0,!0),m.setUint16(6,0,!0),m.setUint16(8,e.length,!0),m.setUint16(10,e.length,!0),m.setUint32(12,s,!0),m.setUint32(16,i,!0),m.setUint16(20,0,!0),r.push(c),t+=22;let u=new Uint8Array(t),o=0;for(let a of r)u.set(a,o),o+=a.length;return u}function Le(n){let e=fr(n),t=ut(e);return Mn([{filename:"model.usda",data:t}])}function lt(n){let e=Be(n),t=En(e),r=$t(t),i=ut(r);return Mn([{filename:"model.usda",data:i}])}function Yt(n){return n&&typeof n.toUSDZ=="function"?n.toUSDZ():n&&typeof n.traverse=="function"?Le(n):lt(n)}function Q(n,e,t,r){let i=typeof n=="number"&&Number.isFinite(n)?n:r;return Math.max(e,Math.min(t,i))}function jt(n){return Array.isArray(n)&&n.length>=3&&Number.isFinite(n[0])&&Number.isFinite(n[1])&&Number.isFinite(n[2])}function le(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Kt(n,e=256){return typeof n=="string"&&n.length>0?n.slice(0,e):void 0}function pr(n){let e=le(n);if(!e||e.lazy===!1)return null;let t=e.mode==="hand-left"||e.mode==="hand-right"?e.mode:"head",r=t!=="head";return{mode:t,lazy:!0,distance:Q(e.distance,.1,10,r?.15:1),deadzoneDeg:Q(e.deadzoneDeg,0,90,r?0:15),stiffness:Q(e.stiffness,.5,40,6),height:Q(e.height,-2,2,r?.12:-.1),faceUser:e.faceUser!==!1,snapOnStart:e.snapOnStart!==!1}}function br(n){let e=le(n);if(!e)return null;let t=e.target;return{target:jt(t)?[t[0],t[1],t[2]]:typeof t=="string"&&t.length>0&&t.length<=256?t:[0,0,0],radius:Q(e.radius,.01,50,.5),speed:Q(e.speed,-20,20,.5),height:Q(e.height,-10,10,0),phase:Q(e.phase,-1e6,1e6,0),faceCenter:e.faceCenter===!0}}function yr(n){if(!n)return null;let e=le(n)??{},t=Q(e.minScale,.001,1e3,.1),r=Q(e.maxScale,t,1e3,Math.max(t,10));return{rotateAxis:e.rotateAxis==="none"?"none":"y",minScale:t,maxScale:r}}var gr=2e3,xr={rain:600,snow:400,sparks:300,confetti:300};function vr(n){let e=le(n);if(!e)return null;let t=e.preset==="snow"||e.preset==="sparks"||e.preset==="confetti"?e.preset:"rain",r=e.area,i=c=>Q(c,.05,50,2),s=jt(r)?[i(r[0]),i(r[1]),i(r[2])]:typeof r=="number"?[i(r),i(r),i(r)]:[2,2,2];return{preset:t,count:Math.round(Q(e.count,1,gr,xr[t])),area:s,speed:Q(e.speed,.05,10,1)}}var wr=4e3;function Tr(n){if(!n)return null;let e=le(n)??{};return{prompt:Kt(e.prompt,wr)??"What is this?",holdMs:Q(e.holdMs,100,5e3,600)}}function Er(n){if(!n)return null;let e=le(n)??{};return{planes:e.planes!==!1,meshes:e.meshes===!0,reticle:e.reticle===!0,objects:e.objects===!0}}function qt(n){let e=Kt(n,4096)?.trim();if(!(!e||/[\x00-\x20\\%]/.test(e))){if(/^https:\/\/[^/]/i.test(e))return e;if(!(e.startsWith("//")||/^[a-z][a-z0-9+.-]*:/i.test(e)))return e.split(/[/?#]/).includes("..")?void 0:e}}function Mr(n){if(typeof n=="string"){let r=qt(n);return r?{src:r,refDistance:1,loop:!1}:null}let e=le(n),t=qt(e?.src);return!e||!t?null:{src:t,refDistance:Q(e.refDistance,.01,1e3,1),loop:e.loop===!0}}var Rr=new Set(["horizontal","vertical","floor","wall","table"]),Sr=new Set(["capsule","cylindrical","spherical"]);function ht(n){let e=le(n);if(!e)return null;let t=Array.isArray(e.traits)?e.traits:[],r=b=>t.includes(b),i={},s=e.grab;s==="1-hand"||s==="2-hand"?i.grab=s:(s===!0||e.grabbable===!0||r("grab"))&&(i.grab="2-hand"),i.grab&&(i.grabbable=!0);let c=e.scale??e.scalable;if(c||r("scale")){let b=le(c)??{},w=Q(b.min,.001,1e3,.05);i.scale={min:w,max:Q(b.max,w,1e3,Math.max(w,5))},i.scalable=!0}let m=e.billboard;typeof m=="string"&&Sr.has(m)?i.billboard=m:(m===!0||r("billboard"))&&(i.billboard="capsule");let u=e.follow,o=typeof u=="string"?u:le(u)?.mode;if(typeof u=="string"?u:le(u)?.lazy===!1)i.follow=o==="hand-left"||o==="hand-right"?o:"head";else{let b=pr(u);b&&(i.follow=b)}let a=e.anchor;typeof a=="string"&&Rr.has(a)&&(i.anchor=a),(e.physics==="dynamic"||e.physics==="static")&&(i.physics=e.physics);let h=br(e.orbit);h&&(i.orbit=h);let l=yr(e.handles);l&&(i.handles=l);let d=vr(e.particles);d&&(i.particles=d);let f=Tr(e.holdToAsk);f&&(i.holdToAsk=f);let T=Er(e.worldUnderstanding);T&&(i.worldUnderstanding=T);let A=qt(e.splatUrl);A&&(i.splatUrl=A);let S=Kt(e.spatialSlot);S&&(i.spatialSlot=S);let L=Mr(e.audio);return L&&(i.audio=L),e.pointerEvents==="none"&&(i.pointerEvents="none"),Object.keys(i).length>0?i:null}function Zt(n){let e={};return n.grab&&(e.interactable={mode:n.grab},e.movable={systemMovable:!0,scaleInZ:!!n.scale,minScale:n.scale?.min??.05,maxScale:n.scale?.max??5}),n.billboard&&(e.billboard={mode:n.billboard}),typeof n.follow=="string"?e.follow={target:n.follow,lazy:!1}:n.follow&&(e.follow={target:n.follow.mode,lazy:!0,distance:n.follow.distance,deadzoneDeg:n.follow.deadzoneDeg,stiffness:n.follow.stiffness,height:n.follow.height,faceUser:n.follow.faceUser}),n.anchor&&(e.anchor={planeType:n.anchor==="vertical"||n.anchor==="wall"?"VERTICAL":"HORIZONTAL",semanticType:n.anchor.toUpperCase()}),n.physics&&(e.rigidbody={type:n.physics}),n.orbit&&(e.orbit={...n.orbit}),n.handles&&(e.resizable={...n.handles}),n.particles&&(e.particles={...n.particles}),n.holdToAsk&&(e.holdToAsk={...n.holdToAsk}),n.worldUnderstanding&&(e.worldUnderstanding={...n.worldUnderstanding}),n.splatUrl&&(e.splat={url:n.splatUrl}),n.spatialSlot&&(e.spatialPanel={slot:n.spatialSlot}),n.audio&&(e.spatialAudio={...n.audio}),e}function Ar(n){let e={},t=(r,i)=>{for(let[s,c]of Object.entries(i)){let m=r+s[0].toUpperCase()+s.slice(1);typeof c=="string"||typeof c=="number"||typeof c=="boolean"?e[m]=c:jt(c)&&(e[m]=[c[0],c[1],c[2]])}};return n.grab&&(e.grab=n.grab),n.scale&&t("scale",n.scale),n.billboard&&(e.billboard=n.billboard),typeof n.follow=="string"?e.follow=n.follow:n.follow&&(e.follow=n.follow.mode,t("follow",{...n.follow,mode:void 0})),n.anchor&&(e.anchor=n.anchor),n.physics&&(e.physics=n.physics),n.orbit&&t("orbit",n.orbit),n.handles&&(e.handles=!0,t("handles",n.handles)),n.particles&&t("particles",n.particles),n.holdToAsk&&(e.holdToAsk=!0,t("holdToAsk",n.holdToAsk)),n.worldUnderstanding&&t("worldUnderstanding",n.worldUnderstanding),n.splatUrl&&(e.splatUrl=n.splatUrl),n.spatialSlot&&(e.spatialSlot=n.spatialSlot),n.audio&&t("audio",n.audio),n.pointerEvents&&(e.pointerEvents=n.pointerEvents),e}function _r(n,e){let t=ht(e);t&&(n.extras={...n.extras,xr:{...n.extras?.xr,...t}},n.extensions={...n.extensions,MOZ_hubs_components:Jt(t),ANDROID_xr_scenecore:Zt(t)})}function Jt(n){let e={};return n.grab&&(e.grabbable={cursor:!0,hand:!0}),n.billboard&&(e.billboard={onlyY:n.billboard!=="spherical"}),e}function Dr(n,e){let t=ht(n),r=[];if(!t)return r;for(let[i,s]of Object.entries(Ar(t)))/^[A-Za-z][A-Za-z0-9]{0,63}$/.test(i)&&(typeof s=="boolean"?r.push(`bool ${i} = ${s}`):typeof s=="number"?Number.isFinite(s)&&r.push(`double ${i} = ${s}`):typeof s=="string"?r.push(`string ${i} = "${e(s)}"`):s.length===3&&s.every(c=>Number.isFinite(c))&&r.push(`double3 ${i} = (${s.join(", ")})`));return r}function Rn(){try{Object.defineProperty(J(),"xrTraitSerializer",{value:Object.freeze({gltfNode:_r,usdLines:Dr}),writable:!1,configurable:!1,enumerable:!0})}catch{}}var mt=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}},j=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,c=t.x,m=t.y,u=t.z;return this.x=i*u-s*m,this.y=s*c-r*u,this.z=r*m-i*c,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)}applyMatrix4(e){let t=this.x,r=this.y,i=this.z,s=e.elements,c=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])*c,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*c,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*c,this}},ft=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}},Xe=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}},Ge=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,c=Math.cos(r/2),m=Math.cos(i/2),u=Math.cos(s/2),o=Math.sin(r/2),a=Math.sin(i/2),h=Math.sin(s/2);return this._x=o*m*u+c*a*h,this._y=c*a*u-o*m*h,this._z=c*m*h+o*a*u,this._w=c*m*u-o*a*h,t&&this._onChangeCallback?.(),this}setFromAxisAngle(e,t){let r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback?.(),this}multiply(e){return this.multiplyQuaternions(this,e)}multiplyQuaternions(e,t){let r=e.x,i=e.y,s=e.z,c=e.w,m=t.x,u=t.y,o=t.z,a=t.w;return this._x=r*a+c*m+i*o-s*u,this._y=i*a+c*u+s*m-r*o,this._z=s*a+c*o+r*u-i*m,this._w=c*a-r*m-i*u-s*o,this._onChangeCallback?.(),this}_onChange(e){return this._onChangeCallback=e,this}},ye=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 st(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 re(this.elements,e.elements,t.elements),this}lookAt(e,t,r){return Ce(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 j(0,0,0),r=new j(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}},dt=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 ae(this.elements,e.elements),this}},he=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)}},Ln={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)},X=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}},pt=class extends X{constructor(e,t){super(e instanceof Float32Array?e:new Float32Array(e),t)}},bt=class extends X{constructor(e,t){super(e instanceof Uint16Array?e:new Uint16Array(e),t)}},yt=class extends X{constructor(e,t){super(e instanceof Uint32Array?e:new Uint32Array(e),t)}},ce=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 X)this.index=e;else if(Array.isArray(e)){let t=0;for(let i=0;i<e.length;i++)e[i]>t&&(t=e[i]);let r=t>65535?new Uint32Array(e):new Uint16Array(e);this.index=new X(r,1)}else e&&e.buffer&&(this.index=new X(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 j,s=new j,c=new j,m=new j,u=new j;if(this.index){let o=this.index.array;for(let a=0;a<o.length;a+=3){let h=o[a],l=o[a+1],d=o[a+2];i.set(e.getX(h),e.getY(h),e.getZ(h)),s.set(e.getX(l),e.getY(l),e.getZ(l)),c.set(e.getX(d),e.getY(d),e.getZ(d)),m.subVectors(c,s),u.subVectors(i,s),m.cross(u).normalize();for(let f of[h,l,d])r[f*3]+=m.x,r[f*3+1]+=m.y,r[f*3+2]+=m.z}}else for(let o=0;o<t;o+=3){i.set(e.getX(o),e.getY(o),e.getZ(o)),s.set(e.getX(o+1),e.getY(o+1),e.getZ(o+1)),c.set(e.getX(o+2),e.getY(o+2),e.getZ(o+2)),m.subVectors(c,s),u.subVectors(i,s),m.cross(u).normalize();for(let a=0;a<3;a++)r[(o+a)*3]=m.x,r[(o+a)*3+1]=m.y,r[(o+a)*3+2]=m.z}for(let o=0;o<t;o++){let a=r[o*3],h=r[o*3+1],l=r[o*3+2],d=Math.hypot(a,h,l)||1;r[o*3]=a/d,r[o*3+1]=h/d,r[o*3+2]=l/d}return this.setAttribute("normal",new X(r,3)),this}setFromBuffers(e,t,r,i){this.setAttribute("position",new X(e instanceof Float32Array?e:new Float32Array(e),3)),this.setAttribute("normal",new X(t instanceof Float32Array?t:new Float32Array(t),3)),this.setAttribute("uv",new X(r instanceof Float32Array?r:new Float32Array(r),2)),this.setIndex(i)}dispose(){}},We=class extends ce{constructor(e=1,t=1,r=1){super();{let h=globalThis.__three_live_native_box__;if(typeof h=="function"){let l=h(e,t,r);this.setFromBuffers(l.positions,l.normals,l.uvs,l.indices);return}}let i=e/2,s=t/2,c=r/2,m=[-i,-s,c,i,-s,c,i,s,c,-i,s,c,i,-s,-c,-i,-s,-c,-i,s,-c,i,s,-c,-i,s,c,i,s,c,i,s,-c,-i,s,-c,-i,-s,-c,i,-s,-c,i,-s,c,-i,-s,c,i,-s,c,i,-s,-c,i,s,-c,i,s,c,-i,-s,-c,-i,-s,c,-i,s,c,-i,s,-c],u=[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],o=[0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1],a=[];for(let h=0;h<6;h++){let l=h*4;a.push(l,l+1,l+2,l,l+2,l+3)}this.setAttribute("position",new X(new Float32Array(m),3)),this.setAttribute("normal",new X(new Float32Array(u),3)),this.setAttribute("uv",new X(new Float32Array(o),2)),this.setIndex(a)}},gt=class extends ce{constructor(e=1,t=1){super();let r=e/2,i=t/2,s=[-r,i,0,r,i,0,-r,-i,0,r,-i,0],c=[0,0,1,0,0,1,0,0,1,0,0,1],m=[0,1,1,1,0,0,1,0],u=[0,2,1,2,3,1];this.setAttribute("position",new X(new Float32Array(s),3)),this.setAttribute("normal",new X(new Float32Array(c),3)),this.setAttribute("uv",new X(new Float32Array(m),2)),this.setIndex(u)}},$e=class extends ce{constructor(e=1,t=16,r=12){super(),t=Math.max(3,Math.floor(t)),r=Math.max(2,Math.floor(r));{let o=globalThis.__three_live_native_sphere__;if(typeof o=="function"){let a=o(e,t,r);this.setAttribute("position",new X(a.positions,3)),this.setAttribute("normal",new X(a.normals,3)),this.setAttribute("uv",new X(a.uvs,2)),this.setIndex(a.indices);return}}let i=[],s=[],c=[],m=[],u=[];for(let o=0;o<=r;o++){let a=[],h=o/r;for(let l=0;l<=t;l++){let d=l/t,f=d*Math.PI*2,T=h*Math.PI,A=-e*Math.cos(f)*Math.sin(T),S=e*Math.cos(T),L=e*Math.sin(f)*Math.sin(T);i.push(A,S,L);let b=Math.hypot(A,S,L)||1;s.push(A/b,S/b,L/b),c.push(d,1-h),a.push(i.length/3-1)}u.push(a)}for(let o=0;o<r;o++)for(let a=0;a<t;a++){let h=u[o][a+1],l=u[o][a],d=u[o+1][a],f=u[o+1][a+1];o!==0&&m.push(h,l,f),o!==r-1&&m.push(l,d,f)}this.setAttribute("position",new X(new Float32Array(i),3)),this.setAttribute("normal",new X(new Float32Array(s),3)),this.setAttribute("uv",new X(new Float32Array(c),2)),this.setIndex(m)}},Ee=class extends ce{constructor(e=1,t=1,r=1,i=16){super(),i=Math.max(3,Math.floor(i));{let a=globalThis.__three_live_native_cylinder__;if(typeof a=="function"){let h=a(e,t,r,i);this.setAttribute("position",new X(h.positions,3)),this.setAttribute("normal",new X(h.normals,3)),this.setAttribute("uv",new X(h.uvs,2)),this.setIndex(h.indices);return}}let s=[],c=[],m=[],u=[],o=r/2;for(let a=0;a<=1;a++){let h=a,l=a===0?e:t,d=a===0?o:-o;for(let f=0;f<=i;f++){let T=f/i,A=T*Math.PI*2,S=Math.sin(A),L=Math.cos(A);s.push(l*S,d,l*L),c.push(S,0,L),m.push(T,1-h)}}for(let a=0;a<i;a++){let h=a,l=a+i+1,d=a+i+2,f=a+1;u.push(h,l,f,l,d,f)}if(e>0){let a=s.length/3;s.push(0,o,0),c.push(0,1,0),m.push(.5,.5);let h=s.length/3;for(let l=0;l<=i;l++){let d=l/i*Math.PI*2,f=Math.sin(d),T=Math.cos(d);s.push(e*f,o,e*T),c.push(0,1,0),m.push(T*.5+.5,f*.5+.5)}for(let l=0;l<i;l++)u.push(a,h+l,h+l+1)}if(t>0){let a=s.length/3;s.push(0,-o,0),c.push(0,-1,0),m.push(.5,.5);let h=s.length/3;for(let l=0;l<=i;l++){let d=l/i*Math.PI*2,f=Math.sin(d),T=Math.cos(d);s.push(t*f,-o,t*T),c.push(0,-1,0),m.push(T*.5+.5,1-(f*.5+.5))}for(let l=0;l<i;l++)u.push(a,h+l+1,h+l)}this.setAttribute("position",new X(new Float32Array(s),3)),this.setAttribute("normal",new X(new Float32Array(c),3)),this.setAttribute("uv",new X(new Float32Array(m),2)),this.setIndex(u)}},xt=class extends Ee{constructor(e=1,t=1,r=16){super(0,e,t,r)}},vt=class extends ce{constructor(e=1,t=.4,r=12,i=32){super(),r=Math.max(3,Math.floor(r)),i=Math.max(3,Math.floor(i));let s=[],c=[],m=[],u=[];for(let o=0;o<=r;o++){let a=o/r*Math.PI*2;for(let h=0;h<=i;h++){let l=h/i*Math.PI*2,d=(e+t*Math.cos(a))*Math.cos(l),f=(e+t*Math.cos(a))*Math.sin(l),T=t*Math.sin(a);s.push(d,f,T);let A=e*Math.cos(l),S=e*Math.sin(l),L=d-A,b=f-S,w=T,y=Math.hypot(L,b,w)||1;c.push(L/y,b/y,w/y),m.push(h/i,o/r)}}for(let o=1;o<=r;o++)for(let a=1;a<=i;a++){let h=(i+1)*o+a-1,l=(i+1)*(o-1)+a-1,d=(i+1)*(o-1)+a,f=(i+1)*o+a;u.push(h,l,f,l,d,f)}this.setAttribute("position",new X(new Float32Array(s),3)),this.setAttribute("normal",new X(new Float32Array(c),3)),this.setAttribute("uv",new X(new Float32Array(m),2)),this.setIndex(u)}},wt=class extends ce{constructor(e=1,t=.4,r=64,i=8,s=2,c=3){super(),r=Math.floor(r),i=Math.floor(i);{let b=globalThis.__three_live_native_torus_knot__;if(typeof b=="function"){let w=b(e,t,r,i,s,c);this.setAttribute("position",new X(w.positions,3)),this.setAttribute("normal",new X(w.normals,3)),this.setAttribute("uv",new X(w.uvs,2)),this.setIndex(w.indices);return}}let m=[],u=[],o=[],a=[],h=new j,l=new j,d=new j,f=new j,T=new j;function A(b,w){let y=Math.cos(w),R=Math.sin(w),p=c/s*w,E=e*(2+Math.cos(p))*.5;b.set(E*y,E*R,e*Math.sin(p)*.5)}let S=[];for(let b=0;b<=i;++b){let w=b/i*Math.PI*2;S.push(-t*Math.cos(w),t*Math.sin(w),b/i)}for(let b=0;b<=r;++b){let w=b/r,y=w*s*Math.PI*2;A(h,y),A(l,y+.01),d.subVectors(l,h).normalize(),f.addVectors(h,l).normalize(),T.crossVectors(d,f).normalize(),f.crossVectors(T,d).normalize();for(let R=0;R<=i;++R){let p=R*3,E=S[p],M=S[p+1],_=S[p+2],I=E*f.x+M*T.x,g=E*f.y+M*T.y,v=E*f.z+M*T.z;m.push(h.x+I,h.y+g,h.z+v);let x=Math.hypot(I,g,v)||1;u.push(I/x,g/x,v/x),o.push(w,_)}}let L=i+1;for(let b=1;b<=r;b++){let w=L*(b-1),y=w+L;for(let R=1;R<=i;R++){let p=w+(R-1),E=y+(R-1),M=y+R,_=w+R;a.push(p,E,_,E,M,_)}}this.setAttribute("position",new X(new Float32Array(m),3)),this.setAttribute("normal",new X(new Float32Array(u),3)),this.setAttribute("uv",new X(new Float32Array(o),2)),this.setIndex(a)}},Ye=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(){}},Tt=class{load(e,t){let r=new Ye(e);return t?.(r),r}};function te(n,e){return n!==void 0?Number(n):e}function Qt(n,e){return n!==void 0?!!n:e}var me=class{constructor(e={}){this.name=e.name||"",this.color=new he(e.color!==void 0?e.color:16777215),this.emissive=new he(e.emissive!==void 0?e.emissive:0),this.emissiveIntensity=te(e.emissiveIntensity,1),this.roughness=te(e.roughness,.5),this.metalness=te(e.metalness,.1),this.opacity=te(e.opacity,1),this.transparent=Qt(e.transparent,!1),this.wireframe=Qt(e.wireframe,!1),this.side=te(e.side,2),this.doubleSided=Qt(e.doubleSided,!0),this.map=e.map||null,this.clearcoat=te(e.clearcoat,0),this.clearcoatRoughness=te(e.clearcoatRoughness,0),this.sheen=te(e.sheen,0),this.sheenColor=new he(e.sheenColor!==void 0?e.sheenColor:0),this.sheenRoughness=te(e.sheenRoughness,0),this.transmission=te(e.transmission,0),this.thickness=te(e.thickness,0),this.attenuationColor=new he(e.attenuationColor!==void 0?e.attenuationColor:16777215),this.attenuationDistance=te(e.attenuationDistance,1/0),this.ior=te(e.ior,1.5),this.dispersion=te(e.dispersion,0),this.iridescence=te(e.iridescence,0),this.iridescenceIOR=te(e.iridescenceIOR,1.3)}dispose(){}},Se=class extends me{},Et=class extends me{},Mt=class extends me{},Rt=class extends me{},St=class extends me{},ie=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 j,this.rotation=new Xe,this.quaternion=new Ge,this.scale=new j(1,1,1),this.matrix=new ye,this.matrixWorld=new ye,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){(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 j(e,t,r);this.updateMatrixWorld(!0);let s=new ye;s.lookAt(this.position,i,new j(0,1,0));let c=s.elements,m=c[0],u=c[4],o=c[8],a=c[1],h=c[5],l=c[9],d=c[2],f=c[6],T=c[10],A=m+h+T;if(A>0){let S=.5/Math.sqrt(A+1);this.quaternion.set((f-l)*S,(o-d)*S,(a-u)*S,.25/S)}}},At=class extends ie{},Ue=class extends ie{constructor(t,r){super();this.isMesh=!0;let i=Array.isArray(r)?r[0]:r;this.geometry=t instanceof ce?t:t?(se("unsupported geometry","BoxGeometry"),new We(.5,.5,.5)):new ce,this.material=i instanceof me?i:i?(se("unsupported material","MeshStandardMaterial"),new Se({color:13421772})):new Se}},Me=class extends ie{constructor(e=16777215,t=1){super(),this.color=new he(e),this.intensity=Number(t),this.type="directional"}},qe=class extends Me{constructor(e,t){super(e,t),this.type="ambient"}},_t=class extends Me{constructor(t,r){super(t,r);this.target=new ie;this.type="directional"}},je=class extends Me{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}},Ke=class extends ie{},Fe=class extends Ke{constructor(t=45,r=1,i=.1,s=1e3){super();this.target=new j(0,0,0);this.fov=Number(t),this.aspect=Number(r),this.near=Number(i),this.far=Number(s)}},Ae=class extends ie{constructor(){super(...arguments);this.background=null;this.environmentIntensity=1}toCanvas3D(){return pe.validate(this),Ie(this)}toGLB(){return pe.validate(this),ze(this)}toUSDZ(){return pe.validate(this),Le(this)}getMeshTransforms(){this.updateMatrixWorld(!0);let t=new Map,r=0;return this.traverse(i=>{if(i instanceof Ue){let s=new Float32Array(i.matrixWorld.elements);t.set(r,s),i.name&&t.set(i.name,s),r++}}),t}},en=Ie,tn=ze,Pn=Le;var pe=class{static validate(e){let t=0,r=0,i=0,s=new Set,c=(u,o,a)=>{throw new Error(`SecurityError: Scene exceeds SECURITY_3D_MAX_${u} (${o}). Found: ${a}`)},m=(u,o)=>{if(!Number.isFinite(o))throw new Error(`SecurityError: Scene reports a non-finite ${u} count (${String(o)}), which cannot be bounds-checked.`);return o};e.traverse(u=>{if(u instanceof Ue){i++,i>1e3&&c("MESHES",1e3,i);let o=u.geometry;if(o){let a=0;if(o.attributes.position&&(a=m("vertex",o.attributes.position.count),t+=a,t>1e5&&c("VERTICES",1e5,t)),o.index){let h=m("index",o.index.count);r+=h,r>3e5&&c("INDICES",3e5,r);let l=o.index.array;if(l&&a>0){let d=Math.min(h,l.length);for(let f=0;f<d;f++){let T=l[f];if(!Number.isFinite(T)||T<0||T>=a)throw new Error(`SecurityError: Index buffer value (${String(T)}) out of vertex bounds [0, ${a}).`)}}}}if(u.material){let a=u.material;a.map&&s.add(a.map),a.normalMap&&s.add(a.normalMap),a.roughnessMap&&s.add(a.roughnessMap)}}}),s.size>16&&c("TEXTURES",16,s.size);for(let u of s){let o=u,a=o.image,h=Number(a?.width??o.width??0)||0,l=Number(a?.height??o.height??0)||0;(!Number.isFinite(h)||!Number.isFinite(l)||h>2048||l>2048)&&c("TEXTURE_DIMENSION",2048,Math.max(h,l))}}},Dt=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 he(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){pe.validate(e);let i=(s,c)=>{typeof self<"u"&&typeof self.postMessage=="function"&&(c&&c.length?self.postMessage(s,c):self.postMessage(s))};if(this.hasInitialModelRendered){let s=e.getMeshTransforms(),c={};for(let[m,u]of s.entries())c[m]=Array.from(u);i({type:"3D_UPDATE_TRANSFORMS",containerId:this.containerId,transforms:c})}else{this.hasInitialModelRendered=!0;let s=en(e),c=tn(e),m=(s.lights||[]).map(u=>({type:u.type,color:u.color,intensity:u.intensity,position:u.position}));i({type:"3D_MODEL_READY",containerId:this.containerId,glbBuffer:c.buffer,dynamicLights:m,camera:t?{fov:t.fov||60,position:[t.position.x,t.position.y,t.position.z]}:void 0},[c.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 Sn(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var Ct=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=Sn(),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=Sn();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Cr(){}var Pe=new Proxy(Cr,{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:Pe},getPrototypeOf:()=>null,setPrototypeOf:()=>!1,apply:()=>Pe,construct:()=>Pe}),An=(()=>{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 Ne(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof location<"u"&&location.href?location.href:"https://localhost/"}function Re(n,e){if(!n||typeof n!="string")return!1;let t=n.trim();if(!t)return!1;try{let r=new URL(t,Ne());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 _n,Ve;function Un(n){if(!Re(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(Ve===void 0||_n!==t){_n=t;try{Ve=t.createPolicy("three-live#worker",{createScriptURL:r=>{if(!Re(r))throw new TypeError(`SecurityError: Disallowed Three-Live worker script URL "${r}".`);return r}})}catch{Ve=null}}return Ve?Ve.createScriptURL(n):n}function Ir(n){J().sandboxEngineSrc=n}function nn(){let n=J().sandboxEngineSrc;if(n)return n;if(An)return An;try{if(typeof document>"u")return null;let e=Ne(),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)&&Re(i,{requireSameOrigin:!0}))return i}}catch{}return null}function Lr(){let n=nn();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(!Re(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,Ne()).href}function Pr(n){J().sandboxIframeSrc=n}function Fn(){let n=J().sandboxIframeSrc;if(n)return n;let e=nn();if(!e||!Re(e))return null;let t=new URL(e,Ne());return t.protocol==="blob:"?null:new URL("three-live-sandbox.html",t).href}function Ur(){let n=Fn();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(!Re(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,Ne()).href}function Fr(n){J().allowClientScripts=n}function Nn(){return!!J().allowClientScripts}function Nr(n){if(!Re(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,Ne()).href}var kr=["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 Or(n){let e=self,t=n.nonce,r=n.engineSrc,i=n.allowedScriptUrl,s=n.allowClientScripts,c=n.revoked,m=e.postMessage.bind(e);function u(y){m({type:"ERROR",nonce:t,message:String(y)})}let o=typeof e.importScripts=="function"?e.importScripts.bind(e):null,a=i,h=null;try{let y=r;if(typeof e.trustedTypes<"u"&&e.trustedTypes&&typeof e.trustedTypes.createPolicy=="function")try{let R={createScriptURL:function(E){if(E!==r&&(!i||E!==i))throw new TypeError("Disallowed worker importScripts URL");return E}};s&&(R.createScript=function(E){return String(E)});let p=e.trustedTypes.createPolicy("three-live#worker-boot",R);y=p.createScriptURL(r),i&&(a=p.createScriptURL(i)),s&&typeof p.createScript=="function"&&(h=p.createScript.bind(p))}catch{}o(y)}catch(y){u('Sandbox failed to load the Three-Live engine from "'+r+'". It must be a same-origin (or CORS-enabled) IIFE bundle such as three-live.min.js. Underlying error: '+(y&&y.message||y));return}let l=e.THREE;if(!l||typeof l.Scene!="function"){u('Sandbox loaded "'+r+'" but it did not install a THREE namespace. Point sandboxEngineSrc at an IIFE build (three-live.min.js), not an ES module build.');return}for(let y=0;y<c.length;y++){let R=c[y],p=e;for(;p&&p!==Object.prototype;){if(p!==e)try{delete p[R]}catch{}try{Object.defineProperty(p,R,{value:void 0,writable:!1,configurable:!1,enumerable:!1})}catch{}try{p=Object.getPrototypeOf(p)}catch{break}}}let d=Object.freeze({now:function(){return Date.now()}}),f=e;for(;f&&f!==Object.prototype;){if(f!==e)try{delete f.performance}catch{}try{Object.defineProperty(f,"performance",{value:d,writable:!1,configurable:!1,enumerable:!1})}catch{}try{f=Object.getPrototypeOf(f)}catch{break}}let T=["3D_MODEL_READY","3D_UPDATE_TRANSFORMS"],A=!1;function S(y,R){if(y.type==="3D_MODEL_READY"){if(A)return;A=!0}y.nonce=t,R&&R.length?m(y,R):m(y)}let L=function(y,R){if(!y||T.indexOf(y.type)===-1)throw new Error("Sandboxed scripts may only post Three-Live scene messages ("+T.join(", ")+").");S(y,R)},b=e;for(;b&&b!==Object.prototype;){if(b===e||Object.prototype.hasOwnProperty.call(b,"postMessage"))try{Object.defineProperty(b,"postMessage",{value:L,writable:!1,configurable:!1})}catch{}try{b=Object.getPrototypeOf(b)}catch{break}}let w=!1;e.onmessage=function(y){let R=y&&y.data;if(!(!R||R.nonce!==t)&&!(R.type!=="EXECUTE"&&R.type!=="EXECUTE_URL")&&!w){w=!0;try{let p=new l.Scene,E=new l.PerspectiveCamera(60,1,.1,1e3),M=new l.WebGLRenderer({isSandboxed:!0});if(R.type==="EXECUTE_URL"){if(!i||R.scriptUrl!==i||typeof o!="function"){u("SecurityError: Refusing to execute unapproved script URL inside sandbox worker.");return}let _=a||i,I=o;if(o=null,a=null,e.THREE=l,e.scene=p,e.camera=E,e.renderer=M,I(_),typeof e.__THREE_LIVE_SCENE__=="function"){let g=e.__THREE_LIVE_SCENE__(l,p,E,M);g&&typeof g.toGLB=="function"&&(p=g)}else e.scene&&typeof e.scene.toGLB=="function"&&(p=e.scene)}else{if(!s){u("SecurityError: Client-modified script compilation (Use Case 1) is disabled in this sandbox worker.");return}let _=h?(0,eval)(h(`(function (THREE, scene, camera, renderer) {
|
|
287
292
|
return (function () {
|
|
288
|
-
`+
|
|
293
|
+
`+R.script+`
|
|
289
294
|
})();
|
|
290
295
|
})`)):new Function("THREE","scene","camera","renderer",`return (function () {
|
|
291
|
-
`+
|
|
292
|
-
})();`);h=null;let C=_(l,b,w,v);C&&typeof C.toGLB=="function"&&(b=C)}if(!M){l.SceneQuotaValidator&&l.SceneQuotaValidator.validate(b);let _=b.toGLB(),C=_ instanceof ArrayBuffer?_:_.buffer.slice(_.byteOffset,_.byteOffset+_.byteLength);R({type:"3D_MODEL_READY",glbBuffer:C},[C])}m({type:"DONE",nonce:t})}catch(b){u(b&&b.message||b)}}},m({type:"READY",nonce:t})}function nn(n,e,t){let r=t?.allowedScriptUrl??null,i=t?.allowClientScripts??r===null,o={nonce:e,engineSrc:n,allowedScriptUrl:r,allowClientScripts:i,revoked:kr};return`'use strict';(${Or.toString()})(${JSON.stringify(o)});`}function kn(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 we=0;function On(){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 Br(n){try{return new TextEncoder().encode(n).length}catch{return n.length}}var zr=1024,Vr=256;function Dn(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 rn(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,zr)};case"3D_UPDATE_TRANSFORMS":{let i=t.transforms;if(Array.isArray(i)){if(i.length>1e3)return null;for(let o of i)if(!Dn(o))return null;return{type:"3D_UPDATE_TRANSFORMS",transforms:i}}if(i&&typeof i=="object"){let o=Object.keys(i);if(o.length>1e3)return null;let c=Object.create(null),m=i;for(let u of o){if(u.length>Vr||u==="__proto__"||u==="constructor"||u==="prototype")return null;let a=m[u];if(!Dn(a))return null;c[u]=a}return{type:"3D_UPDATE_TRANSFORMS",transforms:c}}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 Hr(n){let e=Br(n);if(e>1048576)throw new Error(`SecurityError: Script length (${e} bytes) exceeds SECURITY_3D_MAX_SCRIPT_BYTES (1048576).`)}function Bn(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=On(),o=nn(e,i,n.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:n.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),c=document.createElement("iframe");c.setAttribute("sandbox","allow-scripts"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.display="none",c.src=t,we++;let m=!1,u=!1,a={modelDispatched:!1},s,h=()=>{if(m||u)return;let T=c.contentWindow;!T||typeof T.postMessage!="function"||(u=!0,T.postMessage(n.kind==="url"?{type:"SANDBOX_RUN",nonce:i,workerSource:o,scriptUrl:n.scriptUrl}:{type:"SANDBOX_RUN",nonce:i,workerSource:o,script:n.script},"*"))},l=()=>{},p=T=>{if(m||!c.contentWindow||T.source!==c.contentWindow)return;let M=T.data;if(M&&typeof M=="object"&&M.type==="IFRAME_READY"){h();return}let R=rn(M,i);R&&Bn(R,r,l,a)};l=()=>{m||(m=!0,s!==void 0&&clearTimeout(s),we=Math.max(0,we-1),typeof globalThis.removeEventListener=="function"&&globalThis.removeEventListener("message",p),typeof c.remove=="function"?c.remove():c.parentNode&&c.parentNode.removeChild(c))},s=setTimeout(()=>{m||(l(),kn(r))},3e3),typeof globalThis.addEventListener=="function"&&globalThis.addEventListener("message",p),c.onload=()=>{h()},c.onerror=()=>{l(),r.onError?.(new Error(`Sandbox iframe failed to load "${t}". Verify that three-live-sandbox.html is served at that URL.`))};let f=document.body||document.documentElement;if(!f||typeof f.appendChild!="function"){l();let T=new Error("SecurityError: Cannot mount sandbox iframe because document.body is unavailable.");throw r.onError?.(T),T}return f.appendChild(c),{terminate:l}}function Cn(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(we>=32)return r(`SecurityError: ${we} 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=Lr()}catch(l){let p=l instanceof Error?l.message:String(l);return r(p,"Security Error: sandbox engine URL is not configured.")}if(e==="iframe"){let l;try{l=Ur()}catch(p){let f=p instanceof Error?p.message:String(p);return r(f,"Security Error: sandbox iframe URL is not configured.")}try{return Promise.resolve(Xr(n,i,l,t))}catch(p){return Promise.reject(p)}}let o=On(),c=nn(i,o,n.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:n.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),m;try{let l=new Blob([c],{type:"application/javascript"}),p=URL.createObjectURL(l);try{let f=Un(p);m=new Worker(f)}finally{URL.revokeObjectURL(p)}}catch(l){let p=l instanceof Error?l.message:String(l);return r(`Failed to initialize Web Worker for sandboxed execution (CSP may block blob workers): ${p}`,"Security Error: Failed to start Worker sandbox.")}we++;let u=!1,a={modelDispatched:!1},s,h=()=>{u||(u=!0,s!==void 0&&clearTimeout(s),we=Math.max(0,we-1),m.terminate())};return s=setTimeout(()=>{u||(h(),kn(t))},3e3),m.onmessage=l=>{let p=rn(l.data,o);p&&Bn(p,t,h,a)},m.onerror=l=>{h(),t.onError?.(new Error(`Worker execution error: ${l.message}`))},n.kind==="url"?m.postMessage({type:"EXECUTE_URL",scriptUrl:n.scriptUrl,nonce:o}):m.postMessage({type:"EXECUTE",script:n.script,nonce:o}),Promise.resolve({terminate:h})}function In(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 zn={execute(n,e,t,r){let i=(m,u)=>{let a=new Error(m);return t.onError?.(a),u&&t.onToast?.(u),Promise.reject(a)},o=In(e,i);if(o)return o;try{Hr(n)}catch(m){let u=m instanceof Error?m.message:String(m);return i(u,"Security Error: script exceeds the size limit.")}return r?.allowClientScripts??Nn()?Cn({kind:"script",script:n},e,t,i):i(sn,an)},executeUrl(n,e,t){let r=(c,m)=>{let u=new Error(c);return t.onError?.(u),m&&t.onToast?.(m),Promise.reject(u)},i=In(e,r);if(i)return i;let o;try{o=Nr(n)}catch(c){let m=c instanceof Error?c.message:String(c);return r(m,"Security Error: disallowed scene script URL.")}return Cn({kind:"url",scriptUrl:o},e,t,r)}},Ct=new Set;function oe(n,e){let t=`[three-live] ${n} is unsupported; degraded to ${e}.`;Ct.has(t)||(Ct.add(t),typeof console<"u"&&typeof console.warn=="function"&&console.warn(t))}function Vn(){return Array.from(Ct)}function on(){Ct.clear()}var je=class extends Se{constructor(e={}){oe("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}},Hn=je,_e=class extends We{constructor(e=1,t=0,r="PolyhedronGeometry"){oe(r,"SphereGeometry");let i=Math.max(4,Math.min(32,4<<Math.min(t,3)));super(e,i,i)}},It=class extends _e{constructor(e=1,t=0){super(e,t,"IcosahedronGeometry")}},Lt=class extends _e{constructor(e=1,t=0){super(e,t,"OctahedronGeometry")}},Pt=class extends _e{constructor(e=1,t=0){super(e,t,"DodecahedronGeometry")}},Ut=class extends _e{constructor(e=1,t=0){super(e,t,"TetrahedronGeometry")}},Ft=class extends Ee{constructor(e=1,t=1,r=4,i=8){oe("CapsuleGeometry","CylinderGeometry"),super(e,e,t+e*2,i)}},Nt=class extends Ee{constructor(e=.5,t=1,r=16){oe("RingGeometry","CylinderGeometry"),super(t,t,.01,Math.max(8,r))}},kt=class extends Ee{constructor(e=1,t=16){oe("CircleGeometry","CylinderGeometry"),super(e,e,.01,Math.max(8,t))}},Ot=class extends qe{constructor(t,r,i=0,o=Math.PI/3,c=0,m=2){oe("SpotLight","PointLight");super(t,r,i,m);this.target=new ie;this.angle=Math.PI/3;this.penumbra=0;this.angle=o,this.penumbra=c}},Ze=class extends Ye{constructor(e,t,r){oe("HemisphereLight","AmbientLight"),super(e,r),this.groundColor=new he(t??4473924)}},Xn=Ze,Gn={Vector2:ht,Vector3:q,Vector4:mt,Euler:He,Quaternion:Xe,Matrix4:ye,Matrix3:ft,Color:he,MathUtils:Ln,BufferAttribute:X,Float32BufferAttribute:dt,Uint16BufferAttribute:pt,Uint32BufferAttribute:bt,BufferGeometry:ce,BoxGeometry:Ge,PlaneGeometry:yt,SphereGeometry:We,CylinderGeometry:Ee,ConeGeometry:gt,TorusGeometry:xt,TorusKnotGeometry:vt,IcosahedronGeometry:It,OctahedronGeometry:Lt,DodecahedronGeometry:Pt,TetrahedronGeometry:Ut,CapsuleGeometry:Ft,RingGeometry:Nt,CircleGeometry:kt,Texture:$e,TextureLoader:Tt,Material:me,MeshStandardMaterial:Se,MeshBasicMaterial:wt,MeshLambertMaterial:Et,MeshPhongMaterial:Mt,MeshPhysicalMaterial:Rt,ShaderMaterial:je,RawShaderMaterial:Hn,Object3D:ie,Group:St,Mesh:Pe,Light:Me,AmbientLight:Ye,DirectionalLight:At,PointLight:qe,SpotLight:Ot,HemisphereLight:Ze,RectAreaLight:Xn,Camera:Ke,PerspectiveCamera:Ue,Scene:Ae,WebGLRenderer:_t,Clock:Dt,SceneQuotaValidator:pe,exportSceneToCanvas3D:Qt,exportSceneToGLB:en,exportSceneToUSDZ:Pn,generateUSDZ:$t,glbToUSDZ:ut,sceneToCanvas3D:Ce,sceneToGLB:Be,sceneToUSDZ:Ie,authorScriptRunner:zn,getAuthorWarnings:Vn,clearAuthorWarnings:on};Object.freeze(pe);Object.freeze(pe.prototype);Object.freeze(Ae.prototype);Object.freeze(Gn);var Je=new Proxy(Gn,{get:(n,e)=>e in n?n[e]:(typeof e=="string"&&e!=="then"&&e!=="toJSON"&&!e.startsWith("__")&&oe(`THREE.${e}`,"no-op proxy"),Le),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")}}),Ve={name:"three_author",THREE:Je},Gr=Ve,K=typeof globalThis<"u"?globalThis:typeof window<"u"?window:void 0;typeof K.THREE>"u"&&(K.THREE=Je);typeof K.requestAnimationFrame!="function"&&(K.requestAnimationFrame=()=>(oe("requestAnimationFrame","single-frame static evaluation"),0));typeof K.cancelAnimationFrame!="function"&&(K.cancelAnimationFrame=()=>{});if(typeof window<"u"){let n=window;n.ThreeLive=n.ThreeLive||{},n.ThreeLive.THREE=Je,n.ThreeLivePlugins=n.ThreeLivePlugins||{},n.ThreeLivePlugins.threeAuthor=Ve,n.ThreeLivePlugins.three_author=Ve,n.ThreeLivePlugins["three-author"]=Ve}{Rn();let n=new Ae,e=new Ue(45,1,.1,1e3);e.position.set(0,2,5),K.scene=n,K.camera=e,typeof K.window>"u"&&(K.window={innerWidth:1024,innerHeight:768,devicePixelRatio:1,addEventListener:()=>{},removeEventListener:()=>{}}),typeof K.document>"u"&&(K.document={createElement:()=>({getContext:()=>Le,style:{},addEventListener:()=>{}}),body:{appendChild:()=>{},style:{}},addEventListener:()=>{}}),Object.defineProperty(K,"__three_live_reset_scene__",{value:function(){on(),n=new Ae,e=new Ue(45,1,.1,1e3),e.position.set(0,2,5),K.scene=n,K.camera=e},writable:!1,configurable:!1});let r=function(u){if(u==null)return null;let a=2e4,s=new Set,h=(l,p)=>{if(--a<0||p>32)return;if(l===null||typeof l=="string"||typeof l=="boolean")return l;if(typeof l=="number")return Number.isFinite(l)?l:void 0;if(typeof l!="object"||s.has(l))return;s.add(l);let f;if(Array.isArray(l)){f=[];for(let T of l)f.push(h(T,p+1)??null)}else{f={};for(let T of Object.keys(l)){if(T==="__proto__"||T==="prototype"||T==="constructor")continue;let M=h(l[T],p+1);M!==void 0&&(f[T]=M)}}return s.delete(l),f};try{return h(u,0)??null}catch{return null}},i=15*1024,o=1e3*4,c=function(u){let a=lt(u);if(!a)return{};let s=JSON.stringify({...u,...a});return s.length>i&&(oe(`userData.xr larger than ${i} characters`,"canonical XR traits only"),s=JSON.stringify(a)),{xr_normalized_json:s,xr_scenecore_json:JSON.stringify(jt(a)),xr_hubs_json:JSON.stringify(Zt(a))}};Object.defineProperty(K,"__three_live_extract_scene_raw__",{value:function(){let u=[],a=[],s=[],h=[];function l(d){if(!d)return null;let S=h.indexOf(d);if(S===-1){h.push(d);let x="";d.map&&(typeof d.map=="string"?x=d.map:d.map.source?x=d.map.source:d.map.image&&(x=d.map.image)),a.push({name:d.name||`Material_${a.length}`,base_color:[d.color.r,d.color.g,d.color.b,d.opacity!==void 0?d.opacity:1],metallic:d.metalness!==void 0?d.metalness:.1,roughness:d.roughness!==void 0?d.roughness:.5,double_sided:d.side===2||d.doubleSided,base_color_texture:x||null,clearcoat:d.clearcoat||0,clearcoat_roughness:d.clearcoatRoughness||0,transmission:d.transmission||0,ior:d.ior!==void 0?d.ior:1.5,thickness:d.thickness||0}),S=a.length-1}return S}let p=(d,S)=>typeof d=="number"&&Number.isFinite(d)?d:S,f=[],T=[],M=!1,R=K.scene||n,I=new ye().compose({x:p(R.position?.x,0),y:p(R.position?.y,0),z:p(R.position?.z,0)},{x:p(R.quaternion?.x,0),y:p(R.quaternion?.y,0),z:p(R.quaternion?.z,0),w:p(R.quaternion?.w,1)},{x:p(R.scale?.x,1),y:p(R.scale?.y,1),z:p(R.scale?.z,1)}),y=new Set([R]);{let d=new Set([R]),S=Array.isArray(R.children)?[...R.children]:[],x=0;for(;S.length>0&&x<=o;){let P=S.pop();if(!(!(P instanceof ie)||d.has(P))&&(d.add(P),x++,Array.isArray(P.children)))for(let B of P.children)S.push(B)}if(x>o)return{meshes:[],nodes:new Array(x),materials:[],lights:[]}}let E=[],g=(d,S)=>{let x=Array.isArray(d.children)?d.children:[];for(let P=x.length-1;P>=0;P--)E.push([x[P],S])};g(R,-1);let A=d=>{let S=[];for(let P=d;P>=0&&S.length<=f.length;P=f[P].parent)S.push(P);let x=I.clone();for(let P=S.length-1;P>=0;P--){let B=f[S[P]];x.multiply(new ye().compose({x:B.translation[0],y:B.translation[1],z:B.translation[2]},{x:B.rotation[0],y:B.rotation[1],z:B.rotation[2],w:B.rotation[3]},{x:B.scale[0],y:B.scale[1],z:B.scale[2]}))}return x};for(;E.length>0;){let[d,S]=E.pop();if(!(d instanceof ie)||y.has(d))continue;y.add(d);let x=[p(d.position?.x,0),p(d.position?.y,0),p(d.position?.z,0)],P=[p(d.quaternion?.x,0),p(d.quaternion?.y,0),p(d.quaternion?.z,0),p(d.quaternion?.w,1)],B=[p(d.scale?.x,1),p(d.scale?.y,1),p(d.scale?.z,1)],V=-1,k=d.geometry,L=k?.attributes?.position;L&&L.array&&L.count>0&&(V=u.length,u.push({name:d.name||`Mesh_${u.length}`,raw_positions:L.array,raw_normals:k.attributes.normal?k.attributes.normal.array:null,raw_uvs:k.attributes.uv?k.attributes.uv.array:null,raw_indices:k.index?k.index.array:null,vertex_count:L.count,material_index:l(d.material instanceof me?d.material:null)}));let U=r(d.userData?.xr),D=!!d.userData?.xr&&U!==null,O=f.length;f.push({name:typeof d.name=="string"?d.name.slice(0,1024):"",parent:S,translation:x,rotation:P,scale:B,mesh:V,xr_traits_json:D?JSON.stringify(U):null,...D?c(U):{}});let N=r(d.userData?.interactivity);if(T.push(N),N&&(M=!0),f.length>o)break;if(d instanceof Me){let z=A(O).elements;s.push({light_type:d.type,color:[d.color.r,d.color.g,d.color.b],intensity:d.intensity,position:[p(z[12],0),p(z[13],0),p(z[14],0)]})}g(d,O)}let b=(d,S)=>d.every((x,P)=>x===S[P]),w=r({interactivity:R.userData?.interactivity,gltfExtensions:{KHR_interactivity:R.userData?.gltfExtensions?.KHR_interactivity}}),v=!!(w?.interactivity??w?.gltfExtensions?.KHR_interactivity),_=null;(M||v)&&(_=tt(f.map((d,S)=>({name:d.name,...d.mesh>=0?{mesh:d.mesh}:{},...b(d.translation,[0,0,0])?{}:{translation:d.translation},...b(d.rotation,[0,0,0,1])?{}:{rotation:d.rotation},...b(d.scale,[1,1,1])?{}:{scale:d.scale},extras:T[S]?{interactivity:T[S]}:void 0})),u.map(d=>({primitives:[{material:d.material_index??0}]})),w??void 0));let C=K.camera||e;return{meshes:u,nodes:f,materials:a,lights:s,interactivity_json:_?JSON.stringify(_):null,camera:{fov:C.fov||45,position:C.position?[C.position.x,C.position.y,C.position.z]:[0,2,5],target:C.target?[C.target.x,C.target.y,C.target.z]:[0,0,0]}}},writable:!1,configurable:!1})}var Wr=Je;return tr($r);})();
|
|
296
|
+
`+R.script+`
|
|
297
|
+
})();`);h=null;let I=_(l,p,E,M);I&&typeof I.toGLB=="function"&&(p=I)}if(!A){l.SceneQuotaValidator&&l.SceneQuotaValidator.validate(p);let _=p.toGLB(),I=_ instanceof ArrayBuffer?_:_.buffer.slice(_.byteOffset,_.byteOffset+_.byteLength);S({type:"3D_MODEL_READY",glbBuffer:I},[I])}m({type:"DONE",nonce:t})}catch(p){u(p&&p.message||p)}}},m({type:"READY",nonce:t})}function rn(n,e,t){let r=t?.allowedScriptUrl??null,i=t?.allowClientScripts??r===null,s={nonce:e,engineSrc:n,allowedScriptUrl:r,allowClientScripts:i,revoked:kr};return`'use strict';(${Or.toString()})(${JSON.stringify(s)});`}function kn(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 Te=0;function On(){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 Br(n){try{return new TextEncoder().encode(n).length}catch{return n.length}}var zr=1024,Vr=256;function Dn(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 sn(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,zr)};case"3D_UPDATE_TRANSFORMS":{let i=t.transforms;if(Array.isArray(i)){if(i.length>1e3)return null;for(let s of i)if(!Dn(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 c=Object.create(null),m=i;for(let u of s){if(u.length>Vr||u==="__proto__"||u==="constructor"||u==="prototype")return null;let o=m[u];if(!Dn(o))return null;c[u]=o}return{type:"3D_UPDATE_TRANSFORMS",transforms:c}}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 Hr(n){let e=Br(n);if(e>1048576)throw new Error(`SecurityError: Script length (${e} bytes) exceeds SECURITY_3D_MAX_SCRIPT_BYTES (1048576).`)}function Bn(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=On(),s=rn(e,i,n.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:n.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),c=document.createElement("iframe");c.setAttribute("sandbox","allow-scripts"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.display="none",c.src=t,Te++;let m=!1,u=!1,o={modelDispatched:!1},a,h=()=>{if(m||u)return;let T=c.contentWindow;!T||typeof T.postMessage!="function"||(u=!0,T.postMessage(n.kind==="url"?{type:"SANDBOX_RUN",nonce:i,workerSource:s,scriptUrl:n.scriptUrl}:{type:"SANDBOX_RUN",nonce:i,workerSource:s,script:n.script},"*"))},l=()=>{},d=T=>{if(m||!c.contentWindow||T.source!==c.contentWindow)return;let A=T.data;if(A&&typeof A=="object"&&A.type==="IFRAME_READY"){h();return}let S=sn(A,i);S&&Bn(S,r,l,o)};l=()=>{m||(m=!0,a!==void 0&&clearTimeout(a),Te=Math.max(0,Te-1),typeof globalThis.removeEventListener=="function"&&globalThis.removeEventListener("message",d),typeof c.remove=="function"?c.remove():c.parentNode&&c.parentNode.removeChild(c))},a=setTimeout(()=>{m||(l(),kn(r))},3e3),typeof globalThis.addEventListener=="function"&&globalThis.addEventListener("message",d),c.onload=()=>{h()},c.onerror=()=>{l(),r.onError?.(new Error(`Sandbox iframe failed to load "${t}". Verify that three-live-sandbox.html is served at that URL.`))};let f=document.body||document.documentElement;if(!f||typeof f.appendChild!="function"){l();let T=new Error("SecurityError: Cannot mount sandbox iframe because document.body is unavailable.");throw r.onError?.(T),T}return f.appendChild(c),{terminate:l}}function Cn(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(Te>=32)return r(`SecurityError: ${Te} 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=Lr()}catch(l){let d=l instanceof Error?l.message:String(l);return r(d,"Security Error: sandbox engine URL is not configured.")}if(e==="iframe"){let l;try{l=Ur()}catch(d){let f=d instanceof Error?d.message:String(d);return r(f,"Security Error: sandbox iframe URL is not configured.")}try{return Promise.resolve(Xr(n,i,l,t))}catch(d){return Promise.reject(d)}}let s=On(),c=rn(i,s,n.kind==="url"?{allowClientScripts:!1,allowedScriptUrl:n.scriptUrl}:{allowClientScripts:!0,allowedScriptUrl:null}),m;try{let l=new Blob([c],{type:"application/javascript"}),d=URL.createObjectURL(l);try{let f=Un(d);m=new Worker(f)}finally{URL.revokeObjectURL(d)}}catch(l){let d=l instanceof Error?l.message:String(l);return r(`Failed to initialize Web Worker for sandboxed execution (CSP may block blob workers): ${d}`,"Security Error: Failed to start Worker sandbox.")}Te++;let u=!1,o={modelDispatched:!1},a,h=()=>{u||(u=!0,a!==void 0&&clearTimeout(a),Te=Math.max(0,Te-1),m.terminate())};return a=setTimeout(()=>{u||(h(),kn(t))},3e3),m.onmessage=l=>{let d=sn(l.data,s);d&&Bn(d,t,h,o)},m.onerror=l=>{h(),t.onError?.(new Error(`Worker execution error: ${l.message}`))},n.kind==="url"?m.postMessage({type:"EXECUTE_URL",scriptUrl:n.scriptUrl,nonce:s}):m.postMessage({type:"EXECUTE",script:n.script,nonce:s}),Promise.resolve({terminate:h})}function In(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 zn={execute(n,e,t,r){let i=(m,u)=>{let o=new Error(m);return t.onError?.(o),u&&t.onToast?.(u),Promise.reject(o)},s=In(e,i);if(s)return s;try{Hr(n)}catch(m){let u=m instanceof Error?m.message:String(m);return i(u,"Security Error: script exceeds the size limit.")}return r?.allowClientScripts??Nn()?Cn({kind:"script",script:n},e,t,i):i(an,cn)},executeUrl(n,e,t){let r=(c,m)=>{let u=new Error(c);return t.onError?.(u),m&&t.onToast?.(m),Promise.reject(u)},i=In(e,r);if(i)return i;let s;try{s=Nr(n)}catch(c){let m=c instanceof Error?c.message:String(c);return r(m,"Security Error: disallowed scene script URL.")}return Cn({kind:"url",scriptUrl:s},e,t,r)}},It=new Set;function se(n,e){let t=`[three-live] ${n} is unsupported; degraded to ${e}.`;It.has(t)||(It.add(t),typeof console<"u"&&typeof console.warn=="function"&&console.warn(t))}function Vn(){return Array.from(It)}function on(){It.clear()}var Ze=class extends Se{constructor(e={}){se("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}},Hn=Ze,_e=class extends $e{constructor(e=1,t=0,r="PolyhedronGeometry"){se(r,"SphereGeometry");let i=Math.max(4,Math.min(32,4<<Math.min(t,3)));super(e,i,i)}},Lt=class extends _e{constructor(e=1,t=0){super(e,t,"IcosahedronGeometry")}},Pt=class extends _e{constructor(e=1,t=0){super(e,t,"OctahedronGeometry")}},Ut=class extends _e{constructor(e=1,t=0){super(e,t,"DodecahedronGeometry")}},Ft=class extends _e{constructor(e=1,t=0){super(e,t,"TetrahedronGeometry")}},Nt=class extends Ee{constructor(e=1,t=1,r=4,i=8){se("CapsuleGeometry","CylinderGeometry"),super(e,e,t+e*2,i)}},kt=class extends Ee{constructor(e=.5,t=1,r=16){se("RingGeometry","CylinderGeometry"),super(t,t,.01,Math.max(8,r))}},Ot=class extends Ee{constructor(e=1,t=16){se("CircleGeometry","CylinderGeometry"),super(e,e,.01,Math.max(8,t))}},Bt=class extends je{constructor(t,r,i=0,s=Math.PI/3,c=0,m=2){se("SpotLight","PointLight");super(t,r,i,m);this.target=new ie;this.angle=Math.PI/3;this.penumbra=0;this.angle=s,this.penumbra=c}},Je=class extends qe{constructor(e,t,r){se("HemisphereLight","AmbientLight"),super(e,r),this.groundColor=new he(t??4473924)}},Xn=Je,Gn={Vector2:mt,Vector3:j,Vector4:ft,Euler:Xe,Quaternion:Ge,Matrix4:ye,Matrix3:dt,Color:he,MathUtils:Ln,BufferAttribute:X,Float32BufferAttribute:pt,Uint16BufferAttribute:bt,Uint32BufferAttribute:yt,BufferGeometry:ce,BoxGeometry:We,PlaneGeometry:gt,SphereGeometry:$e,CylinderGeometry:Ee,ConeGeometry:xt,TorusGeometry:vt,TorusKnotGeometry:wt,IcosahedronGeometry:Lt,OctahedronGeometry:Pt,DodecahedronGeometry:Ut,TetrahedronGeometry:Ft,CapsuleGeometry:Nt,RingGeometry:kt,CircleGeometry:Ot,Texture:Ye,TextureLoader:Tt,Material:me,MeshStandardMaterial:Se,MeshBasicMaterial:Et,MeshLambertMaterial:Mt,MeshPhongMaterial:Rt,MeshPhysicalMaterial:St,ShaderMaterial:Ze,RawShaderMaterial:Hn,Object3D:ie,Group:At,Mesh:Ue,Light:Me,AmbientLight:qe,DirectionalLight:_t,PointLight:je,SpotLight:Bt,HemisphereLight:Je,RectAreaLight:Xn,Camera:Ke,PerspectiveCamera:Fe,Scene:Ae,WebGLRenderer:Dt,Clock:Ct,SceneQuotaValidator:pe,exportSceneToCanvas3D:en,exportSceneToGLB:tn,exportSceneToUSDZ:Pn,generateUSDZ:Yt,glbToUSDZ:lt,sceneToCanvas3D:Ie,sceneToGLB:ze,sceneToUSDZ:Le,authorScriptRunner:zn,getAuthorWarnings:Vn,clearAuthorWarnings:on};Object.freeze(pe);Object.freeze(pe.prototype);Object.freeze(Ae.prototype);Object.freeze(Gn);var Qe=new Proxy(Gn,{get:(n,e)=>e in n?n[e]:(typeof e=="string"&&e!=="then"&&e!=="toJSON"&&!e.startsWith("__")&&se(`THREE.${e}`,"no-op proxy"),Pe),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")}}),He={name:"three_author",THREE:Qe},Gr=He,Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:void 0;typeof Z.THREE>"u"&&(Z.THREE=Qe);typeof Z.requestAnimationFrame!="function"&&(Z.requestAnimationFrame=()=>(se("requestAnimationFrame","single-frame static evaluation"),0));typeof Z.cancelAnimationFrame!="function"&&(Z.cancelAnimationFrame=()=>{});if(typeof window<"u"){let n=window;n.ThreeLive=n.ThreeLive||{},n.ThreeLive.THREE=Qe,n.ThreeLivePlugins=n.ThreeLivePlugins||{},n.ThreeLivePlugins.threeAuthor=He,n.ThreeLivePlugins.three_author=He,n.ThreeLivePlugins["three-author"]=He}{Rn();let n=new Ae,e=new Fe(45,1,.1,1e3);e.position.set(0,2,5),Z.scene=n,Z.camera=e,typeof Z.window>"u"&&(Z.window={innerWidth:1024,innerHeight:768,devicePixelRatio:1,addEventListener:()=>{},removeEventListener:()=>{}}),typeof Z.document>"u"&&(Z.document={createElement:()=>({getContext:()=>Pe,style:{},addEventListener:()=>{}}),body:{appendChild:()=>{},style:{}},addEventListener:()=>{}}),Object.defineProperty(Z,"__three_live_reset_scene__",{value:function(){on(),n=new Ae,e=new Fe(45,1,.1,1e3),e.position.set(0,2,5),Z.scene=n,Z.camera=e},writable:!1,configurable:!1});let r=function(u){if(u==null)return null;let o=2e4,a=new Set,h=(l,d)=>{if(--o<0||d>32)return;if(l===null||typeof l=="string"||typeof l=="boolean")return l;if(typeof l=="number")return Number.isFinite(l)?l:void 0;if(typeof l!="object"||a.has(l))return;a.add(l);let f;if(Array.isArray(l)){f=[];for(let T of l)f.push(h(T,d+1)??null)}else{f={};for(let T of Object.keys(l)){if(T==="__proto__"||T==="prototype"||T==="constructor")continue;let A=h(l[T],d+1);A!==void 0&&(f[T]=A)}}return a.delete(l),f};try{return h(u,0)??null}catch{return null}},i=15*1024,s=1e3*4,c=function(u){let o=ht(u);if(!o)return{};let a=JSON.stringify({...u,...o});return a.length>i&&(se(`userData.xr larger than ${i} characters`,"canonical XR traits only"),a=JSON.stringify(o)),{xr_normalized_json:a,xr_scenecore_json:JSON.stringify(Zt(o)),xr_hubs_json:JSON.stringify(Jt(o))}};Object.defineProperty(Z,"__three_live_extract_scene_raw__",{value:function(){let u=[],o=[],a=[],h=[];function l(g){if(!g)return null;let v=h.indexOf(g);if(v===-1){h.push(g);let x="";g.map&&(typeof g.map=="string"?x=g.map:g.map.source?x=g.map.source:g.map.image&&(x=g.map.image)),o.push({name:g.name||`Material_${o.length}`,base_color:[g.color.r,g.color.g,g.color.b,g.opacity!==void 0?g.opacity:1],metallic:g.metalness!==void 0?g.metalness:.1,roughness:g.roughness!==void 0?g.roughness:.5,double_sided:g.side===2||g.doubleSided,base_color_texture:x||null,clearcoat:g.clearcoat||0,clearcoat_roughness:g.clearcoatRoughness||0,transmission:g.transmission||0,ior:g.ior!==void 0?g.ior:1.5,thickness:g.thickness||0}),v=o.length-1}return v}let d=(g,v)=>typeof g=="number"&&Number.isFinite(g)?g:v,f=[],T=[],A=!1,S=Z.scene||n,L=new ye().compose({x:d(S.position?.x,0),y:d(S.position?.y,0),z:d(S.position?.z,0)},{x:d(S.quaternion?.x,0),y:d(S.quaternion?.y,0),z:d(S.quaternion?.z,0),w:d(S.quaternion?.w,1)},{x:d(S.scale?.x,1),y:d(S.scale?.y,1),z:d(S.scale?.z,1)}),b=new Set([S]);{let g=new Set([S]),v=Array.isArray(S.children)?[...S.children]:[],x=0;for(;v.length>0&&x<=s;){let P=v.pop();if(!(!(P instanceof ie)||g.has(P))&&(g.add(P),x++,Array.isArray(P.children)))for(let D of P.children)v.push(D)}if(x>s)return{meshes:[],nodes:new Array(x),materials:[],lights:[]}}let w=[],y=(g,v)=>{let x=Array.isArray(g.children)?g.children:[];for(let P=x.length-1;P>=0;P--)w.push([x[P],v])};y(S,-1);let R=g=>{let v=[];for(let P=g;P>=0&&v.length<=f.length;P=f[P].parent)v.push(P);let x=L.clone();for(let P=v.length-1;P>=0;P--){let D=f[v[P]];x.multiply(new ye().compose({x:D.translation[0],y:D.translation[1],z:D.translation[2]},{x:D.rotation[0],y:D.rotation[1],z:D.rotation[2],w:D.rotation[3]},{x:D.scale[0],y:D.scale[1],z:D.scale[2]}))}return x};for(;w.length>0;){let[g,v]=w.pop();if(!(g instanceof ie)||b.has(g))continue;b.add(g);let x=[d(g.position?.x,0),d(g.position?.y,0),d(g.position?.z,0)],P=[d(g.quaternion?.x,0),d(g.quaternion?.y,0),d(g.quaternion?.z,0),d(g.quaternion?.w,1)],D=[d(g.scale?.x,1),d(g.scale?.y,1),d(g.scale?.z,1)],V=-1,N=g.geometry,U=N?.attributes?.position;U&&U.array&&U.count>0&&(V=u.length,u.push({name:g.name||`Mesh_${u.length}`,raw_positions:U.array,raw_normals:N.attributes.normal?N.attributes.normal.array:null,raw_uvs:N.attributes.uv?N.attributes.uv.array:null,raw_indices:N.index?N.index.array:null,vertex_count:U.count,material_index:l(g.material instanceof me?g.material:null)}));let F=r(g.userData?.xr),C=!!g.userData?.xr&&F!==null,B=f.length;f.push({name:typeof g.name=="string"?g.name.slice(0,1024):"",parent:v,translation:x,rotation:P,scale:D,mesh:V,xr_traits_json:C?JSON.stringify(F):null,...C?c(F):{}});let k=r(g.userData?.interactivity);if(T.push(k),k&&(A=!0),f.length>s)break;if(g instanceof Me){let z=R(B).elements;a.push({light_type:g.type,color:[g.color.r,g.color.g,g.color.b],intensity:g.intensity,position:[d(z[12],0),d(z[13],0),d(z[14],0)]})}y(g,B)}let p=(g,v)=>g.every((x,P)=>x===v[P]),E=r({interactivity:S.userData?.interactivity,gltfExtensions:{KHR_interactivity:S.userData?.gltfExtensions?.KHR_interactivity}}),M=!!(E?.interactivity??E?.gltfExtensions?.KHR_interactivity),_=null;(A||M)&&(_=nt(f.map((g,v)=>({name:g.name,...g.mesh>=0?{mesh:g.mesh}:{},...p(g.translation,[0,0,0])?{}:{translation:g.translation},...p(g.rotation,[0,0,0,1])?{}:{rotation:g.rotation},...p(g.scale,[1,1,1])?{}:{scale:g.scale},extras:T[v]?{interactivity:T[v]}:void 0})),u.map(g=>({primitives:[{material:g.material_index??0}]})),E??void 0));let I=Z.camera||e;return{meshes:u,nodes:f,materials:o,lights:a,interactivity_json:_?JSON.stringify(_):null,camera:{fov:I.fov||45,position:I.position?[I.position.x,I.position.y,I.position.z]:[0,2,5],target:I.target?[I.target.x,I.target.y,I.target.z]:[0,0,0]}}},writable:!1,configurable:!1})}var Wr=Qe;return tr($r);})();
|