@inweb/viewer-three 27.10.0 → 27.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.
Files changed (105) hide show
  1. package/dist/extensions/loaders/GLTFCloudLoader.js +4 -2
  2. package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
  3. package/dist/extensions/loaders/GLTFCloudLoader.min.js +1 -1
  4. package/dist/extensions/loaders/GLTFCloudLoader.module.js +4 -2
  5. package/dist/extensions/loaders/GLTFCloudLoader.module.js.map +1 -1
  6. package/dist/extensions/loaders/GLTFFileLoader.js +2 -0
  7. package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
  8. package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
  9. package/dist/extensions/loaders/GLTFFileLoader.module.js +2 -0
  10. package/dist/extensions/loaders/GLTFFileLoader.module.js.map +1 -1
  11. package/dist/extensions/loaders/IFCXLoader.js +6 -2
  12. package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
  13. package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
  14. package/dist/extensions/loaders/IFCXLoader.module.js +6 -2
  15. package/dist/extensions/loaders/IFCXLoader.module.js.map +1 -1
  16. package/dist/extensions/loaders/PotreeLoader.js +2 -0
  17. package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
  18. package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
  19. package/dist/extensions/loaders/PotreeLoader.module.js +2 -0
  20. package/dist/extensions/loaders/PotreeLoader.module.js.map +1 -1
  21. package/dist/viewer-three.js +880 -258
  22. package/dist/viewer-three.js.map +1 -1
  23. package/dist/viewer-three.min.js +4 -4
  24. package/dist/viewer-three.module.js +765 -258
  25. package/dist/viewer-three.module.js.map +1 -1
  26. package/extensions/loaders/GLTFCloudLoader.ts +5 -3
  27. package/extensions/loaders/GLTFFileLoader.ts +2 -0
  28. package/extensions/loaders/IFCX/IFCXCloudLoader.ts +5 -3
  29. package/extensions/loaders/IFCX/IFCXFileLoader.ts +2 -0
  30. package/extensions/loaders/Potree/PotreeFileLoader.ts +2 -0
  31. package/lib/Viewer/Viewer.d.ts +27 -9
  32. package/lib/Viewer/commands/Deselect.d.ts +2 -0
  33. package/lib/Viewer/commands/Explode.d.ts +1 -1
  34. package/lib/Viewer/commands/GetHidden.d.ts +2 -0
  35. package/lib/Viewer/commands/GetIsolated.d.ts +2 -0
  36. package/lib/Viewer/commands/GetSelected.d.ts +1 -1
  37. package/lib/Viewer/commands/Hide.d.ts +2 -0
  38. package/lib/Viewer/commands/HideAll.d.ts +2 -0
  39. package/lib/Viewer/commands/Isolate.d.ts +2 -0
  40. package/lib/Viewer/commands/Select.d.ts +2 -0
  41. package/lib/Viewer/commands/SetSelected.d.ts +1 -1
  42. package/lib/Viewer/commands/SetSelected2.d.ts +1 -1
  43. package/lib/Viewer/commands/Show.d.ts +2 -0
  44. package/lib/Viewer/commands/ToHandles.d.ts +2 -0
  45. package/lib/Viewer/commands/ToHandles2.d.ts +2 -0
  46. package/lib/Viewer/commands/ToggleSelection.d.ts +2 -0
  47. package/lib/Viewer/commands/Zoom.d.ts +3 -0
  48. package/lib/Viewer/commands/ZoomExtents.d.ts +2 -0
  49. package/lib/Viewer/commands/ZoomTo.d.ts +1 -2
  50. package/lib/Viewer/components/HighlighterComponent.d.ts +4 -3
  51. package/lib/Viewer/components/SelectionComponent.d.ts +1 -9
  52. package/lib/Viewer/components/index.d.ts +1 -1
  53. package/lib/Viewer/draggers/index.d.ts +2 -2
  54. package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +10 -8
  55. package/lib/Viewer/loaders/GLTFCloudDynamicLoader.d.ts +5 -1
  56. package/lib/Viewer/loaders/GLTFFileDynamicLoader.d.ts +5 -1
  57. package/lib/Viewer/loaders/index.d.ts +5 -1
  58. package/lib/Viewer/models/Highlighter.types.d.ts +5 -0
  59. package/lib/Viewer/models/ModelImpl.d.ts +14 -10
  60. package/lib/Viewer/models/ModelImpl.types.d.ts +6 -10
  61. package/package.json +5 -5
  62. package/src/Viewer/Viewer.ts +131 -26
  63. package/src/Viewer/commands/ClearSelected.ts +3 -6
  64. package/src/Viewer/commands/Deselect.ts +35 -0
  65. package/src/Viewer/commands/Explode.ts +4 -3
  66. package/src/Viewer/commands/GetHidden.ts +30 -0
  67. package/src/Viewer/commands/GetIsolated.ts +30 -0
  68. package/src/Viewer/commands/GetSelected.ts +4 -4
  69. package/src/Viewer/commands/GetSelected2.ts +4 -7
  70. package/src/Viewer/commands/Hide.ts +35 -0
  71. package/src/Viewer/commands/HideAll.ts +32 -0
  72. package/src/Viewer/commands/HideSelected.ts +1 -11
  73. package/src/Viewer/commands/Isolate.ts +41 -0
  74. package/src/Viewer/commands/IsolateSelected.ts +1 -4
  75. package/src/Viewer/commands/ResetView.ts +1 -1
  76. package/src/Viewer/commands/Select.ts +36 -0
  77. package/src/Viewer/commands/SelectModel.ts +4 -8
  78. package/src/Viewer/commands/SetDefaultViewPosition.ts +2 -2
  79. package/src/Viewer/commands/SetSelected.ts +8 -11
  80. package/src/Viewer/commands/SetSelected2.ts +5 -16
  81. package/src/Viewer/commands/Show.ts +34 -0
  82. package/src/Viewer/commands/ShowAll.ts +2 -2
  83. package/src/Viewer/commands/{ZoomToObjects.ts → ToHandles.ts} +7 -10
  84. package/src/Viewer/commands/ToHandles2.ts +43 -0
  85. package/src/Viewer/commands/ToggleSelection.ts +40 -0
  86. package/src/Viewer/commands/Zoom.ts +66 -0
  87. package/src/Viewer/commands/{ZoomToExtents.ts → ZoomExtents.ts} +3 -3
  88. package/src/Viewer/commands/ZoomTo.ts +12 -38
  89. package/src/Viewer/commands/ZoomToSelected.ts +1 -7
  90. package/src/Viewer/commands/index.ts +24 -5
  91. package/src/Viewer/components/HighlighterComponent.ts +14 -12
  92. package/src/Viewer/components/SelectionComponent.ts +12 -76
  93. package/src/Viewer/components/index.ts +1 -1
  94. package/src/Viewer/draggers/OrbitDragger.ts +2 -2
  95. package/src/Viewer/draggers/index.ts +2 -2
  96. package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +429 -2
  97. package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +26 -35
  98. package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +33 -3
  99. package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +32 -2
  100. package/src/Viewer/loaders/index.ts +5 -1
  101. package/src/Viewer/models/Highlighter.types.ts +30 -0
  102. package/src/Viewer/models/ModelImpl.ts +68 -57
  103. package/src/Viewer/models/ModelImpl.types.ts +8 -17
  104. package/lib/Viewer/commands/ZoomToExtents.d.ts +0 -2
  105. package/lib/Viewer/commands/ZoomToObjects.d.ts +0 -2
@@ -21,8 +21,8 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { Group, LoaderUtils } from "three";
25
- import { Loader, LoadParams } from "@inweb/viewer-core";
24
+ import { Color, Group, LoaderUtils } from "three";
25
+ import { IOptions, Loader, LoadParams, Options } from "@inweb/viewer-core";
26
26
 
27
27
  import { Viewer } from "../Viewer";
28
28
  import { DynamicModelImpl } from "./DynamicGltfLoader/DynamicModelImpl";
@@ -41,6 +41,8 @@ export class GLTFCloudDynamicLoader extends Loader {
41
41
  }
42
42
 
43
43
  override dispose() {
44
+ this.viewer.removeEventListener("optionschange", this.syncHighlightSettings);
45
+
44
46
  if (this.gltfLoader) this.gltfLoader.clear();
45
47
  }
46
48
 
@@ -62,10 +64,14 @@ export class GLTFCloudDynamicLoader extends Loader {
62
64
  this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);
63
65
  this.gltfLoader.setMaxConcurrentChunks(params.maxConcurrentChunks);
64
66
  this.gltfLoader.setDracoLoader(params.dracoLoader);
67
+ this.gltfLoader.setHighlightSettings(this.getHighlightSettings());
65
68
 
66
69
  const modelImpl = new DynamicModelImpl(scene);
67
- modelImpl.id = model.file.id;
70
+ modelImpl.id = params.modelId || model.file.id;
68
71
  modelImpl.gltfLoader = this.gltfLoader;
72
+ modelImpl.initialize();
73
+
74
+ this.viewer.addEventListener("optionschange", this.syncHighlightSettings);
69
75
 
70
76
  this.gltfLoader.addEventListener("databasechunk", (data) => {
71
77
  this.viewer.scene.add(scene);
@@ -138,4 +144,28 @@ export class GLTFCloudDynamicLoader extends Loader {
138
144
  override cancel() {
139
145
  if (this.gltfLoader) this.gltfLoader.abortLoading();
140
146
  }
147
+
148
+ getHighlightSettings(options?: IOptions): any {
149
+ if (!options) options = this.viewer.options;
150
+ if (!options.enableCustomHighlight) options = Options.defaults();
151
+
152
+ let { facesColor, facesTransparancy, edgesColor } = options;
153
+
154
+ facesColor = new Color().setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
155
+ facesTransparancy = (255 - facesTransparancy) / 255;
156
+ edgesColor = new Color().setRGB(edgesColor.r / 255, edgesColor.g / 255, edgesColor.b / 255);
157
+
158
+ return {
159
+ facesColor,
160
+ facesTransparancy,
161
+ facesOverlap: options.facesOverlap,
162
+ edgesColor,
163
+ edgesVisibility: options.edgesVisibility,
164
+ edgesOverlap: options.edgesOverlap,
165
+ };
166
+ }
167
+
168
+ syncHighlightSettings = ({ data }) => {
169
+ this.gltfLoader.setHighlightSettings(this.getHighlightSettings(data));
170
+ };
141
171
  }
@@ -21,8 +21,8 @@
21
21
  // acknowledge and accept the above terms.
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
- import { FileLoader, Group, LoaderUtils } from "three";
25
- import { Loader } from "@inweb/viewer-core";
24
+ import { Color, FileLoader, Group, LoaderUtils } from "three";
25
+ import { IOptions, Loader, Options } from "@inweb/viewer-core";
26
26
 
27
27
  import { Viewer } from "../Viewer";
28
28
  import { DynamicModelImpl } from "./DynamicGltfLoader/DynamicModelImpl";
@@ -45,6 +45,8 @@ export class GLTFFileDynamicLoader extends Loader {
45
45
  }
46
46
 
47
47
  override dispose() {
48
+ this.viewer.removeEventListener("optionschange", this.syncHighlightSettings);
49
+
48
50
  if (this.gltfLoader) this.gltfLoader.clear();
49
51
  if (this.manager) this.manager.dispose();
50
52
  }
@@ -66,10 +68,14 @@ export class GLTFFileDynamicLoader extends Loader {
66
68
  this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);
67
69
  this.gltfLoader.setMaxConcurrentChunks(params.maxConcurrentChunks);
68
70
  this.gltfLoader.setDracoLoader(params.dracoLoader);
71
+ this.gltfLoader.setHighlightSettings(this.getHighlightSettings());
69
72
 
70
73
  const modelImpl = new DynamicModelImpl(scene);
71
74
  modelImpl.id = params.modelId || this.extractFileName(file);
72
75
  modelImpl.gltfLoader = this.gltfLoader;
76
+ modelImpl.initialize();
77
+
78
+ this.viewer.addEventListener("optionschange", this.syncHighlightSettings);
73
79
 
74
80
  this.gltfLoader.addEventListener("databasechunk", () => {
75
81
  this.viewer.scene.add(scene);
@@ -150,4 +156,28 @@ export class GLTFFileDynamicLoader extends Loader {
150
156
  override cancel() {
151
157
  if (this.gltfLoader) this.gltfLoader.abortLoading();
152
158
  }
159
+
160
+ getHighlightSettings(options?: IOptions): any {
161
+ if (!options) options = this.viewer.options;
162
+ if (!options.enableCustomHighlight) options = Options.defaults();
163
+
164
+ let { facesColor, facesTransparancy, edgesColor } = options;
165
+
166
+ facesColor = new Color().setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
167
+ facesTransparancy = (255 - facesTransparancy) / 255;
168
+ edgesColor = new Color().setRGB(edgesColor.r / 255, edgesColor.g / 255, edgesColor.b / 255);
169
+
170
+ return {
171
+ facesColor,
172
+ facesTransparancy,
173
+ facesOverlap: options.facesOverlap,
174
+ edgesColor,
175
+ edgesVisibility: options.edgesVisibility,
176
+ edgesOverlap: options.edgesOverlap,
177
+ };
178
+ }
179
+
180
+ syncHighlightSettings = ({ data }) => {
181
+ this.gltfLoader.setHighlightSettings(this.getHighlightSettings(data));
182
+ };
153
183
  }
@@ -40,7 +40,9 @@ import { GLTFCloudDynamicLoader } from "./GLTFCloudDynamicLoader";
40
40
  *
41
41
  * - Load raw data from file and convert it to the `Three.js` scene.
42
42
  * - Add scene to the viewer `scene`.
43
- * - Create `ModelImpl` instance with unique model ID add it to the viewer `models` list.
43
+ * - Create `ModelImpl` instance with unique model ID.
44
+ * - Set model objects highlighter, if the model itself does not support highlighting.
45
+ * - Add model it to the viewer `models` list.
44
46
  * - Synchronize viewer options and overlay.
45
47
  * - Update the viewer.
46
48
  *
@@ -80,6 +82,8 @@ import { GLTFCloudDynamicLoader } from "./GLTFCloudDynamicLoader";
80
82
  *
81
83
  * const modelImpl = new ModelImpl(scene);
82
84
  * modelImpl.id = params.modelId;
85
+ * modelImpl.highlighter = this.viewer.getComponent("HighlighterComponent") as any;
86
+ * modelImpl.initialize();
83
87
  *
84
88
  * this.viewer.scene.add(scene);
85
89
  * this.viewer.models.push(modelImpl);
@@ -0,0 +1,30 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (C) 2002-2026, 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-2026 by Open Design Alliance.
18
+ // All rights reserved.
19
+ //
20
+ // By use of this software, its documentation or related materials, you
21
+ // acknowledge and accept the above terms.
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+
24
+ import { Object3D } from "three";
25
+
26
+ export interface IHighlighter {
27
+ highlightObjects(objects: Object3D[]): void;
28
+
29
+ unhighlightObjects(objects: Object3D[]): void;
30
+ }
@@ -25,37 +25,24 @@ import { Box3, Object3D, Vector3 } from "three";
25
25
  import { IInfo, Info } from "@inweb/viewer-core";
26
26
 
27
27
  import { IModelImpl } from "./ModelImpl.types";
28
+ import { IHighlighter } from "./Highlighter.types";
28
29
  import { convertUnits } from "../measurement/UnitConverter";
29
30
  import { getDisplayUnit } from "../measurement/UnitFormatter";
30
31
 
31
32
  export class ModelImpl implements IModelImpl {
32
33
  public id: string;
33
34
  public scene: Object3D;
35
+ public highlighter: IHighlighter;
34
36
 
35
- private handleToObjects: Map<any, Set<Object3D>>;
36
37
  private originalObjects: Set<Object3D>;
38
+ private handleToObjects: Map<string, Set<Object3D>>;
37
39
 
38
40
  constructor(scene: Object3D) {
39
41
  this.id = "";
40
42
  this.scene = scene;
41
43
 
42
- this.handleToObjects = new Map();
43
44
  this.originalObjects = new Set();
44
-
45
- this.scene.traverse((object) => {
46
- this.originalObjects.add(object);
47
-
48
- const handle = object.userData.handle;
49
- if (!handle) return;
50
-
51
- let objects = this.handleToObjects.get(handle);
52
- if (!objects) {
53
- objects = new Set();
54
- this.handleToObjects.set(handle, objects);
55
- }
56
-
57
- objects.add(object);
58
- });
45
+ this.handleToObjects = new Map();
59
46
  }
60
47
 
61
48
  dispose() {
@@ -102,6 +89,26 @@ export class ModelImpl implements IModelImpl {
102
89
  this.scene.clear();
103
90
  }
104
91
 
92
+ initialize(): void {
93
+ this.scene.traverse((object) => {
94
+ this.originalObjects.add(object);
95
+
96
+ const handle = object.userData.handle;
97
+ if (!handle) return;
98
+
99
+ //
100
+ const fullHandle = `${this.id}:${handle}`;
101
+
102
+ let objectsSet = this.handleToObjects.get(fullHandle);
103
+ if (!objectsSet) {
104
+ objectsSet = new Set();
105
+ this.handleToObjects.set(fullHandle, objectsSet);
106
+ }
107
+
108
+ objectsSet.add(object);
109
+ });
110
+ }
111
+
105
112
  getUnits(): string {
106
113
  return "Meters";
107
114
  }
@@ -313,44 +320,36 @@ export class ModelImpl implements IModelImpl {
313
320
  return objects;
314
321
  }
315
322
 
316
- getObjectsByHandles(handles: string | string[]): Object3D[] {
317
- if (!Array.isArray(handles)) handles = [handles];
318
-
319
- const ownHandles: string[] = [];
320
- handles.forEach((handle) => {
321
- const index = handle.indexOf(":");
322
- if (index !== -1) {
323
- if (handle.slice(0, index) !== this.id) return;
324
- handle = handle.slice(index + 1);
325
- }
326
- ownHandles.push(handle);
327
- });
328
-
329
- const handlesSet = new Set<string>(ownHandles);
330
-
323
+ getObjectsByHandles(handles: string[]): Object3D[] {
331
324
  const objects: Object3D[][] = [];
332
- handlesSet.forEach((handle) => {
333
- objects.push(Array.from(this.handleToObjects.get(handle) || []));
325
+ handles.forEach((handle) => {
326
+ const objectsSet = this.handleToObjects.get(handle);
327
+ objects.push(Array.from(objectsSet || []));
334
328
  });
335
329
 
336
330
  return objects.flat();
337
331
  }
338
332
 
339
- getHandlesByObjects(objects: Object3D | Object3D[]): string[] {
340
- if (!Array.isArray(objects)) objects = [objects];
333
+ getHandles(): string[] {
334
+ return Array.from(this.handleToObjects.keys());
335
+ }
341
336
 
342
- const handleSet = new Set<string>();
343
- objects
344
- .filter((object) => this.originalObjects.has(object))
345
- .forEach((object) => {
346
- handleSet.add(`${this.id}:${object.userData.handle}`);
347
- });
337
+ getHandlesByObjects(objects: Object3D[]): string[] {
338
+ const handlesSet = new Set<string>();
339
+ objects.forEach((object) => {
340
+ if (this.originalObjects.has(object)) {
341
+ const fullHandle = `${this.id}:${object.userData.handle}`;
342
+ handlesSet.add(fullHandle);
343
+ }
344
+ });
348
345
 
349
- return Array.from(handleSet);
346
+ return Array.from(handlesSet);
350
347
  }
351
348
 
352
- hideObjects(objects: Object3D | Object3D[]): this {
353
- if (!Array.isArray(objects)) objects = [objects];
349
+ // IModel
350
+
351
+ hide(handles: string[]): this {
352
+ const objects = this.getObjectsByHandles(handles);
354
353
 
355
354
  objects
356
355
  .filter((object) => this.originalObjects.has(object))
@@ -361,18 +360,19 @@ export class ModelImpl implements IModelImpl {
361
360
  return this;
362
361
  }
363
362
 
364
- hideAllObjects(): this {
365
- return this.isolateObjects([]);
363
+ hideAll(): this {
364
+ return this.isolate([]);
366
365
  }
367
366
 
368
- isolateObjects(objects: Object3D | Object3D[]): this {
369
- if (!Array.isArray(objects)) objects = [objects];
367
+ isolate(handles: string[]): this {
368
+ const objects = this.getObjectsByHandles(handles);
370
369
 
371
370
  const visibleSet = new Set(objects);
372
371
  objects
373
372
  .filter((object) => this.originalObjects.has(object))
374
373
  .forEach((object) => {
375
374
  object.traverseAncestors((parent) => visibleSet.add(parent));
375
+ object.traverse((child) => visibleSet.add(child));
376
376
  });
377
377
 
378
378
  this.scene.traverse((object) => (object.visible = visibleSet.has(object)));
@@ -380,29 +380,38 @@ export class ModelImpl implements IModelImpl {
380
380
  return this;
381
381
  }
382
382
 
383
- showObjects(objects: Object3D | Object3D[]): this {
384
- if (!Array.isArray(objects)) objects = [objects];
383
+ show(handles: string[]): this {
384
+ const objects = this.getObjectsByHandles(handles);
385
385
 
386
386
  objects
387
387
  .filter((object) => this.originalObjects.has(object))
388
388
  .forEach((object) => {
389
389
  object.visible = true;
390
390
  object.traverseAncestors((parent) => (parent.visible = true));
391
+ object.traverse((child) => (child.visible = true));
391
392
  });
392
393
 
393
394
  return this;
394
395
  }
395
396
 
396
- showAllObjects(): this {
397
+ showAll(): this {
397
398
  this.scene.traverse((object) => (object.visible = true));
398
399
  return this;
399
400
  }
400
401
 
401
- highlightObjects(objects: Object3D | Object3D[]): this {
402
+ highlight(handles: string[]): this {
403
+ if (this.highlighter) {
404
+ const objects = this.getObjectsByHandles(handles);
405
+ this.highlighter.highlightObjects(objects);
406
+ }
402
407
  return this;
403
408
  }
404
409
 
405
- unhighlightObjects(objects: Object3D | Object3D[]): this {
410
+ unhighlight(handles: string[]): this {
411
+ if (this.highlighter) {
412
+ const objects = this.getObjectsByHandles(handles);
413
+ this.highlighter.unhighlightObjects(objects);
414
+ }
406
415
  return this;
407
416
  }
408
417
 
@@ -415,14 +424,16 @@ export class ModelImpl implements IModelImpl {
415
424
  const handle = object.userData.handle;
416
425
  if (!handle) return extents.getCenter(target);
417
426
 
418
- const center = centersCache.get(handle);
427
+ const fullHandle = `${this.id}:${handle}`;
428
+
429
+ const center = centersCache.get(fullHandle);
419
430
  if (center) return target.copy(center);
420
431
 
421
- const objects = this.getObjectsByHandles(handle);
432
+ const objects = this.getObjectsByHandles([fullHandle]);
422
433
  objects.forEach((x: Object3D) => extents.expandByObject(x));
423
434
  extents.getCenter(target);
424
435
 
425
- centersCache.set(handle, target.clone());
436
+ centersCache.set(fullHandle, target.clone());
426
437
 
427
438
  return target;
428
439
  };
@@ -24,11 +24,16 @@
24
24
  import { Box3, Object3D } from "three";
25
25
  import { IInfo, IModel } from "@inweb/viewer-core";
26
26
 
27
+ import { IHighlighter } from "./Highlighter.types";
28
+
27
29
  /**
28
30
  * Basic model implementation.
29
31
  */
30
32
  export interface IModelImpl extends IModel {
31
33
  scene: Object3D;
34
+ highlighter?: IHighlighter;
35
+
36
+ initialize(): void;
32
37
 
33
38
  getUnits(): string;
34
39
 
@@ -46,23 +51,9 @@ export interface IModelImpl extends IModel {
46
51
 
47
52
  getVisibleObjects(): Object3D[];
48
53
 
49
- getObjectsByHandles(handles: string | string[]): Object3D[];
50
-
51
- getHandlesByObjects(objects: Object3D | Object3D[]): string[];
52
-
53
- hideObjects(objects: Object3D | Object3D[]): this;
54
-
55
- hideAllObjects(): this;
56
-
57
- isolateObjects(objects: Object3D | Object3D[]): this;
58
-
59
- showObjects(objects: Object3D | Object3D[]): this;
60
-
61
- showAllObjects(): this;
62
-
63
- highlightObjects(objects: Object3D | Object3D[]): this;
54
+ getObjectsByHandles(handles: string[]): Object3D[];
64
55
 
65
- unhighlightObjects(objects: Object3D | Object3D[]): this;
56
+ getHandles(): string[];
66
57
 
67
- explode(scale: number, coeff?: number): this;
58
+ getHandlesByObjects(objects: Object3D[]): string[];
68
59
  }
@@ -1,2 +0,0 @@
1
- import type { Viewer } from "../Viewer";
2
- export declare function zoomToExtents(viewer: Viewer): void;
@@ -1,2 +0,0 @@
1
- import type { Viewer } from "../Viewer";
2
- export declare function zoomToObjects(viewer: Viewer, handles?: string[]): void;