@inweb/viewer-three 27.1.1 → 27.1.2

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 (44) hide show
  1. package/dist/extensions/components/AxesHelperComponent.js +12 -11
  2. package/dist/extensions/components/AxesHelperComponent.js.map +1 -1
  3. package/dist/extensions/components/AxesHelperComponent.min.js +1 -1
  4. package/dist/extensions/components/AxesHelperComponent.module.js +12 -11
  5. package/dist/extensions/components/AxesHelperComponent.module.js.map +1 -1
  6. package/dist/extensions/components/GridHelperComponent.js +4 -6
  7. package/dist/extensions/components/GridHelperComponent.js.map +1 -1
  8. package/dist/extensions/components/GridHelperComponent.min.js +1 -1
  9. package/dist/extensions/components/GridHelperComponent.module.js +4 -6
  10. package/dist/extensions/components/GridHelperComponent.module.js.map +1 -1
  11. package/dist/extensions/components/LightHelperComponent.js +5 -5
  12. package/dist/extensions/components/LightHelperComponent.js.map +1 -1
  13. package/dist/extensions/components/LightHelperComponent.min.js +1 -1
  14. package/dist/extensions/components/LightHelperComponent.module.js +6 -6
  15. package/dist/extensions/components/LightHelperComponent.module.js.map +1 -1
  16. package/dist/viewer-three.js +1344 -78
  17. package/dist/viewer-three.js.map +1 -1
  18. package/dist/viewer-three.min.js +4 -4
  19. package/dist/viewer-three.module.js +98 -79
  20. package/dist/viewer-three.module.js.map +1 -1
  21. package/extensions/components/AxesHelperComponent.ts +13 -12
  22. package/extensions/components/GridHelperComponent.ts +4 -6
  23. package/extensions/components/LightHelperComponent.ts +6 -6
  24. package/lib/Viewer/commands/SetDefaultViewPosition.d.ts +1 -1
  25. package/lib/Viewer/loaders/GLTFBinaryParser.d.ts +11 -0
  26. package/lib/Viewer/loaders/GLTFFileDynamicLoader.d.ts +0 -1
  27. package/lib/Viewer/loaders/JSONStreamParser.d.ts +5 -0
  28. package/package.json +7 -5
  29. package/src/Viewer/Viewer.ts +4 -7
  30. package/src/Viewer/commands/SetDefaultViewPosition.ts +3 -3
  31. package/src/Viewer/commands/ZoomTo.ts +6 -6
  32. package/src/Viewer/components/CameraComponent.ts +3 -3
  33. package/src/Viewer/components/LightComponent.ts +5 -8
  34. package/src/Viewer/components/SelectionComponent.ts +3 -1
  35. package/src/Viewer/draggers/CuttingPlaneDragger.ts +6 -6
  36. package/src/Viewer/draggers/FlyDragger.ts +1 -1
  37. package/src/Viewer/draggers/MeasureLineDragger.ts +10 -7
  38. package/src/Viewer/draggers/WalkDragger.ts +1 -1
  39. package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +7 -1
  40. package/src/Viewer/loaders/{GLTFBinaryExtension.ts → GLTFBinaryParser.ts} +34 -29
  41. package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +10 -9
  42. package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +9 -8
  43. package/src/Viewer/loaders/JSONStreamParser.ts +38 -0
  44. package/lib/Viewer/loaders/GLTFBinaryExtension.d.ts +0 -5
@@ -37,22 +37,24 @@
37
37
  this.modelHelpers.length = 0;
38
38
  this.axesHelper1.removeFromParent();
39
39
  this.axesHelper2.removeFromParent();
40
- const size = this.viewer.extents.getSize(new three.Vector3()).length();
41
- const center = this.viewer.extents.getCenter(new three.Vector3());
40
+ const extentsSize = this.viewer.extents.getSize(new three.Vector3()).length() || 1;
41
+ const extentsCenter = this.viewer.extents.getCenter(new three.Vector3());
42
42
  this.axesHelper1.position.set(0, 0, 0);
43
- this.axesHelper1.scale.setScalar(size * 1.25);
44
- this.axesHelper2.position.copy(center);
45
- this.axesHelper2.scale.setScalar(size);
43
+ this.axesHelper1.scale.setScalar(extentsSize * 1.5);
46
44
  this.viewer.helpers.add(this.axesHelper1);
45
+ if (this.viewer.models.length < 1)
46
+ return;
47
+ this.axesHelper2.position.copy(extentsCenter);
48
+ this.axesHelper2.scale.setScalar(extentsSize);
47
49
  this.viewer.helpers.add(this.axesHelper2);
48
50
  if (this.viewer.models.length < 2)
49
51
  return;
50
52
  this.viewer.models.forEach((model) => {
51
- const extents = model.getExtents(new three.Box3());
52
- const size = extents.getSize(new three.Vector3()).length();
53
- const center = extents.getCenter(new three.Vector3());
54
- const helper = new three.AxesHelper(size);
55
- helper.position.copy(center);
53
+ const modelExtents = model.getExtents(new three.Box3());
54
+ const modelSize = modelExtents.getSize(new three.Vector3()).length() || 1;
55
+ const modelCenter = modelExtents.getCenter(new three.Vector3());
56
+ const helper = new three.AxesHelper(modelSize);
57
+ helper.position.copy(modelCenter);
56
58
  this.modelHelpers.push(helper);
57
59
  this.viewer.helpers.add(helper);
58
60
  });
@@ -60,7 +62,6 @@
60
62
  this.axesHelper1 = new three.AxesHelper(1);
61
63
  this.axesHelper2 = new three.AxesHelper(1);
62
64
  this.modelHelpers = [];
63
- this.axesHelper1.setColors("#ccc", "#ccc", "#ccc");
64
65
  this.viewer = viewer;
65
66
  this.viewer.addEventListener("initialize", this.syncHelper);
66
67
  this.viewer.addEventListener("geometryend", this.syncHelper);
@@ -1 +1 @@
1
- {"version":3,"file":"AxesHelperComponent.js","sources":["../../../extensions/components/AxesHelperComponent.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 { AxesHelper, Box3, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass AxesHelperComponent implements IComponent {\n private viewer: Viewer;\n private axesHelper1: AxesHelper;\n private axesHelper2: AxesHelper;\n private modelHelpers: AxesHelper[];\n\n constructor(viewer: Viewer) {\n this.axesHelper1 = new AxesHelper(1);\n this.axesHelper2 = new AxesHelper(1);\n this.modelHelpers = [];\n\n this.axesHelper1.setColors(\"#ccc\", \"#ccc\", \"#ccc\");\n\n this.viewer = viewer;\n this.viewer.addEventListener(\"initialize\", this.syncHelper);\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n\n this.axesHelper1.removeFromParent();\n this.axesHelper1.dispose();\n\n this.axesHelper2.removeFromParent();\n this.axesHelper2.dispose();\n\n this.viewer.removeEventListener(\"initialize\", this.syncHelper);\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.modelHelpers.length = 0;\n\n this.axesHelper1.removeFromParent();\n this.axesHelper2.removeFromParent();\n\n const size = this.viewer.extents.getSize(new Vector3()).length();\n const center = this.viewer.extents.getCenter(new Vector3());\n\n this.axesHelper1.position.set(0, 0, 0);\n this.axesHelper1.scale.setScalar(size * 1.25);\n\n this.axesHelper2.position.copy(center);\n this.axesHelper2.scale.setScalar(size);\n\n this.viewer.helpers.add(this.axesHelper1);\n this.viewer.helpers.add(this.axesHelper2);\n\n if (this.viewer.models.length < 2) return;\n\n this.viewer.models.forEach((model) => {\n const extents = model.getExtents(new Box3());\n const size = extents.getSize(new Vector3()).length();\n const center = extents.getCenter(new Vector3());\n\n const helper = new AxesHelper(size);\n helper.position.copy(center);\n\n this.modelHelpers.push(helper);\n this.viewer.helpers.add(helper);\n });\n };\n}\n\ncomponents.registerComponent(\"AxesHelperComponent\", (viewer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L,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;gBACnC,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,CAAC,OAAO,EAAE;IAClB,QAAA,CAAC,CAAC;IAEF,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;IACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;IAE1B,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;IACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;YAE1B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;YAC/D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;QAC3D;IAsCD;AAEDC,0BAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
1
+ {"version":3,"file":"AxesHelperComponent.js","sources":["../../../extensions/components/AxesHelperComponent.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 { AxesHelper, Box3, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass AxesHelperComponent implements IComponent {\n private viewer: Viewer;\n private axesHelper1: AxesHelper;\n private axesHelper2: AxesHelper;\n private modelHelpers: AxesHelper[];\n\n constructor(viewer: Viewer) {\n this.axesHelper1 = new AxesHelper(1);\n this.axesHelper2 = new AxesHelper(1);\n this.modelHelpers = [];\n\n // this.axesHelper1.setColors(\"#ccc\", \"#ccc\", \"#ccc\");\n\n this.viewer = viewer;\n this.viewer.addEventListener(\"initialize\", this.syncHelper);\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n\n this.axesHelper1.removeFromParent();\n this.axesHelper1.dispose();\n\n this.axesHelper2.removeFromParent();\n this.axesHelper2.dispose();\n\n this.viewer.removeEventListener(\"initialize\", this.syncHelper);\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.modelHelpers.length = 0;\n\n this.axesHelper1.removeFromParent();\n this.axesHelper2.removeFromParent();\n\n const extentsSize = this.viewer.extents.getSize(new Vector3()).length() || 1;\n const extentsCenter = this.viewer.extents.getCenter(new Vector3());\n\n this.axesHelper1.position.set(0, 0, 0);\n this.axesHelper1.scale.setScalar(extentsSize * 1.5);\n this.viewer.helpers.add(this.axesHelper1);\n\n if (this.viewer.models.length < 1) return;\n\n this.axesHelper2.position.copy(extentsCenter);\n this.axesHelper2.scale.setScalar(extentsSize);\n this.viewer.helpers.add(this.axesHelper2);\n\n if (this.viewer.models.length < 2) return;\n\n this.viewer.models.forEach((model) => {\n const modelExtents = model.getExtents(new Box3());\n const modelSize = modelExtents.getSize(new Vector3()).length() || 1;\n const modelCenter = modelExtents.getCenter(new Vector3());\n\n const helper = new AxesHelper(modelSize);\n helper.position.copy(modelCenter);\n\n this.modelHelpers.push(helper);\n this.viewer.helpers.add(helper);\n });\n };\n}\n\ncomponents.registerComponent(\"AxesHelperComponent\", (viewer) => new AxesHelperComponent(viewer));\n"],"names":["Vector3","Box3","AxesHelper","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BA,MAAM,mBAAmB,CAAA;IAMvB,IAAA,WAAA,CAAY,MAAc,EAAA;YA8B1B,IAAA,CAAA,UAAU,GAAG,MAAK;gBAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;oBACnC,MAAM,CAAC,gBAAgB,EAAE;oBACzB,MAAM,CAAC,OAAO,EAAE;IAClB,YAAA,CAAC,CAAC;IACF,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;IAE5B,YAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;IACnC,YAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;IAEnC,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAIA,aAAO,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5E,YAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAIA,aAAO,EAAE,CAAC;IAElE,YAAA,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,GAAG,CAAC;gBACnD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;gBAEzC,IAAI,IAA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gB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;YAC3D,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;YAC5D,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;QACxD;QAEA,OAAO,GAAA;YACL,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;gBACnC,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,CAAC,OAAO,EAAE;IAClB,QAAA,CAAC,CAAC;IAEF,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;IACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;IAE1B,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;IACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;YAE1B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;YAC9D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;YAC/D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;QAC3D;IAuCD;AAEDC,0BAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
@@ -21,4 +21,4 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- !function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,s){"use strict";class t{constructor(s){this.syncHelper=()=>{this.modelHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.modelHelpers.length=0,this.axesHelper1.removeFromParent(),this.axesHelper2.removeFromParent();const s=this.viewer.extents.getSize(new e.Vector3).length(),t=this.viewer.extents.getCenter(new e.Vector3);this.axesHelper1.position.set(0,0,0),this.axesHelper1.scale.setScalar(1.25*s),this.axesHelper2.position.copy(t),this.axesHelper2.scale.setScalar(s),this.viewer.helpers.add(this.axesHelper1),this.viewer.helpers.add(this.axesHelper2),this.viewer.models.length<2||this.viewer.models.forEach(s=>{const t=s.getExtents(new e.Box3),r=t.getSize(new e.Vector3).length(),i=t.getCenter(new e.Vector3),n=new e.AxesHelper(r);n.position.copy(i),this.modelHelpers.push(n),this.viewer.helpers.add(n)})},this.axesHelper1=new e.AxesHelper(1),this.axesHelper2=new e.AxesHelper(1),this.modelHelpers=[],this.axesHelper1.setColors("#ccc","#ccc","#ccc"),this.viewer=s,this.viewer.addEventListener("initialize",this.syncHelper),this.viewer.addEventListener("geometryend",this.syncHelper),this.viewer.addEventListener("clear",this.syncHelper)}dispose(){this.modelHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.axesHelper1.removeFromParent(),this.axesHelper1.dispose(),this.axesHelper2.removeFromParent(),this.axesHelper2.dispose(),this.viewer.removeEventListener("initialize",this.syncHelper),this.viewer.removeEventListener("geometryend",this.syncHelper),this.viewer.removeEventListener("clear",this.syncHelper)}}s.components.registerComponent("AxesHelperComponent",e=>new t(e))});
24
+ !function(e,s){"object"==typeof exports&&"undefined"!=typeof module?s(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],s):s((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,s){"use strict";class t{constructor(s){this.syncHelper=()=>{this.modelHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.modelHelpers.length=0,this.axesHelper1.removeFromParent(),this.axesHelper2.removeFromParent();const s=this.viewer.extents.getSize(new e.Vector3).length()||1,t=this.viewer.extents.getCenter(new e.Vector3);this.axesHelper1.position.set(0,0,0),this.axesHelper1.scale.setScalar(1.5*s),this.viewer.helpers.add(this.axesHelper1),this.viewer.models.length<1||(this.axesHelper2.position.copy(t),this.axesHelper2.scale.setScalar(s),this.viewer.helpers.add(this.axesHelper2),this.viewer.models.length<2||this.viewer.models.forEach(s=>{const t=s.getExtents(new e.Box3),r=t.getSize(new e.Vector3).length()||1,i=t.getCenter(new e.Vector3),n=new e.AxesHelper(r);n.position.copy(i),this.modelHelpers.push(n),this.viewer.helpers.add(n)}))},this.axesHelper1=new e.AxesHelper(1),this.axesHelper2=new e.AxesHelper(1),this.modelHelpers=[],this.viewer=s,this.viewer.addEventListener("initialize",this.syncHelper),this.viewer.addEventListener("geometryend",this.syncHelper),this.viewer.addEventListener("clear",this.syncHelper)}dispose(){this.modelHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.axesHelper1.removeFromParent(),this.axesHelper1.dispose(),this.axesHelper2.removeFromParent(),this.axesHelper2.dispose(),this.viewer.removeEventListener("initialize",this.syncHelper),this.viewer.removeEventListener("geometryend",this.syncHelper),this.viewer.removeEventListener("clear",this.syncHelper)}}s.components.registerComponent("AxesHelperComponent",e=>new t(e))});
@@ -34,22 +34,24 @@ class AxesHelperComponent {
34
34
  this.modelHelpers.length = 0;
35
35
  this.axesHelper1.removeFromParent();
36
36
  this.axesHelper2.removeFromParent();
37
- const size = this.viewer.extents.getSize(new Vector3()).length();
38
- const center = this.viewer.extents.getCenter(new Vector3());
37
+ const extentsSize = this.viewer.extents.getSize(new Vector3()).length() || 1;
38
+ const extentsCenter = this.viewer.extents.getCenter(new Vector3());
39
39
  this.axesHelper1.position.set(0, 0, 0);
40
- this.axesHelper1.scale.setScalar(size * 1.25);
41
- this.axesHelper2.position.copy(center);
42
- this.axesHelper2.scale.setScalar(size);
40
+ this.axesHelper1.scale.setScalar(extentsSize * 1.5);
43
41
  this.viewer.helpers.add(this.axesHelper1);
42
+ if (this.viewer.models.length < 1)
43
+ return;
44
+ this.axesHelper2.position.copy(extentsCenter);
45
+ this.axesHelper2.scale.setScalar(extentsSize);
44
46
  this.viewer.helpers.add(this.axesHelper2);
45
47
  if (this.viewer.models.length < 2)
46
48
  return;
47
49
  this.viewer.models.forEach((model) => {
48
- const extents = model.getExtents(new Box3());
49
- const size = extents.getSize(new Vector3()).length();
50
- const center = extents.getCenter(new Vector3());
51
- const helper = new AxesHelper(size);
52
- helper.position.copy(center);
50
+ const modelExtents = model.getExtents(new Box3());
51
+ const modelSize = modelExtents.getSize(new Vector3()).length() || 1;
52
+ const modelCenter = modelExtents.getCenter(new Vector3());
53
+ const helper = new AxesHelper(modelSize);
54
+ helper.position.copy(modelCenter);
53
55
  this.modelHelpers.push(helper);
54
56
  this.viewer.helpers.add(helper);
55
57
  });
@@ -57,7 +59,6 @@ class AxesHelperComponent {
57
59
  this.axesHelper1 = new AxesHelper(1);
58
60
  this.axesHelper2 = new AxesHelper(1);
59
61
  this.modelHelpers = [];
60
- this.axesHelper1.setColors("#ccc", "#ccc", "#ccc");
61
62
  this.viewer = viewer;
62
63
  this.viewer.addEventListener("initialize", this.syncHelper);
63
64
  this.viewer.addEventListener("geometryend", this.syncHelper);
@@ -1 +1 @@
1
- {"version":3,"file":"AxesHelperComponent.module.js","sources":["../../../extensions/components/AxesHelperComponent.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 { AxesHelper, Box3, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass AxesHelperComponent implements IComponent {\n private viewer: Viewer;\n private axesHelper1: AxesHelper;\n private axesHelper2: AxesHelper;\n private modelHelpers: AxesHelper[];\n\n constructor(viewer: Viewer) {\n this.axesHelper1 = new AxesHelper(1);\n this.axesHelper2 = new AxesHelper(1);\n this.modelHelpers = [];\n\n this.axesHelper1.setColors(\"#ccc\", \"#ccc\", \"#ccc\");\n\n this.viewer = viewer;\n this.viewer.addEventListener(\"initialize\", this.syncHelper);\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n\n this.axesHelper1.removeFromParent();\n this.axesHelper1.dispose();\n\n this.axesHelper2.removeFromParent();\n this.axesHelper2.dispose();\n\n this.viewer.removeEventListener(\"initialize\", this.syncHelper);\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.modelHelpers.length = 0;\n\n this.axesHelper1.removeFromParent();\n this.axesHelper2.removeFromParent();\n\n const size = this.viewer.extents.getSize(new Vector3()).length();\n const center = this.viewer.extents.getCenter(new Vector3());\n\n this.axesHelper1.position.set(0, 0, 0);\n this.axesHelper1.scale.setScalar(size * 1.25);\n\n this.axesHelper2.position.copy(center);\n this.axesHelper2.scale.setScalar(size);\n\n this.viewer.helpers.add(this.axesHelper1);\n this.viewer.helpers.add(this.axesHelper2);\n\n if (this.viewer.models.length < 2) return;\n\n this.viewer.models.forEach((model) => {\n const extents = model.getExtents(new Box3());\n const size = extents.getSize(new Vector3()).length();\n const center = extents.getCenter(new Vector3());\n\n const helper = new AxesHelper(size);\n helper.position.copy(center);\n\n this.modelHelpers.push(helper);\n this.viewer.helpers.add(helper);\n });\n };\n}\n\ncomponents.registerComponent(\"AxesHelperComponent\", (viewer) => new AxesHelperComponent(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,CAAA;AAMvB,IAAA,WAAA,CAAY,MAAc,EAAA;QA8B1B,IAAA,CAAA,UAAU,GAAG,MAAK;YAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;gBACnC,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,CAAC,OAAO,EAAE;AAClB,YAAA,CAAC,CAAC;AACF,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;AAE5B,YAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AACnC,YAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AAEnC,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;AAChE,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC;AAE3D,YAAA,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;YAE7C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;YAEtC,IAAI,CAAC,MAAM,CAAC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AAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IACxD;IAEA,OAAO,GAAA;QACL,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;YACnC,MAAM,CAAC,gBAAgB,EAAE;YACzB,MAAM,CAAC,OAAO,EAAE;AAClB,QAAA,CAAC,CAAC;AAEF,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;AAE1B,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QAE1B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IAC3D;AAsCD;AAED,UAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"AxesHelperComponent.module.js","sources":["../../../extensions/components/AxesHelperComponent.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 { AxesHelper, Box3, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass AxesHelperComponent implements IComponent {\n private viewer: Viewer;\n private axesHelper1: AxesHelper;\n private axesHelper2: AxesHelper;\n private modelHelpers: AxesHelper[];\n\n constructor(viewer: Viewer) {\n this.axesHelper1 = new AxesHelper(1);\n this.axesHelper2 = new AxesHelper(1);\n this.modelHelpers = [];\n\n // this.axesHelper1.setColors(\"#ccc\", \"#ccc\", \"#ccc\");\n\n this.viewer = viewer;\n this.viewer.addEventListener(\"initialize\", this.syncHelper);\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n\n this.axesHelper1.removeFromParent();\n this.axesHelper1.dispose();\n\n this.axesHelper2.removeFromParent();\n this.axesHelper2.dispose();\n\n this.viewer.removeEventListener(\"initialize\", this.syncHelper);\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.modelHelpers.length = 0;\n\n this.axesHelper1.removeFromParent();\n this.axesHelper2.removeFromParent();\n\n const extentsSize = this.viewer.extents.getSize(new Vector3()).length() || 1;\n const extentsCenter = this.viewer.extents.getCenter(new Vector3());\n\n this.axesHelper1.position.set(0, 0, 0);\n this.axesHelper1.scale.setScalar(extentsSize * 1.5);\n this.viewer.helpers.add(this.axesHelper1);\n\n if (this.viewer.models.length < 1) return;\n\n this.axesHelper2.position.copy(extentsCenter);\n this.axesHelper2.scale.setScalar(extentsSize);\n this.viewer.helpers.add(this.axesHelper2);\n\n if (this.viewer.models.length < 2) return;\n\n this.viewer.models.forEach((model) => {\n const modelExtents = model.getExtents(new Box3());\n const modelSize = modelExtents.getSize(new Vector3()).length() || 1;\n const modelCenter = modelExtents.getCenter(new Vector3());\n\n const helper = new AxesHelper(modelSize);\n helper.position.copy(modelCenter);\n\n this.modelHelpers.push(helper);\n this.viewer.helpers.add(helper);\n });\n };\n}\n\ncomponents.registerComponent(\"AxesHelperComponent\", (viewer) => new AxesHelperComponent(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,CAAA;AAMvB,IAAA,WAAA,CAAY,MAAc,EAAA;QA8B1B,IAAA,CAAA,UAAU,GAAG,MAAK;YAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;gBACnC,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,CAAC,OAAO,EAAE;AAClB,YAAA,CAAC,CAAC;AACF,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;AAE5B,YAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AACnC,YAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AAEnC,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;AAC5E,YAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC;AAElE,YAAA,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,GAAG,C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,EAAE;AAItB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IACxD;IAEA,OAAO,GAAA;QACL,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;YACnC,MAAM,CAAC,gBAAgB,EAAE;YACzB,MAAM,CAAC,OAAO,EAAE;AAClB,QAAA,CAAC,CAAC;AAEF,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;AAE1B,QAAA,IAAI,CAAC,WAAW,CAAC,gBAAgB,EAAE;AACnC,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QAE1B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IAC3D;AAuCD;AAED,UAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
@@ -31,14 +31,12 @@
31
31
  constructor(viewer) {
32
32
  this.syncHelper = () => {
33
33
  this.gridHelper.removeFromParent();
34
- if (this.viewer.extents.isEmpty())
35
- return;
36
- const size = this.viewer.extents.getSize(new three.Vector3()).multiply(this.viewer.camera.up).length();
37
- const center = this.viewer.extents.getCenter(new three.Vector3());
34
+ const extentsSizeUp = this.viewer.extents.getSize(new three.Vector3()).multiply(this.viewer.camera.up).length() || 1;
35
+ const extentsCenter = this.viewer.extents.getCenter(new three.Vector3());
38
36
  const upY = new three.Vector3(0, 1, 0);
39
37
  const up = new three.Vector3().copy(this.viewer.camera.up);
40
- this.gridHelper.scale.setScalar(size);
41
- this.gridHelper.position.copy(center);
38
+ this.gridHelper.scale.setScalar(extentsSizeUp);
39
+ this.gridHelper.position.copy(extentsCenter);
42
40
  this.gridHelper.quaternion.setFromUnitVectors(upY, up);
43
41
  this.viewer.helpers.add(this.gridHelper);
44
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"GridHelperComponent.js","sources":["../../../extensions/components/GridHelperComponent.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 { GridHelper, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass GridHelperComponent implements IComponent {\n private viewer: Viewer;\n private gridHelper: GridHelper;\n\n constructor(viewer: Viewer) {\n this.gridHelper = new GridHelper(10, 20, 0x444444, 0xaaaaaa);\n this.viewer = viewer;\n this.viewer.on(\"initialize\", this.syncHelper);\n this.viewer.on(\"geometryend\", this.syncHelper);\n this.viewer.on(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.gridHelper.removeFromParent();\n this.gridHelper.dispose();\n\n this.viewer.off(\"initialize\", this.syncHelper);\n this.viewer.off(\"geometryend\", this.syncHelper);\n this.viewer.off(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.gridHelper.removeFromParent();\n\n if (this.viewer.extents.isEmpty()) return;\n\n const size = this.viewer.extents.getSize(new Vector3()).multiply(this.viewer.camera.up).length();\n const center = this.viewer.extents.getCenter(new Vector3());\n\n const upY = new Vector3(0, 1, 0);\n const up = new Vector3().copy(this.viewer.camera.up);\n\n this.gridHelper.scale.setScalar(size);\n this.gridHelper.position.copy(center);\n this.gridHelper.quaternion.setFromUnitVectors(upY, up);\n\n this.viewer.helpers.add(this.gridHelper);\n };\n}\n\ncomponents.registerComponent(\"GridHelperComponent\", (viewer) => new GridHelperComponent(viewer));\n"],"names":["Vector3","GridHelper","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BA,MAAM,mBAAmB,CAAA;IAIvB,IAAA,WAAA,CAAY,MAAc,EAAA;YAiB1B,IAAA,CAAA,UAAU,GAAG,MAAK;IAChB,YAAA,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;IAElC,YAAA,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;oBAAE;IAEnC,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAIA,aAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;IAChG,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAIA,aAAO,EAAE,CAAC;gBAE3D,MAAM,GAAG,GAAG,IAAIA,aAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChC,YAAA,MAAM,EAAE,GA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,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
1
+ {"version":3,"file":"GridHelperComponent.js","sources":["../../../extensions/components/GridHelperComponent.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 { GridHelper, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass GridHelperComponent implements IComponent {\n private viewer: Viewer;\n private gridHelper: GridHelper;\n\n constructor(viewer: Viewer) {\n this.gridHelper = new GridHelper(10, 20, 0x444444, 0xaaaaaa);\n this.viewer = viewer;\n this.viewer.on(\"initialize\", this.syncHelper);\n this.viewer.on(\"geometryend\", this.syncHelper);\n this.viewer.on(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.gridHelper.removeFromParent();\n this.gridHelper.dispose();\n\n this.viewer.off(\"initialize\", this.syncHelper);\n this.viewer.off(\"geometryend\", this.syncHelper);\n this.viewer.off(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.gridHelper.removeFromParent();\n\n const extentsSizeUp = this.viewer.extents.getSize(new Vector3()).multiply(this.viewer.camera.up).length() || 1;\n const extentsCenter = this.viewer.extents.getCenter(new Vector3());\n\n const upY = new Vector3(0, 1, 0);\n const up = new Vector3().copy(this.viewer.camera.up);\n\n this.gridHelper.scale.setScalar(extentsSizeUp);\n this.gridHelper.position.copy(extentsCenter);\n this.gridHelper.quaternion.setFromUnitVectors(upY, up);\n\n this.viewer.helpers.add(this.gridHelper);\n };\n}\n\ncomponents.registerComponent(\"GridHelperComponent\", (viewer) => new GridHelperComponent(viewer));\n"],"names":["Vector3","GridHelper","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BA,MAAM,mBAAmB,CAAA;IAIvB,IAAA,WAAA,CAAY,MAAc,EAAA;YAiB1B,IAAA,CAAA,UAAU,GAAG,MAAK;IAChB,YAAA,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;IAElC,YAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAIA,aAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC9G,YAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAIA,aAAO,EAAE,CAAC;gBAElE,MAAM,GAAG,GAAG,IAAIA,aAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChC,YAAA,MAAM,EAAE,GAAG,IAAIA,aAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAEpD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;gBAC9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;gBAC5C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,EAAE,EAAE,CAAC;gBAEtD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;IAC1C,QAAA,CAAC;IA9BC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAIC,gBAAU,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC;IAC5D,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;YACpB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;YAC7C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;QAC1C;QAEA,OAAO,GAAA;IACL,QAAA,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;IAClC,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;YAEzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;YAC9C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;QAC3C;IAiBD;AAEDC,0BAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
@@ -21,4 +21,4 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- !function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,i){"use strict";class r{constructor(i){this.syncHelper=()=>{if(this.gridHelper.removeFromParent(),this.viewer.extents.isEmpty())return;const i=this.viewer.extents.getSize(new e.Vector3).multiply(this.viewer.camera.up).length(),r=this.viewer.extents.getCenter(new e.Vector3),t=new e.Vector3(0,1,0),s=(new e.Vector3).copy(this.viewer.camera.up);this.gridHelper.scale.setScalar(i),this.gridHelper.position.copy(r),this.gridHelper.quaternion.setFromUnitVectors(t,s),this.viewer.helpers.add(this.gridHelper)},this.gridHelper=new e.GridHelper(10,20,4473924,11184810),this.viewer=i,this.viewer.on("initialize",this.syncHelper),this.viewer.on("geometryend",this.syncHelper),this.viewer.on("clear",this.syncHelper)}dispose(){this.gridHelper.removeFromParent(),this.gridHelper.dispose(),this.viewer.off("initialize",this.syncHelper),this.viewer.off("geometryend",this.syncHelper),this.viewer.off("clear",this.syncHelper)}}i.components.registerComponent("GridHelperComponent",e=>new r(e))});
24
+ !function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,i){"use strict";class r{constructor(i){this.syncHelper=()=>{this.gridHelper.removeFromParent();const i=this.viewer.extents.getSize(new e.Vector3).multiply(this.viewer.camera.up).length()||1,r=this.viewer.extents.getCenter(new e.Vector3),t=new e.Vector3(0,1,0),s=(new e.Vector3).copy(this.viewer.camera.up);this.gridHelper.scale.setScalar(i),this.gridHelper.position.copy(r),this.gridHelper.quaternion.setFromUnitVectors(t,s),this.viewer.helpers.add(this.gridHelper)},this.gridHelper=new e.GridHelper(10,20,4473924,11184810),this.viewer=i,this.viewer.on("initialize",this.syncHelper),this.viewer.on("geometryend",this.syncHelper),this.viewer.on("clear",this.syncHelper)}dispose(){this.gridHelper.removeFromParent(),this.gridHelper.dispose(),this.viewer.off("initialize",this.syncHelper),this.viewer.off("geometryend",this.syncHelper),this.viewer.off("clear",this.syncHelper)}}i.components.registerComponent("GridHelperComponent",e=>new r(e))});
@@ -28,14 +28,12 @@ class GridHelperComponent {
28
28
  constructor(viewer) {
29
29
  this.syncHelper = () => {
30
30
  this.gridHelper.removeFromParent();
31
- if (this.viewer.extents.isEmpty())
32
- return;
33
- const size = this.viewer.extents.getSize(new Vector3()).multiply(this.viewer.camera.up).length();
34
- const center = this.viewer.extents.getCenter(new Vector3());
31
+ const extentsSizeUp = this.viewer.extents.getSize(new Vector3()).multiply(this.viewer.camera.up).length() || 1;
32
+ const extentsCenter = this.viewer.extents.getCenter(new Vector3());
35
33
  const upY = new Vector3(0, 1, 0);
36
34
  const up = new Vector3().copy(this.viewer.camera.up);
37
- this.gridHelper.scale.setScalar(size);
38
- this.gridHelper.position.copy(center);
35
+ this.gridHelper.scale.setScalar(extentsSizeUp);
36
+ this.gridHelper.position.copy(extentsCenter);
39
37
  this.gridHelper.quaternion.setFromUnitVectors(upY, up);
40
38
  this.viewer.helpers.add(this.gridHelper);
41
39
  };
@@ -1 +1 @@
1
- {"version":3,"file":"GridHelperComponent.module.js","sources":["../../../extensions/components/GridHelperComponent.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 { GridHelper, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass GridHelperComponent implements IComponent {\n private viewer: Viewer;\n private gridHelper: GridHelper;\n\n constructor(viewer: Viewer) {\n this.gridHelper = new GridHelper(10, 20, 0x444444, 0xaaaaaa);\n this.viewer = viewer;\n this.viewer.on(\"initialize\", this.syncHelper);\n this.viewer.on(\"geometryend\", this.syncHelper);\n this.viewer.on(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.gridHelper.removeFromParent();\n this.gridHelper.dispose();\n\n this.viewer.off(\"initialize\", this.syncHelper);\n this.viewer.off(\"geometryend\", this.syncHelper);\n this.viewer.off(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.gridHelper.removeFromParent();\n\n if (this.viewer.extents.isEmpty()) return;\n\n const size = this.viewer.extents.getSize(new Vector3()).multiply(this.viewer.camera.up).length();\n const center = this.viewer.extents.getCenter(new Vector3());\n\n const upY = new Vector3(0, 1, 0);\n const up = new Vector3().copy(this.viewer.camera.up);\n\n this.gridHelper.scale.setScalar(size);\n this.gridHelper.position.copy(center);\n this.gridHelper.quaternion.setFromUnitVectors(upY, up);\n\n this.viewer.helpers.add(this.gridHelper);\n };\n}\n\ncomponents.registerComponent(\"GridHelperComponent\", (viewer) => new GridHelperComponent(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,CAAA;AAIvB,IAAA,WAAA,CAAY,MAAc,EAAA;QAiB1B,IAAA,CAAA,UAAU,GAAG,MAAK;AAChB,YAAA,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;AAElC,YAAA,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;gBAAE;AAEnC,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;AAChG,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,C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AC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IAC3C;AAmBD;AAED,UAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"GridHelperComponent.module.js","sources":["../../../extensions/components/GridHelperComponent.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 { GridHelper, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass GridHelperComponent implements IComponent {\n private viewer: Viewer;\n private gridHelper: GridHelper;\n\n constructor(viewer: Viewer) {\n this.gridHelper = new GridHelper(10, 20, 0x444444, 0xaaaaaa);\n this.viewer = viewer;\n this.viewer.on(\"initialize\", this.syncHelper);\n this.viewer.on(\"geometryend\", this.syncHelper);\n this.viewer.on(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.gridHelper.removeFromParent();\n this.gridHelper.dispose();\n\n this.viewer.off(\"initialize\", this.syncHelper);\n this.viewer.off(\"geometryend\", this.syncHelper);\n this.viewer.off(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.gridHelper.removeFromParent();\n\n const extentsSizeUp = this.viewer.extents.getSize(new Vector3()).multiply(this.viewer.camera.up).length() || 1;\n const extentsCenter = this.viewer.extents.getCenter(new Vector3());\n\n const upY = new Vector3(0, 1, 0);\n const up = new Vector3().copy(this.viewer.camera.up);\n\n this.gridHelper.scale.setScalar(extentsSizeUp);\n this.gridHelper.position.copy(extentsCenter);\n this.gridHelper.quaternion.setFromUnitVectors(upY, up);\n\n this.viewer.helpers.add(this.gridHelper);\n };\n}\n\ncomponents.registerComponent(\"GridHelperComponent\", (viewer) => new GridHelperComponent(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,CAAA;AAIvB,IAAA,WAAA,CAAY,MAAc,EAAA;QAiB1B,IAAA,CAAA,UAAU,GAAG,MAAK;AAChB,YAAA,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;AAElC,YAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;AAC9G,YAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,EAAE,CAAC;YAElE,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAChC,YAAA,MAAM,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAEpD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;YAC9C,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;YAC5C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,kBAAkB,CAAC,GAAG,EAAE,EAAE,CAAC;YAEtD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;AAC1C,QAAA,CAAC;AA9BC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC;AAC5D,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IAC1C;IAEA,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;AAClC,QAAA,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;QAEzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC/C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IAC3C;AAiBD;AAED,UAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
@@ -35,16 +35,16 @@
35
35
  helper.dispose();
36
36
  });
37
37
  this.lightHelpers.length = 0;
38
- const extentsSize = this.viewer.extents.getBoundingSphere(new three.Sphere()).radius * 2;
39
- const size = extentsSize / 20;
38
+ const extentsSize = this.viewer.extents.getSize(new three.Vector3()).length() || 1;
39
+ const helperSize = extentsSize / 20;
40
40
  this.viewer.scene.traverse((object) => {
41
41
  let helper;
42
42
  if (object.isDirectionalLight)
43
- helper = new three.DirectionalLightHelper(object, size, "#aa0000");
43
+ helper = new three.DirectionalLightHelper(object, helperSize, "#aa0000");
44
44
  else if (object.isHemisphereLight)
45
- helper = new three.HemisphereLightHelper(object, size, "#ff9800");
45
+ helper = new three.HemisphereLightHelper(object, helperSize, "#ff9800");
46
46
  else if (object.isPointLight)
47
- helper = new three.PointLightHelper(object, size, "#ff9800");
47
+ helper = new three.PointLightHelper(object, helperSize, "#ff9800");
48
48
  if (helper) {
49
49
  this.lightHelpers.push(helper);
50
50
  this.viewer.helpers.add(helper);
@@ -1 +1 @@
1
- {"version":3,"file":"LightHelperComponent.js","sources":["../../../extensions/components/LightHelperComponent.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 { DirectionalLightHelper, HemisphereLightHelper, PointLightHelper, Sphere } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass LightHelperComponent implements IComponent {\n private viewer: Viewer;\n private lightHelpers: (DirectionalLightHelper | HemisphereLightHelper | PointLightHelper)[];\n\n constructor(viewer: Viewer) {\n this.lightHelpers = [];\n this.viewer = viewer;\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;\n const size = extentsSize / 20;\n\n this.viewer.scene.traverse((object: any) => {\n let helper: DirectionalLightHelper | HemisphereLightHelper | PointLightHelper;\n\n if (object.isDirectionalLight) helper = new DirectionalLightHelper(object, size, \"#aa0000\");\n else if (object.isHemisphereLight) helper = new HemisphereLightHelper(object, size, \"#ff9800\");\n else if (object.isPointLight) helper = new PointLightHelper(object, size, \"#ff9800\");\n\n if (helper) {\n this.lightHelpers.push(helper);\n this.viewer.helpers.add(helper);\n }\n });\n };\n}\n\ncomponents.registerComponent(\"LightHelperComponent\", (viewer) => new LightHelperComponent(viewer));\n"],"names":["Sphere","DirectionalLightHelper","HemisphereLightHelper","PointLightHelper","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BA,MAAM,oBAAoB,CAAA;IAIxB,IAAA,WAAA,CAAY,MAAc,EAAA;YAkB1B,IAAA,CAAA,UAAU,GAAG,MAAK;gBAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;oBACnC,MAAM,CAAC,gBAAgB,EAAE;oBACzB,MAAM,CAAC,OAAO,EAAE;IAClB,YAAA,CAAC,CAAC;IACF,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;IAE5B,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAIA,YAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;IAClF,YAAA,MAAM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AI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;QAC3D;IAyBD;AAEDC,0BAAU,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,MAAM,KAAK,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
1
+ {"version":3,"file":"LightHelperComponent.js","sources":["../../../extensions/components/LightHelperComponent.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 { DirectionalLightHelper, HemisphereLightHelper, PointLightHelper, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass LightHelperComponent implements IComponent {\n private viewer: Viewer;\n private lightHelpers: (DirectionalLightHelper | HemisphereLightHelper | PointLightHelper)[];\n\n constructor(viewer: Viewer) {\n this.lightHelpers = [];\n this.viewer = viewer;\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n const extentsSize = this.viewer.extents.getSize(new Vector3()).length() || 1;\n const helperSize = extentsSize / 20;\n\n this.viewer.scene.traverse((object: any) => {\n let helper: DirectionalLightHelper | HemisphereLightHelper | PointLightHelper;\n\n if (object.isDirectionalLight) helper = new DirectionalLightHelper(object, helperSize, \"#aa0000\");\n else if (object.isHemisphereLight) helper = new HemisphereLightHelper(object, helperSize, \"#ff9800\");\n else if (object.isPointLight) helper = new PointLightHelper(object, helperSize, \"#ff9800\");\n\n if (helper) {\n this.lightHelpers.push(helper);\n this.viewer.helpers.add(helper);\n }\n });\n };\n}\n\ncomponents.registerComponent(\"LightHelperComponent\", (viewer) => new LightHelperComponent(viewer));\n"],"names":["Vector3","DirectionalLightHelper","HemisphereLightHelper","PointLightHelper","components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BA,MAAM,oBAAoB,CAAA;IAIxB,IAAA,WAAA,CAAY,MAAc,EAAA;YAkB1B,IAAA,CAAA,UAAU,GAAG,MAAK;gBAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;oBACnC,MAAM,CAAC,gBAAgB,EAAE;oBACzB,MAAM,CAAC,OAAO,EAAE;IAClB,YAAA,CAAC,CAAC;IACF,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;IAE5B,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAIA,aAAO,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5E,YAAA,MAAM,UAAU,GAAG,WAAW,GAAG,EAAE;gBAEnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAW,KAAI;IACzC,gBAAA,IAAI,MAAyE;oBAE7E,IAAI,MAAM,CAAC,kBAAkB;w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,CAAC,MAAM,CAAC,CAAC;;;;;;"}
@@ -21,4 +21,4 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- !function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,i){"use strict";class t{constructor(i){this.syncHelper=()=>{this.lightHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.lightHelpers.length=0;const i=2*this.viewer.extents.getBoundingSphere(new e.Sphere).radius/20;this.viewer.scene.traverse(t=>{let r;t.isDirectionalLight?r=new e.DirectionalLightHelper(t,i,"#aa0000"):t.isHemisphereLight?r=new e.HemisphereLightHelper(t,i,"#ff9800"):t.isPointLight&&(r=new e.PointLightHelper(t,i,"#ff9800")),r&&(this.lightHelpers.push(r),this.viewer.helpers.add(r))})},this.lightHelpers=[],this.viewer=i,this.viewer.addEventListener("geometryend",this.syncHelper),this.viewer.addEventListener("clear",this.syncHelper)}dispose(){this.lightHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.lightHelpers.length=0,this.viewer.removeEventListener("geometryend",this.syncHelper),this.viewer.removeEventListener("clear",this.syncHelper)}}i.components.registerComponent("LightHelperComponent",e=>new t(e))});
24
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("three"),require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["three","@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).THREE,e.ODA.Three)}(this,function(e,t){"use strict";class i{constructor(t){this.syncHelper=()=>{this.lightHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.lightHelpers.length=0;const t=(this.viewer.extents.getSize(new e.Vector3).length()||1)/20;this.viewer.scene.traverse(i=>{let r;i.isDirectionalLight?r=new e.DirectionalLightHelper(i,t,"#aa0000"):i.isHemisphereLight?r=new e.HemisphereLightHelper(i,t,"#ff9800"):i.isPointLight&&(r=new e.PointLightHelper(i,t,"#ff9800")),r&&(this.lightHelpers.push(r),this.viewer.helpers.add(r))})},this.lightHelpers=[],this.viewer=t,this.viewer.addEventListener("geometryend",this.syncHelper),this.viewer.addEventListener("clear",this.syncHelper)}dispose(){this.lightHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.lightHelpers.length=0,this.viewer.removeEventListener("geometryend",this.syncHelper),this.viewer.removeEventListener("clear",this.syncHelper)}}t.components.registerComponent("LightHelperComponent",e=>new i(e))});
@@ -21,7 +21,7 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { Sphere, DirectionalLightHelper, HemisphereLightHelper, PointLightHelper } from 'three';
24
+ import { Vector3, DirectionalLightHelper, HemisphereLightHelper, PointLightHelper } from 'three';
25
25
  import { components } from '@inweb/viewer-three';
26
26
 
27
27
  class LightHelperComponent {
@@ -32,16 +32,16 @@ class LightHelperComponent {
32
32
  helper.dispose();
33
33
  });
34
34
  this.lightHelpers.length = 0;
35
- const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
36
- const size = extentsSize / 20;
35
+ const extentsSize = this.viewer.extents.getSize(new Vector3()).length() || 1;
36
+ const helperSize = extentsSize / 20;
37
37
  this.viewer.scene.traverse((object) => {
38
38
  let helper;
39
39
  if (object.isDirectionalLight)
40
- helper = new DirectionalLightHelper(object, size, "#aa0000");
40
+ helper = new DirectionalLightHelper(object, helperSize, "#aa0000");
41
41
  else if (object.isHemisphereLight)
42
- helper = new HemisphereLightHelper(object, size, "#ff9800");
42
+ helper = new HemisphereLightHelper(object, helperSize, "#ff9800");
43
43
  else if (object.isPointLight)
44
- helper = new PointLightHelper(object, size, "#ff9800");
44
+ helper = new PointLightHelper(object, helperSize, "#ff9800");
45
45
  if (helper) {
46
46
  this.lightHelpers.push(helper);
47
47
  this.viewer.helpers.add(helper);
@@ -1 +1 @@
1
- {"version":3,"file":"LightHelperComponent.module.js","sources":["../../../extensions/components/LightHelperComponent.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 { DirectionalLightHelper, HemisphereLightHelper, PointLightHelper, Sphere } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass LightHelperComponent implements IComponent {\n private viewer: Viewer;\n private lightHelpers: (DirectionalLightHelper | HemisphereLightHelper | PointLightHelper)[];\n\n constructor(viewer: Viewer) {\n this.lightHelpers = [];\n this.viewer = viewer;\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;\n const size = extentsSize / 20;\n\n this.viewer.scene.traverse((object: any) => {\n let helper: DirectionalLightHelper | HemisphereLightHelper | PointLightHelper;\n\n if (object.isDirectionalLight) helper = new DirectionalLightHelper(object, size, \"#aa0000\");\n else if (object.isHemisphereLight) helper = new HemisphereLightHelper(object, size, \"#ff9800\");\n else if (object.isPointLight) helper = new PointLightHelper(object, size, \"#ff9800\");\n\n if (helper) {\n this.lightHelpers.push(helper);\n this.viewer.helpers.add(helper);\n }\n });\n };\n}\n\ncomponents.registerComponent(\"LightHelperComponent\", (viewer) => new LightHelperComponent(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,oBAAoB,CAAA;AAIxB,IAAA,WAAA,CAAY,MAAc,EAAA;QAkB1B,IAAA,CAAA,UAAU,GAAG,MAAK;YAChB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;gBACnC,MAAM,CAAC,gBAAgB,EAAE;gBACzB,MAAM,CAAC,OAAO,EAAE;AAClB,YAAA,CAAC,CAAC;AACF,YAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;AAE5B,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AAClF,YAAA,MAAM,IAAI,GAAG,WAAW,GAAG,EAAE;YAE7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAW,KAAI;AACzC,gBAAA,IAAI,MAAyE;gBAE7E,IAAI,MAAM,CAAC,kBAAkB;oBAAE,MAAM,GAAG,IAAI,sBAAsB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC;qBACtF,IAAI,MAAM,CAAC,iBAAiB;oBAAE,MAAM,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC;qBACzF,IAAI,MAAM,CAAC,YAAY;oBAAE,MAAM,GAAG,IAAI,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC;gBAEpF,IAAI,MAAM,EAAE;AACV,oBAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;oBAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;gBACjC;AACF,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC;AAvCC,QAAA,IAAI,CAAC,YAAY,GAAG,EAAE;AACtB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;QACpB,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IACxD;IAEA,OAAO,GAAA;QACL,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,KAAI;YACnC,MAAM,CAAC,gBAAgB,EAAE;YACzB,MAAM,CAAC,OAAO,EAAE;AAClB,QAAA,CAAC,CAAC;AACF,QAAA,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;QAE5B,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;IAC3D;AAyBD;AAED,UAAU,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,MAAM,KAAK,IAAI,oBAAoB,CAAC,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"LightHelperComponent.module.js","sources":["../../../extensions/components/LightHelperComponent.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 { DirectionalLightHelper, HemisphereLightHelper, PointLightHelper, Vector3 } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass LightHelperComponent implements IComponent {\n private viewer: Viewer;\n private lightHelpers: (DirectionalLightHelper | HemisphereLightHelper | PointLightHelper)[];\n\n constructor(viewer: Viewer) {\n this.lightHelpers = [];\n this.viewer = viewer;\n this.viewer.addEventListener(\"geometryend\", this.syncHelper);\n this.viewer.addEventListener(\"clear\", this.syncHelper);\n }\n\n dispose() {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n this.viewer.removeEventListener(\"geometryend\", this.syncHelper);\n this.viewer.removeEventListener(\"clear\", this.syncHelper);\n }\n\n syncHelper = () => {\n this.lightHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n this.lightHelpers.length = 0;\n\n const extentsSize = this.viewer.extents.getSize(new Vector3()).length() || 1;\n const helperSize = extentsSize / 20;\n\n this.viewer.scene.traverse((object: any) => {\n let helper: DirectionalLightHelper | HemisphereLightHelper | PointLightHelper;\n\n if (object.isDirectionalLight) helper = new DirectionalLightHelper(object, helperSize, \"#aa0000\");\n else if (object.isHemisphereLight) helper = new HemisphereLightHelper(object, helperSize, \"#ff9800\");\n else if (object.isPointLight) helper = new PointLightHelper(object, helperSize, \"#ff9800\");\n\n if (helper) {\n this.lightHelpers.push(helper);\n this.viewer.helpers.add(helper);\n }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