@fleox/agent3d 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +350 -126
  2. package/changelog.json +12 -0
  3. package/dist/agent/agent3d.mjs +16 -16
  4. package/dist/agent/chunks/{cdp-CaKRRzMX.mjs → cdp-Bdtm4fBN.mjs} +3 -2
  5. package/dist/agent/chunks/{imageCodec-BpDU9Lsq.mjs → imageCodec-Dz9PFxi9.mjs} +1 -1
  6. package/dist/agent/chunks/{package-Ck7_Nszg.mjs → package-BOIyp_2B.mjs} +1 -1
  7. package/dist/agent/chunks/{render-Cbuhz5uW.mjs → render-CN4mgGLQ.mjs} +2 -2
  8. package/dist/runtime/agent3d-runtime.js +23 -23
  9. package/dist/runtime/agent3d-runtime.single.js +2 -2
  10. package/dist/runtime/chunks/{BufferGeometryUtils-Re3wQkXp.js → BufferGeometryUtils-XmME4f7Z.js} +1 -1
  11. package/dist/runtime/chunks/{EXRLoader-Bzm84si5.js → EXRLoader-CBdIpBMT.js} +1 -1
  12. package/dist/runtime/chunks/{FontLoader-BocwqK8V.js → FontLoader-dVu9WH2X.js} +1 -1
  13. package/dist/runtime/chunks/GLTFLoader-Z9Inv-Xm.js +1 -0
  14. package/dist/runtime/chunks/{GroundedSkybox-esvlRCO0.js → GroundedSkybox-g1ASZWNu.js} +1 -1
  15. package/dist/runtime/chunks/{HDRLoader-DHrHp8fs.js → HDRLoader-DBOMWa7O.js} +2 -2
  16. package/dist/{studio/assets/OrbitControls-fcOgB96a.js → runtime/chunks/OrbitControls-BIpWXK4x.js} +1 -1
  17. package/dist/runtime/chunks/{RectAreaLightUniformsLib-_mZ62yWn.js → RectAreaLightUniformsLib-4ZzgX9vp.js} +1 -1
  18. package/dist/runtime/chunks/{RoomEnvironment-CL4UR6ZW.js → RoomEnvironment-CXgfLJdO.js} +1 -1
  19. package/dist/runtime/chunks/{RoundedBoxGeometry-x-ot8ZSh.js → RoundedBoxGeometry-BViRogcJ.js} +1 -1
  20. package/dist/runtime/chunks/{SVGLoader-hRF0EwD-.js → SVGLoader-CV0U1EIF.js} +1 -1
  21. package/dist/runtime/chunks/{Sky-BrLN9Fk5.js → Sky-DGJXlPb_.js} +1 -1
  22. package/dist/runtime/chunks/{extrude-m04mghOS.js → extrude-D6WnITQq.js} +1 -1
  23. package/dist/runtime/chunks/{game-BoG2S6g4.js → game-BoEiyZrL.js} +3 -3
  24. package/dist/runtime/chunks/generators-D5JUo0jp.js +331 -0
  25. package/dist/runtime/chunks/{materials-C2uffFEd.js → materials-Dn-bYrZd.js} +5 -5
  26. package/dist/runtime/chunks/{model-D-4xZz21.js → model-BCVF3QzB.js} +1 -1
  27. package/dist/runtime/chunks/{params-DdApDOBw.js → params-C2uoUDJ0.js} +1 -1
  28. package/dist/runtime/chunks/{physicsHost-DPaVdM0R.js → physicsHost-ChPgysMQ.js} +1 -1
  29. package/dist/runtime/chunks/{postfx-BpBXjLX3.js → postfx-UgKCbmZs.js} +29 -29
  30. package/dist/{studio/assets/shaders-BEznGIct.js → runtime/chunks/shaders-Dw6zHdu_.js} +3 -3
  31. package/dist/runtime/chunks/svg-CmlFY_8O.js +1 -0
  32. package/dist/runtime/chunks/{text-CmkU-b0C.js → text-D1EQpdSU.js} +2 -2
  33. package/dist/runtime/chunks/{three.module-W4hp4qHb.js → three.module-DnaBiDAJ.js} +31 -31
  34. package/dist/runtime/chunks/{toon-B5Jhf37V.js → toon-BsvVk_nK.js} +1 -1
  35. package/dist/runtime/chunks/{util-THUewKBk.js → util-CyaW1fcW.js} +1 -1
  36. package/dist/studio/assets/{BufferGeometryUtils-wW9vV1l2.js → BufferGeometryUtils-CAlXAboW.js} +1 -1
  37. package/dist/studio/assets/{EXRLoader-f8U8jnlr.js → EXRLoader-BKkzlNd8.js} +1 -1
  38. package/dist/studio/assets/{FontLoader-9sHudKzD.js → FontLoader-Bzjx8mXt.js} +2 -2
  39. package/dist/studio/assets/GLTFLoader-1Zd9N406.js +1 -0
  40. package/dist/studio/assets/GroundedSkybox-BEMqNCBD.js +1 -0
  41. package/dist/studio/assets/{HDRLoader-CkQyrTWY.js → HDRLoader-DxB0kxPH.js} +2 -2
  42. package/dist/{runtime/chunks/OrbitControls-sjN2MF0e.js → studio/assets/OrbitControls-MlE9XiCg.js} +1 -1
  43. package/dist/studio/assets/{RectAreaLightUniformsLib-CZHWO9xf.js → RectAreaLightUniformsLib-ClHrtYY6.js} +1 -1
  44. package/dist/studio/assets/{RoomEnvironment-BsISzuCp.js → RoomEnvironment-MJ-jIEC8.js} +1 -1
  45. package/dist/studio/assets/{SVGLoader-BIkQDT66.js → SVGLoader-CIYl0nEy.js} +1 -1
  46. package/dist/studio/assets/{Sky-C282PFL1.js → Sky-DNMfpp92.js} +1 -1
  47. package/dist/studio/assets/{camera-BhKdE9ej.js → camera-7sEn13L-.js} +2 -2
  48. package/dist/studio/assets/editor-CnbvVkhU.js +53 -0
  49. package/dist/studio/assets/{extrude-CnayHczh.js → extrude-9bG8hr2C.js} +1 -1
  50. package/dist/studio/assets/{game-Dv5s4eMN.js → game-B04KGAK0.js} +3 -3
  51. package/dist/studio/assets/generators-LSni1Yfc.js +331 -0
  52. package/dist/studio/assets/{index-Dh-2Y34U.js → index-3LL5NEIH.js} +8 -8
  53. package/dist/studio/assets/{model-XZSP52pV.js → model-CNddhwmA.js} +2 -2
  54. package/dist/studio/assets/{physicsHost-C84FddIe.js → physicsHost-hMU_SDiX.js} +1 -1
  55. package/dist/studio/assets/{postfx-BWWXb8i8.js → postfx-BcCZS0Bq.js} +27 -27
  56. package/dist/studio/assets/runtime-DY_KqD1x.js +572 -0
  57. package/dist/{runtime/chunks/shaders-CmeJRio1.js → studio/assets/shaders-BhMCstyv.js} +3 -3
  58. package/dist/studio/assets/svg-CNKK-h7H.js +2 -0
  59. package/dist/studio/assets/{text-5DsJJHcj.js → text-BSPI7dk1.js} +3 -3
  60. package/dist/studio/assets/{three.module-ByMn_ZTv.js → three.module-CnI50X0U.js} +31 -31
  61. package/dist/studio/index.html +3 -3
  62. package/package.json +1 -1
  63. package/plugin/.claude-plugin/plugin.json +2 -2
  64. package/plugin/skills/agent3d-assets/SKILL.md +24 -24
  65. package/plugin/skills/agent3d-create/SKILL.md +20 -20
  66. package/plugin/skills/agent3d-create/references/art-direction.md +3 -3
  67. package/plugin/skills/agent3d-create/references/recipes.md +6 -6
  68. package/plugin/skills/agent3d-edit/SKILL.md +22 -22
  69. package/plugin/skills/agent3d-edit/references/patch-ops.md +2 -2
  70. package/plugin/skills/agent3d-game/SKILL.md +7 -7
  71. package/plugin/skills/agent3d-publish/SKILL.md +21 -21
  72. package/plugin/skills/agent3d-publish/references/integrations.md +1 -1
  73. package/dist/runtime/chunks/GLTFLoader-DHp1wv6J.js +0 -1
  74. package/dist/runtime/chunks/generators-OHhFCc2E.js +0 -331
  75. package/dist/runtime/chunks/svg-B3nZaQFD.js +0 -1
  76. package/dist/studio/assets/GLTFLoader-C3C_3K62.js +0 -1
  77. package/dist/studio/assets/GroundedSkybox-BTqmv4fv.js +0 -1
  78. package/dist/studio/assets/editor-BgY_RoRd.js +0 -1
  79. package/dist/studio/assets/generators-DVX3bAxe.js +0 -331
  80. package/dist/studio/assets/runtime-k_MFerbJ.js +0 -572
  81. package/dist/studio/assets/svg-DT8kx37i.js +0 -2
@@ -1 +0,0 @@
1
- import{$ as e,At as t,Bn as n,C as r,Ct as i,En as a,Ft as o,Gt as s,Ht as c,I as l,J as u,Jt as d,Kt as f,Ln as p,Lt as m,M as h,Mt as g,Nt as _,Ot as v,Pt as ee,Q as te,Rn as y,S as b,St as ne,Tn as x,W as S,Wt as re,X as ie,Y as C,Z as ae,at as oe,ct as se,dt as ce,et as le,f as ue,ft as w,g as T,h as E,hn as de,in as D,jt as fe,kt as pe,lt as me,mn as he,mt as O,nn as ge,pn as _e,pt as ve,qt as k,rt as ye,s as be,st as xe,tt as A,u as Se,ut as Ce,vt as j,x as we,xt as M,yn as Te,yt as Ee,zt as De}from"./three.module-ByMn_ZTv.js";import{r as N}from"./BufferGeometryUtils-wW9vV1l2.js";import{clone as Oe}from"./SkeletonUtils-CG5akqME.js";var ke=class extends ve{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Pe(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new qe(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new We(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new I(e,F.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new I(e,F.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new Je(e)})}load(e,t,n,r){let i=this,a;if(this.resourcePath!==``)a=this.resourcePath;else if(this.path!==``){let t=O.extractUrlBase(e);a=O.resolveURL(t,this.path)}else a=O.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},s=new l(this.manager);s.setPriority(this.priority),s.setCache(this.cache),s.setPath(this.path),s.setResponseType(`arraybuffer`),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,function(n){try{i.parse(n,a,function(n){t(n),i.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i,a={},o={},s=new TextDecoder;if(typeof e==`string`)i=JSON.parse(e);else if(e instanceof ArrayBuffer){if(s.decode(new Uint8Array(e,0,4))===L){try{a[F.KHR_BINARY_GLTF]=new Ye(e)}catch(e){r&&r(e);return}i=JSON.parse(a[F.KHR_BINARY_GLTF].content)}else i=JSON.parse(s.decode(e))}else i=e;if(i.asset===void 0||i.asset.version[0]<2){r&&r(Error(`THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.`));return}let c=new ct(i,{path:t||this.resourcePath||``,crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){let t=this.pluginCallbacks[e](c);t.name||console.error(`THREE.GLTFLoader: Invalid plugin found: missing name`),o[t.name]=t,a[t.name]=!0}if(i.extensionsUsed)for(let e=0;e<i.extensionsUsed.length;++e){let t=i.extensionsUsed[e],n=i.extensionsRequired||[];switch(t){case F.KHR_MATERIALS_UNLIT:a[t]=new Me;break;case F.KHR_DRACO_MESH_COMPRESSION:a[t]=new Xe(i,this.dracoLoader);break;case F.KHR_TEXTURE_TRANSFORM:a[t]=new Ze;break;case F.KHR_MESH_QUANTIZATION:a[t]=new Qe;break;default:n.indexOf(t)>=0&&o[t]===void 0&&console.warn(`THREE.GLTFLoader: Unknown extension "`+t+`".`)}}c.setExtensions(a),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,t,r,i)})}};function Ae(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}function P(e,t,n){let r=e.json.materials[t];return r.extensions&&r.extensions[n]?r.extensions[n]:null}var F={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_DIFFUSE_ROUGHNESS:`KHR_materials_diffuse_roughness`,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`,KHR_MESHOPT_COMPRESSION:`KHR_meshopt_compression`,EXT_MESH_GPU_INSTANCING:`EXT_mesh_gpu_instancing`},je=class{constructor(e){this.parser=e,this.name=F.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n=`light:`+e,r=t.cache.get(n);if(r)return r;let i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e],o,s=new b(16777215);a.color!==void 0&&s.setRGB(a.color[0],a.color[1],a.color[2],w);let l=a.range===void 0?0:a.range;switch(a.type){case`directional`:o=new h(s),o.target.position.set(0,0,-1),o.add(o.target);break;case`point`:o=new c(s),o.distance=l;break;case`spot`:o=new Te(s),o.distance=l,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle===void 0?0:a.spot.innerConeAngle,a.spot.outerConeAngle=a.spot.outerConeAngle===void 0?Math.PI/4:a.spot.outerConeAngle,o.angle=a.spot.outerConeAngle,o.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw Error(`THREE.GLTFLoader: Unexpected light type: `+a.type)}return o.position.set(0,0,0),X(o,a),a.intensity!==void 0&&(o.intensity=a.intensity),o.name=t.createUniqueName(a.name||`light_`+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if(e===`light`)return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return i===void 0?null:this._loadLight(i).then(function(e){return n._getNodeRef(t.cache,i,e)})}},Me=class{constructor(){this.name=F.KHR_MATERIALS_UNLIT}getMaterialType(){return i}extendParams(e,t,n){let r=[];e.color=new b(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],w),e.opacity=t[3]}i.baseColorTexture!==void 0&&r.push(n.assignTexture(e,`map`,i.baseColorTexture,D))}return Promise.all(r)}},Ne=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}},Pe=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatMap`,n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`clearcoatRoughnessMap`,n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(this.parser.assignTexture(t,`clearcoatNormalMap`,n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){let e=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new p(e,e)}return Promise.all(r)}},Fe=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_DIFFUSE_ROUGHNESS}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.diffuseRoughness=n.diffuseRoughnessFactor===void 0?0:n.diffuseRoughnessFactor,n.diffuseRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`diffuseRoughnessMap`,n.diffuseRoughnessTexture)),Promise.all(r)}},Ie=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_DISPERSION}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion===void 0?0:n.dispersion),Promise.resolve()}},Le=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceMap`,n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessMinimum=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessMaximum=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`iridescenceThicknessMap`,n.iridescenceThicknessTexture)),Promise.all(r)}},Re=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_SHEEN}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];if(t.sheenColor=new b(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){let e=n.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],w)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenColorMap`,n.sheenColorTexture,D)),n.sheenRoughnessTexture!==void 0&&r.push(this.parser.assignTexture(t,`sheenRoughnessMap`,n.sheenRoughnessTexture)),Promise.all(r)}},ze=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(this.parser.assignTexture(t,`transmissionMap`,n.transmissionTexture)),Promise.all(r)}},Be=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_VOLUME}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.thickness=n.thicknessFactor===void 0?0:n.thicknessFactor,n.thicknessTexture!==void 0&&r.push(this.parser.assignTexture(t,`thicknessMap`,n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;let i=n.attenuationColor||[1,1,1];return t.attenuationColor=new b().setRGB(i[0],i[1],i[2],w),Promise.all(r)}},Ve=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_IOR}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);return n===null||(t.ior=n.ior===void 0?1.5:n.ior,t.ior===0&&(t.ior=1e3)),Promise.resolve()}},He=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_SPECULAR}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];t.specularIntensity=n.specularFactor===void 0?1:n.specularFactor,n.specularTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularIntensityMap`,n.specularTexture));let i=n.specularColorFactor||[1,1,1];return t.specularColor=new b().setRGB(i[0],i[1],i[2],w),n.specularColorTexture!==void 0&&r.push(this.parser.assignTexture(t,`specularColorMap`,n.specularColorTexture,D)),Promise.all(r)}},Ue=class{constructor(e){this.parser=e,this.name=F.EXT_MATERIALS_BUMP}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return t.bumpScale=n.bumpFactor===void 0?1:n.bumpFactor,n.bumpTexture!==void 0&&r.push(this.parser.assignTexture(t,`bumpMap`,n.bumpTexture)),Promise.all(r)}},We=class{constructor(e){this.parser=e,this.name=F.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return P(this.parser,e,this.name)===null?null:v}extendMaterialParams(e,t){let n=P(this.parser,e,this.name);if(n===null)return Promise.resolve();let r=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(this.parser.assignTexture(t,`anisotropyMap`,n.anisotropyTexture)),Promise.all(r)}},Ge=class{constructor(e){this.parser=e,this.name=F.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let i=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures`);return null}return t.loadTextureImage(e,i.source,a)}},Ke=class{constructor(e){this.parser=e,this.name=F.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},qe=class{constructor(e){this.parser=e,this.name=F.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;let a=i.extensions[t],o=r.images[a.source],s=n.textureLoader;if(o.uri){let e=n.options.manager.getHandler(o.uri);e!==null&&(s=e)}return n.loadTextureImage(e,a.source,s)}},I=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],r=this.parser.getDependency(`buffer`,e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw Error(`THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files`);return null}return r.then(function(t){let n=e.byteOffset||0,r=e.byteLength||0,a=e.count,o=e.byteStride,s=new Uint8Array(t,n,r);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(a,o,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(a*o);return i.decodeGltfBuffer(new Uint8Array(t),a,o,s,e.mode,e.filter),t})})}return null}},Je=class{constructor(e){this.name=F.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let e of r.primitives)if(e.mode!==V.TRIANGLES&&e.mode!==V.TRIANGLE_STRIP&&e.mode!==V.TRIANGLE_FAN&&e.mode!==void 0)return null;let i=n.extensions[this.name].attributes,a=[],s={};for(let e in i)a.push(this.parser.getDependency(`accessor`,i[e]).then(t=>(s[e]=t,s[e])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(e=>{let t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,i=[];for(let e of n){let t=new M,n=new y,a=new k,c=new y(1,1,1),l=new ie(e.geometry,e.material,r);for(let e=0;e<r;e++)s.TRANSLATION&&n.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&a.fromBufferAttribute(s.ROTATION,e),s.SCALE&&c.fromBufferAttribute(s.SCALE,e),l.setMatrixAt(e,t.compose(n,a,c));let u=null;for(let e in s)if(e===`_COLOR_0`){let t=s[e];l.instanceColor=new C(t.array,t.itemSize,t.normalized)}else if(e!==`TRANSLATION`&&e!==`ROTATION`&&e!==`SCALE`){if(u===null){let e=l.geometry;u=new T,u.name=e.name;for(let t in e.attributes)u.setAttribute(t,e.attributes[t]);for(let t in e.morphAttributes)u.morphAttributes[t]=e.morphAttributes[t];e.index!==null&&u.setIndex(e.index),u.morphTargetsRelative=e.morphTargetsRelative;for(let t of e.groups)u.addGroup(t.start,t.count,t.materialIndex);e.boundingBox!==null&&(u.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(u.boundingSphere=e.boundingSphere.clone()),u.drawRange.start=e.drawRange.start,u.drawRange.count=e.drawRange.count,u.userData=Object.assign({},e.userData),l.geometry=u}let t=s[e];u.setAttribute(e,new C(t.array,t.itemSize,t.normalized))}o.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),i.push(l)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}},L=`glTF`,R=12,z={JSON:1313821514,BIN:5130562},Ye=class{constructor(e){this.name=F.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,R),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==L)throw Error(`THREE.GLTFLoader: Unsupported glTF-Binary header.`);if(this.header.version<2)throw Error(`THREE.GLTFLoader: Legacy binary file detected.`);let r=this.header.length-R,i=new DataView(e,R),a=0;for(;a<r;){let t=i.getUint32(a,!0);a+=4;let r=i.getUint32(a,!0);if(a+=4,r===z.JSON){let r=new Uint8Array(e,R+a,t);this.content=n.decode(r)}else if(r===z.BIN){let n=R+a;this.body=e.slice(n,n+t)}a+=t}if(this.content===null)throw Error(`THREE.GLTFLoader: JSON content not found.`)}},Xe=class{constructor(e,t){if(!t)throw Error(`THREE.GLTFLoader: No DRACOLoader instance provided.`);this.name=F.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(let e in a){let t=K[e]||e.toLowerCase();o[t]=a[e]}for(let t in e.attributes){let r=K[t]||t.toLowerCase();if(a[t]!==void 0){let i=n.accessors[e.attributes[t]];c[r]=H[i.componentType].name,s[r]=i.normalized===!0}}return t.getDependency(`bufferView`,i).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(let t in e.attributes){let n=e.attributes[t],r=s[t];r!==void 0&&(n.normalized=r)}t(e)},o,c,w,n)})})}},Ze=class{constructor(){this.name=F.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){if((t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0)return e;if(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),t.rotation!==void 0){let t=Math.cos(e.rotation),n=Math.sin(e.rotation);e.matrix.set(e.repeat.x*t,e.repeat.y*n,e.offset.x,-e.repeat.x*n,e.repeat.y*t,e.offset.y,0,0,1),e.matrixAutoUpdate=!1}return e.needsUpdate=!0,e}},Qe=class{constructor(){this.name=F.KHR_MESH_QUANTIZATION}},B=class extends e{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=o*2,c=o*3,l=r-t,u=(n-t)/l,d=u*u,f=d*u,p=e*c,m=p-c,h=-2*f+3*d,g=f-d,_=1-h,v=g-d+u;for(let e=0;e!==o;e++){let t=a[m+e+o],n=a[m+e+s]*l,r=a[p+e+o],c=a[p+e]*l;i[e]=_*t+v*n+h*r+g*c}return i}},$e=new k,et=class extends B{interpolate_(e,t,n,r){let i=super.interpolate_(e,t,n,r);return $e.fromArray(i).normalize().toArray(i),i}},V={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},H={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},U={9728:fe,9729:me,9984:_,9985:ce,9986:g,9987:Ce},W={33071:we,33648:t,10497:ge},G={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},K={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`},q={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},tt={CUBICSPLINE:void 0,LINEAR:A,STEP:le},J={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`};function nt(e){return e.DefaultMaterial===void 0&&(e.DefaultMaterial=new pe({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Y(e,t,n){for(let r in n.extensions)e[r]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function X(e,t){t.extras!==void 0&&(typeof t.extras==`object`?Object.assign(e.userData,t.extras):console.warn(`THREE.GLTFLoader: Ignoring primitive type .extras, `+t.extras))}function rt(e,t,n){let r=!1,i=!1,a=!1;for(let e=0,n=t.length;e<n;e++){let n=t[e];if(n.POSITION!==void 0&&(r=!0),n.NORMAL!==void 0&&(i=!0),n.COLOR_0!==void 0&&(a=!0),r&&i&&a)break}if(!r&&!i&&!a)return Promise.resolve(e);let o=[],s=[],c=[];for(let l=0,u=t.length;l<u;l++){let u=t[l];if(r){let t=u.POSITION===void 0?e.attributes.position:n.getDependency(`accessor`,u.POSITION);o.push(t)}if(i){let t=u.NORMAL===void 0?e.attributes.normal:n.getDependency(`accessor`,u.NORMAL);s.push(t)}if(a){let t=u.COLOR_0===void 0?e.attributes.color:n.getDependency(`accessor`,u.COLOR_0);c.push(t)}}return Promise.all([Promise.all(o),Promise.all(s),Promise.all(c)]).then(function(t){let n=t[0],o=t[1],s=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),a&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e})}function it(e,t){if(e.updateMorphTargets(),t.weights!==void 0)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){let n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn(`THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.`)}}function at(e){let t,n=e.extensions&&e.extensions[F.KHR_DRACO_MESH_COMPRESSION];if(t=n?`draco:`+n.bufferView+`:`+n.indices+`:`+Z(n.attributes):e.indices+`:`+Z(e.attributes)+`:`+e.mode,e.targets!==void 0)for(let n=0,r=e.targets.length;n<r;n++)t+=`:`+Z(e.targets[n]);return t}function Z(e){let t=``,n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+`:`+e[n[r]]+`;`;return t}function Q(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw Error(`THREE.GLTFLoader: Unsupported normalized accessor component type.`)}}function ot(e){return e.search(/\.jpe?g($|\?)/i)>0||e.search(/^data\:image\/jpeg/)===0?`image/jpeg`:e.search(/\.webp($|\?)/i)>0||e.search(/^data\:image\/webp/)===0?`image/webp`:e.search(/\.ktx2($|\?)/i)>0||e.search(/^data\:image\/ktx2/)===0?`image/ktx2`:`image/png`}var st=new M,ct=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Ae,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 n=!1,r=-1,i=!1,o=-1;if(typeof navigator<`u`&&navigator.userAgent!==void 0){let e=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(e)===!0;let t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,i=e.indexOf(`Firefox`)>-1,o=i?e.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>`u`||n&&r<17||i&&o<98?(this.textureLoader=new a(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new u(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType(`arraybuffer`),(this.options.withCredentials||this.options.crossOrigin===`use-credentials`)&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([n.getDependencies(`scene`),n.getDependencies(`animation`),n.getDependencies(`camera`)])}).then(function(t){let a={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Y(i,a,r),X(a,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(a)})).then(function(){for(let e of a.scenes)e.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){let r=e[t];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),i=(e,t)=>{let n=this.associations.get(e);n!=null&&this.associations.set(t,n);for(let[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+=`_instance_`+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){let n=e+`:`+t,r=this.cache.get(n);if(!r){switch(e){case`scene`:r=this.loadScene(t);break;case`node`:r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case`mesh`:r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case`accessor`:r=this.loadAccessor(t);break;case`bufferView`:r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case`buffer`:r=this.loadBuffer(t);break;case`material`:r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case`texture`:r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case`skin`:r=this.loadSkin(t);break;case`animation`:r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case`camera`:r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw Error(`Unknown type: `+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e===`mesh`?`es`:`s`)]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!==`arraybuffer`)throw Error(`THREE.GLTFLoader: `+t.type+` buffer type is not supported.`);if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[F.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(e,i){n.load(O.resolveURL(t.uri,r.path),e,void 0,function(){i(Error(`THREE.GLTFLoader: Failed to load buffer "`+t.uri+`".`))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency(`buffer`,t.buffer).then(function(e){let n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let e=G[r.type],t=H[r.componentType],n=r.normalized===!0,i=new t(r.count*e);return Promise.resolve(new E(i,e,n))}let i=[];return r.bufferView===void 0?i.push(null):i.push(this.getDependency(`bufferView`,r.bufferView)),r.sparse!==void 0&&(i.push(this.getDependency(`bufferView`,r.sparse.indices.bufferView)),i.push(this.getDependency(`bufferView`,r.sparse.values.bufferView))),Promise.all(i).then(function(e){let i=e[0],a=G[r.type],o=H[r.componentType],s=o.BYTES_PER_ELEMENT,c=s*a,l=r.byteOffset||0,u=r.bufferView===void 0?void 0:n.bufferViews[r.bufferView].byteStride,d=r.normalized===!0,f,p;if(u&&u!==c){let e=Math.floor(l/u),n=`InterleavedBuffer:`+r.bufferView+`:`+r.componentType+`:`+e+`:`+r.count,c=t.cache.get(n);c||(f=new o(i,e*u,r.count*u/s),c=new ae(f,u/s),t.cache.add(n,c)),p=new te(c,a,l%u/s,d)}else f=i===null?new o(r.count*a):new o(i,l,r.count*a),p=new E(f,a,d);if(r.sparse!==void 0){let t=G.SCALAR,n=H[r.sparse.indices.componentType],s=r.sparse.indices.byteOffset||0,c=r.sparse.values.byteOffset||0,l=new n(e[1],s,r.sparse.count*t),u=new o(e[2],c,r.sparse.count*a);i!==null&&(p=new E(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=l.length;e<t;e++){let t=l[e];if(p.setX(t,u[e*a]),a>=2&&p.setY(t,u[e*a+1]),a>=3&&p.setZ(t,u[e*a+2]),a>=4&&p.setW(t,u[e*a+3]),a>=5)throw Error(`THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.`)}p.normalized=d}return p})}loadTexture(e){let t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r],a=this.textureLoader;if(i.uri){let e=n.manager.getHandler(i.uri);e!==null&&(a=e)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){let r=this,i=this.json,a=i.textures[e],o=i.images[t],s=(o.uri||o.bufferView)+`:`+a.sampler;if(this.textureCache[s])return this.textureCache[s];let c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=a.name||o.name||``,t.name===``&&typeof o.uri==`string`&&o.uri.startsWith(`data:image/`)===!1&&(t.name=o.uri);let n=(i.samplers||{})[a.sampler]||{};return t.magFilter=U[n.magFilter]||1006,t.minFilter=U[n.minFilter]||1008,t.wrapS=W[n.wrapS]||1e3,t.wrapT=W[n.wrapT]||1e3,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==1003&&t.minFilter!==1006,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=c,c}loadImageSource(e,t){let n=this,r=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(e=>e.clone());let a=r.images[e],o=self.URL||self.webkitURL,s=a.uri||``,c=!1,l;if(t.isKTX2Loader===!0&&a.bufferView!==void 0)l=n.getDependency(`bufferView`,a.bufferView).then(function(e){return new Promise(function(n,r){t.parse(e,n,r)})});else{if(a.bufferView!==void 0)s=n.getDependency(`bufferView`,a.bufferView).then(function(e){c=!0;let t=new Blob([e],{type:a.mimeType});return s=o.createObjectURL(t),s});else if(a.uri===void 0)throw Error(`THREE.GLTFLoader: Image `+e+` is missing URI and bufferView`);l=Promise.resolve(s).then(function(e){return new Promise(function(n,r){let a=n;t.isImageBitmapLoader===!0&&(a=function(e){let t=new x(e);t.needsUpdate=!0,n(t)}),t.load(O.resolveURL(e,i.path),a,void 0,r)})})}let u=l.then(function(e){return c===!0&&o.revokeObjectURL(s),X(e,a),e.userData.mimeType=a.mimeType||ot(a.uri),e}).catch(function(e){throw console.error(`THREE.GLTFLoader: Couldn't load texture`,s),e});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let i=this;return this.getDependency(`texture`,n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),i.extensions[F.KHR_TEXTURE_TRANSFORM]){let e=n.extensions===void 0?void 0:n.extensions[F.KHR_TEXTURE_TRANSFORM];if(e){let t=i.associations.get(a);a=i.extensions[F.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),i.associations.set(a,t)}}return r!==void 0&&(a.colorSpace=r),e[t]=a,a})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){let e=`PointsMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new s,j.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e=`LineBasicMaterial:`+n.uuid,t=this.cache.get(e);t||(t=new oe,j.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||i||a){let e=`ClonedMaterial:`+n.uuid+`:`;r&&(e+=`derivative-tangents:`),i&&(e+=`vertex-colors:`),a&&(e+=`flat-shading:`);let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return pe}loadMaterial(e){let t=this,n=this.json,r=this.extensions,a=n.materials[e],o,s={},c=a.extensions||{},l=[];if(c[F.KHR_MATERIALS_UNLIT]){let e=r[F.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),l.push(e.extendParams(s,a,t))}else{let n=a.pbrMetallicRoughness||{};if(s.color=new b(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],w),s.opacity=e[3]}n.baseColorTexture!==void 0&&l.push(t.assignTexture(s,`map`,n.baseColorTexture,D)),s.metalness=n.metallicFactor===void 0?1:n.metallicFactor,s.roughness=n.roughnessFactor===void 0?1:n.roughnessFactor,n.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(s,`metalnessMap`,n.metallicRoughnessTexture)),l.push(t.assignTexture(s,`roughnessMap`,n.metallicRoughnessTexture))),o=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)})))}a.doubleSided===!0&&(s.side=2);let u=a.alphaMode||J.OPAQUE;if(u===J.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,u===J.MASK&&(s.alphaTest=a.alphaCutoff===void 0?.5:a.alphaCutoff)),a.normalTexture!==void 0&&o!==i&&(l.push(t.assignTexture(s,`normalMap`,a.normalTexture)),s.normalScale=new p(1,1),a.normalTexture.scale!==void 0)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}if(a.occlusionTexture!==void 0&&o!==i&&(l.push(t.assignTexture(s,`aoMap`,a.occlusionTexture)),a.occlusionTexture.strength!==void 0&&(s.aoMapIntensity=a.occlusionTexture.strength)),a.emissiveFactor!==void 0&&o!==i){let e=a.emissiveFactor;s.emissive=new b().setRGB(e[0],e[1],e[2],w)}return a.emissiveTexture!==void 0&&o!==i&&l.push(t.assignTexture(s,`emissiveMap`,a.emissiveTexture,D)),Promise.all(l).then(function(){let n=new o(s);return a.name&&(n.name=a.name),X(n,a),t.associations.set(n,{materials:e}),a.extensions&&Y(r,n,a),n})}createUniqueName(e){let t=f.sanitizeNodeName(e||``);return t in this.nodeNamesUsed?t+`_`+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[F.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return $(n,e,t)})}let a=[];for(let n=0,o=e.length;n<o;n++){let o=e[n],s=at(o),c=r[s];if(c)a.push(c.promise);else{let e;e=o.extensions&&o.extensions[F.KHR_DRACO_MESH_COMPRESSION]?i(o):$(new T,o,t),o.mode===V.TRIANGLE_STRIP?e=e.then(e=>N(e,1)):o.mode===V.TRIANGLE_FAN&&(e=e.then(e=>N(e,2))),r[s]={primitive:o,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,n=this.json,r=this.extensions,i=n.meshes[e],a=i.primitives,o=[];for(let e=0,t=a.length;e<t;e++){let t=a[e].material===void 0?nt(this.cache):this.getDependency(`material`,a[e].material);o.push(t)}return o.push(t.loadGeometries(a)),Promise.all(o).then(async function(n){let o=n.slice(0,n.length-1),s=n[n.length-1],c=[];for(let n=0,l=s.length;n<l;n++){let l=s[n],u=a[n],d,f=o[n];if(u.mode===V.TRIANGLES||u.mode===V.TRIANGLE_STRIP||u.mode===V.TRIANGLE_FAN||u.mode===void 0){let e=i.isSkinnedMesh===!0,t=l.hasAttribute(`skinIndex`)&&l.hasAttribute(`skinWeight`);e&&t===!1&&console.warn(`THREE.GLTFLoader: Missing skinIndex or skinWeight attributes. Skinning disabled.`),d=e&&t?new he(l,f):new ne(l,f),d.isSkinnedMesh===!0&&d.normalizeSkinWeights()}else if(u.mode===V.LINES)d=new se(l,f);else if(u.mode===V.LINE_STRIP)d=new ye(l,f);else if(u.mode===V.LINE_LOOP)d=new xe(l,f);else if(u.mode===V.POINTS)d=new re(l,f);else throw Error(`THREE.GLTFLoader: Primitive mode unsupported: `+u.mode);Object.keys(d.geometry.morphAttributes).length>0&&it(d,i),d.name=t.createUniqueName(i.name||`mesh_`+e),X(d,i),u.extensions&&Y(r,d,u),t.assignFinalMaterial(d),c.push(d)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(c.length===1)return i.extensions&&Y(r,c[0],i),c[0];let l=new S;i.extensions&&Y(r,l,i),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r)console.warn(`THREE.GLTFLoader: Missing camera parameters.`);else return n.type===`perspective`?t=new De(Ee.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type===`orthographic`&&(t=new m(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),X(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return t.inverseBindMatrices===void 0?n.push(null):n.push(this.getDependency(`accessor`,t.inverseBindMatrices)),Promise.all(n).then(function(e){let n=e.pop(),r=e,i=[],a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e];if(o){i.push(o);let t=new M;n!==null&&t.fromArray(n.array,e*16),a.push(t)}else console.warn(`THREE.GLTFLoader: Joint "%s" could not be found.`,t.joints[e])}return new _e(i,a)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],i=r.name?r.name:`animation_`+e,a=[],o=[],s=[],c=[],l=[];for(let e=0,t=r.channels.length;e<t;e++){let t=r.channels[e],n=r.samplers[t.sampler],i=t.target,u=i.node,d=r.parameters===void 0?n.input:r.parameters[n.input],f=r.parameters===void 0?n.output:r.parameters[n.output];i.node!==void 0&&(a.push(this.getDependency(`node`,u)),o.push(this.getDependency(`accessor`,d)),s.push(this.getDependency(`accessor`,f)),c.push(n),l.push(i))}return Promise.all([Promise.all(a),Promise.all(o),Promise.all(s),Promise.all(c),Promise.all(l)]).then(function(e){let t=e[0],a=e[1],o=e[2],s=e[3],c=e[4],l=[];for(let e=0,r=t.length;e<r;e++){let r=t[e],i=a[e],u=o[e],d=s[e],f=c[e];if(r===void 0)continue;r.updateMatrix&&r.updateMatrix();let p=n._createAnimationTracks(r,i,u,d,f);if(p)for(let e=0;e<p.length;e++)l.push(p[e])}let u=new be(i,void 0,l);return X(u,r),u})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency(`mesh`,r.mesh).then(function(e){let t=n._getNodeRef(n.meshCache,r.mesh,e);return r.weights!==void 0&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],i=n._loadNodeShallow(e),a=[],o=r.children||[];for(let e=0,t=o.length;e<t;e++)a.push(n.getDependency(`node`,o[e]));let s=r.skin===void 0?Promise.resolve(null):n.getDependency(`skin`,r.skin);return Promise.all([i,Promise.all(a),s]).then(function(e){let t=e[0],n=e[1],r=e[2];r!==null&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,st)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);if(t.userData.pivot!==void 0&&n.length>0){let e=t.userData.pivot,r=n[0];t.pivot=new y().fromArray(e),t.position.x-=e[0],t.position.y-=e[1],t.position.z-=e[2],r.position.set(0,0,0),delete t.userData.pivot}return t})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let i=t.nodes[e],a=i.name?r.createUniqueName(i.name):``,s=[],c=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&s.push(c),i.camera!==void 0&&s.push(r.getDependency(`camera`,i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){s.push(e)}),this.nodeCache[e]=Promise.all(s).then(function(t){let s;if(s=i.isBone===!0?new Se:t.length>1?new S:t.length===1?t[0]:new o,s!==t[0])for(let e=0,n=t.length;e<n;e++)s.add(t[e]);if(i.name&&(s.userData.name=i.name,s.name=a),X(s,i),i.extensions&&Y(n,s,i),i.matrix!==void 0){let e=new M;e.fromArray(i.matrix),s.applyMatrix4(e)}else i.translation!==void 0&&s.position.fromArray(i.translation),i.rotation!==void 0&&s.quaternion.fromArray(i.rotation),i.scale!==void 0&&s.scale.fromArray(i.scale);if(!r.associations.has(s))r.associations.set(s,{});else if(i.mesh!==void 0&&r.meshCache.refs[i.mesh]>1){let e=r.associations.get(s);r.associations.set(s,{...e})}return r.associations.get(s).nodes=e,s}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,i=new S;n.name&&(i.name=r.createUniqueName(n.name)),X(i,n),n.extensions&&Y(t,i,n);let a=n.nodes||[],o=[];for(let e=0,t=a.length;e<t;e++)o.push(r.getDependency(`node`,a[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++){let n=e[t];n.parent===null?i.add(n):i.add(Oe(n))}return r.associations=(e=>{let t=new Map;for(let[e,n]of r.associations)(e instanceof j||e instanceof x)&&t.set(e,n);return e.traverse(e=>{let n=r.associations.get(e);n!=null&&t.set(e,n)}),t})(i),i})}_createAnimationTracks(e,t,r,i,a){let o=[],s=e.name?e.name:e.uuid,c=[];function l(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}q[a.path]===q.weights?(l(e),e.isGroup&&e.children.forEach(l)):c.push(s);let u;switch(q[a.path]){case q.weights:u=ee;break;case q.rotation:u=d;break;case q.translation:case q.scale:u=n;break;default:switch(r.itemSize){case 1:u=ee;break;default:u=n}}let f=i.interpolation===void 0?A:tt[i.interpolation],p=this._getArrayFromAccessor(r);for(let e=0,n=c.length;e<n;e++){let n=new u(c[e]+`.`+q[a.path],t.array,p,f);i.interpolation===`CUBICSPLINE`&&this._createCubicSplineTrackInterpolant(n),o.push(n)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=Q(t.constructor),n=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof d?et:B)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function lt(e,t,n){let r=t.attributes,i=new ue;if(r.POSITION!==void 0){let e=n.json.accessors[r.POSITION],t=e.min,a=e.max;if(t!==void 0&&a!==void 0){if(i.set(new y(t[0],t[1],t[2]),new y(a[0],a[1],a[2])),e.normalized){let t=Q(H[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}else{console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`);return}}else return;let a=t.targets;if(a!==void 0){let e=new y,t=new y;for(let r=0,i=a.length;r<i;r++){let i=a[r];if(i.POSITION!==void 0){let r=n.json.accessors[i.POSITION],a=r.min,o=r.max;if(a!==void 0&&o!==void 0){if(t.setX(Math.max(Math.abs(a[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(a[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(a[2]),Math.abs(o[2]))),r.normalized){let e=Q(H[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn(`THREE.GLTFLoader: Missing min/max properties for accessor POSITION.`)}}i.expandByVector(e)}e.boundingBox=i;let o=new de;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}function $(e,t,n){let i=t.attributes,a=[];function o(t,r){return n.getDependency(`accessor`,t).then(function(t){e.setAttribute(r,t)})}for(let t in i){let n=K[t]||t.toLowerCase();n in e.attributes||a.push(o(i[t],n))}if(t.indices!==void 0&&!e.index){let r=n.getDependency(`accessor`,t.indices).then(function(t){e.setIndex(t)});a.push(r)}return r.workingColorSpace!==`srgb-linear`&&`COLOR_0`in i&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${r.workingColorSpace}" not supported.`),X(e,t),lt(e,t,n),Promise.all(a).then(function(){return t.targets===void 0?e:rt(e,t.targets,n)})}export{ke as GLTFLoader};
@@ -1 +0,0 @@
1
- import{Ct as e,Rn as t,St as n,gn as r}from"./three.module-ByMn_ZTv.js";var i=class extends n{constructor(n,i,a,o=128){if(i<=0||a<=0||o<=0)throw Error(`THREE.GroundedSkybox: height, radius, and resolution must be positive.`);let s=new r(a,2*o,o);s.scale(1,1,-1);let c=s.getAttribute(`position`),l=new t;for(let e=0;e<c.count;++e)if(l.fromBufferAttribute(c,e),l.y<0){let t=-i*3/2,n=l.y<t?-i/l.y:1-l.y*l.y/(3*t*t);l.multiplyScalar(n),l.toArray(c.array,3*e)}c.needsUpdate=!0,super(s,new e({map:n,depthWrite:!1}))}};export{i as GroundedSkybox};
@@ -1 +0,0 @@
1
- import{OrbitControls as e}from"./OrbitControls-fcOgB96a.js";import{$t as t,Bt as n,Ct as r,Dn as i,E as a,Ft as o,It as s,L as c,Ln as l,Lt as u,P as d,Rn as f,St as p,T as m,Ut as h,Vt as g,at as _,bn as v,ct as y,f as b,g as x,gn as ee,h as S,hn as C,m as w,on as T,ot as E,p as D,qt as O,rt as k,xt as A,yt as j,zt as M}from"./three.module-ByMn_ZTv.js";import{r as te}from"./camera-BhKdE9ej.js";import{a as N,i as P,n as ne,o as re}from"./index-Dh-2Y34U.js";var F=new t,I=new f,L=new f,R=new O,ie={X:new f(1,0,0),Y:new f(0,1,0),Z:new f(0,0,1)},z={type:`change`},ae={type:`mouseDown`,mode:null},oe={type:`mouseUp`,mode:null},se={type:`objectChange`},ce=class extends m{constructor(e,t=null){super(void 0,t);let n=new ge(this);this._root=n;let r=new _e;this._gizmo=r,n.add(r);let i=new ve;this._plane=i,n.add(i);let a=this;function o(e,t){let n=t;Object.defineProperty(a,e,{get:function(){return n===void 0?t:n},set:function(t){n!==t&&(n=t,i[e]=t,r[e]=t,a.dispatchEvent({type:e+`-changed`,value:t}),a.dispatchEvent(z))}}),a[e]=t,i[e]=t,r[e]=t}o(`camera`,e),o(`object`,void 0),o(`enabled`,!0),o(`axis`,null),o(`mode`,`translate`),o(`translationSnap`,null),o(`rotationSnap`,null),o(`scaleSnap`,null),o(`space`,`world`),o(`size`,1),this.viewport=null,o(`dragging`,!1),o(`showX`,!0),o(`showY`,!0),o(`showZ`,!0),o(`showXY`,!0),o(`showYZ`,!0),o(`showXZ`,!0),o(`showXYZE`,!0),o(`showE`,!0),o(`minX`,-1/0),o(`maxX`,1/0),o(`minY`,-1/0),o(`maxY`,1/0),o(`minZ`,-1/0),o(`maxZ`,1/0);let s=new f,c=new f,l=new O,u=new O,d=new f,p=new O,m=new f,h=new f,g=new f,_=new f;o(`worldPosition`,s),o(`worldPositionStart`,c),o(`worldQuaternion`,l),o(`worldQuaternionStart`,u),o(`cameraPosition`,d),o(`cameraQuaternion`,p),o(`pointStart`,m),o(`pointEnd`,h),o(`rotationAxis`,g),o(`rotationAngle`,0),o(`eye`,_),this._offset=new f,this._startNorm=new f,this._endNorm=new f,this._cameraScale=new f,this._parentPosition=new f,this._parentQuaternion=new O,this._parentQuaternionInv=new O,this._parentScale=new f,this._worldScaleStart=new f,this._worldQuaternionInv=new O,this._worldScale=new f,this._positionStart=new f,this._quaternionStart=new O,this._scaleStart=new f,this._getPointer=le.bind(this),this._onPointerDown=de.bind(this),this._onPointerHover=ue.bind(this),this._onPointerMove=fe.bind(this),this._onPointerUp=pe.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointermove`,this._onPointerHover),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerHover),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=``}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&F.setFromCamera(e,this.camera);let t=B(this._gizmo.picker[this.mode],F);this.axis=t?t.object.name:null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&F.setFromCamera(e,this.camera);let t=B(this._plane,F,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,ae.mode=this.mode,this.dispatchEvent(ae)}}pointerMove(e){let t=this.axis,n=this.mode,r=this.object,i=this.space;if(n===`scale`?i=`local`:(t===`E`||t===`XYZE`||t===`XYZ`)&&(i=`world`),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&F.setFromCamera(e,this.camera);let a=B(this._plane,F,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n===`translate`)this._offset.copy(this.pointEnd).sub(this.pointStart),i===`local`&&t!==`XYZ`&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf(`X`)===-1&&(this._offset.x=0),t.indexOf(`Y`)===-1&&(this._offset.y=0),t.indexOf(`Z`)===-1&&(this._offset.z=0),i===`local`&&t!==`XYZ`?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i===`local`&&(r.position.applyQuaternion(R.copy(this._quaternionStart).invert()),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i===`world`&&(r.getWorldPosition(I),t.search(`X`)!==-1&&(I.x=Math.round(I.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(I.y=Math.round(I.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(I.z=Math.round(I.z/this.translationSnap)*this.translationSnap),r.position.copy(r.parent.worldToLocal(I)))),r.position.x=Math.max(this.minX,Math.min(this.maxX,r.position.x)),r.position.y=Math.max(this.minY,Math.min(this.maxY,r.position.y)),r.position.z=Math.max(this.minZ,Math.min(this.maxZ,r.position.z));else if(n===`scale`){if(t.search(`XYZ`)!==-1){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),L.set(e,e,e)}else I.copy(this.pointStart),L.copy(this.pointEnd),I.applyQuaternion(this._worldQuaternionInv),L.applyQuaternion(this._worldQuaternionInv),L.divide(I),t.search(`X`)===-1&&(L.x=1),t.search(`Y`)===-1&&(L.y=1),t.search(`Z`)===-1&&(L.z=1);r.scale.copy(this._scaleStart).multiply(L),this.scaleSnap&&(t.search(`X`)!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Y`)!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Z`)!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n===`rotate`){this._offset.copy(this.pointEnd).sub(this.pointStart);let e=20/this.worldPosition.distanceTo(I.setFromMatrixPosition(this.camera.matrixWorld)),n=!1;t===`XYZE`?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(I.copy(this.rotationAxis).cross(this.eye))*e):(t===`X`||t===`Y`||t===`Z`)&&(this.rotationAxis.copy(ie[t]),I.copy(ie[t]),i===`local`&&I.applyQuaternion(this.worldQuaternion),I.cross(this.eye),I.length()===0?n=!0:this.rotationAngle=this._offset.dot(I.normalize())*e),(t===`E`||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i===`local`&&t!==`E`&&t!==`XYZE`?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(R.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(R.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(z),this.dispatchEvent(se)}}pointerUp(e){(e===null||e.button===0)&&(this.dragging&&this.axis!==null&&(oe.mode=this.mode,this.dispatchEvent(oe)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(z),this.dispatchEvent(se),this.pointStart.copy(this.pointEnd))}getRaycaster(){return F}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,r){let i=this._gizmo.materialLib;i.xAxis.color.set(e),i.yAxis.color.set(t),i.zAxis.color.set(n),i.active.color.set(r),i.xAxisTransparent.color.set(e),i.yAxisTransparent.color.set(t),i.zAxisTransparent.color.set(n),i.activeTransparent.color.set(r),i.xAxis._color&&i.xAxis._color.set(e),i.yAxis._color&&i.yAxis._color.set(t),i.zAxis._color&&i.zAxis._color.set(n),i.active._color&&i.active._color.set(r),i.xAxisTransparent._color&&i.xAxisTransparent._color.set(e),i.yAxisTransparent._color&&i.yAxisTransparent._color.set(t),i.zAxisTransparent._color&&i.zAxisTransparent._color.set(n),i.activeTransparent._color&&i.activeTransparent._color.set(r)}};function le(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{let t=this.domElement.getBoundingClientRect(),n=this.viewport,r,i,a,o;return n===null?(r=0,i=0,a=t.width,o=t.height):(r=n.x,i=t.height-n.y-n.w,a=n.z,o=n.w),{x:(e.clientX-t.left-r)/a*2-1,y:-(e.clientY-t.top-i)/o*2+1,button:e.button}}}function ue(e){if(this.enabled)switch(e.pointerType){case`mouse`:case`pen`:this.pointerHover(this._getPointer(e))}}function de(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function fe(e){this.enabled&&this.pointerMove(this._getPointer(e))}function pe(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.pointerUp(this._getPointer(e)))}function B(e,t,n){let r=t.intersectObject(e,!0);for(let e=0;e<r.length;e++)if(r[e].object.visible||n)return r[e];return!1}var V=new d,H=new f(0,1,0),me=new f(0,0,0),he=new A,U=new O,W=new O,G=new f,K=new A,q=new f(1,0,0),J=new f(0,1,0),Y=new f(0,0,1),X=new f,Z=new f,Q=new f,ge=class extends o{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){let t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error(`TransformControls: The attached 3D object must be a part of the scene graph.`):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),this.parent&&(K.copy(this.parent.matrixWorld).invert(),K.decompose(this.position,this.quaternion,this.scale)),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}},_e=class extends o{constructor(){super(),this.isTransformControlsGizmo=!0,this.type=`TransformControlsGizmo`;let e=new r({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new _({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;let l=t.clone();l.opacity=.5;let u=e.clone();u.color.setHex(16711680);let d=e.clone();d.color.setHex(65280);let f=e.clone();f.color.setHex(255);let m=e.clone();m.color.setHex(16711680),m.opacity=.5;let h=e.clone();h.color.setHex(65280),h.opacity=.5;let g=e.clone();g.color.setHex(255),g.opacity=.5;let v=e.clone();v.opacity=.25;let y=e.clone();y.color.setHex(16776960),y.opacity=.25;let b=e.clone();b.color.setHex(16776960);let S=e.clone();S.color.setHex(7895160),this.materialLib={xAxis:u,yAxis:d,zAxis:f,active:b,xAxisTransparent:m,yAxisTransparent:h,zAxisTransparent:g,activeTransparent:y};let C=new a(0,.04,.1,12);C.translate(0,.05,0);let T=new w(.08,.08,.08);T.translate(0,.04,0);let E=new x;E.setAttribute(`position`,new c([0,0,0,1,0,0],3));let D=new a(.0075,.0075,.5,3);D.translate(0,.25,0);function O(e,t){let n=new i(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}function A(){let e=new x;return e.setAttribute(`position`,new c([0,0,0,1,1,1],3)),e}let j={X:[[new p(C,u),[.5,0,0],[0,0,-Math.PI/2]],[new p(C,u),[-.5,0,0],[0,0,Math.PI/2]],[new p(D,u),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new p(C,d),[0,.5,0]],[new p(C,d),[0,-.5,0],[Math.PI,0,0]],[new p(D,d)]],Z:[[new p(C,f),[0,0,.5],[Math.PI/2,0,0]],[new p(C,f),[0,0,-.5],[-Math.PI/2,0,0]],[new p(D,f),null,[Math.PI/2,0,0]]],XYZ:[[new p(new s(.1,0),v),[0,0,0]]],XY:[[new p(new w(.15,.15,.01),g),[.15,.15,0]]],YZ:[[new p(new w(.15,.15,.01),m),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new p(new w(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new p(new a(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new p(new a(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new p(new a(.2,0,.6,4),n),[0,.3,0]],[new p(new a(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new p(new a(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new p(new a(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new p(new s(.2,0),n)]],XY:[[new p(new w(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new p(new w(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new p(new w(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},te={START:[[new p(new s(.01,2),l),null,null,null,`helper`]],END:[[new p(new s(.01,2),l),null,null,null,`helper`]],DELTA:[[new k(A(),l),null,null,null,`helper`]],X:[[new k(E,l),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new k(E,l),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new k(E,l),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},N={XYZE:[[new p(O(.5,1),S),null,[0,Math.PI/2,0]]],X:[[new p(O(.5,.5),u)]],Y:[[new p(O(.5,.5),d),null,[0,0,-Math.PI/2]]],Z:[[new p(O(.5,.5),f),null,[0,Math.PI/2,0]]],E:[[new p(O(.75,1),y),null,[0,Math.PI/2,0]]]},P={AXIS:[[new k(E,l),[-1e3,0,0],null,[1e6,1,1],`helper`]]},ne={XYZE:[[new p(new ee(.25,10,8),n)]],X:[[new p(new i(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new p(new i(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new p(new i(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new p(new i(.75,.1,2,24),n)]]},re={X:[[new p(T,u),[.5,0,0],[0,0,-Math.PI/2]],[new p(D,u),[0,0,0],[0,0,-Math.PI/2]],[new p(T,u),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new p(T,d),[0,.5,0]],[new p(D,d)],[new p(T,d),[0,-.5,0],[0,0,Math.PI]]],Z:[[new p(T,f),[0,0,.5],[Math.PI/2,0,0]],[new p(D,f),[0,0,0],[Math.PI/2,0,0]],[new p(T,f),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new p(new w(.15,.15,.01),g),[.15,.15,0]]],YZ:[[new p(new w(.15,.15,.01),m),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new p(new w(.15,.15,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new p(new w(.1,.1,.1),v)]]},F={X:[[new p(new a(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new p(new a(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new p(new a(.2,0,.6,4),n),[0,.3,0]],[new p(new a(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new p(new a(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new p(new a(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new p(new w(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new p(new w(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new p(new w(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new p(new w(.2,.2,.2),n),[0,0,0]]]},I={X:[[new k(E,l),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new k(E,l),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new k(E,l),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]};function L(e){let t=new o;for(let n in e)for(let r=e[n].length;r--;){let i=e[n][r][0].clone(),a=e[n][r][1],o=e[n][r][2],s=e[n][r][3],c=e[n][r][4];i.name=n,i.tag=c,a&&i.position.set(a[0],a[1],a[2]),o&&i.rotation.set(o[0],o[1],o[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix();let l=i.geometry.clone();l.applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),t.add(i)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=L(j)),this.add(this.gizmo.rotate=L(N)),this.add(this.gizmo.scale=L(re)),this.add(this.picker.translate=L(M)),this.add(this.picker.rotate=L(ne)),this.add(this.picker.scale=L(F)),this.add(this.helper.translate=L(te)),this.add(this.helper.rotate=L(P)),this.add(this.helper.scale=L(I)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){let t=(this.mode===`scale`?`local`:this.space)===`local`?this.worldQuaternion:W;this.gizmo.translate.visible=this.mode===`translate`,this.gizmo.rotate.visible=this.mode===`rotate`,this.gizmo.scale.visible=this.mode===`scale`,this.helper.translate.visible=this.mode===`translate`,this.helper.rotate.visible=this.mode===`rotate`,this.helper.scale.visible=this.mode===`scale`;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e<n.length;e++){let r=n[e];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let i;if(i=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(i*this.size/4),r.tag===`helper`)r.visible=!1,r.name===`AXIS`?(r.visible=!!this.axis,this.axis===`X`&&(R.setFromEuler(V.set(0,0,0)),r.quaternion.copy(t).multiply(R),Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Y`&&(R.setFromEuler(V.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(R),Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Z`&&(R.setFromEuler(V.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(R),Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`XYZE`&&(R.setFromEuler(V.set(0,Math.PI/2,0)),H.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(he.lookAt(me,H,J)),r.quaternion.multiply(R),r.visible=this.dragging),this.axis===`E`&&(r.visible=!1)):r.name===`START`?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name===`END`?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name===`DELTA`?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),I.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),I.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(I),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));else{if(r.quaternion.copy(t),this.mode===`translate`||this.mode===`scale`){let e=.99,n=.2;r.name===`X`&&Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Y`&&Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Z`&&Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XY`&&Math.abs(H.copy(Y).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`YZ`&&Math.abs(H.copy(q).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XZ`&&Math.abs(H.copy(J).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)}else this.mode===`rotate`&&(U.copy(t),H.copy(this.eye).applyQuaternion(R.copy(t).invert()),r.name.search(`E`)!==-1&&r.quaternion.setFromRotationMatrix(he.lookAt(this.eye,me,J)),r.name===`X`&&(R.setFromAxisAngle(q,Math.atan2(-H.y,H.z)),R.multiplyQuaternions(U,R),r.quaternion.copy(R)),r.name===`Y`&&(R.setFromAxisAngle(J,Math.atan2(H.x,H.z)),R.multiplyQuaternions(U,R),r.quaternion.copy(R)),r.name===`Z`&&(R.setFromAxisAngle(Y,Math.atan2(H.y,H.x)),R.multiplyQuaternions(U,R),r.quaternion.copy(R)));r.visible=r.visible&&(r.name.indexOf(`X`)===-1||this.showX),r.visible=r.visible&&(r.name.indexOf(`Y`)===-1||this.showY),r.visible=r.visible&&(r.name.indexOf(`Z`)===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf(`E`)===-1||this.showX&&this.showY&&this.showZ),r.visible=r.visible&&(r.name.indexOf(`XY`)===-1||this.showXY),r.visible=r.visible&&(r.name.indexOf(`YZ`)===-1||this.showYZ),r.visible=r.visible&&(r.name.indexOf(`XZ`)===-1||this.showXZ),r.visible=r.visible&&(r.name!==`E`||this.showE),r.visible=r.visible&&(r.name!==`XYZE`||this.showXYZE),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split(``).some(function(e){return r.name===e}))&&(r.material.color.copy(this.materialLib.active.color),r.material.opacity=1)}}super.updateMatrixWorld(e)}},ve=class extends p{constructor(){super(new g(1e5,1e5,2,2),new r({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type=`TransformControlsPlane`}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode===`scale`&&(t=`local`),X.copy(q).applyQuaternion(t===`local`?this.worldQuaternion:W),Z.copy(J).applyQuaternion(t===`local`?this.worldQuaternion:W),Q.copy(Y).applyQuaternion(t===`local`?this.worldQuaternion:W),H.copy(Z),this.mode){case`translate`:case`scale`:switch(this.axis){case`X`:H.copy(this.eye).cross(X),G.copy(X).cross(H);break;case`Y`:H.copy(this.eye).cross(Z),G.copy(Z).cross(H);break;case`Z`:H.copy(this.eye).cross(Q),G.copy(Q).cross(H);break;case`XY`:G.copy(Q);break;case`YZ`:G.copy(X);break;case`XZ`:H.copy(Q),G.copy(Z);break;case`XYZ`:case`E`:G.set(0,0,0)}break;default:G.set(0,0,0)}G.length()===0?this.quaternion.copy(this.cameraQuaternion):(K.lookAt(I.set(0,0,0),G,H),this.quaternion.setFromRotationMatrix(K)),super.updateMatrixWorld(e)}},ye=8162559,$=e=>[e.x,e.y,e.z];function be(e){for(let t=e;t;t=t.parent)if(!t.visible)return!1;return!0}function xe(e){let t=/^\s*([\d.]+)\s*[:/x]\s*([\d.]+)\s*$/.exec(e.def.target?.aspect??``),n=t?Number(t[1])/Number(t[2]):16/9;return Number.isFinite(n)&&n>0?n:16/9}var Se=class{overlay=new T;bridge;dom;opts;tc;orbit;proxy=new o;editorCam=new M(45,16/9,.05,5e3);sceneCamPose=new A;frustumCam=new M;frustumOrtho=new u;frustum;frustumFill;box=new b;boxHelper;lights=[];handleGeo=new ee(1,16,12);targetGeo=new s(1,0);raycaster=new t;world=null;selection=null;mode=`translate`;snapOn=!1;snap={...ne};shift=!1;view=`editor`;enabled=!0;helpersOn=!0;dragStart=null;dragStartPoint=null;dragged=!1;down=null;raf=0;poseInit=!1;offWorld;disposed=!1;constructor(t){this.opts=t,this.bridge=t.bridge,this.dom=t.dom,this.overlay.add(this.proxy),this.tc=new ce(this.editorCam,this.dom),this.tc.setSize(1.25),this.tc.addEventListener(`dragging-changed`,e=>{let t=!!e.value;this.orbit.enabled=!t&&this.view===`editor`&&this.enabled,t?this.beginDrag():this.endDrag()}),this.tc.addEventListener(`objectChange`,()=>this.onGizmoChange()),this.tc.addEventListener(`change`,()=>this.requestRender()),this.overlay.add(this.tc.getHelper()),this.orbit=new e(this.editorCam,this.dom),this.orbit.enableDamping=!1,this.orbit.screenSpacePanning=!0,this.orbit.rotateSpeed=.55,this.orbit.panSpeed=.9,this.orbit.addEventListener(`change`,()=>{this.requestRender(),this.opts.onCameraChange?.(this.pose())}),t.initialPose&&(this.applyPose(t.initialPose),this.poseInit=!0),this.boxHelper=new D(this.box,ye);let n=this.boxHelper.material;n.depthTest=!1,n.transparent=!0,n.opacity=.9,n.toneMapped=!1,this.boxHelper.visible=!1,this.overlay.add(this.boxHelper),this.frustum=new y(new x().setAttribute(`position`,new S(new Float32Array(84),3)),new _({color:15906388,depthTest:!1,transparent:!0,opacity:.9,toneMapped:!1})),this.frustum.frustumCulled=!1,this.frustumFill=new p(new x().setAttribute(`position`,new S(new Float32Array(18),3)),new r({color:15906388,depthTest:!1,transparent:!0,opacity:.07,side:2,toneMapped:!1})),this.frustumFill.frustumCulled=!1,this.overlay.add(this.frustum,this.frustumFill),this.dom.addEventListener(`pointerdown`,this.onDown),this.dom.addEventListener(`pointerup`,this.onUp),this.dom.addEventListener(`contextmenu`,this.onContext),window.addEventListener(`keydown`,this.onKey),window.addEventListener(`keyup`,this.onKey),window.addEventListener(`blur`,this.onBlur),this.offWorld=this.bridge.onWorld(()=>this.attachWorld()),this.bridge.setOverlay({viewCamera:()=>this.viewCamera(),draw:(e,t)=>this.draw(e,t)}),this.attachWorld()}setSelection(e){let t=JSON.stringify(e)===JSON.stringify(this.selection);this.selection=e,!t&&this.tc.dragging&&this.tc.detach(),this.updateAttachment(),this.requestRender()}setMode(e){this.mode=e,this.updateAttachment(),this.requestRender()}setSpace(e){this.tc.setSpace(e),this.requestRender()}setSnap(e,t){this.snapOn=e,t&&(this.snap={...this.snap,...t}),this.applySnap()}setView(e){this.view=e,this.tc.camera=this.activeCamera(),this.orbit.enabled=e===`editor`&&this.enabled&&!this.tc.dragging,this.requestRender()}setEnabled(e){this.enabled=e,this.tc.enabled=e,this.orbit.enabled=e&&this.view===`editor`,this.updateAttachment(),this.requestRender()}setHelpers(e){this.helpersOn=e,this.requestRender()}pose(){return{position:$(this.editorCam.position),target:$(this.orbit.target)}}sceneCameraPose(){let e=this.world;return e?{position:$(e.rig.rest.position),target:$(e.rig.rest.target)}:null}resetToSceneCamera(){let e=this.sceneCameraPose();e&&(this.applyPose(e),this.opts.onCameraChange?.(this.pose()),this.requestRender())}frameSelection(){let e=this.world;if(!e)return!1;let t,n,r=this.selection;if(r?.kind===`object`){let i=e.entries.get(r.id);if(!i)return!1;if(this.box.setFromObject(i.object),this.box.isEmpty())t=$(i.object.getWorldPosition(new f)),n=1;else{let e=this.box.getBoundingSphere(new C);t=$(e.center),n=e.radius}}else if(r?.kind===`light`){let e=this.lights.find(e=>e.id===r.id);if(!e)return!1;t=$((r.part===`target`&&e.targetHandle?e.targetHandle:e.handle).position),n=1.5}else{let r=new b;for(let t of e.entries.values())t.topLevel&&t.kind!==`particles`&&r.union(new b().setFromObject(t.object));if(r.isEmpty())return!1;let i=r.getBoundingSphere(new C);t=$(i.center),n=i.radius}let i=this.editorCam,a=i.isPerspectiveCamera?i.fov:45,o=i.aspect??1,s=N(t,n,$(i.position),a,o);if(this.applyPose(s),i.isOrthographicCamera){let e=i;e.zoom=Math.max(.05,(e.top-e.bottom)/(n*2.4)),e.updateProjectionMatrix()}return this.opts.onCameraChange?.(this.pose()),this.requestRender(),!0}objectBox(e){let t=this.world?.entries.get(e);if(!t)return null;let n=new b().setFromObject(t.object);return n.isEmpty()?null:{min:$(n.min),max:$(n.max)}}dropPoint(e,t){let r=this.world,i=this.activeCamera();if(i.updateMatrixWorld(),this.raycaster.setFromCamera(new l(e,t),i),r){let e=[...r.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`&&e.kind!==`particles`).map(e=>e.object),t=this.raycaster.intersectObjects(e,!0).find(e=>be(e.object)&&!e.object.isPoints);if(t)return $(t.point)}let a=new n(new f(0,1,0),0),o=new f,s=this.raycaster.ray;return s.intersectPlane(a,o)&&o.distanceTo(s.origin)<200?$(o):$(s.at(6,o))}pick(e,t){let n=this.world;if(!n)return null;let r=this.activeCamera();if(r.updateMatrixWorld(),this.raycaster.setFromCamera(new l(e,t),r),this.helpersOn){let e=this.lights.flatMap(e=>e.targetHandle?[e.handle,e.targetHandle]:[e.handle]).filter(e=>e.visible),t=this.raycaster.intersectObjects(e,!1)[0];if(t)return{light:t.object.userData.lightId,part:t.object.userData.part}}let i=[...n.entries.values()].filter(e=>e.topLevel&&e.kind!==`light`).map(e=>e.object),a=this.raycaster.intersectObjects(i,!0).find(e=>be(e.object)&&!e.object.isPoints);if(!a)return null;let o=n.idsFor(a.object);return o.length?{chain:o}:null}dispose(){this.disposed||(this.disposed=!0,cancelAnimationFrame(this.raf),this.offWorld(),this.bridge.setOverlay(null),this.dom.removeEventListener(`pointerdown`,this.onDown),this.dom.removeEventListener(`pointerup`,this.onUp),this.dom.removeEventListener(`contextmenu`,this.onContext),window.removeEventListener(`keydown`,this.onKey),window.removeEventListener(`keyup`,this.onKey),window.removeEventListener(`blur`,this.onBlur),this.tc.detach(),this.tc.dispose(),this.orbit.dispose(),this.clearLights(),this.handleGeo.dispose(),this.targetGeo.dispose(),this.frustum.geometry.dispose(),this.frustum.material.dispose(),this.frustumFill.geometry.dispose(),this.frustumFill.material.dispose(),this.boxHelper.dispose())}activeCamera(){return this.view===`camera`&&this.world?this.world.camera:this.editorCam}applyPose(e){this.editorCam.position.set(...e.position),this.orbit.target.set(...e.target),this.editorCam.lookAt(this.orbit.target),this.editorCam.updateMatrixWorld(),this.orbit.update()}requestRender(){this.disposed||this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.bridge.running()||this.bridge.render()}))}attachWorld(){let e=this.bridge.world();if(this.world=e,!e)return;let t=e.camera.isOrthographicCamera;if(t!==!!this.editorCam.isOrthographicCamera){let e=this.pose();this.editorCam=t?new u(-1,1,1,-1,.05,5e3):new M(45,16/9,.05,5e3),this.orbit.object=this.editorCam,this.poseInit&&this.applyPose(e)}if(!this.poseInit){let e=this.sceneCameraPose();e&&(this.applyPose(e),this.poseInit=!0)}this.tc.camera=this.activeCamera(),this.buildLights(e),this.tc.dragging&&this.tc.detach(),this.updateAttachment()}clearLights(){for(let e of this.lights)for(let t of[e.handle,e.targetHandle,e.line,e.helper]){if(!t)continue;t.removeFromParent();let n=t.material;t!==e.handle&&t!==e.targetHandle&&t.geometry?.dispose(),n?.dispose?.(),t.dispose?.()}this.lights=[]}buildLights(e){this.clearLights();for(let t of e.entries.values()){if(t.kind!==`light`)continue;let e=t.object,n=t.def.type;if(n===`ambient`||n===`hemisphere`)continue;let i=e.color.clone(),a=(e,n)=>{let a=new p(e,new r({color:n===`position`?i:16777215,depthTest:!1,transparent:!0,opacity:n===`position`?1:.85,toneMapped:!1}));return a.userData={lightId:t.id,part:n},a.renderOrder=10,this.overlay.add(a),a},o=a(this.handleGeo,`position`),s=n===`directional`||n===`spot`||n===`rect`,c=s?a(this.targetGeo,`target`):null,l=null;if(s){let e=new x().setFromPoints([new f,new f(0,-1,0)]);l=new k(e,new E({color:16777215,dashSize:.15,gapSize:.1,depthTest:!1,transparent:!0,opacity:.55,toneMapped:!1})),this.overlay.add(l)}let u=null;n===`spot`?u=new v(e,i):n===`point`&&e.distance>0&&(u=new h(e,Math.min(e.distance*.08,.6),i)),u&&(u.traverse(e=>{let t=e.material;t&&Object.assign(t,{depthTest:!1,transparent:!0,opacity:.45,toneMapped:!1})}),this.overlay.add(u)),this.lights.push({id:t.id,light:e,handle:o,targetHandle:c,line:l,helper:u})}}selectedEntry(){let e=this.selection;return!e||!this.world?null:this.world.entries.get(e.id)??null}updateAttachment(){let e=this.selection,t=this.selectedEntry();!this.enabled||!e||!t||e.kind===`light`!=(t.kind===`light`)?this.tc.object&&!this.tc.dragging&&this.tc.detach():(this.tc.setMode(e.kind===`light`?`translate`:this.mode),this.applySnap(),this.tc.dragging||this.syncProxy(),this.tc.object!==this.proxy&&this.tc.attach(this.proxy))}snapping(){return this.snapOn!==this.shift}applySnap(){this.tc.setRotationSnap(this.snapping()?j.degToRad(this.snap.rotate):null),this.tc.setTranslationSnap(null),this.tc.setScaleSnap(null)}syncProxy(){let e=this.selection,t=this.selectedEntry();if(e&&t){if(e.kind===`light`){let n=t.object,r=e.part===`target`&&n.target?n.target.position:t.rest.position;this.proxy.position.copy(r),this.proxy.quaternion.identity(),this.proxy.scale.set(1,1,1)}else{let e=t.object.parent;e?.updateWorldMatrix(!0,!1);let n=new A().compose(t.rest.position,t.rest.quaternion,t.rest.scale);(e?new A().multiplyMatrices(e.matrixWorld,n):n).decompose(this.proxy.position,this.proxy.quaternion,this.proxy.scale)}this.proxy.updateMatrixWorld(!0)}}restLocal(e){let t=e.def,n=[t.rotation?.[0]??0,t.rotation?.[1]??0,t.rotation?.[2]??0];return{position:$(e.rest.position),rotation:n,scale:$(e.rest.scale)}}beginDrag(){let e=this.selectedEntry(),t=this.selection;if(this.dragged=!0,e&&t){if(t.kind===`light`){let n=e.object;this.dragStartPoint=$(t.part===`target`&&n.target?n.target.position:e.rest.position),this.dragStart=null}else this.dragStart=this.restLocal(e),this.dragStartPoint=null}}current(){let e=this.selectedEntry(),t=this.selection;if(!e||!t)return null;if(this.proxy.updateMatrixWorld(!0),t.kind===`light`){if(!this.dragStartPoint)return null;let e=$(this.proxy.position),t=this.snap.translate;return{point:(this.snapping()?e.map((e,n)=>Math.abs(e-this.dragStartPoint[n])>1e-6?Math.round(e/t)*t:this.dragStartPoint[n]):e).map(e=>Math.round(e*1e3)/1e3||0)}}if(!this.dragStart)return null;let n=e.object.parent;n?.updateWorldMatrix(!0,!1);let r=re(this.proxy.matrixWorld,n?n.matrixWorld:null,this.dragStart);return{transform:P(this.dragStart,r,this.tc.mode,this.snapping()?this.snap:null)}}onGizmoChange(){let e=this.selectedEntry(),t=this.selection,n=this.current();if(e&&t&&n){if(t.kind===`light`&&n.point){let r=e.object;t.part===`target`&&r.target?(r.target.position.set(...n.point),r.target.updateMatrixWorld()):(e.rest.position.set(...n.point),r.position.set(...n.point))}else if(n.transform){let t=n.transform;e.rest.position.set(...t.position),e.rest.quaternion.setFromEuler(new d(...t.rotation.map(e=>j.degToRad(e)),`XYZ`)),e.rest.scale.set(...t.scale),e.object.position.copy(e.rest.position),e.object.quaternion.copy(e.rest.quaternion),e.object.scale.copy(e.rest.scale),this.snapping()&&this.tc.mode!==`rotate`&&this.syncProxy()}this.requestRender()}}endDrag(){let e=this.selection,t=this.current(),n=this.dragStart,r=this.dragStartPoint;this.dragStart=null,this.dragStartPoint=null,e&&t&&((t.point?r&&t.point.every((e,t)=>e===r[t]):n&&t.transform&&JSON.stringify(n)===JSON.stringify(t.transform))||this.opts.onTransformEnd(e,t))}onDown=e=>{this.down={x:e.clientX,y:e.clientY,button:e.button},this.dragged=this.tc.dragging,this.shift!==e.shiftKey&&(this.shift=e.shiftKey,this.applySnap())};onUp=e=>{let t=this.down;if(this.down=null,!t||!this.enabled||t.button!==0||this.dragged||Math.hypot(e.clientX-t.x,e.clientY-t.y)>4)return;let n=this.dom.getBoundingClientRect(),r=(e.clientX-n.left)/n.width*2-1,i=-((e.clientY-n.top)/n.height*2-1);this.opts.onPick(this.pick(r,i))};onContext=e=>e.preventDefault();onKey=e=>{if(e.key!==`Shift`)return;let t=this.snapping();this.shift=e.type===`keydown`,t!==this.snapping()&&this.applySnap()};onBlur=()=>{this.shift=!1,this.applySnap()};viewCamera(){if(this.bridge.world()!==this.world&&this.attachWorld(),!this.world)return null;let e=this.world.camera;if(e.updateMatrixWorld(),this.sceneCamPose.copy(e.matrixWorld),this.view===`camera`||!this.enabled)return null;let t=this.editorCam;if(t.isPerspectiveCamera&&e.isPerspectiveCamera){let n=t,r=e;(n.fov!==r.fov||n.aspect!==r.aspect)&&(n.fov=r.fov,n.aspect=r.aspect,n.updateProjectionMatrix())}else if(t.isOrthographicCamera){let n=t,r=e;(n.left!==r.left||n.top!==r.top||n.right!==r.right)&&(Object.assign(n,{left:r.left,right:r.right,top:r.top,bottom:r.bottom}),n.updateProjectionMatrix())}return t}updateFrustum(e){let t=e.camera,n=xe(e),r=t.isOrthographicCamera,i=r?this.frustumOrtho:this.frustumCam;this.sceneCamPose.decompose(i.position,i.quaternion,new f);let a=Math.max(.5,i.position.distanceTo(e.rig.rest.target));if(r){let e=t,r=(e.top-e.bottom)/2/(e.zoom||1);Object.assign(i,{left:-r*n,right:r*n,top:r,bottom:-r,near:0,far:a})}else{let t=i;t.fov=e.def.camera?.fov??45,t.near=Math.min(.1,a*.05),t.far=a,te(t,e.def.camera,n,n)}i.updateProjectionMatrix(),i.updateMatrixWorld(!0);let o=(e,t,n)=>new f(e,t,n).unproject(i),s=[o(-1,-1,1),o(1,-1,1),o(1,1,1),o(-1,1,1)],c=r?[o(-1,-1,-1),o(1,-1,-1),o(1,1,-1),o(-1,1,-1)]:[i.position,i.position,i.position,i.position],l=s[3].clone().lerp(s[2],.5),u=s[3].clone().sub(s[0]).multiplyScalar(.12),d=s[2].clone().sub(s[3]).multiplyScalar(.06),p=l.clone().add(u),m=[];for(let e=0;e<4;e++)m.push(s[e],s[(e+1)%4],c[e],s[e]);if(r)for(let e=0;e<4;e++)m.push(c[e],c[(e+1)%4]);else m.push(i.position,i.position,i.position,i.position,i.position,i.position,i.position,i.position);m.push(l.clone().sub(d),p,p,l.clone().add(d));let h=this.frustum.geometry.getAttribute(`position`);m.slice(0,28).forEach((e,t)=>h.setXYZ(t,e.x,e.y,e.z)),h.needsUpdate=!0;let g=this.frustumFill.geometry.getAttribute(`position`);[s[0],s[1],s[2],s[0],s[2],s[3]].forEach((e,t)=>g.setXYZ(t,e.x,e.y,e.z)),g.needsUpdate=!0}draw(e,t){let n=this.world;if(!n)return;for(let e of n.scene.children)e.userData.helper&&(e.visible=this.helpersOn);let r=this.view===`editor`&&this.enabled,i=new f().setFromMatrixPosition(t.matrixWorld),a=t.isOrthographicCamera,o=(n,r)=>{if(a){let n=t;return(n.top-n.bottom)/n.zoom*(r/Math.max(e.domElement.clientHeight,1))}let o=t.fov??45;return n.distanceTo(i)*Math.tan(j.degToRad(o)/2)*2*(r/Math.max(e.domElement.clientHeight,1))},s=this.selectedEntry();s&&s.kind!==`light`&&this.enabled?(this.box.setFromObject(s.object),this.boxHelper.visible=!this.box.isEmpty()):this.boxHelper.visible=!1;for(let e of this.lights){let t=e.light.position,n=this.helpersOn&&this.enabled,r=this.selection?.kind===`light`&&this.selection.id===e.id;e.handle.visible=n,e.handle.position.copy(t),e.handle.scale.setScalar(o(t,r?7:5.5));let i=e.light.target;if(e.targetHandle&&i&&(e.targetHandle.visible=n,e.targetHandle.position.copy(i.position),e.targetHandle.scale.setScalar(o(i.position,r?7:5.5)),e.targetHandle.material.opacity=r?.95:.55),e.line&&i){e.line.visible=n;let r=e.line.geometry.getAttribute(`position`);r.setXYZ(0,t.x,t.y,t.z),r.setXYZ(1,i.position.x,i.position.y,i.position.z),r.needsUpdate=!0,e.line.geometry.computeBoundingSphere(),e.line.computeLineDistances()}e.helper&&(e.helper.visible=n&&(r||e.light.type===`SpotLight`),e.light.updateMatrixWorld(),e.helper.update?.())}let c=new f().setFromMatrixPosition(this.sceneCamPose),l=new O().setFromRotationMatrix(new A().extractRotation(this.sceneCamPose)),u=this.editorCam.position.distanceTo(c)<.05*Math.max(1,c.distanceTo(n.rig.rest.target))&&this.editorCam.quaternion.angleTo(l)<.05;this.frustum.visible=this.frustumFill.visible=r&&this.helpersOn&&!u,this.frustum.visible&&this.updateFrustum(n),this.tc.object&&!this.tc.dragging&&this.syncProxy(),this.tc.getHelper().visible=!!this.tc.object&&this.enabled,this.tc.camera=this.view===`camera`?n.camera:this.editorCam;let d=e.autoClear;e.autoClear=!1,e.setRenderTarget(null),e.clearDepth(),e.render(this.overlay,t),e.autoClear=d}};export{Se as SceneEditor};