three-live 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/three-author-engine.js +33 -33
- package/dist/three-author.cjs +22 -22
- package/dist/three-author.js +22 -22
- package/dist/three-live-cad.cjs +2 -2
- package/dist/three-live-cad.js +2 -2
- package/dist/three-live-cad.min.js +2 -2
- package/dist/three-live-full.cjs +52 -52
- package/dist/three-live-full.js +54 -54
- package/dist/three-live-full.min.js +52 -52
- package/dist/three-live-studio.cjs +14 -14
- package/dist/three-live-studio.js +12 -12
- package/dist/three-live-studio.min.js +14 -14
- package/dist/three-live.cjs +11 -11
- package/dist/three-live.js +13 -13
- package/dist/three-live.min.js +11 -11
- package/dist/three-xr.cjs +1 -1
- package/dist/three-xr.js +1 -1
- 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
|
|
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(
|
|
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(
|
|
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];
|
|
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 m=Be.get(e),c=e.getUniformLocation(t,"uHasSH");if(m&&m.length>=27){c&&e.uniform1i(c,1);let i=e.getUniformLocation(t,"uSH");i&&e.uniform3fv(i,m)}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 ze=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],m=a.getAttribute("data-position");if(!m)continue;let c=m.trim().split(/\s+/).map(f=>parseFloat(f.replace(/m$/,"")));if(c.length<3||c.some(isNaN))continue;let i=a.getAttribute("data-normal"),u;if(i){let f=i.trim().split(/\s+/).map(l=>parseFloat(l));f.length>=3&&!f.some(isNaN)&&(u=[f[0],f[1],f[2]])}let s=n.projectPointToScreen([c[0],c[1],c[2]],u);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"]}),ze.set(e,t)},onCameraChange(e,t){t&&He(t,e)},onElementDisconnected(e){let t=ze.get(e);t&&(t.disconnect(),ze.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 Ee(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 Me(e){if(!e)return null;if(typeof e=="string")return{enabled:!0,color:Ee(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:Ee(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 xt(e,t,n,r){let o=t[0],a=t[1],m=t[2],c=t[3],i=n[0],u=n[1],s=n[2],f=n[3],l=o*i+a*u+m*s+c*f;if(l<0&&(i=-i,u=-u,s=-s,f=-f,l=-l),Math.abs(l)>=1)return e[0]=o,e[1]=a,e[2]=m,e[3]=c,e;let b=Math.acos(l),d=Math.sqrt(1-l*l);if(Math.abs(d)<.001)return e[0]=.5*(o+i),e[1]=.5*(a+u),e[2]=.5*(m+s),e[3]=.5*(c+f),e;let p=Math.sin((1-r)*b)/d,g=Math.sin(r*b)/d;return e[0]=o*p+i*g,e[1]=a*p+u*g,e[2]=m*p+s*g,e[3]=c*p+f*g,e}var gt=1024,je=256,Re=2048,cn=128,un=64,ln=16,fn=1e4,mn=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},Se={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},we=(e,t)=>e!==null&&typeof e=="object"&&!ne.has(t)&&Object.prototype.hasOwnProperty.call(e,t),Y=e=>Array.isArray(e)?[...e]:e,Rt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&we(e,"value")?e.value:e,j=(e,t)=>we(e.configuration,t)?Rt(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 me=(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]},Et=(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 xt(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)),dn=(e,t)=>Array.isArray(e)?e.map(n=>t(L(n))):t(L(e)),Mt=(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>gt)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${gt})`);let a=Array.isArray(r.variables)?r.variables:[];if(a.length>je)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${je})`);let m=Array.isArray(r.declarations)?r.declarations:[],c=Array.isArray(r.events)?r.events:[],i=new Map,u=new Map,s=new Map,f=new Map,l=new Map,b=new Map,d=[],p=[],g=new Map,M=1,I=0,v=0,R=0,E=0,N=!1,O=!1,k=!1;a.forEach((T,A)=>{if(!T||typeof T!="object")return;let w=Y(Rt(T.value));i.set(A,w);let _=T.id??T.name;typeof _=="string"&&_&&!ne.has(_)&&i.set(_,w)}),(n?.nodes||[]).forEach((T,A)=>{for(let w of T?.children||[])typeof w=="number"&&g.set(w,A)});let C=T=>T.op||typeof T.declaration=="number"&&m[T.declaration]?.op||"",U=(T,A,w)=>{if(ne.has(A))return;let _=u.get(T);_||u.set(T,_=Object.create(null)),_[A]=w},V=(T,A)=>{if(typeof T!="number"&&typeof T!="string"||typeof T=="string"&&ne.has(T)||!i.has(T)&&i.size>=je*2)return;let w=Y(A);if(i.set(T,w),typeof T=="number"){let _=a[T]?.id??a[T]?.name;typeof _=="string"&&!ne.has(_)&&i.set(_,w)}},B=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 w=T,_=0;w!==void 0&&w>=0&&_<128;w=g.get(w),_++)if(w===A)return!0;return!1},G=T=>{for(let A=d.length-1;A>=0;A--)d[A].key===T&&d.splice(A,1)},oe=T=>{G(T.key),d.length>=cn&&d.shift(),d.push(T)},re=T=>{let A=pe(T)?.segments;if(A){if(A[0]==="nodes"&&Array.isArray(n?.nodes)){let w=n.nodes[me(A[1],n.nodes.length)];if(!w)return;let _=A[2];if(_ in Se){let x=Se[_],h=w[_]||x;return x.map((y,S)=>L(h[S],y))}if(_==="weights"){let x=Array.isArray(w.weights)?w.weights:[0],h=A.length===4?me(A[3],64):-2;return h===-2?x.map(y=>L(y)):h>=0?L(x[h]):void 0}if(_==="visible"||_==="extensions"&&A[3]==="KHR_node_visibility"&&A[4]==="visible")return w.extensions?.KHR_node_visibility?.visible??w.visible??!0}else if(A[0]==="materials"&&Array.isArray(n?.materials)){let w=n.materials[me(A[1],n.materials.length)];if(!w)return;let _=w.pbrMetallicRoughness||{};if(A[2]==="pbrMetallicRoughness"){if(A[3]==="baseColorFactor"){let x=_.baseColorFactor||[1,1,1,1];return[L(x[0],1),L(x[1],1),L(x[2],1),L(x[3],1)]}if(A[3]==="metallicFactor"||A[3]==="roughnessFactor")return L(_[A[3]],1)}if(A[2]==="emissiveFactor"){let x=w.emissiveFactor||[0,0,0];return[L(x[0]),L(x[1]),L(x[2])]}if(A[2]==="alphaCutoff")return L(w.alphaCutoff,.5)}}},ie=(T,A)=>{let w=pe(T)?.segments;if(!w)return!1;if(w[0]==="nodes"&&Array.isArray(n?.nodes)){let _=me(w[1],n.nodes.length),x=n.nodes[_];if(!x)return!1;let h=w[2];if(h in Se&&Array.isArray(A)){let y=Se[h];if(A.length<y.length)return!1;let S=y.map((z,$)=>L(A[$],z));if(h==="rotation"){let z=Math.hypot(...S);S=z>1e-8?S.map($=>$/z):[0,0,0,1]}x[h]=S,delete x.matrix;let D=t?.initialNodeTransforms?.[_];return D&&(D[h[0]]=[...S]),N=!0,!0}if(h==="weights"){Array.isArray(x.weights)||(x.weights=[]);let y=(S,D)=>{for(let z of t?.meshes||[])if(z.nodeIndex===_)for(let $ of z.primitives||[])$.pluginData?.morph?.weights&&($.pluginData.morph.weights[S]=D)};if(w.length===4){let S=me(w[3],64);if(S<0)return!1;y(S,x.weights[S]=L(A))}else if(Array.isArray(A))x.weights=A.slice(0,64).map(S=>L(S)),x.weights.forEach((S,D)=>y(D,S));else return!1;return k=!0,!0}if(h==="visible"||h==="extensions"&&w[3]==="KHR_node_visibility"&&w[4]==="visible"){let y=q(A);return x.visible=y,(!x.extensions||typeof x.extensions!="object")&&(x.extensions={}),x.extensions.KHR_node_visibility={visible:y},O=!0,!0}}else if(w[0]==="materials"&&Array.isArray(n?.materials)){let _=me(w[1],n.materials.length),x=n.materials[_];if(!x)return!1;let h=x.pbrMetallicRoughness||(x.pbrMetallicRoughness={}),y=S=>{for(let D of t?.meshes||[])for(let z of D.primitives||[])(z.materialIndex??0)===_&&S(z)};if(w[2]==="pbrMetallicRoughness"){if(w[3]==="baseColorFactor"&&Array.isArray(A)&&A.length>=3){let S=[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=S,y(D=>D.baseColor=[...S]),k=!0}if(w[3]==="metallicFactor"||w[3]==="roughnessFactor"){let S=w[3]==="metallicFactor",D=ae(L(A,S?0:.5));return h[w[3]]=D,y(z=>z[S?"metallic":"roughness"]=D),k=!0}}if(w[2]==="emissiveFactor"&&Array.isArray(A)&&A.length>=3)return x.emissiveFactor=[0,1,2].map(S=>Math.max(0,L(A[S]))),k=!0;if(w[2]==="alphaCutoff")return x.alphaCutoff=ae(L(A,.5)),k=!0}return!1},Ve=(T,A,w=new Set)=>{let _=j(A,"pointer");if(typeof _!="string"||!_.startsWith("/"))return null;let x=_.replace(/\{([a-zA-Z0-9_]+)\}/g,(h,y)=>{let S=Math.trunc(Number(ge(T,y,void 0,w)??j(A,y)));return Number.isSafeInteger(S)&&S>=0?String(S):"-1"});return pe(x)?x:null},ge=(T,A,w,_)=>{let x=o[T]?.values;if(!we(x,A))return w;let h=x[A];if(h==null)return w;if(typeof h!="object"||Array.isArray(h))return Y(h);let y=h;return typeof y.node=="number"?Yt(y.node,y.socket||"value",_):we(y,"value")?Y(y.value):w},Yt=(T,A,w)=>{if(T<0||T>=o.length||w.has(T)||w.size>128||++R>fn)return;let _=o[T],x=C(_);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(x))return Y(u.get(T)?.[A]);w.add(T);try{let h=(y,S=0)=>ge(T,y,S,w);if(x==="variable/get"){let y=j(_,"variable")??j(_,"id");return typeof y=="number"||typeof y=="string"?Y(i.get(y)):void 0}if(x==="pointer/get"){let y=Ve(T,_,w);return y?re(y):void 0}if(x.startsWith("math/")){let y=x.slice(5);if(y in Tt)return dn(h("a"),Tt[y]);if(y in At){let S=/^(mul|div|rem|mod|pow)$/.test(y)?1:0;return Ke(h("a",y==="mul"?1:0),h("b",S),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 Et(h("a",0),h("b",1),L(h("c",h("t",.5)),.5),y==="quatSlerp");if(y==="dot"){let S=h("a"),D=h("b");return Array.isArray(S)&&Array.isArray(D)?S.reduce((z,$,P)=>z+($||0)*(D[P]||0),0):L(S)*L(D)}if(y==="cross"){let S=h("a",[0,0,0]),D=h("b",[0,0,0]);return Array.isArray(S)&&Array.isArray(D)?[(S[1]||0)*(D[2]||0)-(S[2]||0)*(D[1]||0),(S[2]||0)*(D[0]||0)-(S[0]||0)*(D[2]||0),(S[0]||0)*(D[1]||0)-(S[1]||0)*(D[0]||0)]:[0,0,0]}if(y==="length"){let S=h("a");return Array.isArray(S)?Math.hypot(...S):Math.abs(L(S))}if(y==="distance"){let S=h("a"),D=h("b");return Array.isArray(S)&&Array.isArray(D)?Math.hypot(...S.map((z,$)=>(z||0)-(D[$]||0))):Math.abs(L(S)-L(D))}if(y==="normalize"){let S=h("a");if(!Array.isArray(S))return L(S)>=0?1:-1;let D=Math.hypot(...S);return D>1e-8?S.map(z=>z/D):S.map(()=>0)}if(y.startsWith("combine"))return["a","b","c","d"].slice(0,Number(y[7])||2).map(S=>L(h(S)));if(y.startsWith("extract")){let S=h("a");return Array.isArray(S)?S[A==="0"||A==="x"?0:A==="1"||A==="y"?1:A==="2"||A==="z"?2:3]??0:0}if(y==="eq")return Mt(h("a"),h("b"));if(y==="ne")return!Mt(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 S=Number(h("a"));return!Number.isFinite(S)&&!Number.isNaN(S)}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 x==="type/boolToInt"||x==="type/boolToFloat"?q(h("a",!1))?1:0:x==="type/intToBool"||x==="type/floatToBool"?L(h("a",0))!==0:x==="type/intToFloat"?L(h("a",0)):x==="type/floatToInt"?Math.trunc(L(h("a",0))):void 0}finally{w.delete(T)}},Te=()=>{if(N){N=!1,k=!0;let T=Fe(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(O){O=!1,k=!0;let T=n?.nodes;if(Array.isArray(t?.meshes)&&Array.isArray(T))for(let A of t.meshes){let w=!0;for(let _=A.nodeIndex,x=0;_!==void 0&&_>=0&&x<128;_=g.get(_),x++){let h=T[_];if(h?.visible===!1||h?.extensions?.KHR_node_visibility?.visible===!1){w=!1;break}}A.visible=w}}k&&(k=!1,t?.render?.())},se=(T,A={steps:0})=>{if(!T||typeof T.node!="number")return;A.steps===0&&(R=0);let w=[T],_=x=>{w.length+A.steps<Re&&w.push(x)};for(;w.length>0&&A.steps<Re;){A.steps++;let x=w.shift();if(!x||x.node<0||x.node>=o.length)continue;let h=x.node,y=o[h];if(!y)continue;let S=x.socket||"in",D=C(y),z=(P,F=void 0)=>ge(h,P,F,new Set),$=(P="out")=>{let F=y.flows?.[P];F&&_(F)};switch(D){case"flow/branch":$(q(z("condition",!1))?"true":"false");break;case"flow/sequence":for(let P of Object.keys(y.flows||{}).sort((F,K)=>Number(F)-Number(K)||F.localeCompare(K)))$(P);break;case"flow/switch":{let P=y.flows?.[String(z("selection",z("value",0)))]??y.flows?.default;P&&_(P);break}case"flow/for":{let P=Math.trunc(L(z("startIndex",0))),F=Math.trunc(L(z("endIndex",0))),K=Math.max(1,Math.trunc(L(z("step",1),1))),Q=y.flows?.body;if(Q&&F>P&&E<mn){let qt=Math.min(Math.ceil((F-P)/K),Re);E++;try{for(let ke=0;ke<qt&&A.steps<Re;ke++)U(h,"index",P+ke*K),se(Q,A)}finally{E--}}let ft=y.flows?.completed??y.flows?.out;ft&&_(ft);break}case"flow/doN":{let P=S==="reset"?0:(s.get(h)||0)+1;if(s.set(h,P),U(h,"currentCount",P),U(h,"count",P),S!=="reset"){let F=Math.trunc(L(z("n",j(y,"stopIterations")??j(y,"n")??1),1));P<=F&&$()}break}case"flow/multiGate":{if(S==="reset"){b.set(h,0);break}let P=Object.keys(y.flows||{}).sort();if(!P.length)break;let F=j(y,"isRandom")?Math.floor(Math.random()*P.length):b.get(h)||0;F<P.length&&($(P[F]),b.set(h,j(y,"isLoop")!==!1?(F+1)%P.length:F+1));break}case"flow/waitAll":{if(S==="reset"){f.delete(h);break}let P=f.get(h);P||f.set(h,P=new Set),P.add(S),P.size>=Math.max(1,Math.trunc(Number(j(y,"inputFlows")??2)||2))&&(P.clear(),$("out"),$("completed"));break}case"flow/throttle":{if(S==="reset"){l.delete(h);break}let P=Math.max(0,L(z("duration",0))),F=l.get(h);F===void 0||I-F>=P?(l.set(h,I),U(h,"lastRemainingTime",0),$()):U(h,"lastRemainingTime",Math.max(0,P-(I-F)));break}case"flow/delay":case"flow/setDelay":{if(S==="cancel"){for(let Q=p.length-1;Q>=0;Q--)p[Q].nodeIdx===h&&p.splice(Q,1);U(h,"lastDelayIndex",-1);break}let P=Math.max(0,L(z("duration",j(y,"duration")??0))),F=y.flows?.done??y.flows?.out;if(P<=0){U(h,"lastDelayIndex",-1),F&&_(F);break}p.length>=un&&p.shift();let K=M++;U(h,"lastDelayIndex",K),p.push({id:K,nodeIdx:h,rem:P,done:F}),D==="flow/setDelay"&&y.flows?.out&&y.flows?.done&&$("out");break}case"flow/cancelDelay":{let P=Math.trunc(L(z("delayIndex",-1),-1));if(P<0)p.length=0;else for(let F=p.length-1;F>=0;F--)p[F].id===P&&p.splice(F,1);$();break}case"variable/set":V(j(y,"variable")??j(y,"id"),z("value")),$();break;case"variable/interpolate":{let P=j(y,"variable")??j(y,"id"),F=z("value",z("target")),K=Math.max(0,L(z("duration",j(y,"duration")??.3),.3));P!==void 0&&F!==void 0&&oe({key:`var:${String(P)}`,varKey:P,from:Y(z("from")??i.get(P)??0),to:Y(F),dur:K,elapsed:0,quat:!1,linear:j(y,"easing")==="linear",done:y.flows?.done}),$();break}case"pointer/set":{let P=Ve(h,y),F=z("value");P&&F!==void 0&&(G(`ptr:${P}`),ie(P,F)),$();break}case"pointer/interpolate":{let P=Ve(h,y),F=z("value",z("target")),K=Math.max(0,L(z("duration",j(y,"duration")??.3),.3));if(P&&F!==void 0){let Q=z("from")??re(P);Q!==void 0&&(K<=0?(ie(P,F),$("done")):oe({key:`ptr:${P}`,ptr:P,from:Y(Q),to:Y(F),dur:K,elapsed:0,quat:P.endsWith("/rotation"),linear:j(y,"easing")==="linear",done:y.flows?.done}))}$();break}case"animation/start":{let P=z("animation")??j(y,"animation")??j(y,"clipName"),F=typeof P=="number"?t?.animations?.[P]?.name??n?.animations?.[P]?.name:typeof P=="string"?P:void 0;t?.playAnimation?.(F),k=!0,$();break}case"animation/stop":case"animation/resetAt":t?.pauseAnimation?.(),D==="animation/resetAt"&&t?.evaluateAnimation?.(L(z("time",0))),k=!0,$();break;case"event/send":case"customEvent/send":{let P=B(j(y,"event")??j(y,"id")),F={};for(let K of Object.keys(y.values||{}))ne.has(K)||(F[K]=z(K));P&&(typeof CustomEvent<"u"&&typeof t?.container?.dispatchEvent=="function"&&t.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:P,values:F}})),lt(P,F,A)),$();break}default:$();break}}};this.readScenePointer=re,this.writeScenePointer=ie,this.fireOnStart=()=>{o.forEach(T=>{C(T)==="event/onStart"&&se(T.flows?.out)}),Te()},this.fireOnSelect=T=>{if(!T)return;let A=typeof T.meshIndex=="number"?T.meshIndex:-1,w=typeof T.nodeIndex=="number"?T.nodeIndex:t?.meshes?.[A]?.nodeIndex??-1;o.forEach((_,x)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(C(_)))return;let h=j(_,"nodeIndex")??j(_,"node")??ge(x,"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(w,Math.trunc(Number(h)))){if(U(x,"nodeIndex",w),U(x,"meshIndex",A),Array.isArray(T.hitPoint)){let D=[L(T.hitPoint[0]),L(T.hitPoint[1]),L(T.hitPoint[2])];U(x,"hitPoint",D),U(x,"point",D),U(x,"intersectionPoint",D)}if(Array.isArray(T.normal)){let D=[L(T.normal[0]),L(T.normal[1],1),L(T.normal[2])];U(x,"normal",D),U(x,"hitNormal",D)}typeof T.distance=="number"&&U(x,"distance",T.distance),se(_.flows?.out)}}),Te()},this.receiveCustomEvent=(T,A={})=>lt(T,A,{steps:0});function lt(T,A,w){if(!(v>=ln)){v++;try{let _=B(T);o.forEach((x,h)=>{if(!/^(customE|e)vent\/receive$/.test(C(x)))return;let y=j(x,"event")??j(x,"id");if(!(B(y)!==_&&String(y)!==String(T))){for(let[S,D]of Object.entries(A))ne.has(S)||U(h,S,Y(D));se(x.flows?.out,w)}}),Te()}finally{v--}}}this.tick=T=>{if(!Number.isFinite(T)||T<0)return;let A=Math.min(T,.25);I+=A,o.forEach((_,x)=>{C(_)==="event/onTick"&&(U(x,"timeDelta",A),U(x,"dt",A),U(x,"timeElapsed",I),se(_.flows?.out))});let w=[];for(let _=d.length-1;_>=0;_--){let x=d[_];x.elapsed+=A;let h=x.dur>1e-6?ae(x.elapsed/x.dur):1,y=x.linear?h:h*h*(3-2*h),S=Et(x.from,x.to,y,x.quat);x.ptr?ie(x.ptr,S):x.varKey!==void 0&&V(x.varKey,S),h>=1&&(d.splice(_,1),x.done&&w.push(x.done))}for(let _=p.length-1;_>=0;_--){let x=p[_];x.rem-=A,x.rem<=0&&(p.splice(_,1),x.done&&w.push(x.done))}for(let _ of w)se(_);Te()},this.dispose=()=>{d.length=0,p.length=0,i.clear(),u.clear(),s.clear(),f.clear(),l.clear(),b.clear()}}},J=new WeakMap,_e=new WeakMap;function pn(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||mt().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),m=(_e.get(e)||0)+a,c=!1;for(let i=0;i<o.length;i++){let u=o[i],s=yt(u?.extras?.xr?.orbit);if(!s)continue;let f=0,l=0,b=0;if(Array.isArray(s.target))f=s.target[0],l=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]),l=L(I.translation[1]),b=L(I.translation[2]))}let d=s.phase+s.speed*m,p=f+Math.cos(d)*s.radius,g=l+s.height,M=b+Math.sin(d)*s.radius;if(u.translation=[p,g,M],s.faceCenter){let I=Math.atan2(f-p,b-M);u.rotation=[0,Math.sin(I*.5),0,Math.cos(I*.5)]}c=!0}if(c){_e.set(e,m);let i=Fe(r);e.worldMatrices=i;for(let u of e.meshes||[])u.nodeIndex>=0&&u.nodeIndex<i.length&&(u.transform.set(i[u.nodeIndex]),fe(u.normalMatrix,u.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 St(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 d=he.get(t.name);return{vs:d.vs||n,fs:d.fs||r}}let o=t.extensions||{},a=o.KHR_materials_clearcoat,m=o.KHR_materials_sheen,c=!!o.KHR_materials_transmission,i=!!o.KHR_materials_ior,u=o.KHR_materials_iridescence;if(!a&&!m&&!o.KHR_materials_unlit&&!c&&!o.KHR_materials_volume&&!i&&!o.KHR_materials_dispersion&&!u)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 d=s.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
|
|
32
|
+
}`),{vs:n,fs:o}},onBeforeDrawPrimitive(e,t,n,r,o,a){let d=ze.get(e),c=e.getUniformLocation(t,"uHasSH");if(d&&d.length>=27){c&&e.uniform1i(c,1);let i=e.getUniformLocation(t,"uSH");i&&e.uniform3fv(i,d)}else c&&e.uniform1i(c,0)},onAttributeChanged(e,t,n,r){t==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,r):t==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,r)}};var Ge=new WeakMap;function He(e,t){let n=t||e.viewer;if(!n||typeof n.projectPointToScreen!="function")return;let r=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let o=0;o<r.length;o++){let a=r[o],d=a.getAttribute("data-position");if(!d)continue;let c=d.trim().split(/\s+/).map(f=>parseFloat(f.replace(/m$/,"")));if(c.length<3||c.some(isNaN))continue;let i=a.getAttribute("data-normal"),l;if(i){let f=i.trim().split(/\s+/).map(u=>parseFloat(u));f.length>=3&&!f.some(isNaN)&&(l=[f[0],f[1],f[2]])}let s=n.projectPointToScreen([c[0],c[1],c[2]],l);a.style.position="absolute",a.style.left="0",a.style.top="0",a.style.transform=`translate(-50%, -50%) translate3d(${s.x}px, ${s.y}px, 0)`,a.style.zIndex="3",s.visible?(a.style.opacity="1",a.style.pointerEvents="auto",a.removeAttribute("data-occluded")):(a.style.opacity="0",a.style.pointerEvents="none",a.setAttribute("data-occluded",""))}}var We={name:"hotspots",updateHotspotsForElement:He,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let t=new MutationObserver(()=>{He(e)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),Ge.set(e,t)},onCameraChange(e,t){t&&He(t,e)},onElementDisconnected(e){let t=Ge.get(e);t&&(t.disconnect(),Ge.delete(e))}};function te(e,t,n,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(t,Math.min(n,o))}function an(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function Xe(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function sn(e,t=256){return typeof e=="string"&&e.length>0?e.slice(0,t):void 0}function yt(e){let t=Xe(e);if(!t)return null;let n=t.target;return{target:an(n)?[n[0],n[1],n[2]]:typeof n=="string"&&n.length>0&&n.length<=256?n:[0,0,0],radius:te(t.radius,.01,50,.5),speed:te(t.speed,-20,20,.5),height:te(t.height,-10,10,0),phase:te(t.phase,-1e6,1e6,0),faceCenter:t.faceCenter===!0}}function we(e,t){let n=sn(e,16)?.trim();if(!n)return t;let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n);return r?`#${r[1].toLowerCase()}`:t}function $e(e){if(e===!1||e===null||e===void 0)return null;if(typeof e=="number")return!Number.isFinite(e)||e<=0?null:{enabled:!0,strength:te(e,0,5,.35),threshold:.8,radius:.5};if(e===!0)return{enabled:!0,strength:.35,threshold:.8,radius:.5};let t=Xe(e);if(!t||t.enabled===!1)return null;let n=te(t.strength??t.intensity,0,5,.35);return n<=0?null:{enabled:!0,strength:n,threshold:te(t.threshold,0,4,.8),radius:te(t.radius,0,2,.5)}}function Ee(e){if(!e)return null;if(typeof e=="string")return{enabled:!0,color:we(e,"#38bdf8"),thickness:3,pulse:!1};if(e===!0)return{enabled:!0,color:"#38bdf8",thickness:3,pulse:!1};let t=Xe(e);if(!t||t.enabled===!1)return null;let n=t.thickness??t.width;return{enabled:!0,color:we(t.color,"#38bdf8"),thickness:te(typeof n=="number"&&n>0&&n<.25?Math.max(1.5,n*140):n,.5,20,3),pulse:t.pulse===!0}}function gt(e,t,n,r){let o=t[0],a=t[1],d=t[2],c=t[3],i=n[0],l=n[1],s=n[2],f=n[3],u=o*i+a*l+d*s+c*f;if(u<0&&(i=-i,l=-l,s=-s,f=-f,u=-u),Math.abs(u)>=1)return e[0]=o,e[1]=a,e[2]=d,e[3]=c,e;let b=Math.acos(u),m=Math.sqrt(1-u*u);if(Math.abs(m)<.001)return e[0]=.5*(o+i),e[1]=.5*(a+l),e[2]=.5*(d+s),e[3]=.5*(c+f),e;let p=Math.sin((1-r)*b)/m,x=Math.sin(r*b)/m;return e[0]=o*p+i*x,e[1]=a*p+l*x,e[2]=d*p+s*x,e[3]=c*p+f*x,e}var xt=1024,je=256,Se=2048,cn=128,ln=64,un=16,fn=1e4,dn=8,ne=new Set(["__proto__","constructor","prototype"]),Tt={neg:e=>-e,abs:Math.abs,sign:Math.sign,floor:Math.floor,ceil:Math.ceil,round:Math.round,trunc:Math.trunc,fract:e=>e-Math.floor(e),sqrt:e=>Math.sqrt(Math.max(0,e)),cbrt:Math.cbrt,exp:Math.exp,log:e=>e>0?Math.log(e):0,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:e=>Math.asin(Math.max(-1,Math.min(1,e))),acos:e=>Math.acos(Math.max(-1,Math.min(1,e))),atan:Math.atan,rad:e=>e*Math.PI/180,deg:e=>e*180/Math.PI,saturate:e=>Math.max(0,Math.min(1,e))},At={add:(e,t)=>e+t,sub:(e,t)=>e-t,mul:(e,t)=>e*t,div:(e,t)=>Math.abs(t)<1e-12?0:e/t,rem:(e,t)=>Math.abs(t)<1e-12?0:e%t,mod:(e,t)=>Math.abs(t)<1e-12?0:e%t,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},Me={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},Re=(e,t)=>e!==null&&typeof e=="object"&&!ne.has(t)&&Object.prototype.hasOwnProperty.call(e,t),Y=e=>Array.isArray(e)?[...e]:e,St=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&Re(e,"value")?e.value:e,j=(e,t)=>Re(e.configuration,t)?St(e.configuration[t]):void 0,L=(e,t=0)=>{let n=Number(e);return Number.isFinite(n)?n:t},ae=e=>Math.max(0,Math.min(1,e)),q=e=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!Number.isNaN(e):typeof e=="string"?e.length>0&&e!=="false":!!e;function pe(e){if(typeof e!="string"||!e.startsWith("/"))return null;let t=[];for(let n of e.slice(1).split("/")){let r=n.replace(/~1/g,"/").replace(/~0/g,"~");if(!r||ne.has(r)||ne.has(n))return null;t.push(r)}return{segments:t}}var de=(e,t)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let n=Number(e);return Number.isSafeInteger(n)&&n>=0&&n<t?n:-1},vt=e=>{let t=L(e[0]),n=L(e[1]),r=L(e[2]),o=L(e[3],1),a=Math.hypot(t,n,r,o);return a>1e-8?[t/a,n/a,r/a,o/a]:[0,0,0,1]},wt=(e,t,n,r)=>{if(typeof e=="number"&&typeof t=="number")return e+(t-e)*n;if(Array.isArray(e)&&Array.isArray(t)){if(r&&e.length===4&&t.length===4){let o=[0,0,0,1];return gt(o,vt(e),vt(t),n),o}return e.slice(0,t.length).map((o,a)=>o+(t[a]-o)*n)}return n>=.5?t:e},Ke=(e,t,n)=>Array.isArray(e)&&Array.isArray(t)?e.slice(0,t.length).map((r,o)=>n(L(r),L(t[o]))):Array.isArray(e)?e.map(r=>n(L(r),L(t))):Array.isArray(t)?t.map(r=>n(L(e),L(r))):n(L(e),L(t)),mn=(e,t)=>Array.isArray(e)?e.map(n=>t(L(n))):t(L(e)),Et=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>Math.abs(n-t[r])<=1e-6):e===t,be=class{constructor(t,n,r){let o=Array.isArray(r.nodes)?r.nodes:[];if(o.length>xt)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${xt})`);let a=Array.isArray(r.variables)?r.variables:[];if(a.length>je)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${je})`);let d=Array.isArray(r.declarations)?r.declarations:[],c=Array.isArray(r.events)?r.events:[],i=new Map,l=new Map,s=new Map,f=new Map,u=new Map,b=new Map,m=[],p=[],x=new Map,E=1,I=0,v=0,S=0,w=0,U=!1,V=!1,O=!1;a.forEach((T,A)=>{if(!T||typeof T!="object")return;let R=Y(St(T.value));i.set(A,R);let _=T.id??T.name;typeof _=="string"&&_&&!ne.has(_)&&i.set(_,R)}),(n?.nodes||[]).forEach((T,A)=>{for(let R of T?.children||[])typeof R=="number"&&x.set(R,A)});let N=T=>T.op||typeof T.declaration=="number"&&d[T.declaration]?.op||"",P=(T,A,R)=>{if(ne.has(A))return;let _=l.get(T);_||l.set(T,_=Object.create(null)),_[A]=R},C=(T,A)=>{if(typeof T!="number"&&typeof T!="string"||typeof T=="string"&&ne.has(T)||!i.has(T)&&i.size>=je*2)return;let R=Y(A);if(i.set(T,R),typeof T=="number"){let _=a[T]?.id??a[T]?.name;typeof _=="string"&&!ne.has(_)&&i.set(_,R)}},z=T=>typeof T=="number"?c[T]?.id??String(T):typeof T=="string"?/^\d+$/.test(T)&&c[Number(T)]?.id?c[Number(T)].id:T:"",W=(T,A)=>{for(let R=T,_=0;R!==void 0&&R>=0&&_<128;R=x.get(R),_++)if(R===A)return!0;return!1},B=T=>{for(let A=m.length-1;A>=0;A--)m[A].key===T&&m.splice(A,1)},oe=T=>{B(T.key),m.length>=cn&&m.shift(),m.push(T)},re=T=>{let A=pe(T)?.segments;if(A){if(A[0]==="nodes"&&Array.isArray(n?.nodes)){let R=n.nodes[de(A[1],n.nodes.length)];if(!R)return;let _=A[2];if(_ in Me){let g=Me[_],h=R[_]||g;return g.map((y,M)=>L(h[M],y))}if(_==="weights"){let g=Array.isArray(R.weights)?R.weights:[0],h=A.length===4?de(A[3],64):-2;return h===-2?g.map(y=>L(y)):h>=0?L(g[h]):void 0}if(_==="visible"||_==="extensions"&&A[3]==="KHR_node_visibility"&&A[4]==="visible")return R.extensions?.KHR_node_visibility?.visible??R.visible??!0}else if(A[0]==="materials"&&Array.isArray(n?.materials)){let R=n.materials[de(A[1],n.materials.length)];if(!R)return;let _=R.pbrMetallicRoughness||{};if(A[2]==="pbrMetallicRoughness"){if(A[3]==="baseColorFactor"){let g=_.baseColorFactor||[1,1,1,1];return[L(g[0],1),L(g[1],1),L(g[2],1),L(g[3],1)]}if(A[3]==="metallicFactor"||A[3]==="roughnessFactor")return L(_[A[3]],1)}if(A[2]==="emissiveFactor"){let g=R.emissiveFactor||[0,0,0];return[L(g[0]),L(g[1]),L(g[2])]}if(A[2]==="alphaCutoff")return L(R.alphaCutoff,.5)}}},ie=(T,A)=>{let R=pe(T)?.segments;if(!R)return!1;if(R[0]==="nodes"&&Array.isArray(n?.nodes)){let _=de(R[1],n.nodes.length),g=n.nodes[_];if(!g)return!1;let h=R[2];if(h in Me&&Array.isArray(A)){let y=Me[h];if(A.length<y.length)return!1;let M=y.map((G,$)=>L(A[$],G));if(h==="rotation"){let G=Math.hypot(...M);M=G>1e-8?M.map($=>$/G):[0,0,0,1]}g[h]=M,delete g.matrix;let F=t?.initialNodeTransforms?.[_];return F&&(F[h[0]]=[...M]),U=!0,!0}if(h==="weights"){Array.isArray(g.weights)||(g.weights=[]);let y=(M,F)=>{for(let G of t?.meshes||[])if(G.nodeIndex===_)for(let $ of G.primitives||[])$.pluginData?.morph?.weights&&($.pluginData.morph.weights[M]=F)};if(R.length===4){let M=de(R[3],64);if(M<0)return!1;y(M,g.weights[M]=L(A))}else if(Array.isArray(A))g.weights=A.slice(0,64).map(M=>L(M)),g.weights.forEach((M,F)=>y(F,M));else return!1;return O=!0,!0}if(h==="visible"||h==="extensions"&&R[3]==="KHR_node_visibility"&&R[4]==="visible"){let y=q(A);return g.visible=y,(!g.extensions||typeof g.extensions!="object")&&(g.extensions={}),g.extensions.KHR_node_visibility={visible:y},V=!0,!0}}else if(R[0]==="materials"&&Array.isArray(n?.materials)){let _=de(R[1],n.materials.length),g=n.materials[_];if(!g)return!1;let h=g.pbrMetallicRoughness||(g.pbrMetallicRoughness={}),y=M=>{for(let F of t?.meshes||[])for(let G of F.primitives||[])(G.materialIndex??0)===_&&M(G)};if(R[2]==="pbrMetallicRoughness"){if(R[3]==="baseColorFactor"&&Array.isArray(A)&&A.length>=3){let M=[ae(L(A[0],1)),ae(L(A[1],1)),ae(L(A[2],1)),A[3]!==void 0?ae(L(A[3],1)):h.baseColorFactor?.[3]??1];return h.baseColorFactor=M,y(F=>F.baseColor=[...M]),O=!0}if(R[3]==="metallicFactor"||R[3]==="roughnessFactor"){let M=R[3]==="metallicFactor",F=ae(L(A,M?0:.5));return h[R[3]]=F,y(G=>G[M?"metallic":"roughness"]=F),O=!0}}if(R[2]==="emissiveFactor"&&Array.isArray(A)&&A.length>=3)return g.emissiveFactor=[0,1,2].map(M=>Math.max(0,L(A[M]))),O=!0;if(R[2]==="alphaCutoff")return g.alphaCutoff=ae(L(A,.5)),O=!0}return!1},Ce=(T,A,R=new Set)=>{let _=j(A,"pointer");if(typeof _!="string"||!_.startsWith("/"))return null;let g=_.replace(/\{([a-zA-Z0-9_]+)\}/g,(h,y)=>{let M=Math.trunc(Number(xe(T,y,void 0,R)??j(A,y)));return Number.isSafeInteger(M)&&M>=0?String(M):"-1"});return pe(g)?g:null},xe=(T,A,R,_)=>{let g=o[T]?.values;if(!Re(g,A))return R;let h=g[A];if(h==null)return R;if(typeof h!="object"||Array.isArray(h))return Y(h);let y=h;return typeof y.node=="number"?Yt(y.node,y.socket||"value",_):Re(y,"value")?Y(y.value):R},Yt=(T,A,R)=>{if(T<0||T>=o.length||R.has(T)||R.size>128||++S>fn)return;let _=o[T],g=N(_);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(g))return Y(l.get(T)?.[A]);R.add(T);try{let h=(y,M=0)=>xe(T,y,M,R);if(g==="variable/get"){let y=j(_,"variable")??j(_,"id");return typeof y=="number"||typeof y=="string"?Y(i.get(y)):void 0}if(g==="pointer/get"){let y=Ce(T,_,R);return y?re(y):void 0}if(g.startsWith("math/")){let y=g.slice(5);if(y in Tt)return mn(h("a"),Tt[y]);if(y in At){let M=/^(mul|div|rem|mod|pow)$/.test(y)?1:0;return Ke(h("a",y==="mul"?1:0),h("b",M),At[y])}if(y==="pi")return Math.PI;if(y==="e")return Math.E;if(y==="random")return Math.random();if(y==="clamp")return Ke(Ke(h("a"),h("b",h("min",0)),Math.max),h("c",h("max",1)),Math.min);if(y==="mix"||y==="quatSlerp")return wt(h("a",0),h("b",1),L(h("c",h("t",.5)),.5),y==="quatSlerp");if(y==="dot"){let M=h("a"),F=h("b");return Array.isArray(M)&&Array.isArray(F)?M.reduce((G,$,k)=>G+($||0)*(F[k]||0),0):L(M)*L(F)}if(y==="cross"){let M=h("a",[0,0,0]),F=h("b",[0,0,0]);return Array.isArray(M)&&Array.isArray(F)?[(M[1]||0)*(F[2]||0)-(M[2]||0)*(F[1]||0),(M[2]||0)*(F[0]||0)-(M[0]||0)*(F[2]||0),(M[0]||0)*(F[1]||0)-(M[1]||0)*(F[0]||0)]:[0,0,0]}if(y==="length"){let M=h("a");return Array.isArray(M)?Math.hypot(...M):Math.abs(L(M))}if(y==="distance"){let M=h("a"),F=h("b");return Array.isArray(M)&&Array.isArray(F)?Math.hypot(...M.map((G,$)=>(G||0)-(F[$]||0))):Math.abs(L(M)-L(F))}if(y==="normalize"){let M=h("a");if(!Array.isArray(M))return L(M)>=0?1:-1;let F=Math.hypot(...M);return F>1e-8?M.map(G=>G/F):M.map(()=>0)}if(y.startsWith("combine"))return["a","b","c","d"].slice(0,Number(y[7])||2).map(M=>L(h(M)));if(y.startsWith("extract")){let M=h("a");return Array.isArray(M)?M[A==="0"||A==="x"?0:A==="1"||A==="y"?1:A==="2"||A==="z"?2:3]??0:0}if(y==="eq")return Et(h("a"),h("b"));if(y==="ne")return!Et(h("a"),h("b"));if(y==="lt")return L(h("a"))<L(h("b"));if(y==="le")return L(h("a"))<=L(h("b"));if(y==="gt")return L(h("a"))>L(h("b"));if(y==="ge")return L(h("a"))>=L(h("b"));if(y==="isNaN")return Number.isNaN(Number(h("a")));if(y==="isInf"){let M=Number(h("a"));return!Number.isFinite(M)&&!Number.isNaN(M)}return y==="and"?q(h("a",!1))&&q(h("b",!1)):y==="or"?q(h("a",!1))||q(h("b",!1)):y==="xor"?q(h("a",!1))!==q(h("b",!1)):y==="not"?!q(h("a",!1)):y==="select"?Y(q(h("condition",!1))?h("a"):h("b")):void 0}return g==="type/boolToInt"||g==="type/boolToFloat"?q(h("a",!1))?1:0:g==="type/intToBool"||g==="type/floatToBool"?L(h("a",0))!==0:g==="type/intToFloat"?L(h("a",0)):g==="type/floatToInt"?Math.trunc(L(h("a",0))):void 0}finally{R.delete(T)}},Te=()=>{if(U){U=!1,O=!0;let T=De(n);if(t){t.worldMatrices=T;for(let A of t.meshes||[])A.nodeIndex>=0&&A.nodeIndex<T.length&&(A.transform.set(T[A.nodeIndex]),fe(A.normalMatrix,A.transform))}}if(V){V=!1,O=!0;let T=n?.nodes;if(Array.isArray(t?.meshes)&&Array.isArray(T))for(let A of t.meshes){let R=!0;for(let _=A.nodeIndex,g=0;_!==void 0&&_>=0&&g<128;_=x.get(_),g++){let h=T[_];if(h?.visible===!1||h?.extensions?.KHR_node_visibility?.visible===!1){R=!1;break}}A.visible=R}}O&&(O=!1,t?.render?.())},se=(T,A={steps:0})=>{if(!T||typeof T.node!="number")return;A.steps===0&&(S=0);let R=[T],_=g=>{R.length+A.steps<Se&&R.push(g)};for(;R.length>0&&A.steps<Se;){A.steps++;let g=R.shift();if(!g||g.node<0||g.node>=o.length)continue;let h=g.node,y=o[h];if(!y)continue;let M=g.socket||"in",F=N(y),G=(k,D=void 0)=>xe(h,k,D,new Set),$=(k="out")=>{let D=y.flows?.[k];D&&_(D)};switch(F){case"flow/branch":$(q(G("condition",!1))?"true":"false");break;case"flow/sequence":for(let k of Object.keys(y.flows||{}).sort((D,K)=>Number(D)-Number(K)||D.localeCompare(K)))$(k);break;case"flow/switch":{let k=y.flows?.[String(G("selection",G("value",0)))]??y.flows?.default;k&&_(k);break}case"flow/for":{let k=Math.trunc(L(G("startIndex",0))),D=Math.trunc(L(G("endIndex",0))),K=Math.max(1,Math.trunc(L(G("step",1),1))),Q=y.flows?.body;if(Q&&D>k&&w<dn){let qt=Math.min(Math.ceil((D-k)/K),Se);w++;try{for(let Oe=0;Oe<qt&&A.steps<Se;Oe++)P(h,"index",k+Oe*K),se(Q,A)}finally{w--}}let ft=y.flows?.completed??y.flows?.out;ft&&_(ft);break}case"flow/doN":{let k=M==="reset"?0:(s.get(h)||0)+1;if(s.set(h,k),P(h,"currentCount",k),P(h,"count",k),M!=="reset"){let D=Math.trunc(L(G("n",j(y,"stopIterations")??j(y,"n")??1),1));k<=D&&$()}break}case"flow/multiGate":{if(M==="reset"){b.set(h,0);break}let k=Object.keys(y.flows||{}).sort();if(!k.length)break;let D=j(y,"isRandom")?Math.floor(Math.random()*k.length):b.get(h)||0;D<k.length&&($(k[D]),b.set(h,j(y,"isLoop")!==!1?(D+1)%k.length:D+1));break}case"flow/waitAll":{if(M==="reset"){f.delete(h);break}let k=f.get(h);k||f.set(h,k=new Set),k.add(M),k.size>=Math.max(1,Math.trunc(Number(j(y,"inputFlows")??2)||2))&&(k.clear(),$("out"),$("completed"));break}case"flow/throttle":{if(M==="reset"){u.delete(h);break}let k=Math.max(0,L(G("duration",0))),D=u.get(h);D===void 0||I-D>=k?(u.set(h,I),P(h,"lastRemainingTime",0),$()):P(h,"lastRemainingTime",Math.max(0,k-(I-D)));break}case"flow/delay":case"flow/setDelay":{if(M==="cancel"){for(let Q=p.length-1;Q>=0;Q--)p[Q].nodeIdx===h&&p.splice(Q,1);P(h,"lastDelayIndex",-1);break}let k=Math.max(0,L(G("duration",j(y,"duration")??0))),D=y.flows?.done??y.flows?.out;if(k<=0){P(h,"lastDelayIndex",-1),D&&_(D);break}p.length>=ln&&p.shift();let K=E++;P(h,"lastDelayIndex",K),p.push({id:K,nodeIdx:h,rem:k,done:D}),F==="flow/setDelay"&&y.flows?.out&&y.flows?.done&&$("out");break}case"flow/cancelDelay":{let k=Math.trunc(L(G("delayIndex",-1),-1));if(k<0)p.length=0;else for(let D=p.length-1;D>=0;D--)p[D].id===k&&p.splice(D,1);$();break}case"variable/set":C(j(y,"variable")??j(y,"id"),G("value")),$();break;case"variable/interpolate":{let k=j(y,"variable")??j(y,"id"),D=G("value",G("target")),K=Math.max(0,L(G("duration",j(y,"duration")??.3),.3));k!==void 0&&D!==void 0&&oe({key:`var:${String(k)}`,varKey:k,from:Y(G("from")??i.get(k)??0),to:Y(D),dur:K,elapsed:0,quat:!1,linear:j(y,"easing")==="linear",done:y.flows?.done}),$();break}case"pointer/set":{let k=Ce(h,y),D=G("value");k&&D!==void 0&&(B(`ptr:${k}`),ie(k,D)),$();break}case"pointer/interpolate":{let k=Ce(h,y),D=G("value",G("target")),K=Math.max(0,L(G("duration",j(y,"duration")??.3),.3));if(k&&D!==void 0){let Q=G("from")??re(k);Q!==void 0&&(K<=0?(ie(k,D),$("done")):oe({key:`ptr:${k}`,ptr:k,from:Y(Q),to:Y(D),dur:K,elapsed:0,quat:k.endsWith("/rotation"),linear:j(y,"easing")==="linear",done:y.flows?.done}))}$();break}case"animation/start":{let k=G("animation")??j(y,"animation")??j(y,"clipName"),D=typeof k=="number"?t?.animations?.[k]?.name??n?.animations?.[k]?.name:typeof k=="string"?k:void 0;t?.playAnimation?.(D),O=!0,$();break}case"animation/stop":case"animation/resetAt":t?.pauseAnimation?.(),F==="animation/resetAt"&&t?.evaluateAnimation?.(L(G("time",0))),O=!0,$();break;case"event/send":case"customEvent/send":{let k=z(j(y,"event")??j(y,"id")),D={};for(let K of Object.keys(y.values||{}))ne.has(K)||(D[K]=G(K));k&&(typeof CustomEvent<"u"&&typeof t?.container?.dispatchEvent=="function"&&t.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:k,values:D}})),ut(k,D,A)),$();break}default:$();break}}};this.readScenePointer=re,this.writeScenePointer=ie,this.fireOnStart=()=>{o.forEach(T=>{N(T)==="event/onStart"&&se(T.flows?.out)}),Te()},this.fireOnSelect=T=>{if(!T)return;let A=typeof T.meshIndex=="number"?T.meshIndex:-1,R=typeof T.nodeIndex=="number"?T.nodeIndex:t?.meshes?.[A]?.nodeIndex??-1;o.forEach((_,g)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(N(_)))return;let h=j(_,"nodeIndex")??j(_,"node")??xe(g,"nodeIndex",void 0,new Set),y=j(_,"meshName");if(typeof y=="string"&&y?T.meshName===y:h==null||Number(h)<0||Number.isNaN(Number(h))||W(R,Math.trunc(Number(h)))){if(P(g,"nodeIndex",R),P(g,"meshIndex",A),Array.isArray(T.hitPoint)){let F=[L(T.hitPoint[0]),L(T.hitPoint[1]),L(T.hitPoint[2])];P(g,"hitPoint",F),P(g,"point",F),P(g,"intersectionPoint",F)}if(Array.isArray(T.normal)){let F=[L(T.normal[0]),L(T.normal[1],1),L(T.normal[2])];P(g,"normal",F),P(g,"hitNormal",F)}typeof T.distance=="number"&&P(g,"distance",T.distance),se(_.flows?.out)}}),Te()},this.receiveCustomEvent=(T,A={})=>ut(T,A,{steps:0});function ut(T,A,R){if(!(v>=un)){v++;try{let _=z(T);o.forEach((g,h)=>{if(!/^(customE|e)vent\/receive$/.test(N(g)))return;let y=j(g,"event")??j(g,"id");if(!(z(y)!==_&&String(y)!==String(T))){for(let[M,F]of Object.entries(A))ne.has(M)||P(h,M,Y(F));se(g.flows?.out,R)}}),Te()}finally{v--}}}this.tick=T=>{if(!Number.isFinite(T)||T<0)return;let A=Math.min(T,.25);I+=A,o.forEach((_,g)=>{N(_)==="event/onTick"&&(P(g,"timeDelta",A),P(g,"dt",A),P(g,"timeElapsed",I),se(_.flows?.out))});let R=[];for(let _=m.length-1;_>=0;_--){let g=m[_];g.elapsed+=A;let h=g.dur>1e-6?ae(g.elapsed/g.dur):1,y=g.linear?h:h*h*(3-2*h),M=wt(g.from,g.to,y,g.quat);g.ptr?ie(g.ptr,M):g.varKey!==void 0&&C(g.varKey,M),h>=1&&(m.splice(_,1),g.done&&R.push(g.done))}for(let _=p.length-1;_>=0;_--){let g=p[_];g.rem-=A,g.rem<=0&&(p.splice(_,1),g.done&&R.push(g.done))}for(let _ of R)se(_);Te()},this.dispose=()=>{m.length=0,p.length=0,i.clear(),l.clear(),s.clear(),f.clear(),u.clear(),b.clear()}}},J=new WeakMap,_e=new WeakMap;function pn(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||dt().some(i=>i.name==="xr-live-head-follow")||(typeof e.getAutoRotate=="function"?e.getAutoRotate():e.autoRotate)===!1)return;let r=e.gltf,o=r?.nodes;if(!Array.isArray(o)||o.length===0)return;let a=Math.min(t,.1),d=(_e.get(e)||0)+a,c=!1;for(let i=0;i<o.length;i++){let l=o[i],s=yt(l?.extras?.xr?.orbit);if(!s)continue;let f=0,u=0,b=0;if(Array.isArray(s.target))f=s.target[0],u=s.target[1],b=s.target[2];else if(typeof s.target=="string"&&s.target!=="head"){let I=o.find(v=>v?.name===s.target);Array.isArray(I?.translation)&&(f=L(I.translation[0]),u=L(I.translation[1]),b=L(I.translation[2]))}let m=s.phase+s.speed*d,p=f+Math.cos(m)*s.radius,x=u+s.height,E=b+Math.sin(m)*s.radius;if(l.translation=[p,x,E],s.faceCenter){let I=Math.atan2(f-p,b-E);l.rotation=[0,Math.sin(I*.5),0,Math.cos(I*.5)]}c=!0}if(c){_e.set(e,d);let i=De(r);e.worldMatrices=i;for(let l of e.meshes||[])l.nodeIndex>=0&&l.nodeIndex<i.length&&(l.transform.set(i[l.nodeIndex]),fe(l.normalMatrix,l.transform))}}function Ie(e){if(!(!e||typeof e!="object"))return J.get(e)||J.get(e.viewer)||J.get(e._view)}function Ye(e,t,n){let r=Ie(e);return r?(r.receiveCustomEvent(t,n),!0):!1}var qe={name:"khr-interactivity",sendInteractivityEvent:Ye,getInteractivityVM:Ie,onLoadModel(e,t){if(!e||typeof e!="object")return;J.get(e)?.dispose(),J.delete(e),_e.delete(e);let n=t?.extensions?.KHR_interactivity,r=Array.isArray(n?.graphs)?n.graphs[n.graph??0]:n;if(!r||!Array.isArray(r.nodes))return;let o=new be(e,t,r);J.set(e,o),o.fireOnStart()},onMeshSelect(e,t){J.get(e)?.fireOnSelect(t)},onUpdate(e,t){J.get(e)?.tick(t),pn(e,t)},onDestroy(e,t){J.get(t)?.dispose(),J.delete(t),_e.delete(t)}};var he=new Map,Le=new WeakMap;function Mt(e,t){he.set(e,t)}var Qe={name:"materials",onContextRestored(e){Le.delete(e)},onBuildPrimitiveVAO(e,t,n,r,o){return(((r?.materials&&n.material!==void 0?r.materials[n.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,t){let n=Le.get(e);n||(n=e.createTexture(),Le.set(e,n));let r=Math.max(1,t.canvas.width),o=Math.max(1,t.canvas.height);e.activeTexture(33990),e.bindTexture(3553,n),e.copyTexImage2D(3553,0,6408,0,0,r,o,0),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553)},onResolveShader(e,t,n,r){if(!t)return null;if(t.name&&he.has(t.name)){let m=he.get(t.name);return{vs:m.vs||n,fs:m.fs||r}}let o=t.extensions||{},a=o.KHR_materials_clearcoat,d=o.KHR_materials_sheen,c=!!o.KHR_materials_transmission,i=!!o.KHR_materials_ior,l=o.KHR_materials_iridescence;if(!a&&!d&&!o.KHR_materials_unlit&&!c&&!o.KHR_materials_volume&&!i&&!o.KHR_materials_dispersion&&!l)return null;if(o.KHR_materials_unlit)return{vs:n,fs:r.replace("fragColor=vec4(color,outAlpha);","fragColor=vec4(base.rgb,outAlpha);").replace("fragColor=vec4(color,base.a);","fragColor=vec4(base.rgb,base.a);")};let s=r;if(c){let m=s.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
|
|
33
33
|
`;s=s.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
|
|
34
|
-
${
|
|
35
|
-
vec2 sUV=gl_FragCoord.xy/max(uViewportSize,vec2(1.));float iorB=${f(b,1.5,1,10)},dV=${v},tV=${
|
|
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);
|
|
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
38
|
vec3 aCol=vec3(${f(I[0],1,0,1)},${f(I[1],1,0,1)},${f(I[2],1,0,1)});
|
|
39
|
-
vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${
|
|
40
|
-
diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${d});`)}if(a&&!r.includes("uClearcoat")){let d=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)*${d};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${p})*ccF;fragColor=vec4(color,base.a);`)}if(m){let d=Array.isArray(m.sheenColorFactor)?m.sheenColorFactor:[1,1,1],p=`color+=vec3(${f(d[0],1,0,1)},${f(d[1],1,0,1)},${f(d[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 m=n.materialIndex;if(m!==void 0&&a?.materials){let c=a.materials[m];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 u=e.getUniformLocation(t,"uViewportSize");u&&e.uniform2f(u,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var wt=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 xn(e){let t=e<<24>>24;return(t<<1^t>>7)&255}function It(e){return(e<<1^e>>31)>>>0}function Pt(e){if(e!==void 0&&e!=="NONE"&&e!=="OCTAHEDRAL"&&e!=="QUATERNION"&&e!=="EXPONENTIAL"&&e!=="COLOR")throw X(`unknown filter "${String(e)}"`)}var H=Math.fround;function de(e){return Math.trunc(H(e+(e>=0?.5:-.5)))}function Ze(e,t,n,r="NONE"){if(Pt(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,l=f?32767:127,b=g=>f?o.getInt16(g,!0):o.getInt8(g),d=(g,M)=>f?o.setInt16(g,M,!0):o.setInt8(g,M<<24>>24),p=f?2:1;for(let g=0;g<t;g++){let M=g*n,I=b(M),v=b(M+p),R=H(b(M+2*p)-Math.abs(I)-Math.abs(v)),E=R>=0?0:R;I=H(I+(I>=0?E:-E)),v=H(v+(v>=0?E:-E));let N=H(Math.sqrt(H(H(H(I*I)+H(v*v))+H(R*R))));if(N===0){d(M,0),d(M+p,0),d(M+2*p,l);continue}let O=H(l/N);d(M,de(H(I*O))),d(M+p,de(H(v*O))),d(M+2*p,de(H(R*O)))}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 l=0;l<t;l++){let b=l*8,d=o.getInt16(b+6,!0),p=d|3,g=o.getInt16(b,!0),M=o.getInt16(b+2,!0),I=o.getInt16(b+4,!0),v=H(p*p),R=H(H(H(H(v*2)-H(g*g))-H(M*M))-H(I*I)),E=H(Math.sqrt(R>=0?R:0)),N=H(f/p),O=d&3,k=[0,0,0,0];k[O+1&3]=de(H(g*N)),k[O+2&3]=de(H(M*N)),k[O+3&3]=de(H(I*N)),k[O]=Math.trunc(H(H(E*N)+.5));for(let C=0;C<4;C++)o.setInt16(b+C*2,k[C]<<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 l=0;l<f;l++){let b=l*4,d=o.getUint32(b,!0),p=d<<8>>8,g=d>>24;o.setUint32(b,g+127<<23>>>0,!0);let M=o.getFloat32(b,!0);o.setFloat32(b,H(M*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,m=a?65535:255,c=f=>a?o.getUint16(f,!0):o.getUint8(f),i=f=>a?o.getInt16(f,!0):o.getInt8(f),u=(f,l)=>a?o.setUint16(f,l&65535,!0):o.setUint8(f,l&255),s=a?2:1;for(let f=0;f<t;f++){let l=f*n,b=c(l+3*s);b|=b>>1,b|=b>>2,b|=b>>4,b|=b>>8;let d=c(l),p=i(l+s),g=i(l+2*s),M=d+p-g,I=d+g,v=d-p-g,R=c(l+3*s);R=R<<1&b|R&1;let E=b===0?0:H(m/b);u(l,Math.trunc(H(H(M*E)+.5))),u(l+s,Math.trunc(H(H(I*E)+.5))),u(l+2*s,Math.trunc(H(H(v*E)+.5))),u(l+3*s,Math.trunc(H(H(R*E)+.5)))}}var Ut=160,ee=16,gn=24,Ct=32,Tn=24,An=[0,2,4,8],vn=[0,1,2,4,8];function Vt(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 En(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,m=8/o,c=t+ee*o/8;for(let i=0;i<ee;i++){let u=e[t+Math.floor(i/m)],s=i%m,f=o===1?u>>s&1:u>>8-o-s*o&a;n[r+i]=f===a?e[c++]:f}return c}function Lt(e,t,n,r,o,a,m,c){let i=a/ee,u=i+3>>2;if(n-t<u)throw X("truncated ATTRIBUTES stream");let s=t;t+=u;for(let f=0;f<i;f++){if(n-t<gn)throw X("truncated ATTRIBUTES stream");let l=e[s+(f>>2)]>>(f&3)*2&3;t=En(e,t,r,o+f*ee,m[c+l])}return t}function Mn(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)!==Ut)throw X(`unsupported ATTRIBUTES header 0x${a.toString(16)}`);let m=a&15;if(m>1)throw X(`unsupported ATTRIBUTES codec version ${m}`);let c=n+(m===0?0:n/4),i=m===0?Ct:Tn,u=c<i?i:c;if(o-1<u)throw X("truncated ATTRIBUTES stream");let s=o-c,f=e.slice(s,s+n),l=s+n,b=Vt(n),d=new Uint8Array(256*4),p=1;for(let g=0;g<t;){let M=Math.min(b,t-g),I=M+ee-1&~(ee-1),v=m===0?0:n/4;if(o-p<v)throw X("truncated ATTRIBUTES stream");let R=p;p+=v;for(let E=0;E<n;E+=4){let N=m===0?0:e[R+E/4];for(let C=0;C<4;C++){let U=N>>C*2&3;if(U===3){if(o-p<M)throw X("truncated ATTRIBUTES stream");d.set(e.subarray(p,p+M),C*M),p+=M}else U===2?d.fill(0,C*M,C*M+M):p=m===0?Lt(e,p,o,d,C*M,I,An,0):Lt(e,p,o,d,C*M,I,vn,U)}let O=m===0?0:e[l+E/4],k=O&3;if(k===0)for(let C=0;C<4;C++){let U=f[E+C];for(let V=0;V<M;V++)U=hn(d[C*M+V])+U&255,r[(g+V)*n+E+C]=U}else if(k===1)for(let C=0;C<4;C+=2){let U=f[E+C]|f[E+C+1]<<8,V=C*M;for(let B=0;B<M;B++){let W=d[V+B]|d[V+M+B]<<8;U=yn(W)+U&65535;let G=(g+B)*n+E+C;r[G]=U&255,r[G+1]=U>>8}}else if(k===2){let C=32-(O>>4)&31,U=(f[E]|f[E+1]<<8|f[E+2]<<16|f[E+3]<<24)>>>0;for(let V=0;V<M;V++){let B=(d[V]|d[M+V]<<8|d[2*M+V]<<16|d[3*M+V]<<24)>>>0;B=((B<<C|B>>>(32-C&31))^U)>>>0,U=B;let W=(g+V)*n+E;r[W]=B&255,r[W+1]=B>>>8&255,r[W+2]=B>>>16&255,r[W+3]=B>>>24}}else throw X(`invalid ATTRIBUTES channel ${O}`)}f.set(r.subarray((g+M-1)*n,(g+M)*n)),g+=M}if(o-p!==u)throw X("ATTRIBUTES trailing data")}var kt=224,Ot=208;function Ft(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 m=e[t.pos++]??0;if(r=(r|(m&127)<<o)>>>0,o+=7,m<128)break}return r>>>0}function Ne(e,t,n){let r=Ft(e,t),o=r>>>1^-(r&1);return n+o>>>0}function Rn(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)!==kt)throw X(`unsupported TRIANGLES header 0x${o.toString(16)}`);let a=o&15;if(a>1)throw X(`unsupported TRIANGLES codec version ${a}`);let m=new Uint32Array(16).fill(4294967295),c=new Uint32Array(16).fill(4294967295),i=new Uint32Array(16).fill(4294967295),u=0,s=0,f=(N,O)=>{m[u]=N,c[u]=O,u=u+1&15},l=(N,O=1)=>{i[s]=N,s=s+O&15},b=0,d=0,p=a>=1?13:15,g=1+r,M=e.byteLength-16,I=M,v={pos:g},R=0,E=(N,O,k)=>{n(R++,N),n(R++,O),n(R++,k)};for(let N=1;N<g;N++){let O=e[N];if(O<240){let k=O>>4,C=u-1-k&15,U=m[C],V=c[C],B=0,W=O&15;if(W<p){let G=i[s-1-W&15];B=W===0?b:G;let oe=W===0?1:0;b=b+oe>>>0,l(B,oe)}else{if(v.pos>M)throw X("truncated TRIANGLES stream");B=W!==15?d+(W*2-27)>>>0:Ne(e,v,d),d=B,l(B)}f(B,V),f(U,B),E(U,V,B)}else if(O<254){let k=e[I+(O&15)],C=k>>4,U=k&15,V=b;b=b+1>>>0;let B=i[s-C&15],W=C===0?b:B,G=C===0?1:0;b=b+G>>>0;let oe=i[s-U&15],re=U===0?b:oe,ie=U===0?1:0;b=b+ie>>>0,E(V,W,re),l(V),l(W,G),l(re,ie),f(W,V),f(re,W),f(V,re)}else{if(v.pos>M)throw X("truncated TRIANGLES stream");let k=e[v.pos++],C=O===254?0:15,U=k>>4,V=k&15;k===0&&(b=0);let B=0;C===0&&(B=b,b=b+1>>>0);let W;U===0?(W=b,b=b+1>>>0):W=i[s-U&15];let G;V===0?(G=b,b=b+1>>>0):G=i[s-V&15],C===15&&(d=B=Ne(e,v,d)),U===15&&(d=W=Ne(e,v,d)),V===15&&(d=G=Ne(e,v,d)),E(B,W,G),l(B),l(W,U===0||U===15?1:0),l(G,V===0||V===15?1:0),f(W,B),f(G,W),f(B,G)}}if(v.pos!==M)throw X("TRIANGLES trailing data")}function Sn(e,t,n){if(e.byteLength<1+t+4)throw X("truncated INDICES stream");let r=e[0];if((r&240)!==Ot)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,m=[0,0],c={pos:1};for(let i=0;i<t;i++){if(c.pos>=a)throw X("truncated INDICES stream");let u=Ft(e,c),s=u&1;u>>>=1;let f=u>>>1^-(u&1),l=m[s]+f>>>0;m[s]=l,n(i,l)}if(c.pos!==a)throw X("INDICES trailing data")}function Je(e,t,n,r,o="NONE"){if(Pt(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>wt)throw X(`decompressed size (${a}) exceeds MAX_MESHOPT_BUFFER_BYTES (${wt})`);if(t===0)return new Uint8Array(0);let m=new Uint8Array(a);if(r==="ATTRIBUTES")return Mn(e,t,n,m),Ze(m,t,n,o),m;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(m.buffer),i=n===2?(u,s)=>c.setUint16(u*2,s&65535,!0):(u,s)=>c.setUint32(u*4,s>>>0,!0);return r==="TRIANGLES"?Rn(e,t,i):Sn(e,t,i),m}throw X(`unknown mode "${String(r)}"`)}function Nt(e,t){t>>>=0;do e.push(t&127|(t>127?128:0)),t>>>=7;while(t)}function Dt(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=[Ut],i=Vt(n),u=new Uint8Array(n);t>0&&u.set(e.subarray(0,n));let s=u.slice(),f=new Uint8Array(256);for(let l=0;l<t;){let b=Math.min(i,t-l),d=b+15&-16;for(let p=0;p<n;p++){f.fill(0);let g=u[p];for(let v=0;v<b;v++){let R=e[(l+v)*n+p];f[v]=xn(R-g&255),g=R}u[p]=g;let M=d/16,I=c.length;for(let v=0;v<M+3>>2;v++)c.push(0);for(let v=0;v<M;v++){let R=f.subarray(v*16,v*16+16);if(!R.every(E=>E===0)){c[I+(v>>2)]|=3<<(v&3)*2;for(let E of R)c.push(E)}}}l+=b}for(let l=n;l<Ct;l++)c.push(0);for(let l=0;l<n;l++)c.push(s[l]);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),m=c=>n===2?a.getUint16(c*2,!0):a.getUint32(c*4,!0);if(r==="INDICES"){let c=[Ot|1],i=0;for(let u=0;u<t;u++){let s=m(u),f=s-i|0;i=s,Nt(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=[kt|1];for(let s=0;s<c;s++)i.push(255);let u=0;for(let s=0;s<c;s++){i.push(255);for(let f=0;f<3;f++){let l=m(s*3+f);Nt(i,It(l-u|0)),u=l}}for(let s=0;s<16;s++)i.push(0);return new Uint8Array(i)}throw new Error(`encodeMeshoptBuffer: unknown mode "${String(r)}"`)}function Pe(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=[],m=0;for(let f=0;f<r.bufferViews.length;f++){let l=r.bufferViews[f],b=l?.extensions?.KHR_meshopt_compression,d=b??l?.extensions?.EXT_meshopt_compression;if(!d||typeof d!="object")continue;let p=b?"KHR_meshopt_compression":"EXT_meshopt_compression",g=Number(d.count),M=Number(d.byteStride),I=Number(d.byteOffset??0),v=Number(d.byteLength??0),R=d.mode||"ATTRIBUTES",E=d.filter||"NONE";if(E==="COLOR"&&!b)throw X(`bufferView ${f} uses the COLOR filter, which requires KHR_meshopt_compression`);if(Number(d.buffer??0)!==0)throw new Error(`${p}: bufferView ${f} references buffer ${String(d.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 N=g*M;if(m+=N,m>_t)throw X(`total decompressed size (${m}) exceeds MAX_MESHOPT_TOTAL_BYTES (${_t})`);let O=o.subarray(I,I+v),k=Je(O,g,M,R,E);a.push({index:f,bytes:k,ext:d})}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 u=new Uint8Array(c+i);u.set(o,0);let s=c;for(let f of a){u.set(f.bytes,s);let l=r.bufferViews[f.index];l.buffer=0,l.byteOffset=s,l.byteLength=f.bytes.byteLength,l._decoded=f.bytes,f.ext.mode==="ATTRIBUTES"&&l.byteStride===void 0&&(l.byteStride=Number(f.ext.byteStride)),l.extensions&&(delete l.extensions.EXT_meshopt_compression,delete l.extensions.KHR_meshopt_compression),s+=f.bytes.byteLength+3&-4}n.bin=u.buffer}var Ue={decodeBufferViews(e,t){Pe(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",Ue);var et={name:"meshopt",onParseGLB(e){ce().decoders.set("meshopt",Ue),Pe(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
|
|
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
|
|
41
41
|
layout(location=0) in vec3 aPosition;
|
|
42
42
|
layout(location=1) in vec3 aNormal;
|
|
43
43
|
uniform mat4 uMVP,uVP;
|
|
@@ -64,13 +64,13 @@ uniform vec4 uOutlineColor;
|
|
|
64
64
|
out vec4 fragColor;
|
|
65
65
|
void main(){
|
|
66
66
|
fragColor=uOutlineColor;
|
|
67
|
-
}`,
|
|
67
|
+
}`,zt=`#version 300 es
|
|
68
68
|
out vec2 vUV;
|
|
69
69
|
void main(){
|
|
70
70
|
vec2 pos=vec2((gl_VertexID<<1)&2,gl_VertexID&2);
|
|
71
71
|
vUV=pos;
|
|
72
72
|
gl_Position=vec4(pos*2.0-1.0,0.0,1.0);
|
|
73
|
-
}`,
|
|
73
|
+
}`,Un=`#version 300 es
|
|
74
74
|
precision highp float;
|
|
75
75
|
in vec2 vUV;
|
|
76
76
|
uniform sampler2D uSourceTex;
|
|
@@ -93,7 +93,7 @@ c+=prefilter(texture(uSourceTex,vUV+vec2(h.x,-h.y)).rgb)*0.125;
|
|
|
93
93
|
c+=prefilter(texture(uSourceTex,vUV+vec2(-h.x,h.y)).rgb)*0.125;
|
|
94
94
|
c+=prefilter(texture(uSourceTex,vUV+vec2(h.x,h.y)).rgb)*0.125;
|
|
95
95
|
fragColor=vec4(c,1.0);
|
|
96
|
-
}`,
|
|
96
|
+
}`,kn=`#version 300 es
|
|
97
97
|
precision highp float;
|
|
98
98
|
in vec2 vUV;
|
|
99
99
|
uniform sampler2D uBloomTex;
|
|
@@ -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
|
-
}`,
|
|
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.);}`,
|
|
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);}`,
|
|
118
|
+
}`,Ne=3,ye=new WeakMap;function rt(e,t=[.22,.74,.97]){let n=we(e,"");if(!n.startsWith("#"))return[t[0],t[1],t[2]];let r=n.slice(1);if(r.length===3){let o=+("0x"+r[0]+r[0])/255,a=+("0x"+r[1]+r[1])/255,d=+("0x"+r[2]+r[2])/255;return[o,a,d]}if(r.length===6){let o=+("0x"+r.slice(0,2))/255,a=+("0x"+r.slice(2,4))/255,d=+("0x"+r.slice(4,6))/255;return[o,a,d]}return[t[0],t[1],t[2]]}function Ht(e,t,n=.8,r=.5){let o=Number.isFinite(t)?Math.max(0,t):0;if(o<=0)return[0,0,0];let a=Math.max(0,Number(e[0])||0),d=Math.max(0,Number(e[1])||0),c=Math.max(0,Number(e[2])||0),i=Math.max(a,d,c);if(i<=1e-6)return[0,0,0];let l=Number.isFinite(n)?Math.max(0,n):.8,s=Math.max(l*Math.max(0,r),1e-4),f=Math.max(0,Math.min(2*s,i-l+s)),u=f*f/(4*s+1e-4),m=Math.min(1,Math.max(0,Math.max(u,i-l)/Math.max(i,1e-4)))*o;return[a*m,d*m,c*m]}function Wt(e,t,n,r){let o=Number(e[0])||0,a=Number(e[1])||0,d=Math.hypot(o,a);if(d<=1e-5||t<=0||n<=0)return[0,0];let c=Math.max(1,Number(r[0])||1),i=Math.max(1,Number(r[1])||1),l=Math.max(0,n)*2*t;return[o/d*(l/c),a/d*(l/i)]}function nt(e,t,n){let r=e.createProgram();if(!r)return null;let o=[];for(let[a,d]of[[35633,t],[35632,n]]){let c=e.createShader(a);c&&(e.shaderSource(c,d),e.compileShader(c),e.attachShader(r,c),o.push(c))}e.linkProgram(r);for(let a of o)e.detachShader?.(r,a),e.deleteShader?.(a);return o.length<2||typeof e.getProgramParameter=="function"&&!e.getProgramParameter(r,35714)?(e.deleteProgram?.(r),null):r}var Bt=new WeakSet;function Gt(e){let t=ye.get(e);if(t){if(typeof e.isProgram!="function"||e.isProgram(t.outlineProg))return t;ye.delete(e)}if(Bt.has(e)||e.isContextLost?.())return null;let n=nt(e,In,Ln),r=nt(e,zt,Un),o=nt(e,zt,kn);if(!n||!r||!o){for(let d of[n,r,o])d&&e.deleteProgram(d);return Bt.add(e),null}let a=typeof e.createVertexArray=="function"?e.createVertexArray():null;return t={outlineProg:n,uOutlineMVP:e.getUniformLocation(n,"uMVP"),uOutlineVP:e.getUniformLocation(n,"uVP"),uOutlineNormalMatrix:e.getUniformLocation(n,"uNormalMatrix"),uOutlineViewportSize:e.getUniformLocation(n,"uViewportSize"),uOutlineThickness:e.getUniformLocation(n,"uOutlineThickness"),uOutlineColor:e.getUniformLocation(n,"uOutlineColor"),downProg:r,uDownSourceTex:e.getUniformLocation(r,"uSourceTex"),uDownTexelSize:e.getUniformLocation(r,"uTexelSize"),uDownThreshold:e.getUniformLocation(r,"uThreshold"),upProg:o,uUpBloomTex:e.getUniformLocation(o,"uBloomTex"),uUpTexelSize:e.getUniformLocation(o,"uTexelSize"),uUpRadius:e.getUniformLocation(o,"uRadius"),uUpStrength:e.getUniformLocation(o,"uStrength"),fsVao:a,sceneTex:null,bloomTex:[],bloomFbo:[],mipWidth:[],mipHeight:[],texWidth:0,texHeight:0},ye.set(e,t),t}function Pn(e,t,n,r){if(typeof e.createFramebuffer!="function"||typeof e.copyTexSubImage2D!="function")return!1;let o=Math.max(2,n|0),a=Math.max(2,r|0);if(t.sceneTex&&t.bloomFbo.length===Ne&&t.texWidth===o&&t.texHeight===a)return!0;t.sceneTex||(t.sceneTex=e.createTexture()),e.bindTexture(3553,t.sceneTex),e.texImage2D(3553,0,6408,o,a,0,6408,5121,null),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071);let d=o,c=a;for(let i=0;i<Ne;i++)d=Math.max(1,d>>1),c=Math.max(1,c>>1),t.mipWidth[i]=d,t.mipHeight[i]=c,t.bloomTex[i]||(t.bloomTex[i]=e.createTexture()),e.bindTexture(3553,t.bloomTex[i]),e.texImage2D(3553,0,6408,d,c,0,6408,5121,null),e.texParameteri(3553,10241,9729),e.texParameteri(3553,10240,9729),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),t.bloomFbo[i]||(t.bloomFbo[i]=e.createFramebuffer()),e.bindFramebuffer(36160,t.bloomFbo[i]),e.framebufferTexture2D(36160,36064,3553,t.bloomTex[i],0);return e.bindFramebuffer(36160,null),t.texWidth=o,t.texHeight=a,!0}function Nn(e){let t=e.container;if(t&&typeof t.getAttribute=="function"){let r=t.getAttribute("bloom");if(r!==null){let o=r.trim().toLowerCase();if(o==="false"||o==="0"||o==="none")return null;let a=o===""||o==="true"?.35:Number(o);if(!Number.isFinite(a)||a<=0)return null;let d=$e({strength:a,threshold:tt(t.getAttribute("bloom-threshold"),.62),radius:tt(t.getAttribute("bloom-radius"),.75)});if(d)return d}}let n=null;for(let r of e.meshes||[]){if(r.visible===!1)continue;let o=r?.extras?.xr?.bloom??r?.userData?.xr?.bloom,a=$e(o);a&&(!n||a.strength>n.strength)&&(n=a)}return n}function Cn(e,t){if(e==null)return null;let n=e.trim(),r=n.toLowerCase();if(r==="false"||r==="0"||r==="none")return null;let o=t,a=3.5,d=!1;if(n&&r!=="true"){let c=n.split(/\s+/);for(let i of c)if(i.startsWith("#"))o=i;else if(i.toLowerCase()==="pulse")d=!0;else{let l=Number(i);Number.isFinite(l)&&l>0&&(a=l)}}return Ee({color:o,thickness:a,pulse:d})}var On=new Set(["floor","pedestal","ground","table","grid","pad"]);function Vn(e){return e.replace(/([a-z\d])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z]+/).some(t=>On.has(t))}function Dn(e,t){let n=e.container,r=typeof n?.getAttribute=="function"?n.getAttribute("outline"):null;if(r!=null){let s=r.trim().toLowerCase();if(s==="false"||s==="0"||s==="none")return null}let o=t?.extras?.xr?.outline??t?.userData?.xr?.outline,a=Ee(o);if(a)return a;let d=typeof n?.getAttribute=="function"&&n.getAttribute("outline-color")||"#38bdf8",c=Cn(r,d),i=n!=null&&typeof n.hasAttribute=="function"&&n.hasAttribute("outline-selected")&&n.getAttribute("outline-selected")!=="false",l=e.getSelectedMesh?.()||"";if(l)return t.name!==l?null:c||(i?Ee({color:d,thickness:3,pulse:!1}):null);if(c){let s=t.name||"";return Vn(s)?null:c}return null}var ot={name:"postprocessing",onAttributeChanged(e,t){(t==="bloom"||t==="bloom-threshold"||t==="bloom-radius"||t==="outline"||t==="outline-selected"||t==="outline-color"||t==="selected-mesh")&&e.viewer?.render?.()},onAfterRender(e,t,n){if(!t.meshes||t.meshes.length===0)return;let r=Math.max(1,t.canvas?.width||300),o=Math.max(1,t.canvas?.height||150),a=[];for(let u of t.meshes){if(u.visible===!1)continue;let b=Dn(t,u);b&&a.push({mesh:u,trait:b})}let d=a.length>0?Gt(e):null;if(d){let u=d,b=le(),m=le(),p=new Float32Array(9),x=(typeof performance<"u"?performance.now():Date.now())*.001,E=typeof e.getParameter=="function"?e.getParameter(e.VIEWPORT):null,I=Math.max(1,E?.[2]||r),v=Math.max(1,E?.[3]||o);e.useProgram(u.outlineProg),u.uOutlineViewportSize&&e.uniform2f(u.uOutlineViewportSize,I,v),u.uOutlineVP&&e.uniformMatrix4fv(u.uOutlineVP,!1,n),e.enable(e.CULL_FACE),e.cullFace(e.FRONT),e.enable(2929),e.depthFunc(e.LEQUAL),e.depthMask(!1);for(let{mesh:S,trait:w}of a){let[U,V,O]=rt(w.color),N=w.pulse?.8+.25*Math.sin(x*4):1;u.uOutlineColor&&e.uniform4f(u.uOutlineColor,U,V,O,1),u.uOutlineThickness&&e.uniform1f(u.uOutlineThickness,w.thickness*N),S.worldSpace===!0?b.set(S.transform):ue(b,t.modelRootMatrix,S.transform);let P=S.instanceMatrices;for(let C of S.primitives)if(!(C.pluginData?.skinning?.hasSkin||C.pluginData?.morph?.hasMorph))if(e.bindVertexArray(C.vao),P&&P.length>=16){let z=P.length>>4,W=le();for(let B=0;B<z;B++)ue(W,b,P.subarray(B*16,B*16+16)),ue(m,n,W),fe(p,W),e.uniformMatrix4fv(u.uOutlineMVP,!1,m),e.uniformMatrix3fv(u.uOutlineNormalMatrix,!1,p),C.indices?e.drawElements(4,C.indexCount,C.indexType,0):e.drawArrays(4,0,C.indexCount)}else ue(m,n,b),fe(p,b),e.uniformMatrix4fv(u.uOutlineMVP,!1,m),e.uniformMatrix3fv(u.uOutlineNormalMatrix,!1,p),C.indices?e.drawElements(4,C.indexCount,C.indexType,0):e.drawArrays(4,0,C.indexCount)}e.bindVertexArray(null),e.cullFace(e.BACK),e.disable(e.CULL_FACE),e.depthFunc(e.LESS),e.depthMask(!0)}if(t.xrSessionActive||t.stereoSBS)return;let c=Nn(t);if(!c||c.strength<=0)return;let i=Gt(e);if(!i||!Pn(e,i,r,o)||!i.fsVao)return;e.activeTexture(33984),e.bindTexture(3553,i.sceneTex),e.copyTexSubImage2D(3553,0,0,0,0,0,r,o),e.disable(2929),e.depthMask(!1),e.disable(3042),e.useProgram(i.downProg),e.uniform1i(i.uDownSourceTex,0),e.bindVertexArray(i.fsVao);let l=i.sceneTex,s=r,f=o;for(let u=0;u<Ne;u++){let b=i.mipWidth[u],m=i.mipHeight[u];e.bindFramebuffer(36160,i.bloomFbo[u]),e.viewport(0,0,b,m),e.bindTexture(3553,l),e.uniform2f(i.uDownTexelSize,1/s,1/f),e.uniform1f(i.uDownThreshold,u===0?c.threshold:0),e.drawArrays(4,0,3),l=i.bloomTex[u],s=b,f=m}e.enable(3042),typeof e.blendFuncSeparate=="function"?e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,771):e.blendFunc(e.ONE,e.ONE),e.useProgram(i.upProg),e.uniform1i(i.uUpBloomTex,0),e.uniform1f(i.uUpRadius,c.radius);for(let u=Ne-1;u>=1;u--){let b=u-1;e.bindFramebuffer(36160,i.bloomFbo[b]),e.viewport(0,0,i.mipWidth[b],i.mipHeight[b]),e.bindTexture(3553,i.bloomTex[u]),e.uniform2f(i.uUpTexelSize,1/i.mipWidth[u],1/i.mipHeight[u]),e.uniform1f(i.uUpStrength,.85),e.drawArrays(4,0,3)}e.bindFramebuffer(36160,null),e.viewport(0,0,r,o),e.bindTexture(3553,i.bloomTex[0]),e.uniform2f(i.uUpTexelSize,1/i.mipWidth[0],1/i.mipHeight[0]),e.uniform1f(i.uUpStrength,c.strength),e.drawArrays(4,0,3),e.bindVertexArray(null),e.blendFunc(770,771),e.disable(3042),e.depthMask(!0),e.enable(2929)},onDestroy(e){let t=ye.get(e);if(t){e.deleteProgram(t.outlineProg),e.deleteProgram(t.downProg),e.deleteProgram(t.upProg),t.fsVao&&e.deleteVertexArray(t.fsVao),t.sceneTex&&e.deleteTexture(t.sceneTex);for(let n of t.bloomTex)n&&e.deleteTexture(n);for(let n of t.bloomFbo)n&&e.deleteFramebuffer(n);ye.delete(e)}}};var zn=`#version 300 es
|
|
119
|
+
layout(location=0) in vec3 aPosition;layout(location=1) in vec2 aUV;uniform mat4 uMVP;out vec2 vUV;void main(){vUV=aUV;gl_Position=uMVP*vec4(aPosition,1.);}`,Bn=`#version 300 es
|
|
120
|
+
precision highp float;in vec2 vUV;uniform float uShadowIntensity,uShadowSoftness;out vec4 fragColor;void main(){vec2 p=(vUV-.5)*2.;float d=clamp(length(p),0.,1.);fragColor=vec4(0.,0.,0.,pow(1.-d*d,mix(1.2,2.8,uShadowSoftness))*smoothstep(1.,.85-uShadowSoftness*.6,d)*uShadowIntensity);}`,ge=new WeakMap,Xt=new Float32Array(20);function it(e,t){let[n,r,o,a,d,c]=t;return[e[0]*n+e[4]*r+e[8]*o+e[12],e[1]*n+e[5]*r+e[9]*o+e[13],e[2]*n+e[6]*r+e[10]*o+e[14],Math.abs(e[0])*a+Math.abs(e[4])*d+Math.abs(e[8])*c,Math.abs(e[1])*a+Math.abs(e[5])*d+Math.abs(e[9])*c,Math.abs(e[2])*a+Math.abs(e[6])*d+Math.abs(e[10])*c]}function Gn(e){if(e._lb!==void 0)return e._lb;let t=1e9,n=1e9,r=1e9,o=-1e9,a=-1e9,d=-1e9;for(let c of e.primitives||[]){let i=c.positions;if(i)for(let l=0;l<i.length;l+=3)i[l]<t&&(t=i[l]),i[l+1]<n&&(n=i[l+1]),i[l+2]<r&&(r=i[l+2]),i[l]>o&&(o=i[l]),i[l+1]>a&&(a=i[l+1]),i[l+2]>d&&(d=i[l+2])}return e._lb=t<=o?[(t+o)*.5,(n+a)*.5,(r+d)*.5,(o-t)*.5,(a-n)*.5,(d-r)*.5]:null}function Hn(e){let t=ge.get(e);if(t)return t;let n=(c,i)=>{let l=e.createShader(c);return e.shaderSource(l,i),e.compileShader(l),l},r=e.createProgram();e.attachShader(r,n(35633,zn)),e.attachShader(r,n(35632,Bn)),e.linkProgram(r);let o=e.createVertexArray(),a=e.createBuffer(),d=e.createBuffer();return e.bindVertexArray(o),e.bindBuffer(34962,a),e.bufferData(34962,80,35048),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,5126,!1,20,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,5126,!1,20,12),e.bindBuffer(34963,d),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),t={prog:r,vao:o,vbo:a,ibo:d,uMVP:e.getUniformLocation(r,"uMVP"),uIntensity:e.getUniformLocation(r,"uShadowIntensity"),uSoftness:e.getUniformLocation(r,"uShadowSoftness")},ge.set(e,t),t}var at={name:"contact-shadow",onContextRestored(e){ge.delete(e)},onAfterRender(e,t,n){let r=t.shadowIntensity;if(r<=0||!t.bounds)return;let o=Hn(e),a=!t.xrSessionActive&&(t.backdropMeshes?.length??0)>0,d=[],c=[];for(let p of t.meshes||[]){if(!p||p.visible===!1||p.isPluginMesh||p.name==="__xr_reticle__"||p.name?.startsWith("__xr_slot_"))continue;let x=Gn(p);if(!x)continue;p.transform&&(x=it(p.transform,x)),t.modelRootMatrix&&(x=it(t.modelRootMatrix,x));let[E,I,v,S,w,U]=x,V=[E,v,S,U,I-w,I+w];/floor|table|pedestal|ground|base|plane/i.test(p.name||"")||w<.14&&Math.min(S,U)>.45?c.push(V):d.push(V)}let i=[],l=t.bounds.center||[0,0,0],s=Math.max(.05,Number(t.bounds.radius)||.5),f=t.bounds.min,u=f?[l[0],l[1],l[2],s,Math.max(.01,l[1]-f[1]),s]:[l[0],l[1],l[2],s,s,s];t.modelRootMatrix&&(u=it(t.modelRootMatrix,u));let m=t.xrSessionActive&&c.length===0&&String(t.container?.tagName||"").toLowerCase()==="xr-live"?(t.modelRootMatrix?t.modelRootMatrix[5]*-.25+t.modelRootMatrix[13]:-.25)+.002:u[1]-u[4]+.002;for(let[p,x,E,I,v]of d){let S=-1/0;for(let[U,V,O,N,,P]of c)v>=P-.08&&Math.abs(p-U)<=O&&Math.abs(x-V)<=N&&P+.002>S&&(S=P+.002);a&&(S=Math.max(S,p>=.04&&p<=.36&&x>=-.34&&x<=-.04&&v>=.01?.036:Math.hypot(p,x)<=.66&&v>=-.06?.003:-.477)),isFinite(S)||(S=m);let w=i.find(U=>Math.hypot(p-U[0],x-U[1])<.06&&Math.abs(S-U[5])<.05);w?(w[2]=Math.max(w[2],E*.78),w[3]=Math.max(w[3],I*.78),w[4]=Math.min(w[4],v)):i.push([p,x,E,I,v,S])}if(i.length===0){let p=Math.max(.1,u[3]*1.5)/1.45;i.push([u[0],u[2],p,p,m,m])}e.useProgram(o.prog),e.uniformMatrix4fv(o.uMVP,!1,n),e.enable(3042),(e.blendFuncSeparate||e.blendFunc).call(e,770,771,1,771),e.depthMask(!1),e.bindVertexArray(o.vao),e.bindBuffer(34962,o.vbo);for(let[p,x,E,I,v,S]of i){let w=Math.max(0,v-S),U=r/(1+w*2);if(U<.02)continue;let V=1+Math.min(.75,w*.85),O=Math.max(.045,E*1.45*V),N=Math.max(.045,I*1.45*V);Xt.set([p-O,S,x-N,0,0,p+O,S,x-N,1,0,p+O,S,x+N,1,1,p-O,S,x+N,0,1]),e.bufferSubData(34962,0,Xt),e.uniform1f(o.uIntensity,U),e.uniform1f(o.uSoftness,Math.min(1,t.shadowSoftness+Math.min(.45,w*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let t=ge.get(e);t&&(e.deleteVertexArray(t.vao),e.deleteBuffer(t.vbo),e.deleteBuffer(t.ibo),e.deleteProgram(t.prog),ge.delete(e))}};function st(e){let n=e?.extensions?.KHR_materials_variants?.variants;if(!Array.isArray(n))return[];let r=[];for(let o=0;o<n.length&&r.length<256;o++){let a=n[o]?.name;r.push(typeof a=="string"&&a.length>0?a:`Variant_${o}`)}return r}function $t(e){let n=e?.extensions?.KHR_materials_variants?.mappings;if(!Array.isArray(n))return[];let r=[];for(let o of n){if(!o||typeof o!="object")continue;let a=o,d=Number(a.material);if(!Number.isInteger(d)||d<0)continue;let c=[];if(Array.isArray(a.variants))for(let i of a.variants){let l=Number(i);Number.isInteger(l)&&l>=0&&c.push(l)}c.length>0&&r.push({material:d,variants:c})}return r}function jt(e,t,n,r=0){let o=e;if(o&&typeof o.selectVariant=="function"&&!Array.isArray(t))return o.selectVariant(typeof t=="string"?t:null);let a=e,d=Array.isArray(t)?t:[],c=n??null;if(!c)return r;let l=st(a).indexOf(c);if(l<0)return r;for(let s of d)if(s.variants.includes(l))return s.material;return r}var ct={name:"variants",onLoadModel(e,t){let n=e.getVariantName?.();n&&e.selectVariant(n)}};var Kt=new WeakMap,lt={name:"webxr-suite",onConfigureXRSessionInit(e,t){let n=new Set(t.optionalFeatures||[]);n.add("hit-test"),n.add("light-estimation");let r=e?.querySelector?.('[slot="ar-overlay"]')||null;r&&(n.add("dom-overlay"),t.domOverlay={root:r},r.addEventListener?.("beforexrselect",o=>{o.preventDefault()})),t.optionalFeatures=Array.from(n)},onXRFrame(e,t,n,r){if(!e||!t||!n||!r)return;let o=Kt.get(t);if(o||(o={lightProbe:null},Kt.set(t,o),typeof t.requestLightProbe=="function"&&t.requestLightProbe().then(a=>{o&&a&&(o.lightProbe=a)}).catch(()=>{})),o.lightProbe&&typeof n.getLightEstimate=="function"){let a=n.getLightEstimate(o.lightProbe);if(a){let d=a.primaryLightDirection,c=a.primaryLightIntensity;if(d&&c&&Array.isArray(e.lights)){let i=e.lights.find(s=>s.type==="directional");i||(i={type:"directional",direction:[.5,1,.8],color:[1,1,1],intensity:1},e.lights.push(i)),i.direction=[d.x,d.y,d.z];let l=Math.max(c.x,c.y,c.z,.001);i.color=[c.x/l,c.y/l,c.z/l],i.intensity=l}a.sphericalHarmonicsCoefficients&&e.gl&&ve(e.gl,a.sphericalHarmonicsCoefficients)}}}};Z(at);Z(We);Z(Be);Z(Qe);Z(lt);Z(qe);Z(et);Z(ct);Z(ot);
|