@inweb/viewer-three 26.10.2 → 26.10.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/plugins/components/AxesHelperComponent.js +5 -9
- package/dist/plugins/components/AxesHelperComponent.js.map +1 -1
- package/dist/plugins/components/AxesHelperComponent.min.js +1 -1
- package/dist/plugins/components/AxesHelperComponent.module.js +5 -9
- package/dist/plugins/components/AxesHelperComponent.module.js.map +1 -1
- package/dist/plugins/components/GridHelperComponent.js +62 -0
- package/dist/plugins/components/GridHelperComponent.js.map +1 -0
- package/dist/plugins/components/GridHelperComponent.min.js +24 -0
- package/dist/plugins/components/GridHelperComponent.module.js +57 -0
- package/dist/plugins/components/GridHelperComponent.module.js.map +1 -0
- package/dist/viewer-three.js +32 -16
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +27 -12
- package/dist/viewer-three.module.js.map +1 -1
- package/package.json +5 -5
- package/plugins/components/AxesHelperComponent.ts +6 -11
- package/plugins/components/GridHelperComponent.ts +67 -0
- package/src/Viewer/components/SelectionComponent.ts +7 -1
- package/src/Viewer/draggers/MeasureLineDragger.ts +31 -12
|
@@ -958,7 +958,7 @@ class MeasureLineDragger extends OrbitDragger {
|
|
|
958
958
|
this.overlay.render();
|
|
959
959
|
};
|
|
960
960
|
this.updateSnapper = () => {
|
|
961
|
-
this.snapper.
|
|
961
|
+
this.snapper.setFromViewer(this.viewer);
|
|
962
962
|
};
|
|
963
963
|
this.updateSnapperCamera = () => {
|
|
964
964
|
this.snapper.camera = this.viewer.camera;
|
|
@@ -995,7 +995,6 @@ class MeasureLineDragger extends OrbitDragger {
|
|
|
995
995
|
this.viewer.removeEventListener("showall", this.updateSnapper);
|
|
996
996
|
this.viewer.removeEventListener("changecameramode", this.updateSnapperCamera);
|
|
997
997
|
this.snapper.dispose();
|
|
998
|
-
this.snapper.dispose();
|
|
999
998
|
this.overlay.detach();
|
|
1000
999
|
this.overlay.dispose();
|
|
1001
1000
|
super.dispose();
|
|
@@ -1012,6 +1011,7 @@ class MeasureSnapper {
|
|
|
1012
1011
|
this.camera = camera;
|
|
1013
1012
|
this.canvas = canvas;
|
|
1014
1013
|
this.objects = [];
|
|
1014
|
+
this.clippingPlanes = [];
|
|
1015
1015
|
this.raycaster = new Raycaster();
|
|
1016
1016
|
this.detectRadiusInPixels = this.isMobile() ? MOBILE_SNAP_DISTANCE : DESKTOP_SNAP_DISTANCE;
|
|
1017
1017
|
this.edgesCache = new WeakMap();
|
|
@@ -1027,7 +1027,7 @@ class MeasureSnapper {
|
|
|
1027
1027
|
getMousePosition(event, target) {
|
|
1028
1028
|
return target.set(event.clientX, event.clientY);
|
|
1029
1029
|
}
|
|
1030
|
-
getPointerIntersects(mouse
|
|
1030
|
+
getPointerIntersects(mouse) {
|
|
1031
1031
|
const rect = this.canvas.getBoundingClientRect();
|
|
1032
1032
|
const x = ((mouse.x - rect.left) / rect.width) * 2 - 1;
|
|
1033
1033
|
const y = (-(mouse.y - rect.top) / rect.height) * 2 + 1;
|
|
@@ -1041,7 +1041,11 @@ class MeasureSnapper {
|
|
|
1041
1041
|
Points: { threshold: 0.01 },
|
|
1042
1042
|
Sprite: {},
|
|
1043
1043
|
};
|
|
1044
|
-
|
|
1044
|
+
let intersects = this.raycaster.intersectObjects(this.objects, false);
|
|
1045
|
+
this.clippingPlanes.forEach((plane) => {
|
|
1046
|
+
intersects = intersects.filter((intersect) => plane.distanceToPoint(intersect.point) >= 0);
|
|
1047
|
+
});
|
|
1048
|
+
return intersects;
|
|
1045
1049
|
}
|
|
1046
1050
|
getDetectRadius(point) {
|
|
1047
1051
|
const camera = this.camera;
|
|
@@ -1062,7 +1066,7 @@ class MeasureSnapper {
|
|
|
1062
1066
|
}
|
|
1063
1067
|
getSnapPoint(event) {
|
|
1064
1068
|
const mouse = this.getMousePosition(event, new Vector2());
|
|
1065
|
-
const intersections = this.getPointerIntersects(mouse
|
|
1069
|
+
const intersections = this.getPointerIntersects(mouse);
|
|
1066
1070
|
if (intersections.length === 0)
|
|
1067
1071
|
return undefined;
|
|
1068
1072
|
const object = intersections[0].object;
|
|
@@ -1110,40 +1114,47 @@ class MeasureSnapper {
|
|
|
1110
1114
|
return object.localToWorld(snapPoint);
|
|
1111
1115
|
return intersectionPoint.clone();
|
|
1112
1116
|
}
|
|
1113
|
-
|
|
1117
|
+
setFromViewer(viewer) {
|
|
1114
1118
|
this.objects.length = 0;
|
|
1115
1119
|
viewer.models.forEach((model) => {
|
|
1116
1120
|
model.getVisibleObjects().forEach((object) => this.objects.push(object));
|
|
1117
1121
|
});
|
|
1122
|
+
this.camera = viewer.camera;
|
|
1123
|
+
this.clippingPlanes = viewer.renderer.clippingPlanes || [];
|
|
1118
1124
|
}
|
|
1119
1125
|
}
|
|
1120
1126
|
class MeasureOverlay {
|
|
1121
1127
|
constructor(camera, canvas) {
|
|
1122
1128
|
this.lines = [];
|
|
1129
|
+
this.resizeContainer = (entries) => {
|
|
1130
|
+
const { width, height } = entries[0].contentRect;
|
|
1131
|
+
if (!width || !height)
|
|
1132
|
+
return;
|
|
1133
|
+
this.container.style.width = `${width}px`;
|
|
1134
|
+
this.container.style.height = `${height}px`;
|
|
1135
|
+
};
|
|
1123
1136
|
this.camera = camera;
|
|
1124
1137
|
this.canvas = canvas;
|
|
1125
1138
|
this.projector = new MeasureProjector(camera, canvas);
|
|
1139
|
+
this.resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
1126
1140
|
}
|
|
1127
1141
|
attach() {
|
|
1128
1142
|
this.container = document.createElement("div");
|
|
1129
1143
|
this.container.id = "measure-container";
|
|
1130
|
-
this.container.style.background = "rgba(0,0,0,0)";
|
|
1131
1144
|
this.container.style.position = "absolute";
|
|
1132
|
-
this.container.style.top = "0px";
|
|
1133
|
-
this.container.style.left = "0px";
|
|
1134
|
-
this.container.style.width = "100%";
|
|
1135
|
-
this.container.style.height = "100%";
|
|
1136
1145
|
this.container.style.outline = "none";
|
|
1137
1146
|
this.container.style.pointerEvents = "none";
|
|
1138
1147
|
this.container.style.overflow = "hidden";
|
|
1139
1148
|
if (!this.canvas.parentElement)
|
|
1140
1149
|
return;
|
|
1141
1150
|
this.canvas.parentElement.appendChild(this.container);
|
|
1151
|
+
this.resizeObserver.observe(this.canvas.parentElement);
|
|
1142
1152
|
}
|
|
1143
1153
|
dispose() {
|
|
1144
1154
|
this.clear();
|
|
1145
1155
|
}
|
|
1146
1156
|
detach() {
|
|
1157
|
+
this.resizeObserver.disconnect();
|
|
1147
1158
|
this.container.remove();
|
|
1148
1159
|
this.container = undefined;
|
|
1149
1160
|
}
|
|
@@ -2583,7 +2594,11 @@ class SelectionComponent {
|
|
|
2583
2594
|
Points: { threshold: 0.01 },
|
|
2584
2595
|
Sprite: {},
|
|
2585
2596
|
};
|
|
2586
|
-
|
|
2597
|
+
let intersects = this.raycaster.intersectObjects(objects, false);
|
|
2598
|
+
(this.viewer.renderer.clippingPlanes || []).forEach((plane) => {
|
|
2599
|
+
intersects = intersects.filter((intersect) => plane.distanceToPoint(intersect.point) >= 0);
|
|
2600
|
+
});
|
|
2601
|
+
return intersects;
|
|
2587
2602
|
}
|
|
2588
2603
|
select(objects, model) {
|
|
2589
2604
|
if (!model) {
|