@inweb/viewer-three 26.3.2 → 26.3.3
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/viewer-three.js +302 -278
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +2 -2
- package/dist/viewer-three.module.js +107 -107
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +5 -5
- package/src/Viewer/commands/ClearSelected.ts +3 -3
- package/src/Viewer/commands/SetSelected.ts +3 -3
|
@@ -1486,103 +1486,10 @@ function clearMarkup(viewer) {
|
|
|
1486
1486
|
viewer.clearOverlay();
|
|
1487
1487
|
}
|
|
1488
1488
|
|
|
1489
|
-
class SelectionComponent {
|
|
1490
|
-
constructor(viewer) {
|
|
1491
|
-
this.onPointerDown = event => {
|
|
1492
|
-
if (!event.isPrimary || event.button !== 0) return;
|
|
1493
|
-
this.getMousePosition(event, this.downPosition);
|
|
1494
|
-
};
|
|
1495
|
-
this.onPointerUp = event => {
|
|
1496
|
-
if (!event.isPrimary) return;
|
|
1497
|
-
const upPosition = this.getMousePosition(event, new Vector2);
|
|
1498
|
-
if (this.downPosition.distanceTo(upPosition) !== 0) return;
|
|
1499
|
-
const intersects = this.getPointerIntersects(upPosition);
|
|
1500
|
-
this.clearSelection();
|
|
1501
|
-
if (intersects.length > 0) this.select(intersects[0].object);
|
|
1502
|
-
this.viewer.update();
|
|
1503
|
-
this.viewer.emitEvent({
|
|
1504
|
-
type: "select",
|
|
1505
|
-
data: undefined,
|
|
1506
|
-
handles: this.viewer.getSelected()
|
|
1507
|
-
});
|
|
1508
|
-
};
|
|
1509
|
-
this.onDoubleClick = event => {
|
|
1510
|
-
if (event.button !== 0) return;
|
|
1511
|
-
this.viewer.executeCommand("zoomToSelected");
|
|
1512
|
-
};
|
|
1513
|
-
this.optionsChange = () => {
|
|
1514
|
-
const {facesColor: facesColor, facesTransparancy: facesTransparancy} = this.viewer.options;
|
|
1515
|
-
this.facesMaterial.color.setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
|
|
1516
|
-
this.facesMaterial.opacity = (255 - facesTransparancy) / 255;
|
|
1517
|
-
this.viewer.update();
|
|
1518
|
-
};
|
|
1519
|
-
this.viewer = viewer;
|
|
1520
|
-
this.raycaster = new Raycaster;
|
|
1521
|
-
this.downPosition = new Vector2;
|
|
1522
|
-
const {facesColor: facesColor, facesTransparancy: facesTransparancy} = this.viewer.options;
|
|
1523
|
-
this.facesMaterial = new MeshBasicMaterial;
|
|
1524
|
-
this.facesMaterial.color.setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
|
|
1525
|
-
this.facesMaterial.opacity = (255 - facesTransparancy) / 255;
|
|
1526
|
-
this.facesMaterial.transparent = true;
|
|
1527
|
-
this.viewer.addEventListener("pointerdown", this.onPointerDown);
|
|
1528
|
-
this.viewer.addEventListener("pointerup", this.onPointerUp);
|
|
1529
|
-
this.viewer.addEventListener("dblclick", this.onDoubleClick);
|
|
1530
|
-
this.viewer.addEventListener("optionschange", this.optionsChange);
|
|
1531
|
-
}
|
|
1532
|
-
dispose() {
|
|
1533
|
-
this.facesMaterial.dispose();
|
|
1534
|
-
this.viewer.removeEventListener("pointerdown", this.onPointerDown);
|
|
1535
|
-
this.viewer.removeEventListener("pointerup", this.onPointerUp);
|
|
1536
|
-
this.viewer.removeEventListener("dblclick", this.onDoubleClick);
|
|
1537
|
-
this.viewer.removeEventListener("optionschange", this.optionsChange);
|
|
1538
|
-
}
|
|
1539
|
-
getMousePosition(event, target) {
|
|
1540
|
-
return target.set(event.clientX, event.clientY);
|
|
1541
|
-
}
|
|
1542
|
-
getPointerIntersects(mouse) {
|
|
1543
|
-
const rect = this.viewer.canvas.getBoundingClientRect();
|
|
1544
|
-
const x = (mouse.x - rect.left) / rect.width * 2 - 1;
|
|
1545
|
-
const y = -(mouse.y - rect.top) / rect.height * 2 + 1;
|
|
1546
|
-
const coords = new Vector2(x, y);
|
|
1547
|
-
this.raycaster.setFromCamera(coords, this.viewer.camera);
|
|
1548
|
-
const objects = [];
|
|
1549
|
-
this.viewer.scene.traverseVisible((child => objects.push(child)));
|
|
1550
|
-
this.raycaster.params = this.raycaster.params = {
|
|
1551
|
-
Mesh: {},
|
|
1552
|
-
Line: {
|
|
1553
|
-
threshold: .25
|
|
1554
|
-
},
|
|
1555
|
-
Line2: {
|
|
1556
|
-
threshold: .25
|
|
1557
|
-
},
|
|
1558
|
-
LOD: {},
|
|
1559
|
-
Points: {
|
|
1560
|
-
threshold: .1
|
|
1561
|
-
},
|
|
1562
|
-
Sprite: {}
|
|
1563
|
-
};
|
|
1564
|
-
return this.raycaster.intersectObjects(objects, false);
|
|
1565
|
-
}
|
|
1566
|
-
select(object) {
|
|
1567
|
-
if (object.isSelected) return;
|
|
1568
|
-
object.isSelected = true;
|
|
1569
|
-
object.originalMaterial = object.material;
|
|
1570
|
-
object.material = this.facesMaterial;
|
|
1571
|
-
this.viewer.selected.push(object);
|
|
1572
|
-
}
|
|
1573
|
-
clearSelection() {
|
|
1574
|
-
this.viewer.selected.forEach((object => {
|
|
1575
|
-
object.isSelected = false;
|
|
1576
|
-
object.material = object.originalMaterial;
|
|
1577
|
-
}));
|
|
1578
|
-
this.viewer.selected.length = 0;
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
1489
|
function clearSelected(viewer) {
|
|
1583
|
-
const selection =
|
|
1490
|
+
const selection = viewer.getComponent("SelectionComponent");
|
|
1491
|
+
if (!selection) return;
|
|
1584
1492
|
selection.clearSelection();
|
|
1585
|
-
selection.dispose();
|
|
1586
1493
|
viewer.update();
|
|
1587
1494
|
viewer.emitEvent({
|
|
1588
1495
|
type: "select",
|
|
@@ -1720,17 +1627,110 @@ function getDefaultViewPositions() {
|
|
|
1720
1627
|
function getModels(viewer) {
|
|
1721
1628
|
return viewer.models.map((model => {
|
|
1722
1629
|
var _a;
|
|
1723
|
-
return ((_a = model.userData) === null || _a ===
|
|
1630
|
+
return ((_a = model.userData) === null || _a === void 0 ? void 0 : _a.handle) || "";
|
|
1724
1631
|
})).filter((handle => handle));
|
|
1725
1632
|
}
|
|
1726
1633
|
|
|
1727
1634
|
function getSelected(viewer) {
|
|
1728
1635
|
return viewer.selected.map((object => {
|
|
1729
1636
|
var _a;
|
|
1730
|
-
return (_a = object.userData) === null || _a ===
|
|
1637
|
+
return (_a = object.userData) === null || _a === void 0 ? void 0 : _a.handle;
|
|
1731
1638
|
})).filter((handle => handle));
|
|
1732
1639
|
}
|
|
1733
1640
|
|
|
1641
|
+
class SelectionComponent {
|
|
1642
|
+
constructor(viewer) {
|
|
1643
|
+
this.onPointerDown = event => {
|
|
1644
|
+
if (!event.isPrimary || event.button !== 0) return;
|
|
1645
|
+
this.getMousePosition(event, this.downPosition);
|
|
1646
|
+
};
|
|
1647
|
+
this.onPointerUp = event => {
|
|
1648
|
+
if (!event.isPrimary) return;
|
|
1649
|
+
const upPosition = this.getMousePosition(event, new Vector2);
|
|
1650
|
+
if (this.downPosition.distanceTo(upPosition) !== 0) return;
|
|
1651
|
+
const intersects = this.getPointerIntersects(upPosition);
|
|
1652
|
+
this.clearSelection();
|
|
1653
|
+
if (intersects.length > 0) this.select(intersects[0].object);
|
|
1654
|
+
this.viewer.update();
|
|
1655
|
+
this.viewer.emitEvent({
|
|
1656
|
+
type: "select",
|
|
1657
|
+
data: undefined,
|
|
1658
|
+
handles: this.viewer.getSelected()
|
|
1659
|
+
});
|
|
1660
|
+
};
|
|
1661
|
+
this.onDoubleClick = event => {
|
|
1662
|
+
if (event.button !== 0) return;
|
|
1663
|
+
this.viewer.executeCommand("zoomToSelected");
|
|
1664
|
+
};
|
|
1665
|
+
this.optionsChange = () => {
|
|
1666
|
+
const {facesColor: facesColor, facesTransparancy: facesTransparancy} = this.viewer.options;
|
|
1667
|
+
this.facesMaterial.color.setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
|
|
1668
|
+
this.facesMaterial.opacity = (255 - facesTransparancy) / 255;
|
|
1669
|
+
this.viewer.update();
|
|
1670
|
+
};
|
|
1671
|
+
this.viewer = viewer;
|
|
1672
|
+
this.raycaster = new Raycaster;
|
|
1673
|
+
this.downPosition = new Vector2;
|
|
1674
|
+
const {facesColor: facesColor, facesTransparancy: facesTransparancy} = this.viewer.options;
|
|
1675
|
+
this.facesMaterial = new MeshBasicMaterial;
|
|
1676
|
+
this.facesMaterial.color.setRGB(facesColor.r / 255, facesColor.g / 255, facesColor.b / 255);
|
|
1677
|
+
this.facesMaterial.opacity = (255 - facesTransparancy) / 255;
|
|
1678
|
+
this.facesMaterial.transparent = true;
|
|
1679
|
+
this.viewer.addEventListener("pointerdown", this.onPointerDown);
|
|
1680
|
+
this.viewer.addEventListener("pointerup", this.onPointerUp);
|
|
1681
|
+
this.viewer.addEventListener("dblclick", this.onDoubleClick);
|
|
1682
|
+
this.viewer.addEventListener("optionschange", this.optionsChange);
|
|
1683
|
+
}
|
|
1684
|
+
dispose() {
|
|
1685
|
+
this.facesMaterial.dispose();
|
|
1686
|
+
this.viewer.removeEventListener("pointerdown", this.onPointerDown);
|
|
1687
|
+
this.viewer.removeEventListener("pointerup", this.onPointerUp);
|
|
1688
|
+
this.viewer.removeEventListener("dblclick", this.onDoubleClick);
|
|
1689
|
+
this.viewer.removeEventListener("optionschange", this.optionsChange);
|
|
1690
|
+
}
|
|
1691
|
+
getMousePosition(event, target) {
|
|
1692
|
+
return target.set(event.clientX, event.clientY);
|
|
1693
|
+
}
|
|
1694
|
+
getPointerIntersects(mouse) {
|
|
1695
|
+
const rect = this.viewer.canvas.getBoundingClientRect();
|
|
1696
|
+
const x = (mouse.x - rect.left) / rect.width * 2 - 1;
|
|
1697
|
+
const y = -(mouse.y - rect.top) / rect.height * 2 + 1;
|
|
1698
|
+
const coords = new Vector2(x, y);
|
|
1699
|
+
this.raycaster.setFromCamera(coords, this.viewer.camera);
|
|
1700
|
+
const objects = [];
|
|
1701
|
+
this.viewer.scene.traverseVisible((child => objects.push(child)));
|
|
1702
|
+
this.raycaster.params = this.raycaster.params = {
|
|
1703
|
+
Mesh: {},
|
|
1704
|
+
Line: {
|
|
1705
|
+
threshold: .25
|
|
1706
|
+
},
|
|
1707
|
+
Line2: {
|
|
1708
|
+
threshold: .25
|
|
1709
|
+
},
|
|
1710
|
+
LOD: {},
|
|
1711
|
+
Points: {
|
|
1712
|
+
threshold: .1
|
|
1713
|
+
},
|
|
1714
|
+
Sprite: {}
|
|
1715
|
+
};
|
|
1716
|
+
return this.raycaster.intersectObjects(objects, false);
|
|
1717
|
+
}
|
|
1718
|
+
select(object) {
|
|
1719
|
+
if (object.isSelected) return;
|
|
1720
|
+
object.isSelected = true;
|
|
1721
|
+
object.originalMaterial = object.material;
|
|
1722
|
+
object.material = this.facesMaterial;
|
|
1723
|
+
this.viewer.selected.push(object);
|
|
1724
|
+
}
|
|
1725
|
+
clearSelection() {
|
|
1726
|
+
this.viewer.selected.forEach((object => {
|
|
1727
|
+
object.isSelected = false;
|
|
1728
|
+
object.material = object.originalMaterial;
|
|
1729
|
+
}));
|
|
1730
|
+
this.viewer.selected.length = 0;
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
1734
|
function hideSelected(viewer) {
|
|
1735
1735
|
viewer.selected.forEach((object => object.visible = false));
|
|
1736
1736
|
const selection = new SelectionComponent(viewer);
|
|
@@ -1802,12 +1802,12 @@ function setSelected(viewer, handles = []) {
|
|
|
1802
1802
|
const objects = [];
|
|
1803
1803
|
viewer.scene.traverseVisible((child => {
|
|
1804
1804
|
var _a;
|
|
1805
|
-
if (handleSet.has((_a = child.userData) === null || _a ===
|
|
1805
|
+
if (handleSet.has((_a = child.userData) === null || _a === void 0 ? void 0 : _a.handle)) objects.push(child);
|
|
1806
1806
|
}));
|
|
1807
|
-
const selection =
|
|
1807
|
+
const selection = viewer.getComponent("SelectionComponent");
|
|
1808
|
+
if (!selection) return;
|
|
1808
1809
|
selection.clearSelection();
|
|
1809
1810
|
objects.forEach((object => selection.select(object)));
|
|
1810
|
-
selection.dispose();
|
|
1811
1811
|
viewer.update();
|
|
1812
1812
|
viewer.emitEvent({
|
|
1813
1813
|
type: "select",
|
|
@@ -1833,7 +1833,7 @@ function zoomToObjects(viewer, handles = []) {
|
|
|
1833
1833
|
const objects = [];
|
|
1834
1834
|
viewer.scene.traverseVisible((child => {
|
|
1835
1835
|
var _a;
|
|
1836
|
-
if (handleSet.has((_a = child.userData) === null || _a ===
|
|
1836
|
+
if (handleSet.has((_a = child.userData) === null || _a === void 0 ? void 0 : _a.handle)) objects.push(child);
|
|
1837
1837
|
}));
|
|
1838
1838
|
const extents = objects.reduce(((result, object) => result.expandByObject(object)), new Box3);
|
|
1839
1839
|
if (extents.isEmpty()) extents.copy(viewer.extents);
|
|
@@ -2220,7 +2220,7 @@ class GLTFLoadingManager extends LoadingManager {
|
|
|
2220
2220
|
this.setURLModifier((url => {
|
|
2221
2221
|
const key = decodeURI(url).replace(this.path, "").replace(this.resourcePath, "").replace(/^(\.?\/)/, "");
|
|
2222
2222
|
const dataURL = this.dataURLs.get(key);
|
|
2223
|
-
return dataURL !== null && dataURL !==
|
|
2223
|
+
return dataURL !== null && dataURL !== void 0 ? dataURL : url;
|
|
2224
2224
|
}));
|
|
2225
2225
|
}
|
|
2226
2226
|
dispose() {
|
|
@@ -2340,7 +2340,7 @@ class Viewer extends EventEmitter2 {
|
|
|
2340
2340
|
this.renderer.autoClear = false;
|
|
2341
2341
|
this.renderer.render(this.helpers, this.camera);
|
|
2342
2342
|
this.renderer.clippingPlanes = clippingPlanes;
|
|
2343
|
-
(_b = (_a = this._activeDragger) === null || _a ===
|
|
2343
|
+
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
2344
2344
|
const deltaTime = (time - this.renderTime) / 1e3;
|
|
2345
2345
|
this.renderTime = time;
|
|
2346
2346
|
this.emitEvent({
|
|
@@ -2530,7 +2530,7 @@ class Viewer extends EventEmitter2 {
|
|
|
2530
2530
|
newDragger = draggers.createDragger(name, this);
|
|
2531
2531
|
if (newDragger) {
|
|
2532
2532
|
this._activeDragger = newDragger;
|
|
2533
|
-
(_b = (_a = this._activeDragger).initialize) === null || _b ===
|
|
2533
|
+
(_b = (_a = this._activeDragger).initialize) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
2534
2534
|
}
|
|
2535
2535
|
}
|
|
2536
2536
|
const canvas = this.canvas;
|
|
@@ -2643,7 +2643,7 @@ class Viewer extends EventEmitter2 {
|
|
|
2643
2643
|
}
|
|
2644
2644
|
};
|
|
2645
2645
|
const setClippingPlanes = clipping_planes => {
|
|
2646
|
-
clipping_planes === null || clipping_planes ===
|
|
2646
|
+
clipping_planes === null || clipping_planes === void 0 ? void 0 : clipping_planes.forEach((clipping_plane => {
|
|
2647
2647
|
const plane = new Plane;
|
|
2648
2648
|
plane.setFromNormalAndCoplanarPoint(getVector3FromPoint3d(clipping_plane.direction), getVector3FromPoint3d(clipping_plane.location));
|
|
2649
2649
|
this.renderer.clippingPlanes.push(plane);
|
|
@@ -2652,7 +2652,7 @@ class Viewer extends EventEmitter2 {
|
|
|
2652
2652
|
const setSelection = selection => {
|
|
2653
2653
|
if (selection) this.setSelected(selection.map((component => component.handle)));
|
|
2654
2654
|
};
|
|
2655
|
-
const draggerName = (_a = this._activeDragger) === null || _a ===
|
|
2655
|
+
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
2656
2656
|
this.setActiveDragger();
|
|
2657
2657
|
this.clearSlices();
|
|
2658
2658
|
this.clearOverlay();
|
|
@@ -2664,7 +2664,7 @@ class Viewer extends EventEmitter2 {
|
|
|
2664
2664
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
2665
2665
|
setSelection(viewpoint.selection);
|
|
2666
2666
|
this._markup.setViewpoint(viewpoint);
|
|
2667
|
-
this.target = getVector3FromPoint3d((_c = (_b = viewpoint.custom_fields) === null || _b ===
|
|
2667
|
+
this.target = getVector3FromPoint3d((_c = (_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.camera_target) !== null && _c !== void 0 ? _c : this.target);
|
|
2668
2668
|
this.setActiveDragger(draggerName);
|
|
2669
2669
|
this.emitEvent({
|
|
2670
2670
|
type: "drawviewpoint",
|