@vincentt-xr/sdk 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/GROUNDING.md +537 -0
  2. package/LICENSE +7 -0
  3. package/README.md +85 -0
  4. package/dist/DebuggerUI-CEfdddkZ.cjs +1 -0
  5. package/dist/DebuggerUI-Dgop6Q6o.js +269 -0
  6. package/dist/audio/AudioEngine.d.ts +98 -0
  7. package/dist/audio/index.d.ts +34 -0
  8. package/dist/components/AspectRatioContainer/index.d.ts +10 -0
  9. package/dist/components/BodyTracker/index.d.ts +15 -0
  10. package/dist/components/Debugger/DebuggerProvider.d.ts +22 -0
  11. package/dist/components/Debugger/DebuggerUI.d.ts +13 -0
  12. package/dist/components/Debugger/index.d.ts +38 -0
  13. package/dist/components/Debugger/styles.d.ts +19 -0
  14. package/dist/components/FaceMesh/FaceMesh.d.ts +26 -0
  15. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +34 -0
  16. package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +16 -0
  17. package/dist/components/FaceMesh/canonical/useCanonicalFaceMesh.d.ts +15 -0
  18. package/dist/components/FaceMesh/deform.d.ts +36 -0
  19. package/dist/components/FaceMesh/index.d.ts +6 -0
  20. package/dist/components/FaceMesh/indices.d.ts +1 -0
  21. package/dist/components/FaceMesh/material/blendModes.d.ts +2 -0
  22. package/dist/components/FaceMesh/material/defaults.d.ts +3 -0
  23. package/dist/components/FaceMesh/material/index.d.ts +5 -0
  24. package/dist/components/FaceMesh/material/options.d.ts +25 -0
  25. package/dist/components/FaceMesh/material/support.d.ts +3 -0
  26. package/dist/components/FaceMesh/material/types.d.ts +23 -0
  27. package/dist/components/FaceMesh/uv.d.ts +1 -0
  28. package/dist/components/FaceRetouch/Background.d.ts +16 -0
  29. package/dist/components/FaceRetouch/index.d.ts +6 -0
  30. package/dist/components/FaceRetouch/landmarkMask.d.ts +23 -0
  31. package/dist/components/FaceRetouch/retouchRegions.d.ts +23 -0
  32. package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +14 -0
  33. package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +12 -0
  34. package/dist/components/FaceTracker/BoundingBoxOverlay.d.ts +20 -0
  35. package/dist/components/FaceTracker/index.d.ts +54 -0
  36. package/dist/components/GestureTracker/index.d.ts +31 -0
  37. package/dist/components/GestureTrigger/index.d.ts +3 -0
  38. package/dist/components/HandTracker/index.d.ts +24 -0
  39. package/dist/components/HeadBinding/index.d.ts +31 -0
  40. package/dist/components/HeadBindingOccluder/index.d.ts +36 -0
  41. package/dist/components/HeadOccluder/index.d.ts +13 -0
  42. package/dist/components/Panel/index.d.ts +71 -0
  43. package/dist/components/PerspectiveCamera/index.d.ts +14 -0
  44. package/dist/components/ScreenSpaceUI/ScreenTransform.d.ts +54 -0
  45. package/dist/components/ScreenSpaceUI/context.d.ts +29 -0
  46. package/dist/components/ScreenSpaceUI/index.d.ts +40 -0
  47. package/dist/components/Segmentation/index.d.ts +44 -0
  48. package/dist/components/SpriteAnimation/index.d.ts +52 -0
  49. package/dist/components/TextLabel/index.d.ts +62 -0
  50. package/dist/components/TrackingAnchor/index.d.ts +74 -0
  51. package/dist/components/VideoBackground/index.d.ts +38 -0
  52. package/dist/components/XRCompositor/index.d.ts +5 -0
  53. package/dist/components/XRDebugView/index.d.ts +6 -0
  54. package/dist/components/XRLayer/index.d.ts +6 -0
  55. package/dist/components/XRMediaSurface/index.d.ts +27 -0
  56. package/dist/components/XRProvider/index.d.ts +13 -0
  57. package/dist/components/XRScene/defaults.d.ts +4 -0
  58. package/dist/components/XRScene/index.d.ts +15 -0
  59. package/dist/components/XRViewport/index.d.ts +101 -0
  60. package/dist/components/index.d.ts +26 -0
  61. package/dist/config/index.d.ts +8 -0
  62. package/dist/constants/index.d.ts +25 -0
  63. package/dist/constants/renderLayers.d.ts +25 -0
  64. package/dist/entries/all.d.ts +15 -0
  65. package/dist/entries/core.d.ts +21 -0
  66. package/dist/entries/face-effects.d.ts +19 -0
  67. package/dist/entries/internal.d.ts +16 -0
  68. package/dist/entries/low-level.d.ts +30 -0
  69. package/dist/entries/tracking.d.ts +15 -0
  70. package/dist/face-effects.cjs +252 -0
  71. package/dist/face-effects.js +3542 -0
  72. package/dist/hasFullUnitUVBounds-BGvcFsQM.js +26 -0
  73. package/dist/hasFullUnitUVBounds-p1Dl0ejX.cjs +1 -0
  74. package/dist/hooks/faceResults.d.ts +39 -0
  75. package/dist/hooks/selectors.d.ts +33 -0
  76. package/dist/hooks/useCalibrationFaceTracker.d.ts +23 -0
  77. package/dist/hooks/useDebugger/index.d.ts +25 -0
  78. package/dist/hooks/useDebugger/types.d.ts +20 -0
  79. package/dist/hooks/useFaceBoundingBox.d.ts +11 -0
  80. package/dist/hooks/useFaceResults.d.ts +31 -0
  81. package/dist/hooks/useGestureEdge.d.ts +53 -0
  82. package/dist/hooks/useMediaRecorder.d.ts +40 -0
  83. package/dist/hooks/useTrackerContext.d.ts +35 -0
  84. package/dist/hooks/useXRModel.d.ts +15 -0
  85. package/dist/hooks/useXRSession/constants.d.ts +4 -0
  86. package/dist/hooks/useXRSession/facade.d.ts +39 -0
  87. package/dist/hooks/useXRSession/fns.d.ts +5 -0
  88. package/dist/hooks/useXRSession/index.d.ts +4 -0
  89. package/dist/hooks/useXRSession/registry.d.ts +52 -0
  90. package/dist/hooks/useXRSession/store.d.ts +40 -0
  91. package/dist/index-B5J4gzn2.cjs +1 -0
  92. package/dist/index-BD-JWMjE.js +1991 -0
  93. package/dist/index-BVBVg96G.cjs +1 -0
  94. package/dist/index-CYMj26Ej.js +1331 -0
  95. package/dist/index-DtwHElmG.js +157 -0
  96. package/dist/index-PtFmD6B8.cjs +1 -0
  97. package/dist/internal-DH5d1Xnq.cjs +1 -0
  98. package/dist/internal-KOKJDxCG.js +519 -0
  99. package/dist/internal.cjs +1 -0
  100. package/dist/internal.js +14 -0
  101. package/dist/low-level.cjs +1 -0
  102. package/dist/low-level.js +941 -0
  103. package/dist/main.cjs +1 -0
  104. package/dist/main.js +612 -0
  105. package/dist/models/Base/index.d.ts +25 -0
  106. package/dist/models/Body/index.d.ts +22 -0
  107. package/dist/models/Face/constants.d.ts +2 -0
  108. package/dist/models/Face/index.d.ts +45 -0
  109. package/dist/models/Face/landmarksData.d.ts +2 -0
  110. package/dist/models/Hand/GestureTracking.d.ts +21 -0
  111. package/dist/models/Hand/HandTracking.d.ts +21 -0
  112. package/dist/models/Segmentation/index.d.ts +75 -0
  113. package/dist/models/index.d.ts +5 -0
  114. package/dist/modules/XRClient/index.d.ts +9 -0
  115. package/dist/modules/index.d.ts +1 -0
  116. package/dist/selectors-BHO6TnoC.js +59 -0
  117. package/dist/selectors-Bub0o3qy.cjs +1 -0
  118. package/dist/services/ApiService.d.ts +12 -0
  119. package/dist/services/MetricsCollector/CameraFPSTracker.d.ts +25 -0
  120. package/dist/services/MetricsCollector/MemoryTracker.d.ts +43 -0
  121. package/dist/services/MetricsCollector/RenderTimeTracker.d.ts +10 -0
  122. package/dist/services/MetricsCollector/ResolutionTracker.d.ts +26 -0
  123. package/dist/services/MetricsCollector/index.d.ts +59 -0
  124. package/dist/services/MetricsCollector/types.d.ts +47 -0
  125. package/dist/services/MetricsCollector/utils.d.ts +65 -0
  126. package/dist/texture/computeContainScale.d.ts +25 -0
  127. package/dist/texture/hasFullUnitUVBounds.d.ts +37 -0
  128. package/dist/texture/types.d.ts +20 -0
  129. package/dist/tracking.cjs +1 -0
  130. package/dist/tracking.js +344 -0
  131. package/dist/types/body.d.ts +3 -0
  132. package/dist/types/client.d.ts +3 -0
  133. package/dist/types/common.d.ts +9 -0
  134. package/dist/types/compositor.d.ts +23 -0
  135. package/dist/types/debugger.d.ts +83 -0
  136. package/dist/types/face.d.ts +67 -0
  137. package/dist/types/gesture-tracking.d.ts +15 -0
  138. package/dist/types/hand-tracking.d.ts +5 -0
  139. package/dist/types/headBinding.d.ts +67 -0
  140. package/dist/types/index.d.ts +12 -0
  141. package/dist/types/logger.d.ts +4 -0
  142. package/dist/types/model.d.ts +46 -0
  143. package/dist/types/nodes.d.ts +35 -0
  144. package/dist/types/segmentation.d.ts +31 -0
  145. package/dist/types/session.d.ts +102 -0
  146. package/dist/types/tracking.d.ts +30 -0
  147. package/dist/types/util-types.d.ts +1 -0
  148. package/dist/useFaceResults-cpsSmKKc.js +81 -0
  149. package/dist/useFaceResults-hVUJYSEY.cjs +1 -0
  150. package/dist/utils/calibrationDebug.d.ts +9 -0
  151. package/dist/utils/dataURL.d.ts +6 -0
  152. package/dist/utils/drawMediaCover.d.ts +18 -0
  153. package/dist/utils/errors.d.ts +3 -0
  154. package/dist/utils/fns.d.ts +48 -0
  155. package/dist/utils/headBinding.d.ts +85 -0
  156. package/dist/utils/integrity.d.ts +43 -0
  157. package/dist/utils/landmarkBounds.d.ts +11 -0
  158. package/dist/utils/logger.d.ts +7 -0
  159. package/package.json +113 -0
@@ -0,0 +1,3542 @@
1
+ import * as R from "three";
2
+ import { TrianglesDrawMode as $t, TriangleFanDrawMode as tt, TriangleStripDrawMode as _t, Loader as Jt, LoaderUtils as xe, FileLoader as Lt, MeshPhysicalMaterial as X, Vector2 as It, Color as se, LinearSRGBColorSpace as V, SRGBColorSpace as ve, SpotLight as en, PointLight as tn, DirectionalLight as nn, Matrix4 as Ne, Vector3 as te, Quaternion as Ct, InstancedMesh as sn, InstancedBufferAttribute as rn, Object3D as Nt, TextureLoader as on, ImageBitmapLoader as an, BufferAttribute as He, InterleavedBuffer as cn, InterleavedBufferAttribute as ln, LinearMipmapLinearFilter as Pt, NearestMipmapLinearFilter as un, LinearMipmapNearestFilter as hn, NearestMipmapNearestFilter as dn, LinearFilter as nt, NearestFilter as Ft, RepeatWrapping as st, MirroredRepeatWrapping as fn, ClampToEdgeWrapping as pn, PointsMaterial as mn, Material as je, LineBasicMaterial as gn, MeshStandardMaterial as Ot, DoubleSide as Ie, MeshBasicMaterial as Te, PropertyBinding as An, BufferGeometry as Tn, SkinnedMesh as xn, Mesh as vn, LineSegments as bn, Line as En, LineLoop as Rn, Points as Mn, Group as Xe, PerspectiveCamera as wn, MathUtils as Sn, OrthographicCamera as yn, Skeleton as _n, AnimationClip as Ln, Bone as In, InterpolateDiscrete as Cn, InterpolateLinear as Dt, Texture as ft, VectorKeyframeTrack as pt, NumberKeyframeTrack as mt, QuaternionKeyframeTrack as gt, ColorManagement as At, FrontSide as Nn, Interpolant as Pn, Box3 as Fn, Sphere as On, Euler as Dn } from "three";
3
+ import { jsxs as w, Fragment as rt, jsx as T } from "react/jsx-runtime";
4
+ import { useThree as kt, useLoader as Ke, useFrame as kn } from "@react-three/fiber";
5
+ import { useState as at, useEffect as $, useMemo as j, useRef as N } from "react";
6
+ import { l as Pe, f as Bt, X as Bn } from "./index-CYMj26Ej.js";
7
+ import { a as Un, u as Ut } from "./selectors-BHO6TnoC.js";
8
+ import { p as Gn, F as Hn, b as jn } from "./index-BD-JWMjE.js";
9
+ import { Text as Ye } from "@react-three/drei";
10
+ const Tt = {
11
+ normal: 0,
12
+ add: 1,
13
+ subtract: 2,
14
+ multiply: 3,
15
+ screen: 4,
16
+ overlay: 5,
17
+ softLight: 6,
18
+ hardLight: 7,
19
+ lighten: 8,
20
+ darken: 9,
21
+ difference: 10,
22
+ exclusion: 11
23
+ }, Ve = /* @__PURE__ */ new Set([
24
+ 61,
25
+ 146,
26
+ 91,
27
+ 181,
28
+ 84,
29
+ 17,
30
+ 314,
31
+ 405,
32
+ 321,
33
+ 375,
34
+ 291,
35
+ 78,
36
+ 95,
37
+ 88,
38
+ 178,
39
+ 87,
40
+ 14,
41
+ 317,
42
+ 402,
43
+ 318,
44
+ 324,
45
+ 308,
46
+ 191,
47
+ 80,
48
+ 81,
49
+ 82,
50
+ 13,
51
+ 312,
52
+ 311,
53
+ 310,
54
+ 415
55
+ ]), We = /* @__PURE__ */ new Set([
56
+ 33,
57
+ 7,
58
+ 163,
59
+ 144,
60
+ 145,
61
+ 153,
62
+ 154,
63
+ 155,
64
+ 133,
65
+ 173,
66
+ 157,
67
+ 158,
68
+ 159,
69
+ 160,
70
+ 161,
71
+ 246
72
+ ]), ze = /* @__PURE__ */ new Set([
73
+ 362,
74
+ 382,
75
+ 381,
76
+ 380,
77
+ 374,
78
+ 373,
79
+ 390,
80
+ 249,
81
+ 263,
82
+ 466,
83
+ 388,
84
+ 387,
85
+ 386,
86
+ 385,
87
+ 384,
88
+ 398
89
+ ]), Xn = /* @__PURE__ */ new Set([814, 815, 816, 817, 818, 819, 830, 831, 832, 833]), Kn = (i, e, t) => {
90
+ const s = Ve.has(i) && Ve.has(e) && Ve.has(t), n = We.has(i) && We.has(e) && We.has(t), r = ze.has(i) && ze.has(e) && ze.has(t);
91
+ return s ? "mouth" : n || r ? "eye" : "base";
92
+ }, Yn = (i) => {
93
+ const e = [], t = [], s = [], n = [], r = [], o = [];
94
+ let c = 0, a = 0;
95
+ i.split(`
96
+ `).forEach((u) => {
97
+ const h = u.trim();
98
+ if (!h) return;
99
+ if (h.startsWith("v ")) {
100
+ c += 1;
101
+ return;
102
+ }
103
+ if (h.startsWith("vt ")) {
104
+ const [, A, m] = h.split(/\s+/);
105
+ r.push([Number(A), Number(m)]);
106
+ return;
107
+ }
108
+ if (!h.startsWith("f ")) return;
109
+ const d = a;
110
+ a += 1;
111
+ const [, ...p] = h.split(/\s+/), g = p.map((A) => {
112
+ const [m, f] = A.split("/"), x = Number(m) - 1, v = Number(f) - 1;
113
+ return v >= 0 && r[v] && !o[x] && (o[x] = r[v]), x;
114
+ });
115
+ if (!(g.length < 3))
116
+ for (let A = 1; A < g.length - 1; A += 1) {
117
+ const m = g[0], f = g[A], x = g[A + 1], v = Kn(m, f, x);
118
+ Xn.has(d) ? n.push(m, f, x) : v === "mouth" ? t.push(m, f, x) : v === "eye" ? s.push(m, f, x) : e.push(m, f, x);
119
+ }
120
+ });
121
+ const l = [];
122
+ for (let u = 0; u < c; u += 1) {
123
+ const [h, d] = o[u] ?? [0, 0];
124
+ l.push(h, d);
125
+ }
126
+ return {
127
+ baseIndices: new Uint16Array(e),
128
+ mouthIndices: new Uint16Array(t),
129
+ eyeIndices: new Uint16Array(s),
130
+ noseIndices: new Uint16Array(n),
131
+ uvs: new Float32Array(l),
132
+ vertexCount: c
133
+ };
134
+ }, Vn = "canonical_face_model.obj", Wn = new TextDecoder("utf-8"), qe = /* @__PURE__ */ new Map(), zn = (i) => {
135
+ const e = qe.get(i);
136
+ if (e) return e;
137
+ const t = Bt(i).then((s) => Yn(Wn.decode(s))).catch((s) => {
138
+ throw qe.delete(i), s;
139
+ });
140
+ return qe.set(i, t), t;
141
+ }, qn = (i) => {
142
+ const { mesh: e, url: t } = i ?? {}, s = t ?? `${Pe.sdkAssetsBaseUrl}/${Vn}`, [n, r] = at(e ?? null);
143
+ return $(() => {
144
+ if (e) {
145
+ r(e);
146
+ return;
147
+ }
148
+ let o = !1;
149
+ return zn(s).then((c) => {
150
+ o || r(c);
151
+ }).catch((c) => {
152
+ o || console.error(`${Pe.loggerPrefix} canonical face mesh load failed`, c);
153
+ }), () => {
154
+ o = !0;
155
+ };
156
+ }, [e, s]), n;
157
+ }, Zn = {
158
+ front: R.FrontSide,
159
+ back: R.BackSide,
160
+ double: R.DoubleSide
161
+ }, Qn = `
162
+ attribute vec2 faceUv;
163
+ varying vec2 vUv;
164
+ varying vec2 vFaceUv;
165
+ varying vec3 vNormal;
166
+
167
+ void main() {
168
+ vUv = uv;
169
+ vFaceUv = faceUv;
170
+ vNormal = normalize(normalMatrix * normal);
171
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
172
+ }
173
+ `, $n = `
174
+ uniform sampler2D cameraTexture;
175
+ uniform sampler2D canonicalTexture;
176
+ uniform sampler2D alphaMask;
177
+ uniform vec3 textureTint;
178
+ uniform float opacity;
179
+ uniform float blendMode;
180
+ uniform float useCanonicalTexture;
181
+ uniform float useAlphaMask;
182
+ uniform float alphaOpacity;
183
+ uniform float compositeShading;
184
+ uniform vec3 lightDirection;
185
+ uniform float ambientStrength;
186
+ uniform float directionalStrength;
187
+ varying vec2 vUv;
188
+ varying vec2 vFaceUv;
189
+ varying vec3 vNormal;
190
+
191
+ vec3 linearToSrgb(vec3 value) {
192
+ vec3 low = value * 12.92;
193
+ vec3 high = 1.055 * pow(max(value, vec3(0.0)), vec3(1.0 / 2.4)) - 0.055;
194
+ return mix(high, low, step(value, vec3(0.0031308)));
195
+ }
196
+
197
+ vec3 srgbToLinear(vec3 value) {
198
+ vec3 low = value / 12.92;
199
+ vec3 high = pow(max((value + 0.055) / 1.055, vec3(0.0)), vec3(2.4));
200
+ return mix(high, low, step(value, vec3(0.04045)));
201
+ }
202
+
203
+ float overlayChannel(float base, float blend) {
204
+ return base < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
205
+ }
206
+
207
+ float hardLightChannel(float base, float blend) {
208
+ return blend < 0.5 ? 2.0 * base * blend : 1.0 - 2.0 * (1.0 - base) * (1.0 - blend);
209
+ }
210
+
211
+ float softLightChannel(float base, float blend) {
212
+ if (blend <= 0.5) {
213
+ return base - (1.0 - 2.0 * blend) * base * (1.0 - base);
214
+ }
215
+
216
+ float d = base <= 0.25
217
+ ? ((16.0 * base - 12.0) * base + 4.0) * base
218
+ : sqrt(base);
219
+
220
+ return base + (2.0 * blend - 1.0) * (d - base);
221
+ }
222
+
223
+ vec3 applyBlendMode(vec3 base, vec3 blend, float mode) {
224
+ if (mode < 0.5) return blend;
225
+ if (mode < 1.5) return min(base + blend, 1.0);
226
+ if (mode < 2.5) return max(base - blend, 0.0);
227
+ if (mode < 3.5) return base * blend;
228
+ if (mode < 4.5) return 1.0 - (1.0 - base) * (1.0 - blend);
229
+ if (mode < 5.5) {
230
+ return vec3(
231
+ overlayChannel(base.r, blend.r),
232
+ overlayChannel(base.g, blend.g),
233
+ overlayChannel(base.b, blend.b)
234
+ );
235
+ }
236
+ if (mode < 6.5) {
237
+ return vec3(
238
+ softLightChannel(base.r, blend.r),
239
+ softLightChannel(base.g, blend.g),
240
+ softLightChannel(base.b, blend.b)
241
+ );
242
+ }
243
+ if (mode < 7.5) {
244
+ return vec3(
245
+ hardLightChannel(base.r, blend.r),
246
+ hardLightChannel(base.g, blend.g),
247
+ hardLightChannel(base.b, blend.b)
248
+ );
249
+ }
250
+ if (mode < 8.5) return max(base, blend);
251
+ if (mode < 9.5) return min(base, blend);
252
+ if (mode < 10.5) return abs(base - blend);
253
+ return base + blend - 2.0 * base * blend;
254
+ }
255
+
256
+ void main() {
257
+ vec3 base = linearToSrgb(texture2D(cameraTexture, vFaceUv).rgb);
258
+ vec4 textureSample = texture2D(canonicalTexture, vUv);
259
+ vec3 blend = linearToSrgb(textureSample.rgb) * textureTint;
260
+ float light = ambientStrength + max(dot(normalize(vNormal), normalize(lightDirection)), 0.0) * directionalStrength;
261
+ blend *= mix(1.0, clamp(light, 0.35, 1.35), compositeShading);
262
+ float maskSample = texture2D(alphaMask, vUv).r;
263
+ float mask = useAlphaMask > 0.5 ? mix(1.0, maskSample, alphaOpacity) : 1.0;
264
+ float textureAlpha = useCanonicalTexture > 0.5 ? textureSample.a : 1.0;
265
+ vec3 color = useCanonicalTexture > 0.5 ? applyBlendMode(base, blend, blendMode) : base;
266
+ gl_FragColor = vec4(srgbToLinear(color), opacity * mask * textureAlpha);
267
+ }
268
+ `, Jn = `
269
+ varying vec2 vUv;
270
+ varying vec3 vNormal;
271
+
272
+ void main() {
273
+ vUv = uv;
274
+ vNormal = normalize(normalMatrix * normal);
275
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
276
+ }
277
+ `, es = `
278
+ uniform vec3 color;
279
+ uniform float opacity;
280
+ varying vec3 vNormal;
281
+
282
+ void main() {
283
+ vec3 normalTint = 0.5 + 0.5 * normalize(vNormal);
284
+ vec3 base = color * mix(vec3(1.0), normalTint, 0.35);
285
+
286
+ gl_FragColor = vec4(base, opacity);
287
+ }
288
+ `, ts = () => {
289
+ const i = new Uint8Array([
290
+ 32,
291
+ 32,
292
+ 32,
293
+ 255,
294
+ 96,
295
+ 96,
296
+ 96,
297
+ 255,
298
+ 176,
299
+ 176,
300
+ 176,
301
+ 255,
302
+ 255,
303
+ 255,
304
+ 255,
305
+ 255
306
+ ]), e = new R.DataTexture(i, 4, 1, R.RGBAFormat);
307
+ return e.minFilter = R.NearestFilter, e.magFilter = R.NearestFilter, e.generateMipmaps = !1, e.needsUpdate = !0, e;
308
+ }, ns = () => {
309
+ const i = document.createElement("canvas");
310
+ i.width = 256, i.height = 256;
311
+ const e = i.getContext("2d");
312
+ if (!e)
313
+ return new R.CanvasTexture(i);
314
+ const t = e.createRadialGradient(96, 80, 10, 128, 128, 128);
315
+ t.addColorStop(0, "#ffffff"), t.addColorStop(0.18, "#f7d794"), t.addColorStop(0.45, "#d97706"), t.addColorStop(0.72, "#78350f"), t.addColorStop(1, "#120701"), e.fillStyle = t, e.fillRect(0, 0, i.width, i.height);
316
+ const s = new R.CanvasTexture(i);
317
+ return s.needsUpdate = !0, s;
318
+ }, Cr = ({
319
+ faceIndex: i = 0,
320
+ color: e = "#38bdf8",
321
+ opacity: t = 0.45,
322
+ materialType: s = "basic",
323
+ shaderPreset: n = "basicShader",
324
+ textureMap: r = "none",
325
+ alphaMap: o = "none",
326
+ alphaOpacity: c = 0,
327
+ side: a = "front",
328
+ blendMode: l = "normal",
329
+ showMouthMask: u = !0,
330
+ showEyeMask: h = !0,
331
+ showNoseMask: d = !0,
332
+ maskTextureSource: p = "none",
333
+ maskColor: g = "#111111",
334
+ maskOpacity: A = 0,
335
+ faceTextureUrl: m = "",
336
+ faceTextureStyle2Url: f = "",
337
+ faceAlphaMaskUrl: x = "",
338
+ compositeShading: v = !1,
339
+ mesh: b,
340
+ meshUrl: y
341
+ }) => {
342
+ const L = Un(Bn.FACE_TRACKER), _ = Ut(), { camera: D } = kt(), M = qn({ mesh: b, url: y }), P = Ke(R.TextureLoader, m || "/placeholder.png"), re = Ke(
343
+ R.TextureLoader,
344
+ f || m || "/placeholder.png"
345
+ ), I = Ke(R.TextureLoader, x || "/placeholder.png"), W = j(() => ts(), []), S = j(() => ns(), []), oe = N(null), z = N(null), q = N(null), ue = N(null), he = N(null), de = N(null), fe = N(null), ie = N(null), ae = N(null), pe = N(null), me = N(null), be = N(null), qt = N(new R.Vector3()), Ee = N(!1), J = Zn[a], ce = {
346
+ side: J,
347
+ transparent: !0,
348
+ opacity: t,
349
+ wireframe: !1
350
+ }, Fe = r === "style2" ? re : P, ge = r !== "none", Re = j(
351
+ () => ({
352
+ color: { value: new R.Color(e) },
353
+ opacity: { value: t }
354
+ }),
355
+ []
356
+ ), F = j(
357
+ () => ({
358
+ cameraTexture: { value: null },
359
+ canonicalTexture: { value: null },
360
+ alphaMask: { value: null },
361
+ textureTint: { value: new R.Color(e) },
362
+ opacity: { value: t },
363
+ blendMode: { value: Tt[l] },
364
+ useCanonicalTexture: { value: ge ? 1 : 0 },
365
+ useAlphaMask: { value: o === "canonical" ? 1 : 0 },
366
+ alphaOpacity: { value: c },
367
+ compositeShading: { value: v ? 1 : 0 },
368
+ lightDirection: { value: new R.Vector3(0.3, 0.65, 0.7).normalize() },
369
+ ambientStrength: { value: 0.78 },
370
+ directionalStrength: { value: 0.38 }
371
+ }),
372
+ []
373
+ );
374
+ $(() => {
375
+ Re.color.value.set(e), Re.opacity.value = t;
376
+ }, [e, t, Re]), $(() => {
377
+ F.cameraTexture.value = _ ?? P, F.canonicalTexture.value = Fe, F.alphaMask.value = I, F.textureTint.value.set(e), F.opacity.value = t, F.blendMode.value = Tt[l], F.useCanonicalTexture.value = ge ? 1 : 0, F.useAlphaMask.value = o === "canonical" ? 1 : 0, F.alphaOpacity.value = c, F.compositeShading.value = v ? 1 : 0;
378
+ }, [
379
+ o,
380
+ I,
381
+ c,
382
+ l,
383
+ _,
384
+ e,
385
+ v,
386
+ F,
387
+ P,
388
+ ge,
389
+ t,
390
+ Fe,
391
+ r
392
+ ]);
393
+ const Me = (C) => {
394
+ if (C)
395
+ return p === "canonical" ? /* @__PURE__ */ T(
396
+ "meshBasicMaterial",
397
+ {
398
+ color: g,
399
+ alphaMap: I,
400
+ transparent: !0,
401
+ opacity: A,
402
+ side: J,
403
+ depthWrite: !1,
404
+ depthTest: !1,
405
+ toneMapped: !1
406
+ },
407
+ "masked-canonical-material"
408
+ ) : /* @__PURE__ */ T(
409
+ "meshBasicMaterial",
410
+ {
411
+ color: g,
412
+ transparent: !0,
413
+ opacity: A,
414
+ side: J,
415
+ depthWrite: !1,
416
+ depthTest: !1,
417
+ toneMapped: !1
418
+ },
419
+ "masked-solid-material"
420
+ );
421
+ if (s === "wireframe")
422
+ return /* @__PURE__ */ T(
423
+ "meshBasicMaterial",
424
+ {
425
+ color: e,
426
+ transparent: !0,
427
+ opacity: t,
428
+ side: J,
429
+ depthWrite: !1,
430
+ depthTest: !1,
431
+ wireframe: !0,
432
+ toneMapped: !1
433
+ },
434
+ "wireframe-material"
435
+ );
436
+ if (s === "shader" && _ && (n === "originalFace" || n === "composite" && r === "none"))
437
+ return /* @__PURE__ */ T(
438
+ "meshBasicMaterial",
439
+ {
440
+ map: _,
441
+ alphaMap: I,
442
+ transparent: !0,
443
+ opacity: t,
444
+ side: J,
445
+ depthWrite: !1,
446
+ depthTest: !0,
447
+ toneMapped: !1
448
+ },
449
+ "use-original-face-material"
450
+ );
451
+ if (s === "shader" && n === "composite" && ge && _)
452
+ return /* @__PURE__ */ T(
453
+ "shaderMaterial",
454
+ {
455
+ uniforms: F,
456
+ vertexShader: Qn,
457
+ fragmentShader: $n,
458
+ transparent: !0,
459
+ side: J,
460
+ depthWrite: !1,
461
+ depthTest: !0,
462
+ toneMapped: !1
463
+ },
464
+ "composite-material"
465
+ );
466
+ const k = ge ? Fe : null, B = o === "canonical" && c > 0 ? I : null, U = `${s}-${r}-${o}-${c > 0 ? "alpha-on" : "alpha-off"}`;
467
+ return s === "standard" ? /* @__PURE__ */ T(
468
+ "meshStandardMaterial",
469
+ {
470
+ ...ce,
471
+ color: e,
472
+ map: k ?? void 0,
473
+ alphaMap: B ?? void 0,
474
+ depthWrite: !0,
475
+ depthTest: !0,
476
+ metalness: 0.05,
477
+ roughness: 0.72
478
+ },
479
+ U
480
+ ) : s === "physical" ? /* @__PURE__ */ T(
481
+ "meshPhysicalMaterial",
482
+ {
483
+ ...ce,
484
+ color: e,
485
+ map: k ?? void 0,
486
+ alphaMap: B ?? void 0,
487
+ depthWrite: !0,
488
+ depthTest: !0,
489
+ roughness: 0.58,
490
+ metalness: 0.08,
491
+ clearcoat: 0.35,
492
+ clearcoatRoughness: 0.4
493
+ },
494
+ U
495
+ ) : s === "toon" ? /* @__PURE__ */ T(
496
+ "meshToonMaterial",
497
+ {
498
+ ...ce,
499
+ color: e,
500
+ map: k ?? void 0,
501
+ alphaMap: B ?? void 0,
502
+ gradientMap: W,
503
+ depthWrite: !0,
504
+ depthTest: !0
505
+ },
506
+ U
507
+ ) : s === "normal" ? /* @__PURE__ */ T(
508
+ "meshNormalMaterial",
509
+ {
510
+ ...ce,
511
+ depthWrite: !0,
512
+ depthTest: !0,
513
+ flatShading: !1
514
+ },
515
+ "normal-material"
516
+ ) : s === "matcap" ? /* @__PURE__ */ T(
517
+ "meshMatcapMaterial",
518
+ {
519
+ ...ce,
520
+ color: e,
521
+ matcap: S,
522
+ depthWrite: !0,
523
+ depthTest: !0
524
+ },
525
+ "matcap-material"
526
+ ) : s === "shader" ? /* @__PURE__ */ T(
527
+ "shaderMaterial",
528
+ {
529
+ uniforms: Re,
530
+ vertexShader: Jn,
531
+ fragmentShader: es,
532
+ transparent: !0,
533
+ side: J,
534
+ depthWrite: !1,
535
+ depthTest: !0,
536
+ toneMapped: !1
537
+ },
538
+ "generic-shader-material"
539
+ ) : /* @__PURE__ */ T(
540
+ "meshBasicMaterial",
541
+ {
542
+ ...ce,
543
+ color: e,
544
+ map: k ?? void 0,
545
+ alphaMap: B ?? void 0,
546
+ depthWrite: !1,
547
+ depthTest: r !== "none" || o !== "none",
548
+ toneMapped: !1
549
+ },
550
+ U
551
+ );
552
+ }, Zt = (C) => Gn(C, D, qt.current);
553
+ return kn(() => {
554
+ var ht, dt;
555
+ const C = oe.current, k = z.current, B = q.current, U = ue.current, Oe = he.current, De = de.current, ke = fe.current, Be = ie.current, we = (dt = (ht = L == null ? void 0 : L.detectionResults) == null ? void 0 : ht.faceLandmarks) == null ? void 0 : dt[i];
556
+ if (!M || !C || !k || !B || !U || !Oe || !De || !ke || !Be)
557
+ return;
558
+ if (!we || we.length < M.vertexCount) {
559
+ Oe.visible = !1, De.visible = !1, ke.visible = !1, Be.visible = !1;
560
+ return;
561
+ }
562
+ if (be.current !== M) {
563
+ ae.current = new Float32Array(M.vertexCount * 3), pe.current = new Float32Array(M.uvs), me.current = new Float32Array(M.vertexCount * 2);
564
+ const H = new R.BufferAttribute(ae.current, 3), G = new R.BufferAttribute(pe.current, 2), Z = new R.BufferAttribute(me.current, 2);
565
+ C.setAttribute("position", H), C.setAttribute("uv", G), C.setAttribute("faceUv", Z), C.setIndex(new R.BufferAttribute(M.baseIndices, 1)), k.setAttribute("position", H), k.setAttribute("uv", G), k.setAttribute("faceUv", Z), k.setIndex(new R.BufferAttribute(M.mouthIndices, 1)), B.setAttribute("position", H), B.setAttribute("uv", G), B.setAttribute("faceUv", Z), B.setIndex(new R.BufferAttribute(M.eyeIndices, 1)), U.setAttribute("position", H), U.setAttribute("uv", G), U.setAttribute("faceUv", Z), U.setIndex(new R.BufferAttribute(M.noseIndices, 1)), G.needsUpdate = !0, be.current = M, Ee.current = !1;
566
+ }
567
+ const Se = ae.current, Ue = me.current, ye = pe.current;
568
+ if (!Se || !Ue || !ye) return;
569
+ const ut = s === "shader" && (n === "originalFace" || n === "composite" && r === "none"), Qt = Math.min(we.length, M.vertexCount);
570
+ for (let H = 0; H < Qt; H++) {
571
+ const G = we[H], Z = H * 3, _e = H * 2, Ge = Zt(G);
572
+ Se[Z] = Ge.x, Se[Z + 1] = Ge.y, Se[Z + 2] = Ge.z, Ue[_e] = G.x, Ue[_e + 1] = 1 - G.y, ut && (ye[_e] = G.x, ye[_e + 1] = 1 - G.y);
573
+ }
574
+ ut ? (C.attributes.uv.needsUpdate = !0, Ee.current = !0) : Ee.current && (ye.set(M.uvs), C.attributes.uv.needsUpdate = !0, Ee.current = !1), Oe.visible = !0, De.visible = !0, ke.visible = !0, Be.visible = !0, C.attributes.position.needsUpdate = !0, C.attributes.faceUv.needsUpdate = !0, C.computeVertexNormals(), k.computeVertexNormals(), B.computeVertexNormals(), U.computeVertexNormals();
575
+ }), /* @__PURE__ */ w(rt, { children: [
576
+ /* @__PURE__ */ w("mesh", { ref: he, renderOrder: 10, frustumCulled: !1, children: [
577
+ /* @__PURE__ */ T("bufferGeometry", { ref: oe }),
578
+ Me(!1)
579
+ ] }),
580
+ /* @__PURE__ */ w("mesh", { ref: de, renderOrder: 12, frustumCulled: !1, children: [
581
+ /* @__PURE__ */ T("bufferGeometry", { ref: z }),
582
+ Me(u)
583
+ ] }),
584
+ /* @__PURE__ */ w("mesh", { ref: fe, renderOrder: 12, frustumCulled: !1, children: [
585
+ /* @__PURE__ */ T("bufferGeometry", { ref: q }),
586
+ Me(h)
587
+ ] }),
588
+ /* @__PURE__ */ w("mesh", { ref: ie, renderOrder: 12, frustumCulled: !1, children: [
589
+ /* @__PURE__ */ T("bufferGeometry", { ref: ue }),
590
+ Me(d)
591
+ ] })
592
+ ] });
593
+ }, Nr = {
594
+ materialType: "basic",
595
+ shaderPreset: "basicShader",
596
+ textureMap: "none",
597
+ alphaMap: "none",
598
+ alphaOpacity: 1,
599
+ side: "front",
600
+ blendMode: "normal",
601
+ baseColor: "#38bdf8",
602
+ opacity: 0.45
603
+ }, Pr = {
604
+ mouth: !0,
605
+ eyes: !0,
606
+ nose: !0
607
+ }, Fr = [
608
+ { label: "Wireframe", value: "wireframe" },
609
+ { label: "Basic", value: "basic" },
610
+ { label: "Standard", value: "standard" },
611
+ { label: "Physical", value: "physical" },
612
+ { label: "Toon", value: "toon" },
613
+ { label: "Normal", value: "normal" },
614
+ { label: "Matcap", value: "matcap" },
615
+ { label: "Shader", value: "shader" }
616
+ ], Or = [
617
+ { label: "Basic Shader", value: "basicShader" },
618
+ { label: "Original Face", value: "originalFace" },
619
+ { label: "Composite", value: "composite" }
620
+ ], Dr = [
621
+ { label: "Front", value: "front" },
622
+ { label: "Back", value: "back" },
623
+ { label: "Double", value: "double" }
624
+ ], kr = [
625
+ { label: "None", value: "none" },
626
+ { label: "UV Map 1", value: "canonical" },
627
+ { label: "UV Map 2", value: "style2" }
628
+ ], Br = [
629
+ { label: "None", value: "none" },
630
+ { label: "Default Mask", value: "canonical" }
631
+ ], Ur = [
632
+ { label: "Normal", value: "normal" },
633
+ { label: "Add", value: "add" },
634
+ { label: "Subtract", value: "subtract" },
635
+ { label: "Multiply", value: "multiply" },
636
+ { label: "Screen", value: "screen" },
637
+ { label: "Overlay", value: "overlay" },
638
+ { label: "Soft Light", value: "softLight" },
639
+ { label: "Hard Light", value: "hardLight" },
640
+ { label: "Lighten", value: "lighten" },
641
+ { label: "Darken", value: "darken" },
642
+ { label: "Difference", value: "difference" },
643
+ { label: "Exclusion", value: "exclusion" }
644
+ ], Gr = (i, e) => i === "basic" || i === "standard" || i === "physical" || i === "toon" || i === "shader" && e === "composite", Hr = (i, e) => i === "shader" && e === "composite", ss = `
645
+ varying vec2 vUv;
646
+
647
+ void main() {
648
+ vUv = uv;
649
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
650
+ }
651
+ `, rs = `
652
+ uniform sampler2D cameraTexture;
653
+ uniform sampler2D retouchMaskTexture;
654
+ uniform sampler2D mouthMaskTexture;
655
+ uniform vec2 texelSize;
656
+ uniform float retouchAmount;
657
+ uniform float blurRadius;
658
+ uniform float teethWhitening;
659
+ uniform float previewMask;
660
+ uniform float protectLandmarks;
661
+ varying vec2 vUv;
662
+
663
+ vec3 sampleCamera(vec2 uv) {
664
+ return texture2D(cameraTexture, clamp(uv, vec2(0.0), vec2(1.0))).rgb;
665
+ }
666
+
667
+ vec3 readRetouchMask(vec2 uv) {
668
+ vec4 mask = texture2D(retouchMaskTexture, uv);
669
+ float faceRegion = clamp(mask.b, 0.0, 1.0);
670
+ float softFaceRegion = min(mask.r, faceRegion);
671
+ float protectedRegion = min(mask.g, faceRegion) * protectLandmarks;
672
+ float hardProtectedRegion = step(0.08, protectedRegion);
673
+ float softRetouchRegion = softFaceRegion * (1.0 - protectedRegion);
674
+ float hardRetouchRegion = step(0.5, faceRegion) * (1.0 - hardProtectedRegion);
675
+
676
+ return vec3(
677
+ clamp(softRetouchRegion, 0.0, 1.0),
678
+ clamp(protectedRegion, 0.0, 1.0),
679
+ clamp(hardRetouchRegion, 0.0, 1.0)
680
+ );
681
+ }
682
+
683
+ float readMouthMask(vec2 uv) {
684
+ return clamp(texture2D(mouthMaskTexture, uv).r, 0.0, 1.0);
685
+ }
686
+
687
+ float retouchCoverage(vec2 uv) {
688
+ return step(0.001, readRetouchMask(uv).x);
689
+ }
690
+
691
+ void addMaskedBlurSample(inout vec3 color, inout float weightSum, vec2 centerUv, vec2 sampleUv, float weight) {
692
+ float coverage = retouchCoverage(sampleUv);
693
+ vec3 sampleColor = mix(sampleCamera(centerUv), sampleCamera(sampleUv), coverage);
694
+ color += sampleColor * weight;
695
+ weightSum += weight;
696
+ }
697
+
698
+ vec3 maskedBlurCamera(vec2 uv, float radius) {
699
+ vec2 r = texelSize * radius;
700
+ vec3 color = sampleCamera(uv) * 0.2;
701
+ float weightSum = 0.2;
702
+
703
+ addMaskedBlurSample(color, weightSum, uv, uv + vec2(r.x, 0.0), 0.1);
704
+ addMaskedBlurSample(color, weightSum, uv, uv - vec2(r.x, 0.0), 0.1);
705
+ addMaskedBlurSample(color, weightSum, uv, uv + vec2(0.0, r.y), 0.1);
706
+ addMaskedBlurSample(color, weightSum, uv, uv - vec2(0.0, r.y), 0.1);
707
+ addMaskedBlurSample(color, weightSum, uv, uv + r, 0.075);
708
+ addMaskedBlurSample(color, weightSum, uv, uv - r, 0.075);
709
+ addMaskedBlurSample(color, weightSum, uv, uv + vec2(r.x, -r.y), 0.075);
710
+ addMaskedBlurSample(color, weightSum, uv, uv + vec2(-r.x, r.y), 0.075);
711
+ addMaskedBlurSample(color, weightSum, uv, uv + r * 2.0, 0.05);
712
+ addMaskedBlurSample(color, weightSum, uv, uv - r * 2.0, 0.05);
713
+
714
+ return color / max(weightSum, 0.001);
715
+ }
716
+
717
+ vec3 whitenTeeth(vec3 color, float amount, float mouthRegion) {
718
+ float maxChannel = max(max(color.r, color.g), color.b);
719
+ float minChannel = min(min(color.r, color.g), color.b);
720
+ float saturation = maxChannel - minChannel;
721
+ float brightness = dot(color, vec3(0.299, 0.587, 0.114));
722
+ float redness = max(color.r - max(color.g, color.b), 0.0);
723
+ float greenBlueBalance = 1.0 - smoothstep(0.08, 0.24, abs(color.g - color.b));
724
+ float candidate =
725
+ smoothstep(0.34, 0.62, brightness) *
726
+ (1.0 - smoothstep(0.14, 0.32, redness)) *
727
+ (1.0 - smoothstep(0.18, 0.42, saturation)) *
728
+ greenBlueBalance;
729
+ float whiteningMask = clamp(mouthRegion * candidate, 0.0, 1.0);
730
+ vec3 desaturated = mix(color, vec3(brightness), 0.42);
731
+ vec3 brightened = min(desaturated + vec3(0.16), vec3(1.0));
732
+
733
+ return mix(color, brightened, clamp(amount * whiteningMask * 0.38, 0.0, 1.0));
734
+ }
735
+
736
+ void main() {
737
+ vec3 original = sampleCamera(vUv);
738
+ vec3 masks = readRetouchMask(vUv);
739
+ float mouthMask = readMouthMask(vUv);
740
+
741
+ if (previewMask > 0.5) {
742
+ float sharpPreview = 1.0 - step(0.001, retouchAmount + blurRadius);
743
+ float retouchPreview = mix(masks.x, masks.z, sharpPreview);
744
+ float protectedPreview = mix(masks.y, step(0.08, masks.y), sharpPreview);
745
+ float whiteningPreview = mouthMask * teethWhitening;
746
+ vec3 facePreview = vec3(retouchPreview, 0.08, 0.08);
747
+ vec3 featurePreview = vec3(0.05, protectedPreview, 0.1);
748
+ vec3 whiteningMaskPreview = vec3(whiteningPreview, whiteningPreview, 0.05);
749
+ vec3 maskPreview = max(max(facePreview, featurePreview), whiteningMaskPreview);
750
+ vec3 debugColor = mix(original * 0.18, maskPreview, max(max(retouchPreview, protectedPreview), whiteningPreview));
751
+ gl_FragColor = vec4(debugColor, 1.0);
752
+ #include <colorspace_fragment>
753
+ return;
754
+ }
755
+
756
+ float effectiveBlurRadius = min(blurRadius, 7.0);
757
+ vec3 smallBlur = maskedBlurCamera(vUv, max(0.0, effectiveBlurRadius * 0.45));
758
+ vec3 largeBlur = maskedBlurCamera(vUv, max(0.0, effectiveBlurRadius));
759
+ vec3 detail = original - smallBlur;
760
+ float detailAmount = mix(0.5, 0.9, masks.y);
761
+ vec3 smoothed = clamp(largeBlur + detail * detailAmount, 0.0, 1.0);
762
+ vec3 color = mix(original, smoothed, min(retouchAmount, 0.72) * masks.x);
763
+ color = whitenTeeth(color, teethWhitening, mouthMask);
764
+ gl_FragColor = vec4(color, 1.0);
765
+ #include <colorspace_fragment>
766
+ }
767
+ `, jr = ({
768
+ retouchMask: i,
769
+ mouthMask: e,
770
+ retouchAmount: t,
771
+ blurRadius: s,
772
+ teethWhitening: n,
773
+ previewMask: r,
774
+ protectLandmarks: o
775
+ }) => {
776
+ const { camera: c, size: a } = kt(), l = Ut(), u = j(
777
+ () => ({
778
+ cameraTexture: { value: null },
779
+ retouchMaskTexture: { value: i },
780
+ mouthMaskTexture: { value: e },
781
+ texelSize: { value: new R.Vector2(1 / 1280, 1 / 720) },
782
+ retouchAmount: { value: t },
783
+ blurRadius: { value: s },
784
+ teethWhitening: { value: n },
785
+ previewMask: { value: 0 },
786
+ protectLandmarks: { value: 1 }
787
+ }),
788
+ [e, i]
789
+ ), h = j(() => {
790
+ if (!(c instanceof R.PerspectiveCamera))
791
+ return [10, 10];
792
+ const g = (c.position.z || 5) - -1, A = R.MathUtils.degToRad(c.fov), m = 2 * Math.tan(A / 2) * g;
793
+ return [m * (a.width / a.height), m];
794
+ }, [c, a]);
795
+ return $(() => {
796
+ u.cameraTexture.value = l ?? null, u.retouchMaskTexture.value = i, u.mouthMaskTexture.value = e, u.texelSize.value.set(1 / Math.max(a.width, 1), 1 / Math.max(a.height, 1)), u.retouchAmount.value = t, u.blurRadius.value = s, u.teethWhitening.value = n, u.previewMask.value = r ? 1 : 0, u.protectLandmarks.value = o ? 1 : 0;
797
+ }, [
798
+ s,
799
+ l,
800
+ r,
801
+ o,
802
+ t,
803
+ e,
804
+ i,
805
+ n,
806
+ a.height,
807
+ a.width,
808
+ u
809
+ ]), l ? /* @__PURE__ */ T("group", { position: [0, 0, -1], children: /* @__PURE__ */ w("mesh", { renderOrder: -1e3, children: [
810
+ /* @__PURE__ */ T("planeGeometry", { args: h }),
811
+ /* @__PURE__ */ T(
812
+ "shaderMaterial",
813
+ {
814
+ uniforms: u,
815
+ vertexShader: ss,
816
+ fragmentShader: rs,
817
+ depthTest: !1,
818
+ depthWrite: !1,
819
+ toneMapped: !1
820
+ }
821
+ )
822
+ ] }) }) : null;
823
+ }, ct = 512, Gt = [
824
+ 10,
825
+ 338,
826
+ 297,
827
+ 332,
828
+ 284,
829
+ 251,
830
+ 389,
831
+ 356,
832
+ 454,
833
+ 323,
834
+ 361,
835
+ 288,
836
+ 397,
837
+ 365,
838
+ 379,
839
+ 378,
840
+ 400,
841
+ 377,
842
+ 152,
843
+ 148,
844
+ 176,
845
+ 149,
846
+ 150,
847
+ 136,
848
+ 172,
849
+ 58,
850
+ 132,
851
+ 93,
852
+ 234,
853
+ 127,
854
+ 162,
855
+ 21,
856
+ 54,
857
+ 103,
858
+ 67,
859
+ 109
860
+ ], os = [
861
+ 33,
862
+ 246,
863
+ 161,
864
+ 160,
865
+ 159,
866
+ 158,
867
+ 157,
868
+ 173,
869
+ 133,
870
+ 155,
871
+ 154,
872
+ 153,
873
+ 145,
874
+ 144,
875
+ 163,
876
+ 7
877
+ ], is = [
878
+ 362,
879
+ 398,
880
+ 384,
881
+ 385,
882
+ 386,
883
+ 387,
884
+ 388,
885
+ 466,
886
+ 263,
887
+ 249,
888
+ 390,
889
+ 373,
890
+ 374,
891
+ 380,
892
+ 381,
893
+ 382
894
+ ], as = [
895
+ 61,
896
+ 146,
897
+ 91,
898
+ 181,
899
+ 84,
900
+ 17,
901
+ 314,
902
+ 405,
903
+ 321,
904
+ 375,
905
+ 291,
906
+ 409,
907
+ 270,
908
+ 269,
909
+ 267,
910
+ 0,
911
+ 37,
912
+ 39,
913
+ 40,
914
+ 185
915
+ ], Ht = [
916
+ 78,
917
+ 95,
918
+ 88,
919
+ 178,
920
+ 87,
921
+ 14,
922
+ 317,
923
+ 402,
924
+ 318,
925
+ 324,
926
+ 308,
927
+ 415,
928
+ 310,
929
+ 311,
930
+ 312,
931
+ 13,
932
+ 82,
933
+ 81,
934
+ 80,
935
+ 191
936
+ ], cs = [70, 63, 105, 66, 107, 55, 65, 52, 53, 46], ls = [336, 296, 334, 293, 300, 276, 283, 282, 295, 285], us = [
937
+ os,
938
+ is,
939
+ as,
940
+ Ht,
941
+ cs,
942
+ ls
943
+ ], xt = (i, e, t) => {
944
+ lt(i, e, Gt, t);
945
+ }, hs = (i, e, t) => {
946
+ us.forEach((s) => lt(i, e, s, t));
947
+ }, vt = (i, e, t) => {
948
+ const s = i[e];
949
+ return s ? {
950
+ x: s.x * t,
951
+ y: s.y * t
952
+ } : null;
953
+ }, lt = (i, e, t, s) => {
954
+ const n = vt(e, t[0], s);
955
+ if (n) {
956
+ i.beginPath(), i.moveTo(n.x, n.y);
957
+ for (let r = 1; r < t.length; r += 1) {
958
+ const o = vt(e, t[r], s);
959
+ o && i.lineTo(o.x, o.y);
960
+ }
961
+ i.closePath(), i.fill();
962
+ }
963
+ }, ds = (i, e, t = ct) => {
964
+ i.clearRect(0, 0, t, t), e != null && e.length && (i.save(), i.globalCompositeOperation = "lighter", i.fillStyle = "rgb(0, 0, 255)", xt(i, e, t), i.restore(), i.save(), i.globalCompositeOperation = "lighter", i.filter = "blur(8px)", i.fillStyle = "rgb(255, 0, 0)", xt(i, e, t), i.restore(), i.save(), i.globalCompositeOperation = "lighter", i.filter = "blur(3px)", i.fillStyle = "rgb(0, 255, 0)", hs(i, e, t), i.restore());
965
+ }, fs = (i, e, t = ct) => {
966
+ i.clearRect(0, 0, t, t), e != null && e.length && (i.save(), i.filter = "blur(2px)", i.fillStyle = "rgb(255, 255, 255)", lt(i, e, Ht, t), i.restore());
967
+ }, ps = 0.1, ms = 0.48, gs = 0.012, As = 1, Ts = 1.1, xs = 1.15, vs = 0.04, bs = [
968
+ 61,
969
+ 146,
970
+ 91,
971
+ 181,
972
+ 84,
973
+ 17,
974
+ 314,
975
+ 405,
976
+ 321,
977
+ 375,
978
+ 291,
979
+ 78,
980
+ 95,
981
+ 88,
982
+ 178,
983
+ 87,
984
+ 14,
985
+ 317,
986
+ 402,
987
+ 318,
988
+ 324,
989
+ 308,
990
+ 191,
991
+ 80,
992
+ 81,
993
+ 82,
994
+ 13,
995
+ 312,
996
+ 311,
997
+ 310,
998
+ 415
999
+ ], Es = [
1000
+ 33,
1001
+ 7,
1002
+ 163,
1003
+ 144,
1004
+ 145,
1005
+ 153,
1006
+ 154,
1007
+ 155,
1008
+ 133,
1009
+ 173,
1010
+ 157,
1011
+ 158,
1012
+ 159,
1013
+ 160,
1014
+ 161,
1015
+ 246
1016
+ ], Rs = [
1017
+ 362,
1018
+ 382,
1019
+ 381,
1020
+ 380,
1021
+ 374,
1022
+ 373,
1023
+ 390,
1024
+ 249,
1025
+ 263,
1026
+ 466,
1027
+ 388,
1028
+ 387,
1029
+ 386,
1030
+ 385,
1031
+ 384,
1032
+ 398
1033
+ ], Ms = [70, 63, 105, 66, 107, 55, 65, 52, 53, 46], ws = [336, 296, 334, 293, 300, 285, 295, 282, 283, 276], Ss = [
1034
+ 1,
1035
+ 2,
1036
+ 4,
1037
+ 5,
1038
+ 6,
1039
+ 19,
1040
+ 94,
1041
+ 97,
1042
+ 98,
1043
+ 99,
1044
+ 102,
1045
+ 129,
1046
+ 168,
1047
+ 195,
1048
+ 197,
1049
+ 240,
1050
+ 279,
1051
+ 326,
1052
+ 327,
1053
+ 328,
1054
+ 331,
1055
+ 344,
1056
+ 358,
1057
+ 440
1058
+ ], ys = [
1059
+ bs,
1060
+ Es,
1061
+ Rs,
1062
+ Ms,
1063
+ ws,
1064
+ Ss
1065
+ ], _s = [
1066
+ 61,
1067
+ 91,
1068
+ 84,
1069
+ 17,
1070
+ 314,
1071
+ 321,
1072
+ 291,
1073
+ 78,
1074
+ 178,
1075
+ 14,
1076
+ 402,
1077
+ 308,
1078
+ 80,
1079
+ 13,
1080
+ 312,
1081
+ 0,
1082
+ 33,
1083
+ 144,
1084
+ 145,
1085
+ 153,
1086
+ 155,
1087
+ 133,
1088
+ 157,
1089
+ 159,
1090
+ 161,
1091
+ 246,
1092
+ 362,
1093
+ 382,
1094
+ 374,
1095
+ 373,
1096
+ 263,
1097
+ 466,
1098
+ 388,
1099
+ 386,
1100
+ 384,
1101
+ 398,
1102
+ 70,
1103
+ 105,
1104
+ 107,
1105
+ 55,
1106
+ 52,
1107
+ 46,
1108
+ 336,
1109
+ 334,
1110
+ 300,
1111
+ 285,
1112
+ 282,
1113
+ 276,
1114
+ 1,
1115
+ 4,
1116
+ 5,
1117
+ 94,
1118
+ 97,
1119
+ 98,
1120
+ 327,
1121
+ 326,
1122
+ 2,
1123
+ 195
1124
+ ], Le = (i) => Math.min(Math.max(i, 0), 1), bt = (i, e, t, s, n, r) => {
1125
+ let o = 1, c = 1, a = 0, l = 0, u = 0;
1126
+ if (e.forEach((v) => {
1127
+ const b = i[v];
1128
+ b && (o = Math.min(o, b.x), c = Math.min(c, b.y), a = Math.max(a, b.x), l = Math.max(l, b.y), u += 1);
1129
+ }), u === 0) return null;
1130
+ const h = a - o, d = l - c, p = Math.max(h * t, r), g = Math.max(d * t, r), A = Le(o - p), m = Le(c - g), f = Le(a + p), x = Le(l + g);
1131
+ return {
1132
+ centerX: (A + f) * 0.5,
1133
+ centerY: (m + x) * 0.5,
1134
+ radiusX: Math.max((f - A) * 0.5, r),
1135
+ radiusY: Math.max((x - m) * 0.5, r),
1136
+ strength: s,
1137
+ kind: n
1138
+ };
1139
+ }, Ls = (i, e, t) => i ? {
1140
+ centerX: i.x,
1141
+ centerY: i.y,
1142
+ radiusX: e,
1143
+ radiusY: e,
1144
+ strength: t,
1145
+ kind: "feature"
1146
+ } : null, Is = (i, e) => {
1147
+ if (!(i != null && i.length)) return [];
1148
+ const t = (e == null ? void 0 : e.faceOvalIndices) ?? Gt, s = (e == null ? void 0 : e.featureGroups) ?? ys, n = (e == null ? void 0 : e.featurePointIndices) ?? _s, r = (e == null ? void 0 : e.faceBoundsExpansion) ?? ps, o = (e == null ? void 0 : e.featureBoundsExpansion) ?? ms, c = (e == null ? void 0 : e.minRegionRadius) ?? gs, a = (e == null ? void 0 : e.faceRegionStrength) ?? As, l = (e == null ? void 0 : e.featureRegionStrength) ?? Ts, u = (e == null ? void 0 : e.featurePointRegionStrength) ?? xs, h = (e == null ? void 0 : e.featurePointRadiusRatio) ?? vs, d = [], p = bt(
1149
+ i,
1150
+ t,
1151
+ r,
1152
+ a,
1153
+ "face",
1154
+ c
1155
+ );
1156
+ p && d.push(p);
1157
+ const g = Math.max(
1158
+ Math.max((p == null ? void 0 : p.radiusX) ?? 0, (p == null ? void 0 : p.radiusY) ?? 0) * h,
1159
+ c * 1.35
1160
+ );
1161
+ return s.forEach((A) => {
1162
+ const m = bt(
1163
+ i,
1164
+ A,
1165
+ o,
1166
+ l,
1167
+ "feature",
1168
+ c
1169
+ );
1170
+ m && d.push(m);
1171
+ }), n.forEach((A) => {
1172
+ const m = Ls(
1173
+ i[A],
1174
+ g,
1175
+ u
1176
+ );
1177
+ m && d.push(m);
1178
+ }), d;
1179
+ }, Et = (i) => {
1180
+ const e = document.createElement("canvas");
1181
+ e.width = i, e.height = i;
1182
+ const t = e.getContext("2d", { willReadFrequently: !1 });
1183
+ if (!t) throw new Error("Unable to create face retouch mask context");
1184
+ const s = new R.CanvasTexture(e);
1185
+ return s.colorSpace = R.NoColorSpace, s.minFilter = R.LinearFilter, s.magFilter = R.LinearFilter, s.generateMipmaps = !1, s.needsUpdate = !0, { canvas: e, context: t, texture: s };
1186
+ }, Xr = (i, e = ct) => {
1187
+ const { mask: t, mouthMask: s } = j(() => ({
1188
+ mask: Et(e),
1189
+ mouthMask: Et(e)
1190
+ }), [e]);
1191
+ return $(() => {
1192
+ let n = 0;
1193
+ const r = () => {
1194
+ var c, a;
1195
+ n = requestAnimationFrame(r);
1196
+ const o = (a = (c = i == null ? void 0 : i.detectionResults) == null ? void 0 : c.faceLandmarks) == null ? void 0 : a[0];
1197
+ ds(t.context, o, e), fs(s.context, o, e), t.texture.needsUpdate = !0, s.texture.needsUpdate = !0;
1198
+ };
1199
+ return r(), () => {
1200
+ cancelAnimationFrame(n);
1201
+ };
1202
+ }, [i, t.context, t.texture, s.context, s.texture, e]), { canvas: t.canvas, texture: t.texture, mouthTexture: s.texture };
1203
+ }, Cs = (i) => i.map(
1204
+ (e) => [
1205
+ e.centerX.toFixed(4),
1206
+ e.centerY.toFixed(4),
1207
+ e.radiusX.toFixed(4),
1208
+ e.radiusY.toFixed(4),
1209
+ e.strength.toFixed(2),
1210
+ e.kind
1211
+ ].join(",")
1212
+ ).join("|"), Kr = (i, e) => {
1213
+ const [t, s] = at([]);
1214
+ return $(() => {
1215
+ let n = 0, r = "";
1216
+ const o = () => {
1217
+ var u, h;
1218
+ n = requestAnimationFrame(o);
1219
+ const c = (h = (u = i == null ? void 0 : i.detectionResults) == null ? void 0 : u.faceLandmarks) == null ? void 0 : h[0], a = Is(c, e), l = Cs(a);
1220
+ l !== r && (r = l, s(a));
1221
+ };
1222
+ return o(), () => {
1223
+ cancelAnimationFrame(n);
1224
+ };
1225
+ }, [i]), t;
1226
+ };
1227
+ function Rt(i, e) {
1228
+ if (e === $t)
1229
+ return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), i;
1230
+ if (e === tt || e === _t) {
1231
+ let t = i.getIndex();
1232
+ if (t === null) {
1233
+ const o = [], c = i.getAttribute("position");
1234
+ if (c !== void 0) {
1235
+ for (let a = 0; a < c.count; a++)
1236
+ o.push(a);
1237
+ i.setIndex(o), t = i.getIndex();
1238
+ } else
1239
+ return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), i;
1240
+ }
1241
+ const s = t.count - 2, n = [];
1242
+ if (e === tt)
1243
+ for (let o = 1; o <= s; o++)
1244
+ n.push(t.getX(0)), n.push(t.getX(o)), n.push(t.getX(o + 1));
1245
+ else
1246
+ for (let o = 0; o < s; o++)
1247
+ o % 2 === 0 ? (n.push(t.getX(o)), n.push(t.getX(o + 1)), n.push(t.getX(o + 2))) : (n.push(t.getX(o + 2)), n.push(t.getX(o + 1)), n.push(t.getX(o)));
1248
+ n.length / 3 !== s && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
1249
+ const r = i.clone();
1250
+ return r.setIndex(n), r.clearGroups(), r;
1251
+ } else
1252
+ return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", e), i;
1253
+ }
1254
+ class Ns extends Jt {
1255
+ constructor(e) {
1256
+ super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(t) {
1257
+ return new ks(t);
1258
+ }), this.register(function(t) {
1259
+ return new Bs(t);
1260
+ }), this.register(function(t) {
1261
+ return new Ws(t);
1262
+ }), this.register(function(t) {
1263
+ return new zs(t);
1264
+ }), this.register(function(t) {
1265
+ return new qs(t);
1266
+ }), this.register(function(t) {
1267
+ return new Gs(t);
1268
+ }), this.register(function(t) {
1269
+ return new Hs(t);
1270
+ }), this.register(function(t) {
1271
+ return new js(t);
1272
+ }), this.register(function(t) {
1273
+ return new Xs(t);
1274
+ }), this.register(function(t) {
1275
+ return new Ds(t);
1276
+ }), this.register(function(t) {
1277
+ return new Ks(t);
1278
+ }), this.register(function(t) {
1279
+ return new Us(t);
1280
+ }), this.register(function(t) {
1281
+ return new Vs(t);
1282
+ }), this.register(function(t) {
1283
+ return new Ys(t);
1284
+ }), this.register(function(t) {
1285
+ return new Fs(t);
1286
+ }), this.register(function(t) {
1287
+ return new Zs(t);
1288
+ }), this.register(function(t) {
1289
+ return new Qs(t);
1290
+ });
1291
+ }
1292
+ load(e, t, s, n) {
1293
+ const r = this;
1294
+ let o;
1295
+ if (this.resourcePath !== "")
1296
+ o = this.resourcePath;
1297
+ else if (this.path !== "") {
1298
+ const l = xe.extractUrlBase(e);
1299
+ o = xe.resolveURL(l, this.path);
1300
+ } else
1301
+ o = xe.extractUrlBase(e);
1302
+ this.manager.itemStart(e);
1303
+ const c = function(l) {
1304
+ n ? n(l) : console.error(l), r.manager.itemError(e), r.manager.itemEnd(e);
1305
+ }, a = new Lt(this.manager);
1306
+ a.setPath(this.path), a.setResponseType("arraybuffer"), a.setRequestHeader(this.requestHeader), a.setWithCredentials(this.withCredentials), a.load(e, function(l) {
1307
+ try {
1308
+ r.parse(l, o, function(u) {
1309
+ t(u), r.manager.itemEnd(e);
1310
+ }, c);
1311
+ } catch (u) {
1312
+ c(u);
1313
+ }
1314
+ }, s, c);
1315
+ }
1316
+ setDRACOLoader(e) {
1317
+ return this.dracoLoader = e, this;
1318
+ }
1319
+ setKTX2Loader(e) {
1320
+ return this.ktx2Loader = e, this;
1321
+ }
1322
+ setMeshoptDecoder(e) {
1323
+ return this.meshoptDecoder = e, this;
1324
+ }
1325
+ register(e) {
1326
+ return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
1327
+ }
1328
+ unregister(e) {
1329
+ return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
1330
+ }
1331
+ parse(e, t, s, n) {
1332
+ let r;
1333
+ const o = {}, c = {}, a = new TextDecoder();
1334
+ if (typeof e == "string")
1335
+ r = JSON.parse(e);
1336
+ else if (e instanceof ArrayBuffer)
1337
+ if (a.decode(new Uint8Array(e, 0, 4)) === jt) {
1338
+ try {
1339
+ o[E.KHR_BINARY_GLTF] = new $s(e);
1340
+ } catch (h) {
1341
+ n && n(h);
1342
+ return;
1343
+ }
1344
+ r = JSON.parse(o[E.KHR_BINARY_GLTF].content);
1345
+ } else
1346
+ r = JSON.parse(a.decode(e));
1347
+ else
1348
+ r = e;
1349
+ if (r.asset === void 0 || r.asset.version[0] < 2) {
1350
+ n && n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
1351
+ return;
1352
+ }
1353
+ const l = new hr(r, {
1354
+ path: t || this.resourcePath || "",
1355
+ crossOrigin: this.crossOrigin,
1356
+ requestHeader: this.requestHeader,
1357
+ manager: this.manager,
1358
+ ktx2Loader: this.ktx2Loader,
1359
+ meshoptDecoder: this.meshoptDecoder
1360
+ });
1361
+ l.fileLoader.setRequestHeader(this.requestHeader);
1362
+ for (let u = 0; u < this.pluginCallbacks.length; u++) {
1363
+ const h = this.pluginCallbacks[u](l);
1364
+ h.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), c[h.name] = h, o[h.name] = !0;
1365
+ }
1366
+ if (r.extensionsUsed)
1367
+ for (let u = 0; u < r.extensionsUsed.length; ++u) {
1368
+ const h = r.extensionsUsed[u], d = r.extensionsRequired || [];
1369
+ switch (h) {
1370
+ case E.KHR_MATERIALS_UNLIT:
1371
+ o[h] = new Os();
1372
+ break;
1373
+ case E.KHR_DRACO_MESH_COMPRESSION:
1374
+ o[h] = new Js(r, this.dracoLoader);
1375
+ break;
1376
+ case E.KHR_TEXTURE_TRANSFORM:
1377
+ o[h] = new er();
1378
+ break;
1379
+ case E.KHR_MESH_QUANTIZATION:
1380
+ o[h] = new tr();
1381
+ break;
1382
+ default:
1383
+ d.indexOf(h) >= 0 && c[h] === void 0 && console.warn('THREE.GLTFLoader: Unknown extension "' + h + '".');
1384
+ }
1385
+ }
1386
+ l.setExtensions(o), l.setPlugins(c), l.parse(s, n);
1387
+ }
1388
+ parseAsync(e, t) {
1389
+ const s = this;
1390
+ return new Promise(function(n, r) {
1391
+ s.parse(e, t, n, r);
1392
+ });
1393
+ }
1394
+ }
1395
+ function Ps() {
1396
+ let i = {};
1397
+ return {
1398
+ get: function(e) {
1399
+ return i[e];
1400
+ },
1401
+ add: function(e, t) {
1402
+ i[e] = t;
1403
+ },
1404
+ remove: function(e) {
1405
+ delete i[e];
1406
+ },
1407
+ removeAll: function() {
1408
+ i = {};
1409
+ }
1410
+ };
1411
+ }
1412
+ const E = {
1413
+ KHR_BINARY_GLTF: "KHR_binary_glTF",
1414
+ KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
1415
+ KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
1416
+ KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
1417
+ KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
1418
+ KHR_MATERIALS_IOR: "KHR_materials_ior",
1419
+ KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
1420
+ KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
1421
+ KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
1422
+ KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
1423
+ KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
1424
+ KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
1425
+ KHR_MATERIALS_VOLUME: "KHR_materials_volume",
1426
+ KHR_TEXTURE_BASISU: "KHR_texture_basisu",
1427
+ KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
1428
+ KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
1429
+ KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
1430
+ EXT_MATERIALS_BUMP: "EXT_materials_bump",
1431
+ EXT_TEXTURE_WEBP: "EXT_texture_webp",
1432
+ EXT_TEXTURE_AVIF: "EXT_texture_avif",
1433
+ EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
1434
+ EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
1435
+ };
1436
+ class Fs {
1437
+ constructor(e) {
1438
+ this.parser = e, this.name = E.KHR_LIGHTS_PUNCTUAL, this.cache = { refs: {}, uses: {} };
1439
+ }
1440
+ _markDefs() {
1441
+ const e = this.parser, t = this.parser.json.nodes || [];
1442
+ for (let s = 0, n = t.length; s < n; s++) {
1443
+ const r = t[s];
1444
+ r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
1445
+ }
1446
+ }
1447
+ _loadLight(e) {
1448
+ const t = this.parser, s = "light:" + e;
1449
+ let n = t.cache.get(s);
1450
+ if (n) return n;
1451
+ const r = t.json, a = ((r.extensions && r.extensions[this.name] || {}).lights || [])[e];
1452
+ let l;
1453
+ const u = new se(16777215);
1454
+ a.color !== void 0 && u.setRGB(a.color[0], a.color[1], a.color[2], V);
1455
+ const h = a.range !== void 0 ? a.range : 0;
1456
+ switch (a.type) {
1457
+ case "directional":
1458
+ l = new nn(u), l.target.position.set(0, 0, -1), l.add(l.target);
1459
+ break;
1460
+ case "point":
1461
+ l = new tn(u), l.distance = h;
1462
+ break;
1463
+ case "spot":
1464
+ l = new en(u), l.distance = h, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle !== void 0 ? a.spot.innerConeAngle : 0, a.spot.outerConeAngle = a.spot.outerConeAngle !== void 0 ? a.spot.outerConeAngle : Math.PI / 4, l.angle = a.spot.outerConeAngle, l.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, l.target.position.set(0, 0, -1), l.add(l.target);
1465
+ break;
1466
+ default:
1467
+ throw new Error("THREE.GLTFLoader: Unexpected light type: " + a.type);
1468
+ }
1469
+ return l.position.set(0, 0, 0), K(l, a), a.intensity !== void 0 && (l.intensity = a.intensity), l.name = t.createUniqueName(a.name || "light_" + e), n = Promise.resolve(l), t.cache.add(s, n), n;
1470
+ }
1471
+ getDependency(e, t) {
1472
+ if (e === "light")
1473
+ return this._loadLight(t);
1474
+ }
1475
+ createNodeAttachment(e) {
1476
+ const t = this, s = this.parser, r = s.json.nodes[e], c = (r.extensions && r.extensions[this.name] || {}).light;
1477
+ return c === void 0 ? null : this._loadLight(c).then(function(a) {
1478
+ return s._getNodeRef(t.cache, c, a);
1479
+ });
1480
+ }
1481
+ }
1482
+ class Os {
1483
+ constructor() {
1484
+ this.name = E.KHR_MATERIALS_UNLIT;
1485
+ }
1486
+ getMaterialType() {
1487
+ return Te;
1488
+ }
1489
+ extendParams(e, t, s) {
1490
+ const n = [];
1491
+ e.color = new se(1, 1, 1), e.opacity = 1;
1492
+ const r = t.pbrMetallicRoughness;
1493
+ if (r) {
1494
+ if (Array.isArray(r.baseColorFactor)) {
1495
+ const o = r.baseColorFactor;
1496
+ e.color.setRGB(o[0], o[1], o[2], V), e.opacity = o[3];
1497
+ }
1498
+ r.baseColorTexture !== void 0 && n.push(s.assignTexture(e, "map", r.baseColorTexture, ve));
1499
+ }
1500
+ return Promise.all(n);
1501
+ }
1502
+ }
1503
+ class Ds {
1504
+ constructor(e) {
1505
+ this.parser = e, this.name = E.KHR_MATERIALS_EMISSIVE_STRENGTH;
1506
+ }
1507
+ extendMaterialParams(e, t) {
1508
+ const n = this.parser.json.materials[e];
1509
+ if (!n.extensions || !n.extensions[this.name])
1510
+ return Promise.resolve();
1511
+ const r = n.extensions[this.name].emissiveStrength;
1512
+ return r !== void 0 && (t.emissiveIntensity = r), Promise.resolve();
1513
+ }
1514
+ }
1515
+ class ks {
1516
+ constructor(e) {
1517
+ this.parser = e, this.name = E.KHR_MATERIALS_CLEARCOAT;
1518
+ }
1519
+ getMaterialType(e) {
1520
+ const s = this.parser.json.materials[e];
1521
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1522
+ }
1523
+ extendMaterialParams(e, t) {
1524
+ const s = this.parser, n = s.json.materials[e];
1525
+ if (!n.extensions || !n.extensions[this.name])
1526
+ return Promise.resolve();
1527
+ const r = [], o = n.extensions[this.name];
1528
+ if (o.clearcoatFactor !== void 0 && (t.clearcoat = o.clearcoatFactor), o.clearcoatTexture !== void 0 && r.push(s.assignTexture(t, "clearcoatMap", o.clearcoatTexture)), o.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = o.clearcoatRoughnessFactor), o.clearcoatRoughnessTexture !== void 0 && r.push(s.assignTexture(t, "clearcoatRoughnessMap", o.clearcoatRoughnessTexture)), o.clearcoatNormalTexture !== void 0 && (r.push(s.assignTexture(t, "clearcoatNormalMap", o.clearcoatNormalTexture)), o.clearcoatNormalTexture.scale !== void 0)) {
1529
+ const c = o.clearcoatNormalTexture.scale;
1530
+ t.clearcoatNormalScale = new It(c, c);
1531
+ }
1532
+ return Promise.all(r);
1533
+ }
1534
+ }
1535
+ class Bs {
1536
+ constructor(e) {
1537
+ this.parser = e, this.name = E.KHR_MATERIALS_DISPERSION;
1538
+ }
1539
+ getMaterialType(e) {
1540
+ const s = this.parser.json.materials[e];
1541
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1542
+ }
1543
+ extendMaterialParams(e, t) {
1544
+ const n = this.parser.json.materials[e];
1545
+ if (!n.extensions || !n.extensions[this.name])
1546
+ return Promise.resolve();
1547
+ const r = n.extensions[this.name];
1548
+ return t.dispersion = r.dispersion !== void 0 ? r.dispersion : 0, Promise.resolve();
1549
+ }
1550
+ }
1551
+ class Us {
1552
+ constructor(e) {
1553
+ this.parser = e, this.name = E.KHR_MATERIALS_IRIDESCENCE;
1554
+ }
1555
+ getMaterialType(e) {
1556
+ const s = this.parser.json.materials[e];
1557
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1558
+ }
1559
+ extendMaterialParams(e, t) {
1560
+ const s = this.parser, n = s.json.materials[e];
1561
+ if (!n.extensions || !n.extensions[this.name])
1562
+ return Promise.resolve();
1563
+ const r = [], o = n.extensions[this.name];
1564
+ return o.iridescenceFactor !== void 0 && (t.iridescence = o.iridescenceFactor), o.iridescenceTexture !== void 0 && r.push(s.assignTexture(t, "iridescenceMap", o.iridescenceTexture)), o.iridescenceIor !== void 0 && (t.iridescenceIOR = o.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), o.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = o.iridescenceThicknessMinimum), o.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = o.iridescenceThicknessMaximum), o.iridescenceThicknessTexture !== void 0 && r.push(s.assignTexture(t, "iridescenceThicknessMap", o.iridescenceThicknessTexture)), Promise.all(r);
1565
+ }
1566
+ }
1567
+ class Gs {
1568
+ constructor(e) {
1569
+ this.parser = e, this.name = E.KHR_MATERIALS_SHEEN;
1570
+ }
1571
+ getMaterialType(e) {
1572
+ const s = this.parser.json.materials[e];
1573
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1574
+ }
1575
+ extendMaterialParams(e, t) {
1576
+ const s = this.parser, n = s.json.materials[e];
1577
+ if (!n.extensions || !n.extensions[this.name])
1578
+ return Promise.resolve();
1579
+ const r = [];
1580
+ t.sheenColor = new se(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1;
1581
+ const o = n.extensions[this.name];
1582
+ if (o.sheenColorFactor !== void 0) {
1583
+ const c = o.sheenColorFactor;
1584
+ t.sheenColor.setRGB(c[0], c[1], c[2], V);
1585
+ }
1586
+ return o.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = o.sheenRoughnessFactor), o.sheenColorTexture !== void 0 && r.push(s.assignTexture(t, "sheenColorMap", o.sheenColorTexture, ve)), o.sheenRoughnessTexture !== void 0 && r.push(s.assignTexture(t, "sheenRoughnessMap", o.sheenRoughnessTexture)), Promise.all(r);
1587
+ }
1588
+ }
1589
+ class Hs {
1590
+ constructor(e) {
1591
+ this.parser = e, this.name = E.KHR_MATERIALS_TRANSMISSION;
1592
+ }
1593
+ getMaterialType(e) {
1594
+ const s = this.parser.json.materials[e];
1595
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1596
+ }
1597
+ extendMaterialParams(e, t) {
1598
+ const s = this.parser, n = s.json.materials[e];
1599
+ if (!n.extensions || !n.extensions[this.name])
1600
+ return Promise.resolve();
1601
+ const r = [], o = n.extensions[this.name];
1602
+ return o.transmissionFactor !== void 0 && (t.transmission = o.transmissionFactor), o.transmissionTexture !== void 0 && r.push(s.assignTexture(t, "transmissionMap", o.transmissionTexture)), Promise.all(r);
1603
+ }
1604
+ }
1605
+ class js {
1606
+ constructor(e) {
1607
+ this.parser = e, this.name = E.KHR_MATERIALS_VOLUME;
1608
+ }
1609
+ getMaterialType(e) {
1610
+ const s = this.parser.json.materials[e];
1611
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1612
+ }
1613
+ extendMaterialParams(e, t) {
1614
+ const s = this.parser, n = s.json.materials[e];
1615
+ if (!n.extensions || !n.extensions[this.name])
1616
+ return Promise.resolve();
1617
+ const r = [], o = n.extensions[this.name];
1618
+ t.thickness = o.thicknessFactor !== void 0 ? o.thicknessFactor : 0, o.thicknessTexture !== void 0 && r.push(s.assignTexture(t, "thicknessMap", o.thicknessTexture)), t.attenuationDistance = o.attenuationDistance || 1 / 0;
1619
+ const c = o.attenuationColor || [1, 1, 1];
1620
+ return t.attenuationColor = new se().setRGB(c[0], c[1], c[2], V), Promise.all(r);
1621
+ }
1622
+ }
1623
+ class Xs {
1624
+ constructor(e) {
1625
+ this.parser = e, this.name = E.KHR_MATERIALS_IOR;
1626
+ }
1627
+ getMaterialType(e) {
1628
+ const s = this.parser.json.materials[e];
1629
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1630
+ }
1631
+ extendMaterialParams(e, t) {
1632
+ const n = this.parser.json.materials[e];
1633
+ if (!n.extensions || !n.extensions[this.name])
1634
+ return Promise.resolve();
1635
+ const r = n.extensions[this.name];
1636
+ return t.ior = r.ior !== void 0 ? r.ior : 1.5, Promise.resolve();
1637
+ }
1638
+ }
1639
+ class Ks {
1640
+ constructor(e) {
1641
+ this.parser = e, this.name = E.KHR_MATERIALS_SPECULAR;
1642
+ }
1643
+ getMaterialType(e) {
1644
+ const s = this.parser.json.materials[e];
1645
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1646
+ }
1647
+ extendMaterialParams(e, t) {
1648
+ const s = this.parser, n = s.json.materials[e];
1649
+ if (!n.extensions || !n.extensions[this.name])
1650
+ return Promise.resolve();
1651
+ const r = [], o = n.extensions[this.name];
1652
+ t.specularIntensity = o.specularFactor !== void 0 ? o.specularFactor : 1, o.specularTexture !== void 0 && r.push(s.assignTexture(t, "specularIntensityMap", o.specularTexture));
1653
+ const c = o.specularColorFactor || [1, 1, 1];
1654
+ return t.specularColor = new se().setRGB(c[0], c[1], c[2], V), o.specularColorTexture !== void 0 && r.push(s.assignTexture(t, "specularColorMap", o.specularColorTexture, ve)), Promise.all(r);
1655
+ }
1656
+ }
1657
+ class Ys {
1658
+ constructor(e) {
1659
+ this.parser = e, this.name = E.EXT_MATERIALS_BUMP;
1660
+ }
1661
+ getMaterialType(e) {
1662
+ const s = this.parser.json.materials[e];
1663
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1664
+ }
1665
+ extendMaterialParams(e, t) {
1666
+ const s = this.parser, n = s.json.materials[e];
1667
+ if (!n.extensions || !n.extensions[this.name])
1668
+ return Promise.resolve();
1669
+ const r = [], o = n.extensions[this.name];
1670
+ return t.bumpScale = o.bumpFactor !== void 0 ? o.bumpFactor : 1, o.bumpTexture !== void 0 && r.push(s.assignTexture(t, "bumpMap", o.bumpTexture)), Promise.all(r);
1671
+ }
1672
+ }
1673
+ class Vs {
1674
+ constructor(e) {
1675
+ this.parser = e, this.name = E.KHR_MATERIALS_ANISOTROPY;
1676
+ }
1677
+ getMaterialType(e) {
1678
+ const s = this.parser.json.materials[e];
1679
+ return !s.extensions || !s.extensions[this.name] ? null : X;
1680
+ }
1681
+ extendMaterialParams(e, t) {
1682
+ const s = this.parser, n = s.json.materials[e];
1683
+ if (!n.extensions || !n.extensions[this.name])
1684
+ return Promise.resolve();
1685
+ const r = [], o = n.extensions[this.name];
1686
+ return o.anisotropyStrength !== void 0 && (t.anisotropy = o.anisotropyStrength), o.anisotropyRotation !== void 0 && (t.anisotropyRotation = o.anisotropyRotation), o.anisotropyTexture !== void 0 && r.push(s.assignTexture(t, "anisotropyMap", o.anisotropyTexture)), Promise.all(r);
1687
+ }
1688
+ }
1689
+ class Ws {
1690
+ constructor(e) {
1691
+ this.parser = e, this.name = E.KHR_TEXTURE_BASISU;
1692
+ }
1693
+ loadTexture(e) {
1694
+ const t = this.parser, s = t.json, n = s.textures[e];
1695
+ if (!n.extensions || !n.extensions[this.name])
1696
+ return null;
1697
+ const r = n.extensions[this.name], o = t.options.ktx2Loader;
1698
+ if (!o) {
1699
+ if (s.extensionsRequired && s.extensionsRequired.indexOf(this.name) >= 0)
1700
+ throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
1701
+ return null;
1702
+ }
1703
+ return t.loadTextureImage(e, r.source, o);
1704
+ }
1705
+ }
1706
+ class zs {
1707
+ constructor(e) {
1708
+ this.parser = e, this.name = E.EXT_TEXTURE_WEBP, this.isSupported = null;
1709
+ }
1710
+ loadTexture(e) {
1711
+ const t = this.name, s = this.parser, n = s.json, r = n.textures[e];
1712
+ if (!r.extensions || !r.extensions[t])
1713
+ return null;
1714
+ const o = r.extensions[t], c = n.images[o.source];
1715
+ let a = s.textureLoader;
1716
+ if (c.uri) {
1717
+ const l = s.options.manager.getHandler(c.uri);
1718
+ l !== null && (a = l);
1719
+ }
1720
+ return this.detectSupport().then(function(l) {
1721
+ if (l) return s.loadTextureImage(e, o.source, a);
1722
+ if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
1723
+ throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");
1724
+ return s.loadTexture(e);
1725
+ });
1726
+ }
1727
+ detectSupport() {
1728
+ return this.isSupported || (this.isSupported = new Promise(function(e) {
1729
+ const t = new Image();
1730
+ t.src = "data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA", t.onload = t.onerror = function() {
1731
+ e(t.height === 1);
1732
+ };
1733
+ })), this.isSupported;
1734
+ }
1735
+ }
1736
+ class qs {
1737
+ constructor(e) {
1738
+ this.parser = e, this.name = E.EXT_TEXTURE_AVIF, this.isSupported = null;
1739
+ }
1740
+ loadTexture(e) {
1741
+ const t = this.name, s = this.parser, n = s.json, r = n.textures[e];
1742
+ if (!r.extensions || !r.extensions[t])
1743
+ return null;
1744
+ const o = r.extensions[t], c = n.images[o.source];
1745
+ let a = s.textureLoader;
1746
+ if (c.uri) {
1747
+ const l = s.options.manager.getHandler(c.uri);
1748
+ l !== null && (a = l);
1749
+ }
1750
+ return this.detectSupport().then(function(l) {
1751
+ if (l) return s.loadTextureImage(e, o.source, a);
1752
+ if (n.extensionsRequired && n.extensionsRequired.indexOf(t) >= 0)
1753
+ throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");
1754
+ return s.loadTexture(e);
1755
+ });
1756
+ }
1757
+ detectSupport() {
1758
+ return this.isSupported || (this.isSupported = new Promise(function(e) {
1759
+ const t = new Image();
1760
+ t.src = "data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=", t.onload = t.onerror = function() {
1761
+ e(t.height === 1);
1762
+ };
1763
+ })), this.isSupported;
1764
+ }
1765
+ }
1766
+ class Zs {
1767
+ constructor(e) {
1768
+ this.name = E.EXT_MESHOPT_COMPRESSION, this.parser = e;
1769
+ }
1770
+ loadBufferView(e) {
1771
+ const t = this.parser.json, s = t.bufferViews[e];
1772
+ if (s.extensions && s.extensions[this.name]) {
1773
+ const n = s.extensions[this.name], r = this.parser.getDependency("buffer", n.buffer), o = this.parser.options.meshoptDecoder;
1774
+ if (!o || !o.supported) {
1775
+ if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0)
1776
+ throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
1777
+ return null;
1778
+ }
1779
+ return r.then(function(c) {
1780
+ const a = n.byteOffset || 0, l = n.byteLength || 0, u = n.count, h = n.byteStride, d = new Uint8Array(c, a, l);
1781
+ return o.decodeGltfBufferAsync ? o.decodeGltfBufferAsync(u, h, d, n.mode, n.filter).then(function(p) {
1782
+ return p.buffer;
1783
+ }) : o.ready.then(function() {
1784
+ const p = new ArrayBuffer(u * h);
1785
+ return o.decodeGltfBuffer(new Uint8Array(p), u, h, d, n.mode, n.filter), p;
1786
+ });
1787
+ });
1788
+ } else
1789
+ return null;
1790
+ }
1791
+ }
1792
+ class Qs {
1793
+ constructor(e) {
1794
+ this.name = E.EXT_MESH_GPU_INSTANCING, this.parser = e;
1795
+ }
1796
+ createNodeMesh(e) {
1797
+ const t = this.parser.json, s = t.nodes[e];
1798
+ if (!s.extensions || !s.extensions[this.name] || s.mesh === void 0)
1799
+ return null;
1800
+ const n = t.meshes[s.mesh];
1801
+ for (const l of n.primitives)
1802
+ if (l.mode !== O.TRIANGLES && l.mode !== O.TRIANGLE_STRIP && l.mode !== O.TRIANGLE_FAN && l.mode !== void 0)
1803
+ return null;
1804
+ const o = s.extensions[this.name].attributes, c = [], a = {};
1805
+ for (const l in o)
1806
+ c.push(this.parser.getDependency("accessor", o[l]).then((u) => (a[l] = u, a[l])));
1807
+ return c.length < 1 ? null : (c.push(this.parser.createNodeMesh(e)), Promise.all(c).then((l) => {
1808
+ const u = l.pop(), h = u.isGroup ? u.children : [u], d = l[0].count, p = [];
1809
+ for (const g of h) {
1810
+ const A = new Ne(), m = new te(), f = new Ct(), x = new te(1, 1, 1), v = new sn(g.geometry, g.material, d);
1811
+ for (let b = 0; b < d; b++)
1812
+ a.TRANSLATION && m.fromBufferAttribute(a.TRANSLATION, b), a.ROTATION && f.fromBufferAttribute(a.ROTATION, b), a.SCALE && x.fromBufferAttribute(a.SCALE, b), v.setMatrixAt(b, A.compose(m, f, x));
1813
+ for (const b in a)
1814
+ if (b === "_COLOR_0") {
1815
+ const y = a[b];
1816
+ v.instanceColor = new rn(y.array, y.itemSize, y.normalized);
1817
+ } else b !== "TRANSLATION" && b !== "ROTATION" && b !== "SCALE" && g.geometry.setAttribute(b, a[b]);
1818
+ Nt.prototype.copy.call(v, g), this.parser.assignFinalMaterial(v), p.push(v);
1819
+ }
1820
+ return u.isGroup ? (u.clear(), u.add(...p), u) : p[0];
1821
+ }));
1822
+ }
1823
+ }
1824
+ const jt = "glTF", Ae = 12, Mt = { JSON: 1313821514, BIN: 5130562 };
1825
+ class $s {
1826
+ constructor(e) {
1827
+ this.name = E.KHR_BINARY_GLTF, this.content = null, this.body = null;
1828
+ const t = new DataView(e, 0, Ae), s = new TextDecoder();
1829
+ if (this.header = {
1830
+ magic: s.decode(new Uint8Array(e.slice(0, 4))),
1831
+ version: t.getUint32(4, !0),
1832
+ length: t.getUint32(8, !0)
1833
+ }, this.header.magic !== jt)
1834
+ throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
1835
+ if (this.header.version < 2)
1836
+ throw new Error("THREE.GLTFLoader: Legacy binary file detected.");
1837
+ const n = this.header.length - Ae, r = new DataView(e, Ae);
1838
+ let o = 0;
1839
+ for (; o < n; ) {
1840
+ const c = r.getUint32(o, !0);
1841
+ o += 4;
1842
+ const a = r.getUint32(o, !0);
1843
+ if (o += 4, a === Mt.JSON) {
1844
+ const l = new Uint8Array(e, Ae + o, c);
1845
+ this.content = s.decode(l);
1846
+ } else if (a === Mt.BIN) {
1847
+ const l = Ae + o;
1848
+ this.body = e.slice(l, l + c);
1849
+ }
1850
+ o += c;
1851
+ }
1852
+ if (this.content === null)
1853
+ throw new Error("THREE.GLTFLoader: JSON content not found.");
1854
+ }
1855
+ }
1856
+ class Js {
1857
+ constructor(e, t) {
1858
+ if (!t)
1859
+ throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
1860
+ this.name = E.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
1861
+ }
1862
+ decodePrimitive(e, t) {
1863
+ const s = this.json, n = this.dracoLoader, r = e.extensions[this.name].bufferView, o = e.extensions[this.name].attributes, c = {}, a = {}, l = {};
1864
+ for (const u in o) {
1865
+ const h = ot[u] || u.toLowerCase();
1866
+ c[h] = o[u];
1867
+ }
1868
+ for (const u in e.attributes) {
1869
+ const h = ot[u] || u.toLowerCase();
1870
+ if (o[u] !== void 0) {
1871
+ const d = s.accessors[e.attributes[u]], p = le[d.componentType];
1872
+ l[h] = p.name, a[h] = d.normalized === !0;
1873
+ }
1874
+ }
1875
+ return t.getDependency("bufferView", r).then(function(u) {
1876
+ return new Promise(function(h, d) {
1877
+ n.decodeDracoFile(u, function(p) {
1878
+ for (const g in p.attributes) {
1879
+ const A = p.attributes[g], m = a[g];
1880
+ m !== void 0 && (A.normalized = m);
1881
+ }
1882
+ h(p);
1883
+ }, c, l, V, d);
1884
+ });
1885
+ });
1886
+ }
1887
+ }
1888
+ class er {
1889
+ constructor() {
1890
+ this.name = E.KHR_TEXTURE_TRANSFORM;
1891
+ }
1892
+ extendTexture(e, t) {
1893
+ return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 || (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0), e;
1894
+ }
1895
+ }
1896
+ class tr {
1897
+ constructor() {
1898
+ this.name = E.KHR_MESH_QUANTIZATION;
1899
+ }
1900
+ }
1901
+ class Xt extends Pn {
1902
+ constructor(e, t, s, n) {
1903
+ super(e, t, s, n);
1904
+ }
1905
+ copySampleValue_(e) {
1906
+ const t = this.resultBuffer, s = this.sampleValues, n = this.valueSize, r = e * n * 3 + n;
1907
+ for (let o = 0; o !== n; o++)
1908
+ t[o] = s[r + o];
1909
+ return t;
1910
+ }
1911
+ interpolate_(e, t, s, n) {
1912
+ const r = this.resultBuffer, o = this.sampleValues, c = this.valueSize, a = c * 2, l = c * 3, u = n - t, h = (s - t) / u, d = h * h, p = d * h, g = e * l, A = g - l, m = -2 * p + 3 * d, f = p - d, x = 1 - m, v = f - d + h;
1913
+ for (let b = 0; b !== c; b++) {
1914
+ const y = o[A + b + c], L = o[A + b + a] * u, _ = o[g + b + c], D = o[g + b] * u;
1915
+ r[b] = x * y + v * L + m * _ + f * D;
1916
+ }
1917
+ return r;
1918
+ }
1919
+ }
1920
+ const nr = new Ct();
1921
+ class sr extends Xt {
1922
+ interpolate_(e, t, s, n) {
1923
+ const r = super.interpolate_(e, t, s, n);
1924
+ return nr.fromArray(r).normalize().toArray(r), r;
1925
+ }
1926
+ }
1927
+ const O = {
1928
+ POINTS: 0,
1929
+ LINES: 1,
1930
+ LINE_LOOP: 2,
1931
+ LINE_STRIP: 3,
1932
+ TRIANGLES: 4,
1933
+ TRIANGLE_STRIP: 5,
1934
+ TRIANGLE_FAN: 6
1935
+ }, le = {
1936
+ 5120: Int8Array,
1937
+ 5121: Uint8Array,
1938
+ 5122: Int16Array,
1939
+ 5123: Uint16Array,
1940
+ 5125: Uint32Array,
1941
+ 5126: Float32Array
1942
+ }, wt = {
1943
+ 9728: Ft,
1944
+ 9729: nt,
1945
+ 9984: dn,
1946
+ 9985: hn,
1947
+ 9986: un,
1948
+ 9987: Pt
1949
+ }, St = {
1950
+ 33071: pn,
1951
+ 33648: fn,
1952
+ 10497: st
1953
+ }, Ze = {
1954
+ SCALAR: 1,
1955
+ VEC2: 2,
1956
+ VEC3: 3,
1957
+ VEC4: 4,
1958
+ MAT2: 4,
1959
+ MAT3: 9,
1960
+ MAT4: 16
1961
+ }, ot = {
1962
+ POSITION: "position",
1963
+ NORMAL: "normal",
1964
+ TANGENT: "tangent",
1965
+ TEXCOORD_0: "uv",
1966
+ TEXCOORD_1: "uv1",
1967
+ TEXCOORD_2: "uv2",
1968
+ TEXCOORD_3: "uv3",
1969
+ COLOR_0: "color",
1970
+ WEIGHTS_0: "skinWeight",
1971
+ JOINTS_0: "skinIndex"
1972
+ }, Q = {
1973
+ scale: "scale",
1974
+ translation: "position",
1975
+ rotation: "quaternion",
1976
+ weights: "morphTargetInfluences"
1977
+ }, rr = {
1978
+ CUBICSPLINE: void 0,
1979
+ // We use a custom interpolant (GLTFCubicSplineInterpolation) for CUBICSPLINE tracks. Each
1980
+ // keyframe track will be initialized with a default interpolation type, then modified.
1981
+ LINEAR: Dt,
1982
+ STEP: Cn
1983
+ }, Qe = {
1984
+ OPAQUE: "OPAQUE",
1985
+ MASK: "MASK",
1986
+ BLEND: "BLEND"
1987
+ };
1988
+ function or(i) {
1989
+ return i.DefaultMaterial === void 0 && (i.DefaultMaterial = new Ot({
1990
+ color: 16777215,
1991
+ emissive: 0,
1992
+ metalness: 1,
1993
+ roughness: 1,
1994
+ transparent: !1,
1995
+ depthTest: !0,
1996
+ side: Nn
1997
+ })), i.DefaultMaterial;
1998
+ }
1999
+ function ee(i, e, t) {
2000
+ for (const s in t.extensions)
2001
+ i[s] === void 0 && (e.userData.gltfExtensions = e.userData.gltfExtensions || {}, e.userData.gltfExtensions[s] = t.extensions[s]);
2002
+ }
2003
+ function K(i, e) {
2004
+ e.extras !== void 0 && (typeof e.extras == "object" ? Object.assign(i.userData, e.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + e.extras));
2005
+ }
2006
+ function ir(i, e, t) {
2007
+ let s = !1, n = !1, r = !1;
2008
+ for (let l = 0, u = e.length; l < u; l++) {
2009
+ const h = e[l];
2010
+ if (h.POSITION !== void 0 && (s = !0), h.NORMAL !== void 0 && (n = !0), h.COLOR_0 !== void 0 && (r = !0), s && n && r) break;
2011
+ }
2012
+ if (!s && !n && !r) return Promise.resolve(i);
2013
+ const o = [], c = [], a = [];
2014
+ for (let l = 0, u = e.length; l < u; l++) {
2015
+ const h = e[l];
2016
+ if (s) {
2017
+ const d = h.POSITION !== void 0 ? t.getDependency("accessor", h.POSITION) : i.attributes.position;
2018
+ o.push(d);
2019
+ }
2020
+ if (n) {
2021
+ const d = h.NORMAL !== void 0 ? t.getDependency("accessor", h.NORMAL) : i.attributes.normal;
2022
+ c.push(d);
2023
+ }
2024
+ if (r) {
2025
+ const d = h.COLOR_0 !== void 0 ? t.getDependency("accessor", h.COLOR_0) : i.attributes.color;
2026
+ a.push(d);
2027
+ }
2028
+ }
2029
+ return Promise.all([
2030
+ Promise.all(o),
2031
+ Promise.all(c),
2032
+ Promise.all(a)
2033
+ ]).then(function(l) {
2034
+ const u = l[0], h = l[1], d = l[2];
2035
+ return s && (i.morphAttributes.position = u), n && (i.morphAttributes.normal = h), r && (i.morphAttributes.color = d), i.morphTargetsRelative = !0, i;
2036
+ });
2037
+ }
2038
+ function ar(i, e) {
2039
+ if (i.updateMorphTargets(), e.weights !== void 0)
2040
+ for (let t = 0, s = e.weights.length; t < s; t++)
2041
+ i.morphTargetInfluences[t] = e.weights[t];
2042
+ if (e.extras && Array.isArray(e.extras.targetNames)) {
2043
+ const t = e.extras.targetNames;
2044
+ if (i.morphTargetInfluences.length === t.length) {
2045
+ i.morphTargetDictionary = {};
2046
+ for (let s = 0, n = t.length; s < n; s++)
2047
+ i.morphTargetDictionary[t[s]] = s;
2048
+ } else
2049
+ console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
2050
+ }
2051
+ }
2052
+ function cr(i) {
2053
+ let e;
2054
+ const t = i.extensions && i.extensions[E.KHR_DRACO_MESH_COMPRESSION];
2055
+ if (t ? e = "draco:" + t.bufferView + ":" + t.indices + ":" + $e(t.attributes) : e = i.indices + ":" + $e(i.attributes) + ":" + i.mode, i.targets !== void 0)
2056
+ for (let s = 0, n = i.targets.length; s < n; s++)
2057
+ e += ":" + $e(i.targets[s]);
2058
+ return e;
2059
+ }
2060
+ function $e(i) {
2061
+ let e = "";
2062
+ const t = Object.keys(i).sort();
2063
+ for (let s = 0, n = t.length; s < n; s++)
2064
+ e += t[s] + ":" + i[t[s]] + ";";
2065
+ return e;
2066
+ }
2067
+ function it(i) {
2068
+ switch (i) {
2069
+ case Int8Array:
2070
+ return 1 / 127;
2071
+ case Uint8Array:
2072
+ return 1 / 255;
2073
+ case Int16Array:
2074
+ return 1 / 32767;
2075
+ case Uint16Array:
2076
+ return 1 / 65535;
2077
+ default:
2078
+ throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
2079
+ }
2080
+ }
2081
+ function lr(i) {
2082
+ return i.search(/\.jpe?g($|\?)/i) > 0 || i.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : i.search(/\.webp($|\?)/i) > 0 || i.search(/^data\:image\/webp/) === 0 ? "image/webp" : i.search(/\.ktx2($|\?)/i) > 0 || i.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
2083
+ }
2084
+ const ur = new Ne();
2085
+ class hr {
2086
+ constructor(e = {}, t = {}) {
2087
+ this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new Ps(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = { refs: {}, uses: {} }, this.cameraCache = { refs: {}, uses: {} }, this.lightCache = { refs: {}, uses: {} }, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
2088
+ let s = !1, n = -1, r = !1, o = -1;
2089
+ if (typeof navigator < "u") {
2090
+ const c = navigator.userAgent;
2091
+ s = /^((?!chrome|android).)*safari/i.test(c) === !0;
2092
+ const a = c.match(/Version\/(\d+)/);
2093
+ n = s && a ? parseInt(a[1], 10) : -1, r = c.indexOf("Firefox") > -1, o = r ? c.match(/Firefox\/([0-9]+)\./)[1] : -1;
2094
+ }
2095
+ typeof createImageBitmap > "u" || s && n < 17 || r && o < 98 ? this.textureLoader = new on(this.options.manager) : this.textureLoader = new an(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new Lt(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
2096
+ }
2097
+ setExtensions(e) {
2098
+ this.extensions = e;
2099
+ }
2100
+ setPlugins(e) {
2101
+ this.plugins = e;
2102
+ }
2103
+ parse(e, t) {
2104
+ const s = this, n = this.json, r = this.extensions;
2105
+ this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(o) {
2106
+ return o._markDefs && o._markDefs();
2107
+ }), Promise.all(this._invokeAll(function(o) {
2108
+ return o.beforeRoot && o.beforeRoot();
2109
+ })).then(function() {
2110
+ return Promise.all([
2111
+ s.getDependencies("scene"),
2112
+ s.getDependencies("animation"),
2113
+ s.getDependencies("camera")
2114
+ ]);
2115
+ }).then(function(o) {
2116
+ const c = {
2117
+ scene: o[0][n.scene || 0],
2118
+ scenes: o[0],
2119
+ animations: o[1],
2120
+ cameras: o[2],
2121
+ asset: n.asset,
2122
+ parser: s,
2123
+ userData: {}
2124
+ };
2125
+ return ee(r, c, n), K(c, n), Promise.all(s._invokeAll(function(a) {
2126
+ return a.afterRoot && a.afterRoot(c);
2127
+ })).then(function() {
2128
+ for (const a of c.scenes)
2129
+ a.updateMatrixWorld();
2130
+ e(c);
2131
+ });
2132
+ }).catch(t);
2133
+ }
2134
+ /**
2135
+ * Marks the special nodes/meshes in json for efficient parse.
2136
+ */
2137
+ _markDefs() {
2138
+ const e = this.json.nodes || [], t = this.json.skins || [], s = this.json.meshes || [];
2139
+ for (let n = 0, r = t.length; n < r; n++) {
2140
+ const o = t[n].joints;
2141
+ for (let c = 0, a = o.length; c < a; c++)
2142
+ e[o[c]].isBone = !0;
2143
+ }
2144
+ for (let n = 0, r = e.length; n < r; n++) {
2145
+ const o = e[n];
2146
+ o.mesh !== void 0 && (this._addNodeRef(this.meshCache, o.mesh), o.skin !== void 0 && (s[o.mesh].isSkinnedMesh = !0)), o.camera !== void 0 && this._addNodeRef(this.cameraCache, o.camera);
2147
+ }
2148
+ }
2149
+ /**
2150
+ * Counts references to shared node / Object3D resources. These resources
2151
+ * can be reused, or "instantiated", at multiple nodes in the scene
2152
+ * hierarchy. Mesh, Camera, and Light instances are instantiated and must
2153
+ * be marked. Non-scenegraph resources (like Materials, Geometries, and
2154
+ * Textures) can be reused directly and are not marked here.
2155
+ *
2156
+ * Example: CesiumMilkTruck sample model reuses "Wheel" meshes.
2157
+ *
2158
+ * @param {Object} cache
2159
+ * @param {Object3D} index
2160
+ */
2161
+ _addNodeRef(e, t) {
2162
+ t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
2163
+ }
2164
+ /**
2165
+ * Returns a reference to a shared resource, cloning it if necessary.
2166
+ *
2167
+ * @param {Object} cache
2168
+ * @param {Number} index
2169
+ * @param {Object} object
2170
+ * @return {Object}
2171
+ */
2172
+ _getNodeRef(e, t, s) {
2173
+ if (e.refs[t] <= 1) return s;
2174
+ const n = s.clone(), r = (o, c) => {
2175
+ const a = this.associations.get(o);
2176
+ a != null && this.associations.set(c, a);
2177
+ for (const [l, u] of o.children.entries())
2178
+ r(u, c.children[l]);
2179
+ };
2180
+ return r(s, n), n.name += "_instance_" + e.uses[t]++, n;
2181
+ }
2182
+ _invokeOne(e) {
2183
+ const t = Object.values(this.plugins);
2184
+ t.push(this);
2185
+ for (let s = 0; s < t.length; s++) {
2186
+ const n = e(t[s]);
2187
+ if (n) return n;
2188
+ }
2189
+ return null;
2190
+ }
2191
+ _invokeAll(e) {
2192
+ const t = Object.values(this.plugins);
2193
+ t.unshift(this);
2194
+ const s = [];
2195
+ for (let n = 0; n < t.length; n++) {
2196
+ const r = e(t[n]);
2197
+ r && s.push(r);
2198
+ }
2199
+ return s;
2200
+ }
2201
+ /**
2202
+ * Requests the specified dependency asynchronously, with caching.
2203
+ * @param {string} type
2204
+ * @param {number} index
2205
+ * @return {Promise<Object3D|Material|THREE.Texture|AnimationClip|ArrayBuffer|Object>}
2206
+ */
2207
+ getDependency(e, t) {
2208
+ const s = e + ":" + t;
2209
+ let n = this.cache.get(s);
2210
+ if (!n) {
2211
+ switch (e) {
2212
+ case "scene":
2213
+ n = this.loadScene(t);
2214
+ break;
2215
+ case "node":
2216
+ n = this._invokeOne(function(r) {
2217
+ return r.loadNode && r.loadNode(t);
2218
+ });
2219
+ break;
2220
+ case "mesh":
2221
+ n = this._invokeOne(function(r) {
2222
+ return r.loadMesh && r.loadMesh(t);
2223
+ });
2224
+ break;
2225
+ case "accessor":
2226
+ n = this.loadAccessor(t);
2227
+ break;
2228
+ case "bufferView":
2229
+ n = this._invokeOne(function(r) {
2230
+ return r.loadBufferView && r.loadBufferView(t);
2231
+ });
2232
+ break;
2233
+ case "buffer":
2234
+ n = this.loadBuffer(t);
2235
+ break;
2236
+ case "material":
2237
+ n = this._invokeOne(function(r) {
2238
+ return r.loadMaterial && r.loadMaterial(t);
2239
+ });
2240
+ break;
2241
+ case "texture":
2242
+ n = this._invokeOne(function(r) {
2243
+ return r.loadTexture && r.loadTexture(t);
2244
+ });
2245
+ break;
2246
+ case "skin":
2247
+ n = this.loadSkin(t);
2248
+ break;
2249
+ case "animation":
2250
+ n = this._invokeOne(function(r) {
2251
+ return r.loadAnimation && r.loadAnimation(t);
2252
+ });
2253
+ break;
2254
+ case "camera":
2255
+ n = this.loadCamera(t);
2256
+ break;
2257
+ default:
2258
+ if (n = this._invokeOne(function(r) {
2259
+ return r != this && r.getDependency && r.getDependency(e, t);
2260
+ }), !n)
2261
+ throw new Error("Unknown type: " + e);
2262
+ break;
2263
+ }
2264
+ this.cache.add(s, n);
2265
+ }
2266
+ return n;
2267
+ }
2268
+ /**
2269
+ * Requests all dependencies of the specified type asynchronously, with caching.
2270
+ * @param {string} type
2271
+ * @return {Promise<Array<Object>>}
2272
+ */
2273
+ getDependencies(e) {
2274
+ let t = this.cache.get(e);
2275
+ if (!t) {
2276
+ const s = this, n = this.json[e + (e === "mesh" ? "es" : "s")] || [];
2277
+ t = Promise.all(n.map(function(r, o) {
2278
+ return s.getDependency(e, o);
2279
+ })), this.cache.add(e, t);
2280
+ }
2281
+ return t;
2282
+ }
2283
+ /**
2284
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
2285
+ * @param {number} bufferIndex
2286
+ * @return {Promise<ArrayBuffer>}
2287
+ */
2288
+ loadBuffer(e) {
2289
+ const t = this.json.buffers[e], s = this.fileLoader;
2290
+ if (t.type && t.type !== "arraybuffer")
2291
+ throw new Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
2292
+ if (t.uri === void 0 && e === 0)
2293
+ return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);
2294
+ const n = this.options;
2295
+ return new Promise(function(r, o) {
2296
+ s.load(xe.resolveURL(t.uri, n.path), r, void 0, function() {
2297
+ o(new Error('THREE.GLTFLoader: Failed to load buffer "' + t.uri + '".'));
2298
+ });
2299
+ });
2300
+ }
2301
+ /**
2302
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#buffers-and-buffer-views
2303
+ * @param {number} bufferViewIndex
2304
+ * @return {Promise<ArrayBuffer>}
2305
+ */
2306
+ loadBufferView(e) {
2307
+ const t = this.json.bufferViews[e];
2308
+ return this.getDependency("buffer", t.buffer).then(function(s) {
2309
+ const n = t.byteLength || 0, r = t.byteOffset || 0;
2310
+ return s.slice(r, r + n);
2311
+ });
2312
+ }
2313
+ /**
2314
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#accessors
2315
+ * @param {number} accessorIndex
2316
+ * @return {Promise<BufferAttribute|InterleavedBufferAttribute>}
2317
+ */
2318
+ loadAccessor(e) {
2319
+ const t = this, s = this.json, n = this.json.accessors[e];
2320
+ if (n.bufferView === void 0 && n.sparse === void 0) {
2321
+ const o = Ze[n.type], c = le[n.componentType], a = n.normalized === !0, l = new c(n.count * o);
2322
+ return Promise.resolve(new He(l, o, a));
2323
+ }
2324
+ const r = [];
2325
+ return n.bufferView !== void 0 ? r.push(this.getDependency("bufferView", n.bufferView)) : r.push(null), n.sparse !== void 0 && (r.push(this.getDependency("bufferView", n.sparse.indices.bufferView)), r.push(this.getDependency("bufferView", n.sparse.values.bufferView))), Promise.all(r).then(function(o) {
2326
+ const c = o[0], a = Ze[n.type], l = le[n.componentType], u = l.BYTES_PER_ELEMENT, h = u * a, d = n.byteOffset || 0, p = n.bufferView !== void 0 ? s.bufferViews[n.bufferView].byteStride : void 0, g = n.normalized === !0;
2327
+ let A, m;
2328
+ if (p && p !== h) {
2329
+ const f = Math.floor(d / p), x = "InterleavedBuffer:" + n.bufferView + ":" + n.componentType + ":" + f + ":" + n.count;
2330
+ let v = t.cache.get(x);
2331
+ v || (A = new l(c, f * p, n.count * p / u), v = new cn(A, p / u), t.cache.add(x, v)), m = new ln(v, a, d % p / u, g);
2332
+ } else
2333
+ c === null ? A = new l(n.count * a) : A = new l(c, d, n.count * a), m = new He(A, a, g);
2334
+ if (n.sparse !== void 0) {
2335
+ const f = Ze.SCALAR, x = le[n.sparse.indices.componentType], v = n.sparse.indices.byteOffset || 0, b = n.sparse.values.byteOffset || 0, y = new x(o[1], v, n.sparse.count * f), L = new l(o[2], b, n.sparse.count * a);
2336
+ c !== null && (m = new He(m.array.slice(), m.itemSize, m.normalized)), m.normalized = !1;
2337
+ for (let _ = 0, D = y.length; _ < D; _++) {
2338
+ const M = y[_];
2339
+ if (m.setX(M, L[_ * a]), a >= 2 && m.setY(M, L[_ * a + 1]), a >= 3 && m.setZ(M, L[_ * a + 2]), a >= 4 && m.setW(M, L[_ * a + 3]), a >= 5) throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
2340
+ }
2341
+ m.normalized = g;
2342
+ }
2343
+ return m;
2344
+ });
2345
+ }
2346
+ /**
2347
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#textures
2348
+ * @param {number} textureIndex
2349
+ * @return {Promise<THREE.Texture|null>}
2350
+ */
2351
+ loadTexture(e) {
2352
+ const t = this.json, s = this.options, r = t.textures[e].source, o = t.images[r];
2353
+ let c = this.textureLoader;
2354
+ if (o.uri) {
2355
+ const a = s.manager.getHandler(o.uri);
2356
+ a !== null && (c = a);
2357
+ }
2358
+ return this.loadTextureImage(e, r, c);
2359
+ }
2360
+ loadTextureImage(e, t, s) {
2361
+ const n = this, r = this.json, o = r.textures[e], c = r.images[t], a = (c.uri || c.bufferView) + ":" + o.sampler;
2362
+ if (this.textureCache[a])
2363
+ return this.textureCache[a];
2364
+ const l = this.loadImageSource(t, s).then(function(u) {
2365
+ u.flipY = !1, u.name = o.name || c.name || "", u.name === "" && typeof c.uri == "string" && c.uri.startsWith("data:image/") === !1 && (u.name = c.uri);
2366
+ const d = (r.samplers || {})[o.sampler] || {};
2367
+ return u.magFilter = wt[d.magFilter] || nt, u.minFilter = wt[d.minFilter] || Pt, u.wrapS = St[d.wrapS] || st, u.wrapT = St[d.wrapT] || st, u.generateMipmaps = !u.isCompressedTexture && u.minFilter !== Ft && u.minFilter !== nt, n.associations.set(u, { textures: e }), u;
2368
+ }).catch(function() {
2369
+ return null;
2370
+ });
2371
+ return this.textureCache[a] = l, l;
2372
+ }
2373
+ loadImageSource(e, t) {
2374
+ const s = this, n = this.json, r = this.options;
2375
+ if (this.sourceCache[e] !== void 0)
2376
+ return this.sourceCache[e].then((h) => h.clone());
2377
+ const o = n.images[e], c = self.URL || self.webkitURL;
2378
+ let a = o.uri || "", l = !1;
2379
+ if (o.bufferView !== void 0)
2380
+ a = s.getDependency("bufferView", o.bufferView).then(function(h) {
2381
+ l = !0;
2382
+ const d = new Blob([h], { type: o.mimeType });
2383
+ return a = c.createObjectURL(d), a;
2384
+ });
2385
+ else if (o.uri === void 0)
2386
+ throw new Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
2387
+ const u = Promise.resolve(a).then(function(h) {
2388
+ return new Promise(function(d, p) {
2389
+ let g = d;
2390
+ t.isImageBitmapLoader === !0 && (g = function(A) {
2391
+ const m = new ft(A);
2392
+ m.needsUpdate = !0, d(m);
2393
+ }), t.load(xe.resolveURL(h, r.path), g, void 0, p);
2394
+ });
2395
+ }).then(function(h) {
2396
+ return l === !0 && c.revokeObjectURL(a), K(h, o), h.userData.mimeType = o.mimeType || lr(o.uri), h;
2397
+ }).catch(function(h) {
2398
+ throw console.error("THREE.GLTFLoader: Couldn't load texture", a), h;
2399
+ });
2400
+ return this.sourceCache[e] = u, u;
2401
+ }
2402
+ /**
2403
+ * Asynchronously assigns a texture to the given material parameters.
2404
+ *
2405
+ * @param {Object} materialParams
2406
+ * @param {string} mapName
2407
+ * @param {Object} mapDef
2408
+ * @param {string} colorSpace
2409
+ * @return {Promise<Texture>}
2410
+ */
2411
+ assignTexture(e, t, s, n) {
2412
+ const r = this;
2413
+ return this.getDependency("texture", s.index).then(function(o) {
2414
+ if (!o) return null;
2415
+ if (s.texCoord !== void 0 && s.texCoord > 0 && (o = o.clone(), o.channel = s.texCoord), r.extensions[E.KHR_TEXTURE_TRANSFORM]) {
2416
+ const c = s.extensions !== void 0 ? s.extensions[E.KHR_TEXTURE_TRANSFORM] : void 0;
2417
+ if (c) {
2418
+ const a = r.associations.get(o);
2419
+ o = r.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(o, c), r.associations.set(o, a);
2420
+ }
2421
+ }
2422
+ return n !== void 0 && (o.colorSpace = n), e[t] = o, o;
2423
+ });
2424
+ }
2425
+ /**
2426
+ * Assigns final material to a Mesh, Line, or Points instance. The instance
2427
+ * already has a material (generated from the glTF material options alone)
2428
+ * but reuse of the same glTF material may require multiple threejs materials
2429
+ * to accommodate different primitive types, defines, etc. New materials will
2430
+ * be created if necessary, and reused from a cache.
2431
+ * @param {Object3D} mesh Mesh, Line, or Points instance.
2432
+ */
2433
+ assignFinalMaterial(e) {
2434
+ const t = e.geometry;
2435
+ let s = e.material;
2436
+ const n = t.attributes.tangent === void 0, r = t.attributes.color !== void 0, o = t.attributes.normal === void 0;
2437
+ if (e.isPoints) {
2438
+ const c = "PointsMaterial:" + s.uuid;
2439
+ let a = this.cache.get(c);
2440
+ a || (a = new mn(), je.prototype.copy.call(a, s), a.color.copy(s.color), a.map = s.map, a.sizeAttenuation = !1, this.cache.add(c, a)), s = a;
2441
+ } else if (e.isLine) {
2442
+ const c = "LineBasicMaterial:" + s.uuid;
2443
+ let a = this.cache.get(c);
2444
+ a || (a = new gn(), je.prototype.copy.call(a, s), a.color.copy(s.color), a.map = s.map, this.cache.add(c, a)), s = a;
2445
+ }
2446
+ if (n || r || o) {
2447
+ let c = "ClonedMaterial:" + s.uuid + ":";
2448
+ n && (c += "derivative-tangents:"), r && (c += "vertex-colors:"), o && (c += "flat-shading:");
2449
+ let a = this.cache.get(c);
2450
+ a || (a = s.clone(), r && (a.vertexColors = !0), o && (a.flatShading = !0), n && (a.normalScale && (a.normalScale.y *= -1), a.clearcoatNormalScale && (a.clearcoatNormalScale.y *= -1)), this.cache.add(c, a), this.associations.set(a, this.associations.get(s))), s = a;
2451
+ }
2452
+ e.material = s;
2453
+ }
2454
+ getMaterialType() {
2455
+ return Ot;
2456
+ }
2457
+ /**
2458
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#materials
2459
+ * @param {number} materialIndex
2460
+ * @return {Promise<Material>}
2461
+ */
2462
+ loadMaterial(e) {
2463
+ const t = this, s = this.json, n = this.extensions, r = s.materials[e];
2464
+ let o;
2465
+ const c = {}, a = r.extensions || {}, l = [];
2466
+ if (a[E.KHR_MATERIALS_UNLIT]) {
2467
+ const h = n[E.KHR_MATERIALS_UNLIT];
2468
+ o = h.getMaterialType(), l.push(h.extendParams(c, r, t));
2469
+ } else {
2470
+ const h = r.pbrMetallicRoughness || {};
2471
+ if (c.color = new se(1, 1, 1), c.opacity = 1, Array.isArray(h.baseColorFactor)) {
2472
+ const d = h.baseColorFactor;
2473
+ c.color.setRGB(d[0], d[1], d[2], V), c.opacity = d[3];
2474
+ }
2475
+ h.baseColorTexture !== void 0 && l.push(t.assignTexture(c, "map", h.baseColorTexture, ve)), c.metalness = h.metallicFactor !== void 0 ? h.metallicFactor : 1, c.roughness = h.roughnessFactor !== void 0 ? h.roughnessFactor : 1, h.metallicRoughnessTexture !== void 0 && (l.push(t.assignTexture(c, "metalnessMap", h.metallicRoughnessTexture)), l.push(t.assignTexture(c, "roughnessMap", h.metallicRoughnessTexture))), o = this._invokeOne(function(d) {
2476
+ return d.getMaterialType && d.getMaterialType(e);
2477
+ }), l.push(Promise.all(this._invokeAll(function(d) {
2478
+ return d.extendMaterialParams && d.extendMaterialParams(e, c);
2479
+ })));
2480
+ }
2481
+ r.doubleSided === !0 && (c.side = Ie);
2482
+ const u = r.alphaMode || Qe.OPAQUE;
2483
+ if (u === Qe.BLEND ? (c.transparent = !0, c.depthWrite = !1) : (c.transparent = !1, u === Qe.MASK && (c.alphaTest = r.alphaCutoff !== void 0 ? r.alphaCutoff : 0.5)), r.normalTexture !== void 0 && o !== Te && (l.push(t.assignTexture(c, "normalMap", r.normalTexture)), c.normalScale = new It(1, 1), r.normalTexture.scale !== void 0)) {
2484
+ const h = r.normalTexture.scale;
2485
+ c.normalScale.set(h, h);
2486
+ }
2487
+ if (r.occlusionTexture !== void 0 && o !== Te && (l.push(t.assignTexture(c, "aoMap", r.occlusionTexture)), r.occlusionTexture.strength !== void 0 && (c.aoMapIntensity = r.occlusionTexture.strength)), r.emissiveFactor !== void 0 && o !== Te) {
2488
+ const h = r.emissiveFactor;
2489
+ c.emissive = new se().setRGB(h[0], h[1], h[2], V);
2490
+ }
2491
+ return r.emissiveTexture !== void 0 && o !== Te && l.push(t.assignTexture(c, "emissiveMap", r.emissiveTexture, ve)), Promise.all(l).then(function() {
2492
+ const h = new o(c);
2493
+ return r.name && (h.name = r.name), K(h, r), t.associations.set(h, { materials: e }), r.extensions && ee(n, h, r), h;
2494
+ });
2495
+ }
2496
+ /**
2497
+ * When Object3D instances are targeted by animation, they need unique names.
2498
+ *
2499
+ * @param {String} originalName
2500
+ * @return {String}
2501
+ */
2502
+ createUniqueName(e) {
2503
+ const t = An.sanitizeNodeName(e || "");
2504
+ return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
2505
+ }
2506
+ /**
2507
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#geometry
2508
+ *
2509
+ * Creates BufferGeometries from primitives.
2510
+ *
2511
+ * @param {Array<GLTF.Primitive>} primitives
2512
+ * @return {Promise<Array<BufferGeometry>>}
2513
+ */
2514
+ loadGeometries(e) {
2515
+ const t = this, s = this.extensions, n = this.primitiveCache;
2516
+ function r(c) {
2517
+ return s[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c, t).then(function(a) {
2518
+ return yt(a, c, t);
2519
+ });
2520
+ }
2521
+ const o = [];
2522
+ for (let c = 0, a = e.length; c < a; c++) {
2523
+ const l = e[c], u = cr(l), h = n[u];
2524
+ if (h)
2525
+ o.push(h.promise);
2526
+ else {
2527
+ let d;
2528
+ l.extensions && l.extensions[E.KHR_DRACO_MESH_COMPRESSION] ? d = r(l) : d = yt(new Tn(), l, t), n[u] = { primitive: l, promise: d }, o.push(d);
2529
+ }
2530
+ }
2531
+ return Promise.all(o);
2532
+ }
2533
+ /**
2534
+ * Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#meshes
2535
+ * @param {number} meshIndex
2536
+ * @return {Promise<Group|Mesh|SkinnedMesh>}
2537
+ */
2538
+ loadMesh(e) {
2539
+ const t = this, s = this.json, n = this.extensions, r = s.meshes[e], o = r.primitives, c = [];
2540
+ for (let a = 0, l = o.length; a < l; a++) {
2541
+ const u = o[a].material === void 0 ? or(this.cache) : this.getDependency("material", o[a].material);
2542
+ c.push(u);
2543
+ }
2544
+ return c.push(t.loadGeometries(o)), Promise.all(c).then(function(a) {
2545
+ const l = a.slice(0, a.length - 1), u = a[a.length - 1], h = [];
2546
+ for (let p = 0, g = u.length; p < g; p++) {
2547
+ const A = u[p], m = o[p];
2548
+ let f;
2549
+ const x = l[p];
2550
+ if (m.mode === O.TRIANGLES || m.mode === O.TRIANGLE_STRIP || m.mode === O.TRIANGLE_FAN || m.mode === void 0)
2551
+ f = r.isSkinnedMesh === !0 ? new xn(A, x) : new vn(A, x), f.isSkinnedMesh === !0 && f.normalizeSkinWeights(), m.mode === O.TRIANGLE_STRIP ? f.geometry = Rt(f.geometry, _t) : m.mode === O.TRIANGLE_FAN && (f.geometry = Rt(f.geometry, tt));
2552
+ else if (m.mode === O.LINES)
2553
+ f = new bn(A, x);
2554
+ else if (m.mode === O.LINE_STRIP)
2555
+ f = new En(A, x);
2556
+ else if (m.mode === O.LINE_LOOP)
2557
+ f = new Rn(A, x);
2558
+ else if (m.mode === O.POINTS)
2559
+ f = new Mn(A, x);
2560
+ else
2561
+ throw new Error("THREE.GLTFLoader: Primitive mode unsupported: " + m.mode);
2562
+ Object.keys(f.geometry.morphAttributes).length > 0 && ar(f, r), f.name = t.createUniqueName(r.name || "mesh_" + e), K(f, r), m.extensions && ee(n, f, m), t.assignFinalMaterial(f), h.push(f);
2563
+ }
2564
+ for (let p = 0, g = h.length; p < g; p++)
2565
+ t.associations.set(h[p], {
2566
+ meshes: e,
2567
+ primitives: p
2568
+ });
2569
+ if (h.length === 1)
2570
+ return r.extensions && ee(n, h[0], r), h[0];
2571
+ const d = new Xe();
2572
+ r.extensions && ee(n, d, r), t.associations.set(d, { meshes: e });
2573
+ for (let p = 0, g = h.length; p < g; p++)
2574
+ d.add(h[p]);
2575
+ return d;
2576
+ });
2577
+ }
2578
+ /**
2579
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#cameras
2580
+ * @param {number} cameraIndex
2581
+ * @return {Promise<THREE.Camera>}
2582
+ */
2583
+ loadCamera(e) {
2584
+ let t;
2585
+ const s = this.json.cameras[e], n = s[s.type];
2586
+ if (!n) {
2587
+ console.warn("THREE.GLTFLoader: Missing camera parameters.");
2588
+ return;
2589
+ }
2590
+ return s.type === "perspective" ? t = new wn(Sn.radToDeg(n.yfov), n.aspectRatio || 1, n.znear || 1, n.zfar || 2e6) : s.type === "orthographic" && (t = new yn(-n.xmag, n.xmag, n.ymag, -n.ymag, n.znear, n.zfar)), s.name && (t.name = this.createUniqueName(s.name)), K(t, s), Promise.resolve(t);
2591
+ }
2592
+ /**
2593
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins
2594
+ * @param {number} skinIndex
2595
+ * @return {Promise<Skeleton>}
2596
+ */
2597
+ loadSkin(e) {
2598
+ const t = this.json.skins[e], s = [];
2599
+ for (let n = 0, r = t.joints.length; n < r; n++)
2600
+ s.push(this._loadNodeShallow(t.joints[n]));
2601
+ return t.inverseBindMatrices !== void 0 ? s.push(this.getDependency("accessor", t.inverseBindMatrices)) : s.push(null), Promise.all(s).then(function(n) {
2602
+ const r = n.pop(), o = n, c = [], a = [];
2603
+ for (let l = 0, u = o.length; l < u; l++) {
2604
+ const h = o[l];
2605
+ if (h) {
2606
+ c.push(h);
2607
+ const d = new Ne();
2608
+ r !== null && d.fromArray(r.array, l * 16), a.push(d);
2609
+ } else
2610
+ console.warn('THREE.GLTFLoader: Joint "%s" could not be found.', t.joints[l]);
2611
+ }
2612
+ return new _n(c, a);
2613
+ });
2614
+ }
2615
+ /**
2616
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations
2617
+ * @param {number} animationIndex
2618
+ * @return {Promise<AnimationClip>}
2619
+ */
2620
+ loadAnimation(e) {
2621
+ const t = this.json, s = this, n = t.animations[e], r = n.name ? n.name : "animation_" + e, o = [], c = [], a = [], l = [], u = [];
2622
+ for (let h = 0, d = n.channels.length; h < d; h++) {
2623
+ const p = n.channels[h], g = n.samplers[p.sampler], A = p.target, m = A.node, f = n.parameters !== void 0 ? n.parameters[g.input] : g.input, x = n.parameters !== void 0 ? n.parameters[g.output] : g.output;
2624
+ A.node !== void 0 && (o.push(this.getDependency("node", m)), c.push(this.getDependency("accessor", f)), a.push(this.getDependency("accessor", x)), l.push(g), u.push(A));
2625
+ }
2626
+ return Promise.all([
2627
+ Promise.all(o),
2628
+ Promise.all(c),
2629
+ Promise.all(a),
2630
+ Promise.all(l),
2631
+ Promise.all(u)
2632
+ ]).then(function(h) {
2633
+ const d = h[0], p = h[1], g = h[2], A = h[3], m = h[4], f = [];
2634
+ for (let x = 0, v = d.length; x < v; x++) {
2635
+ const b = d[x], y = p[x], L = g[x], _ = A[x], D = m[x];
2636
+ if (b === void 0) continue;
2637
+ b.updateMatrix && b.updateMatrix();
2638
+ const M = s._createAnimationTracks(b, y, L, _, D);
2639
+ if (M)
2640
+ for (let P = 0; P < M.length; P++)
2641
+ f.push(M[P]);
2642
+ }
2643
+ return new Ln(r, void 0, f);
2644
+ });
2645
+ }
2646
+ createNodeMesh(e) {
2647
+ const t = this.json, s = this, n = t.nodes[e];
2648
+ return n.mesh === void 0 ? null : s.getDependency("mesh", n.mesh).then(function(r) {
2649
+ const o = s._getNodeRef(s.meshCache, n.mesh, r);
2650
+ return n.weights !== void 0 && o.traverse(function(c) {
2651
+ if (c.isMesh)
2652
+ for (let a = 0, l = n.weights.length; a < l; a++)
2653
+ c.morphTargetInfluences[a] = n.weights[a];
2654
+ }), o;
2655
+ });
2656
+ }
2657
+ /**
2658
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#nodes-and-hierarchy
2659
+ * @param {number} nodeIndex
2660
+ * @return {Promise<Object3D>}
2661
+ */
2662
+ loadNode(e) {
2663
+ const t = this.json, s = this, n = t.nodes[e], r = s._loadNodeShallow(e), o = [], c = n.children || [];
2664
+ for (let l = 0, u = c.length; l < u; l++)
2665
+ o.push(s.getDependency("node", c[l]));
2666
+ const a = n.skin === void 0 ? Promise.resolve(null) : s.getDependency("skin", n.skin);
2667
+ return Promise.all([
2668
+ r,
2669
+ Promise.all(o),
2670
+ a
2671
+ ]).then(function(l) {
2672
+ const u = l[0], h = l[1], d = l[2];
2673
+ d !== null && u.traverse(function(p) {
2674
+ p.isSkinnedMesh && p.bind(d, ur);
2675
+ });
2676
+ for (let p = 0, g = h.length; p < g; p++)
2677
+ u.add(h[p]);
2678
+ return u;
2679
+ });
2680
+ }
2681
+ // ._loadNodeShallow() parses a single node.
2682
+ // skin and child nodes are created and added in .loadNode() (no '_' prefix).
2683
+ _loadNodeShallow(e) {
2684
+ const t = this.json, s = this.extensions, n = this;
2685
+ if (this.nodeCache[e] !== void 0)
2686
+ return this.nodeCache[e];
2687
+ const r = t.nodes[e], o = r.name ? n.createUniqueName(r.name) : "", c = [], a = n._invokeOne(function(l) {
2688
+ return l.createNodeMesh && l.createNodeMesh(e);
2689
+ });
2690
+ return a && c.push(a), r.camera !== void 0 && c.push(n.getDependency("camera", r.camera).then(function(l) {
2691
+ return n._getNodeRef(n.cameraCache, r.camera, l);
2692
+ })), n._invokeAll(function(l) {
2693
+ return l.createNodeAttachment && l.createNodeAttachment(e);
2694
+ }).forEach(function(l) {
2695
+ c.push(l);
2696
+ }), this.nodeCache[e] = Promise.all(c).then(function(l) {
2697
+ let u;
2698
+ if (r.isBone === !0 ? u = new In() : l.length > 1 ? u = new Xe() : l.length === 1 ? u = l[0] : u = new Nt(), u !== l[0])
2699
+ for (let h = 0, d = l.length; h < d; h++)
2700
+ u.add(l[h]);
2701
+ if (r.name && (u.userData.name = r.name, u.name = o), K(u, r), r.extensions && ee(s, u, r), r.matrix !== void 0) {
2702
+ const h = new Ne();
2703
+ h.fromArray(r.matrix), u.applyMatrix4(h);
2704
+ } else
2705
+ r.translation !== void 0 && u.position.fromArray(r.translation), r.rotation !== void 0 && u.quaternion.fromArray(r.rotation), r.scale !== void 0 && u.scale.fromArray(r.scale);
2706
+ return n.associations.has(u) || n.associations.set(u, {}), n.associations.get(u).nodes = e, u;
2707
+ }), this.nodeCache[e];
2708
+ }
2709
+ /**
2710
+ * Specification: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#scenes
2711
+ * @param {number} sceneIndex
2712
+ * @return {Promise<Group>}
2713
+ */
2714
+ loadScene(e) {
2715
+ const t = this.extensions, s = this.json.scenes[e], n = this, r = new Xe();
2716
+ s.name && (r.name = n.createUniqueName(s.name)), K(r, s), s.extensions && ee(t, r, s);
2717
+ const o = s.nodes || [], c = [];
2718
+ for (let a = 0, l = o.length; a < l; a++)
2719
+ c.push(n.getDependency("node", o[a]));
2720
+ return Promise.all(c).then(function(a) {
2721
+ for (let u = 0, h = a.length; u < h; u++)
2722
+ r.add(a[u]);
2723
+ const l = (u) => {
2724
+ const h = /* @__PURE__ */ new Map();
2725
+ for (const [d, p] of n.associations)
2726
+ (d instanceof je || d instanceof ft) && h.set(d, p);
2727
+ return u.traverse((d) => {
2728
+ const p = n.associations.get(d);
2729
+ p != null && h.set(d, p);
2730
+ }), h;
2731
+ };
2732
+ return n.associations = l(r), r;
2733
+ });
2734
+ }
2735
+ _createAnimationTracks(e, t, s, n, r) {
2736
+ const o = [], c = e.name ? e.name : e.uuid, a = [];
2737
+ Q[r.path] === Q.weights ? e.traverse(function(d) {
2738
+ d.morphTargetInfluences && a.push(d.name ? d.name : d.uuid);
2739
+ }) : a.push(c);
2740
+ let l;
2741
+ switch (Q[r.path]) {
2742
+ case Q.weights:
2743
+ l = mt;
2744
+ break;
2745
+ case Q.rotation:
2746
+ l = gt;
2747
+ break;
2748
+ case Q.position:
2749
+ case Q.scale:
2750
+ l = pt;
2751
+ break;
2752
+ default:
2753
+ switch (s.itemSize) {
2754
+ case 1:
2755
+ l = mt;
2756
+ break;
2757
+ case 2:
2758
+ case 3:
2759
+ default:
2760
+ l = pt;
2761
+ break;
2762
+ }
2763
+ break;
2764
+ }
2765
+ const u = n.interpolation !== void 0 ? rr[n.interpolation] : Dt, h = this._getArrayFromAccessor(s);
2766
+ for (let d = 0, p = a.length; d < p; d++) {
2767
+ const g = new l(
2768
+ a[d] + "." + Q[r.path],
2769
+ t.array,
2770
+ h,
2771
+ u
2772
+ );
2773
+ n.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(g), o.push(g);
2774
+ }
2775
+ return o;
2776
+ }
2777
+ _getArrayFromAccessor(e) {
2778
+ let t = e.array;
2779
+ if (e.normalized) {
2780
+ const s = it(t.constructor), n = new Float32Array(t.length);
2781
+ for (let r = 0, o = t.length; r < o; r++)
2782
+ n[r] = t[r] * s;
2783
+ t = n;
2784
+ }
2785
+ return t;
2786
+ }
2787
+ _createCubicSplineTrackInterpolant(e) {
2788
+ e.createInterpolant = function(s) {
2789
+ const n = this instanceof gt ? sr : Xt;
2790
+ return new n(this.times, this.values, this.getValueSize() / 3, s);
2791
+ }, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
2792
+ }
2793
+ }
2794
+ function dr(i, e, t) {
2795
+ const s = e.attributes, n = new Fn();
2796
+ if (s.POSITION !== void 0) {
2797
+ const c = t.json.accessors[s.POSITION], a = c.min, l = c.max;
2798
+ if (a !== void 0 && l !== void 0) {
2799
+ if (n.set(
2800
+ new te(a[0], a[1], a[2]),
2801
+ new te(l[0], l[1], l[2])
2802
+ ), c.normalized) {
2803
+ const u = it(le[c.componentType]);
2804
+ n.min.multiplyScalar(u), n.max.multiplyScalar(u);
2805
+ }
2806
+ } else {
2807
+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
2808
+ return;
2809
+ }
2810
+ } else
2811
+ return;
2812
+ const r = e.targets;
2813
+ if (r !== void 0) {
2814
+ const c = new te(), a = new te();
2815
+ for (let l = 0, u = r.length; l < u; l++) {
2816
+ const h = r[l];
2817
+ if (h.POSITION !== void 0) {
2818
+ const d = t.json.accessors[h.POSITION], p = d.min, g = d.max;
2819
+ if (p !== void 0 && g !== void 0) {
2820
+ if (a.setX(Math.max(Math.abs(p[0]), Math.abs(g[0]))), a.setY(Math.max(Math.abs(p[1]), Math.abs(g[1]))), a.setZ(Math.max(Math.abs(p[2]), Math.abs(g[2]))), d.normalized) {
2821
+ const A = it(le[d.componentType]);
2822
+ a.multiplyScalar(A);
2823
+ }
2824
+ c.max(a);
2825
+ } else
2826
+ console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
2827
+ }
2828
+ }
2829
+ n.expandByVector(c);
2830
+ }
2831
+ i.boundingBox = n;
2832
+ const o = new On();
2833
+ n.getCenter(o.center), o.radius = n.min.distanceTo(n.max) / 2, i.boundingSphere = o;
2834
+ }
2835
+ function yt(i, e, t) {
2836
+ const s = e.attributes, n = [];
2837
+ function r(o, c) {
2838
+ return t.getDependency("accessor", o).then(function(a) {
2839
+ i.setAttribute(c, a);
2840
+ });
2841
+ }
2842
+ for (const o in s) {
2843
+ const c = ot[o] || o.toLowerCase();
2844
+ c in i.attributes || n.push(r(s[o], c));
2845
+ }
2846
+ if (e.indices !== void 0 && !i.index) {
2847
+ const o = t.getDependency("accessor", e.indices).then(function(c) {
2848
+ i.setIndex(c);
2849
+ });
2850
+ n.push(o);
2851
+ }
2852
+ return At.workingColorSpace !== V && "COLOR_0" in s && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${At.workingColorSpace}" not supported.`), K(i, e), dr(i, e, t), Promise.all(n).then(function() {
2853
+ return e.targets !== void 0 ? ir(i, e.targets, t) : i;
2854
+ });
2855
+ }
2856
+ const Ce = [0, 0, -10], ne = [0.5, 0.5, 0.5], Kt = 1, Je = /* @__PURE__ */ new Map(), fr = (i) => {
2857
+ const e = Je.get(i);
2858
+ if (e) return e;
2859
+ const t = new Ns(), s = Bt(i).then(
2860
+ (n) => new Promise((r, o) => {
2861
+ t.parse(n, "", r, o);
2862
+ })
2863
+ ).catch((n) => {
2864
+ throw Je.delete(i), n;
2865
+ });
2866
+ return Je.set(i, s), s;
2867
+ }, Yt = ({
2868
+ position: i,
2869
+ rotation: e,
2870
+ scale: t,
2871
+ url: s,
2872
+ showDebugMaterial: n = !1,
2873
+ opacity: r = Kt
2874
+ }) => {
2875
+ const o = s ?? new URL("/assets/xr/3d-models/head-occluder-v2.glb", Pe.assetStorageEndpoint).toString(), [c, a] = at(null);
2876
+ $(() => {
2877
+ let u = !1;
2878
+ return fr(o).then((h) => {
2879
+ u || a(h.scene);
2880
+ }).catch((h) => {
2881
+ u || console.error(`${Pe.loggerPrefix} head occluder load failed`, h);
2882
+ }), () => {
2883
+ u = !0;
2884
+ };
2885
+ }, [o]);
2886
+ const l = j(() => {
2887
+ if (!c) return null;
2888
+ const u = c.clone();
2889
+ return u.traverse((h) => {
2890
+ h instanceof R.Mesh && (h.material = new R.MeshStandardMaterial({
2891
+ color: 15132390,
2892
+ colorWrite: n,
2893
+ depthWrite: !0,
2894
+ opacity: n ? r : 1,
2895
+ side: R.DoubleSide,
2896
+ transparent: n
2897
+ }));
2898
+ }), u;
2899
+ }, [c, n, r]);
2900
+ return $(() => {
2901
+ if (l)
2902
+ return () => {
2903
+ l.traverse((u) => {
2904
+ u instanceof R.Mesh && u.material.dispose();
2905
+ });
2906
+ };
2907
+ }, [l]), l ? (i ? l.position.set(i[0], i[1], i[2]) : l.position.set(
2908
+ Ce[0],
2909
+ Ce[1],
2910
+ Ce[2]
2911
+ ), e && l.rotation.set(e[0], e[1], e[2]), t ? l.scale.set(t[0], t[1], t[2]) : l.scale.set(
2912
+ ne[0],
2913
+ ne[1],
2914
+ ne[2]
2915
+ ), l.renderOrder = -1, /* @__PURE__ */ T("primitive", { object: l })) : null;
2916
+ }, pr = 4, Yr = ({
2917
+ children: i,
2918
+ faceIndex: e = 0,
2919
+ numFaces: t = pr,
2920
+ scaleWithFace: s = !0,
2921
+ occluder: n = !0,
2922
+ showFaceMesh: r = !1,
2923
+ faceMeshMaterial: o
2924
+ }) => {
2925
+ const c = j(
2926
+ () => new R.MeshBasicMaterial({
2927
+ color: "#22c55e",
2928
+ side: R.BackSide,
2929
+ transparent: !0,
2930
+ opacity: 0.35,
2931
+ depthWrite: !1
2932
+ }),
2933
+ []
2934
+ ), a = n === !1 ? null : n === !0 ? {} : n;
2935
+ return /* @__PURE__ */ w(Hn, { faceIndex: e, numFaces: t, scaleWithFace: s, children: [
2936
+ a && /* @__PURE__ */ T(
2937
+ Yt,
2938
+ {
2939
+ position: a.position ?? Ce,
2940
+ rotation: a.rotation,
2941
+ scale: a.scale ?? ne,
2942
+ url: a.url,
2943
+ showDebugMaterial: a.showDebugMaterial,
2944
+ opacity: a.opacity ?? Kt
2945
+ }
2946
+ ),
2947
+ i,
2948
+ r && /* @__PURE__ */ T(
2949
+ jn,
2950
+ {
2951
+ faceIndex: e,
2952
+ numFaces: t,
2953
+ material: o ?? c
2954
+ }
2955
+ )
2956
+ ] });
2957
+ }, mr = 57, gr = 15.5, et = mr / Math.PI / gr, Ar = -0.134, Tr = -0.024, Y = (i, e, t) => Math.min(t, Math.max(e, i)), Vt = (i, e) => i * e - e / 2, Wt = (i, e) => -(i * e - e / 2), xr = ({
2958
+ eyeMidX: i,
2959
+ noseX: e,
2960
+ offsetX: t,
2961
+ rawYaw: s,
2962
+ sideMidX: n
2963
+ }) => {
2964
+ const r = Y((Math.abs(s) - 0.18) / 0.42, 0, 1), o = n * 0.75 + i * 0.25, c = i * 0.7 + e * 0.3;
2965
+ return o * (1 - r) + c * r + t;
2966
+ }, Vr = ({
2967
+ baseScale: i,
2968
+ pitchRadians: e
2969
+ }) => {
2970
+ const t = e * 180 / Math.PI, n = 1 + Y((t - 6) / 22, 0, 1) * 0.22;
2971
+ return [i[0] * n, i[1] * n, i[2] * n];
2972
+ }, Wr = ({ yawRadians: i }) => {
2973
+ const e = Math.abs(i * 180 / Math.PI), s = 0.066 * Y((e - 8) / 12, 0, 1);
2974
+ return Math.sign(i) * s;
2975
+ }, zr = ({
2976
+ pitchRadians: i
2977
+ }) => {
2978
+ const e = i * 180 / Math.PI;
2979
+ return -0.026 * Y((-e - 6) / 18, 0, 1);
2980
+ }, qr = ({
2981
+ baseOffset: i,
2982
+ yawRadians: e
2983
+ }) => {
2984
+ const t = Math.abs(e * 180 / Math.PI), s = Y((t - 8) / 24, 0, 1);
2985
+ return i + s * 0.25;
2986
+ }, Zr = ({
2987
+ baseOffsetY: i,
2988
+ baseScaleY: e,
2989
+ face: t
2990
+ }) => {
2991
+ if (!t || t.bounds.width <= 0)
2992
+ return {
2993
+ aspectRatio: 0,
2994
+ normalizedAspect: 0,
2995
+ scaleY: e,
2996
+ offsetY: i
2997
+ };
2998
+ const s = t.bounds.height / t.bounds.width, n = Y((s - 1.55) / 0.35, -1, 1);
2999
+ return {
3000
+ aspectRatio: s,
3001
+ normalizedAspect: n,
3002
+ scaleY: e + n * 0.06,
3003
+ offsetY: i + n * 5e-3
3004
+ };
3005
+ }, vr = ({
3006
+ face: i,
3007
+ offsetX: e,
3008
+ offsetY: t,
3009
+ scaleX: s,
3010
+ scaleY: n
3011
+ }) => {
3012
+ const r = i.bounds.width * s, o = i.bounds.height * n, c = i.bounds.centerX + e, a = i.bounds.centerY + t;
3013
+ return {
3014
+ x: c - r * 0.5,
3015
+ y: a - o * 0.5,
3016
+ width: r,
3017
+ height: o,
3018
+ centerX: c,
3019
+ centerY: a
3020
+ };
3021
+ }, br = ({
3022
+ face: i,
3023
+ height: e,
3024
+ lockDepth: t,
3025
+ lockRotation: s,
3026
+ model: n,
3027
+ offsetX: r,
3028
+ offsetY: o,
3029
+ scaleX: c,
3030
+ scaleY: a,
3031
+ scaleZ: l,
3032
+ width: u
3033
+ }) => {
3034
+ const h = vr({
3035
+ face: i,
3036
+ offsetX: r,
3037
+ offsetY: o,
3038
+ scaleX: c,
3039
+ scaleY: a
3040
+ }), d = i.landmarks[33], p = i.landmarks[263], g = i.landmarks[234], A = i.landmarks[454], m = i.landmarks[1], f = i.landmarks[10], x = i.landmarks[152], v = h.width * u, b = h.height * e, y = d && p ? (d.x + p.x) * 0.5 : i.bounds.centerX, L = d && p ? (d.y + p.y) * 0.5 : i.bounds.centerY - i.bounds.height * 0.15, _ = g && A ? (g.x + A.x) * 0.5 : y, D = (f == null ? void 0 : f.y) ?? i.bounds.minY, M = (x == null ? void 0 : x.y) ?? i.bounds.maxY, P = (D + M) * 0.5, re = d && p ? Math.atan2(p.y - d.y, p.x - d.x) : 0, I = m && i.bounds.width > 0 ? Y((m.x - i.bounds.centerX) / (i.bounds.width * 0.5), -1, 1) * 0.75 : 0, W = xr({
3041
+ eyeMidX: y,
3042
+ noseX: (m == null ? void 0 : m.x) ?? y,
3043
+ offsetX: r,
3044
+ rawYaw: I,
3045
+ sideMidX: _
3046
+ }), S = P * 0.75 + L * 0.25 + o, oe = n === "v2" ? Vt(W, u) : h.centerX * u - u / 2, z = n === "v2" ? Wt(i.bounds.centerY + o * 0.75, e) : -(h.centerY * e - e / 2), q = f && m ? Math.max(1e-4, m.y - f.y) : i.bounds.height * 0.42, ue = m && x ? Math.max(1e-4, x.y - m.y) : i.bounds.height * 0.58, he = (ue - q) / (ue + q), de = Y((he - Ar) / 0.28, -1, 1) * 0.58, fe = m && i.bounds.height > 0 ? Y(
3047
+ (i.bounds.centerY - m.y) / (i.bounds.height * 0.5) - Tr,
3048
+ -1,
3049
+ 1
3050
+ ) * 0.18 : 0, ie = de * 0.82 + fe * 0.18, ae = s ? 0 : n === "v2" ? I * 0.72 : I, pe = s ? 0 : n === "v2" ? -ie * 0.78 : -ie, me = s ? 0 : -re, be = t ? v * et : n === "v2" ? v * (et + Math.abs(ae) * 0.18) : v * et;
3051
+ return {
3052
+ centerXPx: oe,
3053
+ centerYPx: z,
3054
+ depthPx: be * l,
3055
+ heightPx: b,
3056
+ pitch: pe,
3057
+ rawPitch: ie,
3058
+ rawPitchFromBalance: de,
3059
+ rawPitchFromCenter: fe,
3060
+ rawYaw: I,
3061
+ rotationZ: me,
3062
+ roll: re,
3063
+ shape: h,
3064
+ skullAnchorX: W,
3065
+ skullAnchorY: S,
3066
+ verticalBalance: he,
3067
+ widthPx: v,
3068
+ yaw: ae
3069
+ };
3070
+ }, Er = ({
3071
+ lockDepth: i,
3072
+ lockRotation: e,
3073
+ model: t,
3074
+ face: s,
3075
+ height: n,
3076
+ headDepthOffset: r,
3077
+ offsetX: o,
3078
+ offsetY: c,
3079
+ rotationOffsetX: a,
3080
+ rotationOffsetY: l,
3081
+ rotationOffsetZ: u,
3082
+ scaleX: h,
3083
+ scaleY: d,
3084
+ scaleZ: p,
3085
+ skullCenterMode: g,
3086
+ skullVerticalBias: A,
3087
+ width: m
3088
+ }) => zt({
3089
+ lockDepth: i,
3090
+ lockRotation: e,
3091
+ model: t,
3092
+ face: s,
3093
+ height: n,
3094
+ headDepthOffset: r,
3095
+ offsetX: o,
3096
+ offsetY: c,
3097
+ rotationOffsetX: a,
3098
+ rotationOffsetY: l,
3099
+ rotationOffsetZ: u,
3100
+ scaleX: h,
3101
+ scaleY: d,
3102
+ scaleZ: p,
3103
+ skullCenterMode: g,
3104
+ skullVerticalBias: A,
3105
+ width: m
3106
+ }).pose, zt = ({
3107
+ lockDepth: i,
3108
+ lockRotation: e,
3109
+ model: t,
3110
+ face: s,
3111
+ height: n,
3112
+ headDepthOffset: r,
3113
+ offsetX: o,
3114
+ offsetY: c,
3115
+ rotationOffsetX: a,
3116
+ rotationOffsetY: l,
3117
+ rotationOffsetZ: u,
3118
+ scaleX: h,
3119
+ scaleY: d,
3120
+ scaleZ: p,
3121
+ skullCenterMode: g,
3122
+ skullVerticalBias: A,
3123
+ width: m
3124
+ }) => {
3125
+ const f = br({
3126
+ face: s,
3127
+ height: n,
3128
+ lockDepth: i,
3129
+ lockRotation: e,
3130
+ model: t,
3131
+ offsetX: o,
3132
+ offsetY: c,
3133
+ scaleX: h,
3134
+ scaleY: d,
3135
+ scaleZ: p,
3136
+ width: m
3137
+ });
3138
+ if (g) {
3139
+ const v = new te(
3140
+ 0,
3141
+ f.heightPx * A,
3142
+ -f.depthPx * r
3143
+ ).applyEuler(
3144
+ new Dn(f.pitch, f.yaw, f.rotationZ, "XYZ")
3145
+ ), b = Vt(f.skullAnchorX, m), y = Wt(f.skullAnchorY, n);
3146
+ return {
3147
+ pose: {
3148
+ boxCenterZ: v.z,
3149
+ centerX: b + v.x,
3150
+ centerY: y + v.y,
3151
+ width: f.widthPx,
3152
+ height: f.heightPx,
3153
+ depth: f.depthPx,
3154
+ rotationX: f.pitch + a,
3155
+ rotationY: f.yaw + l,
3156
+ rotationZ: f.rotationZ + u
3157
+ },
3158
+ debugMetrics: {
3159
+ face: {
3160
+ centerX: f.shape.centerX,
3161
+ centerY: f.shape.centerY,
3162
+ width: f.shape.width,
3163
+ height: f.shape.height
3164
+ },
3165
+ normalized: {
3166
+ rawPitch: f.rawPitch,
3167
+ rawPitchFromBalance: f.rawPitchFromBalance,
3168
+ rawPitchFromCenter: f.rawPitchFromCenter,
3169
+ rawYaw: f.rawYaw,
3170
+ roll: f.roll,
3171
+ verticalBalance: f.verticalBalance
3172
+ },
3173
+ pose: {
3174
+ pitch: f.pitch,
3175
+ yaw: f.yaw,
3176
+ rotationX: f.pitch + a,
3177
+ rotationY: f.yaw + l,
3178
+ rotationZ: f.rotationZ + u
3179
+ },
3180
+ skullAnchor: {
3181
+ x: f.skullAnchorX,
3182
+ y: f.skullAnchorY
3183
+ },
3184
+ center: {
3185
+ x: b + v.x,
3186
+ y: y + v.y,
3187
+ z: v.z
3188
+ },
3189
+ depthPx: f.depthPx,
3190
+ screen: {
3191
+ widthPx: f.widthPx,
3192
+ heightPx: f.heightPx
3193
+ }
3194
+ }
3195
+ };
3196
+ }
3197
+ return {
3198
+ pose: {
3199
+ boxCenterZ: -f.depthPx * r,
3200
+ centerX: f.centerXPx,
3201
+ centerY: f.centerYPx,
3202
+ width: f.widthPx,
3203
+ height: f.heightPx,
3204
+ depth: f.depthPx,
3205
+ rotationX: f.pitch + a,
3206
+ rotationY: f.yaw + l,
3207
+ rotationZ: f.rotationZ + u
3208
+ },
3209
+ debugMetrics: {
3210
+ face: {
3211
+ centerX: f.shape.centerX,
3212
+ centerY: f.shape.centerY,
3213
+ width: f.shape.width,
3214
+ height: f.shape.height
3215
+ },
3216
+ normalized: {
3217
+ rawPitch: f.rawPitch,
3218
+ rawPitchFromBalance: f.rawPitchFromBalance,
3219
+ rawPitchFromCenter: f.rawPitchFromCenter,
3220
+ rawYaw: f.rawYaw,
3221
+ roll: f.roll,
3222
+ verticalBalance: f.verticalBalance
3223
+ },
3224
+ pose: {
3225
+ pitch: f.pitch,
3226
+ yaw: f.yaw,
3227
+ rotationX: f.pitch + a,
3228
+ rotationY: f.yaw + l,
3229
+ rotationZ: f.rotationZ + u
3230
+ },
3231
+ skullAnchor: {
3232
+ x: f.skullAnchorX,
3233
+ y: f.skullAnchorY
3234
+ },
3235
+ center: {
3236
+ x: f.centerXPx,
3237
+ y: f.centerYPx,
3238
+ z: -f.depthPx * r
3239
+ },
3240
+ depthPx: f.depthPx,
3241
+ screen: {
3242
+ widthPx: f.widthPx,
3243
+ heightPx: f.heightPx
3244
+ }
3245
+ }
3246
+ };
3247
+ }, Qr = ({
3248
+ lockDepth: i,
3249
+ lockRotation: e,
3250
+ model: t,
3251
+ face: s,
3252
+ height: n,
3253
+ headDepthOffset: r,
3254
+ offsetX: o,
3255
+ offsetY: c,
3256
+ rotationOffsetX: a,
3257
+ rotationOffsetY: l,
3258
+ rotationOffsetZ: u,
3259
+ scaleX: h,
3260
+ scaleY: d,
3261
+ scaleZ: p,
3262
+ skullCenterMode: g,
3263
+ skullVerticalBias: A,
3264
+ width: m
3265
+ }) => zt({
3266
+ lockDepth: i,
3267
+ lockRotation: e,
3268
+ model: t,
3269
+ face: s,
3270
+ height: n,
3271
+ headDepthOffset: r,
3272
+ offsetX: o,
3273
+ offsetY: c,
3274
+ rotationOffsetX: a,
3275
+ rotationOffsetY: l,
3276
+ rotationOffsetZ: u,
3277
+ scaleX: h,
3278
+ scaleY: d,
3279
+ scaleZ: p,
3280
+ skullCenterMode: g,
3281
+ skullVerticalBias: A,
3282
+ width: m
3283
+ }).debugMetrics, $r = ({
3284
+ boxColor: i,
3285
+ boxOpacity: e,
3286
+ face: t,
3287
+ headDepthOffset: s,
3288
+ lockDepth: n,
3289
+ lockRotation: r,
3290
+ model: o,
3291
+ occluderOffset: c,
3292
+ occluderOpacity: a,
3293
+ occluderScale: l,
3294
+ showOccluderProxy: u = !1,
3295
+ offsetX: h,
3296
+ offsetY: d,
3297
+ pose: p,
3298
+ rotationOffsetX: g,
3299
+ rotationOffsetY: A,
3300
+ rotationOffsetZ: m,
3301
+ scaleX: f,
3302
+ scaleY: x,
3303
+ scaleZ: v,
3304
+ show: b,
3305
+ showCenterDot: y,
3306
+ showFacePlaneReference: L,
3307
+ showGizmo: _,
3308
+ showHeadOccluder: D,
3309
+ skullCenterMode: M,
3310
+ skullVerticalBias: P,
3311
+ url: re,
3312
+ viewportHeight: I,
3313
+ viewportWidth: W
3314
+ }) => {
3315
+ const S = j(() => p || (!t || W <= 0 || I <= 0 ? null : Er({
3316
+ face: t,
3317
+ width: W,
3318
+ height: I,
3319
+ headDepthOffset: s,
3320
+ lockDepth: n,
3321
+ lockRotation: r,
3322
+ model: o,
3323
+ offsetX: h,
3324
+ offsetY: d,
3325
+ rotationOffsetX: g,
3326
+ rotationOffsetY: A,
3327
+ rotationOffsetZ: m,
3328
+ scaleX: f,
3329
+ scaleY: x,
3330
+ scaleZ: v,
3331
+ skullCenterMode: M,
3332
+ skullVerticalBias: P
3333
+ })), [
3334
+ t,
3335
+ s,
3336
+ n,
3337
+ r,
3338
+ o,
3339
+ h,
3340
+ d,
3341
+ g,
3342
+ A,
3343
+ m,
3344
+ f,
3345
+ x,
3346
+ v,
3347
+ M,
3348
+ P,
3349
+ p,
3350
+ I,
3351
+ W
3352
+ ]);
3353
+ if (!b || !S) return null;
3354
+ const oe = M ? [0, -S.height * P, S.depth * s] : [0, 0, 0], z = S.height, q = [
3355
+ ne[0] * l[0] * z,
3356
+ ne[1] * l[1] * z,
3357
+ ne[2] * l[2] * z
3358
+ ];
3359
+ return /* @__PURE__ */ w(rt, { children: [
3360
+ /* @__PURE__ */ w(
3361
+ "group",
3362
+ {
3363
+ position: [S.centerX, S.centerY, S.boxCenterZ],
3364
+ rotation: [S.rotationX, S.rotationY, S.rotationZ],
3365
+ children: [
3366
+ /* @__PURE__ */ T("group", { scale: [S.width, S.height, S.depth], children: e > 0 && /* @__PURE__ */ w("mesh", { children: [
3367
+ /* @__PURE__ */ T("boxGeometry", { args: [1, 1, 1] }),
3368
+ /* @__PURE__ */ T("meshBasicMaterial", { color: i, wireframe: !0, transparent: !0, opacity: e })
3369
+ ] }) }),
3370
+ y && /* @__PURE__ */ w("mesh", { children: [
3371
+ /* @__PURE__ */ T("sphereGeometry", { args: [6, 20, 20] }),
3372
+ /* @__PURE__ */ T("meshBasicMaterial", { color: i })
3373
+ ] }),
3374
+ L && /* @__PURE__ */ w("group", { position: oe, children: [
3375
+ /* @__PURE__ */ w("mesh", { rotation: [0, 0, Math.PI / 4], children: [
3376
+ /* @__PURE__ */ T("ringGeometry", { args: [6, 8, 24] }),
3377
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#f8fafc", side: Ie })
3378
+ ] }),
3379
+ /* @__PURE__ */ w("mesh", { rotation: [0, 0, Math.PI / 2], children: [
3380
+ /* @__PURE__ */ T("planeGeometry", { args: [3, 16] }),
3381
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#f8fafc", transparent: !0, opacity: 0.9, side: Ie })
3382
+ ] }),
3383
+ /* @__PURE__ */ w("mesh", { children: [
3384
+ /* @__PURE__ */ T("planeGeometry", { args: [16, 3] }),
3385
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#f8fafc", transparent: !0, opacity: 0.9, side: Ie })
3386
+ ] })
3387
+ ] }),
3388
+ D && /* @__PURE__ */ w(rt, { children: [
3389
+ u && /* @__PURE__ */ w("mesh", { position: c, scale: q, renderOrder: 20, children: [
3390
+ /* @__PURE__ */ T("sphereGeometry", { args: [1, 24, 16] }),
3391
+ /* @__PURE__ */ T(
3392
+ "meshBasicMaterial",
3393
+ {
3394
+ color: "#facc15",
3395
+ wireframe: !0,
3396
+ transparent: !0,
3397
+ opacity: 0.95,
3398
+ depthTest: !1,
3399
+ depthWrite: !1
3400
+ }
3401
+ )
3402
+ ] }),
3403
+ /* @__PURE__ */ T(
3404
+ Yt,
3405
+ {
3406
+ opacity: a,
3407
+ position: c,
3408
+ scale: q,
3409
+ showDebugMaterial: !0,
3410
+ url: re
3411
+ }
3412
+ )
3413
+ ] })
3414
+ ]
3415
+ }
3416
+ ),
3417
+ _ && /* @__PURE__ */ T(
3418
+ "group",
3419
+ {
3420
+ position: [S.centerX, S.centerY, S.boxCenterZ],
3421
+ rotation: [S.rotationX, S.rotationY, S.rotationZ],
3422
+ renderOrder: 10,
3423
+ children: /* @__PURE__ */ w("group", { children: [
3424
+ /* @__PURE__ */ w("mesh", { children: [
3425
+ /* @__PURE__ */ T("sphereGeometry", { args: [6, 20, 20] }),
3426
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#e2e8f0", depthTest: !1, depthWrite: !1 })
3427
+ ] }),
3428
+ /* @__PURE__ */ w("mesh", { position: [18, 0, 0], rotation: [0, 0, -Math.PI / 2], children: [
3429
+ /* @__PURE__ */ T("cylinderGeometry", { args: [1.6, 1.6, 24, 12] }),
3430
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#ef4444", depthTest: !1, depthWrite: !1 })
3431
+ ] }),
3432
+ /* @__PURE__ */ w("mesh", { position: [34, 0, 0], rotation: [0, 0, -Math.PI / 2], children: [
3433
+ /* @__PURE__ */ T("coneGeometry", { args: [4.2, 12, 16] }),
3434
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#ef4444", depthTest: !1, depthWrite: !1 })
3435
+ ] }),
3436
+ /* @__PURE__ */ w("mesh", { position: [0, 18, 0], children: [
3437
+ /* @__PURE__ */ T("cylinderGeometry", { args: [1.6, 1.6, 24, 12] }),
3438
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#22c55e", depthTest: !1, depthWrite: !1 })
3439
+ ] }),
3440
+ /* @__PURE__ */ w("mesh", { position: [0, 34, 0], children: [
3441
+ /* @__PURE__ */ T("coneGeometry", { args: [4.2, 12, 16] }),
3442
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#22c55e", depthTest: !1, depthWrite: !1 })
3443
+ ] }),
3444
+ /* @__PURE__ */ w("mesh", { position: [0, 0, 18], rotation: [Math.PI / 2, 0, 0], children: [
3445
+ /* @__PURE__ */ T("cylinderGeometry", { args: [1.6, 1.6, 24, 12] }),
3446
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#3b82f6", depthTest: !1, depthWrite: !1 })
3447
+ ] }),
3448
+ /* @__PURE__ */ w("mesh", { position: [0, 0, 34], rotation: [Math.PI / 2, 0, 0], children: [
3449
+ /* @__PURE__ */ T("coneGeometry", { args: [4.2, 12, 16] }),
3450
+ /* @__PURE__ */ T("meshBasicMaterial", { color: "#3b82f6", depthTest: !1, depthWrite: !1 })
3451
+ ] }),
3452
+ /* @__PURE__ */ T(
3453
+ Ye,
3454
+ {
3455
+ position: [42, 0, 0],
3456
+ fontSize: 10,
3457
+ color: "#ef4444",
3458
+ anchorX: "center",
3459
+ anchorY: "middle",
3460
+ renderOrder: 11,
3461
+ "material-depthTest": !1,
3462
+ children: "X"
3463
+ }
3464
+ ),
3465
+ /* @__PURE__ */ T(
3466
+ Ye,
3467
+ {
3468
+ position: [0, 42, 0],
3469
+ fontSize: 10,
3470
+ color: "#22c55e",
3471
+ anchorX: "center",
3472
+ anchorY: "middle",
3473
+ renderOrder: 11,
3474
+ "material-depthTest": !1,
3475
+ children: "Y"
3476
+ }
3477
+ ),
3478
+ /* @__PURE__ */ T(
3479
+ Ye,
3480
+ {
3481
+ position: [0, 0, 42],
3482
+ fontSize: 10,
3483
+ color: "#3b82f6",
3484
+ anchorX: "center",
3485
+ anchorY: "middle",
3486
+ renderOrder: 11,
3487
+ "material-depthTest": !1,
3488
+ children: "Z"
3489
+ }
3490
+ )
3491
+ ] })
3492
+ }
3493
+ )
3494
+ ] });
3495
+ };
3496
+ export {
3497
+ Cr as CanonicalFaceMeshRenderer,
3498
+ Nr as DEFAULT_APPEARANCE,
3499
+ ys as DEFAULT_FEATURE_GROUPS,
3500
+ _s as DEFAULT_FEATURE_POINT_INDICES,
3501
+ Pr as DEFAULT_MASKING,
3502
+ ct as FACE_MASK_SIZE,
3503
+ Gt as FACE_OVAL,
3504
+ jr as FaceRetouchBackground,
3505
+ Kt as HEAD_OCCLUDER_DEFAULT_OPACITY,
3506
+ Ce as HEAD_OCCLUDER_DEFAULT_POSITION,
3507
+ ne as HEAD_OCCLUDER_DEFAULT_SCALE,
3508
+ Yr as HeadBinding,
3509
+ $r as HeadBindingOccluder,
3510
+ Yt as HeadOccluder,
3511
+ Ht as INNER_MOUTH,
3512
+ os as LEFT_EYE,
3513
+ cs as LEFT_EYEBROW,
3514
+ as as OUTER_LIPS,
3515
+ is as RIGHT_EYE,
3516
+ ls as RIGHT_EYEBROW,
3517
+ Br as alphaMapOptions,
3518
+ Tt as blendModeIndices,
3519
+ Ur as blendModeOptions,
3520
+ Zr as computeAdaptiveVerticalFit,
3521
+ Er as computeHeadBindingCubePose,
3522
+ Qr as computeHeadBindingDebugMetrics,
3523
+ vr as computeHeadBindingShape,
3524
+ qr as computeUniversalHeadDepthOffset,
3525
+ Vr as computeUniversalOccluderScale,
3526
+ zr as computeUniversalPitchOffsetY,
3527
+ Wr as computeUniversalYawOffsetX,
3528
+ Is as createFaceRetouchRegions,
3529
+ ds as drawFaceRetouchMask,
3530
+ fs as drawMouthRetouchMask,
3531
+ Fr as materialTypeOptions,
3532
+ Yn as parseCanonicalFaceModel,
3533
+ Or as shaderPresetOptions,
3534
+ Dr as sideOptions,
3535
+ zt as solveHeadBinding,
3536
+ Hr as supportsBlendMode,
3537
+ Gr as supportsTexturePanel,
3538
+ kr as textureMapOptions,
3539
+ qn as useCanonicalFaceMesh,
3540
+ Xr as useFaceRetouchMask,
3541
+ Kr as useFaceRetouchRegions
3542
+ };