three-live 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +22 -0
  3. package/dist/three-author-engine.js +28 -26
  4. package/dist/three-author.cjs +29 -27
  5. package/dist/three-author.d.ts +22 -0
  6. package/dist/three-author.js +29 -27
  7. package/dist/three-convert.cjs +21 -19
  8. package/dist/three-convert.d.ts +22 -0
  9. package/dist/three-convert.js +21 -19
  10. package/dist/three-live-animation.cjs +4 -4
  11. package/dist/three-live-animation.d.ts +22 -0
  12. package/dist/three-live-animation.js +4 -4
  13. package/dist/three-live-animation.min.js +4 -4
  14. package/dist/three-live-cad.cjs +2 -2
  15. package/dist/three-live-cad.d.ts +22 -0
  16. package/dist/three-live-cad.js +2 -2
  17. package/dist/three-live-cad.min.js +2 -2
  18. package/dist/three-live-element.cjs +5 -3
  19. package/dist/three-live-element.d.ts +22 -0
  20. package/dist/three-live-element.js +5 -3
  21. package/dist/three-live-full.cjs +48 -46
  22. package/dist/three-live-full.js +47 -45
  23. package/dist/three-live-full.min.js +48 -46
  24. package/dist/three-live-studio.cjs +10 -10
  25. package/dist/three-live-studio.d.ts +22 -0
  26. package/dist/three-live-studio.js +10 -10
  27. package/dist/three-live-studio.min.js +10 -10
  28. package/dist/three-live-viewer.cjs +5 -3
  29. package/dist/three-live-viewer.d.ts +22 -0
  30. package/dist/three-live-viewer.js +5 -3
  31. package/dist/three-live-viewer.min.js +5 -3
  32. package/dist/three-live.cjs +23 -21
  33. package/dist/three-live.js +25 -23
  34. package/dist/three-live.min.js +23 -21
  35. package/dist/three-view.cjs +8 -6
  36. package/dist/three-view.d.ts +22 -0
  37. package/dist/three-view.js +8 -6
  38. package/dist/three-xr.cjs +24 -22
  39. package/dist/three-xr.d.ts +22 -0
  40. package/dist/three-xr.js +24 -22
  41. package/package.json +1 -1
@@ -14,9 +14,9 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- "use strict";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});module.exports=nn(Wn);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];
17
+ "use strict";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:()=>Je,computeOutlineClipOffset:()=>Wt,contactShadowPlugin:()=>at,decodeMeshoptBuffer:()=>et,decodeMeshoptGLB:()=>Ue,encodeMeshoptBuffer:()=>Ft,environmentMapPlugin:()=>Be,evaluateKawaseBloom:()=>Ht,extractMaterialVariants:()=>st,extractPrimitiveVariantMappings:()=>$t,getEnvironmentSH:()=>ht,getInteractivityVM:()=>_e,hotspotPlugin:()=>We,interactivityPlugin:()=>Qe,materialsPlugin:()=>Ze,meshoptDecoder:()=>ke,meshoptPlugin:()=>tt,parseHexRgb:()=>rt,parseSafeGltfPointer:()=>pe,postprocessingPlugin:()=>ot,registerMaterialShader:()=>Mt,selectMaterialVariant:()=>jt,sendInteractivityEvent:()=>qe,setEnvironmentSH:()=>ve,variantsPlugin:()=>ct,webxrPlugin:()=>lt});module.exports=nn(Wn);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],l=t[3],u=t[4],i=t[5],c=t[6],s=t[7],d=t[8],f=t[9],b=t[10],p=t[11],m=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*u+w*d+U*m,e[1]=v*o+S*i+w*f+U*x,e[2]=v*a+S*c+w*b+U*E,e[3]=v*l+S*s+w*p+U*I,v=n[4],S=n[5],w=n[6],U=n[7],e[4]=v*r+S*u+w*d+U*m,e[5]=v*o+S*i+w*f+U*x,e[6]=v*a+S*c+w*b+U*E,e[7]=v*l+S*s+w*p+U*I,v=n[8],S=n[9],w=n[10],U=n[11],e[8]=v*r+S*u+w*d+U*m,e[9]=v*o+S*i+w*f+U*x,e[10]=v*a+S*c+w*b+U*E,e[11]=v*l+S*s+w*p+U*I,v=n[12],S=n[13],w=n[14],U=n[15],e[12]=v*r+S*u+w*d+U*m,e[13]=v*o+S*i+w*f+U*x,e[14]=v*a+S*c+w*b+U*E,e[15]=v*l+S*s+w*p+U*I,e}function rn(e,t,n,r){let o=t[0],a=t[1],l=t[2],u=t[3],i=o+o,c=a+a,s=l+l,d=o*i,f=o*c,b=o*s,p=a*c,m=a*s,x=l*s,E=u*i,I=u*c,v=u*s,S=r[0],w=r[1],U=r[2];return e[0]=(1-(p+x))*S,e[1]=(f+v)*S,e[2]=(b-I)*S,e[3]=0,e[4]=(f-v)*w,e[5]=(1-(d+x))*w,e[6]=(m+E)*w,e[7]=0,e[8]=(b+I)*U,e[9]=(m-E)*U,e[10]=(1-(d+p))*U,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function fe(e,t,n=0){let r=t[0],o=t[1],a=t[2],l=t[4],u=t[5],i=t[6],c=t[8],s=t[9],d=t[10],f=d*u-i*s,b=-d*l+i*c,p=s*l-u*c,m=r*f+o*b+a*p;return!m||n>0&&(!Number.isFinite(m)||Math.abs(m)<=n)||(m=1/m,e[0]=f*m,e[1]=b*m,e[2]=p*m,e[3]=(-d*o+a*s)*m,e[4]=(d*r-a*c)*m,e[5]=(-s*r+o*c)*m,e[6]=(i*o-a*u)*m,e[7]=(-i*r+a*l)*m,e[8]=(u*r-o*l)*m),e}function mt(e,t){let n=t[0],r=t[1],o=t[2],a=t[3],l=t[4],u=t[5],i=t[6],c=t[7],s=t[8],d=t[9],f=t[10],b=t[11],p=t[12],m=t[13],x=t[14],E=t[15],I=n*u-r*l,v=n*i-o*l,S=n*c-a*l,w=r*i-o*u,U=r*c-a*u,V=o*c-a*i,O=s*m-d*p,N=s*x-f*p,P=s*E-b*p,C=d*x-f*m,z=d*E-b*m,W=f*E-b*x,B=I*W-v*z+S*C+w*P-U*N+V*O;return B?(B=1/B,e[0]=(u*W-i*z+c*C)*B,e[1]=(o*z-r*W-a*C)*B,e[2]=(m*V-x*U+E*w)*B,e[3]=(f*U-d*V-b*w)*B,e[4]=(i*P-l*W-c*N)*B,e[5]=(n*W-o*P+a*N)*B,e[6]=(x*S-p*V-E*v)*B,e[7]=(s*V-f*S+b*v)*B,e[8]=(l*z-u*P+c*O)*B,e[9]=(r*P-n*z-a*O)*B,e[10]=(p*U-m*S+E*I)*B,e[11]=(d*S-s*U-b*I)*B,e[12]=(u*N-l*C-i*O)*B,e[13]=(n*C-r*N+o*O)*B,e[14]=(m*v-p*w-x*I)*B,e[15]=(s*w-d*v+f*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 d of s.children)o.add(d);let a=new Set,l=128,u=(s,d,f=0)=>{if(f>l||s<0||s>=n||a.has(s))return;a.add(s);let b=e.nodes[s];if(!b)return;let p=le();if(t&&t[s])p.set(t[s]);else if(b.matrix&&b.matrix.length===16)p.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(p,E,x,I)}let m=r[s];if(d?ue(m,d,p):m.set(p),Array.isArray(b.children))for(let x of b.children)typeof x=="number"&&u(x,m,f+1)},i=[],c=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(c&&Array.isArray(c.nodes))i.push(...c.nodes);else for(let s=0;s<n;s++)o.has(s)||i.push(s);for(let s of i)u(s,null);for(let s=0;s<n;s++)!o.has(s)&&!i.includes(s)&&u(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 l=new Image;l.crossOrigin="anonymous",l.onload=()=>o(l),l.onerror=a,l.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 d=(p,m)=>{let x=t.createShader(p);return t.shaderSource(x,m),t.compileShader(x),x},f=t.createProgram();t.attachShader(f,d(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(f,d(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(f);let b=typeof t.createVertexArray=="function"?t.createVertexArray():null;a={program:f,vao:b},Fe.set(t,a)}let l=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 u=t.getUniformLocation(a.program,"uSkyboxMap");u&&t.uniform1i(u,0);let i=t.getUniformLocation(a.program,"uInvVP");i&&t.uniformMatrix4fv(i,!1,l);let c=t.getUniformLocation(a.program,"uCameraPos");c&&t.uniform3f(c,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];
20
20
  uniform int uHasSH;
21
21
  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
22
  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));}
@@ -29,15 +29,15 @@ envDiffuse=uHasSH==1?evalSHIrradiance(N):textureLod(uEnvironmentMap,equirectangu
29
29
  }else if(uHasSH==1){
30
30
  specularIBL=getStudioRadiance(R,roughness)*integrateBRDFApprox(F,roughness,NoV);
31
31
  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;
32
+ }`),{vs:n,fs:o}},onBeforeDrawPrimitive(e,t,n,r,o,a){let l=ze.get(e),u=e.getUniformLocation(t,"uHasSH");if(l&&l.length>=27){u&&e.uniform1i(u,1);let i=e.getUniformLocation(t,"uSH");i&&e.uniform3fv(i,l)}else u&&e.uniform1i(u,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],l=a.getAttribute("data-position");if(!l)continue;let u=l.trim().split(/\s+/).map(d=>parseFloat(d.replace(/m$/,"")));if(u.length<3||u.some(isNaN))continue;let i=a.getAttribute("data-normal"),c;if(i){let d=i.trim().split(/\s+/).map(f=>parseFloat(f));d.length>=3&&!d.some(isNaN)&&(c=[d[0],d[1],d[2]])}let s=n.projectPointToScreen([u[0],u[1],u[2]],c);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 re(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:re(t.radius,.01,50,.5),speed:re(t.speed,-20,20,.5),height:re(t.height,-10,10,0),phase:re(t.phase,-1e6,1e6,0),faceCenter:t.faceCenter===!0}}function $e(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 je(e){if(!e||typeof e=="number"&&!(e>0&&Number.isFinite(e)))return null;let t=e===!0?{}:typeof e=="number"?{strength:e}:Xe(e);if(!t||t.enabled===!1)return null;let n=re(t.strength??t.intensity,0,5,.35);return n>0?{enabled:!0,strength:n,threshold:re(t.threshold,0,4,.8),radius:re(t.radius,0,2,.5)}:null}function we(e){if(!e)return null;let t=e===!0?{}:typeof e=="string"?{color:e}:Xe(e);if(!t||t.enabled===!1)return null;let n=t.thickness??t.width;return{enabled:!0,color:$e(t.color,"#38bdf8"),thickness:re(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],l=t[2],u=t[3],i=n[0],c=n[1],s=n[2],d=n[3],f=o*i+a*c+l*s+u*d;if(f<0&&(i=-i,c=-c,s=-s,d=-d,f=-f),Math.abs(f)>=1)return e[0]=o,e[1]=a,e[2]=l,e[3]=u,e;let b=Math.acos(f),p=Math.sqrt(1-f*f);if(Math.abs(p)<.001)return e[0]=.5*(o+i),e[1]=.5*(a+c),e[2]=.5*(l+s),e[3]=.5*(u+d),e;let m=Math.sin((1-r)*b)/p,x=Math.sin(r*b)/p;return e[0]=o*m+i*x,e[1]=a*m+c*x,e[2]=l*m+s*x,e[3]=u*m+d*x,e}var xt=1024,Ke=256,Ee=2048,cn=128,ln=64,un=16,fn=1e4,dn=8,te=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},Se={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},Me=(e,t)=>e!==null&&typeof e=="object"&&!te.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)&&Me(e,"value")?e.value:e,j=(e,t)=>Me(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||te.has(r)||te.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},Ye=(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>Ke)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${Ke})`);let l=Array.isArray(r.declarations)?r.declarations:[],u=Array.isArray(r.events)?r.events:[],i=new Map,c=new Map,s=new Map,d=new Map,f=new Map,b=new Map,p=[],m=[],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"&&_&&!te.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"&&l[T.declaration]?.op||"",P=(T,A,R)=>{if(te.has(A))return;let _=c.get(T);_||c.set(T,_=Object.create(null)),_[A]=R},C=(T,A)=>{if(typeof T!="number"&&typeof T!="string"||typeof T=="string"&&te.has(T)||!i.has(T)&&i.size>=Ke*2)return;let R=Y(A);if(i.set(T,R),typeof T=="number"){let _=a[T]?.id??a[T]?.name;typeof _=="string"&&!te.has(_)&&i.set(_,R)}},z=T=>typeof T=="number"?u[T]?.id??String(T):typeof T=="string"?/^\d+$/.test(T)&&u[Number(T)]?.id?u[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=p.length-1;A>=0;A--)p[A].key===T&&p.splice(A,1)},oe=T=>{B(T.key),p.length>=cn&&p.shift(),p.push(T)},ne=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 Se){let g=Se[_],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 Se&&Array.isArray(A)){let y=Se[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(!Me(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",_):Me(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(c.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?ne(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 Ye(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 Ye(Ye(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<Ee&&R.push(g)};for(;R.length>0&&A.steps<Ee;){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),Ee);w++;try{for(let Oe=0;Oe<qt&&A.steps<Ee;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"){d.delete(h);break}let k=d.get(h);k||d.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"){f.delete(h);break}let k=Math.max(0,L(G("duration",0))),D=f.get(h);D===void 0||I-D>=k?(f.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=m.length-1;Q>=0;Q--)m[Q].nodeIdx===h&&m.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}m.length>=ln&&m.shift();let K=E++;P(h,"lastDelayIndex",K),m.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)m.length=0;else for(let D=m.length-1;D>=0;D--)m[D].id===k&&m.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")??ne(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||{}))te.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=ne,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))te.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 _=p.length-1;_>=0;_--){let g=p[_];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&&(p.splice(_,1),g.done&&R.push(g.done))}for(let _=m.length-1;_>=0;_--){let g=m[_];g.rem-=A,g.rem<=0&&(m.splice(_,1),g.done&&R.push(g.done))}for(let _ of R)se(_);Te()},this.dispose=()=>{p.length=0,m.length=0,i.clear(),c.clear(),s.clear(),d.clear(),f.clear(),b.clear()}}},J=new WeakMap,Re=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),l=(Re.get(e)||0)+a,u=!1;for(let i=0;i<o.length;i++){let c=o[i],s=yt(c?.extras?.xr?.orbit);if(!s)continue;let d=0,f=0,b=0;if(Array.isArray(s.target))d=s.target[0],f=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)&&(d=L(I.translation[0]),f=L(I.translation[1]),b=L(I.translation[2]))}let p=s.phase+s.speed*l,m=d+Math.cos(p)*s.radius,x=f+s.height,E=b+Math.sin(p)*s.radius;if(c.translation=[m,x,E],s.faceCenter){let I=Math.atan2(d-m,b-E);c.rotation=[0,Math.sin(I*.5),0,Math.cos(I*.5)]}u=!0}if(u){Re.set(e,l);let i=De(r);e.worldMatrices=i;for(let c of e.meshes||[])c.nodeIndex>=0&&c.nodeIndex<i.length&&(c.transform.set(i[c.nodeIndex]),fe(c.normalMatrix,c.transform))}}function _e(e){if(!(!e||typeof e!="object"))return J.get(e)||J.get(e.viewer)||J.get(e._view)}function qe(e,t,n){let r=_e(e);return r?(r.receiveCustomEvent(t,n),!0):!1}var Qe={name:"khr-interactivity",sendInteractivityEvent:qe,getInteractivityVM:_e,onLoadModel(e,t){if(!e||typeof e!="object")return;J.get(e)?.dispose(),J.delete(e),Re.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),Re.delete(t)}};var he=new Map,Ie=new WeakMap;function Mt(e,t){he.set(e,t)}var Ze={name:"materials",onContextRestored(e){Ie.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=Ie.get(e);n||(n=e.createTexture(),Ie.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 p=he.get(t.name);return{vs:p.vs||n,fs:p.fs||r}}let o=t.extensions||{},a=o.KHR_materials_clearcoat,l=o.KHR_materials_sheen,u=!!o.KHR_materials_transmission,i=!!o.KHR_materials_ior,c=o.KHR_materials_iridescence;if(!a&&!l&&!o.KHR_materials_unlit&&!u&&!o.KHR_materials_volume&&!i&&!o.KHR_materials_dispersion&&!c)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(u){let p=s.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
33
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);
34
+ ${p}out vec4 fragColor;`)}let d=(p,m,x=0,E=1e6,I=3)=>{let v=Number(p);return(Number.isFinite(v)?Math.min(E,Math.max(x,v)):m).toFixed(I)},f=Number(o.KHR_materials_ior?.ior??1.5),b=Number.isFinite(f)?Math.min(10,Math.max(1,f)):1.5;if(i){let p=Math.pow((b-1)/(b+1),2);s=s.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${d(p,.04,0,1,4)}),base.rgb,metallic);`)}if(c){let p=d(c.iridescenceFactor,1,0,1),m=d(c.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.*${m}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${p}*pow(1.-NoV,2.));`)}if(u){let p=d(o.KHR_materials_transmission?.transmissionFactor,1,0,1),m=o.KHR_materials_volume||{},x=d(m.thicknessFactor,.5,0,1e4),E=d(m.attenuationDistance,1,.001,1e6),I=Array.isArray(m.attenuationColor)?m.attenuationColor:[1,1,1],v=d(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=${d(b,1.5,1,10)},dV=${v},tV=${x},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
36
36
  vec3 refractedR=refract(-V,N,1./(iorB-.02*dV)),rG=refract(-V,N,1./iorB),refractedB=refract(-V,N,1./(iorB+.02*dV));
37
37
  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)});
38
+ vec3 aCol=vec3(${d(I[0],1,0,1)},${d(I[1],1,0,1)},${d(I[2],1,0,1)});
39
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
40
+ diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${p});`)}if(a&&!r.includes("uClearcoat")){let p=d(a.clearcoatFactor,1,0,1),m=d(a.clearcoatRoughnessFactor,0,0,1);s=s.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${m},NoV)*${p};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${m})*ccF;fragColor=vec4(color,base.a);`)}if(l){let p=Array.isArray(l.sheenColorFactor)?l.sheenColorFactor:[1,1,1],m=`color+=vec3(${d(p[0],1,0,1)},${d(p[1],1,0,1)},${d(p[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;s.includes("color=applyToneMapping(color,uToneMapping);")?s=s.replace("color=applyToneMapping(color,uToneMapping);",`${m}color=applyToneMapping(color,uToneMapping);`):s=s.replace("fragColor=vec4(color,base.a);",`${m}fragColor=vec4(color,base.a);`)}return{vs:n,fs:s}},onBeforeDrawPrimitive(e,t,n,r,o,a){let l=n.materialIndex;if(l!==void 0&&a?.materials){let u=a.materials[l];u?.name&&he.has(u.name)&&he.get(u.name).onBindUniforms?.(e,t,n)}if(n.isTransmissive){let u=Ie.get(e);if(u){e.activeTexture(33990),e.bindTexture(3553,u);let i=e.getUniformLocation(t,"uTransmissionTex");i&&e.uniform1i(i,6);let c=e.getUniformLocation(t,"uViewportSize");c&&e.uniform2f(c,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 Je(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 d=n===8,f=d?32767:127,b=x=>d?o.getInt16(x,!0):o.getInt8(x),p=(x,E)=>d?o.setInt16(x,E,!0):o.setInt8(x,E<<24>>24),m=d?2:1;for(let x=0;x<t;x++){let E=x*n,I=b(E),v=b(E+m),S=H(b(E+2*m)-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){p(E,0),p(E+m,0),p(E+2*m,f);continue}let V=H(f/U);p(E,me(H(I*V))),p(E+m,me(H(v*V))),p(E+2*m,me(H(S*V)))}return}if(r==="QUATERNION"){if(n!==8)throw X(`QUATERNION filter requires byteStride 8 (got ${n})`);let d=H(32767/H(Math.SQRT2));for(let f=0;f<t;f++){let b=f*8,p=o.getInt16(b+6,!0),m=p|3,x=o.getInt16(b,!0),E=o.getInt16(b+2,!0),I=o.getInt16(b+4,!0),v=H(m*m),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(d/m),V=p&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 d=t*n>>>2;for(let f=0;f<d;f++){let b=f*4,p=o.getUint32(b,!0),m=p<<8>>8,x=p>>24;o.setUint32(b,x+127<<23>>>0,!0);let E=o.getFloat32(b,!0);o.setFloat32(b,H(E*m),!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,l=a?65535:255,u=d=>a?o.getUint16(d,!0):o.getUint8(d),i=d=>a?o.getInt16(d,!0):o.getInt8(d),c=(d,f)=>a?o.setUint16(d,f&65535,!0):o.setUint8(d,f&255),s=a?2:1;for(let d=0;d<t;d++){let f=d*n,b=u(f+3*s);b|=b>>1,b|=b>>2,b|=b>>4,b|=b>>8;let p=u(f),m=i(f+s),x=i(f+2*s),E=p+m-x,I=p+x,v=p-m-x,S=u(f+3*s);S=S<<1&b|S&1;let w=b===0?0:H(l/b);c(f,Math.trunc(H(H(E*w)+.5))),c(f+s,Math.trunc(H(H(I*w)+.5))),c(f+2*s,Math.trunc(H(H(v*w)+.5))),c(f+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,l=8/o,u=t+ee*o/8;for(let i=0;i<ee;i++){let c=e[t+Math.floor(i/l)],s=i%l,d=o===1?c>>s&1:c>>8-o-s*o&a;n[r+i]=d===a?e[u++]:d}return u}function Lt(e,t,n,r,o,a,l,u){let i=a/ee,c=i+3>>2;if(n-t<c)throw X("truncated ATTRIBUTES stream");let s=t;t+=c;for(let d=0;d<i;d++){if(n-t<xn)throw X("truncated ATTRIBUTES stream");let f=e[s+(d>>2)]>>(d&3)*2&3;t=wn(e,t,r,o+d*ee,l[u+f])}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 l=a&15;if(l>1)throw X(`unsupported ATTRIBUTES codec version ${l}`);let u=n+(l===0?0:n/4),i=l===0?Nt:Tn,c=u<i?i:u;if(o-1<c)throw X("truncated ATTRIBUTES stream");let s=o-u,d=e.slice(s,s+n),f=s+n,b=Ct(n),p=new Uint8Array(256*4),m=1;for(let x=0;x<t;){let E=Math.min(b,t-x),I=E+ee-1&~(ee-1),v=l===0?0:n/4;if(o-m<v)throw X("truncated ATTRIBUTES stream");let S=m;m+=v;for(let w=0;w<n;w+=4){let U=l===0?0:e[S+w/4];for(let N=0;N<4;N++){let P=U>>N*2&3;if(P===3){if(o-m<E)throw X("truncated ATTRIBUTES stream");p.set(e.subarray(m,m+E),N*E),m+=E}else P===2?p.fill(0,N*E,N*E+E):m=l===0?Lt(e,m,o,p,N*E,I,An,0):Lt(e,m,o,p,N*E,I,vn,P)}let V=l===0?0:e[f+w/4],O=V&3;if(O===0)for(let N=0;N<4;N++){let P=d[w+N];for(let C=0;C<E;C++)P=hn(p[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=d[w+N]|d[w+N+1]<<8,C=N*E;for(let z=0;z<E;z++){let W=p[C+z]|p[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=(d[w]|d[w+1]<<8|d[w+2]<<16|d[w+3]<<24)>>>0;for(let C=0;C<E;C++){let z=(p[C]|p[E+C]<<8|p[2*E+C]<<16|p[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}`)}d.set(r.subarray((x+E-1)*n,(x+E)*n)),x+=E}if(o-m!==c)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 l=e[t.pos++]??0;if(r=(r|(l&127)<<o)>>>0,o+=7,l<128)break}return r>>>0}function Le(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 l=new Uint32Array(16).fill(4294967295),u=new Uint32Array(16).fill(4294967295),i=new Uint32Array(16).fill(4294967295),c=0,s=0,d=(U,V)=>{l[c]=U,u[c]=V,c=c+1&15},f=(U,V=1)=>{i[s]=U,s=s+V&15},b=0,p=0,m=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=c-1-O&15,P=l[N],C=u[N],z=0,W=V&15;if(W<m){let B=i[s-1-W&15];z=W===0?b:B;let oe=W===0?1:0;b=b+oe>>>0,f(z,oe)}else{if(v.pos>E)throw X("truncated TRIANGLES stream");z=W!==15?p+(W*2-27)>>>0:Le(e,v,p),p=z,f(z)}d(z,C),d(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],ne=P===0?b:oe,ie=P===0?1:0;b=b+ie>>>0,w(C,W,ne),f(C),f(W,B),f(ne,ie),d(W,C),d(ne,W),d(C,ne)}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&&(p=z=Le(e,v,p)),P===15&&(p=W=Le(e,v,p)),C===15&&(p=B=Le(e,v,p)),w(z,W,B),f(z),f(W,P===0||P===15?1:0),f(B,C===0||C===15?1:0),d(W,z),d(B,W),d(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,l=[0,0],u={pos:1};for(let i=0;i<t;i++){if(u.pos>=a)throw X("truncated INDICES stream");let c=Dt(e,u),s=c&1;c>>>=1;let d=c>>>1^-(c&1),f=l[s]+d>>>0;l[s]=f,n(i,f)}if(u.pos!==a)throw X("INDICES trailing data")}function et(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 l=new Uint8Array(a);if(r==="ATTRIBUTES")return En(e,t,n,l),Je(l,t,n,o),l;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 u=new DataView(l.buffer),i=n===2?(c,s)=>u.setUint16(c*2,s&65535,!0):(c,s)=>u.setUint32(c*4,s>>>0,!0);return r==="TRIANGLES"?Sn(e,t,i):Mn(e,t,i),l}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 u=[Pt],i=Ct(n),c=new Uint8Array(n);t>0&&c.set(e.subarray(0,n));let s=c.slice(),d=new Uint8Array(256);for(let f=0;f<t;){let b=Math.min(i,t-f),p=b+15&-16;for(let m=0;m<n;m++){d.fill(0);let x=c[m];for(let v=0;v<b;v++){let S=e[(f+v)*n+m];d[v]=gn(S-x&255),x=S}c[m]=x;let E=p/16,I=u.length;for(let v=0;v<E+3>>2;v++)u.push(0);for(let v=0;v<E;v++){let S=d.subarray(v*16,v*16+16);if(!S.every(w=>w===0)){u[I+(v>>2)]|=3<<(v&3)*2;for(let w of S)u.push(w)}}}f+=b}for(let f=n;f<Nt;f++)u.push(0);for(let f=0;f<n;f++)u.push(s[f]);return new Uint8Array(u)}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),l=u=>n===2?a.getUint16(u*2,!0):a.getUint32(u*4,!0);if(r==="INDICES"){let u=[Vt|1],i=0;for(let c=0;c<t;c++){let s=l(c),d=s-i|0;i=s,Ut(u,It(d)<<1>>>0)}return u.push(0,0,0,0),new Uint8Array(u)}if(r==="TRIANGLES"){if(t%3!==0)throw new Error(`encodeMeshoptBuffer: TRIANGLES count must be divisible by 3 (got ${t})`);let u=t/3,i=[Ot|1];for(let s=0;s<u;s++)i.push(255);let c=0;for(let s=0;s<u;s++){i.push(255);for(let d=0;d<3;d++){let f=l(s*3+d);Ut(i,It(f-c|0)),c=f}}for(let s=0;s<16;s++)i.push(0);return new Uint8Array(i)}throw new Error(`encodeMeshoptBuffer: unknown mode "${String(r)}"`)}function Ue(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=[],l=0;for(let d=0;d<r.bufferViews.length;d++){let f=r.bufferViews[d],b=f?.extensions?.KHR_meshopt_compression,p=b??f?.extensions?.EXT_meshopt_compression;if(!p||typeof p!="object")continue;let m=b?"KHR_meshopt_compression":"EXT_meshopt_compression",x=Number(p.count),E=Number(p.byteStride),I=Number(p.byteOffset??0),v=Number(p.byteLength??0),S=p.mode||"ATTRIBUTES",w=p.filter||"NONE";if(w==="COLOR"&&!b)throw X(`bufferView ${d} uses the COLOR filter, which requires KHR_meshopt_compression`);if(Number(p.buffer??0)!==0)throw new Error(`${m}: bufferView ${d} references buffer ${String(p.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(`${m}: bufferView ${d} compressed range [${I}, ${I+v}] out of bounds (${o.byteLength})`);let U=x*E;if(l+=U,l>_t)throw X(`total decompressed size (${l}) exceeds MAX_MESHOPT_TOTAL_BYTES (${_t})`);let V=o.subarray(I,I+v),O=et(V,x,E,S,w);a.push({index:d,bytes:O,ext:p})}if(a.length===0)return;let u=o.byteLength+3&-4,i=0;for(let d of a)i+=d.bytes.byteLength+3&-4;let c=new Uint8Array(u+i);c.set(o,0);let s=u;for(let d of a){c.set(d.bytes,s);let f=r.bufferViews[d.index];f.buffer=0,f.byteOffset=s,f.byteLength=d.bytes.byteLength,f._decoded=d.bytes,d.ext.mode==="ATTRIBUTES"&&f.byteStride===void 0&&(f.byteStride=Number(d.ext.byteStride)),f.extensions&&(delete f.extensions.EXT_meshopt_compression,delete f.extensions.KHR_meshopt_compression),s+=d.bytes.byteLength+3&-4}n.bin=c.buffer}var ke={decodeBufferViews(e,t){Ue(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",ke);var tt={name:"meshopt",onParseGLB(e){ce().decoders.set("meshopt",ke),Ue(e)}};function Pe(e,t,n,r=!0){let o=[],a=null;try{for(let[l,u]of[[35633,t],[35632,n]]){let i=e.createShader(l);if(!i){if(r)throw new Error("Shader allocation failed");return null}if(o.push(i),e.shaderSource(i,u),e.compileShader(i),e.getShaderParameter&&!e.getShaderParameter(i,35713)){if(r)throw new Error(`Shader compile error: ${e.getShaderInfoLog(i)}`);return null}}if(a=e.createProgram(),!a){if(r)throw new Error("Program allocation failed");return null}for(let l of o)e.attachShader(a,l);if(e.linkProgram(a),e.getProgramParameter&&!e.getProgramParameter(a,35714)){let l=r?e.getProgramInfoLog(a):null;if(e.deleteProgram?.(a),a=null,r)throw new Error(`Program link error: ${l}`);return null}return a}finally{for(let l of o)a&&e.detachShader?.(a,l),e.deleteShader?.(l)}}function nt(e,t){let n=e?.trim(),r=n?Number(n):NaN;return Number.isFinite(r)?r:t}var In=`#version 300 es
41
41
  layout(location=0) in vec3 aPosition;
42
42
  layout(location=1) in vec3 aNormal;
43
43
  uniform mat4 uMVP,uVP;
@@ -115,6 +115,6 @@ sum+=texture(uBloomTex,vUV+vec2(-d.x,-d.y)).rgb*2.0;
115
115
  vec3 bloom=(sum/12.0)*uStrength;
116
116
  float a=clamp(min(bloom.r,min(bloom.g,bloom.b)),0.0,1.0);
117
117
  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
118
+ }`,Ne=3,ye=new WeakMap;function rt(e,t=[.22,.74,.97]){let n=$e(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,l=+("0x"+r[2]+r[2])/255;return[o,a,l]}if(r.length===6){let o=+("0x"+r.slice(0,2))/255,a=+("0x"+r.slice(2,4))/255,l=+("0x"+r.slice(4,6))/255;return[o,a,l]}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),l=Math.max(0,Number(e[1])||0),u=Math.max(0,Number(e[2])||0),i=Math.max(a,l,u);if(i<=1e-6)return[0,0,0];let c=Number.isFinite(n)?Math.max(0,n):.8,s=Math.max(c*Math.max(0,r),1e-4),d=Math.max(0,Math.min(2*s,i-c+s)),f=d*d/(4*s+1e-4),p=Math.min(1,Math.max(0,Math.max(f,i-c)/Math.max(i,1e-4)))*o;return[a*p,l*p,u*p]}function Wt(e,t,n,r){let o=Number(e[0])||0,a=Number(e[1])||0,l=Math.hypot(o,a);if(l<=1e-5||t<=0||n<=0)return[0,0];let u=Math.max(1,Number(r[0])||1),i=Math.max(1,Number(r[1])||1),c=Math.max(0,n)*2*t;return[o/l*(c/u),a/l*(c/i)]}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=Pe(e,In,Ln,!1),r=Pe(e,zt,Un,!1),o=Pe(e,zt,kn,!1);if(!n||!r||!o){for(let l of[n,r,o])l&&e.deleteProgram(l);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 l=o,u=a;for(let i=0;i<Ne;i++)l=Math.max(1,l>>1),u=Math.max(1,u>>1),t.mipWidth[i]=l,t.mipHeight[i]=u,t.bloomTex[i]||(t.bloomTex[i]=e.createTexture()),e.bindTexture(3553,t.bloomTex[i]),e.texImage2D(3553,0,6408,l,u,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 l=je({strength:a,threshold:nt(t.getAttribute("bloom-threshold"),.62),radius:nt(t.getAttribute("bloom-radius"),.75)});if(l)return l}}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=je(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,l=!1;if(n&&r!=="true"){let u=n.split(/\s+/);for(let i of u)if(i.startsWith("#"))o=i;else if(i.toLowerCase()==="pulse")l=!0;else{let c=Number(i);Number.isFinite(c)&&c>0&&(a=c)}}return we({color:o,thickness:a,pulse:l})}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=we(o);if(a)return a;let l=typeof n?.getAttribute=="function"&&n.getAttribute("outline-color")||"#38bdf8",u=Cn(r,l),i=n!=null&&typeof n.hasAttribute=="function"&&n.hasAttribute("outline-selected")&&n.getAttribute("outline-selected")!=="false",c=e.getSelectedMesh?.()||"";if(c)return t.name!==c?null:u||(i?we({color:l,thickness:3,pulse:!1}):null);if(u){let s=t.name||"";return Vn(s)?null:u}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 f of t.meshes){if(f.visible===!1)continue;let b=Dn(t,f);b&&a.push({mesh:f,trait:b})}let l=a.length>0?Gt(e):null;if(l){let f=l,b=le(),p=le(),m=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(f.outlineProg),f.uOutlineViewportSize&&e.uniform2f(f.uOutlineViewportSize,I,v),f.uOutlineVP&&e.uniformMatrix4fv(f.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;f.uOutlineColor&&e.uniform4f(f.uOutlineColor,U,V,O,1),f.uOutlineThickness&&e.uniform1f(f.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(p,n,W),fe(m,W),e.uniformMatrix4fv(f.uOutlineMVP,!1,p),e.uniformMatrix3fv(f.uOutlineNormalMatrix,!1,m),C.indices?e.drawElements(4,C.indexCount,C.indexType,0):e.drawArrays(4,0,C.indexCount)}else ue(p,n,b),fe(m,b),e.uniformMatrix4fv(f.uOutlineMVP,!1,p),e.uniformMatrix3fv(f.uOutlineNormalMatrix,!1,m),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 u=Nn(t);if(!u||u.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 c=i.sceneTex,s=r,d=o;for(let f=0;f<Ne;f++){let b=i.mipWidth[f],p=i.mipHeight[f];e.bindFramebuffer(36160,i.bloomFbo[f]),e.viewport(0,0,b,p),e.bindTexture(3553,c),e.uniform2f(i.uDownTexelSize,1/s,1/d),e.uniform1f(i.uDownThreshold,f===0?u.threshold:0),e.drawArrays(4,0,3),c=i.bloomTex[f],s=b,d=p}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,u.radius);for(let f=Ne-1;f>=1;f--){let b=f-1;e.bindFramebuffer(36160,i.bloomFbo[b]),e.viewport(0,0,i.mipWidth[b],i.mipHeight[b]),e.bindTexture(3553,i.bloomTex[f]),e.uniform2f(i.uUpTexelSize,1/i.mipWidth[f],1/i.mipHeight[f]),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,u.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
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);
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,l,u]=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])*l+Math.abs(e[8])*u,Math.abs(e[1])*a+Math.abs(e[5])*l+Math.abs(e[9])*u,Math.abs(e[2])*a+Math.abs(e[6])*l+Math.abs(e[10])*u]}function Gn(e){if(e._lb!==void 0)return e._lb;let t=1e9,n=1e9,r=1e9,o=-1e9,a=-1e9,l=-1e9;for(let u of e.primitives||[]){let i=u.positions;if(i)for(let c=0;c<i.length;c+=3)i[c]<t&&(t=i[c]),i[c+1]<n&&(n=i[c+1]),i[c+2]<r&&(r=i[c+2]),i[c]>o&&(o=i[c]),i[c+1]>a&&(a=i[c+1]),i[c+2]>l&&(l=i[c+2])}return e._lb=t<=o?[(t+o)*.5,(n+a)*.5,(r+l)*.5,(o-t)*.5,(a-n)*.5,(l-r)*.5]:null}function Hn(e){let t=ge.get(e);if(t)return t;let n=(u,i)=>{let c=e.createShader(u);return e.shaderSource(c,i),e.compileShader(c),c},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(),l=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,l),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),t={prog:r,vao:o,vbo:a,ibo:l,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,l=[],u=[];for(let m of t.meshes||[]){if(!m||m.visible===!1||m.isPluginMesh||m.name==="__xr_reticle__"||m.name?.startsWith("__xr_slot_"))continue;let x=Gn(m);if(!x)continue;m.transform&&(x=it(m.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(m.name||"")||w<.14&&Math.min(S,U)>.45?u.push(V):l.push(V)}let i=[],c=t.bounds.center||[0,0,0],s=Math.max(.05,Number(t.bounds.radius)||.5),d=t.bounds.min,f=d?[c[0],c[1],c[2],s,Math.max(.01,c[1]-d[1]),s]:[c[0],c[1],c[2],s,s,s];t.modelRootMatrix&&(f=it(t.modelRootMatrix,f));let p=t.xrSessionActive&&u.length===0&&String(t.container?.tagName||"").toLowerCase()==="xr-live"?(t.modelRootMatrix?t.modelRootMatrix[5]*-.25+t.modelRootMatrix[13]:-.25)+.002:f[1]-f[4]+.002;for(let[m,x,E,I,v]of l){let S=-1/0;for(let[U,V,O,N,,P]of u)v>=P-.08&&Math.abs(m-U)<=O&&Math.abs(x-V)<=N&&P+.002>S&&(S=P+.002);a&&(S=Math.max(S,m>=.04&&m<=.36&&x>=-.34&&x<=-.04&&v>=.01?.036:Math.hypot(m,x)<=.66&&v>=-.06?.003:-.477)),isFinite(S)||(S=p);let w=i.find(U=>Math.hypot(m-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([m,x,E,I,v,S])}if(i.length===0){let m=Math.max(.1,f[3]*1.5)/1.45;i.push([f[0],f[2],m,m,p,p])}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[m,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([m-O,S,x-N,0,0,m+O,S,x-N,1,0,m+O,S,x+N,1,1,m-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,l=Number(a.material);if(!Number.isInteger(l)||l<0)continue;let u=[];if(Array.isArray(a.variants))for(let i of a.variants){let c=Number(i);Number.isInteger(c)&&c>=0&&u.push(c)}u.length>0&&r.push({material:l,variants:u})}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,l=Array.isArray(t)?t:[],u=n??null;if(!u)return r;let c=st(a).indexOf(u);if(c<0)return r;for(let s of l)if(s.variants.includes(c))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 l=a.primaryLightDirection,u=a.primaryLightIntensity;if(l&&u&&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=[l.x,l.y,l.z];let c=Math.max(u.x,u.y,u.z,.001);i.color=[u.x/c,u.y/c,u.z/c],i.intensity=c}a.sphericalHarmonicsCoefficients&&e.gl&&ve(e.gl,a.sphericalHarmonicsCoefficients)}}}};Z(at);Z(We);Z(Be);Z(Ze);Z(lt);Z(Qe);Z(tt);Z(ct);Z(ot);
@@ -169,6 +169,18 @@ export interface ThreeLiveAttributes {
169
169
  'shadow-softness'?: number | string;
170
170
  /** Tone mapping mode ("neutral", "aces", "agx", "reinhard", "none"). */
171
171
  'tone-mapping'?: string;
172
+ /** Dual-Kawase bloom intensity (0.0 to 5.0). */
173
+ 'bloom'?: number | string;
174
+ /** Luminance threshold for bloom extraction (default: 0.8). */
175
+ 'bloom-threshold'?: number | string;
176
+ /** Blur radius multiplier for bloom passes (default: 0.5). */
177
+ 'bloom-radius'?: number | string;
178
+ /** Declarative silhouette outline toggle or config. */
179
+ 'outline'?: boolean | string;
180
+ /** Highlight the currently `selected-mesh` with a silhouette outline. */
181
+ 'outline-selected'?: boolean | string;
182
+ /** Silhouette outline CSS hex color (default: "#38bdf8"). */
183
+ 'outline-color'?: string;
172
184
  /** Enable or disable interactive camera orbit/pan/zoom controls (default: true). */
173
185
  'camera-controls'?: boolean | string;
174
186
  /** Automatically start keyframe animation playback. */
@@ -210,6 +222,16 @@ export interface ThreeLiveAttributes {
210
222
  // React 19 / JSX Event Listeners
211
223
  onload?: (e: CustomEvent<{model: GLBData}>) => void;
212
224
  onerror?: (e: CustomEvent<{error: any}>) => void;
225
+ 'onthree-load'?: (
226
+ e: CustomEvent<{model: GLBData; source?: 'src' | 'model'}>,
227
+ ) => void;
228
+ 'onthree-error'?: (
229
+ e: CustomEvent<{error: any; message: string; stage: string}>,
230
+ ) => void;
231
+ 'onthree-context-lost'?: (e: CustomEvent<{originalEvent?: Event}>) => void;
232
+ 'onthree-context-restored'?: (
233
+ e: CustomEvent<{originalEvent?: Event}>,
234
+ ) => void;
213
235
  onmeshclick?: (e: CustomEvent<HitDetail>) => void;
214
236
  'oncamera-change'?: (e: CustomEvent<CameraDetail>) => void;
215
237
  'onvariant-applied'?: (e: CustomEvent<{variantName: string | null}>) => void;