three-live 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +117 -4
- package/dist/three-author-engine.js +27 -27
- package/dist/three-author.d.ts +117 -4
- package/dist/three-convert.d.ts +117 -4
- package/dist/three-live-animation.d.ts +117 -4
- package/dist/three-live-element.d.ts +117 -4
- package/dist/three-live-extras.cjs +10 -10
- package/dist/three-live-extras.d.ts +117 -4
- package/dist/three-live-extras.js +10 -10
- package/dist/three-live-extras.min.js +10 -10
- package/dist/three-live-full.cjs +14 -14
- package/dist/three-live-full.js +12 -12
- package/dist/three-live-full.min.js +14 -14
- package/dist/three-live-viewer.d.ts +117 -4
- package/dist/three-view.d.ts +117 -4
- package/dist/three-xr.d.ts +117 -4
- package/package.json +1 -1
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
"use strict";var ve=Object.defineProperty;var
|
|
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.);}`)),
|
|
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.);}`)),
|
|
17
|
+
"use strict";var ve=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var lt=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>{for(var n in t)ve(e,n,{get:t[n],enumerable:!0})},dt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!ut.call(e,o)&&o!==n&&ve(e,o,{get:()=>t[o],enumerable:!(r=ct(t,o))||r.enumerable});return e};var mt=e=>dt(ve({},"__esModule",{value:!0}),e);var kt={};ft(kt,{InteractivityVM:()=>re,contactShadowPlugin:()=>Ve,environmentMapPlugin:()=>Re,getEnvironmentSH:()=>$e,getInteractivityVM:()=>ye,hotspotPlugin:()=>Ie,interactivityPlugin:()=>Fe,materialsPlugin:()=>Ce,parseSafeGltfPointer:()=>ne,registerMaterialShader:()=>rt,sendInteractivityEvent:()=>ke,setEnvironmentSH:()=>le,webxrPlugin:()=>De});module.exports=mt(kt);var ce="__THREE_LIVE_REGISTRY__";function Ae(){let e=typeof globalThis<"u"?globalThis:{};if(!e[ce]){let t={plugins:[],decoders:new Map};try{Object.defineProperty(e,ce,{value:t,writable:!1,configurable:!1,enumerable:!1})}catch{e[ce]=t}}return e[ce]}var Lt=Ae().plugins;function Q(e){let t=Ae().plugins;t.some(n=>n.name===e.name)||t.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 pt(e,t,n){let r=t[0],o=t[1],s=t[2],x=t[3],p=t[4],f=t[5],m=t[6],d=t[7],S=t[8],R=t[9],P=t[10],v=t[11],b=t[12],M=t[13],C=t[14],N=t[15],I=n[0],w=n[1],E=n[2],k=n[3];return e[0]=I*r+w*p+E*S+k*b,e[1]=I*o+w*f+E*R+k*M,e[2]=I*s+w*m+E*P+k*C,e[3]=I*x+w*d+E*v+k*N,I=n[4],w=n[5],E=n[6],k=n[7],e[4]=I*r+w*p+E*S+k*b,e[5]=I*o+w*f+E*R+k*M,e[6]=I*s+w*m+E*P+k*C,e[7]=I*x+w*d+E*v+k*N,I=n[8],w=n[9],E=n[10],k=n[11],e[8]=I*r+w*p+E*S+k*b,e[9]=I*o+w*f+E*R+k*M,e[10]=I*s+w*m+E*P+k*C,e[11]=I*x+w*d+E*v+k*N,I=n[12],w=n[13],E=n[14],k=n[15],e[12]=I*r+w*p+E*S+k*b,e[13]=I*o+w*f+E*R+k*M,e[14]=I*s+w*m+E*P+k*C,e[15]=I*x+w*d+E*v+k*N,e}function yt(e,t,n,r){let o=t[0],s=t[1],x=t[2],p=t[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,M=x*d,C=p*f,N=p*m,I=p*d,w=r[0],E=r[1],k=r[2];return e[0]=(1-(v+M))*w,e[1]=(R+I)*w,e[2]=(P-N)*w,e[3]=0,e[4]=(R-I)*E,e[5]=(1-(S+M))*E,e[6]=(b+C)*E,e[7]=0,e[8]=(P+N)*k,e[9]=(b-C)*k,e[10]=(1-(S+v))*k,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Se(e,t){let n=t[0],r=t[1],o=t[2],s=t[4],x=t[5],p=t[6],f=t[8],m=t[9],d=t[10],S=d*x-p*m,R=-d*s+p*f,P=m*s-x*f,v=n*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*n-o*f)*v,e[5]=(-p*n+o*s)*v,e[6]=P*v,e[7]=(-m*n+r*f)*v,e[8]=(x*n-r*s)*v),e}function Ge(e,t){let n=t[0],r=t[1],o=t[2],s=t[3],x=t[4],p=t[5],f=t[6],m=t[7],d=t[8],S=t[9],R=t[10],P=t[11],v=t[12],b=t[13],M=t[14],C=t[15],N=n*p-r*x,I=n*f-o*x,w=n*m-s*x,E=r*f-o*p,k=r*m-s*p,B=o*m-s*f,U=d*b-S*v,H=d*M-R*v,V=d*C-P*v,Y=S*M-R*b,q=S*C-P*b,Z=R*C-P*M,z=N*Z-I*q+w*Y+E*V-k*H+B*U;return z?(z=1/z,e[0]=(p*Z-f*q+m*Y)*z,e[1]=(o*q-r*Z-s*Y)*z,e[2]=(b*B-M*k+C*E)*z,e[3]=(R*k-S*B-P*E)*z,e[4]=(f*V-x*Z-m*H)*z,e[5]=(n*Z-o*V+s*H)*z,e[6]=(M*w-v*B-C*I)*z,e[7]=(d*B-R*w+P*I)*z,e[8]=(x*q-p*V+m*U)*z,e[9]=(r*V-n*q-s*U)*z,e[10]=(v*k-b*w+C*N)*z,e[11]=(S*w-d*k-P*N)*z,e[12]=(p*H-x*Y-f*U)*z,e[13]=(n*Y-r*H+o*U)*z,e[14]=(b*I-v*E-M*N)*z,e[15]=(d*E-S*I+R*N)*z,e):null}function Te(e,t){let n=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let d=0;d<n;d++)r.push(Be());if(n===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>=n||s.has(d))return;s.add(d);let P=e.nodes[d];if(!P)return;let v=Be();if(t&&t[d])v.set(t[d]);else if(P.matrix&&P.matrix.length===16)v.set(P.matrix);else{let M=P.translation||[0,0,0],C=P.rotation||[0,0,0,1],N=P.scale||[1,1,1];yt(v,C,M,N)}let b=r[d];if(S?pt(b,S,v):b.set(v),Array.isArray(P.children))for(let M of P.children)typeof M=="number"&&p(M,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<n;d++)o.has(d)||f.push(d);for(let d of f)p(d,null);for(let d=0;d<n;d++)!o.has(d)&&!f.includes(d)&&p(d,null);return r}var Me=new WeakMap;function le(e,t){let n=t instanceof Float32Array?t:new Float32Array(t);Me.set(e,n)}function $e(e){return Me.get(e)}async function bt(e,t){if(!t)return null;let n;if(typeof t=="string")if(typeof fetch<"u"&&typeof createImageBitmap=="function"){let s=await(await fetch(t)).blob();n=await createImageBitmap(s)}else if(typeof Image<"u")n=await new Promise((o,s)=>{let x=new Image;x.crossOrigin="anonymous",x.onload=()=>o(x),x.onerror=s,x.src=t});else return null;else n=t;let r=e.createTexture();return e.bindTexture(3553,r),e.texImage2D(3553,0,6408,6408,5121,n),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553),r}var We=new WeakMap,Xe=new Float32Array(16);async function je(e,t,n){let r=n?await bt(e.gl,n):null;e[t]&&e.gl.deleteTexture(e[t]),e[t]=r}var Re={name:"environment-map",setEnvironmentImage(e,t){return je(e,"environmentTexture",t)},setSkyboxImage(e,t){return je(e,"skyboxTexture",t)},onBeforeDrawScene(e,t,n,r,o){if(!e.skyboxTexture||typeof t.createProgram!="function")return;let s=We.get(t);if(!s){let S=(v,b)=>{let M=t.createShader(v);return t.shaderSource(M,b),t.compileShader(M),M},R=t.createProgram();t.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.);}`)),t.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.);}`)),t.linkProgram(R);let P=typeof t.createVertexArray=="function"?t.createVertexArray():null;s={program:R,vao:P},We.set(t,s)}let x=Ge(Xe,n)||Xe;t.depthMask(!1),t.useProgram(s.program),s.vao&&t.bindVertexArray(s.vao),t.activeTexture(33984),t.bindTexture(3553,e.skyboxTexture);let p=t.getUniformLocation(s.program,"uSkyboxMap");p&&t.uniform1i(p,0);let f=t.getUniformLocation(s.program,"uInvVP");f&&t.uniformMatrix4fv(f,!1,x);let m=t.getUniformLocation(s.program,"uCameraPos");m&&t.uniform3f(m,r[0],r[1],r[2]);let d=t.getUniformLocation(s.program,"uExposure");d&&t.uniform1f(d,e.exposure??1),t.drawArrays(4,0,3),t.depthMask(!0)},onResolveShader(e,t,n,r){if(r.includes("evalSHIrradiance"))return null;let o=r.replace("out vec4 fragColor;",`uniform vec3 uSH[9];
|
|
20
20
|
uniform int uHasSH;
|
|
21
21
|
out vec4 fragColor;`).replace("void main(){",`vec3 integrateBRDFApprox(vec3 f0,float r,float NoV){vec4 c0=vec4(-1.,-.0275,-.572,.022),c1=vec4(1.,.0425,1.04,-.04),rv=r*c0+c1;float a=min(rv.x*rv.x,exp2(-9.28*NoV))*rv.x+rv.y;vec2 ab=vec2(-1.04,1.04)*a+rv.zw;return f0*ab.x+vec3(ab.y);}
|
|
22
22
|
vec3 evalSHIrradiance(vec3 n){return max(vec3(0.),uSH[0]+uSH[1]*n.y+uSH[2]*n.z+uSH[3]*n.x+uSH[4]*(n.x*n.y)+uSH[5]*(n.y*n.z)+uSH[6]*(3.*n.z*n.z-1.)+uSH[7]*(n.x*n.z)+uSH[8]*(n.x*n.x-n.y*n.y));}
|
|
@@ -29,14 +29,14 @@ envDiffuse=uHasSH==1?evalSHIrradiance(N):textureLod(uEnvironmentMap,equirectangu
|
|
|
29
29
|
}else if(uHasSH==1){
|
|
30
30
|
specularIBL=getStudioRadiance(R,roughness)*integrateBRDFApprox(F,roughness,NoV);
|
|
31
31
|
envDiffuse=evalSHIrradiance(N);
|
|
32
|
-
}`),{vs: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;
|
|
32
|
+
}`),{vs:n,fs:o}},onBeforeDrawPrimitive(e,t,n,r,o,s){let x=Me.get(e),p=e.getUniformLocation(t,"uHasSH");if(x&&x.length>=27){p&&e.uniform1i(p,1);let f=e.getUniformLocation(t,"uSH");f&&e.uniform3fv(f,x)}else p&&e.uniform1i(p,0)},onAttributeChanged(e,t,n,r){t==="environment-image"&&e.viewer?this.setEnvironmentImage?.(e.viewer,r):t==="skybox-image"&&e.viewer&&this.setSkyboxImage?.(e.viewer,r)}};var we=new WeakMap;function Ee(e,t){let n=t||e.viewer;if(!n||typeof n.projectPointToScreen!="function")return;let r=e.mockHotspots||e.querySelectorAll('[slot^="hotspot-"], [data-position]');for(let o=0;o<r.length;o++){let 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=n.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 t=new MutationObserver(()=>{Ee(e)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),we.set(e,t)},onCameraChange(e,t){t&&Ee(t,e)},onElementDisconnected(e){let t=we.get(e);t&&(t.disconnect(),we.delete(e))}};function ue(e,t,n,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(t,Math.min(n,o))}function ht(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function gt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function qe(e){let t=gt(e);if(!t)return null;let n=t.target;return{target:ht(n)?[n[0],n[1],n[2]]:typeof n=="string"&&n.length>0&&n.length<=256?n:[0,0,0],radius:ue(t.radius,.01,50,.5),speed:ue(t.speed,-20,20,.5),height:ue(t.height,-10,10,0),phase:ue(t.phase,-1e6,1e6,0),faceCenter:t.faceCenter===!0}}function Ke(e,t,n,r){let o=t[0],s=t[1],x=t[2],p=t[3],f=n[0],m=n[1],d=n[2],S=n[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,M=Math.sin(r*P)/v;return e[0]=o*b+f*M,e[1]=s*b+m*M,e[2]=x*b+d*M,e[3]=p*b+S*M,e}var Ye=1024,_e=256,fe=2048,xt=128,vt=64,At=16,St=1e4,Tt=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,t)=>e+t,sub:(e,t)=>e-t,mul:(e,t)=>e*t,div:(e,t)=>Math.abs(t)<1e-12?0:e/t,rem:(e,t)=>Math.abs(t)<1e-12?0:e%t,mod:(e,t)=>Math.abs(t)<1e-12?0:e%t,min:Math.min,max:Math.max,pow:Math.pow,atan2:Math.atan2},de={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},me=(e,t)=>e!==null&&typeof e=="object"&&!K.has(t)&&Object.prototype.hasOwnProperty.call(e,t),W=e=>Array.isArray(e)?[...e]:e,nt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&me(e,"value")?e.value:e,O=(e,t)=>me(e.configuration,t)?nt(e.configuration[t]):void 0,A=(e,t=0)=>{let n=Number(e);return Number.isFinite(n)?n:t},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 ne(e){if(typeof e!="string"||!e.startsWith("/"))return null;let t=[];for(let n of e.slice(1).split("/")){let r=n.replace(/~1/g,"/").replace(/~0/g,"~");if(!r||K.has(r)||K.has(n))return null;t.push(r)}return{segments:t}}var te=(e,t)=>{if(e===void 0||!/^\d+$/.test(e))return-1;let n=Number(e);return Number.isSafeInteger(n)&&n>=0&&n<t?n:-1},Je=e=>{let t=A(e[0]),n=A(e[1]),r=A(e[2]),o=A(e[3],1),s=Math.hypot(t,n,r,o);return s>1e-8?[t/s,n/s,r/s,o/s]:[0,0,0,1]},et=(e,t,n,r)=>{if(typeof e=="number"&&typeof t=="number")return e+(t-e)*n;if(Array.isArray(e)&&Array.isArray(t)){if(r&&e.length===4&&t.length===4){let o=[0,0,0,1];return Ke(o,Je(e),Je(t),n),o}return e.slice(0,t.length).map((o,s)=>o+(t[s]-o)*n)}return n>=.5?t:e},Pe=(e,t,n)=>Array.isArray(e)&&Array.isArray(t)?e.slice(0,t.length).map((r,o)=>n(A(r),A(t[o]))):Array.isArray(e)?e.map(r=>n(A(r),A(t))):Array.isArray(t)?t.map(r=>n(A(e),A(r))):n(A(e),A(t)),Mt=(e,t)=>Array.isArray(e)?e.map(n=>t(A(n))):t(A(e)),tt=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>Math.abs(n-t[r])<=1e-6):e===t,re=class{constructor(t,n,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=[],M=new Map,C=1,N=0,I=0,w=0,E=0,k=!1,B=!1,U=!1;s.forEach((l,u)=>{if(!l||typeof l!="object")return;let h=W(nt(l.value));f.set(u,h);let g=l.id??l.name;typeof g=="string"&&g&&!K.has(g)&&f.set(g,h)}),(n?.nodes||[]).forEach((l,u)=>{for(let h of l?.children||[])typeof h=="number"&&M.set(h,u)});let H=l=>l.op||typeof l.declaration=="number"&&x[l.declaration]?.op||"",V=(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=M.get(h),g++)if(h===u)return!0;return!1},z=l=>{for(let u=v.length-1;u>=0;u--)v[u].key===l&&v.splice(u,1)},Oe=l=>{z(l.key),v.length>=xt&&v.shift(),v.push(l)},he=l=>{let u=ne(l)?.segments;if(u){if(u[0]==="nodes"&&Array.isArray(n?.nodes)){let h=n.nodes[te(u[1],n.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?te(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(n?.materials)){let h=n.materials[te(u[1],n.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=ne(l)?.segments;if(!h)return!1;if(h[0]==="nodes"&&Array.isArray(n?.nodes)){let g=te(h[1],n.nodes.length),c=n.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=t?.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 t?.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=te(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 U=!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(n?.materials)){let g=te(h[1],n.materials.length),c=n.materials[g];if(!c)return!1;let a=c.pbrMetallicRoughness||(c.pbrMetallicRoughness={}),i=y=>{for(let F of t?.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]),U=!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),U=!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]))),U=!0;if(h[2]==="alphaCutoff")return c.alphaCutoff=J(A(u,.5)),U=!0}return!1},ge=(l,u,h=new Set)=>{let g=O(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)??O(u,i)));return Number.isSafeInteger(y)&&y>=0?String(y):"-1"});return ne(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"?it(i.node,i.socket||"value",g):me(i,"value")?W(i.value):h},it=(l,u,h)=>{if(l<0||l>=o.length||h.has(l)||h.size>128||++w>St)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=O(g,"variable")??O(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 Mt(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 et(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,T)=>L+(D||0)*(F[T]||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 tt(a("a"),a("b"));if(i==="ne")return!tt(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,U=!0;let l=Te(n);if(t){t.worldMatrices=l;for(let u of t.meshes||[])u.nodeIndex>=0&&u.nodeIndex<l.length&&(u.transform.set(l[u.nodeIndex]),Se(u.normalMatrix,u.transform))}}if(B){B=!1,U=!0;let l=n?.nodes;if(Array.isArray(t?.meshes)&&Array.isArray(l))for(let u of t.meshes){let h=!0;for(let g=u.nodeIndex,c=0;g!==void 0&&g>=0&&c<128;g=M.get(g),c++){let a=l[g];if(a?.visible===!1||a?.extensions?.KHR_node_visibility?.visible===!1){h=!1;break}}u.visible=h}}U&&(U=!1,t?.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=(T,_=void 0)=>ie(a,T,_,new Set),D=(T="out")=>{let _=i.flows?.[T];_&&g(_)};switch(F){case"flow/branch":D(X(L("condition",!1))?"true":"false");break;case"flow/sequence":for(let T of Object.keys(i.flows||{}).sort((_,G)=>Number(_)-Number(G)||_.localeCompare(G)))D(T);break;case"flow/switch":{let T=i.flows?.[String(L("selection",L("value",0)))]??i.flows?.default;T&&g(T);break}case"flow/for":{let T=Math.trunc(A(L("startIndex",0))),_=Math.trunc(A(L("endIndex",0))),G=Math.max(1,Math.trunc(A(L("step",1),1))),j=i.flows?.body;if(j&&_>T&&E<Tt){let st=Math.min(Math.ceil((_-T)/G),fe);E++;try{for(let xe=0;xe<st&&u.steps<fe;xe++)V(a,"index",T+xe*G),ee(j,u)}finally{E--}}let ze=i.flows?.completed??i.flows?.out;ze&&g(ze);break}case"flow/doN":{let T=y==="reset"?0:(d.get(a)||0)+1;if(d.set(a,T),V(a,"currentCount",T),V(a,"count",T),y!=="reset"){let _=Math.trunc(A(L("n",O(i,"stopIterations")??O(i,"n")??1),1));T<=_&&D()}break}case"flow/multiGate":{if(y==="reset"){P.set(a,0);break}let T=Object.keys(i.flows||{}).sort();if(!T.length)break;let _=O(i,"isRandom")?Math.floor(Math.random()*T.length):P.get(a)||0;_<T.length&&(D(T[_]),P.set(a,O(i,"isLoop")!==!1?(_+1)%T.length:_+1));break}case"flow/waitAll":{if(y==="reset"){S.delete(a);break}let T=S.get(a);T||S.set(a,T=new Set),T.add(y),T.size>=Math.max(1,Math.trunc(Number(O(i,"inputFlows")??2)||2))&&(T.clear(),D("out"),D("completed"));break}case"flow/throttle":{if(y==="reset"){R.delete(a);break}let T=Math.max(0,A(L("duration",0))),_=R.get(a);_===void 0||N-_>=T?(R.set(a,N),V(a,"lastRemainingTime",0),D()):V(a,"lastRemainingTime",Math.max(0,T-(N-_)));break}case"flow/delay":case"flow/setDelay":{if(y==="cancel"){for(let j=b.length-1;j>=0;j--)b[j].nodeIdx===a&&b.splice(j,1);V(a,"lastDelayIndex",-1);break}let T=Math.max(0,A(L("duration",O(i,"duration")??0))),_=i.flows?.done??i.flows?.out;if(T<=0){V(a,"lastDelayIndex",-1),_&&g(_);break}b.length>=vt&&b.shift();let G=C++;V(a,"lastDelayIndex",G),b.push({id:G,nodeIdx:a,rem:T,done:_}),F==="flow/setDelay"&&i.flows?.out&&i.flows?.done&&D("out");break}case"flow/cancelDelay":{let T=Math.trunc(A(L("delayIndex",-1),-1));if(T<0)b.length=0;else for(let _=b.length-1;_>=0;_--)b[_].id===T&&b.splice(_,1);D();break}case"variable/set":Y(O(i,"variable")??O(i,"id"),L("value")),D();break;case"variable/interpolate":{let T=O(i,"variable")??O(i,"id"),_=L("value",L("target")),G=Math.max(0,A(L("duration",O(i,"duration")??.3),.3));T!==void 0&&_!==void 0&&Oe({key:`var:${String(T)}`,varKey:T,from:W(L("from")??f.get(T)??0),to:W(_),dur:G,elapsed:0,quat:!1,linear:O(i,"easing")==="linear",done:i.flows?.done}),D();break}case"pointer/set":{let T=ge(a,i),_=L("value");T&&_!==void 0&&(z(`ptr:${T}`),ae(T,_)),D();break}case"pointer/interpolate":{let T=ge(a,i),_=L("value",L("target")),G=Math.max(0,A(L("duration",O(i,"duration")??.3),.3));if(T&&_!==void 0){let j=L("from")??he(T);j!==void 0&&(G<=0?(ae(T,_),D("done")):Oe({key:`ptr:${T}`,ptr:T,from:W(j),to:W(_),dur:G,elapsed:0,quat:T.endsWith("/rotation"),linear:O(i,"easing")==="linear",done:i.flows?.done}))}D();break}case"animation/start":{let T=L("animation")??O(i,"animation")??O(i,"clipName"),_=typeof T=="number"?t?.animations?.[T]?.name??n?.animations?.[T]?.name:typeof T=="string"?T:void 0;t?.playAnimation?.(_),U=!0,D();break}case"animation/stop":case"animation/resetAt":t?.pauseAnimation?.(),F==="animation/resetAt"&&t?.evaluateAnimation?.(A(L("time",0))),U=!0,D();break;case"event/send":case"customEvent/send":{let T=q(O(i,"event")??O(i,"id")),_={};for(let G of Object.keys(i.values||{}))K.has(G)||(_[G]=L(G));T&&(typeof CustomEvent<"u"&&typeof t?.container?.dispatchEvent=="function"&&t.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:T,values:_}})),Ue(T,_,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:t?.meshes?.[u]?.nodeIndex??-1;o.forEach((g,c)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(H(g)))return;let a=O(g,"nodeIndex")??O(g,"node")??ie(c,"nodeIndex",void 0,new Set),i=O(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(V(c,"nodeIndex",h),V(c,"meshIndex",u),Array.isArray(l.hitPoint)){let F=[A(l.hitPoint[0]),A(l.hitPoint[1]),A(l.hitPoint[2])];V(c,"hitPoint",F),V(c,"point",F),V(c,"intersectionPoint",F)}if(Array.isArray(l.normal)){let F=[A(l.normal[0]),A(l.normal[1],1),A(l.normal[2])];V(c,"normal",F),V(c,"hitNormal",F)}typeof l.distance=="number"&&V(c,"distance",l.distance),ee(g.flows?.out)}}),se()},this.receiveCustomEvent=(l,u={})=>Ue(l,u,{steps:0});function Ue(l,u,h){if(!(I>=At)){I++;try{let g=q(l);o.forEach((c,a)=>{if(!/^(customE|e)vent\/receive$/.test(H(c)))return;let i=O(c,"event")??O(c,"id");if(!(q(i)!==g&&String(i)!==String(l))){for(let[y,F]of Object.entries(u))K.has(y)||V(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);N+=u,o.forEach((g,c)=>{H(g)==="event/onTick"&&(V(c,"timeDelta",u),V(c,"dt",u),V(c,"timeElapsed",N),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=et(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()}}},$=new WeakMap,pe=new WeakMap;function Rt(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||He().some(p=>p.name==="xr-live-head-follow"))return;let n=e.gltf,r=n?.nodes;if(!Array.isArray(r)||r.length===0)return;let o=Math.min(t,.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(N=>N?.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,M=R+Math.sin(P)*m.radius;if(f.translation=[v,b,M],m.faceCenter){let C=Math.atan2(d-v,R-M);f.rotation=[0,Math.sin(C*.5),0,Math.cos(C*.5)]}x=!0}if(x){pe.set(e,s);let p=Te(n);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 $.get(e)||$.get(e.viewer)||$.get(e._view)}function ke(e,t,n){let r=ye(e);return r?(r.receiveCustomEvent(t,n),!0):!1}var Fe={name:"khr-interactivity",sendInteractivityEvent:ke,getInteractivityVM:ye,onLoadModel(e,t){if(!e||typeof e!="object")return;$.get(e)?.dispose(),$.delete(e),pe.delete(e);let n=t?.extensions?.KHR_interactivity,r=Array.isArray(n?.graphs)?n.graphs[n.graph??0]:n;if(!r||!Array.isArray(r.nodes))return;let o=new re(e,t,r);$.set(e,o),o.fireOnStart()},onMeshSelect(e,t){$.get(e)?.fireOnSelect(t)},onUpdate(e,t){$.get(e)?.tick(t),Rt(e,t)},onDestroy(e,t){$.get(t)?.dispose(),$.delete(t),pe.delete(t)}};var oe=new Map,Le=new WeakMap;function rt(e,t){oe.set(e,t)}var Ce={name:"materials",onBuildPrimitiveVAO(e,t,n,r,o){return(((r?.materials&&n.material!==void 0?r.materials[n.material]:null)?.extensions||{}).KHR_materials_transmission?.transmissionFactor??0)>0?{isTransmissive:!0}:null},onBeforeTransmissivePass(e,t){let n=Le.get(e);n||(n=e.createTexture(),Le.set(e,n));let r=Math.max(1,t.canvas.width),o=Math.max(1,t.canvas.height);e.activeTexture(33990),e.bindTexture(3553,n),e.copyTexImage2D(3553,0,6408,0,0,r,o,0),e.texParameteri(3553,10242,33071),e.texParameteri(3553,10243,33071),e.texParameteri(3553,10241,9987),e.texParameteri(3553,10240,9729),e.generateMipmap(3553)},onResolveShader(e,t,n,r){if(!t)return null;if(t.name&&oe.has(t.name)){let v=oe.get(t.name);return{vs:v.vs||n,fs:v.fs||r}}let o=t.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:n,fs:r.replace("fragColor=vec4(color,outAlpha);","fragColor=vec4(base.rgb,outAlpha);").replace("fragColor=vec4(color,base.a);","fragColor=vec4(base.rgb,base.a);")};let d=r;if(p){let v=d.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
|
|
33
33
|
`;d=d.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
|
|
34
|
-
${v}out vec4 fragColor;`)}let S=(v,b,
|
|
35
|
-
vec2 sUV=gl_FragCoord.xy/max(uViewportSize,vec2(1.));float iorB=${S(P,1.5,1,10)},dV=${I},tV=${
|
|
34
|
+
${v}out vec4 fragColor;`)}let S=(v,b,M=0,C=1e6,N=3)=>{let I=Number(v);return(Number.isFinite(I)?Math.min(C,Math.max(M,I)):b).toFixed(N)},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||{},M=S(b.thicknessFactor,.5,0,1e4),C=S(b.attenuationDistance,1,.001,1e6),N=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=${M},lod=clamp(roughness*5.,0.,5.),sc=.06*(1.+tV);
|
|
36
36
|
vec3 refractedR=refract(-V,N,1./(iorB-.02*dV)),rG=refract(-V,N,1./iorB),refractedB=refract(-V,N,1./(iorB+.02*dV));
|
|
37
37
|
vec3 tr=vec3(textureLod(uTransmissionTex,clamp(sUV+refractedR.xy*sc,.001,.999),lod).r,textureLod(uTransmissionTex,clamp(sUV+rG.xy*sc,.001,.999),lod).g,textureLod(uTransmissionTex,clamp(sUV+refractedB.xy*sc,.001,.999),lod).b);
|
|
38
|
-
vec3 aCol=vec3(${S(
|
|
38
|
+
vec3 aCol=vec3(${S(N[0],1,0,1)},${S(N[1],1,0,1)},${S(N[2],1,0,1)});
|
|
39
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:
|
|
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.);}`,
|
|
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,
|
|
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:n,fs:d}},onBeforeDrawPrimitive(e,t,n,r,o,s){let x=n.materialIndex;if(x!==void 0&&s?.materials){let p=s.materials[x];p?.name&&oe.has(p.name)&&oe.get(p.name).onBindUniforms?.(e,t,n)}if(n.isTransmissive){let p=Le.get(e);if(p){e.activeTexture(33990),e.bindTexture(3553,p);let f=e.getUniformLocation(t,"uTransmissionTex");f&&e.uniform1i(f,6);let m=e.getUniformLocation(t,"uViewportSize");m&&e.uniform2f(m,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var Et=`#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.);}`,It=`#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,ot=new Float32Array(20);function Ne(e,t){let[n,r,o,s,x,p]=t;return[e[0]*n+e[4]*r+e[8]*o+e[12],e[1]*n+e[5]*r+e[9]*o+e[13],e[2]*n+e[6]*r+e[10]*o+e[14],Math.abs(e[0])*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 _t(e){if(e._lb!==void 0)return e._lb;let t=1e9,n=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]<t&&(t=f[m]),f[m+1]<n&&(n=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=t<=o?[(t+o)*.5,(n+s)*.5,(r+x)*.5,(o-t)*.5,(s-n)*.5,(x-r)*.5]:null}function Pt(e){let t=be.get(e);if(t)return t;let n=(p,f)=>{let m=e.createShader(p);return e.shaderSource(m,f),e.compileShader(m),m},r=e.createProgram();e.attachShader(r,n(35633,Et)),e.attachShader(r,n(35632,It)),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),t={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,t),t}var Ve={name:"contact-shadow",onAfterRender(e,t,n){let r=t.shadowIntensity;if(r<=0||!t.bounds)return;let o=Pt(e),s=!t.xrSessionActive&&(t.backdropMeshes?.length??0)>0,x=[],p=[];for(let b of t.meshes||[]){if(!b||b.visible===!1||b.isPluginMesh||b.name==="__xr_reticle__"||b.name?.startsWith("__xr_slot_"))continue;let M=_t(b);if(!M)continue;b.transform&&(M=Ne(b.transform,M)),t.modelRootMatrix&&(M=Ne(t.modelRootMatrix,M));let[C,N,I,w,E,k]=M,B=[C,I,w,k,N-E,N+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=t.bounds.center||[0,0,0],d=Math.max(.05,Number(t.bounds.radius)||.5),S=t.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];t.modelRootMatrix&&(R=Ne(t.modelRootMatrix,R));let v=t.xrSessionActive&&p.length===0&&String(t.container?.tagName||"").toLowerCase()==="xr-live"?(t.modelRootMatrix?t.modelRootMatrix[5]*-.25+t.modelRootMatrix[13]:-.25)+.002:R[1]-R[4]+.002;for(let[b,M,C,N,I]of x){let w=-1/0;for(let[k,B,U,H,,V]of p)I>=V-.08&&Math.abs(b-k)<=U&&Math.abs(M-B)<=H&&V+.002>w&&(w=V+.002);s&&(w=Math.max(w,b>=.04&&b<=.36&&M>=-.34&&M<=-.04&&I>=.01?.036:Math.hypot(b,M)<=.66&&I>=-.06?.003:-.477)),isFinite(w)||(w=v);let E=f.find(k=>Math.hypot(b-k[0],M-k[1])<.06&&Math.abs(w-k[5])<.05);E?(E[2]=Math.max(E[2],C*.78),E[3]=Math.max(E[3],N*.78),E[4]=Math.min(E[4],I)):f.push([b,M,C,N,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,n),e.enable(3042),(e.blendFuncSeparate||e.blendFunc).call(e,770,771,1,771),e.depthMask(!1),e.bindVertexArray(o.vao),e.bindBuffer(34962,o.vbo);for(let[b,M,C,N,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),U=Math.max(.045,C*1.45*B),H=Math.max(.045,N*1.45*B);ot.set([b-U,w,M-H,0,0,b+U,w,M-H,1,0,b+U,w,M+H,1,1,b-U,w,M+H,0,1]),e.bufferSubData(34962,0,ot),e.uniform1f(o.uIntensity,k),e.uniform1f(o.uSoftness,Math.min(1,t.shadowSoftness+Math.min(.45,E*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let t=be.get(e);t&&(e.deleteVertexArray(t.vao),e.deleteBuffer(t.vbo),e.deleteBuffer(t.ibo),e.deleteProgram(t.prog),be.delete(e))}};var at=new WeakMap,De={name:"webxr-suite",onConfigureXRSessionInit(e,t){let n=new Set(t.optionalFeatures||[]);n.add("hit-test"),n.add("light-estimation");let r=e?.querySelector?.('[slot="ar-overlay"]')||null;r&&(n.add("dom-overlay"),t.domOverlay={root:r},r.addEventListener?.("beforexrselect",o=>{o.preventDefault()})),t.optionalFeatures=Array.from(n)},onXRFrame(e,t,n,r){if(!e||!t||!n||!r)return;let o=at.get(t);if(o||(o={lightProbe:null},at.set(t,o),typeof t.requestLightProbe=="function"&&t.requestLightProbe().then(s=>{o&&s&&(o.lightProbe=s)}).catch(()=>{})),o.lightProbe&&typeof n.getLightEstimate=="function"){let s=n.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(Ve);Q(Ie);Q(Re);Q(Ce);Q(De);Q(Fe);
|
|
@@ -30,12 +30,12 @@ import type {
|
|
|
30
30
|
} from './three-live/src/three-view';
|
|
31
31
|
import type {ARLaunchResult, ARMode} from './three-live/src/three-xr';
|
|
32
32
|
import type {
|
|
33
|
+
Detection3D,
|
|
33
34
|
DimensionUnit,
|
|
34
35
|
ExplodeMode,
|
|
35
36
|
RemotePeerState,
|
|
36
37
|
SnapSurfaceMode,
|
|
37
38
|
TranscriptEvent,
|
|
38
|
-
Detection3D,
|
|
39
39
|
} from './xr-live/src/plugins/index';
|
|
40
40
|
import type {
|
|
41
41
|
XRAnchorElement,
|
|
@@ -193,7 +193,7 @@ export interface XRLiveAttributes extends ThreeLiveAttributes {
|
|
|
193
193
|
'xr-depth'?: XRDepthMode;
|
|
194
194
|
/** 25-joint hand tracking and gesture recognition mode ("gestures", "joints", "pinch", "none"). */
|
|
195
195
|
'xr-hands'?: XRHandsMode;
|
|
196
|
-
/** Desktop room
|
|
196
|
+
/** Desktop 3D room preview environment, unrelated to `xr-live-sim` ("living-room", "office", "tabletop", "none"). */
|
|
197
197
|
'xr-simulator'?: XRSimulatorRoom;
|
|
198
198
|
/** Spatial UI profile ("quest3", "android-xr", "visionos", "auto"). */
|
|
199
199
|
'xr-profile'?: XRProfile;
|
|
@@ -208,7 +208,14 @@ export interface XRLiveAttributes extends ThreeLiveAttributes {
|
|
|
208
208
|
/** Default display unit for `spatial-measure` ("auto", "m", "cm", "mm", "in", "ft-in"). */
|
|
209
209
|
'measure-unit'?: DimensionUnit;
|
|
210
210
|
/** Spatial plugin: socket, grid, surface, and angle snapping ("grid", "surface", "sockets", "all", "none"). */
|
|
211
|
-
'magnetic-snap'?:
|
|
211
|
+
'magnetic-snap'?:
|
|
212
|
+
| boolean
|
|
213
|
+
| 'grid'
|
|
214
|
+
| 'surface'
|
|
215
|
+
| 'sockets'
|
|
216
|
+
| 'all'
|
|
217
|
+
| 'none'
|
|
218
|
+
| string;
|
|
212
219
|
/** Cartesian snap grid step in meters ("0.05" or "0.05 0.05 0.05"). */
|
|
213
220
|
'snap-grid'?: number | string;
|
|
214
221
|
/** Rotational yaw snap increment in degrees (0 to 180). */
|
|
@@ -241,6 +248,45 @@ export interface XRLiveAttributes extends ThreeLiveAttributes {
|
|
|
241
248
|
'peer-name'?: string;
|
|
242
249
|
/** Local avatar visor & laser color (`#rrggbb`) in `shared-room`. */
|
|
243
250
|
'peer-color'?: string;
|
|
251
|
+
/** xr-live-sim: character camera mode, or `none` to disable the character. */
|
|
252
|
+
'character-controller'?:
|
|
253
|
+
| 'third-person'
|
|
254
|
+
| 'first-person'
|
|
255
|
+
| 'top-down'
|
|
256
|
+
| 'fixed-camera'
|
|
257
|
+
| 'none';
|
|
258
|
+
/** xr-live-sim: character speed override (m/s). */
|
|
259
|
+
'character-speed'?: number | string;
|
|
260
|
+
/** xr-live-sim: character jump velocity override (m/s). */
|
|
261
|
+
'character-jump'?: number | string;
|
|
262
|
+
/** xr-live-sim: on-screen joystick (`auto` shows it on touch screens). */
|
|
263
|
+
'touch-joystick'?: 'auto' | 'always' | 'none';
|
|
264
|
+
/** xr-live-sim: `false` or `none` pauses steering agents. */
|
|
265
|
+
'steering-agents'?: boolean | string;
|
|
266
|
+
/** xr-live-sim: firing mode (empty means `projectile`). */
|
|
267
|
+
'hit-zones'?: '' | 'projectile' | 'hitscan' | 'contact' | 'off';
|
|
268
|
+
/** xr-live-sim: shots per second (default: 4). */
|
|
269
|
+
'fire-rate'?: number | string;
|
|
270
|
+
/** xr-live-sim: projectile speed in m/s (default: 14). */
|
|
271
|
+
'projectile-speed'?: number | string;
|
|
272
|
+
/** xr-live-sim: projectile gravity in m/s² (default: 0). */
|
|
273
|
+
'projectile-gravity'?: number | string;
|
|
274
|
+
/** xr-live-sim: integrity removed per hit (default: 25). */
|
|
275
|
+
'hit-amount'?: number | string;
|
|
276
|
+
/** xr-live-sim: enables objectives and scoring (`none` disables). */
|
|
277
|
+
'objectives'?: boolean | string;
|
|
278
|
+
/** xr-live-sim: scenario countdown in seconds. */
|
|
279
|
+
'scenario-timer'?: number | string;
|
|
280
|
+
/** xr-live-sim: score that passes the scenario. */
|
|
281
|
+
'target-score'?: number | string;
|
|
282
|
+
/** xr-live-sim: attempts before the scenario fails. */
|
|
283
|
+
'attempts'?: number | string;
|
|
284
|
+
/** xr-live-sim: score HUD style. */
|
|
285
|
+
'sim-hud'?: 'auto' | 'minimal' | 'none';
|
|
286
|
+
/** xr-live-sim: plays procedural audio cues (`muted` disables). */
|
|
287
|
+
'synth-audio'?: boolean | string;
|
|
288
|
+
/** xr-live-sim: cue volume from 0 to 1 (default: 0.7). */
|
|
289
|
+
'synth-volume'?: number | string;
|
|
244
290
|
/** Register WebMCP browser AI tools on `navigator.modelContext`. */
|
|
245
291
|
'webmcp'?: boolean | string;
|
|
246
292
|
/** Opt-in gate allowing WebMCP `capture_xr_view` to include the 8x8 depth grid. */
|
|
@@ -314,7 +360,74 @@ export interface XRLiveAttributes extends ThreeLiveAttributes {
|
|
|
314
360
|
e: CustomEvent<Pick<RemotePeerState, 'peerId' | 'name' | 'color'>>,
|
|
315
361
|
) => void;
|
|
316
362
|
onpeersync?: (e: CustomEvent<{peerId: string; nodeId: string}>) => void;
|
|
317
|
-
onpeergrabconflict?: (
|
|
363
|
+
onpeergrabconflict?: (
|
|
364
|
+
e: CustomEvent<{peerId: string; nodeId: string}>,
|
|
365
|
+
) => void;
|
|
366
|
+
/** xr-live-sim events. */
|
|
367
|
+
oncharacterjump?: (
|
|
368
|
+
e: CustomEvent<{nodeId: string; position: [number, number, number]}>,
|
|
369
|
+
) => void;
|
|
370
|
+
oncharacterland?: (
|
|
371
|
+
e: CustomEvent<{nodeId: string; fallSpeed: number}>,
|
|
372
|
+
) => void;
|
|
373
|
+
onagentstatechange?: (
|
|
374
|
+
e: CustomEvent<{nodeId: string; state: string; targetId: string | null}>,
|
|
375
|
+
) => void;
|
|
376
|
+
onagentreach?: (
|
|
377
|
+
e: CustomEvent<{
|
|
378
|
+
agentId: string;
|
|
379
|
+
targetId: string;
|
|
380
|
+
position: [number, number, number];
|
|
381
|
+
}>,
|
|
382
|
+
) => void;
|
|
383
|
+
onxrhit?: (
|
|
384
|
+
e: CustomEvent<{
|
|
385
|
+
targetId: string;
|
|
386
|
+
/** Shooter node name, or `'user'`. */
|
|
387
|
+
sourceId: string;
|
|
388
|
+
amount: number;
|
|
389
|
+
remaining: number;
|
|
390
|
+
point: [number, number, number];
|
|
391
|
+
}>,
|
|
392
|
+
) => void;
|
|
393
|
+
onxrdepleted?: (
|
|
394
|
+
e: CustomEvent<{targetId: string; group: string; scoreValue: number}>,
|
|
395
|
+
) => void;
|
|
396
|
+
onxrzoneenter?: (
|
|
397
|
+
e: CustomEvent<{zoneId: string; nodeId: string; group: string}>,
|
|
398
|
+
) => void;
|
|
399
|
+
onxrzoneexit?: (
|
|
400
|
+
e: CustomEvent<{zoneId: string; nodeId: string; group: string}>,
|
|
401
|
+
) => void;
|
|
402
|
+
onxrspawn?: (
|
|
403
|
+
e: CustomEvent<{spawnerId: string; instanceId: string; index: number}>,
|
|
404
|
+
) => void;
|
|
405
|
+
onxrobjective?: (
|
|
406
|
+
e: CustomEvent<{
|
|
407
|
+
nodeId: string;
|
|
408
|
+
tag: string;
|
|
409
|
+
type: string;
|
|
410
|
+
amount: number;
|
|
411
|
+
totalScore: number;
|
|
412
|
+
remainingRequired: number;
|
|
413
|
+
outOfOrder: boolean;
|
|
414
|
+
}>,
|
|
415
|
+
) => void;
|
|
416
|
+
onxrscorechange?: (
|
|
417
|
+
e: CustomEvent<{
|
|
418
|
+
score: number;
|
|
419
|
+
delta: number;
|
|
420
|
+
attemptsLeft: number | null;
|
|
421
|
+
timeRemaining: number | null;
|
|
422
|
+
}>,
|
|
423
|
+
) => void;
|
|
424
|
+
onxrscenarioend?: (
|
|
425
|
+
e: CustomEvent<{
|
|
426
|
+
outcome: 'pass' | 'fail' | 'timeout';
|
|
427
|
+
finalScore: number;
|
|
428
|
+
elapsedSec: number;
|
|
429
|
+
}>,
|
|
430
|
+
) => void;
|
|
318
431
|
}
|
|
319
432
|
|
|
320
433
|
declare global {
|