@inweb/viewer-three 26.10.6 → 26.12.0
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.
- package/README.md +7 -4
- package/dist/{plugins → extensions}/components/AxesHelperComponent.js +23 -1
- package/dist/extensions/components/AxesHelperComponent.js.map +1 -0
- package/dist/extensions/components/AxesHelperComponent.min.js +24 -0
- package/dist/{plugins → extensions}/components/AxesHelperComponent.module.js +24 -2
- package/dist/extensions/components/AxesHelperComponent.module.js.map +1 -0
- package/dist/{plugins → extensions}/components/ExtentsHelperComponent.js +18 -0
- package/dist/extensions/components/ExtentsHelperComponent.js.map +1 -0
- package/dist/{plugins/components/AxesHelperComponent.min.js → extensions/components/ExtentsHelperComponent.min.js} +1 -1
- package/dist/{plugins → extensions}/components/ExtentsHelperComponent.module.js +19 -1
- package/dist/extensions/components/ExtentsHelperComponent.module.js.map +1 -0
- package/dist/extensions/components/GridHelperComponent.js.map +1 -0
- package/dist/extensions/components/GridHelperComponent.module.js.map +1 -0
- package/dist/extensions/components/InfoPanelComponent.js +170 -0
- package/dist/extensions/components/InfoPanelComponent.js.map +1 -0
- package/dist/extensions/components/InfoPanelComponent.min.js +24 -0
- package/dist/extensions/components/InfoPanelComponent.module.js +164 -0
- package/dist/extensions/components/InfoPanelComponent.module.js.map +1 -0
- package/dist/extensions/components/LightHelperComponent.js.map +1 -0
- package/dist/extensions/components/LightHelperComponent.module.js.map +1 -0
- package/dist/extensions/components/RoomEnvironmentComponent.js.map +1 -0
- package/dist/extensions/components/RoomEnvironmentComponent.module.js.map +1 -0
- package/dist/{plugins → extensions}/components/StatsPanelComponent.js +9 -3
- package/dist/extensions/components/StatsPanelComponent.js.map +1 -0
- package/dist/extensions/components/StatsPanelComponent.min.js +24 -0
- package/dist/{plugins → extensions}/components/StatsPanelComponent.module.js +9 -3
- package/dist/extensions/components/StatsPanelComponent.module.js.map +1 -0
- package/dist/{plugins → extensions}/loaders/GLTFCloudLoader.js +2 -3
- package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -0
- package/dist/{plugins → extensions}/loaders/GLTFCloudLoader.min.js +1 -1
- package/dist/{plugins → extensions}/loaders/GLTFCloudLoader.module.js +2 -3
- package/dist/extensions/loaders/GLTFCloudLoader.module.js.map +1 -0
- package/dist/extensions/loaders/GLTFFileLoader.js +2499 -0
- package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -0
- package/dist/extensions/loaders/GLTFFileLoader.min.js +24 -0
- package/dist/extensions/loaders/GLTFFileLoader.module.js +74 -0
- package/dist/extensions/loaders/GLTFFileLoader.module.js.map +1 -0
- package/dist/{plugins → extensions}/loaders/IFCXLoader.js +5 -7
- package/dist/extensions/loaders/IFCXLoader.js.map +1 -0
- package/dist/{plugins → extensions}/loaders/IFCXLoader.min.js +1 -1
- package/dist/{plugins → extensions}/loaders/IFCXLoader.module.js +5 -7
- package/dist/extensions/loaders/IFCXLoader.module.js.map +1 -0
- package/dist/{plugins → extensions}/loaders/PotreeLoader.js +56 -6
- package/dist/extensions/loaders/PotreeLoader.js.map +1 -0
- package/dist/extensions/loaders/PotreeLoader.min.js +24 -0
- package/dist/{plugins → extensions}/loaders/PotreeLoader.module.js +53 -2
- package/dist/extensions/loaders/PotreeLoader.module.js.map +1 -0
- package/dist/viewer-three.js +1416 -2930
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +8 -3
- package/dist/viewer-three.module.js +1205 -363
- package/dist/viewer-three.module.js.map +1 -1
- package/{plugins → extensions}/components/AxesHelperComponent.ts +31 -2
- package/{plugins → extensions}/components/ExtentsHelperComponent.ts +25 -0
- package/extensions/components/InfoPanelComponent.ts +197 -0
- package/{plugins → extensions}/components/StatsPanelComponent.ts +10 -3
- package/{plugins → extensions}/loaders/GLTFCloudLoader.ts +2 -3
- package/{src/Viewer → extensions}/loaders/GLTFFileLoader.ts +21 -12
- package/{plugins → extensions}/loaders/IFCX/IFCXCloudLoader.ts +5 -5
- package/{plugins → extensions}/loaders/IFCX/IFCXFileLoader.ts +3 -4
- package/{plugins → extensions}/loaders/Potree/PotreeFileLoader.ts +3 -4
- package/extensions/loaders/Potree/PotreeModelImpl.ts +108 -0
- package/lib/Viewer/Viewer.d.ts +28 -20
- package/lib/Viewer/commands/GetSelected2.d.ts +2 -0
- package/lib/Viewer/commands/SelectModel.d.ts +1 -1
- package/lib/Viewer/commands/SetSelected2.d.ts +2 -0
- package/lib/Viewer/components/InfoComponent.d.ts +22 -0
- package/lib/Viewer/components/SelectionComponent.d.ts +1 -3
- package/lib/Viewer/components/index.d.ts +6 -6
- package/lib/Viewer/draggers/MeasureLineDragger.d.ts +7 -1
- package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +2 -1
- package/lib/Viewer/loaders/GLTFBinaryExtension.d.ts +5 -0
- package/lib/Viewer/loaders/GLTFCloudDynamicLoader.d.ts +2 -2
- package/lib/Viewer/loaders/{GLTFFileLoader.d.ts → GLTFFileDynamicLoader.d.ts} +7 -1
- package/lib/Viewer/loaders/GLTFLoadingManager.d.ts +4 -3
- package/lib/Viewer/loaders/RangesLoader.d.ts +15 -0
- package/lib/Viewer/loaders/index.d.ts +22 -14
- package/lib/Viewer/measurement/Snapper.d.ts +15 -0
- package/lib/Viewer/measurement/UnitConverter.d.ts +63 -0
- package/lib/Viewer/measurement/UnitFormatter.d.ts +4 -0
- package/lib/Viewer/models/IModelImpl.d.ts +11 -8
- package/lib/Viewer/models/ModelImpl.d.ts +9 -5
- package/package.json +11 -11
- package/src/Viewer/Viewer.ts +127 -88
- package/src/Viewer/commands/ClearSelected.ts +3 -1
- package/src/Viewer/commands/GetModels.ts +1 -1
- package/src/Viewer/commands/GetSelected.ts +2 -2
- package/{plugins/loaders/Potree/PotreeModelImpl.ts → src/Viewer/commands/GetSelected2.ts} +7 -9
- package/src/Viewer/commands/HideSelected.ts +3 -1
- package/src/Viewer/commands/SelectModel.ts +5 -5
- package/src/Viewer/commands/SetSelected.ts +9 -10
- package/src/Viewer/commands/SetSelected2.ts +42 -0
- package/src/Viewer/commands/ZoomToObjects.ts +5 -6
- package/src/Viewer/commands/ZoomToSelected.ts +3 -1
- package/src/Viewer/commands/index.ts +4 -0
- package/src/Viewer/components/CameraComponent.ts +6 -1
- package/src/Viewer/components/ExtentsComponent.ts +4 -1
- package/src/Viewer/components/InfoComponent.ts +187 -0
- package/src/Viewer/components/SelectionComponent.ts +7 -30
- package/src/Viewer/components/index.ts +8 -6
- package/src/Viewer/draggers/MeasureLineDragger.ts +84 -226
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +276 -39
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +45 -10
- package/src/Viewer/loaders/DynamicGltfLoader/GltfStructure.js +71 -2
- package/src/Viewer/loaders/GLTFBinaryExtension.ts +91 -0
- package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +13 -19
- package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +145 -0
- package/src/Viewer/loaders/GLTFLoadingManager.ts +5 -4
- package/src/Viewer/loaders/RangesLoader.ts +105 -0
- package/src/Viewer/loaders/index.ts +24 -16
- package/src/Viewer/measurement/Snapper.ts +208 -0
- package/src/Viewer/measurement/UnitConverter.ts +47 -0
- package/src/Viewer/measurement/UnitFormatter.ts +95 -0
- package/src/Viewer/models/IModelImpl.ts +17 -8
- package/src/Viewer/models/ModelImpl.ts +205 -16
- package/src/index-umd.ts +1 -1
- package/dist/plugins/components/AxesHelperComponent.js.map +0 -1
- package/dist/plugins/components/AxesHelperComponent.module.js.map +0 -1
- package/dist/plugins/components/ExtentsHelperComponent.js.map +0 -1
- package/dist/plugins/components/ExtentsHelperComponent.min.js +0 -24
- package/dist/plugins/components/ExtentsHelperComponent.module.js.map +0 -1
- package/dist/plugins/components/GridHelperComponent.js.map +0 -1
- package/dist/plugins/components/GridHelperComponent.module.js.map +0 -1
- package/dist/plugins/components/LightHelperComponent.js.map +0 -1
- package/dist/plugins/components/LightHelperComponent.module.js.map +0 -1
- package/dist/plugins/components/RoomEnvironmentComponent.js.map +0 -1
- package/dist/plugins/components/RoomEnvironmentComponent.module.js.map +0 -1
- package/dist/plugins/components/StatsPanelComponent.js.map +0 -1
- package/dist/plugins/components/StatsPanelComponent.min.js +0 -24
- package/dist/plugins/components/StatsPanelComponent.module.js.map +0 -1
- package/dist/plugins/loaders/GLTFCloudLoader.js.map +0 -1
- package/dist/plugins/loaders/GLTFCloudLoader.module.js.map +0 -1
- package/dist/plugins/loaders/IFCXLoader.js.map +0 -1
- package/dist/plugins/loaders/IFCXLoader.module.js.map +0 -1
- package/dist/plugins/loaders/PotreeLoader.js.map +0 -1
- package/dist/plugins/loaders/PotreeLoader.min.js +0 -24
- package/dist/plugins/loaders/PotreeLoader.module.js.map +0 -1
- /package/dist/{plugins → extensions}/components/GridHelperComponent.js +0 -0
- /package/dist/{plugins → extensions}/components/GridHelperComponent.min.js +0 -0
- /package/dist/{plugins → extensions}/components/GridHelperComponent.module.js +0 -0
- /package/dist/{plugins → extensions}/components/LightHelperComponent.js +0 -0
- /package/dist/{plugins → extensions}/components/LightHelperComponent.min.js +0 -0
- /package/dist/{plugins → extensions}/components/LightHelperComponent.module.js +0 -0
- /package/dist/{plugins → extensions}/components/RoomEnvironmentComponent.js +0 -0
- /package/dist/{plugins → extensions}/components/RoomEnvironmentComponent.min.js +0 -0
- /package/dist/{plugins → extensions}/components/RoomEnvironmentComponent.module.js +0 -0
- /package/{plugins → extensions}/components/GridHelperComponent.ts +0 -0
- /package/{plugins → extensions}/components/LightHelperComponent.ts +0 -0
- /package/{plugins → extensions}/components/RoomEnvironmentComponent.ts +0 -0
- /package/{plugins → extensions}/loaders/IFCX/IFCXLoader.ts +0 -0
- /package/{plugins → extensions}/loaders/IFCX/index.ts +0 -0
- /package/{plugins → extensions}/loaders/IFCX/render.js +0 -0
- /package/{plugins → extensions}/loaders/Potree/index.ts +0 -0
package/README.md
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
Core capabilities:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- Rendering CAD/BIM files from [Open Cloud Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server), web, or local files
|
|
8
|
+
- Interactive scene navigation (Orbit, Pan, Zoom, Walk, Fly modes)
|
|
9
|
+
- Model selection and highlighting
|
|
10
|
+
- Cutting planes and slicing
|
|
11
|
+
- Markups and measurements
|
|
12
|
+
- Viewpoint management
|
|
13
|
+
- Extension system for extending functionality
|
|
11
14
|
|
|
12
15
|
This library is a part of [CDE SDK](https://www.opendesign.com/products/cde) by [Open Design Alliance](https://opendesign.com).
|
|
13
16
|
|
|
@@ -30,25 +30,47 @@
|
|
|
30
30
|
class AxesHelperComponent {
|
|
31
31
|
constructor(viewer) {
|
|
32
32
|
this.syncHelper = () => {
|
|
33
|
+
this.modelHelpers.forEach((helper) => {
|
|
34
|
+
helper.removeFromParent();
|
|
35
|
+
helper.dispose();
|
|
36
|
+
});
|
|
37
|
+
this.modelHelpers.length = 0;
|
|
33
38
|
this.axesHelper1.removeFromParent();
|
|
34
39
|
this.axesHelper2.removeFromParent();
|
|
35
40
|
const size = this.viewer.extents.getSize(new three.Vector3()).length();
|
|
36
41
|
const center = this.viewer.extents.getCenter(new three.Vector3());
|
|
37
42
|
this.axesHelper1.position.set(0, 0, 0);
|
|
38
|
-
this.axesHelper1.scale.setScalar(size);
|
|
43
|
+
this.axesHelper1.scale.setScalar(size * 1.25);
|
|
39
44
|
this.axesHelper2.position.copy(center);
|
|
40
45
|
this.axesHelper2.scale.setScalar(size);
|
|
41
46
|
this.viewer.helpers.add(this.axesHelper1);
|
|
42
47
|
this.viewer.helpers.add(this.axesHelper2);
|
|
48
|
+
if (this.viewer.models.length < 2)
|
|
49
|
+
return;
|
|
50
|
+
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);
|
|
56
|
+
this.modelHelpers.push(helper);
|
|
57
|
+
this.viewer.helpers.add(helper);
|
|
58
|
+
});
|
|
43
59
|
};
|
|
44
60
|
this.axesHelper1 = new three.AxesHelper(1);
|
|
45
61
|
this.axesHelper2 = new three.AxesHelper(1);
|
|
62
|
+
this.modelHelpers = [];
|
|
63
|
+
this.axesHelper1.setColors("#ccc", "#ccc", "#ccc");
|
|
46
64
|
this.viewer = viewer;
|
|
47
65
|
this.viewer.addEventListener("initialize", this.syncHelper);
|
|
48
66
|
this.viewer.addEventListener("geometryend", this.syncHelper);
|
|
49
67
|
this.viewer.addEventListener("clear", this.syncHelper);
|
|
50
68
|
}
|
|
51
69
|
dispose() {
|
|
70
|
+
this.modelHelpers.forEach((helper) => {
|
|
71
|
+
helper.removeFromParent();
|
|
72
|
+
helper.dispose();
|
|
73
|
+
});
|
|
52
74
|
this.axesHelper1.removeFromParent();
|
|
53
75
|
this.axesHelper1.dispose();
|
|
54
76
|
this.axesHelper2.removeFromParent();
|
|
@@ -0,0 +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) => 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,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAIA,aAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IAChE,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAIA,aAAO,EAAE,CAAC;IAE3D,YAAA,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC;gBAE7C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;gBACtC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;gBAEtC,IAAI,CA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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;IAsCD;AAEDC,0BAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
!function(e,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))});
|
|
@@ -21,31 +21,53 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { Vector3, AxesHelper } from 'three';
|
|
24
|
+
import { Vector3, Box3, AxesHelper } from 'three';
|
|
25
25
|
import { components } from '@inweb/viewer-three';
|
|
26
26
|
|
|
27
27
|
class AxesHelperComponent {
|
|
28
28
|
constructor(viewer) {
|
|
29
29
|
this.syncHelper = () => {
|
|
30
|
+
this.modelHelpers.forEach((helper) => {
|
|
31
|
+
helper.removeFromParent();
|
|
32
|
+
helper.dispose();
|
|
33
|
+
});
|
|
34
|
+
this.modelHelpers.length = 0;
|
|
30
35
|
this.axesHelper1.removeFromParent();
|
|
31
36
|
this.axesHelper2.removeFromParent();
|
|
32
37
|
const size = this.viewer.extents.getSize(new Vector3()).length();
|
|
33
38
|
const center = this.viewer.extents.getCenter(new Vector3());
|
|
34
39
|
this.axesHelper1.position.set(0, 0, 0);
|
|
35
|
-
this.axesHelper1.scale.setScalar(size);
|
|
40
|
+
this.axesHelper1.scale.setScalar(size * 1.25);
|
|
36
41
|
this.axesHelper2.position.copy(center);
|
|
37
42
|
this.axesHelper2.scale.setScalar(size);
|
|
38
43
|
this.viewer.helpers.add(this.axesHelper1);
|
|
39
44
|
this.viewer.helpers.add(this.axesHelper2);
|
|
45
|
+
if (this.viewer.models.length < 2)
|
|
46
|
+
return;
|
|
47
|
+
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);
|
|
53
|
+
this.modelHelpers.push(helper);
|
|
54
|
+
this.viewer.helpers.add(helper);
|
|
55
|
+
});
|
|
40
56
|
};
|
|
41
57
|
this.axesHelper1 = new AxesHelper(1);
|
|
42
58
|
this.axesHelper2 = new AxesHelper(1);
|
|
59
|
+
this.modelHelpers = [];
|
|
60
|
+
this.axesHelper1.setColors("#ccc", "#ccc", "#ccc");
|
|
43
61
|
this.viewer = viewer;
|
|
44
62
|
this.viewer.addEventListener("initialize", this.syncHelper);
|
|
45
63
|
this.viewer.addEventListener("geometryend", this.syncHelper);
|
|
46
64
|
this.viewer.addEventListener("clear", this.syncHelper);
|
|
47
65
|
}
|
|
48
66
|
dispose() {
|
|
67
|
+
this.modelHelpers.forEach((helper) => {
|
|
68
|
+
helper.removeFromParent();
|
|
69
|
+
helper.dispose();
|
|
70
|
+
});
|
|
49
71
|
this.axesHelper1.removeFromParent();
|
|
50
72
|
this.axesHelper1.dispose();
|
|
51
73
|
this.axesHelper2.removeFromParent();
|
|
@@ -0,0 +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,CAA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AAgB,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;AAsCD;AAED,UAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -30,13 +30,27 @@
|
|
|
30
30
|
class ExtentsHelperComponent {
|
|
31
31
|
constructor(viewer) {
|
|
32
32
|
this.syncHelper = () => {
|
|
33
|
+
this.modelHelpers.forEach((helper) => {
|
|
34
|
+
helper.removeFromParent();
|
|
35
|
+
helper.dispose();
|
|
36
|
+
});
|
|
37
|
+
this.modelHelpers.length = 0;
|
|
33
38
|
this.boxHelper.removeFromParent();
|
|
34
39
|
if (this.viewer.extents.isEmpty())
|
|
35
40
|
return;
|
|
36
41
|
this.boxHelper.box = this.viewer.extents.clone();
|
|
37
42
|
this.viewer.helpers.add(this.boxHelper);
|
|
43
|
+
if (this.viewer.models.length < 2)
|
|
44
|
+
return;
|
|
45
|
+
this.viewer.models.forEach((model) => {
|
|
46
|
+
const extents = model.getExtents(new three.Box3());
|
|
47
|
+
const helper = new three.Box3Helper(extents, "#ff0000");
|
|
48
|
+
this.modelHelpers.push(helper);
|
|
49
|
+
this.viewer.helpers.add(helper);
|
|
50
|
+
});
|
|
38
51
|
};
|
|
39
52
|
this.boxHelper = new three.Box3Helper(new three.Box3(), "#ff0000");
|
|
53
|
+
this.modelHelpers = [];
|
|
40
54
|
this.viewer = viewer;
|
|
41
55
|
this.viewer.on("geometryend", this.syncHelper);
|
|
42
56
|
this.viewer.on("clear", this.syncHelper);
|
|
@@ -47,6 +61,10 @@
|
|
|
47
61
|
this.viewer.on("showall", this.syncHelper);
|
|
48
62
|
}
|
|
49
63
|
dispose() {
|
|
64
|
+
this.modelHelpers.forEach((helper) => {
|
|
65
|
+
helper.removeFromParent();
|
|
66
|
+
helper.dispose();
|
|
67
|
+
});
|
|
50
68
|
this.boxHelper.removeFromParent();
|
|
51
69
|
this.boxHelper.dispose();
|
|
52
70
|
this.viewer.off("geometryend", this.syncHelper);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtentsHelperComponent.js","sources":["../../../extensions/components/ExtentsHelperComponent.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, Box3Helper } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass ExtentsHelperComponent implements IComponent {\n private viewer: Viewer;\n private boxHelper: Box3Helper;\n private modelHelpers: Box3Helper[];\n\n constructor(viewer: Viewer) {\n this.boxHelper = new Box3Helper(new Box3(), \"#ff0000\");\n this.modelHelpers = [];\n\n this.viewer = viewer;\n this.viewer.on(\"geometryend\", this.syncHelper);\n this.viewer.on(\"clear\", this.syncHelper);\n this.viewer.on(\"explode\", this.syncHelper);\n this.viewer.on(\"hide\", this.syncHelper);\n this.viewer.on(\"isolate\", this.syncHelper);\n this.viewer.on(\"show\", this.syncHelper);\n this.viewer.on(\"showall\", this.syncHelper);\n }\n\n dispose() {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n\n this.boxHelper.removeFromParent();\n this.boxHelper.dispose();\n\n this.viewer.off(\"geometryend\", this.syncHelper);\n this.viewer.off(\"clear\", this.syncHelper);\n this.viewer.off(\"explode\", this.syncHelper);\n this.viewer.off(\"hide\", this.syncHelper);\n this.viewer.off(\"isolate\", this.syncHelper);\n this.viewer.off(\"show\", this.syncHelper);\n this.viewer.off(\"showall\", 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.boxHelper.removeFromParent();\n\n if (this.viewer.extents.isEmpty()) return;\n\n this.boxHelper.box = this.viewer.extents.clone();\n this.viewer.helpers.add(this.boxHelper);\n\n if (this.viewer.models.length < 2) return;\n\n this.viewer.models.forEach((model) => {\n const extents = model.getExtents(new Box3());\n\n const helper = new Box3Helper(extents, \"#ff0000\");\n\n this.modelHelpers.push(helper);\n this.viewer.helpers.add(helper);\n });\n };\n}\n\ncomponents.registerCompon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GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC;QAC7C;IA2BD;AAEDE,0BAAU,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,CAAC,MAAM,KAAK,IAAI,sBAAsB,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
|
|
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 i{constructor(s){this.syncHelper=()=>{this.modelHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.modelHelpers.length=0,this.boxHelper.removeFromParent(),this.viewer.extents.isEmpty()||(this.boxHelper.box=this.viewer.extents.clone(),this.viewer.helpers.add(this.boxHelper),this.viewer.models.length<2||this.viewer.models.forEach(s=>{const i=s.getExtents(new e.Box3),t=new e.Box3Helper(i,"#ff0000");this.modelHelpers.push(t),this.viewer.helpers.add(t)}))},this.boxHelper=new e.Box3Helper(new e.Box3,"#ff0000"),this.modelHelpers=[],this.viewer=s,this.viewer.on("geometryend",this.syncHelper),this.viewer.on("clear",this.syncHelper),this.viewer.on("explode",this.syncHelper),this.viewer.on("hide",this.syncHelper),this.viewer.on("isolate",this.syncHelper),this.viewer.on("show",this.syncHelper),this.viewer.on("showall",this.syncHelper)}dispose(){this.modelHelpers.forEach(e=>{e.removeFromParent(),e.dispose()}),this.boxHelper.removeFromParent(),this.boxHelper.dispose(),this.viewer.off("geometryend",this.syncHelper),this.viewer.off("clear",this.syncHelper),this.viewer.off("explode",this.syncHelper),this.viewer.off("hide",this.syncHelper),this.viewer.off("isolate",this.syncHelper),this.viewer.off("show",this.syncHelper),this.viewer.off("showall",this.syncHelper)}}s.components.registerComponent("ExtentsHelperComponent",e=>new i(e))});
|
|
@@ -21,19 +21,33 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import { Box3, Box3Helper } from 'three';
|
|
25
25
|
import { components } from '@inweb/viewer-three';
|
|
26
26
|
|
|
27
27
|
class ExtentsHelperComponent {
|
|
28
28
|
constructor(viewer) {
|
|
29
29
|
this.syncHelper = () => {
|
|
30
|
+
this.modelHelpers.forEach((helper) => {
|
|
31
|
+
helper.removeFromParent();
|
|
32
|
+
helper.dispose();
|
|
33
|
+
});
|
|
34
|
+
this.modelHelpers.length = 0;
|
|
30
35
|
this.boxHelper.removeFromParent();
|
|
31
36
|
if (this.viewer.extents.isEmpty())
|
|
32
37
|
return;
|
|
33
38
|
this.boxHelper.box = this.viewer.extents.clone();
|
|
34
39
|
this.viewer.helpers.add(this.boxHelper);
|
|
40
|
+
if (this.viewer.models.length < 2)
|
|
41
|
+
return;
|
|
42
|
+
this.viewer.models.forEach((model) => {
|
|
43
|
+
const extents = model.getExtents(new Box3());
|
|
44
|
+
const helper = new Box3Helper(extents, "#ff0000");
|
|
45
|
+
this.modelHelpers.push(helper);
|
|
46
|
+
this.viewer.helpers.add(helper);
|
|
47
|
+
});
|
|
35
48
|
};
|
|
36
49
|
this.boxHelper = new Box3Helper(new Box3(), "#ff0000");
|
|
50
|
+
this.modelHelpers = [];
|
|
37
51
|
this.viewer = viewer;
|
|
38
52
|
this.viewer.on("geometryend", this.syncHelper);
|
|
39
53
|
this.viewer.on("clear", this.syncHelper);
|
|
@@ -44,6 +58,10 @@ class ExtentsHelperComponent {
|
|
|
44
58
|
this.viewer.on("showall", this.syncHelper);
|
|
45
59
|
}
|
|
46
60
|
dispose() {
|
|
61
|
+
this.modelHelpers.forEach((helper) => {
|
|
62
|
+
helper.removeFromParent();
|
|
63
|
+
helper.dispose();
|
|
64
|
+
});
|
|
47
65
|
this.boxHelper.removeFromParent();
|
|
48
66
|
this.boxHelper.dispose();
|
|
49
67
|
this.viewer.off("geometryend", this.syncHelper);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtentsHelperComponent.module.js","sources":["../../../extensions/components/ExtentsHelperComponent.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, Box3Helper } from \"three\";\nimport { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nclass ExtentsHelperComponent implements IComponent {\n private viewer: Viewer;\n private boxHelper: Box3Helper;\n private modelHelpers: Box3Helper[];\n\n constructor(viewer: Viewer) {\n this.boxHelper = new Box3Helper(new Box3(), \"#ff0000\");\n this.modelHelpers = [];\n\n this.viewer = viewer;\n this.viewer.on(\"geometryend\", this.syncHelper);\n this.viewer.on(\"clear\", this.syncHelper);\n this.viewer.on(\"explode\", this.syncHelper);\n this.viewer.on(\"hide\", this.syncHelper);\n this.viewer.on(\"isolate\", this.syncHelper);\n this.viewer.on(\"show\", this.syncHelper);\n this.viewer.on(\"showall\", this.syncHelper);\n }\n\n dispose() {\n this.modelHelpers.forEach((helper) => {\n helper.removeFromParent();\n helper.dispose();\n });\n\n this.boxHelper.removeFromParent();\n this.boxHelper.dispose();\n\n this.viewer.off(\"geometryend\", this.syncHelper);\n this.viewer.off(\"clear\", this.syncHelper);\n this.viewer.off(\"explode\", this.syncHelper);\n this.viewer.off(\"hide\", this.syncHelper);\n this.viewer.off(\"isolate\", this.syncHelper);\n this.viewer.off(\"show\", this.syncHelper);\n this.viewer.off(\"showall\", 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.boxHelper.removeFromParent();\n\n if (this.viewer.extents.isEmpty()) return;\n\n this.boxHelper.box = this.viewer.extents.clone();\n this.viewer.helpers.add(this.boxHelper);\n\n if (this.viewer.models.length < 2) return;\n\n this.viewer.models.forEach((model) => {\n const extents = model.getExtents(new Box3());\n\n const helper = new Box3Helper(extents, \"#ff0000\");\n\n this.modelHelpers.push(helper);\n this.viewer.helpers.add(helper);\n });\n };\n}\n\ncomponents.registerComponent(\"ExtentsHelperComponent\", (viewer) => new ExtentsHelperComponent(viewer));\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,sBAAsB,CAAA;AAK1B,IAAA,WAAA,CAAY,MAAc,EAAA;QAgC1B,IAAA,CAAA,UAAU,GAAG,MAAK;YAChB,IAAI,CAAC,YAAY,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AE,IAAI,CAAC,UAAU,CAAC;IAC7C;AA2BD;AAED,UAAU,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,CAAC,MAAM,KAAK,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +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,GAAG,IAAIA,aAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;gBAEpD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC;gBACrC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;gBACrC,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;IAhCC,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;IAmBD;AAEDC,0BAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
|
|
@@ -0,0 +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\", (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M,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;AAmBD;AAED,UAAU,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,CAAC,MAAM,KAAK,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
(function (global, factory) {
|
|
25
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('@inweb/viewer-three')) :
|
|
26
|
+
typeof define === 'function' && define.amd ? define(['@inweb/viewer-three'], factory) :
|
|
27
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ODA.Three));
|
|
28
|
+
})(this, (function (viewerThree) { 'use strict';
|
|
29
|
+
|
|
30
|
+
const map = {
|
|
31
|
+
B: 1,
|
|
32
|
+
KB: 1 << 10,
|
|
33
|
+
MB: 1 << 20,
|
|
34
|
+
GB: 1 << 30,
|
|
35
|
+
};
|
|
36
|
+
function formatBytes(bytes) {
|
|
37
|
+
if (!bytes)
|
|
38
|
+
return "-";
|
|
39
|
+
let unit;
|
|
40
|
+
if (bytes >= map.GB)
|
|
41
|
+
unit = "GB";
|
|
42
|
+
else if (bytes >= map.MB)
|
|
43
|
+
unit = "MB";
|
|
44
|
+
else if (bytes >= map.KB)
|
|
45
|
+
unit = "KB";
|
|
46
|
+
else
|
|
47
|
+
unit = "B";
|
|
48
|
+
const value = bytes / map[unit];
|
|
49
|
+
return value.toFixed() + " " + unit;
|
|
50
|
+
}
|
|
51
|
+
class Panel {
|
|
52
|
+
constructor(label) {
|
|
53
|
+
this.dom = document.createElement("div");
|
|
54
|
+
this.label = document.createElement("div");
|
|
55
|
+
this.label.style.padding = "0.25rem 0";
|
|
56
|
+
this.label.style.fontWeight = "600";
|
|
57
|
+
this.label.innerText = label;
|
|
58
|
+
this.dom.appendChild(this.label);
|
|
59
|
+
this.text = document.createElement("small");
|
|
60
|
+
this.text.style.display = "block";
|
|
61
|
+
this.text.style.padding = "0 0.5rem";
|
|
62
|
+
this.dom.appendChild(this.text);
|
|
63
|
+
}
|
|
64
|
+
update(text) {
|
|
65
|
+
if (this.text.innerText !== text)
|
|
66
|
+
this.text.innerText = text;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
class InfoPanelComponent {
|
|
70
|
+
constructor(viewer) {
|
|
71
|
+
this.updatePreformanceInfo = () => {
|
|
72
|
+
const info = this.viewer.info;
|
|
73
|
+
const text = [];
|
|
74
|
+
text.push(`FPS: ${info.performance.fps}`);
|
|
75
|
+
text.push(`Frame Time: ${info.performance.frameTime} ms`);
|
|
76
|
+
this.performancePanel.update(text.join("\n"));
|
|
77
|
+
this.viewer.update();
|
|
78
|
+
};
|
|
79
|
+
this.updateRenderInfo = () => {
|
|
80
|
+
const info = this.viewer.info;
|
|
81
|
+
const text = [];
|
|
82
|
+
text.push(`Viewport: ${info.render.viewport.width} x ${info.render.viewport.height}`);
|
|
83
|
+
text.push(`Antialiasing: ${info.render.antialiasing}`);
|
|
84
|
+
text.push(`Draw Calls: ${info.render.drawCalls}`);
|
|
85
|
+
text.push(`Triangles: ${info.render.triangles}`);
|
|
86
|
+
text.push(`Points: ${info.render.points}`);
|
|
87
|
+
text.push(`Lines: ${info.render.lines}`);
|
|
88
|
+
this.renderPanel.update(text.join("\n"));
|
|
89
|
+
};
|
|
90
|
+
this.updateSceneInfo = () => {
|
|
91
|
+
const info = this.viewer.info;
|
|
92
|
+
const text = [];
|
|
93
|
+
text.push(`Objects: ${info.optimizedScene.objects}`);
|
|
94
|
+
text.push(`Triangles: ${info.optimizedScene.triangles}`);
|
|
95
|
+
text.push(`Points: ${info.optimizedScene.points}`);
|
|
96
|
+
text.push(`Lines: ${info.optimizedScene.lines}`);
|
|
97
|
+
text.push(`Edges: ${info.optimizedScene.edges}`);
|
|
98
|
+
this.optimizedPanel.update(text.join("\n"));
|
|
99
|
+
text.length = 0;
|
|
100
|
+
text.push(`Objects: ${info.scene.objects}`);
|
|
101
|
+
text.push(`Triangles: ${info.scene.triangles}`);
|
|
102
|
+
text.push(`Points: ${info.scene.points}`);
|
|
103
|
+
text.push(`Lines: ${info.scene.lines}`);
|
|
104
|
+
text.push(`Edges: ${info.scene.edges}`);
|
|
105
|
+
this.scenePanel.update(text.join("\n"));
|
|
106
|
+
text.length = 0;
|
|
107
|
+
text.push(`Geometries: ${info.memory.geometries}`);
|
|
108
|
+
text.push(`Textures: ${info.memory.textures}`);
|
|
109
|
+
text.push(`Materials: ${info.memory.materials}`);
|
|
110
|
+
text.push(`GPU Used: ${formatBytes(info.memory.totalEstimatedGpuBytes)}`);
|
|
111
|
+
text.push(`JS Heap Used: ${formatBytes(info.memory.usedJSHeapSize)}`);
|
|
112
|
+
this.memoryPanel.update(text.join("\n"));
|
|
113
|
+
};
|
|
114
|
+
this.container = document.createElement("div");
|
|
115
|
+
this.container.id = "info-container";
|
|
116
|
+
this.container.style.position = "absolute";
|
|
117
|
+
this.container.style.left = "0px";
|
|
118
|
+
this.container.style.top = "0px";
|
|
119
|
+
this.container.style.maxHeight = "100%";
|
|
120
|
+
this.container.style.overflow = "auto";
|
|
121
|
+
this.container.style.padding = "1rem";
|
|
122
|
+
this.setTheme("dark");
|
|
123
|
+
this.performancePanel = new Panel("Performance");
|
|
124
|
+
this.renderPanel = new Panel("Render");
|
|
125
|
+
this.optimizedPanel = new Panel("Optimized Scene");
|
|
126
|
+
this.scenePanel = new Panel("Scene");
|
|
127
|
+
this.memoryPanel = new Panel("Memory");
|
|
128
|
+
this.container.appendChild(this.performancePanel.dom);
|
|
129
|
+
this.container.appendChild(this.renderPanel.dom);
|
|
130
|
+
this.container.appendChild(this.optimizedPanel.dom);
|
|
131
|
+
this.container.appendChild(this.scenePanel.dom);
|
|
132
|
+
this.container.appendChild(this.memoryPanel.dom);
|
|
133
|
+
viewer.canvas.parentElement.appendChild(this.container);
|
|
134
|
+
this.viewer = viewer;
|
|
135
|
+
this.viewer.addEventListener("clear", this.updateSceneInfo);
|
|
136
|
+
this.viewer.addEventListener("geometryend", this.updateSceneInfo);
|
|
137
|
+
this.viewer.addEventListener("render", this.updateRenderInfo);
|
|
138
|
+
this.viewer.addEventListener("animate", this.updatePreformanceInfo);
|
|
139
|
+
this.updatePreformanceInfo();
|
|
140
|
+
this.updateRenderInfo();
|
|
141
|
+
this.updateSceneInfo();
|
|
142
|
+
}
|
|
143
|
+
dispose() {
|
|
144
|
+
this.viewer.removeEventListener("clear", this.updateSceneInfo);
|
|
145
|
+
this.viewer.removeEventListener("geometryend", this.updateSceneInfo);
|
|
146
|
+
this.viewer.removeEventListener("render", this.updateRenderInfo);
|
|
147
|
+
this.viewer.removeEventListener("animate", this.updatePreformanceInfo);
|
|
148
|
+
this.performancePanel = undefined;
|
|
149
|
+
this.renderPanel = undefined;
|
|
150
|
+
this.optimizedPanel = undefined;
|
|
151
|
+
this.scenePanel = undefined;
|
|
152
|
+
this.memoryPanel = undefined;
|
|
153
|
+
this.container.remove();
|
|
154
|
+
this.container = undefined;
|
|
155
|
+
}
|
|
156
|
+
setTheme(value) {
|
|
157
|
+
if (value === "light") {
|
|
158
|
+
this.container.style.background = "rgba(0, 0, 0, 0.025)";
|
|
159
|
+
this.container.style.color = "#3d3d3d";
|
|
160
|
+
}
|
|
161
|
+
if (value === "dark") {
|
|
162
|
+
this.container.style.background = "rgba(0, 0, 0, 0.88)";
|
|
163
|
+
this.container.style.color = "#ebebeb";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
viewerThree.components.registerComponent("InfoPanelComponent", (viewer) => new InfoPanelComponent(viewer));
|
|
168
|
+
|
|
169
|
+
}));
|
|
170
|
+
//# sourceMappingURL=InfoPanelComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoPanelComponent.js","sources":["../../../extensions/components/InfoPanelComponent.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 { IComponent, components, Viewer } from \"@inweb/viewer-three\";\n\nconst map = {\n B: 1,\n KB: 1 << 10,\n MB: 1 << 20,\n GB: 1 << 30,\n};\n\nfunction formatBytes(bytes: number): string {\n if (!bytes) return \"-\";\n\n let unit: string;\n if (bytes >= map.GB) unit = \"GB\";\n else if (bytes >= map.MB) unit = \"MB\";\n else if (bytes >= map.KB) unit = \"KB\";\n else unit = \"B\";\n\n const value = bytes / map[unit];\n return value.toFixed() + \" \" + unit;\n}\n\nclass Panel {\n public dom: HTMLElement;\n private label: HTMLElement;\n private text: HTMLElement;\n\n constructor(label: string) {\n this.dom = document.createElement(\"div\");\n\n this.label = document.createElement(\"div\");\n this.label.style.padding = \"0.25rem 0\";\n this.label.style.fontWeight = \"600\";\n this.label.innerText = label;\n this.dom.appendChild(this.label);\n\n this.text = document.createElement(\"small\");\n this.text.style.display = \"block\";\n this.text.style.padding = \"0 0.5rem\";\n this.dom.appendChild(this.text);\n }\n\n update(text: string) {\n if (this.text.innerText !== text) this.text.innerText = text;\n }\n}\n\nclass InfoPanelComponent implements IComponent {\n private viewer: Viewer;\n private container: HTMLElement;\n private performancePanel: Panel;\n private renderPanel: Panel;\n private optimizedPanel: Panel;\n private scenePanel: Panel;\n private memoryPanel: Panel;\n\n constructor(viewer: Viewer) {\n this.container = document.createElement(\"div\");\n this.container.id = \"info-container\";\n this.container.style.position = \"absolute\";\n this.container.style.left = \"0px\";\n this.container.style.top = \"0px\";\n this.container.style.maxHeight = \"100%\";\n this.container.style.overflow = \"auto\";\n this.container.style.padding = \"1rem\";\n\n this.setTheme(\"dark\");\n\n this.performancePanel = new Panel(\"Performance\");\n this.renderPanel = new Panel(\"Render\");\n this.optimizedPanel = new Panel(\"Optimized Scene\");\n this.scenePanel = new Panel(\"Scene\");\n this.memoryPanel = new Panel(\"Memory\");\n\n this.container.appendChild(this.performancePanel.dom);\n this.container.appendChild(this.renderPanel.dom);\n this.container.appendChild(this.optimizedPanel.dom);\n this.container.appendChild(this.scenePanel.dom);\n this.container.appendChild(this.memoryPanel.dom);\n\n viewer.canvas.parentElement.appendChild(this.container);\n\n this.viewer = viewer;\n this.viewer.addEventListener(\"clear\", this.updateSceneInfo);\n this.viewer.addEventListener(\"geometryend\", this.updateSceneInfo);\n this.viewer.addEventListener(\"render\", this.updateRenderInfo);\n this.viewer.addEventListener(\"animate\", this.updatePreformanceInfo);\n\n this.updatePreformanceInfo();\n this.updateRenderInfo();\n this.updateSceneInfo();\n }\n\n dispose() {\n this.viewer.removeEventListener(\"clear\", this.updateSceneInfo);\n this.viewer.removeEventListener(\"geometryend\", this.updateSceneInfo);\n this.viewer.removeEventListener(\"render\", this.updateRenderInfo);\n this.viewer.removeEventListener(\"animate\", this.updatePreformanceInfo);\n\n this.performancePanel = undefined;\n this.renderPanel = undefined;\n this.optimizedPanel = undefined;\n this.scenePanel = undefined;\n this.memoryPanel = undefined;\n\n this.container.remove();\n this.container = undefined;\n }\n\n setTheme(value: string) {\n if (value === \"light\") {\n this.container.style.background = \"rgba(0, 0, 0, 0.025)\";\n this.container.style.color = \"#3d3d3d\";\n }\n if (value === \"dark\") {\n this.container.style.background = \"rgba(0, 0, 0, 0.88)\";\n this.container.style.color = \"#ebebeb\";\n }\n }\n\n updatePreformanceInfo = () => {\n const info = this.viewer.info;\n\n const text = [];\n text.push(`FPS: ${info.performance.fps}`);\n text.push(`Frame Time: ${info.performance.frameTime} ms`);\n this.performancePanel.update(text.join(\"\\n\"));\n\n this.viewer.update();\n };\n\n updateRenderInfo = () => {\n const info = this.viewer.info;\n\n const text = [];\n text.push(`Viewport: ${info.render.viewport.width} x ${info.render.viewport.height}`);\n text.push(`Antialiasing: ${info.render.antialiasing}`);\n text.push(`Draw Calls: ${info.render.drawCalls}`);\n text.push(`Triangles: ${info.render.triangles}`);\n text.push(`Points: ${info.render.points}`);\n text.push(`Lines: ${info.render.lines}`);\n this.renderPanel.update(text.join(\"\\n\"));\n };\n\n updateSceneInfo = () => {\n const info = this.viewer.info;\n\n const text = [];\n text.push(`Objects: ${info.optimizedScene.objects}`);\n text.push(`Triangles: ${info.optimizedScene.triangles}`);\n text.push(`Points: ${info.optimizedScene.points}`);\n text.push(`Lines: ${info.optimizedScene.lines}`);\n text.push(`Edges: ${info.optimizedScene.edges}`);\n this.optimizedPanel.update(text.join(\"\\n\"));\n\n text.length = 0;\n text.push(`Objects: ${info.scene.objects}`);\n text.push(`Triangles: ${info.scene.triangles}`);\n text.push(`Points: ${info.scene.points}`);\n text.push(`Lines: ${info.scene.lines}`);\n text.push(`Edges: ${info.scene.edges}`);\n this.scenePanel.update(text.join(\"\\n\"));\n\n text.length = 0;\n text.push(`Geometries: ${info.memory.geometries}`);\n text.push(`Textures: ${info.memory.textures}`);\n text.push(`Materials: ${info.memory.materials}`);\n text.push(`GPU Used: ${formatBytes(info.memory.totalEstimatedGpuBytes)}`);\n text.push(`JS Heap Used: ${formatBytes(info.memory.usedJSHeapSize)}`);\n this.memoryPanel.update(text.join(\"\\n\"));\n };\n}\n\ncomponents.registerComponent(\"InfoPanelComponent\", (viewer) => new InfoPanelComponent(viewer));\n"],"names":["components"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyBA,MAAM,GAAG,GAAG;IACV,IAAA,CAAC,EAAE,CA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;QAC5B;IAEA,IAAA,QAAQ,CAAC,KAAa,EAAA;IACpB,QAAA,IAAI,KAAK,KAAK,OAAO,EAAE;gBACrB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,GAAG,sBAAsB;gBACxD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS;YACxC;IACA,QAAA,IAAI,KAAK,KAAK,MAAM,EAAE;gBACpB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,GAAG,qBAAqB;gBACvD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS;YACxC;QACF;IAqDD;AAEDA,0BAAU,CAAC,iBAAiB,CAAC,oBAAoB,EAAE,CAAC,MAAM,KAAK,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;;;;;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@inweb/viewer-three")):"function"==typeof define&&define.amd?define(["@inweb/viewer-three"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ODA.Three)}(this,function(e){"use strict";const t={B:1,KB:1024,MB:1<<20,GB:1<<30};function n(e){if(!e)return"-";let n;n=e>=t.GB?"GB":e>=t.MB?"MB":e>=t.KB?"KB":"B";return(e/t[n]).toFixed()+" "+n}class i{constructor(e){this.dom=document.createElement("div"),this.label=document.createElement("div"),this.label.style.padding="0.25rem 0",this.label.style.fontWeight="600",this.label.innerText=e,this.dom.appendChild(this.label),this.text=document.createElement("small"),this.text.style.display="block",this.text.style.padding="0 0.5rem",this.dom.appendChild(this.text)}update(e){this.text.innerText!==e&&(this.text.innerText=e)}}class s{constructor(e){this.updatePreformanceInfo=()=>{const e=this.viewer.info,t=[];t.push(`FPS: ${e.performance.fps}`),t.push(`Frame Time: ${e.performance.frameTime} ms`),this.performancePanel.update(t.join("\n")),this.viewer.update()},this.updateRenderInfo=()=>{const e=this.viewer.info,t=[];t.push(`Viewport: ${e.render.viewport.width} x ${e.render.viewport.height}`),t.push(`Antialiasing: ${e.render.antialiasing}`),t.push(`Draw Calls: ${e.render.drawCalls}`),t.push(`Triangles: ${e.render.triangles}`),t.push(`Points: ${e.render.points}`),t.push(`Lines: ${e.render.lines}`),this.renderPanel.update(t.join("\n"))},this.updateSceneInfo=()=>{const e=this.viewer.info,t=[];t.push(`Objects: ${e.optimizedScene.objects}`),t.push(`Triangles: ${e.optimizedScene.triangles}`),t.push(`Points: ${e.optimizedScene.points}`),t.push(`Lines: ${e.optimizedScene.lines}`),t.push(`Edges: ${e.optimizedScene.edges}`),this.optimizedPanel.update(t.join("\n")),t.length=0,t.push(`Objects: ${e.scene.objects}`),t.push(`Triangles: ${e.scene.triangles}`),t.push(`Points: ${e.scene.points}`),t.push(`Lines: ${e.scene.lines}`),t.push(`Edges: ${e.scene.edges}`),this.scenePanel.update(t.join("\n")),t.length=0,t.push(`Geometries: ${e.memory.geometries}`),t.push(`Textures: ${e.memory.textures}`),t.push(`Materials: ${e.memory.materials}`),t.push(`GPU Used: ${n(e.memory.totalEstimatedGpuBytes)}`),t.push(`JS Heap Used: ${n(e.memory.usedJSHeapSize)}`),this.memoryPanel.update(t.join("\n"))},this.container=document.createElement("div"),this.container.id="info-container",this.container.style.position="absolute",this.container.style.left="0px",this.container.style.top="0px",this.container.style.maxHeight="100%",this.container.style.overflow="auto",this.container.style.padding="1rem",this.setTheme("dark"),this.performancePanel=new i("Performance"),this.renderPanel=new i("Render"),this.optimizedPanel=new i("Optimized Scene"),this.scenePanel=new i("Scene"),this.memoryPanel=new i("Memory"),this.container.appendChild(this.performancePanel.dom),this.container.appendChild(this.renderPanel.dom),this.container.appendChild(this.optimizedPanel.dom),this.container.appendChild(this.scenePanel.dom),this.container.appendChild(this.memoryPanel.dom),e.canvas.parentElement.appendChild(this.container),this.viewer=e,this.viewer.addEventListener("clear",this.updateSceneInfo),this.viewer.addEventListener("geometryend",this.updateSceneInfo),this.viewer.addEventListener("render",this.updateRenderInfo),this.viewer.addEventListener("animate",this.updatePreformanceInfo),this.updatePreformanceInfo(),this.updateRenderInfo(),this.updateSceneInfo()}dispose(){this.viewer.removeEventListener("clear",this.updateSceneInfo),this.viewer.removeEventListener("geometryend",this.updateSceneInfo),this.viewer.removeEventListener("render",this.updateRenderInfo),this.viewer.removeEventListener("animate",this.updatePreformanceInfo),this.performancePanel=void 0,this.renderPanel=void 0,this.optimizedPanel=void 0,this.scenePanel=void 0,this.memoryPanel=void 0,this.container.remove(),this.container=void 0}setTheme(e){"light"===e&&(this.container.style.background="rgba(0, 0, 0, 0.025)",this.container.style.color="#3d3d3d"),"dark"===e&&(this.container.style.background="rgba(0, 0, 0, 0.88)",this.container.style.color="#ebebeb")}}e.components.registerComponent("InfoPanelComponent",e=>new s(e))});
|