@inweb/viewer-three 26.12.7 → 27.1.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 (53) hide show
  1. package/dist/extensions/components/InfoPanelComponent.js +7 -9
  2. package/dist/extensions/components/InfoPanelComponent.js.map +1 -1
  3. package/dist/extensions/components/InfoPanelComponent.min.js +1 -1
  4. package/dist/extensions/components/InfoPanelComponent.module.js +7 -9
  5. package/dist/extensions/components/InfoPanelComponent.module.js.map +1 -1
  6. package/dist/extensions/loaders/GLTFCloudLoader.js +1 -1
  7. package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
  8. package/dist/extensions/loaders/GLTFCloudLoader.min.js +1 -1
  9. package/dist/extensions/loaders/GLTFCloudLoader.module.js +1 -1
  10. package/dist/extensions/loaders/GLTFCloudLoader.module.js.map +1 -1
  11. package/dist/extensions/loaders/GLTFFileLoader.js +1 -1
  12. package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
  13. package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
  14. package/dist/extensions/loaders/GLTFFileLoader.module.js +1 -1
  15. package/dist/extensions/loaders/GLTFFileLoader.module.js.map +1 -1
  16. package/dist/extensions/loaders/IFCXLoader.js +2 -2
  17. package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
  18. package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
  19. package/dist/extensions/loaders/IFCXLoader.module.js +2 -2
  20. package/dist/extensions/loaders/IFCXLoader.module.js.map +1 -1
  21. package/dist/extensions/loaders/PotreeLoader.js +1 -1
  22. package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
  23. package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
  24. package/dist/extensions/loaders/PotreeLoader.module.js +1 -1
  25. package/dist/extensions/loaders/PotreeLoader.module.js.map +1 -1
  26. package/dist/viewer-three.js +40 -37
  27. package/dist/viewer-three.js.map +1 -1
  28. package/dist/viewer-three.min.js +3 -3
  29. package/dist/viewer-three.module.js +40 -37
  30. package/dist/viewer-three.module.js.map +1 -1
  31. package/extensions/components/InfoPanelComponent.ts +8 -11
  32. package/extensions/loaders/GLTFCloudLoader.ts +1 -1
  33. package/extensions/loaders/GLTFFileLoader.ts +1 -1
  34. package/extensions/loaders/IFCX/IFCXCloudLoader.ts +1 -1
  35. package/extensions/loaders/IFCX/IFCXFileLoader.ts +1 -1
  36. package/extensions/loaders/Potree/PotreeFileLoader.ts +1 -1
  37. package/lib/Viewer/Viewer.d.ts +1 -0
  38. package/lib/Viewer/commands/CreatePreview.d.ts +1 -1
  39. package/lib/Viewer/components/RenderLoopComponent.d.ts +1 -1
  40. package/lib/Viewer/draggers/FlyDragger.d.ts +1 -0
  41. package/lib/Viewer/draggers/WalkDragger.d.ts +1 -0
  42. package/lib/Viewer/loaders/index.d.ts +2 -1
  43. package/package.json +5 -5
  44. package/src/Viewer/Viewer.ts +34 -25
  45. package/src/Viewer/commands/CreatePreview.ts +2 -2
  46. package/src/Viewer/components/InfoComponent.ts +4 -4
  47. package/src/Viewer/components/RenderLoopComponent.ts +2 -2
  48. package/src/Viewer/draggers/FlyDragger.ts +8 -1
  49. package/src/Viewer/draggers/WalkDragger.ts +8 -1
  50. package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +2 -12
  51. package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +2 -2
  52. package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +2 -2
  53. package/src/Viewer/loaders/index.ts +2 -1
@@ -131,8 +131,8 @@ class PotreeFileLoader extends Loader {
131
131
  this.viewer.models.push(modelImpl);
132
132
  this.viewer.syncOptions();
133
133
  this.viewer.syncOverlay();
134
- this.viewer.update();
135
134
  this.viewer.emitEvent({ type: "databasechunk", data: pco, file });
135
+ this.viewer.update(true);
136
136
  return this;
137
137
  }
138
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PotreeLoader.module.js","sources":["../../../extensions/loaders/Potree/PotreeModelImpl.ts","../../../extensions/loaders/Potree/PotreeFileLoader.ts","../../../extensions/loaders/Potree/index.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 { Box3 } from \"three\";\nimport { PointCloudOctree } from \"potree-core\";\nimport { IInfo, Info } from \"@inweb/viewer-core\";\nimport { ModelImpl } from \"@inweb/viewer-three\";\n\n// Potree model implementation.\n\nexport class PotreeModelImpl extends ModelImpl {\n public pco: PointCloudOctree;\n\n override getInfo(): IInfo {\n // ===================== AI-CODE-START ======================\n // Source: Claude Sonnet 4.5\n // Date: 2025-10-02\n // Reviewer: roman.mochalov@opendesign.com\n // Issue: CLOUD-5738\n\n let totalPoints = 0;\n let totalNodes = 0;\n let loadedGeometryBytes = 0;\n let estimatedTotalGeometryBytes = 0;\n let geometryBytes = 0;\n\n const bytesPerPoint = this.pco.pcoGeometry?.pointAttributes?.byteSize || 0;\n\n if (this.pco.pcoGeometry && this.pco.pcoGeometry.root) {\n this.pco.pcoGeometry.root.traverse((node: any) => {\n totalNodes++;\n\n const numPoints = node.numPoints || 0;\n totalPoints += numPoints;\n\n if (node.loaded && node.geometry) {\n if (node.geometry.attributes) {\n for (const name in node.geometry.attributes) {\n const attribute = node.geometry.attributes[name];\n if (attribute && attribute.array) {\n loadedGeometryBytes += attribute.array.byteLength;\n }\n }\n }\n\n if (node.geometry.index && node.geometry.index.array) {\n loadedGeometryBytes += node.geometry.index.array.byteLength;\n }\n }\n\n if (bytesPerPoint > 0 && numPoints > 0) {\n estimatedTotalGeometryBytes += numPoints * (bytesPerPoint * 2 - 1);\n }\n }, true);\n }\n\n geometryBytes = Math.max(loadedGeometryBytes, estimatedTotalGeometryBytes);\n\n // ===================== AI-CODE-END ======================\n\n const info = new Info();\n\n info.scene.objects = totalNodes;\n info.scene.points = totalPoints;\n info.scene.triangles = 0;\n info.scene.lines = 0;\n info.scene.edges = 0;\n\n info.memory.geometries = totalNodes;\n info.memory.geometryBytes = Math.floor(geometryBytes);\n info.memory.textures = 0;\n info.memory.textureBytes = 0;\n info.memory.materials = 1;\n info.memory.totalEstimatedGpuBytes = Math.floor(geometryBytes);\n\n info.optimizedScene.objects = info.scene.objects;\n info.optimizedScene.triangles = info.scene.triangles;\n info.optimizedScene.points = info.scene.points;\n info.optimizedScene.lines = info.scene.lines;\n info.optimizedScene.edges = info.scene.edges;\n\n return info;\n }\n\n override getExtents(target: Box3): Box3 {\n return target.union(this.pco.pcoGeometry.boundingBox);\n }\n}\n","///////////////////////////////////////////////////////////////////////////////\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 { Euler, Vector3 } from \"three\";\nimport { PointColorType, PointCloudOctree, PointSizeType, PointShape, Potree } from \"potree-core\";\nimport { Loader, LoadParams, Viewer } from \"@inweb/viewer-three\";\n\nimport { PotreeModelImpl } from \"./PotreeModelImpl\";\n\nexport type PotreeLoadParams = LoadParams & {\n path?: string;\n position?: Vector3;\n rotation?: Euler;\n scale?: Vector3;\n};\n\nexport class PotreeFileLoader extends Loader {\n public viewer: Viewer;\n public potree: Potree;\n public pointClouds: PointCloudOctree[];\n\n constructor(viewer: Viewer) {\n super();\n this.viewer = viewer;\n\n this.potree = new Potree();\n this.pointClouds = [];\n\n this.viewer.addEventListener(\"render\", this.updatePointClouds);\n this.viewer.addEventListener(\"changecamera\", this.updatePointClouds);\n }\n\n override dispose() {\n this.pointClouds.forEach((pco) => pco.dispose());\n\n this.viewer.removeEventListener(\"render\", this.updatePointClouds);\n this.viewer.removeEventListener(\"changecamera\", this.updatePointClouds);\n }\n\n override isSupport(file: any, format?: string): boolean {\n return typeof file === \"string\" && /(cloud.js|metadata.json)$/i.test(file);\n }\n\n override async load(file: any, format?: string, params: PotreeLoadParams = {}): Promise<this> {\n const path = (params.path || \"\") + file;\n const index = path.lastIndexOf(\"/\");\n const baseUrl = path.slice(0, index + 1);\n const url = path.slice(index + 1);\n\n const pco = await this.potree.loadPointCloud(url, baseUrl);\n pco.material.size = 1.0;\n pco.material.shape = 2;\n pco.material.inputColorEncoding = 1;\n pco.material.outputColorEncoding = 1;\n pco.material.pointColorType = PointColorType.RGB; // RGB | DEPTH | HEIGHT | POINT_INDEX | LOD | CLASSIFICATION\n pco.material.pointSizeType = PointSizeType.ADAPTIVE; // ADAPTIVE | FIXED\n pco.material.shape = PointShape.CIRCLE; // CIRCLE | SQUARE\n\n if (params.position) pco.position.copy(params.position);\n if (params.rotation) pco.rotation.copy(params.rotation);\n if (params.scale) pco.scale.copy(params.scale);\n\n this.pointClouds.push(pco);\n\n const modelImpl = new PotreeModelImpl(pco);\n modelImpl.id = params.modelId || this.extractFileName(file);\n modelImpl.pco = pco;\n\n this.viewer.scene.add(pco);\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: pco, file });\n\n return this;\n }\n\n updatePointClouds = () => {\n const result = this.potree.updatePointClouds(this.pointClouds, this.viewer.camera, this.viewer.renderer);\n if (result.exceededMaxLoadsToGPU || result.nodeLoadPromises.length > 0) this.viewer.update();\n };\n}\n","///////////////////////////////////////////////////////////////////////////////\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 { loaders } from \"@inweb/viewer-three\";\n\nimport { PotreeFileLoader } from \"./PotreeFileLoader\";\n\nloaders.registerLoader(\"potree-file\", (viewer: any) => new PotreeFileLoader(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BM,MAAO,eAAgB,SAAQ,SAAS,CAAA;IAGnC,OAAO,GAAA;;QAOd,IAAI,WAAW,GAAG,CAAC;QACnB,IAAI,UAAU,GAAG,CAAC;QAClB,IAAI,mBAAmB,GAAG,CAAC;QAC3B,IAAI,2BAA2B,GAAG,CAAC;QACnC,IAAI,aAAa,GAAG,CAAC;AAErB,QAAA,MAAM,aAAa,GAAG,CAAA,CAAA,EAAA,GAAA,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,CAAC,GAAG,CAAC;AAE1B,QAAA,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC;AAC1C,QAAA,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;AAC3D,QAAA,SAAS,CAAC,GAAG,GAAG,GAAG;QAEnB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;QAC1B,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,GAAG,EAAE,IAAI,EAAE,CAAC;AAEjE,QAAA,OAAO,IAAI;IACb;AAMD;;AC7ED,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,MAAW,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"PotreeLoader.module.js","sources":["../../../extensions/loaders/Potree/PotreeModelImpl.ts","../../../extensions/loaders/Potree/PotreeFileLoader.ts","../../../extensions/loaders/Potree/index.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 { Box3 } from \"three\";\nimport { PointCloudOctree } from \"potree-core\";\nimport { IInfo, Info } from \"@inweb/viewer-core\";\nimport { ModelImpl } from \"@inweb/viewer-three\";\n\n// Potree model implementation.\n\nexport class PotreeModelImpl extends ModelImpl {\n public pco: PointCloudOctree;\n\n override getInfo(): IInfo {\n // ===================== AI-CODE-START ======================\n // Source: Claude Sonnet 4.5\n // Date: 2025-10-02\n // Reviewer: roman.mochalov@opendesign.com\n // Issue: CLOUD-5738\n\n let totalPoints = 0;\n let totalNodes = 0;\n let loadedGeometryBytes = 0;\n let estimatedTotalGeometryBytes = 0;\n let geometryBytes = 0;\n\n const bytesPerPoint = this.pco.pcoGeometry?.pointAttributes?.byteSize || 0;\n\n if (this.pco.pcoGeometry && this.pco.pcoGeometry.root) {\n this.pco.pcoGeometry.root.traverse((node: any) => {\n totalNodes++;\n\n const numPoints = node.numPoints || 0;\n totalPoints += numPoints;\n\n if (node.loaded && node.geometry) {\n if (node.geometry.attributes) {\n for (const name in node.geometry.attributes) {\n const attribute = node.geometry.attributes[name];\n if (attribute && attribute.array) {\n loadedGeometryBytes += attribute.array.byteLength;\n }\n }\n }\n\n if (node.geometry.index && node.geometry.index.array) {\n loadedGeometryBytes += node.geometry.index.array.byteLength;\n }\n }\n\n if (bytesPerPoint > 0 && numPoints > 0) {\n estimatedTotalGeometryBytes += numPoints * (bytesPerPoint * 2 - 1);\n }\n }, true);\n }\n\n geometryBytes = Math.max(loadedGeometryBytes, estimatedTotalGeometryBytes);\n\n // ===================== AI-CODE-END ======================\n\n const info = new Info();\n\n info.scene.objects = totalNodes;\n info.scene.points = totalPoints;\n info.scene.triangles = 0;\n info.scene.lines = 0;\n info.scene.edges = 0;\n\n info.memory.geometries = totalNodes;\n info.memory.geometryBytes = Math.floor(geometryBytes);\n info.memory.textures = 0;\n info.memory.textureBytes = 0;\n info.memory.materials = 1;\n info.memory.totalEstimatedGpuBytes = Math.floor(geometryBytes);\n\n info.optimizedScene.objects = info.scene.objects;\n info.optimizedScene.triangles = info.scene.triangles;\n info.optimizedScene.points = info.scene.points;\n info.optimizedScene.lines = info.scene.lines;\n info.optimizedScene.edges = info.scene.edges;\n\n return info;\n }\n\n override getExtents(target: Box3): Box3 {\n return target.union(this.pco.pcoGeometry.boundingBox);\n }\n}\n","///////////////////////////////////////////////////////////////////////////////\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 { Euler, Vector3 } from \"three\";\nimport { PointColorType, PointCloudOctree, PointSizeType, PointShape, Potree } from \"potree-core\";\nimport { Loader, LoadParams, Viewer } from \"@inweb/viewer-three\";\n\nimport { PotreeModelImpl } from \"./PotreeModelImpl\";\n\nexport type PotreeLoadParams = LoadParams & {\n path?: string;\n position?: Vector3;\n rotation?: Euler;\n scale?: Vector3;\n};\n\nexport class PotreeFileLoader extends Loader {\n public viewer: Viewer;\n public potree: Potree;\n public pointClouds: PointCloudOctree[];\n\n constructor(viewer: Viewer) {\n super();\n this.viewer = viewer;\n\n this.potree = new Potree();\n this.pointClouds = [];\n\n this.viewer.addEventListener(\"render\", this.updatePointClouds);\n this.viewer.addEventListener(\"changecamera\", this.updatePointClouds);\n }\n\n override dispose() {\n this.pointClouds.forEach((pco) => pco.dispose());\n\n this.viewer.removeEventListener(\"render\", this.updatePointClouds);\n this.viewer.removeEventListener(\"changecamera\", this.updatePointClouds);\n }\n\n override isSupport(file: any, format?: string): boolean {\n return typeof file === \"string\" && /(cloud.js|metadata.json)$/i.test(file);\n }\n\n override async load(file: any, format?: string, params: PotreeLoadParams = {}): Promise<this> {\n const path = (params.path || \"\") + file;\n const index = path.lastIndexOf(\"/\");\n const baseUrl = path.slice(0, index + 1);\n const url = path.slice(index + 1);\n\n const pco = await this.potree.loadPointCloud(url, baseUrl);\n pco.material.size = 1.0;\n pco.material.shape = 2;\n pco.material.inputColorEncoding = 1;\n pco.material.outputColorEncoding = 1;\n pco.material.pointColorType = PointColorType.RGB; // RGB | DEPTH | HEIGHT | POINT_INDEX | LOD | CLASSIFICATION\n pco.material.pointSizeType = PointSizeType.ADAPTIVE; // ADAPTIVE | FIXED\n pco.material.shape = PointShape.CIRCLE; // CIRCLE | SQUARE\n\n if (params.position) pco.position.copy(params.position);\n if (params.rotation) pco.rotation.copy(params.rotation);\n if (params.scale) pco.scale.copy(params.scale);\n\n this.pointClouds.push(pco);\n\n const modelImpl = new PotreeModelImpl(pco);\n modelImpl.id = params.modelId || this.extractFileName(file);\n modelImpl.pco = pco;\n\n this.viewer.scene.add(pco);\n this.viewer.models.push(modelImpl);\n\n this.viewer.syncOptions();\n this.viewer.syncOverlay();\n\n this.viewer.emitEvent({ type: \"databasechunk\", data: pco, file });\n this.viewer.update(true);\n\n return this;\n }\n\n updatePointClouds = () => {\n const result = this.potree.updatePointClouds(this.pointClouds, this.viewer.camera, this.viewer.renderer);\n if (result.exceededMaxLoadsToGPU || result.nodeLoadPromises.length > 0) this.viewer.update();\n };\n}\n","///////////////////////////////////////////////////////////////////////////////\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 { loaders } from \"@inweb/viewer-three\";\n\nimport { PotreeFileLoader } from \"./PotreeFileLoader\";\n\nloaders.registerLoader(\"potree-file\", (viewer: any) => new PotreeFileLoader(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BM,MAAO,eAAgB,SAAQ,SAAS,CAAA;IAGnC,OAAO,GAAA;;QAOd,IAAI,WAAW,GAAG,CAAC;QACnB,IAAI,UAAU,GAAG,CAAC;QAClB,IAAI,mBAAmB,GAAG,CAAC;QAC3B,IAAI,2BAA2B,GAAG,CAAC;QACnC,IAAI,aAAa,GAAG,CAAC;AAErB,QAAA,MAAM,aAAa,GAAG,CAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,IAAI,CAAC,GAAG,CAAC,WAAW,0CAAE,eAAe,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,QAAQ,KAAI,CAAC;AAE1E,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE;AACrD,YAAA,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAS,KAAI;AAC/C,gBAAA,UAAU,EAAE;AAEZ,gBAAA,MAAM,SAAS,GAAG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AAE;AACzB,QAAA,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;AAEzB,QAAA,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;AACjE,QAAA,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;AAExB,QAAA,OAAO,IAAI;IACb;AAMD;;AC7ED,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,MAAW,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC"}
@@ -34934,11 +34934,13 @@ void main() {
34934
34934
  };
34935
34935
  this.viewerRender = () => {
34936
34936
  this.joyStickControls.update();
34937
- this.controls.update();
34938
34937
  };
34939
34938
  this.viewerZoom = () => {
34940
34939
  this.controls.rotateDelta.set(0, 0);
34941
34940
  };
34941
+ this.animate = () => {
34942
+ this.controls.update();
34943
+ };
34942
34944
  const meshOnlyGround = [];
34943
34945
  viewer.models.forEach((model) => model.getVisibleObjects().forEach((obj) => {
34944
34946
  if (obj instanceof Mesh) {
@@ -34951,12 +34953,14 @@ void main() {
34951
34953
  this.joyStickControls = new JoyStickControls(viewer.camera, viewer.canvas, viewer.canvas, meshOnlyGround);
34952
34954
  this.joyStickControls.addEventListener("change", this.controlsChange);
34953
34955
  this.viewer = viewer;
34956
+ this.viewer.addEventListener("animate", this.animate);
34954
34957
  this.viewer.addEventListener("render", this.viewerRender);
34955
34958
  this.viewer.addEventListener("zoom", this.viewerZoom);
34956
34959
  this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
34957
34960
  this.updateControls();
34958
34961
  }
34959
34962
  dispose() {
34963
+ this.viewer.removeEventListener("animate", this.animate);
34960
34964
  this.viewer.removeEventListener("render", this.viewerRender);
34961
34965
  this.viewer.removeEventListener("zoom", this.viewerZoom);
34962
34966
  this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
@@ -35136,23 +35140,27 @@ void main() {
35136
35140
  };
35137
35141
  this.viewerRender = () => {
35138
35142
  this.joyStickControls.update();
35139
- this.controls.update();
35140
35143
  };
35141
35144
  this.viewerZoom = () => {
35142
35145
  this.controls.rotateDelta.set(0, 0);
35143
35146
  };
35147
+ this.animate = () => {
35148
+ this.controls.update();
35149
+ };
35144
35150
  this.controls = new FlyControls(viewer.camera, viewer.canvas);
35145
35151
  this.controls.addEventListener("change", this.controlsChange);
35146
35152
  this.controls.addEventListener("flyspeedchange", this.flyspeedChange);
35147
35153
  this.joyStickControls = new JoyStickControls(viewer.camera, viewer.canvas, viewer.canvas, []);
35148
35154
  this.joyStickControls.addEventListener("change", this.controlsChange);
35149
35155
  this.viewer = viewer;
35156
+ this.viewer.addEventListener("animate", this.animate);
35150
35157
  this.viewer.addEventListener("render", this.viewerRender);
35151
35158
  this.viewer.addEventListener("zoom", this.viewerZoom);
35152
35159
  this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
35153
35160
  this.updateControls();
35154
35161
  }
35155
35162
  dispose() {
35163
+ this.viewer.removeEventListener("animate", this.animate);
35156
35164
  this.viewer.removeEventListener("render", this.viewerRender);
35157
35165
  this.viewer.removeEventListener("zoom", this.viewerZoom);
35158
35166
  this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
@@ -35202,9 +35210,9 @@ void main() {
35202
35210
  viewer.clearSlices();
35203
35211
  }
35204
35212
 
35205
- function createPreview(viewer, type = "image/jpeg", encoderOptions = 0.25) {
35213
+ function createPreview(viewer, type = "image/jpeg", quality = 0.25) {
35206
35214
  viewer.update(true);
35207
- return viewer.canvas.toDataURL(type, encoderOptions);
35215
+ return viewer.canvas.toDataURL(type, quality);
35208
35216
  }
35209
35217
 
35210
35218
  function explode(viewer, index = 0) {
@@ -35751,9 +35759,9 @@ void main() {
35751
35759
  console.log("File load time:", this.viewer.info.performance.loadTime, "ms");
35752
35760
  };
35753
35761
  this.resize = () => {
35754
- const rendererSize = this.viewer.renderer.getSize(new Vector2());
35755
- this.viewer.info.render.viewport.width = rendererSize.x;
35756
- this.viewer.info.render.viewport.height = rendererSize.y;
35762
+ const { width, height } = this.viewer.canvas;
35763
+ this.viewer.info.render.viewport.width = width;
35764
+ this.viewer.info.render.viewport.height = height;
35757
35765
  };
35758
35766
  this.render = () => {
35759
35767
  this.viewer.info.render.drawCalls = this.viewer.renderer.info.render.calls;
@@ -35802,13 +35810,13 @@ void main() {
35802
35810
 
35803
35811
  class RenderLoopComponent {
35804
35812
  constructor(viewer) {
35805
- this.animate = (time = 0) => {
35813
+ this.animate = (time) => {
35806
35814
  this.requestId = requestAnimationFrame(this.animate);
35807
35815
  this.viewer.render(time);
35808
35816
  this.viewer.emitEvent({ type: "animate", time });
35809
35817
  };
35810
35818
  this.viewer = viewer;
35811
- this.animate();
35819
+ this.requestId = requestAnimationFrame(this.animate);
35812
35820
  }
35813
35821
  dispose() {
35814
35822
  cancelAnimationFrame(this.requestId);
@@ -38097,8 +38105,6 @@ void main() {
38097
38105
  this.frameDelay = 0;
38098
38106
  this.graphicsObjectLimit = 10000;
38099
38107
  this.totalLoadedObjects = 0;
38100
- this.lastUpdateTime = 0;
38101
- this.updateInterval = 1000;
38102
38108
  this.handleToObjects = new Map();
38103
38109
  this.originalObjects = new Set();
38104
38110
  this.originalObjectsToSelection = new Set();
@@ -38774,11 +38780,7 @@ void main() {
38774
38780
  loaded: loadedCount,
38775
38781
  total: totalNodes,
38776
38782
  });
38777
- const currentTime = Date.now();
38778
- if (currentTime - this.lastUpdateTime >= this.updateInterval) {
38779
- this.dispatchEvent("update");
38780
- this.lastUpdateTime = currentTime;
38781
- }
38783
+ this.dispatchEvent("update");
38782
38784
  await new Promise((resolve) => {
38783
38785
  setTimeout(resolve, 0);
38784
38786
  });
@@ -39118,7 +39120,6 @@ void main() {
39118
39120
  this.objectTransforms.clear();
39119
39121
  this.transformedGeometries.clear();
39120
39122
  this.totalLoadedObjects = 0;
39121
- this.lastUpdateTime = 0;
39122
39123
  this.currentMemoryUsage = 0;
39123
39124
  this.loadedGeometrySize = 0;
39124
39125
  this.abortController = new AbortController();
@@ -39229,9 +39230,7 @@ void main() {
39229
39230
  }
39230
39231
  yieldToUI() {
39231
39232
  return new Promise((resolve) => {
39232
- requestAnimationFrame(() => {
39233
- setTimeout(resolve, 0);
39234
- });
39233
+ setTimeout(resolve, 0);
39235
39234
  });
39236
39235
  }
39237
39236
  async optimizeScene() {
@@ -40234,13 +40233,13 @@ void main() {
40234
40233
  this.viewer.models.push(modelImpl);
40235
40234
  this.viewer.syncOptions();
40236
40235
  this.viewer.syncOverlay();
40237
- this.viewer.update();
40238
40236
  this.viewer.emitEvent({ type: "databasechunk", data: scene, file });
40237
+ this.viewer.update(true);
40239
40238
  });
40240
40239
  this.gltfLoader.addEventListener("geometryerror", (data) => {
40241
40240
  this.viewer.emitEvent({ type: "geometryerror", data, file });
40242
40241
  });
40243
- this.gltfLoader.addEventListener("update", (data) => {
40242
+ this.gltfLoader.addEventListener("update", () => {
40244
40243
  this.viewer.update();
40245
40244
  });
40246
40245
  const loadController = {
@@ -40322,13 +40321,13 @@ void main() {
40322
40321
  this.viewer.models.push(modelImpl);
40323
40322
  this.viewer.syncOptions();
40324
40323
  this.viewer.syncOverlay();
40325
- this.viewer.update();
40326
40324
  this.viewer.emitEvent({ type: "databasechunk", data: scene, file: model.file, model });
40325
+ this.viewer.update(true);
40327
40326
  });
40328
40327
  this.gltfLoader.addEventListener("geometryerror", (data) => {
40329
40328
  this.viewer.emitEvent({ type: "geometryerror", data, file: model.file, model });
40330
40329
  });
40331
- this.gltfLoader.addEventListener("update", (data) => {
40330
+ this.gltfLoader.addEventListener("update", () => {
40332
40331
  this.viewer.update();
40333
40332
  });
40334
40333
  const loadController = {
@@ -55399,6 +55398,7 @@ js: import "konva/skia-backend";
55399
55398
  this.target = new Vector3(0, 0, 0);
55400
55399
  this._activeDragger = null;
55401
55400
  this._components = [];
55401
+ this._updateDelay = 1000;
55402
55402
  this._renderNeeded = false;
55403
55403
  this._renderTime = 0;
55404
55404
  this.render = this.render.bind(this);
@@ -55464,11 +55464,13 @@ js: import "konva/skia-backend";
55464
55464
  this.syncOptions();
55465
55465
  this.syncOverlay();
55466
55466
  this._renderTime = performance.now();
55467
- this.render(this._renderTime);
55468
- if (typeof onProgress === "function")
55469
- onProgress(new ProgressEvent("progress", { lengthComputable: true, loaded: 1, total: 1 }));
55467
+ if (typeof onProgress === "function") {
55468
+ const event = new ProgressEvent("progress", { lengthComputable: true, loaded: 1, total: 1 });
55469
+ onProgress(event);
55470
+ }
55470
55471
  this.emitEvent({ type: "initializeprogress", data: 1, loaded: 1, total: 1 });
55471
55472
  this.emitEvent({ type: "initialize" });
55473
+ this.update(true);
55472
55474
  return Promise.resolve(this);
55473
55475
  }
55474
55476
  dispose() {
@@ -55532,14 +55534,16 @@ js: import "konva/skia-backend";
55532
55534
  }
55533
55535
  this.renderer.setSize(width, height, updateStyle);
55534
55536
  this.composer.setSize(width, height);
55535
- this.update(true);
55536
55537
  this.emitEvent({ type: "resize", width, height });
55538
+ this.update(true);
55537
55539
  }
55538
55540
  update(force = false) {
55541
+ const time = performance.now();
55542
+ force = force || time - this._renderTime >= this._updateDelay;
55539
55543
  this._renderNeeded = true;
55540
55544
  if (force)
55541
- this.render();
55542
- this.emitEvent({ type: "update", data: force });
55545
+ this.render(time);
55546
+ this.emitEvent({ type: "update", force });
55543
55547
  }
55544
55548
  render(time, force = false) {
55545
55549
  var _a, _b;
@@ -55607,6 +55611,7 @@ js: import "konva/skia-backend";
55607
55611
  throw error;
55608
55612
  }
55609
55613
  this.emitEvent({ type: "geometryend", file, model });
55614
+ this.update(true);
55610
55615
  return this;
55611
55616
  }
55612
55617
  openGltfFile(file, externalFiles, params = {}) {
@@ -55639,8 +55644,8 @@ js: import "konva/skia-backend";
55639
55644
  this.target.set(0, 0, 0);
55640
55645
  this.syncOptions();
55641
55646
  this.syncOverlay();
55642
- this.update(true);
55643
55647
  this.emitEvent({ type: "clear" });
55648
+ this.update(true);
55644
55649
  return this;
55645
55650
  }
55646
55651
  is3D() {
@@ -55828,7 +55833,7 @@ js: import "konva/skia-backend";
55828
55833
  this.syncOverlay();
55829
55834
  this.setActiveDragger(draggerName);
55830
55835
  this.emitEvent({ type: "drawviewpoint", data: viewpoint });
55831
- this.update();
55836
+ this.update(true);
55832
55837
  }
55833
55838
  createViewpoint() {
55834
55839
  if (!this.renderer)
@@ -55909,11 +55914,9 @@ js: import "konva/skia-backend";
55909
55914
  }
55910
55915
  return { x: intersectionPoint.x, y: intersectionPoint.y, z: intersectionPoint.z };
55911
55916
  }
55912
- else {
55913
- const point = new Vector3(x, y, -1);
55914
- point.unproject(this.camera);
55915
- return { x: point.x, y: point.y, z: point.z };
55916
- }
55917
+ const point = new Vector3(x, y, -1);
55918
+ point.unproject(this.camera);
55919
+ return { x: point.x, y: point.y, z: point.z };
55917
55920
  }
55918
55921
  worldToScreen(position) {
55919
55922
  if (!this.renderer)