@vincentt-xr/sdk 2.0.0-alpha.6 → 2.0.0-alpha.7

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 (77) hide show
  1. package/GROUNDING.md +81 -3
  2. package/dist/{DebuggerUI-DYT_dk1E.cjs → DebuggerUI-B6bP6P9r.cjs} +1 -1
  3. package/dist/{DebuggerUI-C_rbLdkh.js → DebuggerUI-BjOMr8q_.js} +1 -1
  4. package/dist/{FaceMeshRenderer-D1WsrTLA.cjs → FaceMeshRenderer-C5l6VLdO.cjs} +6 -6
  5. package/dist/{FaceMeshRenderer-DSCd1H55.js → FaceMeshRenderer-wjAHrJzP.js} +102 -96
  6. package/dist/{FaceRetouch-DsE0Dbw-.cjs → FaceRetouch-BkJzoA79.cjs} +1 -1
  7. package/dist/{FaceRetouch-CMJbGThL.js → FaceRetouch-DwbKQJAN.js} +4 -4
  8. package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +11 -3
  9. package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +10 -4
  10. package/dist/components/FaceMesh/index.d.ts +2 -2
  11. package/dist/components/SceneObjectRenderer/index.d.ts +9 -2
  12. package/dist/components/XRMediaSurface/index.d.ts +2 -1
  13. package/dist/{contexts-DvQI4PqI.js → contexts-ByhzppYl.js} +3 -3
  14. package/dist/{contexts-h-9TRH0r.cjs → contexts-Dr62It_K.cjs} +1 -1
  15. package/dist/debug-ui/media-source.cjs +1 -1
  16. package/dist/debug-ui/media-source.js +1 -1
  17. package/dist/debug-ui.cjs +1 -1
  18. package/dist/debug-ui.js +10 -10
  19. package/dist/entries/core.d.ts +3 -2
  20. package/dist/entries/face-effects.d.ts +2 -2
  21. package/dist/entries/tracking.d.ts +2 -0
  22. package/dist/face-effects.cjs +1 -1
  23. package/dist/face-effects.js +25 -24
  24. package/dist/{getFaceInfo-B43Cwq4n.js → getFaceInfo-C4QpCQIY.js} +1 -1
  25. package/dist/{getFaceInfo-DEzcL_Ub.cjs → getFaceInfo-fA1bFBub.cjs} +1 -1
  26. package/dist/hooks/useXRSession/facade.d.ts +2 -0
  27. package/dist/{index-I4eF5TKT.js → index-9dlAQAhy.js} +405 -400
  28. package/dist/{index-CY7Z8cHV.cjs → index-BjmTe9eM.cjs} +1 -1
  29. package/dist/{index-D67hHm44.cjs → index-BpEf2BBb.cjs} +1 -1
  30. package/dist/{index-B-s4YbWu.js → index-ByoNj0QP.js} +1 -1
  31. package/dist/{index-CxMEeCRP.cjs → index-CyUUurQT.cjs} +1 -1
  32. package/dist/index-DCiMbxC3.cjs +1 -0
  33. package/dist/{index-G_5h_FJQ.js → index-DXT3WccE.js} +808 -787
  34. package/dist/index-DpI-qo5X.cjs +17 -0
  35. package/dist/{index-DYfY9ljy.js → index-DyVF4vEW.js} +1 -1
  36. package/dist/{index-uE3sKczj.js → index-VJ0SJwmG.js} +1 -1
  37. package/dist/{internal-MvKrz0Nt.cjs → internal-Cq-TEQ5Y.cjs} +1 -1
  38. package/dist/{internal-ldPYiUF0.js → internal-Dmk1cTXq.js} +3 -3
  39. package/dist/internal.cjs +1 -1
  40. package/dist/internal.js +1 -1
  41. package/dist/low-level.cjs +1 -1
  42. package/dist/low-level.js +344 -330
  43. package/dist/main.cjs +1 -1
  44. package/dist/main.js +94 -91
  45. package/dist/{renderGroups-BJsx32q5.cjs → renderGroups-80H3DpTl.cjs} +1 -1
  46. package/dist/{renderGroups-CFt1yYLB.js → renderGroups-KZk6eRiY.js} +1 -1
  47. package/dist/{renderPasses-D-Krl6D0.cjs → renderPasses-BOoBSr8z.cjs} +1 -1
  48. package/dist/{renderPasses-C72MbZ-a.js → renderPasses-BcquyVtu.js} +4 -4
  49. package/dist/scene-object.cjs +1 -1
  50. package/dist/scene-object.js +2 -2
  51. package/dist/screen2d/coordinates.d.ts +20 -0
  52. package/dist/{selectors-ByKNTXeA.js → selectors-B8H97CKA.js} +1 -1
  53. package/dist/{selectors-CAwmL9VW.cjs → selectors-CZLKT2Iv.cjs} +1 -1
  54. package/dist/{session-CANvoLD6.cjs → session-CpkiK5YA.cjs} +1 -1
  55. package/dist/{session-Dhi0OqZo.js → session-DLFN_VII.js} +1 -1
  56. package/dist/tracking/coordinates.d.ts +5 -0
  57. package/dist/tracking.cjs +1 -1
  58. package/dist/tracking.js +69 -66
  59. package/dist/types/common.d.ts +11 -1
  60. package/dist/types/gesture-tracking.d.ts +2 -2
  61. package/dist/types/hand-tracking.d.ts +3 -3
  62. package/dist/types/nodes.d.ts +2 -2
  63. package/dist/types/session.d.ts +7 -1
  64. package/dist/{useFaceInfo-BSZq7AO1.cjs → useFaceInfo-BJ8-_MOs.cjs} +1 -1
  65. package/dist/{useFaceInfo-FVQBBNdY.js → useFaceInfo-Dk426LTu.js} +3 -3
  66. package/dist/{useFaceResults-D62STzT1.js → useFaceResults-CtetsO9M.js} +1 -1
  67. package/dist/{useFaceResults-C3oZkn2Z.cjs → useFaceResults-wBJF3zyp.cjs} +1 -1
  68. package/docs/SDK_DOCUMENTATION.md +3 -0
  69. package/docs/api/capture-recording.mdx +9 -1
  70. package/docs/api/face-mesh.mdx +33 -0
  71. package/docs/api/runtime-3d.mdx +5 -0
  72. package/docs/api/screen-image.mdx +3 -1
  73. package/docs/api/screen-space-coordinates.mdx +31 -0
  74. package/docs/api/trackers.mdx +13 -0
  75. package/package.json +4 -1
  76. package/dist/index-C0-fg1Hk.cjs +0 -1
  77. package/dist/index-DPPpU5By.cjs +0 -17
package/dist/debug-ui.js CHANGED
@@ -1,20 +1,20 @@
1
- import { M as Ws, d as Ms, s as Ls, a as Fs, u as Ns, b as $s } from "./session-Dhi0OqZo.js";
1
+ import { M as Ws, d as Ms, s as Ls, a as Fs, u as Ns, b as $s } from "./session-DLFN_VII.js";
2
2
  import { DefaultSettingPanel as Bs } from "./debug-ui/default-setting.js";
3
3
  import { jsx as e, jsxs as l, Fragment as K } from "react/jsx-runtime";
4
4
  import { useState as x, useRef as te, useEffect as O, useContext as $n, createContext as On, useMemo as gn } from "react";
5
- import { D as bn, a as At, r as Bn, b as An, c as Dn } from "./renderGroups-CFt1yYLB.js";
6
- import { V as Ve, o as un, b as me, A as Vn, z as fn, s as Dt } from "./renderPasses-C72MbZ-a.js";
5
+ import { D as bn, a as At, r as Bn, b as An, c as Dn } from "./renderGroups-KZk6eRiY.js";
6
+ import { V as Ve, o as un, b as me, A as Vn, z as fn, s as Dt } from "./renderPasses-BcquyVtu.js";
7
7
  import Kn, { createPortal as we } from "react-dom";
8
8
  import { DoubleSide as Hn } from "three";
9
- import { E as Pn, s as jn, k as Gn, F as Vt, a as _n, c as ft, G as Xn, H as Un, t as Zn } from "./FaceMeshRenderer-DSCd1H55.js";
10
- import { D as Yn, r as Jn, e as qn, p as Qn, t as Kt, g as el, m as tl, s as nl, a as ll, b as il, c as ol } from "./FaceRetouch-CMJbGThL.js";
11
- import { n as rl } from "./index-uE3sKczj.js";
12
- import { F as al } from "./index-DYfY9ljy.js";
9
+ import { G as Pn, s as jn, k as Gn, F as Vt, a as _n, c as ft, H as Xn, I as Un, u as Zn } from "./FaceMeshRenderer-wjAHrJzP.js";
10
+ import { D as Yn, r as Jn, e as qn, p as Qn, t as Kt, g as el, m as tl, s as nl, a as ll, b as il, c as ol } from "./FaceRetouch-DwbKQJAN.js";
11
+ import { n as rl } from "./index-VJ0SJwmG.js";
12
+ import { F as al } from "./index-DyVF4vEW.js";
13
13
  import { PerspectiveCamera as sl, OrbitControls as dl } from "@react-three/drei";
14
14
  import { useThree as cl } from "@react-three/fiber";
15
- import { e as pl, f as hl } from "./index-G_5h_FJQ.js";
16
- import { X as yl } from "./contexts-DvQI4PqI.js";
17
- import { u as gl } from "./selectors-ByKNTXeA.js";
15
+ import { e as pl, f as hl } from "./index-DXT3WccE.js";
16
+ import { X as yl } from "./contexts-ByhzppYl.js";
17
+ import { u as gl } from "./selectors-B8H97CKA.js";
18
18
  const bl = {
19
19
  position: "fixed",
20
20
  left: 14,
@@ -52,8 +52,9 @@ export { DEFAULT_SCREEN_IMAGE_SETTINGS, DEFAULT_SCREEN_IMAGE_SCENE_SETTINGS, map
52
52
  export type { ScreenImageSettings, ScreenImageSceneSettings, ScreenImageRenderMapping, } from '../screen-image/screenImageSettings';
53
53
  export { DEFAULT_SCREEN_TEXT_SCENE_SETTINGS, DEFAULT_SCREEN_TEXT_SHADOW_LAYER, mapScreenTextInnerShadowToProps, mapScreenTextSettingsToProps, } from '../screen-text/screenTextSettings';
54
54
  export type { ScreenTextRenderMapping, ScreenTextArtPreset, ScreenTextSettings, ScreenTextSceneSettings, ScreenTextStyle, } from '../screen-text/screenTextSettings';
55
- export { DEFAULT_PIXEL_SNAP_INCREMENT, DEFAULT_REFERENCE_PIXELS_PER_UNIT, DEFAULT_SCREEN_TRANSFORM_2D, DEFAULT_SCREEN_TRANSFORM_ROOT, mergeScreenTransform2D, clientToScreenPixels, mediaToScreenPixels, normalizedToScreenPixels, resolveScreenTransform2D, screenPixelsToUnits, screenPixelsToClient, screenPixelsToMedia, screenPixelsToNormalized, screenPointToRay, screenUnitsToPixels, smoothNumber, smoothVector2, smoothVector3, worldToScreenPixels, } from '../screen2d';
56
- export type { ProjectedScreenPixelPoint, ResolvedScreenTransform2D, ScreenClientRect, ScreenPixelPoint, ScreenTransform2DSettings, ScreenTransformRoot, ScreenUnitConversionOptions, ScreenViewportSize, } from '../screen2d';
55
+ export { DEFAULT_PIXEL_SNAP_INCREMENT, DEFAULT_REFERENCE_PIXELS_PER_UNIT, DEFAULT_SCREEN_TRANSFORM_2D, DEFAULT_SCREEN_TRANSFORM_ROOT, mergeScreenTransform2D, clientToScreenPixels, mediaToScreenPixels, normalizedToScreenPixels, resolveScreenTransform2D, screenPixelsToUnits, screenPixelsToClient, screenPixelsToMedia, screenPixelsToNormalized, screenPixelsToScreenSpace, screenPointToRay, screenSpaceToScreenPixels, screenUnitsToPixels, smoothNumber, smoothVector2, smoothVector3, trackerPointToScreenPixels, worldToScreenPixels, } from '../screen2d';
56
+ export type { ProjectedScreenPixelPoint, ResolvedScreenTransform2D, ScreenClientRect, ScreenPixelPoint, ScreenPointUnitConversionOptions, ScreenTransform2DSettings, ScreenTransformRoot, ScreenUnitConversionOptions, ScreenViewportSize, } from '../screen2d';
57
+ export type { NormalizedTrackerPoint, TrackerPoint } from '../types/common';
57
58
  export { computeContainScale } from '../texture/computeContainScale';
58
59
  export { useMediaRecorder } from '../hooks/useMediaRecorder';
59
60
  export type { RecordingStatus, UseMediaRecorderOptions } from '../hooks/useMediaRecorder';
@@ -10,8 +10,8 @@ export { blendModeIndices, DEFAULT_APPEARANCE, DEFAULT_FACE_MESH_RENDERER, DEFAU
10
10
  export type { FaceMeshMaterialType, FaceMeshShaderPreset, FaceMeshTextureMap, FaceMeshAlphaMap, FaceMeshMaskTextureSource, FaceMeshSide, FaceMeshBlendMode, FaceMeshAppearance, FaceMeshMasking, } from '../components/FaceMesh';
11
11
  export { LipEffect, LipEffectMaterial, DEFAULT_LIP_EFFECT } from '../components/LipEffect';
12
12
  export type { LipEffectMaterialSpec, LipEffectMaterialContext, LipEffectProps, LipMaskMode, } from '../components/LipEffect';
13
- export { CanonicalFaceMeshRenderer, FaceMeshMaterial, FaceMeshRenderer, canonicalFaceAlphaMaskUrl, canonicalFaceTextureStyle2Url, canonicalFaceTextureUrl, CANONICAL_FACE_MESH_GEOMETRY_SPECS, mapFaceMeshRendererSettingsToProps, resolveFaceMeshRendererSettings, useCanonicalFaceMesh, parseCanonicalFaceModel, } from '../components/FaceMesh';
14
- export type { CanonicalFaceMeshRendererProps, CanonicalFaceMeshGeometryKey, CanonicalFaceMeshGeometrySpec, FaceMeshMaterialProps, FaceMeshRendererSettings, ParsedCanonicalMesh, } from '../components/FaceMesh';
13
+ export { CanonicalFaceMeshRenderer, FaceMeshMaterial, FaceMeshRenderer, canonicalFaceAlphaMaskUrl, canonicalFaceTextureStyle2Url, canonicalFaceTextureUrl, CANONICAL_FACE_MESH_GEOMETRY_SPECS, mapFaceMeshRendererProps, mapFaceMeshRendererSettingsToProps, resolveFaceMeshRendererSettings, useCanonicalFaceMesh, parseCanonicalFaceModel, } from '../components/FaceMesh';
14
+ export type { CanonicalFaceMeshRendererProps, CanonicalFaceMeshGeometryKey, CanonicalFaceMeshGeometrySpec, FaceMeshMaterialOverride, FaceMeshMaterialOverrideContext, FaceMeshMaterialProps, FaceMeshRendererProps, FaceMeshRendererSettings, ParsedCanonicalMesh, } from '../components/FaceMesh';
15
15
  export { FACE_WARP_3D_PRESET, DEFAULT_FACE_WARP_3D_SETTINGS } from '../components/FaceWarp3D';
16
16
  export type { FaceWarp3DSettings } from '../components/FaceWarp3D';
17
17
  export { FACE_RETOUCH_DEFAULT_CONTROLS, FACE_RETOUCH_SETTINGS_FIELDS, FaceRetouch, patchFaceRetouchControls, resolveFaceRetouchControls, } from '../components/FaceRetouch';
@@ -34,5 +34,7 @@ export { FACE_ATTRIBUTE_EXPRESSION_NAMES } from '../face-attribute-expression';
34
34
  export type { FaceAttributeExpressionName, FaceAttributeExpressionResult, FaceAttributeExpressionScoreName, } from '../face-attribute-expression';
35
35
  export type { FaceTarget, FaceCustomAnchorPoint, HandTarget, BodyTarget, TrackingTarget, TrackerType, } from '../types/tracking';
36
36
  export { FACE_TARGETS, HAND_TARGETS, BODY_TARGETS, getTargetNamespace } from '../types/tracking';
37
+ export { normalizedTrackerPointToTrackerPoint, trackerPointToNormalizedTrackerPoint, } from '../tracking/coordinates';
38
+ export type { NormalizedTrackerPoint, TrackerPoint } from '../types/common';
37
39
  export type { SegmentationType } from '../types/segmentation';
38
40
  export { SEGMENTATION_TYPES } from '../types/segmentation';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),K=require("react"),d=require("three"),me=require("./index-CxMEeCRP.cjs"),re=require("./index-C0-fg1Hk.cjs"),J=require("@react-three/drei"),S=require("./FaceMeshRenderer-D1WsrTLA.cjs"),F=require("./FaceRetouch-DsE0Dbw-.cjs"),Me=require("@react-three/fiber");function Ie(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const C=Ie(d),k={color:"#e85d75",opacity:.8,intensity:1,maskMode:"outer-and-inner-lips",shading:!0,renderOrder:30},Re=({context:l,color:t,opacity:e,intensity:s,shading:n,subtractMouth:i=!1})=>{const r=Me.useLoader(C.TextureLoader,S.TRANSPARENT_TEXTURE_DATA_URL),a=l.designTexture??r,o={cameraTexture:{value:l.cameraTexture},designTexture:{value:a},tint:{value:new C.Color(t)},opacity:{value:e},intensity:{value:s},shading:{value:n?1:0}};return A.jsx("shaderMaterial",{uniforms:o,vertexShader:"attribute vec2 faceUv; varying vec2 vFaceUv; varying vec2 vUv; void main() { vUv = uv; vFaceUv = faceUv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }",fragmentShader:"uniform sampler2D cameraTexture; uniform sampler2D designTexture; uniform vec3 tint; uniform float opacity; uniform float intensity; uniform float shading; varying vec2 vFaceUv; varying vec2 vUv; void main() { vec3 base = texture2D(cameraTexture, vFaceUv).rgb; vec4 design = texture2D(designTexture, vUv); vec3 painted = mix(design.rgb, design.rgb * tint, intensity); vec3 color = mix(base, painted, design.a * opacity); gl_FragColor = vec4(color, opacity * design.a); }",transparent:!0,side:C.DoubleSide,stencilWrite:!1,stencilRef:1,stencilFunc:i?C.NotEqualStencilFunc:C.AlwaysStencilFunc,depthWrite:!1,toneMapped:!1})},Ne=({faceIndex:l=0,designTexture:t,color:e=k.color,opacity:s=k.opacity,intensity:n=k.intensity,maskMode:i=k.maskMode,shading:r=k.shading,material:a,renderOrder:o=k.renderOrder})=>{const c=Me.useLoader(C.TextureLoader,typeof t=="string"?t:S.TRANSPARENT_TEXTURE_DATA_URL),h=typeof t=="string"?c:t??null,u=({cameraTexture:f,geometryKey:m})=>{if(m==="mouth")return A.jsx("meshBasicMaterial",{color:"#ffffff",colorWrite:!1,depthWrite:!1,depthTest:!1,stencilWrite:!0,stencilRef:1,stencilFunc:C.AlwaysStencilFunc,stencilZPass:C.ReplaceStencilOp});const T={cameraTexture:f,designTexture:h,lipMask:null,faceUv:null,faceIndex:l};return a?typeof a=="function"?a(T):a:A.jsx(Re,{context:T,color:e,opacity:s,intensity:n,shading:r,subtractMouth:!0})};return A.jsx(S.CanonicalFaceMeshRenderer,{faceIndex:l,showMouthGeometry:!0,showLipsGeometry:!0,showBaseGeometry:!1,showMouthMask:i==="outer-lips",showEyeGeometry:!1,showNoseGeometry:!1,showLeftEyeGeometry:!1,showRightEyeGeometry:!1,showEyeMask:!1,showNoseMask:!1,renderOrder:o,materialOverride:u})};function ge(l,t){if(t===d.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(t===d.TriangleFanDrawMode||t===d.TriangleStripDrawMode){let e=l.getIndex();if(e===null){const r=[],a=l.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);l.setIndex(r),e=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=e.count-2,n=[];if(t===d.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(e.getX(0)),n.push(e.getX(r)),n.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(e.getX(r)),n.push(e.getX(r+1)),n.push(e.getX(r+2))):(n.push(e.getX(r+2)),n.push(e.getX(r+1)),n.push(e.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),l}class Oe extends d.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Be(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new qe(e)}),this.register(function(e){return new Ze(e)}),this.register(function(e){return new Qe(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Xe(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Ye(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Je(e)}),this.register(function(e){return new $e(e)})}load(t,e,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=d.LoaderUtils.extractUrlBase(t);r=d.LoaderUtils.resolveURL(c,this.path)}else r=d.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){n?n(c):console.error(c),i.manager.itemError(t),i.manager.itemEnd(t)},o=new d.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{i.parse(c,r,function(h){e(h),i.manager.itemEnd(t)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let i;const r={},a={},o=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===_e){try{r[x.KHR_BINARY_GLTF]=new et(t)}catch(u){n&&n(u);return}i=JSON.parse(r[x.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ft(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const u=i.extensionsUsed[h],f=i.extensionsRequired||[];switch(u){case x.KHR_MATERIALS_UNLIT:r[u]=new Ue;break;case x.KHR_DRACO_MESH_COMPRESSION:r[u]=new tt(i,this.dracoLoader);break;case x.KHR_TEXTURE_TRANSFORM:r[u]=new nt;break;case x.KHR_MESH_QUANTIZATION:r[u]=new st;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,i){s.parse(t,e,n,i)})}}function De(){let l={};return{get:function(t){return l[t]},add:function(t,e){l[t]=e},remove:function(t){delete l[t]},removeAll:function(){l={}}}}const x={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class He{constructor(t){this.parser=t,this.name=x.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let c;const h=new d.Color(16777215);o.color!==void 0&&h.setRGB(o.color[0],o.color[1],o.color[2],d.LinearSRGBColorSpace);const u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new d.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new d.PointLight(h),c.distance=u;break;case"spot":c=new d.SpotLight(h),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),D(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,i=s.json.nodes[t],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class Ue{constructor(){this.name=x.KHR_MATERIALS_UNLIT}getMaterialType(){return d.MeshBasicMaterial}extendParams(t,e,s){const n=[];t.color=new d.Color(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;t.color.setRGB(r[0],r[1],r[2],d.LinearSRGBColorSpace),t.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",i.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class ve{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(e.emissiveIntensity=i),Promise.resolve()}}class Be{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(e.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new d.Vector2(a,a)}return Promise.all(i)}}class Ge{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_DISPERSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class ke{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(e.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(e.iridescenceIOR=r.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class je{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new d.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(e,"sheenColorMap",r.sheenColorTexture,d.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Ke{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(e.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class Xe{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(e,"thicknessMap",r.thicknessTexture)),e.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return e.attenuationColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),Promise.all(i)}}class Ve{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Ye{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(e,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return e.specularColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(s.assignTexture(e,"specularColorMap",r.specularColorTexture,d.SRGBColorSpace)),Promise.all(i)}}class We{constructor(t){this.parser=t,this.name=x.EXT_MATERIALS_BUMP}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return e.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(e,"bumpMap",r.bumpTexture)),Promise.all(i)}}class ze{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(e.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(e.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(e,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class qe{constructor(t){this.parser=t,this.name=x.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,r)}}class Ze{constructor(t){this.parser=t,this.name=x.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Qe{constructor(t){this.parser=t,this.name=x.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Je{constructor(t){this.name=x.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,h=n.count,u=n.byteStride,f=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,u,f,n.mode,n.filter).then(function(m){return m.buffer}):r.ready.then(function(){const m=new ArrayBuffer(h*u);return r.decodeGltfBuffer(new Uint8Array(m),h,u,f,n.mode,n.filter),m})})}else return null}}class $e{constructor(t){this.name=x.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==I.TRIANGLES&&c.mode!==I.TRIANGLE_STRIP&&c.mode!==I.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(h=>(o[c]=h,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],f=c[0].count,m=[];for(const T of u){const E=new d.Matrix4,g=new d.Vector3,p=new d.Quaternion,M=new d.Vector3(1,1,1),_=new d.InstancedMesh(T.geometry,T.material,f);for(let R=0;R<f;R++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&p.fromBufferAttribute(o.ROTATION,R),o.SCALE&&M.fromBufferAttribute(o.SCALE,R),_.setMatrixAt(R,E.compose(g,p,M));for(const R in o)if(R==="_COLOR_0"){const L=o[R];_.instanceColor=new d.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&T.geometry.setAttribute(R,o[R]);d.Object3D.prototype.copy.call(_,T),this.parser.assignFinalMaterial(_),m.push(_)}return h.isGroup?(h.clear(),h.add(...m),h):m[0]}))}}const _e="glTF",W=12,Ae={JSON:1313821514,BIN:5130562};class et{constructor(t){this.name=x.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,W),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==_e)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-W,i=new DataView(t,W);let r=0;for(;r<n;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===Ae.JSON){const c=new Uint8Array(t,W+r,a);this.content=s.decode(c)}else if(o===Ae.BIN){const c=W+r;this.body=t.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tt{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=x.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,r=t.extensions[this.name].attributes,a={},o={},c={};for(const h in r){const u=ie[h]||h.toLowerCase();a[u]=r[h]}for(const h in t.attributes){const u=ie[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[t.attributes[h]],m=X[f.componentType];c[u]=m.name,o[u]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(h){return new Promise(function(u,f){n.decodeDracoFile(h,function(m){for(const T in m.attributes){const E=m.attributes[T],g=o[T];g!==void 0&&(E.normalized=g)}u(m)},a,c,d.LinearSRGBColorSpace,f)})})}}class nt{constructor(){this.name=x.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class st{constructor(){this.name=x.KHR_MESH_QUANTIZATION}}class Se extends d.Interpolant{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let r=0;r!==n;r++)e[r]=s[i+r];return e}interpolate_(t,e,s,n){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,h=n-e,u=(s-e)/h,f=u*u,m=f*u,T=t*c,E=T-c,g=-2*m+3*f,p=m-f,M=1-g,_=p-f+u;for(let R=0;R!==a;R++){const L=r[E+R+a],P=r[E+R+o]*h,w=r[T+R+a],N=r[T+R]*h;i[R]=M*L+_*P+g*w+p*N}return i}}const rt=new d.Quaternion;class it extends Se{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return rt.fromArray(i).normalize().toArray(i),i}}const I={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},X={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Te={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},Ee={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ie={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},v={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ot={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},ee={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function at(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new d.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.FrontSide})),l.DefaultMaterial}function G(l,t,e){for(const s in e.extensions)l[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function D(l,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(l.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ct(l,t,e){let s=!1,n=!1,i=!1;for(let c=0,h=t.length;c<h;c++){const u=t[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const r=[],a=[],o=[];for(let c=0,h=t.length;c<h;c++){const u=t[c];if(s){const f=u.POSITION!==void 0?e.getDependency("accessor",u.POSITION):l.attributes.position;r.push(f)}if(n){const f=u.NORMAL!==void 0?e.getDependency("accessor",u.NORMAL):l.attributes.normal;a.push(f)}if(i){const f=u.COLOR_0!==void 0?e.getDependency("accessor",u.COLOR_0):l.attributes.color;o.push(f)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const h=c[0],u=c[1],f=c[2];return s&&(l.morphAttributes.position=h),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=f),l.morphTargetsRelative=!0,l})}function lt(l,t){if(l.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)l.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(l.morphTargetInfluences.length===e.length){l.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)l.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ut(l){let t;const e=l.extensions&&l.extensions[x.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+te(e.attributes):t=l.indices+":"+te(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)t+=":"+te(l.targets[s]);return t}function te(l){let t="";const e=Object.keys(l).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+l[e[s]]+";";return t}function oe(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function ht(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const dt=new d.Matrix4;class ft{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new De,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new d.TextureLoader(this.options.manager):this.textureLoader=new d.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return G(i,a,n),D(a,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const r=e[n].joints;for(let a=0,o=r.length;a<o;a++)t[r[a]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const r=t[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,h]of r.children.entries())i(h,a.children[c])};return i(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&s.push(i)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,r){return s.getDependency(t,r)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[x.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(d.LoaderUtils.resolveURL(e.uri,n.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const r=$[n.type],a=X[n.componentType],o=n.normalized===!0,c=new a(n.count*r);return Promise.resolve(new d.BufferAttribute(c,r,o))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=$[n.type],c=X[n.componentType],h=c.BYTES_PER_ELEMENT,u=h*o,f=n.byteOffset||0,m=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let E,g;if(m&&m!==u){const p=Math.floor(f/m),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+p+":"+n.count;let _=e.cache.get(M);_||(E=new c(a,p*m,n.count*m/h),_=new d.InterleavedBuffer(E,m/h),e.cache.add(M,_)),g=new d.InterleavedBufferAttribute(_,o,f%m/h,T)}else a===null?E=new c(n.count*o):E=new c(a,f,n.count*o),g=new d.BufferAttribute(E,o,T);if(n.sparse!==void 0){const p=$.SCALAR,M=X[n.sparse.indices.componentType],_=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,L=new M(r[1],_,n.sparse.count*p),P=new c(r[2],R,n.sparse.count*o);a!==null&&(g=new d.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let w=0,N=L.length;w<N;w++){const b=L[w];if(g.setX(b,P[w*o]),o>=2&&g.setY(b,P[w*o+1]),o>=3&&g.setZ(b,P[w*o+2]),o>=4&&g.setW(b,P[w*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=T}return g})}loadTexture(t){const e=this.json,s=this.options,i=e.textures[t].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,s){const n=this,i=this.json,r=i.textures[t],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(i.samplers||{})[r.sampler]||{};return h.magFilter=Te[f.magFilter]||d.LinearFilter,h.minFilter=Te[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=Ee[f.wrapS]||d.RepeatWrapping,h.wrapT=Ee[f.wrapT]||d.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==d.NearestFilter&&h.minFilter!==d.LinearFilter,n.associations.set(h,{textures:t}),h}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const s=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const r=n.images[t],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(u){c=!0;const f=new Blob([u],{type:r.mimeType});return o=a.createObjectURL(f),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(o).then(function(u){return new Promise(function(f,m){let T=f;e.isImageBitmapLoader===!0&&(T=function(E){const g=new d.Texture(E);g.needsUpdate=!0,f(g)}),e.load(d.LoaderUtils.resolveURL(u,i.path),T,void 0,m)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),D(u,r),u.userData.mimeType=r.mimeType||ht(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[t]=h,h}assignTexture(t,e,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[x.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[x.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[x.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return n!==void 0&&(r.colorSpace=n),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new d.PointsMaterial,d.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(t.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new d.LineBasicMaterial,d.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(n||i||r){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return d.MeshStandardMaterial}loadMaterial(t){const e=this,s=this.json,n=this.extensions,i=s.materials[t];let r;const a={},o=i.extensions||{},c=[];if(o[x.KHR_MATERIALS_UNLIT]){const u=n[x.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),c.push(u.extendParams(a,i,e))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new d.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],d.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,d.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}i.doubleSided===!0&&(a.side=d.DoubleSide);const h=i.alphaMode||ee.OPAQUE;if(h===ee.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===ee.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==d.MeshBasicMaterial&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new d.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&r!==d.MeshBasicMaterial&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==d.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new d.Color().setRGB(u[0],u[1],u[2],d.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==d.MeshBasicMaterial&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,d.SRGBColorSpace)),Promise.all(c).then(function(){const u=new r(a);return i.name&&(u.name=i.name),D(u,i),e.associations.set(u,{materials:t}),i.extensions&&G(n,u,i),u})}createUniqueName(t){const e=d.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[x.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return xe(o,a,e)})}const r=[];for(let a=0,o=t.length;a<o;a++){const c=t[a],h=ut(c),u=n[h];if(u)r.push(u.promise);else{let f;c.extensions&&c.extensions[x.KHR_DRACO_MESH_COMPRESSION]?f=i(c):f=xe(new d.BufferGeometry,c,e),n[h]={primitive:c,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,n=this.extensions,i=s.meshes[t],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const h=r[o].material===void 0?at(this.cache):this.getDependency("material",r[o].material);a.push(h)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),h=o[o.length-1],u=[];for(let m=0,T=h.length;m<T;m++){const E=h[m],g=r[m];let p;const M=c[m];if(g.mode===I.TRIANGLES||g.mode===I.TRIANGLE_STRIP||g.mode===I.TRIANGLE_FAN||g.mode===void 0)p=i.isSkinnedMesh===!0?new d.SkinnedMesh(E,M):new d.Mesh(E,M),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===I.TRIANGLE_STRIP?p.geometry=ge(p.geometry,d.TriangleStripDrawMode):g.mode===I.TRIANGLE_FAN&&(p.geometry=ge(p.geometry,d.TriangleFanDrawMode));else if(g.mode===I.LINES)p=new d.LineSegments(E,M);else if(g.mode===I.LINE_STRIP)p=new d.Line(E,M);else if(g.mode===I.LINE_LOOP)p=new d.LineLoop(E,M);else if(g.mode===I.POINTS)p=new d.Points(E,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&lt(p,i),p.name=e.createUniqueName(i.name||"mesh_"+t),D(p,i),g.extensions&&G(n,p,g),e.assignFinalMaterial(p),u.push(p)}for(let m=0,T=u.length;m<T;m++)e.associations.set(u[m],{meshes:t,primitives:m});if(u.length===1)return i.extensions&&G(n,u[0],i),u[0];const f=new d.Group;i.extensions&&G(n,f,i),e.associations.set(f,{meshes:t});for(let m=0,T=u.length;m<T;m++)f.add(u[m]);return f})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new d.PerspectiveCamera(d.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new d.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),D(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,i=e.joints.length;n<i;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),r=n,a=[],o=[];for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u){a.push(u);const f=new d.Matrix4;i!==null&&f.fromArray(i.array,c*16),o.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new d.Skeleton(a,o)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,r=[],a=[],o=[],c=[],h=[];for(let u=0,f=n.channels.length;u<f;u++){const m=n.channels[u],T=n.samplers[m.sampler],E=m.target,g=E.node,p=n.parameters!==void 0?n.parameters[T.input]:T.input,M=n.parameters!==void 0?n.parameters[T.output]:T.output;E.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",p)),o.push(this.getDependency("accessor",M)),c.push(T),h.push(E))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(h)]).then(function(u){const f=u[0],m=u[1],T=u[2],E=u[3],g=u[4],p=[];for(let M=0,_=f.length;M<_;M++){const R=f[M],L=m[M],P=T[M],w=E[M],N=g[M];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const b=s._createAnimationTracks(R,L,P,w,N);if(b)for(let O=0;O<b.length;O++)p.push(b[O])}return new d.AnimationClip(i,void 0,p)})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),r})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],i=s._loadNodeShallow(t),r=[],a=n.children||[];for(let c=0,h=a.length;c<h;c++)r.push(s.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const h=c[0],u=c[1],f=c[2];f!==null&&h.traverse(function(m){m.isSkinnedMesh&&m.bind(f,dt)});for(let m=0,T=u.length;m<T;m++)h.add(u[m]);return h})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],r=i.name?n.createUniqueName(i.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&a.push(o),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let h;if(i.isBone===!0?h=new d.Bone:c.length>1?h=new d.Group:c.length===1?h=c[0]:h=new d.Object3D,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(i.name&&(h.userData.name=i.name,h.name=r),D(h,i),i.extensions&&G(s,h,i),i.matrix!==void 0){const u=new d.Matrix4;u.fromArray(i.matrix),h.applyMatrix4(u)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=t,h}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,i=new d.Group;s.name&&(i.name=n.createUniqueName(s.name)),D(i,s),s.extensions&&G(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(n.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let h=0,u=o.length;h<u;h++)i.add(o[h]);const c=h=>{const u=new Map;for(const[f,m]of n.associations)(f instanceof d.Material||f instanceof d.Texture)&&u.set(f,m);return h.traverse(f=>{const m=n.associations.get(f);m!=null&&u.set(f,m)}),u};return n.associations=c(i),i})}_createAnimationTracks(t,e,s,n,i){const r=[],a=t.name?t.name:t.uuid,o=[];v[i.path]===v.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(v[i.path]){case v.weights:c=d.NumberKeyframeTrack;break;case v.rotation:c=d.QuaternionKeyframeTrack;break;case v.position:case v.scale:c=d.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=d.NumberKeyframeTrack;break;case 2:case 3:default:c=d.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?ot[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,m=o.length;f<m;f++){const T=new c(o[f]+"."+v[i.path],e.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=oe(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?it:Se;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pt(l,t,e){const s=t.attributes,n=new d.Box3;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new d.Vector3(o[0],o[1],o[2]),new d.Vector3(c[0],c[1],c[2])),a.normalized){const h=oe(X[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=t.targets;if(i!==void 0){const a=new d.Vector3,o=new d.Vector3;for(let c=0,h=i.length;c<h;c++){const u=i[c];if(u.POSITION!==void 0){const f=e.json.accessors[u.POSITION],m=f.min,T=f.max;if(m!==void 0&&T!==void 0){if(o.setX(Math.max(Math.abs(m[0]),Math.abs(T[0]))),o.setY(Math.max(Math.abs(m[1]),Math.abs(T[1]))),o.setZ(Math.max(Math.abs(m[2]),Math.abs(T[2]))),f.normalized){const E=oe(X[f.componentType]);o.multiplyScalar(E)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}l.boundingBox=n;const r=new d.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=r}function xe(l,t,e){const s=t.attributes,n=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){l.setAttribute(a,o)})}for(const r in s){const a=ie[r]||r.toLowerCase();a in l.attributes||n.push(i(s[r],a))}if(t.indices!==void 0&&!l.index){const r=e.getDependency("accessor",t.indices).then(function(a){l.setIndex(a)});n.push(r)}return d.ColorManagement.workingColorSpace!==d.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.ColorManagement.workingColorSpace}" not supported.`),D(l,t),pt(l,t,e),Promise.all(n).then(function(){return t.targets!==void 0?ct(l,t.targets,e):l})}const z=[0,0,-10],B=[.5,.5,.5],ae=1,ne=new Map,mt=l=>{const t=ne.get(l);if(t)return t;const e=new Oe,s=re.fetchAndVerify(l).then(n=>new Promise((i,r)=>{e.parse(n,"",i,r)})).catch(n=>{throw ne.delete(l),n});return ne.set(l,s),s},ce=({position:l,rotation:t,scale:e,url:s,showDebugMaterial:n=!1,opacity:i=ae})=>{const r=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",re.libConfig.assetStorageEndpoint).toString(),[a,o]=K.useState(null);K.useEffect(()=>{let h=!1;return mt(r).then(u=>{h||o(u.scene)}).catch(u=>{h||console.error(`${re.libConfig.loggerPrefix} head occluder load failed`,u)}),()=>{h=!0}},[r]);const c=K.useMemo(()=>{if(!a)return null;const h=a.clone();return h.traverse(u=>{u instanceof C.Mesh&&(u.material=new C.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?i:1,side:C.DoubleSide,transparent:n}))}),h},[a,n,i]);return K.useEffect(()=>{if(c)return()=>{c.traverse(h=>{h instanceof C.Mesh&&h.material.dispose()})}},[c]),c?(l?c.position.set(l[0],l[1],l[2]):c.position.set(z[0],z[1],z[2]),t&&c.rotation.set(t[0],t[1],t[2]),e?c.scale.set(e[0],e[1],e[2]):c.scale.set(B[0],B[1],B[2]),c.renderOrder=-1,A.jsx("primitive",{object:c})):null},gt=4,At=({children:l,faceIndex:t=0,numFaces:e=gt,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:i=!1,faceMeshMaterial:r})=>{const a=K.useMemo(()=>new C.MeshBasicMaterial({color:"#22c55e",side:C.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),o=n===!1?null:n===!0?{}:n;return A.jsxs(me.FaceTracker,{faceIndex:t,numFaces:e,scaleWithFace:s,children:[o&&A.jsx(ce,{position:o.position??z,rotation:o.rotation,scale:o.scale??B,url:o.url,showDebugMaterial:o.showDebugMaterial,opacity:o.opacity??ae}),l,i&&A.jsx(me.FaceMesh,{faceIndex:t,numFaces:e,material:r??a})]})},Tt=57,Et=15.5,se=Tt/Math.PI/Et,xt=-.134,Mt=-.024,H=(l,t,e)=>Math.min(e,Math.max(t,l)),ye=(l,t)=>l*t-t/2,Le=(l,t)=>-(l*t-t/2),Rt=({eyeMidX:l,noseX:t,offsetX:e,rawYaw:s,sideMidX:n})=>{const i=H((Math.abs(s)-.18)/.42,0,1),r=n*.75+l*.25,a=l*.7+t*.3;return r*(1-i)+a*i+e},_t=({baseScale:l,pitchRadians:t})=>{const e=t*180/Math.PI,n=1+H((e-6)/22,0,1)*.22;return[l[0]*n,l[1]*n,l[2]*n]},St=({yawRadians:l})=>{const t=Math.abs(l*180/Math.PI),s=.066*H((t-8)/12,0,1);return Math.sign(l)*s},yt=({pitchRadians:l})=>{const t=l*180/Math.PI;return-.026*H((-t-6)/18,0,1)},Lt=({baseOffset:l,yawRadians:t})=>{const e=Math.abs(t*180/Math.PI),s=H((e-8)/24,0,1);return l+s*.25},wt=({baseOffsetY:l,baseScaleY:t,face:e})=>{if(!e||e.bounds.width<=0)return{aspectRatio:0,normalizedAspect:0,scaleY:t,offsetY:l};const s=e.bounds.height/e.bounds.width,n=H((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:t+n*.06,offsetY:l+n*.005}},we=({face:l,offsetX:t,offsetY:e,scaleX:s,scaleY:n})=>{const i=l.bounds.width*s,r=l.bounds.height*n,a=l.bounds.centerX+t,o=l.bounds.centerY+e;return{x:a-i*.5,y:o-r*.5,width:i,height:r,centerX:a,centerY:o}},bt=({face:l,height:t,lockDepth:e,lockRotation:s,model:n,offsetX:i,offsetY:r,scaleX:a,scaleY:o,scaleZ:c,width:h})=>{const u=we({face:l,offsetX:i,offsetY:r,scaleX:a,scaleY:o}),f=l.landmarks[33],m=l.landmarks[263],T=l.landmarks[234],E=l.landmarks[454],g=l.landmarks[1],p=l.landmarks[10],M=l.landmarks[152],_=u.width*h,R=u.height*t,L=f&&m?(f.x+m.x)*.5:l.bounds.centerX,P=f&&m?(f.y+m.y)*.5:l.bounds.centerY-l.bounds.height*.15,w=T&&E?(T.x+E.x)*.5:L,N=(p==null?void 0:p.y)??l.bounds.minY,b=(M==null?void 0:M.y)??l.bounds.maxY,O=(N+b)*.5,q=f&&m?Math.atan2(m.y-f.y,m.x-f.x):0,U=g&&l.bounds.width>0?H((g.x-l.bounds.centerX)/(l.bounds.width*.5),-1,1)*.75:0,j=Rt({eyeMidX:L,noseX:(g==null?void 0:g.x)??L,offsetX:i,rawYaw:U,sideMidX:w}),y=O*.75+P*.25+r,Z=n==="v2"?ye(j,h):u.centerX*h-h/2,V=n==="v2"?Le(l.bounds.centerY+r*.75,t):-(u.centerY*t-t/2),Y=p&&g?Math.max(1e-4,g.y-p.y):l.bounds.height*.42,ue=g&&M?Math.max(1e-4,M.y-g.y):l.bounds.height*.58,he=(ue-Y)/(ue+Y),de=H((he-xt)/.28,-1,1)*.58,fe=g&&l.bounds.height>0?H((l.bounds.centerY-g.y)/(l.bounds.height*.5)-Mt,-1,1)*.18:0,Q=de*.82+fe*.18,pe=s?0:n==="v2"?U*.72:U,Ce=s?0:n==="v2"?-Q*.78:-Q,Fe=s?0:-q,Pe=e?_*se:n==="v2"?_*(se+Math.abs(pe)*.18):_*se;return{centerXPx:Z,centerYPx:V,depthPx:Pe*c,heightPx:R,pitch:Ce,rawPitch:Q,rawPitchFromBalance:de,rawPitchFromCenter:fe,rawYaw:U,rotationZ:Fe,roll:q,shape:u,skullAnchorX:j,skullAnchorY:y,verticalBalance:he,widthPx:_,yaw:pe}},be=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g})=>le({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g}).pose,le=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g})=>{const p=bt({face:s,height:n,lockDepth:l,lockRotation:t,model:e,offsetX:r,offsetY:a,scaleX:u,scaleY:f,scaleZ:m,width:g});if(T){const _=new d.Vector3(0,p.heightPx*E,-p.depthPx*i).applyEuler(new d.Euler(p.pitch,p.yaw,p.rotationZ,"XYZ")),R=ye(p.skullAnchorX,g),L=Le(p.skullAnchorY,n);return{pose:{boxCenterZ:_.z,centerX:R+_.x,centerY:L+_.y,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},debugMetrics:{face:{centerX:p.shape.centerX,centerY:p.shape.centerY,width:p.shape.width,height:p.shape.height},normalized:{rawPitch:p.rawPitch,rawPitchFromBalance:p.rawPitchFromBalance,rawPitchFromCenter:p.rawPitchFromCenter,rawYaw:p.rawYaw,roll:p.roll,verticalBalance:p.verticalBalance},pose:{pitch:p.pitch,yaw:p.yaw,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:R+_.x,y:L+_.y,z:_.z},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}}return{pose:{boxCenterZ:-p.depthPx*i,centerX:p.centerXPx,centerY:p.centerYPx,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},debugMetrics:{face:{centerX:p.shape.centerX,centerY:p.shape.centerY,width:p.shape.width,height:p.shape.height},normalized:{rawPitch:p.rawPitch,rawPitchFromBalance:p.rawPitchFromBalance,rawPitchFromCenter:p.rawPitchFromCenter,rawYaw:p.rawYaw,roll:p.roll,verticalBalance:p.verticalBalance},pose:{pitch:p.pitch,yaw:p.yaw,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:p.centerXPx,y:p.centerYPx,z:-p.depthPx*i},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}},Ct=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g})=>le({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g}).debugMetrics,Ft=({boxColor:l,boxOpacity:t,face:e,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,occluderOffset:a,occluderOpacity:o,occluderScale:c,showOccluderProxy:h=!1,offsetX:u,offsetY:f,pose:m,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:g,scaleX:p,scaleY:M,scaleZ:_,show:R,showCenterDot:L,showFacePlaneReference:P,showGizmo:w,showHeadOccluder:N,skullCenterMode:b,skullVerticalBias:O,url:q,viewportHeight:U,viewportWidth:j})=>{const y=K.useMemo(()=>m||(!e||j<=0||U<=0?null:be({face:e,width:j,height:U,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,offsetX:u,offsetY:f,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:g,scaleX:p,scaleY:M,scaleZ:_,skullCenterMode:b,skullVerticalBias:O})),[e,s,n,i,r,u,f,T,E,g,p,M,_,b,O,m,U,j]);if(!R||!y)return null;const Z=b?[0,-y.height*O,y.depth*s]:[0,0,0],V=y.height,Y=[B[0]*c[0]*V,B[1]*c[1]*V,B[2]*c[2]*V];return A.jsxs(A.Fragment,{children:[A.jsxs("group",{position:[y.centerX,y.centerY,y.boxCenterZ],rotation:[y.rotationX,y.rotationY,y.rotationZ],children:[A.jsx("group",{scale:[y.width,y.height,y.depth],children:t>0&&A.jsxs("mesh",{children:[A.jsx("boxGeometry",{args:[1,1,1]}),A.jsx("meshBasicMaterial",{color:l,wireframe:!0,transparent:!0,opacity:t})]})}),L&&A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:l})]}),P&&A.jsxs("group",{position:Z,children:[A.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[A.jsx("ringGeometry",{args:[6,8,24]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",side:d.DoubleSide})]}),A.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[A.jsx("planeGeometry",{args:[3,16]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]}),A.jsxs("mesh",{children:[A.jsx("planeGeometry",{args:[16,3]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]})]}),N&&A.jsxs(A.Fragment,{children:[h&&A.jsxs("mesh",{position:a,scale:Y,renderOrder:20,children:[A.jsx("sphereGeometry",{args:[1,24,16]}),A.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1})]}),A.jsx(ce,{opacity:o,position:a,scale:Y,showDebugMaterial:!0,url:q})]})]}),w&&A.jsx("group",{position:[y.centerX,y.centerY,y.boxCenterZ],rotation:[y.rotationX,y.rotationY,y.rotationZ],renderOrder:10,children:A.jsxs("group",{children:[A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:"#e2e8f0",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[18,0,0],rotation:[0,0,-Math.PI/2],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[34,0,0],rotation:[0,0,-Math.PI/2],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,18,0],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,34,0],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,0,18],rotation:[Math.PI/2,0,0],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,0,34],rotation:[Math.PI/2,0,0],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),A.jsx(J.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),A.jsx(J.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),A.jsx(J.Text,{position:[0,0,42],fontSize:10,color:"#3b82f6",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Z"})]})})]})};exports.CANONICAL_FACE_MESH_GEOMETRY_SPECS=S.CANONICAL_FACE_MESH_GEOMETRY_SPECS;exports.CanonicalFaceMeshRenderer=S.CanonicalFaceMeshRenderer;exports.DEFAULT_APPEARANCE=S.DEFAULT_APPEARANCE;exports.DEFAULT_FACE_MESH_RENDERER=S.DEFAULT_FACE_MESH_RENDERER;exports.DEFAULT_FACE_MESH_TRANSFORM=S.DEFAULT_FACE_MESH_TRANSFORM;exports.DEFAULT_MASKING=S.DEFAULT_MASKING;exports.FACE_MESH_ALPHA_MAPS=S.FACE_MESH_ALPHA_MAPS;exports.FACE_MESH_BLEND_MODES=S.FACE_MESH_BLEND_MODES;exports.FACE_MESH_MASK_TEXTURE_SOURCES=S.FACE_MESH_MASK_TEXTURE_SOURCES;exports.FACE_MESH_MATERIAL_TYPES=S.FACE_MESH_MATERIAL_TYPES;exports.FACE_MESH_SHADER_PRESETS=S.FACE_MESH_SHADER_PRESETS;exports.FACE_MESH_SIDES=S.FACE_MESH_SIDES;exports.FACE_MESH_TEXTURE_MAPS=S.FACE_MESH_TEXTURE_MAPS;exports.FaceMeshMaterial=S.FaceMeshMaterial;exports.FaceMeshRenderer=S.FaceMeshRenderer;exports.blendModeIndices=S.blendModeIndices;exports.canonicalFaceAlphaMaskUrl=S.canonicalFaceAlphaMaskUrl;exports.canonicalFaceTextureStyle2Url=S.canonicalFaceTextureStyle2Url;exports.canonicalFaceTextureUrl=S.canonicalFaceTextureUrl;exports.mapFaceMeshRendererSettingsToProps=S.mapFaceMeshRendererSettingsToProps;exports.parseCanonicalFaceModel=S.parseCanonicalFaceModel;exports.resolveFaceMeshRendererSettings=S.resolveFaceMeshRendererSettings;exports.supportsBlendMode=S.supportsBlendMode;exports.supportsTexturePanel=S.supportsTexturePanel;exports.useCanonicalFaceMesh=S.useCanonicalFaceMesh;exports.DEFAULT_FACE_WARP_3D_SETTINGS=F.DEFAULT_FACE_WARP_3D_SETTINGS;exports.FACE_RETOUCH_DEFAULT_CONTROLS=F.FACE_RETOUCH_DEFAULT_CONTROLS;exports.FACE_RETOUCH_SETTINGS_FIELDS=F.FACE_RETOUCH_SETTINGS_FIELDS;exports.FACE_WARP_3D_PRESET=F.FACE_WARP_3D_PRESET;exports.FaceRetouch=F.FaceRetouch;exports.alphaMapOptions=F.alphaMapOptions;exports.blendModeOptions=F.blendModeOptions;exports.materialTypeOptions=F.materialTypeOptions;exports.patchFaceRetouchControls=F.patchFaceRetouchControls;exports.resolveFaceRetouchControls=F.resolveFaceRetouchControls;exports.shaderPresetOptions=F.shaderPresetOptions;exports.sideOptions=F.sideOptions;exports.textureMapOptions=F.textureMapOptions;exports.DEFAULT_LIP_EFFECT=k;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=ae;exports.HEAD_OCCLUDER_DEFAULT_POSITION=z;exports.HEAD_OCCLUDER_DEFAULT_SCALE=B;exports.HeadBinding=At;exports.HeadBindingOccluder=Ft;exports.HeadOccluder=ce;exports.LipEffect=Ne;exports.LipEffectMaterial=Re;exports.computeAdaptiveVerticalFit=wt;exports.computeHeadBindingCubePose=be;exports.computeHeadBindingDebugMetrics=Ct;exports.computeHeadBindingShape=we;exports.computeUniversalHeadDepthOffset=Lt;exports.computeUniversalOccluderScale=_t;exports.computeUniversalPitchOffsetY=yt;exports.computeUniversalYawOffsetX=St;exports.solveHeadBinding=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("react/jsx-runtime"),K=require("react"),d=require("three"),me=require("./index-CyUUurQT.cjs"),re=require("./index-DCiMbxC3.cjs"),J=require("@react-three/drei"),S=require("./FaceMeshRenderer-C5l6VLdO.cjs"),F=require("./FaceRetouch-BkJzoA79.cjs"),Me=require("@react-three/fiber");function Ie(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const C=Ie(d),k={color:"#e85d75",opacity:.8,intensity:1,maskMode:"outer-and-inner-lips",shading:!0,renderOrder:30},Re=({context:l,color:t,opacity:e,intensity:s,shading:n,subtractMouth:i=!1})=>{const r=Me.useLoader(C.TextureLoader,S.TRANSPARENT_TEXTURE_DATA_URL),a=l.designTexture??r,o={cameraTexture:{value:l.cameraTexture},designTexture:{value:a},tint:{value:new C.Color(t)},opacity:{value:e},intensity:{value:s},shading:{value:n?1:0}};return A.jsx("shaderMaterial",{uniforms:o,vertexShader:"attribute vec2 faceUv; varying vec2 vFaceUv; varying vec2 vUv; void main() { vUv = uv; vFaceUv = faceUv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }",fragmentShader:"uniform sampler2D cameraTexture; uniform sampler2D designTexture; uniform vec3 tint; uniform float opacity; uniform float intensity; uniform float shading; varying vec2 vFaceUv; varying vec2 vUv; void main() { vec3 base = texture2D(cameraTexture, vFaceUv).rgb; vec4 design = texture2D(designTexture, vUv); vec3 painted = mix(design.rgb, design.rgb * tint, intensity); vec3 color = mix(base, painted, design.a * opacity); gl_FragColor = vec4(color, opacity * design.a); }",transparent:!0,side:C.DoubleSide,stencilWrite:!1,stencilRef:1,stencilFunc:i?C.NotEqualStencilFunc:C.AlwaysStencilFunc,depthWrite:!1,toneMapped:!1})},Ne=({faceIndex:l=0,designTexture:t,color:e=k.color,opacity:s=k.opacity,intensity:n=k.intensity,maskMode:i=k.maskMode,shading:r=k.shading,material:a,renderOrder:o=k.renderOrder})=>{const c=Me.useLoader(C.TextureLoader,typeof t=="string"?t:S.TRANSPARENT_TEXTURE_DATA_URL),h=typeof t=="string"?c:t??null,u=({cameraTexture:f,geometryKey:m})=>{if(m==="mouth")return A.jsx("meshBasicMaterial",{color:"#ffffff",colorWrite:!1,depthWrite:!1,depthTest:!1,stencilWrite:!0,stencilRef:1,stencilFunc:C.AlwaysStencilFunc,stencilZPass:C.ReplaceStencilOp});const T={cameraTexture:f,designTexture:h,lipMask:null,faceUv:null,faceIndex:l};return a?typeof a=="function"?a(T):a:A.jsx(Re,{context:T,color:e,opacity:s,intensity:n,shading:r,subtractMouth:!0})};return A.jsx(S.CanonicalFaceMeshRenderer,{faceIndex:l,showMouthGeometry:!0,showLipsGeometry:!0,showBaseGeometry:!1,showMouthMask:i==="outer-lips",showEyeGeometry:!1,showNoseGeometry:!1,showLeftEyeGeometry:!1,showRightEyeGeometry:!1,showEyeMask:!1,showNoseMask:!1,renderOrder:o,materialOverride:u})};function ge(l,t){if(t===d.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(t===d.TriangleFanDrawMode||t===d.TriangleStripDrawMode){let e=l.getIndex();if(e===null){const r=[],a=l.getAttribute("position");if(a!==void 0){for(let o=0;o<a.count;o++)r.push(o);l.setIndex(r),e=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const s=e.count-2,n=[];if(t===d.TriangleFanDrawMode)for(let r=1;r<=s;r++)n.push(e.getX(0)),n.push(e.getX(r)),n.push(e.getX(r+1));else for(let r=0;r<s;r++)r%2===0?(n.push(e.getX(r)),n.push(e.getX(r+1)),n.push(e.getX(r+2))):(n.push(e.getX(r+2)),n.push(e.getX(r+1)),n.push(e.getX(r)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),l}class Oe extends d.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Be(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new qe(e)}),this.register(function(e){return new Ze(e)}),this.register(function(e){return new Qe(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Xe(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Ye(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Je(e)}),this.register(function(e){return new $e(e)})}load(t,e,s,n){const i=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=d.LoaderUtils.extractUrlBase(t);r=d.LoaderUtils.resolveURL(c,this.path)}else r=d.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){n?n(c):console.error(c),i.manager.itemError(t),i.manager.itemEnd(t)},o=new d.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{i.parse(c,r,function(h){e(h),i.manager.itemEnd(t)},a)}catch(h){a(h)}},s,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let i;const r={},a={},o=new TextDecoder;if(typeof t=="string")i=JSON.parse(t);else if(t instanceof ArrayBuffer)if(o.decode(new Uint8Array(t,0,4))===_e){try{r[x.KHR_BINARY_GLTF]=new et(t)}catch(u){n&&n(u);return}i=JSON.parse(r[x.KHR_BINARY_GLTF].content)}else i=JSON.parse(o.decode(t));else i=t;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new ft(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,r[u.name]=!0}if(i.extensionsUsed)for(let h=0;h<i.extensionsUsed.length;++h){const u=i.extensionsUsed[h],f=i.extensionsRequired||[];switch(u){case x.KHR_MATERIALS_UNLIT:r[u]=new Ue;break;case x.KHR_DRACO_MESH_COMPRESSION:r[u]=new tt(i,this.dracoLoader);break;case x.KHR_TEXTURE_TRANSFORM:r[u]=new nt;break;case x.KHR_MESH_QUANTIZATION:r[u]=new st;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,i){s.parse(t,e,n,i)})}}function De(){let l={};return{get:function(t){return l[t]},add:function(t,e){l[t]=e},remove:function(t){delete l[t]},removeAll:function(){l={}}}}const x={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class He{constructor(t){this.parser=t,this.name=x.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(t){const e=this.parser,s="light:"+t;let n=e.cache.get(s);if(n)return n;const i=e.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[t];let c;const h=new d.Color(16777215);o.color!==void 0&&h.setRGB(o.color[0],o.color[1],o.color[2],d.LinearSRGBColorSpace);const u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new d.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new d.PointLight(h),c.distance=u;break;case"spot":c=new d.SpotLight(h),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),D(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=e.createUniqueName(o.name||"light_"+t),n=Promise.resolve(c),e.cache.add(s,n),n}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,s=this.parser,i=s.json.nodes[t],a=(i.extensions&&i.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return s._getNodeRef(e.cache,a,o)})}}class Ue{constructor(){this.name=x.KHR_MATERIALS_UNLIT}getMaterialType(){return d.MeshBasicMaterial}extendParams(t,e,s){const n=[];t.color=new d.Color(1,1,1),t.opacity=1;const i=e.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const r=i.baseColorFactor;t.color.setRGB(r[0],r[1],r[2],d.LinearSRGBColorSpace),t.opacity=r[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(t,"map",i.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class ve{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(e.emissiveIntensity=i),Promise.resolve()}}class Be{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];if(r.clearcoatFactor!==void 0&&(e.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new d.Vector2(a,a)}return Promise.all(i)}}class Ge{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_DISPERSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class ke{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.iridescenceFactor!==void 0&&(e.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(e.iridescenceIOR=r.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class je{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_SHEEN}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];e.sheenColor=new d.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const r=n.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&i.push(s.assignTexture(e,"sheenColorMap",r.sheenColorTexture,d.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(e,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(i)}}class Ke{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.transmissionFactor!==void 0&&(e.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&i.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class Xe{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_VOLUME}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&i.push(s.assignTexture(e,"thicknessMap",r.thicknessTexture)),e.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return e.attenuationColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),Promise.all(i)}}class Ve{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_IOR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return e.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Ye{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_SPECULAR}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];e.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&i.push(s.assignTexture(e,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return e.specularColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&i.push(s.assignTexture(e,"specularColorMap",r.specularColorTexture,d.SRGBColorSpace)),Promise.all(i)}}class We{constructor(t){this.parser=t,this.name=x.EXT_MATERIALS_BUMP}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return e.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&i.push(s.assignTexture(e,"bumpMap",r.bumpTexture)),Promise.all(i)}}class ze{constructor(t){this.parser=t,this.name=x.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const s=this.parser.json.materials[t];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(t,e){const s=this.parser,n=s.json.materials[t];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],r=n.extensions[this.name];return r.anisotropyStrength!==void 0&&(e.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(e.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&i.push(s.assignTexture(e,"anisotropyMap",r.anisotropyTexture)),Promise.all(i)}}class qe{constructor(t){this.parser=t,this.name=x.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,n=s.textures[t];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],r=e.options.ktx2Loader;if(!r){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,i.source,r)}}class Ze{constructor(t){this.parser=t,this.name=x.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Qe{constructor(t){this.parser=t,this.name=x.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,s=this.parser,n=s.json,i=n.textures[t];if(!i.extensions||!i.extensions[e])return null;const r=i.extensions[e],a=n.images[r.source];let o=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(t,r.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Je{constructor(t){this.name=x.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,s=e.bufferViews[t];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,h=n.count,u=n.byteStride,f=new Uint8Array(a,o,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,u,f,n.mode,n.filter).then(function(m){return m.buffer}):r.ready.then(function(){const m=new ArrayBuffer(h*u);return r.decodeGltfBuffer(new Uint8Array(m),h,u,f,n.mode,n.filter),m})})}else return null}}class $e{constructor(t){this.name=x.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,s=e.nodes[t];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=e.meshes[s.mesh];for(const c of n.primitives)if(c.mode!==I.TRIANGLES&&c.mode!==I.TRIANGLE_STRIP&&c.mode!==I.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=s.extensions[this.name].attributes,a=[],o={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(h=>(o[c]=h,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],f=c[0].count,m=[];for(const T of u){const E=new d.Matrix4,g=new d.Vector3,p=new d.Quaternion,M=new d.Vector3(1,1,1),_=new d.InstancedMesh(T.geometry,T.material,f);for(let R=0;R<f;R++)o.TRANSLATION&&g.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&p.fromBufferAttribute(o.ROTATION,R),o.SCALE&&M.fromBufferAttribute(o.SCALE,R),_.setMatrixAt(R,E.compose(g,p,M));for(const R in o)if(R==="_COLOR_0"){const L=o[R];_.instanceColor=new d.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&T.geometry.setAttribute(R,o[R]);d.Object3D.prototype.copy.call(_,T),this.parser.assignFinalMaterial(_),m.push(_)}return h.isGroup?(h.clear(),h.add(...m),h):m[0]}))}}const _e="glTF",W=12,Ae={JSON:1313821514,BIN:5130562};class et{constructor(t){this.name=x.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,W),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==_e)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-W,i=new DataView(t,W);let r=0;for(;r<n;){const a=i.getUint32(r,!0);r+=4;const o=i.getUint32(r,!0);if(r+=4,o===Ae.JSON){const c=new Uint8Array(t,W+r,a);this.content=s.decode(c)}else if(o===Ae.BIN){const c=W+r;this.body=t.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tt{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=x.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,n=this.dracoLoader,i=t.extensions[this.name].bufferView,r=t.extensions[this.name].attributes,a={},o={},c={};for(const h in r){const u=ie[h]||h.toLowerCase();a[u]=r[h]}for(const h in t.attributes){const u=ie[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[t.attributes[h]],m=X[f.componentType];c[u]=m.name,o[u]=f.normalized===!0}}return e.getDependency("bufferView",i).then(function(h){return new Promise(function(u,f){n.decodeDracoFile(h,function(m){for(const T in m.attributes){const E=m.attributes[T],g=o[T];g!==void 0&&(E.normalized=g)}u(m)},a,c,d.LinearSRGBColorSpace,f)})})}}class nt{constructor(){this.name=x.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class st{constructor(){this.name=x.KHR_MESH_QUANTIZATION}}class Se extends d.Interpolant{constructor(t,e,s,n){super(t,e,s,n)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=t*n*3+n;for(let r=0;r!==n;r++)e[r]=s[i+r];return e}interpolate_(t,e,s,n){const i=this.resultBuffer,r=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,h=n-e,u=(s-e)/h,f=u*u,m=f*u,T=t*c,E=T-c,g=-2*m+3*f,p=m-f,M=1-g,_=p-f+u;for(let R=0;R!==a;R++){const L=r[E+R+a],P=r[E+R+o]*h,w=r[T+R+a],N=r[T+R]*h;i[R]=M*L+_*P+g*w+p*N}return i}}const rt=new d.Quaternion;class it extends Se{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return rt.fromArray(i).normalize().toArray(i),i}}const I={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},X={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Te={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},Ee={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ie={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},v={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ot={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},ee={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function at(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new d.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.FrontSide})),l.DefaultMaterial}function G(l,t,e){for(const s in e.extensions)l[s]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=e.extensions[s])}function D(l,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(l.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function ct(l,t,e){let s=!1,n=!1,i=!1;for(let c=0,h=t.length;c<h;c++){const u=t[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(l);const r=[],a=[],o=[];for(let c=0,h=t.length;c<h;c++){const u=t[c];if(s){const f=u.POSITION!==void 0?e.getDependency("accessor",u.POSITION):l.attributes.position;r.push(f)}if(n){const f=u.NORMAL!==void 0?e.getDependency("accessor",u.NORMAL):l.attributes.normal;a.push(f)}if(i){const f=u.COLOR_0!==void 0?e.getDependency("accessor",u.COLOR_0):l.attributes.color;o.push(f)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o)]).then(function(c){const h=c[0],u=c[1],f=c[2];return s&&(l.morphAttributes.position=h),n&&(l.morphAttributes.normal=u),i&&(l.morphAttributes.color=f),l.morphTargetsRelative=!0,l})}function lt(l,t){if(l.updateMorphTargets(),t.weights!==void 0)for(let e=0,s=t.weights.length;e<s;e++)l.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(l.morphTargetInfluences.length===e.length){l.morphTargetDictionary={};for(let s=0,n=e.length;s<n;s++)l.morphTargetDictionary[e[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ut(l){let t;const e=l.extensions&&l.extensions[x.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+te(e.attributes):t=l.indices+":"+te(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)t+=":"+te(l.targets[s]);return t}function te(l){let t="";const e=Object.keys(l).sort();for(let s=0,n=e.length;s<n;s++)t+=e[s]+":"+l[e[s]]+";";return t}function oe(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function ht(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const dt=new d.Matrix4;class ft{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new De,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=s&&o?parseInt(o[1],10):-1,i=a.indexOf("Firefox")>-1,r=i?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&r<98?this.textureLoader=new d.TextureLoader(this.options.manager):this.textureLoader=new d.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(r){const a={scene:r[0][n.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:n.asset,parser:s,userData:{}};return G(i,a,n),D(a,n),Promise.all(s._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=e.length;n<i;n++){const r=e[n].joints;for(let a=0,o=r.length;a<o;a++)t[r[a]].isBone=!0}for(let n=0,i=t.length;n<i;n++){const r=t[n];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(s[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),i=(r,a)=>{const o=this.associations.get(r);o!=null&&this.associations.set(a,o);for(const[c,h]of r.children.entries())i(h,a.children[c])};return i(s,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const n=t(e[s]);if(n)return n}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let n=0;n<e.length;n++){const i=t(e[n]);i&&s.push(i)}return s}getDependency(t,e){const s=t+":"+e;let n=this.cache.get(s);if(!n){switch(t){case"scene":n=this.loadScene(e);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(e)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(e)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t);break}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(n.map(function(i,r){return s.getDependency(t,r)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],s=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[x.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,r){s.load(d.LoaderUtils.resolveURL(e.uri,n.path),i,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(s){const n=e.byteLength||0,i=e.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(n.bufferView===void 0&&n.sparse===void 0){const r=$[n.type],a=X[n.componentType],o=n.normalized===!0,c=new a(n.count*r);return Promise.resolve(new d.BufferAttribute(c,r,o))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(r){const a=r[0],o=$[n.type],c=X[n.componentType],h=c.BYTES_PER_ELEMENT,u=h*o,f=n.byteOffset||0,m=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,T=n.normalized===!0;let E,g;if(m&&m!==u){const p=Math.floor(f/m),M="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+p+":"+n.count;let _=e.cache.get(M);_||(E=new c(a,p*m,n.count*m/h),_=new d.InterleavedBuffer(E,m/h),e.cache.add(M,_)),g=new d.InterleavedBufferAttribute(_,o,f%m/h,T)}else a===null?E=new c(n.count*o):E=new c(a,f,n.count*o),g=new d.BufferAttribute(E,o,T);if(n.sparse!==void 0){const p=$.SCALAR,M=X[n.sparse.indices.componentType],_=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,L=new M(r[1],_,n.sparse.count*p),P=new c(r[2],R,n.sparse.count*o);a!==null&&(g=new d.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let w=0,N=L.length;w<N;w++){const b=L[w];if(g.setX(b,P[w*o]),o>=2&&g.setY(b,P[w*o+1]),o>=3&&g.setZ(b,P[w*o+2]),o>=4&&g.setW(b,P[w*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=T}return g})}loadTexture(t){const e=this.json,s=this.options,i=e.textures[t].source,r=e.images[i];let a=this.textureLoader;if(r.uri){const o=s.manager.getHandler(r.uri);o!==null&&(a=o)}return this.loadTextureImage(t,i,a)}loadTextureImage(t,e,s){const n=this,i=this.json,r=i.textures[t],a=i.images[e],o=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,s).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const f=(i.samplers||{})[r.sampler]||{};return h.magFilter=Te[f.magFilter]||d.LinearFilter,h.minFilter=Te[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=Ee[f.wrapS]||d.RepeatWrapping,h.wrapT=Ee[f.wrapT]||d.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==d.NearestFilter&&h.minFilter!==d.LinearFilter,n.associations.set(h,{textures:t}),h}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const s=this,n=this.json,i=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const r=n.images[t],a=self.URL||self.webkitURL;let o=r.uri||"",c=!1;if(r.bufferView!==void 0)o=s.getDependency("bufferView",r.bufferView).then(function(u){c=!0;const f=new Blob([u],{type:r.mimeType});return o=a.createObjectURL(f),o});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(o).then(function(u){return new Promise(function(f,m){let T=f;e.isImageBitmapLoader===!0&&(T=function(E){const g=new d.Texture(E);g.needsUpdate=!0,f(g)}),e.load(d.LoaderUtils.resolveURL(u,i.path),T,void 0,m)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),D(u,r),u.userData.mimeType=r.mimeType||ht(r.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[t]=h,h}assignTexture(t,e,s,n){const i=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(r=r.clone(),r.channel=s.texCoord),i.extensions[x.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[x.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=i.associations.get(r);r=i.extensions[x.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),i.associations.set(r,o)}}return n!==void 0&&(r.colorSpace=n),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=e.attributes.tangent===void 0,i=e.attributes.color!==void 0,r=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new d.PointsMaterial,d.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,o.sizeAttenuation=!1,this.cache.add(a,o)),s=o}else if(t.isLine){const a="LineBasicMaterial:"+s.uuid;let o=this.cache.get(a);o||(o=new d.LineBasicMaterial,d.Material.prototype.copy.call(o,s),o.color.copy(s.color),o.map=s.map,this.cache.add(a,o)),s=o}if(n||i||r){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),i&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=s.clone(),i&&(o.vertexColors=!0),r&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(s))),s=o}t.material=s}getMaterialType(){return d.MeshStandardMaterial}loadMaterial(t){const e=this,s=this.json,n=this.extensions,i=s.materials[t];let r;const a={},o=i.extensions||{},c=[];if(o[x.KHR_MATERIALS_UNLIT]){const u=n[x.KHR_MATERIALS_UNLIT];r=u.getMaterialType(),c.push(u.extendParams(a,i,e))}else{const u=i.pbrMetallicRoughness||{};if(a.color=new d.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],d.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,d.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),r=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}i.doubleSided===!0&&(a.side=d.DoubleSide);const h=i.alphaMode||ee.OPAQUE;if(h===ee.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===ee.MASK&&(a.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&r!==d.MeshBasicMaterial&&(c.push(e.assignTexture(a,"normalMap",i.normalTexture)),a.normalScale=new d.Vector2(1,1),i.normalTexture.scale!==void 0)){const u=i.normalTexture.scale;a.normalScale.set(u,u)}if(i.occlusionTexture!==void 0&&r!==d.MeshBasicMaterial&&(c.push(e.assignTexture(a,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&r!==d.MeshBasicMaterial){const u=i.emissiveFactor;a.emissive=new d.Color().setRGB(u[0],u[1],u[2],d.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&r!==d.MeshBasicMaterial&&c.push(e.assignTexture(a,"emissiveMap",i.emissiveTexture,d.SRGBColorSpace)),Promise.all(c).then(function(){const u=new r(a);return i.name&&(u.name=i.name),D(u,i),e.associations.set(u,{materials:t}),i.extensions&&G(n,u,i),u})}createUniqueName(t){const e=d.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function i(a){return s[x.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return xe(o,a,e)})}const r=[];for(let a=0,o=t.length;a<o;a++){const c=t[a],h=ut(c),u=n[h];if(u)r.push(u.promise);else{let f;c.extensions&&c.extensions[x.KHR_DRACO_MESH_COMPRESSION]?f=i(c):f=xe(new d.BufferGeometry,c,e),n[h]={primitive:c,promise:f},r.push(f)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,n=this.extensions,i=s.meshes[t],r=i.primitives,a=[];for(let o=0,c=r.length;o<c;o++){const h=r[o].material===void 0?at(this.cache):this.getDependency("material",r[o].material);a.push(h)}return a.push(e.loadGeometries(r)),Promise.all(a).then(function(o){const c=o.slice(0,o.length-1),h=o[o.length-1],u=[];for(let m=0,T=h.length;m<T;m++){const E=h[m],g=r[m];let p;const M=c[m];if(g.mode===I.TRIANGLES||g.mode===I.TRIANGLE_STRIP||g.mode===I.TRIANGLE_FAN||g.mode===void 0)p=i.isSkinnedMesh===!0?new d.SkinnedMesh(E,M):new d.Mesh(E,M),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),g.mode===I.TRIANGLE_STRIP?p.geometry=ge(p.geometry,d.TriangleStripDrawMode):g.mode===I.TRIANGLE_FAN&&(p.geometry=ge(p.geometry,d.TriangleFanDrawMode));else if(g.mode===I.LINES)p=new d.LineSegments(E,M);else if(g.mode===I.LINE_STRIP)p=new d.Line(E,M);else if(g.mode===I.LINE_LOOP)p=new d.LineLoop(E,M);else if(g.mode===I.POINTS)p=new d.Points(E,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(p.geometry.morphAttributes).length>0&&lt(p,i),p.name=e.createUniqueName(i.name||"mesh_"+t),D(p,i),g.extensions&&G(n,p,g),e.assignFinalMaterial(p),u.push(p)}for(let m=0,T=u.length;m<T;m++)e.associations.set(u[m],{meshes:t,primitives:m});if(u.length===1)return i.extensions&&G(n,u[0],i),u[0];const f=new d.Group;i.extensions&&G(n,f,i),e.associations.set(f,{meshes:t});for(let m=0,T=u.length;m<T;m++)f.add(u[m]);return f})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?e=new d.PerspectiveCamera(d.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(e=new d.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),D(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let n=0,i=e.joints.length;n<i;n++)s.push(this._loadNodeShallow(e.joints[n]));return e.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),r=n,a=[],o=[];for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u){a.push(u);const f=new d.Matrix4;i!==null&&f.fromArray(i.array,c*16),o.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new d.Skeleton(a,o)})}loadAnimation(t){const e=this.json,s=this,n=e.animations[t],i=n.name?n.name:"animation_"+t,r=[],a=[],o=[],c=[],h=[];for(let u=0,f=n.channels.length;u<f;u++){const m=n.channels[u],T=n.samplers[m.sampler],E=m.target,g=E.node,p=n.parameters!==void 0?n.parameters[T.input]:T.input,M=n.parameters!==void 0?n.parameters[T.output]:T.output;E.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",p)),o.push(this.getDependency("accessor",M)),c.push(T),h.push(E))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(h)]).then(function(u){const f=u[0],m=u[1],T=u[2],E=u[3],g=u[4],p=[];for(let M=0,_=f.length;M<_;M++){const R=f[M],L=m[M],P=T[M],w=E[M],N=g[M];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const b=s._createAnimationTracks(R,L,P,w,N);if(b)for(let O=0;O<b.length;O++)p.push(b[O])}return new d.AnimationClip(i,void 0,p)})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const r=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),r})}loadNode(t){const e=this.json,s=this,n=e.nodes[t],i=s._loadNodeShallow(t),r=[],a=n.children||[];for(let c=0,h=a.length;c<h;c++)r.push(s.getDependency("node",a[c]));const o=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(r),o]).then(function(c){const h=c[0],u=c[1],f=c[2];f!==null&&h.traverse(function(m){m.isSkinnedMesh&&m.bind(f,dt)});for(let m=0,T=u.length;m<T;m++)h.add(u[m]);return h})}_loadNodeShallow(t){const e=this.json,s=this.extensions,n=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const i=e.nodes[t],r=i.name?n.createUniqueName(i.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return o&&a.push(o),i.camera!==void 0&&a.push(n.getDependency("camera",i.camera).then(function(c){return n._getNodeRef(n.cameraCache,i.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let h;if(i.isBone===!0?h=new d.Bone:c.length>1?h=new d.Group:c.length===1?h=c[0]:h=new d.Object3D,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(i.name&&(h.userData.name=i.name,h.name=r),D(h,i),i.extensions&&G(s,h,i),i.matrix!==void 0){const u=new d.Matrix4;u.fromArray(i.matrix),h.applyMatrix4(u)}else i.translation!==void 0&&h.position.fromArray(i.translation),i.rotation!==void 0&&h.quaternion.fromArray(i.rotation),i.scale!==void 0&&h.scale.fromArray(i.scale);return n.associations.has(h)||n.associations.set(h,{}),n.associations.get(h).nodes=t,h}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,i=new d.Group;s.name&&(i.name=n.createUniqueName(s.name)),D(i,s),s.extensions&&G(e,i,s);const r=s.nodes||[],a=[];for(let o=0,c=r.length;o<c;o++)a.push(n.getDependency("node",r[o]));return Promise.all(a).then(function(o){for(let h=0,u=o.length;h<u;h++)i.add(o[h]);const c=h=>{const u=new Map;for(const[f,m]of n.associations)(f instanceof d.Material||f instanceof d.Texture)&&u.set(f,m);return h.traverse(f=>{const m=n.associations.get(f);m!=null&&u.set(f,m)}),u};return n.associations=c(i),i})}_createAnimationTracks(t,e,s,n,i){const r=[],a=t.name?t.name:t.uuid,o=[];v[i.path]===v.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(v[i.path]){case v.weights:c=d.NumberKeyframeTrack;break;case v.rotation:c=d.QuaternionKeyframeTrack;break;case v.position:case v.scale:c=d.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=d.NumberKeyframeTrack;break;case 2:case 3:default:c=d.VectorKeyframeTrack;break}break}const h=n.interpolation!==void 0?ot[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,m=o.length;f<m;f++){const T=new c(o[f]+"."+v[i.path],e.array,u,h);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(T),r.push(T)}return r}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const s=oe(e.constructor),n=new Float32Array(e.length);for(let i=0,r=e.length;i<r;i++)n[i]=e[i]*s;e=n}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?it:Se;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pt(l,t,e){const s=t.attributes,n=new d.Box3;if(s.POSITION!==void 0){const a=e.json.accessors[s.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new d.Vector3(o[0],o[1],o[2]),new d.Vector3(c[0],c[1],c[2])),a.normalized){const h=oe(X[a.componentType]);n.min.multiplyScalar(h),n.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=t.targets;if(i!==void 0){const a=new d.Vector3,o=new d.Vector3;for(let c=0,h=i.length;c<h;c++){const u=i[c];if(u.POSITION!==void 0){const f=e.json.accessors[u.POSITION],m=f.min,T=f.max;if(m!==void 0&&T!==void 0){if(o.setX(Math.max(Math.abs(m[0]),Math.abs(T[0]))),o.setY(Math.max(Math.abs(m[1]),Math.abs(T[1]))),o.setZ(Math.max(Math.abs(m[2]),Math.abs(T[2]))),f.normalized){const E=oe(X[f.componentType]);o.multiplyScalar(E)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}l.boundingBox=n;const r=new d.Sphere;n.getCenter(r.center),r.radius=n.min.distanceTo(n.max)/2,l.boundingSphere=r}function xe(l,t,e){const s=t.attributes,n=[];function i(r,a){return e.getDependency("accessor",r).then(function(o){l.setAttribute(a,o)})}for(const r in s){const a=ie[r]||r.toLowerCase();a in l.attributes||n.push(i(s[r],a))}if(t.indices!==void 0&&!l.index){const r=e.getDependency("accessor",t.indices).then(function(a){l.setIndex(a)});n.push(r)}return d.ColorManagement.workingColorSpace!==d.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.ColorManagement.workingColorSpace}" not supported.`),D(l,t),pt(l,t,e),Promise.all(n).then(function(){return t.targets!==void 0?ct(l,t.targets,e):l})}const z=[0,0,-10],B=[.5,.5,.5],ae=1,ne=new Map,mt=l=>{const t=ne.get(l);if(t)return t;const e=new Oe,s=re.fetchAndVerify(l).then(n=>new Promise((i,r)=>{e.parse(n,"",i,r)})).catch(n=>{throw ne.delete(l),n});return ne.set(l,s),s},ce=({position:l,rotation:t,scale:e,url:s,showDebugMaterial:n=!1,opacity:i=ae})=>{const r=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",re.libConfig.assetStorageEndpoint).toString(),[a,o]=K.useState(null);K.useEffect(()=>{let h=!1;return mt(r).then(u=>{h||o(u.scene)}).catch(u=>{h||console.error(`${re.libConfig.loggerPrefix} head occluder load failed`,u)}),()=>{h=!0}},[r]);const c=K.useMemo(()=>{if(!a)return null;const h=a.clone();return h.traverse(u=>{u instanceof C.Mesh&&(u.material=new C.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?i:1,side:C.DoubleSide,transparent:n}))}),h},[a,n,i]);return K.useEffect(()=>{if(c)return()=>{c.traverse(h=>{h instanceof C.Mesh&&h.material.dispose()})}},[c]),c?(l?c.position.set(l[0],l[1],l[2]):c.position.set(z[0],z[1],z[2]),t&&c.rotation.set(t[0],t[1],t[2]),e?c.scale.set(e[0],e[1],e[2]):c.scale.set(B[0],B[1],B[2]),c.renderOrder=-1,A.jsx("primitive",{object:c})):null},gt=4,At=({children:l,faceIndex:t=0,numFaces:e=gt,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:i=!1,faceMeshMaterial:r})=>{const a=K.useMemo(()=>new C.MeshBasicMaterial({color:"#22c55e",side:C.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),o=n===!1?null:n===!0?{}:n;return A.jsxs(me.FaceTracker,{faceIndex:t,numFaces:e,scaleWithFace:s,children:[o&&A.jsx(ce,{position:o.position??z,rotation:o.rotation,scale:o.scale??B,url:o.url,showDebugMaterial:o.showDebugMaterial,opacity:o.opacity??ae}),l,i&&A.jsx(me.FaceMesh,{faceIndex:t,numFaces:e,material:r??a})]})},Tt=57,Et=15.5,se=Tt/Math.PI/Et,xt=-.134,Mt=-.024,H=(l,t,e)=>Math.min(e,Math.max(t,l)),ye=(l,t)=>l*t-t/2,Le=(l,t)=>-(l*t-t/2),Rt=({eyeMidX:l,noseX:t,offsetX:e,rawYaw:s,sideMidX:n})=>{const i=H((Math.abs(s)-.18)/.42,0,1),r=n*.75+l*.25,a=l*.7+t*.3;return r*(1-i)+a*i+e},_t=({baseScale:l,pitchRadians:t})=>{const e=t*180/Math.PI,n=1+H((e-6)/22,0,1)*.22;return[l[0]*n,l[1]*n,l[2]*n]},St=({yawRadians:l})=>{const t=Math.abs(l*180/Math.PI),s=.066*H((t-8)/12,0,1);return Math.sign(l)*s},yt=({pitchRadians:l})=>{const t=l*180/Math.PI;return-.026*H((-t-6)/18,0,1)},Lt=({baseOffset:l,yawRadians:t})=>{const e=Math.abs(t*180/Math.PI),s=H((e-8)/24,0,1);return l+s*.25},wt=({baseOffsetY:l,baseScaleY:t,face:e})=>{if(!e||e.bounds.width<=0)return{aspectRatio:0,normalizedAspect:0,scaleY:t,offsetY:l};const s=e.bounds.height/e.bounds.width,n=H((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:t+n*.06,offsetY:l+n*.005}},we=({face:l,offsetX:t,offsetY:e,scaleX:s,scaleY:n})=>{const i=l.bounds.width*s,r=l.bounds.height*n,a=l.bounds.centerX+t,o=l.bounds.centerY+e;return{x:a-i*.5,y:o-r*.5,width:i,height:r,centerX:a,centerY:o}},bt=({face:l,height:t,lockDepth:e,lockRotation:s,model:n,offsetX:i,offsetY:r,scaleX:a,scaleY:o,scaleZ:c,width:h})=>{const u=we({face:l,offsetX:i,offsetY:r,scaleX:a,scaleY:o}),f=l.landmarks[33],m=l.landmarks[263],T=l.landmarks[234],E=l.landmarks[454],g=l.landmarks[1],p=l.landmarks[10],M=l.landmarks[152],_=u.width*h,R=u.height*t,L=f&&m?(f.x+m.x)*.5:l.bounds.centerX,P=f&&m?(f.y+m.y)*.5:l.bounds.centerY-l.bounds.height*.15,w=T&&E?(T.x+E.x)*.5:L,N=(p==null?void 0:p.y)??l.bounds.minY,b=(M==null?void 0:M.y)??l.bounds.maxY,O=(N+b)*.5,q=f&&m?Math.atan2(m.y-f.y,m.x-f.x):0,U=g&&l.bounds.width>0?H((g.x-l.bounds.centerX)/(l.bounds.width*.5),-1,1)*.75:0,j=Rt({eyeMidX:L,noseX:(g==null?void 0:g.x)??L,offsetX:i,rawYaw:U,sideMidX:w}),y=O*.75+P*.25+r,Z=n==="v2"?ye(j,h):u.centerX*h-h/2,V=n==="v2"?Le(l.bounds.centerY+r*.75,t):-(u.centerY*t-t/2),Y=p&&g?Math.max(1e-4,g.y-p.y):l.bounds.height*.42,ue=g&&M?Math.max(1e-4,M.y-g.y):l.bounds.height*.58,he=(ue-Y)/(ue+Y),de=H((he-xt)/.28,-1,1)*.58,fe=g&&l.bounds.height>0?H((l.bounds.centerY-g.y)/(l.bounds.height*.5)-Mt,-1,1)*.18:0,Q=de*.82+fe*.18,pe=s?0:n==="v2"?U*.72:U,Ce=s?0:n==="v2"?-Q*.78:-Q,Fe=s?0:-q,Pe=e?_*se:n==="v2"?_*(se+Math.abs(pe)*.18):_*se;return{centerXPx:Z,centerYPx:V,depthPx:Pe*c,heightPx:R,pitch:Ce,rawPitch:Q,rawPitchFromBalance:de,rawPitchFromCenter:fe,rawYaw:U,rotationZ:Fe,roll:q,shape:u,skullAnchorX:j,skullAnchorY:y,verticalBalance:he,widthPx:_,yaw:pe}},be=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g})=>le({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g}).pose,le=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g})=>{const p=bt({face:s,height:n,lockDepth:l,lockRotation:t,model:e,offsetX:r,offsetY:a,scaleX:u,scaleY:f,scaleZ:m,width:g});if(T){const _=new d.Vector3(0,p.heightPx*E,-p.depthPx*i).applyEuler(new d.Euler(p.pitch,p.yaw,p.rotationZ,"XYZ")),R=ye(p.skullAnchorX,g),L=Le(p.skullAnchorY,n);return{pose:{boxCenterZ:_.z,centerX:R+_.x,centerY:L+_.y,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},debugMetrics:{face:{centerX:p.shape.centerX,centerY:p.shape.centerY,width:p.shape.width,height:p.shape.height},normalized:{rawPitch:p.rawPitch,rawPitchFromBalance:p.rawPitchFromBalance,rawPitchFromCenter:p.rawPitchFromCenter,rawYaw:p.rawYaw,roll:p.roll,verticalBalance:p.verticalBalance},pose:{pitch:p.pitch,yaw:p.yaw,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:R+_.x,y:L+_.y,z:_.z},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}}return{pose:{boxCenterZ:-p.depthPx*i,centerX:p.centerXPx,centerY:p.centerYPx,width:p.widthPx,height:p.heightPx,depth:p.depthPx,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},debugMetrics:{face:{centerX:p.shape.centerX,centerY:p.shape.centerY,width:p.shape.width,height:p.shape.height},normalized:{rawPitch:p.rawPitch,rawPitchFromBalance:p.rawPitchFromBalance,rawPitchFromCenter:p.rawPitchFromCenter,rawYaw:p.rawYaw,roll:p.roll,verticalBalance:p.verticalBalance},pose:{pitch:p.pitch,yaw:p.yaw,rotationX:p.pitch+o,rotationY:p.yaw+c,rotationZ:p.rotationZ+h},skullAnchor:{x:p.skullAnchorX,y:p.skullAnchorY},center:{x:p.centerXPx,y:p.centerYPx,z:-p.depthPx*i},depthPx:p.depthPx,screen:{widthPx:p.widthPx,heightPx:p.heightPx}}}},Ct=({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g})=>le({lockDepth:l,lockRotation:t,model:e,face:s,height:n,headDepthOffset:i,offsetX:r,offsetY:a,rotationOffsetX:o,rotationOffsetY:c,rotationOffsetZ:h,scaleX:u,scaleY:f,scaleZ:m,skullCenterMode:T,skullVerticalBias:E,width:g}).debugMetrics,Ft=({boxColor:l,boxOpacity:t,face:e,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,occluderOffset:a,occluderOpacity:o,occluderScale:c,showOccluderProxy:h=!1,offsetX:u,offsetY:f,pose:m,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:g,scaleX:p,scaleY:M,scaleZ:_,show:R,showCenterDot:L,showFacePlaneReference:P,showGizmo:w,showHeadOccluder:N,skullCenterMode:b,skullVerticalBias:O,url:q,viewportHeight:U,viewportWidth:j})=>{const y=K.useMemo(()=>m||(!e||j<=0||U<=0?null:be({face:e,width:j,height:U,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,offsetX:u,offsetY:f,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:g,scaleX:p,scaleY:M,scaleZ:_,skullCenterMode:b,skullVerticalBias:O})),[e,s,n,i,r,u,f,T,E,g,p,M,_,b,O,m,U,j]);if(!R||!y)return null;const Z=b?[0,-y.height*O,y.depth*s]:[0,0,0],V=y.height,Y=[B[0]*c[0]*V,B[1]*c[1]*V,B[2]*c[2]*V];return A.jsxs(A.Fragment,{children:[A.jsxs("group",{position:[y.centerX,y.centerY,y.boxCenterZ],rotation:[y.rotationX,y.rotationY,y.rotationZ],children:[A.jsx("group",{scale:[y.width,y.height,y.depth],children:t>0&&A.jsxs("mesh",{children:[A.jsx("boxGeometry",{args:[1,1,1]}),A.jsx("meshBasicMaterial",{color:l,wireframe:!0,transparent:!0,opacity:t})]})}),L&&A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:l})]}),P&&A.jsxs("group",{position:Z,children:[A.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[A.jsx("ringGeometry",{args:[6,8,24]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",side:d.DoubleSide})]}),A.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[A.jsx("planeGeometry",{args:[3,16]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]}),A.jsxs("mesh",{children:[A.jsx("planeGeometry",{args:[16,3]}),A.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]})]}),N&&A.jsxs(A.Fragment,{children:[h&&A.jsxs("mesh",{position:a,scale:Y,renderOrder:20,children:[A.jsx("sphereGeometry",{args:[1,24,16]}),A.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1})]}),A.jsx(ce,{opacity:o,position:a,scale:Y,showDebugMaterial:!0,url:q})]})]}),w&&A.jsx("group",{position:[y.centerX,y.centerY,y.boxCenterZ],rotation:[y.rotationX,y.rotationY,y.rotationZ],renderOrder:10,children:A.jsxs("group",{children:[A.jsxs("mesh",{children:[A.jsx("sphereGeometry",{args:[6,20,20]}),A.jsx("meshBasicMaterial",{color:"#e2e8f0",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[18,0,0],rotation:[0,0,-Math.PI/2],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[34,0,0],rotation:[0,0,-Math.PI/2],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,18,0],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,34,0],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,0,18],rotation:[Math.PI/2,0,0],children:[A.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),A.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),A.jsxs("mesh",{position:[0,0,34],rotation:[Math.PI/2,0,0],children:[A.jsx("coneGeometry",{args:[4.2,12,16]}),A.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),A.jsx(J.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),A.jsx(J.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),A.jsx(J.Text,{position:[0,0,42],fontSize:10,color:"#3b82f6",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Z"})]})})]})};exports.CANONICAL_FACE_MESH_GEOMETRY_SPECS=S.CANONICAL_FACE_MESH_GEOMETRY_SPECS;exports.CanonicalFaceMeshRenderer=S.CanonicalFaceMeshRenderer;exports.DEFAULT_APPEARANCE=S.DEFAULT_APPEARANCE;exports.DEFAULT_FACE_MESH_RENDERER=S.DEFAULT_FACE_MESH_RENDERER;exports.DEFAULT_FACE_MESH_TRANSFORM=S.DEFAULT_FACE_MESH_TRANSFORM;exports.DEFAULT_MASKING=S.DEFAULT_MASKING;exports.FACE_MESH_ALPHA_MAPS=S.FACE_MESH_ALPHA_MAPS;exports.FACE_MESH_BLEND_MODES=S.FACE_MESH_BLEND_MODES;exports.FACE_MESH_MASK_TEXTURE_SOURCES=S.FACE_MESH_MASK_TEXTURE_SOURCES;exports.FACE_MESH_MATERIAL_TYPES=S.FACE_MESH_MATERIAL_TYPES;exports.FACE_MESH_SHADER_PRESETS=S.FACE_MESH_SHADER_PRESETS;exports.FACE_MESH_SIDES=S.FACE_MESH_SIDES;exports.FACE_MESH_TEXTURE_MAPS=S.FACE_MESH_TEXTURE_MAPS;exports.FaceMeshMaterial=S.FaceMeshMaterial;exports.FaceMeshRenderer=S.FaceMeshRenderer;exports.blendModeIndices=S.blendModeIndices;exports.canonicalFaceAlphaMaskUrl=S.canonicalFaceAlphaMaskUrl;exports.canonicalFaceTextureStyle2Url=S.canonicalFaceTextureStyle2Url;exports.canonicalFaceTextureUrl=S.canonicalFaceTextureUrl;exports.mapFaceMeshRendererProps=S.mapFaceMeshRendererProps;exports.mapFaceMeshRendererSettingsToProps=S.mapFaceMeshRendererSettingsToProps;exports.parseCanonicalFaceModel=S.parseCanonicalFaceModel;exports.resolveFaceMeshRendererSettings=S.resolveFaceMeshRendererSettings;exports.supportsBlendMode=S.supportsBlendMode;exports.supportsTexturePanel=S.supportsTexturePanel;exports.useCanonicalFaceMesh=S.useCanonicalFaceMesh;exports.DEFAULT_FACE_WARP_3D_SETTINGS=F.DEFAULT_FACE_WARP_3D_SETTINGS;exports.FACE_RETOUCH_DEFAULT_CONTROLS=F.FACE_RETOUCH_DEFAULT_CONTROLS;exports.FACE_RETOUCH_SETTINGS_FIELDS=F.FACE_RETOUCH_SETTINGS_FIELDS;exports.FACE_WARP_3D_PRESET=F.FACE_WARP_3D_PRESET;exports.FaceRetouch=F.FaceRetouch;exports.alphaMapOptions=F.alphaMapOptions;exports.blendModeOptions=F.blendModeOptions;exports.materialTypeOptions=F.materialTypeOptions;exports.patchFaceRetouchControls=F.patchFaceRetouchControls;exports.resolveFaceRetouchControls=F.resolveFaceRetouchControls;exports.shaderPresetOptions=F.shaderPresetOptions;exports.sideOptions=F.sideOptions;exports.textureMapOptions=F.textureMapOptions;exports.DEFAULT_LIP_EFFECT=k;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=ae;exports.HEAD_OCCLUDER_DEFAULT_POSITION=z;exports.HEAD_OCCLUDER_DEFAULT_SCALE=B;exports.HeadBinding=At;exports.HeadBindingOccluder=Ft;exports.HeadOccluder=ce;exports.LipEffect=Ne;exports.LipEffectMaterial=Re;exports.computeAdaptiveVerticalFit=wt;exports.computeHeadBindingCubePose=be;exports.computeHeadBindingDebugMetrics=Ct;exports.computeHeadBindingShape=we;exports.computeUniversalHeadDepthOffset=Lt;exports.computeUniversalOccluderScale=_t;exports.computeUniversalPitchOffsetY=yt;exports.computeUniversalYawOffsetX=St;exports.solveHeadBinding=le;
@@ -2,12 +2,12 @@ import { jsx as T, jsxs as w, Fragment as ye } from "react/jsx-runtime";
2
2
  import { useState as rt, useEffect as we, useMemo as Te } from "react";
3
3
  import * as b from "three";
4
4
  import { TrianglesDrawMode as it, TriangleFanDrawMode as fe, TriangleStripDrawMode as He, Loader as ot, LoaderUtils as Z, FileLoader as ke, MeshPhysicalMaterial as C, Vector2 as Be, Color as j, LinearSRGBColorSpace as v, SRGBColorSpace as Q, SpotLight as at, PointLight as ct, DirectionalLight as lt, Matrix4 as te, Vector3 as U, Quaternion as Ue, InstancedMesh as ut, InstancedBufferAttribute as ht, Object3D as Ge, TextureLoader as dt, ImageBitmapLoader as ft, BufferAttribute as re, InterleavedBuffer as pt, InterleavedBufferAttribute as mt, LinearMipmapLinearFilter as je, NearestMipmapLinearFilter as gt, LinearMipmapNearestFilter as At, NearestMipmapNearestFilter as Tt, LinearFilter as pe, NearestFilter as Ke, RepeatWrapping as me, MirroredRepeatWrapping as Et, ClampToEdgeWrapping as xt, PointsMaterial as Rt, Material as ie, LineBasicMaterial as Mt, MeshStandardMaterial as Xe, DoubleSide as $, MeshBasicMaterial as q, PropertyBinding as _t, BufferGeometry as yt, SkinnedMesh as wt, Mesh as St, LineSegments as Lt, Line as bt, LineLoop as It, Points as Nt, Group as oe, PerspectiveCamera as Ct, MathUtils as Pt, OrthographicCamera as Ft, Skeleton as Ot, AnimationClip as Dt, Bone as vt, InterpolateDiscrete as Ht, InterpolateLinear as Ye, Texture as Se, VectorKeyframeTrack as Le, NumberKeyframeTrack as be, QuaternionKeyframeTrack as Ie, ColorManagement as Ne, FrontSide as kt, Interpolant as Bt, Box3 as Ut, Sphere as Gt, Euler as jt } from "three";
5
- import { b as Kt, c as Xt } from "./index-B-s4YbWu.js";
6
- import { l as Ce, f as Yt } from "./index-I4eF5TKT.js";
5
+ import { b as Kt, c as Xt } from "./index-ByoNj0QP.js";
6
+ import { l as Ce, f as Yt } from "./index-9dlAQAhy.js";
7
7
  import { Text as ae } from "@react-three/drei";
8
- import { T as Ve, C as Vt } from "./FaceMeshRenderer-DSCd1H55.js";
9
- import { q as is, D as os, h as as, i as cs, j as ls, d as us, e as hs, f as ds, F as fs, a as ps, b as ms, c as gs, l as As, m as Ts, g as Es, n as xs, o as Rs, p as Ms, r as _s, v as ys, t as ws, k as Ss, s as Ls, u as bs } from "./FaceMeshRenderer-DSCd1H55.js";
10
- import { D as Ns, d as Cs, e as Ps, F as Fs, f as Os, b as Ds, c as vs, m as Hs, p as ks, r as Bs, s as Us, a as Gs, t as js } from "./FaceRetouch-CMJbGThL.js";
8
+ import { T as Ve, C as Vt } from "./FaceMeshRenderer-wjAHrJzP.js";
9
+ import { q as is, D as os, h as as, i as cs, j as ls, d as us, e as hs, f as ds, F as fs, a as ps, b as ms, c as gs, l as As, m as Ts, g as Es, n as xs, o as Rs, p as Ms, r as _s, t as ys, w as ws, u as Ss, k as Ls, s as bs, v as Is } from "./FaceMeshRenderer-wjAHrJzP.js";
10
+ import { D as Cs, d as Ps, e as Fs, F as Os, f as Ds, b as vs, c as Hs, m as ks, p as Bs, r as Us, s as Gs, a as js, t as Ks } from "./FaceRetouch-DwbKQJAN.js";
11
11
  import { useLoader as We } from "@react-three/fiber";
12
12
  const X = {
13
13
  color: "#e85d75",
@@ -2392,7 +2392,7 @@ export {
2392
2392
  os as DEFAULT_APPEARANCE,
2393
2393
  as as DEFAULT_FACE_MESH_RENDERER,
2394
2394
  cs as DEFAULT_FACE_MESH_TRANSFORM,
2395
- Ns as DEFAULT_FACE_WARP_3D_SETTINGS,
2395
+ Cs as DEFAULT_FACE_WARP_3D_SETTINGS,
2396
2396
  X as DEFAULT_LIP_EFFECT,
2397
2397
  ls as DEFAULT_MASKING,
2398
2398
  us as FACE_MESH_ALPHA_MAPS,
@@ -2402,12 +2402,12 @@ export {
2402
2402
  ps as FACE_MESH_SHADER_PRESETS,
2403
2403
  ms as FACE_MESH_SIDES,
2404
2404
  gs as FACE_MESH_TEXTURE_MAPS,
2405
- Cs as FACE_RETOUCH_DEFAULT_CONTROLS,
2406
- Ps as FACE_RETOUCH_SETTINGS_FIELDS,
2407
- Fs as FACE_WARP_3D_PRESET,
2405
+ Ps as FACE_RETOUCH_DEFAULT_CONTROLS,
2406
+ Fs as FACE_RETOUCH_SETTINGS_FIELDS,
2407
+ Os as FACE_WARP_3D_PRESET,
2408
2408
  As as FaceMeshMaterial,
2409
2409
  Ts as FaceMeshRenderer,
2410
- Os as FaceRetouch,
2410
+ Ds as FaceRetouch,
2411
2411
  Ze as HEAD_OCCLUDER_DEFAULT_OPACITY,
2412
2412
  ee as HEAD_OCCLUDER_DEFAULT_POSITION,
2413
2413
  G as HEAD_OCCLUDER_DEFAULT_SCALE,
@@ -2416,9 +2416,9 @@ export {
2416
2416
  Qe as HeadOccluder,
2417
2417
  zn as LipEffect,
2418
2418
  Wt as LipEffectMaterial,
2419
- Ds as alphaMapOptions,
2419
+ vs as alphaMapOptions,
2420
2420
  Es as blendModeIndices,
2421
- vs as blendModeOptions,
2421
+ Hs as blendModeOptions,
2422
2422
  xs as canonicalFaceAlphaMaskUrl,
2423
2423
  Rs as canonicalFaceTextureStyle2Url,
2424
2424
  Ms as canonicalFaceTextureUrl,
@@ -2430,17 +2430,18 @@ export {
2430
2430
  Zn as computeUniversalOccluderScale,
2431
2431
  Jn as computeUniversalPitchOffsetY,
2432
2432
  Qn as computeUniversalYawOffsetX,
2433
- _s as mapFaceMeshRendererSettingsToProps,
2434
- Hs as materialTypeOptions,
2435
- ys as parseCanonicalFaceModel,
2436
- ks as patchFaceRetouchControls,
2437
- ws as resolveFaceMeshRendererSettings,
2438
- Bs as resolveFaceRetouchControls,
2439
- Us as shaderPresetOptions,
2440
- Gs as sideOptions,
2433
+ _s as mapFaceMeshRendererProps,
2434
+ ys as mapFaceMeshRendererSettingsToProps,
2435
+ ks as materialTypeOptions,
2436
+ ws as parseCanonicalFaceModel,
2437
+ Bs as patchFaceRetouchControls,
2438
+ Ss as resolveFaceMeshRendererSettings,
2439
+ Us as resolveFaceRetouchControls,
2440
+ Gs as shaderPresetOptions,
2441
+ js as sideOptions,
2441
2442
  et as solveHeadBinding,
2442
- Ss as supportsBlendMode,
2443
- Ls as supportsTexturePanel,
2444
- js as textureMapOptions,
2445
- bs as useCanonicalFaceMesh
2443
+ Ls as supportsBlendMode,
2444
+ bs as supportsTexturePanel,
2445
+ Ks as textureMapOptions,
2446
+ Is as useCanonicalFaceMesh
2446
2447
  };
@@ -1,5 +1,5 @@
1
1
  import { useState as X, useEffect as Y } from "react";
2
- import { F as A } from "./index-B-s4YbWu.js";
2
+ import { F as A } from "./index-ByoNj0QP.js";
3
3
  const E = (e, t = {
4
4
  minX: 0,
5
5
  minY: 0,
@@ -1 +1 @@
1
- "use strict";const x=require("react"),b=require("./index-CxMEeCRP.cjs"),E=(e,t={minX:0,minY:0,maxX:0,maxY:0,width:0,height:0,centerX:0,centerY:0})=>{if(e.length===0)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t.width=0,t.height=0,t.centerX=0,t.centerY=0,t;let n=1,s=1,i=0,o=0;for(let l=0;l<e.length;l++){const{x:a,y:r}=e[l];a<n&&(n=a),r<s&&(s=r),a>i&&(i=a),r>o&&(o=r)}const c=Math.max(0,i-n),u=Math.max(0,o-s);return t.minX=n,t.minY=s,t.maxX=i,t.maxY=o,t.width=c,t.height=u,t.centerX=n+c*.5,t.centerY=s+u*.5,t},_=(e,t)=>e.map(n=>({landmarks:n,bounds:E(n)})),C={publishedCount:0,lastPublishAt:-1/0,lastNonEmptyAt:-1},I=(e,t,n,s,i)=>{if(t>0){const o={...e,lastNonEmptyAt:n};return n-e.lastPublishAt>=s?{action:"publish",state:{publishedCount:t,lastPublishAt:n,lastNonEmptyAt:n}}:{action:"none",state:o}}return e.publishedCount===0?{action:"none",state:e}:e.lastNonEmptyAt>=0&&n-e.lastNonEmptyAt<i?{action:"none",state:e}:{action:"clear",state:{publishedCount:0,lastPublishAt:-1/0,lastNonEmptyAt:e.lastNonEmptyAt}}},L=({enabled:e,holdMs:t,node:n,onFrame:s,prepare:i,throttleMs:o})=>{const[c,u]=x.useState([]);return x.useEffect(()=>{if(!e||!n){u(h=>h.length===0?h:[]);return}let l=0,a,r=C;const d=(h,m,f)=>{const{action:A,state:S}=I(r,h,m,o,t);r=S,A==="publish"?u(f):A==="clear"&&u(y=>y.length===0?y:[])},F=()=>{l=requestAnimationFrame(F),s==null||s();const h=performance.now(),m=n.getDetectionResults();if(!m){d(0,h,[]),a=m;return}if(m===a)return;a=m;const f=i(m);d(f.length,h,f)};return l=requestAnimationFrame(F),()=>cancelAnimationFrame(l)},[e,t,n,s,i,o]),c},R=.5,P=(e,t)=>{for(const n in t)delete t[n];if(e)for(const n of e)t[n.categoryName]=n.score;return t},X=(e,t)=>e.blendshapes[t]??0,T=(e,t,n=R)=>X(e,t)>=n,Y=e=>{const t=e[b.FACE_EYE_DISTANCE_LANDMARKS.left],n=e[b.FACE_EYE_DISTANCE_LANDMARKS.right];return!t||!n?0:Math.hypot(t.x-n.x,t.y-n.y)},D=()=>({index:0,landmarks:[],bounds:{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0,centerX:0,centerY:0},pose:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:0,y:0,z:0}},eyeDistance:0,blendshapes:{}}),p=(e,t)=>{t.x=e.x,t.y=e.y,t.z=e.z},N=(e,t,n=0,s)=>{var u,l,a;const i=(u=t.faceLandmarks)==null?void 0:u[n],o=e.getFace(n);if(!i||!o)return null;const c=s??D();return c.index=n,c.landmarks=i,E(i,c.bounds),p(o.transform.position,c.pose.position),p(o.transform.rotation,c.pose.rotation),p(o.transform.scale,c.pose.scale),c.eyeDistance=Y(i),P((a=(l=t.faceBlendshapes)==null?void 0:l[n])==null?void 0:a.categories,c.blendshapes),c},B=(e,t=0,n)=>{const s=e.getDetectionResults();return s?N(e,s,t,n):null};exports.DEFAULT_FACE_EXPRESSION_THRESHOLD=R;exports.computeLandmarkBounds=E;exports.createFaceInfoTarget=D;exports.getFaceBlendshape=X;exports.getFaceEyeDistance=Y;exports.getFaceInfo=B;exports.getFaceInfoFromResults=N;exports.hasFaceExpression=T;exports.prepareCalibrationFaceResults=_;exports.useFaceResultReader=L;
1
+ "use strict";const x=require("react"),b=require("./index-CyUUurQT.cjs"),E=(e,t={minX:0,minY:0,maxX:0,maxY:0,width:0,height:0,centerX:0,centerY:0})=>{if(e.length===0)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t.width=0,t.height=0,t.centerX=0,t.centerY=0,t;let n=1,s=1,i=0,o=0;for(let l=0;l<e.length;l++){const{x:a,y:r}=e[l];a<n&&(n=a),r<s&&(s=r),a>i&&(i=a),r>o&&(o=r)}const c=Math.max(0,i-n),u=Math.max(0,o-s);return t.minX=n,t.minY=s,t.maxX=i,t.maxY=o,t.width=c,t.height=u,t.centerX=n+c*.5,t.centerY=s+u*.5,t},_=(e,t)=>e.map(n=>({landmarks:n,bounds:E(n)})),C={publishedCount:0,lastPublishAt:-1/0,lastNonEmptyAt:-1},I=(e,t,n,s,i)=>{if(t>0){const o={...e,lastNonEmptyAt:n};return n-e.lastPublishAt>=s?{action:"publish",state:{publishedCount:t,lastPublishAt:n,lastNonEmptyAt:n}}:{action:"none",state:o}}return e.publishedCount===0?{action:"none",state:e}:e.lastNonEmptyAt>=0&&n-e.lastNonEmptyAt<i?{action:"none",state:e}:{action:"clear",state:{publishedCount:0,lastPublishAt:-1/0,lastNonEmptyAt:e.lastNonEmptyAt}}},L=({enabled:e,holdMs:t,node:n,onFrame:s,prepare:i,throttleMs:o})=>{const[c,u]=x.useState([]);return x.useEffect(()=>{if(!e||!n){u(h=>h.length===0?h:[]);return}let l=0,a,r=C;const d=(h,m,f)=>{const{action:A,state:S}=I(r,h,m,o,t);r=S,A==="publish"?u(f):A==="clear"&&u(y=>y.length===0?y:[])},F=()=>{l=requestAnimationFrame(F),s==null||s();const h=performance.now(),m=n.getDetectionResults();if(!m){d(0,h,[]),a=m;return}if(m===a)return;a=m;const f=i(m);d(f.length,h,f)};return l=requestAnimationFrame(F),()=>cancelAnimationFrame(l)},[e,t,n,s,i,o]),c},R=.5,P=(e,t)=>{for(const n in t)delete t[n];if(e)for(const n of e)t[n.categoryName]=n.score;return t},X=(e,t)=>e.blendshapes[t]??0,T=(e,t,n=R)=>X(e,t)>=n,Y=e=>{const t=e[b.FACE_EYE_DISTANCE_LANDMARKS.left],n=e[b.FACE_EYE_DISTANCE_LANDMARKS.right];return!t||!n?0:Math.hypot(t.x-n.x,t.y-n.y)},D=()=>({index:0,landmarks:[],bounds:{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0,centerX:0,centerY:0},pose:{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:0,y:0,z:0}},eyeDistance:0,blendshapes:{}}),p=(e,t)=>{t.x=e.x,t.y=e.y,t.z=e.z},N=(e,t,n=0,s)=>{var u,l,a;const i=(u=t.faceLandmarks)==null?void 0:u[n],o=e.getFace(n);if(!i||!o)return null;const c=s??D();return c.index=n,c.landmarks=i,E(i,c.bounds),p(o.transform.position,c.pose.position),p(o.transform.rotation,c.pose.rotation),p(o.transform.scale,c.pose.scale),c.eyeDistance=Y(i),P((a=(l=t.faceBlendshapes)==null?void 0:l[n])==null?void 0:a.categories,c.blendshapes),c},B=(e,t=0,n)=>{const s=e.getDetectionResults();return s?N(e,s,t,n):null};exports.DEFAULT_FACE_EXPRESSION_THRESHOLD=R;exports.computeLandmarkBounds=E;exports.createFaceInfoTarget=D;exports.getFaceBlendshape=X;exports.getFaceEyeDistance=Y;exports.getFaceInfo=B;exports.getFaceInfoFromResults=N;exports.hasFaceExpression=T;exports.prepareCalibrationFaceResults=_;exports.useFaceResultReader=L;
@@ -15,8 +15,10 @@ export type SessionFacade = {
15
15
  registerXRPipeline: (params: RegisterXRPipelineParams) => Promise<void>;
16
16
  getModelNode: <T extends Record<string, unknown>>(modelCode: XRModel) => T;
17
17
  captureFrame: () => string;
18
+ captureStream: (fps?: number) => MediaStream;
18
19
  getInputFrame: () => OffscreenCanvas | HTMLCanvasElement | null;
19
20
  _setRenderTarget: (canvas: HTMLCanvasElement) => Promise<void>;
21
+ _setCaptureTarget: (canvas: HTMLCanvasElement | undefined) => void;
20
22
  _setRenderSize: (width: number, height: number) => Promise<void>;
21
23
  _setR3FState: (state: {
22
24
  renderer: WebGLRenderer;