three-live 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/index.d.ts +182 -6
- package/dist/three-author-engine.js +66 -41
- package/dist/three-author.cjs +63 -39
- package/dist/three-author.d.ts +182 -6
- package/dist/three-author.js +63 -39
- package/dist/three-convert.cjs +61 -37
- package/dist/three-convert.d.ts +182 -6
- package/dist/three-convert.js +61 -37
- package/dist/three-live-animation.cjs +7 -7
- package/dist/three-live-animation.d.ts +182 -6
- package/dist/three-live-animation.js +7 -7
- package/dist/three-live-animation.min.js +7 -7
- package/dist/three-live-cad.cjs +18 -0
- package/dist/{three-live-extras.d.ts → three-live-cad.d.ts} +182 -6
- package/dist/three-live-cad.js +18 -0
- package/dist/three-live-cad.min.js +18 -0
- package/dist/three-live-element.cjs +29 -5
- package/dist/three-live-element.d.ts +182 -6
- package/dist/three-live-element.js +29 -5
- package/dist/three-live-full.cjs +159 -56
- package/dist/three-live-full.js +159 -56
- package/dist/three-live-full.min.js +159 -56
- package/dist/three-live-studio.cjs +120 -0
- package/dist/three-live-studio.d.ts +509 -0
- package/dist/three-live-studio.js +120 -0
- package/dist/three-live-studio.min.js +120 -0
- package/dist/three-live-viewer.cjs +29 -5
- package/dist/three-live-viewer.d.ts +182 -6
- package/dist/three-live-viewer.js +29 -5
- package/dist/three-live-viewer.min.js +29 -5
- package/dist/three-live.cjs +66 -42
- package/dist/three-live.js +66 -42
- package/dist/three-live.min.js +66 -42
- package/dist/three-view.cjs +29 -5
- package/dist/three-view.d.ts +182 -6
- package/dist/three-view.js +29 -5
- package/dist/three-xr.cjs +65 -41
- package/dist/three-xr.d.ts +182 -6
- package/dist/three-xr.js +65 -41
- package/package.json +10 -5
- package/dist/three-live-extras.cjs +0 -42
- package/dist/three-live-extras.js +0 -42
- package/dist/three-live-extras.min.js +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-live",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Lightweight 3D, WebXR, and procedural Three.js runtime",
|
|
5
5
|
"author": "Google LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -59,10 +59,15 @@
|
|
|
59
59
|
"import": "./dist/three-live-viewer.js",
|
|
60
60
|
"require": "./dist/three-live-viewer.cjs"
|
|
61
61
|
},
|
|
62
|
-
"./
|
|
63
|
-
"types": "./dist/three-live-
|
|
64
|
-
"import": "./dist/three-live-
|
|
65
|
-
"require": "./dist/three-live-
|
|
62
|
+
"./studio": {
|
|
63
|
+
"types": "./dist/three-live-studio.d.ts",
|
|
64
|
+
"import": "./dist/three-live-studio.js",
|
|
65
|
+
"require": "./dist/three-live-studio.cjs"
|
|
66
|
+
},
|
|
67
|
+
"./cad": {
|
|
68
|
+
"types": "./dist/three-live-cad.d.ts",
|
|
69
|
+
"import": "./dist/three-live-cad.js",
|
|
70
|
+
"require": "./dist/three-live-cad.cjs"
|
|
66
71
|
},
|
|
67
72
|
"./animation": {
|
|
68
73
|
"types": "./dist/three-live-animation.d.ts",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
"use strict";var ve=Object.defineProperty;var ln=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var dn=(e,n)=>{for(var t in n)ve(e,t,{get:n[t],enumerable:!0})},mn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of un(n))!fn.call(e,o)&&o!==t&&ve(e,o,{get:()=>n[o],enumerable:!(r=ln(n,o))||r.enumerable});return e};var pn=e=>mn(ve({},"__esModule",{value:!0}),e);var Fn={};dn(Fn,{InteractivityVM:()=>re,contactShadowPlugin:()=>Ne,environmentMapPlugin:()=>Re,getEnvironmentSH:()=>je,getInteractivityVM:()=>ye,hotspotPlugin:()=>Ie,interactivityPlugin:()=>Fe,materialsPlugin:()=>Ce,parseSafeGltfPointer:()=>te,registerMaterialShader:()=>rn,sendInteractivityEvent:()=>ke,setEnvironmentSH:()=>le,webxrPlugin:()=>De});module.exports=pn(Fn);var ce="__THREE_LIVE_REGISTRY__";function Ae(){let e=typeof globalThis<"u"?globalThis:{};if(!e[ce]){let n={plugins:[],decoders:new Map};try{Object.defineProperty(e,ce,{value:n,writable:!1,configurable:!1,enumerable:!1})}catch{e[ce]=n}}return e[ce]}var Cn=Ae().plugins;function Q(e){let n=Ae().plugins;n.some(t=>t.name===e.name)||n.push(e)}function He(){return Ae().plugins}function Be(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function yn(e,n,t){let r=n[0],o=n[1],s=n[2],x=n[3],p=n[4],f=n[5],m=n[6],d=n[7],S=n[8],R=n[9],P=n[10],v=n[11],b=n[12],T=n[13],C=n[14],V=n[15],I=t[0],w=t[1],E=t[2],k=t[3];return e[0]=I*r+w*p+E*S+k*b,e[1]=I*o+w*f+E*R+k*T,e[2]=I*s+w*m+E*P+k*C,e[3]=I*x+w*d+E*v+k*V,I=t[4],w=t[5],E=t[6],k=t[7],e[4]=I*r+w*p+E*S+k*b,e[5]=I*o+w*f+E*R+k*T,e[6]=I*s+w*m+E*P+k*C,e[7]=I*x+w*d+E*v+k*V,I=t[8],w=t[9],E=t[10],k=t[11],e[8]=I*r+w*p+E*S+k*b,e[9]=I*o+w*f+E*R+k*T,e[10]=I*s+w*m+E*P+k*C,e[11]=I*x+w*d+E*v+k*V,I=t[12],w=t[13],E=t[14],k=t[15],e[12]=I*r+w*p+E*S+k*b,e[13]=I*o+w*f+E*R+k*T,e[14]=I*s+w*m+E*P+k*C,e[15]=I*x+w*d+E*v+k*V,e}function bn(e,n,t,r){let o=n[0],s=n[1],x=n[2],p=n[3],f=o+o,m=s+s,d=x+x,S=o*f,R=o*m,P=o*d,v=s*m,b=s*d,T=x*d,C=p*f,V=p*m,I=p*d,w=r[0],E=r[1],k=r[2];return e[0]=(1-(v+T))*w,e[1]=(R+I)*w,e[2]=(P-V)*w,e[3]=0,e[4]=(R-I)*E,e[5]=(1-(S+T))*E,e[6]=(b+C)*E,e[7]=0,e[8]=(P+V)*k,e[9]=(b-C)*k,e[10]=(1-(S+v))*k,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Se(e,n){let t=n[0],r=n[1],o=n[2],s=n[4],x=n[5],p=n[6],f=n[8],m=n[9],d=n[10],S=d*x-p*m,R=-d*s+p*f,P=m*s-x*f,v=t*S+r*R+o*P;return v&&(v=1/v,e[0]=S*v,e[1]=(-d*r+o*m)*v,e[2]=(p*r-o*x)*v,e[3]=R*v,e[4]=(d*t-o*f)*v,e[5]=(-p*t+o*s)*v,e[6]=P*v,e[7]=(-m*t+r*f)*v,e[8]=(x*t-r*s)*v),e}function Ge(e,n){let t=n[0],r=n[1],o=n[2],s=n[3],x=n[4],p=n[5],f=n[6],m=n[7],d=n[8],S=n[9],R=n[10],P=n[11],v=n[12],b=n[13],T=n[14],C=n[15],V=t*p-r*x,I=t*f-o*x,w=t*m-s*x,E=r*f-o*p,k=r*m-s*p,B=o*m-s*f,z=d*b-S*v,H=d*T-R*v,N=d*C-P*v,Y=S*T-R*b,q=S*C-P*b,Z=R*C-P*T,O=V*Z-I*q+w*Y+E*N-k*H+B*z;return O?(O=1/O,e[0]=(p*Z-f*q+m*Y)*O,e[1]=(o*q-r*Z-s*Y)*O,e[2]=(b*B-T*k+C*E)*O,e[3]=(R*k-S*B-P*E)*O,e[4]=(f*N-x*Z-m*H)*O,e[5]=(t*Z-o*N+s*H)*O,e[6]=(T*w-v*B-C*I)*O,e[7]=(d*B-R*w+P*I)*O,e[8]=(x*q-p*N+m*z)*O,e[9]=(r*N-t*q-s*z)*O,e[10]=(v*k-b*w+C*V)*O,e[11]=(S*w-d*k-P*V)*O,e[12]=(p*H-x*Y-f*z)*O,e[13]=(t*Y-r*H+o*z)*O,e[14]=(b*I-v*E-T*V)*O,e[15]=(d*E-S*I+R*V)*O,e):null}function Me(e,n){let t=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let d=0;d<t;d++)r.push(Be());if(t===0)return r;let o=new Set;for(let d of e.nodes)if(Array.isArray(d.children))for(let S of d.children)o.add(S);let s=new Set,x=128,p=(d,S,R=0)=>{if(R>x||d<0||d>=t||s.has(d))return;s.add(d);let P=e.nodes[d];if(!P)return;let v=Be();if(n&&n[d])v.set(n[d]);else if(P.matrix&&P.matrix.length===16)v.set(P.matrix);else{let T=P.translation||[0,0,0],C=P.rotation||[0,0,0,1],V=P.scale||[1,1,1];bn(v,C,T,V)}let b=r[d];if(S?yn(b,S,v):b.set(v),Array.isArray(P.children))for(let T of P.children)typeof T=="number"&&p(T,b,R+1)},f=[],m=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(m&&Array.isArray(m.nodes))f.push(...m.nodes);else for(let d=0;d<t;d++)o.has(d)||f.push(d);for(let d of f)p(d,null);for(let d=0;d<t;d++)!o.has(d)&&!f.includes(d)&&p(d,null);return r}var Te=new WeakMap;function le(e,n){let t=n instanceof Float32Array?n:new Float32Array(n);Te.set(e,t)}function je(e){return Te.get(e)}async function hn(e,n){if(!n)return null;let t;if(typeof n=="string")if(typeof fetch<"u"&&typeof createImageBitmap=="function"){let s=await(await fetch(n)).blob();t=await createImageBitmap(s)}else if(typeof Image<"u")t=await new Promise((o,s)=>{let x=new Image;x.crossOrigin="anonymous",x.onload=()=>o(x),x.onerror=s,x.src=n});else return null;else t=n;let r=e.createTexture();return e.bindTexture(3553,r),e.texImage2D(3553,0,6408,6408,5121,t),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 We=new WeakMap,Xe=new Float32Array(16);async function $e(e,n,t){let r=t?await hn(e.gl,t):null;e[n]&&e.gl.deleteTexture(e[n]),e[n]=r}var Re={name:"environment-map",setEnvironmentImage(e,n){return $e(e,"environmentTexture",n)},setSkyboxImage(e,n){return $e(e,"skyboxTexture",n)},onBeforeDrawScene(e,n,t,r,o){if(!e.skyboxTexture||typeof n.createProgram!="function")return;let s=We.get(n);if(!s){let S=(v,b)=>{let T=n.createShader(v);return n.shaderSource(T,b),n.compileShader(T),T},R=n.createProgram();n.attachShader(R,S(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.);}`)),n.attachShader(R,S(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.);}`)),n.linkProgram(R);let P=typeof n.createVertexArray=="function"?n.createVertexArray():null;s={program:R,vao:P},We.set(n,s)}let x=Ge(Xe,t)||Xe;n.depthMask(!1),n.useProgram(s.program),s.vao&&n.bindVertexArray(s.vao),n.activeTexture(33984),n.bindTexture(3553,e.skyboxTexture);let p=n.getUniformLocation(s.program,"uSkyboxMap");p&&n.uniform1i(p,0);let f=n.getUniformLocation(s.program,"uInvVP");f&&n.uniformMatrix4fv(f,!1,x);let m=n.getUniformLocation(s.program,"uCameraPos");m&&n.uniform3f(m,r[0],r[1],r[2]);let d=n.getUniformLocation(s.program,"uExposure");d&&n.uniform1f(d,e.exposure??1),n.drawArrays(4,0,3),n.depthMask(!0)},onResolveShader(e,n,t,r){if(r.includes("evalSHIrradiance"))return null;let o=r.replace("out vec4 fragColor;",`uniform vec3 uSH[9];
|
|
20
|
-
uniform int uHasSH;
|
|
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
|
-
vec3 evalSHIrradiance(vec3 n){return max(vec3(0.),uSH[0]+uSH[1]*n.y+uSH[2]*n.z+uSH[3]*n.x+uSH[4]*(n.x*n.y)+uSH[5]*(n.y*n.z)+uSH[6]*(3.*n.z*n.z-1.)+uSH[7]*(n.x*n.z)+uSH[8]*(n.x*n.x-n.y*n.y));}
|
|
23
|
-
void main(){`);return o=o.replace(`if(uHasEnvironmentMap==1){
|
|
24
|
-
specularIBL=texture(uEnvironmentMap,equirectangularUV(R)).rgb*(F*brdf.x+brdf.y);
|
|
25
|
-
envDiffuse=texture(uEnvironmentMap,equirectangularUV(N)).rgb;
|
|
26
|
-
}`,`if(uHasEnvironmentMap==1){
|
|
27
|
-
specularIBL=textureLod(uEnvironmentMap,equirectangularUV(R),clamp(roughness*6.0,0.0,6.0)).rgb*integrateBRDFApprox(F,roughness,NoV);
|
|
28
|
-
envDiffuse=uHasSH==1?evalSHIrradiance(N):textureLod(uEnvironmentMap,equirectangularUV(N),5.0).rgb;
|
|
29
|
-
}else if(uHasSH==1){
|
|
30
|
-
specularIBL=getStudioRadiance(R,roughness)*integrateBRDFApprox(F,roughness,NoV);
|
|
31
|
-
envDiffuse=evalSHIrradiance(N);
|
|
32
|
-
}`),{vs:t,fs:o}},onBeforeDrawPrimitive(e,n,t,r,o,s){let x=Te.get(e),p=e.getUniformLocation(n,"uHasSH");if(x&&x.length>=27){p&&e.uniform1i(p,1);let f=e.getUniformLocation(n,"uSH");f&&e.uniform3fv(f,x)}else p&&e.uniform1i(p,0)},onAttributeChanged(e,n,t,r){n==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,r):n==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,r)}};var we=new WeakMap;function Ee(e,n){let t=n||e.viewer;if(!t||typeof t.projectPointToScreen!="function")return;let r=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let o=0;o<r.length;o++){let s=r[o],x=s.getAttribute("data-position");if(!x)continue;let p=x.trim().split(/\s+/).map(S=>parseFloat(S.replace(/m$/,"")));if(p.length<3||p.some(isNaN))continue;let f=s.getAttribute("data-normal"),m;if(f){let S=f.trim().split(/\s+/).map(R=>parseFloat(R));S.length>=3&&!S.some(isNaN)&&(m=[S[0],S[1],S[2]])}let d=t.projectPointToScreen([p[0],p[1],p[2]],m);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transform=`translate(-50%, -50%) translate3d(${d.x}px, ${d.y}px, 0)`,s.style.zIndex="3",d.visible?(s.style.opacity="1",s.style.pointerEvents="auto",s.removeAttribute("data-occluded")):(s.style.opacity="0",s.style.pointerEvents="none",s.setAttribute("data-occluded",""))}}var Ie={name:"hotspots",updateHotspotsForElement:Ee,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let n=new MutationObserver(()=>{Ee(e)});n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),we.set(e,n)},onCameraChange(e,n){n&&Ee(n,e)},onElementDisconnected(e){let n=we.get(e);n&&(n.disconnect(),we.delete(e))}};function ue(e,n,t,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(n,Math.min(t,o))}function gn(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function xn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function qe(e){let n=xn(e);if(!n)return null;let t=n.target;return{target:gn(t)?[t[0],t[1],t[2]]:typeof t=="string"&&t.length>0&&t.length<=256?t:[0,0,0],radius:ue(n.radius,.01,50,.5),speed:ue(n.speed,-20,20,.5),height:ue(n.height,-10,10,0),phase:ue(n.phase,-1e6,1e6,0),faceCenter:n.faceCenter===!0}}function Ke(e,n,t,r){let o=n[0],s=n[1],x=n[2],p=n[3],f=t[0],m=t[1],d=t[2],S=t[3],R=o*f+s*m+x*d+p*S;if(R<0&&(f=-f,m=-m,d=-d,S=-S,R=-R),Math.abs(R)>=1)return e[0]=o,e[1]=s,e[2]=x,e[3]=p,e;let P=Math.acos(R),v=Math.sqrt(1-R*R);if(Math.abs(v)<.001)return e[0]=.5*(o+f),e[1]=.5*(s+m),e[2]=.5*(x+d),e[3]=.5*(p+S),e;let b=Math.sin((1-r)*P)/v,T=Math.sin(r*P)/v;return e[0]=o*b+f*T,e[1]=s*b+m*T,e[2]=x*b+d*T,e[3]=p*b+S*T,e}var Ye=1024,_e=256,fe=2048,vn=128,An=64,Sn=16,Mn=1e4,Tn=8,K=new Set(["__proto__","constructor","prototype"]),Ze={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))},Qe={add:(e,n)=>e+n,sub:(e,n)=>e-n,mul:(e,n)=>e*n,div:(e,n)=>Math.abs(n)<1e-12?0:e/n,rem:(e,n)=>Math.abs(n)<1e-12?0:e%n,mod:(e,n)=>Math.abs(n)<1e-12?0:e%n,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},de={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},me=(e,n)=>e!==null&&typeof e=="object"&&!K.has(n)&&Object.prototype.hasOwnProperty.call(e,n),W=e=>Array.isArray(e)?[...e]:e,tn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&me(e,"value")?e.value:e,U=(e,n)=>me(e.configuration,n)?tn(e.configuration[n]):void 0,A=(e,n=0)=>{let t=Number(e);return Number.isFinite(t)?t:n},J=e=>Math.max(0,Math.min(1,e)),X=e=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!Number.isNaN(e):typeof e=="string"?e.length>0&&e!=="false":!!e;function te(e){if(typeof e!="string"||!e.startsWith("/"))return null;let n=[];for(let t of e.slice(1).split("/")){let r=t.replace(/~1/g,"/").replace(/~0/g,"~");if(!r||K.has(r)||K.has(t))return null;n.push(r)}return{segments:n}}var ne=(e,n)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<n?t:-1},Je=e=>{let n=A(e[0]),t=A(e[1]),r=A(e[2]),o=A(e[3],1),s=Math.hypot(n,t,r,o);return s>1e-8?[n/s,t/s,r/s,o/s]:[0,0,0,1]},en=(e,n,t,r)=>{if(typeof e=="number"&&typeof n=="number")return e+(n-e)*t;if(Array.isArray(e)&&Array.isArray(n)){if(r&&e.length===4&&n.length===4){let o=[0,0,0,1];return Ke(o,Je(e),Je(n),t),o}return e.slice(0,n.length).map((o,s)=>o+(n[s]-o)*t)}return t>=.5?n:e},Pe=(e,n,t)=>Array.isArray(e)&&Array.isArray(n)?e.slice(0,n.length).map((r,o)=>t(A(r),A(n[o]))):Array.isArray(e)?e.map(r=>t(A(r),A(n))):Array.isArray(n)?n.map(r=>t(A(e),A(r))):t(A(e),A(n)),Rn=(e,n)=>Array.isArray(e)?e.map(t=>n(A(t))):n(A(e)),nn=(e,n)=>Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every((t,r)=>Math.abs(t-n[r])<=1e-6):e===n,re=class{constructor(n,t,r){let o=Array.isArray(r.nodes)?r.nodes:[];if(o.length>Ye)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${Ye})`);let s=Array.isArray(r.variables)?r.variables:[];if(s.length>_e)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${_e})`);let x=Array.isArray(r.declarations)?r.declarations:[],p=Array.isArray(r.events)?r.events:[],f=new Map,m=new Map,d=new Map,S=new Map,R=new Map,P=new Map,v=[],b=[],T=new Map,C=1,V=0,I=0,w=0,E=0,k=!1,B=!1,z=!1;s.forEach((l,u)=>{if(!l||typeof l!="object")return;let h=W(tn(l.value));f.set(u,h);let g=l.id??l.name;typeof g=="string"&&g&&!K.has(g)&&f.set(g,h)}),(t?.nodes||[]).forEach((l,u)=>{for(let h of l?.children||[])typeof h=="number"&&T.set(h,u)});let H=l=>l.op||typeof l.declaration=="number"&&x[l.declaration]?.op||"",N=(l,u,h)=>{if(K.has(u))return;let g=m.get(l);g||m.set(l,g=Object.create(null)),g[u]=h},Y=(l,u)=>{if(typeof l!="number"&&typeof l!="string"||typeof l=="string"&&K.has(l)||!f.has(l)&&f.size>=_e*2)return;let h=W(u);if(f.set(l,h),typeof l=="number"){let g=s[l]?.id??s[l]?.name;typeof g=="string"&&!K.has(g)&&f.set(g,h)}},q=l=>typeof l=="number"?p[l]?.id??String(l):typeof l=="string"?/^\d+$/.test(l)&&p[Number(l)]?.id?p[Number(l)].id:l:"",Z=(l,u)=>{for(let h=l,g=0;h!==void 0&&h>=0&&g<128;h=T.get(h),g++)if(h===u)return!0;return!1},O=l=>{for(let u=v.length-1;u>=0;u--)v[u].key===l&&v.splice(u,1)},Ue=l=>{O(l.key),v.length>=vn&&v.shift(),v.push(l)},he=l=>{let u=te(l)?.segments;if(u){if(u[0]==="nodes"&&Array.isArray(t?.nodes)){let h=t.nodes[ne(u[1],t.nodes.length)];if(!h)return;let g=u[2];if(g in de){let c=de[g],a=h[g]||c;return c.map((i,y)=>A(a[y],i))}if(g==="weights"){let c=Array.isArray(h.weights)?h.weights:[0],a=u.length===4?ne(u[3],64):-2;return a===-2?c.map(i=>A(i)):a>=0?A(c[a]):void 0}if(g==="visible"||g==="extensions"&&u[3]==="KHR_node_visibility"&&u[4]==="visible")return h.extensions?.KHR_node_visibility?.visible??h.visible??!0}else if(u[0]==="materials"&&Array.isArray(t?.materials)){let h=t.materials[ne(u[1],t.materials.length)];if(!h)return;let g=h.pbrMetallicRoughness||{};if(u[2]==="pbrMetallicRoughness"){if(u[3]==="baseColorFactor"){let c=g.baseColorFactor||[1,1,1,1];return[A(c[0],1),A(c[1],1),A(c[2],1),A(c[3],1)]}if(u[3]==="metallicFactor"||u[3]==="roughnessFactor")return A(g[u[3]],1)}if(u[2]==="emissiveFactor"){let c=h.emissiveFactor||[0,0,0];return[A(c[0]),A(c[1]),A(c[2])]}if(u[2]==="alphaCutoff")return A(h.alphaCutoff,.5)}}},ae=(l,u)=>{let h=te(l)?.segments;if(!h)return!1;if(h[0]==="nodes"&&Array.isArray(t?.nodes)){let g=ne(h[1],t.nodes.length),c=t.nodes[g];if(!c)return!1;let a=h[2];if(a in de&&Array.isArray(u)){let i=de[a];if(u.length<i.length)return!1;let y=i.map((L,D)=>A(u[D],L));if(a==="rotation"){let L=Math.hypot(...y);y=L>1e-8?y.map(D=>D/L):[0,0,0,1]}c[a]=y,delete c.matrix;let F=n?.initialNodeTransforms?.[g];return F&&(F[a[0]]=[...y]),k=!0,!0}if(a==="weights"){Array.isArray(c.weights)||(c.weights=[]);let i=(y,F)=>{for(let L of n?.meshes||[])if(L.nodeIndex===g)for(let D of L.primitives||[])D.pluginData?.morph?.weights&&(D.pluginData.morph.weights[y]=F)};if(h.length===4){let y=ne(h[3],64);if(y<0)return!1;i(y,c.weights[y]=A(u))}else if(Array.isArray(u))c.weights=u.slice(0,64).map(y=>A(y)),c.weights.forEach((y,F)=>i(F,y));else return!1;return z=!0,!0}if(a==="visible"||a==="extensions"&&h[3]==="KHR_node_visibility"&&h[4]==="visible"){let i=X(u);return c.visible=i,(!c.extensions||typeof c.extensions!="object")&&(c.extensions={}),c.extensions.KHR_node_visibility={visible:i},B=!0,!0}}else if(h[0]==="materials"&&Array.isArray(t?.materials)){let g=ne(h[1],t.materials.length),c=t.materials[g];if(!c)return!1;let a=c.pbrMetallicRoughness||(c.pbrMetallicRoughness={}),i=y=>{for(let F of n?.meshes||[])for(let L of F.primitives||[])(L.materialIndex??0)===g&&y(L)};if(h[2]==="pbrMetallicRoughness"){if(h[3]==="baseColorFactor"&&Array.isArray(u)&&u.length>=3){let y=[J(A(u[0],1)),J(A(u[1],1)),J(A(u[2],1)),u[3]!==void 0?J(A(u[3],1)):a.baseColorFactor?.[3]??1];return a.baseColorFactor=y,i(F=>F.baseColor=[...y]),z=!0}if(h[3]==="metallicFactor"||h[3]==="roughnessFactor"){let y=h[3]==="metallicFactor",F=J(A(u,y?0:.5));return a[h[3]]=F,i(L=>L[y?"metallic":"roughness"]=F),z=!0}}if(h[2]==="emissiveFactor"&&Array.isArray(u)&&u.length>=3)return c.emissiveFactor=[0,1,2].map(y=>Math.max(0,A(u[y]))),z=!0;if(h[2]==="alphaCutoff")return c.alphaCutoff=J(A(u,.5)),z=!0}return!1},ge=(l,u,h=new Set)=>{let g=U(u,"pointer");if(typeof g!="string"||!g.startsWith("/"))return null;let c=g.replace(/\{([a-zA-Z0-9_]+)\}/g,(a,i)=>{let y=Math.trunc(Number(ie(l,i,void 0,h)??U(u,i)));return Number.isSafeInteger(y)&&y>=0?String(y):"-1"});return te(c)?c:null},ie=(l,u,h,g)=>{let c=o[l]?.values;if(!me(c,u))return h;let a=c[u];if(a==null)return h;if(typeof a!="object"||Array.isArray(a))return W(a);let i=a;return typeof i.node=="number"?sn(i.node,i.socket||"value",g):me(i,"value")?W(i.value):h},sn=(l,u,h)=>{if(l<0||l>=o.length||h.has(l)||h.size>128||++w>Mn)return;let g=o[l],c=H(g);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(c))return W(m.get(l)?.[u]);h.add(l);try{let a=(i,y=0)=>ie(l,i,y,h);if(c==="variable/get"){let i=U(g,"variable")??U(g,"id");return typeof i=="number"||typeof i=="string"?W(f.get(i)):void 0}if(c==="pointer/get"){let i=ge(l,g,h);return i?he(i):void 0}if(c.startsWith("math/")){let i=c.slice(5);if(i in Ze)return Rn(a("a"),Ze[i]);if(i in Qe){let y=/^(mul|div|rem|mod|pow)$/.test(i)?1:0;return Pe(a("a",i==="mul"?1:0),a("b",y),Qe[i])}if(i==="pi")return Math.PI;if(i==="e")return Math.E;if(i==="random")return Math.random();if(i==="clamp")return Pe(Pe(a("a"),a("b",a("min",0)),Math.max),a("c",a("max",1)),Math.min);if(i==="mix"||i==="quatSlerp")return en(a("a",0),a("b",1),A(a("c",a("t",.5)),.5),i==="quatSlerp");if(i==="dot"){let y=a("a"),F=a("b");return Array.isArray(y)&&Array.isArray(F)?y.reduce((L,D,M)=>L+(D||0)*(F[M]||0),0):A(y)*A(F)}if(i==="cross"){let y=a("a",[0,0,0]),F=a("b",[0,0,0]);return Array.isArray(y)&&Array.isArray(F)?[(y[1]||0)*(F[2]||0)-(y[2]||0)*(F[1]||0),(y[2]||0)*(F[0]||0)-(y[0]||0)*(F[2]||0),(y[0]||0)*(F[1]||0)-(y[1]||0)*(F[0]||0)]:[0,0,0]}if(i==="length"){let y=a("a");return Array.isArray(y)?Math.hypot(...y):Math.abs(A(y))}if(i==="distance"){let y=a("a"),F=a("b");return Array.isArray(y)&&Array.isArray(F)?Math.hypot(...y.map((L,D)=>(L||0)-(F[D]||0))):Math.abs(A(y)-A(F))}if(i==="normalize"){let y=a("a");if(!Array.isArray(y))return A(y)>=0?1:-1;let F=Math.hypot(...y);return F>1e-8?y.map(L=>L/F):y.map(()=>0)}if(i.startsWith("combine"))return["a","b","c","d"].slice(0,Number(i[7])||2).map(y=>A(a(y)));if(i.startsWith("extract")){let y=a("a");return Array.isArray(y)?y[u==="0"||u==="x"?0:u==="1"||u==="y"?1:u==="2"||u==="z"?2:3]??0:0}if(i==="eq")return nn(a("a"),a("b"));if(i==="ne")return!nn(a("a"),a("b"));if(i==="lt")return A(a("a"))<A(a("b"));if(i==="le")return A(a("a"))<=A(a("b"));if(i==="gt")return A(a("a"))>A(a("b"));if(i==="ge")return A(a("a"))>=A(a("b"));if(i==="isNaN")return Number.isNaN(Number(a("a")));if(i==="isInf"){let y=Number(a("a"));return!Number.isFinite(y)&&!Number.isNaN(y)}return i==="and"?X(a("a",!1))&&X(a("b",!1)):i==="or"?X(a("a",!1))||X(a("b",!1)):i==="xor"?X(a("a",!1))!==X(a("b",!1)):i==="not"?!X(a("a",!1)):i==="select"?W(X(a("condition",!1))?a("a"):a("b")):void 0}return c==="type/boolToInt"||c==="type/boolToFloat"?X(a("a",!1))?1:0:c==="type/intToBool"||c==="type/floatToBool"?A(a("a",0))!==0:c==="type/intToFloat"?A(a("a",0)):c==="type/floatToInt"?Math.trunc(A(a("a",0))):void 0}finally{h.delete(l)}},se=()=>{if(k){k=!1,z=!0;let l=Me(t);if(n){n.worldMatrices=l;for(let u of n.meshes||[])u.nodeIndex>=0&&u.nodeIndex<l.length&&(u.transform.set(l[u.nodeIndex]),Se(u.normalMatrix,u.transform))}}if(B){B=!1,z=!0;let l=t?.nodes;if(Array.isArray(n?.meshes)&&Array.isArray(l))for(let u of n.meshes){let h=!0;for(let g=u.nodeIndex,c=0;g!==void 0&&g>=0&&c<128;g=T.get(g),c++){let a=l[g];if(a?.visible===!1||a?.extensions?.KHR_node_visibility?.visible===!1){h=!1;break}}u.visible=h}}z&&(z=!1,n?.render?.())},ee=(l,u={steps:0})=>{if(!l||typeof l.node!="number")return;u.steps===0&&(w=0);let h=[l],g=c=>{h.length+u.steps<fe&&h.push(c)};for(;h.length>0&&u.steps<fe;){u.steps++;let c=h.shift();if(!c||c.node<0||c.node>=o.length)continue;let a=c.node,i=o[a];if(!i)continue;let y=c.socket||"in",F=H(i),L=(M,_=void 0)=>ie(a,M,_,new Set),D=(M="out")=>{let _=i.flows?.[M];_&&g(_)};switch(F){case"flow/branch":D(X(L("condition",!1))?"true":"false");break;case"flow/sequence":for(let M of Object.keys(i.flows||{}).sort((_,G)=>Number(_)-Number(G)||_.localeCompare(G)))D(M);break;case"flow/switch":{let M=i.flows?.[String(L("selection",L("value",0)))]??i.flows?.default;M&&g(M);break}case"flow/for":{let M=Math.trunc(A(L("startIndex",0))),_=Math.trunc(A(L("endIndex",0))),G=Math.max(1,Math.trunc(A(L("step",1),1))),$=i.flows?.body;if($&&_>M&&E<Tn){let cn=Math.min(Math.ceil((_-M)/G),fe);E++;try{for(let xe=0;xe<cn&&u.steps<fe;xe++)N(a,"index",M+xe*G),ee($,u)}finally{E--}}let Oe=i.flows?.completed??i.flows?.out;Oe&&g(Oe);break}case"flow/doN":{let M=y==="reset"?0:(d.get(a)||0)+1;if(d.set(a,M),N(a,"currentCount",M),N(a,"count",M),y!=="reset"){let _=Math.trunc(A(L("n",U(i,"stopIterations")??U(i,"n")??1),1));M<=_&&D()}break}case"flow/multiGate":{if(y==="reset"){P.set(a,0);break}let M=Object.keys(i.flows||{}).sort();if(!M.length)break;let _=U(i,"isRandom")?Math.floor(Math.random()*M.length):P.get(a)||0;_<M.length&&(D(M[_]),P.set(a,U(i,"isLoop")!==!1?(_+1)%M.length:_+1));break}case"flow/waitAll":{if(y==="reset"){S.delete(a);break}let M=S.get(a);M||S.set(a,M=new Set),M.add(y),M.size>=Math.max(1,Math.trunc(Number(U(i,"inputFlows")??2)||2))&&(M.clear(),D("out"),D("completed"));break}case"flow/throttle":{if(y==="reset"){R.delete(a);break}let M=Math.max(0,A(L("duration",0))),_=R.get(a);_===void 0||V-_>=M?(R.set(a,V),N(a,"lastRemainingTime",0),D()):N(a,"lastRemainingTime",Math.max(0,M-(V-_)));break}case"flow/delay":case"flow/setDelay":{if(y==="cancel"){for(let $=b.length-1;$>=0;$--)b[$].nodeIdx===a&&b.splice($,1);N(a,"lastDelayIndex",-1);break}let M=Math.max(0,A(L("duration",U(i,"duration")??0))),_=i.flows?.done??i.flows?.out;if(M<=0){N(a,"lastDelayIndex",-1),_&&g(_);break}b.length>=An&&b.shift();let G=C++;N(a,"lastDelayIndex",G),b.push({id:G,nodeIdx:a,rem:M,done:_}),F==="flow/setDelay"&&i.flows?.out&&i.flows?.done&&D("out");break}case"flow/cancelDelay":{let M=Math.trunc(A(L("delayIndex",-1),-1));if(M<0)b.length=0;else for(let _=b.length-1;_>=0;_--)b[_].id===M&&b.splice(_,1);D();break}case"variable/set":Y(U(i,"variable")??U(i,"id"),L("value")),D();break;case"variable/interpolate":{let M=U(i,"variable")??U(i,"id"),_=L("value",L("target")),G=Math.max(0,A(L("duration",U(i,"duration")??.3),.3));M!==void 0&&_!==void 0&&Ue({key:`var:${String(M)}`,varKey:M,from:W(L("from")??f.get(M)??0),to:W(_),dur:G,elapsed:0,quat:!1,linear:U(i,"easing")==="linear",done:i.flows?.done}),D();break}case"pointer/set":{let M=ge(a,i),_=L("value");M&&_!==void 0&&(O(`ptr:${M}`),ae(M,_)),D();break}case"pointer/interpolate":{let M=ge(a,i),_=L("value",L("target")),G=Math.max(0,A(L("duration",U(i,"duration")??.3),.3));if(M&&_!==void 0){let $=L("from")??he(M);$!==void 0&&(G<=0?(ae(M,_),D("done")):Ue({key:`ptr:${M}`,ptr:M,from:W($),to:W(_),dur:G,elapsed:0,quat:M.endsWith("/rotation"),linear:U(i,"easing")==="linear",done:i.flows?.done}))}D();break}case"animation/start":{let M=L("animation")??U(i,"animation")??U(i,"clipName"),_=typeof M=="number"?n?.animations?.[M]?.name??t?.animations?.[M]?.name:typeof M=="string"?M:void 0;n?.playAnimation?.(_),z=!0,D();break}case"animation/stop":case"animation/resetAt":n?.pauseAnimation?.(),F==="animation/resetAt"&&n?.evaluateAnimation?.(A(L("time",0))),z=!0,D();break;case"event/send":case"customEvent/send":{let M=q(U(i,"event")??U(i,"id")),_={};for(let G of Object.keys(i.values||{}))K.has(G)||(_[G]=L(G));M&&(typeof CustomEvent<"u"&&typeof n?.container?.dispatchEvent=="function"&&n.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:M,values:_}})),ze(M,_,u)),D();break}default:D();break}}};this.readScenePointer=he,this.writeScenePointer=ae,this.fireOnStart=()=>{o.forEach(l=>{H(l)==="event/onStart"&&ee(l.flows?.out)}),se()},this.fireOnSelect=l=>{if(!l)return;let u=typeof l.meshIndex=="number"?l.meshIndex:-1,h=typeof l.nodeIndex=="number"?l.nodeIndex:n?.meshes?.[u]?.nodeIndex??-1;o.forEach((g,c)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(H(g)))return;let a=U(g,"nodeIndex")??U(g,"node")??ie(c,"nodeIndex",void 0,new Set),i=U(g,"meshName");if(typeof i=="string"&&i?l.meshName===i:a==null||Number(a)<0||Number.isNaN(Number(a))||Z(h,Math.trunc(Number(a)))){if(N(c,"nodeIndex",h),N(c,"meshIndex",u),Array.isArray(l.hitPoint)){let F=[A(l.hitPoint[0]),A(l.hitPoint[1]),A(l.hitPoint[2])];N(c,"hitPoint",F),N(c,"point",F),N(c,"intersectionPoint",F)}if(Array.isArray(l.normal)){let F=[A(l.normal[0]),A(l.normal[1],1),A(l.normal[2])];N(c,"normal",F),N(c,"hitNormal",F)}typeof l.distance=="number"&&N(c,"distance",l.distance),ee(g.flows?.out)}}),se()},this.receiveCustomEvent=(l,u={})=>ze(l,u,{steps:0});function ze(l,u,h){if(!(I>=Sn)){I++;try{let g=q(l);o.forEach((c,a)=>{if(!/^(customE|e)vent\/receive$/.test(H(c)))return;let i=U(c,"event")??U(c,"id");if(!(q(i)!==g&&String(i)!==String(l))){for(let[y,F]of Object.entries(u))K.has(y)||N(a,y,W(F));ee(c.flows?.out,h)}}),se()}finally{I--}}}this.tick=l=>{if(!Number.isFinite(l)||l<0)return;let u=Math.min(l,.25);V+=u,o.forEach((g,c)=>{H(g)==="event/onTick"&&(N(c,"timeDelta",u),N(c,"dt",u),N(c,"timeElapsed",V),ee(g.flows?.out))});let h=[];for(let g=v.length-1;g>=0;g--){let c=v[g];c.elapsed+=u;let a=c.dur>1e-6?J(c.elapsed/c.dur):1,i=c.linear?a:a*a*(3-2*a),y=en(c.from,c.to,i,c.quat);c.ptr?ae(c.ptr,y):c.varKey!==void 0&&Y(c.varKey,y),a>=1&&(v.splice(g,1),c.done&&h.push(c.done))}for(let g=b.length-1;g>=0;g--){let c=b[g];c.rem-=u,c.rem<=0&&(b.splice(g,1),c.done&&h.push(c.done))}for(let g of h)ee(g);se()},this.dispose=()=>{v.length=0,b.length=0,f.clear(),m.clear(),d.clear(),S.clear(),R.clear(),P.clear()}}},j=new WeakMap,pe=new WeakMap;function wn(e,n){if(!e||typeof e!="object"||!Number.isFinite(n)||n<=0||He().some(p=>p.name==="xr-live-head-follow"))return;let t=e.gltf,r=t?.nodes;if(!Array.isArray(r)||r.length===0)return;let o=Math.min(n,.1),s=(pe.get(e)||0)+o,x=!1;for(let p=0;p<r.length;p++){let f=r[p],m=qe(f?.extras?.xr?.orbit);if(!m)continue;let d=0,S=0,R=0;if(Array.isArray(m.target))d=m.target[0],S=m.target[1],R=m.target[2];else if(typeof m.target=="string"&&m.target!=="head"){let C=r.find(V=>V?.name===m.target);Array.isArray(C?.translation)&&(d=A(C.translation[0]),S=A(C.translation[1]),R=A(C.translation[2]))}let P=m.phase+m.speed*s,v=d+Math.cos(P)*m.radius,b=S+m.height,T=R+Math.sin(P)*m.radius;if(f.translation=[v,b,T],m.faceCenter){let C=Math.atan2(d-v,R-T);f.rotation=[0,Math.sin(C*.5),0,Math.cos(C*.5)]}x=!0}if(x){pe.set(e,s);let p=Me(t);e.worldMatrices=p;for(let f of e.meshes||[])f.nodeIndex>=0&&f.nodeIndex<p.length&&(f.transform.set(p[f.nodeIndex]),Se(f.normalMatrix,f.transform))}}function ye(e){if(!(!e||typeof e!="object"))return j.get(e)||j.get(e.viewer)||j.get(e._view)}function ke(e,n,t){let r=ye(e);return r?(r.receiveCustomEvent(n,t),!0):!1}var Fe={name:"khr-interactivity",sendInteractivityEvent:ke,getInteractivityVM:ye,onLoadModel(e,n){if(!e||typeof e!="object")return;j.get(e)?.dispose(),j.delete(e),pe.delete(e);let t=n?.extensions?.KHR_interactivity,r=Array.isArray(t?.graphs)?t.graphs[t.graph??0]:t;if(!r||!Array.isArray(r.nodes))return;let o=new re(e,n,r);j.set(e,o),o.fireOnStart()},onMeshSelect(e,n){j.get(e)?.fireOnSelect(n)},onUpdate(e,n){j.get(e)?.tick(n),wn(e,n)},onDestroy(e,n){j.get(n)?.dispose(),j.delete(n),pe.delete(n)}};var oe=new Map,Le=new WeakMap;function rn(e,n){oe.set(e,n)}var Ce={name:"materials",onBuildPrimitiveVAO(e,n,t,r,o){return(((r?.materials&&t.material!==void 0?r.materials[t.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,n){let t=Le.get(e);t||(t=e.createTexture(),Le.set(e,t));let r=Math.max(1,n.canvas.width),o=Math.max(1,n.canvas.height);e.activeTexture(33990),e.bindTexture(3553,t),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,n,t,r){if(!n)return null;if(n.name&&oe.has(n.name)){let v=oe.get(n.name);return{vs:v.vs||t,fs:v.fs||r}}let o=n.extensions||{},s=o.KHR_materials_clearcoat,x=o.KHR_materials_sheen,p=!!o.KHR_materials_transmission,f=!!o.KHR_materials_ior,m=o.KHR_materials_iridescence;if(!s&&!x&&!o.KHR_materials_unlit&&!p&&!o.KHR_materials_volume&&!f&&!o.KHR_materials_dispersion&&!m)return null;if(o.KHR_materials_unlit)return{vs:t,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 d=r;if(p){let v=d.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
|
|
33
|
-
`;d=d.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
|
|
34
|
-
${v}out vec4 fragColor;`)}let S=(v,b,T=0,C=1e6,V=3)=>{let I=Number(v);return(Number.isFinite(I)?Math.min(C,Math.max(T,I)):b).toFixed(V)},R=Number(o.KHR_materials_ior?.ior??1.5),P=Number.isFinite(R)?Math.min(10,Math.max(1,R)):1.5;if(f){let v=Math.pow((P-1)/(P+1),2);d=d.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${S(v,.04,0,1,4)}),base.rgb,metallic);`)}if(m){let v=S(m.iridescenceFactor,1,0,1),b=S(m.iridescenceIor,1.3,1,10);d=d.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${b}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${v}*pow(1.-NoV,2.));`)}if(p){let v=S(o.KHR_materials_transmission?.transmissionFactor,1,0,1),b=o.KHR_materials_volume||{},T=S(b.thicknessFactor,.5,0,1e4),C=S(b.attenuationDistance,1,.001,1e6),V=Array.isArray(b.attenuationColor)?b.attenuationColor:[1,1,1],I=S(o.KHR_materials_dispersion?.dispersion,0,0,10);d=d.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=${S(P,1.5,1,10)},dV=${I},tV=${T},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
|
|
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
|
-
vec3 tr=vec3(textureLod(uTransmissionTex,clamp(sUV+refractedR.xy*sc,.001,.999),lod).r,textureLod(uTransmissionTex,clamp(sUV+rG.xy*sc,.001,.999),lod).g,textureLod(uTransmissionTex,clamp(sUV+refractedB.xy*sc,.001,.999),lod).b);
|
|
38
|
-
vec3 aCol=vec3(${S(V[0],1,0,1)},${S(V[1],1,0,1)},${S(V[2],1,0,1)});
|
|
39
|
-
vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${C},.001));
|
|
40
|
-
diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${v});`)}if(s&&!r.includes("uClearcoat")){let v=S(s.clearcoatFactor,1,0,1),b=S(s.clearcoatRoughnessFactor,0,0,1);d=d.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${b},NoV)*${v};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${b})*ccF;fragColor=vec4(color,base.a);`)}if(x){let v=Array.isArray(x.sheenColorFactor)?x.sheenColorFactor:[1,1,1],b=`color+=vec3(${S(v[0],1,0,1)},${S(v[1],1,0,1)},${S(v[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;d.includes("color=applyToneMapping(color,uToneMapping);")?d=d.replace("color=applyToneMapping(color,uToneMapping);",`${b}color=applyToneMapping(color,uToneMapping);`):d=d.replace("fragColor=vec4(color,base.a);",`${b}fragColor=vec4(color,base.a);`)}return{vs:t,fs:d}},onBeforeDrawPrimitive(e,n,t,r,o,s){let x=t.materialIndex;if(x!==void 0&&s?.materials){let p=s.materials[x];p?.name&&oe.has(p.name)&&oe.get(p.name).onBindUniforms?.(e,n,t)}if(t.isTransmissive){let p=Le.get(e);if(p){e.activeTexture(33990),e.bindTexture(3553,p);let f=e.getUniformLocation(n,"uTransmissionTex");f&&e.uniform1i(f,6);let m=e.getUniformLocation(n,"uViewportSize");m&&e.uniform2f(m,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var In=`#version 300 es
|
|
41
|
-
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.);}`,_n=`#version 300 es
|
|
42
|
-
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);}`,be=new WeakMap,on=new Float32Array(20);function Ve(e,n){let[t,r,o,s,x,p]=n;return[e[0]*t+e[4]*r+e[8]*o+e[12],e[1]*t+e[5]*r+e[9]*o+e[13],e[2]*t+e[6]*r+e[10]*o+e[14],Math.abs(e[0])*s+Math.abs(e[4])*x+Math.abs(e[8])*p,Math.abs(e[1])*s+Math.abs(e[5])*x+Math.abs(e[9])*p,Math.abs(e[2])*s+Math.abs(e[6])*x+Math.abs(e[10])*p]}function Pn(e){if(e._lb!==void 0)return e._lb;let n=1e9,t=1e9,r=1e9,o=-1e9,s=-1e9,x=-1e9;for(let p of e.primitives||[]){let f=p.positions;if(f)for(let m=0;m<f.length;m+=3)f[m]<n&&(n=f[m]),f[m+1]<t&&(t=f[m+1]),f[m+2]<r&&(r=f[m+2]),f[m]>o&&(o=f[m]),f[m+1]>s&&(s=f[m+1]),f[m+2]>x&&(x=f[m+2])}return e._lb=n<=o?[(n+o)*.5,(t+s)*.5,(r+x)*.5,(o-n)*.5,(s-t)*.5,(x-r)*.5]:null}function kn(e){let n=be.get(e);if(n)return n;let t=(p,f)=>{let m=e.createShader(p);return e.shaderSource(m,f),e.compileShader(m),m},r=e.createProgram();e.attachShader(r,t(35633,In)),e.attachShader(r,t(35632,_n)),e.linkProgram(r);let o=e.createVertexArray(),s=e.createBuffer(),x=e.createBuffer();return e.bindVertexArray(o),e.bindBuffer(34962,s),e.bufferData(34962,80,35048),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,5126,!1,20,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,5126,!1,20,12),e.bindBuffer(34963,x),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),n={prog:r,vao:o,vbo:s,ibo:x,uMVP:e.getUniformLocation(r,"uMVP"),uIntensity:e.getUniformLocation(r,"uShadowIntensity"),uSoftness:e.getUniformLocation(r,"uShadowSoftness")},be.set(e,n),n}var Ne={name:"contact-shadow",onAfterRender(e,n,t){let r=n.shadowIntensity;if(r<=0||!n.bounds)return;let o=kn(e),s=!n.xrSessionActive&&(n.backdropMeshes?.length??0)>0,x=[],p=[];for(let b of n.meshes||[]){if(!b||b.visible===!1||b.isPluginMesh||b.name==="__xr_reticle__"||b.name?.startsWith("__xr_slot_"))continue;let T=Pn(b);if(!T)continue;b.transform&&(T=Ve(b.transform,T)),n.modelRootMatrix&&(T=Ve(n.modelRootMatrix,T));let[C,V,I,w,E,k]=T,B=[C,I,w,k,V-E,V+E];/floor|table|pedestal|ground|base|plane/i.test(b.name||"")||E<.14&&Math.min(w,k)>.45?p.push(B):x.push(B)}let f=[],m=n.bounds.center||[0,0,0],d=Math.max(.05,Number(n.bounds.radius)||.5),S=n.bounds.min,R=S?[m[0],m[1],m[2],d,Math.max(.01,m[1]-S[1]),d]:[m[0],m[1],m[2],d,d,d];n.modelRootMatrix&&(R=Ve(n.modelRootMatrix,R));let v=n.xrSessionActive&&p.length===0&&String(n.container?.tagName||"").toLowerCase()==="xr-live"?(n.modelRootMatrix?n.modelRootMatrix[5]*-.25+n.modelRootMatrix[13]:-.25)+.002:R[1]-R[4]+.002;for(let[b,T,C,V,I]of x){let w=-1/0;for(let[k,B,z,H,,N]of p)I>=N-.08&&Math.abs(b-k)<=z&&Math.abs(T-B)<=H&&N+.002>w&&(w=N+.002);s&&(w=Math.max(w,b>=.04&&b<=.36&&T>=-.34&&T<=-.04&&I>=.01?.036:Math.hypot(b,T)<=.66&&I>=-.06?.003:-.477)),isFinite(w)||(w=v);let E=f.find(k=>Math.hypot(b-k[0],T-k[1])<.06&&Math.abs(w-k[5])<.05);E?(E[2]=Math.max(E[2],C*.78),E[3]=Math.max(E[3],V*.78),E[4]=Math.min(E[4],I)):f.push([b,T,C,V,I,w])}if(f.length===0){let b=Math.max(.1,R[3]*1.5)/1.45;f.push([R[0],R[2],b,b,v,v])}e.useProgram(o.prog),e.uniformMatrix4fv(o.uMVP,!1,t),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[b,T,C,V,I,w]of f){let E=Math.max(0,I-w),k=r/(1+E*2);if(k<.02)continue;let B=1+Math.min(.75,E*.85),z=Math.max(.045,C*1.45*B),H=Math.max(.045,V*1.45*B);on.set([b-z,w,T-H,0,0,b+z,w,T-H,1,0,b+z,w,T+H,1,1,b-z,w,T+H,0,1]),e.bufferSubData(34962,0,on),e.uniform1f(o.uIntensity,k),e.uniform1f(o.uSoftness,Math.min(1,n.shadowSoftness+Math.min(.45,E*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let n=be.get(e);n&&(e.deleteVertexArray(n.vao),e.deleteBuffer(n.vbo),e.deleteBuffer(n.ibo),e.deleteProgram(n.prog),be.delete(e))}};var an=new WeakMap,De={name:"webxr-suite",onConfigureXRSessionInit(e,n){let t=new Set(n.optionalFeatures||[]);t.add("hit-test"),t.add("light-estimation");let r=e?.querySelector?.('[slot="ar-overlay"]')||null;r&&(t.add("dom-overlay"),n.domOverlay={root:r},r.addEventListener?.("beforexrselect",o=>{o.preventDefault()})),n.optionalFeatures=Array.from(t)},onXRFrame(e,n,t,r){if(!e||!n||!t||!r)return;let o=an.get(n);if(o||(o={lightProbe:null},an.set(n,o),typeof n.requestLightProbe=="function"&&n.requestLightProbe().then(s=>{o&&s&&(o.lightProbe=s)}).catch(()=>{})),o.lightProbe&&typeof t.getLightEstimate=="function"){let s=t.getLightEstimate(o.lightProbe);if(s){let x=s.primaryLightDirection,p=s.primaryLightIntensity;if(x&&p&&Array.isArray(e.lights)){let f=e.lights.find(d=>d.type==="directional");f||(f={type:"directional",direction:[.5,1,.8],color:[1,1,1],intensity:1},e.lights.push(f)),f.direction=[x.x,x.y,x.z];let m=Math.max(p.x,p.y,p.z,.001);f.color=[p.x/m,p.y/m,p.z/m],f.intensity=m}s.sphericalHarmonicsCoefficients&&e.gl&&le(e.gl,s.sphericalHarmonicsCoefficients)}}}};Q(Ne);Q(Ie);Q(Re);Q(Ce);Q(De);Q(Fe);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var ie="__THREE_LIVE_REGISTRY__";function ge(){let e=typeof globalThis<"u"?globalThis:{};if(!e[ie]){let n={plugins:[],decoders:new Map};try{Object.defineProperty(e,ie,{value:n,writable:!1,configurable:!1,enumerable:!1})}catch{e[ie]=n}}return e[ie]}var Rn=ge().plugins;function Q(e){let n=ge().plugins;n.some(t=>t.name===e.name)||n.push(e)}function Le(){return ge().plugins}function Ce(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function an(e,n,t){let r=n[0],o=n[1],s=n[2],x=n[3],p=n[4],f=n[5],m=n[6],d=n[7],S=n[8],R=n[9],P=n[10],v=n[11],b=n[12],T=n[13],C=n[14],V=n[15],I=t[0],w=t[1],E=t[2],k=t[3];return e[0]=I*r+w*p+E*S+k*b,e[1]=I*o+w*f+E*R+k*T,e[2]=I*s+w*m+E*P+k*C,e[3]=I*x+w*d+E*v+k*V,I=t[4],w=t[5],E=t[6],k=t[7],e[4]=I*r+w*p+E*S+k*b,e[5]=I*o+w*f+E*R+k*T,e[6]=I*s+w*m+E*P+k*C,e[7]=I*x+w*d+E*v+k*V,I=t[8],w=t[9],E=t[10],k=t[11],e[8]=I*r+w*p+E*S+k*b,e[9]=I*o+w*f+E*R+k*T,e[10]=I*s+w*m+E*P+k*C,e[11]=I*x+w*d+E*v+k*V,I=t[12],w=t[13],E=t[14],k=t[15],e[12]=I*r+w*p+E*S+k*b,e[13]=I*o+w*f+E*R+k*T,e[14]=I*s+w*m+E*P+k*C,e[15]=I*x+w*d+E*v+k*V,e}function sn(e,n,t,r){let o=n[0],s=n[1],x=n[2],p=n[3],f=o+o,m=s+s,d=x+x,S=o*f,R=o*m,P=o*d,v=s*m,b=s*d,T=x*d,C=p*f,V=p*m,I=p*d,w=r[0],E=r[1],k=r[2];return e[0]=(1-(v+T))*w,e[1]=(R+I)*w,e[2]=(P-V)*w,e[3]=0,e[4]=(R-I)*E,e[5]=(1-(S+T))*E,e[6]=(b+C)*E,e[7]=0,e[8]=(P+V)*k,e[9]=(b-C)*k,e[10]=(1-(S+v))*k,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function xe(e,n){let t=n[0],r=n[1],o=n[2],s=n[4],x=n[5],p=n[6],f=n[8],m=n[9],d=n[10],S=d*x-p*m,R=-d*s+p*f,P=m*s-x*f,v=t*S+r*R+o*P;return v&&(v=1/v,e[0]=S*v,e[1]=(-d*r+o*m)*v,e[2]=(p*r-o*x)*v,e[3]=R*v,e[4]=(d*t-o*f)*v,e[5]=(-p*t+o*s)*v,e[6]=P*v,e[7]=(-m*t+r*f)*v,e[8]=(x*t-r*s)*v),e}function Ve(e,n){let t=n[0],r=n[1],o=n[2],s=n[3],x=n[4],p=n[5],f=n[6],m=n[7],d=n[8],S=n[9],R=n[10],P=n[11],v=n[12],b=n[13],T=n[14],C=n[15],V=t*p-r*x,I=t*f-o*x,w=t*m-s*x,E=r*f-o*p,k=r*m-s*p,B=o*m-s*f,z=d*b-S*v,H=d*T-R*v,N=d*C-P*v,Y=S*T-R*b,q=S*C-P*b,Z=R*C-P*T,O=V*Z-I*q+w*Y+E*N-k*H+B*z;return O?(O=1/O,e[0]=(p*Z-f*q+m*Y)*O,e[1]=(o*q-r*Z-s*Y)*O,e[2]=(b*B-T*k+C*E)*O,e[3]=(R*k-S*B-P*E)*O,e[4]=(f*N-x*Z-m*H)*O,e[5]=(t*Z-o*N+s*H)*O,e[6]=(T*w-v*B-C*I)*O,e[7]=(d*B-R*w+P*I)*O,e[8]=(x*q-p*N+m*z)*O,e[9]=(r*N-t*q-s*z)*O,e[10]=(v*k-b*w+C*V)*O,e[11]=(S*w-d*k-P*V)*O,e[12]=(p*H-x*Y-f*z)*O,e[13]=(t*Y-r*H+o*z)*O,e[14]=(b*I-v*E-T*V)*O,e[15]=(d*E-S*I+R*V)*O,e):null}function ve(e,n){let t=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let d=0;d<t;d++)r.push(Ce());if(t===0)return r;let o=new Set;for(let d of e.nodes)if(Array.isArray(d.children))for(let S of d.children)o.add(S);let s=new Set,x=128,p=(d,S,R=0)=>{if(R>x||d<0||d>=t||s.has(d))return;s.add(d);let P=e.nodes[d];if(!P)return;let v=Ce();if(n&&n[d])v.set(n[d]);else if(P.matrix&&P.matrix.length===16)v.set(P.matrix);else{let T=P.translation||[0,0,0],C=P.rotation||[0,0,0,1],V=P.scale||[1,1,1];sn(v,C,T,V)}let b=r[d];if(S?an(b,S,v):b.set(v),Array.isArray(P.children))for(let T of P.children)typeof T=="number"&&p(T,b,R+1)},f=[],m=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(m&&Array.isArray(m.nodes))f.push(...m.nodes);else for(let d=0;d<t;d++)o.has(d)||f.push(d);for(let d of f)p(d,null);for(let d=0;d<t;d++)!o.has(d)&&!f.includes(d)&&p(d,null);return r}var Ae=new WeakMap;function Se(e,n){let t=n instanceof Float32Array?n:new Float32Array(n);Ae.set(e,t)}function cn(e){return Ae.get(e)}async function ln(e,n){if(!n)return null;let t;if(typeof n=="string")if(typeof fetch<"u"&&typeof createImageBitmap=="function"){let s=await(await fetch(n)).blob();t=await createImageBitmap(s)}else if(typeof Image<"u")t=await new Promise((o,s)=>{let x=new Image;x.crossOrigin="anonymous",x.onload=()=>o(x),x.onerror=s,x.src=n});else return null;else t=n;let r=e.createTexture();return e.bindTexture(3553,r),e.texImage2D(3553,0,6408,6408,5121,t),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 Ne=new WeakMap,De=new Float32Array(16);async function Ue(e,n,t){let r=t?await ln(e.gl,t):null;e[n]&&e.gl.deleteTexture(e[n]),e[n]=r}var ze={name:"environment-map",setEnvironmentImage(e,n){return Ue(e,"environmentTexture",n)},setSkyboxImage(e,n){return Ue(e,"skyboxTexture",n)},onBeforeDrawScene(e,n,t,r,o){if(!e.skyboxTexture||typeof n.createProgram!="function")return;let s=Ne.get(n);if(!s){let S=(v,b)=>{let T=n.createShader(v);return n.shaderSource(T,b),n.compileShader(T),T},R=n.createProgram();n.attachShader(R,S(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.);}`)),n.attachShader(R,S(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.);}`)),n.linkProgram(R);let P=typeof n.createVertexArray=="function"?n.createVertexArray():null;s={program:R,vao:P},Ne.set(n,s)}let x=Ve(De,t)||De;n.depthMask(!1),n.useProgram(s.program),s.vao&&n.bindVertexArray(s.vao),n.activeTexture(33984),n.bindTexture(3553,e.skyboxTexture);let p=n.getUniformLocation(s.program,"uSkyboxMap");p&&n.uniform1i(p,0);let f=n.getUniformLocation(s.program,"uInvVP");f&&n.uniformMatrix4fv(f,!1,x);let m=n.getUniformLocation(s.program,"uCameraPos");m&&n.uniform3f(m,r[0],r[1],r[2]);let d=n.getUniformLocation(s.program,"uExposure");d&&n.uniform1f(d,e.exposure??1),n.drawArrays(4,0,3),n.depthMask(!0)},onResolveShader(e,n,t,r){if(r.includes("evalSHIrradiance"))return null;let o=r.replace("out vec4 fragColor;",`uniform vec3 uSH[9];
|
|
20
|
-
uniform int uHasSH;
|
|
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
|
-
vec3 evalSHIrradiance(vec3 n){return max(vec3(0.),uSH[0]+uSH[1]*n.y+uSH[2]*n.z+uSH[3]*n.x+uSH[4]*(n.x*n.y)+uSH[5]*(n.y*n.z)+uSH[6]*(3.*n.z*n.z-1.)+uSH[7]*(n.x*n.z)+uSH[8]*(n.x*n.x-n.y*n.y));}
|
|
23
|
-
void main(){`);return o=o.replace(`if(uHasEnvironmentMap==1){
|
|
24
|
-
specularIBL=texture(uEnvironmentMap,equirectangularUV(R)).rgb*(F*brdf.x+brdf.y);
|
|
25
|
-
envDiffuse=texture(uEnvironmentMap,equirectangularUV(N)).rgb;
|
|
26
|
-
}`,`if(uHasEnvironmentMap==1){
|
|
27
|
-
specularIBL=textureLod(uEnvironmentMap,equirectangularUV(R),clamp(roughness*6.0,0.0,6.0)).rgb*integrateBRDFApprox(F,roughness,NoV);
|
|
28
|
-
envDiffuse=uHasSH==1?evalSHIrradiance(N):textureLod(uEnvironmentMap,equirectangularUV(N),5.0).rgb;
|
|
29
|
-
}else if(uHasSH==1){
|
|
30
|
-
specularIBL=getStudioRadiance(R,roughness)*integrateBRDFApprox(F,roughness,NoV);
|
|
31
|
-
envDiffuse=evalSHIrradiance(N);
|
|
32
|
-
}`),{vs:t,fs:o}},onBeforeDrawPrimitive(e,n,t,r,o,s){let x=Ae.get(e),p=e.getUniformLocation(n,"uHasSH");if(x&&x.length>=27){p&&e.uniform1i(p,1);let f=e.getUniformLocation(n,"uSH");f&&e.uniform3fv(f,x)}else p&&e.uniform1i(p,0)},onAttributeChanged(e,n,t,r){n==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,r):n==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,r)}};var Me=new WeakMap;function Te(e,n){let t=n||e.viewer;if(!t||typeof t.projectPointToScreen!="function")return;let r=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let o=0;o<r.length;o++){let s=r[o],x=s.getAttribute("data-position");if(!x)continue;let p=x.trim().split(/\s+/).map(S=>parseFloat(S.replace(/m$/,"")));if(p.length<3||p.some(isNaN))continue;let f=s.getAttribute("data-normal"),m;if(f){let S=f.trim().split(/\s+/).map(R=>parseFloat(R));S.length>=3&&!S.some(isNaN)&&(m=[S[0],S[1],S[2]])}let d=t.projectPointToScreen([p[0],p[1],p[2]],m);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transform=`translate(-50%, -50%) translate3d(${d.x}px, ${d.y}px, 0)`,s.style.zIndex="3",d.visible?(s.style.opacity="1",s.style.pointerEvents="auto",s.removeAttribute("data-occluded")):(s.style.opacity="0",s.style.pointerEvents="none",s.setAttribute("data-occluded",""))}}var Oe={name:"hotspots",updateHotspotsForElement:Te,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let n=new MutationObserver(()=>{Te(e)});n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),Me.set(e,n)},onCameraChange(e,n){n&&Te(n,e)},onElementDisconnected(e){let n=Me.get(e);n&&(n.disconnect(),Me.delete(e))}};function se(e,n,t,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(n,Math.min(t,o))}function un(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function fn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function He(e){let n=fn(e);if(!n)return null;let t=n.target;return{target:un(t)?[t[0],t[1],t[2]]:typeof t=="string"&&t.length>0&&t.length<=256?t:[0,0,0],radius:se(n.radius,.01,50,.5),speed:se(n.speed,-20,20,.5),height:se(n.height,-10,10,0),phase:se(n.phase,-1e6,1e6,0),faceCenter:n.faceCenter===!0}}function Be(e,n,t,r){let o=n[0],s=n[1],x=n[2],p=n[3],f=t[0],m=t[1],d=t[2],S=t[3],R=o*f+s*m+x*d+p*S;if(R<0&&(f=-f,m=-m,d=-d,S=-S,R=-R),Math.abs(R)>=1)return e[0]=o,e[1]=s,e[2]=x,e[3]=p,e;let P=Math.acos(R),v=Math.sqrt(1-R*R);if(Math.abs(v)<.001)return e[0]=.5*(o+f),e[1]=.5*(s+m),e[2]=.5*(x+d),e[3]=.5*(p+S),e;let b=Math.sin((1-r)*P)/v,T=Math.sin(r*P)/v;return e[0]=o*b+f*T,e[1]=s*b+m*T,e[2]=x*b+d*T,e[3]=p*b+S*T,e}var Ge=1024,Re=256,ce=2048,dn=128,mn=64,pn=16,yn=1e4,bn=8,K=new Set(["__proto__","constructor","prototype"]),We={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))},Xe={add:(e,n)=>e+n,sub:(e,n)=>e-n,mul:(e,n)=>e*n,div:(e,n)=>Math.abs(n)<1e-12?0:e/n,rem:(e,n)=>Math.abs(n)<1e-12?0:e%n,mod:(e,n)=>Math.abs(n)<1e-12?0:e%n,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},le={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},fe=(e,n)=>e!==null&&typeof e=="object"&&!K.has(n)&&Object.prototype.hasOwnProperty.call(e,n),W=e=>Array.isArray(e)?[...e]:e,Ke=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&fe(e,"value")?e.value:e,U=(e,n)=>fe(e.configuration,n)?Ke(e.configuration[n]):void 0,A=(e,n=0)=>{let t=Number(e);return Number.isFinite(t)?t:n},J=e=>Math.max(0,Math.min(1,e)),X=e=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!Number.isNaN(e):typeof e=="string"?e.length>0&&e!=="false":!!e;function ue(e){if(typeof e!="string"||!e.startsWith("/"))return null;let n=[];for(let t of e.slice(1).split("/")){let r=t.replace(/~1/g,"/").replace(/~0/g,"~");if(!r||K.has(r)||K.has(t))return null;n.push(r)}return{segments:n}}var ne=(e,n)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<n?t:-1},$e=e=>{let n=A(e[0]),t=A(e[1]),r=A(e[2]),o=A(e[3],1),s=Math.hypot(n,t,r,o);return s>1e-8?[n/s,t/s,r/s,o/s]:[0,0,0,1]},je=(e,n,t,r)=>{if(typeof e=="number"&&typeof n=="number")return e+(n-e)*t;if(Array.isArray(e)&&Array.isArray(n)){if(r&&e.length===4&&n.length===4){let o=[0,0,0,1];return Be(o,$e(e),$e(n),t),o}return e.slice(0,n.length).map((o,s)=>o+(n[s]-o)*t)}return t>=.5?n:e},we=(e,n,t)=>Array.isArray(e)&&Array.isArray(n)?e.slice(0,n.length).map((r,o)=>t(A(r),A(n[o]))):Array.isArray(e)?e.map(r=>t(A(r),A(n))):Array.isArray(n)?n.map(r=>t(A(e),A(r))):t(A(e),A(n)),hn=(e,n)=>Array.isArray(e)?e.map(t=>n(A(t))):n(A(e)),qe=(e,n)=>Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every((t,r)=>Math.abs(t-n[r])<=1e-6):e===n,de=class{constructor(n,t,r){let o=Array.isArray(r.nodes)?r.nodes:[];if(o.length>Ge)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${Ge})`);let s=Array.isArray(r.variables)?r.variables:[];if(s.length>Re)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${Re})`);let x=Array.isArray(r.declarations)?r.declarations:[],p=Array.isArray(r.events)?r.events:[],f=new Map,m=new Map,d=new Map,S=new Map,R=new Map,P=new Map,v=[],b=[],T=new Map,C=1,V=0,I=0,w=0,E=0,k=!1,B=!1,z=!1;s.forEach((l,u)=>{if(!l||typeof l!="object")return;let h=W(Ke(l.value));f.set(u,h);let g=l.id??l.name;typeof g=="string"&&g&&!K.has(g)&&f.set(g,h)}),(t?.nodes||[]).forEach((l,u)=>{for(let h of l?.children||[])typeof h=="number"&&T.set(h,u)});let H=l=>l.op||typeof l.declaration=="number"&&x[l.declaration]?.op||"",N=(l,u,h)=>{if(K.has(u))return;let g=m.get(l);g||m.set(l,g=Object.create(null)),g[u]=h},Y=(l,u)=>{if(typeof l!="number"&&typeof l!="string"||typeof l=="string"&&K.has(l)||!f.has(l)&&f.size>=Re*2)return;let h=W(u);if(f.set(l,h),typeof l=="number"){let g=s[l]?.id??s[l]?.name;typeof g=="string"&&!K.has(g)&&f.set(g,h)}},q=l=>typeof l=="number"?p[l]?.id??String(l):typeof l=="string"?/^\d+$/.test(l)&&p[Number(l)]?.id?p[Number(l)].id:l:"",Z=(l,u)=>{for(let h=l,g=0;h!==void 0&&h>=0&&g<128;h=T.get(h),g++)if(h===u)return!0;return!1},O=l=>{for(let u=v.length-1;u>=0;u--)v[u].key===l&&v.splice(u,1)},Pe=l=>{O(l.key),v.length>=dn&&v.shift(),v.push(l)},ye=l=>{let u=ue(l)?.segments;if(u){if(u[0]==="nodes"&&Array.isArray(t?.nodes)){let h=t.nodes[ne(u[1],t.nodes.length)];if(!h)return;let g=u[2];if(g in le){let c=le[g],a=h[g]||c;return c.map((i,y)=>A(a[y],i))}if(g==="weights"){let c=Array.isArray(h.weights)?h.weights:[0],a=u.length===4?ne(u[3],64):-2;return a===-2?c.map(i=>A(i)):a>=0?A(c[a]):void 0}if(g==="visible"||g==="extensions"&&u[3]==="KHR_node_visibility"&&u[4]==="visible")return h.extensions?.KHR_node_visibility?.visible??h.visible??!0}else if(u[0]==="materials"&&Array.isArray(t?.materials)){let h=t.materials[ne(u[1],t.materials.length)];if(!h)return;let g=h.pbrMetallicRoughness||{};if(u[2]==="pbrMetallicRoughness"){if(u[3]==="baseColorFactor"){let c=g.baseColorFactor||[1,1,1,1];return[A(c[0],1),A(c[1],1),A(c[2],1),A(c[3],1)]}if(u[3]==="metallicFactor"||u[3]==="roughnessFactor")return A(g[u[3]],1)}if(u[2]==="emissiveFactor"){let c=h.emissiveFactor||[0,0,0];return[A(c[0]),A(c[1]),A(c[2])]}if(u[2]==="alphaCutoff")return A(h.alphaCutoff,.5)}}},re=(l,u)=>{let h=ue(l)?.segments;if(!h)return!1;if(h[0]==="nodes"&&Array.isArray(t?.nodes)){let g=ne(h[1],t.nodes.length),c=t.nodes[g];if(!c)return!1;let a=h[2];if(a in le&&Array.isArray(u)){let i=le[a];if(u.length<i.length)return!1;let y=i.map((L,D)=>A(u[D],L));if(a==="rotation"){let L=Math.hypot(...y);y=L>1e-8?y.map(D=>D/L):[0,0,0,1]}c[a]=y,delete c.matrix;let F=n?.initialNodeTransforms?.[g];return F&&(F[a[0]]=[...y]),k=!0,!0}if(a==="weights"){Array.isArray(c.weights)||(c.weights=[]);let i=(y,F)=>{for(let L of n?.meshes||[])if(L.nodeIndex===g)for(let D of L.primitives||[])D.pluginData?.morph?.weights&&(D.pluginData.morph.weights[y]=F)};if(h.length===4){let y=ne(h[3],64);if(y<0)return!1;i(y,c.weights[y]=A(u))}else if(Array.isArray(u))c.weights=u.slice(0,64).map(y=>A(y)),c.weights.forEach((y,F)=>i(F,y));else return!1;return z=!0,!0}if(a==="visible"||a==="extensions"&&h[3]==="KHR_node_visibility"&&h[4]==="visible"){let i=X(u);return c.visible=i,(!c.extensions||typeof c.extensions!="object")&&(c.extensions={}),c.extensions.KHR_node_visibility={visible:i},B=!0,!0}}else if(h[0]==="materials"&&Array.isArray(t?.materials)){let g=ne(h[1],t.materials.length),c=t.materials[g];if(!c)return!1;let a=c.pbrMetallicRoughness||(c.pbrMetallicRoughness={}),i=y=>{for(let F of n?.meshes||[])for(let L of F.primitives||[])(L.materialIndex??0)===g&&y(L)};if(h[2]==="pbrMetallicRoughness"){if(h[3]==="baseColorFactor"&&Array.isArray(u)&&u.length>=3){let y=[J(A(u[0],1)),J(A(u[1],1)),J(A(u[2],1)),u[3]!==void 0?J(A(u[3],1)):a.baseColorFactor?.[3]??1];return a.baseColorFactor=y,i(F=>F.baseColor=[...y]),z=!0}if(h[3]==="metallicFactor"||h[3]==="roughnessFactor"){let y=h[3]==="metallicFactor",F=J(A(u,y?0:.5));return a[h[3]]=F,i(L=>L[y?"metallic":"roughness"]=F),z=!0}}if(h[2]==="emissiveFactor"&&Array.isArray(u)&&u.length>=3)return c.emissiveFactor=[0,1,2].map(y=>Math.max(0,A(u[y]))),z=!0;if(h[2]==="alphaCutoff")return c.alphaCutoff=J(A(u,.5)),z=!0}return!1},be=(l,u,h=new Set)=>{let g=U(u,"pointer");if(typeof g!="string"||!g.startsWith("/"))return null;let c=g.replace(/\{([a-zA-Z0-9_]+)\}/g,(a,i)=>{let y=Math.trunc(Number(oe(l,i,void 0,h)??U(u,i)));return Number.isSafeInteger(y)&&y>=0?String(y):"-1"});return ue(c)?c:null},oe=(l,u,h,g)=>{let c=o[l]?.values;if(!fe(c,u))return h;let a=c[u];if(a==null)return h;if(typeof a!="object"||Array.isArray(a))return W(a);let i=a;return typeof i.node=="number"?rn(i.node,i.socket||"value",g):fe(i,"value")?W(i.value):h},rn=(l,u,h)=>{if(l<0||l>=o.length||h.has(l)||h.size>128||++w>yn)return;let g=o[l],c=H(g);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(c))return W(m.get(l)?.[u]);h.add(l);try{let a=(i,y=0)=>oe(l,i,y,h);if(c==="variable/get"){let i=U(g,"variable")??U(g,"id");return typeof i=="number"||typeof i=="string"?W(f.get(i)):void 0}if(c==="pointer/get"){let i=be(l,g,h);return i?ye(i):void 0}if(c.startsWith("math/")){let i=c.slice(5);if(i in We)return hn(a("a"),We[i]);if(i in Xe){let y=/^(mul|div|rem|mod|pow)$/.test(i)?1:0;return we(a("a",i==="mul"?1:0),a("b",y),Xe[i])}if(i==="pi")return Math.PI;if(i==="e")return Math.E;if(i==="random")return Math.random();if(i==="clamp")return we(we(a("a"),a("b",a("min",0)),Math.max),a("c",a("max",1)),Math.min);if(i==="mix"||i==="quatSlerp")return je(a("a",0),a("b",1),A(a("c",a("t",.5)),.5),i==="quatSlerp");if(i==="dot"){let y=a("a"),F=a("b");return Array.isArray(y)&&Array.isArray(F)?y.reduce((L,D,M)=>L+(D||0)*(F[M]||0),0):A(y)*A(F)}if(i==="cross"){let y=a("a",[0,0,0]),F=a("b",[0,0,0]);return Array.isArray(y)&&Array.isArray(F)?[(y[1]||0)*(F[2]||0)-(y[2]||0)*(F[1]||0),(y[2]||0)*(F[0]||0)-(y[0]||0)*(F[2]||0),(y[0]||0)*(F[1]||0)-(y[1]||0)*(F[0]||0)]:[0,0,0]}if(i==="length"){let y=a("a");return Array.isArray(y)?Math.hypot(...y):Math.abs(A(y))}if(i==="distance"){let y=a("a"),F=a("b");return Array.isArray(y)&&Array.isArray(F)?Math.hypot(...y.map((L,D)=>(L||0)-(F[D]||0))):Math.abs(A(y)-A(F))}if(i==="normalize"){let y=a("a");if(!Array.isArray(y))return A(y)>=0?1:-1;let F=Math.hypot(...y);return F>1e-8?y.map(L=>L/F):y.map(()=>0)}if(i.startsWith("combine"))return["a","b","c","d"].slice(0,Number(i[7])||2).map(y=>A(a(y)));if(i.startsWith("extract")){let y=a("a");return Array.isArray(y)?y[u==="0"||u==="x"?0:u==="1"||u==="y"?1:u==="2"||u==="z"?2:3]??0:0}if(i==="eq")return qe(a("a"),a("b"));if(i==="ne")return!qe(a("a"),a("b"));if(i==="lt")return A(a("a"))<A(a("b"));if(i==="le")return A(a("a"))<=A(a("b"));if(i==="gt")return A(a("a"))>A(a("b"));if(i==="ge")return A(a("a"))>=A(a("b"));if(i==="isNaN")return Number.isNaN(Number(a("a")));if(i==="isInf"){let y=Number(a("a"));return!Number.isFinite(y)&&!Number.isNaN(y)}return i==="and"?X(a("a",!1))&&X(a("b",!1)):i==="or"?X(a("a",!1))||X(a("b",!1)):i==="xor"?X(a("a",!1))!==X(a("b",!1)):i==="not"?!X(a("a",!1)):i==="select"?W(X(a("condition",!1))?a("a"):a("b")):void 0}return c==="type/boolToInt"||c==="type/boolToFloat"?X(a("a",!1))?1:0:c==="type/intToBool"||c==="type/floatToBool"?A(a("a",0))!==0:c==="type/intToFloat"?A(a("a",0)):c==="type/floatToInt"?Math.trunc(A(a("a",0))):void 0}finally{h.delete(l)}},ae=()=>{if(k){k=!1,z=!0;let l=ve(t);if(n){n.worldMatrices=l;for(let u of n.meshes||[])u.nodeIndex>=0&&u.nodeIndex<l.length&&(u.transform.set(l[u.nodeIndex]),xe(u.normalMatrix,u.transform))}}if(B){B=!1,z=!0;let l=t?.nodes;if(Array.isArray(n?.meshes)&&Array.isArray(l))for(let u of n.meshes){let h=!0;for(let g=u.nodeIndex,c=0;g!==void 0&&g>=0&&c<128;g=T.get(g),c++){let a=l[g];if(a?.visible===!1||a?.extensions?.KHR_node_visibility?.visible===!1){h=!1;break}}u.visible=h}}z&&(z=!1,n?.render?.())},ee=(l,u={steps:0})=>{if(!l||typeof l.node!="number")return;u.steps===0&&(w=0);let h=[l],g=c=>{h.length+u.steps<ce&&h.push(c)};for(;h.length>0&&u.steps<ce;){u.steps++;let c=h.shift();if(!c||c.node<0||c.node>=o.length)continue;let a=c.node,i=o[a];if(!i)continue;let y=c.socket||"in",F=H(i),L=(M,_=void 0)=>oe(a,M,_,new Set),D=(M="out")=>{let _=i.flows?.[M];_&&g(_)};switch(F){case"flow/branch":D(X(L("condition",!1))?"true":"false");break;case"flow/sequence":for(let M of Object.keys(i.flows||{}).sort((_,G)=>Number(_)-Number(G)||_.localeCompare(G)))D(M);break;case"flow/switch":{let M=i.flows?.[String(L("selection",L("value",0)))]??i.flows?.default;M&&g(M);break}case"flow/for":{let M=Math.trunc(A(L("startIndex",0))),_=Math.trunc(A(L("endIndex",0))),G=Math.max(1,Math.trunc(A(L("step",1),1))),$=i.flows?.body;if($&&_>M&&E<bn){let on=Math.min(Math.ceil((_-M)/G),ce);E++;try{for(let he=0;he<on&&u.steps<ce;he++)N(a,"index",M+he*G),ee($,u)}finally{E--}}let Fe=i.flows?.completed??i.flows?.out;Fe&&g(Fe);break}case"flow/doN":{let M=y==="reset"?0:(d.get(a)||0)+1;if(d.set(a,M),N(a,"currentCount",M),N(a,"count",M),y!=="reset"){let _=Math.trunc(A(L("n",U(i,"stopIterations")??U(i,"n")??1),1));M<=_&&D()}break}case"flow/multiGate":{if(y==="reset"){P.set(a,0);break}let M=Object.keys(i.flows||{}).sort();if(!M.length)break;let _=U(i,"isRandom")?Math.floor(Math.random()*M.length):P.get(a)||0;_<M.length&&(D(M[_]),P.set(a,U(i,"isLoop")!==!1?(_+1)%M.length:_+1));break}case"flow/waitAll":{if(y==="reset"){S.delete(a);break}let M=S.get(a);M||S.set(a,M=new Set),M.add(y),M.size>=Math.max(1,Math.trunc(Number(U(i,"inputFlows")??2)||2))&&(M.clear(),D("out"),D("completed"));break}case"flow/throttle":{if(y==="reset"){R.delete(a);break}let M=Math.max(0,A(L("duration",0))),_=R.get(a);_===void 0||V-_>=M?(R.set(a,V),N(a,"lastRemainingTime",0),D()):N(a,"lastRemainingTime",Math.max(0,M-(V-_)));break}case"flow/delay":case"flow/setDelay":{if(y==="cancel"){for(let $=b.length-1;$>=0;$--)b[$].nodeIdx===a&&b.splice($,1);N(a,"lastDelayIndex",-1);break}let M=Math.max(0,A(L("duration",U(i,"duration")??0))),_=i.flows?.done??i.flows?.out;if(M<=0){N(a,"lastDelayIndex",-1),_&&g(_);break}b.length>=mn&&b.shift();let G=C++;N(a,"lastDelayIndex",G),b.push({id:G,nodeIdx:a,rem:M,done:_}),F==="flow/setDelay"&&i.flows?.out&&i.flows?.done&&D("out");break}case"flow/cancelDelay":{let M=Math.trunc(A(L("delayIndex",-1),-1));if(M<0)b.length=0;else for(let _=b.length-1;_>=0;_--)b[_].id===M&&b.splice(_,1);D();break}case"variable/set":Y(U(i,"variable")??U(i,"id"),L("value")),D();break;case"variable/interpolate":{let M=U(i,"variable")??U(i,"id"),_=L("value",L("target")),G=Math.max(0,A(L("duration",U(i,"duration")??.3),.3));M!==void 0&&_!==void 0&&Pe({key:`var:${String(M)}`,varKey:M,from:W(L("from")??f.get(M)??0),to:W(_),dur:G,elapsed:0,quat:!1,linear:U(i,"easing")==="linear",done:i.flows?.done}),D();break}case"pointer/set":{let M=be(a,i),_=L("value");M&&_!==void 0&&(O(`ptr:${M}`),re(M,_)),D();break}case"pointer/interpolate":{let M=be(a,i),_=L("value",L("target")),G=Math.max(0,A(L("duration",U(i,"duration")??.3),.3));if(M&&_!==void 0){let $=L("from")??ye(M);$!==void 0&&(G<=0?(re(M,_),D("done")):Pe({key:`ptr:${M}`,ptr:M,from:W($),to:W(_),dur:G,elapsed:0,quat:M.endsWith("/rotation"),linear:U(i,"easing")==="linear",done:i.flows?.done}))}D();break}case"animation/start":{let M=L("animation")??U(i,"animation")??U(i,"clipName"),_=typeof M=="number"?n?.animations?.[M]?.name??t?.animations?.[M]?.name:typeof M=="string"?M:void 0;n?.playAnimation?.(_),z=!0,D();break}case"animation/stop":case"animation/resetAt":n?.pauseAnimation?.(),F==="animation/resetAt"&&n?.evaluateAnimation?.(A(L("time",0))),z=!0,D();break;case"event/send":case"customEvent/send":{let M=q(U(i,"event")??U(i,"id")),_={};for(let G of Object.keys(i.values||{}))K.has(G)||(_[G]=L(G));M&&(typeof CustomEvent<"u"&&typeof n?.container?.dispatchEvent=="function"&&n.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:M,values:_}})),ke(M,_,u)),D();break}default:D();break}}};this.readScenePointer=ye,this.writeScenePointer=re,this.fireOnStart=()=>{o.forEach(l=>{H(l)==="event/onStart"&&ee(l.flows?.out)}),ae()},this.fireOnSelect=l=>{if(!l)return;let u=typeof l.meshIndex=="number"?l.meshIndex:-1,h=typeof l.nodeIndex=="number"?l.nodeIndex:n?.meshes?.[u]?.nodeIndex??-1;o.forEach((g,c)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(H(g)))return;let a=U(g,"nodeIndex")??U(g,"node")??oe(c,"nodeIndex",void 0,new Set),i=U(g,"meshName");if(typeof i=="string"&&i?l.meshName===i:a==null||Number(a)<0||Number.isNaN(Number(a))||Z(h,Math.trunc(Number(a)))){if(N(c,"nodeIndex",h),N(c,"meshIndex",u),Array.isArray(l.hitPoint)){let F=[A(l.hitPoint[0]),A(l.hitPoint[1]),A(l.hitPoint[2])];N(c,"hitPoint",F),N(c,"point",F),N(c,"intersectionPoint",F)}if(Array.isArray(l.normal)){let F=[A(l.normal[0]),A(l.normal[1],1),A(l.normal[2])];N(c,"normal",F),N(c,"hitNormal",F)}typeof l.distance=="number"&&N(c,"distance",l.distance),ee(g.flows?.out)}}),ae()},this.receiveCustomEvent=(l,u={})=>ke(l,u,{steps:0});function ke(l,u,h){if(!(I>=pn)){I++;try{let g=q(l);o.forEach((c,a)=>{if(!/^(customE|e)vent\/receive$/.test(H(c)))return;let i=U(c,"event")??U(c,"id");if(!(q(i)!==g&&String(i)!==String(l))){for(let[y,F]of Object.entries(u))K.has(y)||N(a,y,W(F));ee(c.flows?.out,h)}}),ae()}finally{I--}}}this.tick=l=>{if(!Number.isFinite(l)||l<0)return;let u=Math.min(l,.25);V+=u,o.forEach((g,c)=>{H(g)==="event/onTick"&&(N(c,"timeDelta",u),N(c,"dt",u),N(c,"timeElapsed",V),ee(g.flows?.out))});let h=[];for(let g=v.length-1;g>=0;g--){let c=v[g];c.elapsed+=u;let a=c.dur>1e-6?J(c.elapsed/c.dur):1,i=c.linear?a:a*a*(3-2*a),y=je(c.from,c.to,i,c.quat);c.ptr?re(c.ptr,y):c.varKey!==void 0&&Y(c.varKey,y),a>=1&&(v.splice(g,1),c.done&&h.push(c.done))}for(let g=b.length-1;g>=0;g--){let c=b[g];c.rem-=u,c.rem<=0&&(b.splice(g,1),c.done&&h.push(c.done))}for(let g of h)ee(g);ae()},this.dispose=()=>{v.length=0,b.length=0,f.clear(),m.clear(),d.clear(),S.clear(),R.clear(),P.clear()}}},j=new WeakMap,me=new WeakMap;function gn(e,n){if(!e||typeof e!="object"||!Number.isFinite(n)||n<=0||Le().some(p=>p.name==="xr-live-head-follow"))return;let t=e.gltf,r=t?.nodes;if(!Array.isArray(r)||r.length===0)return;let o=Math.min(n,.1),s=(me.get(e)||0)+o,x=!1;for(let p=0;p<r.length;p++){let f=r[p],m=He(f?.extras?.xr?.orbit);if(!m)continue;let d=0,S=0,R=0;if(Array.isArray(m.target))d=m.target[0],S=m.target[1],R=m.target[2];else if(typeof m.target=="string"&&m.target!=="head"){let C=r.find(V=>V?.name===m.target);Array.isArray(C?.translation)&&(d=A(C.translation[0]),S=A(C.translation[1]),R=A(C.translation[2]))}let P=m.phase+m.speed*s,v=d+Math.cos(P)*m.radius,b=S+m.height,T=R+Math.sin(P)*m.radius;if(f.translation=[v,b,T],m.faceCenter){let C=Math.atan2(d-v,R-T);f.rotation=[0,Math.sin(C*.5),0,Math.cos(C*.5)]}x=!0}if(x){me.set(e,s);let p=ve(t);e.worldMatrices=p;for(let f of e.meshes||[])f.nodeIndex>=0&&f.nodeIndex<p.length&&(f.transform.set(p[f.nodeIndex]),xe(f.normalMatrix,f.transform))}}function Ee(e){if(!(!e||typeof e!="object"))return j.get(e)||j.get(e.viewer)||j.get(e._view)}function Ye(e,n,t){let r=Ee(e);return r?(r.receiveCustomEvent(n,t),!0):!1}var Ze={name:"khr-interactivity",sendInteractivityEvent:Ye,getInteractivityVM:Ee,onLoadModel(e,n){if(!e||typeof e!="object")return;j.get(e)?.dispose(),j.delete(e),me.delete(e);let t=n?.extensions?.KHR_interactivity,r=Array.isArray(t?.graphs)?t.graphs[t.graph??0]:t;if(!r||!Array.isArray(r.nodes))return;let o=new de(e,n,r);j.set(e,o),o.fireOnStart()},onMeshSelect(e,n){j.get(e)?.fireOnSelect(n)},onUpdate(e,n){j.get(e)?.tick(n),gn(e,n)},onDestroy(e,n){j.get(n)?.dispose(),j.delete(n),me.delete(n)}};var te=new Map,Ie=new WeakMap;function xn(e,n){te.set(e,n)}var Qe={name:"materials",onBuildPrimitiveVAO(e,n,t,r,o){return(((r?.materials&&t.material!==void 0?r.materials[t.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,n){let t=Ie.get(e);t||(t=e.createTexture(),Ie.set(e,t));let r=Math.max(1,n.canvas.width),o=Math.max(1,n.canvas.height);e.activeTexture(33990),e.bindTexture(3553,t),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,n,t,r){if(!n)return null;if(n.name&&te.has(n.name)){let v=te.get(n.name);return{vs:v.vs||t,fs:v.fs||r}}let o=n.extensions||{},s=o.KHR_materials_clearcoat,x=o.KHR_materials_sheen,p=!!o.KHR_materials_transmission,f=!!o.KHR_materials_ior,m=o.KHR_materials_iridescence;if(!s&&!x&&!o.KHR_materials_unlit&&!p&&!o.KHR_materials_volume&&!f&&!o.KHR_materials_dispersion&&!m)return null;if(o.KHR_materials_unlit)return{vs:t,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 d=r;if(p){let v=d.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
|
|
33
|
-
`;d=d.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
|
|
34
|
-
${v}out vec4 fragColor;`)}let S=(v,b,T=0,C=1e6,V=3)=>{let I=Number(v);return(Number.isFinite(I)?Math.min(C,Math.max(T,I)):b).toFixed(V)},R=Number(o.KHR_materials_ior?.ior??1.5),P=Number.isFinite(R)?Math.min(10,Math.max(1,R)):1.5;if(f){let v=Math.pow((P-1)/(P+1),2);d=d.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${S(v,.04,0,1,4)}),base.rgb,metallic);`)}if(m){let v=S(m.iridescenceFactor,1,0,1),b=S(m.iridescenceIor,1.3,1,10);d=d.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${b}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${v}*pow(1.-NoV,2.));`)}if(p){let v=S(o.KHR_materials_transmission?.transmissionFactor,1,0,1),b=o.KHR_materials_volume||{},T=S(b.thicknessFactor,.5,0,1e4),C=S(b.attenuationDistance,1,.001,1e6),V=Array.isArray(b.attenuationColor)?b.attenuationColor:[1,1,1],I=S(o.KHR_materials_dispersion?.dispersion,0,0,10);d=d.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=${S(P,1.5,1,10)},dV=${I},tV=${T},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
|
|
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
|
-
vec3 tr=vec3(textureLod(uTransmissionTex,clamp(sUV+refractedR.xy*sc,.001,.999),lod).r,textureLod(uTransmissionTex,clamp(sUV+rG.xy*sc,.001,.999),lod).g,textureLod(uTransmissionTex,clamp(sUV+refractedB.xy*sc,.001,.999),lod).b);
|
|
38
|
-
vec3 aCol=vec3(${S(V[0],1,0,1)},${S(V[1],1,0,1)},${S(V[2],1,0,1)});
|
|
39
|
-
vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${C},.001));
|
|
40
|
-
diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${v});`)}if(s&&!r.includes("uClearcoat")){let v=S(s.clearcoatFactor,1,0,1),b=S(s.clearcoatRoughnessFactor,0,0,1);d=d.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${b},NoV)*${v};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${b})*ccF;fragColor=vec4(color,base.a);`)}if(x){let v=Array.isArray(x.sheenColorFactor)?x.sheenColorFactor:[1,1,1],b=`color+=vec3(${S(v[0],1,0,1)},${S(v[1],1,0,1)},${S(v[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;d.includes("color=applyToneMapping(color,uToneMapping);")?d=d.replace("color=applyToneMapping(color,uToneMapping);",`${b}color=applyToneMapping(color,uToneMapping);`):d=d.replace("fragColor=vec4(color,base.a);",`${b}fragColor=vec4(color,base.a);`)}return{vs:t,fs:d}},onBeforeDrawPrimitive(e,n,t,r,o,s){let x=t.materialIndex;if(x!==void 0&&s?.materials){let p=s.materials[x];p?.name&&te.has(p.name)&&te.get(p.name).onBindUniforms?.(e,n,t)}if(t.isTransmissive){let p=Ie.get(e);if(p){e.activeTexture(33990),e.bindTexture(3553,p);let f=e.getUniformLocation(n,"uTransmissionTex");f&&e.uniform1i(f,6);let m=e.getUniformLocation(n,"uViewportSize");m&&e.uniform2f(m,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var An=`#version 300 es
|
|
41
|
-
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.);}`,Sn=`#version 300 es
|
|
42
|
-
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);}`,pe=new WeakMap,Je=new Float32Array(20);function _e(e,n){let[t,r,o,s,x,p]=n;return[e[0]*t+e[4]*r+e[8]*o+e[12],e[1]*t+e[5]*r+e[9]*o+e[13],e[2]*t+e[6]*r+e[10]*o+e[14],Math.abs(e[0])*s+Math.abs(e[4])*x+Math.abs(e[8])*p,Math.abs(e[1])*s+Math.abs(e[5])*x+Math.abs(e[9])*p,Math.abs(e[2])*s+Math.abs(e[6])*x+Math.abs(e[10])*p]}function Mn(e){if(e._lb!==void 0)return e._lb;let n=1e9,t=1e9,r=1e9,o=-1e9,s=-1e9,x=-1e9;for(let p of e.primitives||[]){let f=p.positions;if(f)for(let m=0;m<f.length;m+=3)f[m]<n&&(n=f[m]),f[m+1]<t&&(t=f[m+1]),f[m+2]<r&&(r=f[m+2]),f[m]>o&&(o=f[m]),f[m+1]>s&&(s=f[m+1]),f[m+2]>x&&(x=f[m+2])}return e._lb=n<=o?[(n+o)*.5,(t+s)*.5,(r+x)*.5,(o-n)*.5,(s-t)*.5,(x-r)*.5]:null}function Tn(e){let n=pe.get(e);if(n)return n;let t=(p,f)=>{let m=e.createShader(p);return e.shaderSource(m,f),e.compileShader(m),m},r=e.createProgram();e.attachShader(r,t(35633,An)),e.attachShader(r,t(35632,Sn)),e.linkProgram(r);let o=e.createVertexArray(),s=e.createBuffer(),x=e.createBuffer();return e.bindVertexArray(o),e.bindBuffer(34962,s),e.bufferData(34962,80,35048),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,5126,!1,20,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,5126,!1,20,12),e.bindBuffer(34963,x),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),n={prog:r,vao:o,vbo:s,ibo:x,uMVP:e.getUniformLocation(r,"uMVP"),uIntensity:e.getUniformLocation(r,"uShadowIntensity"),uSoftness:e.getUniformLocation(r,"uShadowSoftness")},pe.set(e,n),n}var en={name:"contact-shadow",onAfterRender(e,n,t){let r=n.shadowIntensity;if(r<=0||!n.bounds)return;let o=Tn(e),s=!n.xrSessionActive&&(n.backdropMeshes?.length??0)>0,x=[],p=[];for(let b of n.meshes||[]){if(!b||b.visible===!1||b.isPluginMesh||b.name==="__xr_reticle__"||b.name?.startsWith("__xr_slot_"))continue;let T=Mn(b);if(!T)continue;b.transform&&(T=_e(b.transform,T)),n.modelRootMatrix&&(T=_e(n.modelRootMatrix,T));let[C,V,I,w,E,k]=T,B=[C,I,w,k,V-E,V+E];/floor|table|pedestal|ground|base|plane/i.test(b.name||"")||E<.14&&Math.min(w,k)>.45?p.push(B):x.push(B)}let f=[],m=n.bounds.center||[0,0,0],d=Math.max(.05,Number(n.bounds.radius)||.5),S=n.bounds.min,R=S?[m[0],m[1],m[2],d,Math.max(.01,m[1]-S[1]),d]:[m[0],m[1],m[2],d,d,d];n.modelRootMatrix&&(R=_e(n.modelRootMatrix,R));let v=n.xrSessionActive&&p.length===0&&String(n.container?.tagName||"").toLowerCase()==="xr-live"?(n.modelRootMatrix?n.modelRootMatrix[5]*-.25+n.modelRootMatrix[13]:-.25)+.002:R[1]-R[4]+.002;for(let[b,T,C,V,I]of x){let w=-1/0;for(let[k,B,z,H,,N]of p)I>=N-.08&&Math.abs(b-k)<=z&&Math.abs(T-B)<=H&&N+.002>w&&(w=N+.002);s&&(w=Math.max(w,b>=.04&&b<=.36&&T>=-.34&&T<=-.04&&I>=.01?.036:Math.hypot(b,T)<=.66&&I>=-.06?.003:-.477)),isFinite(w)||(w=v);let E=f.find(k=>Math.hypot(b-k[0],T-k[1])<.06&&Math.abs(w-k[5])<.05);E?(E[2]=Math.max(E[2],C*.78),E[3]=Math.max(E[3],V*.78),E[4]=Math.min(E[4],I)):f.push([b,T,C,V,I,w])}if(f.length===0){let b=Math.max(.1,R[3]*1.5)/1.45;f.push([R[0],R[2],b,b,v,v])}e.useProgram(o.prog),e.uniformMatrix4fv(o.uMVP,!1,t),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[b,T,C,V,I,w]of f){let E=Math.max(0,I-w),k=r/(1+E*2);if(k<.02)continue;let B=1+Math.min(.75,E*.85),z=Math.max(.045,C*1.45*B),H=Math.max(.045,V*1.45*B);Je.set([b-z,w,T-H,0,0,b+z,w,T-H,1,0,b+z,w,T+H,1,1,b-z,w,T+H,0,1]),e.bufferSubData(34962,0,Je),e.uniform1f(o.uIntensity,k),e.uniform1f(o.uSoftness,Math.min(1,n.shadowSoftness+Math.min(.45,E*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let n=pe.get(e);n&&(e.deleteVertexArray(n.vao),e.deleteBuffer(n.vbo),e.deleteBuffer(n.ibo),e.deleteProgram(n.prog),pe.delete(e))}};var nn=new WeakMap,tn={name:"webxr-suite",onConfigureXRSessionInit(e,n){let t=new Set(n.optionalFeatures||[]);t.add("hit-test"),t.add("light-estimation");let r=e?.querySelector?.('[slot="ar-overlay"]')||null;r&&(t.add("dom-overlay"),n.domOverlay={root:r},r.addEventListener?.("beforexrselect",o=>{o.preventDefault()})),n.optionalFeatures=Array.from(t)},onXRFrame(e,n,t,r){if(!e||!n||!t||!r)return;let o=nn.get(n);if(o||(o={lightProbe:null},nn.set(n,o),typeof n.requestLightProbe=="function"&&n.requestLightProbe().then(s=>{o&&s&&(o.lightProbe=s)}).catch(()=>{})),o.lightProbe&&typeof t.getLightEstimate=="function"){let s=t.getLightEstimate(o.lightProbe);if(s){let x=s.primaryLightDirection,p=s.primaryLightIntensity;if(x&&p&&Array.isArray(e.lights)){let f=e.lights.find(d=>d.type==="directional");f||(f={type:"directional",direction:[.5,1,.8],color:[1,1,1],intensity:1},e.lights.push(f)),f.direction=[x.x,x.y,x.z];let m=Math.max(p.x,p.y,p.z,.001);f.color=[p.x/m,p.y/m,p.z/m],f.intensity=m}s.sphericalHarmonicsCoefficients&&e.gl&&Se(e.gl,s.sphericalHarmonicsCoefficients)}}}};Q(en);Q(Oe);Q(ze);Q(Qe);Q(tn);Q(Ze);export{de as InteractivityVM,en as contactShadowPlugin,ze as environmentMapPlugin,cn as getEnvironmentSH,Ee as getInteractivityVM,Oe as hotspotPlugin,Ze as interactivityPlugin,Qe as materialsPlugin,ue as parseSafeGltfPointer,xn as registerMaterialShader,Ye as sendInteractivityEvent,Se as setEnvironmentSH,tn as webxrPlugin};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
"use strict";var ThreeLiveExtras=(()=>{var ve=Object.defineProperty;var ln=Object.getOwnPropertyDescriptor;var un=Object.getOwnPropertyNames;var fn=Object.prototype.hasOwnProperty;var dn=(e,n)=>{for(var t in n)ve(e,t,{get:n[t],enumerable:!0})},mn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of un(n))!fn.call(e,o)&&o!==t&&ve(e,o,{get:()=>n[o],enumerable:!(r=ln(n,o))||r.enumerable});return e};var pn=e=>mn(ve({},"__esModule",{value:!0}),e);var Fn={};dn(Fn,{InteractivityVM:()=>re,contactShadowPlugin:()=>Ne,environmentMapPlugin:()=>Re,getEnvironmentSH:()=>je,getInteractivityVM:()=>ye,hotspotPlugin:()=>Ie,interactivityPlugin:()=>Fe,materialsPlugin:()=>Ce,parseSafeGltfPointer:()=>te,registerMaterialShader:()=>rn,sendInteractivityEvent:()=>ke,setEnvironmentSH:()=>le,webxrPlugin:()=>De});var ce="__THREE_LIVE_REGISTRY__";function Ae(){let e=typeof globalThis<"u"?globalThis:{};if(!e[ce]){let n={plugins:[],decoders:new Map};try{Object.defineProperty(e,ce,{value:n,writable:!1,configurable:!1,enumerable:!1})}catch{e[ce]=n}}return e[ce]}var Cn=Ae().plugins;function Q(e){let n=Ae().plugins;n.some(t=>t.name===e.name)||n.push(e)}function He(){return Ae().plugins}function Be(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function yn(e,n,t){let r=n[0],o=n[1],s=n[2],x=n[3],p=n[4],f=n[5],m=n[6],d=n[7],S=n[8],R=n[9],P=n[10],v=n[11],b=n[12],T=n[13],C=n[14],V=n[15],I=t[0],w=t[1],E=t[2],k=t[3];return e[0]=I*r+w*p+E*S+k*b,e[1]=I*o+w*f+E*R+k*T,e[2]=I*s+w*m+E*P+k*C,e[3]=I*x+w*d+E*v+k*V,I=t[4],w=t[5],E=t[6],k=t[7],e[4]=I*r+w*p+E*S+k*b,e[5]=I*o+w*f+E*R+k*T,e[6]=I*s+w*m+E*P+k*C,e[7]=I*x+w*d+E*v+k*V,I=t[8],w=t[9],E=t[10],k=t[11],e[8]=I*r+w*p+E*S+k*b,e[9]=I*o+w*f+E*R+k*T,e[10]=I*s+w*m+E*P+k*C,e[11]=I*x+w*d+E*v+k*V,I=t[12],w=t[13],E=t[14],k=t[15],e[12]=I*r+w*p+E*S+k*b,e[13]=I*o+w*f+E*R+k*T,e[14]=I*s+w*m+E*P+k*C,e[15]=I*x+w*d+E*v+k*V,e}function bn(e,n,t,r){let o=n[0],s=n[1],x=n[2],p=n[3],f=o+o,m=s+s,d=x+x,S=o*f,R=o*m,P=o*d,v=s*m,b=s*d,T=x*d,C=p*f,V=p*m,I=p*d,w=r[0],E=r[1],k=r[2];return e[0]=(1-(v+T))*w,e[1]=(R+I)*w,e[2]=(P-V)*w,e[3]=0,e[4]=(R-I)*E,e[5]=(1-(S+T))*E,e[6]=(b+C)*E,e[7]=0,e[8]=(P+V)*k,e[9]=(b-C)*k,e[10]=(1-(S+v))*k,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Se(e,n){let t=n[0],r=n[1],o=n[2],s=n[4],x=n[5],p=n[6],f=n[8],m=n[9],d=n[10],S=d*x-p*m,R=-d*s+p*f,P=m*s-x*f,v=t*S+r*R+o*P;return v&&(v=1/v,e[0]=S*v,e[1]=(-d*r+o*m)*v,e[2]=(p*r-o*x)*v,e[3]=R*v,e[4]=(d*t-o*f)*v,e[5]=(-p*t+o*s)*v,e[6]=P*v,e[7]=(-m*t+r*f)*v,e[8]=(x*t-r*s)*v),e}function Ge(e,n){let t=n[0],r=n[1],o=n[2],s=n[3],x=n[4],p=n[5],f=n[6],m=n[7],d=n[8],S=n[9],R=n[10],P=n[11],v=n[12],b=n[13],T=n[14],C=n[15],V=t*p-r*x,I=t*f-o*x,w=t*m-s*x,E=r*f-o*p,k=r*m-s*p,B=o*m-s*f,z=d*b-S*v,H=d*T-R*v,N=d*C-P*v,Y=S*T-R*b,q=S*C-P*b,Z=R*C-P*T,O=V*Z-I*q+w*Y+E*N-k*H+B*z;return O?(O=1/O,e[0]=(p*Z-f*q+m*Y)*O,e[1]=(o*q-r*Z-s*Y)*O,e[2]=(b*B-T*k+C*E)*O,e[3]=(R*k-S*B-P*E)*O,e[4]=(f*N-x*Z-m*H)*O,e[5]=(t*Z-o*N+s*H)*O,e[6]=(T*w-v*B-C*I)*O,e[7]=(d*B-R*w+P*I)*O,e[8]=(x*q-p*N+m*z)*O,e[9]=(r*N-t*q-s*z)*O,e[10]=(v*k-b*w+C*V)*O,e[11]=(S*w-d*k-P*V)*O,e[12]=(p*H-x*Y-f*z)*O,e[13]=(t*Y-r*H+o*z)*O,e[14]=(b*I-v*E-T*V)*O,e[15]=(d*E-S*I+R*V)*O,e):null}function Me(e,n){let t=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let d=0;d<t;d++)r.push(Be());if(t===0)return r;let o=new Set;for(let d of e.nodes)if(Array.isArray(d.children))for(let S of d.children)o.add(S);let s=new Set,x=128,p=(d,S,R=0)=>{if(R>x||d<0||d>=t||s.has(d))return;s.add(d);let P=e.nodes[d];if(!P)return;let v=Be();if(n&&n[d])v.set(n[d]);else if(P.matrix&&P.matrix.length===16)v.set(P.matrix);else{let T=P.translation||[0,0,0],C=P.rotation||[0,0,0,1],V=P.scale||[1,1,1];bn(v,C,T,V)}let b=r[d];if(S?yn(b,S,v):b.set(v),Array.isArray(P.children))for(let T of P.children)typeof T=="number"&&p(T,b,R+1)},f=[],m=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(m&&Array.isArray(m.nodes))f.push(...m.nodes);else for(let d=0;d<t;d++)o.has(d)||f.push(d);for(let d of f)p(d,null);for(let d=0;d<t;d++)!o.has(d)&&!f.includes(d)&&p(d,null);return r}var Te=new WeakMap;function le(e,n){let t=n instanceof Float32Array?n:new Float32Array(n);Te.set(e,t)}function je(e){return Te.get(e)}async function hn(e,n){if(!n)return null;let t;if(typeof n=="string")if(typeof fetch<"u"&&typeof createImageBitmap=="function"){let s=await(await fetch(n)).blob();t=await createImageBitmap(s)}else if(typeof Image<"u")t=await new Promise((o,s)=>{let x=new Image;x.crossOrigin="anonymous",x.onload=()=>o(x),x.onerror=s,x.src=n});else return null;else t=n;let r=e.createTexture();return e.bindTexture(3553,r),e.texImage2D(3553,0,6408,6408,5121,t),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 We=new WeakMap,Xe=new Float32Array(16);async function $e(e,n,t){let r=t?await hn(e.gl,t):null;e[n]&&e.gl.deleteTexture(e[n]),e[n]=r}var Re={name:"environment-map",setEnvironmentImage(e,n){return $e(e,"environmentTexture",n)},setSkyboxImage(e,n){return $e(e,"skyboxTexture",n)},onBeforeDrawScene(e,n,t,r,o){if(!e.skyboxTexture||typeof n.createProgram!="function")return;let s=We.get(n);if(!s){let S=(v,b)=>{let T=n.createShader(v);return n.shaderSource(T,b),n.compileShader(T),T},R=n.createProgram();n.attachShader(R,S(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.);}`)),n.attachShader(R,S(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.);}`)),n.linkProgram(R);let P=typeof n.createVertexArray=="function"?n.createVertexArray():null;s={program:R,vao:P},We.set(n,s)}let x=Ge(Xe,t)||Xe;n.depthMask(!1),n.useProgram(s.program),s.vao&&n.bindVertexArray(s.vao),n.activeTexture(33984),n.bindTexture(3553,e.skyboxTexture);let p=n.getUniformLocation(s.program,"uSkyboxMap");p&&n.uniform1i(p,0);let f=n.getUniformLocation(s.program,"uInvVP");f&&n.uniformMatrix4fv(f,!1,x);let m=n.getUniformLocation(s.program,"uCameraPos");m&&n.uniform3f(m,r[0],r[1],r[2]);let d=n.getUniformLocation(s.program,"uExposure");d&&n.uniform1f(d,e.exposure??1),n.drawArrays(4,0,3),n.depthMask(!0)},onResolveShader(e,n,t,r){if(r.includes("evalSHIrradiance"))return null;let o=r.replace("out vec4 fragColor;",`uniform vec3 uSH[9];
|
|
20
|
-
uniform int uHasSH;
|
|
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
|
-
vec3 evalSHIrradiance(vec3 n){return max(vec3(0.),uSH[0]+uSH[1]*n.y+uSH[2]*n.z+uSH[3]*n.x+uSH[4]*(n.x*n.y)+uSH[5]*(n.y*n.z)+uSH[6]*(3.*n.z*n.z-1.)+uSH[7]*(n.x*n.z)+uSH[8]*(n.x*n.x-n.y*n.y));}
|
|
23
|
-
void main(){`);return o=o.replace(`if(uHasEnvironmentMap==1){
|
|
24
|
-
specularIBL=texture(uEnvironmentMap,equirectangularUV(R)).rgb*(F*brdf.x+brdf.y);
|
|
25
|
-
envDiffuse=texture(uEnvironmentMap,equirectangularUV(N)).rgb;
|
|
26
|
-
}`,`if(uHasEnvironmentMap==1){
|
|
27
|
-
specularIBL=textureLod(uEnvironmentMap,equirectangularUV(R),clamp(roughness*6.0,0.0,6.0)).rgb*integrateBRDFApprox(F,roughness,NoV);
|
|
28
|
-
envDiffuse=uHasSH==1?evalSHIrradiance(N):textureLod(uEnvironmentMap,equirectangularUV(N),5.0).rgb;
|
|
29
|
-
}else if(uHasSH==1){
|
|
30
|
-
specularIBL=getStudioRadiance(R,roughness)*integrateBRDFApprox(F,roughness,NoV);
|
|
31
|
-
envDiffuse=evalSHIrradiance(N);
|
|
32
|
-
}`),{vs:t,fs:o}},onBeforeDrawPrimitive(e,n,t,r,o,s){let x=Te.get(e),p=e.getUniformLocation(n,"uHasSH");if(x&&x.length>=27){p&&e.uniform1i(p,1);let f=e.getUniformLocation(n,"uSH");f&&e.uniform3fv(f,x)}else p&&e.uniform1i(p,0)},onAttributeChanged(e,n,t,r){n==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,r):n==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,r)}};var we=new WeakMap;function Ee(e,n){let t=n||e.viewer;if(!t||typeof t.projectPointToScreen!="function")return;let r=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let o=0;o<r.length;o++){let s=r[o],x=s.getAttribute("data-position");if(!x)continue;let p=x.trim().split(/\s+/).map(S=>parseFloat(S.replace(/m$/,"")));if(p.length<3||p.some(isNaN))continue;let f=s.getAttribute("data-normal"),m;if(f){let S=f.trim().split(/\s+/).map(R=>parseFloat(R));S.length>=3&&!S.some(isNaN)&&(m=[S[0],S[1],S[2]])}let d=t.projectPointToScreen([p[0],p[1],p[2]],m);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transform=`translate(-50%, -50%) translate3d(${d.x}px, ${d.y}px, 0)`,s.style.zIndex="3",d.visible?(s.style.opacity="1",s.style.pointerEvents="auto",s.removeAttribute("data-occluded")):(s.style.opacity="0",s.style.pointerEvents="none",s.setAttribute("data-occluded",""))}}var Ie={name:"hotspots",updateHotspotsForElement:Ee,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let n=new MutationObserver(()=>{Ee(e)});n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),we.set(e,n)},onCameraChange(e,n){n&&Ee(n,e)},onElementDisconnected(e){let n=we.get(e);n&&(n.disconnect(),we.delete(e))}};function ue(e,n,t,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(n,Math.min(t,o))}function gn(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function xn(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function qe(e){let n=xn(e);if(!n)return null;let t=n.target;return{target:gn(t)?[t[0],t[1],t[2]]:typeof t=="string"&&t.length>0&&t.length<=256?t:[0,0,0],radius:ue(n.radius,.01,50,.5),speed:ue(n.speed,-20,20,.5),height:ue(n.height,-10,10,0),phase:ue(n.phase,-1e6,1e6,0),faceCenter:n.faceCenter===!0}}function Ke(e,n,t,r){let o=n[0],s=n[1],x=n[2],p=n[3],f=t[0],m=t[1],d=t[2],S=t[3],R=o*f+s*m+x*d+p*S;if(R<0&&(f=-f,m=-m,d=-d,S=-S,R=-R),Math.abs(R)>=1)return e[0]=o,e[1]=s,e[2]=x,e[3]=p,e;let P=Math.acos(R),v=Math.sqrt(1-R*R);if(Math.abs(v)<.001)return e[0]=.5*(o+f),e[1]=.5*(s+m),e[2]=.5*(x+d),e[3]=.5*(p+S),e;let b=Math.sin((1-r)*P)/v,T=Math.sin(r*P)/v;return e[0]=o*b+f*T,e[1]=s*b+m*T,e[2]=x*b+d*T,e[3]=p*b+S*T,e}var Ye=1024,_e=256,fe=2048,vn=128,An=64,Sn=16,Mn=1e4,Tn=8,K=new Set(["__proto__","constructor","prototype"]),Ze={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))},Qe={add:(e,n)=>e+n,sub:(e,n)=>e-n,mul:(e,n)=>e*n,div:(e,n)=>Math.abs(n)<1e-12?0:e/n,rem:(e,n)=>Math.abs(n)<1e-12?0:e%n,mod:(e,n)=>Math.abs(n)<1e-12?0:e%n,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},de={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},me=(e,n)=>e!==null&&typeof e=="object"&&!K.has(n)&&Object.prototype.hasOwnProperty.call(e,n),W=e=>Array.isArray(e)?[...e]:e,tn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&me(e,"value")?e.value:e,U=(e,n)=>me(e.configuration,n)?tn(e.configuration[n]):void 0,A=(e,n=0)=>{let t=Number(e);return Number.isFinite(t)?t:n},J=e=>Math.max(0,Math.min(1,e)),X=e=>typeof e=="boolean"?e:typeof e=="number"?e!==0&&!Number.isNaN(e):typeof e=="string"?e.length>0&&e!=="false":!!e;function te(e){if(typeof e!="string"||!e.startsWith("/"))return null;let n=[];for(let t of e.slice(1).split("/")){let r=t.replace(/~1/g,"/").replace(/~0/g,"~");if(!r||K.has(r)||K.has(t))return null;n.push(r)}return{segments:n}}var ne=(e,n)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let t=Number(e);return Number.isSafeInteger(t)&&t>=0&&t<n?t:-1},Je=e=>{let n=A(e[0]),t=A(e[1]),r=A(e[2]),o=A(e[3],1),s=Math.hypot(n,t,r,o);return s>1e-8?[n/s,t/s,r/s,o/s]:[0,0,0,1]},en=(e,n,t,r)=>{if(typeof e=="number"&&typeof n=="number")return e+(n-e)*t;if(Array.isArray(e)&&Array.isArray(n)){if(r&&e.length===4&&n.length===4){let o=[0,0,0,1];return Ke(o,Je(e),Je(n),t),o}return e.slice(0,n.length).map((o,s)=>o+(n[s]-o)*t)}return t>=.5?n:e},Pe=(e,n,t)=>Array.isArray(e)&&Array.isArray(n)?e.slice(0,n.length).map((r,o)=>t(A(r),A(n[o]))):Array.isArray(e)?e.map(r=>t(A(r),A(n))):Array.isArray(n)?n.map(r=>t(A(e),A(r))):t(A(e),A(n)),Rn=(e,n)=>Array.isArray(e)?e.map(t=>n(A(t))):n(A(e)),nn=(e,n)=>Array.isArray(e)&&Array.isArray(n)?e.length===n.length&&e.every((t,r)=>Math.abs(t-n[r])<=1e-6):e===n,re=class{constructor(n,t,r){let o=Array.isArray(r.nodes)?r.nodes:[];if(o.length>Ye)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${Ye})`);let s=Array.isArray(r.variables)?r.variables:[];if(s.length>_e)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${_e})`);let x=Array.isArray(r.declarations)?r.declarations:[],p=Array.isArray(r.events)?r.events:[],f=new Map,m=new Map,d=new Map,S=new Map,R=new Map,P=new Map,v=[],b=[],T=new Map,C=1,V=0,I=0,w=0,E=0,k=!1,B=!1,z=!1;s.forEach((l,u)=>{if(!l||typeof l!="object")return;let h=W(tn(l.value));f.set(u,h);let g=l.id??l.name;typeof g=="string"&&g&&!K.has(g)&&f.set(g,h)}),(t?.nodes||[]).forEach((l,u)=>{for(let h of l?.children||[])typeof h=="number"&&T.set(h,u)});let H=l=>l.op||typeof l.declaration=="number"&&x[l.declaration]?.op||"",N=(l,u,h)=>{if(K.has(u))return;let g=m.get(l);g||m.set(l,g=Object.create(null)),g[u]=h},Y=(l,u)=>{if(typeof l!="number"&&typeof l!="string"||typeof l=="string"&&K.has(l)||!f.has(l)&&f.size>=_e*2)return;let h=W(u);if(f.set(l,h),typeof l=="number"){let g=s[l]?.id??s[l]?.name;typeof g=="string"&&!K.has(g)&&f.set(g,h)}},q=l=>typeof l=="number"?p[l]?.id??String(l):typeof l=="string"?/^\d+$/.test(l)&&p[Number(l)]?.id?p[Number(l)].id:l:"",Z=(l,u)=>{for(let h=l,g=0;h!==void 0&&h>=0&&g<128;h=T.get(h),g++)if(h===u)return!0;return!1},O=l=>{for(let u=v.length-1;u>=0;u--)v[u].key===l&&v.splice(u,1)},Ue=l=>{O(l.key),v.length>=vn&&v.shift(),v.push(l)},he=l=>{let u=te(l)?.segments;if(u){if(u[0]==="nodes"&&Array.isArray(t?.nodes)){let h=t.nodes[ne(u[1],t.nodes.length)];if(!h)return;let g=u[2];if(g in de){let c=de[g],a=h[g]||c;return c.map((i,y)=>A(a[y],i))}if(g==="weights"){let c=Array.isArray(h.weights)?h.weights:[0],a=u.length===4?ne(u[3],64):-2;return a===-2?c.map(i=>A(i)):a>=0?A(c[a]):void 0}if(g==="visible"||g==="extensions"&&u[3]==="KHR_node_visibility"&&u[4]==="visible")return h.extensions?.KHR_node_visibility?.visible??h.visible??!0}else if(u[0]==="materials"&&Array.isArray(t?.materials)){let h=t.materials[ne(u[1],t.materials.length)];if(!h)return;let g=h.pbrMetallicRoughness||{};if(u[2]==="pbrMetallicRoughness"){if(u[3]==="baseColorFactor"){let c=g.baseColorFactor||[1,1,1,1];return[A(c[0],1),A(c[1],1),A(c[2],1),A(c[3],1)]}if(u[3]==="metallicFactor"||u[3]==="roughnessFactor")return A(g[u[3]],1)}if(u[2]==="emissiveFactor"){let c=h.emissiveFactor||[0,0,0];return[A(c[0]),A(c[1]),A(c[2])]}if(u[2]==="alphaCutoff")return A(h.alphaCutoff,.5)}}},ae=(l,u)=>{let h=te(l)?.segments;if(!h)return!1;if(h[0]==="nodes"&&Array.isArray(t?.nodes)){let g=ne(h[1],t.nodes.length),c=t.nodes[g];if(!c)return!1;let a=h[2];if(a in de&&Array.isArray(u)){let i=de[a];if(u.length<i.length)return!1;let y=i.map((L,D)=>A(u[D],L));if(a==="rotation"){let L=Math.hypot(...y);y=L>1e-8?y.map(D=>D/L):[0,0,0,1]}c[a]=y,delete c.matrix;let F=n?.initialNodeTransforms?.[g];return F&&(F[a[0]]=[...y]),k=!0,!0}if(a==="weights"){Array.isArray(c.weights)||(c.weights=[]);let i=(y,F)=>{for(let L of n?.meshes||[])if(L.nodeIndex===g)for(let D of L.primitives||[])D.pluginData?.morph?.weights&&(D.pluginData.morph.weights[y]=F)};if(h.length===4){let y=ne(h[3],64);if(y<0)return!1;i(y,c.weights[y]=A(u))}else if(Array.isArray(u))c.weights=u.slice(0,64).map(y=>A(y)),c.weights.forEach((y,F)=>i(F,y));else return!1;return z=!0,!0}if(a==="visible"||a==="extensions"&&h[3]==="KHR_node_visibility"&&h[4]==="visible"){let i=X(u);return c.visible=i,(!c.extensions||typeof c.extensions!="object")&&(c.extensions={}),c.extensions.KHR_node_visibility={visible:i},B=!0,!0}}else if(h[0]==="materials"&&Array.isArray(t?.materials)){let g=ne(h[1],t.materials.length),c=t.materials[g];if(!c)return!1;let a=c.pbrMetallicRoughness||(c.pbrMetallicRoughness={}),i=y=>{for(let F of n?.meshes||[])for(let L of F.primitives||[])(L.materialIndex??0)===g&&y(L)};if(h[2]==="pbrMetallicRoughness"){if(h[3]==="baseColorFactor"&&Array.isArray(u)&&u.length>=3){let y=[J(A(u[0],1)),J(A(u[1],1)),J(A(u[2],1)),u[3]!==void 0?J(A(u[3],1)):a.baseColorFactor?.[3]??1];return a.baseColorFactor=y,i(F=>F.baseColor=[...y]),z=!0}if(h[3]==="metallicFactor"||h[3]==="roughnessFactor"){let y=h[3]==="metallicFactor",F=J(A(u,y?0:.5));return a[h[3]]=F,i(L=>L[y?"metallic":"roughness"]=F),z=!0}}if(h[2]==="emissiveFactor"&&Array.isArray(u)&&u.length>=3)return c.emissiveFactor=[0,1,2].map(y=>Math.max(0,A(u[y]))),z=!0;if(h[2]==="alphaCutoff")return c.alphaCutoff=J(A(u,.5)),z=!0}return!1},ge=(l,u,h=new Set)=>{let g=U(u,"pointer");if(typeof g!="string"||!g.startsWith("/"))return null;let c=g.replace(/\{([a-zA-Z0-9_]+)\}/g,(a,i)=>{let y=Math.trunc(Number(ie(l,i,void 0,h)??U(u,i)));return Number.isSafeInteger(y)&&y>=0?String(y):"-1"});return te(c)?c:null},ie=(l,u,h,g)=>{let c=o[l]?.values;if(!me(c,u))return h;let a=c[u];if(a==null)return h;if(typeof a!="object"||Array.isArray(a))return W(a);let i=a;return typeof i.node=="number"?sn(i.node,i.socket||"value",g):me(i,"value")?W(i.value):h},sn=(l,u,h)=>{if(l<0||l>=o.length||h.has(l)||h.size>128||++w>Mn)return;let g=o[l],c=H(g);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(c))return W(m.get(l)?.[u]);h.add(l);try{let a=(i,y=0)=>ie(l,i,y,h);if(c==="variable/get"){let i=U(g,"variable")??U(g,"id");return typeof i=="number"||typeof i=="string"?W(f.get(i)):void 0}if(c==="pointer/get"){let i=ge(l,g,h);return i?he(i):void 0}if(c.startsWith("math/")){let i=c.slice(5);if(i in Ze)return Rn(a("a"),Ze[i]);if(i in Qe){let y=/^(mul|div|rem|mod|pow)$/.test(i)?1:0;return Pe(a("a",i==="mul"?1:0),a("b",y),Qe[i])}if(i==="pi")return Math.PI;if(i==="e")return Math.E;if(i==="random")return Math.random();if(i==="clamp")return Pe(Pe(a("a"),a("b",a("min",0)),Math.max),a("c",a("max",1)),Math.min);if(i==="mix"||i==="quatSlerp")return en(a("a",0),a("b",1),A(a("c",a("t",.5)),.5),i==="quatSlerp");if(i==="dot"){let y=a("a"),F=a("b");return Array.isArray(y)&&Array.isArray(F)?y.reduce((L,D,M)=>L+(D||0)*(F[M]||0),0):A(y)*A(F)}if(i==="cross"){let y=a("a",[0,0,0]),F=a("b",[0,0,0]);return Array.isArray(y)&&Array.isArray(F)?[(y[1]||0)*(F[2]||0)-(y[2]||0)*(F[1]||0),(y[2]||0)*(F[0]||0)-(y[0]||0)*(F[2]||0),(y[0]||0)*(F[1]||0)-(y[1]||0)*(F[0]||0)]:[0,0,0]}if(i==="length"){let y=a("a");return Array.isArray(y)?Math.hypot(...y):Math.abs(A(y))}if(i==="distance"){let y=a("a"),F=a("b");return Array.isArray(y)&&Array.isArray(F)?Math.hypot(...y.map((L,D)=>(L||0)-(F[D]||0))):Math.abs(A(y)-A(F))}if(i==="normalize"){let y=a("a");if(!Array.isArray(y))return A(y)>=0?1:-1;let F=Math.hypot(...y);return F>1e-8?y.map(L=>L/F):y.map(()=>0)}if(i.startsWith("combine"))return["a","b","c","d"].slice(0,Number(i[7])||2).map(y=>A(a(y)));if(i.startsWith("extract")){let y=a("a");return Array.isArray(y)?y[u==="0"||u==="x"?0:u==="1"||u==="y"?1:u==="2"||u==="z"?2:3]??0:0}if(i==="eq")return nn(a("a"),a("b"));if(i==="ne")return!nn(a("a"),a("b"));if(i==="lt")return A(a("a"))<A(a("b"));if(i==="le")return A(a("a"))<=A(a("b"));if(i==="gt")return A(a("a"))>A(a("b"));if(i==="ge")return A(a("a"))>=A(a("b"));if(i==="isNaN")return Number.isNaN(Number(a("a")));if(i==="isInf"){let y=Number(a("a"));return!Number.isFinite(y)&&!Number.isNaN(y)}return i==="and"?X(a("a",!1))&&X(a("b",!1)):i==="or"?X(a("a",!1))||X(a("b",!1)):i==="xor"?X(a("a",!1))!==X(a("b",!1)):i==="not"?!X(a("a",!1)):i==="select"?W(X(a("condition",!1))?a("a"):a("b")):void 0}return c==="type/boolToInt"||c==="type/boolToFloat"?X(a("a",!1))?1:0:c==="type/intToBool"||c==="type/floatToBool"?A(a("a",0))!==0:c==="type/intToFloat"?A(a("a",0)):c==="type/floatToInt"?Math.trunc(A(a("a",0))):void 0}finally{h.delete(l)}},se=()=>{if(k){k=!1,z=!0;let l=Me(t);if(n){n.worldMatrices=l;for(let u of n.meshes||[])u.nodeIndex>=0&&u.nodeIndex<l.length&&(u.transform.set(l[u.nodeIndex]),Se(u.normalMatrix,u.transform))}}if(B){B=!1,z=!0;let l=t?.nodes;if(Array.isArray(n?.meshes)&&Array.isArray(l))for(let u of n.meshes){let h=!0;for(let g=u.nodeIndex,c=0;g!==void 0&&g>=0&&c<128;g=T.get(g),c++){let a=l[g];if(a?.visible===!1||a?.extensions?.KHR_node_visibility?.visible===!1){h=!1;break}}u.visible=h}}z&&(z=!1,n?.render?.())},ee=(l,u={steps:0})=>{if(!l||typeof l.node!="number")return;u.steps===0&&(w=0);let h=[l],g=c=>{h.length+u.steps<fe&&h.push(c)};for(;h.length>0&&u.steps<fe;){u.steps++;let c=h.shift();if(!c||c.node<0||c.node>=o.length)continue;let a=c.node,i=o[a];if(!i)continue;let y=c.socket||"in",F=H(i),L=(M,_=void 0)=>ie(a,M,_,new Set),D=(M="out")=>{let _=i.flows?.[M];_&&g(_)};switch(F){case"flow/branch":D(X(L("condition",!1))?"true":"false");break;case"flow/sequence":for(let M of Object.keys(i.flows||{}).sort((_,G)=>Number(_)-Number(G)||_.localeCompare(G)))D(M);break;case"flow/switch":{let M=i.flows?.[String(L("selection",L("value",0)))]??i.flows?.default;M&&g(M);break}case"flow/for":{let M=Math.trunc(A(L("startIndex",0))),_=Math.trunc(A(L("endIndex",0))),G=Math.max(1,Math.trunc(A(L("step",1),1))),$=i.flows?.body;if($&&_>M&&E<Tn){let cn=Math.min(Math.ceil((_-M)/G),fe);E++;try{for(let xe=0;xe<cn&&u.steps<fe;xe++)N(a,"index",M+xe*G),ee($,u)}finally{E--}}let Oe=i.flows?.completed??i.flows?.out;Oe&&g(Oe);break}case"flow/doN":{let M=y==="reset"?0:(d.get(a)||0)+1;if(d.set(a,M),N(a,"currentCount",M),N(a,"count",M),y!=="reset"){let _=Math.trunc(A(L("n",U(i,"stopIterations")??U(i,"n")??1),1));M<=_&&D()}break}case"flow/multiGate":{if(y==="reset"){P.set(a,0);break}let M=Object.keys(i.flows||{}).sort();if(!M.length)break;let _=U(i,"isRandom")?Math.floor(Math.random()*M.length):P.get(a)||0;_<M.length&&(D(M[_]),P.set(a,U(i,"isLoop")!==!1?(_+1)%M.length:_+1));break}case"flow/waitAll":{if(y==="reset"){S.delete(a);break}let M=S.get(a);M||S.set(a,M=new Set),M.add(y),M.size>=Math.max(1,Math.trunc(Number(U(i,"inputFlows")??2)||2))&&(M.clear(),D("out"),D("completed"));break}case"flow/throttle":{if(y==="reset"){R.delete(a);break}let M=Math.max(0,A(L("duration",0))),_=R.get(a);_===void 0||V-_>=M?(R.set(a,V),N(a,"lastRemainingTime",0),D()):N(a,"lastRemainingTime",Math.max(0,M-(V-_)));break}case"flow/delay":case"flow/setDelay":{if(y==="cancel"){for(let $=b.length-1;$>=0;$--)b[$].nodeIdx===a&&b.splice($,1);N(a,"lastDelayIndex",-1);break}let M=Math.max(0,A(L("duration",U(i,"duration")??0))),_=i.flows?.done??i.flows?.out;if(M<=0){N(a,"lastDelayIndex",-1),_&&g(_);break}b.length>=An&&b.shift();let G=C++;N(a,"lastDelayIndex",G),b.push({id:G,nodeIdx:a,rem:M,done:_}),F==="flow/setDelay"&&i.flows?.out&&i.flows?.done&&D("out");break}case"flow/cancelDelay":{let M=Math.trunc(A(L("delayIndex",-1),-1));if(M<0)b.length=0;else for(let _=b.length-1;_>=0;_--)b[_].id===M&&b.splice(_,1);D();break}case"variable/set":Y(U(i,"variable")??U(i,"id"),L("value")),D();break;case"variable/interpolate":{let M=U(i,"variable")??U(i,"id"),_=L("value",L("target")),G=Math.max(0,A(L("duration",U(i,"duration")??.3),.3));M!==void 0&&_!==void 0&&Ue({key:`var:${String(M)}`,varKey:M,from:W(L("from")??f.get(M)??0),to:W(_),dur:G,elapsed:0,quat:!1,linear:U(i,"easing")==="linear",done:i.flows?.done}),D();break}case"pointer/set":{let M=ge(a,i),_=L("value");M&&_!==void 0&&(O(`ptr:${M}`),ae(M,_)),D();break}case"pointer/interpolate":{let M=ge(a,i),_=L("value",L("target")),G=Math.max(0,A(L("duration",U(i,"duration")??.3),.3));if(M&&_!==void 0){let $=L("from")??he(M);$!==void 0&&(G<=0?(ae(M,_),D("done")):Ue({key:`ptr:${M}`,ptr:M,from:W($),to:W(_),dur:G,elapsed:0,quat:M.endsWith("/rotation"),linear:U(i,"easing")==="linear",done:i.flows?.done}))}D();break}case"animation/start":{let M=L("animation")??U(i,"animation")??U(i,"clipName"),_=typeof M=="number"?n?.animations?.[M]?.name??t?.animations?.[M]?.name:typeof M=="string"?M:void 0;n?.playAnimation?.(_),z=!0,D();break}case"animation/stop":case"animation/resetAt":n?.pauseAnimation?.(),F==="animation/resetAt"&&n?.evaluateAnimation?.(A(L("time",0))),z=!0,D();break;case"event/send":case"customEvent/send":{let M=q(U(i,"event")??U(i,"id")),_={};for(let G of Object.keys(i.values||{}))K.has(G)||(_[G]=L(G));M&&(typeof CustomEvent<"u"&&typeof n?.container?.dispatchEvent=="function"&&n.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:M,values:_}})),ze(M,_,u)),D();break}default:D();break}}};this.readScenePointer=he,this.writeScenePointer=ae,this.fireOnStart=()=>{o.forEach(l=>{H(l)==="event/onStart"&&ee(l.flows?.out)}),se()},this.fireOnSelect=l=>{if(!l)return;let u=typeof l.meshIndex=="number"?l.meshIndex:-1,h=typeof l.nodeIndex=="number"?l.nodeIndex:n?.meshes?.[u]?.nodeIndex??-1;o.forEach((g,c)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(H(g)))return;let a=U(g,"nodeIndex")??U(g,"node")??ie(c,"nodeIndex",void 0,new Set),i=U(g,"meshName");if(typeof i=="string"&&i?l.meshName===i:a==null||Number(a)<0||Number.isNaN(Number(a))||Z(h,Math.trunc(Number(a)))){if(N(c,"nodeIndex",h),N(c,"meshIndex",u),Array.isArray(l.hitPoint)){let F=[A(l.hitPoint[0]),A(l.hitPoint[1]),A(l.hitPoint[2])];N(c,"hitPoint",F),N(c,"point",F),N(c,"intersectionPoint",F)}if(Array.isArray(l.normal)){let F=[A(l.normal[0]),A(l.normal[1],1),A(l.normal[2])];N(c,"normal",F),N(c,"hitNormal",F)}typeof l.distance=="number"&&N(c,"distance",l.distance),ee(g.flows?.out)}}),se()},this.receiveCustomEvent=(l,u={})=>ze(l,u,{steps:0});function ze(l,u,h){if(!(I>=Sn)){I++;try{let g=q(l);o.forEach((c,a)=>{if(!/^(customE|e)vent\/receive$/.test(H(c)))return;let i=U(c,"event")??U(c,"id");if(!(q(i)!==g&&String(i)!==String(l))){for(let[y,F]of Object.entries(u))K.has(y)||N(a,y,W(F));ee(c.flows?.out,h)}}),se()}finally{I--}}}this.tick=l=>{if(!Number.isFinite(l)||l<0)return;let u=Math.min(l,.25);V+=u,o.forEach((g,c)=>{H(g)==="event/onTick"&&(N(c,"timeDelta",u),N(c,"dt",u),N(c,"timeElapsed",V),ee(g.flows?.out))});let h=[];for(let g=v.length-1;g>=0;g--){let c=v[g];c.elapsed+=u;let a=c.dur>1e-6?J(c.elapsed/c.dur):1,i=c.linear?a:a*a*(3-2*a),y=en(c.from,c.to,i,c.quat);c.ptr?ae(c.ptr,y):c.varKey!==void 0&&Y(c.varKey,y),a>=1&&(v.splice(g,1),c.done&&h.push(c.done))}for(let g=b.length-1;g>=0;g--){let c=b[g];c.rem-=u,c.rem<=0&&(b.splice(g,1),c.done&&h.push(c.done))}for(let g of h)ee(g);se()},this.dispose=()=>{v.length=0,b.length=0,f.clear(),m.clear(),d.clear(),S.clear(),R.clear(),P.clear()}}},j=new WeakMap,pe=new WeakMap;function wn(e,n){if(!e||typeof e!="object"||!Number.isFinite(n)||n<=0||He().some(p=>p.name==="xr-live-head-follow"))return;let t=e.gltf,r=t?.nodes;if(!Array.isArray(r)||r.length===0)return;let o=Math.min(n,.1),s=(pe.get(e)||0)+o,x=!1;for(let p=0;p<r.length;p++){let f=r[p],m=qe(f?.extras?.xr?.orbit);if(!m)continue;let d=0,S=0,R=0;if(Array.isArray(m.target))d=m.target[0],S=m.target[1],R=m.target[2];else if(typeof m.target=="string"&&m.target!=="head"){let C=r.find(V=>V?.name===m.target);Array.isArray(C?.translation)&&(d=A(C.translation[0]),S=A(C.translation[1]),R=A(C.translation[2]))}let P=m.phase+m.speed*s,v=d+Math.cos(P)*m.radius,b=S+m.height,T=R+Math.sin(P)*m.radius;if(f.translation=[v,b,T],m.faceCenter){let C=Math.atan2(d-v,R-T);f.rotation=[0,Math.sin(C*.5),0,Math.cos(C*.5)]}x=!0}if(x){pe.set(e,s);let p=Me(t);e.worldMatrices=p;for(let f of e.meshes||[])f.nodeIndex>=0&&f.nodeIndex<p.length&&(f.transform.set(p[f.nodeIndex]),Se(f.normalMatrix,f.transform))}}function ye(e){if(!(!e||typeof e!="object"))return j.get(e)||j.get(e.viewer)||j.get(e._view)}function ke(e,n,t){let r=ye(e);return r?(r.receiveCustomEvent(n,t),!0):!1}var Fe={name:"khr-interactivity",sendInteractivityEvent:ke,getInteractivityVM:ye,onLoadModel(e,n){if(!e||typeof e!="object")return;j.get(e)?.dispose(),j.delete(e),pe.delete(e);let t=n?.extensions?.KHR_interactivity,r=Array.isArray(t?.graphs)?t.graphs[t.graph??0]:t;if(!r||!Array.isArray(r.nodes))return;let o=new re(e,n,r);j.set(e,o),o.fireOnStart()},onMeshSelect(e,n){j.get(e)?.fireOnSelect(n)},onUpdate(e,n){j.get(e)?.tick(n),wn(e,n)},onDestroy(e,n){j.get(n)?.dispose(),j.delete(n),pe.delete(n)}};var oe=new Map,Le=new WeakMap;function rn(e,n){oe.set(e,n)}var Ce={name:"materials",onBuildPrimitiveVAO(e,n,t,r,o){return(((r?.materials&&t.material!==void 0?r.materials[t.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,n){let t=Le.get(e);t||(t=e.createTexture(),Le.set(e,t));let r=Math.max(1,n.canvas.width),o=Math.max(1,n.canvas.height);e.activeTexture(33990),e.bindTexture(3553,t),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,n,t,r){if(!n)return null;if(n.name&&oe.has(n.name)){let v=oe.get(n.name);return{vs:v.vs||t,fs:v.fs||r}}let o=n.extensions||{},s=o.KHR_materials_clearcoat,x=o.KHR_materials_sheen,p=!!o.KHR_materials_transmission,f=!!o.KHR_materials_ior,m=o.KHR_materials_iridescence;if(!s&&!x&&!o.KHR_materials_unlit&&!p&&!o.KHR_materials_volume&&!f&&!o.KHR_materials_dispersion&&!m)return null;if(o.KHR_materials_unlit)return{vs:t,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 d=r;if(p){let v=d.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
|
|
33
|
-
`;d=d.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
|
|
34
|
-
${v}out vec4 fragColor;`)}let S=(v,b,T=0,C=1e6,V=3)=>{let I=Number(v);return(Number.isFinite(I)?Math.min(C,Math.max(T,I)):b).toFixed(V)},R=Number(o.KHR_materials_ior?.ior??1.5),P=Number.isFinite(R)?Math.min(10,Math.max(1,R)):1.5;if(f){let v=Math.pow((P-1)/(P+1),2);d=d.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${S(v,.04,0,1,4)}),base.rgb,metallic);`)}if(m){let v=S(m.iridescenceFactor,1,0,1),b=S(m.iridescenceIor,1.3,1,10);d=d.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${b}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${v}*pow(1.-NoV,2.));`)}if(p){let v=S(o.KHR_materials_transmission?.transmissionFactor,1,0,1),b=o.KHR_materials_volume||{},T=S(b.thicknessFactor,.5,0,1e4),C=S(b.attenuationDistance,1,.001,1e6),V=Array.isArray(b.attenuationColor)?b.attenuationColor:[1,1,1],I=S(o.KHR_materials_dispersion?.dispersion,0,0,10);d=d.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=${S(P,1.5,1,10)},dV=${I},tV=${T},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
|
|
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
|
-
vec3 tr=vec3(textureLod(uTransmissionTex,clamp(sUV+refractedR.xy*sc,.001,.999),lod).r,textureLod(uTransmissionTex,clamp(sUV+rG.xy*sc,.001,.999),lod).g,textureLod(uTransmissionTex,clamp(sUV+refractedB.xy*sc,.001,.999),lod).b);
|
|
38
|
-
vec3 aCol=vec3(${S(V[0],1,0,1)},${S(V[1],1,0,1)},${S(V[2],1,0,1)});
|
|
39
|
-
vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${C},.001));
|
|
40
|
-
diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${v});`)}if(s&&!r.includes("uClearcoat")){let v=S(s.clearcoatFactor,1,0,1),b=S(s.clearcoatRoughnessFactor,0,0,1);d=d.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${b},NoV)*${v};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${b})*ccF;fragColor=vec4(color,base.a);`)}if(x){let v=Array.isArray(x.sheenColorFactor)?x.sheenColorFactor:[1,1,1],b=`color+=vec3(${S(v[0],1,0,1)},${S(v[1],1,0,1)},${S(v[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;d.includes("color=applyToneMapping(color,uToneMapping);")?d=d.replace("color=applyToneMapping(color,uToneMapping);",`${b}color=applyToneMapping(color,uToneMapping);`):d=d.replace("fragColor=vec4(color,base.a);",`${b}fragColor=vec4(color,base.a);`)}return{vs:t,fs:d}},onBeforeDrawPrimitive(e,n,t,r,o,s){let x=t.materialIndex;if(x!==void 0&&s?.materials){let p=s.materials[x];p?.name&&oe.has(p.name)&&oe.get(p.name).onBindUniforms?.(e,n,t)}if(t.isTransmissive){let p=Le.get(e);if(p){e.activeTexture(33990),e.bindTexture(3553,p);let f=e.getUniformLocation(n,"uTransmissionTex");f&&e.uniform1i(f,6);let m=e.getUniformLocation(n,"uViewportSize");m&&e.uniform2f(m,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var In=`#version 300 es
|
|
41
|
-
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.);}`,_n=`#version 300 es
|
|
42
|
-
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);}`,be=new WeakMap,on=new Float32Array(20);function Ve(e,n){let[t,r,o,s,x,p]=n;return[e[0]*t+e[4]*r+e[8]*o+e[12],e[1]*t+e[5]*r+e[9]*o+e[13],e[2]*t+e[6]*r+e[10]*o+e[14],Math.abs(e[0])*s+Math.abs(e[4])*x+Math.abs(e[8])*p,Math.abs(e[1])*s+Math.abs(e[5])*x+Math.abs(e[9])*p,Math.abs(e[2])*s+Math.abs(e[6])*x+Math.abs(e[10])*p]}function Pn(e){if(e._lb!==void 0)return e._lb;let n=1e9,t=1e9,r=1e9,o=-1e9,s=-1e9,x=-1e9;for(let p of e.primitives||[]){let f=p.positions;if(f)for(let m=0;m<f.length;m+=3)f[m]<n&&(n=f[m]),f[m+1]<t&&(t=f[m+1]),f[m+2]<r&&(r=f[m+2]),f[m]>o&&(o=f[m]),f[m+1]>s&&(s=f[m+1]),f[m+2]>x&&(x=f[m+2])}return e._lb=n<=o?[(n+o)*.5,(t+s)*.5,(r+x)*.5,(o-n)*.5,(s-t)*.5,(x-r)*.5]:null}function kn(e){let n=be.get(e);if(n)return n;let t=(p,f)=>{let m=e.createShader(p);return e.shaderSource(m,f),e.compileShader(m),m},r=e.createProgram();e.attachShader(r,t(35633,In)),e.attachShader(r,t(35632,_n)),e.linkProgram(r);let o=e.createVertexArray(),s=e.createBuffer(),x=e.createBuffer();return e.bindVertexArray(o),e.bindBuffer(34962,s),e.bufferData(34962,80,35048),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,5126,!1,20,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,5126,!1,20,12),e.bindBuffer(34963,x),e.bufferData(34963,new Uint16Array([0,1,2,0,2,3]),35044),e.bindVertexArray(null),n={prog:r,vao:o,vbo:s,ibo:x,uMVP:e.getUniformLocation(r,"uMVP"),uIntensity:e.getUniformLocation(r,"uShadowIntensity"),uSoftness:e.getUniformLocation(r,"uShadowSoftness")},be.set(e,n),n}var Ne={name:"contact-shadow",onAfterRender(e,n,t){let r=n.shadowIntensity;if(r<=0||!n.bounds)return;let o=kn(e),s=!n.xrSessionActive&&(n.backdropMeshes?.length??0)>0,x=[],p=[];for(let b of n.meshes||[]){if(!b||b.visible===!1||b.isPluginMesh||b.name==="__xr_reticle__"||b.name?.startsWith("__xr_slot_"))continue;let T=Pn(b);if(!T)continue;b.transform&&(T=Ve(b.transform,T)),n.modelRootMatrix&&(T=Ve(n.modelRootMatrix,T));let[C,V,I,w,E,k]=T,B=[C,I,w,k,V-E,V+E];/floor|table|pedestal|ground|base|plane/i.test(b.name||"")||E<.14&&Math.min(w,k)>.45?p.push(B):x.push(B)}let f=[],m=n.bounds.center||[0,0,0],d=Math.max(.05,Number(n.bounds.radius)||.5),S=n.bounds.min,R=S?[m[0],m[1],m[2],d,Math.max(.01,m[1]-S[1]),d]:[m[0],m[1],m[2],d,d,d];n.modelRootMatrix&&(R=Ve(n.modelRootMatrix,R));let v=n.xrSessionActive&&p.length===0&&String(n.container?.tagName||"").toLowerCase()==="xr-live"?(n.modelRootMatrix?n.modelRootMatrix[5]*-.25+n.modelRootMatrix[13]:-.25)+.002:R[1]-R[4]+.002;for(let[b,T,C,V,I]of x){let w=-1/0;for(let[k,B,z,H,,N]of p)I>=N-.08&&Math.abs(b-k)<=z&&Math.abs(T-B)<=H&&N+.002>w&&(w=N+.002);s&&(w=Math.max(w,b>=.04&&b<=.36&&T>=-.34&&T<=-.04&&I>=.01?.036:Math.hypot(b,T)<=.66&&I>=-.06?.003:-.477)),isFinite(w)||(w=v);let E=f.find(k=>Math.hypot(b-k[0],T-k[1])<.06&&Math.abs(w-k[5])<.05);E?(E[2]=Math.max(E[2],C*.78),E[3]=Math.max(E[3],V*.78),E[4]=Math.min(E[4],I)):f.push([b,T,C,V,I,w])}if(f.length===0){let b=Math.max(.1,R[3]*1.5)/1.45;f.push([R[0],R[2],b,b,v,v])}e.useProgram(o.prog),e.uniformMatrix4fv(o.uMVP,!1,t),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[b,T,C,V,I,w]of f){let E=Math.max(0,I-w),k=r/(1+E*2);if(k<.02)continue;let B=1+Math.min(.75,E*.85),z=Math.max(.045,C*1.45*B),H=Math.max(.045,V*1.45*B);on.set([b-z,w,T-H,0,0,b+z,w,T-H,1,0,b+z,w,T+H,1,1,b-z,w,T+H,0,1]),e.bufferSubData(34962,0,on),e.uniform1f(o.uIntensity,k),e.uniform1f(o.uSoftness,Math.min(1,n.shadowSoftness+Math.min(.45,E*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let n=be.get(e);n&&(e.deleteVertexArray(n.vao),e.deleteBuffer(n.vbo),e.deleteBuffer(n.ibo),e.deleteProgram(n.prog),be.delete(e))}};var an=new WeakMap,De={name:"webxr-suite",onConfigureXRSessionInit(e,n){let t=new Set(n.optionalFeatures||[]);t.add("hit-test"),t.add("light-estimation");let r=e?.querySelector?.('[slot="ar-overlay"]')||null;r&&(t.add("dom-overlay"),n.domOverlay={root:r},r.addEventListener?.("beforexrselect",o=>{o.preventDefault()})),n.optionalFeatures=Array.from(t)},onXRFrame(e,n,t,r){if(!e||!n||!t||!r)return;let o=an.get(n);if(o||(o={lightProbe:null},an.set(n,o),typeof n.requestLightProbe=="function"&&n.requestLightProbe().then(s=>{o&&s&&(o.lightProbe=s)}).catch(()=>{})),o.lightProbe&&typeof t.getLightEstimate=="function"){let s=t.getLightEstimate(o.lightProbe);if(s){let x=s.primaryLightDirection,p=s.primaryLightIntensity;if(x&&p&&Array.isArray(e.lights)){let f=e.lights.find(d=>d.type==="directional");f||(f={type:"directional",direction:[.5,1,.8],color:[1,1,1],intensity:1},e.lights.push(f)),f.direction=[x.x,x.y,x.z];let m=Math.max(p.x,p.y,p.z,.001);f.color=[p.x/m,p.y/m,p.z/m],f.intensity=m}s.sphericalHarmonicsCoefficients&&e.gl&&le(e.gl,s.sphericalHarmonicsCoefficients)}}}};Q(Ne);Q(Ie);Q(Re);Q(Ce);Q(De);Q(Fe);return pn(Fn);})();
|