@vincentt-xr/sdk 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (71) hide show
  1. package/GROUNDING.md +67 -9
  2. package/dist/{DebuggerUI-Cq28c18s.js → DebuggerUI-DhKTXTY2.js} +1 -1
  3. package/dist/{DebuggerUI-B45_Gb9d.cjs → DebuggerUI-bnGHSSOb.cjs} +1 -1
  4. package/dist/{FaceMeshRenderer-6t8OsQhK.js → FaceMeshRenderer-B2i2NW71.js} +3 -3
  5. package/dist/{FaceMeshRenderer-lQLhYIW-.cjs → FaceMeshRenderer-BSOq1OnG.cjs} +1 -1
  6. package/dist/{FaceRetouch-CDrL0pXg.js → FaceRetouch-Bg-OBU4n.js} +30 -30
  7. package/dist/{FaceRetouch-DtNl8-4e.cjs → FaceRetouch-TZeBGIqW.cjs} +1 -1
  8. package/dist/components/MeshRenderer/index.d.ts +1 -0
  9. package/dist/components/ScreenImage/source.d.ts +3 -0
  10. package/dist/contexts-B2_NsTnk.js +660 -0
  11. package/dist/contexts-BgWfyxre.cjs +1 -0
  12. package/dist/debug-ui/media-source.cjs +1 -1
  13. package/dist/debug-ui/media-source.js +1 -1
  14. package/dist/debug-ui.cjs +3 -3
  15. package/dist/debug-ui.js +1246 -1205
  16. package/dist/entries/low-level.d.ts +5 -0
  17. package/dist/face-effects.cjs +1 -1
  18. package/dist/face-effects.js +4 -4
  19. package/dist/{getFaceInfo-hUKMLFcr.js → getFaceInfo-4DhcPZDJ.js} +1 -1
  20. package/dist/{getFaceInfo-CyPAKh3h.cjs → getFaceInfo-QOQ_dc-W.cjs} +1 -1
  21. package/dist/hooks/selectors.d.ts +2 -4
  22. package/dist/hooks/useXRModel.d.ts +5 -0
  23. package/dist/hooks/useXRSession/reason.d.ts +19 -0
  24. package/dist/hooks/useXRSession/store.d.ts +12 -4
  25. package/dist/index-72Wb15Ca.js +214 -0
  26. package/dist/{index-JygePOwo.js → index-BMeBJ0dV.js} +322 -299
  27. package/dist/index-C9yQVzAh.cjs +1 -0
  28. package/dist/index-CNGzE49z.cjs +17 -0
  29. package/dist/{index-Di70KWuY.js → index-Cj3fGDtZ.js} +844 -825
  30. package/dist/{index-BgQAX8rs.js → index-D1kj6uc-.js} +123 -120
  31. package/dist/{index-D4bLzBr6.cjs → index-Da7uycur.cjs} +1 -1
  32. package/dist/{index-DSpzjuqd.cjs → index-WPPnlFO1.cjs} +1 -1
  33. package/dist/index-ZaDEzDtR.cjs +1 -0
  34. package/dist/{index-UC0Ux38E.js → index-g250Tqme.js} +1 -1
  35. package/dist/{internal-DuMPpcbp.js → internal-34pb7djs.js} +3 -3
  36. package/dist/{internal-i2JkM85N.cjs → internal-Dtvo4WYo.cjs} +1 -1
  37. package/dist/internal.cjs +1 -1
  38. package/dist/internal.js +1 -1
  39. package/dist/low-level.cjs +1 -1
  40. package/dist/low-level.js +399 -490
  41. package/dist/main.cjs +1 -1
  42. package/dist/main.js +28 -28
  43. package/dist/{renderGroups-C9QJrAXu.js → renderGroups-CPWUX6z9.js} +1 -1
  44. package/dist/{renderGroups-Dvm1J4lW.cjs → renderGroups-jSUOY1Oq.cjs} +1 -1
  45. package/dist/{renderPasses-CjgG_6kQ.js → renderPasses-CLlYRdMk.js} +5 -5
  46. package/dist/{renderPasses-CT5iBwtg.cjs → renderPasses-KUJUSevp.cjs} +2 -2
  47. package/dist/scene-object.cjs +1 -1
  48. package/dist/scene-object.js +2 -2
  49. package/dist/{selectors-Dw3C-gSk.js → selectors-DLxL8Q66.js} +4 -4
  50. package/dist/{selectors-2QvO5RYY.cjs → selectors-S8g25ke9.cjs} +1 -1
  51. package/dist/{session-C1StwN0f.js → session-CbtvwiaD.js} +1 -1
  52. package/dist/{session-BChR4TgK.cjs → session-DP8AF7Rg.cjs} +1 -1
  53. package/dist/texture/animatedTexture.d.ts +2 -0
  54. package/dist/texture/gifReader.d.ts +17 -0
  55. package/dist/texture/gifTextureSource.d.ts +16 -0
  56. package/dist/tracking.cjs +1 -1
  57. package/dist/tracking.js +9 -9
  58. package/dist/{useFaceInfo-C-WfMlYp.cjs → useFaceInfo-BvZeUBsL.cjs} +1 -1
  59. package/dist/{useFaceInfo-CwsHZedC.js → useFaceInfo-C06EyScd.js} +3 -3
  60. package/dist/{useFaceResults-CkFc1egZ.js → useFaceResults-C1Ppc8rS.js} +1 -1
  61. package/dist/{useFaceResults-VcFdOUFV.cjs → useFaceResults-CCNiH7VZ.cjs} +1 -1
  62. package/docs/api/screen-image.mdx +27 -3
  63. package/docs/api/texture-sources.mdx +25 -6
  64. package/docs/texture-api-consumer.md +26 -0
  65. package/package.json +4 -3
  66. package/dist/contexts-BKvTIayr.cjs +0 -1
  67. package/dist/contexts-Bk5zz_VR.js +0 -214
  68. package/dist/index-82aENaRq.cjs +0 -1
  69. package/dist/index-CEc1CAmB.cjs +0 -1
  70. package/dist/index-CTHeBQOs.js +0 -178
  71. package/dist/index-DzEzkBIH.cjs +0 -17
@@ -13,6 +13,8 @@ export { useXRModel } from '../hooks/useXRModel';
13
13
  export type { UseXRModelResult } from '../hooks/useXRModel';
14
14
  export type { XRModelNodeSegmentation, XRModelNodeBodyTracking, XRModelNodeHandTracking, XRModelNodeGestureTracking, XRModelNodeFaceTracking, } from '../types/nodes';
15
15
  export { useXRReady, useXRError, useXRCameraTexture, useXRRenderSize, useXRModelNode, useXRPipelineSnapshot, } from '../hooks/selectors';
16
+ export type { XRSessionError } from '../hooks/useXRSession/store';
17
+ export type { XRErrorReason } from '../hooks/useXRSession/reason';
16
18
  export type { GestureName } from '../hooks/useGestureEdge';
17
19
  export { useFaceBoundingBox } from '../hooks/useFaceBoundingBox';
18
20
  export { computeLandmarkBounds } from '../utils/landmarkBounds';
@@ -42,6 +44,9 @@ export { hasFullUnitUVBounds } from '../texture/hasFullUnitUVBounds';
42
44
  export { getPlaybackFrame, getSequenceFrame } from '../texture/animationMath';
43
45
  export type { PlaybackFrameResult } from '../texture/animationMath';
44
46
  export { BasicAnimatedTextureController } from '../texture/animatedTexture';
47
+ export { gifTextureSourceProvider } from '../texture/gifTextureSource';
48
+ export { MAX_GIF_BYTES, MAX_GIF_FRAMES, MAX_GIF_PIXELS } from '../texture/gifTextureSource';
49
+ export type { GifTextureSource } from '../texture/gifTextureSource';
45
50
  export type { AnimatedTextureCapabilities, AnimatedTextureController, AnimatedTextureListener, AnimatedTextureEvent, AnimatedTextureEventListener, AnimatedTextureEventType, AnimatedTexturePlayMode, AnimatedTextureSnapshot, AnimatedTextureState, } from '../texture/animatedTexture';
46
51
  export { TextureSourceLoadError, createTextureSourceResolver, disposeResolvedTextureSource, resolveTextureSource, throwIfAborted, } from '../texture/sourceResolver';
47
52
  export type { ResolvedTextureSource, TextureSourceProvider, TextureSourceResolver, } from '../texture/sourceResolver';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),k=require("react"),d=require("three"),pe=require("./index-82aENaRq.cjs"),se=require("./index-D4bLzBr6.cjs"),Q=require("@react-three/drei"),S=require("./FaceMeshRenderer-lQLhYIW-.cjs"),b=require("./FaceRetouch-DtNl8-4e.cjs");function be(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 v=be(d);function me(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 Fe extends d.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new De(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Ye(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Xe(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new qe(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))===xe){try{r[x.KHR_BINARY_GLTF]=new Ze(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 lt(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 Ne;break;case x.KHR_DRACO_MESH_COMPRESSION:r[u]=new Qe(i,this.dracoLoader);break;case x.KHR_TEXTURE_TRANSFORM:r[u]=new Je;break;case x.KHR_MESH_QUANTIZATION:r[u]=new $e;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 Ie(){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 Pe{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),O(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 Ne{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 Oe{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 De{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 He{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 Be{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 Ue{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 Ge{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 je{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 ke{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 ve{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 Ke{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 Xe{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 Ye{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 Ve{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 We{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 ze{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 qe{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,A=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&&A.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&p.fromBufferAttribute(o.ROTATION,R),o.SCALE&&M.fromBufferAttribute(o.SCALE,R),_.setMatrixAt(R,E.compose(A,p,M));for(const R in o)if(R==="_COLOR_0"){const y=o[R];_.instanceColor=new d.InstancedBufferAttribute(y.array,y.itemSize,y.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 xe="glTF",V=12,Ae={JSON:1313821514,BIN:5130562};class Ze{constructor(t){this.name=x.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,V),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!==xe)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-V,i=new DataView(t,V);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,V+r,a);this.content=s.decode(c)}else if(o===Ae.BIN){const c=V+r;this.body=t.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Qe{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=re[h]||h.toLowerCase();a[u]=r[h]}for(const h in t.attributes){const u=re[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[t.attributes[h]],m=K[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],A=o[T];A!==void 0&&(E.normalized=A)}u(m)},a,c,d.LinearSRGBColorSpace,f)})})}}class Je{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 $e{constructor(){this.name=x.KHR_MESH_QUANTIZATION}}class Me 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,A=-2*m+3*f,p=m-f,M=1-A,_=p-f+u;for(let R=0;R!==a;R++){const y=r[E+R+a],F=r[E+R+o]*h,w=r[T+R+a],P=r[T+R]*h;i[R]=M*y+_*F+A*w+p*P}return i}}const et=new d.Quaternion;class tt extends Me{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return et.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},K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ge={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},Te={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},J={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},re={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"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},nt={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},$={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function st(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 O(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 rt(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 it(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 ot(l){let t;const e=l.extensions&&l.extensions[x.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+ee(e.attributes):t=l.indices+":"+ee(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)t+=":"+ee(l.targets[s]);return t}function ee(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 ie(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 at(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 ct=new d.Matrix4;class lt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Ie,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),O(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=J[n.type],a=K[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=J[n.type],c=K[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,A;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,_)),A=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),A=new d.BufferAttribute(E,o,T);if(n.sparse!==void 0){const p=J.SCALAR,M=K[n.sparse.indices.componentType],_=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,y=new M(r[1],_,n.sparse.count*p),F=new c(r[2],R,n.sparse.count*o);a!==null&&(A=new d.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let w=0,P=y.length;w<P;w++){const C=y[w];if(A.setX(C,F[w*o]),o>=2&&A.setY(C,F[w*o+1]),o>=3&&A.setZ(C,F[w*o+2]),o>=4&&A.setW(C,F[w*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=T}return A})}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=ge[f.magFilter]||d.LinearFilter,h.minFilter=ge[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=Te[f.wrapS]||d.RepeatWrapping,h.wrapT=Te[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 A=new d.Texture(E);A.needsUpdate=!0,f(A)}),e.load(d.LoaderUtils.resolveURL(u,i.path),T,void 0,m)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),O(u,r),u.userData.mimeType=r.mimeType||at(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||$.OPAQUE;if(h===$.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===$.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),O(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 Ee(o,a,e)})}const r=[];for(let a=0,o=t.length;a<o;a++){const c=t[a],h=ot(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=Ee(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?st(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],A=r[m];let p;const M=c[m];if(A.mode===I.TRIANGLES||A.mode===I.TRIANGLE_STRIP||A.mode===I.TRIANGLE_FAN||A.mode===void 0)p=i.isSkinnedMesh===!0?new d.SkinnedMesh(E,M):new d.Mesh(E,M),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),A.mode===I.TRIANGLE_STRIP?p.geometry=me(p.geometry,d.TriangleStripDrawMode):A.mode===I.TRIANGLE_FAN&&(p.geometry=me(p.geometry,d.TriangleFanDrawMode));else if(A.mode===I.LINES)p=new d.LineSegments(E,M);else if(A.mode===I.LINE_STRIP)p=new d.Line(E,M);else if(A.mode===I.LINE_LOOP)p=new d.LineLoop(E,M);else if(A.mode===I.POINTS)p=new d.Points(E,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(p.geometry.morphAttributes).length>0&&it(p,i),p.name=e.createUniqueName(i.name||"mesh_"+t),O(p,i),A.extensions&&G(n,p,A),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)),O(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,A=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",A)),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],A=u[4],p=[];for(let M=0,_=f.length;M<_;M++){const R=f[M],y=m[M],F=T[M],w=E[M],P=A[M];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const C=s._createAnimationTracks(R,y,F,w,P);if(C)for(let N=0;N<C.length;N++)p.push(C[N])}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,ct)});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),O(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)),O(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=[];B[i.path]===B.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(B[i.path]){case B.weights:c=d.NumberKeyframeTrack;break;case B.rotation:c=d.QuaternionKeyframeTrack;break;case B.position:case B.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?nt[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,m=o.length;f<m;f++){const T=new c(o[f]+"."+B[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=ie(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?tt:Me;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ut(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=ie(K[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=ie(K[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 Ee(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=re[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.`),O(l,t),ut(l,t,e),Promise.all(n).then(function(){return t.targets!==void 0?rt(l,t.targets,e):l})}const W=[0,0,-10],U=[.5,.5,.5],oe=1,te=new Map,ht=l=>{const t=te.get(l);if(t)return t;const e=new Fe,s=se.fetchAndVerify(l).then(n=>new Promise((i,r)=>{e.parse(n,"",i,r)})).catch(n=>{throw te.delete(l),n});return te.set(l,s),s},ae=({position:l,rotation:t,scale:e,url:s,showDebugMaterial:n=!1,opacity:i=oe})=>{const r=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",se.libConfig.assetStorageEndpoint).toString(),[a,o]=k.useState(null);k.useEffect(()=>{let h=!1;return ht(r).then(u=>{h||o(u.scene)}).catch(u=>{h||console.error(`${se.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 v.Mesh&&(u.material=new v.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?i:1,side:v.DoubleSide,transparent:n}))}),h},[a,n,i]);return k.useEffect(()=>{if(c)return()=>{c.traverse(h=>{h instanceof v.Mesh&&h.material.dispose()})}},[c]),c?(l?c.position.set(l[0],l[1],l[2]):c.position.set(W[0],W[1],W[2]),t&&c.rotation.set(t[0],t[1],t[2]),e?c.scale.set(e[0],e[1],e[2]):c.scale.set(U[0],U[1],U[2]),c.renderOrder=-1,g.jsx("primitive",{object:c})):null},dt=4,ft=({children:l,faceIndex:t=0,numFaces:e=dt,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:i=!1,faceMeshMaterial:r})=>{const a=k.useMemo(()=>new v.MeshBasicMaterial({color:"#22c55e",side:v.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),o=n===!1?null:n===!0?{}:n;return g.jsxs(pe.FaceTracker,{faceIndex:t,numFaces:e,scaleWithFace:s,children:[o&&g.jsx(ae,{position:o.position??W,rotation:o.rotation,scale:o.scale??U,url:o.url,showDebugMaterial:o.showDebugMaterial,opacity:o.opacity??oe}),l,i&&g.jsx(pe.FaceMesh,{faceIndex:t,numFaces:e,material:r??a})]})},pt=57,mt=15.5,ne=pt/Math.PI/mt,At=-.134,gt=-.024,D=(l,t,e)=>Math.min(e,Math.max(t,l)),Re=(l,t)=>l*t-t/2,_e=(l,t)=>-(l*t-t/2),Tt=({eyeMidX:l,noseX:t,offsetX:e,rawYaw:s,sideMidX:n})=>{const i=D((Math.abs(s)-.18)/.42,0,1),r=n*.75+l*.25,a=l*.7+t*.3;return r*(1-i)+a*i+e},Et=({baseScale:l,pitchRadians:t})=>{const e=t*180/Math.PI,n=1+D((e-6)/22,0,1)*.22;return[l[0]*n,l[1]*n,l[2]*n]},xt=({yawRadians:l})=>{const t=Math.abs(l*180/Math.PI),s=.066*D((t-8)/12,0,1);return Math.sign(l)*s},Mt=({pitchRadians:l})=>{const t=l*180/Math.PI;return-.026*D((-t-6)/18,0,1)},Rt=({baseOffset:l,yawRadians:t})=>{const e=Math.abs(t*180/Math.PI),s=D((e-8)/24,0,1);return l+s*.25},_t=({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=D((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:t+n*.06,offsetY:l+n*.005}},Se=({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}},St=({face:l,height:t,lockDepth:e,lockRotation:s,model:n,offsetX:i,offsetY:r,scaleX:a,scaleY:o,scaleZ:c,width:h})=>{const u=Se({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],A=l.landmarks[1],p=l.landmarks[10],M=l.landmarks[152],_=u.width*h,R=u.height*t,y=f&&m?(f.x+m.x)*.5:l.bounds.centerX,F=f&&m?(f.y+m.y)*.5:l.bounds.centerY-l.bounds.height*.15,w=T&&E?(T.x+E.x)*.5:y,P=(p==null?void 0:p.y)??l.bounds.minY,C=(M==null?void 0:M.y)??l.bounds.maxY,N=(P+C)*.5,z=f&&m?Math.atan2(m.y-f.y,m.x-f.x):0,H=A&&l.bounds.width>0?D((A.x-l.bounds.centerX)/(l.bounds.width*.5),-1,1)*.75:0,j=Tt({eyeMidX:y,noseX:(A==null?void 0:A.x)??y,offsetX:i,rawYaw:H,sideMidX:w}),L=N*.75+F*.25+r,q=n==="v2"?Re(j,h):u.centerX*h-h/2,X=n==="v2"?_e(l.bounds.centerY+r*.75,t):-(u.centerY*t-t/2),Y=p&&A?Math.max(1e-4,A.y-p.y):l.bounds.height*.42,le=A&&M?Math.max(1e-4,M.y-A.y):l.bounds.height*.58,ue=(le-Y)/(le+Y),he=D((ue-At)/.28,-1,1)*.58,de=A&&l.bounds.height>0?D((l.bounds.centerY-A.y)/(l.bounds.height*.5)-gt,-1,1)*.18:0,Z=he*.82+de*.18,fe=s?0:n==="v2"?H*.72:H,ye=s?0:n==="v2"?-Z*.78:-Z,we=s?0:-z,Ce=e?_*ne:n==="v2"?_*(ne+Math.abs(fe)*.18):_*ne;return{centerXPx:q,centerYPx:X,depthPx:Ce*c,heightPx:R,pitch:ye,rawPitch:Z,rawPitchFromBalance:he,rawPitchFromCenter:de,rawYaw:H,rotationZ:we,roll:z,shape:u,skullAnchorX:j,skullAnchorY:L,verticalBalance:ue,widthPx:_,yaw:fe}},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:A})=>ce({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:A}).pose,ce=({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:A})=>{const p=St({face:s,height:n,lockDepth:l,lockRotation:t,model:e,offsetX:r,offsetY:a,scaleX:u,scaleY:f,scaleZ:m,width:A});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=Re(p.skullAnchorX,A),y=_e(p.skullAnchorY,n);return{pose:{boxCenterZ:_.z,centerX:R+_.x,centerY:y+_.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:y+_.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}}}},Lt=({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:A})=>ce({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:A}).debugMetrics,yt=({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:A,scaleX:p,scaleY:M,scaleZ:_,show:R,showCenterDot:y,showFacePlaneReference:F,showGizmo:w,showHeadOccluder:P,skullCenterMode:C,skullVerticalBias:N,url:z,viewportHeight:H,viewportWidth:j})=>{const L=k.useMemo(()=>m||(!e||j<=0||H<=0?null:Le({face:e,width:j,height:H,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,offsetX:u,offsetY:f,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:A,scaleX:p,scaleY:M,scaleZ:_,skullCenterMode:C,skullVerticalBias:N})),[e,s,n,i,r,u,f,T,E,A,p,M,_,C,N,m,H,j]);if(!R||!L)return null;const q=C?[0,-L.height*N,L.depth*s]:[0,0,0],X=L.height,Y=[U[0]*c[0]*X,U[1]*c[1]*X,U[2]*c[2]*X];return g.jsxs(g.Fragment,{children:[g.jsxs("group",{position:[L.centerX,L.centerY,L.boxCenterZ],rotation:[L.rotationX,L.rotationY,L.rotationZ],children:[g.jsx("group",{scale:[L.width,L.height,L.depth],children:t>0&&g.jsxs("mesh",{children:[g.jsx("boxGeometry",{args:[1,1,1]}),g.jsx("meshBasicMaterial",{color:l,wireframe:!0,transparent:!0,opacity:t})]})}),y&&g.jsxs("mesh",{children:[g.jsx("sphereGeometry",{args:[6,20,20]}),g.jsx("meshBasicMaterial",{color:l})]}),F&&g.jsxs("group",{position:q,children:[g.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[g.jsx("ringGeometry",{args:[6,8,24]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",side:d.DoubleSide})]}),g.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[g.jsx("planeGeometry",{args:[3,16]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]}),g.jsxs("mesh",{children:[g.jsx("planeGeometry",{args:[16,3]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]})]}),P&&g.jsxs(g.Fragment,{children:[h&&g.jsxs("mesh",{position:a,scale:Y,renderOrder:20,children:[g.jsx("sphereGeometry",{args:[1,24,16]}),g.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1})]}),g.jsx(ae,{opacity:o,position:a,scale:Y,showDebugMaterial:!0,url:z})]})]}),w&&g.jsx("group",{position:[L.centerX,L.centerY,L.boxCenterZ],rotation:[L.rotationX,L.rotationY,L.rotationZ],renderOrder:10,children:g.jsxs("group",{children:[g.jsxs("mesh",{children:[g.jsx("sphereGeometry",{args:[6,20,20]}),g.jsx("meshBasicMaterial",{color:"#e2e8f0",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[18,0,0],rotation:[0,0,-Math.PI/2],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[34,0,0],rotation:[0,0,-Math.PI/2],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,18,0],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,34,0],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,0,18],rotation:[Math.PI/2,0,0],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,0,34],rotation:[Math.PI/2,0,0],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),g.jsx(Q.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),g.jsx(Q.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),g.jsx(Q.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=b.DEFAULT_FACE_WARP_3D_SETTINGS;exports.FACE_RETOUCH_DEFAULT_CONTROLS=b.FACE_RETOUCH_DEFAULT_CONTROLS;exports.FACE_RETOUCH_SETTINGS_FIELDS=b.FACE_RETOUCH_SETTINGS_FIELDS;exports.FACE_WARP_3D_PRESET=b.FACE_WARP_3D_PRESET;exports.FaceRetouch=b.FaceRetouch;exports.alphaMapOptions=b.alphaMapOptions;exports.blendModeOptions=b.blendModeOptions;exports.materialTypeOptions=b.materialTypeOptions;exports.patchFaceRetouchControls=b.patchFaceRetouchControls;exports.resolveFaceRetouchControls=b.resolveFaceRetouchControls;exports.shaderPresetOptions=b.shaderPresetOptions;exports.sideOptions=b.sideOptions;exports.textureMapOptions=b.textureMapOptions;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=oe;exports.HEAD_OCCLUDER_DEFAULT_POSITION=W;exports.HEAD_OCCLUDER_DEFAULT_SCALE=U;exports.HeadBinding=ft;exports.HeadBindingOccluder=yt;exports.HeadOccluder=ae;exports.computeAdaptiveVerticalFit=_t;exports.computeHeadBindingCubePose=Le;exports.computeHeadBindingDebugMetrics=Lt;exports.computeHeadBindingShape=Se;exports.computeUniversalHeadDepthOffset=Rt;exports.computeUniversalOccluderScale=Et;exports.computeUniversalPitchOffsetY=Mt;exports.computeUniversalYawOffsetX=xt;exports.solveHeadBinding=ce;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),k=require("react"),d=require("three"),pe=require("./index-ZaDEzDtR.cjs"),se=require("./index-Da7uycur.cjs"),Q=require("@react-three/drei"),S=require("./FaceMeshRenderer-BSOq1OnG.cjs"),b=require("./FaceRetouch-TZeBGIqW.cjs");function be(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 v=be(d);function me(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 Fe extends d.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new De(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Ye(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Xe(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new qe(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))===xe){try{r[x.KHR_BINARY_GLTF]=new Ze(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 lt(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 Ne;break;case x.KHR_DRACO_MESH_COMPRESSION:r[u]=new Qe(i,this.dracoLoader);break;case x.KHR_TEXTURE_TRANSFORM:r[u]=new Je;break;case x.KHR_MESH_QUANTIZATION:r[u]=new $e;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 Ie(){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 Pe{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),O(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 Ne{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 Oe{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 De{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 He{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 Be{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 Ue{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 Ge{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 je{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 ke{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 ve{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 Ke{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 Xe{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 Ye{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 Ve{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 We{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 ze{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 qe{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,A=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&&A.fromBufferAttribute(o.TRANSLATION,R),o.ROTATION&&p.fromBufferAttribute(o.ROTATION,R),o.SCALE&&M.fromBufferAttribute(o.SCALE,R),_.setMatrixAt(R,E.compose(A,p,M));for(const R in o)if(R==="_COLOR_0"){const y=o[R];_.instanceColor=new d.InstancedBufferAttribute(y.array,y.itemSize,y.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 xe="glTF",V=12,Ae={JSON:1313821514,BIN:5130562};class Ze{constructor(t){this.name=x.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,V),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!==xe)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-V,i=new DataView(t,V);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,V+r,a);this.content=s.decode(c)}else if(o===Ae.BIN){const c=V+r;this.body=t.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Qe{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=re[h]||h.toLowerCase();a[u]=r[h]}for(const h in t.attributes){const u=re[h]||h.toLowerCase();if(r[h]!==void 0){const f=s.accessors[t.attributes[h]],m=K[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],A=o[T];A!==void 0&&(E.normalized=A)}u(m)},a,c,d.LinearSRGBColorSpace,f)})})}}class Je{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 $e{constructor(){this.name=x.KHR_MESH_QUANTIZATION}}class Me 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,A=-2*m+3*f,p=m-f,M=1-A,_=p-f+u;for(let R=0;R!==a;R++){const y=r[E+R+a],F=r[E+R+o]*h,w=r[T+R+a],P=r[T+R]*h;i[R]=M*y+_*F+A*w+p*P}return i}}const et=new d.Quaternion;class tt extends Me{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return et.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},K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ge={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},Te={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},J={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},re={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"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},nt={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},$={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function st(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 O(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 rt(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 it(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 ot(l){let t;const e=l.extensions&&l.extensions[x.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+ee(e.attributes):t=l.indices+":"+ee(l.attributes)+":"+l.mode,l.targets!==void 0)for(let s=0,n=l.targets.length;s<n;s++)t+=":"+ee(l.targets[s]);return t}function ee(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 ie(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 at(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 ct=new d.Matrix4;class lt{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new Ie,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),O(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=J[n.type],a=K[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=J[n.type],c=K[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,A;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,_)),A=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),A=new d.BufferAttribute(E,o,T);if(n.sparse!==void 0){const p=J.SCALAR,M=K[n.sparse.indices.componentType],_=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,y=new M(r[1],_,n.sparse.count*p),F=new c(r[2],R,n.sparse.count*o);a!==null&&(A=new d.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let w=0,P=y.length;w<P;w++){const C=y[w];if(A.setX(C,F[w*o]),o>=2&&A.setY(C,F[w*o+1]),o>=3&&A.setZ(C,F[w*o+2]),o>=4&&A.setW(C,F[w*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=T}return A})}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=ge[f.magFilter]||d.LinearFilter,h.minFilter=ge[f.minFilter]||d.LinearMipmapLinearFilter,h.wrapS=Te[f.wrapS]||d.RepeatWrapping,h.wrapT=Te[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 A=new d.Texture(E);A.needsUpdate=!0,f(A)}),e.load(d.LoaderUtils.resolveURL(u,i.path),T,void 0,m)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),O(u,r),u.userData.mimeType=r.mimeType||at(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||$.OPAQUE;if(h===$.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===$.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),O(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 Ee(o,a,e)})}const r=[];for(let a=0,o=t.length;a<o;a++){const c=t[a],h=ot(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=Ee(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?st(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],A=r[m];let p;const M=c[m];if(A.mode===I.TRIANGLES||A.mode===I.TRIANGLE_STRIP||A.mode===I.TRIANGLE_FAN||A.mode===void 0)p=i.isSkinnedMesh===!0?new d.SkinnedMesh(E,M):new d.Mesh(E,M),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),A.mode===I.TRIANGLE_STRIP?p.geometry=me(p.geometry,d.TriangleStripDrawMode):A.mode===I.TRIANGLE_FAN&&(p.geometry=me(p.geometry,d.TriangleFanDrawMode));else if(A.mode===I.LINES)p=new d.LineSegments(E,M);else if(A.mode===I.LINE_STRIP)p=new d.Line(E,M);else if(A.mode===I.LINE_LOOP)p=new d.LineLoop(E,M);else if(A.mode===I.POINTS)p=new d.Points(E,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(p.geometry.morphAttributes).length>0&&it(p,i),p.name=e.createUniqueName(i.name||"mesh_"+t),O(p,i),A.extensions&&G(n,p,A),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)),O(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,A=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",A)),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],A=u[4],p=[];for(let M=0,_=f.length;M<_;M++){const R=f[M],y=m[M],F=T[M],w=E[M],P=A[M];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const C=s._createAnimationTracks(R,y,F,w,P);if(C)for(let N=0;N<C.length;N++)p.push(C[N])}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,ct)});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),O(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)),O(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=[];B[i.path]===B.weights?t.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(B[i.path]){case B.weights:c=d.NumberKeyframeTrack;break;case B.rotation:c=d.QuaternionKeyframeTrack;break;case B.position:case B.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?nt[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let f=0,m=o.length;f<m;f++){const T=new c(o[f]+"."+B[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=ie(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?tt:Me;return new n(this.times,this.values,this.getValueSize()/3,s)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ut(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=ie(K[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=ie(K[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 Ee(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=re[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.`),O(l,t),ut(l,t,e),Promise.all(n).then(function(){return t.targets!==void 0?rt(l,t.targets,e):l})}const W=[0,0,-10],U=[.5,.5,.5],oe=1,te=new Map,ht=l=>{const t=te.get(l);if(t)return t;const e=new Fe,s=se.fetchAndVerify(l).then(n=>new Promise((i,r)=>{e.parse(n,"",i,r)})).catch(n=>{throw te.delete(l),n});return te.set(l,s),s},ae=({position:l,rotation:t,scale:e,url:s,showDebugMaterial:n=!1,opacity:i=oe})=>{const r=s??new URL("/assets/xr/3d-models/head-occluder-v2.glb",se.libConfig.assetStorageEndpoint).toString(),[a,o]=k.useState(null);k.useEffect(()=>{let h=!1;return ht(r).then(u=>{h||o(u.scene)}).catch(u=>{h||console.error(`${se.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 v.Mesh&&(u.material=new v.MeshStandardMaterial({color:15132390,colorWrite:n,depthWrite:!0,opacity:n?i:1,side:v.DoubleSide,transparent:n}))}),h},[a,n,i]);return k.useEffect(()=>{if(c)return()=>{c.traverse(h=>{h instanceof v.Mesh&&h.material.dispose()})}},[c]),c?(l?c.position.set(l[0],l[1],l[2]):c.position.set(W[0],W[1],W[2]),t&&c.rotation.set(t[0],t[1],t[2]),e?c.scale.set(e[0],e[1],e[2]):c.scale.set(U[0],U[1],U[2]),c.renderOrder=-1,g.jsx("primitive",{object:c})):null},dt=4,ft=({children:l,faceIndex:t=0,numFaces:e=dt,scaleWithFace:s=!0,occluder:n=!0,showFaceMesh:i=!1,faceMeshMaterial:r})=>{const a=k.useMemo(()=>new v.MeshBasicMaterial({color:"#22c55e",side:v.BackSide,transparent:!0,opacity:.35,depthWrite:!1}),[]),o=n===!1?null:n===!0?{}:n;return g.jsxs(pe.FaceTracker,{faceIndex:t,numFaces:e,scaleWithFace:s,children:[o&&g.jsx(ae,{position:o.position??W,rotation:o.rotation,scale:o.scale??U,url:o.url,showDebugMaterial:o.showDebugMaterial,opacity:o.opacity??oe}),l,i&&g.jsx(pe.FaceMesh,{faceIndex:t,numFaces:e,material:r??a})]})},pt=57,mt=15.5,ne=pt/Math.PI/mt,At=-.134,gt=-.024,D=(l,t,e)=>Math.min(e,Math.max(t,l)),Re=(l,t)=>l*t-t/2,_e=(l,t)=>-(l*t-t/2),Tt=({eyeMidX:l,noseX:t,offsetX:e,rawYaw:s,sideMidX:n})=>{const i=D((Math.abs(s)-.18)/.42,0,1),r=n*.75+l*.25,a=l*.7+t*.3;return r*(1-i)+a*i+e},Et=({baseScale:l,pitchRadians:t})=>{const e=t*180/Math.PI,n=1+D((e-6)/22,0,1)*.22;return[l[0]*n,l[1]*n,l[2]*n]},xt=({yawRadians:l})=>{const t=Math.abs(l*180/Math.PI),s=.066*D((t-8)/12,0,1);return Math.sign(l)*s},Mt=({pitchRadians:l})=>{const t=l*180/Math.PI;return-.026*D((-t-6)/18,0,1)},Rt=({baseOffset:l,yawRadians:t})=>{const e=Math.abs(t*180/Math.PI),s=D((e-8)/24,0,1);return l+s*.25},_t=({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=D((s-1.55)/.35,-1,1);return{aspectRatio:s,normalizedAspect:n,scaleY:t+n*.06,offsetY:l+n*.005}},Se=({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}},St=({face:l,height:t,lockDepth:e,lockRotation:s,model:n,offsetX:i,offsetY:r,scaleX:a,scaleY:o,scaleZ:c,width:h})=>{const u=Se({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],A=l.landmarks[1],p=l.landmarks[10],M=l.landmarks[152],_=u.width*h,R=u.height*t,y=f&&m?(f.x+m.x)*.5:l.bounds.centerX,F=f&&m?(f.y+m.y)*.5:l.bounds.centerY-l.bounds.height*.15,w=T&&E?(T.x+E.x)*.5:y,P=(p==null?void 0:p.y)??l.bounds.minY,C=(M==null?void 0:M.y)??l.bounds.maxY,N=(P+C)*.5,z=f&&m?Math.atan2(m.y-f.y,m.x-f.x):0,H=A&&l.bounds.width>0?D((A.x-l.bounds.centerX)/(l.bounds.width*.5),-1,1)*.75:0,j=Tt({eyeMidX:y,noseX:(A==null?void 0:A.x)??y,offsetX:i,rawYaw:H,sideMidX:w}),L=N*.75+F*.25+r,q=n==="v2"?Re(j,h):u.centerX*h-h/2,X=n==="v2"?_e(l.bounds.centerY+r*.75,t):-(u.centerY*t-t/2),Y=p&&A?Math.max(1e-4,A.y-p.y):l.bounds.height*.42,le=A&&M?Math.max(1e-4,M.y-A.y):l.bounds.height*.58,ue=(le-Y)/(le+Y),he=D((ue-At)/.28,-1,1)*.58,de=A&&l.bounds.height>0?D((l.bounds.centerY-A.y)/(l.bounds.height*.5)-gt,-1,1)*.18:0,Z=he*.82+de*.18,fe=s?0:n==="v2"?H*.72:H,ye=s?0:n==="v2"?-Z*.78:-Z,we=s?0:-z,Ce=e?_*ne:n==="v2"?_*(ne+Math.abs(fe)*.18):_*ne;return{centerXPx:q,centerYPx:X,depthPx:Ce*c,heightPx:R,pitch:ye,rawPitch:Z,rawPitchFromBalance:he,rawPitchFromCenter:de,rawYaw:H,rotationZ:we,roll:z,shape:u,skullAnchorX:j,skullAnchorY:L,verticalBalance:ue,widthPx:_,yaw:fe}},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:A})=>ce({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:A}).pose,ce=({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:A})=>{const p=St({face:s,height:n,lockDepth:l,lockRotation:t,model:e,offsetX:r,offsetY:a,scaleX:u,scaleY:f,scaleZ:m,width:A});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=Re(p.skullAnchorX,A),y=_e(p.skullAnchorY,n);return{pose:{boxCenterZ:_.z,centerX:R+_.x,centerY:y+_.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:y+_.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}}}},Lt=({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:A})=>ce({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:A}).debugMetrics,yt=({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:A,scaleX:p,scaleY:M,scaleZ:_,show:R,showCenterDot:y,showFacePlaneReference:F,showGizmo:w,showHeadOccluder:P,skullCenterMode:C,skullVerticalBias:N,url:z,viewportHeight:H,viewportWidth:j})=>{const L=k.useMemo(()=>m||(!e||j<=0||H<=0?null:Le({face:e,width:j,height:H,headDepthOffset:s,lockDepth:n,lockRotation:i,model:r,offsetX:u,offsetY:f,rotationOffsetX:T,rotationOffsetY:E,rotationOffsetZ:A,scaleX:p,scaleY:M,scaleZ:_,skullCenterMode:C,skullVerticalBias:N})),[e,s,n,i,r,u,f,T,E,A,p,M,_,C,N,m,H,j]);if(!R||!L)return null;const q=C?[0,-L.height*N,L.depth*s]:[0,0,0],X=L.height,Y=[U[0]*c[0]*X,U[1]*c[1]*X,U[2]*c[2]*X];return g.jsxs(g.Fragment,{children:[g.jsxs("group",{position:[L.centerX,L.centerY,L.boxCenterZ],rotation:[L.rotationX,L.rotationY,L.rotationZ],children:[g.jsx("group",{scale:[L.width,L.height,L.depth],children:t>0&&g.jsxs("mesh",{children:[g.jsx("boxGeometry",{args:[1,1,1]}),g.jsx("meshBasicMaterial",{color:l,wireframe:!0,transparent:!0,opacity:t})]})}),y&&g.jsxs("mesh",{children:[g.jsx("sphereGeometry",{args:[6,20,20]}),g.jsx("meshBasicMaterial",{color:l})]}),F&&g.jsxs("group",{position:q,children:[g.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[g.jsx("ringGeometry",{args:[6,8,24]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",side:d.DoubleSide})]}),g.jsxs("mesh",{rotation:[0,0,Math.PI/2],children:[g.jsx("planeGeometry",{args:[3,16]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]}),g.jsxs("mesh",{children:[g.jsx("planeGeometry",{args:[16,3]}),g.jsx("meshBasicMaterial",{color:"#f8fafc",transparent:!0,opacity:.9,side:d.DoubleSide})]})]}),P&&g.jsxs(g.Fragment,{children:[h&&g.jsxs("mesh",{position:a,scale:Y,renderOrder:20,children:[g.jsx("sphereGeometry",{args:[1,24,16]}),g.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1})]}),g.jsx(ae,{opacity:o,position:a,scale:Y,showDebugMaterial:!0,url:z})]})]}),w&&g.jsx("group",{position:[L.centerX,L.centerY,L.boxCenterZ],rotation:[L.rotationX,L.rotationY,L.rotationZ],renderOrder:10,children:g.jsxs("group",{children:[g.jsxs("mesh",{children:[g.jsx("sphereGeometry",{args:[6,20,20]}),g.jsx("meshBasicMaterial",{color:"#e2e8f0",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[18,0,0],rotation:[0,0,-Math.PI/2],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[34,0,0],rotation:[0,0,-Math.PI/2],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#ef4444",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,18,0],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,34,0],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#22c55e",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,0,18],rotation:[Math.PI/2,0,0],children:[g.jsx("cylinderGeometry",{args:[1.6,1.6,24,12]}),g.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),g.jsxs("mesh",{position:[0,0,34],rotation:[Math.PI/2,0,0],children:[g.jsx("coneGeometry",{args:[4.2,12,16]}),g.jsx("meshBasicMaterial",{color:"#3b82f6",depthTest:!1,depthWrite:!1})]}),g.jsx(Q.Text,{position:[42,0,0],fontSize:10,color:"#ef4444",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"X"}),g.jsx(Q.Text,{position:[0,42,0],fontSize:10,color:"#22c55e",anchorX:"center",anchorY:"middle",renderOrder:11,"material-depthTest":!1,children:"Y"}),g.jsx(Q.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=b.DEFAULT_FACE_WARP_3D_SETTINGS;exports.FACE_RETOUCH_DEFAULT_CONTROLS=b.FACE_RETOUCH_DEFAULT_CONTROLS;exports.FACE_RETOUCH_SETTINGS_FIELDS=b.FACE_RETOUCH_SETTINGS_FIELDS;exports.FACE_WARP_3D_PRESET=b.FACE_WARP_3D_PRESET;exports.FaceRetouch=b.FaceRetouch;exports.alphaMapOptions=b.alphaMapOptions;exports.blendModeOptions=b.blendModeOptions;exports.materialTypeOptions=b.materialTypeOptions;exports.patchFaceRetouchControls=b.patchFaceRetouchControls;exports.resolveFaceRetouchControls=b.resolveFaceRetouchControls;exports.shaderPresetOptions=b.shaderPresetOptions;exports.sideOptions=b.sideOptions;exports.textureMapOptions=b.textureMapOptions;exports.HEAD_OCCLUDER_DEFAULT_OPACITY=oe;exports.HEAD_OCCLUDER_DEFAULT_POSITION=W;exports.HEAD_OCCLUDER_DEFAULT_SCALE=U;exports.HeadBinding=ft;exports.HeadBindingOccluder=yt;exports.HeadOccluder=ae;exports.computeAdaptiveVerticalFit=_t;exports.computeHeadBindingCubePose=Le;exports.computeHeadBindingDebugMetrics=Lt;exports.computeHeadBindingShape=Se;exports.computeUniversalHeadDepthOffset=Rt;exports.computeUniversalOccluderScale=Et;exports.computeUniversalPitchOffsetY=Mt;exports.computeUniversalYawOffsetX=xt;exports.solveHeadBinding=ce;
@@ -2,11 +2,11 @@ import { jsx as R, jsxs as S, Fragment as Me } from "react/jsx-runtime";
2
2
  import { useState as tt, useEffect as we, useMemo as Ae } from "react";
3
3
  import * as K from "three";
4
4
  import { TrianglesDrawMode as nt, TriangleFanDrawMode as de, TriangleStripDrawMode as He, Loader as st, LoaderUtils as q, FileLoader as Be, MeshPhysicalMaterial as N, Vector2 as ke, Color as v, LinearSRGBColorSpace as D, SRGBColorSpace as Z, SpotLight as rt, PointLight as it, DirectionalLight as ot, Matrix4 as ee, Vector3 as G, Quaternion as Ge, InstancedMesh as at, InstancedBufferAttribute as ct, Object3D as Ue, TextureLoader as lt, ImageBitmapLoader as ut, BufferAttribute as se, InterleavedBuffer as ht, InterleavedBufferAttribute as dt, LinearMipmapLinearFilter as ve, NearestMipmapLinearFilter as ft, LinearMipmapNearestFilter as pt, NearestMipmapNearestFilter as mt, LinearFilter as fe, NearestFilter as je, RepeatWrapping as pe, MirroredRepeatWrapping as gt, ClampToEdgeWrapping as At, PointsMaterial as Tt, Material as re, LineBasicMaterial as Et, MeshStandardMaterial as Ke, DoubleSide as J, MeshBasicMaterial as W, PropertyBinding as xt, BufferGeometry as Rt, SkinnedMesh as _t, Mesh as Mt, LineSegments as wt, Line as St, LineLoop as yt, Points as Lt, Group as ie, PerspectiveCamera as bt, MathUtils as It, OrthographicCamera as Nt, Skeleton as Ct, AnimationClip as Pt, Bone as Ft, InterpolateDiscrete as Ot, InterpolateLinear as Xe, Texture as Se, VectorKeyframeTrack as ye, NumberKeyframeTrack as Le, QuaternionKeyframeTrack as be, ColorManagement as Ie, FrontSide as Dt, Interpolant as Ht, Box3 as Bt, Sphere as kt, Euler as Gt } from "three";
5
- import { b as Ut, c as vt } from "./index-BgQAX8rs.js";
6
- import { l as Ne, f as jt } from "./index-JygePOwo.js";
5
+ import { b as Ut, c as vt } from "./index-D1kj6uc-.js";
6
+ import { l as Ne, f as jt } from "./index-BMeBJ0dV.js";
7
7
  import { Text as oe } from "@react-three/drei";
8
- import { q as Qn, C as Jn, D as $n, a as es, c as ts, d as ns, F as ss, e as rs, f as is, g as os, h as as, i as cs, j as ls, l as us, m as hs, b as ds, n as fs, o as ps, p as ms, r as gs, v as As, t as Ts, k as Es, s as xs, u as Rs } from "./FaceMeshRenderer-6t8OsQhK.js";
9
- import { D as Ms, d as ws, e as Ss, F as ys, f as Ls, b as bs, c as Is, m as Ns, p as Cs, r as Ps, s as Fs, a as Os, t as Ds } from "./FaceRetouch-CDrL0pXg.js";
8
+ import { q as Qn, C as Jn, D as $n, a as es, c as ts, d as ns, F as ss, e as rs, f as is, g as os, h as as, i as cs, j as ls, l as us, m as hs, b as ds, n as fs, o as ps, p as ms, r as gs, v as As, t as Ts, k as Es, s as xs, u as Rs } from "./FaceMeshRenderer-B2i2NW71.js";
9
+ import { D as Ms, d as ws, e as Ss, F as ys, f as Ls, b as bs, c as Is, m as Ns, p as Cs, r as Ps, s as Fs, a as Os, t as Ds } from "./FaceRetouch-Bg-OBU4n.js";
10
10
  function Ce(l, t) {
11
11
  if (t === nt)
12
12
  return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), l;
@@ -1,5 +1,5 @@
1
1
  import { useState as X, useEffect as Y } from "react";
2
- import { F as A } from "./index-BgQAX8rs.js";
2
+ import { F as A } from "./index-D1kj6uc-.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-82aENaRq.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-ZaDEzDtR.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,10 +1,8 @@
1
1
  import { CanvasTexture } from 'three';
2
2
  import { XRModel } from '../constants';
3
+ import { XRSessionError } from './useXRSession/store';
3
4
  export declare const useXRReady: () => boolean;
4
- export declare const useXRError: () => {
5
- error: string;
6
- message: string;
7
- } | undefined;
5
+ export declare const useXRError: () => XRSessionError | undefined;
8
6
  export declare const useXRCameraTexture: () => CanvasTexture | undefined;
9
7
  export declare const useXRRenderSize: () => {
10
8
  width: number;
@@ -1,4 +1,9 @@
1
1
  import { XRModel } from '../constants';
2
+ /**
3
+ * Serialize model options to a value-stable key. Exported for tests: the
4
+ * acquire effect must key on this, not on the options object's identity.
5
+ */
6
+ export declare function serializeModelOptions(options?: Record<string, unknown>): string;
2
7
  export type UseXRModelResult<T extends Record<string, unknown>> = {
3
8
  ready: boolean;
4
9
  node: T | null;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Machine-readable cause for a failed XR session start.
3
+ *
4
+ * `getUserMedia` rejects with a `DOMException` whose `name` carries the cause,
5
+ * but that name is a vendor vocabulary: `TrackStartError` and
6
+ * `PermissionDeniedError` are legacy aliases real engines still throw, and
7
+ * browsers rename these. Consumers read this SDK-owned enum instead, so a
8
+ * future browser rename is a one-line change here rather than a reinterpretation
9
+ * of everything downstream already recorded.
10
+ *
11
+ * Module-local and pure — no DOM access beyond the `instanceof` checks, so it is
12
+ * unit-testable with synthesized exceptions.
13
+ *
14
+ * Depends on: nothing.
15
+ * Depended on by: `facade.ts`, `store.ts`, `../selectors.ts`.
16
+ */
17
+ export type XRErrorReason = "permission-denied" | "camera-in-use" | "no-camera" | "unsupported" | "unknown";
18
+ export declare const mapDomExceptionToReason: (err: unknown) => XRErrorReason;
19
+ export declare const MESSAGE_FOR: Record<XRErrorReason, string>;
@@ -2,14 +2,22 @@ import { CanvasTexture } from 'three';
2
2
  import { XRMediaSource, XRModel } from '../../constants';
3
3
  import { XRMediaSourceKind } from '../../types/compositor';
4
4
  import { BaseXRModel } from '../../models/Base';
5
+ import { XRErrorReason } from './reason';
5
6
  export type SessionLifecycleState = "idle" | "media-bound" | "running" | "stopped";
7
+ /**
8
+ * `message` is human prose and may be reworded at any time; `reason` is the
9
+ * stable machine-readable identity. `error` is a legacy constant kept for
10
+ * backwards compatibility.
11
+ */
12
+ export type XRSessionError = {
13
+ error: string;
14
+ message: string;
15
+ reason: XRErrorReason;
16
+ };
6
17
  export type SessionState = {
7
18
  lifecycle: SessionLifecycleState;
8
19
  ready: boolean;
9
- error: {
10
- error: string;
11
- message: string;
12
- } | undefined;
20
+ error: XRSessionError | undefined;
13
21
  cameraTexture: CanvasTexture | undefined;
14
22
  renderWidth: number;
15
23
  renderHeight: number;