@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.
- package/dist/extensions/loaders/GLTFCloudLoader.js +4 -2
- package/dist/extensions/loaders/GLTFCloudLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.min.js +1 -1
- package/dist/extensions/loaders/GLTFCloudLoader.module.js +4 -2
- package/dist/extensions/loaders/GLTFCloudLoader.module.js.map +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.js +2 -0
- package/dist/extensions/loaders/GLTFFileLoader.js.map +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.min.js +1 -1
- package/dist/extensions/loaders/GLTFFileLoader.module.js +2 -0
- package/dist/extensions/loaders/GLTFFileLoader.module.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.js +6 -2
- package/dist/extensions/loaders/IFCXLoader.js.map +1 -1
- package/dist/extensions/loaders/IFCXLoader.min.js +1 -1
- package/dist/extensions/loaders/IFCXLoader.module.js +6 -2
- package/dist/extensions/loaders/IFCXLoader.module.js.map +1 -1
- package/dist/extensions/loaders/PotreeLoader.js +2 -0
- package/dist/extensions/loaders/PotreeLoader.js.map +1 -1
- package/dist/extensions/loaders/PotreeLoader.min.js +1 -1
- package/dist/extensions/loaders/PotreeLoader.module.js +2 -0
- package/dist/extensions/loaders/PotreeLoader.module.js.map +1 -1
- package/dist/viewer-three.js +880 -258
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +4 -4
- package/dist/viewer-three.module.js +765 -258
- package/dist/viewer-three.module.js.map +1 -1
- package/extensions/loaders/GLTFCloudLoader.ts +5 -3
- package/extensions/loaders/GLTFFileLoader.ts +2 -0
- package/extensions/loaders/IFCX/IFCXCloudLoader.ts +5 -3
- package/extensions/loaders/IFCX/IFCXFileLoader.ts +2 -0
- package/extensions/loaders/Potree/PotreeFileLoader.ts +2 -0
- package/lib/Viewer/Viewer.d.ts +27 -9
- package/lib/Viewer/commands/Deselect.d.ts +2 -0
- package/lib/Viewer/commands/Explode.d.ts +1 -1
- package/lib/Viewer/commands/GetHidden.d.ts +2 -0
- package/lib/Viewer/commands/GetIsolated.d.ts +2 -0
- package/lib/Viewer/commands/GetSelected.d.ts +1 -1
- package/lib/Viewer/commands/Hide.d.ts +2 -0
- package/lib/Viewer/commands/HideAll.d.ts +2 -0
- package/lib/Viewer/commands/Isolate.d.ts +2 -0
- package/lib/Viewer/commands/Select.d.ts +2 -0
- package/lib/Viewer/commands/SetSelected.d.ts +1 -1
- package/lib/Viewer/commands/SetSelected2.d.ts +1 -1
- package/lib/Viewer/commands/Show.d.ts +2 -0
- package/lib/Viewer/commands/ToHandles.d.ts +2 -0
- package/lib/Viewer/commands/ToHandles2.d.ts +2 -0
- package/lib/Viewer/commands/ToggleSelection.d.ts +2 -0
- package/lib/Viewer/commands/Zoom.d.ts +3 -0
- package/lib/Viewer/commands/ZoomExtents.d.ts +2 -0
- package/lib/Viewer/commands/ZoomTo.d.ts +1 -2
- package/lib/Viewer/components/HighlighterComponent.d.ts +4 -3
- package/lib/Viewer/components/SelectionComponent.d.ts +1 -9
- package/lib/Viewer/components/index.d.ts +1 -1
- package/lib/Viewer/draggers/index.d.ts +2 -2
- package/lib/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.d.ts +10 -8
- package/lib/Viewer/loaders/GLTFCloudDynamicLoader.d.ts +5 -1
- package/lib/Viewer/loaders/GLTFFileDynamicLoader.d.ts +5 -1
- package/lib/Viewer/loaders/index.d.ts +5 -1
- package/lib/Viewer/models/Highlighter.types.d.ts +5 -0
- package/lib/Viewer/models/ModelImpl.d.ts +14 -10
- package/lib/Viewer/models/ModelImpl.types.d.ts +6 -10
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +131 -26
- package/src/Viewer/commands/ClearSelected.ts +3 -6
- package/src/Viewer/commands/Deselect.ts +35 -0
- package/src/Viewer/commands/Explode.ts +4 -3
- package/src/Viewer/commands/GetHidden.ts +30 -0
- package/src/Viewer/commands/GetIsolated.ts +30 -0
- package/src/Viewer/commands/GetSelected.ts +4 -4
- package/src/Viewer/commands/GetSelected2.ts +4 -7
- package/src/Viewer/commands/Hide.ts +35 -0
- package/src/Viewer/commands/HideAll.ts +32 -0
- package/src/Viewer/commands/HideSelected.ts +1 -11
- package/src/Viewer/commands/Isolate.ts +41 -0
- package/src/Viewer/commands/IsolateSelected.ts +1 -4
- package/src/Viewer/commands/ResetView.ts +1 -1
- package/src/Viewer/commands/Select.ts +36 -0
- package/src/Viewer/commands/SelectModel.ts +4 -8
- package/src/Viewer/commands/SetDefaultViewPosition.ts +2 -2
- package/src/Viewer/commands/SetSelected.ts +8 -11
- package/src/Viewer/commands/SetSelected2.ts +5 -16
- package/src/Viewer/commands/Show.ts +34 -0
- package/src/Viewer/commands/ShowAll.ts +2 -2
- package/src/Viewer/commands/{ZoomToObjects.ts → ToHandles.ts} +7 -10
- package/src/Viewer/commands/ToHandles2.ts +43 -0
- package/src/Viewer/commands/ToggleSelection.ts +40 -0
- package/src/Viewer/commands/Zoom.ts +66 -0
- package/src/Viewer/commands/{ZoomToExtents.ts → ZoomExtents.ts} +3 -3
- package/src/Viewer/commands/ZoomTo.ts +12 -38
- package/src/Viewer/commands/ZoomToSelected.ts +1 -7
- package/src/Viewer/commands/index.ts +24 -5
- package/src/Viewer/components/HighlighterComponent.ts +14 -12
- package/src/Viewer/components/SelectionComponent.ts +12 -76
- package/src/Viewer/components/index.ts +1 -1
- package/src/Viewer/draggers/OrbitDragger.ts +2 -2
- package/src/Viewer/draggers/index.ts +2 -2
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicGltfLoader.js +429 -2
- package/src/Viewer/loaders/DynamicGltfLoader/DynamicModelImpl.ts +26 -35
- package/src/Viewer/loaders/GLTFCloudDynamicLoader.ts +33 -3
- package/src/Viewer/loaders/GLTFFileDynamicLoader.ts +32 -2
- package/src/Viewer/loaders/index.ts +5 -1
- package/src/Viewer/models/Highlighter.types.ts +30 -0
- package/src/Viewer/models/ModelImpl.ts +68 -57
- package/src/Viewer/models/ModelImpl.types.ts +8 -17
- package/lib/Viewer/commands/ZoomToExtents.d.ts +0 -2
- package/lib/Viewer/commands/ZoomToObjects.d.ts +0 -2
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
// acknowledge and accept the above terms.
|
|
22
22
|
///////////////////////////////////////////////////////////////////////////////
|
|
23
23
|
|
|
24
|
-
import { draggersRegistry, commandsRegistry, Options, componentsRegistry, Info, Loader, loadersRegistry, CANVAS_EVENTS } from '@inweb/viewer-core';
|
|
24
|
+
import { draggersRegistry, commandsRegistry, Options, componentsRegistry, Info, Loader, loadersRegistry, CANVAS_EVENTS, Selector, VisibilityManager } from '@inweb/viewer-core';
|
|
25
25
|
export * from '@inweb/viewer-core';
|
|
26
26
|
import { EventDispatcher, Vector3, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Object3D, BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, Line3, Raycaster, MathUtils, EdgesGeometry, Plane, Matrix4, Vector4, Controls, Box3, Clock, Color, PerspectiveCamera, OrthographicCamera, AmbientLight, DirectionalLight, HemisphereLight, REVISION, MeshPhongMaterial, WebGLRenderTarget, UnsignedByteType, RGBAFormat, ShaderMaterial, PointsMaterial, Points, Sphere, ShapeUtils, CylinderGeometry, Sprite, CanvasTexture, SRGBColorSpace, SpriteMaterial, TextureLoader, BufferAttribute, LinearMipmapLinearFilter, NearestMipmapLinearFilter, LinearMipmapNearestFilter, NearestMipmapNearestFilter, LinearFilter, NearestFilter, RepeatWrapping, MirroredRepeatWrapping, ClampToEdgeWrapping, MeshStandardMaterial, DataTexture, FloatType, TriangleStripDrawMode, TriangleFanDrawMode, LineSegments, LineLoop, Group, NormalBlending, LoadingManager, LoaderUtils, FileLoader, Scene, WebGLRenderer, LinearSRGBColorSpace } from 'three';
|
|
27
27
|
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
|
|
@@ -931,7 +931,7 @@ class OrbitDragger {
|
|
|
931
931
|
this.viewer.addEventListener("drawviewpoint", this.updateControls);
|
|
932
932
|
this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
|
|
933
933
|
this.viewer.addEventListener("optionschange", this.updateZoomSpeed);
|
|
934
|
-
this.viewer.addEventListener("contextmenu", this.stopContextMenu);
|
|
934
|
+
this.viewer.canvas.addEventListener("contextmenu", this.stopContextMenu);
|
|
935
935
|
this.updateControls();
|
|
936
936
|
this.updateControlsCamera();
|
|
937
937
|
}
|
|
@@ -943,7 +943,7 @@ class OrbitDragger {
|
|
|
943
943
|
this.viewer.removeEventListener("drawviewpoint", this.updateControls);
|
|
944
944
|
this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
|
|
945
945
|
this.viewer.removeEventListener("optionschange", this.updateZoomSpeed);
|
|
946
|
-
this.viewer.removeEventListener("contextmenu", this.stopContextMenu);
|
|
946
|
+
this.viewer.canvas.removeEventListener("contextmenu", this.stopContextMenu);
|
|
947
947
|
this.orbit.removeEventListener("start", this.controlsStart);
|
|
948
948
|
this.orbit.removeEventListener("change", this.controlsChange);
|
|
949
949
|
this.orbit.dispose();
|
|
@@ -2412,17 +2412,44 @@ function clearMarkup(viewer) {
|
|
|
2412
2412
|
}
|
|
2413
2413
|
|
|
2414
2414
|
function clearSelected(viewer) {
|
|
2415
|
-
|
|
2416
|
-
|
|
2415
|
+
viewer.selector.clearSelected();
|
|
2416
|
+
viewer.emitEvent({ type: "select" });
|
|
2417
|
+
viewer.emitEvent({ type: "select2" });
|
|
2417
2418
|
viewer.update();
|
|
2418
|
-
viewer.emitEvent({ type: "select", handles: [] });
|
|
2419
|
-
viewer.emitEvent({ type: "select2", handles: [] });
|
|
2420
2419
|
}
|
|
2421
2420
|
|
|
2422
2421
|
function clearSlices(viewer) {
|
|
2423
2422
|
viewer.clearSlices();
|
|
2424
2423
|
}
|
|
2425
2424
|
|
|
2425
|
+
function toHandles2(viewer, handles = []) {
|
|
2426
|
+
if (!Array.isArray(handles))
|
|
2427
|
+
handles = [handles];
|
|
2428
|
+
if (handles.length === 0)
|
|
2429
|
+
return handles;
|
|
2430
|
+
if (handles[0].includes(":"))
|
|
2431
|
+
return handles;
|
|
2432
|
+
const handles2 = [];
|
|
2433
|
+
handles.forEach((handle) => {
|
|
2434
|
+
if (handle.includes(":")) {
|
|
2435
|
+
handles2.push(handle);
|
|
2436
|
+
}
|
|
2437
|
+
else
|
|
2438
|
+
viewer.models.forEach((model) => {
|
|
2439
|
+
handles2.push(`${model.id}:${handle}`);
|
|
2440
|
+
});
|
|
2441
|
+
});
|
|
2442
|
+
return handles2;
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
function deselect(viewer, handles = []) {
|
|
2446
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2447
|
+
viewer.selector.deselect(handles2);
|
|
2448
|
+
viewer.emitEvent({ type: "select" });
|
|
2449
|
+
viewer.emitEvent({ type: "select2" });
|
|
2450
|
+
viewer.update();
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2426
2453
|
function getSnapshot(viewer, type, quality) {
|
|
2427
2454
|
var _a, _b;
|
|
2428
2455
|
viewer.update(true);
|
|
@@ -2434,16 +2461,17 @@ function getSnapshot(viewer, type, quality) {
|
|
|
2434
2461
|
return viewer.canvas.toDataURL(mimeType, imageQuality);
|
|
2435
2462
|
}
|
|
2436
2463
|
|
|
2437
|
-
function explode(viewer,
|
|
2438
|
-
viewer.models.forEach((model) => model.explode(
|
|
2464
|
+
function explode(viewer, scale = 0) {
|
|
2465
|
+
viewer.models.forEach((model) => model.explode(scale));
|
|
2466
|
+
viewer.explodeScale = scale;
|
|
2439
2467
|
viewer.update();
|
|
2440
|
-
viewer.emitEvent({ type: "explode", data:
|
|
2468
|
+
viewer.emitEvent({ type: "explode", data: scale });
|
|
2441
2469
|
}
|
|
2442
2470
|
function collect(viewer) {
|
|
2443
2471
|
explode(viewer, 0);
|
|
2444
2472
|
}
|
|
2445
2473
|
|
|
2446
|
-
function
|
|
2474
|
+
function zoom(viewer, box) {
|
|
2447
2475
|
if (box.isEmpty())
|
|
2448
2476
|
return;
|
|
2449
2477
|
const boxCenter = box.getCenter(new Vector3());
|
|
@@ -2503,7 +2531,7 @@ function setDefaultViewPosition(viewer, position = "sw") {
|
|
|
2503
2531
|
viewer.target.copy(extentsCenter);
|
|
2504
2532
|
viewer.update();
|
|
2505
2533
|
viewer.emit({ type: "viewposition", data: position });
|
|
2506
|
-
|
|
2534
|
+
zoom(viewer, viewer.extents);
|
|
2507
2535
|
}
|
|
2508
2536
|
|
|
2509
2537
|
function getDefaultViewPositions() {
|
|
@@ -2514,34 +2542,72 @@ function getModels(viewer) {
|
|
|
2514
2542
|
return viewer.models.map((model) => model.id);
|
|
2515
2543
|
}
|
|
2516
2544
|
|
|
2517
|
-
function
|
|
2518
|
-
|
|
2545
|
+
function toHandles(viewer, handles2) {
|
|
2546
|
+
if (!Array.isArray(handles2))
|
|
2547
|
+
handles2 = [handles2];
|
|
2548
|
+
if (handles2.length === 0)
|
|
2549
|
+
return handles2;
|
|
2550
|
+
if (!handles2[0].includes(":"))
|
|
2551
|
+
return handles2;
|
|
2519
2552
|
const handles = handles2.map((handle) => handle.slice(handle.indexOf(":") + 1));
|
|
2520
2553
|
return handles;
|
|
2521
2554
|
}
|
|
2522
2555
|
|
|
2556
|
+
function getSelected(viewer, multimodel = false) {
|
|
2557
|
+
const handles2 = Array.from(viewer.selector.selected);
|
|
2558
|
+
return multimodel ? handles2 : toHandles(viewer, handles2);
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2523
2561
|
function getSelected2(viewer) {
|
|
2524
|
-
|
|
2525
|
-
viewer.
|
|
2526
|
-
handles2.push(model.getHandlesByObjects(viewer.selected));
|
|
2527
|
-
});
|
|
2528
|
-
return handles2.flat();
|
|
2562
|
+
console.warn("getSelected2 command has been deprecated since 27.11 and will be removed in a future release, use getSelected instead");
|
|
2563
|
+
return viewer.executeCommand("getSelected", true);
|
|
2529
2564
|
}
|
|
2530
2565
|
|
|
2531
|
-
function
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2566
|
+
function getHidden(viewer, multimodel = false) {
|
|
2567
|
+
const handles2 = Array.from(viewer.visibilityManager.hidden);
|
|
2568
|
+
return multimodel ? handles2 : toHandles(viewer, handles2);
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
function getIsolated(viewer, multimodel = false) {
|
|
2572
|
+
const handles2 = Array.from(viewer.visibilityManager.isolated);
|
|
2573
|
+
return multimodel ? handles2 : toHandles(viewer, handles2);
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
function hide(viewer, handles) {
|
|
2577
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2578
|
+
viewer.deselect(handles2);
|
|
2579
|
+
viewer.visibilityManager.hide(handles2);
|
|
2536
2580
|
viewer.emitEvent({ type: "hide" });
|
|
2537
|
-
viewer.
|
|
2538
|
-
viewer.emitEvent({ type: "select2", handles: [] });
|
|
2581
|
+
viewer.update();
|
|
2539
2582
|
}
|
|
2540
2583
|
|
|
2541
|
-
function
|
|
2542
|
-
viewer.
|
|
2584
|
+
function hideAll(viewer) {
|
|
2585
|
+
viewer.clearSelected();
|
|
2586
|
+
viewer.visibilityManager.hideAll();
|
|
2587
|
+
viewer.emitEvent({ type: "hideall" });
|
|
2543
2588
|
viewer.update();
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
function hideSelected(viewer) {
|
|
2592
|
+
viewer.hide(viewer.getSelected(true));
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
function isolate(viewer, handles) {
|
|
2596
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2597
|
+
const handlesSet = new Set(handles2);
|
|
2598
|
+
const toDeselect = [];
|
|
2599
|
+
for (const handle of viewer.selector.selected) {
|
|
2600
|
+
if (!handlesSet.has(handle))
|
|
2601
|
+
toDeselect.push(handle);
|
|
2602
|
+
}
|
|
2603
|
+
viewer.deselect(toDeselect);
|
|
2604
|
+
viewer.visibilityManager.isolate(handles2);
|
|
2544
2605
|
viewer.emitEvent({ type: "isolate" });
|
|
2606
|
+
viewer.update();
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
function isolateSelected(viewer) {
|
|
2610
|
+
viewer.isolate(viewer.getSelected(true));
|
|
2545
2611
|
}
|
|
2546
2612
|
|
|
2547
2613
|
function regenerateAll(viewer) {
|
|
@@ -2556,17 +2622,25 @@ function resetView(viewer) {
|
|
|
2556
2622
|
viewer.executeCommand("clearSelected");
|
|
2557
2623
|
viewer.executeCommand("showAll");
|
|
2558
2624
|
viewer.executeCommand("explode", 0);
|
|
2559
|
-
viewer.executeCommand("
|
|
2625
|
+
viewer.executeCommand("zoomExtents");
|
|
2560
2626
|
viewer.emit({ type: "resetview" });
|
|
2561
2627
|
}
|
|
2562
2628
|
|
|
2563
|
-
function
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2566
|
-
viewer.
|
|
2629
|
+
function select(viewer, handles = []) {
|
|
2630
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2631
|
+
viewer.show(handles2);
|
|
2632
|
+
viewer.selector.select(handles2);
|
|
2633
|
+
viewer.emitEvent({ type: "select" });
|
|
2634
|
+
viewer.emitEvent({ type: "select2" });
|
|
2567
2635
|
viewer.update();
|
|
2568
|
-
|
|
2569
|
-
|
|
2636
|
+
}
|
|
2637
|
+
|
|
2638
|
+
function selectModel(viewer, id) {
|
|
2639
|
+
let handles = [];
|
|
2640
|
+
const model = viewer.models.find((model) => model.id === id);
|
|
2641
|
+
if (model)
|
|
2642
|
+
handles = model.getHandles();
|
|
2643
|
+
viewer.setSelected(handles);
|
|
2570
2644
|
}
|
|
2571
2645
|
|
|
2572
2646
|
function setActiveDragger(viewer, dragger = "") {
|
|
@@ -2578,60 +2652,64 @@ function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
|
2578
2652
|
}
|
|
2579
2653
|
|
|
2580
2654
|
function setSelected(viewer, handles = []) {
|
|
2581
|
-
const handles2 =
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
viewer.models.forEach((model) => {
|
|
2588
|
-
handles2.push(`${model.id}:${handle}`);
|
|
2589
|
-
});
|
|
2590
|
-
});
|
|
2591
|
-
viewer.executeCommand("setSelected2", handles2);
|
|
2655
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2656
|
+
viewer.show(handles2);
|
|
2657
|
+
viewer.selector.setSelected(handles2);
|
|
2658
|
+
viewer.emitEvent({ type: "select" });
|
|
2659
|
+
viewer.emitEvent({ type: "select2" });
|
|
2660
|
+
viewer.update();
|
|
2592
2661
|
}
|
|
2593
2662
|
|
|
2594
|
-
function setSelected2(viewer,
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
viewer.update();
|
|
2663
|
+
function setSelected2(viewer, handles2 = []) {
|
|
2664
|
+
console.warn("setSelected2 command has been deprecated since 27.11 and will be removed in a future release, use setSelected instead");
|
|
2665
|
+
viewer.executeCommand("setSelected", handles2);
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
function show(viewer, handles) {
|
|
2669
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2670
|
+
viewer.visibilityManager.show(handles2);
|
|
2603
2671
|
viewer.emitEvent({ type: "show" });
|
|
2604
|
-
viewer.
|
|
2605
|
-
viewer.emitEvent({ type: "select2", data: undefined, handles });
|
|
2672
|
+
viewer.update();
|
|
2606
2673
|
}
|
|
2607
2674
|
|
|
2608
2675
|
function showAll(viewer) {
|
|
2609
|
-
viewer.
|
|
2610
|
-
viewer.update();
|
|
2676
|
+
viewer.visibilityManager.showAll();
|
|
2611
2677
|
viewer.emitEvent({ type: "showall" });
|
|
2678
|
+
viewer.update();
|
|
2612
2679
|
}
|
|
2613
2680
|
|
|
2614
|
-
function
|
|
2615
|
-
|
|
2681
|
+
function toggleSelection(viewer, handles = []) {
|
|
2682
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2683
|
+
if (viewer.selector.selected.has(handles2[0])) {
|
|
2684
|
+
viewer.selector.deselect(handles2);
|
|
2685
|
+
}
|
|
2686
|
+
else {
|
|
2687
|
+
viewer.show(handles2);
|
|
2688
|
+
viewer.selector.select(handles2);
|
|
2689
|
+
}
|
|
2690
|
+
viewer.emitEvent({ type: "select" });
|
|
2691
|
+
viewer.emitEvent({ type: "select2" });
|
|
2692
|
+
viewer.update();
|
|
2616
2693
|
}
|
|
2617
2694
|
|
|
2618
|
-
function
|
|
2695
|
+
function zoomExtents(viewer) {
|
|
2696
|
+
zoom(viewer, viewer.extents);
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
function zoomTo(viewer, handles = []) {
|
|
2700
|
+
const handles2 = toHandles2(viewer, handles);
|
|
2619
2701
|
const extents = new Box3();
|
|
2620
2702
|
viewer.models.forEach((model) => {
|
|
2621
|
-
const objects = model.getObjectsByHandles(
|
|
2703
|
+
const objects = model.getObjectsByHandles(handles2);
|
|
2622
2704
|
objects.forEach((object) => extents.expandByObject(object));
|
|
2623
2705
|
});
|
|
2624
2706
|
if (extents.isEmpty())
|
|
2625
2707
|
extents.copy(viewer.extents);
|
|
2626
|
-
|
|
2708
|
+
zoom(viewer, extents);
|
|
2627
2709
|
}
|
|
2628
2710
|
|
|
2629
2711
|
function zoomToSelected(viewer) {
|
|
2630
|
-
|
|
2631
|
-
viewer.selected.forEach((object) => extents.expandByObject(object));
|
|
2632
|
-
if (extents.isEmpty())
|
|
2633
|
-
extents.copy(viewer.extents);
|
|
2634
|
-
zoomTo(viewer, extents);
|
|
2712
|
+
zoomTo(viewer, viewer.getSelected(true));
|
|
2635
2713
|
}
|
|
2636
2714
|
|
|
2637
2715
|
const commands = commandsRegistry("threejs");
|
|
@@ -2640,25 +2718,34 @@ commands.registerCommand("clearMarkup", clearMarkup);
|
|
|
2640
2718
|
commands.registerCommand("clearSelected", clearSelected);
|
|
2641
2719
|
commands.registerCommand("clearSlices", clearSlices);
|
|
2642
2720
|
commands.registerCommand("collect", collect);
|
|
2721
|
+
commands.registerCommand("deselect", deselect);
|
|
2643
2722
|
commands.registerCommand("getSnapshot", getSnapshot);
|
|
2644
2723
|
commands.registerCommand("explode", explode);
|
|
2645
2724
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
2646
2725
|
commands.registerCommand("getModels", getModels);
|
|
2647
2726
|
commands.registerCommand("getSelected", getSelected);
|
|
2648
2727
|
commands.registerCommand("getSelected2", getSelected2);
|
|
2728
|
+
commands.registerCommand("getHidden", getHidden);
|
|
2729
|
+
commands.registerCommand("getIsolated", getIsolated);
|
|
2730
|
+
commands.registerCommand("hide", hide);
|
|
2731
|
+
commands.registerCommand("hideAll", hideAll);
|
|
2649
2732
|
commands.registerCommand("hideSelected", hideSelected);
|
|
2733
|
+
commands.registerCommand("isolate", isolate);
|
|
2650
2734
|
commands.registerCommand("isolateSelected", isolateSelected);
|
|
2651
2735
|
commands.registerCommand("regenerateAll", regenerateAll);
|
|
2652
2736
|
commands.registerCommand("resetView", resetView);
|
|
2737
|
+
commands.registerCommand("select", select);
|
|
2653
2738
|
commands.registerCommand("selectModel", selectModel);
|
|
2654
2739
|
commands.registerCommand("setActiveDragger", setActiveDragger);
|
|
2655
2740
|
commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
2656
2741
|
commands.registerCommand("setMarkupColor", setMarkupColor);
|
|
2657
2742
|
commands.registerCommand("setSelected", setSelected);
|
|
2658
2743
|
commands.registerCommand("setSelected2", setSelected2);
|
|
2744
|
+
commands.registerCommand("show", show);
|
|
2659
2745
|
commands.registerCommand("showAll", showAll);
|
|
2660
|
-
commands.registerCommand("
|
|
2661
|
-
commands.registerCommand("
|
|
2746
|
+
commands.registerCommand("toggleSelection", toggleSelection);
|
|
2747
|
+
commands.registerCommand("zoomExtents", zoomExtents);
|
|
2748
|
+
commands.registerCommand("zoomTo", zoomTo);
|
|
2662
2749
|
commands.registerCommand("zoomToSelected", zoomToSelected);
|
|
2663
2750
|
commands.registerCommand("top", (viewer) => setDefaultViewPosition(viewer, "top"));
|
|
2664
2751
|
commands.registerCommand("bottom", (viewer) => setDefaultViewPosition(viewer, "bottom"));
|
|
@@ -2673,7 +2760,8 @@ commands.registerCommand("nw", (viewer) => setDefaultViewPosition(viewer, "nw"))
|
|
|
2673
2760
|
commands.registerCommandAlias("clearMarkup", "clearOverlay");
|
|
2674
2761
|
commands.registerCommandAlias("clearSelected", "unselect");
|
|
2675
2762
|
commands.registerCommandAlias("getSnapshot", "createPreview");
|
|
2676
|
-
commands.registerCommandAlias("
|
|
2763
|
+
commands.registerCommandAlias("zoomExtents", "zoomToExtents");
|
|
2764
|
+
commands.registerCommandAlias("zoomTo", "zoomToObjects");
|
|
2677
2765
|
commands.registerCommandAlias("top", "k3DViewTop");
|
|
2678
2766
|
commands.registerCommandAlias("bottom", "k3DViewBottom");
|
|
2679
2767
|
commands.registerCommandAlias("left", "k3DViewLeft");
|
|
@@ -3209,10 +3297,7 @@ class HighlighterComponent {
|
|
|
3209
3297
|
this.viewer.removeEventListener("optionschange", this.syncOptions);
|
|
3210
3298
|
this.viewer.removeEventListener("resize", this.viewerResize);
|
|
3211
3299
|
}
|
|
3212
|
-
|
|
3213
|
-
const { edgesVisibility } = this.viewer.options;
|
|
3214
|
-
if (!Array.isArray(objects))
|
|
3215
|
-
objects = [objects];
|
|
3300
|
+
highlightObjects(objects) {
|
|
3216
3301
|
if (objects.length === 0)
|
|
3217
3302
|
return;
|
|
3218
3303
|
objects
|
|
@@ -3227,7 +3312,7 @@ class HighlighterComponent {
|
|
|
3227
3312
|
? HighlighterUtils.fromIndexedLine(positions, indices)
|
|
3228
3313
|
: HighlighterUtils.fromNonIndexedLine(positions, object.isLineSegments);
|
|
3229
3314
|
const wireframe = new Wireframe(lineGeometry, this.lineGlowMaterial);
|
|
3230
|
-
wireframe.visible = edgesVisibility;
|
|
3315
|
+
wireframe.visible = this.viewer.options.edgesVisibility;
|
|
3231
3316
|
wireframe.userData.isHighlightWireframe = true;
|
|
3232
3317
|
object.add(wireframe);
|
|
3233
3318
|
object.userData.highlightWireframe = wireframe;
|
|
@@ -3239,7 +3324,7 @@ class HighlighterComponent {
|
|
|
3239
3324
|
const edgesGeometry = new EdgesGeometry(object.geometry, 89);
|
|
3240
3325
|
const lineGeometry = new LineSegmentsGeometry().fromEdgesGeometry(edgesGeometry);
|
|
3241
3326
|
const wireframe = new Wireframe(lineGeometry, this.edgesMaterial);
|
|
3242
|
-
wireframe.visible = edgesVisibility;
|
|
3327
|
+
wireframe.visible = this.viewer.options.edgesVisibility;
|
|
3243
3328
|
wireframe.userData.isHighlightWireframe = true;
|
|
3244
3329
|
object.add(wireframe);
|
|
3245
3330
|
object.userData.highlightWireframe = wireframe;
|
|
@@ -3249,16 +3334,16 @@ class HighlighterComponent {
|
|
|
3249
3334
|
}
|
|
3250
3335
|
});
|
|
3251
3336
|
}
|
|
3252
|
-
|
|
3253
|
-
if (!Array.isArray(objects))
|
|
3254
|
-
objects = [objects];
|
|
3337
|
+
unhighlightObjects(objects) {
|
|
3255
3338
|
if (objects.length === 0)
|
|
3256
3339
|
return;
|
|
3257
3340
|
objects.forEach((object) => {
|
|
3341
|
+
var _a, _b, _c;
|
|
3258
3342
|
if (!object.userData.isHighlighted)
|
|
3259
3343
|
return;
|
|
3260
3344
|
object.material = object.userData.originalMaterial;
|
|
3261
|
-
object.userData.highlightWireframe.removeFromParent();
|
|
3345
|
+
(_a = object.userData.highlightWireframe) === null || _a === void 0 ? void 0 : _a.removeFromParent();
|
|
3346
|
+
(_c = (_b = object.userData.highlightWireframe) === null || _b === void 0 ? void 0 : _b.geometry) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
3262
3347
|
delete object.userData.isHighlighted;
|
|
3263
3348
|
delete object.userData.originalMaterial;
|
|
3264
3349
|
delete object.userData.highlightWireframe;
|
|
@@ -3279,8 +3364,10 @@ class HighlighterComponent {
|
|
|
3279
3364
|
this.lineGlowMaterial.color.setRGB(edgesColor.r / 255, edgesColor.g / 255, edgesColor.b / 255);
|
|
3280
3365
|
this.lineGlowMaterial.depthTest = !edgesOverlap;
|
|
3281
3366
|
this.lineGlowMaterial.depthWrite = !edgesOverlap;
|
|
3282
|
-
this.viewer.
|
|
3283
|
-
|
|
3367
|
+
const handles = this.viewer.getSelected(true);
|
|
3368
|
+
const objects = this.viewer.models.flatMap((model) => model.getObjectsByHandles(handles));
|
|
3369
|
+
objects.forEach((object) => {
|
|
3370
|
+
const wireframe = object.userData.highlightWireframe;
|
|
3284
3371
|
if (wireframe)
|
|
3285
3372
|
wireframe.visible = edgesVisibility;
|
|
3286
3373
|
});
|
|
@@ -3311,91 +3398,38 @@ class SelectionComponent {
|
|
|
3311
3398
|
intersections.push({ ...intersects[0], model });
|
|
3312
3399
|
});
|
|
3313
3400
|
intersections = intersections.sort((a, b) => a.distance - b.distance);
|
|
3314
|
-
if (!event.shiftKey)
|
|
3315
|
-
this.clearSelection();
|
|
3316
3401
|
if (intersections.length > 0) {
|
|
3317
3402
|
const model = intersections[0].model;
|
|
3318
|
-
const handles = model.getHandlesByObjects(intersections[0].object);
|
|
3319
|
-
const objects = model.getObjectsByHandles(handles);
|
|
3403
|
+
const handles = model.getHandlesByObjects([intersections[0].object]);
|
|
3320
3404
|
if (!event.shiftKey)
|
|
3321
|
-
this.
|
|
3405
|
+
this.viewer.setSelected(handles);
|
|
3322
3406
|
else
|
|
3323
|
-
this.toggleSelection(
|
|
3407
|
+
this.viewer.toggleSelection(handles);
|
|
3408
|
+
}
|
|
3409
|
+
else {
|
|
3410
|
+
if (!event.shiftKey)
|
|
3411
|
+
this.viewer.clearSelected();
|
|
3324
3412
|
}
|
|
3325
|
-
this.viewer.update();
|
|
3326
|
-
this.viewer.emitEvent({ type: "select", data: undefined, handles: this.viewer.getSelected() });
|
|
3327
|
-
this.viewer.emitEvent({ type: "select2", data: undefined, handles: this.viewer.getSelected2() });
|
|
3328
3413
|
};
|
|
3329
3414
|
this.onDoubleClick = (event) => {
|
|
3330
3415
|
if (event.button !== 0)
|
|
3331
3416
|
return;
|
|
3332
|
-
this.viewer.
|
|
3333
|
-
};
|
|
3334
|
-
this.initHighlighter = () => {
|
|
3335
|
-
this.highlighter = this.viewer.getComponent("HighlighterComponent");
|
|
3417
|
+
this.viewer.zoomToSelected();
|
|
3336
3418
|
};
|
|
3337
3419
|
this.viewer = viewer;
|
|
3338
3420
|
this.downPosition = new Vector2();
|
|
3339
|
-
this.viewer.addEventListener("pointerdown", this.onPointerDown);
|
|
3340
|
-
this.viewer.addEventListener("pointerup", this.onPointerUp);
|
|
3341
|
-
this.viewer.addEventListener("dblclick", this.onDoubleClick);
|
|
3342
|
-
this.viewer.addEventListener("initialize", this.initHighlighter);
|
|
3421
|
+
this.viewer.canvas.addEventListener("pointerdown", this.onPointerDown);
|
|
3422
|
+
this.viewer.canvas.addEventListener("pointerup", this.onPointerUp);
|
|
3423
|
+
this.viewer.canvas.addEventListener("dblclick", this.onDoubleClick);
|
|
3343
3424
|
}
|
|
3344
3425
|
dispose() {
|
|
3345
|
-
this.viewer.removeEventListener("pointerdown", this.onPointerDown);
|
|
3346
|
-
this.viewer.removeEventListener("pointerup", this.onPointerUp);
|
|
3347
|
-
this.viewer.removeEventListener("dblclick", this.onDoubleClick);
|
|
3348
|
-
this.viewer.removeEventListener("initialize", this.initHighlighter);
|
|
3426
|
+
this.viewer.canvas.removeEventListener("pointerdown", this.onPointerDown);
|
|
3427
|
+
this.viewer.canvas.removeEventListener("pointerup", this.onPointerUp);
|
|
3428
|
+
this.viewer.canvas.removeEventListener("dblclick", this.onDoubleClick);
|
|
3349
3429
|
}
|
|
3350
3430
|
getMousePosition(event, target) {
|
|
3351
3431
|
return target.set(event.clientX, event.clientY);
|
|
3352
3432
|
}
|
|
3353
|
-
select(objects, model) {
|
|
3354
|
-
if (!model) {
|
|
3355
|
-
this.viewer.models.forEach((model) => this.select(objects, model));
|
|
3356
|
-
return;
|
|
3357
|
-
}
|
|
3358
|
-
if (!Array.isArray(objects))
|
|
3359
|
-
objects = [objects];
|
|
3360
|
-
if (objects.length === 0)
|
|
3361
|
-
return;
|
|
3362
|
-
model.highlightObjects(objects);
|
|
3363
|
-
this.highlighter.highlight(objects);
|
|
3364
|
-
objects.forEach((object) => this.viewer.selected.push(object));
|
|
3365
|
-
objects.forEach((object) => (object.userData.isSelected = true));
|
|
3366
|
-
}
|
|
3367
|
-
deselect(objects, model) {
|
|
3368
|
-
if (!model) {
|
|
3369
|
-
this.viewer.models.forEach((model) => this.select(objects, model));
|
|
3370
|
-
return;
|
|
3371
|
-
}
|
|
3372
|
-
if (!Array.isArray(objects))
|
|
3373
|
-
objects = [objects];
|
|
3374
|
-
if (objects.length === 0)
|
|
3375
|
-
return;
|
|
3376
|
-
model.unhighlightObjects(objects);
|
|
3377
|
-
this.highlighter.unhighlight(objects);
|
|
3378
|
-
this.viewer.selected = this.viewer.selected.filter((x) => !objects.includes(x));
|
|
3379
|
-
objects.forEach((object) => (object.userData.isSelected = false));
|
|
3380
|
-
}
|
|
3381
|
-
toggleSelection(objects, model) {
|
|
3382
|
-
if (!Array.isArray(objects))
|
|
3383
|
-
objects = [objects];
|
|
3384
|
-
if (objects.length === 0)
|
|
3385
|
-
return;
|
|
3386
|
-
if (objects[0].userData.isSelected)
|
|
3387
|
-
this.deselect(objects, model);
|
|
3388
|
-
else
|
|
3389
|
-
this.select(objects, model);
|
|
3390
|
-
}
|
|
3391
|
-
clearSelection() {
|
|
3392
|
-
if (this.viewer.selected.length === 0)
|
|
3393
|
-
return;
|
|
3394
|
-
this.viewer.models.forEach((model) => model.unhighlightObjects(this.viewer.selected));
|
|
3395
|
-
this.highlighter.unhighlight(this.viewer.selected);
|
|
3396
|
-
this.viewer.selected.forEach((object) => (object.userData.isSelected = false));
|
|
3397
|
-
this.viewer.selected.length = 0;
|
|
3398
|
-
}
|
|
3399
3433
|
}
|
|
3400
3434
|
|
|
3401
3435
|
class ClippingPlaneComponent {
|
|
@@ -4381,20 +4415,8 @@ class ModelImpl {
|
|
|
4381
4415
|
constructor(scene) {
|
|
4382
4416
|
this.id = "";
|
|
4383
4417
|
this.scene = scene;
|
|
4384
|
-
this.handleToObjects = new Map();
|
|
4385
4418
|
this.originalObjects = new Set();
|
|
4386
|
-
this.
|
|
4387
|
-
this.originalObjects.add(object);
|
|
4388
|
-
const handle = object.userData.handle;
|
|
4389
|
-
if (!handle)
|
|
4390
|
-
return;
|
|
4391
|
-
let objects = this.handleToObjects.get(handle);
|
|
4392
|
-
if (!objects) {
|
|
4393
|
-
objects = new Set();
|
|
4394
|
-
this.handleToObjects.set(handle, objects);
|
|
4395
|
-
}
|
|
4396
|
-
objects.add(object);
|
|
4397
|
-
});
|
|
4419
|
+
this.handleToObjects = new Map();
|
|
4398
4420
|
}
|
|
4399
4421
|
dispose() {
|
|
4400
4422
|
function disposeMaterial(material) {
|
|
@@ -4415,6 +4437,21 @@ class ModelImpl {
|
|
|
4415
4437
|
this.scene.traverse(disposeObject);
|
|
4416
4438
|
this.scene.clear();
|
|
4417
4439
|
}
|
|
4440
|
+
initialize() {
|
|
4441
|
+
this.scene.traverse((object) => {
|
|
4442
|
+
this.originalObjects.add(object);
|
|
4443
|
+
const handle = object.userData.handle;
|
|
4444
|
+
if (!handle)
|
|
4445
|
+
return;
|
|
4446
|
+
const fullHandle = `${this.id}:${handle}`;
|
|
4447
|
+
let objectsSet = this.handleToObjects.get(fullHandle);
|
|
4448
|
+
if (!objectsSet) {
|
|
4449
|
+
objectsSet = new Set();
|
|
4450
|
+
this.handleToObjects.set(fullHandle, objectsSet);
|
|
4451
|
+
}
|
|
4452
|
+
objectsSet.add(object);
|
|
4453
|
+
});
|
|
4454
|
+
}
|
|
4418
4455
|
getUnits() {
|
|
4419
4456
|
return "Meters";
|
|
4420
4457
|
}
|
|
@@ -4585,39 +4622,28 @@ class ModelImpl {
|
|
|
4585
4622
|
return objects;
|
|
4586
4623
|
}
|
|
4587
4624
|
getObjectsByHandles(handles) {
|
|
4588
|
-
if (!Array.isArray(handles))
|
|
4589
|
-
handles = [handles];
|
|
4590
|
-
const ownHandles = [];
|
|
4591
|
-
handles.forEach((handle) => {
|
|
4592
|
-
const index = handle.indexOf(":");
|
|
4593
|
-
if (index !== -1) {
|
|
4594
|
-
if (handle.slice(0, index) !== this.id)
|
|
4595
|
-
return;
|
|
4596
|
-
handle = handle.slice(index + 1);
|
|
4597
|
-
}
|
|
4598
|
-
ownHandles.push(handle);
|
|
4599
|
-
});
|
|
4600
|
-
const handlesSet = new Set(ownHandles);
|
|
4601
4625
|
const objects = [];
|
|
4602
|
-
|
|
4603
|
-
|
|
4626
|
+
handles.forEach((handle) => {
|
|
4627
|
+
const objectsSet = this.handleToObjects.get(handle);
|
|
4628
|
+
objects.push(Array.from(objectsSet || []));
|
|
4604
4629
|
});
|
|
4605
4630
|
return objects.flat();
|
|
4606
4631
|
}
|
|
4632
|
+
getHandles() {
|
|
4633
|
+
return Array.from(this.handleToObjects.keys());
|
|
4634
|
+
}
|
|
4607
4635
|
getHandlesByObjects(objects) {
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
handleSet.add(`${this.id}:${object.userData.handle}`);
|
|
4636
|
+
const handlesSet = new Set();
|
|
4637
|
+
objects.forEach((object) => {
|
|
4638
|
+
if (this.originalObjects.has(object)) {
|
|
4639
|
+
const fullHandle = `${this.id}:${object.userData.handle}`;
|
|
4640
|
+
handlesSet.add(fullHandle);
|
|
4641
|
+
}
|
|
4615
4642
|
});
|
|
4616
|
-
return Array.from(
|
|
4643
|
+
return Array.from(handlesSet);
|
|
4617
4644
|
}
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
objects = [objects];
|
|
4645
|
+
hide(handles) {
|
|
4646
|
+
const objects = this.getObjectsByHandles(handles);
|
|
4621
4647
|
objects
|
|
4622
4648
|
.filter((object) => this.originalObjects.has(object))
|
|
4623
4649
|
.forEach((object) => {
|
|
@@ -4625,40 +4651,48 @@ class ModelImpl {
|
|
|
4625
4651
|
});
|
|
4626
4652
|
return this;
|
|
4627
4653
|
}
|
|
4628
|
-
|
|
4629
|
-
return this.
|
|
4654
|
+
hideAll() {
|
|
4655
|
+
return this.isolate([]);
|
|
4630
4656
|
}
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
objects = [objects];
|
|
4657
|
+
isolate(handles) {
|
|
4658
|
+
const objects = this.getObjectsByHandles(handles);
|
|
4634
4659
|
const visibleSet = new Set(objects);
|
|
4635
4660
|
objects
|
|
4636
4661
|
.filter((object) => this.originalObjects.has(object))
|
|
4637
4662
|
.forEach((object) => {
|
|
4638
4663
|
object.traverseAncestors((parent) => visibleSet.add(parent));
|
|
4664
|
+
object.traverse((child) => visibleSet.add(child));
|
|
4639
4665
|
});
|
|
4640
4666
|
this.scene.traverse((object) => (object.visible = visibleSet.has(object)));
|
|
4641
4667
|
return this;
|
|
4642
4668
|
}
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
objects = [objects];
|
|
4669
|
+
show(handles) {
|
|
4670
|
+
const objects = this.getObjectsByHandles(handles);
|
|
4646
4671
|
objects
|
|
4647
4672
|
.filter((object) => this.originalObjects.has(object))
|
|
4648
4673
|
.forEach((object) => {
|
|
4649
4674
|
object.visible = true;
|
|
4650
4675
|
object.traverseAncestors((parent) => (parent.visible = true));
|
|
4676
|
+
object.traverse((child) => (child.visible = true));
|
|
4651
4677
|
});
|
|
4652
4678
|
return this;
|
|
4653
4679
|
}
|
|
4654
|
-
|
|
4680
|
+
showAll() {
|
|
4655
4681
|
this.scene.traverse((object) => (object.visible = true));
|
|
4656
4682
|
return this;
|
|
4657
4683
|
}
|
|
4658
|
-
|
|
4684
|
+
highlight(handles) {
|
|
4685
|
+
if (this.highlighter) {
|
|
4686
|
+
const objects = this.getObjectsByHandles(handles);
|
|
4687
|
+
this.highlighter.highlightObjects(objects);
|
|
4688
|
+
}
|
|
4659
4689
|
return this;
|
|
4660
4690
|
}
|
|
4661
|
-
|
|
4691
|
+
unhighlight(handles) {
|
|
4692
|
+
if (this.highlighter) {
|
|
4693
|
+
const objects = this.getObjectsByHandles(handles);
|
|
4694
|
+
this.highlighter.unhighlightObjects(objects);
|
|
4695
|
+
}
|
|
4662
4696
|
return this;
|
|
4663
4697
|
}
|
|
4664
4698
|
explode(scale = 0, coeff = 4) {
|
|
@@ -4668,13 +4702,14 @@ class ModelImpl {
|
|
|
4668
4702
|
const handle = object.userData.handle;
|
|
4669
4703
|
if (!handle)
|
|
4670
4704
|
return extents.getCenter(target);
|
|
4671
|
-
const
|
|
4705
|
+
const fullHandle = `${this.id}:${handle}`;
|
|
4706
|
+
const center = centersCache.get(fullHandle);
|
|
4672
4707
|
if (center)
|
|
4673
4708
|
return target.copy(center);
|
|
4674
|
-
const objects = this.getObjectsByHandles(
|
|
4709
|
+
const objects = this.getObjectsByHandles([fullHandle]);
|
|
4675
4710
|
objects.forEach((x) => extents.expandByObject(x));
|
|
4676
4711
|
extents.getCenter(target);
|
|
4677
|
-
centersCache.set(
|
|
4712
|
+
centersCache.set(fullHandle, target.clone());
|
|
4678
4713
|
return target;
|
|
4679
4714
|
};
|
|
4680
4715
|
const calcObjectOffset = (object, target) => {
|
|
@@ -4731,6 +4766,8 @@ class ModelImpl {
|
|
|
4731
4766
|
}
|
|
4732
4767
|
|
|
4733
4768
|
class DynamicModelImpl extends ModelImpl {
|
|
4769
|
+
initialize() {
|
|
4770
|
+
}
|
|
4734
4771
|
getInfo() {
|
|
4735
4772
|
const stats = this.gltfLoader.getStats();
|
|
4736
4773
|
const info = new Info();
|
|
@@ -4764,51 +4801,36 @@ class DynamicModelImpl extends ModelImpl {
|
|
|
4764
4801
|
return this.gltfLoader.getOriginalObjectForSelect();
|
|
4765
4802
|
}
|
|
4766
4803
|
getObjectsByHandles(handles) {
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
handlesSet.forEach((handle) => {
|
|
4772
|
-
objects.push(this.gltfLoader.getObjectsByHandle(handle));
|
|
4773
|
-
});
|
|
4774
|
-
return objects.flat();
|
|
4804
|
+
return handles.flatMap((handle) => this.gltfLoader.getObjectsByHandle(handle));
|
|
4805
|
+
}
|
|
4806
|
+
getHandles() {
|
|
4807
|
+
return Array.from(this.gltfLoader.handleToObjects.keys());
|
|
4775
4808
|
}
|
|
4776
4809
|
getHandlesByObjects(objects) {
|
|
4777
|
-
|
|
4778
|
-
objects = [objects];
|
|
4779
|
-
const handleSet = new Set();
|
|
4780
|
-
objects
|
|
4781
|
-
.filter((object) => this.gltfLoader.originalObjects.has(object))
|
|
4782
|
-
.forEach((object) => {
|
|
4783
|
-
handleSet.add(object.userData.handle);
|
|
4784
|
-
});
|
|
4785
|
-
return Array.from(handleSet);
|
|
4810
|
+
return this.gltfLoader.getHandlesByObjects(objects);
|
|
4786
4811
|
}
|
|
4787
|
-
|
|
4788
|
-
const handles = this.getHandlesByObjects(objects);
|
|
4812
|
+
hide(handles) {
|
|
4789
4813
|
this.gltfLoader.hideObjects(handles);
|
|
4790
4814
|
return this;
|
|
4791
4815
|
}
|
|
4792
|
-
|
|
4793
|
-
const handles = this.getHandlesByObjects(objects);
|
|
4816
|
+
isolate(handles) {
|
|
4794
4817
|
this.gltfLoader.isolateObjects(new Set(handles));
|
|
4795
4818
|
return this;
|
|
4796
4819
|
}
|
|
4797
|
-
|
|
4798
|
-
const handles = this.getHandlesByObjects(objects);
|
|
4820
|
+
show(handles) {
|
|
4799
4821
|
this.gltfLoader.showObjects(handles);
|
|
4800
4822
|
return this;
|
|
4801
4823
|
}
|
|
4802
|
-
|
|
4824
|
+
showAll() {
|
|
4803
4825
|
this.gltfLoader.showAllHiddenObjects();
|
|
4804
4826
|
return this;
|
|
4805
4827
|
}
|
|
4806
|
-
|
|
4807
|
-
this.gltfLoader.
|
|
4828
|
+
highlight(handles) {
|
|
4829
|
+
this.gltfLoader.highlightObjects(handles);
|
|
4808
4830
|
return this;
|
|
4809
4831
|
}
|
|
4810
|
-
|
|
4811
|
-
this.gltfLoader.
|
|
4832
|
+
unhighlight(handles) {
|
|
4833
|
+
this.gltfLoader.unhighlightObjects(handles);
|
|
4812
4834
|
return this;
|
|
4813
4835
|
}
|
|
4814
4836
|
explode(scale = 0, coeff = 4) {
|
|
@@ -4818,13 +4840,14 @@ class DynamicModelImpl extends ModelImpl {
|
|
|
4818
4840
|
const handle = object.userData.handle;
|
|
4819
4841
|
if (!handle)
|
|
4820
4842
|
return extents.getCenter(target);
|
|
4821
|
-
const
|
|
4843
|
+
const fullHandle = handle;
|
|
4844
|
+
const center = centersCache.get(fullHandle);
|
|
4822
4845
|
if (center)
|
|
4823
4846
|
return target.copy(center);
|
|
4824
|
-
const objects = this.getObjectsByHandles(
|
|
4847
|
+
const objects = this.getObjectsByHandles([fullHandle]);
|
|
4825
4848
|
objects.forEach((x) => extents.expandByObject(x));
|
|
4826
4849
|
extents.getCenter(target);
|
|
4827
|
-
centersCache.set(
|
|
4850
|
+
centersCache.set(fullHandle, target.clone());
|
|
4828
4851
|
return target;
|
|
4829
4852
|
};
|
|
4830
4853
|
const calcObjectOffset = (object, target) => {
|
|
@@ -5549,6 +5572,9 @@ class GltfStructure {
|
|
|
5549
5572
|
|
|
5550
5573
|
const DRACO_EXTENSION_NAME = "KHR_draco_mesh_compression";
|
|
5551
5574
|
const STRUCTURE_ID_SEPARATOR = ":";
|
|
5575
|
+
const MAX_HIGHLIGHT_STYLES = 8;
|
|
5576
|
+
const HIGHLIGHT_STYLE_VEC4_COUNT = 4;
|
|
5577
|
+
const HIGHLIGHT_OVERLAY_RENDER_ORDER = 999;
|
|
5552
5578
|
class DynamicGltfLoader {
|
|
5553
5579
|
constructor(camera, scene, renderer) {
|
|
5554
5580
|
this.camera = camera;
|
|
@@ -5622,6 +5648,24 @@ class DynamicGltfLoader {
|
|
|
5622
5648
|
this.transformData = null;
|
|
5623
5649
|
this.identityTransformData = null;
|
|
5624
5650
|
this.visibilityMaterials = new Set();
|
|
5651
|
+
this.colorOverrides = new Map();
|
|
5652
|
+
this.highlightedHandles = new Map();
|
|
5653
|
+
this.highlightStyles = [];
|
|
5654
|
+
this.highlightStyleNames = new Map();
|
|
5655
|
+
this.highlightOverlays = new Map();
|
|
5656
|
+
this.highlightOverlayMaterials = null;
|
|
5657
|
+
this.objectStateTextureSize = 1;
|
|
5658
|
+
this.colorOverrideData = new Uint8Array(4);
|
|
5659
|
+
this.highlightData = new Uint8Array(4);
|
|
5660
|
+
this.objectStateUniforms = {
|
|
5661
|
+
colorOverrideTexture: { value: this.createObjectStateTexture(this.colorOverrideData, 1) },
|
|
5662
|
+
highlightTexture: { value: this.createObjectStateTexture(this.highlightData, 1) },
|
|
5663
|
+
objectStateTextureSize: { value: 1 },
|
|
5664
|
+
highlightStyles: {
|
|
5665
|
+
value: Array.from({ length: MAX_HIGHLIGHT_STYLES * HIGHLIGHT_STYLE_VEC4_COUNT }, () => new Vector4()),
|
|
5666
|
+
},
|
|
5667
|
+
};
|
|
5668
|
+
this.setHighlightStyle("default", {});
|
|
5625
5669
|
this._dracoLoader = null;
|
|
5626
5670
|
}
|
|
5627
5671
|
setDracoLoader(loader = null) {
|
|
@@ -5849,6 +5893,25 @@ class DynamicGltfLoader {
|
|
|
5849
5893
|
material.needsUpdate = true;
|
|
5850
5894
|
});
|
|
5851
5895
|
}
|
|
5896
|
+
createObjectStateTexture(data, size) {
|
|
5897
|
+
const texture = new DataTexture(data, size, size, RGBAFormat, UnsignedByteType);
|
|
5898
|
+
texture.minFilter = NearestFilter;
|
|
5899
|
+
texture.magFilter = NearestFilter;
|
|
5900
|
+
texture.generateMipmaps = false;
|
|
5901
|
+
texture.needsUpdate = true;
|
|
5902
|
+
return texture;
|
|
5903
|
+
}
|
|
5904
|
+
initObjectStateTextures() {
|
|
5905
|
+
const size = Math.max(1, Math.ceil(Math.sqrt(this.maxObjectId + 1)));
|
|
5906
|
+
this.objectStateUniforms.colorOverrideTexture.value.dispose();
|
|
5907
|
+
this.objectStateUniforms.highlightTexture.value.dispose();
|
|
5908
|
+
this.objectStateTextureSize = size;
|
|
5909
|
+
this.colorOverrideData = new Uint8Array(size * size * 4);
|
|
5910
|
+
this.highlightData = new Uint8Array(size * size * 4);
|
|
5911
|
+
this.objectStateUniforms.colorOverrideTexture.value = this.createObjectStateTexture(this.colorOverrideData, size);
|
|
5912
|
+
this.objectStateUniforms.highlightTexture.value = this.createObjectStateTexture(this.highlightData, size);
|
|
5913
|
+
this.objectStateUniforms.objectStateTextureSize.value = size;
|
|
5914
|
+
}
|
|
5852
5915
|
_resetTransformData(updateTexture = true) {
|
|
5853
5916
|
if (!this.transformData || !this.identityTransformData) return;
|
|
5854
5917
|
this.transformData.set(this.identityTransformData);
|
|
@@ -6512,6 +6575,15 @@ class DynamicGltfLoader {
|
|
|
6512
6575
|
if (meshDef.extras && meshDef.extras.handle) {
|
|
6513
6576
|
handle = this.getFullHandle(structure.id, meshDef.extras.handle);
|
|
6514
6577
|
}
|
|
6578
|
+
if (!handle) {
|
|
6579
|
+
handle =
|
|
6580
|
+
isEdge && structure._lastFaceHandle
|
|
6581
|
+
? structure._lastFaceHandle
|
|
6582
|
+
: this.getFullHandle(structure.id, structure._nextObjectId++);
|
|
6583
|
+
}
|
|
6584
|
+
if (!isEdge) {
|
|
6585
|
+
structure._lastFaceHandle = handle;
|
|
6586
|
+
}
|
|
6515
6587
|
this.nodes.set(uniqueNodeId, {
|
|
6516
6588
|
position: nodeGroup ? nodeGroup.position.clone() : new Vector3().setFromMatrixPosition(nodeMatrix),
|
|
6517
6589
|
nodeIndex: nodeId,
|
|
@@ -6523,7 +6595,7 @@ class DynamicGltfLoader {
|
|
|
6523
6595
|
structure,
|
|
6524
6596
|
extras: nodeDef.extras,
|
|
6525
6597
|
geometryExtents,
|
|
6526
|
-
handle
|
|
6598
|
+
handle,
|
|
6527
6599
|
});
|
|
6528
6600
|
}
|
|
6529
6601
|
if (nodeDef.children) {
|
|
@@ -6760,16 +6832,28 @@ class DynamicGltfLoader {
|
|
|
6760
6832
|
}
|
|
6761
6833
|
}
|
|
6762
6834
|
}
|
|
6763
|
-
createVisibilityMaterial(material) {
|
|
6835
|
+
createVisibilityMaterial(material, options = {}) {
|
|
6764
6836
|
this.visibilityMaterials.add(material);
|
|
6765
6837
|
const uniforms = {
|
|
6766
6838
|
transformTexture: { value: this.transformTexture },
|
|
6767
6839
|
transformTextureSize: { value: this.transformTextureSize },
|
|
6768
6840
|
};
|
|
6769
6841
|
material.userData.visibilityUniforms = uniforms;
|
|
6842
|
+
const stateUniforms = this.objectStateUniforms;
|
|
6843
|
+
material.defines = material.defines || {};
|
|
6844
|
+
if (material.name === "edges" || options.edges) {
|
|
6845
|
+
material.defines.HL_IS_EDGE = "";
|
|
6846
|
+
}
|
|
6847
|
+
if (options.overlay) {
|
|
6848
|
+
material.defines.HL_OVERLAY = "";
|
|
6849
|
+
}
|
|
6770
6850
|
material.onBeforeCompile = (shader) => {
|
|
6771
6851
|
shader.uniforms.transformTexture = uniforms.transformTexture;
|
|
6772
6852
|
shader.uniforms.transformTextureSize = uniforms.transformTextureSize;
|
|
6853
|
+
shader.uniforms.colorOverrideTexture = stateUniforms.colorOverrideTexture;
|
|
6854
|
+
shader.uniforms.highlightTexture = stateUniforms.highlightTexture;
|
|
6855
|
+
shader.uniforms.objectStateTextureSize = stateUniforms.objectStateTextureSize;
|
|
6856
|
+
shader.uniforms.highlightStyles = stateUniforms.highlightStyles;
|
|
6773
6857
|
shader.vertexShader = shader.vertexShader.replace(
|
|
6774
6858
|
"#include <common>",
|
|
6775
6859
|
`
|
|
@@ -6795,6 +6879,18 @@ class DynamicGltfLoader {
|
|
|
6795
6879
|
|
|
6796
6880
|
return mat4(row0, row1, row2, row3);
|
|
6797
6881
|
}
|
|
6882
|
+
|
|
6883
|
+
uniform highp sampler2D colorOverrideTexture;
|
|
6884
|
+
uniform highp sampler2D highlightTexture;
|
|
6885
|
+
uniform float objectStateTextureSize;
|
|
6886
|
+
varying vec4 vColorOverride;
|
|
6887
|
+
varying float vHighlightStyle;
|
|
6888
|
+
|
|
6889
|
+
ivec2 getObjectStateCoord(float instanceId) {
|
|
6890
|
+
int size = int(objectStateTextureSize);
|
|
6891
|
+
int index = int(instanceId);
|
|
6892
|
+
return ivec2(index % size, index / size);
|
|
6893
|
+
}
|
|
6798
6894
|
`
|
|
6799
6895
|
);
|
|
6800
6896
|
shader.vertexShader = shader.vertexShader.replace(
|
|
@@ -6803,6 +6899,9 @@ class DynamicGltfLoader {
|
|
|
6803
6899
|
void main() {
|
|
6804
6900
|
mat4 batchingMatrix = getTransformMatrix(objectId);
|
|
6805
6901
|
vVisibility = visibility;
|
|
6902
|
+
ivec2 objectStateCoord = getObjectStateCoord(objectId);
|
|
6903
|
+
vColorOverride = texelFetch(colorOverrideTexture, objectStateCoord, 0);
|
|
6904
|
+
vHighlightStyle = floor(texelFetch(highlightTexture, objectStateCoord, 0).r * 255.0 + 0.5) - 1.0;
|
|
6806
6905
|
`
|
|
6807
6906
|
);
|
|
6808
6907
|
if (shader.vertexShader.includes("#include <beginnormal_vertex>")) {
|
|
@@ -6832,6 +6931,27 @@ class DynamicGltfLoader {
|
|
|
6832
6931
|
`
|
|
6833
6932
|
#include <common>
|
|
6834
6933
|
varying float vVisibility;
|
|
6934
|
+
varying vec4 vColorOverride;
|
|
6935
|
+
varying float vHighlightStyle;
|
|
6936
|
+
uniform vec4 highlightStyles[${MAX_HIGHLIGHT_STYLES * HIGHLIGHT_STYLE_VEC4_COUNT}];
|
|
6937
|
+
|
|
6938
|
+
// Edges color for the "edges" material, faces color for everything else
|
|
6939
|
+
vec4 getHighlightColor(int base) {
|
|
6940
|
+
#ifdef HL_IS_EDGE
|
|
6941
|
+
return highlightStyles[base + 1];
|
|
6942
|
+
#else
|
|
6943
|
+
return highlightStyles[base];
|
|
6944
|
+
#endif
|
|
6945
|
+
}
|
|
6946
|
+
|
|
6947
|
+
// Edges overlap flag for the "edges" material, faces overlap for everything else
|
|
6948
|
+
float getHighlightOverlay(int base) {
|
|
6949
|
+
#ifdef HL_IS_EDGE
|
|
6950
|
+
return highlightStyles[base + 3].x;
|
|
6951
|
+
#else
|
|
6952
|
+
return highlightStyles[base + 2].z;
|
|
6953
|
+
#endif
|
|
6954
|
+
}
|
|
6835
6955
|
`
|
|
6836
6956
|
)
|
|
6837
6957
|
.replace(
|
|
@@ -6839,6 +6959,45 @@ class DynamicGltfLoader {
|
|
|
6839
6959
|
`
|
|
6840
6960
|
void main() {
|
|
6841
6961
|
if (vVisibility < 0.5) discard;
|
|
6962
|
+
#ifdef HL_OVERLAY
|
|
6963
|
+
if (vHighlightStyle < 0.0 || getHighlightOverlay(int(vHighlightStyle) * ${HIGHLIGHT_STYLE_VEC4_COUNT}) < 0.5) discard;
|
|
6964
|
+
#endif
|
|
6965
|
+
`
|
|
6966
|
+
)
|
|
6967
|
+
.replace(
|
|
6968
|
+
"#include <color_fragment>",
|
|
6969
|
+
`
|
|
6970
|
+
#include <color_fragment>
|
|
6971
|
+
if (vColorOverride.a > 0.5) diffuseColor.rgb = vColorOverride.rgb;
|
|
6972
|
+
#ifdef HL_OVERLAY
|
|
6973
|
+
{
|
|
6974
|
+
int hlBase = int(vHighlightStyle) * ${HIGHLIGHT_STYLE_VEC4_COUNT};
|
|
6975
|
+
// Blend factor becomes overlay alpha: blends highlight with what is underneath
|
|
6976
|
+
vec4 hlColor = getHighlightColor(hlBase);
|
|
6977
|
+
diffuseColor = vec4(hlColor.rgb, highlightStyles[hlBase + 2].y * hlColor.a);
|
|
6978
|
+
}
|
|
6979
|
+
#else
|
|
6980
|
+
if (vHighlightStyle >= 0.0) {
|
|
6981
|
+
int hlBase = int(vHighlightStyle) * ${HIGHLIGHT_STYLE_VEC4_COUNT};
|
|
6982
|
+
vec4 hlColor = getHighlightColor(hlBase);
|
|
6983
|
+
// With overlap the overlay pass does the blending, keep the original color here
|
|
6984
|
+
float hlMix = getHighlightOverlay(hlBase) > 0.5 ? 0.0 : hlColor.a;
|
|
6985
|
+
diffuseColor.rgb = mix(diffuseColor.rgb, hlColor.rgb, hlMix);
|
|
6986
|
+
// Keep highlighted objects readable even when the material is dimmed (e.g. X-ray)
|
|
6987
|
+
if (highlightStyles[hlBase + 2].w >= 0.0) diffuseColor.a = highlightStyles[hlBase + 2].w;
|
|
6988
|
+
}
|
|
6989
|
+
#endif
|
|
6990
|
+
`
|
|
6991
|
+
)
|
|
6992
|
+
.replace(
|
|
6993
|
+
"#include <opaque_fragment>",
|
|
6994
|
+
`
|
|
6995
|
+
if (vHighlightStyle >= 0.0) {
|
|
6996
|
+
int hlBase = int(vHighlightStyle) * ${HIGHLIGHT_STYLE_VEC4_COUNT};
|
|
6997
|
+
vec4 hlColor = getHighlightColor(hlBase);
|
|
6998
|
+
outgoingLight += hlColor.rgb * hlColor.a * highlightStyles[hlBase + 2].x;
|
|
6999
|
+
}
|
|
7000
|
+
#include <opaque_fragment>
|
|
6842
7001
|
`
|
|
6843
7002
|
);
|
|
6844
7003
|
};
|
|
@@ -6900,6 +7059,7 @@ class DynamicGltfLoader {
|
|
|
6900
7059
|
}
|
|
6901
7060
|
});
|
|
6902
7061
|
this.structureRoots.clear();
|
|
7062
|
+
this._disposeHighlightOverlays();
|
|
6903
7063
|
this.mergedMesh.forEach((mesh) => {
|
|
6904
7064
|
if (mesh.geometry) mesh.geometry.dispose();
|
|
6905
7065
|
if (mesh.material) {
|
|
@@ -6958,6 +7118,9 @@ class DynamicGltfLoader {
|
|
|
6958
7118
|
this.objectVisibility = new Float32Array();
|
|
6959
7119
|
this.meshToNodeMap = null;
|
|
6960
7120
|
this.visibilityMaterials.clear();
|
|
7121
|
+
this.colorOverrides.clear();
|
|
7122
|
+
this.highlightedHandles.clear();
|
|
7123
|
+
this.initObjectStateTextures();
|
|
6961
7124
|
}
|
|
6962
7125
|
setStructureTransform(structureId, matrix) {
|
|
6963
7126
|
const rootGroup = this.structureRoots.get(structureId);
|
|
@@ -7121,6 +7284,7 @@ class DynamicGltfLoader {
|
|
|
7121
7284
|
if (totalObjectsToMerge > 0) {
|
|
7122
7285
|
this.maxObjectId = totalObjectsToMerge;
|
|
7123
7286
|
this.initTransformTexture();
|
|
7287
|
+
this.initObjectStateTextures();
|
|
7124
7288
|
this.initializeObjectVisibility();
|
|
7125
7289
|
this.maxObjectId = 0;
|
|
7126
7290
|
}
|
|
@@ -7168,6 +7332,8 @@ class DynamicGltfLoader {
|
|
|
7168
7332
|
this.originalObjectsToSelection.add(obj);
|
|
7169
7333
|
}
|
|
7170
7334
|
});
|
|
7335
|
+
this.syncColorOverrides();
|
|
7336
|
+
this.syncHighlightedObjects();
|
|
7171
7337
|
console.log(`Optimization complete. Total objects: ${this.maxObjectId}`);
|
|
7172
7338
|
this.dispatchEvent("optimizationprogress", {
|
|
7173
7339
|
phase: "complete",
|
|
@@ -7724,6 +7890,217 @@ class DynamicGltfLoader {
|
|
|
7724
7890
|
});
|
|
7725
7891
|
this.syncHiddenObjects();
|
|
7726
7892
|
}
|
|
7893
|
+
setColorByHandle(handle, color) {
|
|
7894
|
+
if (color === null || color === undefined) {
|
|
7895
|
+
this.colorOverrides.delete(handle);
|
|
7896
|
+
} else {
|
|
7897
|
+
this.colorOverrides.set(handle, new Color(color));
|
|
7898
|
+
}
|
|
7899
|
+
this.syncColorOverrides();
|
|
7900
|
+
}
|
|
7901
|
+
setColorByHandles(handles, color) {
|
|
7902
|
+
const overrideColor = new Color(color);
|
|
7903
|
+
handles.forEach((handle) => {
|
|
7904
|
+
this.colorOverrides.set(handle, overrideColor);
|
|
7905
|
+
});
|
|
7906
|
+
this.syncColorOverrides();
|
|
7907
|
+
}
|
|
7908
|
+
clearColorByHandles(handles) {
|
|
7909
|
+
handles.forEach((handle) => {
|
|
7910
|
+
this.colorOverrides.delete(handle);
|
|
7911
|
+
});
|
|
7912
|
+
this.syncColorOverrides();
|
|
7913
|
+
}
|
|
7914
|
+
setColorsByHandles(colors) {
|
|
7915
|
+
for (const [handle, color] of colors) {
|
|
7916
|
+
if (color === null || color === undefined) {
|
|
7917
|
+
this.colorOverrides.delete(handle);
|
|
7918
|
+
} else {
|
|
7919
|
+
this.colorOverrides.set(handle, new Color(color));
|
|
7920
|
+
}
|
|
7921
|
+
}
|
|
7922
|
+
this.syncColorOverrides();
|
|
7923
|
+
}
|
|
7924
|
+
clearAllColorOverrides() {
|
|
7925
|
+
this.colorOverrides.clear();
|
|
7926
|
+
this.syncColorOverrides();
|
|
7927
|
+
}
|
|
7928
|
+
getOptimizedHandles() {
|
|
7929
|
+
return Array.from(this.handleToOptimizedObjects.keys());
|
|
7930
|
+
}
|
|
7931
|
+
syncColorOverrides() {
|
|
7932
|
+
const data = this.colorOverrideData;
|
|
7933
|
+
const texelCount = data.length / 4;
|
|
7934
|
+
data.fill(0);
|
|
7935
|
+
this.colorOverrides.forEach((color, handle) => {
|
|
7936
|
+
const index = this.objectIdToIndex.get(handle);
|
|
7937
|
+
if (index === undefined || index >= texelCount) return;
|
|
7938
|
+
const offset = index * 4;
|
|
7939
|
+
data[offset] = Math.round(MathUtils.clamp(color.r, 0, 1) * 255);
|
|
7940
|
+
data[offset + 1] = Math.round(MathUtils.clamp(color.g, 0, 1) * 255);
|
|
7941
|
+
data[offset + 2] = Math.round(MathUtils.clamp(color.b, 0, 1) * 255);
|
|
7942
|
+
data[offset + 3] = 255;
|
|
7943
|
+
});
|
|
7944
|
+
this.objectStateUniforms.colorOverrideTexture.value.needsUpdate = true;
|
|
7945
|
+
}
|
|
7946
|
+
setHighlightStyle(name, settings = {}) {
|
|
7947
|
+
let index = this.highlightStyleNames.get(name);
|
|
7948
|
+
if (index === undefined) {
|
|
7949
|
+
if (this.highlightStyles.length >= MAX_HIGHLIGHT_STYLES) {
|
|
7950
|
+
console.warn(`DynamicLoader: Max highlight styles (${MAX_HIGHLIGHT_STYLES}) reached, "${name}" ignored`);
|
|
7951
|
+
return;
|
|
7952
|
+
}
|
|
7953
|
+
index = this.highlightStyles.length;
|
|
7954
|
+
this.highlightStyleNames.set(name, index);
|
|
7955
|
+
}
|
|
7956
|
+
const style = {
|
|
7957
|
+
fillColor: new Color(settings.fillColor ?? 0x4aa9fa),
|
|
7958
|
+
fillMix: settings.fillMix ?? 1,
|
|
7959
|
+
fillOpacity: settings.fillOpacity ?? -1,
|
|
7960
|
+
lineColor: new Color(settings.lineColor ?? settings.fillColor ?? 0x4aa9fa),
|
|
7961
|
+
lineMix: settings.lineMix ?? 1,
|
|
7962
|
+
emissiveIntensity: settings.emissiveIntensity ?? 0,
|
|
7963
|
+
facesOverlay: settings.facesOverlay ?? settings.overlay ?? true,
|
|
7964
|
+
edgesOverlay: settings.edgesOverlay ?? settings.overlay ?? true,
|
|
7965
|
+
overlayOpacity: settings.overlayOpacity ?? 1,
|
|
7966
|
+
};
|
|
7967
|
+
this.highlightStyles[index] = style;
|
|
7968
|
+
const vectors = this.objectStateUniforms.highlightStyles.value;
|
|
7969
|
+
const base = index * HIGHLIGHT_STYLE_VEC4_COUNT;
|
|
7970
|
+
vectors[base].set(style.fillColor.r, style.fillColor.g, style.fillColor.b, style.fillMix);
|
|
7971
|
+
vectors[base + 1].set(style.lineColor.r, style.lineColor.g, style.lineColor.b, style.lineMix);
|
|
7972
|
+
vectors[base + 2].set(style.emissiveIntensity, style.overlayOpacity, style.facesOverlay ? 1 : 0, style.fillOpacity);
|
|
7973
|
+
vectors[base + 3].set(style.edgesOverlay ? 1 : 0, 0, 0, 0);
|
|
7974
|
+
if (this.highlightedHandles.size !== 0) {
|
|
7975
|
+
this.syncHighlightedObjects();
|
|
7976
|
+
}
|
|
7977
|
+
}
|
|
7978
|
+
setHighlightSettings(settings = {}, styleName = "default") {
|
|
7979
|
+
const index = this.highlightStyleNames.get(styleName);
|
|
7980
|
+
const current = index !== undefined ? this.highlightStyles[index] : {};
|
|
7981
|
+
const merged = {
|
|
7982
|
+
facesColor: current.fillColor,
|
|
7983
|
+
edgesColor: current.lineColor,
|
|
7984
|
+
edgesVisibility: true,
|
|
7985
|
+
edgesOverlap: true,
|
|
7986
|
+
facesOverlap: true,
|
|
7987
|
+
colorBlend: 1,
|
|
7988
|
+
...current.viewerSettings,
|
|
7989
|
+
...settings,
|
|
7990
|
+
};
|
|
7991
|
+
this.setHighlightStyle(styleName, {
|
|
7992
|
+
...current,
|
|
7993
|
+
fillColor: merged.facesColor,
|
|
7994
|
+
lineColor: merged.edgesColor,
|
|
7995
|
+
fillMix: merged.colorBlend,
|
|
7996
|
+
lineMix: merged.edgesVisibility ? merged.colorBlend : 0,
|
|
7997
|
+
facesOverlay: merged.facesOverlap,
|
|
7998
|
+
edgesOverlay: merged.edgesVisibility && merged.edgesOverlap,
|
|
7999
|
+
});
|
|
8000
|
+
const style = this.highlightStyles[this.highlightStyleNames.get(styleName)];
|
|
8001
|
+
if (style) style.viewerSettings = merged;
|
|
8002
|
+
}
|
|
8003
|
+
highlightObjects(handles, styleName = "default") {
|
|
8004
|
+
const styleIndex = this.highlightStyleNames.get(styleName);
|
|
8005
|
+
if (styleIndex === undefined) {
|
|
8006
|
+
console.warn(`DynamicLoader: Unknown highlight style "${styleName}"`);
|
|
8007
|
+
return;
|
|
8008
|
+
}
|
|
8009
|
+
handles.forEach((handle) => {
|
|
8010
|
+
this.highlightedHandles.set(handle, styleIndex);
|
|
8011
|
+
});
|
|
8012
|
+
this.syncHighlightedObjects();
|
|
8013
|
+
}
|
|
8014
|
+
unhighlightObjects(handles) {
|
|
8015
|
+
handles.forEach((handle) => {
|
|
8016
|
+
this.highlightedHandles.delete(handle);
|
|
8017
|
+
});
|
|
8018
|
+
this.syncHighlightedObjects();
|
|
8019
|
+
}
|
|
8020
|
+
unhighlightAllObjects() {
|
|
8021
|
+
this.highlightedHandles.clear();
|
|
8022
|
+
this.syncHighlightedObjects();
|
|
8023
|
+
}
|
|
8024
|
+
isHandleHighlighted(handle) {
|
|
8025
|
+
return this.highlightedHandles.has(handle);
|
|
8026
|
+
}
|
|
8027
|
+
isHandleOptimized(handle) {
|
|
8028
|
+
return this.handleToOptimizedObjects.has(handle);
|
|
8029
|
+
}
|
|
8030
|
+
syncHighlightedObjects() {
|
|
8031
|
+
const data = this.highlightData;
|
|
8032
|
+
const texelCount = data.length / 4;
|
|
8033
|
+
data.fill(0);
|
|
8034
|
+
const overlayTargets = new Set();
|
|
8035
|
+
this.highlightedHandles.forEach((styleIndex, handle) => {
|
|
8036
|
+
const index = this.objectIdToIndex.get(handle);
|
|
8037
|
+
if (index === undefined || index >= texelCount) return;
|
|
8038
|
+
data[index * 4] = styleIndex + 1;
|
|
8039
|
+
const style = this.highlightStyles[styleIndex];
|
|
8040
|
+
if (style.facesOverlay || style.edgesOverlay) {
|
|
8041
|
+
const mergedObjects = this.handleToOptimizedObjects.get(handle);
|
|
8042
|
+
if (!mergedObjects) return;
|
|
8043
|
+
mergedObjects.forEach((object) => {
|
|
8044
|
+
if (object.userData.isEdge ? style.edgesOverlay : style.facesOverlay) overlayTargets.add(object);
|
|
8045
|
+
});
|
|
8046
|
+
}
|
|
8047
|
+
});
|
|
8048
|
+
this.objectStateUniforms.highlightTexture.value.needsUpdate = true;
|
|
8049
|
+
this.highlightOverlays.forEach((overlay, mergedObject) => {
|
|
8050
|
+
overlay.visible = overlayTargets.has(mergedObject);
|
|
8051
|
+
});
|
|
8052
|
+
overlayTargets.forEach((mergedObject) => {
|
|
8053
|
+
if (!this.highlightOverlays.has(mergedObject)) {
|
|
8054
|
+
this._createHighlightOverlay(mergedObject);
|
|
8055
|
+
}
|
|
8056
|
+
});
|
|
8057
|
+
}
|
|
8058
|
+
_getHighlightOverlayMaterial(mergedObject) {
|
|
8059
|
+
if (!this.highlightOverlayMaterials) {
|
|
8060
|
+
const common = { transparent: true, depthTest: false, depthWrite: false };
|
|
8061
|
+
this.highlightOverlayMaterials = {
|
|
8062
|
+
mesh: this.createVisibilityMaterial(new MeshPhongMaterial({ ...common, specular: 0x222222, shininess: 0 }), {
|
|
8063
|
+
overlay: true,
|
|
8064
|
+
}),
|
|
8065
|
+
line: this.createVisibilityMaterial(new LineBasicMaterial({ ...common }), { overlay: true }),
|
|
8066
|
+
edges: this.createVisibilityMaterial(new LineBasicMaterial({ ...common }), { overlay: true, edges: true }),
|
|
8067
|
+
points: this.createVisibilityMaterial(new PointsMaterial({ ...common, size: 0.05, sizeAttenuation: false }), {
|
|
8068
|
+
overlay: true,
|
|
8069
|
+
}),
|
|
8070
|
+
};
|
|
8071
|
+
}
|
|
8072
|
+
if (mergedObject.isPoints) return this.highlightOverlayMaterials.points;
|
|
8073
|
+
if (mergedObject.isLine) {
|
|
8074
|
+
return mergedObject.userData.isEdge ? this.highlightOverlayMaterials.edges : this.highlightOverlayMaterials.line;
|
|
8075
|
+
}
|
|
8076
|
+
return this.highlightOverlayMaterials.mesh;
|
|
8077
|
+
}
|
|
8078
|
+
_createHighlightOverlay(mergedObject) {
|
|
8079
|
+
const overlay = new mergedObject.constructor(
|
|
8080
|
+
mergedObject.geometry,
|
|
8081
|
+
this._getHighlightOverlayMaterial(mergedObject)
|
|
8082
|
+
);
|
|
8083
|
+
overlay.frustumCulled = false;
|
|
8084
|
+
overlay.renderOrder = HIGHLIGHT_OVERLAY_RENDER_ORDER;
|
|
8085
|
+
overlay.raycast = () => {};
|
|
8086
|
+
overlay.userData.isHighlightOverlay = true;
|
|
8087
|
+
mergedObject.add(overlay);
|
|
8088
|
+
this.highlightOverlays.set(mergedObject, overlay);
|
|
8089
|
+
return overlay;
|
|
8090
|
+
}
|
|
8091
|
+
_disposeHighlightOverlays() {
|
|
8092
|
+
this.highlightOverlays.forEach((overlay) => {
|
|
8093
|
+
if (overlay.parent) overlay.parent.remove(overlay);
|
|
8094
|
+
});
|
|
8095
|
+
this.highlightOverlays.clear();
|
|
8096
|
+
if (this.highlightOverlayMaterials) {
|
|
8097
|
+
Object.values(this.highlightOverlayMaterials).forEach((material) => {
|
|
8098
|
+
this.visibilityMaterials.delete(material);
|
|
8099
|
+
material.dispose();
|
|
8100
|
+
});
|
|
8101
|
+
this.highlightOverlayMaterials = null;
|
|
8102
|
+
}
|
|
8103
|
+
}
|
|
7727
8104
|
_updateVisibilityAttribute(mergedObject) {
|
|
7728
8105
|
if (
|
|
7729
8106
|
mergedObject.geometry &&
|
|
@@ -8168,9 +8545,13 @@ class RangesLoader {
|
|
|
8168
8545
|
class GLTFFileDynamicLoader extends Loader {
|
|
8169
8546
|
constructor(viewer) {
|
|
8170
8547
|
super();
|
|
8548
|
+
this.syncHighlightSettings = ({ data }) => {
|
|
8549
|
+
this.gltfLoader.setHighlightSettings(this.getHighlightSettings(data));
|
|
8550
|
+
};
|
|
8171
8551
|
this.viewer = viewer;
|
|
8172
8552
|
}
|
|
8173
8553
|
dispose() {
|
|
8554
|
+
this.viewer.removeEventListener("optionschange", this.syncHighlightSettings);
|
|
8174
8555
|
if (this.gltfLoader)
|
|
8175
8556
|
this.gltfLoader.clear();
|
|
8176
8557
|
if (this.manager)
|
|
@@ -8188,9 +8569,12 @@ class GLTFFileDynamicLoader extends Loader {
|
|
|
8188
8569
|
this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);
|
|
8189
8570
|
this.gltfLoader.setMaxConcurrentChunks(params.maxConcurrentChunks);
|
|
8190
8571
|
this.gltfLoader.setDracoLoader(params.dracoLoader);
|
|
8572
|
+
this.gltfLoader.setHighlightSettings(this.getHighlightSettings());
|
|
8191
8573
|
const modelImpl = new DynamicModelImpl(scene);
|
|
8192
8574
|
modelImpl.id = params.modelId || this.extractFileName(file);
|
|
8193
8575
|
modelImpl.gltfLoader = this.gltfLoader;
|
|
8576
|
+
modelImpl.initialize();
|
|
8577
|
+
this.viewer.addEventListener("optionschange", this.syncHighlightSettings);
|
|
8194
8578
|
this.gltfLoader.addEventListener("databasechunk", () => {
|
|
8195
8579
|
this.viewer.scene.add(scene);
|
|
8196
8580
|
this.viewer.models.push(modelImpl);
|
|
@@ -8252,15 +8636,37 @@ class GLTFFileDynamicLoader extends Loader {
|
|
|
8252
8636
|
if (this.gltfLoader)
|
|
8253
8637
|
this.gltfLoader.abortLoading();
|
|
8254
8638
|
}
|
|
8639
|
+
getHighlightSettings(options) {
|
|
8640
|
+
if (!options)
|
|
8641
|
+
options = this.viewer.options;
|
|
8642
|
+
if (!options.enableCustomHighlight)
|
|
8643
|
+
options = Options.defaults();
|
|
8644
|
+
let { facesColor, facesTransparancy, edgesColor } = options;
|
|
8645
|
+
facesColor = new Color().setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
|
|
8646
|
+
facesTransparancy = (255 - facesTransparancy) / 255;
|
|
8647
|
+
edgesColor = new Color().setRGB(edgesColor.r / 255, edgesColor.g / 255, edgesColor.b / 255);
|
|
8648
|
+
return {
|
|
8649
|
+
facesColor,
|
|
8650
|
+
facesTransparancy,
|
|
8651
|
+
facesOverlap: options.facesOverlap,
|
|
8652
|
+
edgesColor,
|
|
8653
|
+
edgesVisibility: options.edgesVisibility,
|
|
8654
|
+
edgesOverlap: options.edgesOverlap,
|
|
8655
|
+
};
|
|
8656
|
+
}
|
|
8255
8657
|
}
|
|
8256
8658
|
|
|
8257
8659
|
class GLTFCloudDynamicLoader extends Loader {
|
|
8258
8660
|
constructor(viewer) {
|
|
8259
8661
|
super();
|
|
8260
8662
|
this.requestId = 0;
|
|
8663
|
+
this.syncHighlightSettings = ({ data }) => {
|
|
8664
|
+
this.gltfLoader.setHighlightSettings(this.getHighlightSettings(data));
|
|
8665
|
+
};
|
|
8261
8666
|
this.viewer = viewer;
|
|
8262
8667
|
}
|
|
8263
8668
|
dispose() {
|
|
8669
|
+
this.viewer.removeEventListener("optionschange", this.syncHighlightSettings);
|
|
8264
8670
|
if (this.gltfLoader)
|
|
8265
8671
|
this.gltfLoader.clear();
|
|
8266
8672
|
}
|
|
@@ -8278,9 +8684,12 @@ class GLTFCloudDynamicLoader extends Loader {
|
|
|
8278
8684
|
this.gltfLoader.setVisibleEdges(this.viewer.options.edgeModel);
|
|
8279
8685
|
this.gltfLoader.setMaxConcurrentChunks(params.maxConcurrentChunks);
|
|
8280
8686
|
this.gltfLoader.setDracoLoader(params.dracoLoader);
|
|
8687
|
+
this.gltfLoader.setHighlightSettings(this.getHighlightSettings());
|
|
8281
8688
|
const modelImpl = new DynamicModelImpl(scene);
|
|
8282
|
-
modelImpl.id = model.file.id;
|
|
8689
|
+
modelImpl.id = params.modelId || model.file.id;
|
|
8283
8690
|
modelImpl.gltfLoader = this.gltfLoader;
|
|
8691
|
+
modelImpl.initialize();
|
|
8692
|
+
this.viewer.addEventListener("optionschange", this.syncHighlightSettings);
|
|
8284
8693
|
this.gltfLoader.addEventListener("databasechunk", (data) => {
|
|
8285
8694
|
this.viewer.scene.add(scene);
|
|
8286
8695
|
this.viewer.models.push(modelImpl);
|
|
@@ -8331,6 +8740,24 @@ class GLTFCloudDynamicLoader extends Loader {
|
|
|
8331
8740
|
if (this.gltfLoader)
|
|
8332
8741
|
this.gltfLoader.abortLoading();
|
|
8333
8742
|
}
|
|
8743
|
+
getHighlightSettings(options) {
|
|
8744
|
+
if (!options)
|
|
8745
|
+
options = this.viewer.options;
|
|
8746
|
+
if (!options.enableCustomHighlight)
|
|
8747
|
+
options = Options.defaults();
|
|
8748
|
+
let { facesColor, facesTransparancy, edgesColor } = options;
|
|
8749
|
+
facesColor = new Color().setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
|
|
8750
|
+
facesTransparancy = (255 - facesTransparancy) / 255;
|
|
8751
|
+
edgesColor = new Color().setRGB(edgesColor.r / 255, edgesColor.g / 255, edgesColor.b / 255);
|
|
8752
|
+
return {
|
|
8753
|
+
facesColor,
|
|
8754
|
+
facesTransparancy,
|
|
8755
|
+
facesOverlap: options.facesOverlap,
|
|
8756
|
+
edgesColor,
|
|
8757
|
+
edgesVisibility: options.edgesVisibility,
|
|
8758
|
+
edgesOverlap: options.edgesOverlap,
|
|
8759
|
+
};
|
|
8760
|
+
}
|
|
8334
8761
|
}
|
|
8335
8762
|
|
|
8336
8763
|
const loaders = loadersRegistry("threejs");
|
|
@@ -8347,12 +8774,14 @@ class Viewer extends EventEmitter2 {
|
|
|
8347
8774
|
this.info = new Info();
|
|
8348
8775
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
8349
8776
|
this.canvaseventlistener = (event) => this.emit(event);
|
|
8350
|
-
this.
|
|
8777
|
+
this.selector = new Selector(this.models);
|
|
8778
|
+
this.visibilityManager = new VisibilityManager(this.models);
|
|
8779
|
+
this.explodeScale = 0;
|
|
8780
|
+
this.clippingPlanes = [];
|
|
8351
8781
|
this.extents = new Box3();
|
|
8352
8782
|
this.target = new Vector3(0, 0, 0);
|
|
8353
|
-
this.clippingPlanes = [];
|
|
8354
8783
|
this._activeDragger = null;
|
|
8355
|
-
this._components =
|
|
8784
|
+
this._components = new Map();
|
|
8356
8785
|
this._renderNeeded = false;
|
|
8357
8786
|
this._renderTime = 0;
|
|
8358
8787
|
this.render = this.render.bind(this);
|
|
@@ -8417,7 +8846,7 @@ class Viewer extends EventEmitter2 {
|
|
|
8417
8846
|
for (const name of components.getComponents().keys()) {
|
|
8418
8847
|
const component = components.createComponent(name, this);
|
|
8419
8848
|
if (component)
|
|
8420
|
-
this._components.
|
|
8849
|
+
this._components.set(name, component);
|
|
8421
8850
|
}
|
|
8422
8851
|
this.syncOptions();
|
|
8423
8852
|
this.syncOverlay();
|
|
@@ -8438,7 +8867,7 @@ class Viewer extends EventEmitter2 {
|
|
|
8438
8867
|
this.removeAllListeners();
|
|
8439
8868
|
this.setActiveDragger();
|
|
8440
8869
|
this._components.forEach((component) => component.dispose());
|
|
8441
|
-
this._components.
|
|
8870
|
+
this._components.clear();
|
|
8442
8871
|
this._markup.dispose();
|
|
8443
8872
|
if (this.canvas) {
|
|
8444
8873
|
this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
|
|
@@ -8494,8 +8923,8 @@ class Viewer extends EventEmitter2 {
|
|
|
8494
8923
|
}
|
|
8495
8924
|
update(force = false) {
|
|
8496
8925
|
const time = performance.now();
|
|
8497
|
-
if (typeof force === "number"
|
|
8498
|
-
force =
|
|
8926
|
+
if (typeof force === "number")
|
|
8927
|
+
force = time - this._renderTime >= force;
|
|
8499
8928
|
this._renderNeeded = true;
|
|
8500
8929
|
if (force)
|
|
8501
8930
|
this.render(time);
|
|
@@ -8627,8 +9056,8 @@ class Viewer extends EventEmitter2 {
|
|
|
8627
9056
|
this.emitEvent({ type: "clearslices" });
|
|
8628
9057
|
this.update();
|
|
8629
9058
|
}
|
|
8630
|
-
getSelected() {
|
|
8631
|
-
return this.executeCommand("getSelected");
|
|
9059
|
+
getSelected(multimodel) {
|
|
9060
|
+
return this.executeCommand("getSelected", multimodel);
|
|
8632
9061
|
}
|
|
8633
9062
|
getSelected2() {
|
|
8634
9063
|
return this.executeCommand("getSelected2");
|
|
@@ -8639,18 +9068,54 @@ class Viewer extends EventEmitter2 {
|
|
|
8639
9068
|
setSelected2(handles) {
|
|
8640
9069
|
this.executeCommand("setSelected2", handles);
|
|
8641
9070
|
}
|
|
9071
|
+
select(handles) {
|
|
9072
|
+
this.executeCommand("select", handles);
|
|
9073
|
+
}
|
|
9074
|
+
deselect(handles) {
|
|
9075
|
+
this.executeCommand("deselect", handles);
|
|
9076
|
+
}
|
|
9077
|
+
toggleSelection(handles) {
|
|
9078
|
+
this.executeCommand("toggleSelection", handles);
|
|
9079
|
+
}
|
|
8642
9080
|
clearSelected() {
|
|
8643
9081
|
this.executeCommand("clearSelected");
|
|
8644
9082
|
}
|
|
9083
|
+
getHidden(multimodel) {
|
|
9084
|
+
return this.executeCommand("getHidden", multimodel);
|
|
9085
|
+
}
|
|
9086
|
+
getIsolated(multimodel) {
|
|
9087
|
+
return this.executeCommand("getIsolated", multimodel);
|
|
9088
|
+
}
|
|
9089
|
+
hide(handle) {
|
|
9090
|
+
this.executeCommand("hide", handle);
|
|
9091
|
+
}
|
|
8645
9092
|
hideSelected() {
|
|
8646
9093
|
this.executeCommand("hideSelected");
|
|
8647
9094
|
}
|
|
9095
|
+
hideAll() {
|
|
9096
|
+
this.executeCommand("hideAll");
|
|
9097
|
+
}
|
|
9098
|
+
isolate(handle) {
|
|
9099
|
+
this.executeCommand("isolate", handle);
|
|
9100
|
+
}
|
|
8648
9101
|
isolateSelected() {
|
|
8649
9102
|
this.executeCommand("isolateSelected");
|
|
8650
9103
|
}
|
|
9104
|
+
show(handle) {
|
|
9105
|
+
this.executeCommand("show", handle);
|
|
9106
|
+
}
|
|
8651
9107
|
showAll() {
|
|
8652
9108
|
this.executeCommand("showAll");
|
|
8653
9109
|
}
|
|
9110
|
+
zoomExtents() {
|
|
9111
|
+
this.executeCommand("zoomExtents");
|
|
9112
|
+
}
|
|
9113
|
+
zoomTo(handles) {
|
|
9114
|
+
this.executeCommand("zoomTo", handles);
|
|
9115
|
+
}
|
|
9116
|
+
zoomToSelected() {
|
|
9117
|
+
this.executeCommand("zoomToSelected");
|
|
9118
|
+
}
|
|
8654
9119
|
explode(index = 0) {
|
|
8655
9120
|
this.executeCommand("explode", index);
|
|
8656
9121
|
}
|
|
@@ -8692,10 +9157,10 @@ class Viewer extends EventEmitter2 {
|
|
|
8692
9157
|
}
|
|
8693
9158
|
}
|
|
8694
9159
|
getComponent(name) {
|
|
8695
|
-
return this._components.
|
|
9160
|
+
return this._components.get(name) || null;
|
|
8696
9161
|
}
|
|
8697
9162
|
drawViewpoint(viewpoint) {
|
|
8698
|
-
var _a, _b, _c, _d;
|
|
9163
|
+
var _a, _b, _c, _d, _e;
|
|
8699
9164
|
if (!this.renderer)
|
|
8700
9165
|
return;
|
|
8701
9166
|
const getVector3FromPoint3d = ({ x, y, z }) => new Vector3(x, y, z);
|
|
@@ -8757,8 +9222,26 @@ class Viewer extends EventEmitter2 {
|
|
|
8757
9222
|
}
|
|
8758
9223
|
};
|
|
8759
9224
|
const setSelection = (selection) => {
|
|
8760
|
-
if (selection)
|
|
8761
|
-
this.setSelected(selection.map((
|
|
9225
|
+
if (selection) {
|
|
9226
|
+
this.setSelected(selection.map(({ handle }) => handle));
|
|
9227
|
+
}
|
|
9228
|
+
};
|
|
9229
|
+
const setVisibility = (visibility) => {
|
|
9230
|
+
if (visibility && visibility.exceptions)
|
|
9231
|
+
if (visibility.default_visibility) {
|
|
9232
|
+
this.hide(visibility.exceptions.map(({ handle }) => handle));
|
|
9233
|
+
}
|
|
9234
|
+
else {
|
|
9235
|
+
this.isolate(visibility.exceptions.map(({ handle }) => handle));
|
|
9236
|
+
}
|
|
9237
|
+
};
|
|
9238
|
+
const setExplodeScale = (scale) => {
|
|
9239
|
+
if (scale > 0)
|
|
9240
|
+
this.explode(scale);
|
|
9241
|
+
};
|
|
9242
|
+
const setCameraTarget = (target) => {
|
|
9243
|
+
if (target)
|
|
9244
|
+
this.target = getVector3FromPoint3d(target);
|
|
8762
9245
|
};
|
|
8763
9246
|
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
8764
9247
|
this.setActiveDragger();
|
|
@@ -8770,9 +9253,11 @@ class Viewer extends EventEmitter2 {
|
|
|
8770
9253
|
setOrthogonalCamera(viewpoint.orthogonal_camera);
|
|
8771
9254
|
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
8772
9255
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
9256
|
+
setVisibility(((_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.visibility2) || viewpoint.visibility);
|
|
9257
|
+
setSelection(((_c = viewpoint.custom_fields) === null || _c === void 0 ? void 0 : _c.selection2) || viewpoint.selection);
|
|
9258
|
+
setExplodeScale((_d = viewpoint.custom_fields) === null || _d === void 0 ? void 0 : _d.explodeScale);
|
|
9259
|
+
setCameraTarget((_e = viewpoint.custom_fields) === null || _e === void 0 ? void 0 : _e.camera_target);
|
|
9260
|
+
this.markup.setViewpoint(viewpoint);
|
|
8776
9261
|
this.syncOverlay();
|
|
8777
9262
|
this.setActiveDragger(draggerName);
|
|
8778
9263
|
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
@@ -8818,21 +9303,43 @@ class Viewer extends EventEmitter2 {
|
|
|
8818
9303
|
return clipping_planes;
|
|
8819
9304
|
};
|
|
8820
9305
|
const getSelection = () => {
|
|
8821
|
-
|
|
9306
|
+
const selected2 = Array.from(this.selector.selected);
|
|
9307
|
+
const selected = toHandles(this, selected2);
|
|
9308
|
+
return selected.map((handle) => ({ handle }));
|
|
8822
9309
|
};
|
|
8823
9310
|
const getSelection2 = () => {
|
|
8824
|
-
|
|
9311
|
+
const selected2 = Array.from(this.selector.selected);
|
|
9312
|
+
return selected2.map((handle) => ({ handle }));
|
|
9313
|
+
};
|
|
9314
|
+
const getVisibility = () => {
|
|
9315
|
+
const exceptions2 = Array.from(this.visibilityManager.exceptions);
|
|
9316
|
+
const exceptions = toHandles(this, exceptions2);
|
|
9317
|
+
return {
|
|
9318
|
+
default_visibility: this.visibilityManager.defaultVisible,
|
|
9319
|
+
exceptions: exceptions.map((handle) => ({ handle })),
|
|
9320
|
+
};
|
|
9321
|
+
};
|
|
9322
|
+
const getVisibility2 = () => {
|
|
9323
|
+
const exceptions = Array.from(this.visibilityManager.exceptions);
|
|
9324
|
+
return {
|
|
9325
|
+
default_visibility: this.visibilityManager.defaultVisible,
|
|
9326
|
+
exceptions: exceptions.map((handle) => ({ handle })),
|
|
9327
|
+
};
|
|
8825
9328
|
};
|
|
8826
9329
|
const viewpoint = { custom_fields: {} };
|
|
8827
9330
|
viewpoint.orthogonal_camera = getOrthogonalCamera();
|
|
8828
9331
|
viewpoint.perspective_camera = getPerspectiveCamera();
|
|
8829
9332
|
viewpoint.clipping_planes = getClippingPlanes();
|
|
8830
9333
|
viewpoint.selection = getSelection();
|
|
9334
|
+
viewpoint.visibility = getVisibility();
|
|
8831
9335
|
viewpoint.description = new Date().toDateString();
|
|
8832
9336
|
viewpoint.snapshot = { data: this.getSnapshot() };
|
|
8833
|
-
this._markup.getViewpoint(viewpoint);
|
|
8834
|
-
viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
|
|
8835
9337
|
viewpoint.custom_fields.selection2 = getSelection2();
|
|
9338
|
+
viewpoint.custom_fields.visibility2 = getVisibility2();
|
|
9339
|
+
viewpoint.custom_fields.explodeScale = this.explodeScale;
|
|
9340
|
+
viewpoint.custom_fields.camera_target = getPoint3dFromVector3(this.target);
|
|
9341
|
+
viewpoint.custom_fields.files = this.models.map((model) => model.id);
|
|
9342
|
+
this.markup.getViewpoint(viewpoint);
|
|
8836
9343
|
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
8837
9344
|
return viewpoint;
|
|
8838
9345
|
}
|