three-live 0.0.1-alpha.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +58 -0
  3. package/dist/index.d.ts +224 -0
  4. package/dist/three-author-engine.js +297 -0
  5. package/dist/three-author.cjs +297 -0
  6. package/dist/three-author.d.ts +224 -0
  7. package/dist/three-author.js +297 -0
  8. package/dist/three-convert.cjs +291 -0
  9. package/dist/three-convert.d.ts +224 -0
  10. package/dist/three-convert.js +291 -0
  11. package/dist/three-live-animation.cjs +36 -0
  12. package/dist/three-live-animation.d.ts +224 -0
  13. package/dist/three-live-animation.js +36 -0
  14. package/dist/three-live-animation.min.js +36 -0
  15. package/dist/three-live-element.cjs +222 -0
  16. package/dist/three-live-element.d.ts +224 -0
  17. package/dist/three-live-element.js +222 -0
  18. package/dist/three-live-extras.cjs +42 -0
  19. package/dist/three-live-extras.d.ts +224 -0
  20. package/dist/three-live-extras.js +42 -0
  21. package/dist/three-live-extras.min.js +42 -0
  22. package/dist/three-live-full.cjs +341 -0
  23. package/dist/three-live-full.js +341 -0
  24. package/dist/three-live-full.min.js +341 -0
  25. package/dist/three-live-sandbox.html +157 -0
  26. package/dist/three-live-viewer.cjs +222 -0
  27. package/dist/three-live-viewer.d.ts +224 -0
  28. package/dist/three-live-viewer.js +222 -0
  29. package/dist/three-live-viewer.min.js +222 -0
  30. package/dist/three-live.cjs +299 -0
  31. package/dist/three-live.js +299 -0
  32. package/dist/three-live.min.js +299 -0
  33. package/dist/three-view.cjs +222 -0
  34. package/dist/three-view.d.ts +224 -0
  35. package/dist/three-view.js +222 -0
  36. package/dist/three-xr.cjs +291 -0
  37. package/dist/three-xr.d.ts +224 -0
  38. package/dist/three-xr.js +291 -0
  39. package/package.json +78 -6
  40. package/index.js +0 -1
@@ -0,0 +1,224 @@
1
+ // Copyright 2026 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ /**
16
+ * @fileoverview Ambient and module declarations for three-live and xr-live.
17
+ * Enables zero-config, type-safe usage of <three-live> and <xr-live> in React 19,
18
+ * Next.js, Vue, Svelte, and modern TSX/JSX environments.
19
+ */
20
+
21
+ import type {
22
+ CameraState,
23
+ ThreeLiveElement,
24
+ } from './three-live/src/three-live-element';
25
+ import type {
26
+ CameraDetail,
27
+ GLBData,
28
+ HitDetail,
29
+ ThreeView,
30
+ } from './three-live/src/three-view';
31
+ import type {ARLaunchResult, ARMode} from './three-live/src/three-xr';
32
+ import type {TranscriptEvent} from './xr-live/src/plugins/gemini-live';
33
+ import type {Detection3D} from './xr-live/src/plugins/world-understanding';
34
+ import type {
35
+ XRAnchorElement,
36
+ XRDepthMode,
37
+ XRHandsMode,
38
+ XRLiveElement,
39
+ XRMode,
40
+ XRProfile,
41
+ XRSimulatorRoom,
42
+ } from './xr-live/src/xr-live-element';
43
+
44
+ export * from './three-live/src/core';
45
+ export {
46
+ getInteractivityVM,
47
+ interactivityPlugin,
48
+ InteractivityVM,
49
+ parseSafeGltfPointer,
50
+ sendInteractivityEvent,
51
+ type InteractivityDeclaration,
52
+ type InteractivityEventDef,
53
+ type InteractivityFlowTarget,
54
+ type InteractivityGraph,
55
+ type InteractivityNode,
56
+ type InteractivityValue,
57
+ type InteractivityValueSocket,
58
+ type InteractivityVariableDef,
59
+ } from './three-live/src/plugins/interactivity';
60
+ export {
61
+ ThreeLiveElement,
62
+ type ARLaunchOptions,
63
+ type ARLaunchResult,
64
+ type ARMode,
65
+ type ARProvider,
66
+ type CameraState,
67
+ } from './three-live/src/three-live-element';
68
+ export {
69
+ XRAnchorElement,
70
+ XRLiveElement,
71
+ type XRDepthMode,
72
+ type XRHandsMode,
73
+ type XRMode,
74
+ type XRProfile,
75
+ type XRSimulatorRoom,
76
+ } from './xr-live/src/xr-live-element';
77
+ /** Optional spatial plugins (`xr-live/plugins`, `xr-live-plugins.min.js`). */
78
+ export * from './xr-live/src/plugins/index';
79
+
80
+ /**
81
+ * Declarative JSX / HTML attributes supported by the <three-live> custom element.
82
+ */
83
+ export interface ThreeLiveAttributes {
84
+ /** URL to glTF 2.0 binary (.glb) model. */
85
+ 'src'?: string;
86
+ /** URL to Apple Universal Scene Description (.usdz) model for iOS Quick Look. */
87
+ 'ios-src'?: string;
88
+ /** URL or inline script for procedural Three.js scene generation. */
89
+ 'script-src'?: string;
90
+ /** Responsive image preview shown before 3D model finishes hydration. */
91
+ 'poster'?: string;
92
+ /** Uniform or per-axis scale multiplier ("x y z"). */
93
+ 'scale'?: string;
94
+ /** Initial camera orbit angles and distance: "theta phi [radius]" (e.g. "0deg 75deg 3m") or JSON string. */
95
+ 'camera-orbit'?: string | CameraState;
96
+ /** Orbit center coordinate "x y z". */
97
+ 'camera-target'?: string;
98
+ /** Lower bounds for camera orbit ("theta phi radius"). */
99
+ 'min-camera-orbit'?: string;
100
+ /** Upper bounds for camera orbit ("theta phi radius"). */
101
+ 'max-camera-orbit'?: string;
102
+ /** Vertical field of view angle (e.g. "45deg"). */
103
+ 'field-of-view'?: string;
104
+ /** Sub-mesh name to highlight with interactive selection color. */
105
+ 'selected-mesh'?: string;
106
+ /** Exposure / lighting multiplier for studio IBL lighting (default: 1.0). */
107
+ 'exposure'?: number | string;
108
+ /** Equirectangular HDR/LDR environment map URL. */
109
+ 'environment-image'?: string;
110
+ /** Visible background equirectangular skybox image URL. */
111
+ 'skybox-image'?: string;
112
+ /** Ground contact shadow opacity (0.0 to 1.0). */
113
+ 'shadow-intensity'?: number | string;
114
+ /** Radial Gaussian blur falloff of contact shadow (0.0 to 1.0). */
115
+ 'shadow-softness'?: number | string;
116
+ /** Tone mapping mode ("neutral", "reinhard", "none"). */
117
+ 'tone-mapping'?: string;
118
+ /** Enable or disable interactive camera orbit/pan/zoom controls (default: true). */
119
+ 'camera-controls'?: boolean | string;
120
+ /** Automatically start keyframe animation playback. */
121
+ 'autoplay'?: boolean | string;
122
+ /** Name of specific glTF animation clip to play. */
123
+ 'animation-name'?: string;
124
+ /** Automatically rotate scene around the Y-axis when user is idle. */
125
+ 'auto-rotate'?: boolean | string;
126
+ /** Delay in milliseconds before auto-rotation resumes after user interaction (default: 3000). */
127
+ 'auto-rotate-delay'?: number | string;
128
+ /** Rate of turntable auto-rotation (e.g. "30deg", "0.5rad", "100%", default: "30deg"). */
129
+ 'rotation-per-second'?: string;
130
+ /** Enable one-tap Augmented Reality button overlay. */
131
+ 'ar'?: boolean | string;
132
+ /** Ordered list of AR launch targets ('webxr', 'quick-look', 'scene-viewer'). */
133
+ 'ar-modes'?: string;
134
+ /** Controls whether the model can be scaled in AR ("auto" or "fixed"). */
135
+ 'ar-scale'?: 'auto' | 'fixed';
136
+ /** Controls whether the model is placed on horizontal surfaces ("floor") or vertical surfaces ("wall"). */
137
+ 'ar-placement'?: 'floor' | 'wall';
138
+ /**
139
+ * Mandatory isolation level for procedural scripts. Defaults to `'worker'`,
140
+ * which runs the script in a dedicated Web Worker with network, storage and
141
+ * thread-spawning capabilities revoked across the prototype chain. `'iframe'`
142
+ * runs the Worker inside an opaque-origin `<iframe sandbox="allow-scripts">`
143
+ * (`three-live-sandbox.html`) with a strict `connect-src 'none'` Content
144
+ * Security Policy.
145
+ */
146
+ sandbox?: 'worker' | 'iframe';
147
+ /**
148
+ * Opt-in attribute allowing client-modified Three.js script strings
149
+ * (`executeScript(code)` and inline `<script type="text/three-live">`).
150
+ * Server-generated scripts (`script-src`) are enabled by default.
151
+ */
152
+ 'allow-client-scripts'?: boolean | string;
153
+
154
+ // React 19 / JSX Event Listeners
155
+ onload?: (e: CustomEvent<{model: GLBData}>) => void;
156
+ onerror?: (e: CustomEvent<{error: any}>) => void;
157
+ onmeshclick?: (e: CustomEvent<HitDetail>) => void;
158
+ 'oncamera-change'?: (e: CustomEvent<CameraDetail>) => void;
159
+ 'onar-status'?: (
160
+ e: CustomEvent<{
161
+ status: 'session-started' | 'not-presenting' | 'failed';
162
+ error?: any;
163
+ }>,
164
+ ) => void;
165
+
166
+ // Standard HTML / JSX attributes
167
+ id?: string;
168
+ className?: string;
169
+ class?: string;
170
+ style?: any;
171
+ ref?: any;
172
+ key?: any;
173
+ slot?: string;
174
+ tabIndex?: number;
175
+ role?: string;
176
+ 'aria-label'?: string;
177
+ children?: any;
178
+ }
179
+
180
+ /**
181
+ * Declarative JSX / HTML attributes supported by the <xr-live> spatial computing element.
182
+ */
183
+ export interface XRLiveAttributes extends ThreeLiveAttributes {
184
+ /** WebXR session target mode ("ar", "vr", "inline", or "auto"). */
185
+ 'xr-mode'?: XRMode;
186
+ /** Real-world hardware depth occlusion or physics mode ("occlusion", "occlusion-physics", "mesh", "none"). */
187
+ 'xr-depth'?: XRDepthMode;
188
+ /** 25-joint hand tracking and gesture recognition mode ("gestures", "joints", "pinch", "none"). */
189
+ 'xr-hands'?: XRHandsMode;
190
+ /** Desktop room simulator environment ("living-room", "office", "tabletop", "none"). */
191
+ 'xr-simulator'?: XRSimulatorRoom;
192
+ /** Spatial UI profile ("quest3", "android-xr", "visionos", "auto"). */
193
+ 'xr-profile'?: XRProfile;
194
+ /** Spatial plugin: enables plane/mesh detection; include "reticle" for a gaze reticle. */
195
+ 'world-understanding'?: boolean | string;
196
+ /** Spatial plugin: pinch in empty space to paint 3D tubes (optional `#rrggbb` color). */
197
+ 'spatial-paint'?: boolean | string;
198
+ 'onxr-object-detected'?: (e: CustomEvent<Detection3D>) => void;
199
+ 'onxr-transcription'?: (e: CustomEvent<TranscriptEvent>) => void;
200
+ 'onxr-hold-to-ask'?: (
201
+ e: CustomEvent<{mesh: string; transcript: string; prompt: string}>,
202
+ ) => void;
203
+ 'onxr-handles-change'?: (
204
+ e: CustomEvent<{mesh: string; scale: number; yawDeg: number}>,
205
+ ) => void;
206
+ 'onxr-paint-stroke'?: (
207
+ e: CustomEvent<{index: number; points: number; lengthMeters: number}>,
208
+ ) => void;
209
+ }
210
+
211
+ declare global {
212
+ namespace JSX {
213
+ interface IntrinsicElements {
214
+ 'three-live': ThreeLiveAttributes;
215
+ 'xr-live': XRLiveAttributes;
216
+ }
217
+ }
218
+
219
+ interface HTMLElementTagNameMap {
220
+ 'three-live': ThreeLiveElement;
221
+ 'xr-live': XRLiveElement;
222
+ 'xr-anchor': XRAnchorElement;
223
+ }
224
+ }
@@ -0,0 +1,42 @@
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 t={plugins:[],decoders:new Map};try{Object.defineProperty(e,ie,{value:t,writable:!1,configurable:!1,enumerable:!1})}catch{e[ie]=t}}return e[ie]}var Rt=ge().plugins;function Q(e){let t=ge().plugins;t.some(n=>n.name===e.name)||t.push(e)}function Ce(){return ge().plugins}function Ve(){let e=new Float32Array(16);return e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function at(e,t,n){let r=t[0],o=t[1],s=t[2],x=t[3],p=t[4],f=t[5],d=t[6],m=t[7],M=t[8],S=t[9],F=t[10],v=t[11],y=t[12],R=t[13],V=t[14],N=t[15],E=n[0],w=n[1],I=n[2],P=n[3];return e[0]=E*r+w*p+I*M+P*y,e[1]=E*o+w*f+I*S+P*R,e[2]=E*s+w*d+I*F+P*V,e[3]=E*x+w*m+I*v+P*N,E=n[4],w=n[5],I=n[6],P=n[7],e[4]=E*r+w*p+I*M+P*y,e[5]=E*o+w*f+I*S+P*R,e[6]=E*s+w*d+I*F+P*V,e[7]=E*x+w*m+I*v+P*N,E=n[8],w=n[9],I=n[10],P=n[11],e[8]=E*r+w*p+I*M+P*y,e[9]=E*o+w*f+I*S+P*R,e[10]=E*s+w*d+I*F+P*V,e[11]=E*x+w*m+I*v+P*N,E=n[12],w=n[13],I=n[14],P=n[15],e[12]=E*r+w*p+I*M+P*y,e[13]=E*o+w*f+I*S+P*R,e[14]=E*s+w*d+I*F+P*V,e[15]=E*x+w*m+I*v+P*N,e}function it(e,t,n,r){let o=t[0],s=t[1],x=t[2],p=t[3],f=o+o,d=s+s,m=x+x,M=o*f,S=o*d,F=o*m,v=s*d,y=s*m,R=x*m,V=p*f,N=p*d,E=p*m,w=r[0],I=r[1],P=r[2];return e[0]=(1-(v+R))*w,e[1]=(S+E)*w,e[2]=(F-N)*w,e[3]=0,e[4]=(S-E)*I,e[5]=(1-(M+R))*I,e[6]=(y+V)*I,e[7]=0,e[8]=(F+N)*P,e[9]=(y-V)*P,e[10]=(1-(M+v))*P,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function xe(e,t){let n=t[0],r=t[1],o=t[2],s=t[4],x=t[5],p=t[6],f=t[8],d=t[9],m=t[10],M=m*x-p*d,S=-m*s+p*f,F=d*s-x*f,v=n*M+r*S+o*F;return v&&(v=1/v,e[0]=M*v,e[1]=(-m*r+o*d)*v,e[2]=(p*r-o*x)*v,e[3]=S*v,e[4]=(m*n-o*f)*v,e[5]=(-p*n+o*s)*v,e[6]=F*v,e[7]=(-d*n+r*f)*v,e[8]=(x*n-r*s)*v),e}function Ne(e,t){let n=t[0],r=t[1],o=t[2],s=t[3],x=t[4],p=t[5],f=t[6],d=t[7],m=t[8],M=t[9],S=t[10],F=t[11],v=t[12],y=t[13],R=t[14],V=t[15],N=n*p-r*x,E=n*f-o*x,w=n*d-s*x,I=r*f-o*p,P=r*d-s*p,O=o*d-s*f,H=m*y-M*v,B=m*R-S*v,k=m*V-F*v,Y=M*R-S*y,q=M*V-F*y,Z=S*V-F*R,z=N*Z-E*q+w*Y+I*k-P*B+O*H;return z?(z=1/z,e[0]=(p*Z-f*q+d*Y)*z,e[1]=(o*q-r*Z-s*Y)*z,e[2]=(y*O-R*P+V*I)*z,e[3]=(S*P-M*O-F*I)*z,e[4]=(f*k-x*Z-d*B)*z,e[5]=(n*Z-o*k+s*B)*z,e[6]=(R*w-v*O-V*E)*z,e[7]=(m*O-S*w+F*E)*z,e[8]=(x*q-p*k+d*H)*z,e[9]=(r*k-n*q-s*H)*z,e[10]=(v*P-y*w+V*N)*z,e[11]=(M*w-m*P-F*N)*z,e[12]=(p*B-x*Y-f*H)*z,e[13]=(n*Y-r*B+o*H)*z,e[14]=(y*E-v*I-R*N)*z,e[15]=(m*I-M*E+S*N)*z,e):null}function ve(e,t){let n=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let m=0;m<n;m++)r.push(Ve());if(n===0)return r;let o=new Set;for(let m of e.nodes)if(Array.isArray(m.children))for(let M of m.children)o.add(M);let s=new Set,x=128,p=(m,M,S=0)=>{if(S>x||m<0||m>=n||s.has(m))return;s.add(m);let F=e.nodes[m];if(!F)return;let v=Ve();if(t&&t[m])v.set(t[m]);else if(F.matrix&&F.matrix.length===16)v.set(F.matrix);else{let R=F.translation||[0,0,0],V=F.rotation||[0,0,0,1],N=F.scale||[1,1,1];it(v,V,R,N)}let y=r[m];if(M?at(y,M,v):y.set(v),Array.isArray(F.children))for(let R of F.children)typeof R=="number"&&p(R,y,S+1)},f=[],d=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(d&&Array.isArray(d.nodes))f.push(...d.nodes);else for(let m=0;m<n;m++)o.has(m)||f.push(m);for(let m of f)p(m,null);for(let m=0;m<n;m++)!o.has(m)&&!f.includes(m)&&p(m,null);return r}var Ae=new WeakMap;function Me(e,t){let n=t instanceof Float32Array?t:new Float32Array(t);Ae.set(e,n)}function st(e){return Ae.get(e)}async function ct(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 ke=new WeakMap,De=new Float32Array(16);async function Ue(e,t,n){let r=n?await ct(e.gl,n):null;e[t]&&e.gl.deleteTexture(e[t]),e[t]=r}var He={name:"environment-map",setEnvironmentImage(e,t){return Ue(e,"environmentTexture",t)},setSkyboxImage(e,t){return Ue(e,"skyboxTexture",t)},onBeforeDrawScene(e,t,n,r,o){if(!e.skyboxTexture||typeof t.createProgram!="function")return;let s=ke.get(t);if(!s){let M=(v,y)=>{let R=t.createShader(v);return t.shaderSource(R,y),t.compileShader(R),R},S=t.createProgram();t.attachShader(S,M(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(S,M(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(S);let F=typeof t.createVertexArray=="function"?t.createVertexArray():null;s={program:S,vao:F},ke.set(t,s)}let x=Ne(De,n)||De;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 d=t.getUniformLocation(s.program,"uCameraPos");d&&t.uniform3f(d,r[0],r[1],r[2]);let m=t.getUniformLocation(s.program,"uExposure");m&&t.uniform1f(m,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
+ 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:n,fs:o}},onBeforeDrawPrimitive(e,t,n,r,o,s){let x=Ae.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 Te=new WeakMap;function Re(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(M=>parseFloat(M.replace(/m$/,"")));if(p.length<3||p.some(isNaN))continue;let f=s.getAttribute("data-normal"),d;if(f){let M=f.trim().split(/\s+/).map(S=>parseFloat(S));M.length>=3&&!M.some(isNaN)&&(d=[M[0],M[1],M[2]])}let m=n.projectPointToScreen([p[0],p[1],p[2]],d);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transform=`translate(-50%, -50%) translate3d(${m.x}px, ${m.y}px, 0)`,s.style.zIndex="3",m.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 ze={name:"hotspots",updateHotspotsForElement:Re,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let t=new MutationObserver(()=>{Re(e)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),Te.set(e,t)},onCameraChange(e,t){t&&Re(t,e)},onElementDisconnected(e){let t=Te.get(e);t&&(t.disconnect(),Te.delete(e))}};function se(e,t,n,r){let o=typeof e=="number"&&Number.isFinite(e)?e:r;return Math.max(t,Math.min(n,o))}function lt(e){return Array.isArray(e)&&e.length>=3&&Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])}function ut(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Be(e){let t=ut(e);if(!t)return null;let n=t.target;return{target:lt(n)?[n[0],n[1],n[2]]:typeof n=="string"&&n.length>0&&n.length<=256?n:[0,0,0],radius:se(t.radius,.01,50,.5),speed:se(t.speed,-20,20,.5),height:se(t.height,-10,10,0),phase:se(t.phase,-1e6,1e6,0),faceCenter:t.faceCenter===!0}}function Oe(e,t,n,r){let o=t[0],s=t[1],x=t[2],p=t[3],f=n[0],d=n[1],m=n[2],M=n[3],S=o*f+s*d+x*m+p*M;if(S<0&&(f=-f,d=-d,m=-m,M=-M,S=-S),Math.abs(S)>=1)return e[0]=o,e[1]=s,e[2]=x,e[3]=p,e;let F=Math.acos(S),v=Math.sqrt(1-S*S);if(Math.abs(v)<.001)return e[0]=.5*(o+f),e[1]=.5*(s+d),e[2]=.5*(x+m),e[3]=.5*(p+M),e;let y=Math.sin((1-r)*F)/v,R=Math.sin(r*F)/v;return e[0]=o*y+f*R,e[1]=s*y+d*R,e[2]=x*y+m*R,e[3]=p*y+M*R,e}var We=1024,Se=256,ce=2048,ft=128,mt=64,dt=16,pt=1e4,bt=8,K=new Set(["__proto__","constructor","prototype"]),Ge={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,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},le={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},fe=(e,t)=>e!==null&&typeof e=="object"&&!K.has(t)&&Object.prototype.hasOwnProperty.call(e,t),G=e=>Array.isArray(e)?[...e]:e,Ke=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&fe(e,"value")?e.value:e,U=(e,t)=>fe(e.configuration,t)?Ke(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 ue(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},$e=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]},je=(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 Oe(o,$e(e),$e(t),n),o}return e.slice(0,t.length).map((o,s)=>o+(t[s]-o)*n)}return n>=.5?t:e},we=(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)),yt=(e,t)=>Array.isArray(e)?e.map(n=>t(A(n))):t(A(e)),qe=(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,me=class{constructor(t,n,r){let o=Array.isArray(r.nodes)?r.nodes:[];if(o.length>We)throw new Error(`SecurityError: Exceeds MAX_GRAPH_NODES (${We})`);let s=Array.isArray(r.variables)?r.variables:[];if(s.length>Se)throw new Error(`SecurityError: Exceeds MAX_VARIABLES (${Se})`);let x=Array.isArray(r.declarations)?r.declarations:[],p=Array.isArray(r.events)?r.events:[],f=new Map,d=new Map,m=new Map,M=new Map,S=new Map,F=new Map,v=[],y=[],R=new Map,V=1,N=0,E=0,w=0,I=0,P=!1,O=!1,H=!1;s.forEach((l,u)=>{if(!l||typeof l!="object")return;let h=G(Ke(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"&&R.set(h,u)});let B=l=>l.op||typeof l.declaration=="number"&&x[l.declaration]?.op||"",k=(l,u,h)=>{if(K.has(u))return;let g=d.get(l);g||d.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>=Se*2)return;let h=G(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=R.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)},Fe=l=>{z(l.key),v.length>=ft&&v.shift(),v.push(l)},be=l=>{let u=ue(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 le){let c=le[g],a=h[g]||c;return c.map((i,b)=>A(a[b],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)}}},re=(l,u)=>{let h=ue(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 le&&Array.isArray(u)){let i=le[a];if(u.length<i.length)return!1;let b=i.map((C,D)=>A(u[D],C));if(a==="rotation"){let C=Math.hypot(...b);b=C>1e-8?b.map(D=>D/C):[0,0,0,1]}c[a]=b,delete c.matrix;let L=t?.initialNodeTransforms?.[g];return L&&(L[a[0]]=[...b]),P=!0,!0}if(a==="weights"){Array.isArray(c.weights)||(c.weights=[]);let i=(b,L)=>{for(let C of t?.meshes||[])if(C.nodeIndex===g)for(let D of C.primitives||[])D.pluginData?.morph?.weights&&(D.pluginData.morph.weights[b]=L)};if(h.length===4){let b=te(h[3],64);if(b<0)return!1;i(b,c.weights[b]=A(u))}else if(Array.isArray(u))c.weights=u.slice(0,64).map(b=>A(b)),c.weights.forEach((b,L)=>i(L,b));else return!1;return H=!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},O=!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=b=>{for(let L of t?.meshes||[])for(let C of L.primitives||[])(C.materialIndex??0)===g&&b(C)};if(h[2]==="pbrMetallicRoughness"){if(h[3]==="baseColorFactor"&&Array.isArray(u)&&u.length>=3){let b=[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=b,i(L=>L.baseColor=[...b]),H=!0}if(h[3]==="metallicFactor"||h[3]==="roughnessFactor"){let b=h[3]==="metallicFactor",L=J(A(u,b?0:.5));return a[h[3]]=L,i(C=>C[b?"metallic":"roughness"]=L),H=!0}}if(h[2]==="emissiveFactor"&&Array.isArray(u)&&u.length>=3)return c.emissiveFactor=[0,1,2].map(b=>Math.max(0,A(u[b]))),H=!0;if(h[2]==="alphaCutoff")return c.alphaCutoff=J(A(u,.5)),H=!0}return!1},ye=(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 b=Math.trunc(Number(oe(l,i,void 0,h)??U(u,i)));return Number.isSafeInteger(b)&&b>=0?String(b):"-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 G(a);let i=a;return typeof i.node=="number"?rt(i.node,i.socket||"value",g):fe(i,"value")?G(i.value):h},rt=(l,u,h)=>{if(l<0||l>=o.length||h.has(l)||h.size>128||++w>pt)return;let g=o[l],c=B(g);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(c))return G(d.get(l)?.[u]);h.add(l);try{let a=(i,b=0)=>oe(l,i,b,h);if(c==="variable/get"){let i=U(g,"variable")??U(g,"id");return typeof i=="number"||typeof i=="string"?G(f.get(i)):void 0}if(c==="pointer/get"){let i=ye(l,g,h);return i?be(i):void 0}if(c.startsWith("math/")){let i=c.slice(5);if(i in Ge)return yt(a("a"),Ge[i]);if(i in Xe){let b=/^(mul|div|rem|mod|pow)$/.test(i)?1:0;return we(a("a",i==="mul"?1:0),a("b",b),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 b=a("a"),L=a("b");return Array.isArray(b)&&Array.isArray(L)?b.reduce((C,D,T)=>C+(D||0)*(L[T]||0),0):A(b)*A(L)}if(i==="cross"){let b=a("a",[0,0,0]),L=a("b",[0,0,0]);return Array.isArray(b)&&Array.isArray(L)?[(b[1]||0)*(L[2]||0)-(b[2]||0)*(L[1]||0),(b[2]||0)*(L[0]||0)-(b[0]||0)*(L[2]||0),(b[0]||0)*(L[1]||0)-(b[1]||0)*(L[0]||0)]:[0,0,0]}if(i==="length"){let b=a("a");return Array.isArray(b)?Math.hypot(...b):Math.abs(A(b))}if(i==="distance"){let b=a("a"),L=a("b");return Array.isArray(b)&&Array.isArray(L)?Math.hypot(...b.map((C,D)=>(C||0)-(L[D]||0))):Math.abs(A(b)-A(L))}if(i==="normalize"){let b=a("a");if(!Array.isArray(b))return A(b)>=0?1:-1;let L=Math.hypot(...b);return L>1e-8?b.map(C=>C/L):b.map(()=>0)}if(i.startsWith("combine"))return["a","b","c","d"].slice(0,Number(i[7])||2).map(b=>A(a(b)));if(i.startsWith("extract")){let b=a("a");return Array.isArray(b)?b[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 b=Number(a("a"));return!Number.isFinite(b)&&!Number.isNaN(b)}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"?G(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(P){P=!1,H=!0;let l=ve(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]),xe(u.normalMatrix,u.transform))}}if(O){O=!1,H=!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=R.get(g),c++){let a=l[g];if(a?.visible===!1||a?.extensions?.KHR_node_visibility?.visible===!1){h=!1;break}}u.visible=h}}H&&(H=!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<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 b=c.socket||"in",L=B(i),C=(T,_=void 0)=>oe(a,T,_,new Set),D=(T="out")=>{let _=i.flows?.[T];_&&g(_)};switch(L){case"flow/branch":D(X(C("condition",!1))?"true":"false");break;case"flow/sequence":for(let T of Object.keys(i.flows||{}).sort((_,W)=>Number(_)-Number(W)||_.localeCompare(W)))D(T);break;case"flow/switch":{let T=i.flows?.[String(C("selection",C("value",0)))]??i.flows?.default;T&&g(T);break}case"flow/for":{let T=Math.trunc(A(C("startIndex",0))),_=Math.trunc(A(C("endIndex",0))),W=Math.max(1,Math.trunc(A(C("step",1),1))),$=i.flows?.body;if($&&_>T&&I<bt){let ot=Math.min(Math.ceil((_-T)/W),ce);I++;try{for(let he=0;he<ot&&u.steps<ce;he++)k(a,"index",T+he*W),ee($,u)}finally{I--}}let Le=i.flows?.completed??i.flows?.out;Le&&g(Le);break}case"flow/doN":{let T=b==="reset"?0:(m.get(a)||0)+1;if(m.set(a,T),k(a,"currentCount",T),k(a,"count",T),b!=="reset"){let _=Math.trunc(A(C("n",U(i,"stopIterations")??U(i,"n")??1),1));T<=_&&D()}break}case"flow/multiGate":{if(b==="reset"){F.set(a,0);break}let T=Object.keys(i.flows||{}).sort();if(!T.length)break;let _=U(i,"isRandom")?Math.floor(Math.random()*T.length):F.get(a)||0;_<T.length&&(D(T[_]),F.set(a,U(i,"isLoop")!==!1?(_+1)%T.length:_+1));break}case"flow/waitAll":{if(b==="reset"){M.delete(a);break}let T=M.get(a);T||M.set(a,T=new Set),T.add(b),T.size>=Math.max(1,Math.trunc(Number(U(i,"inputFlows")??2)||2))&&(T.clear(),D("out"),D("completed"));break}case"flow/throttle":{if(b==="reset"){S.delete(a);break}let T=Math.max(0,A(C("duration",0))),_=S.get(a);_===void 0||N-_>=T?(S.set(a,N),k(a,"lastRemainingTime",0),D()):k(a,"lastRemainingTime",Math.max(0,T-(N-_)));break}case"flow/delay":case"flow/setDelay":{if(b==="cancel"){for(let $=y.length-1;$>=0;$--)y[$].nodeIdx===a&&y.splice($,1);k(a,"lastDelayIndex",-1);break}let T=Math.max(0,A(C("duration",U(i,"duration")??0))),_=i.flows?.done??i.flows?.out;if(T<=0){k(a,"lastDelayIndex",-1),_&&g(_);break}y.length>=mt&&y.shift();let W=V++;k(a,"lastDelayIndex",W),y.push({id:W,nodeIdx:a,rem:T,done:_}),L==="flow/setDelay"&&i.flows?.out&&i.flows?.done&&D("out");break}case"flow/cancelDelay":{let T=Math.trunc(A(C("delayIndex",-1),-1));if(T<0)y.length=0;else for(let _=y.length-1;_>=0;_--)y[_].id===T&&y.splice(_,1);D();break}case"variable/set":Y(U(i,"variable")??U(i,"id"),C("value")),D();break;case"variable/interpolate":{let T=U(i,"variable")??U(i,"id"),_=C("value",C("target")),W=Math.max(0,A(C("duration",U(i,"duration")??.3),.3));T!==void 0&&_!==void 0&&Fe({key:`var:${String(T)}`,varKey:T,from:G(C("from")??f.get(T)??0),to:G(_),dur:W,elapsed:0,quat:!1,linear:U(i,"easing")==="linear",done:i.flows?.done}),D();break}case"pointer/set":{let T=ye(a,i),_=C("value");T&&_!==void 0&&(z(`ptr:${T}`),re(T,_)),D();break}case"pointer/interpolate":{let T=ye(a,i),_=C("value",C("target")),W=Math.max(0,A(C("duration",U(i,"duration")??.3),.3));if(T&&_!==void 0){let $=C("from")??be(T);$!==void 0&&(W<=0?(re(T,_),D("done")):Fe({key:`ptr:${T}`,ptr:T,from:G($),to:G(_),dur:W,elapsed:0,quat:T.endsWith("/rotation"),linear:U(i,"easing")==="linear",done:i.flows?.done}))}D();break}case"animation/start":{let T=C("animation")??U(i,"animation")??U(i,"clipName"),_=typeof T=="number"?t?.animations?.[T]?.name??n?.animations?.[T]?.name:typeof T=="string"?T:void 0;t?.playAnimation?.(_),H=!0,D();break}case"animation/stop":case"animation/resetAt":t?.pauseAnimation?.(),L==="animation/resetAt"&&t?.evaluateAnimation?.(A(C("time",0))),H=!0,D();break;case"event/send":case"customEvent/send":{let T=q(U(i,"event")??U(i,"id")),_={};for(let W of Object.keys(i.values||{}))K.has(W)||(_[W]=C(W));T&&(typeof CustomEvent<"u"&&typeof t?.container?.dispatchEvent=="function"&&t.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:T,values:_}})),Pe(T,_,u)),D();break}default:D();break}}};this.readScenePointer=be,this.writeScenePointer=re,this.fireOnStart=()=>{o.forEach(l=>{B(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:t?.meshes?.[u]?.nodeIndex??-1;o.forEach((g,c)=>{if(!/^(pointer|event|scene)\/onSelect$/.test(B(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(k(c,"nodeIndex",h),k(c,"meshIndex",u),Array.isArray(l.hitPoint)){let L=[A(l.hitPoint[0]),A(l.hitPoint[1]),A(l.hitPoint[2])];k(c,"hitPoint",L),k(c,"point",L),k(c,"intersectionPoint",L)}if(Array.isArray(l.normal)){let L=[A(l.normal[0]),A(l.normal[1],1),A(l.normal[2])];k(c,"normal",L),k(c,"hitNormal",L)}typeof l.distance=="number"&&k(c,"distance",l.distance),ee(g.flows?.out)}}),ae()},this.receiveCustomEvent=(l,u={})=>Pe(l,u,{steps:0});function Pe(l,u,h){if(!(E>=dt)){E++;try{let g=q(l);o.forEach((c,a)=>{if(!/^(customE|e)vent\/receive$/.test(B(c)))return;let i=U(c,"event")??U(c,"id");if(!(q(i)!==g&&String(i)!==String(l))){for(let[b,L]of Object.entries(u))K.has(b)||k(a,b,G(L));ee(c.flows?.out,h)}}),ae()}finally{E--}}}this.tick=l=>{if(!Number.isFinite(l)||l<0)return;let u=Math.min(l,.25);N+=u,o.forEach((g,c)=>{B(g)==="event/onTick"&&(k(c,"timeDelta",u),k(c,"dt",u),k(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),b=je(c.from,c.to,i,c.quat);c.ptr?re(c.ptr,b):c.varKey!==void 0&&Y(c.varKey,b),a>=1&&(v.splice(g,1),c.done&&h.push(c.done))}for(let g=y.length-1;g>=0;g--){let c=y[g];c.rem-=u,c.rem<=0&&(y.splice(g,1),c.done&&h.push(c.done))}for(let g of h)ee(g);ae()},this.dispose=()=>{v.length=0,y.length=0,f.clear(),d.clear(),m.clear(),M.clear(),S.clear(),F.clear()}}},j=new WeakMap,de=new WeakMap;function ht(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||Ce().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=(de.get(e)||0)+o,x=!1;for(let p=0;p<r.length;p++){let f=r[p],d=Be(f?.extras?.xr?.orbit);if(!d)continue;let m=0,M=0,S=0;if(Array.isArray(d.target))m=d.target[0],M=d.target[1],S=d.target[2];else if(typeof d.target=="string"&&d.target!=="head"){let V=r.find(N=>N?.name===d.target);Array.isArray(V?.translation)&&(m=A(V.translation[0]),M=A(V.translation[1]),S=A(V.translation[2]))}let F=d.phase+d.speed*s,v=m+Math.cos(F)*d.radius,y=M+d.height,R=S+Math.sin(F)*d.radius;if(f.translation=[v,y,R],d.faceCenter){let V=Math.atan2(m-v,S-R);f.rotation=[0,Math.sin(V*.5),0,Math.cos(V*.5)]}x=!0}if(x){de.set(e,s);let p=ve(n);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 Ie(e){if(!(!e||typeof e!="object"))return j.get(e)||j.get(e.viewer)||j.get(e._view)}function Ye(e,t,n){let r=Ie(e);return r?(r.receiveCustomEvent(t,n),!0):!1}var Ze={name:"khr-interactivity",sendInteractivityEvent:Ye,getInteractivityVM:Ie,onLoadModel(e,t){if(!e||typeof e!="object")return;j.get(e)?.dispose(),j.delete(e),de.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 me(e,t,r);j.set(e,o),o.fireOnStart()},onMeshSelect(e,t){j.get(e)?.fireOnSelect(t)},onUpdate(e,t){j.get(e)?.tick(t),ht(e,t)},onDestroy(e,t){j.get(t)?.dispose(),j.delete(t),de.delete(t)}};var ne=new Map,Ee=new WeakMap;function gt(e,t){ne.set(e,t)}var Qe={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=Ee.get(e);n||(n=e.createTexture(),Ee.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&&ne.has(t.name)){let v=ne.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,d=o.KHR_materials_iridescence;if(!s&&!x&&!o.KHR_materials_unlit&&!p&&!o.KHR_materials_volume&&!f&&!o.KHR_materials_dispersion&&!d)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 m=r;if(p){let v=m.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
33
+ `;m=m.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
34
+ ${v}out vec4 fragColor;`)}let M=(v,y,R=0,V=1e6,N=3)=>{let E=Number(v);return(Number.isFinite(E)?Math.min(V,Math.max(R,E)):y).toFixed(N)},S=Number(o.KHR_materials_ior?.ior??1.5),F=Number.isFinite(S)?Math.min(10,Math.max(1,S)):1.5;if(f){let v=Math.pow((F-1)/(F+1),2);m=m.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${M(v,.04,0,1,4)}),base.rgb,metallic);`)}if(d){let v=M(d.iridescenceFactor,1,0,1),y=M(d.iridescenceIor,1.3,1,10);m=m.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${y}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${v}*pow(1.-NoV,2.));`)}if(p){let v=M(o.KHR_materials_transmission?.transmissionFactor,1,0,1),y=o.KHR_materials_volume||{},R=M(y.thicknessFactor,.5,0,1e4),V=M(y.attenuationDistance,1,.001,1e6),N=Array.isArray(y.attenuationColor)?y.attenuationColor:[1,1,1],E=M(o.KHR_materials_dispersion?.dispersion,0,0,10);m=m.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=${M(F,1.5,1,10)},dV=${E},tV=${R},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(${M(N[0],1,0,1)},${M(N[1],1,0,1)},${M(N[2],1,0,1)});
39
+ vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${V},.001));
40
+ diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${v});`)}if(s&&!r.includes("uClearcoat")){let v=M(s.clearcoatFactor,1,0,1),y=M(s.clearcoatRoughnessFactor,0,0,1);m=m.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${y},NoV)*${v};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${y})*ccF;fragColor=vec4(color,base.a);`)}if(x){let v=Array.isArray(x.sheenColorFactor)?x.sheenColorFactor:[1,1,1],y=`color+=vec3(${M(v[0],1,0,1)},${M(v[1],1,0,1)},${M(v[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;m.includes("color=applyToneMapping(color,uToneMapping);")?m=m.replace("color=applyToneMapping(color,uToneMapping);",`${y}color=applyToneMapping(color,uToneMapping);`):m=m.replace("fragColor=vec4(color,base.a);",`${y}fragColor=vec4(color,base.a);`)}return{vs:n,fs:m}},onBeforeDrawPrimitive(e,t,n,r,o,s){let x=n.materialIndex;if(x!==void 0&&s?.materials){let p=s.materials[x];p?.name&&ne.has(p.name)&&ne.get(p.name).onBindUniforms?.(e,t,n)}if(n.isTransmissive){let p=Ee.get(e);if(p){e.activeTexture(33990),e.bindTexture(3553,p);let f=e.getUniformLocation(t,"uTransmissionTex");f&&e.uniform1i(f,6);let d=e.getUniformLocation(t,"uViewportSize");d&&e.uniform2f(d,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var vt=`#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.);}`,At=`#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,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 Mt(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 d=0;d<f.length;d+=3)f[d]<t&&(t=f[d]),f[d+1]<n&&(n=f[d+1]),f[d+2]<r&&(r=f[d+2]),f[d]>o&&(o=f[d]),f[d+1]>s&&(s=f[d+1]),f[d+2]>x&&(x=f[d+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 Tt(e){let t=pe.get(e);if(t)return t;let n=(p,f)=>{let d=e.createShader(p);return e.shaderSource(d,f),e.compileShader(d),d},r=e.createProgram();e.attachShader(r,n(35633,vt)),e.attachShader(r,n(35632,At)),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")},pe.set(e,t),t}var et={name:"contact-shadow",onAfterRender(e,t,n){let r=t.shadowIntensity;if(r<=0||!t.bounds)return;let o=Tt(e),s=!t.xrSessionActive&&(t.backdropMeshes?.length??0)>0,x=[],p=[];for(let y of t.meshes||[]){if(!y||y.visible===!1||y.isPluginMesh||y.name==="__xr_reticle__"||y.name?.startsWith("__xr_slot_"))continue;let R=Mt(y);if(!R)continue;y.transform&&(R=_e(y.transform,R)),t.modelRootMatrix&&(R=_e(t.modelRootMatrix,R));let[V,N,E,w,I,P]=R,O=[V,E,w,P,N-I,N+I];/floor|table|pedestal|ground|base|plane/i.test(y.name||"")||I<.14&&Math.min(w,P)>.45?p.push(O):x.push(O)}let f=[],d=t.bounds.center||[0,0,0],m=Math.max(.05,Number(t.bounds.radius)||.5),M=t.bounds.min,S=M?[d[0],d[1],d[2],m,Math.max(.01,d[1]-M[1]),m]:[d[0],d[1],d[2],m,m,m];t.modelRootMatrix&&(S=_e(t.modelRootMatrix,S));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:S[1]-S[4]+.002;for(let[y,R,V,N,E]of x){let w=-1/0;for(let[P,O,H,B,,k]of p)E>=k-.08&&Math.abs(y-P)<=H&&Math.abs(R-O)<=B&&k+.002>w&&(w=k+.002);s&&(w=Math.max(w,y>=.04&&y<=.36&&R>=-.34&&R<=-.04&&E>=.01?.036:Math.hypot(y,R)<=.66&&E>=-.06?.003:-.477)),isFinite(w)||(w=v);let I=f.find(P=>Math.hypot(y-P[0],R-P[1])<.06&&Math.abs(w-P[5])<.05);I?(I[2]=Math.max(I[2],V*.78),I[3]=Math.max(I[3],N*.78),I[4]=Math.min(I[4],E)):f.push([y,R,V,N,E,w])}if(f.length===0){let y=Math.max(.1,S[3]*1.5)/1.45;f.push([S[0],S[2],y,y,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[y,R,V,N,E,w]of f){let I=Math.max(0,E-w),P=r/(1+I*2);if(P<.02)continue;let O=1+Math.min(.75,I*.85),H=Math.max(.045,V*1.45*O),B=Math.max(.045,N*1.45*O);Je.set([y-H,w,R-B,0,0,y+H,w,R-B,1,0,y+H,w,R+B,1,1,y-H,w,R+B,0,1]),e.bufferSubData(34962,0,Je),e.uniform1f(o.uIntensity,P),e.uniform1f(o.uSoftness,Math.min(1,t.shadowSoftness+Math.min(.45,I*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let t=pe.get(e);t&&(e.deleteVertexArray(t.vao),e.deleteBuffer(t.vbo),e.deleteBuffer(t.ibo),e.deleteProgram(t.prog),pe.delete(e))}};var tt=new WeakMap,nt={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=tt.get(t);if(o||(o={lightProbe:null},tt.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(m=>m.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 d=Math.max(p.x,p.y,p.z,.001);f.color=[p.x/d,p.y/d,p.z/d],f.intensity=d}s.sphericalHarmonicsCoefficients&&e.gl&&Me(e.gl,s.sphericalHarmonicsCoefficients)}}}};Q(et);Q(ze);Q(He);Q(Qe);Q(nt);Q(Ze);export{me as InteractivityVM,et as contactShadowPlugin,He as environmentMapPlugin,st as getEnvironmentSH,Ie as getInteractivityVM,ze as hotspotPlugin,Ze as interactivityPlugin,Qe as materialsPlugin,ue as parseSafeGltfPointer,gt as registerMaterialShader,Ye as sendInteractivityEvent,Me as setEnvironmentSH,nt as webxrPlugin};
@@ -0,0 +1,42 @@
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 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})},mt=(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 dt=e=>mt(ve({},"__esModule",{value:!0}),e);var Pt={};ft(Pt,{InteractivityVM:()=>re,contactShadowPlugin:()=>ke,environmentMapPlugin:()=>Se,getEnvironmentSH:()=>je,getInteractivityVM:()=>be,hotspotPlugin:()=>Ee,interactivityPlugin:()=>Le,materialsPlugin:()=>Ve,parseSafeGltfPointer:()=>ne,registerMaterialShader:()=>rt,sendInteractivityEvent:()=>Pe,setEnvironmentSH:()=>le,webxrPlugin:()=>De});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 Ct=Ae().plugins;function Q(e){let t=Ae().plugins;t.some(n=>n.name===e.name)||t.push(e)}function Be(){return Ae().plugins}function Oe(){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],d=t[6],m=t[7],M=t[8],S=t[9],F=t[10],v=t[11],y=t[12],R=t[13],V=t[14],N=t[15],E=n[0],w=n[1],I=n[2],P=n[3];return e[0]=E*r+w*p+I*M+P*y,e[1]=E*o+w*f+I*S+P*R,e[2]=E*s+w*d+I*F+P*V,e[3]=E*x+w*m+I*v+P*N,E=n[4],w=n[5],I=n[6],P=n[7],e[4]=E*r+w*p+I*M+P*y,e[5]=E*o+w*f+I*S+P*R,e[6]=E*s+w*d+I*F+P*V,e[7]=E*x+w*m+I*v+P*N,E=n[8],w=n[9],I=n[10],P=n[11],e[8]=E*r+w*p+I*M+P*y,e[9]=E*o+w*f+I*S+P*R,e[10]=E*s+w*d+I*F+P*V,e[11]=E*x+w*m+I*v+P*N,E=n[12],w=n[13],I=n[14],P=n[15],e[12]=E*r+w*p+I*M+P*y,e[13]=E*o+w*f+I*S+P*R,e[14]=E*s+w*d+I*F+P*V,e[15]=E*x+w*m+I*v+P*N,e}function bt(e,t,n,r){let o=t[0],s=t[1],x=t[2],p=t[3],f=o+o,d=s+s,m=x+x,M=o*f,S=o*d,F=o*m,v=s*d,y=s*m,R=x*m,V=p*f,N=p*d,E=p*m,w=r[0],I=r[1],P=r[2];return e[0]=(1-(v+R))*w,e[1]=(S+E)*w,e[2]=(F-N)*w,e[3]=0,e[4]=(S-E)*I,e[5]=(1-(M+R))*I,e[6]=(y+V)*I,e[7]=0,e[8]=(F+N)*P,e[9]=(y-V)*P,e[10]=(1-(M+v))*P,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Me(e,t){let n=t[0],r=t[1],o=t[2],s=t[4],x=t[5],p=t[6],f=t[8],d=t[9],m=t[10],M=m*x-p*d,S=-m*s+p*f,F=d*s-x*f,v=n*M+r*S+o*F;return v&&(v=1/v,e[0]=M*v,e[1]=(-m*r+o*d)*v,e[2]=(p*r-o*x)*v,e[3]=S*v,e[4]=(m*n-o*f)*v,e[5]=(-p*n+o*s)*v,e[6]=F*v,e[7]=(-d*n+r*f)*v,e[8]=(x*n-r*s)*v),e}function We(e,t){let n=t[0],r=t[1],o=t[2],s=t[3],x=t[4],p=t[5],f=t[6],d=t[7],m=t[8],M=t[9],S=t[10],F=t[11],v=t[12],y=t[13],R=t[14],V=t[15],N=n*p-r*x,E=n*f-o*x,w=n*d-s*x,I=r*f-o*p,P=r*d-s*p,O=o*d-s*f,H=m*y-M*v,B=m*R-S*v,k=m*V-F*v,Y=M*R-S*y,q=M*V-F*y,Z=S*V-F*R,z=N*Z-E*q+w*Y+I*k-P*B+O*H;return z?(z=1/z,e[0]=(p*Z-f*q+d*Y)*z,e[1]=(o*q-r*Z-s*Y)*z,e[2]=(y*O-R*P+V*I)*z,e[3]=(S*P-M*O-F*I)*z,e[4]=(f*k-x*Z-d*B)*z,e[5]=(n*Z-o*k+s*B)*z,e[6]=(R*w-v*O-V*E)*z,e[7]=(m*O-S*w+F*E)*z,e[8]=(x*q-p*k+d*H)*z,e[9]=(r*k-n*q-s*H)*z,e[10]=(v*P-y*w+V*N)*z,e[11]=(M*w-m*P-F*N)*z,e[12]=(p*B-x*Y-f*H)*z,e[13]=(n*Y-r*B+o*H)*z,e[14]=(y*E-v*I-R*N)*z,e[15]=(m*I-M*E+S*N)*z,e):null}function Te(e,t){let n=Array.isArray(e?.nodes)?e.nodes.length:0,r=[];for(let m=0;m<n;m++)r.push(Oe());if(n===0)return r;let o=new Set;for(let m of e.nodes)if(Array.isArray(m.children))for(let M of m.children)o.add(M);let s=new Set,x=128,p=(m,M,S=0)=>{if(S>x||m<0||m>=n||s.has(m))return;s.add(m);let F=e.nodes[m];if(!F)return;let v=Oe();if(t&&t[m])v.set(t[m]);else if(F.matrix&&F.matrix.length===16)v.set(F.matrix);else{let R=F.translation||[0,0,0],V=F.rotation||[0,0,0,1],N=F.scale||[1,1,1];bt(v,V,R,N)}let y=r[m];if(M?pt(y,M,v):y.set(v),Array.isArray(F.children))for(let R of F.children)typeof R=="number"&&p(R,y,S+1)},f=[],d=e.scenes&&e.scenes[e.scene!==void 0?e.scene:0];if(d&&Array.isArray(d.nodes))f.push(...d.nodes);else for(let m=0;m<n;m++)o.has(m)||f.push(m);for(let m of f)p(m,null);for(let m=0;m<n;m++)!o.has(m)&&!f.includes(m)&&p(m,null);return r}var Re=new WeakMap;function le(e,t){let n=t instanceof Float32Array?t:new Float32Array(t);Re.set(e,n)}function je(e){return Re.get(e)}async function yt(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 Ge=new WeakMap,Xe=new Float32Array(16);async function $e(e,t,n){let r=n?await yt(e.gl,n):null;e[t]&&e.gl.deleteTexture(e[t]),e[t]=r}var Se={name:"environment-map",setEnvironmentImage(e,t){return $e(e,"environmentTexture",t)},setSkyboxImage(e,t){return $e(e,"skyboxTexture",t)},onBeforeDrawScene(e,t,n,r,o){if(!e.skyboxTexture||typeof t.createProgram!="function")return;let s=Ge.get(t);if(!s){let M=(v,y)=>{let R=t.createShader(v);return t.shaderSource(R,y),t.compileShader(R),R},S=t.createProgram();t.attachShader(S,M(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(S,M(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(S);let F=typeof t.createVertexArray=="function"?t.createVertexArray():null;s={program:S,vao:F},Ge.set(t,s)}let x=We(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 d=t.getUniformLocation(s.program,"uCameraPos");d&&t.uniform3f(d,r[0],r[1],r[2]);let m=t.getUniformLocation(s.program,"uExposure");m&&t.uniform1f(m,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
+ 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:n,fs:o}},onBeforeDrawPrimitive(e,t,n,r,o,s){let x=Re.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 Ie(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(M=>parseFloat(M.replace(/m$/,"")));if(p.length<3||p.some(isNaN))continue;let f=s.getAttribute("data-normal"),d;if(f){let M=f.trim().split(/\s+/).map(S=>parseFloat(S));M.length>=3&&!M.some(isNaN)&&(d=[M[0],M[1],M[2]])}let m=n.projectPointToScreen([p[0],p[1],p[2]],d);s.style.position="absolute",s.style.left="0",s.style.top="0",s.style.transform=`translate(-50%, -50%) translate3d(${m.x}px, ${m.y}px, 0)`,s.style.zIndex="3",m.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 Ee={name:"hotspots",updateHotspotsForElement:Ie,onElementConnected(e){if(typeof MutationObserver>"u"||!e)return;let t=new MutationObserver(()=>{Ie(e)});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-position","data-normal"]}),we.set(e,t)},onCameraChange(e,t){t&&Ie(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],d=n[1],m=n[2],M=n[3],S=o*f+s*d+x*m+p*M;if(S<0&&(f=-f,d=-d,m=-m,M=-M,S=-S),Math.abs(S)>=1)return e[0]=o,e[1]=s,e[2]=x,e[3]=p,e;let F=Math.acos(S),v=Math.sqrt(1-S*S);if(Math.abs(v)<.001)return e[0]=.5*(o+f),e[1]=.5*(s+d),e[2]=.5*(x+m),e[3]=.5*(p+M),e;let y=Math.sin((1-r)*F)/v,R=Math.sin(r*F)/v;return e[0]=o*y+f*R,e[1]=s*y+d*R,e[2]=x*y+m*R,e[3]=p*y+M*R,e}var Ye=1024,_e=256,fe=2048,xt=128,vt=64,At=16,Mt=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},me={translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]},de=(e,t)=>e!==null&&typeof e=="object"&&!K.has(t)&&Object.prototype.hasOwnProperty.call(e,t),G=e=>Array.isArray(e)?[...e]:e,nt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&de(e,"value")?e.value:e,U=(e,t)=>de(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},Fe=(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)),Rt=(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,d=new Map,m=new Map,M=new Map,S=new Map,F=new Map,v=[],y=[],R=new Map,V=1,N=0,E=0,w=0,I=0,P=!1,O=!1,H=!1;s.forEach((l,u)=>{if(!l||typeof l!="object")return;let h=G(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"&&R.set(h,u)});let B=l=>l.op||typeof l.declaration=="number"&&x[l.declaration]?.op||"",k=(l,u,h)=>{if(K.has(u))return;let g=d.get(l);g||d.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=G(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=R.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)},Ue=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 me){let c=me[g],a=h[g]||c;return c.map((i,b)=>A(a[b],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 me&&Array.isArray(u)){let i=me[a];if(u.length<i.length)return!1;let b=i.map((C,D)=>A(u[D],C));if(a==="rotation"){let C=Math.hypot(...b);b=C>1e-8?b.map(D=>D/C):[0,0,0,1]}c[a]=b,delete c.matrix;let L=t?.initialNodeTransforms?.[g];return L&&(L[a[0]]=[...b]),P=!0,!0}if(a==="weights"){Array.isArray(c.weights)||(c.weights=[]);let i=(b,L)=>{for(let C of t?.meshes||[])if(C.nodeIndex===g)for(let D of C.primitives||[])D.pluginData?.morph?.weights&&(D.pluginData.morph.weights[b]=L)};if(h.length===4){let b=te(h[3],64);if(b<0)return!1;i(b,c.weights[b]=A(u))}else if(Array.isArray(u))c.weights=u.slice(0,64).map(b=>A(b)),c.weights.forEach((b,L)=>i(L,b));else return!1;return H=!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},O=!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=b=>{for(let L of t?.meshes||[])for(let C of L.primitives||[])(C.materialIndex??0)===g&&b(C)};if(h[2]==="pbrMetallicRoughness"){if(h[3]==="baseColorFactor"&&Array.isArray(u)&&u.length>=3){let b=[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=b,i(L=>L.baseColor=[...b]),H=!0}if(h[3]==="metallicFactor"||h[3]==="roughnessFactor"){let b=h[3]==="metallicFactor",L=J(A(u,b?0:.5));return a[h[3]]=L,i(C=>C[b?"metallic":"roughness"]=L),H=!0}}if(h[2]==="emissiveFactor"&&Array.isArray(u)&&u.length>=3)return c.emissiveFactor=[0,1,2].map(b=>Math.max(0,A(u[b]))),H=!0;if(h[2]==="alphaCutoff")return c.alphaCutoff=J(A(u,.5)),H=!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 b=Math.trunc(Number(ie(l,i,void 0,h)??U(u,i)));return Number.isSafeInteger(b)&&b>=0?String(b):"-1"});return ne(c)?c:null},ie=(l,u,h,g)=>{let c=o[l]?.values;if(!de(c,u))return h;let a=c[u];if(a==null)return h;if(typeof a!="object"||Array.isArray(a))return G(a);let i=a;return typeof i.node=="number"?it(i.node,i.socket||"value",g):de(i,"value")?G(i.value):h},it=(l,u,h)=>{if(l<0||l>=o.length||h.has(l)||h.size>128||++w>Mt)return;let g=o[l],c=B(g);if(/^(event\/|pointer\/on|scene\/on|flow\/)/.test(c))return G(d.get(l)?.[u]);h.add(l);try{let a=(i,b=0)=>ie(l,i,b,h);if(c==="variable/get"){let i=U(g,"variable")??U(g,"id");return typeof i=="number"||typeof i=="string"?G(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 Rt(a("a"),Ze[i]);if(i in Qe){let b=/^(mul|div|rem|mod|pow)$/.test(i)?1:0;return Fe(a("a",i==="mul"?1:0),a("b",b),Qe[i])}if(i==="pi")return Math.PI;if(i==="e")return Math.E;if(i==="random")return Math.random();if(i==="clamp")return Fe(Fe(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 b=a("a"),L=a("b");return Array.isArray(b)&&Array.isArray(L)?b.reduce((C,D,T)=>C+(D||0)*(L[T]||0),0):A(b)*A(L)}if(i==="cross"){let b=a("a",[0,0,0]),L=a("b",[0,0,0]);return Array.isArray(b)&&Array.isArray(L)?[(b[1]||0)*(L[2]||0)-(b[2]||0)*(L[1]||0),(b[2]||0)*(L[0]||0)-(b[0]||0)*(L[2]||0),(b[0]||0)*(L[1]||0)-(b[1]||0)*(L[0]||0)]:[0,0,0]}if(i==="length"){let b=a("a");return Array.isArray(b)?Math.hypot(...b):Math.abs(A(b))}if(i==="distance"){let b=a("a"),L=a("b");return Array.isArray(b)&&Array.isArray(L)?Math.hypot(...b.map((C,D)=>(C||0)-(L[D]||0))):Math.abs(A(b)-A(L))}if(i==="normalize"){let b=a("a");if(!Array.isArray(b))return A(b)>=0?1:-1;let L=Math.hypot(...b);return L>1e-8?b.map(C=>C/L):b.map(()=>0)}if(i.startsWith("combine"))return["a","b","c","d"].slice(0,Number(i[7])||2).map(b=>A(a(b)));if(i.startsWith("extract")){let b=a("a");return Array.isArray(b)?b[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 b=Number(a("a"));return!Number.isFinite(b)&&!Number.isNaN(b)}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"?G(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(P){P=!1,H=!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]),Me(u.normalMatrix,u.transform))}}if(O){O=!1,H=!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=R.get(g),c++){let a=l[g];if(a?.visible===!1||a?.extensions?.KHR_node_visibility?.visible===!1){h=!1;break}}u.visible=h}}H&&(H=!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 b=c.socket||"in",L=B(i),C=(T,_=void 0)=>ie(a,T,_,new Set),D=(T="out")=>{let _=i.flows?.[T];_&&g(_)};switch(L){case"flow/branch":D(X(C("condition",!1))?"true":"false");break;case"flow/sequence":for(let T of Object.keys(i.flows||{}).sort((_,W)=>Number(_)-Number(W)||_.localeCompare(W)))D(T);break;case"flow/switch":{let T=i.flows?.[String(C("selection",C("value",0)))]??i.flows?.default;T&&g(T);break}case"flow/for":{let T=Math.trunc(A(C("startIndex",0))),_=Math.trunc(A(C("endIndex",0))),W=Math.max(1,Math.trunc(A(C("step",1),1))),$=i.flows?.body;if($&&_>T&&I<Tt){let st=Math.min(Math.ceil((_-T)/W),fe);I++;try{for(let xe=0;xe<st&&u.steps<fe;xe++)k(a,"index",T+xe*W),ee($,u)}finally{I--}}let ze=i.flows?.completed??i.flows?.out;ze&&g(ze);break}case"flow/doN":{let T=b==="reset"?0:(m.get(a)||0)+1;if(m.set(a,T),k(a,"currentCount",T),k(a,"count",T),b!=="reset"){let _=Math.trunc(A(C("n",U(i,"stopIterations")??U(i,"n")??1),1));T<=_&&D()}break}case"flow/multiGate":{if(b==="reset"){F.set(a,0);break}let T=Object.keys(i.flows||{}).sort();if(!T.length)break;let _=U(i,"isRandom")?Math.floor(Math.random()*T.length):F.get(a)||0;_<T.length&&(D(T[_]),F.set(a,U(i,"isLoop")!==!1?(_+1)%T.length:_+1));break}case"flow/waitAll":{if(b==="reset"){M.delete(a);break}let T=M.get(a);T||M.set(a,T=new Set),T.add(b),T.size>=Math.max(1,Math.trunc(Number(U(i,"inputFlows")??2)||2))&&(T.clear(),D("out"),D("completed"));break}case"flow/throttle":{if(b==="reset"){S.delete(a);break}let T=Math.max(0,A(C("duration",0))),_=S.get(a);_===void 0||N-_>=T?(S.set(a,N),k(a,"lastRemainingTime",0),D()):k(a,"lastRemainingTime",Math.max(0,T-(N-_)));break}case"flow/delay":case"flow/setDelay":{if(b==="cancel"){for(let $=y.length-1;$>=0;$--)y[$].nodeIdx===a&&y.splice($,1);k(a,"lastDelayIndex",-1);break}let T=Math.max(0,A(C("duration",U(i,"duration")??0))),_=i.flows?.done??i.flows?.out;if(T<=0){k(a,"lastDelayIndex",-1),_&&g(_);break}y.length>=vt&&y.shift();let W=V++;k(a,"lastDelayIndex",W),y.push({id:W,nodeIdx:a,rem:T,done:_}),L==="flow/setDelay"&&i.flows?.out&&i.flows?.done&&D("out");break}case"flow/cancelDelay":{let T=Math.trunc(A(C("delayIndex",-1),-1));if(T<0)y.length=0;else for(let _=y.length-1;_>=0;_--)y[_].id===T&&y.splice(_,1);D();break}case"variable/set":Y(U(i,"variable")??U(i,"id"),C("value")),D();break;case"variable/interpolate":{let T=U(i,"variable")??U(i,"id"),_=C("value",C("target")),W=Math.max(0,A(C("duration",U(i,"duration")??.3),.3));T!==void 0&&_!==void 0&&Ue({key:`var:${String(T)}`,varKey:T,from:G(C("from")??f.get(T)??0),to:G(_),dur:W,elapsed:0,quat:!1,linear:U(i,"easing")==="linear",done:i.flows?.done}),D();break}case"pointer/set":{let T=ge(a,i),_=C("value");T&&_!==void 0&&(z(`ptr:${T}`),ae(T,_)),D();break}case"pointer/interpolate":{let T=ge(a,i),_=C("value",C("target")),W=Math.max(0,A(C("duration",U(i,"duration")??.3),.3));if(T&&_!==void 0){let $=C("from")??he(T);$!==void 0&&(W<=0?(ae(T,_),D("done")):Ue({key:`ptr:${T}`,ptr:T,from:G($),to:G(_),dur:W,elapsed:0,quat:T.endsWith("/rotation"),linear:U(i,"easing")==="linear",done:i.flows?.done}))}D();break}case"animation/start":{let T=C("animation")??U(i,"animation")??U(i,"clipName"),_=typeof T=="number"?t?.animations?.[T]?.name??n?.animations?.[T]?.name:typeof T=="string"?T:void 0;t?.playAnimation?.(_),H=!0,D();break}case"animation/stop":case"animation/resetAt":t?.pauseAnimation?.(),L==="animation/resetAt"&&t?.evaluateAnimation?.(A(C("time",0))),H=!0,D();break;case"event/send":case"customEvent/send":{let T=q(U(i,"event")??U(i,"id")),_={};for(let W of Object.keys(i.values||{}))K.has(W)||(_[W]=C(W));T&&(typeof CustomEvent<"u"&&typeof t?.container?.dispatchEvent=="function"&&t.container.dispatchEvent(new CustomEvent("interactivityEvent",{bubbles:!0,composed:!0,detail:{id:T,values:_}})),He(T,_,u)),D();break}default:D();break}}};this.readScenePointer=he,this.writeScenePointer=ae,this.fireOnStart=()=>{o.forEach(l=>{B(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(B(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(k(c,"nodeIndex",h),k(c,"meshIndex",u),Array.isArray(l.hitPoint)){let L=[A(l.hitPoint[0]),A(l.hitPoint[1]),A(l.hitPoint[2])];k(c,"hitPoint",L),k(c,"point",L),k(c,"intersectionPoint",L)}if(Array.isArray(l.normal)){let L=[A(l.normal[0]),A(l.normal[1],1),A(l.normal[2])];k(c,"normal",L),k(c,"hitNormal",L)}typeof l.distance=="number"&&k(c,"distance",l.distance),ee(g.flows?.out)}}),se()},this.receiveCustomEvent=(l,u={})=>He(l,u,{steps:0});function He(l,u,h){if(!(E>=At)){E++;try{let g=q(l);o.forEach((c,a)=>{if(!/^(customE|e)vent\/receive$/.test(B(c)))return;let i=U(c,"event")??U(c,"id");if(!(q(i)!==g&&String(i)!==String(l))){for(let[b,L]of Object.entries(u))K.has(b)||k(a,b,G(L));ee(c.flows?.out,h)}}),se()}finally{E--}}}this.tick=l=>{if(!Number.isFinite(l)||l<0)return;let u=Math.min(l,.25);N+=u,o.forEach((g,c)=>{B(g)==="event/onTick"&&(k(c,"timeDelta",u),k(c,"dt",u),k(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),b=et(c.from,c.to,i,c.quat);c.ptr?ae(c.ptr,b):c.varKey!==void 0&&Y(c.varKey,b),a>=1&&(v.splice(g,1),c.done&&h.push(c.done))}for(let g=y.length-1;g>=0;g--){let c=y[g];c.rem-=u,c.rem<=0&&(y.splice(g,1),c.done&&h.push(c.done))}for(let g of h)ee(g);se()},this.dispose=()=>{v.length=0,y.length=0,f.clear(),d.clear(),m.clear(),M.clear(),S.clear(),F.clear()}}},j=new WeakMap,pe=new WeakMap;function St(e,t){if(!e||typeof e!="object"||!Number.isFinite(t)||t<=0||Be().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],d=qe(f?.extras?.xr?.orbit);if(!d)continue;let m=0,M=0,S=0;if(Array.isArray(d.target))m=d.target[0],M=d.target[1],S=d.target[2];else if(typeof d.target=="string"&&d.target!=="head"){let V=r.find(N=>N?.name===d.target);Array.isArray(V?.translation)&&(m=A(V.translation[0]),M=A(V.translation[1]),S=A(V.translation[2]))}let F=d.phase+d.speed*s,v=m+Math.cos(F)*d.radius,y=M+d.height,R=S+Math.sin(F)*d.radius;if(f.translation=[v,y,R],d.faceCenter){let V=Math.atan2(m-v,S-R);f.rotation=[0,Math.sin(V*.5),0,Math.cos(V*.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]),Me(f.normalMatrix,f.transform))}}function be(e){if(!(!e||typeof e!="object"))return j.get(e)||j.get(e.viewer)||j.get(e._view)}function Pe(e,t,n){let r=be(e);return r?(r.receiveCustomEvent(t,n),!0):!1}var Le={name:"khr-interactivity",sendInteractivityEvent:Pe,getInteractivityVM:be,onLoadModel(e,t){if(!e||typeof e!="object")return;j.get(e)?.dispose(),j.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);j.set(e,o),o.fireOnStart()},onMeshSelect(e,t){j.get(e)?.fireOnSelect(t)},onUpdate(e,t){j.get(e)?.tick(t),St(e,t)},onDestroy(e,t){j.get(t)?.dispose(),j.delete(t),pe.delete(t)}};var oe=new Map,Ce=new WeakMap;function rt(e,t){oe.set(e,t)}var Ve={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=Ce.get(e);n||(n=e.createTexture(),Ce.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,d=o.KHR_materials_iridescence;if(!s&&!x&&!o.KHR_materials_unlit&&!p&&!o.KHR_materials_volume&&!f&&!o.KHR_materials_dispersion&&!d)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 m=r;if(p){let v=m.includes("uniform vec2 uViewportSize;")?"":`uniform vec2 uViewportSize;
33
+ `;m=m.replace("out vec4 fragColor;",`uniform sampler2D uTransmissionTex;
34
+ ${v}out vec4 fragColor;`)}let M=(v,y,R=0,V=1e6,N=3)=>{let E=Number(v);return(Number.isFinite(E)?Math.min(V,Math.max(R,E)):y).toFixed(N)},S=Number(o.KHR_materials_ior?.ior??1.5),F=Number.isFinite(S)?Math.min(10,Math.max(1,S)):1.5;if(f){let v=Math.pow((F-1)/(F+1),2);m=m.replace("vec3 F0=mix(vec3(0.04),base.rgb,metallic);",`vec3 F0=mix(vec3(${M(v,.04,0,1,4)}),base.rgb,metallic);`)}if(d){let v=M(d.iridescenceFactor,1,0,1),y=M(d.iridescenceIor,1.3,1,10);m=m.replace("vec3 F=F_SchlickRoughness(F0,roughness,NoV);",`vec3 F=F_SchlickRoughness(F0,roughness,NoV);vec3 iridColor=.5+.5*cos(800.*${y}*NoV*vec3(.015,.018,.022));F=mix(F,iridColor,${v}*pow(1.-NoV,2.));`)}if(p){let v=M(o.KHR_materials_transmission?.transmissionFactor,1,0,1),y=o.KHR_materials_volume||{},R=M(y.thicknessFactor,.5,0,1e4),V=M(y.attenuationDistance,1,.001,1e6),N=Array.isArray(y.attenuationColor)?y.attenuationColor:[1,1,1],E=M(o.KHR_materials_dispersion?.dispersion,0,0,10);m=m.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=${M(F,1.5,1,10)},dV=${E},tV=${R},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(${M(N[0],1,0,1)},${M(N[1],1,0,1)},${M(N[2],1,0,1)});
39
+ vec3 volumeAtten=exp(-tV*(vec3(1.)-aCol)/max(${V},.001));
40
+ diffuseIBL=mix(diffuseIBL,tr*volumeAtten*base.rgb,${v});`)}if(s&&!r.includes("uClearcoat")){let v=M(s.clearcoatFactor,1,0,1),y=M(s.clearcoatRoughnessFactor,0,0,1);m=m.replace("fragColor=vec4(color,base.a);",`vec3 ccF=F_SchlickRoughness(vec3(.04),${y},NoV)*${v};color=color*(vec3(1.)-ccF)+getStudioRadiance(R,${y})*ccF;fragColor=vec4(color,base.a);`)}if(x){let v=Array.isArray(x.sheenColorFactor)?x.sheenColorFactor:[1,1,1],y=`color+=vec3(${M(v[0],1,0,1)},${M(v[1],1,0,1)},${M(v[2],1,0,1)})*pow(1.-NoV,4.)*.5;`;m.includes("color=applyToneMapping(color,uToneMapping);")?m=m.replace("color=applyToneMapping(color,uToneMapping);",`${y}color=applyToneMapping(color,uToneMapping);`):m=m.replace("fragColor=vec4(color,base.a);",`${y}fragColor=vec4(color,base.a);`)}return{vs:n,fs:m}},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=Ce.get(e);if(p){e.activeTexture(33990),e.bindTexture(3553,p);let f=e.getUniformLocation(t,"uTransmissionTex");f&&e.uniform1i(f,6);let d=e.getUniformLocation(t,"uViewportSize");d&&e.uniform2f(d,e.drawingBufferWidth||1,e.drawingBufferHeight||1)}}}};var It=`#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.);}`,Et=`#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);}`,ye=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 d=0;d<f.length;d+=3)f[d]<t&&(t=f[d]),f[d+1]<n&&(n=f[d+1]),f[d+2]<r&&(r=f[d+2]),f[d]>o&&(o=f[d]),f[d+1]>s&&(s=f[d+1]),f[d+2]>x&&(x=f[d+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 Ft(e){let t=ye.get(e);if(t)return t;let n=(p,f)=>{let d=e.createShader(p);return e.shaderSource(d,f),e.compileShader(d),d},r=e.createProgram();e.attachShader(r,n(35633,It)),e.attachShader(r,n(35632,Et)),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")},ye.set(e,t),t}var ke={name:"contact-shadow",onAfterRender(e,t,n){let r=t.shadowIntensity;if(r<=0||!t.bounds)return;let o=Ft(e),s=!t.xrSessionActive&&(t.backdropMeshes?.length??0)>0,x=[],p=[];for(let y of t.meshes||[]){if(!y||y.visible===!1||y.isPluginMesh||y.name==="__xr_reticle__"||y.name?.startsWith("__xr_slot_"))continue;let R=_t(y);if(!R)continue;y.transform&&(R=Ne(y.transform,R)),t.modelRootMatrix&&(R=Ne(t.modelRootMatrix,R));let[V,N,E,w,I,P]=R,O=[V,E,w,P,N-I,N+I];/floor|table|pedestal|ground|base|plane/i.test(y.name||"")||I<.14&&Math.min(w,P)>.45?p.push(O):x.push(O)}let f=[],d=t.bounds.center||[0,0,0],m=Math.max(.05,Number(t.bounds.radius)||.5),M=t.bounds.min,S=M?[d[0],d[1],d[2],m,Math.max(.01,d[1]-M[1]),m]:[d[0],d[1],d[2],m,m,m];t.modelRootMatrix&&(S=Ne(t.modelRootMatrix,S));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:S[1]-S[4]+.002;for(let[y,R,V,N,E]of x){let w=-1/0;for(let[P,O,H,B,,k]of p)E>=k-.08&&Math.abs(y-P)<=H&&Math.abs(R-O)<=B&&k+.002>w&&(w=k+.002);s&&(w=Math.max(w,y>=.04&&y<=.36&&R>=-.34&&R<=-.04&&E>=.01?.036:Math.hypot(y,R)<=.66&&E>=-.06?.003:-.477)),isFinite(w)||(w=v);let I=f.find(P=>Math.hypot(y-P[0],R-P[1])<.06&&Math.abs(w-P[5])<.05);I?(I[2]=Math.max(I[2],V*.78),I[3]=Math.max(I[3],N*.78),I[4]=Math.min(I[4],E)):f.push([y,R,V,N,E,w])}if(f.length===0){let y=Math.max(.1,S[3]*1.5)/1.45;f.push([S[0],S[2],y,y,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[y,R,V,N,E,w]of f){let I=Math.max(0,E-w),P=r/(1+I*2);if(P<.02)continue;let O=1+Math.min(.75,I*.85),H=Math.max(.045,V*1.45*O),B=Math.max(.045,N*1.45*O);ot.set([y-H,w,R-B,0,0,y+H,w,R-B,1,0,y+H,w,R+B,1,1,y-H,w,R+B,0,1]),e.bufferSubData(34962,0,ot),e.uniform1f(o.uIntensity,P),e.uniform1f(o.uSoftness,Math.min(1,t.shadowSoftness+Math.min(.45,I*.6))),e.drawElements(4,6,5123,0)}e.bindVertexArray(null),e.depthMask(!0),e.disable(3042)},onDestroy(e){let t=ye.get(e);t&&(e.deleteVertexArray(t.vao),e.deleteBuffer(t.vbo),e.deleteBuffer(t.ibo),e.deleteProgram(t.prog),ye.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(m=>m.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 d=Math.max(p.x,p.y,p.z,.001);f.color=[p.x/d,p.y/d,p.z/d],f.intensity=d}s.sphericalHarmonicsCoefficients&&e.gl&&le(e.gl,s.sphericalHarmonicsCoefficients)}}}};Q(ke);Q(Ee);Q(Se);Q(Ve);Q(De);Q(Le);return dt(Pt);})();