@inweb/viewer-three 26.10.1 → 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/plugins/loaders/IFCXLoader.js.map +1 -1
- package/dist/plugins/loaders/IFCXLoader.module.js.map +1 -1
- package/dist/viewer-three.js +163 -59
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -3
- package/dist/viewer-three.module.js +151 -56
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/components/CameraComponent.d.ts +5 -1
- package/lib/Viewer/draggers/CuttingPlaneDragger.d.ts +1 -0
- package/lib/Viewer/draggers/FlyDragger.d.ts +1 -0
- package/lib/Viewer/draggers/MeasureLineDragger.d.ts +1 -0
- package/lib/Viewer/draggers/OrbitDragger.d.ts +1 -0
- package/lib/Viewer/draggers/WalkDragger.d.ts +1 -0
- package/package.json +5 -5
- package/plugins/components/AxesHelperComponent.ts +6 -11
- package/plugins/components/GridHelperComponent.ts +67 -0
- package/plugins/loaders/IFCX/render.js +2 -2
- package/src/Viewer/Viewer.ts +4 -0
- package/src/Viewer/components/CameraComponent.ts +86 -25
- package/src/Viewer/components/SelectionComponent.ts +7 -1
- package/src/Viewer/controls/WalkControls.ts +1 -1
- package/src/Viewer/draggers/CuttingPlaneDragger.ts +12 -6
- package/src/Viewer/draggers/FlyDragger.ts +10 -4
- package/src/Viewer/draggers/MeasureLineDragger.ts +50 -17
- package/src/Viewer/draggers/OrbitDragger.ts +7 -1
- package/src/Viewer/draggers/WalkDragger.ts +10 -4
package/dist/viewer-three.js
CHANGED
|
@@ -236,6 +236,7 @@
|
|
|
236
236
|
enableGestures: true,
|
|
237
237
|
geometryType: "vsfx",
|
|
238
238
|
rulerUnit: "Default",
|
|
239
|
+
cameraMode: "perspective",
|
|
239
240
|
};
|
|
240
241
|
}
|
|
241
242
|
class Options {
|
|
@@ -491,6 +492,13 @@
|
|
|
491
492
|
this._data.rulerUnit = value;
|
|
492
493
|
this.change();
|
|
493
494
|
}
|
|
495
|
+
get cameraMode() {
|
|
496
|
+
return this._data.cameraMode || "perspective";
|
|
497
|
+
}
|
|
498
|
+
set cameraMode(value) {
|
|
499
|
+
this._data.cameraMode = value;
|
|
500
|
+
this.change();
|
|
501
|
+
}
|
|
494
502
|
}
|
|
495
503
|
const CanvasEvents = [
|
|
496
504
|
"click",
|
|
@@ -33674,10 +33682,13 @@ void main() {
|
|
|
33674
33682
|
class OrbitDragger {
|
|
33675
33683
|
constructor(viewer) {
|
|
33676
33684
|
this.updateControls = () => {
|
|
33685
|
+
this.orbit.target.copy(this.viewer.target);
|
|
33686
|
+
this.orbit.update();
|
|
33687
|
+
};
|
|
33688
|
+
this.updateControlsCamera = () => {
|
|
33677
33689
|
this.orbit.maxDistance = this.viewer.camera.far;
|
|
33678
33690
|
this.orbit.minDistance = this.viewer.camera.near;
|
|
33679
33691
|
this.orbit.object = this.viewer.camera;
|
|
33680
|
-
this.orbit.target.copy(this.viewer.target);
|
|
33681
33692
|
this.orbit.update();
|
|
33682
33693
|
};
|
|
33683
33694
|
this.controlsStart = () => {
|
|
@@ -33734,6 +33745,7 @@ void main() {
|
|
|
33734
33745
|
this.viewer.on("viewposition", this.updateControls);
|
|
33735
33746
|
this.viewer.addEventListener("zoom", this.updateControls);
|
|
33736
33747
|
this.viewer.addEventListener("drawviewpoint", this.updateControls);
|
|
33748
|
+
this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
|
|
33737
33749
|
this.viewer.addEventListener("contextmenu", this.stopContextMenu);
|
|
33738
33750
|
this.updateControls();
|
|
33739
33751
|
}
|
|
@@ -33743,6 +33755,7 @@ void main() {
|
|
|
33743
33755
|
this.viewer.off("viewposition", this.updateControls);
|
|
33744
33756
|
this.viewer.removeEventListener("zoom", this.updateControls);
|
|
33745
33757
|
this.viewer.removeEventListener("drawviewpoint", this.updateControls);
|
|
33758
|
+
this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
|
|
33746
33759
|
this.viewer.removeEventListener("contextmenu", this.stopContextMenu);
|
|
33747
33760
|
this.orbit.removeEventListener("start", this.controlsStart);
|
|
33748
33761
|
this.orbit.removeEventListener("change", this.controlsChange);
|
|
@@ -33764,6 +33777,9 @@ void main() {
|
|
|
33764
33777
|
this.planeHelper.size = this.viewer.extents.getSize(new Vector3()).length();
|
|
33765
33778
|
this.viewer.update();
|
|
33766
33779
|
};
|
|
33780
|
+
this.updateTransformCamera = () => {
|
|
33781
|
+
this.transform.camera = this.viewer.camera;
|
|
33782
|
+
};
|
|
33767
33783
|
this.onDoubleClick = (event) => {
|
|
33768
33784
|
event.stopPropagation();
|
|
33769
33785
|
this.plane.negate();
|
|
@@ -33789,16 +33805,18 @@ void main() {
|
|
|
33789
33805
|
this.transform.addEventListener("change", this.transformChange);
|
|
33790
33806
|
this.transform.addEventListener("dragging-changed", this.transformDrag);
|
|
33791
33807
|
this.viewer.helpers.add(this.transform.getHelper());
|
|
33792
|
-
this.viewer.
|
|
33793
|
-
this.viewer.
|
|
33794
|
-
this.viewer.
|
|
33808
|
+
this.viewer.addEventListener("explode", this.updatePlaneSize);
|
|
33809
|
+
this.viewer.addEventListener("show", this.updatePlaneSize);
|
|
33810
|
+
this.viewer.addEventListener("showall", this.updatePlaneSize);
|
|
33811
|
+
this.viewer.addEventListener("changecameramode", this.updateTransformCamera);
|
|
33795
33812
|
this.viewer.canvas.addEventListener("dblclick", this.onDoubleClick, true);
|
|
33796
33813
|
this.viewer.update();
|
|
33797
33814
|
}
|
|
33798
33815
|
dispose() {
|
|
33799
|
-
this.viewer.
|
|
33800
|
-
this.viewer.
|
|
33801
|
-
this.viewer.
|
|
33816
|
+
this.viewer.removeEventListener("explode", this.updatePlaneSize);
|
|
33817
|
+
this.viewer.removeEventListener("show", this.updatePlaneSize);
|
|
33818
|
+
this.viewer.removeEventListener("showall", this.updatePlaneSize);
|
|
33819
|
+
this.viewer.removeEventListener("changecameramode", this.updateTransformCamera);
|
|
33802
33820
|
this.viewer.canvas.removeEventListener("dblclick", this.onDoubleClick, true);
|
|
33803
33821
|
this.transform.removeEventListener("change", this.transformChange);
|
|
33804
33822
|
this.transform.removeEventListener("dragging-changed", this.transformDrag);
|
|
@@ -33879,7 +33897,11 @@ void main() {
|
|
|
33879
33897
|
this.overlay.render();
|
|
33880
33898
|
};
|
|
33881
33899
|
this.updateSnapper = () => {
|
|
33882
|
-
this.snapper.
|
|
33900
|
+
this.snapper.setFromViewer(this.viewer);
|
|
33901
|
+
};
|
|
33902
|
+
this.updateSnapperCamera = () => {
|
|
33903
|
+
this.snapper.camera = this.viewer.camera;
|
|
33904
|
+
this.overlay.camera = this.viewer.camera;
|
|
33883
33905
|
};
|
|
33884
33906
|
this.overlay = new MeasureOverlay(viewer.camera, viewer.canvas);
|
|
33885
33907
|
this.overlay.attach();
|
|
@@ -33897,6 +33919,7 @@ void main() {
|
|
|
33897
33919
|
this.viewer.addEventListener("isolate", this.updateSnapper);
|
|
33898
33920
|
this.viewer.addEventListener("show", this.updateSnapper);
|
|
33899
33921
|
this.viewer.addEventListener("showall", this.updateSnapper);
|
|
33922
|
+
this.viewer.addEventListener("changecameramode", this.updateSnapperCamera);
|
|
33900
33923
|
}
|
|
33901
33924
|
dispose() {
|
|
33902
33925
|
this.viewer.canvas.removeEventListener("pointerdown", this.onPointerDown);
|
|
@@ -33909,6 +33932,7 @@ void main() {
|
|
|
33909
33932
|
this.viewer.removeEventListener("isolate", this.updateSnapper);
|
|
33910
33933
|
this.viewer.removeEventListener("show", this.updateSnapper);
|
|
33911
33934
|
this.viewer.removeEventListener("showall", this.updateSnapper);
|
|
33935
|
+
this.viewer.removeEventListener("changecameramode", this.updateSnapperCamera);
|
|
33912
33936
|
this.snapper.dispose();
|
|
33913
33937
|
this.overlay.detach();
|
|
33914
33938
|
this.overlay.dispose();
|
|
@@ -33926,6 +33950,7 @@ void main() {
|
|
|
33926
33950
|
this.camera = camera;
|
|
33927
33951
|
this.canvas = canvas;
|
|
33928
33952
|
this.objects = [];
|
|
33953
|
+
this.clippingPlanes = [];
|
|
33929
33954
|
this.raycaster = new Raycaster();
|
|
33930
33955
|
this.detectRadiusInPixels = this.isMobile() ? MOBILE_SNAP_DISTANCE : DESKTOP_SNAP_DISTANCE;
|
|
33931
33956
|
this.edgesCache = new WeakMap();
|
|
@@ -33941,7 +33966,7 @@ void main() {
|
|
|
33941
33966
|
getMousePosition(event, target) {
|
|
33942
33967
|
return target.set(event.clientX, event.clientY);
|
|
33943
33968
|
}
|
|
33944
|
-
getPointerIntersects(mouse
|
|
33969
|
+
getPointerIntersects(mouse) {
|
|
33945
33970
|
const rect = this.canvas.getBoundingClientRect();
|
|
33946
33971
|
const x = ((mouse.x - rect.left) / rect.width) * 2 - 1;
|
|
33947
33972
|
const y = (-(mouse.y - rect.top) / rect.height) * 2 + 1;
|
|
@@ -33955,28 +33980,32 @@ void main() {
|
|
|
33955
33980
|
Points: { threshold: 0.01 },
|
|
33956
33981
|
Sprite: {},
|
|
33957
33982
|
};
|
|
33958
|
-
|
|
33983
|
+
let intersects = this.raycaster.intersectObjects(this.objects, false);
|
|
33984
|
+
this.clippingPlanes.forEach((plane) => {
|
|
33985
|
+
intersects = intersects.filter((intersect) => plane.distanceToPoint(intersect.point) >= 0);
|
|
33986
|
+
});
|
|
33987
|
+
return intersects;
|
|
33959
33988
|
}
|
|
33960
33989
|
getDetectRadius(point) {
|
|
33961
33990
|
const camera = this.camera;
|
|
33962
33991
|
if (camera.isOrthographicCamera) {
|
|
33963
|
-
const
|
|
33992
|
+
const fieldHeight = (camera.top - camera.bottom) / camera.zoom;
|
|
33964
33993
|
const canvasHeight = this.canvas.height;
|
|
33965
|
-
const worldUnitsPerPixel =
|
|
33994
|
+
const worldUnitsPerPixel = fieldHeight / canvasHeight;
|
|
33966
33995
|
return this.detectRadiusInPixels * worldUnitsPerPixel;
|
|
33967
33996
|
}
|
|
33968
33997
|
if (camera.isPerspectiveCamera) {
|
|
33969
33998
|
const distance = camera.position.distanceTo(point);
|
|
33970
|
-
const
|
|
33999
|
+
const fieldHeight = 2 * Math.tan(MathUtils.degToRad(camera.fov * 0.5)) * distance;
|
|
33971
34000
|
const canvasHeight = this.canvas.height;
|
|
33972
|
-
const worldUnitsPerPixel =
|
|
34001
|
+
const worldUnitsPerPixel = fieldHeight / canvasHeight;
|
|
33973
34002
|
return this.detectRadiusInPixels * worldUnitsPerPixel;
|
|
33974
34003
|
}
|
|
33975
34004
|
return 0.1;
|
|
33976
34005
|
}
|
|
33977
34006
|
getSnapPoint(event) {
|
|
33978
34007
|
const mouse = this.getMousePosition(event, new Vector2());
|
|
33979
|
-
const intersections = this.getPointerIntersects(mouse
|
|
34008
|
+
const intersections = this.getPointerIntersects(mouse);
|
|
33980
34009
|
if (intersections.length === 0)
|
|
33981
34010
|
return undefined;
|
|
33982
34011
|
const object = intersections[0].object;
|
|
@@ -34024,40 +34053,47 @@ void main() {
|
|
|
34024
34053
|
return object.localToWorld(snapPoint);
|
|
34025
34054
|
return intersectionPoint.clone();
|
|
34026
34055
|
}
|
|
34027
|
-
|
|
34056
|
+
setFromViewer(viewer) {
|
|
34028
34057
|
this.objects.length = 0;
|
|
34029
34058
|
viewer.models.forEach((model) => {
|
|
34030
34059
|
model.getVisibleObjects().forEach((object) => this.objects.push(object));
|
|
34031
34060
|
});
|
|
34061
|
+
this.camera = viewer.camera;
|
|
34062
|
+
this.clippingPlanes = viewer.renderer.clippingPlanes || [];
|
|
34032
34063
|
}
|
|
34033
34064
|
}
|
|
34034
34065
|
class MeasureOverlay {
|
|
34035
34066
|
constructor(camera, canvas) {
|
|
34036
34067
|
this.lines = [];
|
|
34068
|
+
this.resizeContainer = (entries) => {
|
|
34069
|
+
const { width, height } = entries[0].contentRect;
|
|
34070
|
+
if (!width || !height)
|
|
34071
|
+
return;
|
|
34072
|
+
this.container.style.width = `${width}px`;
|
|
34073
|
+
this.container.style.height = `${height}px`;
|
|
34074
|
+
};
|
|
34037
34075
|
this.camera = camera;
|
|
34038
34076
|
this.canvas = canvas;
|
|
34039
34077
|
this.projector = new MeasureProjector(camera, canvas);
|
|
34078
|
+
this.resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
34040
34079
|
}
|
|
34041
34080
|
attach() {
|
|
34042
34081
|
this.container = document.createElement("div");
|
|
34043
34082
|
this.container.id = "measure-container";
|
|
34044
|
-
this.container.style.background = "rgba(0,0,0,0)";
|
|
34045
34083
|
this.container.style.position = "absolute";
|
|
34046
|
-
this.container.style.top = "0px";
|
|
34047
|
-
this.container.style.left = "0px";
|
|
34048
|
-
this.container.style.width = "100%";
|
|
34049
|
-
this.container.style.height = "100%";
|
|
34050
34084
|
this.container.style.outline = "none";
|
|
34051
34085
|
this.container.style.pointerEvents = "none";
|
|
34052
34086
|
this.container.style.overflow = "hidden";
|
|
34053
34087
|
if (!this.canvas.parentElement)
|
|
34054
34088
|
return;
|
|
34055
34089
|
this.canvas.parentElement.appendChild(this.container);
|
|
34090
|
+
this.resizeObserver.observe(this.canvas.parentElement);
|
|
34056
34091
|
}
|
|
34057
34092
|
dispose() {
|
|
34058
34093
|
this.clear();
|
|
34059
34094
|
}
|
|
34060
34095
|
detach() {
|
|
34096
|
+
this.resizeObserver.disconnect();
|
|
34061
34097
|
this.container.remove();
|
|
34062
34098
|
this.container = undefined;
|
|
34063
34099
|
}
|
|
@@ -34066,7 +34102,7 @@ void main() {
|
|
|
34066
34102
|
this.lines = [];
|
|
34067
34103
|
}
|
|
34068
34104
|
render() {
|
|
34069
|
-
this.projector.
|
|
34105
|
+
this.projector.setFromCamera(this.camera);
|
|
34070
34106
|
this.lines.forEach((line) => line.render());
|
|
34071
34107
|
}
|
|
34072
34108
|
update() {
|
|
@@ -34217,6 +34253,10 @@ void main() {
|
|
|
34217
34253
|
this.camera = camera;
|
|
34218
34254
|
this.canvas = canvas;
|
|
34219
34255
|
}
|
|
34256
|
+
setFromCamera(camera) {
|
|
34257
|
+
this.camera = camera;
|
|
34258
|
+
this.updateProjectionMatrix();
|
|
34259
|
+
}
|
|
34220
34260
|
updateProjectionMatrix() {
|
|
34221
34261
|
const rect = this.canvas.getBoundingClientRect();
|
|
34222
34262
|
_widthHalf = rect.width / 2;
|
|
@@ -34393,7 +34433,7 @@ void main() {
|
|
|
34393
34433
|
Points: { threshold: 0 },
|
|
34394
34434
|
Sprite: { threshold: 0 },
|
|
34395
34435
|
};
|
|
34396
|
-
|
|
34436
|
+
const intersects = this.raycaster.intersectObjects(this.groundObjects, false);
|
|
34397
34437
|
if (intersects.length > 0) {
|
|
34398
34438
|
const groundY = intersects[0].point.y;
|
|
34399
34439
|
const targetY = groundY + this.EYE_HEIGHT;
|
|
@@ -34485,6 +34525,9 @@ void main() {
|
|
|
34485
34525
|
const size = this.viewer.extents.getSize(new Vector3());
|
|
34486
34526
|
this.controls.movementSpeed = Math.min(size.x, size.y, size.z) / 2;
|
|
34487
34527
|
};
|
|
34528
|
+
this.updateControlsCamera = () => {
|
|
34529
|
+
this.controls.object = this.viewer.camera;
|
|
34530
|
+
};
|
|
34488
34531
|
this.controlsChange = () => {
|
|
34489
34532
|
this.viewer.update();
|
|
34490
34533
|
this.viewer.emitEvent({ type: "changecamera" });
|
|
@@ -34508,13 +34551,15 @@ void main() {
|
|
|
34508
34551
|
this.controls.addEventListener("change", this.controlsChange);
|
|
34509
34552
|
this.controls.addEventListener("walkspeedchange", this.walkspeedChange);
|
|
34510
34553
|
this.viewer = viewer;
|
|
34511
|
-
this.viewer.
|
|
34512
|
-
this.viewer.
|
|
34554
|
+
this.viewer.addEventListener("render", this.viewerRender);
|
|
34555
|
+
this.viewer.addEventListener("zoom", this.viewerZoom);
|
|
34556
|
+
this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
|
|
34513
34557
|
this.updateControls();
|
|
34514
34558
|
}
|
|
34515
34559
|
dispose() {
|
|
34516
|
-
this.viewer.
|
|
34517
|
-
this.viewer.
|
|
34560
|
+
this.viewer.removeEventListener("render", this.viewerRender);
|
|
34561
|
+
this.viewer.removeEventListener("zoom", this.viewerZoom);
|
|
34562
|
+
this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
|
|
34518
34563
|
this.controls.removeEventListener("walkspeedchange", this.walkspeedChange);
|
|
34519
34564
|
this.controls.removeEventListener("change", this.controlsChange);
|
|
34520
34565
|
this.controls.dispose();
|
|
@@ -34674,6 +34719,9 @@ void main() {
|
|
|
34674
34719
|
const size = this.viewer.extents.getSize(new Vector3());
|
|
34675
34720
|
this.controls.movementSpeed = Math.min(size.x, size.y, size.z) / 2;
|
|
34676
34721
|
};
|
|
34722
|
+
this.updateControlsCamera = () => {
|
|
34723
|
+
this.controls.object = this.viewer.camera;
|
|
34724
|
+
};
|
|
34677
34725
|
this.controlsChange = () => {
|
|
34678
34726
|
this.viewer.update();
|
|
34679
34727
|
this.viewer.emitEvent({ type: "changecamera" });
|
|
@@ -34691,13 +34739,15 @@ void main() {
|
|
|
34691
34739
|
this.controls.addEventListener("change", this.controlsChange);
|
|
34692
34740
|
this.controls.addEventListener("flyspeedchange", this.flyspeedChange);
|
|
34693
34741
|
this.viewer = viewer;
|
|
34694
|
-
this.viewer.
|
|
34695
|
-
this.viewer.
|
|
34742
|
+
this.viewer.addEventListener("render", this.viewerRender);
|
|
34743
|
+
this.viewer.addEventListener("zoom", this.viewerZoom);
|
|
34744
|
+
this.viewer.addEventListener("changecameramode", this.updateControlsCamera);
|
|
34696
34745
|
this.updateControls();
|
|
34697
34746
|
}
|
|
34698
34747
|
dispose() {
|
|
34699
|
-
this.viewer.
|
|
34700
|
-
this.viewer.
|
|
34748
|
+
this.viewer.removeEventListener("render", this.viewerRender);
|
|
34749
|
+
this.viewer.removeEventListener("zoom", this.viewerZoom);
|
|
34750
|
+
this.viewer.removeEventListener("changecameramode", this.updateControlsCamera);
|
|
34701
34751
|
this.controls.removeEventListener("flyspeedchange", this.flyspeedChange);
|
|
34702
34752
|
this.controls.removeEventListener("change", this.controlsChange);
|
|
34703
34753
|
this.controls.dispose();
|
|
@@ -34995,10 +35045,10 @@ void main() {
|
|
|
34995
35045
|
|
|
34996
35046
|
class CameraComponent {
|
|
34997
35047
|
constructor(viewer) {
|
|
35048
|
+
this.optionsChange = () => {
|
|
35049
|
+
this.switchCameraMode(this.viewer.options.cameraMode);
|
|
35050
|
+
};
|
|
34998
35051
|
this.geometryEnd = () => {
|
|
34999
|
-
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2;
|
|
35000
|
-
const rendererSize = this.viewer.renderer.getSize(new Vector2());
|
|
35001
|
-
const aspect = rendererSize.x / rendererSize.y;
|
|
35002
35052
|
let camera;
|
|
35003
35053
|
this.viewer.scene.traverse((object) => {
|
|
35004
35054
|
if (object.isCamera)
|
|
@@ -35010,36 +35060,83 @@ void main() {
|
|
|
35010
35060
|
if (camera) {
|
|
35011
35061
|
camera.isDefaultCamera = true;
|
|
35012
35062
|
camera.scale.set(1, 1, 1);
|
|
35013
|
-
this.
|
|
35014
|
-
|
|
35015
|
-
this.viewer.
|
|
35016
|
-
this.viewer.
|
|
35063
|
+
this.switchCamera(camera);
|
|
35064
|
+
const mode = this.getCameraMode(camera);
|
|
35065
|
+
this.viewer.options.cameraMode = mode;
|
|
35066
|
+
this.viewer.emitEvent({ type: "changecameramode", mode });
|
|
35017
35067
|
}
|
|
35018
35068
|
else {
|
|
35019
|
-
|
|
35020
|
-
}
|
|
35021
|
-
if (camera.isPerspectiveCamera) {
|
|
35022
|
-
camera.aspect = aspect;
|
|
35023
|
-
camera.near = extentsSize / 1000;
|
|
35024
|
-
camera.far = extentsSize * 1000;
|
|
35025
|
-
camera.updateProjectionMatrix();
|
|
35026
|
-
}
|
|
35027
|
-
if (camera.isOrthographicCamera) {
|
|
35028
|
-
camera.left = camera.bottom * aspect;
|
|
35029
|
-
camera.right = camera.top * aspect;
|
|
35030
|
-
camera.near = 0;
|
|
35031
|
-
camera.far = extentsSize * 1000;
|
|
35032
|
-
camera.updateProjectionMatrix();
|
|
35033
|
-
}
|
|
35034
|
-
if (!camera.isDefaultCamera) {
|
|
35069
|
+
this.switchCamera(this.viewer.camera);
|
|
35035
35070
|
this.viewer.executeCommand("setDefaultViewPosition");
|
|
35036
35071
|
}
|
|
35037
35072
|
};
|
|
35038
35073
|
this.viewer = viewer;
|
|
35039
35074
|
this.viewer.addEventListener("databasechunk", this.geometryEnd);
|
|
35075
|
+
this.viewer.addEventListener("optionschange", this.optionsChange);
|
|
35076
|
+
this.viewer.addEventListener("initialize", this.optionsChange);
|
|
35040
35077
|
}
|
|
35041
35078
|
dispose() {
|
|
35042
35079
|
this.viewer.removeEventListener("databasechunk", this.geometryEnd);
|
|
35080
|
+
this.viewer.removeEventListener("optionschange", this.optionsChange);
|
|
35081
|
+
this.viewer.removeEventListener("initialize", this.optionsChange);
|
|
35082
|
+
}
|
|
35083
|
+
getCameraMode(camera) {
|
|
35084
|
+
return camera.isOrthographicCamera ? "orthographic" : "perspective";
|
|
35085
|
+
}
|
|
35086
|
+
switchCamera(camera) {
|
|
35087
|
+
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere()).radius * 2 || 1;
|
|
35088
|
+
const rendererSize = this.viewer.renderer.getSize(new Vector2());
|
|
35089
|
+
const aspect = rendererSize.x / rendererSize.y;
|
|
35090
|
+
if (camera.isPerspectiveCamera) {
|
|
35091
|
+
camera.aspect = aspect;
|
|
35092
|
+
camera.near = extentsSize / 1000;
|
|
35093
|
+
camera.far = extentsSize * 1000;
|
|
35094
|
+
}
|
|
35095
|
+
if (camera.isOrthographicCamera) {
|
|
35096
|
+
camera.left = camera.bottom * aspect;
|
|
35097
|
+
camera.right = camera.top * aspect;
|
|
35098
|
+
camera.near = 0;
|
|
35099
|
+
camera.far = extentsSize * 1000;
|
|
35100
|
+
}
|
|
35101
|
+
camera.updateProjectionMatrix();
|
|
35102
|
+
this.viewer.camera = camera;
|
|
35103
|
+
this.viewer.renderPass.camera = camera;
|
|
35104
|
+
this.viewer.helpersPass.camera = camera;
|
|
35105
|
+
this.viewer.ssaaRenderPass.camera = camera;
|
|
35106
|
+
this.viewer.update();
|
|
35107
|
+
}
|
|
35108
|
+
switchCameraMode(mode) {
|
|
35109
|
+
if (!mode)
|
|
35110
|
+
return;
|
|
35111
|
+
const currentCamera = this.viewer.camera;
|
|
35112
|
+
if (mode === this.getCameraMode(currentCamera))
|
|
35113
|
+
return;
|
|
35114
|
+
const target = this.viewer.target.clone();
|
|
35115
|
+
let camera;
|
|
35116
|
+
if (currentCamera.isOrthographicCamera) {
|
|
35117
|
+
const fov = currentCamera.userData.fov || 45;
|
|
35118
|
+
const fieldHeight = (currentCamera.top - currentCamera.bottom) / currentCamera.zoom;
|
|
35119
|
+
const distance = fieldHeight / (2 * Math.tan(MathUtils.degToRad(fov) / 2));
|
|
35120
|
+
const direction = new Vector3().subVectors(currentCamera.position, target).normalize();
|
|
35121
|
+
camera = new PerspectiveCamera(fov);
|
|
35122
|
+
camera.position.copy(direction).multiplyScalar(distance).add(target);
|
|
35123
|
+
}
|
|
35124
|
+
if (currentCamera.isPerspectiveCamera) {
|
|
35125
|
+
const fov = currentCamera.fov;
|
|
35126
|
+
const distance = currentCamera.position.distanceTo(target);
|
|
35127
|
+
const fieldHeight = 2 * Math.tan(MathUtils.degToRad(fov) / 2) * distance;
|
|
35128
|
+
camera = new OrthographicCamera();
|
|
35129
|
+
camera.top = fieldHeight / 2;
|
|
35130
|
+
camera.bottom = -fieldHeight / 2;
|
|
35131
|
+
camera.position.copy(currentCamera.position);
|
|
35132
|
+
camera.userData.fov = fov;
|
|
35133
|
+
}
|
|
35134
|
+
if (!camera)
|
|
35135
|
+
return;
|
|
35136
|
+
camera.up.copy(currentCamera.up);
|
|
35137
|
+
camera.quaternion.copy(currentCamera.quaternion);
|
|
35138
|
+
this.switchCamera(camera);
|
|
35139
|
+
this.viewer.emitEvent({ type: "changecameramode", mode });
|
|
35043
35140
|
}
|
|
35044
35141
|
}
|
|
35045
35142
|
|
|
@@ -36075,7 +36172,11 @@ void main() {
|
|
|
36075
36172
|
Points: { threshold: 0.01 },
|
|
36076
36173
|
Sprite: {},
|
|
36077
36174
|
};
|
|
36078
|
-
|
|
36175
|
+
let intersects = this.raycaster.intersectObjects(objects, false);
|
|
36176
|
+
(this.viewer.renderer.clippingPlanes || []).forEach((plane) => {
|
|
36177
|
+
intersects = intersects.filter((intersect) => plane.distanceToPoint(intersect.point) >= 0);
|
|
36178
|
+
});
|
|
36179
|
+
return intersects;
|
|
36079
36180
|
}
|
|
36080
36181
|
select(objects, model) {
|
|
36081
36182
|
if (!model) {
|
|
@@ -56053,16 +56154,17 @@ void main() {
|
|
|
56053
56154
|
this._markupContainer = document.createElement("div");
|
|
56054
56155
|
this._markupContainer.id = "markup-container";
|
|
56055
56156
|
this._markupContainer.style.position = "absolute";
|
|
56056
|
-
this._markupContainer.style.top = "0px";
|
|
56057
|
-
this._markupContainer.style.left = "0px";
|
|
56058
56157
|
this._markupContainer.style.outline = "0px";
|
|
56059
56158
|
this._markupContainer.style.pointerEvents = "none";
|
|
56060
56159
|
const parentDiv = this._container.parentElement;
|
|
56061
56160
|
parentDiv.appendChild(this._markupContainer);
|
|
56062
|
-
if (viewer)
|
|
56161
|
+
if (viewer) {
|
|
56063
56162
|
this._viewer.addEventListener("resize", this.resizeViewer);
|
|
56064
|
-
|
|
56163
|
+
}
|
|
56164
|
+
else {
|
|
56065
56165
|
this._resizeObserver = new ResizeObserver(debounce(this.resizeContainer, 100));
|
|
56166
|
+
this._resizeObserver.observe(parentDiv);
|
|
56167
|
+
}
|
|
56066
56168
|
this._markupColor.setColor(255, 0, 0);
|
|
56067
56169
|
this.initializeKonva();
|
|
56068
56170
|
if (this._viewer) {
|
|
@@ -57241,6 +57343,7 @@ void main() {
|
|
|
57241
57343
|
this.renderPass.camera = camera;
|
|
57242
57344
|
this.helpersPass.camera = camera;
|
|
57243
57345
|
this.ssaaRenderPass.camera = camera;
|
|
57346
|
+
this.emitEvent({ type: "changecameramode", mode: "orthographic" });
|
|
57244
57347
|
}
|
|
57245
57348
|
};
|
|
57246
57349
|
const setPerspectiveCamera = (perspective_camera) => {
|
|
@@ -57262,6 +57365,7 @@ void main() {
|
|
|
57262
57365
|
this.renderPass.camera = camera;
|
|
57263
57366
|
this.helpersPass.camera = camera;
|
|
57264
57367
|
this.ssaaRenderPass.camera = camera;
|
|
57368
|
+
this.emitEvent({ type: "changecameramode", mode: "perspective" });
|
|
57265
57369
|
}
|
|
57266
57370
|
};
|
|
57267
57371
|
const setClippingPlanes = (clipping_planes) => {
|