@2112-lab/central-plant 0.1.3 โ†’ 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/bundle/index.js +1 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -1
  3. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
  8. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
  12. package/dist/cjs/src/analysis/analysis.js +1 -0
  13. package/dist/cjs/src/analysis/testing.js +1 -0
  14. package/dist/cjs/src/core/centralPlant.js +1 -0
  15. package/dist/cjs/src/core/debugLogger.js +1 -0
  16. package/dist/cjs/src/core/mathUtils.js +1 -0
  17. package/dist/cjs/src/core/nameUtils.js +1 -0
  18. package/dist/cjs/src/data/export.js +1 -0
  19. package/dist/cjs/src/data/import.js +1 -0
  20. package/dist/cjs/src/data/numerics.js +1 -0
  21. package/dist/cjs/src/helpers/sceneHelper.js +1 -0
  22. package/dist/cjs/src/index.js +1 -1
  23. package/dist/cjs/src/managers/components/animationManager.js +1 -0
  24. package/dist/cjs/src/managers/components/componentManager.js +1 -0
  25. package/dist/cjs/src/managers/components/pathfindingManager.js +1 -0
  26. package/dist/cjs/src/managers/controls/TransformControls.js +1 -0
  27. package/dist/cjs/src/managers/controls/cameraControlsManager.js +1 -0
  28. package/dist/cjs/src/managers/controls/dragDropManager.js +1 -0
  29. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +1 -0
  30. package/dist/cjs/src/managers/controls/transformControlsManager.js +1 -0
  31. package/dist/cjs/src/managers/environment/environmentManager.js +1 -0
  32. package/dist/cjs/src/managers/environment/textureConfig.js +1 -0
  33. package/dist/cjs/src/managers/scene/sceneExportManager.js +1 -0
  34. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -0
  35. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1 -0
  36. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -0
  37. package/dist/cjs/src/managers/system/disposalManager.js +1 -0
  38. package/dist/cjs/src/managers/system/hotReloadManager.js +1 -0
  39. package/dist/cjs/src/managers/system/performanceMonitor.js +1 -0
  40. package/dist/cjs/src/rendering/modelPreloader.js +1 -0
  41. package/dist/cjs/src/rendering/rendering2D.js +1 -0
  42. package/dist/cjs/src/rendering/rendering3D.js +1 -0
  43. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -1
  44. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1
  45. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
  46. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
  47. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
  49. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
  50. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -1
  51. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -1
  52. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
  53. package/dist/esm/src/analysis/analysis.js +1 -0
  54. package/dist/esm/src/analysis/testing.js +1 -0
  55. package/dist/esm/src/core/centralPlant.js +1 -0
  56. package/dist/esm/src/core/debugLogger.js +1 -0
  57. package/dist/esm/src/core/mathUtils.js +1 -0
  58. package/dist/esm/src/core/nameUtils.js +1 -0
  59. package/dist/esm/src/data/export.js +1 -0
  60. package/dist/esm/src/data/import.js +1 -0
  61. package/dist/esm/src/data/numerics.js +1 -0
  62. package/dist/esm/src/helpers/sceneHelper.js +1 -0
  63. package/dist/esm/src/index.js +1 -1
  64. package/dist/esm/src/managers/components/animationManager.js +1 -0
  65. package/dist/esm/src/managers/components/componentManager.js +1 -0
  66. package/dist/esm/src/managers/components/pathfindingManager.js +1 -0
  67. package/dist/esm/src/managers/controls/TransformControls.js +1 -0
  68. package/dist/esm/src/managers/controls/cameraControlsManager.js +1 -0
  69. package/dist/esm/src/managers/controls/dragDropManager.js +1 -0
  70. package/dist/esm/src/managers/controls/keyboardControlsManager.js +1 -0
  71. package/dist/esm/src/managers/controls/transformControlsManager.js +1 -0
  72. package/dist/esm/src/managers/environment/environmentManager.js +1 -0
  73. package/dist/esm/src/managers/environment/textureConfig.js +1 -0
  74. package/dist/esm/src/managers/scene/sceneExportManager.js +1 -0
  75. package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -0
  76. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1 -0
  77. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -0
  78. package/dist/esm/src/managers/system/disposalManager.js +1 -0
  79. package/dist/esm/src/managers/system/hotReloadManager.js +1 -0
  80. package/dist/esm/src/managers/system/performanceMonitor.js +1 -0
  81. package/dist/esm/src/rendering/modelPreloader.js +1 -0
  82. package/dist/esm/src/rendering/rendering2D.js +1 -0
  83. package/dist/esm/src/rendering/rendering3D.js +1 -0
  84. package/dist/index.d.ts +52 -255
  85. package/package.json +3 -6
  86. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
  87. package/dist/cjs/src/animationManager.js +0 -1
  88. package/dist/cjs/src/componentManager.js +0 -1
  89. package/dist/cjs/src/debugLogger.js +0 -1
  90. package/dist/cjs/src/disposalManager.js +0 -1
  91. package/dist/cjs/src/environmentManager.js +0 -1
  92. package/dist/cjs/src/hotReloadManager.js +0 -1
  93. package/dist/cjs/src/keyboardControlsManager.js +0 -1
  94. package/dist/cjs/src/nameUtils.js +0 -1
  95. package/dist/cjs/src/pathfindingManager.js +0 -1
  96. package/dist/cjs/src/performanceMonitor.js +0 -1
  97. package/dist/cjs/src/sceneExportManager.js +0 -1
  98. package/dist/cjs/src/sceneInitializationManager.js +0 -1
  99. package/dist/cjs/src/textureConfig.js +0 -1
  100. package/dist/cjs/src/transformControlsManager.js +0 -1
  101. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1
  102. package/dist/esm/src/animationManager.js +0 -1
  103. package/dist/esm/src/componentManager.js +0 -1
  104. package/dist/esm/src/debugLogger.js +0 -1
  105. package/dist/esm/src/disposalManager.js +0 -1
  106. package/dist/esm/src/environmentManager.js +0 -1
  107. package/dist/esm/src/hotReloadManager.js +0 -1
  108. package/dist/esm/src/keyboardControlsManager.js +0 -1
  109. package/dist/esm/src/nameUtils.js +0 -1
  110. package/dist/esm/src/pathfindingManager.js +0 -1
  111. package/dist/esm/src/performanceMonitor.js +0 -1
  112. package/dist/esm/src/sceneExportManager.js +0 -1
  113. package/dist/esm/src/sceneInitializationManager.js +0 -1
  114. package/dist/esm/src/textureConfig.js +0 -1
  115. package/dist/esm/src/transformControlsManager.js +0 -1
@@ -1 +1 @@
1
- import{Loader as t,LoaderUtils as e,FileLoader as s,Color as n,SpotLight as i,PointLight as r,DirectionalLight as o,MeshBasicMaterial as c,sRGBEncoding as a,MeshPhysicalMaterial as u,Vector2 as h,Matrix4 as f,Vector3 as l,Quaternion as A,InstancedMesh as d,Object3D as w,TextureLoader as m,ImageBitmapLoader as v,BufferAttribute as E,InterleavedBuffer as T,InterleavedBufferAttribute as p,LinearFilter as _,LinearMipmapLinearFilter as R,RepeatWrapping as P,PointsMaterial as M,Material as g,LineBasicMaterial as L,MeshStandardMaterial as I,DoubleSide as b,PropertyBinding as S,BufferGeometry as H,SkinnedMesh as y,Mesh as N,LineSegments as O,Line as B,LineLoop as x,Points as F,Group as G,PerspectiveCamera as U,MathUtils as k,OrthographicCamera as K,Skeleton as C,InterpolateLinear as D,AnimationClip as V,Bone as X,NearestFilter as j,NearestMipmapNearestFilter as Q,LinearMipmapNearestFilter as W,NearestMipmapLinearFilter as Y,ClampToEdgeWrapping as J,MirroredRepeatWrapping as Z,InterpolateDiscrete as q,FrontSide as z,Texture as $,TriangleStripDrawMode as tt,TriangleFanDrawMode as et,VectorKeyframeTrack as st,QuaternionKeyframeTrack as nt,NumberKeyframeTrack as it,Box3 as rt,Sphere as ot,Interpolant as ct}from"three";import{toTrianglesDrawMode as at}from"../utils/BufferGeometryUtils.js";class ut extends t{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new wt(t)}),this.register(function(t){return new Rt(t)}),this.register(function(t){return new Pt(t)}),this.register(function(t){return new Mt(t)}),this.register(function(t){return new vt(t)}),this.register(function(t){return new Et(t)}),this.register(function(t){return new Tt(t)}),this.register(function(t){return new pt(t)}),this.register(function(t){return new dt(t)}),this.register(function(t){return new _t(t)}),this.register(function(t){return new mt(t)}),this.register(function(t){return new lt(t)}),this.register(function(t){return new gt(t)}),this.register(function(t){return new Lt(t)})}load(t,n,i,r){const o=this;let c;c=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:e.extractUrlBase(t),this.manager.itemStart(t);const a=function(e){r&&r(e),o.manager.itemError(t),o.manager.itemEnd(t)},u=new s(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(t,function(e){try{o.parse(e,c,function(e){n(e),o.manager.itemEnd(t)},a)}catch(t){a(t)}},i,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,n){let i;const r={},o={},c=new TextDecoder;if("string"==typeof t)i=JSON.parse(t);else if(t instanceof ArrayBuffer){if(c.decode(new Uint8Array(t,0,4))===It){try{r[ft.KHR_BINARY_GLTF]=new Ht(t)}catch(t){return void(n&&n(t))}i=JSON.parse(r[ft.KHR_BINARY_GLTF].content)}else i=JSON.parse(c.decode(t))}else i=t;if(void 0===i.asset||i.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const a=new se(i,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](a);o[e.name]=e,r[e.name]=!0}if(i.extensionsUsed)for(let t=0;t<i.extensionsUsed.length;++t){const e=i.extensionsUsed[t],s=i.extensionsRequired||[];switch(e){case ft.KHR_MATERIALS_UNLIT:r[e]=new At;break;case ft.KHR_DRACO_MESH_COMPRESSION:r[e]=new yt(i,this.dracoLoader);break;case ft.KHR_TEXTURE_TRANSFORM:r[e]=new Nt;break;case ft.KHR_MESH_QUANTIZATION:r[e]=new Ot;break;default:s.indexOf(e)>=0&&o[e]}}a.setExtensions(r),a.setPlugins(o),a.parse(s,n)}parseAsync(t,e){const s=this;return new Promise(function(n,i){s.parse(t,e,n,i)})}}function ht(){let t={};return{get:function(e){return t[e]},add:function(e,s){t[e]=s},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const ft={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_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_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_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 lt{constructor(t){this.parser=t,this.name=ft.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}t(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,n=e.length;s<n;s++){const n=e[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&t.i(this.cache,n.extensions[this.name].light)}}o(t){const e=this.parser,s="light:"+t;let c=e.cache.get(s);if(c)return c;const a=e.json,u=((a.extensions&&a.extensions[this.name]||{}).lights||[])[t];let h;const f=new n(16777215);void 0!==u.color&&f.fromArray(u.color);const l=void 0!==u.range?u.range:0;switch(u.type){case"directional":h=new o(f),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new r(f),h.distance=l;break;case"spot":h=new i(f),h.distance=l,u.spot=u.spot||{},u.spot.innerConeAngle=void 0!==u.spot.innerConeAngle?u.spot.innerConeAngle:0,u.spot.outerConeAngle=void 0!==u.spot.outerConeAngle?u.spot.outerConeAngle:Math.PI/4,h.angle=u.spot.outerConeAngle,h.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return h.position.set(0,0,0),h.decay=2,Zt(h,u),void 0!==u.intensity&&(h.intensity=u.intensity),h.name=e.createUniqueName(u.name||"light_"+t),c=Promise.resolve(h),e.cache.add(s,c),c}getDependency(t,e){if("light"===t)return this.o(e)}createNodeAttachment(t){const e=this,s=this.parser,n=s.json.nodes[t],i=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===i?null:this.o(i).then(function(t){return s.u(e.cache,i,t)})}}class At{constructor(){this.name=ft.KHR_MATERIALS_UNLIT}getMaterialType(){return c}extendParams(t,e,s){const i=[];t.color=new n(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;t.color.fromArray(e),t.opacity=e[3]}void 0!==r.baseColorTexture&&i.push(s.assignTexture(t,"map",r.baseColorTexture,a))}return Promise.all(i)}}class dt{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const s=this.parser.json.materials[t];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(e.emissiveIntensity=n),Promise.resolve()}}class wt{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}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(void 0!==r.clearcoatFactor&&(e.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&i.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&i.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(i.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const t=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new h(t,t)}return Promise.all(i)}}class mt{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}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 void 0!==r.iridescenceFactor&&(e.iridescence=r.iridescenceFactor),void 0!==r.iridescenceTexture&&i.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),void 0!==r.iridescenceIor&&(e.iridescenceIOR=r.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==r.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),void 0!==r.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),void 0!==r.iridescenceThicknessTexture&&i.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(i)}}class vt{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new n(0,0,0),e.sheenRoughness=0,e.sheen=1;const o=i.extensions[this.name];return void 0!==o.sheenColorFactor&&e.sheenColor.fromArray(o.sheenColorFactor),void 0!==o.sheenRoughnessFactor&&(e.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&r.push(s.assignTexture(e,"sheenColorMap",o.sheenColorTexture,a)),void 0!==o.sheenRoughnessTexture&&r.push(s.assignTexture(e,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class Et{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}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 void 0!==r.transmissionFactor&&(e.transmission=r.transmissionFactor),void 0!==r.transmissionTexture&&i.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(i)}}class Tt{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];e.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&r.push(s.assignTexture(e,"thicknessMap",o.thicknessTexture)),e.attenuationDistance=o.attenuationDistance||1/0;const c=o.attenuationColor||[1,1,1];return e.attenuationColor=new n(c[0],c[1],c[2]),Promise.all(r)}}class pt{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}extendMaterialParams(t,e){const s=this.parser.json.materials[t];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return e.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class _t{constructor(t){this.parser=t,this.name=ft.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?u:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],o=i.extensions[this.name];e.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&r.push(s.assignTexture(e,"specularIntensityMap",o.specularTexture));const c=o.specularColorFactor||[1,1,1];return e.specularColor=new n(c[0],c[1],c[2]),void 0!==o.specularColorTexture&&r.push(s.assignTexture(e,"specularColorMap",o.specularColorTexture,a)),Promise.all(r)}}class Rt{constructor(t){this.parser=t,this.name=ft.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 Pt{constructor(t){this.parser=t,this.name=ft.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],o=n.images[r.source];let c=s.textureLoader;if(o.uri){const t=s.options.manager.getHandler(o.uri);null!==t&&(c=t)}return this.detectSupport().then(function(i){if(i)return s.loadTextureImage(t,r.source,c);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(1===e.height)}})),this.isSupported}}class Mt{constructor(t){this.parser=t,this.name=ft.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],o=n.images[r.source];let c=s.textureLoader;if(o.uri){const t=s.options.manager.getHandler(o.uri);null!==t&&(c=t)}return this.detectSupport().then(function(i){if(i)return s.loadTextureImage(t,r.source,c);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(1===e.height)}})),this.isSupported}}class gt{constructor(t){this.name=ft.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 t=s.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.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 n.then(function(e){const s=t.byteOffset||0,n=t.byteLength||0,r=t.count,o=t.byteStride,c=new Uint8Array(e,s,n);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(r,o,c,t.mode,t.filter).then(function(t){return t.buffer}):i.ready.then(function(){const e=new ArrayBuffer(r*o);return i.decodeGltfBuffer(new Uint8Array(e),r,o,c,t.mode,t.filter),e})})}return null}}class Lt{constructor(t){this.name=ft.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]||void 0===s.mesh)return null;const n=e.meshes[s.mesh];for(const t of n.primitives)if(t.mode!==Gt.TRIANGLES&&t.mode!==Gt.TRIANGLE_STRIP&&t.mode!==Gt.TRIANGLE_FAN&&void 0!==t.mode)return null;const i=s.extensions[this.name].attributes,r=[],o={};for(const t in i)r.push(this.parser.getDependency("accessor",i[t]).then(e=>(o[t]=e,o[t])));return r.length<1?null:(r.push(this.parser.createNodeMesh(t)),Promise.all(r).then(t=>{const e=t.pop(),s=e.isGroup?e.children:[e],n=t[0].count,i=[];for(const t of s){const e=new f,s=new l,r=new A,c=new l(1,1,1),a=new d(t.geometry,t.material,n);for(let t=0;t<n;t++)o.TRANSLATION&&s.fromBufferAttribute(o.TRANSLATION,t),o.ROTATION&&r.fromBufferAttribute(o.ROTATION,t),o.SCALE&&c.fromBufferAttribute(o.SCALE,t),a.setMatrixAt(t,e.compose(s,r,c));for(const e in o)"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,o[e]);w.prototype.copy.call(a,t),a.frustumCulled=!1,this.parser.assignFinalMaterial(a),i.push(a)}return e.isGroup?(e.clear(),e.add(...i),e):i[0]}))}}const It="glTF",bt=1313821514,St=5130562;class Ht{constructor(t){this.name=ft.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),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!==It)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-12,i=new DataView(t,12);let r=0;for(;r<n;){const e=i.getUint32(r,!0);r+=4;const n=i.getUint32(r,!0);if(r+=4,n===bt){const n=new Uint8Array(t,12+r,e);this.content=s.decode(n)}else if(n===St){const s=12+r;this.body=t.slice(s,s+e)}r+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class yt{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ft.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,o={},c={},a={};for(const t in r){const e=Dt[t]||t.toLowerCase();o[e]=r[t]}for(const e in t.attributes){const n=Dt[e]||e.toLowerCase();if(void 0!==r[e]){const i=s.accessors[t.attributes[e]],r=Ut[i.componentType];a[n]=r.name,c[n]=!0===i.normalized}}return e.getDependency("bufferView",i).then(function(t){return new Promise(function(e){n.decodeDracoFile(t,function(t){for(const e in t.attributes){const s=t.attributes[e],n=c[e];void 0!==n&&(s.normalized=n)}e(t)},o,a)})})}}class Nt{constructor(){this.name=ft.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return e.texCoord,void 0===e.offset&&void 0===e.rotation&&void 0===e.scale||(t=t.clone(),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Ot{constructor(){this.name=ft.KHR_MESH_QUANTIZATION}}class Bt extends ct{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 t=0;t!==n;t++)e[t]=s[i+t];return e}interpolate_(t,e,s,n){const i=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=2*o,a=3*o,u=n-e,h=(s-e)/u,f=h*h,l=f*h,A=t*a,d=A-a,w=-2*l+3*f,m=l-f,v=1-w,E=m-f+h;for(let t=0;t!==o;t++){const e=r[d+t+o],s=r[d+t+c]*u,n=r[A+t+o],a=r[A+t]*u;i[t]=v*e+E*s+w*n+m*a}return i}}const xt=new A;class Ft extends Bt{interpolate_(t,e,s,n){const i=super.interpolate_(t,e,s,n);return xt.fromArray(i).normalize().toArray(i),i}}const Gt={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},Ut={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kt={9728:j,9729:_,9984:Q,9985:W,9986:Y,9987:R},Kt={33071:J,33648:Z,10497:P},Ct={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Dt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Vt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Xt={CUBICSPLINE:void 0,LINEAR:D,STEP:q},jt="OPAQUE",Qt="MASK",Wt="BLEND";function Yt(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new I({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:z})),t.DefaultMaterial}function Jt(t,e,s){for(const n in s.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=s.extensions[n])}function Zt(t,e){void 0!==e.extras&&"object"==typeof e.extras&&Object.assign(t.userData,e.extras)}function qt(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let s=0,n=e.weights.length;s<n;s++)t.morphTargetInfluences[s]=e.weights[s];if(e.extras&&Array.isArray(e.extras.targetNames)){const s=e.extras.targetNames;if(t.morphTargetInfluences.length===s.length){t.morphTargetDictionary={};for(let e=0,n=s.length;e<n;e++)t.morphTargetDictionary[s[e]]=e}}}function zt(t){const e=t.extensions&&t.extensions[ft.KHR_DRACO_MESH_COMPRESSION];let s;return s=e?"draco:"+e.bufferView+":"+e.indices+":"+$t(e.attributes):t.indices+":"+$t(t.attributes)+":"+t.mode,s}function $t(t){let e="";const s=Object.keys(t).sort();for(let n=0,i=s.length;n<i;n++)e+=s[n]+":"+t[s[n]]+";";return e}function te(t){switch(t){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.")}}const ee=new f;class se{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new ht,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,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new m(this.options.manager):this.textureLoader=new v(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new s(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&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.h(function(t){return t.t&&t.t()}),Promise.all(this.h(function(t){return t.beforeRoot&&t.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(e){const r={scene:e[0][n.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:n.asset,parser:s,userData:{}};Jt(i,r,n),Zt(r,n),Promise.all(s.h(function(t){return t.afterRoot&&t.afterRoot(r)})).then(function(){t(r)})}).catch(e)}t(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=e.length;s<n;s++){const n=e[s].joints;for(let e=0,s=n.length;e<s;e++)t[n[e]].isBone=!0}for(let e=0,n=t.length;e<n;e++){const n=t[e];void 0!==n.mesh&&(this.i(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this.i(this.cameraCache,n.camera)}}i(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}u(t,e,s){if(t.refs[e]<=1)return s;const n=s.clone(),i=(t,e)=>{const s=this.associations.get(t);null!=s&&this.associations.set(e,s);for(const[s,n]of t.children.entries())i(n,e.children[s])};return i(s,n),n.name+="_instance_"+t.uses[e]++,n}l(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}h(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.l(function(t){return t.loadNode&&t.loadNode(e)});break;case"mesh":n=this.l(function(t){return t.loadMesh&&t.loadMesh(e)});break;case"accessor":n=this.loadAccessor(e);break;case"bufferView":n=this.l(function(t){return t.loadBufferView&&t.loadBufferView(e)});break;case"buffer":n=this.loadBuffer(e);break;case"material":n=this.l(function(t){return t.loadMaterial&&t.loadMaterial(e)});break;case"texture":n=this.l(function(t){return t.loadTexture&&t.loadTexture(e)});break;case"skin":n=this.loadSkin(e);break;case"animation":n=this.l(function(t){return t.loadAnimation&&t.loadAnimation(e)});break;case"camera":n=this.loadCamera(e);break;default:if(n=this.l(function(s){return s!=this&&s.getDependency&&s.getDependency(t,e)}),!n)throw new Error("Unknown type: "+t)}this.cache.add(s,n)}return n}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,n=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(n.map(function(e,n){return s.getDependency(t,n)})),this.cache.add(t,e)}return e}loadBuffer(t){const s=this.json.buffers[t],n=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[ft.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(t,r){n.load(e.resolveURL(s.uri,i.path),t,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(t){const s=e.byteLength||0,n=e.byteOffset||0;return t.slice(n,n+s)})}loadAccessor(t){const e=this,s=this.json,n=this.json.accessors[t];if(void 0===n.bufferView&&void 0===n.sparse){const t=Ct[n.type],e=Ut[n.componentType],s=!0===n.normalized,i=new e(n.count*t);return Promise.resolve(new E(i,t,s))}const i=[];return void 0!==n.bufferView?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),void 0!==n.sparse&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(t){const i=t[0],r=Ct[n.type],o=Ut[n.componentType],c=o.BYTES_PER_ELEMENT,a=c*r,u=n.byteOffset||0,h=void 0!==n.bufferView?s.bufferViews[n.bufferView].byteStride:void 0,f=!0===n.normalized;let l,A;if(h&&h!==a){const t=Math.floor(u/h),s="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+t+":"+n.count;let a=e.cache.get(s);a||(l=new o(i,t*h,n.count*h/c),a=new T(l,h/c),e.cache.add(s,a)),A=new p(a,r,u%h/c,f)}else l=null===i?new o(n.count*r):new o(i,u,n.count*r),A=new E(l,r,f);if(void 0!==n.sparse){const e=Ct.SCALAR,s=Ut[n.sparse.indices.componentType],c=n.sparse.indices.byteOffset||0,a=n.sparse.values.byteOffset||0,u=new s(t[1],c,n.sparse.count*e),h=new o(t[2],a,n.sparse.count*r);null!==i&&(A=new E(A.array.slice(),A.itemSize,A.normalized));for(let t=0,e=u.length;t<e;t++){const e=u[t];if(A.setX(e,h[t*r]),r>=2&&A.setY(e,h[t*r+1]),r>=3&&A.setZ(e,h[t*r+2]),r>=4&&A.setW(e,h[t*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return A})}loadTexture(t){const e=this.json,s=this.options,n=e.textures[t].source,i=e.images[n];let r=this.textureLoader;if(i.uri){const t=s.manager.getHandler(i.uri);null!==t&&(r=t)}return this.loadTextureImage(t,n,r)}loadTextureImage(t,e,s){const n=this,i=this.json,r=i.textures[t],o=i.images[e],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const a=this.loadImageSource(e,s).then(function(e){e.flipY=!1,e.name=r.name||o.name||"";const s=(i.samplers||{})[r.sampler]||{};return e.magFilter=kt[s.magFilter]||_,e.minFilter=kt[s.minFilter]||R,e.wrapS=Kt[s.wrapS]||P,e.wrapT=Kt[s.wrapT]||P,n.associations.set(e,{textures:t}),e}).catch(function(){return null});return this.textureCache[c]=a,a}loadImageSource(t,s){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(t=>t.clone());const o=i.images[t],c=self.URL||self.webkitURL;let a=o.uri||"",u=!1;if(void 0!==o.bufferView)a=n.getDependency("bufferView",o.bufferView).then(function(t){u=!0;const e=new Blob([t],{type:o.mimeType});return a=c.createObjectURL(e),a});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(a).then(function(t){return new Promise(function(n,i){let o=n;!0===s.isImageBitmapLoader&&(o=function(t){const e=new $(t);e.needsUpdate=!0,n(e)}),s.load(e.resolveURL(t,r.path),o,void 0,i)})}).then(function(t){var e;return!0===u&&c.revokeObjectURL(a),t.userData.mimeType=o.mimeType||((e=o.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"),t}).catch(function(t){throw t});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(void 0!==s.texCoord&&0!=s.texCoord&&("aoMap"!==e||s.texCoord),i.extensions[ft.KHR_TEXTURE_TRANSFORM]){const t=void 0!==s.extensions?s.extensions[ft.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=i.associations.get(r);r=i.extensions[ft.KHR_TEXTURE_TRANSFORM].extendTexture(r,t),i.associations.set(r,e)}}return void 0!==n&&(r.encoding=n),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const n=void 0===e.attributes.tangent,i=void 0!==e.attributes.color,r=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+s.uuid;let e=this.cache.get(t);e||(e=new M,g.prototype.copy.call(e,s),e.color.copy(s.color),e.map=s.map,e.sizeAttenuation=!1,this.cache.add(t,e)),s=e}else if(t.isLine){const t="LineBasicMaterial:"+s.uuid;let e=this.cache.get(t);e||(e=new L,g.prototype.copy.call(e,s),e.color.copy(s.color),this.cache.add(t,e)),s=e}if(n||i||r){let t="ClonedMaterial:"+s.uuid+":";n&&(t+="derivative-tangents:"),i&&(t+="vertex-colors:"),r&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=s.clone(),i&&(e.vertexColors=!0),r&&(e.flatShading=!0),n&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(s))),s=e}s.aoMap&&void 0===e.attributes.uv2&&void 0!==e.attributes.uv&&e.setAttribute("uv2",e.attributes.uv),t.material=s}getMaterialType(){return I}loadMaterial(t){const e=this,s=this.json,i=this.extensions,r=s.materials[t];let o;const u={},f=[];if((r.extensions||{})[ft.KHR_MATERIALS_UNLIT]){const t=i[ft.KHR_MATERIALS_UNLIT];o=t.getMaterialType(),f.push(t.extendParams(u,r,e))}else{const s=r.pbrMetallicRoughness||{};if(u.color=new n(1,1,1),u.opacity=1,Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;u.color.fromArray(t),u.opacity=t[3]}void 0!==s.baseColorTexture&&f.push(e.assignTexture(u,"map",s.baseColorTexture,a)),u.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,u.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(f.push(e.assignTexture(u,"metalnessMap",s.metallicRoughnessTexture)),f.push(e.assignTexture(u,"roughnessMap",s.metallicRoughnessTexture))),o=this.l(function(e){return e.getMaterialType&&e.getMaterialType(t)}),f.push(Promise.all(this.h(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,u)})))}!0===r.doubleSided&&(u.side=b);const l=r.alphaMode||jt;if(l===Wt?(u.transparent=!0,u.depthWrite=!1):(u.transparent=!1,l===Qt&&(u.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&o!==c&&(f.push(e.assignTexture(u,"normalMap",r.normalTexture)),u.normalScale=new h(1,1),void 0!==r.normalTexture.scale)){const t=r.normalTexture.scale;u.normalScale.set(t,t)}return void 0!==r.occlusionTexture&&o!==c&&(f.push(e.assignTexture(u,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(u.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&o!==c&&(u.emissive=(new n).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&o!==c&&f.push(e.assignTexture(u,"emissiveMap",r.emissiveTexture,a)),Promise.all(f).then(function(){const s=new o(u);return r.name&&(s.name=r.name),Zt(s,r),e.associations.set(s,{materials:t}),r.extensions&&Jt(i,s,r),s})}createUniqueName(t){const e=S.sanitizeNodeName(t||"");let s=e;for(let t=1;this.nodeNamesUsed[s];++t)s=e+"_"+t;return this.nodeNamesUsed[s]=!0,s}loadGeometries(t){const e=this,s=this.extensions,n=this.primitiveCache;function i(t){return s[ft.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then(function(s){return ne(s,t,e)})}const r=[];for(let s=0,o=t.length;s<o;s++){const o=t[s],c=zt(o),a=n[c];if(a)r.push(a.promise);else{let t;t=o.extensions&&o.extensions[ft.KHR_DRACO_MESH_COMPRESSION]?i(o):ne(new H,o,e),n[c]={primitive:o,promise:t},r.push(t)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,n=this.extensions,i=s.meshes[t],r=i.primitives,o=[];for(let t=0,e=r.length;t<e;t++){const e=void 0===r[t].material?Yt(this.cache):this.getDependency("material",r[t].material);o.push(e)}return o.push(e.loadGeometries(r)),Promise.all(o).then(function(s){const o=s.slice(0,s.length-1),c=s[s.length-1],a=[];for(let s=0,u=c.length;s<u;s++){const u=c[s],h=r[s];let f;const l=o[s];if(h.mode===Gt.TRIANGLES||h.mode===Gt.TRIANGLE_STRIP||h.mode===Gt.TRIANGLE_FAN||void 0===h.mode)f=!0===i.isSkinnedMesh?new y(u,l):new N(u,l),!0===f.isSkinnedMesh&&f.normalizeSkinWeights(),h.mode===Gt.TRIANGLE_STRIP?f.geometry=at(f.geometry,tt):h.mode===Gt.TRIANGLE_FAN&&(f.geometry=at(f.geometry,et));else if(h.mode===Gt.LINES)f=new O(u,l);else if(h.mode===Gt.LINE_STRIP)f=new B(u,l);else if(h.mode===Gt.LINE_LOOP)f=new x(u,l);else{if(h.mode!==Gt.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);f=new F(u,l)}Object.keys(f.geometry.morphAttributes).length>0&&qt(f,i),f.name=e.createUniqueName(i.name||"mesh_"+t),Zt(f,i),h.extensions&&Jt(n,f,h),e.assignFinalMaterial(f),a.push(f)}for(let s=0,n=a.length;s<n;s++)e.associations.set(a[s],{meshes:t,primitives:s});if(1===a.length)return a[0];const u=new G;e.associations.set(u,{meshes:t});for(let t=0,e=a.length;t<e;t++)u.add(a[t]);return u})}loadCamera(t){let e;const s=this.json.cameras[t],n=s[s.type];if(n)return"perspective"===s.type?e=new U(k.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===s.type&&(e=new K(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),Zt(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let t=0,n=e.joints.length;t<n;t++)s.push(this.A(e.joints[t]));return void 0!==e.inverseBindMatrices?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(t){const e=t.pop(),s=t,n=[],i=[];for(let t=0,r=s.length;t<r;t++){const r=s[t];if(r){n.push(r);const s=new f;null!==e&&s.fromArray(e.array,16*t),i.push(s)}}return new C(n,i)})}loadAnimation(t){const e=this.json.animations[t],s=[],n=[],i=[],r=[],o=[];for(let t=0,c=e.channels.length;t<c;t++){const c=e.channels[t],a=e.samplers[c.sampler],u=c.target,h=u.node,f=void 0!==e.parameters?e.parameters[a.input]:a.input,l=void 0!==e.parameters?e.parameters[a.output]:a.output;s.push(this.getDependency("node",h)),n.push(this.getDependency("accessor",f)),i.push(this.getDependency("accessor",l)),r.push(a),o.push(u)}return Promise.all([Promise.all(s),Promise.all(n),Promise.all(i),Promise.all(r),Promise.all(o)]).then(function(s){const n=s[0],i=s[1],r=s[2],o=s[3],c=s[4],a=[];for(let t=0,e=n.length;t<e;t++){const e=n[t],s=i[t],u=r[t],h=o[t],f=c[t];if(void 0===e)continue;let l;switch(e.updateMatrix(),Vt[f.path]){case Vt.weights:l=it;break;case Vt.rotation:l=nt;break;default:l=st}const A=e.name?e.name:e.uuid,d=void 0!==h.interpolation?Xt[h.interpolation]:D,w=[];Vt[f.path]===Vt.weights?e.traverse(function(t){t.morphTargetInfluences&&w.push(t.name?t.name:t.uuid)}):w.push(A);let m=u.array;if(u.normalized){const t=te(m.constructor),e=new Float32Array(m.length);for(let s=0,n=m.length;s<n;s++)e[s]=m[s]*t;m=e}for(let t=0,e=w.length;t<e;t++){const e=new l(w[t]+"."+Vt[f.path],s.array,m,d);"CUBICSPLINE"===h.interpolation&&(e.createInterpolant=function(t){return new(this instanceof nt?Ft:Bt)(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),a.push(e)}}const u=e.name?e.name:"animation_"+t;return new V(u,void 0,a)})}createNodeMesh(t){const e=this.json,s=this,n=e.nodes[t];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then(function(t){const e=s.u(s.meshCache,n.mesh,t);return void 0!==n.weights&&e.traverse(function(t){if(t.isMesh)for(let e=0,s=n.weights.length;e<s;e++)t.morphTargetInfluences[e]=n.weights[e]}),e})}loadNode(t){const e=this,s=this.json.nodes[t],n=e.A(t),i=[],r=s.children||[];for(let t=0,s=r.length;t<s;t++)i.push(e.getDependency("node",r[t]));const o=void 0===s.skin?Promise.resolve(null):e.getDependency("skin",s.skin);return Promise.all([n,Promise.all(i),o]).then(function(t){const e=t[0],s=t[1],n=t[2];null!==n&&e.traverse(function(t){t.isSkinnedMesh&&t.bind(n,ee)});for(let t=0,n=s.length;t<n;t++)e.add(s[t]);return e})}A(t){const e=this.json,s=this.extensions,n=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const i=e.nodes[t],r=i.name?n.createUniqueName(i.name):"",o=[],c=n.l(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return c&&o.push(c),void 0!==i.camera&&o.push(n.getDependency("camera",i.camera).then(function(t){return n.u(n.cameraCache,i.camera,t)})),n.h(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(t){o.push(t)}),this.nodeCache[t]=Promise.all(o).then(function(e){let o;if(o=!0===i.isBone?new X:e.length>1?new G:1===e.length?e[0]:new w,o!==e[0])for(let t=0,s=e.length;t<s;t++)o.add(e[t]);if(i.name&&(o.userData.name=i.name,o.name=r),Zt(o,i),i.extensions&&Jt(s,o,i),void 0!==i.matrix){const t=new f;t.fromArray(i.matrix),o.applyMatrix4(t)}else void 0!==i.translation&&o.position.fromArray(i.translation),void 0!==i.rotation&&o.quaternion.fromArray(i.rotation),void 0!==i.scale&&o.scale.fromArray(i.scale);return n.associations.has(o)||n.associations.set(o,{}),n.associations.get(o).nodes=t,o}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],n=this,i=new G;s.name&&(i.name=n.createUniqueName(s.name)),Zt(i,s),s.extensions&&Jt(e,i,s);const r=s.nodes||[],o=[];for(let t=0,e=r.length;t<e;t++)o.push(n.getDependency("node",r[t]));return Promise.all(o).then(function(t){for(let e=0,s=t.length;e<s;e++)i.add(t[e]);return n.associations=(t=>{const e=new Map;for(const[t,s]of n.associations)(t instanceof g||t instanceof $)&&e.set(t,s);return t.traverse(t=>{const s=n.associations.get(t);null!=s&&e.set(t,s)}),e})(i),i})}}function ne(t,e,s){const n=e.attributes,i=[];function r(e,n){return s.getDependency("accessor",e).then(function(e){t.setAttribute(n,e)})}for(const e in n){const s=Dt[e]||e.toLowerCase();s in t.attributes||i.push(r(n[e],s))}if(void 0!==e.indices&&!t.index){const n=s.getDependency("accessor",e.indices).then(function(e){t.setIndex(e)});i.push(n)}return Zt(t,e),function(t,e,s){const n=e.attributes,i=new rt;if(void 0===n.POSITION)return;{const t=s.json.accessors[n.POSITION],e=t.min,r=t.max;if(void 0===e||void 0===r)return;if(i.set(new l(e[0],e[1],e[2]),new l(r[0],r[1],r[2])),t.normalized){const e=te(Ut[t.componentType]);i.min.multiplyScalar(e),i.max.multiplyScalar(e)}}const r=e.targets;if(void 0!==r){const t=new l,e=new l;for(let n=0,i=r.length;n<i;n++){const i=r[n];if(void 0!==i.POSITION){const n=s.json.accessors[i.POSITION],r=n.min,o=n.max;if(void 0!==r&&void 0!==o){if(e.setX(Math.max(Math.abs(r[0]),Math.abs(o[0]))),e.setY(Math.max(Math.abs(r[1]),Math.abs(o[1]))),e.setZ(Math.max(Math.abs(r[2]),Math.abs(o[2]))),n.normalized){const t=te(Ut[n.componentType]);e.multiplyScalar(t)}t.max(e)}}}i.expandByVector(t)}t.boundingBox=i;const o=new ot;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,t.boundingSphere=o}(t,e,s),Promise.all(i).then(function(){return void 0!==e.targets?function(t,e,s){let n=!1,i=!1,r=!1;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(i=!0),void 0!==s.COLOR_0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(t);const o=[],c=[],a=[];for(let u=0,h=e.length;u<h;u++){const h=e[u];if(n){const e=void 0!==h.POSITION?s.getDependency("accessor",h.POSITION):t.attributes.position;o.push(e)}if(i){const e=void 0!==h.NORMAL?s.getDependency("accessor",h.NORMAL):t.attributes.normal;c.push(e)}if(r){const e=void 0!==h.COLOR_0?s.getDependency("accessor",h.COLOR_0):t.attributes.color;a.push(e)}}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(a)]).then(function(e){const s=e[0],o=e[1],c=e[2];return n&&(t.morphAttributes.position=s),i&&(t.morphAttributes.normal=o),r&&(t.morphAttributes.color=c),t.morphTargetsRelative=!0,t})}(t,e.targets,s):t})}export{ut as GLTFLoader};
1
+ import{Loader as t,LoaderUtils as e,FileLoader as s,Color as i,LinearSRGBColorSpace as n,SpotLight as r,PointLight as o,DirectionalLight as c,MeshBasicMaterial as a,SRGBColorSpace as u,MeshPhysicalMaterial as h,Vector2 as f,Matrix4 as l,Vector3 as d,Quaternion as m,InstancedMesh as w,InstancedBufferAttribute as v,Object3D as T,TextureLoader as _,ImageBitmapLoader as E,BufferAttribute as p,InterleavedBuffer as R,InterleavedBufferAttribute as A,LinearFilter as P,LinearMipmapLinearFilter as M,RepeatWrapping as L,NearestFilter as g,PointsMaterial as I,Material as S,LineBasicMaterial as y,MeshStandardMaterial as b,DoubleSide as H,PropertyBinding as O,BufferGeometry as N,SkinnedMesh as x,Mesh as k,LineSegments as K,Line as U,LineLoop as C,Points as F,Group as G,PerspectiveCamera as D,MathUtils as V,OrthographicCamera as X,Skeleton as B,AnimationClip as j,Bone as J,InterpolateLinear as q,ColorManagement as z,NearestMipmapNearestFilter as W,LinearMipmapNearestFilter as Y,NearestMipmapLinearFilter as $,ClampToEdgeWrapping as Q,MirroredRepeatWrapping as Z,InterpolateDiscrete as tt,FrontSide as et,Texture as st,TriangleStripDrawMode as it,TriangleFanDrawMode as nt,VectorKeyframeTrack as rt,NumberKeyframeTrack as ot,QuaternionKeyframeTrack as ct,Box3 as at,Sphere as ut,Interpolant as ht}from"three";import{toTrianglesDrawMode as ft}from"../utils/BufferGeometryUtils.js";class lt extends t{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new _t(t)}),this.register(function(t){return new Et(t)}),this.register(function(t){return new St(t)}),this.register(function(t){return new yt(t)}),this.register(function(t){return new bt(t)}),this.register(function(t){return new Rt(t)}),this.register(function(t){return new At(t)}),this.register(function(t){return new Pt(t)}),this.register(function(t){return new Mt(t)}),this.register(function(t){return new Tt(t)}),this.register(function(t){return new Lt(t)}),this.register(function(t){return new pt(t)}),this.register(function(t){return new It(t)}),this.register(function(t){return new gt(t)}),this.register(function(t){return new wt(t)}),this.register(function(t){return new Ht(t)}),this.register(function(t){return new Ot(t)})}load(t,i,n,r){const o=this;let c;if(""!==this.resourcePath)c=this.resourcePath;else if(""!==this.path){const s=e.extractUrlBase(t);c=e.resolveURL(s,this.path)}else c=e.extractUrlBase(t);this.manager.itemStart(t);const a=function(e){r&&r(e),o.manager.itemError(t),o.manager.itemEnd(t)},u=new s(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(t,function(e){try{o.parse(e,c,function(e){i(e),o.manager.itemEnd(t)},a)}catch(t){a(t)}},n,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-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,s,i){let n;const r={},o={},c=new TextDecoder;if("string"==typeof t)n=JSON.parse(t);else if(t instanceof ArrayBuffer){if(c.decode(new Uint8Array(t,0,4))===Nt){try{r[mt.KHR_BINARY_GLTF]=new Kt(t)}catch(t){return void(i&&i(t))}n=JSON.parse(r[mt.KHR_BINARY_GLTF].content)}else n=JSON.parse(c.decode(t))}else n=t;if(void 0===n.asset||n.asset.version[0]<2)return void(i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const a=new ae(n,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t<this.pluginCallbacks.length;t++){const e=this.pluginCallbacks[t](a);e.name,o[e.name]=e,r[e.name]=!0}if(n.extensionsUsed)for(let t=0;t<n.extensionsUsed.length;++t){const e=n.extensionsUsed[t],s=n.extensionsRequired||[];switch(e){case mt.KHR_MATERIALS_UNLIT:r[e]=new vt;break;case mt.KHR_DRACO_MESH_COMPRESSION:r[e]=new Ut(n,this.dracoLoader);break;case mt.KHR_TEXTURE_TRANSFORM:r[e]=new Ct;break;case mt.KHR_MESH_QUANTIZATION:r[e]=new Ft;break;default:s.indexOf(e)>=0&&o[e]}}a.setExtensions(r),a.setPlugins(o),a.parse(s,i)}parseAsync(t,e){const s=this;return new Promise(function(i,n){s.parse(t,e,i,n)})}}function dt(){let t={};return{get:function(e){return t[e]},add:function(e,s){t[e]=s},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const mt={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 wt{constructor(t){this.parser=t,this.name=mt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}t(){const t=this.parser,e=this.parser.json.nodes||[];for(let s=0,i=e.length;s<i;s++){const i=e[s];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&t.i(this.cache,i.extensions[this.name].light)}}o(t){const e=this.parser,s="light:"+t;let a=e.cache.get(s);if(a)return a;const u=e.json,h=((u.extensions&&u.extensions[this.name]||{}).lights||[])[t];let f;const l=new i(16777215);void 0!==h.color&&l.setRGB(h.color[0],h.color[1],h.color[2],n);const d=void 0!==h.range?h.range:0;switch(h.type){case"directional":f=new c(l),f.target.position.set(0,0,-1),f.add(f.target);break;case"point":f=new o(l),f.distance=d;break;case"spot":f=new r(l),f.distance=d,h.spot=h.spot||{},h.spot.innerConeAngle=void 0!==h.spot.innerConeAngle?h.spot.innerConeAngle:0,h.spot.outerConeAngle=void 0!==h.spot.outerConeAngle?h.spot.outerConeAngle:Math.PI/4,f.angle=h.spot.outerConeAngle,f.penumbra=1-h.spot.innerConeAngle/h.spot.outerConeAngle,f.target.position.set(0,0,-1),f.add(f.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+h.type)}return f.position.set(0,0,0),se(f,h),void 0!==h.intensity&&(f.intensity=h.intensity),f.name=e.createUniqueName(h.name||"light_"+t),a=Promise.resolve(f),e.cache.add(s,a),a}getDependency(t,e){if("light"===t)return this.o(e)}createNodeAttachment(t){const e=this,s=this.parser,i=s.json.nodes[t],n=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===n?null:this.o(n).then(function(t){return s.u(e.cache,n,t)})}}class vt{constructor(){this.name=mt.KHR_MATERIALS_UNLIT}getMaterialType(){return a}extendParams(t,e,s){const r=[];t.color=new i(1,1,1),t.opacity=1;const o=e.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const e=o.baseColorFactor;t.color.setRGB(e[0],e[1],e[2],n),t.opacity=e[3]}void 0!==o.baseColorTexture&&r.push(s.assignTexture(t,"map",o.baseColorTexture,u))}return Promise.all(r)}}class Tt{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const s=this.parser.json.materials[t];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name].emissiveStrength;return void 0!==i&&(e.emissiveIntensity=i),Promise.resolve()}}class _t{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];if(void 0!==r.clearcoatFactor&&(e.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&n.push(s.assignTexture(e,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(e.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&n.push(s.assignTexture(e,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(n.push(s.assignTexture(e,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const t=r.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new f(t,t)}return Promise.all(n)}}class Et{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_DISPERSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser.json.materials[t];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return e.dispersion=void 0!==i.dispersion?i.dispersion:0,Promise.resolve()}}class pt{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return void 0!==r.iridescenceFactor&&(e.iridescence=r.iridescenceFactor),void 0!==r.iridescenceTexture&&n.push(s.assignTexture(e,"iridescenceMap",r.iridescenceTexture)),void 0!==r.iridescenceIor&&(e.iridescenceIOR=r.iridescenceIor),void 0===e.iridescenceThicknessRange&&(e.iridescenceThicknessRange=[100,400]),void 0!==r.iridescenceThicknessMinimum&&(e.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),void 0!==r.iridescenceThicknessMaximum&&(e.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),void 0!==r.iridescenceThicknessTexture&&n.push(s.assignTexture(e,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(n)}}class Rt{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_SHEEN}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,r=s.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];e.sheenColor=new i(0,0,0),e.sheenRoughness=0,e.sheen=1;const c=r.extensions[this.name];if(void 0!==c.sheenColorFactor){const t=c.sheenColorFactor;e.sheenColor.setRGB(t[0],t[1],t[2],n)}return void 0!==c.sheenRoughnessFactor&&(e.sheenRoughness=c.sheenRoughnessFactor),void 0!==c.sheenColorTexture&&o.push(s.assignTexture(e,"sheenColorMap",c.sheenColorTexture,u)),void 0!==c.sheenRoughnessTexture&&o.push(s.assignTexture(e,"sheenRoughnessMap",c.sheenRoughnessTexture)),Promise.all(o)}}class At{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return void 0!==r.transmissionFactor&&(e.transmission=r.transmissionFactor),void 0!==r.transmissionTexture&&n.push(s.assignTexture(e,"transmissionMap",r.transmissionTexture)),Promise.all(n)}}class Pt{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_VOLUME}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,r=s.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],c=r.extensions[this.name];e.thickness=void 0!==c.thicknessFactor?c.thicknessFactor:0,void 0!==c.thicknessTexture&&o.push(s.assignTexture(e,"thicknessMap",c.thicknessTexture)),e.attenuationDistance=c.attenuationDistance||1/0;const a=c.attenuationColor||[1,1,1];return e.attenuationColor=(new i).setRGB(a[0],a[1],a[2],n),Promise.all(o)}}class Mt{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_IOR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser.json.materials[t];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return e.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class Lt{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_SPECULAR}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,r=s.json.materials[t];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],c=r.extensions[this.name];e.specularIntensity=void 0!==c.specularFactor?c.specularFactor:1,void 0!==c.specularTexture&&o.push(s.assignTexture(e,"specularIntensityMap",c.specularTexture));const a=c.specularColorFactor||[1,1,1];return e.specularColor=(new i).setRGB(a[0],a[1],a[2],n),void 0!==c.specularColorTexture&&o.push(s.assignTexture(e,"specularColorMap",c.specularColorTexture,u)),Promise.all(o)}}class gt{constructor(t){this.parser=t,this.name=mt.EXT_MATERIALS_BUMP}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return e.bumpScale=void 0!==r.bumpFactor?r.bumpFactor:1,void 0!==r.bumpTexture&&n.push(s.assignTexture(e,"bumpMap",r.bumpTexture)),Promise.all(n)}}class It{constructor(t){this.parser=t,this.name=mt.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const e=this.parser.json.materials[t];return e.extensions&&e.extensions[this.name]?h:null}extendMaterialParams(t,e){const s=this.parser,i=s.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],r=i.extensions[this.name];return void 0!==r.anisotropyStrength&&(e.anisotropy=r.anisotropyStrength),void 0!==r.anisotropyRotation&&(e.anisotropyRotation=r.anisotropyRotation),void 0!==r.anisotropyTexture&&n.push(s.assignTexture(e,"anisotropyMap",r.anisotropyTexture)),Promise.all(n)}}class St{constructor(t){this.parser=t,this.name=mt.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,s=e.json,i=s.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const n=i.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,n.source,r)}}class yt{constructor(t){this.parser=t,this.name=mt.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,s=this.parser,i=s.json,n=i.textures[t];if(!n.extensions||!n.extensions[e])return null;const r=n.extensions[e],o=i.images[r.source];let c=s.textureLoader;if(o.uri){const t=s.options.manager.getHandler(o.uri);null!==t&&(c=t)}return s.loadTextureImage(t,r.source,c)}}class bt{constructor(t){this.parser=t,this.name=mt.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,s=this.parser,i=s.json,n=i.textures[t];if(!n.extensions||!n.extensions[e])return null;const r=n.extensions[e],o=i.images[r.source];let c=s.textureLoader;if(o.uri){const t=s.options.manager.getHandler(o.uri);null!==t&&(c=t)}return s.loadTextureImage(t,r.source,c)}}class Ht{constructor(t){this.name=mt.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 t=s.extensions[this.name],i=this.parser.getDependency("buffer",t.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.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(e){const s=t.byteOffset||0,i=t.byteLength||0,r=t.count,o=t.byteStride,c=new Uint8Array(e,s,i);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(r,o,c,t.mode,t.filter).then(function(t){return t.buffer}):n.ready.then(function(){const e=new ArrayBuffer(r*o);return n.decodeGltfBuffer(new Uint8Array(e),r,o,c,t.mode,t.filter),e})})}return null}}class Ot{constructor(t){this.name=mt.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]||void 0===s.mesh)return null;const i=e.meshes[s.mesh];for(const t of i.primitives)if(t.mode!==Xt.TRIANGLES&&t.mode!==Xt.TRIANGLE_STRIP&&t.mode!==Xt.TRIANGLE_FAN&&void 0!==t.mode)return null;const n=s.extensions[this.name].attributes,r=[],o={};for(const t in n)r.push(this.parser.getDependency("accessor",n[t]).then(e=>(o[t]=e,o[t])));return r.length<1?null:(r.push(this.parser.createNodeMesh(t)),Promise.all(r).then(t=>{const e=t.pop(),s=e.isGroup?e.children:[e],i=t[0].count,n=[];for(const t of s){const e=new l,s=new d,r=new m,c=new d(1,1,1),a=new w(t.geometry,t.material,i);for(let t=0;t<i;t++)o.TRANSLATION&&s.fromBufferAttribute(o.TRANSLATION,t),o.ROTATION&&r.fromBufferAttribute(o.ROTATION,t),o.SCALE&&c.fromBufferAttribute(o.SCALE,t),a.setMatrixAt(t,e.compose(s,r,c));for(const e in o)if("_COLOR_0"===e){const t=o[e];a.instanceColor=new v(t.array,t.itemSize,t.normalized)}else"TRANSLATION"!==e&&"ROTATION"!==e&&"SCALE"!==e&&t.geometry.setAttribute(e,o[e]);T.prototype.copy.call(a,t),this.parser.assignFinalMaterial(a),n.push(a)}return e.isGroup?(e.clear(),e.add(...n),e):n[0]}))}}const Nt="glTF",xt=1313821514,kt=5130562;class Kt{constructor(t){this.name=mt.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12),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!==Nt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,n=new DataView(t,12);let r=0;for(;r<i;){const e=n.getUint32(r,!0);r+=4;const i=n.getUint32(r,!0);if(r+=4,i===xt){const i=new Uint8Array(t,12+r,e);this.content=s.decode(i)}else if(i===kt){const s=12+r;this.body=t.slice(s,s+e)}r+=e}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ut{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=mt.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const s=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,c={},a={},u={};for(const t in o){const e=zt[t]||t.toLowerCase();c[e]=o[t]}for(const e in t.attributes){const i=zt[e]||e.toLowerCase();if(void 0!==o[e]){const n=s.accessors[t.attributes[e]],r=Bt[n.componentType];u[i]=r.name,a[i]=!0===n.normalized}}return e.getDependency("bufferView",r).then(function(t){return new Promise(function(e,s){i.decodeDracoFile(t,function(t){for(const e in t.attributes){const s=t.attributes[e],i=a[e];void 0!==i&&(s.normalized=i)}e(t)},c,u,n,s)})})}}class Ct{constructor(){this.name=mt.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return void 0!==e.texCoord&&e.texCoord!==t.channel||void 0!==e.offset||void 0!==e.rotation||void 0!==e.scale?(t=t.clone(),void 0!==e.texCoord&&(t.channel=e.texCoord),void 0!==e.offset&&t.offset.fromArray(e.offset),void 0!==e.rotation&&(t.rotation=e.rotation),void 0!==e.scale&&t.repeat.fromArray(e.scale),t.needsUpdate=!0,t):t}}class Ft{constructor(){this.name=mt.KHR_MESH_QUANTIZATION}}class Gt extends ht{constructor(t,e,s,i){super(t,e,s,i)}copySampleValue_(t){const e=this.resultBuffer,s=this.sampleValues,i=this.valueSize,n=t*i*3+i;for(let t=0;t!==i;t++)e[t]=s[n+t];return e}interpolate_(t,e,s,i){const n=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=2*o,a=3*o,u=i-e,h=(s-e)/u,f=h*h,l=f*h,d=t*a,m=d-a,w=-2*l+3*f,v=l-f,T=1-w,_=v-f+h;for(let t=0;t!==o;t++){const e=r[m+t+o],s=r[m+t+c]*u,i=r[d+t+o],a=r[d+t]*u;n[t]=T*e+_*s+w*i+v*a}return n}}const Dt=new m;class Vt extends Gt{interpolate_(t,e,s,i){const n=super.interpolate_(t,e,s,i);return Dt.fromArray(n).normalize().toArray(n),n}}const Xt={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},Bt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jt={9728:g,9729:P,9984:W,9985:Y,9986:$,9987:M},Jt={33071:Q,33648:Z,10497:L},qt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zt={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"},Wt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yt={CUBICSPLINE:void 0,LINEAR:q,STEP:tt},$t="OPAQUE",Qt="MASK",Zt="BLEND";function te(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new b({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:et})),t.DefaultMaterial}function ee(t,e,s){for(const i in s.extensions)void 0===t[i]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[i]=s.extensions[i])}function se(t,e){void 0!==e.extras&&"object"==typeof e.extras&&Object.assign(t.userData,e.extras)}function ie(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let s=0,i=e.weights.length;s<i;s++)t.morphTargetInfluences[s]=e.weights[s];if(e.extras&&Array.isArray(e.extras.targetNames)){const s=e.extras.targetNames;if(t.morphTargetInfluences.length===s.length){t.morphTargetDictionary={};for(let e=0,i=s.length;e<i;e++)t.morphTargetDictionary[s[e]]=e}}}function ne(t){let e;const s=t.extensions&&t.extensions[mt.KHR_DRACO_MESH_COMPRESSION];if(e=s?"draco:"+s.bufferView+":"+s.indices+":"+re(s.attributes):t.indices+":"+re(t.attributes)+":"+t.mode,void 0!==t.targets)for(let s=0,i=t.targets.length;s<i;s++)e+=":"+re(t.targets[s]);return e}function re(t){let e="";const s=Object.keys(t).sort();for(let i=0,n=s.length;i<n;i++)e+=s[i]+":"+t[s[i]]+";";return e}function oe(t){switch(t){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.")}}const ce=new l;class ae{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new dt,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 i=!1,n=-1,r=!1,o=-1;if("undefined"!=typeof navigator){const t=navigator.userAgent;i=!0===/^((?!chrome|android).)*safari/i.test(t);const e=t.match(/Version\/(\d+)/);n=i&&e?parseInt(e[1],10):-1,r=t.indexOf("Firefox")>-1,o=r?t.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||i&&n<17||r&&o<98?this.textureLoader=new _(this.options.manager):this.textureLoader=new E(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new s(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const s=this,i=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this.h(function(t){return t.t&&t.t()}),Promise.all(this.h(function(t){return t.beforeRoot&&t.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(e){const r={scene:e[0][i.scene||0],scenes:e[0],animations:e[1],cameras:e[2],asset:i.asset,parser:s,userData:{}};return ee(n,r,i),se(r,i),Promise.all(s.h(function(t){return t.afterRoot&&t.afterRoot(r)})).then(function(){for(const t of r.scenes)t.updateMatrixWorld();t(r)})}).catch(e)}t(){const t=this.json.nodes||[],e=this.json.skins||[],s=this.json.meshes||[];for(let s=0,i=e.length;s<i;s++){const i=e[s].joints;for(let e=0,s=i.length;e<s;e++)t[i[e]].isBone=!0}for(let e=0,i=t.length;e<i;e++){const i=t[e];void 0!==i.mesh&&(this.i(this.meshCache,i.mesh),void 0!==i.skin&&(s[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this.i(this.cameraCache,i.camera)}}i(t,e){void 0!==e&&(void 0===t.refs[e]&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}u(t,e,s){if(t.refs[e]<=1)return s;const i=s.clone(),n=(t,e)=>{const s=this.associations.get(t);null!=s&&this.associations.set(e,s);for(const[s,i]of t.children.entries())n(i,e.children[s])};return n(s,i),i.name+="_instance_"+t.uses[e]++,i}l(t){const e=Object.values(this.plugins);e.push(this);for(let s=0;s<e.length;s++){const i=t(e[s]);if(i)return i}return null}h(t){const e=Object.values(this.plugins);e.unshift(this);const s=[];for(let i=0;i<e.length;i++){const n=t(e[i]);n&&s.push(n)}return s}getDependency(t,e){const s=t+":"+e;let i=this.cache.get(s);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this.l(function(t){return t.loadNode&&t.loadNode(e)});break;case"mesh":i=this.l(function(t){return t.loadMesh&&t.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this.l(function(t){return t.loadBufferView&&t.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this.l(function(t){return t.loadMaterial&&t.loadMaterial(e)});break;case"texture":i=this.l(function(t){return t.loadTexture&&t.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this.l(function(t){return t.loadAnimation&&t.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this.l(function(s){return s!=this&&s.getDependency&&s.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t)}this.cache.add(s,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const s=this,i=this.json[t+("mesh"===t?"es":"s")]||[];e=Promise.all(i.map(function(e,i){return s.getDependency(t,i)})),this.cache.add(t,e)}return e}loadBuffer(t){const s=this.json.buffers[t],i=this.fileLoader;if(s.type&&"arraybuffer"!==s.type)throw new Error("THREE.GLTFLoader: "+s.type+" buffer type is not supported.");if(void 0===s.uri&&0===t)return Promise.resolve(this.extensions[mt.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(t,r){i.load(e.resolveURL(s.uri,n.path),t,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(t){const s=e.byteLength||0,i=e.byteOffset||0;return t.slice(i,i+s)})}loadAccessor(t){const e=this,s=this.json,i=this.json.accessors[t];if(void 0===i.bufferView&&void 0===i.sparse){const t=qt[i.type],e=Bt[i.componentType],s=!0===i.normalized,n=new e(i.count*t);return Promise.resolve(new p(n,t,s))}const n=[];return void 0!==i.bufferView?n.push(this.getDependency("bufferView",i.bufferView)):n.push(null),void 0!==i.sparse&&(n.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(n).then(function(t){const n=t[0],r=qt[i.type],o=Bt[i.componentType],c=o.BYTES_PER_ELEMENT,a=c*r,u=i.byteOffset||0,h=void 0!==i.bufferView?s.bufferViews[i.bufferView].byteStride:void 0,f=!0===i.normalized;let l,d;if(h&&h!==a){const t=Math.floor(u/h),s="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+t+":"+i.count;let a=e.cache.get(s);a||(l=new o(n,t*h,i.count*h/c),a=new R(l,h/c),e.cache.add(s,a)),d=new A(a,r,u%h/c,f)}else l=null===n?new o(i.count*r):new o(n,u,i.count*r),d=new p(l,r,f);if(void 0!==i.sparse){const e=qt.SCALAR,s=Bt[i.sparse.indices.componentType],c=i.sparse.indices.byteOffset||0,a=i.sparse.values.byteOffset||0,u=new s(t[1],c,i.sparse.count*e),h=new o(t[2],a,i.sparse.count*r);null!==n&&(d=new p(d.array.slice(),d.itemSize,d.normalized)),d.normalized=!1;for(let t=0,e=u.length;t<e;t++){const e=u[t];if(d.setX(e,h[t*r]),r>=2&&d.setY(e,h[t*r+1]),r>=3&&d.setZ(e,h[t*r+2]),r>=4&&d.setW(e,h[t*r+3]),r>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}d.normalized=f}return d})}loadTexture(t){const e=this.json,s=this.options,i=e.textures[t].source,n=e.images[i];let r=this.textureLoader;if(n.uri){const t=s.manager.getHandler(n.uri);null!==t&&(r=t)}return this.loadTextureImage(t,i,r)}loadTextureImage(t,e,s){const i=this,n=this.json,r=n.textures[t],o=n.images[e],c=(o.uri||o.bufferView)+":"+r.sampler;if(this.textureCache[c])return this.textureCache[c];const a=this.loadImageSource(e,s).then(function(e){e.flipY=!1,e.name=r.name||o.name||"",""===e.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(e.name=o.uri);const s=(n.samplers||{})[r.sampler]||{};return e.magFilter=jt[s.magFilter]||P,e.minFilter=jt[s.minFilter]||M,e.wrapS=Jt[s.wrapS]||L,e.wrapT=Jt[s.wrapT]||L,e.generateMipmaps=!e.isCompressedTexture&&e.minFilter!==g&&e.minFilter!==P,i.associations.set(e,{textures:t}),e}).catch(function(){return null});return this.textureCache[c]=a,a}loadImageSource(t,s){const i=this,n=this.json,r=this.options;if(void 0!==this.sourceCache[t])return this.sourceCache[t].then(t=>t.clone());const o=n.images[t],c=self.URL||self.webkitURL;let a=o.uri||"",u=!1;if(void 0!==o.bufferView)a=i.getDependency("bufferView",o.bufferView).then(function(t){u=!0;const e=new Blob([t],{type:o.mimeType});return a=c.createObjectURL(e),a});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const h=Promise.resolve(a).then(function(t){return new Promise(function(i,n){let o=i;!0===s.isImageBitmapLoader&&(o=function(t){const e=new st(t);e.needsUpdate=!0,i(e)}),s.load(e.resolveURL(t,r.path),o,void 0,n)})}).then(function(t){var e;return!0===u&&c.revokeObjectURL(a),se(t,o),t.userData.mimeType=o.mimeType||((e=o.uri).search(/\.jpe?g($|\?)/i)>0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":e.search(/\.ktx2($|\?)/i)>0||0===e.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),t}).catch(function(t){throw t});return this.sourceCache[t]=h,h}assignTexture(t,e,s,i){const n=this;return this.getDependency("texture",s.index).then(function(r){if(!r)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((r=r.clone()).channel=s.texCoord),n.extensions[mt.KHR_TEXTURE_TRANSFORM]){const t=void 0!==s.extensions?s.extensions[mt.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=n.associations.get(r);r=n.extensions[mt.KHR_TEXTURE_TRANSFORM].extendTexture(r,t),n.associations.set(r,e)}}return void 0!==i&&(r.colorSpace=i),t[e]=r,r})}assignFinalMaterial(t){const e=t.geometry;let s=t.material;const i=void 0===e.attributes.tangent,n=void 0!==e.attributes.color,r=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+s.uuid;let e=this.cache.get(t);e||(e=new I,S.prototype.copy.call(e,s),e.color.copy(s.color),e.map=s.map,e.sizeAttenuation=!1,this.cache.add(t,e)),s=e}else if(t.isLine){const t="LineBasicMaterial:"+s.uuid;let e=this.cache.get(t);e||(e=new y,S.prototype.copy.call(e,s),e.color.copy(s.color),e.map=s.map,this.cache.add(t,e)),s=e}if(i||n||r){let t="ClonedMaterial:"+s.uuid+":";i&&(t+="derivative-tangents:"),n&&(t+="vertex-colors:"),r&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=s.clone(),n&&(e.vertexColors=!0),r&&(e.flatShading=!0),i&&(e.normalScale&&(e.normalScale.y*=-1),e.clearcoatNormalScale&&(e.clearcoatNormalScale.y*=-1)),this.cache.add(t,e),this.associations.set(e,this.associations.get(s))),s=e}t.material=s}getMaterialType(){return b}loadMaterial(t){const e=this,s=this.json,r=this.extensions,o=s.materials[t];let c;const h={},l=[];if((o.extensions||{})[mt.KHR_MATERIALS_UNLIT]){const t=r[mt.KHR_MATERIALS_UNLIT];c=t.getMaterialType(),l.push(t.extendParams(h,o,e))}else{const s=o.pbrMetallicRoughness||{};if(h.color=new i(1,1,1),h.opacity=1,Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;h.color.setRGB(t[0],t[1],t[2],n),h.opacity=t[3]}void 0!==s.baseColorTexture&&l.push(e.assignTexture(h,"map",s.baseColorTexture,u)),h.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,h.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(l.push(e.assignTexture(h,"metalnessMap",s.metallicRoughnessTexture)),l.push(e.assignTexture(h,"roughnessMap",s.metallicRoughnessTexture))),c=this.l(function(e){return e.getMaterialType&&e.getMaterialType(t)}),l.push(Promise.all(this.h(function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,h)})))}!0===o.doubleSided&&(h.side=H);const d=o.alphaMode||$t;if(d===Zt?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,d===Qt&&(h.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&c!==a&&(l.push(e.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new f(1,1),void 0!==o.normalTexture.scale)){const t=o.normalTexture.scale;h.normalScale.set(t,t)}if(void 0!==o.occlusionTexture&&c!==a&&(l.push(e.assignTexture(h,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(h.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&c!==a){const t=o.emissiveFactor;h.emissive=(new i).setRGB(t[0],t[1],t[2],n)}return void 0!==o.emissiveTexture&&c!==a&&l.push(e.assignTexture(h,"emissiveMap",o.emissiveTexture,u)),Promise.all(l).then(function(){const s=new c(h);return o.name&&(s.name=o.name),se(s,o),e.associations.set(s,{materials:t}),o.extensions&&ee(r,s,o),s})}createUniqueName(t){const e=O.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,s=this.extensions,i=this.primitiveCache;function n(t){return s[mt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then(function(s){return ue(s,t,e)})}const r=[];for(let s=0,o=t.length;s<o;s++){const o=t[s],c=ne(o),a=i[c];if(a)r.push(a.promise);else{let t;t=o.extensions&&o.extensions[mt.KHR_DRACO_MESH_COMPRESSION]?n(o):ue(new N,o,e),i[c]={primitive:o,promise:t},r.push(t)}}return Promise.all(r)}loadMesh(t){const e=this,s=this.json,i=this.extensions,n=s.meshes[t],r=n.primitives,o=[];for(let t=0,e=r.length;t<e;t++){const e=void 0===r[t].material?te(this.cache):this.getDependency("material",r[t].material);o.push(e)}return o.push(e.loadGeometries(r)),Promise.all(o).then(function(s){const o=s.slice(0,s.length-1),c=s[s.length-1],a=[];for(let s=0,u=c.length;s<u;s++){const u=c[s],h=r[s];let f;const l=o[s];if(h.mode===Xt.TRIANGLES||h.mode===Xt.TRIANGLE_STRIP||h.mode===Xt.TRIANGLE_FAN||void 0===h.mode)f=!0===n.isSkinnedMesh?new x(u,l):new k(u,l),!0===f.isSkinnedMesh&&f.normalizeSkinWeights(),h.mode===Xt.TRIANGLE_STRIP?f.geometry=ft(f.geometry,it):h.mode===Xt.TRIANGLE_FAN&&(f.geometry=ft(f.geometry,nt));else if(h.mode===Xt.LINES)f=new K(u,l);else if(h.mode===Xt.LINE_STRIP)f=new U(u,l);else if(h.mode===Xt.LINE_LOOP)f=new C(u,l);else{if(h.mode!==Xt.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);f=new F(u,l)}Object.keys(f.geometry.morphAttributes).length>0&&ie(f,n),f.name=e.createUniqueName(n.name||"mesh_"+t),se(f,n),h.extensions&&ee(i,f,h),e.assignFinalMaterial(f),a.push(f)}for(let s=0,i=a.length;s<i;s++)e.associations.set(a[s],{meshes:t,primitives:s});if(1===a.length)return n.extensions&&ee(i,a[0],n),a[0];const u=new G;n.extensions&&ee(i,u,n),e.associations.set(u,{meshes:t});for(let t=0,e=a.length;t<e;t++)u.add(a[t]);return u})}loadCamera(t){let e;const s=this.json.cameras[t],i=s[s.type];if(i)return"perspective"===s.type?e=new D(V.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===s.type&&(e=new X(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),s.name&&(e.name=this.createUniqueName(s.name)),se(e,s),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],s=[];for(let t=0,i=e.joints.length;t<i;t++)s.push(this.m(e.joints[t]));return void 0!==e.inverseBindMatrices?s.push(this.getDependency("accessor",e.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(t){const e=t.pop(),s=t,i=[],n=[];for(let t=0,r=s.length;t<r;t++){const r=s[t];if(r){i.push(r);const s=new l;null!==e&&s.fromArray(e.array,16*t),n.push(s)}}return new B(i,n)})}loadAnimation(t){const e=this.json,s=this,i=e.animations[t],n=i.name?i.name:"animation_"+t,r=[],o=[],c=[],a=[],u=[];for(let t=0,e=i.channels.length;t<e;t++){const e=i.channels[t],s=i.samplers[e.sampler],n=e.target,h=n.node,f=void 0!==i.parameters?i.parameters[s.input]:s.input,l=void 0!==i.parameters?i.parameters[s.output]:s.output;void 0!==n.node&&(r.push(this.getDependency("node",h)),o.push(this.getDependency("accessor",f)),c.push(this.getDependency("accessor",l)),a.push(s),u.push(n))}return Promise.all([Promise.all(r),Promise.all(o),Promise.all(c),Promise.all(a),Promise.all(u)]).then(function(t){const e=t[0],i=t[1],r=t[2],o=t[3],c=t[4],a=[];for(let t=0,n=e.length;t<n;t++){const n=e[t],u=i[t],h=r[t],f=o[t],l=c[t];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();const d=s.v(n,u,h,f,l);if(d)for(let t=0;t<d.length;t++)a.push(d[t])}return new j(n,void 0,a)})}createNodeMesh(t){const e=this.json,s=this,i=e.nodes[t];return void 0===i.mesh?null:s.getDependency("mesh",i.mesh).then(function(t){const e=s.u(s.meshCache,i.mesh,t);return void 0!==i.weights&&e.traverse(function(t){if(t.isMesh)for(let e=0,s=i.weights.length;e<s;e++)t.morphTargetInfluences[e]=i.weights[e]}),e})}loadNode(t){const e=this,s=this.json.nodes[t],i=e.m(t),n=[],r=s.children||[];for(let t=0,s=r.length;t<s;t++)n.push(e.getDependency("node",r[t]));const o=void 0===s.skin?Promise.resolve(null):e.getDependency("skin",s.skin);return Promise.all([i,Promise.all(n),o]).then(function(t){const e=t[0],s=t[1],i=t[2];null!==i&&e.traverse(function(t){t.isSkinnedMesh&&t.bind(i,ce)});for(let t=0,i=s.length;t<i;t++)e.add(s[t]);return e})}m(t){const e=this.json,s=this.extensions,i=this;if(void 0!==this.nodeCache[t])return this.nodeCache[t];const n=e.nodes[t],r=n.name?i.createUniqueName(n.name):"",o=[],c=i.l(function(e){return e.createNodeMesh&&e.createNodeMesh(t)});return c&&o.push(c),void 0!==n.camera&&o.push(i.getDependency("camera",n.camera).then(function(t){return i.u(i.cameraCache,n.camera,t)})),i.h(function(e){return e.createNodeAttachment&&e.createNodeAttachment(t)}).forEach(function(t){o.push(t)}),this.nodeCache[t]=Promise.all(o).then(function(e){let o;if(o=!0===n.isBone?new J:e.length>1?new G:1===e.length?e[0]:new T,o!==e[0])for(let t=0,s=e.length;t<s;t++)o.add(e[t]);if(n.name&&(o.userData.name=n.name,o.name=r),se(o,n),n.extensions&&ee(s,o,n),void 0!==n.matrix){const t=new l;t.fromArray(n.matrix),o.applyMatrix4(t)}else void 0!==n.translation&&o.position.fromArray(n.translation),void 0!==n.rotation&&o.quaternion.fromArray(n.rotation),void 0!==n.scale&&o.scale.fromArray(n.scale);if(i.associations.has(o)){if(void 0!==n.mesh&&i.meshCache.refs[n.mesh]>1){const t=i.associations.get(o);i.associations.set(o,{...t})}}else i.associations.set(o,{});return i.associations.get(o).nodes=t,o}),this.nodeCache[t]}loadScene(t){const e=this.extensions,s=this.json.scenes[t],i=this,n=new G;s.name&&(n.name=i.createUniqueName(s.name)),se(n,s),s.extensions&&ee(e,n,s);const r=s.nodes||[],o=[];for(let t=0,e=r.length;t<e;t++)o.push(i.getDependency("node",r[t]));return Promise.all(o).then(function(t){for(let e=0,s=t.length;e<s;e++)n.add(t[e]);return i.associations=(t=>{const e=new Map;for(const[t,s]of i.associations)(t instanceof S||t instanceof st)&&e.set(t,s);return t.traverse(t=>{const s=i.associations.get(t);null!=s&&e.set(t,s)}),e})(n),n})}v(t,e,s,i,n){const r=[],o=t.name?t.name:t.uuid,c=[];let a;switch(Wt[n.path]===Wt.weights?t.traverse(function(t){t.morphTargetInfluences&&c.push(t.name?t.name:t.uuid)}):c.push(o),Wt[n.path]){case Wt.weights:a=ot;break;case Wt.rotation:a=ct;break;case Wt.translation:case Wt.scale:a=rt;break;default:if(1===s.itemSize)a=ot;else a=rt}const u=void 0!==i.interpolation?Yt[i.interpolation]:q,h=this.T(s);for(let t=0,s=c.length;t<s;t++){const s=new a(c[t]+"."+Wt[n.path],e.array,h,u);"CUBICSPLINE"===i.interpolation&&this._(s),r.push(s)}return r}T(t){let e=t.array;if(t.normalized){const t=oe(e.constructor),s=new Float32Array(e.length);for(let i=0,n=e.length;i<n;i++)s[i]=e[i]*t;e=s}return e}_(t){t.createInterpolant=function(t){return new(this instanceof ct?Vt:Gt)(this.times,this.values,this.getValueSize()/3,t)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ue(t,e,s){const i=e.attributes,n=[];function r(e,i){return s.getDependency("accessor",e).then(function(e){t.setAttribute(i,e)})}for(const e in i){const s=zt[e]||e.toLowerCase();s in t.attributes||n.push(r(i[e],s))}if(void 0!==e.indices&&!t.index){const i=s.getDependency("accessor",e.indices).then(function(e){t.setIndex(e)});n.push(i)}return z.workingColorSpace,se(t,e),function(t,e,s){const i=e.attributes,n=new at;if(void 0===i.POSITION)return;{const t=s.json.accessors[i.POSITION],e=t.min,r=t.max;if(void 0===e||void 0===r)return;if(n.set(new d(e[0],e[1],e[2]),new d(r[0],r[1],r[2])),t.normalized){const e=oe(Bt[t.componentType]);n.min.multiplyScalar(e),n.max.multiplyScalar(e)}}const r=e.targets;if(void 0!==r){const t=new d,e=new d;for(let i=0,n=r.length;i<n;i++){const n=r[i];if(void 0!==n.POSITION){const i=s.json.accessors[n.POSITION],r=i.min,o=i.max;if(void 0!==r&&void 0!==o){if(e.setX(Math.max(Math.abs(r[0]),Math.abs(o[0]))),e.setY(Math.max(Math.abs(r[1]),Math.abs(o[1]))),e.setZ(Math.max(Math.abs(r[2]),Math.abs(o[2]))),i.normalized){const t=oe(Bt[i.componentType]);e.multiplyScalar(t)}t.max(e)}}}n.expandByVector(t)}t.boundingBox=n;const o=new ut;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,t.boundingSphere=o}(t,e,s),Promise.all(n).then(function(){return void 0!==e.targets?function(t,e,s){let i=!1,n=!1,r=!1;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(void 0!==s.POSITION&&(i=!0),void 0!==s.NORMAL&&(n=!0),void 0!==s.COLOR_0&&(r=!0),i&&n&&r)break}if(!i&&!n&&!r)return Promise.resolve(t);const o=[],c=[],a=[];for(let u=0,h=e.length;u<h;u++){const h=e[u];if(i){const e=void 0!==h.POSITION?s.getDependency("accessor",h.POSITION):t.attributes.position;o.push(e)}if(n){const e=void 0!==h.NORMAL?s.getDependency("accessor",h.NORMAL):t.attributes.normal;c.push(e)}if(r){const e=void 0!==h.COLOR_0?s.getDependency("accessor",h.COLOR_0):t.attributes.color;a.push(e)}}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(a)]).then(function(e){const s=e[0],o=e[1],c=e[2];return i&&(t.morphAttributes.position=s),n&&(t.morphAttributes.normal=o),r&&(t.morphAttributes.color=c),t.morphTargetsRelative=!0,t})}(t,e.targets,s):t})}export{lt as GLTFLoader};
@@ -1 +1 @@
1
- import{DataTextureLoader as t,HalfFloatType as r,FloatType as n,DataUtils as e,LinearEncoding as s,LinearFilter as i}from"three";class o extends t{constructor(t){super(t),this.type=r}parse(t){const s=function(t,r){return-1},i=function(t,r,n){r=r||1024;let e=t.pos,s=-1,i=0,o="",a=String.fromCharCode.apply(null,new Uint16Array(t.subarray(e,e+128)));for(;0>(s=a.indexOf("\n"))&&i<r&&e<t.byteLength;)o+=a,i+=a.length,e+=128,a+=String.fromCharCode.apply(null,new Uint16Array(t.subarray(e,e+128)));return-1<s&&(!1!==n&&(t.pos+=i+s+1),o+a.slice(0,s))},o=function(t,r,n,e){const s=t[r+3],i=Math.pow(2,s-128)/255;n[e+0]=t[r+0]*i,n[e+1]=t[r+1]*i,n[e+2]=t[r+2]*i,n[e+3]=1},a=function(t,r,n,s){const i=t[r+3],o=Math.pow(2,i-128)/255;n[s+0]=e.toHalfFloat(Math.min(t[r+0]*o,65504)),n[s+1]=e.toHalfFloat(Math.min(t[r+1]*o,65504)),n[s+2]=e.toHalfFloat(Math.min(t[r+2]*o,65504)),n[s+3]=e.toHalfFloat(1)},c=new Uint8Array(t);c.pos=0;const u=function(t){const r=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,e=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,o={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let a,c;if(t.pos>=t.byteLength||!(a=i(t)))return-1;if(!(c=a.match(/^#\?(\S+)/)))return-1;for(o.valid|=1,o.programtype=c[1],o.string+=a+"\n";a=i(t),!1!==a;)if(o.string+=a+"\n","#"!==a.charAt(0)){if((c=a.match(r))&&(o.gamma=parseFloat(c[1])),(c=a.match(n))&&(o.exposure=parseFloat(c[1])),(c=a.match(e))&&(o.valid|=2,o.format=c[1]),(c=a.match(s))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=a+"\n";return 2&o.valid&&4&o.valid?o:-1}(c);if(-1!==u){const t=u.width,e=u.height,i=function(t,r,n){const e=r;if(e<8||e>32767||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);if(e!==(t[2]<<8|t[3]))return-1;const i=new Uint8Array(4*r*n);if(!i.length)return-1;let o=0,a=0;const c=4*e,u=new Uint8Array(4),f=new Uint8Array(c);let l=n;for(;l>0&&a<t.byteLength;){if(a+4>t.byteLength)return s();if(u[0]=t[a++],u[1]=t[a++],u[2]=t[a++],u[3]=t[a++],2!=u[0]||2!=u[1]||(u[2]<<8|u[3])!=e)return s();let r,n=0;for(;n<c&&a<t.byteLength;){r=t[a++];const e=r>128;if(e&&(r-=128),0===r||n+r>c)return s();if(e){const e=t[a++];for(let t=0;t<r;t++)f[n++]=e}else f.set(t.subarray(a,a+r),n),n+=r,a+=r}const h=e;for(let t=0;t<h;t++){let r=0;i[o]=f[t+r],r+=e,i[o+1]=f[t+r],r+=e,i[o+2]=f[t+r],r+=e,i[o+3]=f[t+r],o+=4}l--}return i}(c.subarray(c.pos),t,e);if(-1!==i){let s,c,f;switch(this.type){case n:f=i.length/4;const t=new Float32Array(4*f);for(let r=0;r<f;r++)o(i,4*r,t,4*r);s=t,c=n;break;case r:f=i.length/4;const e=new Uint16Array(4*f);for(let t=0;t<f;t++)a(i,4*t,e,4*t);s=e,c=r}return{width:t,height:e,data:s,header:u.string,gamma:u.gamma,exposure:u.exposure,type:c}}}return null}setDataType(t){return this.type=t,this}load(t,e,o,a){return super.load(t,function(t,o){switch(t.type){case n:case r:t.encoding=s,t.minFilter=i,t.magFilter=i,t.generateMipmaps=!1,t.flipY=!0}e&&e(t,o)},o,a)}}export{o as RGBELoader};
1
+ import{DataTextureLoader as r,HalfFloatType as t,FloatType as e,DataUtils as n,LinearSRGBColorSpace as a,LinearFilter as s}from"three";class o extends r{constructor(r){super(r),this.type=t}parse(r){const a=function(r,t){switch(r){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:throw new Error("THREE.RGBELoader: Memory Error: "+(t||""))}},s=function(r,t,e){t=t||1024;let n=r.pos,a=-1,s=0,o="",i=String.fromCharCode.apply(null,new Uint16Array(r.subarray(n,n+128)));for(;0>(a=i.indexOf("\n"))&&s<t&&n<r.byteLength;)o+=i,s+=i.length,n+=128,i+=String.fromCharCode.apply(null,new Uint16Array(r.subarray(n,n+128)));return-1<a&&(!1!==e&&(r.pos+=s+a+1),o+i.slice(0,a))},o=function(r,t,e,n){const a=r[t+3],s=Math.pow(2,a-128)/255;e[n+0]=r[t+0]*s,e[n+1]=r[t+1]*s,e[n+2]=r[t+2]*s,e[n+3]=1},i=function(r,t,e,a){const s=r[t+3],o=Math.pow(2,s-128)/255;e[a+0]=n.toHalfFloat(Math.min(r[t+0]*o,65504)),e[a+1]=n.toHalfFloat(Math.min(r[t+1]*o,65504)),e[a+2]=n.toHalfFloat(Math.min(r[t+2]*o,65504)),e[a+3]=n.toHalfFloat(1)},c=new Uint8Array(r);c.pos=0;const l=function(r){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,e=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,i={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let c,l;for((r.pos>=r.byteLength||!(c=s(r)))&&a(1,"no header found"),(l=c.match(/^#\?(\S+)/))||a(3,"bad initial token"),i.valid|=1,i.programtype=l[1],i.string+=c+"\n";c=s(r),!1!==c;)if(i.string+=c+"\n","#"!==c.charAt(0)){if((l=c.match(t))&&(i.gamma=parseFloat(l[1])),(l=c.match(e))&&(i.exposure=parseFloat(l[1])),(l=c.match(n))&&(i.valid|=2,i.format=l[1]),(l=c.match(o))&&(i.valid|=4,i.height=parseInt(l[1],10),i.width=parseInt(l[2],10)),2&i.valid&&4&i.valid)break}else i.comments+=c+"\n";return 2&i.valid||a(3,"missing format specifier"),4&i.valid||a(3,"missing image size specifier"),i}(c),d=l.width,f=l.height,h=function(r,t,e){const n=t;if(n<8||n>32767||2!==r[0]||2!==r[1]||128&r[2])return new Uint8Array(r);n!==(r[2]<<8|r[3])&&a(3,"wrong scanline width");const s=new Uint8Array(4*t*e);s.length||a(4,"unable to allocate buffer space");let o=0,i=0;const c=4*n,l=new Uint8Array(4),d=new Uint8Array(c);let f=e;for(;f>0&&i<r.byteLength;){i+4>r.byteLength&&a(1),l[0]=r[i++],l[1]=r[i++],l[2]=r[i++],l[3]=r[i++],2==l[0]&&2==l[1]&&(l[2]<<8|l[3])==n||a(3,"bad rgbe scanline format");let t,e=0;for(;e<c&&i<r.byteLength;){t=r[i++];const n=t>128;if(n&&(t-=128),(0===t||e+t>c)&&a(3,"bad scanline data"),n){const n=r[i++];for(let r=0;r<t;r++)d[e++]=n}else d.set(r.subarray(i,i+t),e),e+=t,i+=t}const h=n;for(let r=0;r<h;r++){let t=0;s[o]=d[r+t],t+=n,s[o+1]=d[r+t],t+=n,s[o+2]=d[r+t],t+=n,s[o+3]=d[r+t],o+=4}f--}return s}(c.subarray(c.pos),d,f);let u,w,E;switch(this.type){case e:E=h.length/4;const r=new Float32Array(4*E);for(let t=0;t<E;t++)o(h,4*t,r,4*t);u=r,w=e;break;case t:E=h.length/4;const n=new Uint16Array(4*E);for(let r=0;r<E;r++)i(h,4*r,n,4*r);u=n,w=t;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:d,height:f,data:u,header:l.string,gamma:l.gamma,exposure:l.exposure,type:w}}setDataType(r){return this.type=r,this}load(r,n,o,i){return super.load(r,function(r,o){switch(r.type){case e:case t:r.colorSpace=a,r.minFilter=s,r.magFilter=s,r.generateMipmaps=!1,r.flipY=!0}n&&n(r,o)},o,i)}}export{o as RGBELoader};
@@ -0,0 +1 @@
1
+ import{Object3D as t,Vector2 as n,Vector3 as e,Matrix4 as o}from"three";class i extends t{constructor(t=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=t,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new n(.5,.5),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&null!==t.element.parentNode&&t.element.remove()})})}copy(t,n){return super.copy(t,n),this.element=t.element.cloneNode(!0),this.center=t.center,this}}const s=new e,c=new o,r=new o,u=new e,h=new e;class f{constructor(t={}){const n=this;let e,o,i,f;const a={objects:new WeakMap},l=void 0!==t.element?t.element:document.createElement("div");function d(t){t.isCSS2DObject&&(t.element.style.display="none");for(let n=0,e=t.children.length;n<e;n++)d(t.children[n])}function p(t,e,o){if(!1!==t.visible){if(t.isCSS2DObject){s.setFromMatrixPosition(t.matrixWorld),s.applyMatrix4(r);const c=s.z>=-1&&s.z<=1&&!0===t.layers.test(o.layers),u=t.element;u.style.display=!0===c?"":"none",!0===c&&(t.onBeforeRender(n,e,o),u.style.transform="translate("+-100*t.center.x+"%,"+-100*t.center.y+"%)translate("+(s.x*i+i)+"px,"+(-s.y*f+f)+"px)",u.parentNode!==l&&l.appendChild(u),t.onAfterRender(n,e,o));const h={distanceToCameraSquared:w(o,t)};a.objects.set(t,h)}for(let n=0,i=t.children.length;n<i;n++)p(t.children[n],e,o)}else d(t)}function w(t,n){return u.setFromMatrixPosition(t.matrixWorld),h.setFromMatrixPosition(n.matrixWorld),u.distanceToSquared(h)}l.style.overflow="hidden",this.domElement=l,this.getSize=function(){return{width:e,height:o}},this.render=function(t,n){!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),c.copy(n.matrixWorldInverse),r.multiplyMatrices(n.projectionMatrix,c),p(t,t,n),function(t){const n=function(t){const n=[];return t.traverseVisible(function(t){t.isCSS2DObject&&n.push(t)}),n}(t).sort(function(t,n){if(t.renderOrder!==n.renderOrder)return n.renderOrder-t.renderOrder;return a.objects.get(t).distanceToCameraSquared-a.objects.get(n).distanceToCameraSquared}),e=n.length;for(let t=0,o=n.length;t<o;t++)n[t].element.style.zIndex=e-t}(t)},this.setSize=function(t,n){e=t,o=n,i=e/2,f=o/2,l.style.width=t+"px",l.style.height=n+"px"}}}export{i as CSS2DObject,f as CSS2DRenderer};
@@ -0,0 +1 @@
1
+ import{createClass as e,classCallCheck as t}from"../../_virtual/_rollupPluginBabelHelpers.js";import*as n from"three";import{logger as i}from"../core/debugLogger.js";var a=function(){return e(function e(){t(this,e),this.analysisHistory=[],this.validationRules=new Map,this.adjustmentStrategies=new Map,this.initializeDefaultRules()},[{key:"initializeDefaultRules",value:function(){this.addValidationRule("component_bounds",{check:function(e){var t=(new n.Box3).setFromObject(e);return!t.isEmpty()&&t.getSize(new n.Vector3).length()>0},message:"Component has invalid bounding box"}),this.addValidationRule("component_position",{check:function(e){var t=e.position;return!isNaN(t.x)&&!isNaN(t.y)&&!isNaN(t.z)&&isFinite(t.x)&&isFinite(t.y)&&isFinite(t.z)},message:"Component has invalid position values"}),this.addValidationRule("component_scale",{check:function(e){var t=e.scale;return t.x>0&&t.y>0&&t.z>0&&t.x<1e3&&t.y<1e3&&t.z<1e3},message:"Component has invalid scale values"}),this.addValidationRule("scene_complexity",{check:function(e){var t=0;return e.traverse(function(e){e.isMesh&&t++}),t<1e4},message:"Scene complexity too high (too many meshes)"})}},{key:"addValidationRule",value:function(e,t){this.validationRules.set(e,t)}},{key:"addAdjustmentStrategy",value:function(e,t){this.adjustmentStrategies.set(e,t)}},{key:"analyzeScene",value:function(e){var t=performance.now();i.info("๐Ÿ” Starting scene analysis...");var n={timestamp:(new Date).toISOString(),performance:{},structure:{},quality:{},recommendations:[]},a=0,r=0,s=0,o=0,u=new Set,c=new Set;e.traverse(function(e){if(e.isMesh){if(a++,e.geometry){r++;var t=e.geometry.getAttribute("position");t&&(s+=t.count,e.geometry.index?o+=e.geometry.index.count/3:o+=t.count/3)}if(e.material)if(Array.isArray(e.material))e.material.forEach(function(e){return u.add(e.uuid)});else{u.add(e.material.uuid);var n=e.material;Object.keys(n).forEach(function(e){n[e]&&n[e].isTexture&&c.add(n[e].uuid)})}}}),n.performance={meshCount:a,geometryCount:r,materialCount:u.size,textureCount:c.size,vertexCount:s,triangleCount:o,memoryEstimate:this.estimateMemoryUsage(s,u.size,c.size)},n.structure=this.analyzeSceneStructure(e),n.quality=this.analyzeQuality(e),n.recommendations=this.generateRecommendations(n);var l=performance.now();return n.performance.analysisTime=l-t,i.info("โœ… Scene analysis complete in ".concat(n.performance.analysisTime.toFixed(2),"ms")),this.analysisHistory.push(n),n}},{key:"analyzeSceneStructure",value:function(e){var t={depth:0,branches:0,emptyNodes:0,namedObjects:0,groups:0},n=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t.depth=Math.max(t.depth,i),e.children.length>0&&t.branches++,0!==e.children.length||e.isMesh||e.isLight||e.isCamera||t.emptyNodes++,e.name&&""!==e.name.trim()&&t.namedObjects++,e.isGroup&&t.groups++,e.children.forEach(function(e){return n(e,i+1)})};return n(e),t}},{key:"analyzeQuality",value:function(e){var t=this,n={duplicateMaterials:0,unusedMaterials:0,missingTextures:0,invalidTransforms:0,memoryLeaks:[],optimization:{mergeable:[],instancingCandidates:[]}},i=new Map,a=new Map;return e.traverse(function(e){if(e.material){var r=t.getMaterialSignature(e.material);i.has(r)?n.duplicateMaterials++:i.set(r,e.material)}if(e.geometry){var s=t.getGeometrySignature(e.geometry);a.has(s)||a.set(s,[]),a.get(s).push(e)}!e.position||isFinite(e.position.x)&&isFinite(e.position.y)&&isFinite(e.position.z)||n.invalidTransforms++}),a.forEach(function(e,t){e.length>1&&n.optimization.instancingCandidates.push({geometry:t,count:e.length,objects:e.map(function(e){return e.uuid})})}),n}},{key:"generateRecommendations",value:function(e){var t=[];return e.performance.triangleCount>5e5&&t.push({type:"performance",priority:"high",message:"Consider using Level of Detail (LOD) for high polygon models",action:"implement_lod"}),e.performance.materialCount>50&&t.push({type:"performance",priority:"medium",message:"High material count detected. Consider material atlasing",action:"optimize_materials"}),e.quality.duplicateMaterials>10&&t.push({type:"optimization",priority:"medium",message:"Duplicate materials found. Consider material sharing",action:"merge_materials"}),e.quality.optimization.instancingCandidates.length>0&&t.push({type:"optimization",priority:"high",message:"Instancing opportunities detected for repeated geometries",action:"implement_instancing"}),t}},{key:"validateScene",value:function(e){var t=this;i.info("๐Ÿ” Validating scene components...");var n={passed:[],failed:[],warnings:[]};return this.validationRules.forEach(function(t,i){try{t.check(e)?n.passed.push({rule:i,target:"scene"}):n.failed.push({rule:i,target:"scene",message:t.message})}catch(e){n.warnings.push({rule:i,target:"scene",message:"Validation error: ".concat(e.message)})}}),e.traverse(function(e){e.isMesh&&t.validationRules.forEach(function(t,i){try{t.check(e)?n.passed.push({rule:i,target:e.uuid}):n.failed.push({rule:i,target:e.uuid,message:t.message,objectName:e.name||"Unnamed Object"})}catch(t){n.warnings.push({rule:i,target:e.uuid,message:"Validation error: ".concat(t.message),objectName:e.name||"Unnamed Object"})}})}),i.info("โœ… Validation complete: ".concat(n.passed.length," passed, ").concat(n.failed.length," failed, ").concat(n.warnings.length," warnings")),n}},{key:"applyAdjustments",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];i.info("๐Ÿ”ง Applying scene adjustments...");var a={applied:[],failed:[],skipped:[]};return n.forEach(function(n){var i=t.adjustmentStrategies.get(n.type);if(i)try{var r=i(e,n.options||{});a.applied.push({adjustment:n.type,result:r})}catch(e){a.failed.push({adjustment:n.type,error:e.message})}else a.skipped.push({adjustment:n.type,reason:"No strategy found"})}),i.info("โœ… Adjustments complete: ".concat(a.applied.length," applied, ").concat(a.failed.length," failed, ").concat(a.skipped.length," skipped")),a}},{key:"getMaterialSignature",value:function(e){var t={type:e.type,color:e.color?e.color.getHex():null,metalness:e.metalness,roughness:e.roughness,transparent:e.transparent,opacity:e.opacity};return JSON.stringify(t)}},{key:"getGeometrySignature",value:function(e){var t,n=Object.keys(e.attributes),i=(null===(t=e.getAttribute("position"))||void 0===t?void 0:t.count)||0,a=!!e.index;return"".concat(e.type,"_").concat(i,"_").concat(a,"_").concat(n.join(","))}},{key:"estimateMemoryUsage",value:function(e,t,n){var i=32*e,a=1024*t,r=1048576*n,s=i+a+r;return{geometry:this.formatBytes(i),materials:this.formatBytes(a),textures:this.formatBytes(r),total:this.formatBytes(s),totalBytes:s}}},{key:"formatBytes",value:function(e){if(0===e)return"0 Bytes";var t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]}},{key:"getAnalysisHistory",value:function(){return this.analysisHistory}},{key:"clearHistory",value:function(){this.analysisHistory=[]}},{key:"dispose",value:function(){this.clearHistory(),this.validationRules.clear(),this.adjustmentStrategies.clear(),i.info("Analysis disposed")}}])}();export{a as Analysis};
@@ -0,0 +1 @@
1
+ import{createClass as e,typeof as t,createForOfIteratorHelper as r,slicedToArray as n,classCallCheck as o,defineProperty as s,objectSpread2 as i,asyncToGenerator as a,regenerator as u}from"../../_virtual/_rollupPluginBabelHelpers.js";import{logger as c}from"../core/debugLogger.js";var f=function(){return e(function e(){var t,r=this;o(this,e),s(this,"mock",{create:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=i({calls:[],callCount:0},e);return Object.keys(e).forEach(function(r){var n=e[r];t[r]=function(){for(var e=arguments.length,o=new Array(e),s=0;s<e;s++)o[s]=arguments[s];return t.calls.push({method:r,args:o,timestamp:Date.now()}),t.callCount++,n.apply(void 0,o)}}),t},spy:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){},t=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return t.calls.push({args:n,timestamp:Date.now()}),t.callCount++,void 0!==t.returnValue?t.returnValue:e.apply(void 0,n)};return t.calls=[],t.callCount=0,t.returnValue=void 0,t.returns=function(e){return t.returnValue=e,t},t.throws=function(e){return t.throwError=e,t},t},three:{vector3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return{x:e,y:t,z:r,set:function(n,o,s){e=n,t=o,r=s},clone:function(){return{x:e,y:t,z:r}},add:function(n){return{x:e+n.x,y:t+n.y,z:r+n.z}},sub:function(n){return{x:e-n.x,y:t-n.y,z:r-n.z}},length:function(){return Math.sqrt(e*e+t*t+r*r)},normalize:function(){var n=Math.sqrt(e*e+t*t+r*r);return{x:e/n,y:t/n,z:r/n}}}},object3D:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},children:[],parent:null,name:e.name||"",uuid:e.uuid||Math.random().toString(36),add:function(e){this.children.push(e),e.parent=this},remove:function(e){var t=this.children.indexOf(e);t>-1&&this.children.splice(t,1)},traverse:function(e){e(this),this.children.forEach(function(t){return t.traverse(e)})}}},scene:function(){return i(i({},r.mock.three.object3D()),{},{background:null,environment:null,fog:null,type:"Scene"})}}}),s(this,"benchmark",{run:(t=a(u().m(function e(t,n){var o,s,i,a,f,h,d,l,p,m,w,v,E,g,y,b,k,x,T,M=arguments;return u().w(function(e){for(;;)switch(e.n){case 0:s=(o=M.length>2&&void 0!==M[2]?M[2]:{}).iterations,i=void 0===s?1e3:s,a=o.warmupIterations,f=void 0===a?10:a,h=o.timeout,d=void 0===h?5e3:h,c.info("โฑ๏ธ Running benchmark: ".concat(t)),l=0;case 1:if(!(l<f)){e.n=3;break}return e.n=2,n();case 2:l++,e.n=1;break;case 3:p=[],m=performance.now(),w=0;case 4:if(!(w<i)){e.n=7;break}return v=performance.now(),e.n=5,n();case 5:if(E=performance.now(),p.push(E-v),!(performance.now()-m>d)){e.n=6;break}return c.warn('โš ๏ธ Benchmark "'.concat(t,'" timed out after ').concat(w+1," iterations")),e.a(3,7);case 6:w++,e.n=4;break;case 7:return g=performance.now()-m,y=p.reduce(function(e,t){return e+t},0)/p.length,b=Math.min.apply(Math,p),k=Math.max.apply(Math,p),x=p.sort()[Math.floor(p.length/2)],T={name:t,iterations:p.length,totalTime:g,avgTime:y,minTime:b,maxTime:k,medianTime:x,opsPerSecond:1e3/y},r.benchmarks.set(t,T),c.info('โœ… Benchmark "'.concat(t,'" completed: ').concat(T.opsPerSecond.toFixed(2)," ops/sec")),e.a(2,T)}},e)})),function(e,r){return t.apply(this,arguments)}),compare:function(e){var t=e.map(function(e){return r.benchmarks.get(e)}).filter(Boolean);if(t.length<2)throw new Error("Need at least 2 benchmarks to compare");var n=t.reduce(function(e,t){return e.opsPerSecond>t.opsPerSecond?e:t}),o=t.map(function(e){return{name:e.name,opsPerSecond:e.opsPerSecond,relativeSpeed:e.opsPerSecond/n.opsPerSecond,slower:n.opsPerSecond/e.opsPerSecond}});return{fastest:n.name,comparison:o}}}),this.testSuites=new Map,this.testResults=[],this.mockData=new Map,this.assertions=new Map,this.benchmarks=new Map,this.setupDefaultAssertions()},[{key:"setupDefaultAssertions",value:function(){this.addAssertion("equals",function(e,t,r){if(e!==t)throw new Error(r||"Expected ".concat(t,", got ").concat(e))}),this.addAssertion("notEquals",function(e,t,r){if(e===t)throw new Error(r||"Expected not ".concat(t,", got ").concat(e))}),this.addAssertion("deepEquals",function(e,t,r){if(JSON.stringify(e)!==JSON.stringify(t))throw new Error(r||"Deep equality failed")}),this.addAssertion("true",function(e,t){if(!0!==e)throw new Error(t||"Expected true, got ".concat(e))}),this.addAssertion("false",function(e,t){if(!1!==e)throw new Error(t||"Expected false, got ".concat(e))}),this.addAssertion("truthy",function(e,t){if(!e)throw new Error(t||"Expected truthy value, got ".concat(e))}),this.addAssertion("falsy",function(e,t){if(e)throw new Error(t||"Expected falsy value, got ".concat(e))}),this.addAssertion("null",function(e,t){if(null!==e)throw new Error(t||"Expected null, got ".concat(e))}),this.addAssertion("undefined",function(e,t){if(void 0!==e)throw new Error(t||"Expected undefined, got ".concat(e))}),this.addAssertion("defined",function(e,t){if(void 0===e)throw new Error(t||"Expected defined value, got undefined")}),this.addAssertion("instanceOf",function(e,r,n){if(!(e instanceof r))throw new Error(n||"Expected instance of ".concat(r.name,", got ").concat(t(e)))}),this.addAssertion("typeof",function(e,r,n){if(t(e)!==r)throw new Error(n||"Expected type ".concat(r,", got ").concat(t(e)))}),this.addAssertion("greaterThan",function(e,t,r){if(e<=t)throw new Error(r||"Expected ".concat(e," > ").concat(t))}),this.addAssertion("lessThan",function(e,t,r){if(e>=t)throw new Error(r||"Expected ".concat(e," < ").concat(t))}),this.addAssertion("greaterThanOrEqual",function(e,t,r){if(e<t)throw new Error(r||"Expected ".concat(e," >= ").concat(t))}),this.addAssertion("lessThanOrEqual",function(e,t,r){if(e>t)throw new Error(r||"Expected ".concat(e," <= ").concat(t))}),this.addAssertion("approximately",function(e,t,r,n){if(Math.abs(e-t)>r)throw new Error(n||"Expected ".concat(e," โ‰ˆ ").concat(t," (ยฑ").concat(r,")"))}),this.addAssertion("includes",function(e,t,r){if(!e.includes(t))throw new Error(r||'Expected "'.concat(e,'" to include "').concat(t,'"'))}),this.addAssertion("startsWith",function(e,t,r){if(!e.startsWith(t))throw new Error(r||'Expected "'.concat(e,'" to start with "').concat(t,'"'))}),this.addAssertion("endsWith",function(e,t,r){if(!e.endsWith(t))throw new Error(r||'Expected "'.concat(e,'" to end with "').concat(t,'"'))}),this.addAssertion("matches",function(e,t,r){if(!t.test(e))throw new Error(r||'Expected "'.concat(e,'" to match pattern ').concat(t))}),this.addAssertion("hasLength",function(e,t,r){if(e.length!==t)throw new Error(r||"Expected length ".concat(t,", got ").concat(e.length))}),this.addAssertion("isEmpty",function(e,t){if(0!==e.length)throw new Error(t||"Expected empty array/string, got length ".concat(e.length))}),this.addAssertion("isNotEmpty",function(e,t){if(0===e.length)throw new Error(t||"Expected non-empty array/string")}),this.addAssertion("hasProperty",function(e,t,r){if(!e.hasOwnProperty(t))throw new Error(r||'Expected object to have property "'.concat(t,'"'))}),this.addAssertion("hasMethod",function(e,t,r){if("function"!=typeof e[t])throw new Error(r||'Expected object to have method "'.concat(t,'"'))}),this.addAssertion("resolves",function(){var e=a(u().m(function e(t,r){var n;return u().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,t;case 1:e.n=3;break;case 2:throw e.p=2,n=e.v,new Error(r||"Expected promise to resolve, but it rejected: ".concat(n.message));case 3:return e.a(2)}},e,null,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()),this.addAssertion("rejects",function(){var e=a(u().m(function e(t,r){return u().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,e.n=1,t;case 1:throw new Error(r||"Expected promise to reject, but it resolved");case 2:e.p=2,e.v;case 3:return e.a(2)}},e,null,[[0,2]])}));return function(t,r){return e.apply(this,arguments)}}()),this.addAssertion("throws",function(e,t){try{throw e(),new Error(t||"Expected function to throw, but it didn't")}catch(e){}})}},{key:"addAssertion",value:function(e,t){this.assertions.set(e,t)}},{key:"createTestSuite",value:function(e){var t=this,r={name:e,tests:[],beforeEach:null,afterEach:null,beforeAll:null,afterAll:null,setup:arguments.length>1&&void 0!==arguments[1]?arguments[1]:null};return this.testSuites.set(e,r),{test:function(r,n){return t.addTest(e,r,n)},beforeEach:function(e){r.beforeEach=e},afterEach:function(e){r.afterEach=e},beforeAll:function(e){r.beforeAll=e},afterAll:function(e){r.afterAll=e}}}},{key:"addTest",value:function(e,t,r){var n=this.testSuites.get(e);if(!n)throw new Error('Test suite "'.concat(e,'" not found'));n.tests.push({name:t,fn:r,skip:!1,only:!1})}},{key:"runAllTests",value:(d=a(u().m(function e(){var t,o,s,i,a,f,h,d;return u().w(function(e){for(;;)switch(e.n){case 0:c.info("๐Ÿงช Running all test suites..."),t=performance.now(),o={suites:[],totalTests:0,passedTests:0,failedTests:0,skippedTests:0,duration:0},s=r(this.testSuites),e.p=1,s.s();case 2:if((i=s.n()).done){e.n=5;break}return a=n(i.value,2),f=a[0],a[1],e.n=3,this.runTestSuite(f);case 3:h=e.v,o.suites.push(h),o.totalTests+=h.totalTests,o.passedTests+=h.passedTests,o.failedTests+=h.failedTests,o.skippedTests+=h.skippedTests;case 4:e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,d=e.v,s.e(d);case 7:return e.p=7,s.f(),e.f(7);case 8:return o.duration=performance.now()-t,c.info("โœ… All tests completed: ".concat(o.passedTests,"/").concat(o.totalTests," passed in ").concat(o.duration.toFixed(2),"ms")),this.testResults.push(o),e.a(2,o)}},e,this,[[1,6,7,8]])})),function(){return d.apply(this,arguments)})},{key:"runTestSuite",value:(h=a(u().m(function e(t){var n,o,s,i,a,f,h,d,l;return u().w(function(e){for(;;)switch(e.n){case 0:if(n=this.testSuites.get(t)){e.n=1;break}throw new Error('Test suite "'.concat(t,'" not found'));case 1:if(c.info("๐Ÿงช Running test suite: ".concat(t)),o=performance.now(),s={name:t,tests:[],totalTests:n.tests.length,passedTests:0,failedTests:0,skippedTests:0,duration:0},e.p=2,!n.setup){e.n=3;break}return e.n=3,n.setup();case 3:if(!n.beforeAll){e.n=4;break}return e.n=4,n.beforeAll();case 4:i=r(n.tests),e.p=5,i.s();case 6:if((a=i.n()).done){e.n=9;break}return f=a.value,e.n=7,this.runTest(n,f);case 7:h=e.v,s.tests.push(h),"passed"===h.status?s.passedTests++:"failed"===h.status?s.failedTests++:"skipped"===h.status&&s.skippedTests++;case 8:e.n=6;break;case 9:e.n=11;break;case 10:e.p=10,d=e.v,i.e(d);case 11:return e.p=11,i.f(),e.f(11);case 12:if(!n.afterAll){e.n=13;break}return e.n=13,n.afterAll();case 13:e.n=15;break;case 14:e.p=14,l=e.v,c.error('โŒ Test suite "'.concat(t,'" setup failed:'),l);case 15:return s.duration=performance.now()-o,c.info('โœ… Suite "'.concat(t,'" completed: ').concat(s.passedTests,"/").concat(s.totalTests," passed")),e.a(2,s)}},e,this,[[5,10,11,12],[2,14]])})),function(e){return h.apply(this,arguments)})},{key:"runTest",value:(f=a(u().m(function e(t,r){var n,o,s,i;return u().w(function(e){for(;;)switch(e.n){case 0:if(!r.skip){e.n=1;break}return e.a(2,{name:r.name,status:"skipped",duration:0,error:null});case 1:if(n=performance.now(),o={name:r.name,status:"passed",duration:0,error:null},e.p=2,!t.beforeEach){e.n=3;break}return e.n=3,t.beforeEach();case 3:return s=this.createAssertionContext(),e.n=4,r.fn(s);case 4:if(!t.afterEach){e.n=5;break}return e.n=5,t.afterEach();case 5:e.n=7;break;case 6:e.p=6,i=e.v,o.status="failed",o.error={message:i.message,stack:i.stack},c.error('โŒ Test "'.concat(r.name,'" failed:'),i.message);case 7:return o.duration=performance.now()-n,e.a(2,o)}},e,this,[[2,6]])})),function(e,t){return f.apply(this,arguments)})},{key:"createAssertionContext",value:function(){var e,t={},o=r(this.assertions);try{for(o.s();!(e=o.n()).done;){var s=n(e.value,2),i=s[0],a=s[1];t[i]=a}}catch(e){o.e(e)}finally{o.f()}return t}},{key:"generateReport",value:function(e){var t=(e.passedTests/e.totalTests*100).toFixed(1),r='\n<!DOCTYPE html>\n<html>\n<head>\n <title>Test Report</title>\n <style>\n body { font-family: Arial, sans-serif; margin: 20px; }\n .summary { background: #f5f5f5; padding: 15px; border-radius: 5px; margin-bottom: 20px; }\n .suite { margin-bottom: 20px; border: 1px solid #ddd; border-radius: 5px; }\n .suite-header { background: #e9e9e9; padding: 10px; font-weight: bold; }\n .test { padding: 10px; border-bottom: 1px solid #eee; }\n .test:last-child { border-bottom: none; }\n .passed { color: green; }\n .failed { color: red; }\n .skipped { color: orange; }\n .error { background: #ffe6e6; padding: 10px; margin-top: 5px; border-radius: 3px; }\n </style>\n</head>\n<body>\n <h1>Test Report</h1>\n \n <div class="summary">\n <h2>Summary</h2>\n <p><strong>Total Tests:</strong> '.concat(e.totalTests,'</p>\n <p><strong>Passed:</strong> <span class="passed">').concat(e.passedTests,'</span></p>\n <p><strong>Failed:</strong> <span class="failed">').concat(e.failedTests,'</span></p>\n <p><strong>Skipped:</strong> <span class="skipped">').concat(e.skippedTests,"</span></p>\n <p><strong>Pass Rate:</strong> ").concat(t,"%</p>\n <p><strong>Duration:</strong> ").concat(e.duration.toFixed(2),"ms</p>\n </div>\n \n <h2>Test Suites</h2>\n");return e.suites.forEach(function(e){r+='\n <div class="suite">\n <div class="suite-header">\n '.concat(e.name," (").concat(e.passedTests,"/").concat(e.totalTests," passed)\n </div>\n"),e.tests.forEach(function(e){r+='\n <div class="test">\n <span class="'.concat(e.status,'">').concat(e.status.toUpperCase(),"</span>\n <strong>").concat(e.name,"</strong>\n <small>(").concat(e.duration.toFixed(2),"ms)</small>\n"),e.error&&(r+='\n <div class="error">\n <strong>Error:</strong> '.concat(e.error.message,"\n </div>\n")),r+=" </div>"}),r+=" </div>"}),r+="\n</body>\n</html>\n"}},{key:"clearResults",value:function(){this.testResults=[]}},{key:"getResults",value:function(){return this.testResults}},{key:"getBenchmarks",value:function(){return this.benchmarks}},{key:"dispose",value:function(){this.testSuites.clear(),this.clearResults(),this.mockData.clear(),this.benchmarks.clear(),c.info("Testing disposed")}}]);var f,h,d}();export{f as Testing};
@@ -0,0 +1 @@
1
+ import{createClass as e,objectSpread2 as t,typeof as n,classCallCheck as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import{createTransformControls as a}from"../managers/controls/transformControlsManager.js";import{HotReloadManager as o}from"../managers/system/hotReloadManager.js";import{DisposalManager as s}from"../managers/system/disposalManager.js";import{SceneExportManager as r}from"../managers/scene/sceneExportManager.js";import{ComponentManager as l}from"../managers/components/componentManager.js";import{SceneInitializationManager as u}from"../managers/scene/sceneInitializationManager.js";import{EnvironmentManager as c}from"../managers/environment/environmentManager.js";import{KeyboardControlsManager as h}from"../managers/controls/keyboardControlsManager.js";import{PathfindingManager as m}from"../managers/components/pathfindingManager.js";import{SceneOperationsManager as d}from"../managers/scene/sceneOperationsManager.js";import{AnimationManager as f}from"../managers/components/animationManager.js";import{CameraControlsManager as v}from"../managers/controls/cameraControlsManager.js";import{SceneTooltipsManager as p}from"../managers/scene/sceneTooltipsManager.js";import{generateUuidFromName as g,getHardcodedUuid as y}from"./nameUtils.js";import{logger as k,transformLogger as w,pathfinderLogger as M,modelLogger as S}from"./debugLogger.js";import j from"../rendering/modelPreloader.js";import b from"../managers/controls/dragDropManager.js";import{SceneHelper as C}from"../helpers/sceneHelper.js";var D=function(){return e(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;i(this,e),this.sceneViewer=t,this.managers={},this.utilities={},this.isInitialized=!1,this.importedSceneData=null,this.metadata={},this.transformHistory={lastTransform:null},this.setDefaultSceneMetadata(),this.initializeUtilities(),t&&(this.initializeManagers(),this.isInitialized=!0)},[{key:"setSceneViewer",value:function(e){this.sceneViewer=e,!this.isInitialized&&e&&(this.initializeManagers(),this.isInitialized=!0)}},{key:"initializeManagers",value:function(){this.sceneViewer&&(this.managers.hotReloadManager=new o(this.sceneViewer),this.managers.disposalManager=new s(this.sceneViewer),this.managers.sceneExportManager=new r(this.sceneViewer),this.managers.componentManager=new l(this.sceneViewer),this.managers.sceneInitializationManager=new u(this.sceneViewer),this.managers.environmentManager=new c(this.sceneViewer),this.managers.keyboardControlsManager=new h(this.sceneViewer),this.managers.pathfindingManager=new m(this.sceneViewer),this.managers.sceneOperationsManager=new d(this.sceneViewer),this.managers.animationManager=new f(this.sceneViewer),this.managers.cameraControlsManager=new v(this.sceneViewer))}},{key:"initializeUtilities",value:function(){this.utilities.createTransformControls=a,this.utilities.generateUuidFromName=g,this.utilities.getHardcodedUuid=y,this.utilities.logger=k,this.utilities.transformLogger=w,this.utilities.pathfinderLogger=M,this.utilities.modelLogger=S,this.utilities.modelPreloader=j,this.utilities.SceneHelper=C,this.utilities.DragDropManager=b}},{key:"attachToComponent",value:function(){var e=this;this.sceneViewer&&(this.isInitialized||this.initializeManagers(),Object.keys(this.managers).forEach(function(t){e.sceneViewer[t]=e.managers[t]}),Object.keys(this.utilities).forEach(function(t){e.sceneViewer[t]=e.utilities[t]}))}},{key:"initializePostSceneManagers",value:function(){this.sceneViewer.$refs.container&&this.sceneViewer.camera&&this.sceneViewer.scene&&(this.managers.tooltipsManager=new p(this.sceneViewer.$refs.container,this.sceneViewer.camera,this.sceneViewer.scene),this.sceneViewer.tooltipsManager=this.managers.tooltipsManager),this.sceneViewer.scene&&this.sceneViewer.camera&&(this.managers.dragDropManager=new b({scene:this.sceneViewer.scene,camera:this.sceneViewer.camera,transformManager:this.sceneViewer.transformManager,modelPreloader:this.utilities.modelPreloader,componentManager:this.sceneViewer.componentManager}),this.sceneViewer.dragDropManager=this.managers.dragDropManager),this.sceneViewer.scene&&this.sceneViewer.camera&&this.sceneViewer.renderer&&(this.utilities.sceneHelper=new C({scene:this.sceneViewer.scene,camera:this.sceneViewer.camera,renderer:this.sceneViewer.renderer,controls:this.sceneViewer.controls,transformManager:this.sceneViewer.transformManager,componentManager:this.sceneViewer.componentManager,pathfindingManager:this.sceneViewer.pathfindingManager,currentSceneData:this.sceneViewer.currentSceneData,logger:this.utilities.logger}),this.sceneViewer.sceneHelper=this.utilities.sceneHelper)}},{key:"updateSceneHelperData",value:function(e){this.utilities.sceneHelper&&"function"==typeof this.utilities.sceneHelper.updateSceneData&&this.utilities.sceneHelper.updateSceneData(e)}},{key:"setImportedSceneData",value:function(e){this.importedSceneData=t({},e),this.setDefaultImportedSceneMetadata(e),this.utilities.sceneHelper&&"function"==typeof this.utilities.sceneHelper.updateSceneData&&this.utilities.sceneHelper.updateSceneData(e)}},{key:"getImportedSceneData",value:function(){return this.importedSceneData}},{key:"getImportedConnections",value:function(){var e;return(null===(e=this.importedSceneData)||void 0===e?void 0:e.connections)||[]}},{key:"getImportedSceneObjects",value:function(){var e;return(null===(e=this.importedSceneData)||void 0===e||null===(e=e.scene)||void 0===e?void 0:e.object)||null}},{key:"clearImportedSceneData",value:function(){this.importedSceneData=null}},{key:"setMetadata",value:function(e,t){this.metadata[e]=t}},{key:"getMetadata",value:function(e){return this.metadata[e]}},{key:"getAllMetadata",value:function(){return t({},this.metadata)}},{key:"removeMetadata",value:function(e){delete this.metadata[e]}},{key:"clearAllMetadata",value:function(){this.metadata={}}},{key:"clearAllData",value:function(){this.metadata={},this.transformHistory.lastTransform=null}},{key:"recordTransform",value:function(e){var t,n;if(e&&e.object){e.previousValues;var i={type:e.type,object:e.object,values:e.values,previousValues:e.previousValues,timestamp:(new Date).toISOString(),objectId:(null===(t=e.object)||void 0===t?void 0:t.uuid)||(null===(n=e.object)||void 0===n?void 0:n.id)||"unknown"};this.transformHistory.lastTransform=i}}},{key:"getLastTransform",value:function(){return this.transformHistory.lastTransform}},{key:"getTransformHistory",value:function(){return t({},this.transformHistory)}},{key:"clearTransformHistory",value:function(){this.transformHistory.lastTransform=null}},{key:"hasMetadata",value:function(e){return e in this.metadata}},{key:"setDefaultSceneMetadata",value:function(){var e=this,t={sceneInfo:{name:"Untitled Central Plant Scene",description:"A central plant facility scene",version:"1.0.0",created:(new Date).toISOString(),lastModified:(new Date).toISOString(),author:"Engineering Team"},projectSettings:{units:"metric",scale:1,gridSize:1,snapToGrid:!0,showGrid:!0,showAxes:!0},viewportSettings:{defaultViewMode:"perspective",backgroundType:"skybox",showEnvironment:!0,autoRotate:!1,cameraPosition:{x:10,y:10,z:10},cameraTarget:{x:0,y:0,z:0}},componentSettings:{defaultComponentScale:1,showBoundingBoxes:!1,showConnectionPaths:!0,highlightOnHover:!0,selectionOutlineColor:"#00ff00"},spatialBoundaries:{min:{x:-60,y:-16,z:-60},max:{x:60,y:16,z:60},center:{x:0,y:4,z:0}},systemInfo:{centralPlantVersion:"2.0.0",buildDate:(new Date).toISOString(),platform:"undefined"!=typeof window?window.navigator.platform:"Unknown",userAgent:"undefined"!=typeof window?window.navigator.userAgent:"Unknown"}};Object.keys(t).forEach(function(n){e.hasMetadata(n)||e.setMetadata(n,t[n])})}},{key:"setDefaultImportedSceneMetadata",value:function(e){var n,i,a,o=(new Date).toISOString(),s=(null===(n=e.connections)||void 0===n?void 0:n.length)||0,r=(null===(i=e.scene)||void 0===i||null===(i=i.object)||void 0===i||null===(i=i.children)||void 0===i?void 0:i.length)||0,l={};null!==(a=e.scene)&&void 0!==a&&null!==(a=a.object)&&void 0!==a&&a.children&&e.scene.object.children.forEach(function(e){var t,n=(null===(t=e.userData)||void 0===t?void 0:t.componentType)||"unknown";l[n]=(l[n]||0)+1});var u={importInfo:{importTimestamp:o,originalFileName:null,fileSize:null,importMethod:"file-upload",importVersion:"1.0.0"},sceneAnalysis:{totalComponents:r,totalConnections:s,componentTypes:l,sceneComplexity:this.calculateSceneComplexity(s,r),hasValidStructure:this.validateImportedSceneStructure(e)},dataQuality:{hasConnections:s>0,hasComponents:r>0,hasValidScene:!!e.scene,missingData:this.identifyMissingData(e),warnings:this.generateImportWarnings(e)},processingStats:{processedAt:o,processingDuration:null,memoryUsage:this.estimateMemoryUsage(e),cacheStatus:"pending"}};if(this.setMetadata("lastImport",u),this.hasMetadata("sceneInfo")){var c=this.getMetadata("sceneInfo");this.setMetadata("sceneInfo",t(t({},c),{},{lastModified:o,importSource:"file-import",dataSourceType:"json"}))}}},{key:"calculateSceneComplexity",value:function(e,t){var n=e+t;return n<=10?"simple":n<=50?"moderate":n<=200?"complex":"very-complex"}},{key:"validateImportedSceneStructure",value:function(e){return!!(e&&e.scene&&e.scene.object&&Array.isArray(e.connections))}},{key:"identifyMissingData",value:function(e){var t,n=[];return e.connections&&0!==e.connections.length||n.push("No connection data found"),null!==(t=e.scene)&&void 0!==t&&null!==(t=t.object)&&void 0!==t&&t.children&&0!==e.scene.object.children.length||n.push("No component data found"),e.metadata||n.push("No metadata found"),e.version||n.push("No version information"),n}},{key:"generateImportWarnings",value:function(e){var t,n,i=[],a=(null===(t=e.scene)||void 0===t||null===(t=t.object)||void 0===t||null===(t=t.children)||void 0===t?void 0:t.length)||0;a>100&&i.push("Large scene detected (".concat(a," components) - may impact performance"));var o=(null===(n=e.connections)||void 0===n?void 0:n.length)||0;return a>0&&0===o&&i.push("Components found but no connections - scene may be incomplete"),e.version&&parseFloat(e.version)<1&&i.push("Scene data version is older than current - some features may not work correctly"),i}},{key:"estimateMemoryUsage",value:function(e){var t=JSON.stringify(e).length,n=(t/1024/1024).toFixed(2);return{jsonSizeBytes:t,estimatedMB:parseFloat(n),category:n<1?"small":n<10?"medium":"large"}}},{key:"updateMetadataCategory",value:function(e,n){if(this.hasMetadata(e)){var i=this.getMetadata(e);this.setMetadata(e,t(t({},i),n))}else this.setMetadata(e,n)}},{key:"undoTransform",value:function(){var e=this.getLastTransform();if(!e)return!1;try{var t,n=e.object,i=e.type,a=e.previousValues;if(!n||!a)return!1;if(this.debugTransformState(n,"Before Undo"),this.sceneViewer&&this.sceneViewer.scene){var o=!1;if(this.sceneViewer.scene.traverse(function(e){e===n&&(o=!0)}),!o)return!1}switch(i){case"translate":case"position":a.position?(void 0!==a.position.x&&(n.position.x=a.position.x),void 0!==a.position.y&&(n.position.y=a.position.y),void 0!==a.position.z&&(n.position.z=a.position.z)):(void 0!==a.x&&(n.position.x=a.x),void 0!==a.y&&(n.position.y=a.y),void 0!==a.z&&(n.position.z=a.z));break;case"rotate":case"rotation":a.rotation?(void 0!==a.rotation.x&&(n.rotation.x=a.rotation.x),void 0!==a.rotation.y&&(n.rotation.y=a.rotation.y),void 0!==a.rotation.z&&(n.rotation.z=a.rotation.z)):(void 0!==a.x&&(n.rotation.x=a.x),void 0!==a.y&&(n.rotation.y=a.y),void 0!==a.z&&(n.rotation.z=a.z));break;case"scale":a.scale?(void 0!==a.scale.x&&(n.scale.x=a.scale.x),void 0!==a.scale.y&&(n.scale.y=a.scale.y),void 0!==a.scale.z&&(n.scale.z=a.scale.z)):(void 0!==a.x&&(n.scale.x=a.x),void 0!==a.y&&(n.scale.y=a.y),void 0!==a.z&&(n.scale.z=a.z));break;default:return!1}n.updateMatrix(),n.updateMatrixWorld(!0);var s=null===(t=this.sceneViewer)||void 0===t?void 0:t.transformManager;if(s&&s.transformControls){var r=s.transformControls;r.object===n&&(r.detach(),s.ensureSceneAttachment&&s.ensureSceneAttachment(!0),r.attach(n),s.selectedObject=n,s.updateBoundingBox&&s.updateBoundingBox(),s.boundingBoxCache&&s.boundingBoxCache.has(n)&&s.boundingBoxCache.delete(n))}if(this.sceneViewer&&this.sceneViewer.sceneOperationsManager&&this.sceneViewer.currentSceneData)try{this.sceneViewer.onTransformEnd(n)}catch(e){}if("undefined"!=typeof window){var l=new CustomEvent("sceneUpdateComplete",{detail:{timestamp:Date.now(),action:"undo-transform",objectId:n.uuid||n.id||"unknown"}});window.dispatchEvent(l)}return this.clearTransformHistory(),this.ensureObjectSelectable(n),this.debugTransformState(n,"After Undo"),!0}catch(e){return!1}}},{key:"ensureObjectSelectable",value:function(e){if(!e||!this.sceneViewer)return!1;try{var t=this.sceneViewer.transformManager;return!!t&&(t.recoverTransformControls?t.recoverTransformControls(e):(e.updateMatrixWorld(!0),t.boundingBoxCache&&t.boundingBoxCache.has(e)&&t.boundingBoxCache.delete(e),t.ensureSceneAttachment&&t.ensureSceneAttachment(!0),t.selectedObject===e&&(t.deselectObject(),requestAnimationFrame(function(){t.selectObjectForTransformOnly(e)})),!0))}catch(e){return!1}}},{key:"debugTransformState",value:function(e){}},{key:"fixTransformControlsSelection",value:function(){if(!this.sceneViewer||!this.sceneViewer.transformManager)return!1;var e=this.sceneViewer.transformManager;if(e.recoverTransformControls&&e.recoverTransformControls())return!0;try{var t=e.currentMode,n=e.currentSpace;return e.transformControls&&(e.transformControls.detach(),e.scene.remove(e.transformControls),e.transformControls.dispose(),e.transformControls=null),e.createTransformControls(),e.setupEventListeners(),e.setMode(t),e.setSpace(n),!0}catch(e){return!1}}},{key:"isObjectInScene",value:function(e){if(!this.sceneViewer||!this.sceneViewer.scene)return!1;var t=!1;return this.sceneViewer.scene.traverse(function(n){n===e&&(t=!0)}),t}}])}();export{D as CentralPlant,D as default};
@@ -0,0 +1 @@
1
+ import{createClass as e,toConsumableArray as r,classCallCheck as i}from"../../_virtual/_rollupPluginBabelHelpers.js";var n=function(){return e(function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"SceneViewer",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";i(this,e),this.namespace=r,this.debugLevel=n,this.isProduction="production"===process.env.NODE_ENV,this.enabled=!this.isProduction,this.levels={error:0,warn:1,info:2,debug:3,verbose:4},this.currentLevel=this.levels[n]||this.levels.info},[{key:"setLevel",value:function(e){return this.currentLevel=this.levels[e]||this.levels.info,this}},{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"_shouldLog",value:function(e){return this.enabled&&this.levels[e]<=this.currentLevel}},{key:"_formatMessage",value:function(e,r){for(var i="[".concat(this.namespace,":").concat(e.toUpperCase(),"]"),n=arguments.length,t=new Array(n>2?n-2:0),s=2;s<n;s++)t[s-2]=arguments[s];return[i,r].concat(t)}},{key:"error",value:function(e){if(this.i("error")){for(var i,n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];(i=console).error.apply(i,r(this.t.apply(this,["error",e].concat(t))))}}},{key:"warn",value:function(e){if(this.i("warn")){for(var i,n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];(i=console).warn.apply(i,r(this.t.apply(this,["warn",e].concat(t))))}}},{key:"info",value:function(e){if(this.i("info")){for(var i,n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];(i=console).log.apply(i,r(this.t.apply(this,["info",e].concat(t))))}}},{key:"debug",value:function(e){if(this.i("debug")){for(var i,n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];(i=console).debug.apply(i,r(this.t.apply(this,["debug",e].concat(t))))}}},{key:"verbose",value:function(e){if(this.i("verbose")){for(var i,n=arguments.length,t=new Array(n>1?n-1:0),s=1;s<n;s++)t[s-1]=arguments[s];(i=console).debug.apply(i,r(this.t.apply(this,["verbose",e].concat(t))))}}},{key:"phase",value:function(e,r){for(var i=arguments.length,n=new Array(i>2?i-2:0),t=2;t<i;t++)n[t-2]=arguments[t];this.info.apply(this,["๐Ÿ” PHASE ".concat(e,": ").concat(r)].concat(n))}},{key:"success",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.info.apply(this,["โœ… ".concat(e)].concat(i))}},{key:"failure",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.error.apply(this,["โŒ ".concat(e)].concat(i))}},{key:"loading",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.debug.apply(this,["๐Ÿ”„ ".concat(e)].concat(i))}},{key:"timing",value:function(e){for(var r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];this.debug.apply(this,["โฑ๏ธ ".concat(e)].concat(i))}}])}(),t=new n("SceneViewer","info"),s=new n("Transform","warn"),o=new n("Pathfinder","info"),a=new n("Models","info");new n("Materials","warn");export{n as DebugLogger,t as logger,a as modelLogger,o as pathfinderLogger,s as transformLogger};
@@ -0,0 +1 @@
1
+ import{defineProperty as t,createClass as n,toConsumableArray as r,slicedToArray as e,classCallCheck as u}from"../../_virtual/_rollupPluginBabelHelpers.js";var a,i=n(function t(){u(this,t)});a=i,t(i,"PI",Math.PI),t(i,"TWO_PI",2*Math.PI),t(i,"HALF_PI",Math.PI/2),t(i,"DEG_TO_RAD",Math.PI/180),t(i,"RAD_TO_DEG",180/Math.PI),t(i,"EPSILON",1e-10),t(i,"angle",{toRadians:function(t){return t*a.DEG_TO_RAD},toDegrees:function(t){return t*a.RAD_TO_DEG},normalize:function(t){for(;t<0;)t+=a.TWO_PI;for(;t>=a.TWO_PI;)t-=a.TWO_PI;return t},normalizeSignedAngle:function(t){return(t=a.angle.normalize(t))>Math.PI?t-a.TWO_PI:t},distance:function(t,n){var r=a.angle.normalizeSignedAngle(n-t);return Math.abs(r)},lerp:function(t,n,r){var e=a.angle.normalizeSignedAngle(n-t);return a.angle.normalize(t+e*r)}}),t(i,"interpolation",{linear:function(t,n,r){return t+(n-t)*r},smoothstep:function(t,n,r){var e=r*r*(3-2*r);return a.interpolation.linear(t,n,e)},smootherstep:function(t,n,r){var e=r*r*r*(r*(6*r-15)+10);return a.interpolation.linear(t,n,e)},cosine:function(t,n,r){var e=r*Math.PI,u=.5*(1-Math.cos(e));return t*(1-u)+n*u},cubic:function(t,n,r,e,u){var a=u*u;return.5*(2*n+(-t+r)*u+(2*t-5*n+4*r-e)*a+(3*n-t-3*r+e)*(a*u))}}),t(i,"easing",{easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:(4-2*t)*t-1},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t},easeInSine:function(t){return 1-Math.cos(t*a.HALF_PI)},easeOutSine:function(t){return Math.sin(t*a.HALF_PI)},easeInOutSine:function(t){return.5*(1-Math.cos(a.PI*t))},easeInExpo:function(t){return 0===t?0:Math.pow(2,10*(t-1))},easeOutExpo:function(t){return 1===t?1:1-Math.pow(2,-10*t)},easeInOutExpo:function(t){return 0===t?0:1===t?1:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1)))},easeInCirc:function(t){return 1-Math.sqrt(1-t*t)},easeOutCirc:function(t){return Math.sqrt(1- --t*t)},easeInOutCirc:function(t){return(t*=2)<1?.5*(1-Math.sqrt(1-t*t)):(t-=2,.5*(Math.sqrt(1-t*t)+1))},easeInElastic:function(t){if(0===t)return 0;if(1===t)return 1;return-Math.pow(2,10*(t-=1))*Math.sin((t-.075)*a.TWO_PI/.3)},easeOutElastic:function(t){if(0===t)return 0;if(1===t)return 1;return Math.pow(2,-10*t)*Math.sin((t-.075)*a.TWO_PI/.3)+1}}),t(i,"geometry",{triangleArea:function(t,n,r){return.5*Math.abs((n[0]-t[0])*(r[1]-t[1])-(r[0]-t[0])*(n[1]-t[1]))},polygonArea:function(t){for(var n=0,r=t.length,e=0;e<r;e++){var u=(e+1)%r;n+=t[e][0]*t[u][1],n-=t[u][0]*t[e][1]}return Math.abs(n)/2},pointInTriangle:function(t,n,r,e){var u=a.geometry.triangleArea(n,r,e),i=a.geometry.triangleArea(t,r,e),o=a.geometry.triangleArea(n,t,e),c=a.geometry.triangleArea(n,r,t);return Math.abs(u-(i+o+c))<a.EPSILON},polygonCentroid:function(t){for(var n=0,r=0,e=0,u=t.length,a=0;a<u;a++){var i=(a+1)%u,o=t[a][0]*t[i][1]-t[i][0]*t[a][1];e+=o,n+=(t[a][0]+t[i][0])*o,r+=(t[a][1]+t[i][1])*o}return[n/=6*(e/=2),r/=6*e]}}),t(i,"random",{float:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t+Math.random()*(n-t)},int:function(t,n){return Math.floor(a.random.float(t,n+1))},boolean:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5;return Math.random()<t},choice:function(t){return t[a.random.int(0,t.length-1)]},shuffle:function(t){for(var n=r(t),e=n.length-1;e>0;e--){var u=Math.floor(Math.random()*(e+1)),a=[n[u],n[e]];n[e]=a[0],n[u]=a[1]}return n},unitCircle:function(){var t=a.random.float(0,a.TWO_PI);return[Math.cos(t),Math.sin(t)]},insideUnitCircle:function(){var t=a.random.unitCircle(),n=e(t,2),r=n[0],u=n[1],i=Math.sqrt(Math.random());return[r*i,u*i]},unitSphere:function(){var t=Math.random(),n=Math.random(),r=a.TWO_PI*t,e=Math.acos(2*n-1);return[Math.sin(e)*Math.cos(r),Math.sin(e)*Math.sin(r),Math.cos(e)]}}),t(i,"color",{hslToRgb:function(t,n,r){t/=360;var e,u,a,i=(1-Math.abs(2*r-1))*n,o=i*(1-Math.abs(6*t%2-1)),c=r-i/2;return t<1/6?(e=i,u=o,a=0):t<2/6?(e=o,u=i,a=0):t<.5?(e=0,u=i,a=o):t<4/6?(e=0,u=o,a=i):t<5/6?(e=o,u=0,a=i):(e=i,u=0,a=o),[Math.round(255*(e+c)),Math.round(255*(u+c)),Math.round(255*(a+c))]},rgbToHsl:function(t,n,r){t/=255,n/=255,r/=255;var e=Math.max(t,n,r),u=Math.min(t,n,r),a=(e+u)/2;if(e===u)return[0,0,a];var i,o=e-u,c=a>.5?o/(2-e-u):o/(e+u);switch(e){case t:i=(n-r)/o+(n<r?6:0);break;case n:i=(r-t)/o+2;break;case r:i=(t-n)/o+4}return[360*(i/=6),c,a]},lerp:function(t,n,r){return[Math.round(a.interpolation.linear(t[0],n[0],r)),Math.round(a.interpolation.linear(t[1],n[1],r)),Math.round(a.interpolation.linear(t[2],n[2],r))]}}),t(i,"utils",{clamp:function(t,n,r){return Math.max(n,Math.min(r,t))},map:function(t,n,r,e,u){return e+(t-n)*(u-e)/(r-n)},isPowerOfTwo:function(t){return!(t&t-1)},nextPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log2(t)))},gcd:function(t,n){return 0===n?t:a.utils.gcd(n,t%n)},lcm:function(t,n){return Math.abs(t*n)/a.utils.gcd(t,n)},approxEqual:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a.EPSILON;return Math.abs(t-n)<r},round:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=Math.pow(10,n);return Math.round(t*r)/r}});export{i as MathUtils};
@@ -0,0 +1 @@
1
+ function n(n){if(!n)return null;var r=n.toUpperCase().replace(/\s+COMPONENT$/i,"").replace(/\s+/g,"-").replace(/[^A-Z0-9\-]/g,"");return r=r.replace(/-COMPONENT$/,"")}function r(r,u){if(!r||!u)return null;var l=null;return r.traverse(function(r){var i;if(!l)if(r.uuid!==u)if((null===(i=r.userData)||void 0===i?void 0:i.originalUuid)!==u){if(r.name&&n(r.name)===u)return void(l=r)}else l=r;else l=r}),l}function u(r){var u;return r?null!==(u=r.userData)&&void 0!==u&&u.originalUuid?r.userData.originalUuid:r.uuid&&!r.uuid.includes("-")&&r.uuid.length>10?r.uuid:r.name?n(r.name):null:null}export{r as findObjectByHardcodedUuid,n as generateUuidFromName,u as getHardcodedUuid};
@@ -0,0 +1 @@
1
+ import{createClass as e,objectSpread2 as t,toConsumableArray as r,classCallCheck as n,typeof as o,asyncToGenerator as i,regenerator as a,createForOfIteratorHelper as s}from"../../_virtual/_rollupPluginBabelHelpers.js";import"three";import{GLTFExporter as u}from"../../node_modules/three/examples/jsm/exporters/GLTFExporter.js";import{OBJExporter as c}from"../../node_modules/three/examples/jsm/exporters/OBJExporter.js";import{STLExporter as l}from"../../node_modules/three/examples/jsm/exporters/STLExporter.js";import{PLYExporter as f}from"../../node_modules/three/examples/jsm/exporters/PLYExporter.js";import{logger as p}from"../core/debugLogger.js";var m=function(){return e(function e(){n(this,e),this.exporters={gltf:new u,obj:new c,stl:new l,ply:new f},this.supportedFormats={models:["gltf","glb","obj","stl","ply","dae"],scenes:["json"],images:["png","jpg","jpeg","webp"],data:["json","csv","xml"]},this.exportHistory=[]},[{key:"exportModel",value:(g=i(a().m(function e(r,n){var o,i,s,u,c,l,f,m,v,d,h=arguments;return a().w(function(e){for(;;)switch(e.n){case 0:o=h.length>2&&void 0!==h[2]?h[2]:{},i=performance.now(),p.info("๐Ÿ”„ Exporting model to ".concat(n.toUpperCase(),"...")),e.p=1,u=t({binary:"glb"===n,embedImages:!0,includeCustomExtensions:!1},o),v=n.toLowerCase(),e.n="gltf"===v||"glb"===v?2:"obj"===v?4:"stl"===v?6:8;break;case 2:return e.n=3,this.exportGLTF(r,u);case 3:case 5:case 7:return s=e.v,e.a(3,9);case 4:return e.n=5,this.exportOBJ(r,u);case 6:return e.n=7,this.exportSTL(r,u);case 8:throw new Error("Unsupported format: ".concat(n));case 9:return c=performance.now()-i,l={timestamp:(new Date).toISOString(),format:n.toLowerCase(),objectName:r.name||"Unnamed Object",exportTime:c,options:u,success:!0},this.exportHistory.push(l),p.info("โœ… Model exported successfully to ".concat(n.toUpperCase()," in ").concat(c.toFixed(2),"ms")),e.a(2,{data:s,format:n,exportTime:c,filename:this.generateFilename(r.name||"model",n)});case 10:throw e.p=10,d=e.v,f=performance.now()-i,m={timestamp:(new Date).toISOString(),format:n.toLowerCase(),objectName:r.name||"Unnamed Object",exportTime:f,options:o,success:!1,error:d.message},this.exportHistory.push(m),p.error("โŒ Failed to export model to ".concat(n.toUpperCase(),":"),d),d;case 11:return e.a(2)}},e,this,[[1,10]])})),function(e,t){return g.apply(this,arguments)})},{key:"exportGLTF",value:(y=i(a().m(function e(t){var r,n=this,o=arguments;return a().w(function(e){for(;;)if(0===e.n)return r=o.length>1&&void 0!==o[1]?o[1]:{},e.a(2,new Promise(function(e,o){n.exporters.gltf.parse(t,function(t){return e(t)},o,r)}))},e)})),function(e){return y.apply(this,arguments)})},{key:"exportOBJ",value:(h=i(a().m(function e(t){var r=this;return a().w(function(e){for(;;)if(0===e.n)return e.a(2,new Promise(function(e){e(r.exporters.obj.parse(t))}))},e)})),function(e){return h.apply(this,arguments)})},{key:"exportSTL",value:(d=i(a().m(function e(t){var r,n=this,o=arguments;return a().w(function(e){for(;;)if(0===e.n)return r=o.length>1&&void 0!==o[1]?o[1]:{},e.a(2,new Promise(function(e){e(n.exporters.stl.parse(t,r))}))},e)})),function(e){return d.apply(this,arguments)})},{key:"exportPLY",value:(v=i(a().m(function e(t){var r,n=this,o=arguments;return a().w(function(e){for(;;)if(0===e.n)return r=o.length>1&&void 0!==o[1]?o[1]:{},e.a(2,new Promise(function(e){e(n.exporters.ply.parse(t,r))}))},e)})),function(e){return v.apply(this,arguments)})},{key:"exportSceneConfig",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};p.info("๐Ÿ”„ Exporting scene configuration...");try{var i={metadata:t({version:"1.0.0",generator:"Export",timestamp:(new Date).toISOString()},o),scene:this.serializeObject(e),connections:r(n),cameras:this.extractCameras(e),lights:this.extractLights(e)};return p.info("โœ… Scene configuration exported successfully"),i}catch(e){throw p.error("โŒ Failed to export scene configuration:",e),e}}},{key:"serializeObject",value:function(e){var r=this,n={uuid:e.uuid,name:e.name,type:e.type,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,castShadow:e.castShadow,receiveShadow:e.receiveShadow,userData:t({},e.userData),children:[]};return e.geometry&&(n.geometry={type:e.geometry.type,uuid:e.geometry.uuid,attributes:this.serializeGeometryAttributes(e.geometry)}),e.material&&(n.material=this.serializeMaterial(e.material)),e.children.forEach(function(e){n.children.push(r.serializeObject(e))}),n}},{key:"serializeGeometryAttributes",value:function(e){var t={};return Object.keys(e.attributes).forEach(function(r){var n=e.attributes[r];t[r]={type:n.constructor.name,itemSize:n.itemSize,count:n.count,normalized:n.normalized}}),t}},{key:"serializeMaterial",value:function(e){var t={type:e.type,uuid:e.uuid,name:e.name,color:e.color?e.color.getHex():null,transparent:e.transparent,opacity:e.opacity,side:e.side,visible:e.visible};void 0!==e.metalness&&(t.metalness=e.metalness),void 0!==e.roughness&&(t.roughness=e.roughness),void 0!==e.clearcoat&&(t.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(t.clearcoatRoughness=e.clearcoatRoughness);return["map","normalMap","roughnessMap","metalnessMap","aoMap","emissiveMap"].forEach(function(r){var n;e[r]&&(t[r]={uuid:e[r].uuid,name:e[r].name,image:(null===(n=e[r].image)||void 0===n?void 0:n.src)||null})}),t}},{key:"extractCameras",value:function(e){var t=[];return e.traverse(function(e){if(e.isCamera){var r={uuid:e.uuid,name:e.name,type:e.type,position:e.position.toArray(),rotation:e.rotation.toArray(),fov:e.fov,aspect:e.aspect,near:e.near,far:e.far};t.push(r)}}),t}},{key:"extractLights",value:function(e){var t=[];return e.traverse(function(e){if(e.isLight){var r={uuid:e.uuid,name:e.name,type:e.type,position:e.position.toArray(),color:e.color.getHex(),intensity:e.intensity};void 0!==e.distance&&(r.distance=e.distance),void 0!==e.decay&&(r.decay=e.decay),void 0!==e.angle&&(r.angle=e.angle),void 0!==e.penumbra&&(r.penumbra=e.penumbra),void 0!==e.castShadow&&(r.castShadow=e.castShadow),t.push(r)}}),t}},{key:"exportToCSV",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e||0===e.length)return"";t||(t=Object.keys(e[0]));var r=[];return r.push(t.join(",")),e.forEach(function(e){var n=t.map(function(t){var r=e[t];return"string"==typeof r&&(r.includes(",")||r.includes('"'))?'"'.concat(r.replace(/"/g,'""'),'"'):r});r.push(n.join(","))}),r.join("\n")}},{key:"exportToXML",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"root",n=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=" ".repeat(r),a="";return Object.keys(e).forEach(function(s){var u=e[s];"object"!==o(u)||null===u||Array.isArray(u)?Array.isArray(u)?u.forEach(function(e){a+="".concat(i,"<").concat(s,">"),"object"===o(e)?a+="\n"+n(e,r+1)+i:a+=t.escapeXML(e),a+="</".concat(s,">\n")}):a+="".concat(i,"<").concat(s,">").concat(t.escapeXML(u),"</").concat(s,">\n"):(a+="".concat(i,"<").concat(s,">\n"),a+=n(u,r+1),a+="".concat(i,"</").concat(s,">\n"))}),a};return'<?xml version="1.0" encoding="UTF-8"?>\n'+"<".concat(r,">\n")+n(e,1)+"</".concat(r,">")}},{key:"downloadFile",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/octet-stream";r=e instanceof ArrayBuffer||"string"==typeof e?new Blob([e],{type:n}):new Blob([JSON.stringify(e,null,2)],{type:"application/json"});var o=URL.createObjectURL(r),i=document.createElement("a");i.href=o,i.download=t,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o),p.info("โœ… File downloaded: ".concat(t))}},{key:"exportBatch",value:(m=i(a().m(function e(t){var r,n,o,i,u,c,l,f;return a().w(function(e){for(;;)switch(e.n){case 0:p.info("๐Ÿ”„ Starting batch export of ".concat(t.length," objects...")),r=[],n=[],o=s(t),e.p=1,o.s();case 2:if((i=o.n()).done){e.n=7;break}return u=i.value,e.p=3,e.n=4,this.exportModel(u.object,u.format,u.options);case 4:c=e.v,r.push(c),e.n=6;break;case 5:e.p=5,l=e.v,n.push({object:u.object.name||"Unnamed Object",format:u.format,error:l.message});case 6:e.n=2;break;case 7:e.n=9;break;case 8:e.p=8,f=e.v,o.e(f);case 9:return e.p=9,o.f(),e.f(9);case 10:return p.info("โœ… Batch export complete: ".concat(r.length," successful, ").concat(n.length," failed")),e.a(2,{results:r,errors:n})}},e,this,[[3,5],[1,8,9,10]])})),function(e){return m.apply(this,arguments)})},{key:"generateFilename",value:function(e,t){var r=(new Date).toISOString().replace(/[:.]/g,"-").slice(0,-5),n=e.replace(/[^a-zA-Z0-9_-]/g,"_");return"".concat(n,"_").concat(r,".").concat(t.toLowerCase())}},{key:"escapeXML",value:function(e){return null==e?"":String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}},{key:"isFormatSupported",value:function(e,t){var r;return(null===(r=this.supportedFormats[t])||void 0===r?void 0:r.includes(e.toLowerCase()))||!1}},{key:"getExportHistory",value:function(){return this.exportHistory}},{key:"clearHistory",value:function(){this.exportHistory=[]}},{key:"getSupportedFormats",value:function(){return t({},this.supportedFormats)}},{key:"dispose",value:function(){this.clearHistory(),p.info("Export disposed")}}]);var m,v,d,h,y,g}();export{m as Export};
@@ -0,0 +1 @@
1
+ import{createClass as e,slicedToArray as r,classCallCheck as t,asyncToGenerator as o,regenerator as n,toConsumableArray as s,createForOfIteratorHelper as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import*as a from"three";import{GLTFLoader as c}from"../../node_modules/three/examples/jsm/loaders/GLTFLoader.js";import{DRACOLoader as u}from"../../node_modules/three/examples/jsm/loaders/DRACOLoader.js";import{logger as l}from"../core/debugLogger.js";var f=function(){return e(function e(){t(this,e),this.gltfLoader=new c,this.dracoLoader=new u,this.textureLoader=new a.TextureLoader,this.dracoLoader.setDecoderPath("/draco/"),this.gltfLoader.setDRACOLoader(this.dracoLoader),this.supportedFormats={models:[".glb",".gltf"],textures:[".jpg",".jpeg",".png",".hdr",".exr"],scenes:[".json"],configs:[".json",".yaml",".yml"]}},[{key:"importModel",value:(d=o(n().m(function e(r){var t,o,i,a,c,u,f,m,p,d,h,v,g,y,w,k=this,b=arguments;return n().w(function(e){for(;;)switch(e.n){case 0:return o=(t=b.length>1&&void 0!==b[1]?b[1]:{}).scale,i=void 0===o?1:o,a=t.position,c=void 0===a?[0,0,0]:a,u=t.rotation,f=void 0===u?[0,0,0]:u,m=t.castShadow,p=void 0===m||m,d=t.receiveShadow,h=void 0===d||d,e.p=1,l.info("๐Ÿ”„ Importing model: ".concat(r)),e.n=2,new Promise(function(e,t){k.gltfLoader.load(r,e,function(e){var r=(e.loaded/e.total*100).toFixed(1);l.debug("Loading progress: ".concat(r,"%"))},t)});case 2:return y=e.v,1!==i&&y.scene.scale.setScalar(i),(v=y.scene.position).set.apply(v,s(c)),(g=y.scene.rotation).set.apply(g,s(f)),y.scene.traverse(function(e){e.isMesh&&(e.castShadow=p,e.receiveShadow=h)}),l.info("โœ… Model imported successfully: ".concat(r)),e.a(2,{scene:y.scene,animations:y.animations,cameras:y.cameras,asset:y.asset});case 3:throw e.p=3,w=e.v,l.error("โŒ Failed to import model ".concat(r,":"),w),w;case 4:return e.a(2)}},e,null,[[1,3]])})),function(e){return d.apply(this,arguments)})},{key:"importTextures",value:(p=o(n().m(function e(r){var t,o,s,i,a=this;return n().w(function(e){for(;;)switch(e.n){case 0:return t=Array.isArray(r)?r:[r],e.p=1,o=t.map(function(e){return new Promise(function(r,t){a.textureLoader.load(e,r,void 0,t)})}),e.n=2,Promise.all(o);case 2:return s=e.v,l.info("โœ… Imported ".concat(s.length," texture(s)")),e.a(2,Array.isArray(r)?s:s[0]);case 3:throw e.p=3,i=e.v,l.error("โŒ Failed to import textures:",i),i;case 4:return e.a(2)}},e,null,[[1,3]])})),function(e){return p.apply(this,arguments)})},{key:"importSceneConfig",value:(m=o(n().m(function e(r){var t,o,s,i,a,c;return n().w(function(e){for(;;)switch(e.n){case 0:return e.p=0,l.info("๐Ÿ”„ Importing scene config: ".concat(r)),e.n=1,fetch(r);case 1:if((t=e.v).ok){e.n=2;break}throw new Error("HTTP ".concat(t.status,": ").concat(t.statusText));case 2:return e.n=3,t.json();case 3:for(o=e.v,s=0,i=["scene","connections"];s<i.length;s++)o[a=i[s]]||l.warn("โš ๏ธ Missing required property: ".concat(a));return l.info("โœ… Scene config imported: ".concat(r)),e.a(2,o);case 4:throw e.p=4,c=e.v,l.error("โŒ Failed to import scene config ".concat(r,":"),c),c;case 5:return e.a(2)}},e,null,[[0,4]])})),function(e){return m.apply(this,arguments)})},{key:"importBatch",value:(f=o(n().m(function e(r){var t,o,s,a,c,u,f,m,p;return n().w(function(e){for(;;)switch(e.n){case 0:l.info("๐Ÿ”„ Starting batch import of ".concat(r.length," files")),t=[],o=[],s=i(r),e.p=1,s.s();case 2:if((a=s.n()).done){e.n=14;break}c=a.value,e.p=3,u=void 0,f=c.type,e.n="model"===f?4:"texture"===f?6:"scene"===f?8:10;break;case 4:return e.n=5,this.importModel(c.url,c.options);case 5:return u=e.v,e.a(3,11);case 6:return e.n=7,this.importTextures(c.url);case 7:return u=e.v,e.a(3,11);case 8:return e.n=9,this.importSceneConfig(c.url);case 9:return u=e.v,e.a(3,11);case 10:throw new Error("Unknown import type: ".concat(c.type));case 11:t.push({url:c.url,type:c.type,data:u}),e.n=13;break;case 12:e.p=12,m=e.v,o.push({url:c.url,type:c.type,error:m}),l.error("โŒ Failed to import ".concat(c.url,":"),m);case 13:e.n=2;break;case 14:e.n=16;break;case 15:e.p=15,p=e.v,s.e(p);case 16:return e.p=16,s.f(),e.f(16);case 17:return l.info("โœ… Batch import complete: ".concat(t.length," successful, ").concat(o.length," failed")),e.a(2,{results:t,errors:o})}},e,this,[[3,12],[1,15,16,17]])})),function(e){return f.apply(this,arguments)})},{key:"isFormatSupported",value:function(e,r){var t,o="."+e.split(".").pop().toLowerCase();return(null===(t=this.supportedFormats[r])||void 0===t?void 0:t.includes(o))||!1}},{key:"getFormatInfo",value:function(e){for(var t="."+e.split(".").pop().toLowerCase(),o=0,n=Object.entries(this.supportedFormats);o<n.length;o++){var s=r(n[o],2),i=s[0];if(s[1].includes(t))return{category:i,extension:t,supported:!0}}return{category:"unknown",extension:t,supported:!1}}},{key:"dispose",value:function(){this.dracoLoader.dispose&&this.dracoLoader.dispose(),l.info("Import disposed")}}]);var f,m,p,d}();export{f as Import};
@@ -0,0 +1 @@
1
+ import{createClass as r,classCallCheck as n,defineProperty as t,toConsumableArray as e}from"../../_virtual/_rollupPluginBabelHelpers.js";var o=function(){return r(function r(){var o=this;n(this,r),t(this,"vector",{add:function(r,n){return r.map(function(r,t){return r+(n[t]||0)})},subtract:function(r,n){return r.map(function(r,t){return r-(n[t]||0)})},scale:function(r,n){return r.map(function(r){return r*n})},dot:function(r,n){return r.reduce(function(r,t,e){return r+t*(n[e]||0)},0)},cross:function(r,n){return[r[1]*n[2]-r[2]*n[1],r[2]*n[0]-r[0]*n[2],r[0]*n[1]-r[1]*n[0]]},magnitude:function(r){return Math.sqrt(r.reduce(function(r,n){return r+n*n},0))},normalize:function(r){var n=o.vector.magnitude(r);return n>0?r.map(function(r){return r/n}):r.slice()},distance:function(r,n){return o.vector.magnitude(o.vector.subtract(r,n))},lerp:function(r,n,t){return r.map(function(r,e){return r+t*((n[e]||0)-r)})}}),t(this,"matrix",{identity:function(r){for(var n=Array(r).fill().map(function(){return Array(r).fill(0)}),t=0;t<r;t++)n[t][t]=1;return n},multiply:function(r,n){for(var t=r.length,e=n[0].length,o=Array(t).fill().map(function(){return Array(e).fill(0)}),u=0;u<t;u++)for(var i=0;i<e;i++)for(var a=0;a<r[0].length;a++)o[u][i]+=r[u][a]*n[a][i];return o},multiplyVector:function(r,n){return r.map(function(r){return r.reduce(function(r,t,e){return r+t*(n[e]||0)},0)})},determinant:function(r){var n=r.length;if(2===n)return r[0][0]*r[1][1]-r[0][1]*r[1][0];if(3===n)return r[0][0]*(r[1][1]*r[2][2]-r[1][2]*r[2][1])-r[0][1]*(r[1][0]*r[2][2]-r[1][2]*r[2][0])+r[0][2]*(r[1][0]*r[2][1]-r[1][1]*r[2][0]);throw new Error("Determinant calculation only supported for 2x2 and 3x3 matrices")},transpose:function(r){return r[0].map(function(n,t){return r.map(function(r){return r[t]})})}}),t(this,"analysis",{newtonRaphson:function(r,n,t){for(var e=t,u=0;u<o.maxIterations;){var i=r(e),a=n(e);if(Math.abs(a)<o.precision)throw new Error("Derivative too small, cannot continue");var c=e-i/a;if(Math.abs(c-e)<o.convergenceThreshold)return{root:c,iterations:u+1,converged:!0,error:Math.abs(r(c))};e=c,u++}return{root:e,iterations:u,converged:!1,error:Math.abs(r(e))}},bisection:function(r,n,t){if(r(n)*r(t)>=0)throw new Error("Function must have opposite signs at bounds");for(var e=n,u=t,i=0;i<o.maxIterations;){var a=(e+u)/2,c=r(a);if(Math.abs(c)<o.convergenceThreshold||Math.abs(u-e)<o.convergenceThreshold)return{root:a,iterations:i+1,converged:!0,error:Math.abs(c)};r(e)*c<0?u=a:e=a,i++}return{root:(e+u)/2,iterations:i,converged:!1,error:Math.abs(r((e+u)/2))}},simpson:function(r,n,t){var e=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;e%2!=0&&e++;for(var o=(t-n)/e,u=r(n)+r(t),i=1;i<e;i++){u+=(i%2==0?2:4)*r(n+i*o)}return o/3*u},derivative:function(r,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e-8;return(r(n+t)-r(n-t))/(2*t)}}),t(this,"stats",{mean:function(r){return r.reduce(function(r,n){return r+n},0)/r.length},median:function(r){var n=e(r).sort(function(r,n){return r-n}),t=Math.floor(n.length/2);return n.length%2==0?(n[t-1]+n[t])/2:n[t]},stdDev:function(r){var n=o.stats.mean(r),t=r.reduce(function(r,t){return r+Math.pow(t-n,2)},0)/r.length;return Math.sqrt(t)},correlation:function(r,n){for(var t=Math.min(r.length,n.length),e=o.stats.mean(r.slice(0,t)),u=o.stats.mean(n.slice(0,t)),i=0,a=0,c=0,f=0;f<t;f++){var s=r[f]-e,v=n[f]-u;i+=s*v,a+=s*s,c+=v*v}var h=Math.sqrt(a*c);return 0!==h?i/h:0},linearRegression:function(r,n){for(var t=Math.min(r.length,n.length),e=o.stats.mean(r.slice(0,t)),u=o.stats.mean(n.slice(0,t)),i=0,a=0,c=0;c<t;c++){var f=r[c]-e;i+=f*(n[c]-u),a+=f*f}for(var s=0!==a?i/a:0,v=u-s*e,h=0,l=0,d=0;d<t;d++){var p=s*r[d]+v;h+=Math.pow(n[d]-p,2),l+=Math.pow(n[d]-u,2)}return{slope:s,intercept:v,rSquared:0!==l?1-h/l:0,predict:function(r){return s*r+v}}}}),t(this,"utils",{clamp:function(r,n,t){return Math.max(n,Math.min(t,r))},map:function(r,n,t,e,o){return e+(r-n)*(o-e)/(t-n)},approxEqual:function(r,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.precision;return Math.abs(r-n)<t},round:function(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=Math.pow(10,n);return Math.round(r*t)/t},range:function(r,n){for(var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,e=[],o=r;o<=n;o+=t)e.push(o);return e},linspace:function(r,n,t){var e=(n-r)/(t-1);return Array.from({length:t},function(n,t){return r+t*e})}}),this.precision=1e-10,this.maxIterations=1e3,this.convergenceThreshold=1e-6},[{key:"setPrecision",value:function(r){this.precision=r}},{key:"setMaxIterations",value:function(r){this.maxIterations=r}},{key:"setConvergenceThreshold",value:function(r){this.convergenceThreshold=r}}])}();export{o as Numerics};
@@ -0,0 +1 @@
1
+ import{createClass as e,objectSpread2 as t,classCallCheck as i}from"../../_virtual/_rollupPluginBabelHelpers.js";import*as n from"three";import{getHardcodedUuid as s}from"../core/nameUtils.js";var o=function(){return e(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e),this.scene=t.scene||null,this.camera=t.camera||null,this.renderer=t.renderer||null,this.controls=t.controls||null,this.transformManager=t.transformManager||null,this.componentManager=t.componentManager||null,this.pathfindingManager=t.pathfindingManager||null,this.currentSceneData=t.currentSceneData||null,this.logger=t.logger||console,this.isInitialized=!1,this.selectedObject=null,this.sceneObjects=[],this.logger.info("๐Ÿ”ง SceneHelper initialized")},[{key:"initialize",value:function(e){this.scene=e.scene,this.camera=e.camera,this.renderer=e.renderer,this.controls=e.controls,this.transformManager=e.transformManager,this.componentManager=e.componentManager,this.pathfindingManager=e.pathfindingManager,this.currentSceneData=e.currentSceneData,this.isInitialized=!0,this.logger.info("โœ… SceneHelper initialized with scene components")}},{key:"updateSceneData",value:function(e){this.currentSceneData=e}},{key:"isReady",value:function(){return this.isInitialized&&this.scene&&this.camera&&this.renderer}},{key:"getSceneObjects",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.scene)return this.logger.warn("โš ๏ธ Scene not available for object retrieval"),[];var i=e.includeComponents,n=void 0===i||i,o=e.includeConnectors,l=void 0===o||o,r=e.includeGateways,a=void 0===r||r,u=e.includeHelpers,h=void 0!==u&&u,c=e.includeInvisible,v=void 0!==c&&c,f=e.componentTypesFilter,d=void 0===f?null:f,b=[];return this.scene.traverse(function(e){if(e.userData){var i=e.userData.componentType,o=e.visible;(v||o)&&("component"!==i||n)&&("connector"!==i||l)&&("gateway"!==i||a)&&("helper"!==i||h)&&(d&&Array.isArray(d)&&!d.includes(i)||e.name&&(e.name.includes("helper")||e.name.includes("Helper")||e.name.includes("controls")||"CameraGimbal"===e.name||"GridHelper"===e.type||"AxesHelper"===e.type)||b.push({uuid:s(e),name:e.name||"Unnamed Object",type:e.type,object:e,componentType:i,position:e.position.clone(),rotation:e.rotation.clone(),scale:e.scale.clone(),visible:o,userData:t({},e.userData)}))}}),b}},{key:"getSceneObjectsHierarchy",value:function(){if(!this.scene)return this.logger.warn("โš ๏ธ Scene not available for hierarchy retrieval"),[];var e=function(t){var i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(t.name&&(t.name.includes("helper")||t.name.includes("Helper")||t.name.includes("controls")||"CameraGimbal"===t.name)||"GridHelper"===t.type||"AxesHelper"===t.type)return null;var o=null===(i=t.userData)||void 0===i?void 0:i.componentType;if(!("Scene"===t.type||"component"===o||"connector"===o||"gateway"===o)&&"Scene"!==t.type)return null;var l={uuid:s(t),name:t.name||"Unnamed Object",type:t.type,object:t,componentType:o||"other",level:n,visible:t.visible,children:[]};return t.children&&t.children.length>0&&t.children.forEach(function(t){var i=e(t,n+1);i&&l.children.push(i)}),l},t=[];return this.scene.children&&this.scene.children.length>0&&this.scene.children.forEach(function(i){var n=e(i,0);n&&t.push(n)}),t}},{key:"findObjectByUuid",value:function(e){if(!this.scene||!e)return null;var t=null;return this.scene.traverse(function(i){s(i)!==e||(t=i)}),t}},{key:"findObjectsByName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.scene||!e)return[];var i=[];return this.scene.traverse(function(n){n.name&&((t?n.name===e:n.name.toLowerCase().includes(e.toLowerCase()))&&i.push(n))}),i}},{key:"findObjectsByComponentType",value:function(e){if(!this.scene||!e)return[];var t=[];return this.scene.traverse(function(i){var n;(null===(n=i.userData)||void 0===n?void 0:n.componentType)===e&&t.push(i)}),t}},{key:"isSelectableObject",value:function(e){var t;if(!e||!e.parent)return!1;var i=null===(t=e.userData)||void 0===t?void 0:t.componentType,n="component"===i,s="connector"===i,o="gateway"===i;return(e.isMesh||e.isObject3D)&&e.visible&&(n||s||o)}},{key:"selectObject",value:function(e){return e&&this.isSelectableObject(e)?(this.selectedObject=e,this.transformManager&&this.transformManager.selectObject(e),this.logger.info("โœ… Object selected: ".concat(e.name," (").concat(e.uuid,")")),!0):(this.logger.warn("โš ๏ธ Cannot select invalid object"),!1)}},{key:"deselectObject",value:function(){this.transformManager&&this.transformManager.deselectObject(),this.selectedObject=null,this.logger.info("โœ… Object deselected")}},{key:"getSelectedObject",value:function(){return this.selectedObject}},{key:"getSelectedTransform",value:function(){return this.transformManager&&this.selectedObject?this.transformManager.getTransformData():null}},{key:"focusOnObject",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&this.camera&&this.controls){var i=t.distance,s=void 0===i?10:i,o=t.animate,l=void 0===o||o,r=t.duration,a=void 0===r?1e3:r,u=new n.Vector3;e.getWorldPosition(u);var h=u.clone().add(new n.Vector3(s,s,s));l&&this.controls.transitionTo?this.controls.transitionTo(h,u,a):(this.camera.position.copy(h),this.camera.lookAt(u),this.controls.target&&(this.controls.target.copy(u),this.controls.update())),this.logger.info("๐ŸŽฅ Camera focused on object: ".concat(e.name))}else this.logger.warn("โš ๏ธ Cannot focus on object: missing components")}},{key:"fitAllObjectsInView",value:function(){if(this.camera&&this.controls){var e=new n.Box3,t=this.getSceneObjects({includeHelpers:!1});if(0!==t.length){t.forEach(function(t){var i=t.object;e.expandByObject(i)});var i=e.getCenter(new n.Vector3),s=e.getSize(new n.Vector3),o=Math.max(s.x,s.y,s.z)/(2*Math.tan(Math.PI*this.camera.fov/360));this.camera.position.copy(i),this.camera.position.z+=1.5*o,this.controls.target&&(this.controls.target.copy(i),this.controls.update()),this.logger.info("๐ŸŽฅ Camera fitted to ".concat(t.length," objects"))}else this.logger.warn("โš ๏ธ No objects to fit in view")}else this.logger.warn("โš ๏ธ Cannot fit objects in view: missing camera or controls")}},{key:"getComponentsWithDimensions",value:function(){if(!this.currentSceneData)return[];var e=[];return this.scene.traverse(function(t){t.userData&&"component"===t.userData.componentType&&t.userData.dimensions&&e.push({name:t.name||"Unnamed Component",uuid:s(t),position:t.position.clone(),rotation:t.rotation.clone(),dimensions:t.userData.dimensions,boundingBox:t.userData.adaptedBoundingBox,libraryId:t.userData.libraryId,object:t})}),e}},{key:"getSceneStats",value:function(){if(!this.scene)return{};var e={totalObjects:0,components:0,connectors:0,gateways:0,meshes:0,materials:0,textures:0,lights:0,cameras:0};return this.scene.traverse(function(t){var i,n,s;e.totalObjects++,"component"===(null===(i=t.userData)||void 0===i?void 0:i.componentType)&&e.components++,"connector"===(null===(n=t.userData)||void 0===n?void 0:n.componentType)&&e.connectors++,"gateway"===(null===(s=t.userData)||void 0===s?void 0:s.componentType)&&e.gateways++,t.isMesh&&e.meshes++,t.isLight&&e.lights++,t.isCamera&&e.cameras++,t.material&&e.materials++}),e}},{key:"debugSceneInfo",value:function(){var e,t=this.getSceneStats(),i=this.getSceneObjects();this.logger.info("๐Ÿ” Scene Debug Information:"),this.logger.info(" Statistics:",t),this.logger.info(" Objects:",i.length),this.logger.info(" Selected:",(null===(e=this.selectedObject)||void 0===e?void 0:e.name)||"None"),this.logger.info(" Scene Data:",this.currentSceneData?"Available":"Not Available")}},{key:"hasVisibleObjects",value:function(){var e=this;if(!this.scene)return!1;var t=!1;return this.scene.traverse(function(i){var n;i.visible&&null!==(n=i.userData)&&void 0!==n&&n.componentType&&i!==e.scene&&(t=!0)}),t}},{key:"dispose",value:function(){this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.transformManager=null,this.componentManager=null,this.pathfindingManager=null,this.currentSceneData=null,this.selectedObject=null,this.sceneObjects=[],this.isInitialized=!1,this.logger.info("๐Ÿงน SceneHelper disposed")}}])}();export{o as SceneHelper,o as default};
@@ -1 +1 @@
1
- import*as r from"./animationManager.js";export{r as animationManager};import*as o from"./componentManager.js";export{o as componentManager};import*as e from"./debugLogger.js";export{e as debugLogger};export{logger,modelLogger,pathfinderLogger,transformLogger}from"./debugLogger.js";import*as a from"./disposalManager.js";export{a as disposalManager};import*as t from"./environmentManager.js";export{t as environmentManager};import*as n from"./hotReloadManager.js";export{n as hotReloadManager};import*as s from"./keyboardControlsManager.js";export{s as keyboardControlsManager};import*as m from"./nameUtils.js";export{m as nameUtils};export{findObjectByHardcodedUuid,generateUuidFromName,getHardcodedUuid}from"./nameUtils.js";import*as p from"./pathfindingManager.js";export{p as pathfindingManager};import*as i from"./performanceMonitor.js";import*as g from"./sceneExportManager.js";export{g as sceneExportManager};export{getSceneExportManager}from"./sceneExportManager.js";import*as f from"./sceneInitializationManager.js";export{f as sceneInitializationManager};import*as d from"./textureConfig.js";export{d as textureConfig};import*as x from"./transformControlsManager.js";export{x as transformControlsManager};export{getTransformControlsManager}from"./transformControlsManager.js";var j={animation:r,component:o,debug:e,disposal:a,environment:t,hotReload:n,keyboardControls:s,name:m,pathfinding:p,performance:i,sceneExport:g,sceneInitialization:f,texture:d,transformControls:x};export{j as default};
1
+ export{CentralPlant}from"./core/centralPlant.js";export{DebugLogger,logger,modelLogger,pathfinderLogger,transformLogger}from"./core/debugLogger.js";export{findObjectByHardcodedUuid,generateUuidFromName,getHardcodedUuid}from"./core/nameUtils.js";export{MathUtils}from"./core/mathUtils.js";export{SceneInitializationManager}from"./managers/scene/sceneInitializationManager.js";export{SceneOperationsManager}from"./managers/scene/sceneOperationsManager.js";export{SceneExportManager}from"./managers/scene/sceneExportManager.js";export{SceneTooltipsManager}from"./managers/scene/sceneTooltipsManager.js";export{ComponentManager}from"./managers/components/componentManager.js";export{AnimationManager}from"./managers/components/animationManager.js";export{PathfindingManager}from"./managers/components/pathfindingManager.js";export{createTransformControls}from"./managers/controls/transformControlsManager.js";export{KeyboardControlsManager}from"./managers/controls/keyboardControlsManager.js";export{CameraControlsManager}from"./managers/controls/cameraControlsManager.js";export{default as DragDropManager}from"./managers/controls/dragDropManager.js";export{EnvironmentManager}from"./managers/environment/environmentManager.js";export{loadTextureSetAndCreateMaterial}from"./managers/environment/textureConfig.js";export{HotReloadManager}from"./managers/system/hotReloadManager.js";export{DisposalManager}from"./managers/system/disposalManager.js";export{PerformanceMonitor}from"./managers/system/performanceMonitor.js";export{default as modelPreloader}from"./rendering/modelPreloader.js";import*as r from"./rendering/rendering2D.js";export{r as Rendering2D};import*as e from"./rendering/rendering3D.js";export{e as Rendering3D};import*as a from"./data/import.js";export{a as ImportUtils};import*as o from"./data/export.js";export{o as ExportUtils};import*as n from"./data/numerics.js";export{n as Numerics};import*as s from"./analysis/analysis.js";export{s as Analysis};import*as t from"./analysis/testing.js";export{t as Testing};
@@ -0,0 +1 @@
1
+ import{createClass as t,classCallCheck as i}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{logger as e}from"../../core/debugLogger.js";var n=function(){return t(function t(e){i(this,t),this.sceneViewer=e,this.lastFrameTime=0,this.targetFPS=60,this.frameInterval=1e3/this.targetFPS,this.animationId=null},[{key:"startAnimation",value:function(){var t=this,i=this.sceneViewer,n=function(e){i.isDestroyed||(t.animationId=requestAnimationFrame(n),e-t.lastFrameTime<t.frameInterval||(t.lastFrameTime=e,!i.isDestroyed&&i.controls&&i.renderer&&i.scene&&i.camera&&t.updateFrame()))};n(0),e.info("Animation loop started")}},{key:"updateFrame",value:function(){var t=this.sceneViewer;t.controls.update(),t.performanceMonitor&&(t.performanceMonitor.update(),t.performanceMonitor.updateSceneStats(t.scene)),t.renderer.render(t.scene,t.camera),t.tooltipsManager&&t.tooltipsManager.render()}},{key:"stopAnimation",value:function(){this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=null,e.info("Animation loop stopped"))}},{key:"setTargetFPS",value:function(t){this.targetFPS=t,this.frameInterval=1e3/this.targetFPS,e.info("Target FPS set to: ".concat(t))}},{key:"getCurrentFPS",value:function(){var t=this.sceneViewer;return t.performanceMonitor?t.performanceMonitor.getCurrentFPS():null}},{key:"dispose",value:function(){this.stopAnimation(),this.lastFrameTime=0,e.info("AnimationManager disposed")}}])}();export{n as AnimationManager};
@@ -0,0 +1 @@
1
+ import{createClass as n,classCallCheck as e,asyncToGenerator as r,regenerator as o,objectSpread2 as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import"three";import{findObjectByHardcodedUuid as i}from"../../core/nameUtils.js";import a from"../../rendering/modelPreloader.js";var u=function(){return n(function n(r){e(this,n),this.sceneViewer=r},[{key:"addComponentToScene",value:(u=r(o().m(function n(e){var r,i,u,l,c,s,d,v,f,m,p=this;return o().w(function(n){for(;;)switch(n.n){case 0:if(n.p=0,e.libraryId&&e.modelKey){n.n=1;break}return n.a(2,!1);case 1:return i=e.libraryId+"-"+Date.now()+"-"+Math.random().toString(36).substr(2,9),u={},n.p=2,n.n=3,fetch("./library/component-dictionary.json");case 3:return l=n.v,n.n=4,l.json();case 4:u=n.v,n.n=6;break;case 5:return n.p=5,n.v,n.a(2,!1);case 6:if(c=u[e.libraryId]){n.n=7;break}return n.a(2,!1);case 7:if(s=e.position||{x:0,y:0,z:0},d=a.getCachedModelWithDimensions(c.modelKey,e.libraryId)){n.n=11;break}return n.p=8,n.n=9,new Promise(function(n,e){p.sceneViewer.gltfLoader.load("./library/models/".concat(c.modelKey),n,void 0,e)});case 9:v=n.v,d=v.scene,d=a.addDimensionsToModel(d,e.libraryId),n.n=11;break;case 10:return n.p=10,n.v,n.a(2,!1);case 11:return(f=d.clone()).uuid=i,f.name=(e.uuid||e.libraryId)+" Component",f.position.set(s.x,s.y,s.z),f.userData=t({libraryId:e.libraryId,componentType:"component",forExport:!0,originalUuid:i},(null===(r=d.userData)||void 0===r?void 0:r.dimensions)&&{dimensions:d.userData.dimensions}),c.boundingBox&&(f.userData.dimensions={x:c.boundingBox.x,y:c.boundingBox.y,z:c.boundingBox.z}),c.adaptedBoundingBox&&(f.userData.adaptedBoundingBox={x:c.adaptedBoundingBox.x,y:c.adaptedBoundingBox.y,z:c.adaptedBoundingBox.z}),f.traverse(function(n){n.isMesh&&(n.castShadow=!0,n.receiveShadow=!0,n.material&&(n.material.envMapIntensity=1),n.name&&n.name.toLowerCase().includes("connector")&&(n.userData||(n.userData={}),n.userData.forExport=!0,n.userData.componentType="connector"))}),this.sceneViewer.scene.add(f),"undefined"!=typeof window&&(m=new CustomEvent("componentAdded",{detail:{component:f,libraryId:e.libraryId,uuid:i,position:f.position,dimensions:f.userData.dimensions}}),window.dispatchEvent(m)),this.sceneViewer.enableTransformControls&&this.sceneViewer.enableTransformControls(),n.a(2,!0);case 12:return n.p=12,n.v,n.a(2,!1)}},n,this,[[8,10],[2,5],[0,12]])})),function(n){return u.apply(this,arguments)})},{key:"removeComponentFromScene",value:function(n){try{var e=i(this.sceneViewer.scene,n);if(!e)return!1;if(e.traverse(function(n){n.geometry&&n.geometry.dispose(),n.material&&(Array.isArray(n.material)?n.material.forEach(function(n){return n.dispose()}):n.material.dispose())}),this.sceneViewer.scene.remove(e),"undefined"!=typeof window){var r,o=new CustomEvent("componentRemoved",{detail:{uuid:n,name:e.name,libraryId:null===(r=e.userData)||void 0===r?void 0:r.libraryId}});window.dispatchEvent(o)}return!0}catch(n){return!1}}},{key:"getSceneComponents",value:function(){var n=[];return this.sceneViewer.scene.traverse(function(e){var r,o;"component"===(null===(r=e.userData)||void 0===r?void 0:r.componentType)&&n.push({uuid:(null===(o=e.userData)||void 0===o?void 0:o.originalUuid)||e.uuid,name:e.name,libraryId:e.userData.libraryId,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},scale:{x:e.scale.x,y:e.scale.y,z:e.scale.z}})}),n}},{key:"updateComponent",value:function(n,e){try{var r,o,t,a,u,l,c,s,d,v=i(this.sceneViewer.scene,n);if(!v)return!1;if(e.position)v.position.set(null!==(r=e.position.x)&&void 0!==r?r:v.position.x,null!==(o=e.position.y)&&void 0!==o?o:v.position.y,null!==(t=e.position.z)&&void 0!==t?t:v.position.z);if(e.rotation)v.rotation.set(null!==(a=e.rotation.x)&&void 0!==a?a:v.rotation.x,null!==(u=e.rotation.y)&&void 0!==u?u:v.rotation.y,null!==(l=e.rotation.z)&&void 0!==l?l:v.rotation.z);if(e.scale)v.scale.set(null!==(c=e.scale.x)&&void 0!==c?c:v.scale.x,null!==(s=e.scale.y)&&void 0!==s?s:v.scale.y,null!==(d=e.scale.z)&&void 0!==d?d:v.scale.z);return e.name&&(v.name=e.name),!0}catch(n){return!1}}}]);var u}();export{u as ComponentManager};
@@ -0,0 +1 @@
1
+ import{createClass as n,objectSpread2 as e,construct as t,toConsumableArray as r,slicedToArray as i,classCallCheck as o,createForOfIteratorHelper as a,asyncToGenerator as u,regenerator as s}from"../../../_virtual/_rollupPluginBabelHelpers.js";import*as c from"three";import{Pathfinder as l}from"../../../node_modules/@2112-lab/pathfinder/dist/index.esm.js";import{logger as f,pathfinderLogger as v}from"../../core/debugLogger.js";import{generateUuidFromName as d}from"../../core/nameUtils.js";var h=function(){return n(function n(e){o(this,n),this.sceneViewer=e,this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,this.pathfinderConfig={grid:{size:.5,safetyMargin:0,minSegmentLength:.5,timeout:1e3}}},[{key:"getPathfinderVersionInfo",value:(w=u(s().m(function n(){var e;return s().w(function(n){for(;;)switch(n.n){case 0:if(!this.pathfinderVersionInfo){n.n=1;break}return n.a(2,this.pathfinderVersionInfo);case 1:return e={version:"1.0.17",detectionMethod:"hardcoded-fallback",timestamp:(new Date).toISOString()},this.pathfinderVersionInfo=e,n.a(2,e)}},n,this)})),function(){return w.apply(this,arguments)})},{key:"logPathfinderVersion",value:(g=u(s().m(function n(){var e,t,r,i=arguments;return s().w(function(n){for(;;)switch(n.n){case 0:return e=i.length>0&&void 0!==i[0]?i[0]:"Unknown Context",n.p=1,n.n=2,this.getPathfinderVersionInfo();case 2:t=n.v,v.info("[".concat(e,"] Pathfinder Module Information:"),{version:t.version,detectionMethod:t.detectionMethod,context:e,timestamp:t.timestamp,pathfinderInstance:!!this.pathfinder}),n.n=4;break;case 3:n.p=3,r=n.v,v.error("[".concat(e,"] Failed to get pathfinder version:"),r);case 4:return n.a(2)}},n,this,[[1,3]])})),function(){return g.apply(this,arguments)})},{key:"getPathColor",value:function(n){var e=["#468e49","#245e29","#2e80d2","#1d51a1"];return e[n%e.length]}},{key:"_executePathfinding",value:(p=u(s().m(function n(e,t){var r,i,o,a,u,f,v,d=this,h=arguments;return s().w(function(n){for(;;)switch(n.n){case 0:return i=(r=h.length>2&&void 0!==h[2]?h[2]:{}).createGateways,o=void 0!==i&&i,a=r.context,u=void 0===a?"Pathfinding":a,n.n=1,this.logPathfinderVersion(u);case 1:return this.pathfinder=new l(this.pathfinderConfig),this.sceneViewer.pathfinder=this.pathfinder,e.object.children=e.object.children.filter(function(n){return"computed"!==n.userData.origin}),f=this.pathfinder.findPaths(e,t),o&&f.gateways&&f.gateways.forEach(function(n){if(n.position){var e=new c.Mesh(new c.SphereGeometry(.15,16,16),new c.MeshStandardMaterial({color:16777215,roughness:.7,metalness:.3,emissive:0}));e.position.copy(n.position),e.name=n.id,e.uuid=n.id,e.userData={componentType:"gateway",forExport:!0,gatewayId:n.id,originalUuid:n.id,origin:"computed",connections:n.connections},d.sceneViewer.scene.add(e)}}),v=this.mergeColinearPaths(f.paths),this.createPipePaths(v,this.crosscubeTextureSet),n.a(2,f)}},n,this)})),function(n,e){return p.apply(this,arguments)})},{key:"initializePathfinder",value:(y=u(s().m(function n(e,t){var r;return s().w(function(n){for(;;)switch(n.n){case 0:return this.crosscubeTextureSet=t,n.n=1,this.t(e.scene,e.connections,{createGateways:!0,context:"Scene Loading"});case 1:return(r=n.v).rewiredConnections,n.a(2,r)}},n,this)})),function(n,e){return y.apply(this,arguments)})},{key:"removeComputedObjects",value:function(){var n=this.sceneViewer,e=[];n.scene.traverse(function(n){if(n.name&&n.name.includes("Polyline")){var t=!1,r=[];if(n.traverse(function(n){n.userData&&n.userData.isPipeSegment&&n.userData.isManuallyPositioned&&(t=!0,r.push(n))}),t){var i=[];n.traverse(function(n){(n.userData&&n.userData.isPipeSegment&&!n.userData.isManuallyPositioned||n.userData&&n.userData.isPipeElbow)&&i.push(n)}),i.forEach(function(e){n.remove(e),e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(function(n){return n.dispose()}):e.material.dispose())}),0===n.children.length&&e.push(n)}else e.push(n)}n.userData&&"computed"===n.userData.origin&&e.push(n)});for(var t=0,r=e;t<r.length;t++){var i=r[t];n.scene.remove(i),i.geometry&&i.geometry.dispose(),i.material&&(Array.isArray(i.material)?i.material.forEach(function(n){return n.dispose()}):i.material.dispose())}}},{key:"createPipeMaterial",value:function(n,i){if(n){var o=e(e({},n.config.materialProps),{},{color:this.getPathColor(i),map:n.textures.diffuse,normalMap:n.textures.normal,roughnessMap:n.textures.roughness,metalness:.2,roughness:.9,clearcoat:.2,clearcoatRoughness:.2,envMapIntensity:.6,reflectivity:.4});o.normalScale&&Array.isArray(o.normalScale)&&(o.normalScale=t(c.Vector2,r(o.normalScale)));var a=new c.MeshPhysicalMaterial(o);return[a.map,a.normalMap,a.roughnessMap].filter(Boolean).forEach(function(e){e.wrapS=e.wrapT=c.RepeatWrapping,e.repeat.set(2*n.config.repeat.x,2*n.config.repeat.y)}),a}return new c.MeshPhysicalMaterial({color:this.getPathColor(i),metalness:.9,roughness:.7,clearcoat:.1,clearcoatRoughness:.3,envMapIntensity:1.5,reflectivity:.3})}},{key:"createPipePaths",value:function(n,e){var t=this,r=this.sceneViewer;n.forEach(function(n,i){if(n.path&&n.path.length>=2){var o=new c.Object3D;o.name="Polyline ".concat(n.from,"-").concat(n.to);for(var a=t.createPipeMaterial(e,i),u=n.path.map(function(n){return n instanceof c.Vector3?n.clone():Array.isArray(n)?(new c.Vector3).fromArray(n):void 0!==n.x&&void 0!==n.y&&void 0!==n.z?new c.Vector3(n.x,n.y,n.z):new c.Vector3(0,0,0)}),s=function(e){var s=u[e],l=u[e+1],f=(new c.Vector3).subVectors(l,s),v=f.length();if(v<1e-6)return 0;var d=!1;if(r.scene.traverse(function(t){t.userData&&t.userData.isPipeSegment&&t.userData.isManuallyPositioned&&t.userData.segmentId==="pipe-segment-".concat(n.from,"-").concat(n.to,"-").concat(e)&&(d=!0)}),d)return 0;var h=new c.CylinderGeometry(.1,.1,v,8,1,!1),m=new c.Mesh(h,a);m.position.copy(s).add(l).multiplyScalar(.5);var y=new c.Quaternion,p=new c.Vector3(0,1,0);y.setFromUnitVectors(p,f.clone().normalize()),m.quaternion.copy(y),m.castShadow=!0,m.receiveShadow=!0;var g="pipe-segment-".concat(n.from,"-").concat(n.to,"-").concat(e);if(m.name="Pipe Segment ".concat(e+1,": ").concat(n.from,"-").concat(n.to),m.userData={isPipeSegment:!0,segmentId:g,segmentIndex:e,pathFrom:n.from,pathTo:n.to,pathIndex:i,length:v.toFixed(2),component:{type:"PipeSegment",attributes:{length:{key:"Length",value:v.toFixed(2),unit:"m"}}}},o.add(m),e<u.length-2){var w=u[e+1].clone().sub(u[e]).normalize(),k=u[e+2].clone().sub(u[e+1]).normalize(),x=w.angleTo(k);if(x>Math.PI/36){var P=t.createElbowGeometry(u[e],u[e+1],u[e+2],.1);if(P){var S=new c.Mesh(P,a);S.castShadow=!0,S.receiveShadow=!0;var b="pipe-elbow-".concat(n.from,"-").concat(n.to,"-").concat(e);S.name="Pipe Elbow ".concat(e+1,": ").concat(n.from,"-").concat(n.to),S.userData={isPipeElbow:!0,elbowId:b,elbowIndex:e,pathFrom:n.from,pathTo:n.to,pathIndex:i,angle:(180*x/Math.PI).toFixed(1),component:{type:"PipeElbow",attributes:{angle:{key:"Bend Angle",value:(180*x/Math.PI).toFixed(1),unit:"ยฐ"}}}},o.add(S)}}}},l=0;l<u.length-1;l++)s(l);o.name="Polyline",r.scene.add(o)}})}},{key:"handleManualSegmentTransformation",value:function(n,e){if(n&&n.userData&&n.userData.isPipeSegment){var t=this.calculateSegmentEndpoints(n),r=this.createSegmentConnectors(n,t);this.addConnectorsToScene(r),this.convertConnectedGatewaysToManual(r,e);var i=this.findOriginalConnection(n,e.connections);i&&(this.restructureConnections(i,r,e),n.userData.isManuallyPositioned=!0,n.userData.manualConnectors=r.map(function(n){return n.uuid}),this.addManualSegmentToSceneData(n))}}},{key:"convertConnectedGatewaysToManual",value:function(n,e){var t,r,i=this,o=this.sceneViewer,a=[],u=null!==(t=n[0])&&void 0!==t&&null!==(t=t.userData)&&void 0!==t&&t.manualSegmentUuid?o.scene.getObjectByProperty("uuid",n[0].userData.manualSegmentUuid):null;u&&null!==(r=u.userData)&&void 0!==r&&r.isPipeSegment&&([u.userData.pathFrom,u.userData.pathTo].forEach(function(n){var t,r,u=null;(o.scene.traverse(function(e){var t;e.uuid!==n&&(null===(t=e.userData)||void 0===t?void 0:t.originalUuid)!==n||(u=e)}),u)&&("gateway"===(null===(t=u.userData)||void 0===t?void 0:t.componentType)&&"computed"===(null===(r=u.userData)||void 0===r?void 0:r.origin)&&(i.convertGatewayToManual(u,e),a.push(u)))}),a.length)}},{key:"convertGatewayToManual",value:function(n,e){var t;n.userData.origin="declared";for(var r=0;r<e.scene.object.children.length;r++){var i,o,a=e.scene.object.children[r];if(a.uuid===n.uuid||a.uuid===(null===(i=n.userData)||void 0===i?void 0:i.originalUuid)||n.uuid===(null===(o=a.userData)||void 0===o?void 0:o.originalUuid)){a.userData||(a.userData={}),a.userData.origin="declared";break}}if(null!==(t=n.userData)&&void 0!==t&&t.connections&&e.connections){var u=n.userData.connections,s=e.connections;u.removed&&Array.isArray(u.removed)&&(e.connections=s.filter(function(n){var e=u.removed.some(function(e){return e.from===n.from&&e.to===n.to||e.from===n.to&&e.to===n.from});return!e})),u.added&&Array.isArray(u.added)&&u.added.forEach(function(n){e.connections.some(function(e){return e.from===n.from&&e.to===n.to||e.from===n.to&&e.to===n.from})||e.connections.push(n)})}}},{key:"findOriginalConnection",value:function(n,e){var t=n.userData,r=t.pathFrom,i=t.pathTo,o=e.find(function(n){return n.from===r&&n.to===i||n.from===i&&n.to===r});if(o)return o;var a=this.sceneViewer,u=null,s=null;if(a.scene.traverse(function(n){var e,t;n.uuid!==r&&(null===(e=n.userData)||void 0===e?void 0:e.originalUuid)!==r||(u=n),n.uuid!==i&&(null===(t=n.userData)||void 0===t?void 0:t.originalUuid)!==i||(s=n)}),u&&s&&(o=e.find(function(n){return n.from===u.uuid&&n.to===s.uuid||n.from===s.uuid&&n.to===u.uuid})))return o;var c=e.filter(function(n){var e,t,o=n.from===r||n.from===i,u=n.to===r||n.to===i,s="gateway"===(null===(e=a.scene.getObjectByProperty("uuid",n.from))||void 0===e||null===(e=e.userData)||void 0===e?void 0:e.componentType),c="gateway"===(null===(t=a.scene.getObjectByProperty("uuid",n.to))||void 0===t||null===(t=t.userData)||void 0===t?void 0:t.componentType);return o||u||s||c});return c.length>0?c[0]:null}},{key:"calculateSegmentEndpoints",value:function(n){var e=n.geometry.parameters.height||1,t=new c.Vector3,r=new c.Vector3,i=new c.Vector3(0,1,0);return i.applyQuaternion(n.quaternion),t.copy(n.position).sub(i.clone().multiplyScalar(e/2)),r.copy(n.position).add(i.clone().multiplyScalar(e/2)),{start:t,end:r}}},{key:"createSegmentConnectors",value:function(n,e){var t=n.userData.segmentId,r=[],i=new c.Mesh(new c.SphereGeometry(.2,16,16),new c.MeshStandardMaterial({color:65280,roughness:.7,metalness:.3,emissive:13056}));i.position.copy(e.start),i.uuid="".concat(t,"-connector-start"),i.name="Manual Segment Start Connector: ".concat(n.name),i.userData={componentType:"connector",forExport:!0,isManualSegmentConnector:!0,segmentId:t,connectorType:"start",manualSegmentUuid:n.uuid};var o=new c.Mesh(new c.SphereGeometry(.2,16,16),new c.MeshStandardMaterial({color:16711680,roughness:.7,metalness:.3,emissive:3342336}));return o.position.copy(e.end),o.uuid="".concat(t,"-connector-end"),o.name="Manual Segment End Connector: ".concat(n.name),o.userData={componentType:"connector",forExport:!0,isManualSegmentConnector:!0,segmentId:t,connectorType:"end",manualSegmentUuid:n.uuid},r.push(i,o),r}},{key:"addConnectorsToScene",value:function(n){var t=this.sceneViewer;n.forEach(function(n){if(t.scene.add(n),t.currentSceneData&&t.currentSceneData.scene&&t.currentSceneData.scene.object){var r={uuid:n.uuid,name:n.name,type:n.type,userData:e({},n.userData),position:{x:n.position.x,y:n.position.y,z:n.position.z},rotation:{x:n.rotation.x,y:n.rotation.y,z:n.rotation.z},scale:{x:n.scale.x,y:n.scale.y,z:n.scale.z},geometry:"CONNECTOR-GEO"};t.currentSceneData.scene.object.children.push(r)}})}},{key:"addManualSegmentToSceneData",value:function(n){var t=this.sceneViewer;if(t.currentSceneData&&t.currentSceneData.scene&&t.currentSceneData.scene.object){var r={uuid:n.uuid,name:n.name,type:n.type,userData:e({},n.userData),position:{x:n.position.x,y:n.position.y,z:n.position.z},rotation:{x:n.rotation.x,y:n.rotation.y,z:n.rotation.z},scale:{x:n.scale.x,y:n.scale.y,z:n.scale.z}};t.currentSceneData.scene.object.children.push(r)}}},{key:"restructureConnections",value:function(n,e,t){var o=i(e,2),a=o[0],u=o[1],s=t.connections.findIndex(function(e){return e.from===n.from&&e.to===n.to||e.from===n.to&&e.to===n.from});if(-1!==s){t.connections.splice(s,1);var c={from:n.from,to:a.uuid},l={from:u.uuid,to:n.to};t.connections.push(c,l),this.sceneViewer.currentSceneData&&(this.sceneViewer.currentSceneData.connections=r(t.connections))}}},{key:"createElbowGeometry",value:function(n,e,t,r){try{var i=3*r,o=this.createElbowCurve(n,e,t,i);return new c.TubeGeometry(o,12,r,8,!1)}catch(n){return null}}},{key:"createElbowCurve",value:function(n,e,t,r){var i=e.clone().sub(n).normalize(),o=t.clone().sub(e).normalize(),a=.001*r,u=e.clone().sub(i.clone().multiplyScalar(a)),s=e.clone().add(o.clone().multiplyScalar(a)),l=e.clone();return new c.QuadraticBezierCurve3(u,l,s)}},{key:"recomputeWorldBoundingBoxes",value:function(n){this.sceneViewer.scene.traverse(function(e){if(e.isMesh){var t=null,r=function(n){var t,i=a(n);try{for(i.s();!(t=i.n()).done;){var o,u,s=t.value;if(s.uuid===e.uuid||s.uuid===(null===(o=e.userData)||void 0===o?void 0:o.originalUuid)||e.uuid===(null===(u=s.userData)||void 0===u?void 0:u.originalUuid))return s;if(e.name&&s.name){var c=d(e.name),l=d(s.name);if(c===l||c===s.uuid||l===e.uuid)return s}if(e.name&&s.name&&e.name===s.name)return s;if(s.children){var f=r(s.children);if(f)return f}}}catch(n){i.e(n)}finally{i.f()}return null};if(t=r(n.scene.object.children)){var i=(new c.Box3).setFromObject(e);t.userData||(t.userData={}),t.userData.worldBoundingBox={min:i.min.toArray(),max:i.max.toArray()},t.userData.origin||(t.userData.origin=e.userData.origin),t.userData.direction||(t.userData.direction=e.userData.direction),t.userData.group||(t.userData.group=e.userData.group),t.userData.connections||(t.userData.connections=e.userData.connections),e.userData.associatedJsonObject=t}}})}},{key:"updatePathfindingWithConnections",value:(m=u(s().m(function n(e){var t,i;return s().w(function(n){for(;;)switch(n.n){case 0:if((t=this.sceneViewer).currentSceneData){n.n=1;break}return n.a(2,!1);case 1:return this.removeComputedObjects(),(i=JSON.parse(JSON.stringify(t.currentSceneData))).connections=r(e),n.n=2,this.t(i.scene,i.connections,{createGateways:!1,context:"Connections Update"});case 2:return t.currentSceneData=i,n.a(2,!0)}},n,this)})),function(n){return m.apply(this,arguments)})},{key:"updatePathfindingAfterTransform",value:(h=u(s().m(function n(e){return s().w(function(n){for(;;)switch(n.n){case 0:return this.removeComputedObjects(),n.n=1,this.t(e.scene,e.connections,{createGateways:!0,context:"Transform Update"});case 1:return n.a(2)}},n,this)})),function(n){return h.apply(this,arguments)})},{key:"dispose",value:function(){this.removeComputedObjects(),this.pathfinder=null,this.crosscubeTextureSet=null,this.pathfinderVersionInfo=null,f.info("PathfindingManager disposed")}},{key:"mergeColinearPaths",value:function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001,t=JSON.parse(JSON.stringify(n));return t.forEach(function(n){if(n.path&&!(n.path.length<=2)){var t=n.path.map(function(n){return n instanceof c.Vector3?n.clone():Array.isArray(n)?(new c.Vector3).fromArray(n):void 0!==n.x&&void 0!==n.y&&void 0!==n.z?new c.Vector3(n.x,n.y,n.z):new c.Vector3(0,0,0)});if(!(t.length<=2)){for(var r=[t[0]],i=0,o=function(){var n=t[i],o=t[i+1],a=(new c.Vector3).subVectors(o,n);if(a.length()<1e-6)return i++,1;a.normalize();for(var u=i+2;u<t.length;){var s=t[u],l=(new c.Vector3).subVectors(s,n);if(l.length()<1e-6)u++;else{l.normalize();var f=a.dot(l);if(!(Math.abs(f-1)<e))break;o=s,u++}}o.equals(n)||r.push(o);var v=t.findIndex(function(n,e){return e>i&&n.equals(o)});-1===v?i++:i=v};i<t.length-1;)o();var a=r.map(function(e){return Array.isArray(n.path[0])?[e.x,e.y,e.z]:void 0!==n.path[0].x?{x:e.x,y:e.y,z:e.z}:e});n.path=a;t.length,r.length}}}),t}}]);var h,m,y,p,g,w}();export{h as PathfindingManager};