three-live 1.2.4 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +58 -0
  3. package/dist/three-author-engine.js +89 -63
  4. package/dist/three-author.cjs +88 -62
  5. package/dist/three-author.d.ts +58 -0
  6. package/dist/three-author.js +87 -61
  7. package/dist/three-convert.cjs +81 -59
  8. package/dist/three-convert.d.ts +58 -0
  9. package/dist/three-convert.js +80 -58
  10. package/dist/three-live-animation.cjs +8 -9
  11. package/dist/three-live-animation.d.ts +58 -0
  12. package/dist/three-live-animation.js +7 -8
  13. package/dist/three-live-animation.min.js +6 -7
  14. package/dist/three-live-cad.cjs +3 -4
  15. package/dist/three-live-cad.d.ts +58 -0
  16. package/dist/three-live-cad.js +2 -3
  17. package/dist/three-live-cad.min.js +3 -4
  18. package/dist/three-live-cli.js +231 -0
  19. package/dist/three-live-element.cjs +20 -21
  20. package/dist/three-live-element.d.ts +58 -0
  21. package/dist/three-live-element.js +19 -20
  22. package/dist/three-live-full.cjs +113 -87
  23. package/dist/three-live-full.js +110 -84
  24. package/dist/three-live-full.min.js +113 -87
  25. package/dist/three-live-studio.cjs +19 -20
  26. package/dist/three-live-studio.d.ts +58 -0
  27. package/dist/three-live-studio.js +18 -19
  28. package/dist/three-live-studio.min.js +18 -19
  29. package/dist/three-live-viewer.cjs +20 -21
  30. package/dist/three-live-viewer.d.ts +58 -0
  31. package/dist/three-live-viewer.js +19 -20
  32. package/dist/three-live-viewer.min.js +20 -21
  33. package/dist/three-live.cjs +90 -64
  34. package/dist/three-live.js +89 -63
  35. package/dist/three-live.min.js +89 -63
  36. package/dist/three-view.cjs +18 -19
  37. package/dist/three-view.d.ts +58 -0
  38. package/dist/three-view.js +19 -20
  39. package/dist/three-xr.cjs +81 -59
  40. package/dist/three-xr.d.ts +58 -0
  41. package/dist/three-xr.js +80 -58
  42. package/package.json +7 -1
@@ -1,4 +1,4 @@
1
- /**
1
+ "use strict";/**
2
2
  * @license
3
3
  * Copyright 2026 Google LLC
4
4
  *
@@ -13,14 +13,13 @@
13
13
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
- */
17
- "use strict";var ThreeLiveStudio=(()=>{var Ve=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Jt=Object.prototype.hasOwnProperty;var en=(e,t)=>{for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},tn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zt(t))!Jt.call(e,o)&&o!==n&&Ve(e,o,{get:()=>t[o],enumerable:!(r=Qt(t,o))||r.enumerable});return e};var nn=e=>tn(Ve({},"__esModule",{value:!0}),e);var Wn={};en(Wn,{InteractivityVM:()=>be,applyMeshoptFilter:()=>Ze,computeOutlineClipOffset:()=>Wt,contactShadowPlugin:()=>at,decodeMeshoptBuffer:()=>Je,decodeMeshoptGLB:()=>ke,encodeMeshoptBuffer:()=>Ft,environmentMapPlugin:()=>Be,evaluateKawaseBloom:()=>Ht,extractMaterialVariants:()=>st,extractPrimitiveVariantMappings:()=>$t,getEnvironmentSH:()=>ht,getInteractivityVM:()=>Ie,hotspotPlugin:()=>We,interactivityPlugin:()=>qe,materialsPlugin:()=>Qe,meshoptDecoder:()=>Pe,meshoptPlugin:()=>et,parseHexRgb:()=>rt,parseSafeGltfPointer:()=>pe,postprocessingPlugin:()=>ot,registerMaterialShader:()=>Mt,selectMaterialVariant:()=>jt,sendInteractivityEvent:()=>Ye,setEnvironmentSH:()=>ve,variantsPlugin:()=>ct,webxrPlugin:()=>lt});var Ae="__THREE_LIVE_REGISTRY__";function ce(){let e=typeof globalThis<"u"?globalThis:{};if(!e[Ae]){let t={plugins:[],decoders:new Map};try{Object.defineProperty(e,Ae,{value:t,writable:!1,configurable:!1,enumerable:!1})}catch{e[Ae]=t}}return e[Ae]}var $n=ce().plugins;function Z(e){let t=ce().plugins;t.some(n=>n.name===e.name)||t.push(e),e.onRegister?.()}function dt(){return ce().plugins}function le(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function ue(e,t,n){let r=t[0],o=t[1],a=t[2],d=t[3],c=t[4],i=t[5],l=t[6],s=t[7],f=t[8],u=t[9],b=t[10],m=t[11],p=t[12],x=t[13],E=t[14],I=t[15],v=n[0],S=n[1],w=n[2],U=n[3];return e[0]=v*r+S*c+w*f+U*p,e[1]=v*o+S*i+w*u+U*x,e[2]=v*a+S*l+w*b+U*E,e[3]=v*d+S*s+w*m+U*I,v=n[4],S=n[5],w=n[6],U=n[7],e[4]=v*r+S*c+w*f+U*p,e[5]=v*o+S*i+w*u+U*x,e[6]=v*a+S*l+w*b+U*E,e[7]=v*d+S*s+w*m+U*I,v=n[8],S=n[9],w=n[10],U=n[11],e[8]=v*r+S*c+w*f+U*p,e[9]=v*o+S*i+w*u+U*x,e[10]=v*a+S*l+w*b+U*E,e[11]=v*d+S*s+w*m+U*I,v=n[12],S=n[13],w=n[14],U=n[15],e[12]=v*r+S*c+w*f+U*p,e[13]=v*o+S*i+w*u+U*x,e[14]=v*a+S*l+w*b+U*E,e[15]=v*d+S*s+w*m+U*I,e}function rn(e,t,n,r){let o=t[0],a=t[1],d=t[2],c=t[3],i=o+o,l=a+a,s=d+d,f=o*i,u=o*l,b=o*s,m=a*l,p=a*s,x=d*s,E=c*i,I=c*l,v=c*s,S=r[0],w=r[1],U=r[2];return e[0]=(1-(m+x))*S,e[1]=(u+v)*S,e[2]=(b-I)*S,e[3]=0,e[4]=(u-v)*w,e[5]=(1-(f+x))*w,e[6]=(p+E)*w,e[7]=0,e[8]=(b+I)*U,e[9]=(p-E)*U,e[10]=(1-(f+m))*U,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function fe(e,t){let n=t[0],r=t[1],o=t[2],a=t[4],d=t[5],c=t[6],i=t[8],l=t[9],s=t[10],f=s*d-c*l,u=-s*a+c*i,b=l*a-d*i,m=n*f+r*u+o*b;return m&&(m=1/m,e[0]=f*m,e[1]=u*m,e[2]=b*m,e[3]=(-s*r+o*l)*m,e[4]=(s*n-o*i)*m,e[5]=(-l*n+r*i)*m,e[6]=(c*r-o*d)*m,e[7]=(-c*n+o*a)*m,e[8]=(d*n-r*a)*m),e}function mt(e,t){let n=t[0],r=t[1],o=t[2],a=t[3],d=t[4],c=t[5],i=t[6],l=t[7],s=t[8],f=t[9],u=t[10],b=t[11],m=t[12],p=t[13],x=t[14],E=t[15],I=n*c-r*d,v=n*i-o*d,S=n*l-a*d,w=r*i-o*c,U=r*l-a*c,V=o*l-a*i,O=s*p-f*m,N=s*x-u*m,P=s*E-b*m,C=f*x-u*p,z=f*E-b*p,W=u*E-b*x,B=I*W-v*z+S*C+w*P-U*N+V*O;return B?(B=1/B,e[0]=(c*W-i*z+l*C)*B,e[1]=(o*z-r*W-a*C)*B,e[2]=(p*V-x*U+E*w)*B,e[3]=(u*U-f*V-b*w)*B,e[4]=(i*P-d*W-l*N)*B,e[5]=(n*W-o*P+a*N)*B,e[6]=(x*S-m*V-E*v)*B,e[7]=(s*V-u*S+b*v)*B,e[8]=(d*z-c*P+l*O)*B,e[9]=(r*P-n*z-a*O)*B,e[10]=(m*U-p*S+E*I)*B,e[11]=(f*S-s*U-b*I)*B,e[12]=(c*N-d*C-i*O)*B,e[13]=(n*C-r*N+o*O)*B,e[14]=(p*v-m*w-x*I)*B,e[15]=(s*w-f*v+u*I)*B,e):null}function De(e,t){let n=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let s=0;s<n;s++)r.push(le());if(n===0)return r;let o=new Set;for(let s of e.nodes)if(Array.isArray(s.children))for(let f of s.children)o.add(f);let a=new Set,d=128,c=(s,f,u=0)=>{if(u>d||s<0||s>=n||a.has(s))return;a.add(s);let b=e.nodes[s];if(!b)return;let m=le();if(t&&t[s])m.set(t[s]);else if(b.matrix&&b.matrix.length===16)m.set(b.matrix);else{let x=b.translation||[0,0,0],E=b.rotation||[0,0,0,1],I=b.scale||[1,1,1];rn(m,E,x,I)}let p=r[s];if(f?ue(p,f,m):p.set(m),Array.isArray(b.children))for(let x of b.children)typeof x=="number"&&c(x,p,u+1)},i=[],l=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(l&&Array.isArray(l.nodes))i.push(...l.nodes);else for(let s=0;s<n;s++)o.has(s)||i.push(s);for(let s of i)c(s,null);for(let s=0;s<n;s++)!o.has(s)&&!i.includes(s)&&c(s,null);return r}var ze=new WeakMap;function ve(e,t){let n=t instanceof Float32Array?t:new Float32Array(t);ze.set(e,n)}function ht(e){return ze.get(e)}async function on(e,t){if(!t)return null;let n;if(typeof t=="string")if(typeof fetch<"u"&&typeof createImageBitmap=="function"){let a=await(await fetch(t)).blob();n=await createImageBitmap(a)}else if(typeof Image<"u")n=await new Promise((o,a)=>{let d=new Image;d.crossOrigin="anonymous",d.onload=()=>o(d),d.onerror=a,d.src=t});else return null;else n=t;let r=e.createTexture();return e.bindTexture(3553,r),e.texImage2D(3553,0,6408,6408,5121,n),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553),r}var Fe=new WeakMap,pt=new Float32Array(16);async function bt(e,t,n){let r=n?await on(e.gl,n):null;e[t]&&e.gl.deleteTexture(e[t]),e[t]=r}var Be={name:"environment-map",onContextRestored(e){Fe.delete(e)},setEnvironmentImage(e,t){return bt(e,"environmentTexture",t)},setSkyboxImage(e,t){return bt(e,"skyboxTexture",t)},onBeforeDrawScene(e,t,n,r,o){if(!e.skyboxTexture||typeof t.createProgram!="function")return;let a=Fe.get(t);if(!a){let f=(m,p)=>{let x=t.createShader(m);return t.shaderSource(x,p),t.compileShader(x),x},u=t.createProgram();t.attachShader(u,f(35633,`#version 300 es
18
- out vec2 vNDC;void main(){vec2 p=vec2((gl_VertexID<<1)&2,gl_VertexID&2);vNDC=p*2.-1.;gl_Position=vec4(vNDC,.999999,1.);}`)),t.attachShader(u,f(35632,`#version 300 es
19
- precision highp float;in vec2 vNDC;uniform mat4 uInvVP;uniform vec3 uCameraPos;uniform sampler2D uSkyboxMap;uniform float uExposure;out vec4 fragColor;vec2 eqUV(vec3 d){return vec2(atan(d.x,d.z)/6.2831853+.5,asin(clamp(d.y,-1.,1.))/3.1415926+.5);}void main(){vec4 fp=uInvVP*vec4(vNDC,1.,1.);vec3 dir=normalize(fp.xyz/fp.w-uCameraPos);fragColor=vec4(pow(texture(uSkyboxMap,eqUV(dir)).rgb*uExposure,vec3(1./2.2)),1.);}`)),t.linkProgram(u);let b=typeof t.createVertexArray=="function"?t.createVertexArray():null;a={program:u,vao:b},Fe.set(t,a)}let d=mt(pt,n)||pt;t.depthMask(!1),t.useProgram(a.program),a.vao&&t.bindVertexArray(a.vao),t.activeTexture(33984),t.bindTexture(3553,e.skyboxTexture);let c=t.getUniformLocation(a.program,"uSkyboxMap");c&&t.uniform1i(c,0);let i=t.getUniformLocation(a.program,"uInvVP");i&&t.uniformMatrix4fv(i,!1,d);let l=t.getUniformLocation(a.program,"uCameraPos");l&&t.uniform3f(l,r[0],r[1],r[2]);let s=t.getUniformLocation(a.program,"uExposure");s&&t.uniform1f(s,e.exposure??1),t.drawArrays(4,0,3),t.depthMask(!0)},onResolveShader(e,t,n,r){if(r.includes("evalSHIrradiance"))return null;let o=r.replace("out vec4 fragColor;",`uniform vec3 uSH[9];
16
+ */var ThreeLiveStudio=(()=>{var ze=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,rr=Object.getOwnPropertyNames,ir=Object.prototype.hasOwnProperty,nr=(e,t)=>{for(var r in t)ze(e,r,{get:t[r],enumerable:!0})},ar=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of rr(t))!ir.call(e,n)&&n!==r&&ze(e,n,{get:()=>t[n],enumerable:!(i=tr(t,n))||i.enumerable});return e},or=e=>ar(ze({},"__esModule",{value:!0}),e),at={};nr(at,{InteractivityVM:()=>Mt,LOD:()=>Ir,LodController:()=>St,applyMeshoptFilter:()=>_t,computeOutlineClipOffset:()=>Wr,contactShadowPlugin:()=>Xt,decimateGeometry:()=>Nr,decodeMeshoptBuffer:()=>kt,decodeMeshoptGLB:()=>tt,encodeMeshoptBuffer:()=>Hr,environmentMapPlugin:()=>ft,evaluateKawaseBloom:()=>qr,extractMaterialVariants:()=>Qt,extractPrimitiveVariantMappings:()=>ai,getEnvironmentSH:()=>cr,getInteractivityVM:()=>Ye,getLodController:()=>Lr,hotspotPlugin:()=>ct,installLodExtension:()=>Ue,interactivityPlugin:()=>At,lodPlugin:()=>Tt,materialsPlugin:()=>Nt,meshoptDecoder:()=>rt,meshoptPlugin:()=>Bt,parseHexRgb:()=>jt,parseLod:()=>et,parseSafeGltfPointer:()=>Fe,postprocessingPlugin:()=>qt,registerMaterialShader:()=>Er,selectLodLevelIndex:()=>Je,selectMaterialVariant:()=>oi,sendInteractivityEvent:()=>wt,setEnvironmentSH:()=>lt,variantsPlugin:()=>Zt,webxrPlugin:()=>Jt});var _e="__THREE_LIVE_REGISTRY__";function ye(){let e=typeof globalThis<"u"?globalThis:{};if(!e[_e]){let t={plugins:[],decoders:new Map};try{Object.defineProperty(e,_e,{value:t,writable:!1,configurable:!1,enumerable:!1})}catch{e[_e]=t}}return e[_e]}var si=ye().plugins;function lr(e){let t=ye();t.workerExtensionInstallers||(t.workerExtensionInstallers=[]),t.workerExtensionInstallers.includes(e)||t.workerExtensionInstallers.push(e)}function se(e){let t=ye().plugins;t.some(r=>r.name===e.name)||t.push(e),e.onRegister?.()}function sr(){return ye().plugins}function Ae(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function Se(e,t,r){let i=t[0],n=t[1],s=t[2],m=t[3],c=t[4],o=t[5],d=t[6],a=t[7],u=t[8],l=t[9],h=t[10],f=t[11],g=t[12],A=t[13],v=t[14],T=t[15],p=r[0],b=r[1],y=r[2],L=r[3];return e[0]=p*i+b*c+y*u+L*g,e[1]=p*n+b*o+y*l+L*A,e[2]=p*s+b*d+y*h+L*v,e[3]=p*m+b*a+y*f+L*T,p=r[4],b=r[5],y=r[6],L=r[7],e[4]=p*i+b*c+y*u+L*g,e[5]=p*n+b*o+y*l+L*A,e[6]=p*s+b*d+y*h+L*v,e[7]=p*m+b*a+y*f+L*T,p=r[8],b=r[9],y=r[10],L=r[11],e[8]=p*i+b*c+y*u+L*g,e[9]=p*n+b*o+y*l+L*A,e[10]=p*s+b*d+y*h+L*v,e[11]=p*m+b*a+y*f+L*T,p=r[12],b=r[13],y=r[14],L=r[15],e[12]=p*i+b*c+y*u+L*g,e[13]=p*n+b*o+y*l+L*A,e[14]=p*s+b*d+y*h+L*v,e[15]=p*m+b*a+y*f+L*T,e}function ur(e,t,r,i){let n=t[0],s=t[1],m=t[2],c=t[3],o=n+n,d=s+s,a=m+m,u=n*o,l=n*d,h=n*a,f=s*d,g=s*a,A=m*a,v=c*o,T=c*d,p=c*a,b=i[0],y=i[1],L=i[2];return e[0]=(1-(f+A))*b,e[1]=(l+p)*b,e[2]=(h-T)*b,e[3]=0,e[4]=(l-p)*y,e[5]=(1-(u+A))*y,e[6]=(g+v)*y,e[7]=0,e[8]=(h+T)*L,e[9]=(g-v)*L,e[10]=(1-(u+f))*L,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Ve(e,t,r=0){let i=t[0],n=t[1],s=t[2],m=t[4],c=t[5],o=t[6],d=t[8],a=t[9],u=t[10],l=u*c-o*a,h=-u*m+o*d,f=a*m-c*d,g=i*l+n*h+s*f;return!g||r>0&&(!Number.isFinite(g)||Math.abs(g)<=r)||(g=1/g,e[0]=l*g,e[1]=h*g,e[2]=f*g,e[3]=(-u*n+s*a)*g,e[4]=(u*i-s*d)*g,e[5]=(-a*i+n*d)*g,e[6]=(o*n-s*c)*g,e[7]=(-o*i+s*m)*g,e[8]=(c*i-n*m)*g),e}function fr(e,t){let r=t[0],i=t[1],n=t[2],s=t[3],m=t[4],c=t[5],o=t[6],d=t[7],a=t[8],u=t[9],l=t[10],h=t[11],f=t[12],g=t[13],A=t[14],v=t[15],T=r*c-i*m,p=r*o-n*m,b=r*d-s*m,y=i*o-n*c,L=i*d-s*c,C=n*d-s*o,F=a*g-u*f,_=a*A-l*f,O=a*v-h*f,D=u*A-l*g,$=u*v-h*g,z=l*v-h*A,k=T*z-p*$+b*D+y*O-L*_+C*F;return k?(k=1/k,e[0]=(c*z-o*$+d*D)*k,e[1]=(n*$-i*z-s*D)*k,e[2]=(g*C-A*L+v*y)*k,e[3]=(l*L-u*C-h*y)*k,e[4]=(o*O-m*z-d*_)*k,e[5]=(r*z-n*O+s*_)*k,e[6]=(A*b-f*C-v*p)*k,e[7]=(a*C-l*b+h*p)*k,e[8]=(m*$-c*O+d*F)*k,e[9]=(i*O-r*$-s*F)*k,e[10]=(f*L-g*b+v*T)*k,e[11]=(u*b-a*L-h*T)*k,e[12]=(c*_-m*D-o*F)*k,e[13]=(r*D-i*_+n*F)*k,e[14]=(g*p-f*y-A*T)*k,e[15]=(a*y-u*p+l*T)*k,e):null}function ot(e,t){let r=Array.isArray(e?.nodes)?e.nodes.length:0,i=[];for(let a=0;a<r;a++)i.push(Ae());if(r===0)return i;let n=new Set;for(let a of e.nodes)if(Array.isArray(a.children))for(let u of a.children)n.add(u);let s=new Set,m=128,c=(a,u,l=0)=>{if(l>m||a<0||a>=r||s.has(a))return;s.add(a);let h=e.nodes[a];if(!h)return;let f=Ae();if(t&&t[a])f.set(t[a]);else if(h.matrix&&h.matrix.length===16)f.set(h.matrix);else{let A=h.translation||[0,0,0],v=h.rotation||[0,0,0,1],T=h.scale||[1,1,1];ur(f,v,A,T)}let g=i[a];if(u?Se(g,u,f):g.set(f),Array.isArray(h.children))for(let A of h.children)typeof A=="number"&&c(A,g,l+1)},o=[],d=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(d&&Array.isArray(d.nodes))o.push(...d.nodes);else for(let a=0;a<r;a++)n.has(a)||o.push(a);for(let a of o)c(a,null);for(let a=0;a<r;a++)!n.has(a)&&!o.includes(a)&&c(a,null);return i}var je=new WeakMap;function lt(e,t){let r=t instanceof Float32Array?t:new Float32Array(t);je.set(e,r)}function cr(e){return je.get(e)}async function hr(e,t){if(!t)return null;let r;if(typeof t=="string")if(typeof fetch<"u"&&typeof createImageBitmap=="function"){let n=await(await fetch(t)).blob();r=await createImageBitmap(n)}else if(typeof Image<"u")r=await new Promise((n,s)=>{let m=new Image;m.crossOrigin="anonymous",m.onload=()=>n(m),m.onerror=s,m.src=t});else return null;else r=t;let i=e.createTexture();return e.bindTexture(3553,i),e.texImage2D(3553,0,6408,6408,5121,r),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553),i}var Ge=new WeakMap,st=new Float32Array(16);async function ut(e,t,r){let i=r?await hr(e.gl,r):null;e[t]&&e.gl.deleteTexture(e[t]),e[t]=i}var ft={name:"environment-map",onContextRestored(e){Ge.delete(e)},setEnvironmentImage(e,t){return ut(e,"environmentTexture",t)},setSkyboxImage(e,t){return ut(e,"skyboxTexture",t)},onBeforeDrawScene(e,t,r,i,n){if(!e.skyboxTexture||typeof t.createProgram!="function")return;let s=Ge.get(t);if(!s){let u=(f,g)=>{let A=t.createShader(f);return t.shaderSource(A,g),t.compileShader(A),A},l=t.createProgram();t.attachShader(l,u(35633,`#version 300 es
17
+ out vec2 vNDC;void main(){vec2 p=vec2((gl_VertexID<<1)&2,gl_VertexID&2);vNDC=p*2.-1.;gl_Position=vec4(vNDC,.999999,1.);}`)),t.attachShader(l,u(35632,`#version 300 es
18
+ precision highp float;in vec2 vNDC;uniform mat4 uInvVP;uniform vec3 uCameraPos;uniform sampler2D uSkyboxMap;uniform float uExposure;out vec4 fragColor;vec2 eqUV(vec3 d){return vec2(atan(d.x,d.z)/6.2831853+.5,asin(clamp(d.y,-1.,1.))/3.1415926+.5);}void main(){vec4 fp=uInvVP*vec4(vNDC,1.,1.);vec3 dir=normalize(fp.xyz/fp.w-uCameraPos);fragColor=vec4(pow(texture(uSkyboxMap,eqUV(dir)).rgb*uExposure,vec3(1./2.2)),1.);}`)),t.linkProgram(l);let h=typeof t.createVertexArray=="function"?t.createVertexArray():null;s={program:l,vao:h},Ge.set(t,s)}let m=fr(st,r)||st;t.depthMask(!1),t.useProgram(s.program),s.vao&&t.bindVertexArray(s.vao),t.activeTexture(33984),t.bindTexture(3553,e.skyboxTexture);let c=t.getUniformLocation(s.program,"uSkyboxMap");c&&t.uniform1i(c,0);let o=t.getUniformLocation(s.program,"uInvVP");o&&t.uniformMatrix4fv(o,!1,m);let d=t.getUniformLocation(s.program,"uCameraPos");d&&t.uniform3f(d,i[0],i[1],i[2]);let a=t.getUniformLocation(s.program,"uExposure");a&&t.uniform1f(a,e.exposure??1),t.drawArrays(4,0,3),t.depthMask(!0)},onResolveShader(e,t,r,i){if(i.includes("evalSHIrradiance"))return null;let n=i.replace("out vec4 fragColor;",`uniform vec3 uSH[9];
20
19
  uniform int uHasSH;
21
20
  out vec4 fragColor;`).replace("void main(){",`vec3 integrateBRDFApprox(vec3 f0,float r,float NoV){vec4 c0=vec4(-1.,-.0275,-.572,.022),c1=vec4(1.,.0425,1.04,-.04),rv=r*c0+c1;float a=min(rv.x*rv.x,exp2(-9.28*NoV))*rv.x+rv.y;vec2 ab=vec2(-1.04,1.04)*a+rv.zw;return f0*ab.x+vec3(ab.y);}
22
21
  vec3 evalSHIrradiance(vec3 n){return max(vec3(0.),uSH[0]+uSH[1]*n.y+uSH[2]*n.z+uSH[3]*n.x+uSH[4]*(n.x*n.y)+uSH[5]*(n.y*n.z)+uSH[6]*(3.*n.z*n.z-1.)+uSH[7]*(n.x*n.z)+uSH[8]*(n.x*n.x-n.y*n.y));}
23
- void main(){`);return o=o.replace(`if(uHasEnvironmentMap==1){
22
+ void main(){`);return n=n.replace(`if(uHasEnvironmentMap==1){
24
23
  specularIBL=texture(uEnvironmentMap,equirectangularUV(R)).rgb*(F*brdf.x+brdf.y);
25
24
  envDiffuse=texture(uEnvironmentMap,equirectangularUV(N)).rgb;
26
25
  }`,`if(uHasEnvironmentMap==1){
@@ -29,15 +28,15 @@ envDiffuse=uHasSH==1?evalSHIrradiance(N):textureLod(uEnvironmentMap,equirectangu
29
28
  }else if(uHasSH==1){
30
29
  specularIBL=getStudioRadiance(R,roughness)*integrateBRDFApprox(F,roughness,NoV);
31
30
  envDiffuse=evalSHIrradiance(N);
32
- }`),{vs:n,fs:o}},onBeforeDrawPrimitive(e,t,n,r,o,a){let d=ze.get(e),c=e.getUniformLocation(t,"uHasSH");if(d&&d.length>=27){c&&e.uniform1i(c,1);let i=e.getUniformLocation(t,"uSH");i&&e.uniform3fv(i,d)}else c&&e.uniform1i(c,0)},onAttributeChanged(e,t,n,r){t==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,r):t==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,r)}};var Ge=new WeakMap;function He(e,t){let n=t||e.viewer;if(!n||typeof n.projectPointToScreen!="function")return;let r=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let o=0;o<r.length;o++){let a=r[o],d=a.getAttribute("data-position");if(!d)continue;let c=d.trim().split(/\s+/).map(f=>parseFloat(f.replace(/m$/,"")));if(c.length<3||c.some(isNaN))continue;let i=a.getAttribute("data-normal"),l;if(i){let f=i.trim().split(/\s+/).map(u=>parseFloat(u));f.length>=3&&!f.some(isNaN)&&(l=[f[0],f[1],f[2]])}let s=n.projectPointToScreen([c[0],c[1],c[2]],l);a.style.position="absolute",a.style.left="0",a.style.top="0",a.style.transform=`translate(-50%, -50%) translate3d(${s.x}px, ${s.y}px, 0)`,a.style.zIndex="3",s.visible?(a.style.opacity="1",a.style.pointerEvents="auto",a.removeAttribute("data-occluded")):(a.style.opacity="0",a.style.pointerEvents="none",a.setAttribute("data-occluded",""))}}var We={name:"hotspots",updateHotspotsForElement:He,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let t=new MutationObserver(()=>{He(e)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),Ge.set(e,t)},onCameraChange(e,t){t&&He(t,e)},onElementDisconnected(e){let t=Ge.get(e);t&&(t.disconnect(),Ge.delete(e))}};function te(e,t,n,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(t,Math.min(n,o))}function an(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function Xe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function sn(e,t=256){return typeof e=="string"&&e.length>0?e.slice(0,t):void 0}function yt(e){let t=Xe(e);if(!t)return null;let n=t.target;return{target:an(n)?[n[0],n[1],n[2]]:typeof n=="string"&&n.length>0&&n.length<=256?n:[0,0,0],radius:te(t.radius,.01,50,.5),speed:te(t.speed,-20,20,.5),height:te(t.height,-10,10,0),phase:te(t.phase,-1e6,1e6,0),faceCenter:t.faceCenter===!0}}function we(e,t){let n=sn(e,16)?.trim();if(!n)return t;let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n);return r?`#${r[1].toLowerCase()}`:t}function $e(e){if(e===!1||e===null||e===void 0)return null;if(typeof e=="number")return!Number.isFinite(e)||e<=0?null:{enabled:!0,strength:te(e,0,5,.35),threshold:.8,radius:.5};if(e===!0)return{enabled:!0,strength:.35,threshold:.8,radius:.5};let t=Xe(e);if(!t||t.enabled===!1)return null;let n=te(t.strength??t.intensity,0,5,.35);return n<=0?null:{enabled:!0,strength:n,threshold:te(t.threshold,0,4,.8),radius:te(t.radius,0,2,.5)}}function Ee(e){if(!e)return null;if(typeof e=="string")return{enabled:!0,color:we(e,"#38bdf8"),thickness:3,pulse:!1};if(e===!0)return{enabled:!0,color:"#38bdf8",thickness:3,pulse:!1};let t=Xe(e);if(!t||t.enabled===!1)return null;let n=t.thickness??t.width;return{enabled:!0,color:we(t.color,"#38bdf8"),thickness:te(typeof n=="number"&&n>0&&n<.25?Math.max(1.5,n*140):n,.5,20,3),pulse:t.pulse===!0}}function gt(e,t,n,r){let o=t[0],a=t[1],d=t[2],c=t[3],i=n[0],l=n[1],s=n[2],f=n[3],u=o*i+a*l+d*s+c*f;if(u<0&&(i=-i,l=-l,s=-s,f=-f,u=-u),Math.abs(u)>=1)return e[0]=o,e[1]=a,e[2]=d,e[3]=c,e;let b=Math.acos(u),m=Math.sqrt(1-u*u);if(Math.abs(m)<.001)return e[0]=.5*(o+i),e[1]=.5*(a+l),e[2]=.5*(d+s),e[3]=.5*(c+f),e;let p=Math.sin((1-r)*b)/m,x=Math.sin(r*b)/m;return e[0]=o*p+i*x,e[1]=a*p+l*x,e[2]=d*p+s*x,e[3]=c*p+f*x,e}var xt=1024,je=256,Se=2048,cn=128,ln=64,un=16,fn=1e4,dn=8,ne=new Set(["__proto__","constructor","prototype"]),Tt={neg:e=>-e,abs:Math.abs,sign:Math.sign,floor:Math.floor,ceil:Math.ceil,round:Math.round,trunc:Math.trunc,fract:e=>e-Math.floor(e),sqrt:e=>Math.sqrt(Math.max(0,e)),cbrt:Math.cbrt,exp:Math.exp,log:e=>e>0?Math.log(e):0,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:e=>Math.asin(Math.max(-1,Math.min(1,e))),acos:e=>Math.acos(Math.max(-1,Math.min(1,e))),atan:Math.atan,rad:e=>e*Math.PI/180,deg:e=>e*180/Math.PI,saturate:e=>Math.max(0,Math.min(1,e))},At={add:(e,t)=>e+t,sub:(e,t)=>e-t,mul:(e,t)=>e*t,div:(e,t)=>Math.abs(t)<1e-12?0:e/t,rem:(e,t)=>Math.abs(t)<1e-12?0:e%t,mod:(e,t)=>Math.abs(t)<1e-12?0:e%t,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},Me={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},Re=(e,t)=>e!==null&&typeof e=="object"&&!ne.has(t)&&Object.prototype.hasOwnProperty.call(e,t),Y=e=>Array.isArray(e)?[...e]:e,St=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&Re(e,"value")?e.value:e,j=(e,t)=>Re(e.configuration,t)?St(e.configuration[t]):void 0,L=(e,t=0)=>{let n=Number(e);return Number.isFinite(n)?n:t},ae=e=>Math.max(0,Math.min(1,e)),q=e=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!Number.isNaN(e):typeof e=="string"?e.length>0&&e!=="false":!!e;function pe(e){if(typeof e!="string"||!e.startsWith("/"))return null;let t=[];for(let n of e.slice(1).split("/")){let r=n.replace(/~1/g,"/").replace(/~0/g,"~");if(!r||ne.has(r)||ne.has(n))return null;t.push(r)}return{segments:t}}var de=(e,t)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let n=Number(e);return Number.isSafeInteger(n)&&n>=0&&n<t?n:-1},vt=e=>{let t=L(e[0]),n=L(e[1]),r=L(e[2]),o=L(e[3],1),a=Math.hypot(t,n,r,o);return a>1e-8?[t/a,n/a,r/a,o/a]:[0,0,0,1]},wt=(e,t,n,r)=>{if(typeof e=="number"&&typeof t=="number")return e+(t-e)*n;if(Array.isArray(e)&&Array.isArray(t)){if(r&&e.length===4&&t.length===4){let o=[0,0,0,1];return gt(o,vt(e),vt(t),n),o}return e.slice(0,t.length).map((o,a)=>o+(t[a]-o)*n)}return n>=.5?t:e},Ke=(e,t,n)=>Array.isArray(e)&&Array.isArray(t)?e.slice(0,t.length).map((r,o)=>n(L(r),L(t[o]))):Array.isArray(e)?e.map(r=>n(L(r),L(t))):Array.isArray(t)?t.map(r=>n(L(e),L(r))):n(L(e),L(t)),mn=(e,t)=>Array.isArray(e)?e.map(n=>t(L(n))):t(L(e)),Et=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>Math.abs(n-t[r])<=1e-6):e===t,be=class{constructor(t,n,r){let o=Array.isArray(r.nodes)?r.nodes:[];if(o.length>xt)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${xt})`);let a=Array.isArray(r.variables)?r.variables:[];if(a.length>je)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${je})`);let d=Array.isArray(r.declarations)?r.declarations:[],c=Array.isArray(r.events)?r.events:[],i=new Map,l=new Map,s=new Map,f=new Map,u=new Map,b=new Map,m=[],p=[],x=new Map,E=1,I=0,v=0,S=0,w=0,U=!1,V=!1,O=!1;a.forEach((T,A)=>{if(!T||typeof T!="object")return;let R=Y(St(T.value));i.set(A,R);let _=T.id??T.name;typeof _=="string"&&_&&!ne.has(_)&&i.set(_,R)}),(n?.nodes||[]).forEach((T,A)=>{for(let R of T?.children||[])typeof R=="number"&&x.set(R,A)});let N=T=>T.op||typeof T.declaration=="number"&&d[T.declaration]?.op||"",P=(T,A,R)=>{if(ne.has(A))return;let _=l.get(T);_||l.set(T,_=Object.create(null)),_[A]=R},C=(T,A)=>{if(typeof T!="number"&&typeof T!="string"||typeof T=="string"&&ne.has(T)||!i.has(T)&&i.size>=je*2)return;let R=Y(A);if(i.set(T,R),typeof T=="number"){let _=a[T]?.id??a[T]?.name;typeof _=="string"&&!ne.has(_)&&i.set(_,R)}},z=T=>typeof T=="number"?c[T]?.id??String(T):typeof T=="string"?/^\d+$/.test(T)&&c[Number(T)]?.id?c[Number(T)].id:T:"",W=(T,A)=>{for(let R=T,_=0;R!==void 0&&R>=0&&_<128;R=x.get(R),_++)if(R===A)return!0;return!1},B=T=>{for(let A=m.length-1;A>=0;A--)m[A].key===T&&m.splice(A,1)},oe=T=>{B(T.key),m.length>=cn&&m.shift(),m.push(T)},re=T=>{let A=pe(T)?.segments;if(A){if(A[0]==="nodes"&&Array.isArray(n?.nodes)){let R=n.nodes[de(A[1],n.nodes.length)];if(!R)return;let _=A[2];if(_ in Me){let g=Me[_],h=R[_]||g;return g.map((y,M)=>L(h[M],y))}if(_==="weights"){let g=Array.isArray(R.weights)?R.weights:[0],h=A.length===4?de(A[3],64):-2;return h===-2?g.map(y=>L(y)):h>=0?L(g[h]):void 0}if(_==="visible"||_==="extensions"&&A[3]==="KHR_node_visibility"&&A[4]==="visible")return R.extensions?.KHR_node_visibility?.visible??R.visible??!0}else if(A[0]==="materials"&&Array.isArray(n?.materials)){let R=n.materials[de(A[1],n.materials.length)];if(!R)return;let _=R.pbrMetallicRoughness||{};if(A[2]==="pbrMetallicRoughness"){if(A[3]==="baseColorFactor"){let g=_.baseColorFactor||[1,1,1,1];return[L(g[0],1),L(g[1],1),L(g[2],1),L(g[3],1)]}if(A[3]==="metallicFactor"||A[3]==="roughnessFactor")return L(_[A[3]],1)}if(A[2]==="emissiveFactor"){let g=R.emissiveFactor||[0,0,0];return[L(g[0]),L(g[1]),L(g[2])]}if(A[2]==="alphaCutoff")return L(R.alphaCutoff,.5)}}},ie=(T,A)=>{let R=pe(T)?.segments;if(!R)return!1;if(R[0]==="nodes"&&Array.isArray(n?.nodes)){let _=de(R[1],n.nodes.length),g=n.nodes[_];if(!g)return!1;let h=R[2];if(h in Me&&Array.isArray(A)){let y=Me[h];if(A.length<y.length)return!1;let M=y.map((G,$)=>L(A[$],G));if(h==="rotation"){let G=Math.hypot(...M);M=G>1e-8?M.map($=>$/G):[0,0,0,1]}g[h]=M,delete g.matrix;let F=t?.initialNodeTransforms?.[_];return F&&(F[h[0]]=[...M]),U=!0,!0}if(h==="weights"){Array.isArray(g.weights)||(g.weights=[]);let y=(M,F)=>{for(let G of t?.meshes||[])if(G.nodeIndex===_)for(let $ of G.primitives||[])$.pluginData?.morph?.weights&&($.pluginData.morph.weights[M]=F)};if(R.length===4){let M=de(R[3],64);if(M<0)return!1;y(M,g.weights[M]=L(A))}else if(Array.isArray(A))g.weights=A.slice(0,64).map(M=>L(M)),g.weights.forEach((M,F)=>y(F,M));else return!1;return O=!0,!0}if(h==="visible"||h==="extensions"&&R[3]==="KHR_node_visibility"&&R[4]==="visible"){let y=q(A);return g.visible=y,(!g.extensions||typeof g.extensions!="object")&&(g.extensions={}),g.extensions.KHR_node_visibility={visible:y},V=!0,!0}}else if(R[0]==="materials"&&Array.isArray(n?.materials)){let _=de(R[1],n.materials.length),g=n.materials[_];if(!g)return!1;let h=g.pbrMetallicRoughness||(g.pbrMetallicRoughness={}),y=M=>{for(let F of t?.meshes||[])for(let G of F.primitives||[])(G.materialIndex??0)===_&&M(G)};if(R[2]==="pbrMetallicRoughness"){if(R[3]==="baseColorFactor"&&Array.isArray(A)&&A.length>=3){let M=[ae(L(A[0],1)),ae(L(A[1],1)),ae(L(A[2],1)),A[3]!==void 0?ae(L(A[3],1)):h.baseColorFactor?.[3]??1];return h.baseColorFactor=M,y(F=>F.baseColor=[...M]),O=!0}if(R[3]==="metallicFactor"||R[3]==="roughnessFactor"){let M=R[3]==="metallicFactor",F=ae(L(A,M?0:.5));return h[R[3]]=F,y(G=>G[M?"metallic":"roughness"]=F),O=!0}}if(R[2]==="emissiveFactor"&&Array.isArray(A)&&A.length>=3)return g.emissiveFactor=[0,1,2].map(M=>Math.max(0,L(A[M]))),O=!0;if(R[2]==="alphaCutoff")return g.alphaCutoff=ae(L(A,.5)),O=!0}return!1},Ce=(T,A,R=new Set)=>{let _=j(A,"pointer");if(typeof _!="string"||!_.startsWith("/"))return null;let g=_.replace(/\{([a-zA-Z0-9_]+)\}/g,(h,y)=>{let M=Math.trunc(Number(xe(T,y,void 0,R)??j(A,y)));return Number.isSafeInteger(M)&&M>=0?String(M):"-1"});return pe(g)?g:null},xe=(T,A,R,_)=>{let g=o[T]?.values;if(!Re(g,A))return R;let h=g[A];if(h==null)return R;if(typeof h!="object"||Array.isArray(h))return Y(h);let y=h;return typeof y.node=="number"?Yt(y.node,y.socket||"value",_):Re(y,"value")?Y(y.value):R},Yt=(T,A,R)=>{if(T<0||T>=o.length||R.has(T)||R.size>128||++S>fn)return;let _=o[T],g=N(_);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(g))return Y(l.get(T)?.[A]);R.add(T);try{let h=(y,M=0)=>xe(T,y,M,R);if(g==="variable/get"){let y=j(_,"variable")??j(_,"id");return typeof y=="number"||typeof y=="string"?Y(i.get(y)):void 0}if(g==="pointer/get"){let y=Ce(T,_,R);return y?re(y):void 0}if(g.startsWith("math/")){let y=g.slice(5);if(y in Tt)return mn(h("a"),Tt[y]);if(y in At){let M=/^(mul|div|rem|mod|pow)$/.test(y)?1:0;return Ke(h("a",y==="mul"?1:0),h("b",M),At[y])}if(y==="pi")return Math.PI;if(y==="e")return Math.E;if(y==="random")return Math.random();if(y==="clamp")return Ke(Ke(h("a"),h("b",h("min",0)),Math.max),h("c",h("max",1)),Math.min);if(y==="mix"||y==="quatSlerp")return wt(h("a",0),h("b",1),L(h("c",h("t",.5)),.5),y==="quatSlerp");if(y==="dot"){let M=h("a"),F=h("b");return Array.isArray(M)&&Array.isArray(F)?M.reduce((G,$,k)=>G+($||0)*(F[k]||0),0):L(M)*L(F)}if(y==="cross"){let M=h("a",[0,0,0]),F=h("b",[0,0,0]);return Array.isArray(M)&&Array.isArray(F)?[(M[1]||0)*(F[2]||0)-(M[2]||0)*(F[1]||0),(M[2]||0)*(F[0]||0)-(M[0]||0)*(F[2]||0),(M[0]||0)*(F[1]||0)-(M[1]||0)*(F[0]||0)]:[0,0,0]}if(y==="length"){let M=h("a");return Array.isArray(M)?Math.hypot(...M):Math.abs(L(M))}if(y==="distance"){let M=h("a"),F=h("b");return Array.isArray(M)&&Array.isArray(F)?Math.hypot(...M.map((G,$)=>(G||0)-(F[$]||0))):Math.abs(L(M)-L(F))}if(y==="normalize"){let M=h("a");if(!Array.isArray(M))return L(M)>=0?1:-1;let F=Math.hypot(...M);return F>1e-8?M.map(G=>G/F):M.map(()=>0)}if(y.startsWith("combine"))return["a","b","c","d"].slice(0,Number(y[7])||2).map(M=>L(h(M)));if(y.startsWith("extract")){let M=h("a");return Array.isArray(M)?M[A==="0"||A==="x"?0:A==="1"||A==="y"?1:A==="2"||A==="z"?2:3]??0:0}if(y==="eq")return Et(h("a"),h("b"));if(y==="ne")return!Et(h("a"),h("b"));if(y==="lt")return L(h("a"))<L(h("b"));if(y==="le")return L(h("a"))<=L(h("b"));if(y==="gt")return L(h("a"))>L(h("b"));if(y==="ge")return L(h("a"))>=L(h("b"));if(y==="isNaN")return Number.isNaN(Number(h("a")));if(y==="isInf"){let M=Number(h("a"));return!Number.isFinite(M)&&!Number.isNaN(M)}return y==="and"?q(h("a",!1))&&q(h("b",!1)):y==="or"?q(h("a",!1))||q(h("b",!1)):y==="xor"?q(h("a",!1))!==q(h("b",!1)):y==="not"?!q(h("a",!1)):y==="select"?Y(q(h("condition",!1))?h("a"):h("b")):void 0}return g==="type/boolToInt"||g==="type/boolToFloat"?q(h("a",!1))?1:0:g==="type/intToBool"||g==="type/floatToBool"?L(h("a",0))!==0:g==="type/intToFloat"?L(h("a",0)):g==="type/floatToInt"?Math.trunc(L(h("a",0))):void 0}finally{R.delete(T)}},Te=()=>{if(U){U=!1,O=!0;let T=De(n);if(t){t.worldMatrices=T;for(let A of t.meshes||[])A.nodeIndex>=0&&A.nodeIndex<T.length&&(A.transform.set(T[A.nodeIndex]),fe(A.normalMatrix,A.transform))}}if(V){V=!1,O=!0;let T=n?.nodes;if(Array.isArray(t?.meshes)&&Array.isArray(T))for(let A of t.meshes){let R=!0;for(let _=A.nodeIndex,g=0;_!==void 0&&_>=0&&g<128;_=x.get(_),g++){let h=T[_];if(h?.visible===!1||h?.extensions?.KHR_node_visibility?.visible===!1){R=!1;break}}A.visible=R}}O&&(O=!1,t?.render?.())},se=(T,A={steps:0})=>{if(!T||typeof T.node!="number")return;A.steps===0&&(S=0);let R=[T],_=g=>{R.length+A.steps<Se&&R.push(g)};for(;R.length>0&&A.steps<Se;){A.steps++;let g=R.shift();if(!g||g.node<0||g.node>=o.length)continue;let h=g.node,y=o[h];if(!y)continue;let M=g.socket||"in",F=N(y),G=(k,D=void 0)=>xe(h,k,D,new Set),$=(k="out")=>{let D=y.flows?.[k];D&&_(D)};switch(F){case"flow/branch":$(q(G("condition",!1))?"true":"false");break;case"flow/sequence":for(let k of Object.keys(y.flows||{}).sort((D,K)=>Number(D)-Number(K)||D.localeCompare(K)))$(k);break;case"flow/switch":{let k=y.flows?.[String(G("selection",G("value",0)))]??y.flows?.default;k&&_(k);break}case"flow/for":{let k=Math.trunc(L(G("startIndex",0))),D=Math.trunc(L(G("endIndex",0))),K=Math.max(1,Math.trunc(L(G("step",1),1))),Q=y.flows?.body;if(Q&&D>k&&w<dn){let qt=Math.min(Math.ceil((D-k)/K),Se);w++;try{for(let Oe=0;Oe<qt&&A.steps<Se;Oe++)P(h,"index",k+Oe*K),se(Q,A)}finally{w--}}let ft=y.flows?.completed??y.flows?.out;ft&&_(ft);break}case"flow/doN":{let k=M==="reset"?0:(s.get(h)||0)+1;if(s.set(h,k),P(h,"currentCount",k),P(h,"count",k),M!=="reset"){let D=Math.trunc(L(G("n",j(y,"stopIterations")??j(y,"n")??1),1));k<=D&&$()}break}case"flow/multiGate":{if(M==="reset"){b.set(h,0);break}let k=Object.keys(y.flows||{}).sort();if(!k.length)break;let D=j(y,"isRandom")?Math.floor(Math.random()*k.length):b.get(h)||0;D<k.length&&($(k[D]),b.set(h,j(y,"isLoop")!==!1?(D+1)%k.length:D+1));break}case"flow/waitAll":{if(M==="reset"){f.delete(h);break}let k=f.get(h);k||f.set(h,k=new Set),k.add(M),k.size>=Math.max(1,Math.trunc(Number(j(y,"inputFlows")??2)||2))&&(k.clear(),$("out"),$("completed"));break}case"flow/throttle":{if(M==="reset"){u.delete(h);break}let k=Math.max(0,L(G("duration",0))),D=u.get(h);D===void 0||I-D>=k?(u.set(h,I),P(h,"lastRemainingTime",0),$()):P(h,"lastRemainingTime",Math.max(0,k-(I-D)));break}case"flow/delay":case"flow/setDelay":{if(M==="cancel"){for(let Q=p.length-1;Q>=0;Q--)p[Q].nodeIdx===h&&p.splice(Q,1);P(h,"lastDelayIndex",-1);break}let k=Math.max(0,L(G("duration",j(y,"duration")??0))),D=y.flows?.done??y.flows?.out;if(k<=0){P(h,"lastDelayIndex",-1),D&&_(D);break}p.length>=ln&&p.shift();let K=E++;P(h,"lastDelayIndex",K),p.push({id:K,nodeIdx:h,rem:k,done:D}),F==="flow/setDelay"&&y.flows?.out&&y.flows?.done&&$("out");break}case"flow/cancelDelay":{let k=Math.trunc(L(G("delayIndex",-1),-1));if(k<0)p.length=0;else for(let D=p.length-1;D>=0;D--)p[D].id===k&&p.splice(D,1);$();break}case"variable/set":C(j(y,"variable")??j(y,"id"),G("value")),$();break;case"variable/interpolate":{let k=j(y,"variable")??j(y,"id"),D=G("value",G("target")),K=Math.max(0,L(G("duration",j(y,"duration")??.3),.3));k!==void 0&&D!==void 0&&oe({key:`var:${String(k)}`,varKey:k,from:Y(G("from")??i.get(k)??0),to:Y(D),dur:K,elapsed:0,quat:!1,linear:j(y,"easing")==="linear",done:y.flows?.done}),$();break}case"pointer/set":{let k=Ce(h,y),D=G("value");k&&D!==void 0&&(B(`ptr:${k}`),ie(k,D)),$();break}case"pointer/interpolate":{let k=Ce(h,y),D=G("value",G("target")),K=Math.max(0,L(G("duration",j(y,"duration")??.3),.3));if(k&&D!==void 0){let Q=G("from")??re(k);Q!==void 0&&(K<=0?(ie(k,D),$("done")):oe({key:`ptr:${k}`,ptr:k,from:Y(Q),to:Y(D),dur:K,elapsed:0,quat:k.endsWith("/rotation"),linear:j(y,"easing")==="linear",done:y.flows?.done}))}$();break}case"animation/start":{let k=G("animation")??j(y,"animation")??j(y,"clipName"),D=typeof k=="number"?t?.animations?.[k]?.name??n?.animations?.[k]?.name:typeof k=="string"?k:void 0;t?.playAnimation?.(D),O=!0,$();break}case"animation/stop":case"animation/resetAt":t?.pauseAnimation?.(),F==="animation/resetAt"&&t?.evaluateAnimation?.(L(G("time",0))),O=!0,$();break;case"event/send":case"customEvent/send":{let k=z(j(y,"event")??j(y,"id")),D={};for(let K of Object.keys(y.values||{}))ne.has(K)||(D[K]=G(K));k&&(typeof CustomEvent<"u"&&typeof t?.container?.dispatchEvent=="function"&&t.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:k,values:D}})),ut(k,D,A)),$();break}default:$();break}}};this.readScenePointer=re,this.writeScenePointer=ie,this.fireOnStart=()=>{o.forEach(T=>{N(T)==="event/onStart"&&se(T.flows?.out)}),Te()},this.fireOnSelect=T=>{if(!T)return;let A=typeof T.meshIndex=="number"?T.meshIndex:-1,R=typeof T.nodeIndex=="number"?T.nodeIndex:t?.meshes?.[A]?.nodeIndex??-1;o.forEach((_,g)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(N(_)))return;let h=j(_,"nodeIndex")??j(_,"node")??xe(g,"nodeIndex",void 0,new Set),y=j(_,"meshName");if(typeof y=="string"&&y?T.meshName===y:h==null||Number(h)<0||Number.isNaN(Number(h))||W(R,Math.trunc(Number(h)))){if(P(g,"nodeIndex",R),P(g,"meshIndex",A),Array.isArray(T.hitPoint)){let F=[L(T.hitPoint[0]),L(T.hitPoint[1]),L(T.hitPoint[2])];P(g,"hitPoint",F),P(g,"point",F),P(g,"intersectionPoint",F)}if(Array.isArray(T.normal)){let F=[L(T.normal[0]),L(T.normal[1],1),L(T.normal[2])];P(g,"normal",F),P(g,"hitNormal",F)}typeof T.distance=="number"&&P(g,"distance",T.distance),se(_.flows?.out)}}),Te()},this.receiveCustomEvent=(T,A={})=>ut(T,A,{steps:0});function ut(T,A,R){if(!(v>=un)){v++;try{let _=z(T);o.forEach((g,h)=>{if(!/^(customE|e)vent\/receive$/.test(N(g)))return;let y=j(g,"event")??j(g,"id");if(!(z(y)!==_&&String(y)!==String(T))){for(let[M,F]of Object.entries(A))ne.has(M)||P(h,M,Y(F));se(g.flows?.out,R)}}),Te()}finally{v--}}}this.tick=T=>{if(!Number.isFinite(T)||T<0)return;let A=Math.min(T,.25);I+=A,o.forEach((_,g)=>{N(_)==="event/onTick"&&(P(g,"timeDelta",A),P(g,"dt",A),P(g,"timeElapsed",I),se(_.flows?.out))});let R=[];for(let _=m.length-1;_>=0;_--){let g=m[_];g.elapsed+=A;let h=g.dur>1e-6?ae(g.elapsed/g.dur):1,y=g.linear?h:h*h*(3-2*h),M=wt(g.from,g.to,y,g.quat);g.ptr?ie(g.ptr,M):g.varKey!==void 0&&C(g.varKey,M),h>=1&&(m.splice(_,1),g.done&&R.push(g.done))}for(let _=p.length-1;_>=0;_--){let g=p[_];g.rem-=A,g.rem<=0&&(p.splice(_,1),g.done&&R.push(g.done))}for(let _ of R)se(_);Te()},this.dispose=()=>{m.length=0,p.length=0,i.clear(),l.clear(),s.clear(),f.clear(),u.clear(),b.clear()}}},J=new WeakMap,_e=new WeakMap;function pn(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||dt().some(i=>i.name==="xr-live-head-follow")||(typeof e.getAutoRotate=="function"?e.getAutoRotate():e.autoRotate)===!1)return;let r=e.gltf,o=r?.nodes;if(!Array.isArray(o)||o.length===0)return;let a=Math.min(t,.1),d=(_e.get(e)||0)+a,c=!1;for(let i=0;i<o.length;i++){let l=o[i],s=yt(l?.extras?.xr?.orbit);if(!s)continue;let f=0,u=0,b=0;if(Array.isArray(s.target))f=s.target[0],u=s.target[1],b=s.target[2];else if(typeof s.target=="string"&&s.target!=="head"){let I=o.find(v=>v?.name===s.target);Array.isArray(I?.translation)&&(f=L(I.translation[0]),u=L(I.translation[1]),b=L(I.translation[2]))}let m=s.phase+s.speed*d,p=f+Math.cos(m)*s.radius,x=u+s.height,E=b+Math.sin(m)*s.radius;if(l.translation=[p,x,E],s.faceCenter){let I=Math.atan2(f-p,b-E);l.rotation=[0,Math.sin(I*.5),0,Math.cos(I*.5)]}c=!0}if(c){_e.set(e,d);let i=De(r);e.worldMatrices=i;for(let l of e.meshes||[])l.nodeIndex>=0&&l.nodeIndex<i.length&&(l.transform.set(i[l.nodeIndex]),fe(l.normalMatrix,l.transform))}}function Ie(e){if(!(!e||typeof e!="object"))return J.get(e)||J.get(e.viewer)||J.get(e._view)}function Ye(e,t,n){let r=Ie(e);return r?(r.receiveCustomEvent(t,n),!0):!1}var qe={name:"khr-interactivity",sendInteractivityEvent:Ye,getInteractivityVM:Ie,onLoadModel(e,t){if(!e||typeof e!="object")return;J.get(e)?.dispose(),J.delete(e),_e.delete(e);let n=t?.extensions?.KHR_interactivity,r=Array.isArray(n?.graphs)?n.graphs[n.graph??0]:n;if(!r||!Array.isArray(r.nodes))return;let o=new be(e,t,r);J.set(e,o),o.fireOnStart()},onMeshSelect(e,t){J.get(e)?.fireOnSelect(t)},onUpdate(e,t){J.get(e)?.tick(t),pn(e,t)},onDestroy(e,t){J.get(t)?.dispose(),J.delete(t),_e.delete(t)}};var he=new Map,Le=new WeakMap;function Mt(e,t){he.set(e,t)}var Qe={name:"materials",onContextRestored(e){Le.delete(e)},onBuildPrimitiveVAO(e,t,n,r,o){return(((r?.materials&&n.material!==void 0?r.materials[n.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,t){let n=Le.get(e);n||(n=e.createTexture(),Le.set(e,n));let r=Math.max(1,t.canvas.width),o=Math.max(1,t.canvas.height);e.activeTexture(33990),e.bindTexture(3553,n),e.copyTexImage2D(3553,0,6408,0,0,r,o,0),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553)},onResolveShader(e,t,n,r){if(!t)return null;if(t.name&&he.has(t.name)){let m=he.get(t.name);return{vs:m.vs||n,fs:m.fs||r}}let o=t.extensions||{},a=o.KHR_materials_clearcoat,d=o.KHR_materials_sheen,c=!!o.KHR_materials_transmission,i=!!o.KHR_materials_ior,l=o.KHR_materials_iridescence;if(!a&&!d&&!o.KHR_materials_unlit&&!c&&!o.KHR_materials_volume&&!i&&!o.KHR_materials_dispersion&&!l)return null;if(o.KHR_materials_unlit)return{vs:n,fs:r.replace("fragColor=vec4(color,outAlpha);","fragColor=vec4(base.rgb,outAlpha);").replace("fragColor=vec4(color,base.a);","fragColor=vec4(base.rgb,base.a);")};let s=r;if(c){let m=s.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
33
- `;s=s.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
34
- ${m}out vec4 fragColor;`)}let f=(m,p,x=0,E=1e6,I=3)=>{let v=Number(m);return(Number.isFinite(v)?Math.min(E,Math.max(x,v)):p).toFixed(I)},u=Number(o.KHR_materials_ior?.ior??1.5),b=Number.isFinite(u)?Math.min(10,Math.max(1,u)):1.5;if(i){let m=Math.pow((b-1)/(b+1),2);s=s.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${f(m,.04,0,1,4)}),base.rgb,metallic);`)}if(l){let m=f(l.iridescenceFactor,1,0,1),p=f(l.iridescenceIor,1.3,1,10);s=s.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${p}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${m}*pow(1.-NoV,2.));`)}if(c){let m=f(o.KHR_materials_transmission?.transmissionFactor,1,0,1),p=o.KHR_materials_volume||{},x=f(p.thicknessFactor,.5,0,1e4),E=f(p.attenuationDistance,1,.001,1e6),I=Array.isArray(p.attenuationColor)?p.attenuationColor:[1,1,1],v=f(o.KHR_materials_dispersion?.dispersion,0,0,10);s=s.replace("vec3 diffuseIBL=kD*base.rgb*(uAmbientColor+envDiffuse*0.5)*occ;",`vec3 diffuseIBL=kD*base.rgb*(uAmbientColor+envDiffuse*0.5)*occ;
35
- vec2 sUV=gl_FragCoord.xy/max(uViewportSize,vec2(1.));float iorB=${f(b,1.5,1,10)},dV=${v},tV=${x},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
31
+ }`),{vs:r,fs:n}},onBeforeDrawPrimitive(e,t,r,i,n,s){let m=je.get(e),c=e.getUniformLocation(t,"uHasSH");if(m&&m.length>=27){c&&e.uniform1i(c,1);let o=e.getUniformLocation(t,"uSH");o&&e.uniform3fv(o,m)}else c&&e.uniform1i(c,0)},onAttributeChanged(e,t,r,i){t==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,i):t==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,i)}},Ke=new WeakMap;function qe(e,t){let r=t||e.viewer;if(!r||typeof r.projectPointToScreen!="function")return;let i=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let n=0;n<i.length;n++){let s=i[n],m=s.getAttribute("data-position");if(!m)continue;let c=m.trim().split(/\s+/).map(u=>parseFloat(u.replace(/m$/,"")));if(c.length<3||c.some(isNaN))continue;let o=s.getAttribute("data-normal"),d;if(o){let u=o.trim().split(/\s+/).map(l=>parseFloat(l));u.length>=3&&!u.some(isNaN)&&(d=[u[0],u[1],u[2]])}let a=r.projectPointToScreen([c[0],c[1],c[2]],d);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transform=`translate(-50%, -50%) translate3d(${a.x}px, ${a.y}px, 0)`,s.style.zIndex="3",a.visible?(s.style.opacity="1",s.style.pointerEvents="auto",s.removeAttribute("data-occluded")):(s.style.opacity="0",s.style.pointerEvents="none",s.setAttribute("data-occluded",""))}}var ct={name:"hotspots",updateHotspotsForElement:qe,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let t=new MutationObserver(()=>{qe(e)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),Ke.set(e,t)},onCameraChange(e,t){t&&qe(t,e)},onElementDisconnected(e){let t=Ke.get(e);t&&(t.disconnect(),Ke.delete(e))}};function me(e,t,r,i){let n=typeof e=="number"&&Number.isFinite(e)?e:i;return Math.max(t,Math.min(r,n))}function mr(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function We(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function dr(e,t=256){return typeof e=="string"&&e.length>0?e.slice(0,t):void 0}function pr(e){let t=We(e);if(!t)return null;let r=t.target;return{target:mr(r)?[r[0],r[1],r[2]]:typeof r=="string"&&r.length>0&&r.length<=256?r:[0,0,0],radius:me(t.radius,.01,50,.5),speed:me(t.speed,-20,20,.5),height:me(t.height,-10,10,0),phase:me(t.phase,-1e6,1e6,0),faceCenter:t.faceCenter===!0}}var gr=["hum","reactor","wind","beacon","geiger","chimeLoop","machinery","water"],br=["confirm","error","alarm","warning","pickup","jump","beam","impact","burst","powerup","step","pass","fail"],ui=new Set(gr),fi=new Set(br);function ht(e,t){let r=dr(e,16)?.trim();if(!r)return t;let i=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(r);return i?`#${i[1].toLowerCase()}`:t}function mt(e){if(!e||typeof e=="number"&&!(e>0&&Number.isFinite(e)))return null;let t=e===!0?{}:typeof e=="number"?{strength:e}:We(e);if(!t||t.enabled===!1)return null;let r=me(t.strength??t.intensity,0,5,.35);return r>0?{enabled:!0,strength:r,threshold:me(t.threshold,0,4,.8),radius:me(t.radius,0,2,.5)}:null}function Xe(e){if(!e)return null;let t=e===!0?{}:typeof e=="string"?{color:e}:We(e);if(!t||t.enabled===!1)return null;let r=t.thickness??t.width;return{enabled:!0,color:ht(t.color,"#38bdf8"),thickness:me(typeof r=="number"&&r>0&&r<.25?Math.max(1.5,r*140):r,.5,20,3),pulse:t.pulse===!0}}function yr(e,t,r,i){let n=t[0],s=t[1],m=t[2],c=t[3],o=r[0],d=r[1],a=r[2],u=r[3],l=n*o+s*d+m*a+c*u;if(l<0&&(o=-o,d=-d,a=-a,u=-u,l=-l),Math.abs(l)>=1)return e[0]=n,e[1]=s,e[2]=m,e[3]=c,e;let h=Math.acos(l),f=Math.sqrt(1-l*l);if(Math.abs(f)<.001)return e[0]=.5*(n+o),e[1]=.5*(s+d),e[2]=.5*(m+a),e[3]=.5*(c+u),e;let g=Math.sin((1-i)*h)/f,A=Math.sin(i*h)/f;return e[0]=n*g+o*A,e[1]=s*g+d*A,e[2]=m*g+a*A,e[3]=c*g+u*A,e}var dt=1024,Qe=256,Re=2048,vr=128,xr=64,Mr=16,wr=1e4,Ar=8,he=new Set(["__proto__","constructor","prototype"]),pt={neg:e=>-e,abs:Math.abs,sign:Math.sign,floor:Math.floor,ceil:Math.ceil,round:Math.round,trunc:Math.trunc,fract:e=>e-Math.floor(e),sqrt:e=>Math.sqrt(Math.max(0,e)),cbrt:Math.cbrt,exp:Math.exp,log:e=>e>0?Math.log(e):0,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:e=>Math.asin(Math.max(-1,Math.min(1,e))),acos:e=>Math.acos(Math.max(-1,Math.min(1,e))),atan:Math.atan,rad:e=>e*Math.PI/180,deg:e=>e*180/Math.PI,saturate:e=>Math.max(0,Math.min(1,e))},gt={add:(e,t)=>e+t,sub:(e,t)=>e-t,mul:(e,t)=>e*t,div:(e,t)=>Math.abs(t)<1e-12?0:e/t,rem:(e,t)=>Math.abs(t)<1e-12?0:e%t,mod:(e,t)=>Math.abs(t)<1e-12?0:e%t,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},Ce={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},De=(e,t)=>e!==null&&typeof e=="object"&&!he.has(t)&&Object.prototype.hasOwnProperty.call(e,t),te=e=>Array.isArray(e)?[...e]:e,bt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&De(e,"value")?e.value:e,W=(e,t)=>De(e.configuration,t)?bt(e.configuration[t]):void 0,V=(e,t=0)=>{let r=Number(e);return Number.isFinite(r)?r:t},ve=e=>Math.max(0,Math.min(1,e)),oe=e=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!Number.isNaN(e):typeof e=="string"?e.length>0&&e!=="false":!!e;function Fe(e){if(typeof e!="string"||!e.startsWith("/"))return null;let t=[];for(let r of e.slice(1).split("/")){let i=r.replace(/~1/g,"/").replace(/~0/g,"~");if(!i||he.has(i)||he.has(r))return null;t.push(i)}return{segments:t}}var xe=(e,t)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let r=Number(e);return Number.isSafeInteger(r)&&r>=0&&r<t?r:-1},yt=e=>{let t=V(e[0]),r=V(e[1]),i=V(e[2]),n=V(e[3],1),s=Math.hypot(t,r,i,n);return s>1e-8?[t/s,r/s,i/s,n/s]:[0,0,0,1]},vt=(e,t,r,i)=>{if(typeof e=="number"&&typeof t=="number")return e+(t-e)*r;if(Array.isArray(e)&&Array.isArray(t)){if(i&&e.length===4&&t.length===4){let n=[0,0,0,1];return yr(n,yt(e),yt(t),r),n}return e.slice(0,t.length).map((n,s)=>n+(t[s]-n)*r)}return r>=.5?t:e},Ze=(e,t,r)=>Array.isArray(e)&&Array.isArray(t)?e.slice(0,t.length).map((i,n)=>r(V(i),V(t[n]))):Array.isArray(e)?e.map(i=>r(V(i),V(t))):Array.isArray(t)?t.map(i=>r(V(e),V(i))):r(V(e),V(t)),Sr=(e,t)=>Array.isArray(e)?e.map(r=>t(V(r))):t(V(e)),xt=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((r,i)=>Math.abs(r-t[i])<=1e-6):e===t,Mt=class{constructor(e,t,r){let i=Array.isArray(r.nodes)?r.nodes:[];if(i.length>dt)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${dt})`);let n=Array.isArray(r.variables)?r.variables:[];if(n.length>Qe)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${Qe})`);let s=Array.isArray(r.declarations)?r.declarations:[],m=Array.isArray(r.events)?r.events:[],c=new Map,o=new Map,d=new Map,a=new Map,u=new Map,l=new Map,h=[],f=[],g=new Map,A=1,v=0,T=0,p=0,b=0,y=!1,L=!1,C=!1;n.forEach((N,x)=>{if(!N||typeof N!="object")return;let E=te(bt(N.value));c.set(x,E);let P=N.id??N.name;typeof P=="string"&&P&&!he.has(P)&&c.set(P,E)}),(t?.nodes||[]).forEach((N,x)=>{for(let E of N?.children||[])typeof E=="number"&&g.set(E,x)});let F=N=>N.op||typeof N.declaration=="number"&&s[N.declaration]?.op||"",_=(N,x,E)=>{if(he.has(x))return;let P=o.get(N);P||o.set(N,P=Object.create(null)),P[x]=E},O=(N,x)=>{if(typeof N!="number"&&typeof N!="string"||typeof N=="string"&&he.has(N)||!c.has(N)&&c.size>=Qe*2)return;let E=te(x);if(c.set(N,E),typeof N=="number"){let P=n[N]?.id??n[N]?.name;typeof P=="string"&&!he.has(P)&&c.set(P,E)}},D=N=>typeof N=="number"?m[N]?.id??String(N):typeof N=="string"?/^\d+$/.test(N)&&m[Number(N)]?.id?m[Number(N)].id:N:"",$=(N,x)=>{for(let E=N,P=0;E!==void 0&&E>=0&&P<128;E=g.get(E),P++)if(E===x)return!0;return!1},z=N=>{for(let x=h.length-1;x>=0;x--)h[x].key===N&&h.splice(x,1)},k=N=>{z(N.key),h.length>=vr&&h.shift(),h.push(N)},re=N=>{let x=Fe(N)?.segments;if(x){if(x[0]==="nodes"&&Array.isArray(t?.nodes)){let E=t.nodes[xe(x[1],t.nodes.length)];if(!E)return;let P=x[2];if(P in Ce){let S=Ce[P],M=E[P]||S;return S.map((w,I)=>V(M[I],w))}if(P==="weights"){let S=Array.isArray(E.weights)?E.weights:[0],M=x.length===4?xe(x[3],64):-2;return M===-2?S.map(w=>V(w)):M>=0?V(S[M]):void 0}if(P==="visible"||P==="extensions"&&x[3]==="KHR_node_visibility"&&x[4]==="visible")return E.extensions?.KHR_node_visibility?.visible??E.visible??!0}else if(x[0]==="materials"&&Array.isArray(t?.materials)){let E=t.materials[xe(x[1],t.materials.length)];if(!E)return;let P=E.pbrMetallicRoughness||{};if(x[2]==="pbrMetallicRoughness"){if(x[3]==="baseColorFactor"){let S=P.baseColorFactor||[1,1,1,1];return[V(S[0],1),V(S[1],1),V(S[2],1),V(S[3],1)]}if(x[3]==="metallicFactor"||x[3]==="roughnessFactor")return V(P[x[3]],1)}if(x[2]==="emissiveFactor"){let S=E.emissiveFactor||[0,0,0];return[V(S[0]),V(S[1]),V(S[2])]}if(x[2]==="alphaCutoff")return V(E.alphaCutoff,.5)}}},Z=(N,x)=>{let E=Fe(N)?.segments;if(!E)return!1;if(E[0]==="nodes"&&Array.isArray(t?.nodes)){let P=xe(E[1],t.nodes.length),S=t.nodes[P];if(!S)return!1;let M=E[2];if(M in Ce&&Array.isArray(x)){let w=Ce[M];if(x.length<w.length)return!1;let I=w.map((H,K)=>V(x[K],H));if(M==="rotation"){let H=Math.hypot(...I);I=H>1e-8?I.map(K=>K/H):[0,0,0,1]}S[M]=I,delete S.matrix;let B=e?.initialNodeTransforms?.[P];return B&&(B[M[0]]=[...I]),y=!0,!0}if(M==="weights"){Array.isArray(S.weights)||(S.weights=[]);let w=(I,B)=>{for(let H of e?.meshes||[])if(H.nodeIndex===P)for(let K of H.primitives||[])K.pluginData?.morph?.weights&&(K.pluginData.morph.weights[I]=B)};if(E.length===4){let I=xe(E[3],64);if(I<0)return!1;w(I,S.weights[I]=V(x))}else if(Array.isArray(x))S.weights=x.slice(0,64).map(I=>V(I)),S.weights.forEach((I,B)=>w(B,I));else return!1;return C=!0,!0}if(M==="visible"||M==="extensions"&&E[3]==="KHR_node_visibility"&&E[4]==="visible"){let w=oe(x);return S.visible=w,(!S.extensions||typeof S.extensions!="object")&&(S.extensions={}),S.extensions.KHR_node_visibility={visible:w},L=!0,!0}}else if(E[0]==="materials"&&Array.isArray(t?.materials)){let P=xe(E[1],t.materials.length),S=t.materials[P];if(!S)return!1;let M=S.pbrMetallicRoughness||(S.pbrMetallicRoughness={}),w=I=>{for(let B of e?.meshes||[])for(let H of B.primitives||[])(H.materialIndex??0)===P&&I(H)};if(E[2]==="pbrMetallicRoughness"){if(E[3]==="baseColorFactor"&&Array.isArray(x)&&x.length>=3){let I=[ve(V(x[0],1)),ve(V(x[1],1)),ve(V(x[2],1)),x[3]!==void 0?ve(V(x[3],1)):M.baseColorFactor?.[3]??1];return M.baseColorFactor=I,w(B=>B.baseColor=[...I]),C=!0}if(E[3]==="metallicFactor"||E[3]==="roughnessFactor"){let I=E[3]==="metallicFactor",B=ve(V(x,I?0:.5));return M[E[3]]=B,w(H=>H[I?"metallic":"roughness"]=B),C=!0}}if(E[2]==="emissiveFactor"&&Array.isArray(x)&&x.length>=3)return S.emissiveFactor=[0,1,2].map(I=>Math.max(0,V(x[I]))),C=!0;if(E[2]==="alphaCutoff")return S.alphaCutoff=ve(V(x,.5)),C=!0}return!1},X=(N,x,E=new Set)=>{let P=W(x,"pointer");if(typeof P!="string"||!P.startsWith("/"))return null;let S=P.replace(/\{([a-zA-Z0-9_]+)\}/g,(M,w)=>{let I=Math.trunc(Number(ie(N,w,void 0,E)??W(x,w)));return Number.isSafeInteger(I)&&I>=0?String(I):"-1"});return Fe(S)?S:null},ie=(N,x,E,P)=>{let S=i[N]?.values;if(!De(S,x))return E;let M=S[x];if(M==null)return E;if(typeof M!="object"||Array.isArray(M))return te(M);let w=M;return typeof w.node=="number"?He(w.node,w.socket||"value",P):De(w,"value")?te(w.value):E},He=(N,x,E)=>{if(N<0||N>=i.length||E.has(N)||E.size>128||++p>wr)return;let P=i[N],S=F(P);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(S))return te(o.get(N)?.[x]);E.add(N);try{let M=(w,I=0)=>ie(N,w,I,E);if(S==="variable/get"){let w=W(P,"variable")??W(P,"id");return typeof w=="number"||typeof w=="string"?te(c.get(w)):void 0}if(S==="pointer/get"){let w=X(N,P,E);return w?re(w):void 0}if(S.startsWith("math/")){let w=S.slice(5);if(w in pt)return Sr(M("a"),pt[w]);if(w in gt){let I=/^(mul|div|rem|mod|pow)$/.test(w)?1:0;return Ze(M("a",w==="mul"?1:0),M("b",I),gt[w])}if(w==="pi")return Math.PI;if(w==="e")return Math.E;if(w==="random")return Math.random();if(w==="clamp")return Ze(Ze(M("a"),M("b",M("min",0)),Math.max),M("c",M("max",1)),Math.min);if(w==="mix"||w==="quatSlerp")return vt(M("a",0),M("b",1),V(M("c",M("t",.5)),.5),w==="quatSlerp");if(w==="dot"){let I=M("a"),B=M("b");return Array.isArray(I)&&Array.isArray(B)?I.reduce((H,K,R)=>H+(K||0)*(B[R]||0),0):V(I)*V(B)}if(w==="cross"){let I=M("a",[0,0,0]),B=M("b",[0,0,0]);return Array.isArray(I)&&Array.isArray(B)?[(I[1]||0)*(B[2]||0)-(I[2]||0)*(B[1]||0),(I[2]||0)*(B[0]||0)-(I[0]||0)*(B[2]||0),(I[0]||0)*(B[1]||0)-(I[1]||0)*(B[0]||0)]:[0,0,0]}if(w==="length"){let I=M("a");return Array.isArray(I)?Math.hypot(...I):Math.abs(V(I))}if(w==="distance"){let I=M("a"),B=M("b");return Array.isArray(I)&&Array.isArray(B)?Math.hypot(...I.map((H,K)=>(H||0)-(B[K]||0))):Math.abs(V(I)-V(B))}if(w==="normalize"){let I=M("a");if(!Array.isArray(I))return V(I)>=0?1:-1;let B=Math.hypot(...I);return B>1e-8?I.map(H=>H/B):I.map(()=>0)}if(w.startsWith("combine"))return["a","b","c","d"].slice(0,Number(w[7])||2).map(I=>V(M(I)));if(w.startsWith("extract")){let I=M("a");return Array.isArray(I)?I[x==="0"||x==="x"?0:x==="1"||x==="y"?1:x==="2"||x==="z"?2:3]??0:0}if(w==="eq")return xt(M("a"),M("b"));if(w==="ne")return!xt(M("a"),M("b"));if(w==="lt")return V(M("a"))<V(M("b"));if(w==="le")return V(M("a"))<=V(M("b"));if(w==="gt")return V(M("a"))>V(M("b"));if(w==="ge")return V(M("a"))>=V(M("b"));if(w==="isNaN")return Number.isNaN(Number(M("a")));if(w==="isInf"){let I=Number(M("a"));return!Number.isFinite(I)&&!Number.isNaN(I)}return w==="and"?oe(M("a",!1))&&oe(M("b",!1)):w==="or"?oe(M("a",!1))||oe(M("b",!1)):w==="xor"?oe(M("a",!1))!==oe(M("b",!1)):w==="not"?!oe(M("a",!1)):w==="select"?te(oe(M("condition",!1))?M("a"):M("b")):void 0}return S==="type/boolToInt"||S==="type/boolToFloat"?oe(M("a",!1))?1:0:S==="type/intToBool"||S==="type/floatToBool"?V(M("a",0))!==0:S==="type/intToFloat"?V(M("a",0)):S==="type/floatToInt"?Math.trunc(V(M("a",0))):void 0}finally{E.delete(N)}},we=()=>{if(y){y=!1,C=!0;let N=ot(t);if(e){e.worldMatrices=N;for(let x of e.meshes||[])x.nodeIndex>=0&&x.nodeIndex<N.length&&(x.transform.set(N[x.nodeIndex]),Ve(x.normalMatrix,x.transform))}}if(L){L=!1,C=!0;let N=t?.nodes;if(Array.isArray(e?.meshes)&&Array.isArray(N))for(let x of e.meshes){let E=!0;for(let P=x.nodeIndex,S=0;P!==void 0&&P>=0&&S<128;P=g.get(P),S++){let M=N[P];if(M?.visible===!1||M?.extensions?.KHR_node_visibility?.visible===!1){E=!1;break}}x.visible=E}}C&&(C=!1,e?.render?.())},ne=(N,x={steps:0})=>{if(!N||typeof N.node!="number")return;x.steps===0&&(p=0);let E=[N],P=S=>{E.length+x.steps<Re&&E.push(S)};for(;E.length>0&&x.steps<Re;){x.steps++;let S=E.shift();if(!S||S.node<0||S.node>=i.length)continue;let M=S.node,w=i[M];if(!w)continue;let I=S.socket||"in",B=F(w),H=(R,U=void 0)=>ie(M,R,U,new Set),K=(R="out")=>{let U=w.flows?.[R];U&&P(U)};switch(B){case"flow/branch":K(oe(H("condition",!1))?"true":"false");break;case"flow/sequence":for(let R of Object.keys(w.flows||{}).sort((U,Q)=>Number(U)-Number(Q)||U.localeCompare(Q)))K(R);break;case"flow/switch":{let R=w.flows?.[String(H("selection",H("value",0)))]??w.flows?.default;R&&P(R);break}case"flow/for":{let R=Math.trunc(V(H("startIndex",0))),U=Math.trunc(V(H("endIndex",0))),Q=Math.max(1,Math.trunc(V(H("step",1),1))),Y=w.flows?.body;if(Y&&U>R&&b<Ar){let G=Math.min(Math.ceil((U-R)/Q),Re);b++;try{for(let ee=0;ee<G&&x.steps<Re;ee++)_(M,"index",R+ee*Q),ne(Y,x)}finally{b--}}let de=w.flows?.completed??w.flows?.out;de&&P(de);break}case"flow/doN":{let R=I==="reset"?0:(d.get(M)||0)+1;if(d.set(M,R),_(M,"currentCount",R),_(M,"count",R),I!=="reset"){let U=Math.trunc(V(H("n",W(w,"stopIterations")??W(w,"n")??1),1));R<=U&&K()}break}case"flow/multiGate":{if(I==="reset"){l.set(M,0);break}let R=Object.keys(w.flows||{}).sort();if(!R.length)break;let U=W(w,"isRandom")?Math.floor(Math.random()*R.length):l.get(M)||0;U<R.length&&(K(R[U]),l.set(M,W(w,"isLoop")!==!1?(U+1)%R.length:U+1));break}case"flow/waitAll":{if(I==="reset"){a.delete(M);break}let R=a.get(M);R||a.set(M,R=new Set),R.add(I),R.size>=Math.max(1,Math.trunc(Number(W(w,"inputFlows")??2)||2))&&(R.clear(),K("out"),K("completed"));break}case"flow/throttle":{if(I==="reset"){u.delete(M);break}let R=Math.max(0,V(H("duration",0))),U=u.get(M);U===void 0||v-U>=R?(u.set(M,v),_(M,"lastRemainingTime",0),K()):_(M,"lastRemainingTime",Math.max(0,R-(v-U)));break}case"flow/delay":case"flow/setDelay":{if(I==="cancel"){for(let Y=f.length-1;Y>=0;Y--)f[Y].nodeIdx===M&&f.splice(Y,1);_(M,"lastDelayIndex",-1);break}let R=Math.max(0,V(H("duration",W(w,"duration")??0))),U=w.flows?.done??w.flows?.out;if(R<=0){_(M,"lastDelayIndex",-1),U&&P(U);break}f.length>=xr&&f.shift();let Q=A++;_(M,"lastDelayIndex",Q),f.push({id:Q,nodeIdx:M,rem:R,done:U}),B==="flow/setDelay"&&w.flows?.out&&w.flows?.done&&K("out");break}case"flow/cancelDelay":{let R=Math.trunc(V(H("delayIndex",-1),-1));if(R<0)f.length=0;else for(let U=f.length-1;U>=0;U--)f[U].id===R&&f.splice(U,1);K();break}case"variable/set":O(W(w,"variable")??W(w,"id"),H("value")),K();break;case"variable/interpolate":{let R=W(w,"variable")??W(w,"id"),U=H("value",H("target")),Q=Math.max(0,V(H("duration",W(w,"duration")??.3),.3));R!==void 0&&U!==void 0&&k({key:`var:${String(R)}`,varKey:R,from:te(H("from")??c.get(R)??0),to:te(U),dur:Q,elapsed:0,quat:!1,linear:W(w,"easing")==="linear",done:w.flows?.done}),K();break}case"pointer/set":{let R=X(M,w),U=H("value");R&&U!==void 0&&(z(`ptr:${R}`),Z(R,U)),K();break}case"pointer/interpolate":{let R=X(M,w),U=H("value",H("target")),Q=Math.max(0,V(H("duration",W(w,"duration")??.3),.3));if(R&&U!==void 0){let Y=H("from")??re(R);Y!==void 0&&(Q<=0?(Z(R,U),K("done")):k({key:`ptr:${R}`,ptr:R,from:te(Y),to:te(U),dur:Q,elapsed:0,quat:R.endsWith("/rotation"),linear:W(w,"easing")==="linear",done:w.flows?.done}))}K();break}case"animation/start":{let R=H("animation")??W(w,"animation")??W(w,"clipName"),U=typeof R=="number"?e?.animations?.[R]?.name??t?.animations?.[R]?.name:typeof R=="string"?R:void 0;e?.playAnimation?.(U),C=!0,K();break}case"animation/stop":case"animation/resetAt":e?.pauseAnimation?.(),B==="animation/resetAt"&&e?.evaluateAnimation?.(V(H("time",0))),C=!0,K();break;case"event/send":case"customEvent/send":{let R=D(W(w,"event")??W(w,"id")),U={};for(let Q of Object.keys(w.values||{}))he.has(Q)||(U[Q]=H(Q));R&&(typeof CustomEvent<"u"&&typeof e?.container?.dispatchEvent=="function"&&e.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:R,values:U}})),ce(R,U,x)),K();break}default:K();break}}};this.readScenePointer=re,this.writeScenePointer=Z,this.fireOnStart=()=>{i.forEach(N=>{F(N)==="event/onStart"&&ne(N.flows?.out)}),we()},this.fireOnSelect=N=>{if(!N)return;let x=typeof N.meshIndex=="number"?N.meshIndex:-1,E=typeof N.nodeIndex=="number"?N.nodeIndex:e?.meshes?.[x]?.nodeIndex??-1;i.forEach((P,S)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(F(P)))return;let M=W(P,"nodeIndex")??W(P,"node")??ie(S,"nodeIndex",void 0,new Set),w=W(P,"meshName");if(typeof w=="string"&&w?N.meshName===w:M==null||Number(M)<0||Number.isNaN(Number(M))||$(E,Math.trunc(Number(M)))){if(_(S,"nodeIndex",E),_(S,"meshIndex",x),Array.isArray(N.hitPoint)){let I=[V(N.hitPoint[0]),V(N.hitPoint[1]),V(N.hitPoint[2])];_(S,"hitPoint",I),_(S,"point",I),_(S,"intersectionPoint",I)}if(Array.isArray(N.normal)){let I=[V(N.normal[0]),V(N.normal[1],1),V(N.normal[2])];_(S,"normal",I),_(S,"hitNormal",I)}typeof N.distance=="number"&&_(S,"distance",N.distance),ne(P.flows?.out)}}),we()},this.receiveCustomEvent=(N,x={})=>ce(N,x,{steps:0});function ce(N,x,E){if(!(T>=Mr)){T++;try{let P=D(N);i.forEach((S,M)=>{if(!/^(customE|e)vent\/receive$/.test(F(S)))return;let w=W(S,"event")??W(S,"id");if(!(D(w)!==P&&String(w)!==String(N))){for(let[I,B]of Object.entries(x))he.has(I)||_(M,I,te(B));ne(S.flows?.out,E)}}),we()}finally{T--}}}this.tick=N=>{if(!Number.isFinite(N)||N<0)return;let x=Math.min(N,.25);v+=x,i.forEach((P,S)=>{F(P)==="event/onTick"&&(_(S,"timeDelta",x),_(S,"dt",x),_(S,"timeElapsed",v),ne(P.flows?.out))});let E=[];for(let P=h.length-1;P>=0;P--){let S=h[P];S.elapsed+=x;let M=S.dur>1e-6?ve(S.elapsed/S.dur):1,w=S.linear?M:M*M*(3-2*M),I=vt(S.from,S.to,w,S.quat);S.ptr?Z(S.ptr,I):S.varKey!==void 0&&O(S.varKey,I),M>=1&&(h.splice(P,1),S.done&&E.push(S.done))}for(let P=f.length-1;P>=0;P--){let S=f[P];S.rem-=x,S.rem<=0&&(f.splice(P,1),S.done&&E.push(S.done))}for(let P of E)ne(P);we()},this.dispose=()=>{h.length=0,f.length=0,c.clear(),o.clear(),d.clear(),a.clear(),u.clear(),l.clear()}}},ue=new WeakMap,Oe=new WeakMap;function Tr(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||sr().some(c=>c.name==="xr-live-head-follow")||(typeof e.getAutoRotate=="function"?e.getAutoRotate():e.autoRotate)===!1)return;let r=e.gltf,i=r?.nodes;if(!Array.isArray(i)||i.length===0)return;let n=Math.min(t,.1),s=(Oe.get(e)||0)+n,m=!1;for(let c=0;c<i.length;c++){let o=i[c],d=pr(o?.extras?.xr?.orbit);if(!d)continue;let a=0,u=0,l=0;if(Array.isArray(d.target))a=d.target[0],u=d.target[1],l=d.target[2];else if(typeof d.target=="string"&&d.target!=="head"){let v=i.find(T=>T?.name===d.target);Array.isArray(v?.translation)&&(a=V(v.translation[0]),u=V(v.translation[1]),l=V(v.translation[2]))}let h=d.phase+d.speed*s,f=a+Math.cos(h)*d.radius,g=u+d.height,A=l+Math.sin(h)*d.radius;if(o.translation=[f,g,A],d.faceCenter){let v=Math.atan2(a-f,l-A);o.rotation=[0,Math.sin(v*.5),0,Math.cos(v*.5)]}m=!0}if(m){Oe.set(e,s);let c=ot(r);e.worldMatrices=c;for(let o of e.meshes||[])o.nodeIndex>=0&&o.nodeIndex<c.length&&(o.transform.set(c[o.nodeIndex]),Ve(o.normalMatrix,o.transform))}}function Ye(e){if(!(!e||typeof e!="object"))return ue.get(e)||ue.get(e.viewer)||ue.get(e._view)}function wt(e,t,r){let i=Ye(e);return i?(i.receiveCustomEvent(t,r),!0):!1}var At={name:"khr-interactivity",sendInteractivityEvent:wt,getInteractivityVM:Ye,onLoadModel(e,t){if(!e||typeof e!="object")return;ue.get(e)?.dispose(),ue.delete(e),Oe.delete(e);let r=t?.extensions?.KHR_interactivity,i=Array.isArray(r?.graphs)?r.graphs[r.graph??0]:r;if(!i||!Array.isArray(i.nodes))return;let n=new Mt(e,t,i);ue.set(e,n),n.fireOnStart()},onMeshSelect(e,t){ue.get(e)?.fireOnSelect(t)},onUpdate(e,t){ue.get(e)?.tick(t),Tr(e,t)},onDestroy(e,t){ue.get(t)?.dispose(),ue.delete(t),Oe.delete(t)}};function Ue(e,t){let r=(a,u,l,h)=>{let f=typeof a=="number"?a:Number(a);return Number.isFinite(f)?Math.max(u,Math.min(l,f)):h};function i(a,u,l=0,h=.05,f){if(!a||!a.length)return-1;let g=a[0]>0?[0,...a]:a,A=Number.isFinite(u)?Math.max(0,u):0,v=Number.isFinite(h)?Math.max(0,Math.min(.5,h)):.05;if(typeof f=="number"&&Number.isFinite(f)&&f>0){let b=l===-1?f*(1-v):f*(1+v);if(A>b)return-1}let T=0;for(let b=g.length-1;b>=1;b--)if(A>=g[b]){T=b;break}if(l<0||l>=g.length||l===T)return T;if(T>l){let b=l;for(let y=l+1;y<=T&&A>=g[y]*(1+v);y++)b=y;return b}let p=l;for(let b=l;b>T&&A<g[b]*(1-v);b--)p=b-1;return p}function n(a){if(!a)return null;let u=a===!0?{distances:[4,10],ratios:[.5,.25]}:Array.isArray(a)?{distances:a}:typeof a=="object"?a:null;if(!u||u.enabled===!1)return null;let l=r(u.hysteresis,0,.5,.05),h=[],f;if(Array.isArray(u.levels)&&u.levels.length>0){let T=u.levels.slice(0,8);for(let b=0;b<T.length;b++){let y=T[b];if(!y||typeof y!="object"||Array.isArray(y))continue;let L=y,C=r(L.distance,0,1e4,b===0?0:b*4),F=typeof L.hysteresis=="number"?r(L.hysteresis,0,.5,l):void 0,_=typeof L.ratio=="number"?r(L.ratio,.05,1,.5):void 0,O=typeof L.childIndex=="number"&&Number.isFinite(L.childIndex)?Math.max(0,Math.round(L.childIndex)):void 0,D=typeof L.node=="string"&&/^[A-Za-z0-9_.:-]+$/.test(L.node.trim())?L.node.trim().slice(0,64):void 0;h.push({distance:C,...F!==void 0?{hysteresis:F}:{},..._!==void 0?{ratio:_}:{},...O!==void 0?{childIndex:O}:{},...D?{node:D}:{}})}h.sort((b,y)=>b.distance-y.distance),h.length>0&&h[0].distance>0&&h.unshift({distance:0,childIndex:0});let p=0;h=h.slice(0,8).map((b,y)=>{let L=y===0?0:Math.max(p,b.distance);return p=L,{...b,distance:L,childIndex:b.childIndex??y}})}if(Array.isArray(u.ratios)&&u.ratios.length>0){let T=[];for(let p of u.ratios.slice(0,7))typeof p=="number"&&T.push(r(p,.05,1,.5));T.length>0&&(f=T)}if(h.length===0){let T=Array.isArray(u.distances)?u.distances:[],p=[];for(let y of T.slice(0,8))typeof y=="number"&&p.push(r(y,0,1e4,4));if(p.length===0&&f&&f.length>0)for(let y=0;y<f.length;y++)p.push((y+1)*4);if(p.length===0&&u.cullDistance===void 0)return null;p.length===0||p[0]>0?p.unshift(0):f&&f.length===p.length&&f[0]===1&&(f=f.slice(1));let b=0;for(let y=0;y<Math.min(8,p.length);y++){let L=y===0?0:Math.max(b,p[y]);b=L;let C=y>0&&f?f[y-1]:void 0;h.push({distance:L,childIndex:y,...C!==void 0?{ratio:C}:{}})}}else if(!f){let T=[];for(let p=1;p<h.length;p++)typeof h[p].ratio=="number"&&T.push(h[p].ratio);T.length>0&&(f=T)}let g=h.map(T=>T.distance),A=g[g.length-1]??0,v=u.cullDistance!==void 0&&u.cullDistance!==null&&u.cullDistance!==!1?r(u.cullDistance,Math.max(1,A),1e4,100):void 0;return{levels:h,distances:g,...f?{ratios:f}:{},hysteresis:l,...v!==void 0?{cullDistance:v}:{}}}function s(a,u){let l=a?.attributes?.position;if(!l||!l.array||l.count<3)return a;let h=r(u,.05,1,.5),f=l.array,g=l.count,A=a.attributes?.normal?.array,v=a.attributes?.uv?.array,T=a.index?.array,p=Math.floor((T?T.length:g)/3);if(p<1)return a;let b=Math.max(1,Math.min(p,Math.round(p*h))),y=1/0,L=1/0,C=1/0,F=-1/0,_=-1/0,O=-1/0;for(let x=0;x<g;x++){let E=f[x*3],P=f[x*3+1],S=f[x*3+2];E<y&&(y=E),P<L&&(L=P),S<C&&(C=S),E>F&&(F=E),P>_&&(_=P),S>O&&(O=S)}let D=Math.max(1e-5,F-y),$=Math.max(1e-5,_-L),z=Math.max(1e-5,O-C),k=Math.max(D,$,z),re=x=>{let E=Math.max(1,Math.round(D/k*x)),P=Math.max(1,Math.round($/k*x)),S=Math.max(1,Math.round(z/k*x)),M=new Map,w=new Int32Array(g),I=[],B=[],H=[],K=[];for(let G=0;G<g;G++){let ee=f[G*3],pe=f[G*3+1],ge=f[G*3+2],le=Math.min(E-1,Math.max(0,Math.floor((ee-y)/D*E))),ae=Math.min(P-1,Math.max(0,Math.floor((pe-L)/$*P))),be=Math.min(S-1,Math.max(0,Math.floor((ge-C)/z*S))),Pe=le+ae*E+be*E*P,J=M.get(Pe);J===void 0?(J=K.length,M.set(Pe,J),I.push(ee,pe,ge),A&&B.push(A[G*3],A[G*3+1],A[G*3+2]),v&&H.push(v[G*2],v[G*2+1]),K.push(1)):(I[J*3]+=ee,I[J*3+1]+=pe,I[J*3+2]+=ge,A&&(B[J*3]+=A[G*3],B[J*3+1]+=A[G*3+1],B[J*3+2]+=A[G*3+2]),K[J]++),w[G]=J}let R=[],U=new Set;for(let G=0;G<p;G++){let ee=T?T[G*3]:G*3,pe=T?T[G*3+1]:G*3+1,ge=T?T[G*3+2]:G*3+2,le=w[ee],ae=w[pe],be=w[ge];if(le===ae||ae===be||be===le)continue;let Pe=Math.min(le,ae,be),J=Math.max(le,ae,be),li=le+ae+be-Pe-J,er=`${Pe}_${li}_${J}`;U.has(er)||(U.add(er),R.push(le,ae,be))}let Q=K.length,Y=new Float32Array(Q*3),de=A?new Float32Array(Q*3):null;for(let G=0;G<Q;G++){let ee=1/K[G];if(Y[G*3]=I[G*3]*ee,Y[G*3+1]=I[G*3+1]*ee,Y[G*3+2]=I[G*3+2]*ee,de){let pe=B[G*3],ge=B[G*3+1],le=B[G*3+2],ae=Math.hypot(pe,ge,le)||1;de[G*3]=pe/ae,de[G*3+1]=ge/ae,de[G*3+2]=le/ae}}return{pos:Y,norm:de,uv:v?new Float32Array(H):null,tris:R,triCount:R.length/3,vertCount:Q}},Z=Math.max(2,Math.round(Math.sqrt(b/4))),X=re(Z);if(X.triCount>b*1.25&&Z>2){let x=Math.max(2,Math.round(Z*Math.sqrt(b/X.triCount)));if(x!==Z){let E=re(x);E.triCount>=Math.min(4,b)&&(X=E)}}else if(X.triCount<Math.min(4,b)){let x=re(Math.max(Z*2,8));x.triCount>X.triCount&&(X=x)}let ie=X.tris;if(h<1&&X.triCount>b){let x=[],E=X.triCount/b;for(let P=0;P<b;P++){let S=Math.min(X.triCount-1,Math.floor(P*E));x.push(X.tris[S*3],X.tris[S*3+1],X.tris[S*3+2])}ie=x}if(ie.length<3){ie=[];for(let x=0;x<b*3;x++)ie.push(T?T[x]:x);X={pos:f.slice(),norm:A?A.slice():null,uv:v?v.slice():null,tris:ie,triCount:b,vertCount:g}}let He=e??t?.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0),we=He?.BufferGeometry??a.constructor,ne=He?.BufferAttribute??l.constructor,ce=new we;ce.setAttribute("position",new ne(X.pos,3)),X.norm&&ce.setAttribute("normal",new ne(X.norm,3)),X.uv&&ce.setAttribute("uv",new ne(X.uv,2));let N=X.vertCount>65535?new Uint32Array(ie):new Uint16Array(ie);return typeof ce.setIndex=="function"?ce.setIndex(new ne(N,1)):ce.index=new ne(N,1),ce}let m=e?.Object3D??t?.threeNamespace?.Object3D??class{constructor(){this.name="",this.position={x:0,y:0,z:0},this.rotation={x:0,y:0,z:0},this.quaternion={x:0,y:0,z:0,w:1},this.scale={x:1,y:1,z:1},this.visible=!0,this.parent=null,this.children=[],this.userData={}}add(...a){for(let u of a)u&&(u.parent=this,this.children.push(u));return this}};class c extends m{constructor(){super(),this.isLOD=!0,this.type="LOD",this.autoUpdate=!0,this.levels=[],this._currentLevel=0}addLevel(u,l=0,h=.05){if(!u)return this;let f=Math.max(0,Number.isFinite(Number(l))?Number(l):0),g=r(h,0,.5,.05),A=this.levels.length;for(let p=0;p<this.levels.length;p++)if(f<this.levels[p].distance){A=p;break}this.levels.splice(A,0,{object:u,distance:f,hysteresis:g}),this.add(u);let v=this.levels.map(p=>p.object),T=this.children.filter(p=>!v.includes(p));this.children=[...v,...T];for(let p=0;p<this.levels.length;p++)this.levels[p].object.visible=p===this._currentLevel;return this.syncUserDataTrait(),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(u){if(!this.levels.length)return null;let l=i(this.levels.map(h=>h.distance),u,this._currentLevel,this.levels[0]?.hysteresis??.05,this.userData?.xr?.lod?.cullDistance);return l>=0&&l<this.levels.length?this.levels[l].object:null}update(u){if(this.levels.length===0||!u)return;let l=u.position??{x:0,y:0,z:0},h=this.position??{x:0,y:0,z:0},f=Math.hypot((Number(l.x)||0)-(Number(h.x)||0),(Number(l.y)||0)-(Number(h.y)||0),(Number(l.z)||0)-(Number(h.z)||0)),g=i(this.levels.map(A=>A.distance),f,this._currentLevel,this.levels[0]?.hysteresis??.05,this.userData?.xr?.lod?.cullDistance);this._currentLevel=g;for(let A=0;A<this.levels.length;A++)this.levels[A].object.visible=A===g}syncUserDataTrait(){this.userData=this.userData||{},this.userData.xr=this.userData.xr||{};let u=this.userData.xr.lod?.cullDistance;this.userData.xr.lod={levels:this.levels.map((l,h)=>({distance:l.distance,hysteresis:l.hysteresis,childIndex:h,...l.object?.name?{node:l.object.name}:{}})),distances:this.levels.map(l=>l.distance),hysteresis:this.levels[0]?.hysteresis??.05,...u!==void 0?{cullDistance:u}:{}}}}function o(a){if(!a||a._lodMaterialized||!a.userData?.xr?.lod||a.isLOD||Array.isArray(a.children)&&a.children.length>0)return;let u=a.geometry?.attributes?.position;if(!u||!u.array||u.count<3)return;let l=n(a.userData.xr.lod);if(!l||l.levels.length<2)return;a._lodMaterialized=!0;let h=a.geometry;a._lodOriginalGeometry=h;let f=e??t?.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0),g=f?.Mesh??a.constructor,A=f?.BufferGeometry??h.constructor,v=typeof a.name=="string"&&a.name.trim()?a.name.trim():"Mesh",T=new g(h,a.material);T.name=`${v}_LOD0`,T.visible=!0,T.castShadow=!!a.castShadow,T.receiveShadow=!!a.receiveShadow,a.add(T);for(let p=1;p<l.levels.length;p++){let b=l.levels[p].ratio??l.ratios?.[p-1]??Math.max(.05,Math.pow(.5,p)),y=s(h,b),L=new g(y,a.material);L.name=`${v}_LOD${p}`,L.visible=!1,L.castShadow=!!a.castShadow,L.receiveShadow=!!a.receiveShadow,a.add(L)}a.geometry=new A,a.userData.xr.lod={...l,levels:l.levels.map((p,b)=>({...p,childIndex:b,node:`${v}_LOD${b}`}))}}let d={LOD:c,decimateGeometry:s,selectLodLevelIndex:i,parseLod:n,materializeLodGeometry:o};return t&&typeof t=="object"&&(t.authorNamespace||(t.authorNamespace={}),Object.assign(t.authorNamespace,{LOD:c,decimateGeometry:s}),t._lodMaterialize=o,t.materializeDeclarativeGeometry=a=>{t._cadMaterialize?.(a),t._lodMaterialize?.(a)}),d}var Te=Ue(),Nr=Te.decimateGeometry,Je=Te.selectLodLevelIndex,et=Te.parseLod,ci=Te.materializeLodGeometry,Ir=Te.LOD,Ne=new WeakMap;function Lr(e){return e&&typeof e=="object"?Ne.get(e):void 0}var St=class{constructor(e,t){this.groups=[],this.viewer=e,this.gltf=t,this.rebuild()}rebuild(){this.groups.length=0;let e=this.gltf?.nodes;if(!Array.isArray(e)||e.length===0)return;let t=new Map;for(let i of this.viewer?.meshes??[])if(typeof i?.nodeIndex=="number"&&i.nodeIndex>=0){let n=t.get(i.nodeIndex);n||(n=[],t.set(i.nodeIndex,n)),n.push(i)}let r=i=>{let n=[],s=new Set,m=[i];for(;m.length>0;){let c=m.pop();if(s.has(c)||c<0||c>=e.length)continue;s.add(c);let o=t.get(c);o&&n.push(...o);let d=e[c]?.children;if(Array.isArray(d))for(let a=d.length-1;a>=0;a--)typeof d[a]=="number"&&m.push(d[a])}return n};for(let i=0;i<e.length;i++){let n=e[i];if(!n||typeof n!="object")continue;let s=n.extras?.xr?.lod??n.extensions?.ANDROID_xr_scenecore?.lod??n.extensions?.MOZ_hubs_components?.lod,m=Array.isArray(n.extensions?.MSFT_lod?.ids)?n.extensions.MSFT_lod.ids.filter(h=>typeof h=="number"&&Number.isInteger(h)&&h>=0&&h<e.length):[],c=et(s);if(!c&&m.length>0&&(c=et({distances:m.map((h,f)=>f*4)})),!c)continue;let o=m.length>0?m:Array.isArray(n.children)?n.children.filter(h=>typeof h=="number"&&Number.isInteger(h)&&h>=0&&h<e.length):[],d=[],a=[];if(o.length>0){let h=Math.min(o.length,c.levels.length);for(let f=0;f<h;f++){let g=o[f];d.push(g),a.push(r(g))}}else{let h=t.get(i)??[];if(h.length===0)continue;d.push(i),a.push(h)}let u=c.distances.slice(0,a.length);u.length===0&&u.push(0);let l={nodeIndex:i,name:typeof n.name=="string"?n.name:`LOD_${i}`,distances:u,hysteresis:c.hysteresis,...c.cullDistance!==void 0?{cullDistance:c.cullDistance}:{},childNodeIndices:d,levelMeshes:a,activeLevelIndex:0,lastDistance:0};this.applyGroupVisibility(l,0),this.groups.push(l)}}getGroups(){return this.groups}getActiveLevel(e){let t=this.findGroup(e);return t?t.activeLevelIndex:null}forceLodLevel(e,t){let r=this.findGroup(e);if(!r)return;if(t==null){r.forcedLevelIndex=null;let n=Je(r.distances,r.lastDistance,r.activeLevelIndex,r.hysteresis,r.cullDistance);r.activeLevelIndex=n,this.applyGroupVisibility(r,n);return}let i=t<0?-1:Math.min(Math.max(0,Math.trunc(t)),r.levelMeshes.length-1);r.forcedLevelIndex=i,r.activeLevelIndex=i,this.applyGroupVisibility(r,i)}findGroup(e){return typeof e=="number"?this.groups.find(t=>t.nodeIndex===e)??this.groups[e]:this.groups.find(t=>t.name===e)}update(e){if(this.groups.length===0)return;let t=this.viewer?.worldMatrices,r=this.viewer?.modelRootMatrix;for(let i of this.groups){let n=Array.isArray(t)&&i.nodeIndex<t.length?t[i.nodeIndex]:null,s=n&&n[12]||0,m=n&&n[13]||0,c=n&&n[14]||0,o=r?r[0]*s+r[4]*m+r[8]*c+r[12]:s,d=r?r[1]*s+r[5]*m+r[9]*c+r[13]:m,a=r?r[2]*s+r[6]*m+r[10]*c+r[14]:c,u=Math.hypot((e[0]||0)-o,(e[1]||0)-d,(e[2]||0)-a);if(i.lastDistance=u,i.forcedLevelIndex!==void 0&&i.forcedLevelIndex!==null){i.activeLevelIndex!==i.forcedLevelIndex&&(i.activeLevelIndex=i.forcedLevelIndex,this.applyGroupVisibility(i,i.forcedLevelIndex));continue}let l=Je(i.distances,u,i.activeLevelIndex,i.hysteresis,i.cullDistance);l!==i.activeLevelIndex&&(i.activeLevelIndex=l,this.applyGroupVisibility(i,l))}}applyGroupVisibility(e,t){let r=this.gltf?.nodes;for(let i=0;i<e.levelMeshes.length;i++){let n=i===t;for(let c of e.levelMeshes[i])c.visible=n;let s=e.childNodeIndices[i],m=Array.isArray(r)?r[s]:null;m&&typeof m=="object"&&(m.visible=n,m.extensions=m.extensions||{},m.extensions.KHR_node_visibility={visible:n})}}},Tt={name:"lod",onRegister(){lr(Ue);let e=ye(),t=e.threeNamespace??(typeof globalThis<"u"?globalThis.THREE:void 0);Ue(t,e)},onLoadModel(e,t){!e||typeof e!="object"||Ne.set(e,new St(e,t))},onUpdate(e){let t=Ne.get(e);if(!t||typeof e?.getCameraOrbit!="function")return;let r=e.getCameraOrbit(),i=typeof e.getCameraTarget=="function"?e.getCameraTarget():{x:0,y:0,z:0},n=r?.radius??3,s=r?.phi??0,m=r?.theta??0,c=Math.cos(s),o=(i.x||0)+n*c*Math.sin(m),d=(i.y||0)+n*Math.sin(s),a=(i.z||0)+n*c*Math.cos(m);t.update([o,d,a])},onBeforeDrawScene(e,t,r,i){let n=Ne.get(e);n&&n.update(i)},onDestroy(e,t){t&&typeof t=="object"&&Ne.delete(t)}},Ie=new Map,ke=new WeakMap;function Er(e,t){Ie.set(e,t)}var Nt={name:"materials",onContextRestored(e){ke.delete(e)},onBuildPrimitiveVAO(e,t,r,i,n){return(((i?.materials&&r.material!==void 0?i.materials[r.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,t){let r=ke.get(e);r||(r=e.createTexture(),ke.set(e,r));let i=Math.max(1,t.canvas.width),n=Math.max(1,t.canvas.height);e.activeTexture(33990),e.bindTexture(3553,r),e.copyTexImage2D(3553,0,6408,0,0,i,n,0),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553)},onResolveShader(e,t,r,i){if(!t)return null;if(t.name&&Ie.has(t.name)){let f=Ie.get(t.name);return{vs:f.vs||r,fs:f.fs||i}}let n=t.extensions||{},s=n.KHR_materials_clearcoat,m=n.KHR_materials_sheen,c=!!n.KHR_materials_transmission,o=!!n.KHR_materials_ior,d=n.KHR_materials_iridescence;if(!s&&!m&&!n.KHR_materials_unlit&&!c&&!n.KHR_materials_volume&&!o&&!n.KHR_materials_dispersion&&!d)return null;if(n.KHR_materials_unlit)return{vs:r,fs:i.replace("fragColor=vec4(color,outAlpha);","fragColor=vec4(base.rgb,outAlpha);").replace("fragColor=vec4(color,base.a);","fragColor=vec4(base.rgb,base.a);")};let a=i;if(c){let f=a.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
32
+ `;a=a.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
33
+ ${f}out vec4 fragColor;`)}let u=(f,g,A=0,v=1e6,T=3)=>{let p=Number(f);return(Number.isFinite(p)?Math.min(v,Math.max(A,p)):g).toFixed(T)},l=Number(n.KHR_materials_ior?.ior??1.5),h=Number.isFinite(l)?Math.min(10,Math.max(1,l)):1.5;if(o){let f=Math.pow((h-1)/(h+1),2);a=a.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${u(f,.04,0,1,4)}),base.rgb,metallic);`)}if(d){let f=u(d.iridescenceFactor,1,0,1),g=u(d.iridescenceIor,1.3,1,10);a=a.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${g}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${f}*pow(1.-NoV,2.));`)}if(c){let f=u(n.KHR_materials_transmission?.transmissionFactor,1,0,1),g=n.KHR_materials_volume||{},A=u(g.thicknessFactor,.5,0,1e4),v=u(g.attenuationDistance,1,.001,1e6),T=Array.isArray(g.attenuationColor)?g.attenuationColor:[1,1,1],p=u(n.KHR_materials_dispersion?.dispersion,0,0,10);a=a.replace("vec3 diffuseIBL=kD*base.rgb*(uAmbientColor+envDiffuse*0.5)*occ;",`vec3 diffuseIBL=kD*base.rgb*(uAmbientColor+envDiffuse*0.5)*occ;
34
+ vec2 sUV=gl_FragCoord.xy/max(uViewportSize,vec2(1.));float iorB=${u(h,1.5,1,10)},dV=${p},tV=${A},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
36
35
  vec3 refractedR=refract(-V,N,1./(iorB-.02*dV)),rG=refract(-V,N,1./iorB),refractedB=refract(-V,N,1./(iorB+.02*dV));
37
36
  vec3 tr=vec3(textureLod(uTransmissionTex,clamp(sUV+refractedR.xy*sc,.001,.999),lod).r,textureLod(uTransmissionTex,clamp(sUV+rG.xy*sc,.001,.999),lod).g,textureLod(uTransmissionTex,clamp(sUV+refractedB.xy*sc,.001,.999),lod).b);
38
- vec3 aCol=vec3(${f(I[0],1,0,1)},${f(I[1],1,0,1)},${f(I[2],1,0,1)});
39
- vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${E},.001));
40
- diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${m});`)}if(a&&!r.includes("uClearcoat")){let m=f(a.clearcoatFactor,1,0,1),p=f(a.clearcoatRoughnessFactor,0,0,1);s=s.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${p},NoV)*${m};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${p})*ccF;fragColor=vec4(color,base.a);`)}if(d){let m=Array.isArray(d.sheenColorFactor)?d.sheenColorFactor:[1,1,1],p=`color+=vec3(${f(m[0],1,0,1)},${f(m[1],1,0,1)},${f(m[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;s.includes("color=applyToneMapping(color,uToneMapping);")?s=s.replace("color=applyToneMapping(color,uToneMapping);",`${p}color=applyToneMapping(color,uToneMapping);`):s=s.replace("fragColor=vec4(color,base.a);",`${p}fragColor=vec4(color,base.a);`)}return{vs:n,fs:s}},onBeforeDrawPrimitive(e,t,n,r,o,a){let d=n.materialIndex;if(d!==void 0&&a?.materials){let c=a.materials[d];c?.name&&he.has(c.name)&&he.get(c.name).onBindUniforms?.(e,t,n)}if(n.isTransmissive){let c=Le.get(e);if(c){e.activeTexture(33990),e.bindTexture(3553,c);let i=e.getUniformLocation(t,"uTransmissionTex");i&&e.uniform1i(i,6);let l=e.getUniformLocation(t,"uViewportSize");l&&e.uniform2f(l,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var Rt=64*1024*1024,_t=128*1024*1024,bn=16777216;function hn(e){return(e>>>1^-(e&1))&255}function yn(e){return(e>>>1^-(e&1))&65535}function gn(e){let t=e<<24>>24;return(t<<1^t>>7)&255}function It(e){return(e<<1^e>>31)>>>0}function kt(e){if(e!==void 0&&e!=="NONE"&&e!=="OCTAHEDRAL"&&e!=="QUATERNION"&&e!=="EXPONENTIAL"&&e!=="COLOR")throw X(`unknown filter "${String(e)}"`)}var H=Math.fround;function me(e){return Math.trunc(H(e+(e>=0?.5:-.5)))}function Ze(e,t,n,r="NONE"){if(kt(r),!r||r==="NONE"||t<=0)return;let o=new DataView(e.buffer,e.byteOffset,e.byteLength);if(r==="OCTAHEDRAL"){if(n!==4&&n!==8)throw X(`OCTAHEDRAL filter requires byteStride 4 or 8 (got ${n})`);let f=n===8,u=f?32767:127,b=x=>f?o.getInt16(x,!0):o.getInt8(x),m=(x,E)=>f?o.setInt16(x,E,!0):o.setInt8(x,E<<24>>24),p=f?2:1;for(let x=0;x<t;x++){let E=x*n,I=b(E),v=b(E+p),S=H(b(E+2*p)-Math.abs(I)-Math.abs(v)),w=S>=0?0:S;I=H(I+(I>=0?w:-w)),v=H(v+(v>=0?w:-w));let U=H(Math.sqrt(H(H(H(I*I)+H(v*v))+H(S*S))));if(U===0){m(E,0),m(E+p,0),m(E+2*p,u);continue}let V=H(u/U);m(E,me(H(I*V))),m(E+p,me(H(v*V))),m(E+2*p,me(H(S*V)))}return}if(r==="QUATERNION"){if(n!==8)throw X(`QUATERNION filter requires byteStride 8 (got ${n})`);let f=H(32767/H(Math.SQRT2));for(let u=0;u<t;u++){let b=u*8,m=o.getInt16(b+6,!0),p=m|3,x=o.getInt16(b,!0),E=o.getInt16(b+2,!0),I=o.getInt16(b+4,!0),v=H(p*p),S=H(H(H(H(v*2)-H(x*x))-H(E*E))-H(I*I)),w=H(Math.sqrt(S>=0?S:0)),U=H(f/p),V=m&3,O=[0,0,0,0];O[V+1&3]=me(H(x*U)),O[V+2&3]=me(H(E*U)),O[V+3&3]=me(H(I*U)),O[V]=Math.trunc(H(H(w*U)+.5));for(let N=0;N<4;N++)o.setInt16(b+N*2,O[N]<<16>>16,!0)}return}if(r==="EXPONENTIAL"){if(n<4||n%4!==0)throw X(`EXPONENTIAL filter requires byteStride multiple of 4 (got ${n})`);let f=t*n>>>2;for(let u=0;u<f;u++){let b=u*4,m=o.getUint32(b,!0),p=m<<8>>8,x=m>>24;o.setUint32(b,x+127<<23>>>0,!0);let E=o.getFloat32(b,!0);o.setFloat32(b,H(E*p),!0)}return}if(n!==4&&n!==8)throw new Error(`KHR_meshopt_compression: COLOR filter requires byteStride 4 or 8 (got ${n})`);let a=n===8,d=a?65535:255,c=f=>a?o.getUint16(f,!0):o.getUint8(f),i=f=>a?o.getInt16(f,!0):o.getInt8(f),l=(f,u)=>a?o.setUint16(f,u&65535,!0):o.setUint8(f,u&255),s=a?2:1;for(let f=0;f<t;f++){let u=f*n,b=c(u+3*s);b|=b>>1,b|=b>>2,b|=b>>4,b|=b>>8;let m=c(u),p=i(u+s),x=i(u+2*s),E=m+p-x,I=m+x,v=m-p-x,S=c(u+3*s);S=S<<1&b|S&1;let w=b===0?0:H(d/b);l(u,Math.trunc(H(H(E*w)+.5))),l(u+s,Math.trunc(H(H(I*w)+.5))),l(u+2*s,Math.trunc(H(H(v*w)+.5))),l(u+3*s,Math.trunc(H(H(S*w)+.5)))}}var Pt=160,ee=16,xn=24,Nt=32,Tn=24,An=[0,2,4,8],vn=[0,1,2,4,8];function Ct(e){let t=Math.floor(8192/e)&~(ee-1);return t<256?t:256}function X(e){return new Error(`EXT_meshopt_compression: ${e}`)}function wn(e,t,n,r,o){if(o===0)return n.fill(0,r,r+ee),t;if(o===8)return n.set(e.subarray(t,t+ee),r),t+ee;let a=(1<<o)-1,d=8/o,c=t+ee*o/8;for(let i=0;i<ee;i++){let l=e[t+Math.floor(i/d)],s=i%d,f=o===1?l>>s&1:l>>8-o-s*o&a;n[r+i]=f===a?e[c++]:f}return c}function Lt(e,t,n,r,o,a,d,c){let i=a/ee,l=i+3>>2;if(n-t<l)throw X("truncated ATTRIBUTES stream");let s=t;t+=l;for(let f=0;f<i;f++){if(n-t<xn)throw X("truncated ATTRIBUTES stream");let u=e[s+(f>>2)]>>(f&3)*2&3;t=wn(e,t,r,o+f*ee,d[c+u])}return t}function En(e,t,n,r){if(n%4!==0||n>256)throw X(`ATTRIBUTES byteStride must be a multiple of 4 and <= 256 (got ${n})`);let o=e.byteLength;if(o<1)throw X("truncated ATTRIBUTES stream");let a=e[0];if((a&240)!==Pt)throw X(`unsupported ATTRIBUTES header 0x${a.toString(16)}`);let d=a&15;if(d>1)throw X(`unsupported ATTRIBUTES codec version ${d}`);let c=n+(d===0?0:n/4),i=d===0?Nt:Tn,l=c<i?i:c;if(o-1<l)throw X("truncated ATTRIBUTES stream");let s=o-c,f=e.slice(s,s+n),u=s+n,b=Ct(n),m=new Uint8Array(256*4),p=1;for(let x=0;x<t;){let E=Math.min(b,t-x),I=E+ee-1&~(ee-1),v=d===0?0:n/4;if(o-p<v)throw X("truncated ATTRIBUTES stream");let S=p;p+=v;for(let w=0;w<n;w+=4){let U=d===0?0:e[S+w/4];for(let N=0;N<4;N++){let P=U>>N*2&3;if(P===3){if(o-p<E)throw X("truncated ATTRIBUTES stream");m.set(e.subarray(p,p+E),N*E),p+=E}else P===2?m.fill(0,N*E,N*E+E):p=d===0?Lt(e,p,o,m,N*E,I,An,0):Lt(e,p,o,m,N*E,I,vn,P)}let V=d===0?0:e[u+w/4],O=V&3;if(O===0)for(let N=0;N<4;N++){let P=f[w+N];for(let C=0;C<E;C++)P=hn(m[N*E+C])+P&255,r[(x+C)*n+w+N]=P}else if(O===1)for(let N=0;N<4;N+=2){let P=f[w+N]|f[w+N+1]<<8,C=N*E;for(let z=0;z<E;z++){let W=m[C+z]|m[C+E+z]<<8;P=yn(W)+P&65535;let B=(x+z)*n+w+N;r[B]=P&255,r[B+1]=P>>8}}else if(O===2){let N=32-(V>>4)&31,P=(f[w]|f[w+1]<<8|f[w+2]<<16|f[w+3]<<24)>>>0;for(let C=0;C<E;C++){let z=(m[C]|m[E+C]<<8|m[2*E+C]<<16|m[3*E+C]<<24)>>>0;z=((z<<N|z>>>(32-N&31))^P)>>>0,P=z;let W=(x+C)*n+w;r[W]=z&255,r[W+1]=z>>>8&255,r[W+2]=z>>>16&255,r[W+3]=z>>>24}}else throw X(`invalid ATTRIBUTES channel ${V}`)}f.set(r.subarray((x+E-1)*n,(x+E)*n)),x+=E}if(o-p!==l)throw X("ATTRIBUTES trailing data")}var Ot=224,Vt=208;function Dt(e,t){let n=e[t.pos++]??0;if(n<128)return n;let r=n&127,o=7;for(let a=0;a<4;a++){let d=e[t.pos++]??0;if(r=(r|(d&127)<<o)>>>0,o+=7,d<128)break}return r>>>0}function Ue(e,t,n){let r=Dt(e,t),o=r>>>1^-(r&1);return n+o>>>0}function Sn(e,t,n){if(t%3!==0)throw X(`TRIANGLES count must be divisible by 3 (got ${t})`);let r=t/3;if(e.byteLength<1+r+16)throw X("truncated TRIANGLES stream");let o=e[0];if((o&240)!==Ot)throw X(`unsupported TRIANGLES header 0x${o.toString(16)}`);let a=o&15;if(a>1)throw X(`unsupported TRIANGLES codec version ${a}`);let d=new Uint32Array(16).fill(4294967295),c=new Uint32Array(16).fill(4294967295),i=new Uint32Array(16).fill(4294967295),l=0,s=0,f=(U,V)=>{d[l]=U,c[l]=V,l=l+1&15},u=(U,V=1)=>{i[s]=U,s=s+V&15},b=0,m=0,p=a>=1?13:15,x=1+r,E=e.byteLength-16,I=E,v={pos:x},S=0,w=(U,V,O)=>{n(S++,U),n(S++,V),n(S++,O)};for(let U=1;U<x;U++){let V=e[U];if(V<240){let O=V>>4,N=l-1-O&15,P=d[N],C=c[N],z=0,W=V&15;if(W<p){let B=i[s-1-W&15];z=W===0?b:B;let oe=W===0?1:0;b=b+oe>>>0,u(z,oe)}else{if(v.pos>E)throw X("truncated TRIANGLES stream");z=W!==15?m+(W*2-27)>>>0:Ue(e,v,m),m=z,u(z)}f(z,C),f(P,z),w(P,C,z)}else if(V<254){let O=e[I+(V&15)],N=O>>4,P=O&15,C=b;b=b+1>>>0;let z=i[s-N&15],W=N===0?b:z,B=N===0?1:0;b=b+B>>>0;let oe=i[s-P&15],re=P===0?b:oe,ie=P===0?1:0;b=b+ie>>>0,w(C,W,re),u(C),u(W,B),u(re,ie),f(W,C),f(re,W),f(C,re)}else{if(v.pos>E)throw X("truncated TRIANGLES stream");let O=e[v.pos++],N=V===254?0:15,P=O>>4,C=O&15;O===0&&(b=0);let z=0;N===0&&(z=b,b=b+1>>>0);let W;P===0?(W=b,b=b+1>>>0):W=i[s-P&15];let B;C===0?(B=b,b=b+1>>>0):B=i[s-C&15],N===15&&(m=z=Ue(e,v,m)),P===15&&(m=W=Ue(e,v,m)),C===15&&(m=B=Ue(e,v,m)),w(z,W,B),u(z),u(W,P===0||P===15?1:0),u(B,C===0||C===15?1:0),f(W,z),f(B,W),f(z,B)}}if(v.pos!==E)throw X("TRIANGLES trailing data")}function Mn(e,t,n){if(e.byteLength<1+t+4)throw X("truncated INDICES stream");let r=e[0];if((r&240)!==Vt)throw X(`unsupported INDICES header 0x${r.toString(16)}`);let o=r&15;if(o>1)throw X(`unsupported INDICES codec version ${o}`);let a=e.byteLength-4,d=[0,0],c={pos:1};for(let i=0;i<t;i++){if(c.pos>=a)throw X("truncated INDICES stream");let l=Dt(e,c),s=l&1;l>>>=1;let f=l>>>1^-(l&1),u=d[s]+f>>>0;d[s]=u,n(i,u)}if(c.pos!==a)throw X("INDICES trailing data")}function Je(e,t,n,r,o="NONE"){if(kt(o),!Number.isInteger(t)||t<0||t>bn||!Number.isInteger(n)||n<=0||n>256)throw X(`invalid count (${t}) or byteStride (${n})`);let a=t*n;if(a>Rt)throw X(`decompressed size (${a}) exceeds MAX_MESHOPT_BUFFER_BYTES (${Rt})`);if(t===0)return new Uint8Array(0);let d=new Uint8Array(a);if(r==="ATTRIBUTES")return En(e,t,n,d),Ze(d,t,n,o),d;if(r==="TRIANGLES"||r==="INDICES"){if(n!==2&&n!==4)throw X(`${r} byteStride must be 2 or 4 (got ${n})`);if(o&&o!=="NONE")throw X(`filter ${o} is only valid for ATTRIBUTES`);let c=new DataView(d.buffer),i=n===2?(l,s)=>c.setUint16(l*2,s&65535,!0):(l,s)=>c.setUint32(l*4,s>>>0,!0);return r==="TRIANGLES"?Sn(e,t,i):Mn(e,t,i),d}throw X(`unknown mode "${String(r)}"`)}function Ut(e,t){t>>>=0;do e.push(t&127|(t>127?128:0)),t>>>=7;while(t)}function Ft(e,t,n,r){let o=t*n;if(e.byteLength<o)throw new Error(`encodeMeshoptBuffer: raw buffer (${e.byteLength}) smaller than count * byteStride (${o})`);if(r==="ATTRIBUTES"){if(n%4!==0||n>256)throw new Error(`encodeMeshoptBuffer: ATTRIBUTES byteStride must be a multiple of 4 and <= 256 (got ${n})`);let c=[Pt],i=Ct(n),l=new Uint8Array(n);t>0&&l.set(e.subarray(0,n));let s=l.slice(),f=new Uint8Array(256);for(let u=0;u<t;){let b=Math.min(i,t-u),m=b+15&-16;for(let p=0;p<n;p++){f.fill(0);let x=l[p];for(let v=0;v<b;v++){let S=e[(u+v)*n+p];f[v]=gn(S-x&255),x=S}l[p]=x;let E=m/16,I=c.length;for(let v=0;v<E+3>>2;v++)c.push(0);for(let v=0;v<E;v++){let S=f.subarray(v*16,v*16+16);if(!S.every(w=>w===0)){c[I+(v>>2)]|=3<<(v&3)*2;for(let w of S)c.push(w)}}}u+=b}for(let u=n;u<Nt;u++)c.push(0);for(let u=0;u<n;u++)c.push(s[u]);return new Uint8Array(c)}if(n!==2&&n!==4)throw new Error(`encodeMeshoptBuffer: ${r} byteStride must be 2 or 4 (got ${n})`);let a=new DataView(e.buffer,e.byteOffset,e.byteLength),d=c=>n===2?a.getUint16(c*2,!0):a.getUint32(c*4,!0);if(r==="INDICES"){let c=[Vt|1],i=0;for(let l=0;l<t;l++){let s=d(l),f=s-i|0;i=s,Ut(c,It(f)<<1>>>0)}return c.push(0,0,0,0),new Uint8Array(c)}if(r==="TRIANGLES"){if(t%3!==0)throw new Error(`encodeMeshoptBuffer: TRIANGLES count must be divisible by 3 (got ${t})`);let c=t/3,i=[Ot|1];for(let s=0;s<c;s++)i.push(255);let l=0;for(let s=0;s<c;s++){i.push(255);for(let f=0;f<3;f++){let u=d(s*3+f);Ut(i,It(u-l|0)),l=u}}for(let s=0;s<16;s++)i.push(0);return new Uint8Array(i)}throw new Error(`encodeMeshoptBuffer: unknown mode "${String(r)}"`)}function ke(e,t){let n=t&&typeof t=="object"?t:e,r=t&&typeof t=="object"?e:n?.gltf;if(!r||!Array.isArray(r.bufferViews))return;let o=new Uint8Array(n.bin),a=[],d=0;for(let f=0;f<r.bufferViews.length;f++){let u=r.bufferViews[f],b=u?.extensions?.KHR_meshopt_compression,m=b??u?.extensions?.EXT_meshopt_compression;if(!m||typeof m!="object")continue;let p=b?"KHR_meshopt_compression":"EXT_meshopt_compression",x=Number(m.count),E=Number(m.byteStride),I=Number(m.byteOffset??0),v=Number(m.byteLength??0),S=m.mode||"ATTRIBUTES",w=m.filter||"NONE";if(w==="COLOR"&&!b)throw X(`bufferView ${f} uses the COLOR filter, which requires KHR_meshopt_compression`);if(Number(m.buffer??0)!==0)throw new Error(`${p}: bufferView ${f} references buffer ${String(m.buffer)}; only the GLB BIN chunk (buffer 0) is supported`);if(!Number.isInteger(I)||I<0||!Number.isInteger(v)||v<0||I+v>o.byteLength)throw new Error(`${p}: bufferView ${f} compressed range [${I}, ${I+v}] out of bounds (${o.byteLength})`);let U=x*E;if(d+=U,d>_t)throw X(`total decompressed size (${d}) exceeds MAX_MESHOPT_TOTAL_BYTES (${_t})`);let V=o.subarray(I,I+v),O=Je(V,x,E,S,w);a.push({index:f,bytes:O,ext:m})}if(a.length===0)return;let c=o.byteLength+3&-4,i=0;for(let f of a)i+=f.bytes.byteLength+3&-4;let l=new Uint8Array(c+i);l.set(o,0);let s=c;for(let f of a){l.set(f.bytes,s);let u=r.bufferViews[f.index];u.buffer=0,u.byteOffset=s,u.byteLength=f.bytes.byteLength,u._decoded=f.bytes,f.ext.mode==="ATTRIBUTES"&&u.byteStride===void 0&&(u.byteStride=Number(f.ext.byteStride)),u.extensions&&(delete u.extensions.EXT_meshopt_compression,delete u.extensions.KHR_meshopt_compression),s+=f.bytes.byteLength+3&-4}n.bin=l.buffer}var Pe={decodeBufferViews(e,t){ke(t)},decodePrimitive(e,t,n){let r=t?.extensions;r?.EXT_meshopt_compression&&delete r.EXT_meshopt_compression,r?.KHR_meshopt_compression&&delete r.KHR_meshopt_compression}};ce().decoders.set("meshopt",Pe);var et={name:"meshopt",onParseGLB(e){ce().decoders.set("meshopt",Pe),ke(e)}};function tt(e,t){let n=e?.trim(),r=n?Number(n):NaN;return Number.isFinite(r)?r:t}var In=`#version 300 es
37
+ vec3 aCol=vec3(${u(T[0],1,0,1)},${u(T[1],1,0,1)},${u(T[2],1,0,1)});
38
+ vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${v},.001));
39
+ diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${f});`)}if(s&&!i.includes("uClearcoat")){let f=u(s.clearcoatFactor,1,0,1),g=u(s.clearcoatRoughnessFactor,0,0,1);a=a.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${g},NoV)*${f};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${g})*ccF;fragColor=vec4(color,base.a);`)}if(m){let f=Array.isArray(m.sheenColorFactor)?m.sheenColorFactor:[1,1,1],g=`color+=vec3(${u(f[0],1,0,1)},${u(f[1],1,0,1)},${u(f[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;a.includes("color=applyToneMapping(color,uToneMapping);")?a=a.replace("color=applyToneMapping(color,uToneMapping);",`${g}color=applyToneMapping(color,uToneMapping);`):a=a.replace("fragColor=vec4(color,base.a);",`${g}fragColor=vec4(color,base.a);`)}return{vs:r,fs:a}},onBeforeDrawPrimitive(e,t,r,i,n,s){let m=r.materialIndex;if(m!==void 0&&s?.materials){let c=s.materials[m];c?.name&&Ie.has(c.name)&&Ie.get(c.name).onBindUniforms?.(e,t,r)}if(r.isTransmissive){let c=ke.get(e);if(c){e.activeTexture(33990),e.bindTexture(3553,c);let o=e.getUniformLocation(t,"uTransmissionTex");o&&e.uniform1i(o,6);let d=e.getUniformLocation(t,"uViewportSize");d&&e.uniform2f(d,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}},It=64*1024*1024,Lt=128*1024*1024,Pr=16777216;function _r(e){return(e>>>1^-(e&1))&255}function Vr(e){return(e>>>1^-(e&1))&65535}function Rr(e){let t=e<<24>>24;return(t<<1^t>>7)&255}function Et(e){return(e<<1^e>>31)>>>0}function Pt(e){if(e!==void 0&&e!=="NONE"&&e!=="OCTAHEDRAL"&&e!=="QUATERNION"&&e!=="EXPONENTIAL"&&e!=="COLOR")throw q(`unknown filter "${String(e)}"`)}var j=Math.fround;function Me(e){return Math.trunc(j(e+(e>=0?.5:-.5)))}function _t(e,t,r,i="NONE"){if(Pt(i),!i||i==="NONE"||t<=0)return;let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(i==="OCTAHEDRAL"){if(r!==4&&r!==8)throw q(`OCTAHEDRAL filter requires byteStride 4 or 8 (got ${r})`);let u=r===8,l=u?32767:127,h=A=>u?n.getInt16(A,!0):n.getInt8(A),f=(A,v)=>u?n.setInt16(A,v,!0):n.setInt8(A,v<<24>>24),g=u?2:1;for(let A=0;A<t;A++){let v=A*r,T=h(v),p=h(v+g),b=j(h(v+2*g)-Math.abs(T)-Math.abs(p)),y=b>=0?0:b;T=j(T+(T>=0?y:-y)),p=j(p+(p>=0?y:-y));let L=j(Math.sqrt(j(j(j(T*T)+j(p*p))+j(b*b))));if(L===0){f(v,0),f(v+g,0),f(v+2*g,l);continue}let C=j(l/L);f(v,Me(j(T*C))),f(v+g,Me(j(p*C))),f(v+2*g,Me(j(b*C)))}return}if(i==="QUATERNION"){if(r!==8)throw q(`QUATERNION filter requires byteStride 8 (got ${r})`);let u=j(32767/j(Math.SQRT2));for(let l=0;l<t;l++){let h=l*8,f=n.getInt16(h+6,!0),g=f|3,A=n.getInt16(h,!0),v=n.getInt16(h+2,!0),T=n.getInt16(h+4,!0),p=j(g*g),b=j(j(j(j(p*2)-j(A*A))-j(v*v))-j(T*T)),y=j(Math.sqrt(b>=0?b:0)),L=j(u/g),C=f&3,F=[0,0,0,0];F[C+1&3]=Me(j(A*L)),F[C+2&3]=Me(j(v*L)),F[C+3&3]=Me(j(T*L)),F[C]=Math.trunc(j(j(y*L)+.5));for(let _=0;_<4;_++)n.setInt16(h+_*2,F[_]<<16>>16,!0)}return}if(i==="EXPONENTIAL"){if(r<4||r%4!==0)throw q(`EXPONENTIAL filter requires byteStride multiple of 4 (got ${r})`);let u=t*r>>>2;for(let l=0;l<u;l++){let h=l*4,f=n.getUint32(h,!0),g=f<<8>>8,A=f>>24;n.setUint32(h,A+127<<23>>>0,!0);let v=n.getFloat32(h,!0);n.setFloat32(h,j(v*g),!0)}return}if(r!==4&&r!==8)throw new Error(`KHR_meshopt_compression: COLOR filter requires byteStride 4 or 8 (got ${r})`);let s=r===8,m=s?65535:255,c=u=>s?n.getUint16(u,!0):n.getUint8(u),o=u=>s?n.getInt16(u,!0):n.getInt8(u),d=(u,l)=>s?n.setUint16(u,l&65535,!0):n.setUint8(u,l&255),a=s?2:1;for(let u=0;u<t;u++){let l=u*r,h=c(l+3*a);h|=h>>1,h|=h>>2,h|=h>>4,h|=h>>8;let f=c(l),g=o(l+a),A=o(l+2*a),v=f+g-A,T=f+A,p=f-g-A,b=c(l+3*a);b=b<<1&h|b&1;let y=h===0?0:j(m/h);d(l,Math.trunc(j(j(v*y)+.5))),d(l+a,Math.trunc(j(j(T*y)+.5))),d(l+2*a,Math.trunc(j(j(p*y)+.5))),d(l+3*a,Math.trunc(j(j(b*y)+.5)))}}var Vt=160,fe=16,Cr=24,Rt=32,Dr=24,Fr=[0,2,4,8],Or=[0,1,2,4,8];function Ct(e){let t=Math.floor(8192/e)&~(fe-1);return t<256?t:256}function q(e){return new Error(`EXT_meshopt_compression: ${e}`)}function Ur(e,t,r,i,n){if(n===0)return r.fill(0,i,i+fe),t;if(n===8)return r.set(e.subarray(t,t+fe),i),t+fe;let s=(1<<n)-1,m=8/n,c=t+fe*n/8;for(let o=0;o<fe;o++){let d=e[t+Math.floor(o/m)],a=o%m,u=n===1?d>>a&1:d>>8-n-a*n&s;r[i+o]=u===s?e[c++]:u}return c}function Dt(e,t,r,i,n,s,m,c){let o=s/fe,d=o+3>>2;if(r-t<d)throw q("truncated ATTRIBUTES stream");let a=t;t+=d;for(let u=0;u<o;u++){if(r-t<Cr)throw q("truncated ATTRIBUTES stream");let l=e[a+(u>>2)]>>(u&3)*2&3;t=Ur(e,t,i,n+u*fe,m[c+l])}return t}function kr(e,t,r,i){if(r%4!==0||r>256)throw q(`ATTRIBUTES byteStride must be a multiple of 4 and <= 256 (got ${r})`);let n=e.byteLength;if(n<1)throw q("truncated ATTRIBUTES stream");let s=e[0];if((s&240)!==Vt)throw q(`unsupported ATTRIBUTES header 0x${s.toString(16)}`);let m=s&15;if(m>1)throw q(`unsupported ATTRIBUTES codec version ${m}`);let c=r+(m===0?0:r/4),o=m===0?Rt:Dr,d=c<o?o:c;if(n-1<d)throw q("truncated ATTRIBUTES stream");let a=n-c,u=e.slice(a,a+r),l=a+r,h=Ct(r),f=new Uint8Array(256*4),g=1;for(let A=0;A<t;){let v=Math.min(h,t-A),T=v+fe-1&~(fe-1),p=m===0?0:r/4;if(n-g<p)throw q("truncated ATTRIBUTES stream");let b=g;g+=p;for(let y=0;y<r;y+=4){let L=m===0?0:e[b+y/4];for(let _=0;_<4;_++){let O=L>>_*2&3;if(O===3){if(n-g<v)throw q("truncated ATTRIBUTES stream");f.set(e.subarray(g,g+v),_*v),g+=v}else O===2?f.fill(0,_*v,_*v+v):g=m===0?Dt(e,g,n,f,_*v,T,Fr,0):Dt(e,g,n,f,_*v,T,Or,O)}let C=m===0?0:e[l+y/4],F=C&3;if(F===0)for(let _=0;_<4;_++){let O=u[y+_];for(let D=0;D<v;D++)O=_r(f[_*v+D])+O&255,i[(A+D)*r+y+_]=O}else if(F===1)for(let _=0;_<4;_+=2){let O=u[y+_]|u[y+_+1]<<8,D=_*v;for(let $=0;$<v;$++){let z=f[D+$]|f[D+v+$]<<8;O=Vr(z)+O&65535;let k=(A+$)*r+y+_;i[k]=O&255,i[k+1]=O>>8}}else if(F===2){let _=32-(C>>4)&31,O=(u[y]|u[y+1]<<8|u[y+2]<<16|u[y+3]<<24)>>>0;for(let D=0;D<v;D++){let $=(f[D]|f[v+D]<<8|f[2*v+D]<<16|f[3*v+D]<<24)>>>0;$=(($<<_|$>>>(32-_&31))^O)>>>0,O=$;let z=(A+D)*r+y;i[z]=$&255,i[z+1]=$>>>8&255,i[z+2]=$>>>16&255,i[z+3]=$>>>24}}else throw q(`invalid ATTRIBUTES channel ${C}`)}u.set(i.subarray((A+v-1)*r,(A+v)*r)),A+=v}if(n-g!==d)throw q("ATTRIBUTES trailing data")}var Ft=224,Ot=208;function Ut(e,t){let r=e[t.pos++]??0;if(r<128)return r;let i=r&127,n=7;for(let s=0;s<4;s++){let m=e[t.pos++]??0;if(i=(i|(m&127)<<n)>>>0,n+=7,m<128)break}return i>>>0}function $e(e,t,r){let i=Ut(e,t),n=i>>>1^-(i&1);return r+n>>>0}function $r(e,t,r){if(t%3!==0)throw q(`TRIANGLES count must be divisible by 3 (got ${t})`);let i=t/3;if(e.byteLength<1+i+16)throw q("truncated TRIANGLES stream");let n=e[0];if((n&240)!==Ft)throw q(`unsupported TRIANGLES header 0x${n.toString(16)}`);let s=n&15;if(s>1)throw q(`unsupported TRIANGLES codec version ${s}`);let m=new Uint32Array(16).fill(4294967295),c=new Uint32Array(16).fill(4294967295),o=new Uint32Array(16).fill(4294967295),d=0,a=0,u=(L,C)=>{m[d]=L,c[d]=C,d=d+1&15},l=(L,C=1)=>{o[a]=L,a=a+C&15},h=0,f=0,g=s>=1?13:15,A=1+i,v=e.byteLength-16,T=v,p={pos:A},b=0,y=(L,C,F)=>{r(b++,L),r(b++,C),r(b++,F)};for(let L=1;L<A;L++){let C=e[L];if(C<240){let F=C>>4,_=d-1-F&15,O=m[_],D=c[_],$=0,z=C&15;if(z<g){let k=o[a-1-z&15];$=z===0?h:k;let re=z===0?1:0;h=h+re>>>0,l($,re)}else{if(p.pos>v)throw q("truncated TRIANGLES stream");$=z!==15?f+(z*2-27)>>>0:$e(e,p,f),f=$,l($)}u($,D),u(O,$),y(O,D,$)}else if(C<254){let F=e[T+(C&15)],_=F>>4,O=F&15,D=h;h=h+1>>>0;let $=o[a-_&15],z=_===0?h:$,k=_===0?1:0;h=h+k>>>0;let re=o[a-O&15],Z=O===0?h:re,X=O===0?1:0;h=h+X>>>0,y(D,z,Z),l(D),l(z,k),l(Z,X),u(z,D),u(Z,z),u(D,Z)}else{if(p.pos>v)throw q("truncated TRIANGLES stream");let F=e[p.pos++],_=C===254?0:15,O=F>>4,D=F&15;F===0&&(h=0);let $=0;_===0&&($=h,h=h+1>>>0);let z;O===0?(z=h,h=h+1>>>0):z=o[a-O&15];let k;D===0?(k=h,h=h+1>>>0):k=o[a-D&15],_===15&&(f=$=$e(e,p,f)),O===15&&(f=z=$e(e,p,f)),D===15&&(f=k=$e(e,p,f)),y($,z,k),l($),l(z,O===0||O===15?1:0),l(k,D===0||D===15?1:0),u(z,$),u(k,z),u($,k)}}if(p.pos!==v)throw q("TRIANGLES trailing data")}function Br(e,t,r){if(e.byteLength<1+t+4)throw q("truncated INDICES stream");let i=e[0];if((i&240)!==Ot)throw q(`unsupported INDICES header 0x${i.toString(16)}`);let n=i&15;if(n>1)throw q(`unsupported INDICES codec version ${n}`);let s=e.byteLength-4,m=[0,0],c={pos:1};for(let o=0;o<t;o++){if(c.pos>=s)throw q("truncated INDICES stream");let d=Ut(e,c),a=d&1;d>>>=1;let u=d>>>1^-(d&1),l=m[a]+u>>>0;m[a]=l,r(o,l)}if(c.pos!==s)throw q("INDICES trailing data")}function kt(e,t,r,i,n="NONE"){if(Pt(n),!Number.isInteger(t)||t<0||t>Pr||!Number.isInteger(r)||r<=0||r>256)throw q(`invalid count (${t}) or byteStride (${r})`);let s=t*r;if(s>It)throw q(`decompressed size (${s}) exceeds MAX_MESHOPT_BUFFER_BYTES (${It})`);if(t===0)return new Uint8Array(0);let m=new Uint8Array(s);if(i==="ATTRIBUTES")return kr(e,t,r,m),_t(m,t,r,n),m;if(i==="TRIANGLES"||i==="INDICES"){if(r!==2&&r!==4)throw q(`${i} byteStride must be 2 or 4 (got ${r})`);if(n&&n!=="NONE")throw q(`filter ${n} is only valid for ATTRIBUTES`);let c=new DataView(m.buffer),o=r===2?(d,a)=>c.setUint16(d*2,a&65535,!0):(d,a)=>c.setUint32(d*4,a>>>0,!0);return i==="TRIANGLES"?$r(e,t,o):Br(e,t,o),m}throw q(`unknown mode "${String(i)}"`)}function $t(e,t){t>>>=0;do e.push(t&127|(t>127?128:0)),t>>>=7;while(t)}function Hr(e,t,r,i){let n=t*r;if(e.byteLength<n)throw new Error(`encodeMeshoptBuffer: raw buffer (${e.byteLength}) smaller than count * byteStride (${n})`);if(i==="ATTRIBUTES"){if(r%4!==0||r>256)throw new Error(`encodeMeshoptBuffer: ATTRIBUTES byteStride must be a multiple of 4 and <= 256 (got ${r})`);let c=[Vt],o=Ct(r),d=new Uint8Array(r);t>0&&d.set(e.subarray(0,r));let a=d.slice(),u=new Uint8Array(256);for(let l=0;l<t;){let h=Math.min(o,t-l),f=h+15&-16;for(let g=0;g<r;g++){u.fill(0);let A=d[g];for(let p=0;p<h;p++){let b=e[(l+p)*r+g];u[p]=Rr(b-A&255),A=b}d[g]=A;let v=f/16,T=c.length;for(let p=0;p<v+3>>2;p++)c.push(0);for(let p=0;p<v;p++){let b=u.subarray(p*16,p*16+16);if(!b.every(y=>y===0)){c[T+(p>>2)]|=3<<(p&3)*2;for(let y of b)c.push(y)}}}l+=h}for(let l=r;l<Rt;l++)c.push(0);for(let l=0;l<r;l++)c.push(a[l]);return new Uint8Array(c)}if(r!==2&&r!==4)throw new Error(`encodeMeshoptBuffer: ${i} byteStride must be 2 or 4 (got ${r})`);let s=new DataView(e.buffer,e.byteOffset,e.byteLength),m=c=>r===2?s.getUint16(c*2,!0):s.getUint32(c*4,!0);if(i==="INDICES"){let c=[Ot|1],o=0;for(let d=0;d<t;d++){let a=m(d),u=a-o|0;o=a,$t(c,Et(u)<<1>>>0)}return c.push(0,0,0,0),new Uint8Array(c)}if(i==="TRIANGLES"){if(t%3!==0)throw new Error(`encodeMeshoptBuffer: TRIANGLES count must be divisible by 3 (got ${t})`);let c=t/3,o=[Ft|1];for(let a=0;a<c;a++)o.push(255);let d=0;for(let a=0;a<c;a++){o.push(255);for(let u=0;u<3;u++){let l=m(a*3+u);$t(o,Et(l-d|0)),d=l}}for(let a=0;a<16;a++)o.push(0);return new Uint8Array(o)}throw new Error(`encodeMeshoptBuffer: unknown mode "${String(i)}"`)}function tt(e,t){let r=t&&typeof t=="object"?t:e,i=t&&typeof t=="object"?e:r?.gltf;if(!i||!Array.isArray(i.bufferViews))return;let n=new Uint8Array(r.bin),s=[],m=0;for(let u=0;u<i.bufferViews.length;u++){let l=i.bufferViews[u],h=l?.extensions?.KHR_meshopt_compression,f=h??l?.extensions?.EXT_meshopt_compression;if(!f||typeof f!="object")continue;let g=h?"KHR_meshopt_compression":"EXT_meshopt_compression",A=Number(f.count),v=Number(f.byteStride),T=Number(f.byteOffset??0),p=Number(f.byteLength??0),b=f.mode||"ATTRIBUTES",y=f.filter||"NONE";if(y==="COLOR"&&!h)throw q(`bufferView ${u} uses the COLOR filter, which requires KHR_meshopt_compression`);if(Number(f.buffer??0)!==0)throw new Error(`${g}: bufferView ${u} references buffer ${String(f.buffer)}; only the GLB BIN chunk (buffer 0) is supported`);if(!Number.isInteger(T)||T<0||!Number.isInteger(p)||p<0||T+p>n.byteLength)throw new Error(`${g}: bufferView ${u} compressed range [${T}, ${T+p}] out of bounds (${n.byteLength})`);let L=A*v;if(m+=L,m>Lt)throw q(`total decompressed size (${m}) exceeds MAX_MESHOPT_TOTAL_BYTES (${Lt})`);let C=n.subarray(T,T+p),F=kt(C,A,v,b,y);s.push({index:u,bytes:F,ext:f})}if(s.length===0)return;let c=n.byteLength+3&-4,o=0;for(let u of s)o+=u.bytes.byteLength+3&-4;let d=new Uint8Array(c+o);d.set(n,0);let a=c;for(let u of s){d.set(u.bytes,a);let l=i.bufferViews[u.index];l.buffer=0,l.byteOffset=a,l.byteLength=u.bytes.byteLength,l._decoded=u.bytes,u.ext.mode==="ATTRIBUTES"&&l.byteStride===void 0&&(l.byteStride=Number(u.ext.byteStride)),l.extensions&&(delete l.extensions.EXT_meshopt_compression,delete l.extensions.KHR_meshopt_compression),a+=u.bytes.byteLength+3&-4}r.bin=d.buffer}var rt={decodeBufferViews(e,t){tt(t)},decodePrimitive(e,t,r){let i=t?.extensions;i?.EXT_meshopt_compression&&delete i.EXT_meshopt_compression,i?.KHR_meshopt_compression&&delete i.KHR_meshopt_compression}};ye().decoders.set("meshopt",rt);var Bt={name:"meshopt",onParseGLB(e){ye().decoders.set("meshopt",rt),tt(e)}};function it(e,t,r,i=!0){let n=[],s=null;try{for(let[m,c]of[[35633,t],[35632,r]]){let o=e.createShader(m);if(!o){if(i)throw new Error("Shader allocation failed");return null}if(n.push(o),e.shaderSource(o,c),e.compileShader(o),e.getShaderParameter&&!e.getShaderParameter(o,35713)){if(i)throw new Error(`Shader compile error: ${e.getShaderInfoLog(o)}`);return null}}if(s=e.createProgram(),!s){if(i)throw new Error("Program allocation failed");return null}for(let m of n)e.attachShader(s,m);if(e.linkProgram(s),e.getProgramParameter&&!e.getProgramParameter(s,35714)){let m=i?e.getProgramInfoLog(s):null;if(e.deleteProgram?.(s),s=null,i)throw new Error(`Program link error: ${m}`);return null}return s}finally{for(let m of n)s&&e.detachShader?.(s,m),e.deleteShader?.(m)}}function Ht(e,t){let r=e?.trim(),i=r?Number(r):NaN;return Number.isFinite(i)?i:t}var zr=`#version 300 es
41
40
  layout(location=0) in vec3 aPosition;
42
41
  layout(location=1) in vec3 aNormal;
43
42
  uniform mat4 uMVP,uVP;
@@ -58,7 +57,7 @@ vec2 pxOffset=dir*(uOutlineThickness*2.0/max(uViewportSize,vec2(1.0)))*clipPos.w
58
57
  clipPos.xy+=pxOffset;
59
58
  clipPos.z+=1e-4*clipPos.w;
60
59
  gl_Position=clipPos;
61
- }`,Ln=`#version 300 es
60
+ }`,jr=`#version 300 es
62
61
  precision highp float;
63
62
  uniform vec4 uOutlineColor;
64
63
  out vec4 fragColor;
@@ -70,7 +69,7 @@ void main(){
70
69
  vec2 pos=vec2((gl_VertexID<<1)&2,gl_VertexID&2);
71
70
  vUV=pos;
72
71
  gl_Position=vec4(pos*2.0-1.0,0.0,1.0);
73
- }`,Un=`#version 300 es
72
+ }`,Gr=`#version 300 es
74
73
  precision highp float;
75
74
  in vec2 vUV;
76
75
  uniform sampler2D uSourceTex;
@@ -93,7 +92,7 @@ c+=prefilter(texture(uSourceTex,vUV+vec2(h.x,-h.y)).rgb)*0.125;
93
92
  c+=prefilter(texture(uSourceTex,vUV+vec2(-h.x,h.y)).rgb)*0.125;
94
93
  c+=prefilter(texture(uSourceTex,vUV+vec2(h.x,h.y)).rgb)*0.125;
95
94
  fragColor=vec4(c,1.0);
96
- }`,kn=`#version 300 es
95
+ }`,Kr=`#version 300 es
97
96
  precision highp float;
98
97
  in vec2 vUV;
99
98
  uniform sampler2D uBloomTex;
@@ -115,6 +114,6 @@ sum+=texture(uBloomTex,vUV+vec2(-d.x,-d.y)).rgb*2.0;
115
114
  vec3 bloom=(sum/12.0)*uStrength;
116
115
  float a=clamp(min(bloom.r,min(bloom.g,bloom.b)),0.0,1.0);
117
116
  fragColor=vec4(bloom,a);
118
- }`,Ne=3,ye=new WeakMap;function rt(e,t=[.22,.74,.97]){let n=we(e,"");if(!n.startsWith("#"))return[t[0],t[1],t[2]];let r=n.slice(1);if(r.length===3){let o=+("0x"+r[0]+r[0])/255,a=+("0x"+r[1]+r[1])/255,d=+("0x"+r[2]+r[2])/255;return[o,a,d]}if(r.length===6){let o=+("0x"+r.slice(0,2))/255,a=+("0x"+r.slice(2,4))/255,d=+("0x"+r.slice(4,6))/255;return[o,a,d]}return[t[0],t[1],t[2]]}function Ht(e,t,n=.8,r=.5){let o=Number.isFinite(t)?Math.max(0,t):0;if(o<=0)return[0,0,0];let a=Math.max(0,Number(e[0])||0),d=Math.max(0,Number(e[1])||0),c=Math.max(0,Number(e[2])||0),i=Math.max(a,d,c);if(i<=1e-6)return[0,0,0];let l=Number.isFinite(n)?Math.max(0,n):.8,s=Math.max(l*Math.max(0,r),1e-4),f=Math.max(0,Math.min(2*s,i-l+s)),u=f*f/(4*s+1e-4),m=Math.min(1,Math.max(0,Math.max(u,i-l)/Math.max(i,1e-4)))*o;return[a*m,d*m,c*m]}function Wt(e,t,n,r){let o=Number(e[0])||0,a=Number(e[1])||0,d=Math.hypot(o,a);if(d<=1e-5||t<=0||n<=0)return[0,0];let c=Math.max(1,Number(r[0])||1),i=Math.max(1,Number(r[1])||1),l=Math.max(0,n)*2*t;return[o/d*(l/c),a/d*(l/i)]}function nt(e,t,n){let r=e.createProgram();if(!r)return null;let o=[];for(let[a,d]of[[35633,t],[35632,n]]){let c=e.createShader(a);c&&(e.shaderSource(c,d),e.compileShader(c),e.attachShader(r,c),o.push(c))}e.linkProgram(r);for(let a of o)e.detachShader?.(r,a),e.deleteShader?.(a);return o.length<2||typeof e.getProgramParameter=="function"&&!e.getProgramParameter(r,35714)?(e.deleteProgram?.(r),null):r}var Bt=new WeakSet;function Gt(e){let t=ye.get(e);if(t){if(typeof e.isProgram!="function"||e.isProgram(t.outlineProg))return t;ye.delete(e)}if(Bt.has(e)||e.isContextLost?.())return null;let n=nt(e,In,Ln),r=nt(e,zt,Un),o=nt(e,zt,kn);if(!n||!r||!o){for(let d of[n,r,o])d&&e.deleteProgram(d);return Bt.add(e),null}let a=typeof e.createVertexArray=="function"?e.createVertexArray():null;return t={outlineProg:n,uOutlineMVP:e.getUniformLocation(n,"uMVP"),uOutlineVP:e.getUniformLocation(n,"uVP"),uOutlineNormalMatrix:e.getUniformLocation(n,"uNormalMatrix"),uOutlineViewportSize:e.getUniformLocation(n,"uViewportSize"),uOutlineThickness:e.getUniformLocation(n,"uOutlineThickness"),uOutlineColor:e.getUniformLocation(n,"uOutlineColor"),downProg:r,uDownSourceTex:e.getUniformLocation(r,"uSourceTex"),uDownTexelSize:e.getUniformLocation(r,"uTexelSize"),uDownThreshold:e.getUniformLocation(r,"uThreshold"),upProg:o,uUpBloomTex:e.getUniformLocation(o,"uBloomTex"),uUpTexelSize:e.getUniformLocation(o,"uTexelSize"),uUpRadius:e.getUniformLocation(o,"uRadius"),uUpStrength:e.getUniformLocation(o,"uStrength"),fsVao:a,sceneTex:null,bloomTex:[],bloomFbo:[],mipWidth:[],mipHeight:[],texWidth:0,texHeight:0},ye.set(e,t),t}function Pn(e,t,n,r){if(typeof e.createFramebuffer!="function"||typeof e.copyTexSubImage2D!="function")return!1;let o=Math.max(2,n|0),a=Math.max(2,r|0);if(t.sceneTex&&t.bloomFbo.length===Ne&&t.texWidth===o&&t.texHeight===a)return!0;t.sceneTex||(t.sceneTex=e.createTexture()),e.bindTexture(3553,t.sceneTex),e.texImage2D(3553,0,6408,o,a,0,6408,5121,null),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071);let d=o,c=a;for(let i=0;i<Ne;i++)d=Math.max(1,d>>1),c=Math.max(1,c>>1),t.mipWidth[i]=d,t.mipHeight[i]=c,t.bloomTex[i]||(t.bloomTex[i]=e.createTexture()),e.bindTexture(3553,t.bloomTex[i]),e.texImage2D(3553,0,6408,d,c,0,6408,5121,null),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),t.bloomFbo[i]||(t.bloomFbo[i]=e.createFramebuffer()),e.bindFramebuffer(36160,t.bloomFbo[i]),e.framebufferTexture2D(36160,36064,3553,t.bloomTex[i],0);return e.bindFramebuffer(36160,null),t.texWidth=o,t.texHeight=a,!0}function Nn(e){let t=e.container;if(t&&typeof t.getAttribute=="function"){let r=t.getAttribute("bloom");if(r!==null){let o=r.trim().toLowerCase();if(o==="false"||o==="0"||o==="none")return null;let a=o===""||o==="true"?.35:Number(o);if(!Number.isFinite(a)||a<=0)return null;let d=$e({strength:a,threshold:tt(t.getAttribute("bloom-threshold"),.62),radius:tt(t.getAttribute("bloom-radius"),.75)});if(d)return d}}let n=null;for(let r of e.meshes||[]){if(r.visible===!1)continue;let o=r?.extras?.xr?.bloom??r?.userData?.xr?.bloom,a=$e(o);a&&(!n||a.strength>n.strength)&&(n=a)}return n}function Cn(e,t){if(e==null)return null;let n=e.trim(),r=n.toLowerCase();if(r==="false"||r==="0"||r==="none")return null;let o=t,a=3.5,d=!1;if(n&&r!=="true"){let c=n.split(/\s+/);for(let i of c)if(i.startsWith("#"))o=i;else if(i.toLowerCase()==="pulse")d=!0;else{let l=Number(i);Number.isFinite(l)&&l>0&&(a=l)}}return Ee({color:o,thickness:a,pulse:d})}var On=new Set(["floor","pedestal","ground","table","grid","pad"]);function Vn(e){return e.replace(/([a-z\d])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/).some(t=>On.has(t))}function Dn(e,t){let n=e.container,r=typeof n?.getAttribute=="function"?n.getAttribute("outline"):null;if(r!=null){let s=r.trim().toLowerCase();if(s==="false"||s==="0"||s==="none")return null}let o=t?.extras?.xr?.outline??t?.userData?.xr?.outline,a=Ee(o);if(a)return a;let d=typeof n?.getAttribute=="function"&&n.getAttribute("outline-color")||"#38bdf8",c=Cn(r,d),i=n!=null&&typeof n.hasAttribute=="function"&&n.hasAttribute("outline-selected")&&n.getAttribute("outline-selected")!=="false",l=e.getSelectedMesh?.()||"";if(l)return t.name!==l?null:c||(i?Ee({color:d,thickness:3,pulse:!1}):null);if(c){let s=t.name||"";return Vn(s)?null:c}return null}var ot={name:"postprocessing",onAttributeChanged(e,t){(t==="bloom"||t==="bloom-threshold"||t==="bloom-radius"||t==="outline"||t==="outline-selected"||t==="outline-color"||t==="selected-mesh")&&e.viewer?.render?.()},onAfterRender(e,t,n){if(!t.meshes||t.meshes.length===0)return;let r=Math.max(1,t.canvas?.width||300),o=Math.max(1,t.canvas?.height||150),a=[];for(let u of t.meshes){if(u.visible===!1)continue;let b=Dn(t,u);b&&a.push({mesh:u,trait:b})}let d=a.length>0?Gt(e):null;if(d){let u=d,b=le(),m=le(),p=new Float32Array(9),x=(typeof performance<"u"?performance.now():Date.now())*.001,E=typeof e.getParameter=="function"?e.getParameter(e.VIEWPORT):null,I=Math.max(1,E?.[2]||r),v=Math.max(1,E?.[3]||o);e.useProgram(u.outlineProg),u.uOutlineViewportSize&&e.uniform2f(u.uOutlineViewportSize,I,v),u.uOutlineVP&&e.uniformMatrix4fv(u.uOutlineVP,!1,n),e.enable(e.CULL_FACE),e.cullFace(e.FRONT),e.enable(2929),e.depthFunc(e.LEQUAL),e.depthMask(!1);for(let{mesh:S,trait:w}of a){let[U,V,O]=rt(w.color),N=w.pulse?.8+.25*Math.sin(x*4):1;u.uOutlineColor&&e.uniform4f(u.uOutlineColor,U,V,O,1),u.uOutlineThickness&&e.uniform1f(u.uOutlineThickness,w.thickness*N),S.worldSpace===!0?b.set(S.transform):ue(b,t.modelRootMatrix,S.transform);let P=S.instanceMatrices;for(let C of S.primitives)if(!(C.pluginData?.skinning?.hasSkin||C.pluginData?.morph?.hasMorph))if(e.bindVertexArray(C.vao),P&&P.length>=16){let z=P.length>>4,W=le();for(let B=0;B<z;B++)ue(W,b,P.subarray(B*16,B*16+16)),ue(m,n,W),fe(p,W),e.uniformMatrix4fv(u.uOutlineMVP,!1,m),e.uniformMatrix3fv(u.uOutlineNormalMatrix,!1,p),C.indices?e.drawElements(4,C.indexCount,C.indexType,0):e.drawArrays(4,0,C.indexCount)}else ue(m,n,b),fe(p,b),e.uniformMatrix4fv(u.uOutlineMVP,!1,m),e.uniformMatrix3fv(u.uOutlineNormalMatrix,!1,p),C.indices?e.drawElements(4,C.indexCount,C.indexType,0):e.drawArrays(4,0,C.indexCount)}e.bindVertexArray(null),e.cullFace(e.BACK),e.disable(e.CULL_FACE),e.depthFunc(e.LESS),e.depthMask(!0)}if(t.xrSessionActive||t.stereoSBS)return;let c=Nn(t);if(!c||c.strength<=0)return;let i=Gt(e);if(!i||!Pn(e,i,r,o)||!i.fsVao)return;e.activeTexture(33984),e.bindTexture(3553,i.sceneTex),e.copyTexSubImage2D(3553,0,0,0,0,0,r,o),e.disable(2929),e.depthMask(!1),e.disable(3042),e.useProgram(i.downProg),e.uniform1i(i.uDownSourceTex,0),e.bindVertexArray(i.fsVao);let l=i.sceneTex,s=r,f=o;for(let u=0;u<Ne;u++){let b=i.mipWidth[u],m=i.mipHeight[u];e.bindFramebuffer(36160,i.bloomFbo[u]),e.viewport(0,0,b,m),e.bindTexture(3553,l),e.uniform2f(i.uDownTexelSize,1/s,1/f),e.uniform1f(i.uDownThreshold,u===0?c.threshold:0),e.drawArrays(4,0,3),l=i.bloomTex[u],s=b,f=m}e.enable(3042),typeof e.blendFuncSeparate=="function"?e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,771):e.blendFunc(e.ONE,e.ONE),e.useProgram(i.upProg),e.uniform1i(i.uUpBloomTex,0),e.uniform1f(i.uUpRadius,c.radius);for(let u=Ne-1;u>=1;u--){let b=u-1;e.bindFramebuffer(36160,i.bloomFbo[b]),e.viewport(0,0,i.mipWidth[b],i.mipHeight[b]),e.bindTexture(3553,i.bloomTex[u]),e.uniform2f(i.uUpTexelSize,1/i.mipWidth[u],1/i.mipHeight[u]),e.uniform1f(i.uUpStrength,.85),e.drawArrays(4,0,3)}e.bindFramebuffer(36160,null),e.viewport(0,0,r,o),e.bindTexture(3553,i.bloomTex[0]),e.uniform2f(i.uUpTexelSize,1/i.mipWidth[0],1/i.mipHeight[0]),e.uniform1f(i.uUpStrength,c.strength),e.drawArrays(4,0,3),e.bindVertexArray(null),e.blendFunc(770,771),e.disable(3042),e.depthMask(!0),e.enable(2929)},onDestroy(e){let t=ye.get(e);if(t){e.deleteProgram(t.outlineProg),e.deleteProgram(t.downProg),e.deleteProgram(t.upProg),t.fsVao&&e.deleteVertexArray(t.fsVao),t.sceneTex&&e.deleteTexture(t.sceneTex);for(let n of t.bloomTex)n&&e.deleteTexture(n);for(let n of t.bloomFbo)n&&e.deleteFramebuffer(n);ye.delete(e)}}};var zn=`#version 300 es
119
- layout(location=0) in vec3 aPosition;layout(location=1) in vec2 aUV;uniform mat4 uMVP;out vec2 vUV;void main(){vUV=aUV;gl_Position=uMVP*vec4(aPosition,1.);}`,Bn=`#version 300 es
120
- precision highp float;in vec2 vUV;uniform float uShadowIntensity,uShadowSoftness;out vec4 fragColor;void main(){vec2 p=(vUV-.5)*2.;float d=clamp(length(p),0.,1.);fragColor=vec4(0.,0.,0.,pow(1.-d*d,mix(1.2,2.8,uShadowSoftness))*smoothstep(1.,.85-uShadowSoftness*.6,d)*uShadowIntensity);}`,ge=new WeakMap,Xt=new Float32Array(20);function it(e,t){let[n,r,o,a,d,c]=t;return[e[0]*n+e[4]*r+e[8]*o+e[12],e[1]*n+e[5]*r+e[9]*o+e[13],e[2]*n+e[6]*r+e[10]*o+e[14],Math.abs(e[0])*a+Math.abs(e[4])*d+Math.abs(e[8])*c,Math.abs(e[1])*a+Math.abs(e[5])*d+Math.abs(e[9])*c,Math.abs(e[2])*a+Math.abs(e[6])*d+Math.abs(e[10])*c]}function Gn(e){if(e._lb!==void 0)return e._lb;let t=1e9,n=1e9,r=1e9,o=-1e9,a=-1e9,d=-1e9;for(let c of e.primitives||[]){let i=c.positions;if(i)for(let l=0;l<i.length;l+=3)i[l]<t&&(t=i[l]),i[l+1]<n&&(n=i[l+1]),i[l+2]<r&&(r=i[l+2]),i[l]>o&&(o=i[l]),i[l+1]>a&&(a=i[l+1]),i[l+2]>d&&(d=i[l+2])}return e._lb=t<=o?[(t+o)*.5,(n+a)*.5,(r+d)*.5,(o-t)*.5,(a-n)*.5,(d-r)*.5]:null}function Hn(e){let t=ge.get(e);if(t)return t;let n=(c,i)=>{let l=e.createShader(c);return e.shaderSource(l,i),e.compileShader(l),l},r=e.createProgram();e.attachShader(r,n(35633,zn)),e.attachShader(r,n(35632,Bn)),e.linkProgram(r);let o=e.createVertexArray(),a=e.createBuffer(),d=e.createBuffer();return e.bindVertexArray(o),e.bindBuffer(34962,a),e.bufferData(34962,80,35048),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,5126,!1,20,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,5126,!1,20,12),e.bindBuffer(34963,d),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),t={prog:r,vao:o,vbo:a,ibo:d,uMVP:e.getUniformLocation(r,"uMVP"),uIntensity:e.getUniformLocation(r,"uShadowIntensity"),uSoftness:e.getUniformLocation(r,"uShadowSoftness")},ge.set(e,t),t}var at={name:"contact-shadow",onContextRestored(e){ge.delete(e)},onAfterRender(e,t,n){let r=t.shadowIntensity;if(r<=0||!t.bounds)return;let o=Hn(e),a=!t.xrSessionActive&&(t.backdropMeshes?.length??0)>0,d=[],c=[];for(let p of t.meshes||[]){if(!p||p.visible===!1||p.isPluginMesh||p.name==="__xr_reticle__"||p.name?.startsWith("__xr_slot_"))continue;let x=Gn(p);if(!x)continue;p.transform&&(x=it(p.transform,x)),t.modelRootMatrix&&(x=it(t.modelRootMatrix,x));let[E,I,v,S,w,U]=x,V=[E,v,S,U,I-w,I+w];/floor|table|pedestal|ground|base|plane/i.test(p.name||"")||w<.14&&Math.min(S,U)>.45?c.push(V):d.push(V)}let i=[],l=t.bounds.center||[0,0,0],s=Math.max(.05,Number(t.bounds.radius)||.5),f=t.bounds.min,u=f?[l[0],l[1],l[2],s,Math.max(.01,l[1]-f[1]),s]:[l[0],l[1],l[2],s,s,s];t.modelRootMatrix&&(u=it(t.modelRootMatrix,u));let m=t.xrSessionActive&&c.length===0&&String(t.container?.tagName||"").toLowerCase()==="xr-live"?(t.modelRootMatrix?t.modelRootMatrix[5]*-.25+t.modelRootMatrix[13]:-.25)+.002:u[1]-u[4]+.002;for(let[p,x,E,I,v]of d){let S=-1/0;for(let[U,V,O,N,,P]of c)v>=P-.08&&Math.abs(p-U)<=O&&Math.abs(x-V)<=N&&P+.002>S&&(S=P+.002);a&&(S=Math.max(S,p>=.04&&p<=.36&&x>=-.34&&x<=-.04&&v>=.01?.036:Math.hypot(p,x)<=.66&&v>=-.06?.003:-.477)),isFinite(S)||(S=m);let w=i.find(U=>Math.hypot(p-U[0],x-U[1])<.06&&Math.abs(S-U[5])<.05);w?(w[2]=Math.max(w[2],E*.78),w[3]=Math.max(w[3],I*.78),w[4]=Math.min(w[4],v)):i.push([p,x,E,I,v,S])}if(i.length===0){let p=Math.max(.1,u[3]*1.5)/1.45;i.push([u[0],u[2],p,p,m,m])}e.useProgram(o.prog),e.uniformMatrix4fv(o.uMVP,!1,n),e.enable(3042),(e.blendFuncSeparate||e.blendFunc).call(e,770,771,1,771),e.depthMask(!1),e.bindVertexArray(o.vao),e.bindBuffer(34962,o.vbo);for(let[p,x,E,I,v,S]of i){let w=Math.max(0,v-S),U=r/(1+w*2);if(U<.02)continue;let V=1+Math.min(.75,w*.85),O=Math.max(.045,E*1.45*V),N=Math.max(.045,I*1.45*V);Xt.set([p-O,S,x-N,0,0,p+O,S,x-N,1,0,p+O,S,x+N,1,1,p-O,S,x+N,0,1]),e.bufferSubData(34962,0,Xt),e.uniform1f(o.uIntensity,U),e.uniform1f(o.uSoftness,Math.min(1,t.shadowSoftness+Math.min(.45,w*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let t=ge.get(e);t&&(e.deleteVertexArray(t.vao),e.deleteBuffer(t.vbo),e.deleteBuffer(t.ibo),e.deleteProgram(t.prog),ge.delete(e))}};function st(e){let n=e?.extensions?.KHR_materials_variants?.variants;if(!Array.isArray(n))return[];let r=[];for(let o=0;o<n.length&&r.length<256;o++){let a=n[o]?.name;r.push(typeof a=="string"&&a.length>0?a:`Variant_${o}`)}return r}function $t(e){let n=e?.extensions?.KHR_materials_variants?.mappings;if(!Array.isArray(n))return[];let r=[];for(let o of n){if(!o||typeof o!="object")continue;let a=o,d=Number(a.material);if(!Number.isInteger(d)||d<0)continue;let c=[];if(Array.isArray(a.variants))for(let i of a.variants){let l=Number(i);Number.isInteger(l)&&l>=0&&c.push(l)}c.length>0&&r.push({material:d,variants:c})}return r}function jt(e,t,n,r=0){let o=e;if(o&&typeof o.selectVariant=="function"&&!Array.isArray(t))return o.selectVariant(typeof t=="string"?t:null);let a=e,d=Array.isArray(t)?t:[],c=n??null;if(!c)return r;let l=st(a).indexOf(c);if(l<0)return r;for(let s of d)if(s.variants.includes(l))return s.material;return r}var ct={name:"variants",onLoadModel(e,t){let n=e.getVariantName?.();n&&e.selectVariant(n)}};var Kt=new WeakMap,lt={name:"webxr-suite",onConfigureXRSessionInit(e,t){let n=new Set(t.optionalFeatures||[]);n.add("hit-test"),n.add("light-estimation");let r=e?.querySelector?.('[slot="ar-overlay"]')||null;r&&(n.add("dom-overlay"),t.domOverlay={root:r},r.addEventListener?.("beforexrselect",o=>{o.preventDefault()})),t.optionalFeatures=Array.from(n)},onXRFrame(e,t,n,r){if(!e||!t||!n||!r)return;let o=Kt.get(t);if(o||(o={lightProbe:null},Kt.set(t,o),typeof t.requestLightProbe=="function"&&t.requestLightProbe().then(a=>{o&&a&&(o.lightProbe=a)}).catch(()=>{})),o.lightProbe&&typeof n.getLightEstimate=="function"){let a=n.getLightEstimate(o.lightProbe);if(a){let d=a.primaryLightDirection,c=a.primaryLightIntensity;if(d&&c&&Array.isArray(e.lights)){let i=e.lights.find(s=>s.type==="directional");i||(i={type:"directional",direction:[.5,1,.8],color:[1,1,1],intensity:1},e.lights.push(i)),i.direction=[d.x,d.y,d.z];let l=Math.max(c.x,c.y,c.z,.001);i.color=[c.x/l,c.y/l,c.z/l],i.intensity=l}a.sphericalHarmonicsCoefficients&&e.gl&&ve(e.gl,a.sphericalHarmonicsCoefficients)}}}};Z(at);Z(We);Z(Be);Z(Qe);Z(lt);Z(qe);Z(et);Z(ct);Z(ot);return nn(Wn);})();
117
+ }`,Be=3,Le=new WeakMap;function jt(e,t=[.22,.74,.97]){let r=ht(e,"");if(!r.startsWith("#"))return[t[0],t[1],t[2]];let i=r.slice(1);if(i.length===3){let n=+("0x"+i[0]+i[0])/255,s=+("0x"+i[1]+i[1])/255,m=+("0x"+i[2]+i[2])/255;return[n,s,m]}if(i.length===6){let n=+("0x"+i.slice(0,2))/255,s=+("0x"+i.slice(2,4))/255,m=+("0x"+i.slice(4,6))/255;return[n,s,m]}return[t[0],t[1],t[2]]}function qr(e,t,r=.8,i=.5){let n=Number.isFinite(t)?Math.max(0,t):0;if(n<=0)return[0,0,0];let s=Math.max(0,Number(e[0])||0),m=Math.max(0,Number(e[1])||0),c=Math.max(0,Number(e[2])||0),o=Math.max(s,m,c);if(o<=1e-6)return[0,0,0];let d=Number.isFinite(r)?Math.max(0,r):.8,a=Math.max(d*Math.max(0,i),1e-4),u=Math.max(0,Math.min(2*a,o-d+a)),l=u*u/(4*a+1e-4),h=Math.min(1,Math.max(0,Math.max(l,o-d)/Math.max(o,1e-4)))*n;return[s*h,m*h,c*h]}function Wr(e,t,r,i){let n=Number(e[0])||0,s=Number(e[1])||0,m=Math.hypot(n,s);if(m<=1e-5||t<=0||r<=0)return[0,0];let c=Math.max(1,Number(i[0])||1),o=Math.max(1,Number(i[1])||1),d=Math.max(0,r)*2*t;return[n/m*(d/c),s/m*(d/o)]}var Gt=new WeakSet;function Kt(e){let t=Le.get(e);if(t){if(typeof e.isProgram!="function"||e.isProgram(t.outlineProg))return t;Le.delete(e)}if(Gt.has(e)||e.isContextLost?.())return null;let r=it(e,zr,jr,!1),i=it(e,zt,Gr,!1),n=it(e,zt,Kr,!1);if(!r||!i||!n){for(let m of[r,i,n])m&&e.deleteProgram(m);return Gt.add(e),null}let s=typeof e.createVertexArray=="function"?e.createVertexArray():null;return t={outlineProg:r,uOutlineMVP:e.getUniformLocation(r,"uMVP"),uOutlineVP:e.getUniformLocation(r,"uVP"),uOutlineNormalMatrix:e.getUniformLocation(r,"uNormalMatrix"),uOutlineViewportSize:e.getUniformLocation(r,"uViewportSize"),uOutlineThickness:e.getUniformLocation(r,"uOutlineThickness"),uOutlineColor:e.getUniformLocation(r,"uOutlineColor"),downProg:i,uDownSourceTex:e.getUniformLocation(i,"uSourceTex"),uDownTexelSize:e.getUniformLocation(i,"uTexelSize"),uDownThreshold:e.getUniformLocation(i,"uThreshold"),upProg:n,uUpBloomTex:e.getUniformLocation(n,"uBloomTex"),uUpTexelSize:e.getUniformLocation(n,"uTexelSize"),uUpRadius:e.getUniformLocation(n,"uRadius"),uUpStrength:e.getUniformLocation(n,"uStrength"),fsVao:s,sceneTex:null,bloomTex:[],bloomFbo:[],mipWidth:[],mipHeight:[],texWidth:0,texHeight:0},Le.set(e,t),t}function Xr(e,t,r,i){if(typeof e.createFramebuffer!="function"||typeof e.copyTexSubImage2D!="function")return!1;let n=Math.max(2,r|0),s=Math.max(2,i|0);if(t.sceneTex&&t.bloomFbo.length===Be&&t.texWidth===n&&t.texHeight===s)return!0;t.sceneTex||(t.sceneTex=e.createTexture()),e.bindTexture(3553,t.sceneTex),e.texImage2D(3553,0,6408,n,s,0,6408,5121,null),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071);let m=n,c=s;for(let o=0;o<Be;o++)m=Math.max(1,m>>1),c=Math.max(1,c>>1),t.mipWidth[o]=m,t.mipHeight[o]=c,t.bloomTex[o]||(t.bloomTex[o]=e.createTexture()),e.bindTexture(3553,t.bloomTex[o]),e.texImage2D(3553,0,6408,m,c,0,6408,5121,null),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),t.bloomFbo[o]||(t.bloomFbo[o]=e.createFramebuffer()),e.bindFramebuffer(36160,t.bloomFbo[o]),e.framebufferTexture2D(36160,36064,3553,t.bloomTex[o],0);return e.bindFramebuffer(36160,null),t.texWidth=n,t.texHeight=s,!0}function Qr(e){let t=e.container;if(t&&typeof t.getAttribute=="function"){let i=t.getAttribute("bloom");if(i!==null){let n=i.trim().toLowerCase();if(n==="false"||n==="0"||n==="none")return null;let s=n===""||n==="true"?.35:Number(n);if(!Number.isFinite(s)||s<=0)return null;let m=mt({strength:s,threshold:Ht(t.getAttribute("bloom-threshold"),.62),radius:Ht(t.getAttribute("bloom-radius"),.75)});if(m)return m}}let r=null;for(let i of e.meshes||[]){if(i.visible===!1)continue;let n=i?.extras?.xr?.bloom??i?.userData?.xr?.bloom,s=mt(n);s&&(!r||s.strength>r.strength)&&(r=s)}return r}function Zr(e,t){if(e==null)return null;let r=e.trim(),i=r.toLowerCase();if(i==="false"||i==="0"||i==="none")return null;let n=t,s=3.5,m=!1;if(r&&i!=="true"){let c=r.split(/\s+/);for(let o of c)if(o.startsWith("#"))n=o;else if(o.toLowerCase()==="pulse")m=!0;else{let d=Number(o);Number.isFinite(d)&&d>0&&(s=d)}}return Xe({color:n,thickness:s,pulse:m})}var Yr=new Set(["floor","pedestal","ground","table","grid","pad"]);function Jr(e){return e.replace(/([a-z\d])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/).some(t=>Yr.has(t))}function ei(e,t){let r=e.container,i=typeof r?.getAttribute=="function"?r.getAttribute("outline"):null;if(i!=null){let a=i.trim().toLowerCase();if(a==="false"||a==="0"||a==="none")return null}let n=t?.extras?.xr?.outline??t?.userData?.xr?.outline,s=Xe(n);if(s)return s;let m=typeof r?.getAttribute=="function"&&r.getAttribute("outline-color")||"#38bdf8",c=Zr(i,m),o=r!=null&&typeof r.hasAttribute=="function"&&r.hasAttribute("outline-selected")&&r.getAttribute("outline-selected")!=="false",d=e.getSelectedMesh?.()||"";if(d)return t.name!==d?null:c||(o?Xe({color:m,thickness:3,pulse:!1}):null);if(c){let a=t.name||"";return Jr(a)?null:c}return null}var qt={name:"postprocessing",onAttributeChanged(e,t){(t==="bloom"||t==="bloom-threshold"||t==="bloom-radius"||t==="outline"||t==="outline-selected"||t==="outline-color"||t==="selected-mesh")&&e.viewer?.render?.()},onAfterRender(e,t,r){if(!t.meshes||t.meshes.length===0)return;let i=Math.max(1,t.canvas?.width||300),n=Math.max(1,t.canvas?.height||150),s=[];for(let l of t.meshes){if(l.visible===!1)continue;let h=ei(t,l);h&&s.push({mesh:l,trait:h})}let m=s.length>0?Kt(e):null;if(m){let l=m,h=Ae(),f=Ae(),g=new Float32Array(9),A=(typeof performance<"u"?performance.now():Date.now())*.001,v=typeof e.getParameter=="function"?e.getParameter(e.VIEWPORT):null,T=Math.max(1,v?.[2]||i),p=Math.max(1,v?.[3]||n);e.useProgram(l.outlineProg),l.uOutlineViewportSize&&e.uniform2f(l.uOutlineViewportSize,T,p),l.uOutlineVP&&e.uniformMatrix4fv(l.uOutlineVP,!1,r),e.enable(e.CULL_FACE),e.cullFace(e.FRONT),e.enable(2929),e.depthFunc(e.LEQUAL),e.depthMask(!1);for(let{mesh:b,trait:y}of s){let[L,C,F]=jt(y.color),_=y.pulse?.8+.25*Math.sin(A*4):1;l.uOutlineColor&&e.uniform4f(l.uOutlineColor,L,C,F,1),l.uOutlineThickness&&e.uniform1f(l.uOutlineThickness,y.thickness*_),b.worldSpace===!0?h.set(b.transform):Se(h,t.modelRootMatrix,b.transform);let O=b.instanceMatrices;for(let D of b.primitives)if(!(D.pluginData?.skinning?.hasSkin||D.pluginData?.morph?.hasMorph))if(e.bindVertexArray(D.vao),O&&O.length>=16){let $=O.length>>4,z=Ae();for(let k=0;k<$;k++)Se(z,h,O.subarray(k*16,k*16+16)),Se(f,r,z),Ve(g,z),e.uniformMatrix4fv(l.uOutlineMVP,!1,f),e.uniformMatrix3fv(l.uOutlineNormalMatrix,!1,g),D.indices?e.drawElements(4,D.indexCount,D.indexType,0):e.drawArrays(4,0,D.indexCount)}else Se(f,r,h),Ve(g,h),e.uniformMatrix4fv(l.uOutlineMVP,!1,f),e.uniformMatrix3fv(l.uOutlineNormalMatrix,!1,g),D.indices?e.drawElements(4,D.indexCount,D.indexType,0):e.drawArrays(4,0,D.indexCount)}e.bindVertexArray(null),e.cullFace(e.BACK),e.disable(e.CULL_FACE),e.depthFunc(e.LESS),e.depthMask(!0)}if(t.xrSessionActive||t.stereoSBS)return;let c=Qr(t);if(!c||c.strength<=0)return;let o=Kt(e);if(!o||!Xr(e,o,i,n)||!o.fsVao)return;e.activeTexture(33984),e.bindTexture(3553,o.sceneTex),e.copyTexSubImage2D(3553,0,0,0,0,0,i,n),e.disable(2929),e.depthMask(!1),e.disable(3042),e.useProgram(o.downProg),e.uniform1i(o.uDownSourceTex,0),e.bindVertexArray(o.fsVao);let d=o.sceneTex,a=i,u=n;for(let l=0;l<Be;l++){let h=o.mipWidth[l],f=o.mipHeight[l];e.bindFramebuffer(36160,o.bloomFbo[l]),e.viewport(0,0,h,f),e.bindTexture(3553,d),e.uniform2f(o.uDownTexelSize,1/a,1/u),e.uniform1f(o.uDownThreshold,l===0?c.threshold:0),e.drawArrays(4,0,3),d=o.bloomTex[l],a=h,u=f}e.enable(3042),typeof e.blendFuncSeparate=="function"?e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,771):e.blendFunc(e.ONE,e.ONE),e.useProgram(o.upProg),e.uniform1i(o.uUpBloomTex,0),e.uniform1f(o.uUpRadius,c.radius);for(let l=Be-1;l>=1;l--){let h=l-1;e.bindFramebuffer(36160,o.bloomFbo[h]),e.viewport(0,0,o.mipWidth[h],o.mipHeight[h]),e.bindTexture(3553,o.bloomTex[l]),e.uniform2f(o.uUpTexelSize,1/o.mipWidth[l],1/o.mipHeight[l]),e.uniform1f(o.uUpStrength,.85),e.drawArrays(4,0,3)}e.bindFramebuffer(36160,null),e.viewport(0,0,i,n),e.bindTexture(3553,o.bloomTex[0]),e.uniform2f(o.uUpTexelSize,1/o.mipWidth[0],1/o.mipHeight[0]),e.uniform1f(o.uUpStrength,c.strength),e.drawArrays(4,0,3),e.bindVertexArray(null),e.blendFunc(770,771),e.disable(3042),e.depthMask(!0),e.enable(2929)},onDestroy(e){let t=Le.get(e);if(t){e.deleteProgram(t.outlineProg),e.deleteProgram(t.downProg),e.deleteProgram(t.upProg),t.fsVao&&e.deleteVertexArray(t.fsVao),t.sceneTex&&e.deleteTexture(t.sceneTex);for(let r of t.bloomTex)r&&e.deleteTexture(r);for(let r of t.bloomFbo)r&&e.deleteFramebuffer(r);Le.delete(e)}}},ti=`#version 300 es
118
+ layout(location=0) in vec3 aPosition;layout(location=1) in vec2 aUV;uniform mat4 uMVP;out vec2 vUV;void main(){vUV=aUV;gl_Position=uMVP*vec4(aPosition,1.);}`,ri=`#version 300 es
119
+ precision highp float;in vec2 vUV;uniform float uShadowIntensity,uShadowSoftness;out vec4 fragColor;void main(){vec2 p=(vUV-.5)*2.;float d=clamp(length(p),0.,1.);fragColor=vec4(0.,0.,0.,pow(1.-d*d,mix(1.2,2.8,uShadowSoftness))*smoothstep(1.,.85-uShadowSoftness*.6,d)*uShadowIntensity);}`,Ee=new WeakMap,Wt=new Float32Array(20);function nt(e,t){let[r,i,n,s,m,c]=t;return[e[0]*r+e[4]*i+e[8]*n+e[12],e[1]*r+e[5]*i+e[9]*n+e[13],e[2]*r+e[6]*i+e[10]*n+e[14],Math.abs(e[0])*s+Math.abs(e[4])*m+Math.abs(e[8])*c,Math.abs(e[1])*s+Math.abs(e[5])*m+Math.abs(e[9])*c,Math.abs(e[2])*s+Math.abs(e[6])*m+Math.abs(e[10])*c]}function ii(e){if(e._lb!==void 0)return e._lb;let t=1e9,r=1e9,i=1e9,n=-1e9,s=-1e9,m=-1e9;for(let c of e.primitives||[]){let o=c.positions;if(o)for(let d=0;d<o.length;d+=3)o[d]<t&&(t=o[d]),o[d+1]<r&&(r=o[d+1]),o[d+2]<i&&(i=o[d+2]),o[d]>n&&(n=o[d]),o[d+1]>s&&(s=o[d+1]),o[d+2]>m&&(m=o[d+2])}return e._lb=t<=n?[(t+n)*.5,(r+s)*.5,(i+m)*.5,(n-t)*.5,(s-r)*.5,(m-i)*.5]:null}function ni(e){let t=Ee.get(e);if(t)return t;let r=(c,o)=>{let d=e.createShader(c);return e.shaderSource(d,o),e.compileShader(d),d},i=e.createProgram();e.attachShader(i,r(35633,ti)),e.attachShader(i,r(35632,ri)),e.linkProgram(i);let n=e.createVertexArray(),s=e.createBuffer(),m=e.createBuffer();return e.bindVertexArray(n),e.bindBuffer(34962,s),e.bufferData(34962,80,35048),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,5126,!1,20,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,5126,!1,20,12),e.bindBuffer(34963,m),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),t={prog:i,vao:n,vbo:s,ibo:m,uMVP:e.getUniformLocation(i,"uMVP"),uIntensity:e.getUniformLocation(i,"uShadowIntensity"),uSoftness:e.getUniformLocation(i,"uShadowSoftness")},Ee.set(e,t),t}var Xt={name:"contact-shadow",onContextRestored(e){Ee.delete(e)},onAfterRender(e,t,r){let i=t.shadowIntensity;if(i<=0||!t.bounds)return;let n=ni(e),s=!t.xrSessionActive&&(t.backdropMeshes?.length??0)>0,m=[],c=[];for(let f of t.meshes||[]){if(!f||f.visible===!1||f.isPluginMesh||f.name==="__xr_reticle__"||f.name?.startsWith("__xr_slot_"))continue;let g=ii(f);if(!g)continue;f.transform&&(g=nt(f.transform,g)),t.modelRootMatrix&&(g=nt(t.modelRootMatrix,g));let[A,v,T,p,b,y]=g,L=[A,T,p,y,v-b,v+b];/floor|table|pedestal|ground|base|plane/i.test(f.name||"")||b<.14&&Math.min(p,y)>.45?c.push(L):m.push(L)}let o=[],d=t.bounds.center||[0,0,0],a=Math.max(.05,Number(t.bounds.radius)||.5),u=t.bounds.min,l=u?[d[0],d[1],d[2],a,Math.max(.01,d[1]-u[1]),a]:[d[0],d[1],d[2],a,a,a];t.modelRootMatrix&&(l=nt(t.modelRootMatrix,l));let h=t.xrSessionActive&&c.length===0&&String(t.container?.tagName||"").toLowerCase()==="xr-live"?(t.modelRootMatrix?t.modelRootMatrix[5]*-.25+t.modelRootMatrix[13]:-.25)+.002:l[1]-l[4]+.002;for(let[f,g,A,v,T]of m){let p=-1/0;for(let[y,L,C,F,,_]of c)T>=_-.08&&Math.abs(f-y)<=C&&Math.abs(g-L)<=F&&_+.002>p&&(p=_+.002);s&&(p=Math.max(p,f>=.04&&f<=.36&&g>=-.34&&g<=-.04&&T>=.01?.036:Math.hypot(f,g)<=.66&&T>=-.06?.003:-.477)),isFinite(p)||(p=h);let b=o.find(y=>Math.hypot(f-y[0],g-y[1])<.06&&Math.abs(p-y[5])<.05);b?(b[2]=Math.max(b[2],A*.78),b[3]=Math.max(b[3],v*.78),b[4]=Math.min(b[4],T)):o.push([f,g,A,v,T,p])}if(o.length===0){let f=Math.max(.1,l[3]*1.5)/1.45;o.push([l[0],l[2],f,f,h,h])}e.useProgram(n.prog),e.uniformMatrix4fv(n.uMVP,!1,r),e.enable(3042),(e.blendFuncSeparate||e.blendFunc).call(e,770,771,1,771),e.depthMask(!1),e.bindVertexArray(n.vao),e.bindBuffer(34962,n.vbo);for(let[f,g,A,v,T,p]of o){let b=Math.max(0,T-p),y=i/(1+b*2);if(y<.02)continue;let L=1+Math.min(.75,b*.85),C=Math.max(.045,A*1.45*L),F=Math.max(.045,v*1.45*L);Wt.set([f-C,p,g-F,0,0,f+C,p,g-F,1,0,f+C,p,g+F,1,1,f-C,p,g+F,0,1]),e.bufferSubData(34962,0,Wt),e.uniform1f(n.uIntensity,y),e.uniform1f(n.uSoftness,Math.min(1,t.shadowSoftness+Math.min(.45,b*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let t=Ee.get(e);t&&(e.deleteVertexArray(t.vao),e.deleteBuffer(t.vbo),e.deleteBuffer(t.ibo),e.deleteProgram(t.prog),Ee.delete(e))}};function Qt(e){let t=e?.extensions?.KHR_materials_variants?.variants;if(!Array.isArray(t))return[];let r=[];for(let i=0;i<t.length&&r.length<256;i++){let n=t[i]?.name;r.push(typeof n=="string"&&n.length>0?n:`Variant_${i}`)}return r}function ai(e){let t=e?.extensions?.KHR_materials_variants?.mappings;if(!Array.isArray(t))return[];let r=[];for(let i of t){if(!i||typeof i!="object")continue;let n=i,s=Number(n.material);if(!Number.isInteger(s)||s<0)continue;let m=[];if(Array.isArray(n.variants))for(let c of n.variants){let o=Number(c);Number.isInteger(o)&&o>=0&&m.push(o)}m.length>0&&r.push({material:s,variants:m})}return r}function oi(e,t,r,i=0){let n=e;if(n&&typeof n.selectVariant=="function"&&!Array.isArray(t))return n.selectVariant(typeof t=="string"?t:null);let s=e,m=Array.isArray(t)?t:[],c=r??null;if(!c)return i;let o=Qt(s).indexOf(c);if(o<0)return i;for(let d of m)if(d.variants.includes(o))return d.material;return i}var Zt={name:"variants",onLoadModel(e,t){let r=e.getVariantName?.();r&&e.selectVariant(r)}},Yt=new WeakMap,Jt={name:"webxr-suite",onConfigureXRSessionInit(e,t){let r=new Set(t.optionalFeatures||[]);r.add("hit-test"),r.add("light-estimation");let i=e?.querySelector?.('[slot="ar-overlay"]')||null;i&&(r.add("dom-overlay"),t.domOverlay={root:i},i.addEventListener?.("beforexrselect",n=>{n.preventDefault()})),t.optionalFeatures=Array.from(r)},onXRFrame(e,t,r,i){if(!e||!t||!r||!i)return;let n=Yt.get(t);if(n||(n={lightProbe:null},Yt.set(t,n),typeof t.requestLightProbe=="function"&&t.requestLightProbe().then(s=>{n&&s&&(n.lightProbe=s)}).catch(()=>{})),n.lightProbe&&typeof r.getLightEstimate=="function"){let s=r.getLightEstimate(n.lightProbe);if(s){let m=s.primaryLightDirection,c=s.primaryLightIntensity;if(m&&c&&Array.isArray(e.lights)){let o=e.lights.find(a=>a.type==="directional");o||(o={type:"directional",direction:[.5,1,.8],color:[1,1,1],intensity:1},e.lights.push(o)),o.direction=[m.x,m.y,m.z];let d=Math.max(c.x,c.y,c.z,.001);o.color=[c.x/d,c.y/d,c.z/d],o.intensity=d}s.sphericalHarmonicsCoefficients&&e.gl&&lt(e.gl,s.sphericalHarmonicsCoefficients)}}}};return se(Xt),se(ct),se(ft),se(Nt),se(Jt),se(At),se(Bt),se(Zt),se(qt),se(Tt),or(at)})();