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

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 (58) hide show
  1. package/GROUNDING.md +34 -9
  2. package/dist/{DebuggerUI-Cq28c18s.js → DebuggerUI-xp4bg3gH.js} +1 -1
  3. package/dist/{FaceMeshRenderer-6t8OsQhK.js → FaceMeshRenderer-CALA4k49.js} +2 -2
  4. package/dist/{FaceMeshRenderer-lQLhYIW-.cjs → FaceMeshRenderer-D4PFqsb3.cjs} +1 -1
  5. package/dist/{FaceRetouch-DtNl8-4e.cjs → FaceRetouch-Bq2rtPlV.cjs} +1 -1
  6. package/dist/{FaceRetouch-CDrL0pXg.js → FaceRetouch-DF5UsOsZ.js} +29 -29
  7. package/dist/components/MeshRenderer/index.d.ts +1 -0
  8. package/dist/components/ScreenImage/source.d.ts +3 -0
  9. package/dist/contexts-D5TQcwmv.js +660 -0
  10. package/dist/contexts-Dv1SA0bS.cjs +1 -0
  11. package/dist/debug-ui.cjs +3 -3
  12. package/dist/debug-ui.js +1246 -1205
  13. package/dist/entries/low-level.d.ts +3 -0
  14. package/dist/face-effects.cjs +1 -1
  15. package/dist/face-effects.js +3 -3
  16. package/dist/{getFaceInfo-hUKMLFcr.js → getFaceInfo-Cjcgcc4w.js} +1 -1
  17. package/dist/{getFaceInfo-CyPAKh3h.cjs → getFaceInfo-oQcP40Ha.cjs} +1 -1
  18. package/dist/hooks/useXRModel.d.ts +5 -0
  19. package/dist/{index-DSpzjuqd.cjs → index-Be-S7uSm.cjs} +1 -1
  20. package/dist/index-DdWBnI7A.cjs +17 -0
  21. package/dist/{index-Di70KWuY.js → index-DpVIEBHw.js} +844 -825
  22. package/dist/index-DqhqBi7O.cjs +1 -0
  23. package/dist/{index-UC0Ux38E.js → index-HxT9XEuh.js} +1 -1
  24. package/dist/index-N7C6fNah.js +214 -0
  25. package/dist/index-UU5ODHGU.cjs +1 -0
  26. package/dist/{index-BgQAX8rs.js → index-YMUaJU7U.js} +122 -119
  27. package/dist/{internal-DuMPpcbp.js → internal-D7NxAsc6.js} +2 -2
  28. package/dist/internal.js +1 -1
  29. package/dist/low-level.cjs +1 -1
  30. package/dist/low-level.js +399 -490
  31. package/dist/main.cjs +1 -1
  32. package/dist/main.js +26 -26
  33. package/dist/{renderGroups-C9QJrAXu.js → renderGroups-JEXqSACh.js} +1 -1
  34. package/dist/{renderGroups-Dvm1J4lW.cjs → renderGroups-uXXsFpvw.cjs} +1 -1
  35. package/dist/{renderPasses-CT5iBwtg.cjs → renderPasses-CVWt0t8m.cjs} +2 -2
  36. package/dist/{renderPasses-CjgG_6kQ.js → renderPasses-CdGZeHHL.js} +4 -4
  37. package/dist/scene-object.cjs +1 -1
  38. package/dist/scene-object.js +2 -2
  39. package/dist/{selectors-Dw3C-gSk.js → selectors-twqYByYZ.js} +3 -3
  40. package/dist/texture/animatedTexture.d.ts +2 -0
  41. package/dist/texture/gifReader.d.ts +17 -0
  42. package/dist/texture/gifTextureSource.d.ts +16 -0
  43. package/dist/tracking.cjs +1 -1
  44. package/dist/tracking.js +8 -8
  45. package/dist/{useFaceInfo-CwsHZedC.js → useFaceInfo-DOJCGlDG.js} +2 -2
  46. package/dist/{useFaceInfo-C-WfMlYp.cjs → useFaceInfo-DSUmuzzO.cjs} +1 -1
  47. package/dist/{useFaceResults-VcFdOUFV.cjs → useFaceResults-B1BSGUAW.cjs} +1 -1
  48. package/dist/{useFaceResults-CkFc1egZ.js → useFaceResults-CBmhT5E8.js} +1 -1
  49. package/docs/api/screen-image.mdx +27 -3
  50. package/docs/api/texture-sources.mdx +25 -6
  51. package/docs/texture-api-consumer.md +26 -0
  52. package/package.json +3 -3
  53. package/dist/contexts-BKvTIayr.cjs +0 -1
  54. package/dist/contexts-Bk5zz_VR.js +0 -214
  55. package/dist/index-82aENaRq.cjs +0 -1
  56. package/dist/index-CEc1CAmB.cjs +0 -1
  57. package/dist/index-CTHeBQOs.js +0 -178
  58. package/dist/index-DzEzkBIH.cjs +0 -17
@@ -42,6 +42,9 @@ export { hasFullUnitUVBounds } from '../texture/hasFullUnitUVBounds';
42
42
  export { getPlaybackFrame, getSequenceFrame } from '../texture/animationMath';
43
43
  export type { PlaybackFrameResult } from '../texture/animationMath';
44
44
  export { BasicAnimatedTextureController } from '../texture/animatedTexture';
45
+ export { gifTextureSourceProvider } from '../texture/gifTextureSource';
46
+ export { MAX_GIF_BYTES, MAX_GIF_FRAMES, MAX_GIF_PIXELS } from '../texture/gifTextureSource';
47
+ export type { GifTextureSource } from '../texture/gifTextureSource';
45
48
  export type { AnimatedTextureCapabilities, AnimatedTextureController, AnimatedTextureListener, AnimatedTextureEvent, AnimatedTextureEventListener, AnimatedTextureEventType, AnimatedTexturePlayMode, AnimatedTextureSnapshot, AnimatedTextureState, } from '../texture/animatedTexture';
46
49
  export { TextureSourceLoadError, createTextureSourceResolver, disposeResolvedTextureSource, resolveTextureSource, throwIfAborted, } from '../texture/sourceResolver';
47
50
  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-DqhqBi7O.cjs"),se=require("./index-D4bLzBr6.cjs"),Q=require("@react-three/drei"),S=require("./FaceMeshRenderer-D4PFqsb3.cjs"),b=require("./FaceRetouch-Bq2rtPlV.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";
5
+ import { b as Ut, c as vt } from "./index-YMUaJU7U.js";
6
6
  import { l as Ne, f as jt } from "./index-JygePOwo.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-CALA4k49.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-DF5UsOsZ.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-YMUaJU7U.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-DqhqBi7O.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,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;
@@ -1 +1 @@
1
- "use strict";const w=require("react/jsx-runtime"),_=require("@react-three/fiber"),p=require("react"),H=require("three"),O=require("./renderLayers-lDtL0_43.cjs"),S=require("./index-82aENaRq.cjs");function D(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const h=D(H),q=["face.center","face.forehead","face.noseTip","face.chin","face.leftEyeOuter","face.rightEyeOuter","face.leftCheek","face.rightCheek","face.mouthCenter","face.leftEye","face.rightEye","face.leftEarlobe","face.rightEarlobe","face.custom"],v=["hand.wrist","hand.thumbTip","hand.indexTip","hand.middleTip","hand.ringTip","hand.pinkyTip","hand.indexBase","hand.middleBase","hand.ringBase","hand.pinkyBase"],z=["body.head","body.neck","body.leftShoulder","body.rightShoulder","body.leftElbow","body.rightElbow","body.leftWrist","body.rightWrist","body.leftHip","body.rightHip","body.leftKnee","body.rightKnee","body.leftAnkle","body.rightAnkle"],A=e=>e.startsWith("face.")?"face":e.startsWith("hand.")?"hand":e.startsWith("body.")?"body":null,N={target:"face.center",customAnchorPoint:{x:0,y:0,z:0},offset:{x:0,y:0,z:0},smoothing:0,followFaceRoll:!1},R=(e,r,n)=>r+n*(e-r),E=(e,r)=>1/(1+1/(2*Math.PI*e)/r),C=(e,r,n,a,T,t)=>{if(!e.initialized||n<=0)return e.pos.copy(r),e.prevRaw.copy(r),e.dxHat.set(0,0,0),e.initialized=!0,e;const c=E(t,n),u=["x","y","z"];for(const o of u){const l=(r[o]-e.prevRaw[o])/n,i=R(l,e.dxHat[o],c);e.dxHat[o]=i;const f=a+T*Math.abs(i),d=E(f,n);e.pos[o]=R(r[o],e.pos[o],d),e.prevRaw[o]=r[o]}return e},m=(e,r,n,a)=>C(e,r,n,a*.1,.5,1),F=({target:e,customAnchorPoint:r,offset:n,smoothing:a=0,children:T})=>{const t=S.useTrackerContext(),c=p.useRef(null),u=p.useRef(!1),o=p.useRef(new h.Vector3),l=p.useRef({pos:new h.Vector3,prevRaw:new h.Vector3,dxHat:new h.Vector3,initialized:!1}),i=A(e),f=t!==null&&i!==null&&t.type!==i,d=t===null,b=d||f||i===null;return p.useEffect(()=>{d?console.warn(`[TrackingAnchor] target "${e}" requires a FaceTracker / HandTracker / BodyTracker ancestor; rendering null.`):f?console.warn(`[TrackingAnchor] target "${e}" namespace does not match parent tracker type "${t==null?void 0:t.type}"; rendering null.`):i===null&&console.warn(`[TrackingAnchor] target "${e}" is not a recognized face/hand/body landmark; rendering null.`)},[e,i,d,f,t==null?void 0:t.type]),_.useFrame((G,k)=>{if(b||!c.current||!t)return;const y=t.resolveLandmark(e,r);if(!y){c.current.visible=!1,u.current=!1,l.current.initialized=!1;return}c.current.visible=!0;const s=o.current.copy(y.position),g=c.current.parent;if(g){g.updateMatrixWorld();const x=new h.Matrix4().copy(g.matrixWorld).invert();s.applyMatrix4(x)}n&&(s.x+=n[0],s.y+=n[1],s.z+=n[2]),a>0?(m(l.current,s,u.current?k:0,a),c.current.position.copy(l.current.pos)):c.current.position.copy(s),u.current=!0,y.quaternion&&c.current.quaternion.copy(y.quaternion)}),b?null:w.jsx("group",{ref:c,renderOrder:O.RENDER_LAYERS.TRACKED,children:T})};exports.BODY_TARGETS=z;exports.DEFAULT_TRACKING_ANCHOR=N;exports.FACE_TARGETS=q;exports.HAND_TARGETS=v;exports.TrackingAnchor=F;exports.getTargetNamespace=A;exports.stepTrackingSmoothing=m;
1
+ "use strict";const w=require("react/jsx-runtime"),_=require("@react-three/fiber"),p=require("react"),H=require("three"),O=require("./renderLayers-lDtL0_43.cjs"),S=require("./index-DqhqBi7O.cjs");function D(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const h=D(H),q=["face.center","face.forehead","face.noseTip","face.chin","face.leftEyeOuter","face.rightEyeOuter","face.leftCheek","face.rightCheek","face.mouthCenter","face.leftEye","face.rightEye","face.leftEarlobe","face.rightEarlobe","face.custom"],v=["hand.wrist","hand.thumbTip","hand.indexTip","hand.middleTip","hand.ringTip","hand.pinkyTip","hand.indexBase","hand.middleBase","hand.ringBase","hand.pinkyBase"],z=["body.head","body.neck","body.leftShoulder","body.rightShoulder","body.leftElbow","body.rightElbow","body.leftWrist","body.rightWrist","body.leftHip","body.rightHip","body.leftKnee","body.rightKnee","body.leftAnkle","body.rightAnkle"],A=e=>e.startsWith("face.")?"face":e.startsWith("hand.")?"hand":e.startsWith("body.")?"body":null,N={target:"face.center",customAnchorPoint:{x:0,y:0,z:0},offset:{x:0,y:0,z:0},smoothing:0,followFaceRoll:!1},R=(e,r,n)=>r+n*(e-r),E=(e,r)=>1/(1+1/(2*Math.PI*e)/r),C=(e,r,n,a,T,t)=>{if(!e.initialized||n<=0)return e.pos.copy(r),e.prevRaw.copy(r),e.dxHat.set(0,0,0),e.initialized=!0,e;const c=E(t,n),u=["x","y","z"];for(const o of u){const l=(r[o]-e.prevRaw[o])/n,i=R(l,e.dxHat[o],c);e.dxHat[o]=i;const f=a+T*Math.abs(i),d=E(f,n);e.pos[o]=R(r[o],e.pos[o],d),e.prevRaw[o]=r[o]}return e},m=(e,r,n,a)=>C(e,r,n,a*.1,.5,1),F=({target:e,customAnchorPoint:r,offset:n,smoothing:a=0,children:T})=>{const t=S.useTrackerContext(),c=p.useRef(null),u=p.useRef(!1),o=p.useRef(new h.Vector3),l=p.useRef({pos:new h.Vector3,prevRaw:new h.Vector3,dxHat:new h.Vector3,initialized:!1}),i=A(e),f=t!==null&&i!==null&&t.type!==i,d=t===null,b=d||f||i===null;return p.useEffect(()=>{d?console.warn(`[TrackingAnchor] target "${e}" requires a FaceTracker / HandTracker / BodyTracker ancestor; rendering null.`):f?console.warn(`[TrackingAnchor] target "${e}" namespace does not match parent tracker type "${t==null?void 0:t.type}"; rendering null.`):i===null&&console.warn(`[TrackingAnchor] target "${e}" is not a recognized face/hand/body landmark; rendering null.`)},[e,i,d,f,t==null?void 0:t.type]),_.useFrame((G,k)=>{if(b||!c.current||!t)return;const y=t.resolveLandmark(e,r);if(!y){c.current.visible=!1,u.current=!1,l.current.initialized=!1;return}c.current.visible=!0;const s=o.current.copy(y.position),g=c.current.parent;if(g){g.updateMatrixWorld();const x=new h.Matrix4().copy(g.matrixWorld).invert();s.applyMatrix4(x)}n&&(s.x+=n[0],s.y+=n[1],s.z+=n[2]),a>0?(m(l.current,s,u.current?k:0,a),c.current.position.copy(l.current.pos)):c.current.position.copy(s),u.current=!0,y.quaternion&&c.current.quaternion.copy(y.quaternion)}),b?null:w.jsx("group",{ref:c,renderOrder:O.RENDER_LAYERS.TRACKED,children:T})};exports.BODY_TARGETS=z;exports.DEFAULT_TRACKING_ANCHOR=N;exports.FACE_TARGETS=q;exports.HAND_TARGETS=v;exports.TrackingAnchor=F;exports.getTargetNamespace=A;exports.stepTrackingSmoothing=m;
@@ -0,0 +1,17 @@
1
+ "use strict";const l=require("react/jsx-runtime"),J=require("@react-three/fiber"),v=require("react"),Y=require("three"),z=require("./index-UU5ODHGU.cjs"),re=require("./FaceMeshRenderer-D4PFqsb3.cjs"),x=require("./renderPasses-CVWt0t8m.cjs"),te=require("./contexts-Dv1SA0bS.cjs"),Xe=require("./index-DqhqBi7O.cjs"),Pe=require("./index-Be-S7uSm.cjs"),rt=require("./useFaceInfo-DSUmuzzO.cjs"),Ae=require("./index-D4bLzBr6.cjs"),it=require("@react-three/drei");function st(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const w=st(Y),q={width:720,height:1280},ot=(t=[.5,.5])=>[t[0]*2-1,t[1]*2-1],de=({position:t=[0,0],size:e=[1,1]})=>{const n=e[0]/2,r=e[1]/2;return{left:t[0]-n,right:t[0]+n,top:t[1]+r,bottom:t[1]-r}},at=({position:t=[0,0],size:e=[q.width,q.width],canvasSize:n=q})=>{const r=n.width/2||q.width/2,s=n.height/2||q.height/2;return de({position:[t[0]/r,t[1]/s],size:[e[0]/r,e[1]/s]})},je=({coordinateSpace:t="normalized",canvasSize:e=q,position:n,size:r,fallbackAnchors:s})=>s||(!n&&!r?de({}):t==="canvas"?at({position:n,size:r,canvasSize:e}):de({position:n,size:r})),he=(t,e)=>{if(!Number.isFinite(t)||t<=0)throw new RangeError(`${e} must be positive`);return t},oe=(t,e)=>{const n=he(e.width,"root.width"),r=he(e.height,"root.height");return!Number.isFinite(t.width)||!Number.isFinite(t.height)||t.width<=0||t.height<=0?0:Math.min(t.width/n,t.height/r)},ve=(t,e,n,r)=>{const s=oe(e,n);return s===0?Object.assign(r,{x:0,y:0}):(r.x=(t.x-e.width*.5)/s,r.y=(e.height*.5-t.y)/s,r)},Ce=(t,e,n,r)=>{const s=oe(e,n);return r.x=t.x*s+e.width*.5,r.y=e.height*.5-t.y*s,r},Ge=({parentSize:t,referencePixelsPerUnit:e=x.DEFAULT_REFERENCE_PIXELS_PER_UNIT,root:n=x.DEFAULT_SCREEN_TRANSFORM_ROOT})=>oe(t,n)*(x.DEFAULT_REFERENCE_PIXELS_PER_UNIT/he(e,"referencePixelsPerUnit")),lt=(t,e)=>t*Ge(e),ct=(t,e)=>{const n=Ge(e);return n===0?0:t/n},At=({point:t,rect:e,root:n=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:r={x:0,y:0}})=>ve({x:t.x-e.left,y:t.y-e.top},e,n,r),dt=({point:t,rect:e,root:n=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:r={x:0,y:0}})=>(Ce(t,e,n,r),r.x+=e.left,r.y+=e.top,r),He=({point:t,root:e=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:n={x:0,y:0},viewportSize:r})=>ve({x:t.x*r.width,y:t.y*r.height},r,e,n),ht=({point:t,root:e=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:n={x:0,y:0},viewportSize:r})=>r.width<=0||r.height<=0?Object.assign(n,{x:0,y:0}):(Ce(t,r,e,n),n.x/=r.width,n.y/=r.height,n),gt=({layout:t,mirrored:e=!1,point:n,root:r=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:s={x:0,y:0}})=>{if(t.scale<=0)return Object.assign(s,{x:0,y:0});const i=t.offsetX+n.x*t.scale;return ve({x:e?t.destination.width-i:i,y:t.offsetY+n.y*t.scale},t.destination,r,s)},ut=({layout:t,mirrored:e=!1,point:n,root:r=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:s={x:0,y:0}})=>{if(t.scale<=0)return Object.assign(s,{x:0,y:0});Ce(n,t.destination,r,s);const i=e?t.destination.width-s.x:s.x;return s.x=(i-t.offsetX)/t.scale,s.y=(s.y-t.offsetY)/t.scale,s},ae=new Y.Vector3,Qe=new Y.Vector2,ke=new Y.Raycaster,ft=({camera:t,point:e,root:n=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:r={x:0,y:0,depth:0},viewportSize:s})=>{const i=oe(s,n);return ae.set(e.x,e.y,e.z).project(t),r.x=i===0?0:ae.x*s.width/(2*i),r.y=i===0?0:ae.y*s.height/(2*i),r.depth=ae.z,r},St=({camera:t,point:e,root:n=x.DEFAULT_SCREEN_TRANSFORM_ROOT,target:r=new Y.Ray,viewportSize:s})=>{const i=oe(s,n);return Qe.set(s.width<=0?0:e.x*i*2/s.width,s.height<=0?0:e.y*i*2/s.height),ke.setFromCamera(Qe,t),r.copy(ke.ray)},Je=({children:t,depth:e=0})=>{const{camera:n,size:r}=J.useThree(),s=v.useMemo(()=>{if(!n.isPerspectiveCamera)return{width:10,height:10};const i=n,o=Math.abs(i.position.z-e),c=i.fov*Math.PI/180,a=2*Math.tan(c/2)*o;return{width:a*(r.width/r.height),height:a}},[n,r,e]);return l.jsx(z.ScreenSpaceContext.Provider,{value:s,children:l.jsx("group",{position:[0,0,e],children:t})})},Ne=v.forwardRef(({texture:t,name:e,overlay:n,opacity:r,position:s,rotation:i,scale:o,visible:c,renderOrder:a},d)=>l.jsxs("mesh",{ref:d,name:e,position:s,rotation:i,scale:o,visible:c,renderOrder:a,children:[l.jsx("planeGeometry",{args:[1,1]}),l.jsx("meshBasicMaterial",{map:t,transparent:!0,opacity:r,depthTest:!n,depthWrite:!n})]}));Ne.displayName="TextLabelMesh";const Et={color:"#ffffff",strokeWidth:0,strokeOpacity:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowOpacity:1,fontWeight:"bold",fontStyle:"normal",fontFamily:"Arial, sans-serif",fontSize:48,textAlign:"center",verticalAlign:"center",minFontSize:12,letterSpacing:0,lineSpacing:.3,bgColor:"rgba(20,40,110,0.88)",bgFillMode:"solid",bgOpacity:1,bgFit:"full",bgTextureFit:"cover",bgTextureFlipX:!1,bgTextureFlipY:!1,borderWidth:0,borderRadius:24,padding:32,aspect:2.5,resolution:512,opacity:1,underline:!1,strikethrough:!1,bendPreset:"arc",bendStrength:0},ge=t=>{v.useEffect(()=>()=>{t==null||t.dispose()},[t])};function vt(t,e,n){return n==="left"?e:n==="right"?t-e:t/2}function Ct(t,e,n,r,s){return s==="top"?e+n/2:s==="bottom"?t-e-r+n/2:t/2-(r-n)/2}function mt(t,e,n,r){return r==="full"||n==="left"?0:n==="right"?t-e:(t-e)/2}function ze(t,e,n,r){return`${t} ${e} ${n}px ${r}`}function se(t,e){const n=Math.max(0,Math.min(e,1));return t*n*.08}function Ue(t,e){const n=Math.max(0,Math.min(e,1));return t*(1.2+n*.6)}function Ke(t,e){"letterSpacing"in t&&(t.letterSpacing=`${e}px`)}function Ve(t){"letterSpacing"in t&&(t.letterSpacing="0px")}function ne(t,e,n){Ke(t,n);const r=t.measureText(e).width;return Ve(t),r}function ue(t,e,n,r){return Math.max(1,Math.floor((t-e*2)/Ue(n,r)))}function bt(t,e,n,r,s){return e.length<=r&&e.every(i=>ne(t,i,s)<=n)}function fe(t,e,n,r,s,i,o,c){t.font=ze(r,s,i,o);const a=e.split(" "),d=[];let A="";for(const g of a){const u=A?`${A} ${g}`:g;ne(t,u,c)>n&&A?(d.push(A),A=g):A=u}return A&&d.push(A),d}function Fe(t,e,n,r,s,i,o,c){const d=e.split(/\r?\n/).flatMap(A=>A.trim().length===0?[""]:fe(t,A,n,r,s,i,o,c));return d.length>0?d:[e]}function qe(t,e,n,r,s){const i=r?"...":"";let o=e.trimEnd();for(;o.length>0&&ne(t,`${o}${i}`,s)>n;)o=o.slice(0,-1).trimEnd();return`${o}${i}`}function Se(t,e,n,r,s){return e.map((i,o)=>{if(ne(t,i,s)<=n)return i;const c=o===e.length-1;return qe(t,i,n,r==="ellipsis"&&c,s)})}function Le(t,e,n,r,s,i){if(e.length<=n)return Se(t,e,r,s?"ellipsis":"clip",i);const o=e.slice(0,n),c=o[n-1];return o[n-1]=qe(t,c,r,s,i),Se(t,o,r,s?"ellipsis":"clip",i)}function It(t){const{ctx:e,text:n,explicitLines:r,maxWidth:s,maxHeight:i,padding:o,fontStyle:c,fontWeight:a,fontSize:d,fontFamily:A,letterSpacing:g,lineSpacing:u,overflow:S,resizeToFit:C,minFontSize:E}=t;let f=d,m=se(f,g),I=r??Fe(e,n,s,c,a,f,A,m),b=ue(i,o,f,u);const p=C===!0||S==="shrink";for(;p&&!bt(e,I,s,b,m)&&f>E&&(f=Math.max(E,f-4),m=se(f,g),I=r??Fe(e,n,s,c,a,f,A,m),b=ue(i,o,f,u),f!==E););return S==="ellipsis"?I=Le(e,I,b,s,!0,m):S==="clamp"||S==="shrink"?I=Le(e,I,b,s,!1,m):S!=="clip"&&(I=Se(e,I,s,void 0,m)),{fontSize:f,lines:I}}function Tt(t){const{ctx:e,text:n,maxWidth:r,maxHeight:s,padding:i,fontStyle:o,fontWeight:c,fontSize:a,fontFamily:d,letterSpacing:A,lineSpacing:g}=t;let u=a,S=fe(e,n,r,o,c,u,d,se(u,A));const C=ue(s,i,u,g);return S.length>C&&(u=Math.max(12,Math.round(u*.75)),S=fe(e,n,r,o,c,u,d,se(u,A))),{fontSize:u,lines:S}}function Ee(t,e){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):(()=>{const n=document.createElement("canvas");return n.width=t,n.height=e,n})()}function xt(t,e){const n=e.width-e.padding*2,s=Array.isArray(e.lines)||e.text.includes(`
2
+ `)||e.overflow!==void 0||e.resizeToFit!==void 0?It({ctx:t,text:e.text,explicitLines:e.lines,maxWidth:n,maxHeight:e.height,padding:e.padding,fontStyle:e.fontStyle,fontWeight:e.fontWeight,fontSize:e.fontSize,fontFamily:e.fontFamily,overflow:e.overflow,resizeToFit:e.resizeToFit,minFontSize:e.minFontSize,letterSpacing:e.letterSpacing,lineSpacing:e.lineSpacing}):Tt({ctx:t,text:e.text,maxWidth:n,maxHeight:e.height,padding:e.padding,fontStyle:e.fontStyle,fontWeight:e.fontWeight,fontSize:e.fontSize,fontFamily:e.fontFamily,letterSpacing:e.letterSpacing,lineSpacing:e.lineSpacing}),i=s.fontSize,o=s.lines;t.font=ze(e.fontStyle,e.fontWeight,i,e.fontFamily);const c=se(i,e.letterSpacing),a=Ue(i,e.lineSpacing),d=Math.max(i,i+(o.length-1)*a),A=Ct(e.height,e.padding,i,d,e.verticalAlign),g=o.map(u=>ne(t,u,c));return{fontSize:i,resolvedLines:o,letterSpacingPx:c,lineHeight:a,startY:A,textBlockWidth:Math.min(e.width,Math.max(0,Math.max(...g,0))+e.padding*2),textBlockHeight:Math.min(e.height,d+e.padding*2),textX:vt(e.width,e.padding,e.textAlign)}}function yt(t,e,n,r,s,i){t.beginPath(),t.moveTo(e+i,n),t.lineTo(e+r-i,n),t.quadraticCurveTo(e+r,n,e+r,n+i),t.lineTo(e+r,n+s-i),t.quadraticCurveTo(e+r,n+s,e+r-i,n+s),t.lineTo(e+i,n+s),t.quadraticCurveTo(e,n+s,e,n+s-i),t.lineTo(e,n+i),t.quadraticCurveTo(e,n,e+i,n),t.closePath()}function Re(t,e,n){return typeof t!="number"||Number.isNaN(t)||t<=0?e:Math.min(t,n)}function Mt(t,e){const n=mt(e.canvasWidth,e.panelWidth,e.textAlign,e.bgFit),r=(e.canvasHeight-e.panelHeight)/2,s=Math.min(e.borderRadius,Math.min(e.panelWidth,e.panelHeight)/2);yt(t,n,r,e.panelWidth,e.panelHeight,s),Bt(t,{panelX:n,panelY:r,panelWidth:e.panelWidth,panelHeight:e.panelHeight,bgColor:e.bgColor,bgFillMode:e.bgFillMode,bgOpacity:e.bgOpacity,bgGradientStops:e.bgGradientStops,bgTextureImage:e.bgTextureImage,bgTextureFit:e.bgTextureFit,bgTextureFlipX:e.bgTextureFlipX,bgTextureFlipY:e.bgTextureFlipY}),e.borderColor&&e.borderWidth>0&&(t.lineWidth=e.borderWidth,t.strokeStyle=e.borderColor,t.stroke())}function Bt(t,e){if(t.save(),t.globalAlpha=Math.max(0,Math.min(e.bgOpacity,1)),e.bgFillMode==="gradient"&&e.bgGradientStops&&e.bgGradientStops.length>1){const n=t.createLinearGradient(e.panelX,e.panelY,e.panelX+e.panelWidth,e.panelY+e.panelHeight);[...e.bgGradientStops].sort((r,s)=>r.position-s.position).forEach(r=>n.addColorStop(Math.max(0,Math.min(r.position,1)),r.color)),t.fillStyle=n,t.fill(),t.restore();return}if(e.bgTextureImage){t.clip(),pt(t,{image:e.bgTextureImage,x:e.panelX,y:e.panelY,width:e.panelWidth,height:e.panelHeight,fit:e.bgTextureFit,flipX:e.bgTextureFlipX,flipY:e.bgTextureFlipY}),t.restore();return}t.fillStyle=e.bgColor,t.fill(),t.restore()}function pt(t,e){const{image:n,x:r,y:s,width:i,height:o,fit:c,flipX:a,flipY:d}=e,A="naturalWidth"in n?n.naturalWidth:"videoWidth"in n?n.videoWidth:n.width,g="naturalHeight"in n?n.naturalHeight:"videoHeight"in n?n.videoHeight:n.height;let u=i,S=o,C=r,E=s;if(c!=="stretch"&&A>0&&g>0){const f=c==="cover"?Math.max(i/A,o/g):Math.min(i/A,o/g);u=A*f,S=g*f,C=r+(i-u)/2,E=s+(o-S)/2}t.save(),(a||d)&&(t.translate(a?r+i:0,d?s+o:0),t.scale(a?-1:1,d?-1:1),C=a?-(C-r)-u+r:C,E=d?-(E-s)-S+s:E),t.drawImage(n,C,E,u,S),t.restore()}function wt(t,e,n,r,s,i){const o=s/72,c=Math.abs(o),a=1-Math.min(1,Math.abs(e)),d=Math.min(1,Math.abs(e)),A=r<=1?.5:n/(r-1),g=Math.sin(A*Math.PI*2-Math.PI/2),u=Math.sin(A*Math.PI*2.7-Math.PI/2)*(.65+A*.35),S=s*e*e,C=2*s*e/i,E={xOffset:0,yOffset:0,rotation:0,scaleX:1,scaleY:1};switch(t){case"arc":return{...E,yOffset:S,rotation:Math.atan(C)};case"arc-lower":return{...E,yOffset:S*.55,scaleY:Math.max(.2,1+o*e*e*.45)};case"arc-upper":return{...E,yOffset:-S*.55,scaleY:Math.max(.2,1-o*e*e*.45)};case"arch":return{...E,yOffset:S};case"bulge":return{...E,scaleY:Math.max(.2,1+o*a*.75)};case"shell-lower":return{...E,yOffset:s*.45*A*a,scaleY:Math.max(.2,1+o*A*a)};case"shell-upper":return{...E,yOffset:-s*.45*(1-A)*a,scaleY:Math.max(.2,1+o*(1-A)*a)};case"flag":return{...E,yOffset:s*.65*u,rotation:Math.atan(s/Math.max(i,1)*Math.cos(A*Math.PI*2.7)*1.6)};case"wave":return{...E,yOffset:s*.6*g,rotation:Math.atan(s/Math.max(i,1)*Math.cos(A*Math.PI*2)*1.4)};case"fish":return{...E,scaleX:Math.max(.25,1-c*d*.55),scaleY:Math.max(.2,1+o*a)};case"rise":return{...E,yOffset:s*e};case"fisheye":return{...E,yOffset:s*.18*e*a,scaleX:Math.max(.25,1+o*a*.7),scaleY:Math.max(.2,1+o*a*.7)};case"inflate":return{...E,scaleX:Math.max(.25,1+o*a*.6),scaleY:Math.max(.2,1+o*a*.6)};case"squeeze":return{...E,scaleY:Math.max(.2,1-o*a*.8)};case"twist":return{...E,yOffset:s*e,rotation:o*e*.45,scaleY:Math.max(.2,1+o*e*.25)};default:return E}}function $(t,e,n,r,s,i,o="arc",c=0){if(c!==0){Qt(t,e,n,r,s,i,o,c);return}Ke(t,s),i==="fill"?t.fillText(e,n,r):t.strokeText(e,n,r),Ve(t)}function Qt(t,e,n,r,s,i,o,c){const a=Array.from(e);if(a.length===0)return;const d=a.map(m=>t.measureText(m).width),A=d.reduce((m,I)=>m+I,0)+s*Math.max(0,a.length-1),g=t.textAlign,u=g==="right"?n-A:g==="center"?n-A/2:n,C=Math.max(-100,Math.min(c,100))/100*72,E=Math.max(A/2,1);let f=u;for(let m=0;m<a.length;m++){const I=a[m],b=d[m],p=f+b/2,Q=(p-u-A/2)/E,M=wt(o,Q,m,a.length,C,E);t.save(),t.translate(p+M.xOffset,r+M.yOffset),t.rotate(M.rotation),t.scale(M.scaleX,M.scaleY),t.textAlign="center",i==="fill"?t.fillText(I,0,0):t.strokeText(I,0,0),t.restore(),f+=b+s}}function De(t,e,n,r,s,i,o,c,a){const d=ne(t,e,c),A=s==="center"?n-d/2:s==="right"?n-d:n,g=a==="underline"?o*.42:-o*.08,u=r+g;t.save(),t.strokeStyle=i,t.lineWidth=Math.max(2,o*.06),t.lineCap="round",t.beginPath(),t.moveTo(A,u),t.lineTo(A+d,u),t.stroke(),t.restore()}function kt(t,e){for(let n=0;n<e.lines.length;n++){const r=e.lines[n],s=e.startY+n*e.lineHeight;for(const i of e.shadowLayers)t.save(),t.shadowColor=i.color,t.shadowBlur=i.blur,t.shadowOffsetX=i.offsetX??0,t.shadowOffsetY=i.offsetY??0,t.globalAlpha=i.opacity??1,t.fillStyle=e.color,$(t,r,e.textX,s,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength),t.restore();for(const i of e.strokeLayers)t.save(),t.lineJoin="round",t.miterLimit=2,t.lineWidth=i.width,t.strokeStyle=i.color,t.globalAlpha=i.opacity??1,$(t,r,e.textX,s,e.letterSpacingPx,"stroke",e.bendPreset,e.bendStrength),t.restore();t.save(),t.fillStyle=e.color,t.globalAlpha=1,$(t,r,e.textX,s,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength),t.restore(),e.underline&&De(t,r,e.textX,s,e.textAlign,e.color,e.fontSize,e.letterSpacingPx,"underline"),e.strikethrough&&De(t,r,e.textX,s,e.textAlign,e.color,e.fontSize,e.letterSpacingPx,"strikethrough")}}function Ft(t,e){const n=Math.max(0,Math.min(e.intensity,1));if(n<=0)return;const r=Math.max(0,Math.min(e.range,1)),s=r*72,i=Math.max(-.5,Math.min(e.horizontalAngle,.5))*80,o=Math.max(-.5,Math.min(e.verticalAngle,.5))*80;for(let c=0;c<e.lines.length;c++){const a=e.startY+c*e.lineHeight;t.save(),t.globalAlpha=n,t.shadowColor=e.color,t.shadowBlur=s,t.shadowOffsetX=i,t.shadowOffsetY=o,e.style==="contoured"?(t.lineJoin="round",t.miterLimit=2,t.lineWidth=Math.max(2,r*42),t.strokeStyle=e.color,$(t,e.lines[c],e.textX,a,e.letterSpacingPx,"stroke",e.bendPreset,e.bendStrength)):(t.fillStyle=e.color,$(t,e.lines[c],e.textX,a,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength)),t.restore()}}function Lt(t,e){const n=Ee(e.width,e.height),r=n.getContext("2d");r.clearRect(0,0,e.width,e.height),r.font=e.font,r.fillStyle="#ffffff",r.textAlign=e.textAlign,r.textBaseline="middle";for(let o=0;o<e.lines.length;o++)$(r,e.lines[o],e.textX,e.startY+o*e.lineHeight,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength);const s=Ee(e.width,e.height),i=s.getContext("2d");i.clearRect(0,0,e.width,e.height),i.save(),i.globalAlpha=e.opacity,i.filter=e.blur>0?`blur(${e.blur}px)`:"none",i.drawImage(n,e.offsetX,e.offsetY),i.restore(),i.globalCompositeOperation="destination-in",i.drawImage(n,0,0),i.globalCompositeOperation="source-in",i.globalAlpha=e.opacity,i.fillStyle=e.color,i.fillRect(0,0,e.width,e.height),t.drawImage(s,0,0)}function Rt(t){const{width:e,height:n,color:r,strokeLayers:s,strokeColor:i,strokeWidth:o,strokeOpacity:c,shadowLayers:a,innerShadow:d,glow:A,shadowColor:g,shadowBlur:u,shadowOffsetX:S,shadowOffsetY:C,shadowOpacity:E,textAlign:f,bgFillMode:m,bgOpacity:I,bgFit:b,bgAutoSize:p,bgWidth:Q,bgHeight:M,bgGradientStops:T,bgTextureImage:h,bgTextureFit:B,bgTextureFlipX:j,bgTextureFlipY:O,underline:Z,strikethrough:U,bendPreset:G,bendStrength:D}=t;let{fontSize:K,bgColor:N}=t;const V=[...s??[],...i&&o>0?[{color:i,width:o,opacity:c}]:[]].filter(L=>L.width>0),W=[...a??[],...g&&(u>0||S!==0||C!==0)?[{color:g,blur:u,offsetX:S,offsetY:C,opacity:E}]:[]].filter(L=>L.blur>0||(L.offsetX??0)!==0||(L.offsetY??0)!==0);let R;const H=Ee(e,n),F=H.getContext("2d");F.clearRect(0,0,e,n),F.fillStyle=r,F.textAlign=f,F.textBaseline="middle";const y=xt(F,t);if(K=y.fontSize,N!=="transparent"){const L=p===!0,_=Re(L?void 0:Q,b==="text"||L?y.textBlockWidth:e,e),X=Re(L?void 0:M,b==="text"||L?y.textBlockHeight:n,n);Mt(F,{canvasWidth:e,canvasHeight:n,textAlign:f,bgFit:b,panelWidth:_,panelHeight:X,bgColor:N,bgFillMode:m,bgOpacity:I,bgGradientStops:T,bgTextureImage:h,bgTextureFit:B,bgTextureFlipX:j,bgTextureFlipY:O,borderColor:t.borderColor,borderWidth:t.borderWidth,borderRadius:t.borderRadius})}return A&&Ft(F,{lines:y.resolvedLines,textX:y.textX,startY:y.startY,lineHeight:y.lineHeight,letterSpacingPx:y.letterSpacingPx,bendPreset:G,bendStrength:D,color:A.color,style:A.style,intensity:A.intensity??.5,range:A.range??.5,horizontalAngle:A.horizontalAngle??0,verticalAngle:A.verticalAngle??0}),kt(F,{lines:y.resolvedLines,textX:y.textX,startY:y.startY,lineHeight:y.lineHeight,textAlign:f,color:r,fontSize:K,letterSpacingPx:y.letterSpacingPx,bendPreset:G,bendStrength:D,shadowLayers:W,strokeLayers:V,underline:Z,strikethrough:U}),d&&Lt(F,{width:e,height:n,font:F.font,lines:y.resolvedLines,textX:y.textX,startY:y.startY,lineHeight:y.lineHeight,letterSpacingPx:y.letterSpacingPx,bendPreset:G,bendStrength:D,textAlign:f,color:d.color,opacity:d.opacity??1,blur:d.blur,offsetX:d.offsetX??0,offsetY:d.offsetY??0}),R=new w.CanvasTexture(H),R.needsUpdate=!0,R}function Dt(t,e){const{lines:n,color:r,strokeLayers:s,outlineEnabled:i,strokeColor:o,strokeWidth:c,strokeOpacity:a,shadowLayers:d,shadowEnabled:A,innerShadow:g,glow:u,shadowColor:S,shadowBlur:C,shadowOffsetX:E,shadowOffsetY:f,shadowOpacity:m,fontWeight:I,fontStyle:b,fontFamily:p,fontSize:Q,textAlign:M,verticalAlign:T,overflow:h,resizeToFit:B,minFontSize:j,letterSpacing:O,lineSpacing:Z,bgFillMode:U,bgOpacity:G,bgFit:D,bgAutoSize:K,bgWidth:N,bgHeight:V,bgGradientStops:W,bgTextureFit:R,bgTextureFlipX:H,bgTextureFlipY:F,borderColor:y,borderWidth:L,borderRadius:_,padding:X,aspect:me,resolution:ce,underline:be,strikethrough:Ie,bendPreset:Te,bendStrength:xe}=t,ye=v.useMemo(()=>i===!1?[]:s,[i,s]),Me=v.useMemo(()=>A===!1?[]:d,[A,d]),Be=void 0,pe=v.useMemo(()=>({text:e.text,lines:n,color:r,strokeLayers:ye,strokeColor:i===!1?void 0:o,strokeWidth:i===!1?0:c,strokeOpacity:a,shadowLayers:Me,innerShadow:g,glow:u,shadowColor:A===!1?void 0:S,shadowBlur:A===!1?0:C,shadowOffsetX:A===!1?0:E,shadowOffsetY:A===!1?0:f,shadowOpacity:m,fontWeight:I,fontStyle:b,fontFamily:p,fontSize:Q,textAlign:M,verticalAlign:T,overflow:h,resizeToFit:B,minFontSize:j,letterSpacing:O,lineSpacing:Z,bgColor:e.bgColor,bgFillMode:U,bgOpacity:G,bgFit:D,bgAutoSize:K,bgWidth:N,bgHeight:V,bgGradientStops:W,bgTextureImage:Be,bgTextureFit:R,bgTextureFlipX:H,bgTextureFlipY:F,borderColor:y,borderWidth:L,borderRadius:_,padding:X,height:ce,width:Math.round(ce*Math.max(me,.1)),underline:be,strikethrough:Ie,bendPreset:Te,bendStrength:xe}),[e.text,e.bgColor,n,r,ye,i,o,c,a,Me,g,u,A,S,C,E,f,m,I,b,p,Q,M,T,h,B,j,O,Z,U,G,D,K,N,V,W,Be,R,H,F,y,L,_,X,me,ce,be,Ie,Te,xe]),we=v.useMemo(()=>Rt(pe),[pe]);return ge(we),we}function Ze(t){const e={...Et,...t},{text:n,bgColor:r,opacity:s,name:i,overlay:o=!0,position:c,rotation:a,scale:d,visible:A,renderOrder:g}=e,[u,S]=v.useState(null),[C,E]=v.useState(null),f=v.useRef(n);f.current!==n&&(f.current=n,u!==null&&S(null));const m=v.useRef(r);m.current!==r&&(m.current=r,C!==null&&E(null));const I=v.useRef(null),Q=Dt(e,{text:u??n,bgColor:C??r});return v.useEffect(()=>{const M=I.current;if(M)return M.userData.setText=T=>S(T),M.userData.setBgColor=T=>E(T),()=>{delete M.userData.setText,delete M.userData.setBgColor}},[]),l.jsx(Ne,{ref:I,name:i,texture:Q,overlay:o,opacity:s,position:c,rotation:a,scale:d,visible:A,renderOrder:g})}function le(t,e){return!Number.isFinite(t)||!Number.isFinite(e)||t<=0||e<=0?[1,1,1]:Math.abs(t-e)<1e-6?[1,1,1]:t>e?[e/t,1,1]:[1,t/e,1]}const Yt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyAAAAMgCAMAAADsrvZaAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAUpQTFRFqampbGxsb29vcHBwSUlJcXFxkJCQenp6dHR0cnJyo6Ojg4ODfHx8nZ2dn5+fqqqqtLS0q6urc3NzrKysra2trq6udXV1r6+veHh4eXl5d3d3i4uLqKioe3t7fX19p6enpaWldnZ2sLCwpqamfn5+hISEpKSkkZGRgYGBnp6ef39/hoaGoKCgjo6OsbGxoaGhl5eXgICAgoKCnJycjIyMoqKilZWVmpqaiIiImZmZh4eHlJSUlpaWm5ubioqKiYmJhYWFj4+PkpKSs7OzmJiYsrKyk5OTjY2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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApsT/B5IXXl4PVzuXAAAAAElFTkSuQmCC",Wt=(t,e)=>t||(e==="cover"?"fill":e==="stretch"?"stretch":"fit"),Ye=(t,e)=>{const[n,r]=le(t,e);return n===1&&r===1?[1,1,1]:n<1?[1,1/n,1]:[1/r,1,1]},Ot=(t,e,n,r,s,i,o)=>{let c=[1,1,1],a=[1,1,1],d=[1,1],A=[0,0];switch(t){case"fit":c=le(e,n),a=c;break;case"fitWidth":c=[1,e>0&&n>0?e/n:1,1],a=c;break;case"fitHeight":c=[e>0&&n>0?n/e:1,1,1],a=c;break;case"center":c=i&&o&&i.width>0&&i.height>0&&o.width>0&&o.height>0?[o.width/i.width,o.height/i.height,1]:le(e,n),a=c;break;case"fill":c=Ye(e,n),a=c;break;case"fillAndCut":if(a=Ye(e,n),n>e){const g=e/n;d=[g,1],A=[(1-g)/2,0]}else if(n<e){const g=n/e;d=[1,g],A=[0,(1-g)/2]}break}return{meshScale:[c[0]*(r?-1:1),c[1]*(s?-1:1),1],guideScale:a,repeat:d,offset:A}},Xt=(t,e)=>t??(e?{kind:"image",src:e}:{kind:"default"}),ee=t=>{const e=t.image;return{width:(e==null?void 0:e.videoWidth)??(e==null?void 0:e.width)??1,height:(e==null?void 0:e.videoHeight)??(e==null?void 0:e.height)??1}},Pt=t=>{const{width:e,height:n}=ee(t);return e>0&&n>0?e/n:1},jt=new Set(["overlay","softLight","hardLight","difference","exclusion"]),Gt={overlay:0,softLight:1,hardLight:2,difference:3,exclusion:4},Ht=t=>{switch(t){case"add":return{blending:w.AdditiveBlending};case"subtract":return{blending:w.SubtractiveBlending};case"multiply":return{blending:w.MultiplyBlending};case"screen":return{blending:w.CustomBlending,blendSrc:w.OneFactor,blendDst:w.OneMinusSrcColorFactor,blendEquation:w.AddEquation};case"lighten":return{blending:w.CustomBlending,blendSrc:w.OneFactor,blendDst:w.OneFactor,blendEquation:w.MaxEquation};case"darken":return{blending:w.CustomBlending,blendSrc:w.OneFactor,blendDst:w.OneFactor,blendEquation:w.MinEquation};default:return{blending:w.NormalBlending}}},Jt=`
3
+ varying vec2 vUv;
4
+ void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}`,Nt=`
5
+ uniform sampler2D imageMap;uniform sampler2D backdropMap;uniform vec2 resolution;
6
+ uniform vec3 tint;uniform float opacity;uniform float alphaTest;uniform int blendMode;varying vec2 vUv;
7
+ float overlayChannel(float b,float s){return b<.5?2.*b*s:1.-2.*(1.-b)*(1.-s);}
8
+ float hardLightChannel(float b,float s){return s<.5?2.*b*s:1.-2.*(1.-b)*(1.-s);}
9
+ float softLightChannel(float b,float s){return s<.5?b-(1.-2.*s)*b*(1.-b):b+(2.*s-1.)*(sqrt(max(b,0.))-b);}
10
+ vec3 applyAdvancedBlend(vec3 b,vec3 s){
11
+ if(blendMode==0)return vec3(overlayChannel(b.r,s.r),overlayChannel(b.g,s.g),overlayChannel(b.b,s.b));
12
+ if(blendMode==1)return vec3(softLightChannel(b.r,s.r),softLightChannel(b.g,s.g),softLightChannel(b.b,s.b));
13
+ if(blendMode==2)return vec3(hardLightChannel(b.r,s.r),hardLightChannel(b.g,s.g),hardLightChannel(b.b,s.b));
14
+ if(blendMode==3)return abs(b-s);return b+s-2.*b*s;}
15
+ void main(){vec4 image=texture2D(imageMap,vUv)*vec4(tint,opacity);if(image.a<=alphaTest)discard;
16
+ vec2 uv=gl_FragCoord.xy/max(resolution,vec2(1.));vec3 base=texture2D(backdropMap,uv).rgb;
17
+ vec3 mixed=applyAdvancedBlend(base,image.rgb);gl_FragColor=vec4(mix(base,mixed,image.a),1.);}`,zt=()=>{const t=document.createElement("canvas");t.width=256,t.height=256;const e=t.getContext("2d");if(!e)return new w.CanvasTexture(t);const n=e.createRadialGradient(96,80,10,128,128,128);n.addColorStop(0,"#ffffff"),n.addColorStop(.18,"#f8fafc"),n.addColorStop(.44,"#cbd5e1"),n.addColorStop(.72,"#475569"),n.addColorStop(1,"#0f172a"),e.fillStyle=n,e.fillRect(0,0,t.width,t.height);const r=new w.CanvasTexture(t);return r.needsUpdate=!0,r};function Ut({materialTexture:t,sourceTexture:e,onSourceSizeChange:n}){const r=v.useRef(ee(e));return J.useFrame(()=>{t.needsUpdate=!0;const s=ee(e);(s.width!==r.current.width||s.height!==r.current.height)&&(r.current=s,n(s))}),null}const Kt=999,Vt=Math.PI/180,qt=te.createTextureSourceResolver([te.gifTextureSourceProvider]);function Zt(t){const[e,n]=v.useState(null);return v.useEffect(()=>{if(n(null),!t||typeof document>"u")return;const r=new AbortController;let s;return qt({kind:"gif",src:t},r.signal).then(i=>{s=i,n(i)}).catch(i=>{i instanceof DOMException&&i.name==="AbortError"||console.warn("[xr-sdk] Failed to load GIF ScreenImage source",i)}),()=>{r.abort(),te.disposeResolvedTextureSource(s)}},[t]),e}function We({name:t,source:e,src:n,fit:r,stretchMode:s,materialType:i="unlit",blendMode:o="normal",backdropTexture:c=null,rotation:a=0,opacity:d=1,color:A="#ffffff",flipX:g=!1,flipY:u=!1,renderOrder:S=Kt,transparent:C=!0,alphaTest:E=0,overlay:f=!0,visible:m,layoutSize:I}){const{size:b}=J.useThree(),p=te.useXRViewportRenderOutputs(),Q=Xt(e,n),M=Q.kind==="image"?Q.src:Yt,T=it.useTexture(M),h=Zt(Q.kind==="gif"?Q.src:void 0),B=Q.kind==="texture"?Q.texture:Q.kind==="gif"?(h==null?void 0:h.texture)??T:T,j=z.useScreenRectAspect(),O=Wt(s,r),[Z,U]=v.useState(()=>ee(B));v.useEffect(()=>{U(ee(B))},[B]);const G=B instanceof w.VideoTexture||typeof HTMLCanvasElement<"u"&&B.image instanceof HTMLCanvasElement,D=G?Z:ee(B),K=v.useCallback(X=>U(X),[]),N=D.width>0&&D.height>0?D.width/D.height:Pt(B),V=v.useMemo(()=>zt(),[]),W=v.useMemo(()=>Ot(O,j,N,g,u,I,D),[O,j,N,g,u,I,D]),R=v.useMemo(()=>{const X=B.clone();return X.needsUpdate=!0,X.repeat.set(W.repeat[0],W.repeat[1]),X.offset.set(W.offset[0],W.offset[1]),X},[B,W.repeat,W.offset]);ge(R),ge(V);const H=v.useMemo(()=>Ht(o),[o]),F=jt.has(o)?o:null,y=c??(p==null?void 0:p.finalColorTexture)??(p==null?void 0:p.sceneColorTexture)??null,L=F!==null&&y!==null,_=v.useMemo(()=>({imageMap:{value:R},backdropMap:{value:y},resolution:{value:new w.Vector2(b.width,b.height)},tint:{value:new w.Color(A)},opacity:{value:d},alphaTest:{value:E},blendMode:{value:F===null?0:Gt[F]}}),[F,E,y,b.height,b.width,A,R,d]);return l.jsxs("group",{visible:m,children:[G?l.jsx(Ut,{materialTexture:R,sourceTexture:B,onSourceSizeChange:K}):null,l.jsxs("mesh",{name:t,scale:W.meshScale,rotation:[0,0,a*Vt],renderOrder:S,children:[l.jsx("planeGeometry",{args:[1,1]}),L?l.jsx("shaderMaterial",{uniforms:_,vertexShader:Jt,fragmentShader:Nt,transparent:!1,depthTest:!f,depthWrite:!f,toneMapped:!1}):i==="standardPBR"?l.jsx("meshStandardMaterial",{map:R,transparent:C||d<1,opacity:d,color:A,alphaTest:E,depthTest:!f,depthWrite:!f,toneMapped:!1,roughness:.72,metalness:.08,emissive:A,emissiveIntensity:.18,...H}):i==="matcap"?l.jsx("meshMatcapMaterial",{map:R,matcap:V,transparent:C||d<1,opacity:d,color:A,alphaTest:E,depthTest:!f,depthWrite:!f,toneMapped:!1,...H}):l.jsx("meshBasicMaterial",{map:R,transparent:C||d<1,opacity:d,color:A,alphaTest:E,depthTest:!f,depthWrite:!f,toneMapped:!1,...H})]})]})}const _t={left:0,right:0,top:0,bottom:0},$t=Math.PI/180;function en({anchors:t,offsets:e,pivot:n,rotation:r,children:s}){const{width:i,height:o}=z.useScreenSpace(),c=v.useMemo(()=>({left:-1,right:1,top:1,bottom:-1,...t}),[t]),a=v.useMemo(()=>({..._t,...e}),[e]),d=v.useMemo(()=>te.computeScreenTransform(i,o,c,a,n),[o,n,c,a,i]),A=d.width>0&&d.height>0?d.width/d.height:null;return l.jsx("group",{position:[d.centerX-d.pivotX,d.centerY-d.pivotY,0],rotation:[0,0,r*$t],scale:[d.width,d.height,1],children:l.jsx(z.ScreenRectAspectContext.Provider,{value:A,children:s})})}function tn({transform:t,guideLayer:e,onChange:n,children:r}){return l.jsx(x.ScreenTransformFrame,{guideColor:"#22d3ee",guideLayer:e,transform:t,onChange:n,children:r})}const nn={left:-1,right:1,top:1,bottom:-1},rn={},sn=[.5,.5];[["Normal","normal"],["Add","add"],["Subtract","subtract"],["Multiply","multiply"],["Screen","screen"],["Lighten","lighten"],["Darken","darken"],["Overlay","overlay"],["Soft Light","softLight"],["Hard Light","hardLight"],["Difference","difference"],["Exclusion","exclusion"]].map(([t,e])=>({label:t,value:e}));const on=t=>[t[0]*2-1,t[1]*2-1],an=(t,e,n,r,s)=>t||(!r&&!s?nn:je({coordinateSpace:e,canvasSize:n??q,position:r,size:s}));function _e({anchors:t,coordinateSpace:e,canvasSize:n,position:r,size:s,offsets:i=rn,pivot:o=sn,rotation:c=0,transform:a,onScreenTransformChange:d,transformGuideLayer:A="scene",...g}){const u=v.useMemo(()=>an(t,e,n,r,s),[t,n,e,r,s]),S=v.useMemo(()=>on(o),[o]);if(a){const C=x.mergeScreenTransform2D(a);return C.enabled?l.jsx(tn,{guideLayer:A,transform:C,onChange:d,children:l.jsx(We,{...g,layoutSize:C.size,renderOrder:g.renderOrder??C.renderOrder,overlay:g.overlay??C.overlay,visible:g.visible??C.visible,rotation:0})}):null}return l.jsx(en,{anchors:u,offsets:i,pivot:S,rotation:c,children:l.jsx(We,{...g,layoutSize:s?{width:s[0],height:s[1]}:void 0,rotation:0})})}const ln=2.5,cn="#38bdf8",An={top:{left:-.92,right:.92,top:.92,bottom:.56},center:{left:-.92,right:.92,top:.18,bottom:-.18},bottom:{left:-.92,right:.92,top:-.56,bottom:-.92}};function dn({bend:t,bendPreset:e,bendStrength:n}){return{bendPreset:(t==null?void 0:t.preset)??e,bendStrength:(t==null?void 0:t.strength)??n}}function hn({width:t,height:e}){const n=Math.max(1,t),r=Math.max(1,e);return{aspect:n/r,resolution:r}}function Oe(t){const e=z.useScreenRectAspect(),{bend:n,layoutSize:r,renderOrder:s,overlay:i=!0,...o}=t,c=r?hn(r):void 0,a=Math.max((c==null?void 0:c.aspect)??e??ln,.1),d=dn({bend:n,bendPreset:o.bendPreset,bendStrength:o.bendStrength});return l.jsx(Ze,{...o,aspect:a,resolution:(c==null?void 0:c.resolution)??o.resolution,...d,overlay:i,renderOrder:s})}function gn({transform:t,guideLayer:e,onChange:n,children:r}){return l.jsx(x.ScreenTransformFrame,{guideColor:cn,guideLayer:e,transform:t,onChange:n,children:r})}function un(t="center"){return An[t]}function fn({anchors:t,coordinateSpace:e,canvasSize:n,position:r,size:s,transform:i,pivot:o,verticalAlign:c}){return{resolvedAnchors:i!=null&&i.anchors?i.anchors:t||(i!=null&&i.position||i!=null&&i.size||r||s?je({coordinateSpace:(i==null?void 0:i.coordinateSpace)??e,canvasSize:(i==null?void 0:i.canvasSize)??n,position:(i==null?void 0:i.position)??r,size:(i==null?void 0:i.size)??s}):un(c)),resolvedOffsets:i==null?void 0:i.offsets,resolvedPivot:ot((i==null?void 0:i.pivot)??o??[.5,.5])}}function $e({anchors:t,coordinateSpace:e,canvasSize:n,offsets:r,pivot:s,position:i,rotation:o=0,size:c,transform:a,screenTransform:d,onScreenTransformChange:A,transformGuideLayer:g="scene",verticalAlign:u="center",...S}){const{resolvedAnchors:C,resolvedOffsets:E,resolvedPivot:f}=v.useMemo(()=>fn({anchors:t,coordinateSpace:e,canvasSize:n,position:i,size:c,transform:a,pivot:s,verticalAlign:u}),[t,n,e,s,i,c,a,u]),m=(a==null?void 0:a.offsets)??r??E,I=(a==null?void 0:a.rotation)??o;if(d){const b=x.mergeScreenTransform2D(d);return b.enabled?l.jsx(gn,{guideLayer:g,transform:b,onChange:A,children:l.jsx(Oe,{...S,layoutSize:b.size,verticalAlign:u,renderOrder:S.renderOrder??b.renderOrder,overlay:S.overlay??b.overlay,visible:S.visible??b.visible})}):null}return l.jsx(te.ScreenTransform,{anchors:C,offsets:m,pivot:f,children:l.jsx("group",{rotation:[0,0,I*Math.PI/180],children:l.jsx(Oe,{...S,verticalAlign:u})})})}const et=({settings:t,transform:e})=>{const n=v.useMemo(()=>l.jsxs("group",{name:"LightEditorGizmo",visible:t.showHelper,children:[l.jsxs("mesh",{renderOrder:1e3,children:[l.jsx("sphereGeometry",{args:[.12,12,8]}),l.jsx("meshBasicMaterial",{color:"#facc15",wireframe:!0,depthTest:!1,depthWrite:!1})]}),l.jsxs("mesh",{position:[0,0,-.35],rotation:[Math.PI/2,0,0],renderOrder:1e3,children:[l.jsx("coneGeometry",{args:[.08,.45,12]}),l.jsx("meshBasicMaterial",{color:"#fde047",wireframe:!0,depthTest:!1,depthWrite:!1})]})]}),[t.showHelper]);return t.enabled?l.jsxs(re.Transform3D,{value:e,children:[n,t.type==="ambient"?l.jsx("ambientLight",{color:t.color,intensity:t.intensity}):null,t.type==="directional"?l.jsx("directionalLight",{color:t.color,intensity:t.intensity,castShadow:t.castShadow}):null,t.type==="point"?l.jsx("pointLight",{color:t.color,intensity:t.intensity,distance:t.distance,decay:t.decay,castShadow:t.castShadow}):null,t.type==="spot"?l.jsx("spotLight",{color:t.color,intensity:t.intensity,distance:t.distance,angle:t.angle,penumbra:t.penumbra,decay:t.decay,castShadow:t.castShadow}):null]}):null},Sn=({source:t,target:e,settings:n})=>{if(!n.enabled||!e)return!1;const r=new Y.Quaternion;if(n.mode==="point"){const i=new Y.Vector3;e.getWorldPosition(i),t.lookAt(i),r.copy(t.quaternion)}else e.getWorldQuaternion(r);const s=new Y.Quaternion().setFromEuler(new Y.Euler(n.offsetRotation.x*Math.PI/180,n.offsetRotation.y*Math.PI/180,n.offsetRotation.z*Math.PI/180));return t.quaternion.copy(r).multiply(s),!0},tt=({target:t,settings:e,children:n})=>{const r=v.useRef(null);return J.useFrame(()=>{r.current&&Sn({source:r.current,target:t,settings:e})}),l.jsx("group",{ref:r,children:n})},En=(t,e)=>{let n=t;for(;n&&n!==e;){if("isTransformControls"in n&&n.isTransformControls===!0)return!0;n=n.parent}return!1},P=({children:t,layer:e})=>{const n=v.useRef(null),r=v.useRef(0),s=v.useCallback(()=>{e===void 0||!n.current||n.current.traverse(i=>{En(i,n.current)||i.layers.set(e)})},[e]);return v.useLayoutEffect(()=>{s(),r.current=2},[s,t]),J.useFrame(()=>{r.current<=0||(s(),r.current-=1)},-1e3),l.jsx("group",{ref:n,children:t})},k=(t,e)=>(t==null?void 0:t.type)===e,vn=t=>null,ie=({children:t,inside:e})=>e?l.jsx(l.Fragment,{children:t}):l.jsx(Je,{children:t}),Cn=({children:t,insideScreenSpaceUI:e,objectRef:n,renderOrder:r,settings:s})=>l.jsx(ie,{inside:e,children:l.jsx(mn,{settings:s,renderOrder:r,objectRef:n,children:t})}),mn=({children:t,objectRef:e,renderOrder:n,settings:r})=>{const s=z.useScreenSpace();if(!r.enabled||!r.visible)return null;const i=x.resolveScreenTransform2D({transform:r,parentSize:s});return l.jsx("group",{ref:e,position:i.center,rotation:i.rotation,scale:i.size,renderOrder:n??r.renderOrder,children:t})},bn=({anchor:t,children:e,insideScreenSpaceUI:n,objectRef:r,renderOrder:s,settings:i})=>l.jsx(ie,{inside:n,children:l.jsx(In,{anchor:t,settings:i,renderOrder:s,objectRef:r,children:e})}),In=({anchor:t,children:e,objectRef:n,renderOrder:r,settings:s})=>{const i=rt.useFaceInfo({targetFps:24}),{size:o}=J.useThree(),c=z.useScreenSpace(),a=v.useRef(null),d=v.useRef(new Y.Vector3),A=v.useRef({pos:new Y.Vector3,prevRaw:new Y.Vector3,dxHat:new Y.Vector3,initialized:!1}),g=v.useRef(!1),u=v.useRef({x:0,y:0,z:0,visibility:0}),S=v.useRef({x:0,y:0}),C=i?Xe.resolveFaceAnchorPoint(t.target,i.landmarks,t.customAnchorPoint,u.current):null,E=C?He({point:C,viewportSize:o,target:S.current}):null,f=E?x.resolveScreenTransform2D({transform:{...s,position:{x:E.x+s.position.x+t.offset.x,y:E.y+s.position.y+t.offset.y}},parentSize:c}):null;return J.useFrame((m,I)=>{const b=a.current;if(b){if(b.visible=!!(f&&s.enabled&&s.visible),!f){g.current=!1,A.current.initialized=!1;return}d.current.set(f.center[0],f.center[1],t.offset.z),t.smoothing>0?(Pe.stepTrackingSmoothing(A.current,d.current,g.current?I:0,t.smoothing),b.position.copy(A.current.pos)):b.position.copy(d.current),g.current=!0}}),l.jsx("group",{ref:m=>{a.current=m,n==null||n(m)},rotation:[(f==null?void 0:f.rotation[0])??0,(f==null?void 0:f.rotation[1])??0,((f==null?void 0:f.rotation[2])??0)+(t.followFaceRoll?(i==null?void 0:i.pose.rotation.z)??0:0)],scale:[s.size.width/100*s.scale2D.x,s.size.height/100*s.scale2D.y,1],renderOrder:r??s.renderOrder,children:e})},nt=({editorMode:t=!1,fallback:e=vn,insideScreenSpaceUI:n=!1,objectId:r,onComponentChange:s,renderLayer:i,renderOrder:o,store:c})=>{const a=Ae.useRegisterRuntimeObject(),d=Ae.useResolveRuntimeObject(),A=c.objects[r];if(!A||!A.enabled)return null;const g=x.getOrderedComponents(c,r).filter(h=>h.enabled),u=g.find(h=>h.type==="Transform"),S=g.find(h=>h.type==="ScreenTransform"),C=g.find(h=>h.type==="ScreenImage"),E=g.find(h=>h.type==="ScreenText"),f=g.find(h=>h.type==="ScreenShape"),m=g.find(h=>h.type==="MeshRenderer"),I=g.find(h=>h.type==="FaceMeshRenderer"),b=g.find(h=>h.type==="Light"),p=g.find(h=>h.type==="LookAt"),Q=g.find(h=>h.type==="PinToMesh"),M=g.find(h=>h.type==="TrackingAnchor"),T=x.getSceneObjectChildren(c,r).map(h=>l.jsx(nt,{objectId:h.id,store:c,editorMode:t,renderOrder:o,renderLayer:i,onComponentChange:s,fallback:e,insideScreenSpaceUI:n||!!S},h.id));if(k(u,"Transform")&&k(b,"Light"))return l.jsx(P,{layer:i,children:l.jsxs("group",{ref:h=>a(r,h),children:[l.jsx(et,{settings:b.settings,transform:u.settings}),T]})});if(k(u,"Transform")&&k(m,"MeshRenderer")){const h=k(p,"LookAt")?p.settings:x.createDefaultComponent("LookAt",r).settings,B=h.inheritChildren?T:null,j=h.inheritChildren?null:T;return l.jsx(P,{layer:i,children:l.jsx("group",{ref:O=>a(r,O),children:l.jsx(x.PinToMesh,{target:k(Q,"PinToMesh")?d(Q.settings.targetObjectId):null,settings:k(Q,"PinToMesh")?Q.settings:x.createDefaultComponent("PinToMesh",r).settings,children:l.jsxs(re.Transform3D,{value:u.settings,onChange:s?O=>s({...u,settings:O}):void 0,children:[l.jsxs(tt,{target:k(p,"LookAt")?d(p.settings.targetObjectId):null,settings:h,children:[l.jsx(z.MeshRenderer,{value:m.settings,renderOrder:o}),B]}),j]})})})})}if(k(I,"FaceMeshRenderer"))return l.jsx(P,{layer:i,children:l.jsxs("group",{ref:h=>a(r,h),children:[l.jsx(re.FaceMeshRenderer,{value:I.settings,transform:k(u,"Transform")?u.settings:void 0}),T]})});if(k(u,"Transform")){if(k(M,"TrackingAnchor")){const h=M.settings;return l.jsx(P,{layer:i,children:l.jsx(Xe.FaceTracker,{followFaceRoll:h.followFaceRoll,children:l.jsx(Pe.TrackingAnchor,{target:h.target,customAnchorPoint:h.customAnchorPoint,offset:[h.offset.x,h.offset.y,h.offset.z],smoothing:h.smoothing,children:l.jsx(re.Transform3D,{objectRef:B=>a(r,B),value:u.settings,children:T})})})})}return l.jsx(P,{layer:i,children:l.jsx("group",{children:l.jsx(re.Transform3D,{objectRef:h=>a(r,h),value:u.settings,onChange:s?h=>s({...u,settings:h}):void 0,children:T})})})}if(k(S,"ScreenTransform")&&k(C,"ScreenImage")){const h=x.mapScreenImageSettingsToProps({screenSpaceUI:{enabled:!0},screenImage:{...C.settings,screenTransform:S.settings}});return h.shouldRender?l.jsx(P,{layer:i,children:l.jsx("group",{renderOrder:o,children:l.jsxs(ie,{inside:n,children:[l.jsx(_e,{...h.props,renderOrder:o??h.props.renderOrder,onScreenTransformChange:s?B=>s({...S,settings:B}):void 0}),T]})})}):null}if(k(S,"ScreenTransform")&&k(E,"ScreenText")){const h=x.mapScreenTextSettingsToProps({screenSpaceUI:{enabled:!0},screenText:{...E.settings,screenTransform:S.settings}});return h.shouldRender?l.jsx(P,{layer:i,children:l.jsx("group",{renderOrder:o,children:l.jsxs(ie,{inside:n,children:[l.jsx($e,{...h.props,renderOrder:o??h.props.renderOrder,onScreenTransformChange:s?B=>s({...S,settings:B}):void 0}),T]})})}):null}return k(S,"ScreenTransform")&&k(f,"ScreenShape")?l.jsx(P,{layer:i,children:l.jsx("group",{ref:h=>a(r,h),renderOrder:o,children:l.jsxs(ie,{inside:n,children:[l.jsx(x.ScreenShape,{name:A.name,settings:f.settings,transform:S.settings,renderOrder:o,onScreenTransformChange:s?h=>s({...S,settings:h}):void 0}),T]})})}):k(S,"ScreenTransform")?k(M,"TrackingAnchor")?l.jsx(P,{layer:i,children:l.jsx("group",{children:l.jsx(bn,{anchor:M.settings,settings:S.settings,renderOrder:o,insideScreenSpaceUI:n,objectRef:h=>a(r,h),children:T})})}):l.jsx(P,{layer:i,children:l.jsx("group",{children:l.jsx(Cn,{settings:S.settings,renderOrder:o,insideScreenSpaceUI:n,objectRef:h=>a(r,h),children:T})})}):t?l.jsxs(l.Fragment,{children:[T,e(`Object "${A.name}" has unsupported components: ${g.map(h=>h.type).join(", ")}`)]}):T.length?l.jsx(l.Fragment,{children:T}):null},Tn=({layers:t})=>{const{camera:e,gl:n,raycaster:r,scene:s}=J.useThree(),{session:i}=Ae.useXRContext(),o=v.useCallback(()=>x.renderSequentialPasses({renderer:n,scene:s,camera:e,layers:t}),[e,n,t,s]);return J.useFrame(o,1),v.useEffect(()=>{const c=r.layers.mask;return t.forEach(a=>r.layers.enable(a)),()=>{r.layers.mask=c}},[t,r]),v.useEffect(()=>(i._setR3FState({renderer:n,scene:s,camera:e,renderFrame:o}),()=>i._setR3FState({renderer:n,scene:s,camera:e})),[e,n,o,s,i]),null};exports.LightObject=et;exports.LookAt=tt;exports.RenderGroupLayer=P;exports.SceneObjectRenderer=nt;exports.ScreenImage=_e;exports.ScreenSpaceUI=Je;exports.ScreenText=$e;exports.SequentialRenderPasses=Tn;exports.TextLabel=Ze;exports.clientToScreenPixels=At;exports.computeContainScale=le;exports.mediaToScreenPixels=gt;exports.normalizedToScreenPixels=He;exports.screenPixelsToClient=dt;exports.screenPixelsToMedia=ut;exports.screenPixelsToNormalized=ht;exports.screenPixelsToUnits=lt;exports.screenPointToRay=St;exports.screenUnitsToPixels=ct;exports.worldToScreenPixels=ft;