@inweb/viewer-three 26.10.6 → 26.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/plugins/components/AxesHelperComponent.js +23 -1
  2. package/dist/plugins/components/AxesHelperComponent.js.map +1 -1
  3. package/dist/plugins/components/AxesHelperComponent.min.js +1 -1
  4. package/dist/plugins/components/AxesHelperComponent.module.js +24 -2
  5. package/dist/plugins/components/AxesHelperComponent.module.js.map +1 -1
  6. package/dist/plugins/components/ExtentsHelperComponent.js +18 -0
  7. package/dist/plugins/components/ExtentsHelperComponent.js.map +1 -1
  8. package/dist/plugins/components/ExtentsHelperComponent.min.js +1 -1
  9. package/dist/plugins/components/ExtentsHelperComponent.module.js +19 -1
  10. package/dist/plugins/components/ExtentsHelperComponent.module.js.map +1 -1
  11. package/dist/plugins/loaders/GLTFCloudLoader.js +2 -3
  12. package/dist/plugins/loaders/GLTFCloudLoader.js.map +1 -1
  13. package/dist/plugins/loaders/GLTFCloudLoader.min.js +1 -1
  14. package/dist/plugins/loaders/GLTFCloudLoader.module.js +2 -3
  15. package/dist/plugins/loaders/GLTFCloudLoader.module.js.map +1 -1
  16. package/dist/plugins/loaders/GLTFFileLoader.js +2499 -0
  17. package/dist/plugins/loaders/GLTFFileLoader.js.map +1 -0
  18. package/dist/plugins/loaders/GLTFFileLoader.min.js +24 -0
  19. package/dist/plugins/loaders/GLTFFileLoader.module.js +74 -0
  20. package/dist/plugins/loaders/GLTFFileLoader.module.js.map +1 -0
  21. package/dist/plugins/loaders/IFCXLoader.js +5 -7
  22. package/dist/plugins/loaders/IFCXLoader.js.map +1 -1
  23. package/dist/plugins/loaders/IFCXLoader.min.js +1 -1
  24. package/dist/plugins/loaders/IFCXLoader.module.js +5 -7
  25. package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -1
  26. package/dist/plugins/loaders/PotreeLoader.js +1 -2
  27. package/dist/plugins/loaders/PotreeLoader.js.map +1 -1
  28. package/dist/plugins/loaders/PotreeLoader.min.js +1 -1
  29. package/dist/plugins/loaders/PotreeLoader.module.js +1 -2
  30. package/dist/plugins/loaders/PotreeLoader.module.js.map +1 -1
  31. package/dist/viewer-three.js +770 -2777
  32. package/dist/viewer-three.js.map +1 -1
  33. package/dist/viewer-three.min.js +3 -3
  34. package/dist/viewer-three.module.js +609 -206
  35. package/dist/viewer-three.module.js.map +1 -1
  36. package/lib/Viewer/Viewer.d.ts +27 -20
  37. package/lib/Viewer/commands/GetSelected2.d.ts +2 -0
  38. package/lib/Viewer/commands/SelectModel.d.ts +1 -1
  39. package/lib/Viewer/commands/SetSelected2.d.ts +2 -0
  40. package/lib/Viewer/components/index.d.ts +6 -6
  41. package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +0 -1
  42. package/lib/Viewer/loaders/GLTFBinaryExtension.d.ts +5 -0
  43. package/lib/Viewer/loaders/GLTFCloudDynamicLoader.d.ts +2 -2
  44. package/lib/Viewer/loaders/{GLTFFileLoader.d.ts → GLTFFileDynamicLoader.d.ts} +7 -1
  45. package/lib/Viewer/loaders/GLTFLoadingManager.d.ts +4 -3
  46. package/lib/Viewer/loaders/RangesLoader.d.ts +15 -0
  47. package/lib/Viewer/loaders/index.d.ts +22 -14
  48. package/lib/Viewer/models/IModelImpl.d.ts +6 -8
  49. package/lib/Viewer/models/ModelImpl.d.ts +3 -5
  50. package/package.json +5 -5
  51. package/plugins/components/AxesHelperComponent.ts +31 -2
  52. package/plugins/components/ExtentsHelperComponent.ts +25 -0
  53. package/plugins/loaders/GLTFCloudLoader.ts +2 -3
  54. package/{src/Viewer → plugins}/loaders/GLTFFileLoader.ts +21 -12
  55. package/plugins/loaders/IFCX/IFCXCloudLoader.ts +5 -5
  56. package/plugins/loaders/IFCX/IFCXFileLoader.ts +3 -4
  57. package/plugins/loaders/Potree/PotreeFileLoader.ts +3 -4
  58. package/src/Viewer/Viewer.ts +120 -88
  59. package/src/Viewer/commands/ClearSelected.ts +3 -1
  60. package/src/Viewer/commands/GetModels.ts +1 -1
  61. package/src/Viewer/commands/GetSelected.ts +2 -2
  62. package/src/Viewer/commands/GetSelected2.ts +34 -0
  63. package/src/Viewer/commands/HideSelected.ts +3 -1
  64. package/src/Viewer/commands/SelectModel.ts +5 -5
  65. package/src/Viewer/commands/SetSelected.ts +9 -10
  66. package/src/Viewer/commands/SetSelected2.ts +42 -0
  67. package/src/Viewer/commands/ZoomToObjects.ts +5 -6
  68. package/src/Viewer/commands/ZoomToSelected.ts +3 -1
  69. package/src/Viewer/commands/index.ts +4 -0
  70. package/src/Viewer/components/CameraComponent.ts +6 -1
  71. package/src/Viewer/components/ExtentsComponent.ts +4 -1
  72. package/src/Viewer/components/SelectionComponent.ts +2 -0
  73. package/src/Viewer/components/index.ts +6 -6
  74. package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +253 -22
  75. package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +20 -10
  76. package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +3 -1
  77. package/src/Viewer/loaders/GLTFBinaryExtension.ts +91 -0
  78. package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +13 -19
  79. package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +145 -0
  80. package/src/Viewer/loaders/GLTFLoadingManager.ts +5 -4
  81. package/src/Viewer/loaders/RangesLoader.ts +95 -0
  82. package/src/Viewer/loaders/index.ts +24 -16
  83. package/src/Viewer/models/IModelImpl.ts +8 -9
  84. package/src/Viewer/models/ModelImpl.ts +30 -17
@@ -0,0 +1,24 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["exports","three","@inweb/viewer-three"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ODA=e.ODA||{},e.ODA.Three=e.ODA.Three||{},e.ODA.Three.Plugins=e.ODA.Three.Plugins||{}),e.THREE,e.ODA.Three)}(this,function(e,t,s){"use strict";function n(e,s){if(s===t.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(s===t.TriangleFanDrawMode||s===t.TriangleStripDrawMode){let n=e.getIndex();if(null===n){const t=[],s=e.getAttribute("position");if(void 0===s)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<s.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(s===t.TriangleFanDrawMode)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(i),o.clearGroups(),o}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",s),e}class r extends t.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new u(e)}),this.register(function(e){return new h(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new _(e)}),this.register(function(e){return new M(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new p(e)}),this.register(function(e){return new f(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new l(e)}),this.register(function(e){return new T(e)}),this.register(function(e){return new d(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new x(e)}),this.register(function(e){return new a(e)}),this.register(function(e){return new w(e)}),this.register(function(e){return new E(e)})}load(e,s,n,r){const i=this;let o;if(""!==this.resourcePath)o=this.resourcePath;else if(""!==this.path){const s=t.LoaderUtils.extractUrlBase(e);o=t.LoaderUtils.resolveURL(s,this.path)}else o=t.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},c=new t.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(t){try{i.parse(t,o,function(t){s(t),i.manager.itemEnd(e)},a)}catch(e){a(e)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let r;const i={},a={},l=new TextDecoder;if("string"==typeof e)r=JSON.parse(e);else if(e instanceof ArrayBuffer){if(l.decode(new Uint8Array(e,0,4))===A){try{i[o.KHR_BINARY_GLTF]=new S(e)}catch(e){return void(n&&n(e))}r=JSON.parse(i[o.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e))}else r=e;if(void 0===r.asset||r.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const u=new ee(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](u);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[t.name]=t,i[t.name]=!0}if(r.extensionsUsed)for(let e=0;e<r.extensionsUsed.length;++e){const t=r.extensionsUsed[e],s=r.extensionsRequired||[];switch(t){case o.KHR_MATERIALS_UNLIT:i[t]=new c;break;case o.KHR_DRACO_MESH_COMPRESSION:i[t]=new I(r,this.dracoLoader);break;case o.KHR_TEXTURE_TRANSFORM:i[t]=new b;break;case o.KHR_MESH_QUANTIZATION:i[t]=new C;break;default:s.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(i),u.setPlugins(a),u.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function i(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const o={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 a{constructor(e){this.parser=e,this.name=o.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const s=this.parser,n="light:"+e;let r=s.cache.get(n);if(r)return r;const i=s.json,o=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let a;const c=new t.Color(16777215);void 0!==o.color&&c.setRGB(o.color[0],o.color[1],o.color[2],t.LinearSRGBColorSpace);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new t.DirectionalLight(c),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new t.PointLight(c),a.distance=l;break;case"spot":a=new t.SpotLight(c),a.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),W(a,o),void 0!==o.intensity&&(a.intensity=o.intensity),a.name=s.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),s.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,n=s.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then(function(e){return s._getNodeRef(t.cache,r,e)})}}class c{constructor(){this.name=o.KHR_MATERIALS_UNLIT}getMaterialType(){return t.MeshBasicMaterial}extendParams(e,s,n){const r=[];e.color=new t.Color(1,1,1),e.opacity=1;const i=s.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const s=i.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],t.LinearSRGBColorSpace),e.opacity=s[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,t.SRGBColorSpace))}return Promise.all(r)}}class l{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class u{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,s){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(s.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&i.push(n.assignTexture(s,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(s.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&i.push(n.assignTexture(s,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(i.push(n.assignTexture(s,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;s.clearcoatNormalScale=new t.Vector2(e,e)}return Promise.all(i)}}class h{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class d{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&r.push(s.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&r.push(s.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class m{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,s){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];s.sheenColor=new t.Color(0,0,0),s.sheenRoughness=0,s.sheen=1;const o=r.extensions[this.name];if(void 0!==o.sheenColorFactor){const e=o.sheenColorFactor;s.sheenColor.setRGB(e[0],e[1],e[2],t.LinearSRGBColorSpace)}return void 0!==o.sheenRoughnessFactor&&(s.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&i.push(n.assignTexture(s,"sheenColorMap",o.sheenColorTexture,t.SRGBColorSpace)),void 0!==o.sheenRoughnessTexture&&i.push(n.assignTexture(s,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class p{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&r.push(s.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class f{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,s){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&i.push(n.assignTexture(s,"thicknessMap",o.thicknessTexture)),s.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return s.attenuationColor=(new t.Color).setRGB(a[0],a[1],a[2],t.LinearSRGBColorSpace),Promise.all(i)}}class g{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const n=s.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class T{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,s){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],o=r.extensions[this.name];s.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&i.push(n.assignTexture(s,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return s.specularColor=(new t.Color).setRGB(a[0],a[1],a[2],t.LinearSRGBColorSpace),void 0!==o.specularColorTexture&&i.push(n.assignTexture(s,"specularColorMap",o.specularColorTexture,t.SRGBColorSpace)),Promise.all(i)}}class x{constructor(e){this.parser=e,this.name=o.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&r.push(s.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(r)}}class R{constructor(e){this.parser=e,this.name=o.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return s.extensions&&s.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],i=n.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&r.push(s.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class v{constructor(e){this.parser=e,this.name=o.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const r=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){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 t.loadTextureImage(e,r.source,i)}}class _{constructor(e){this.parser=e,this.name=o.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return s.loadTextureImage(e,i.source,a)}}class M{constructor(e){this.parser=e,this.name=o.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=n.images[i.source];let a=s.textureLoader;if(o.uri){const e=s.options.manager.getHandler(o.uri);null!==e&&(a=e)}return s.loadTextureImage(e,i.source,a)}}class w{constructor(e){this.name=o.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(t){const s=e.byteOffset||0,n=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,s,n);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then(function(e){return e.buffer}):r.ready.then(function(){const t=new ArrayBuffer(i*o);return r.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t})})}return null}}class E{constructor(e){this.name=o.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const s=this.parser.json,n=s.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=s.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==H.TRIANGLES&&e.mode!==H.TRIANGLE_STRIP&&e.mode!==H.TRIANGLE_FAN&&void 0!==e.mode)return null;const i=n.extensions[this.name].attributes,o=[],a={};for(const e in i)o.push(this.parser.getDependency("accessor",i[e]).then(t=>(a[e]=t,a[e])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(e=>{const s=e.pop(),n=s.isGroup?s.children:[s],r=e[0].count,i=[];for(const e of n){const s=new t.Matrix4,n=new t.Vector3,o=new t.Quaternion,c=new t.Vector3(1,1,1),l=new t.InstancedMesh(e.geometry,e.material,r);for(let e=0;e<r;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&o.fromBufferAttribute(a.ROTATION,e),a.SCALE&&c.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,s.compose(n,o,c));for(const s in a)if("_COLOR_0"===s){const e=a[s];l.instanceColor=new t.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==s&&"ROTATION"!==s&&"SCALE"!==s&&e.geometry.setAttribute(s,a[s]);t.Object3D.prototype.copy.call(l,e),this.parser.assignFinalMaterial(l),i.push(l)}return s.isGroup?(s.clear(),s.add(...i),s):i[0]}))}}const A="glTF",y=1313821514,L=5130562;class S{constructor(e){this.name=o.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==A)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,r=new DataView(e,12);let i=0;for(;i<n;){const t=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===y){const n=new Uint8Array(e,12+i,t);this.content=s.decode(n)}else if(n===L){const s=12+i;this.body=e.slice(s,s+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class I{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=o.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,s){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(const e in o){const t=G[e]||e.toLowerCase();a[t]=o[e]}for(const t in e.attributes){const s=G[t]||t.toLowerCase();if(void 0!==o[t]){const r=n.accessors[e.attributes[t]],i=F[r.componentType];l[s]=i.name,c[s]=!0===r.normalized}}return s.getDependency("bufferView",i).then(function(e){return new Promise(function(s,n){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const s=e.attributes[t],n=c[t];void 0!==n&&(s.normalized=n)}s(e)},a,l,t.LinearSRGBColorSpace,n)})})}}class b{constructor(){this.name=o.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class C{constructor(){this.name=o.KHR_MESH_QUANTIZATION}}class N extends t.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let e=0;e!==n;e++)t[e]=s[r+e];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=n-t,u=(s-t)/l,h=u*u,d=h*u,m=e*c,p=m-c,f=-2*d+3*h,g=d-h,T=1-f,x=g-h+u;for(let e=0;e!==o;e++){const t=i[p+e+o],s=i[p+e+a]*l,n=i[m+e+o],c=i[m+e]*l;r[e]=T*t+x*s+f*n+g*c}return r}}const O=new t.Quaternion;class P extends N{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return O.fromArray(r).normalize().toArray(r),r}}const H={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},F={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},k={9728:t.NearestFilter,9729:t.LinearFilter,9984:t.NearestMipmapNearestFilter,9985:t.LinearMipmapNearestFilter,9986:t.NearestMipmapLinearFilter,9987:t.LinearMipmapLinearFilter},D={33071:t.ClampToEdgeWrapping,33648:t.MirroredRepeatWrapping,10497:t.RepeatWrapping},U={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},G={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},B={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},K={CUBICSPLINE:void 0,LINEAR:t.InterpolateLinear,STEP:t.InterpolateDiscrete},j="OPAQUE",V="MASK",X="BLEND";function z(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new t.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:t.FrontSide})),e.DefaultMaterial}function q(e,t,s){for(const n in s.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=s.extensions[n])}function W(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Y(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,n=t.weights.length;s<n;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,n=s.length;t<n;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Q(e){let t;const s=e.extensions&&e.extensions[o.KHR_DRACO_MESH_COMPRESSION];if(t=s?"draco:"+s.bufferView+":"+s.indices+":"+J(s.attributes):e.indices+":"+J(e.attributes)+":"+e.mode,void 0!==e.targets)for(let s=0,n=e.targets.length;s<n;s++)t+=":"+J(e.targets[s]);return t}function J(e){let t="";const s=Object.keys(e).sort();for(let n=0,r=s.length;n<r;n++)t+=s[n]+":"+e[s[n]]+";";return t}function Z(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const $=new t.Matrix4;class ee{constructor(e={},s={}){this.json=e,this.extensions={},this.plugins={},this.options=s,this.cache=new i,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,o=!1,a=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,o=e.indexOf("Firefox")>-1,a=o?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&r<17||o&&a<98?this.textureLoader=new t.TextureLoader(this.options.manager):this.textureLoader=new t.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new t.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(t){const i={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:s,userData:{}};return q(r,i,n),W(i,n),Promise.all(s._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let s=0,n=t.length;s<n;s++){const n=t[s].joints;for(let t=0,s=n.length;t<s;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(s[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),r=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[s,n]of e.children.entries())r(n,t.children[s])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const r=e(t[n]);r&&s.push(r)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e)}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map(function(t,n){return s.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const s=this.json.buffers[e],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===e)return Promise.resolve(this.extensions[o.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,i){n.load(t.LoaderUtils.resolveURL(s.uri,r.path),e,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+s.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+s)})}loadAccessor(e){const s=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=U[r.type],s=F[r.componentType],n=!0===r.normalized,i=new s(r.count*e);return Promise.resolve(new t.BufferAttribute(i,e,n))}const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then(function(e){const i=e[0],o=U[r.type],a=F[r.componentType],c=a.BYTES_PER_ELEMENT,l=c*o,u=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let m,p;if(h&&h!==l){const e=Math.floor(u/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=s.cache.get(n);l||(m=new a(i,e*h,r.count*h/c),l=new t.InterleavedBuffer(m,h/c),s.cache.add(n,l)),p=new t.InterleavedBufferAttribute(l,o,u%h/c,d)}else m=null===i?new a(r.count*o):new a(i,u,r.count*o),p=new t.BufferAttribute(m,o,d);if(void 0!==r.sparse){const s=U.SCALAR,n=F[r.sparse.indices.componentType],c=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(e[1],c,r.sparse.count*s),h=new a(e[2],l,r.sparse.count*o);null!==i&&(p=new t.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(p.setX(t,h[e*o]),o>=2&&p.setY(t,h[e*o+1]),o>=3&&p.setZ(t,h[e*o+2]),o>=4&&p.setW(t,h[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p})}loadTexture(e){const t=this.json,s=this.options,n=t.textures[e].source,r=t.images[n];let i=this.textureLoader;if(r.uri){const e=s.manager.getHandler(r.uri);null!==e&&(i=e)}return this.loadTextureImage(e,n,i)}loadTextureImage(e,s,n){const r=this,i=this.json,o=i.textures[e],a=i.images[s],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];const l=this.loadImageSource(s,n).then(function(s){s.flipY=!1,s.name=o.name||a.name||"",""===s.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(s.name=a.uri);const n=(i.samplers||{})[o.sampler]||{};return s.magFilter=k[n.magFilter]||t.LinearFilter,s.minFilter=k[n.minFilter]||t.LinearMipmapLinearFilter,s.wrapS=D[n.wrapS]||t.RepeatWrapping,s.wrapT=D[n.wrapT]||t.RepeatWrapping,s.generateMipmaps=!s.isCompressedTexture&&s.minFilter!==t.NearestFilter&&s.minFilter!==t.LinearFilter,r.associations.set(s,{textures:e}),s}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,s){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const o=r.images[e],a=self.URL||self.webkitURL;let c=o.uri||"",l=!1;if(void 0!==o.bufferView)c=n.getDependency("bufferView",o.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return c=a.createObjectURL(t),c});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(c).then(function(e){return new Promise(function(n,r){let o=n;!0===s.isImageBitmapLoader&&(o=function(e){const s=new t.Texture(e);s.needsUpdate=!0,n(s)}),s.load(t.LoaderUtils.resolveURL(e,i.path),o,void 0,r)})}).then(function(e){var t;return!0===l&&a.revokeObjectURL(c),W(e,o),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),e});return this.sourceCache[e]=u,u}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((i=i.clone()).channel=s.texCoord),r.extensions[o.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[o.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(i);i=r.extensions[o.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),r.associations.set(i,t)}}return void 0!==n&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const s=e.geometry;let n=e.material;const r=void 0===s.attributes.tangent,i=void 0!==s.attributes.color,o=void 0===s.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let s=this.cache.get(e);s||(s=new t.PointsMaterial,t.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,s.sizeAttenuation=!1,this.cache.add(e,s)),n=s}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let s=this.cache.get(e);s||(s=new t.LineBasicMaterial,t.Material.prototype.copy.call(s,n),s.color.copy(n.color),s.map=n.map,this.cache.add(e,s)),n=s}if(r||i||o){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return t.MeshStandardMaterial}loadMaterial(e){const s=this,n=this.json,r=this.extensions,i=n.materials[e];let a;const c={},l=[];if((i.extensions||{})[o.KHR_MATERIALS_UNLIT]){const e=r[o.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),l.push(e.extendParams(c,i,s))}else{const n=i.pbrMetallicRoughness||{};if(c.color=new t.Color(1,1,1),c.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;c.color.setRGB(e[0],e[1],e[2],t.LinearSRGBColorSpace),c.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(s.assignTexture(c,"map",n.baseColorTexture,t.SRGBColorSpace)),c.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,c.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(s.assignTexture(c,"metalnessMap",n.metallicRoughnessTexture)),l.push(s.assignTexture(c,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,c)})))}!0===i.doubleSided&&(c.side=t.DoubleSide);const u=i.alphaMode||j;if(u===X?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,u===V&&(c.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&a!==t.MeshBasicMaterial&&(l.push(s.assignTexture(c,"normalMap",i.normalTexture)),c.normalScale=new t.Vector2(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;c.normalScale.set(e,e)}if(void 0!==i.occlusionTexture&&a!==t.MeshBasicMaterial&&(l.push(s.assignTexture(c,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(c.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&a!==t.MeshBasicMaterial){const e=i.emissiveFactor;c.emissive=(new t.Color).setRGB(e[0],e[1],e[2],t.LinearSRGBColorSpace)}return void 0!==i.emissiveTexture&&a!==t.MeshBasicMaterial&&l.push(s.assignTexture(c,"emissiveMap",i.emissiveTexture,t.SRGBColorSpace)),Promise.all(l).then(function(){const t=new a(c);return i.name&&(t.name=i.name),W(t,i),s.associations.set(t,{materials:e}),i.extensions&&q(r,t,i),t})}createUniqueName(e){const s=t.PropertyBinding.sanitizeNodeName(e||"");return s in this.nodeNamesUsed?s+"_"+ ++this.nodeNamesUsed[s]:(this.nodeNamesUsed[s]=0,s)}loadGeometries(e){const s=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[o.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,s).then(function(t){return te(t,e,s)})}const a=[];for(let n=0,c=e.length;n<c;n++){const c=e[n],l=Q(c),u=r[l];if(u)a.push(u.promise);else{let e;e=c.extensions&&c.extensions[o.KHR_DRACO_MESH_COMPRESSION]?i(c):te(new t.BufferGeometry,c,s),r[l]={primitive:c,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){const s=this,r=this.json,i=this.extensions,o=r.meshes[e],a=o.primitives,c=[];for(let e=0,t=a.length;e<t;e++){const t=void 0===a[e].material?z(this.cache):this.getDependency("material",a[e].material);c.push(t)}return c.push(s.loadGeometries(a)),Promise.all(c).then(function(r){const c=r.slice(0,r.length-1),l=r[r.length-1],u=[];for(let r=0,h=l.length;r<h;r++){const h=l[r],d=a[r];let m;const p=c[r];if(d.mode===H.TRIANGLES||d.mode===H.TRIANGLE_STRIP||d.mode===H.TRIANGLE_FAN||void 0===d.mode)m=!0===o.isSkinnedMesh?new t.SkinnedMesh(h,p):new t.Mesh(h,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),d.mode===H.TRIANGLE_STRIP?m.geometry=n(m.geometry,t.TriangleStripDrawMode):d.mode===H.TRIANGLE_FAN&&(m.geometry=n(m.geometry,t.TriangleFanDrawMode));else if(d.mode===H.LINES)m=new t.LineSegments(h,p);else if(d.mode===H.LINE_STRIP)m=new t.Line(h,p);else if(d.mode===H.LINE_LOOP)m=new t.LineLoop(h,p);else{if(d.mode!==H.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);m=new t.Points(h,p)}Object.keys(m.geometry.morphAttributes).length>0&&Y(m,o),m.name=s.createUniqueName(o.name||"mesh_"+e),W(m,o),d.extensions&&q(i,m,d),s.assignFinalMaterial(m),u.push(m)}for(let t=0,n=u.length;t<n;t++)s.associations.set(u[t],{meshes:e,primitives:t});if(1===u.length)return o.extensions&&q(i,u[0],o),u[0];const h=new t.Group;o.extensions&&q(i,h,o),s.associations.set(h,{meshes:e});for(let e=0,t=u.length;e<t;e++)h.add(u[e]);return h})}loadCamera(e){let s;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?s=new t.PerspectiveCamera(t.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(s=new t.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(s.name=this.createUniqueName(n.name)),W(s,n),Promise.resolve(s);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const s=this.json.skins[e],n=[];for(let e=0,t=s.joints.length;e<t;e++)n.push(this._loadNodeShallow(s.joints[e]));return void 0!==s.inverseBindMatrices?n.push(this.getDependency("accessor",s.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(e){const n=e.pop(),r=e,i=[],o=[];for(let e=0,a=r.length;e<a;e++){const a=r[e];if(a){i.push(a);const s=new t.Matrix4;null!==n&&s.fromArray(n.array,16*e),o.push(s)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',s.joints[e])}return new t.Skeleton(i,o)})}loadAnimation(e){const s=this.json,n=this,r=s.animations[e],i=r.name?r.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],s=r.samplers[t.sampler],n=t.target,i=n.node,h=void 0!==r.parameters?r.parameters[s.input]:s.input,d=void 0!==r.parameters?r.parameters[s.output]:s.output;void 0!==n.node&&(o.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),c.push(this.getDependency("accessor",d)),l.push(s),u.push(n))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(e){const s=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=[];for(let e=0,t=s.length;e<t;e++){const t=s[e],r=o[e],i=a[e],h=c[e],d=l[e];if(void 0===t)continue;t.updateMatrix&&t.updateMatrix();const m=n._createAnimationTracks(t,r,i,h,d);if(m)for(let e=0;e<m.length;e++)u.push(m[e])}const h=new t.AnimationClip(i,void 0,u);return W(h,r),h})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return void 0===n.mesh?null:s.getDependency("mesh",n.mesh).then(function(e){const t=s._getNodeRef(s.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,s=n.weights.length;t<s;t++)e.morphTargetInfluences[t]=n.weights[t]}),t})}loadNode(e){const t=this,s=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],i=s.children||[];for(let e=0,s=i.length;e<s;e++)r.push(t.getDependency("node",i[e]));const o=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([n,Promise.all(r),o]).then(function(e){const t=e[0],s=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,$)});for(let e=0,n=s.length;e<n;e++)t.add(s[e]);return t})}_loadNodeShallow(e){const s=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const i=s.nodes[e],o=i.name?r.createUniqueName(i.name):"",a=[],c=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&a.push(c),void 0!==i.camera&&a.push(r.getDependency("camera",i.camera).then(function(e){return r._getNodeRef(r.cameraCache,i.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){a.push(e)}),this.nodeCache[e]=Promise.all(a).then(function(s){let a;if(a=!0===i.isBone?new t.Bone:s.length>1?new t.Group:1===s.length?s[0]:new t.Object3D,a!==s[0])for(let e=0,t=s.length;e<t;e++)a.add(s[e]);if(i.name&&(a.userData.name=i.name,a.name=o),W(a,i),i.extensions&&q(n,a,i),void 0!==i.matrix){const e=new t.Matrix4;e.fromArray(i.matrix),a.applyMatrix4(e)}else void 0!==i.translation&&a.position.fromArray(i.translation),void 0!==i.rotation&&a.quaternion.fromArray(i.rotation),void 0!==i.scale&&a.scale.fromArray(i.scale);if(r.associations.has(a)){if(void 0!==i.mesh&&r.meshCache.refs[i.mesh]>1){const e=r.associations.get(a);r.associations.set(a,{...e})}}else r.associations.set(a,{});return r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const s=this.extensions,n=this.json.scenes[e],r=this,i=new t.Group;n.name&&(i.name=r.createUniqueName(n.name)),W(i,n),n.extensions&&q(s,i,n);const o=n.nodes||[],a=[];for(let e=0,t=o.length;e<t;e++)a.push(r.getDependency("node",o[e]));return Promise.all(a).then(function(e){for(let t=0,s=e.length;t<s;t++)i.add(e[t]);return r.associations=(e=>{const s=new Map;for(const[e,n]of r.associations)(e instanceof t.Material||e instanceof t.Texture)&&s.set(e,n);return e.traverse(e=>{const t=r.associations.get(e);null!=t&&s.set(e,t)}),s})(i),i})}_createAnimationTracks(e,s,n,r,i){const o=[],a=e.name?e.name:e.uuid,c=[];let l;switch(B[i.path]===B.weights?e.traverse(function(e){e.morphTargetInfluences&&c.push(e.name?e.name:e.uuid)}):c.push(a),B[i.path]){case B.weights:l=t.NumberKeyframeTrack;break;case B.rotation:l=t.QuaternionKeyframeTrack;break;case B.translation:case B.scale:l=t.VectorKeyframeTrack;break;default:if(1===n.itemSize)l=t.NumberKeyframeTrack;else l=t.VectorKeyframeTrack}const u=void 0!==r.interpolation?K[r.interpolation]:t.InterpolateLinear,h=this._getArrayFromAccessor(n);for(let e=0,t=c.length;e<t;e++){const t=new l(c[e]+"."+B[i.path],s.array,h,u);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(t),o.push(t)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=Z(t.constructor),s=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)s[n]=t[n]*e;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof t.QuaternionKeyframeTrack?P:N)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function te(e,s,n){const r=s.attributes,i=[];function o(t,s){return n.getDependency("accessor",t).then(function(t){e.setAttribute(s,t)})}for(const t in r){const s=G[t]||t.toLowerCase();s in e.attributes||i.push(o(r[t],s))}if(void 0!==s.indices&&!e.index){const t=n.getDependency("accessor",s.indices).then(function(t){e.setIndex(t)});i.push(t)}return t.ColorManagement.workingColorSpace!==t.LinearSRGBColorSpace&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${t.ColorManagement.workingColorSpace}" not supported.`),W(e,s),function(e,s,n){const r=s.attributes,i=new t.Box3;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],s=e.min,o=e.max;if(void 0===s||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new t.Vector3(s[0],s[1],s[2]),new t.Vector3(o[0],o[1],o[2])),e.normalized){const t=Z(F[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const o=s.targets;if(void 0!==o){const e=new t.Vector3,s=new t.Vector3;for(let t=0,r=o.length;t<r;t++){const r=o[t];if(void 0!==r.POSITION){const t=n.json.accessors[r.POSITION],i=t.min,o=t.max;if(void 0!==i&&void 0!==o){if(s.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),s.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),s.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),t.normalized){const e=Z(F[t.componentType]);s.multiplyScalar(e)}e.max(s)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const a=new t.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=a}(e,s,n),Promise.all(i).then(function(){return void 0!==s.targets?function(e,t,s){let n=!1,r=!1,i=!1;for(let e=0,s=t.length;e<s;e++){const s=t[e];if(void 0!==s.POSITION&&(n=!0),void 0!==s.NORMAL&&(r=!0),void 0!==s.COLOR_0&&(i=!0),n&&r&&i)break}if(!n&&!r&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(n){const t=void 0!==u.POSITION?s.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(r){const t=void 0!==u.NORMAL?s.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?s.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(t){const s=t[0],o=t[1],a=t[2];return n&&(e.morphAttributes.position=s),r&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,s.targets,n):e})}class se extends s.Loader{constructor(e){super(),this.viewer=e}dispose(){this.manager&&this.manager.dispose()}isSupport(e,t){return("string"==typeof e||e instanceof globalThis.File||e instanceof ArrayBuffer)&&/(gltf|glb)$/i.test(t)}async load(e,t,n={}){this.manager=new s.GLTFLoadingManager(e,n);const i=new r(this.manager);i.setPath(this.manager.path),i.setCrossOrigin(n.crossOrigin||i.crossOrigin),i.setRequestHeader(n.requestHeader||{}),i.setWithCredentials(n.withCredentials||i.withCredentials);const o=await i.loadAsync(this.manager.fileURL,t=>{const{lengthComputable:s,loaded:n,total:r}=t,i=s?n/r:1;this.viewer.emitEvent({type:"geometryprogress",data:i,file:e})});if(!this.viewer.scene)return this;let a=0;o.scene.traverse(e=>{e.userData={handle:a+"",...e.userData},a++});const c=new s.ModelImpl(o.scene);return c.id=n.modelId||this.extractFileName(e),this.viewer.scene.add(o.scene),this.viewer.models.push(c),this.viewer.syncOptions(),this.viewer.syncOverlay(),this.viewer.update(),this.viewer.emitEvent({type:"databasechunk",data:o.scene,file:e}),this}}s.loaders.registerLoader("gltf-file",e=>new se(e)),e.GLTFFileLoader=se});
@@ -0,0 +1,74 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
3
+ // All rights reserved.
4
+ //
5
+ // This software and its documentation and related materials are owned by
6
+ // the Alliance. The software may only be incorporated into application
7
+ // programs owned by members of the Alliance, subject to a signed
8
+ // Membership Agreement and Supplemental Software License Agreement with the
9
+ // Alliance. The structure and organization of this software are the valuable
10
+ // trade secrets of the Alliance and its suppliers. The software is also
11
+ // protected by copyright law and international treaty provisions. Application
12
+ // programs incorporating this software must include the following statement
13
+ // with their copyright notices:
14
+ //
15
+ // This application incorporates Open Design Alliance software pursuant to a
16
+ // license agreement with Open Design Alliance.
17
+ // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
25
+ import { loaders, Loader, GLTFLoadingManager, ModelImpl } from '@inweb/viewer-three';
26
+
27
+ class GLTFFileLoader extends Loader {
28
+ constructor(viewer) {
29
+ super();
30
+ this.viewer = viewer;
31
+ }
32
+ dispose() {
33
+ if (this.manager)
34
+ this.manager.dispose();
35
+ }
36
+ isSupport(file, format) {
37
+ return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
38
+ /(gltf|glb)$/i.test(format));
39
+ }
40
+ async load(file, format, params = {}) {
41
+ this.manager = new GLTFLoadingManager(file, params);
42
+ const loader = new GLTFLoader(this.manager);
43
+ loader.setPath(this.manager.path);
44
+ loader.setCrossOrigin(params.crossOrigin || loader.crossOrigin);
45
+ loader.setRequestHeader(params.requestHeader || {});
46
+ loader.setWithCredentials(params.withCredentials || loader.withCredentials);
47
+ const progress = (event) => {
48
+ const { lengthComputable, loaded, total } = event;
49
+ const progress = lengthComputable ? loaded / total : 1;
50
+ this.viewer.emitEvent({ type: "geometryprogress", data: progress, file });
51
+ };
52
+ const gltf = await loader.loadAsync(this.manager.fileURL, progress);
53
+ if (!this.viewer.scene)
54
+ return this;
55
+ let handle = 0;
56
+ gltf.scene.traverse((object) => {
57
+ object.userData = { handle: handle + "", ...object.userData };
58
+ handle++;
59
+ });
60
+ const modelImpl = new ModelImpl(gltf.scene);
61
+ modelImpl.id = params.modelId || this.extractFileName(file);
62
+ this.viewer.scene.add(gltf.scene);
63
+ this.viewer.models.push(modelImpl);
64
+ this.viewer.syncOptions();
65
+ this.viewer.syncOverlay();
66
+ this.viewer.update();
67
+ this.viewer.emitEvent({ type: "databasechunk", data: gltf.scene, file });
68
+ return this;
69
+ }
70
+ }
71
+ loaders.registerLoader("gltf-file", (viewer) => new GLTFFileLoader(viewer));
72
+
73
+ export { GLTFFileLoader };
74
+ //# sourceMappingURL=GLTFFileLoader.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GLTFFileLoader.module.js","sources":["../../../plugins/loaders/GLTFFileLoader.ts"],"sourcesContent":["///////////////////////////////////////////////////////////////////////////////\n// Copyright (C) 2002-2025, Open Design Alliance (the \"Alliance\").\n// All rights reserved.\n//\n// This software and its documentation and related materials are owned by\n// the Alliance. The software may only be incorporated into application\n// programs owned by members of the Alliance, subject to a signed\n// Membership Agreement and Supplemental Software License Agreement with the\n// Alliance. The structure and organization of this software are the valuable\n// trade secrets of the Alliance and its suppliers. The software is also\n// protected by copyright law and international treaty provisions. Application\n// programs incorporating this software must include the following statement\n// with their copyright notices:\n//\n// This application incorporates Open Design Alliance software pursuant to a\n// license agreement with Open Design Alliance.\n// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.\n// All rights reserved.\n//\n// By use of this software, its documentation or related materials, you\n// acknowledge and accept the above terms.\n///////////////////////////////////////////////////////////////////////////////\n\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { GLTFLoadingManager, GLTFLoadParams, Loader, loaders, ModelImpl, Viewer } from \"@inweb/viewer-three\";\n\nexport class GLTFFileLoader extends Loader {\n public viewer: Viewer;\n private manager: GLTFLoadingManager;\n\n constructor(viewer: Viewer) {\n super();\n this.viewer = viewer;\n }\n\n override dispose() {\n if (this.manager) this.manager.dispose();\n }\n\n override isSupport(file: any, format?: string): boolean {\n return (\n (typeof file === \"string\" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&\n /(gltf|glb)$/i.test(format)\n );\n }\n\n override async load(file: any, format?: string, params: GLTFLoadParams = {}): Promise<this> {\n this.manager = new GLTFLoadingManager(file, params);\n\n const loader = new GLTFLoader(this.manager);\n loader.setPath(this.manager.path);\n loader.setCrossOrigin(params.crossOrigin || loader.crossOrigin);\n loader.setRequestHeader((params.requestHeader as any) || {});\n loader.setWithCredentials(params.withCredentials || loader.withCredentials);\n\n const progress = (event: ProgressEvent) => {\n const { lengthComputable, loaded, total } = event;\n const progress = lengthComputable ? loaded / total : 1;\n this.viewer.emitEvent({ type: \"geometryprogress\", data: progress, file });\n };\n\n const gltf = await loader.loadAsync(this.manager.fileURL, progress);\n if (!this.viewer.scene) return this;\n\n let handle = 0;\n gltf.scene.traverse((object) => {\n object.userData = { handle: handle + \"\", ...object.userData };\n handle++;\n });\n\n const modelImpl = new ModelImpl(gltf.scene);\n modelImpl.id = params.modelId || this.extractFileName(file);\n\n this.viewer.scene.add(gltf.scene);\n this.viewer.models.push(modelImpl);\n\n this.viewer.syncOptions();\n this.viewer.syncOverlay();\n this.viewer.update();\n\n this.viewer.emitEvent({ type: \"databasechunk\", data: gltf.scene, file });\n\n return this;\n }\n}\n\nloaders.registerLoader(\"gltf-file\", (viewer: any) => new GLTFFileLoader(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BM,MAAO,cAAe,SAAQ,MAAM,CAAA;AAIxC,IAAA,WAAA,CAAY,MAAc,EAAA;AACxB,QAAA,KAAK,EAAE;AACP,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;IAES,OAAO,GAAA;QACd,IAAI,IAAI,CAAC,OAAO;AAAE,YAAA,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;IAC1C;IAES,SAAS,CAAC,IAAS,EAAE,MAAe,EAAA;AAC3C,QAAA,QACE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,YAAY,UAAU,CAAC,IAAI,IAAI,IAAI,YAAY,WAAW;AAC3F,YAAA,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;IAE/B;IAES,MAAM,IAAI,CAAC,IAAS,EAAE,MAAe,EAAE,SAAyB,EAAE,EAAA;QACzE,IAAI,CAAC,OAAO,GAAG,IAAI,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC;QAEnD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;QAC3C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;QACjC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,WAAW,CAAC;QAC/D,MAAM,CAAC,gBAAgB,CAAE,MAAM,CAAC,aAAqB,IAAI,EAAE,CAAC;QAC5D,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC;AAE3E,QAAA,MAAM,QAAQ,GAAG,CAAC,KAAoB,KAAI;YACxC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK;AACjD,YAAA,MAAM,QAAQ,GAAG,gBAAgB,GAAG,MAAM,GAAG,KAAK,GAAG,CAAC;AACtD,YAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC3E,QAAA,CAAC;AAED,QAAA,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;AACnE,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK;AAAE,YAAA,OAAO,IAAI;QAEnC,IAAI,MAAM,GAAG,CAAC;QACd,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAI;AAC7B,YAAA,MAAM,CAAC,QAAQ,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE;AAC7D,YAAA,MAAM,EAAE;AACV,QAAA,CAAC,CAAC;QAEF,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;AAC3C,QAAA,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;QAE3D,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;AAElC,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;AACzB,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;AACzB,QAAA,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;AAEpB,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;AAExE,QAAA,OAAO,IAAI;IACb;AACD;AAED,OAAO,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,MAAW,KAAK,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;;;;"}
@@ -1250,7 +1250,7 @@
1250
1250
  return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
1251
1251
  /(ifcx)$/i.test(format));
1252
1252
  }
1253
- async load(file, format, params) {
1253
+ async load(file, format, params = {}) {
1254
1254
  const manager = new viewerThree.GLTFLoadingManager(file, params);
1255
1255
  const loader = new IFCXLoader(manager);
1256
1256
  loader.setPath(manager.path);
@@ -1266,12 +1266,11 @@
1266
1266
  return this;
1267
1267
  let handle = 0;
1268
1268
  scene.traverse((object) => {
1269
- object.userData = { handle, ...object.userData };
1269
+ object.userData = { handle: handle + "", ...object.userData };
1270
1270
  handle++;
1271
1271
  });
1272
1272
  const modelImpl = new viewerThree.ModelImpl(scene);
1273
- modelImpl.loader = this;
1274
- modelImpl.viewer = this.viewer;
1273
+ modelImpl.id = params.modelId || this.extractFileName(file);
1275
1274
  this.viewer.scene.add(scene);
1276
1275
  this.viewer.models.push(modelImpl);
1277
1276
  this.viewer.syncOptions();
@@ -1306,12 +1305,11 @@
1306
1305
  clear();
1307
1306
  let handle = 0;
1308
1307
  scene.traverse((object) => {
1309
- object.userData = { handle, ...object.userData };
1308
+ object.userData = { handle: handle + "", ...object.userData };
1310
1309
  handle++;
1311
1310
  });
1312
1311
  const modelImpl = new viewerThree.ModelImpl(scene);
1313
- modelImpl.loader = this;
1314
- modelImpl.viewer = this.viewer;
1312
+ modelImpl.id = file.id;
1315
1313
  this.viewer.scene.add(scene);
1316
1314
  this.viewer.models.push(modelImpl);
1317
1315
  this.viewer.syncOptions();