@inweb/viewer-three 26.1.2 → 26.1.4
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 +16315 -16590
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +3 -9
- package/dist/viewer-three.module.js +165 -251
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +34 -34
- package/lib/Viewer/commands/index.d.ts +8 -14
- package/lib/Viewer/components/DefaultPositionComponent.d.ts +9 -0
- package/lib/Viewer/components/WCSHelperComponent.d.ts +0 -1
- package/lib/Viewer/components/index.d.ts +20 -20
- package/lib/Viewer/draggers/OrbitDragger.d.ts +0 -1
- package/lib/Viewer/draggers/index.d.ts +19 -25
- package/package.json +9 -9
- package/src/Viewer/Viewer.ts +50 -112
- package/src/Viewer/commands/Explode.ts +27 -26
- package/src/Viewer/commands/IsolateSelected.ts +15 -6
- package/src/Viewer/commands/SetDefaultViewPosition.ts +4 -4
- package/src/Viewer/commands/ZoomToExtents.ts +15 -2
- package/src/Viewer/commands/ZoomToObjects.ts +12 -4
- package/src/Viewer/commands/ZoomToSelected.ts +14 -3
- package/src/Viewer/commands/index.ts +8 -14
- package/src/Viewer/{commands/ZoomTo.ts → components/DefaultPositionComponent.ts} +22 -34
- package/src/Viewer/components/ExtentsComponent.ts +3 -10
- package/src/Viewer/components/ResizeCanvasComponent.ts +2 -13
- package/src/Viewer/components/WCSHelperComponent.ts +0 -9
- package/src/Viewer/components/index.ts +22 -22
- package/src/Viewer/draggers/OrbitDragger.ts +8 -11
- package/src/Viewer/draggers/index.ts +19 -25
- package/lib/Viewer/commands/ZoomTo.d.ts +0 -3
- package/lib/Viewer/components/CameraComponent.d.ts +0 -8
- package/src/Viewer/components/CameraComponent.ts +0 -78
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
|
|
3
|
-
import { Line,
|
|
3
|
+
import { Line, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, Vector3, EventDispatcher, MOUSE, TOUCH, Quaternion, Spherical, Vector2, Plane, Object3D, Matrix4, Vector4, Raycaster, Controls, Clock, Box3, Sphere, Color, PMREMGenerator, AmbientLight, DirectionalLight, OrthographicCamera, CylinderGeometry, Sprite, CanvasTexture, SRGBColorSpace, SpriteMaterial, LoadingManager, LoaderUtils, Scene, PerspectiveCamera, WebGLRenderer, LinearToneMapping } from "three";
|
|
4
4
|
|
|
5
5
|
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ class CommandsRegistry {
|
|
|
43
43
|
}
|
|
44
44
|
const {handler: handler, thisArg: thisArg} = command;
|
|
45
45
|
const result = handler.apply(thisArg, [ viewer, ...args ]);
|
|
46
|
-
viewer === null || viewer ===
|
|
46
|
+
viewer === null || viewer === void 0 ? void 0 : viewer.emit({
|
|
47
47
|
type: "command",
|
|
48
48
|
data: id,
|
|
49
49
|
args: args
|
|
@@ -539,8 +539,8 @@ class KonvaLine {
|
|
|
539
539
|
const konvaPoints = [];
|
|
540
540
|
params.points.forEach((point => konvaPoints.push(point.x, point.y)));
|
|
541
541
|
this._ref = new Konva.Line({
|
|
542
|
-
stroke: (_a = params.color) !== null && _a !==
|
|
543
|
-
strokeWidth: (_b = params.width) !== null && _b !==
|
|
542
|
+
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
543
|
+
strokeWidth: (_b = params.width) !== null && _b !== void 0 ? _b : 4,
|
|
544
544
|
globalCompositeOperation: "source-over",
|
|
545
545
|
lineCap: "round",
|
|
546
546
|
lineJoin: "round",
|
|
@@ -647,12 +647,12 @@ class KonvaText {
|
|
|
647
647
|
x: params.position.x,
|
|
648
648
|
y: params.position.y,
|
|
649
649
|
text: params.text,
|
|
650
|
-
fontSize: (_a = params.fontSize) !== null && _a !==
|
|
650
|
+
fontSize: (_a = params.fontSize) !== null && _a !== void 0 ? _a : 34,
|
|
651
651
|
fontFamily: this.TEXT_FONT_FAMILY,
|
|
652
|
-
fill: (_b = params.color) !== null && _b !==
|
|
652
|
+
fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
|
|
653
653
|
align: "left",
|
|
654
654
|
draggable: true,
|
|
655
|
-
rotation: (_c = params.rotation) !== null && _c !==
|
|
655
|
+
rotation: (_c = params.rotation) !== null && _c !== void 0 ? _c : 0
|
|
656
656
|
});
|
|
657
657
|
this._ref.width(this._ref.getTextWidth());
|
|
658
658
|
this._ref.on("transform", (e => {
|
|
@@ -750,15 +750,15 @@ class KonvaRectangle {
|
|
|
750
750
|
y: 100
|
|
751
751
|
};
|
|
752
752
|
this._ref = new Konva.Rect({
|
|
753
|
-
stroke: (_a = params.color) !== null && _a !==
|
|
754
|
-
strokeWidth: (_b = params.lineWidth) !== null && _b !==
|
|
753
|
+
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
754
|
+
strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
|
|
755
755
|
globalCompositeOperation: "source-over",
|
|
756
756
|
lineCap: "round",
|
|
757
757
|
lineJoin: "round",
|
|
758
758
|
x: params.position.x,
|
|
759
759
|
y: params.position.y,
|
|
760
|
-
width: (_c = params.width) !== null && _c !==
|
|
761
|
-
height: (_d = params.height) !== null && _d !==
|
|
760
|
+
width: (_c = params.width) !== null && _c !== void 0 ? _c : 200,
|
|
761
|
+
height: (_d = params.height) !== null && _d !== void 0 ? _d : 200,
|
|
762
762
|
draggable: true,
|
|
763
763
|
strokeScaleEnabled: false
|
|
764
764
|
});
|
|
@@ -868,8 +868,8 @@ class KonvaEllipse {
|
|
|
868
868
|
y: 25
|
|
869
869
|
};
|
|
870
870
|
this._ref = new Konva.Ellipse({
|
|
871
|
-
stroke: (_a = params.color) !== null && _a !==
|
|
872
|
-
strokeWidth: (_b = params.lineWidth) !== null && _b !==
|
|
871
|
+
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
872
|
+
strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
|
|
873
873
|
globalCompositeOperation: "source-over",
|
|
874
874
|
lineCap: "round",
|
|
875
875
|
lineJoin: "round",
|
|
@@ -998,8 +998,8 @@ class KonvaArrow {
|
|
|
998
998
|
y: 100
|
|
999
999
|
};
|
|
1000
1000
|
this._ref = new Konva.Arrow({
|
|
1001
|
-
stroke: (_a = params.color) !== null && _a !==
|
|
1002
|
-
fill: (_b = params.color) !== null && _b !==
|
|
1001
|
+
stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
|
|
1002
|
+
fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
|
|
1003
1003
|
strokeWidth: 4,
|
|
1004
1004
|
globalCompositeOperation: "source-over",
|
|
1005
1005
|
lineCap: "round",
|
|
@@ -1139,8 +1139,8 @@ class KonvaImage {
|
|
|
1139
1139
|
x: params.position.x,
|
|
1140
1140
|
y: params.position.y,
|
|
1141
1141
|
image: this._canvasImage,
|
|
1142
|
-
width: (_a = params.width) !== null && _a !==
|
|
1143
|
-
height: (_b = params.height) !== null && _b !==
|
|
1142
|
+
width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
|
|
1143
|
+
height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
|
|
1144
1144
|
draggable: true
|
|
1145
1145
|
});
|
|
1146
1146
|
this._ref.on("transform", (e => {
|
|
@@ -1250,10 +1250,10 @@ class KonvaCloud {
|
|
|
1250
1250
|
this._ref = new Konva.Shape({
|
|
1251
1251
|
x: params.position.x,
|
|
1252
1252
|
y: params.position.y,
|
|
1253
|
-
width: (_a = params.width) !== null && _a !==
|
|
1254
|
-
height: (_b = params.height) !== null && _b !==
|
|
1255
|
-
stroke: (_c = params.color) !== null && _c !==
|
|
1256
|
-
strokeWidth: (_d = params.lineWidth) !== null && _d !==
|
|
1253
|
+
width: (_a = params.width) !== null && _a !== void 0 ? _a : 200,
|
|
1254
|
+
height: (_b = params.height) !== null && _b !== void 0 ? _b : 200,
|
|
1255
|
+
stroke: (_c = params.color) !== null && _c !== void 0 ? _c : "#ff0000",
|
|
1256
|
+
strokeWidth: (_d = params.lineWidth) !== null && _d !== void 0 ? _d : 4,
|
|
1257
1257
|
draggable: true,
|
|
1258
1258
|
strokeScaleEnabled: false,
|
|
1259
1259
|
globalCompositeOperation: "source-over",
|
|
@@ -1502,9 +1502,9 @@ class KonvaMarkup {
|
|
|
1502
1502
|
initialize(container, containerEvents, viewer, worldTransformer) {
|
|
1503
1503
|
if (!Konva) throw new Error('Markup error: Konva is not initialized. Forgot to add <script src="https://unpkg.com/konva@9/konva.min.js"><\/script> to your page?');
|
|
1504
1504
|
this._viewer = viewer;
|
|
1505
|
-
this._worldTransformer = worldTransformer !== null && worldTransformer !==
|
|
1505
|
+
this._worldTransformer = worldTransformer !== null && worldTransformer !== void 0 ? worldTransformer : new WorldTransform;
|
|
1506
1506
|
this._container = container;
|
|
1507
|
-
this._containerEvents = containerEvents !== null && containerEvents !==
|
|
1507
|
+
this._containerEvents = containerEvents !== null && containerEvents !== void 0 ? containerEvents : [];
|
|
1508
1508
|
this._markupContainer = document.createElement("div");
|
|
1509
1509
|
this._markupContainer.id = "markup-container";
|
|
1510
1510
|
this._markupContainer.style.position = "absolute";
|
|
@@ -1532,9 +1532,9 @@ class KonvaMarkup {
|
|
|
1532
1532
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
1533
1533
|
}
|
|
1534
1534
|
this.destroyKonva();
|
|
1535
|
-
(_a = this._resizeObserver) === null || _a ===
|
|
1535
|
+
(_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
1536
1536
|
this._resizeObserver = undefined;
|
|
1537
|
-
(_b = this._markupContainer) === null || _b ===
|
|
1537
|
+
(_b = this._markupContainer) === null || _b === void 0 ? void 0 : _b.remove();
|
|
1538
1538
|
this._markupContainer = undefined;
|
|
1539
1539
|
this._container = undefined;
|
|
1540
1540
|
this._viewer = undefined;
|
|
@@ -1566,14 +1566,14 @@ class KonvaMarkup {
|
|
|
1566
1566
|
const hexColor = new MarkupColor(r, g, b).asHex();
|
|
1567
1567
|
this.getObjects().filter((obj => {
|
|
1568
1568
|
var _a;
|
|
1569
|
-
return (_a = obj.setColor) === null || _a ===
|
|
1569
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
1570
1570
|
}));
|
|
1571
1571
|
}
|
|
1572
1572
|
colorizeSelectedMarkups(r, g, b) {
|
|
1573
1573
|
const hexColor = new MarkupColor(r, g, b).asHex();
|
|
1574
1574
|
this.getSelectedObjects().filter((obj => {
|
|
1575
1575
|
var _a;
|
|
1576
|
-
return (_a = obj.setColor) === null || _a ===
|
|
1576
|
+
return (_a = obj.setColor) === null || _a === void 0 ? void 0 : _a.call(obj, hexColor);
|
|
1577
1577
|
}));
|
|
1578
1578
|
}
|
|
1579
1579
|
setViewpoint(viewpoint) {
|
|
@@ -1589,13 +1589,13 @@ class KonvaMarkup {
|
|
|
1589
1589
|
x: 0,
|
|
1590
1590
|
y: 0
|
|
1591
1591
|
});
|
|
1592
|
-
const markupColor = ((_a = viewpoint.custom_fields) === null || _a ===
|
|
1592
|
+
const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || {
|
|
1593
1593
|
r: 255,
|
|
1594
1594
|
g: 0,
|
|
1595
1595
|
b: 0
|
|
1596
1596
|
};
|
|
1597
1597
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
1598
|
-
(_b = viewpoint.lines) === null || _b ===
|
|
1598
|
+
(_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line => {
|
|
1599
1599
|
const linePoints = [];
|
|
1600
1600
|
line.points.forEach((point => {
|
|
1601
1601
|
const screenPoint = this._worldTransformer.worldToScreen(point);
|
|
@@ -1604,28 +1604,28 @@ class KonvaMarkup {
|
|
|
1604
1604
|
}));
|
|
1605
1605
|
this.addLine(linePoints, line.color, line.type, line.width, line.id);
|
|
1606
1606
|
}));
|
|
1607
|
-
(_c = viewpoint.texts) === null || _c ===
|
|
1607
|
+
(_c = viewpoint.texts) === null || _c === void 0 ? void 0 : _c.forEach((text => {
|
|
1608
1608
|
const screenPoint = this._worldTransformer.worldToScreen(text.position);
|
|
1609
1609
|
this.addText(text.text, screenPoint, text.angle, text.color, text.text_size, text.font_size, text.id);
|
|
1610
1610
|
}));
|
|
1611
|
-
(_d = viewpoint.rectangles) === null || _d ===
|
|
1611
|
+
(_d = viewpoint.rectangles) === null || _d === void 0 ? void 0 : _d.forEach((rect => {
|
|
1612
1612
|
const screenPoint = this._worldTransformer.worldToScreen(rect.position);
|
|
1613
1613
|
this.addRectangle(screenPoint, rect.width, rect.height, rect.line_width, rect.color, rect.id);
|
|
1614
1614
|
}));
|
|
1615
|
-
(_e = viewpoint.ellipses) === null || _e ===
|
|
1615
|
+
(_e = viewpoint.ellipses) === null || _e === void 0 ? void 0 : _e.forEach((ellipse => {
|
|
1616
1616
|
const screenPoint = this._worldTransformer.worldToScreen(ellipse.position);
|
|
1617
1617
|
this.addEllipse(screenPoint, ellipse.radius, ellipse.line_width, ellipse.color, ellipse.id);
|
|
1618
1618
|
}));
|
|
1619
|
-
(_f = viewpoint.arrows) === null || _f ===
|
|
1619
|
+
(_f = viewpoint.arrows) === null || _f === void 0 ? void 0 : _f.forEach((arrow => {
|
|
1620
1620
|
const startPoint = this._worldTransformer.worldToScreen(arrow.start);
|
|
1621
1621
|
const endPoint = this._worldTransformer.worldToScreen(arrow.end);
|
|
1622
1622
|
this.addArrow(startPoint, endPoint, arrow.color, arrow.id);
|
|
1623
1623
|
}));
|
|
1624
|
-
(_g = viewpoint.clouds) === null || _g ===
|
|
1624
|
+
(_g = viewpoint.clouds) === null || _g === void 0 ? void 0 : _g.forEach((cloud => {
|
|
1625
1625
|
const screenPoint = this._worldTransformer.worldToScreen(cloud.position);
|
|
1626
1626
|
this.addCloud(screenPoint, cloud.width, cloud.height, cloud.line_width, cloud.color, cloud.id);
|
|
1627
1627
|
}));
|
|
1628
|
-
(_h = viewpoint.images) === null || _h ===
|
|
1628
|
+
(_h = viewpoint.images) === null || _h === void 0 ? void 0 : _h.forEach((image => {
|
|
1629
1629
|
const screenPoint = this._worldTransformer.worldToScreen(image.position);
|
|
1630
1630
|
this.addImage(screenPoint, image.src, image.width, image.height, image.id);
|
|
1631
1631
|
}));
|
|
@@ -1919,7 +1919,7 @@ class KonvaMarkup {
|
|
|
1919
1919
|
this.removeTextInput();
|
|
1920
1920
|
this.removeImageInput();
|
|
1921
1921
|
this.clearOverlay();
|
|
1922
|
-
(_a = this._konvaStage) === null || _a ===
|
|
1922
|
+
(_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
1923
1923
|
this._groupImages = undefined;
|
|
1924
1924
|
this._groupGeometry = undefined;
|
|
1925
1925
|
this._groupTexts = undefined;
|
|
@@ -2169,7 +2169,7 @@ class KonvaMarkup {
|
|
|
2169
2169
|
}
|
|
2170
2170
|
removeTextInput() {
|
|
2171
2171
|
var _a;
|
|
2172
|
-
(_a = this._textInputRef) === null || _a ===
|
|
2172
|
+
(_a = this._textInputRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
2173
2173
|
this._textInputRef = null;
|
|
2174
2174
|
this._textInputPos = null;
|
|
2175
2175
|
this._textInputAngle = 0;
|
|
@@ -2212,14 +2212,14 @@ class KonvaMarkup {
|
|
|
2212
2212
|
}
|
|
2213
2213
|
removeImageInput() {
|
|
2214
2214
|
var _a;
|
|
2215
|
-
(_a = this._imageInputRef) === null || _a ===
|
|
2215
|
+
(_a = this._imageInputRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
2216
2216
|
this._imageInputRef = null;
|
|
2217
2217
|
this._imageInputPos = null;
|
|
2218
2218
|
}
|
|
2219
2219
|
addText(text, position, angle, color, textSize, fontSize, id) {
|
|
2220
2220
|
var _a;
|
|
2221
2221
|
if (!text) return;
|
|
2222
|
-
(_a = this.getSelectedObjects().at(0)) === null || _a ===
|
|
2222
|
+
(_a = this.getSelectedObjects().at(0)) === null || _a === void 0 ? void 0 : _a.delete();
|
|
2223
2223
|
this.clearSelected();
|
|
2224
2224
|
this.removeTextInput();
|
|
2225
2225
|
const tolerance = 1e-6;
|
|
@@ -2294,7 +2294,7 @@ class KonvaMarkup {
|
|
|
2294
2294
|
addImage(position, src, width, height, id) {
|
|
2295
2295
|
var _a;
|
|
2296
2296
|
if (!position || !src) return;
|
|
2297
|
-
(_a = this.getSelectedObjects().at(0)) === null || _a ===
|
|
2297
|
+
(_a = this.getSelectedObjects().at(0)) === null || _a === void 0 ? void 0 : _a.delete();
|
|
2298
2298
|
this.clearSelected();
|
|
2299
2299
|
this.removeImageInput();
|
|
2300
2300
|
const konvaImage = new KonvaImage({
|
|
@@ -3049,7 +3049,6 @@ class OrbitDragger {
|
|
|
3049
3049
|
this.updateControls = () => {
|
|
3050
3050
|
this.orbit.maxDistance = this.viewer.camera.far;
|
|
3051
3051
|
this.orbit.minDistance = this.viewer.camera.near;
|
|
3052
|
-
this.orbit.object = this.viewer.camera;
|
|
3053
3052
|
this.orbit.target.copy(this.viewer.target);
|
|
3054
3053
|
this.orbit.update();
|
|
3055
3054
|
};
|
|
@@ -3104,20 +3103,19 @@ class OrbitDragger {
|
|
|
3104
3103
|
this.orbit.addEventListener("change", this.controlsChange);
|
|
3105
3104
|
this.changed = false;
|
|
3106
3105
|
this.viewer = viewer;
|
|
3107
|
-
this.viewer.
|
|
3106
|
+
this.viewer.on("geometryend", this.updateControls);
|
|
3108
3107
|
this.viewer.on("viewposition", this.updateControls);
|
|
3109
|
-
this.viewer.
|
|
3110
|
-
this.viewer.
|
|
3111
|
-
this.viewer.
|
|
3108
|
+
this.viewer.on("zoom", this.updateControls);
|
|
3109
|
+
this.viewer.on("drawviewpoint", this.updateControls);
|
|
3110
|
+
this.viewer.on("contextmenu", this.stopContextMenu);
|
|
3112
3111
|
this.updateControls();
|
|
3113
3112
|
}
|
|
3114
|
-
initialize() {}
|
|
3115
3113
|
dispose() {
|
|
3116
|
-
this.viewer.
|
|
3114
|
+
this.viewer.off("geometryend", this.updateControls);
|
|
3117
3115
|
this.viewer.off("viewposition", this.updateControls);
|
|
3118
|
-
this.viewer.
|
|
3119
|
-
this.viewer.
|
|
3120
|
-
this.viewer.
|
|
3116
|
+
this.viewer.off("zoom", this.updateControls);
|
|
3117
|
+
this.viewer.off("drawviewpoint", this.updateControls);
|
|
3118
|
+
this.viewer.off("contextmenu", this.stopContextMenu);
|
|
3121
3119
|
this.orbit.removeEventListener("start", this.controlsStart);
|
|
3122
3120
|
this.orbit.removeEventListener("change", this.controlsChange);
|
|
3123
3121
|
this.orbit.dispose();
|
|
@@ -3895,43 +3893,45 @@ function createPreview(viewer, type = "image/jpeg", encoderOptions = .25) {
|
|
|
3895
3893
|
return viewer.canvas.toDataURL(type, encoderOptions);
|
|
3896
3894
|
}
|
|
3897
3895
|
|
|
3898
|
-
function
|
|
3896
|
+
function calcObjectDepth(object, depth) {
|
|
3899
3897
|
let res = depth;
|
|
3900
3898
|
object.children.forEach((x => {
|
|
3901
|
-
const objectDepth =
|
|
3899
|
+
const objectDepth = calcObjectDepth(x, depth + 1);
|
|
3902
3900
|
if (res < objectDepth) res = objectDepth;
|
|
3903
3901
|
}));
|
|
3904
3902
|
object.originalPosition = object.position.clone();
|
|
3905
|
-
object.originalCenter = (new Box3).setFromObject(object).getCenter(new Vector3);
|
|
3906
|
-
object.isExplodeLocked = depth > 2 && object.children.length === 0;
|
|
3907
3903
|
return res;
|
|
3908
3904
|
}
|
|
3909
3905
|
|
|
3910
|
-
function explodeScene(scene, scale = 0
|
|
3906
|
+
function explodeScene(scene, scale = 0) {
|
|
3911
3907
|
scale /= 100;
|
|
3912
|
-
if (!scene.
|
|
3913
|
-
const maxDepth = scene.
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3908
|
+
if (!scene.maxDepth) scene.maxDepth = calcObjectDepth(scene, 1);
|
|
3909
|
+
const maxDepth = scene.maxDepth;
|
|
3910
|
+
let explodeDepth = scale * (maxDepth - 1) + 1;
|
|
3911
|
+
if (maxDepth === 1) explodeDepth = 1;
|
|
3912
|
+
function explodeObject(object, depth, parentCenter, parentOffset) {
|
|
3913
|
+
const objectBox = (new Box3).setFromObject(object);
|
|
3914
|
+
const objectCenter = objectBox.getCenter(new Vector3);
|
|
3915
|
+
const objectOffset = parentOffset.clone();
|
|
3916
|
+
if (depth > 0 && depth <= explodeDepth) {
|
|
3917
|
+
const offset = objectCenter.clone().sub(parentCenter).multiplyScalar(scale);
|
|
3918
|
+
objectOffset.add(offset);
|
|
3919
|
+
}
|
|
3920
|
+
object.children.forEach((object => explodeObject(object, depth + 1, objectCenter, objectOffset)));
|
|
3921
|
+
const originalPosition = object.originalPosition;
|
|
3922
|
+
object.position.copy(originalPosition);
|
|
3923
|
+
if (scale > 0) {
|
|
3924
|
+
const direction = objectCenter.sub(parentCenter).normalize();
|
|
3925
|
+
object.position.add(direction.add(objectOffset));
|
|
3926
3926
|
}
|
|
3927
|
-
object.children.forEach((x => explodeObject(x, depth + 1)));
|
|
3928
3927
|
}
|
|
3929
|
-
|
|
3928
|
+
const sceneExtents = (new Box3).setFromObject(scene);
|
|
3929
|
+
const sceneCenter = sceneExtents.getCenter(new Vector3);
|
|
3930
|
+
explodeObject(scene, 0, sceneCenter, new Vector3(0, 0, 0));
|
|
3930
3931
|
}
|
|
3931
3932
|
|
|
3932
3933
|
function explode(viewer, index = 0) {
|
|
3933
|
-
viewer.models.forEach((
|
|
3934
|
-
viewer.scene.updateMatrixWorld();
|
|
3934
|
+
viewer.models.forEach((gltf => explodeScene(gltf.scene, index)));
|
|
3935
3935
|
viewer.update();
|
|
3936
3936
|
viewer.emitEvent({
|
|
3937
3937
|
type: "explode",
|
|
@@ -3943,40 +3943,6 @@ function collect(viewer) {
|
|
|
3943
3943
|
explode(viewer, 0);
|
|
3944
3944
|
}
|
|
3945
3945
|
|
|
3946
|
-
function zoomTo(viewer, box) {
|
|
3947
|
-
if (box.isEmpty()) return;
|
|
3948
|
-
const center = box.getCenter(new Vector3);
|
|
3949
|
-
const sphere = box.getBoundingSphere(new Sphere);
|
|
3950
|
-
const rendererSize = viewer.renderer.getSize(new Vector2);
|
|
3951
|
-
const aspect = rendererSize.x / rendererSize.y;
|
|
3952
|
-
const camera = viewer.camera;
|
|
3953
|
-
if (camera.isPerspectiveCamera) {
|
|
3954
|
-
const offset = new Vector3(0, 0, 1);
|
|
3955
|
-
offset.applyQuaternion(camera.quaternion);
|
|
3956
|
-
offset.multiplyScalar(sphere.radius / Math.tan(MathUtils.DEG2RAD * camera.fov * .5));
|
|
3957
|
-
camera.position.copy(center).add(offset);
|
|
3958
|
-
camera.updateMatrixWorld();
|
|
3959
|
-
}
|
|
3960
|
-
if (camera.isOrthographicCamera) {
|
|
3961
|
-
camera.top = sphere.radius;
|
|
3962
|
-
camera.bottom = -sphere.radius;
|
|
3963
|
-
camera.left = camera.bottom * aspect;
|
|
3964
|
-
camera.right = camera.top * aspect;
|
|
3965
|
-
camera.zoom = 1;
|
|
3966
|
-
camera.updateProjectionMatrix();
|
|
3967
|
-
const offset = new Vector3(0, 0, 1);
|
|
3968
|
-
offset.applyQuaternion(camera.quaternion);
|
|
3969
|
-
offset.multiplyScalar(viewer.extents.getBoundingSphere(new Sphere).radius * 3);
|
|
3970
|
-
camera.position.copy(center).add(offset);
|
|
3971
|
-
camera.updateMatrixWorld();
|
|
3972
|
-
}
|
|
3973
|
-
viewer.target.copy(center);
|
|
3974
|
-
viewer.update();
|
|
3975
|
-
viewer.emitEvent({
|
|
3976
|
-
type: "zoom"
|
|
3977
|
-
});
|
|
3978
|
-
}
|
|
3979
|
-
|
|
3980
3946
|
const defaultViewPositions = {
|
|
3981
3947
|
top: new Vector3(0, 0, 1),
|
|
3982
3948
|
bottom: new Vector3(0, 0, -1),
|
|
@@ -3994,10 +3960,11 @@ function setDefaultViewPosition(viewer, position) {
|
|
|
3994
3960
|
const direction = defaultViewPositions[position] || defaultViewPositions["sw"];
|
|
3995
3961
|
const center = viewer.extents.getCenter(new Vector3);
|
|
3996
3962
|
const sphere = viewer.extents.getBoundingSphere(new Sphere);
|
|
3997
|
-
const
|
|
3963
|
+
const offet = direction.clone().multiplyScalar(sphere.radius);
|
|
3998
3964
|
const camera = viewer.camera;
|
|
3999
|
-
camera.position.copy(center).add(
|
|
3965
|
+
camera.position.copy(center).add(offet);
|
|
4000
3966
|
camera.lookAt(center);
|
|
3967
|
+
camera.updateProjectionMatrix();
|
|
4001
3968
|
camera.updateMatrixWorld();
|
|
4002
3969
|
viewer.target.copy(center);
|
|
4003
3970
|
viewer.update();
|
|
@@ -4005,7 +3972,7 @@ function setDefaultViewPosition(viewer, position) {
|
|
|
4005
3972
|
type: "viewposition",
|
|
4006
3973
|
data: position
|
|
4007
3974
|
});
|
|
4008
|
-
|
|
3975
|
+
viewer.executeCommand("zoomToExtents");
|
|
4009
3976
|
}
|
|
4010
3977
|
|
|
4011
3978
|
function getDefaultViewPositions() {
|
|
@@ -4015,14 +3982,14 @@ function getDefaultViewPositions() {
|
|
|
4015
3982
|
function getModels(viewer) {
|
|
4016
3983
|
return viewer.models.map((model => {
|
|
4017
3984
|
var _a;
|
|
4018
|
-
return ((_a = model.userData) === null || _a ===
|
|
3985
|
+
return ((_a = model.userData) === null || _a === void 0 ? void 0 : _a.handle) || "";
|
|
4019
3986
|
})).filter((handle => handle));
|
|
4020
3987
|
}
|
|
4021
3988
|
|
|
4022
3989
|
function getSelected(viewer) {
|
|
4023
3990
|
return viewer.selected.map((object => {
|
|
4024
3991
|
var _a;
|
|
4025
|
-
return (_a = object.userData) === null || _a ===
|
|
3992
|
+
return (_a = object.userData) === null || _a === void 0 ? void 0 : _a.handle;
|
|
4026
3993
|
})).filter((handle => handle));
|
|
4027
3994
|
}
|
|
4028
3995
|
|
|
@@ -4043,12 +4010,16 @@ function hideSelected(viewer) {
|
|
|
4043
4010
|
}
|
|
4044
4011
|
|
|
4045
4012
|
function isolateSelected(viewer) {
|
|
4046
|
-
const
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
object.
|
|
4050
|
-
|
|
4051
|
-
|
|
4013
|
+
const selectedSet = new Set(viewer.selected);
|
|
4014
|
+
function isolateObject(object, depth) {
|
|
4015
|
+
let canBeIsolated = true;
|
|
4016
|
+
object.children.forEach((object => {
|
|
4017
|
+
if (selectedSet.has(object)) canBeIsolated = false; else isolateObject(object, depth + 1);
|
|
4018
|
+
}));
|
|
4019
|
+
if (canBeIsolated && depth > 0) object.visible = false;
|
|
4020
|
+
return canBeIsolated;
|
|
4021
|
+
}
|
|
4022
|
+
isolateObject(viewer.scene, 0);
|
|
4052
4023
|
viewer.update();
|
|
4053
4024
|
viewer.emitEvent({
|
|
4054
4025
|
type: "isolate"
|
|
@@ -4097,7 +4068,7 @@ function setSelected(viewer, handles = []) {
|
|
|
4097
4068
|
const objects = [];
|
|
4098
4069
|
viewer.scene.traverseVisible((child => {
|
|
4099
4070
|
var _a;
|
|
4100
|
-
if (handleSet.has((_a = child.userData) === null || _a ===
|
|
4071
|
+
if (handleSet.has((_a = child.userData) === null || _a === void 0 ? void 0 : _a.handle)) objects.push(child);
|
|
4101
4072
|
}));
|
|
4102
4073
|
const selection = new SelectionComponent(viewer);
|
|
4103
4074
|
selection.clearSelection();
|
|
@@ -4120,7 +4091,18 @@ function showAll(viewer) {
|
|
|
4120
4091
|
}
|
|
4121
4092
|
|
|
4122
4093
|
function zoomToExtents(viewer) {
|
|
4123
|
-
|
|
4094
|
+
if (viewer.extents.isEmpty()) return;
|
|
4095
|
+
const center = viewer.extents.getCenter(new Vector3);
|
|
4096
|
+
const distance = viewer.extents.getBoundingSphere(new Sphere).radius;
|
|
4097
|
+
const delta = new Vector3(0, 0, 1);
|
|
4098
|
+
delta.applyQuaternion(viewer.camera.quaternion);
|
|
4099
|
+
delta.multiplyScalar(distance * 3);
|
|
4100
|
+
viewer.camera.position.copy(center).add(delta);
|
|
4101
|
+
viewer.target.copy(center);
|
|
4102
|
+
viewer.update();
|
|
4103
|
+
viewer.emitEvent({
|
|
4104
|
+
type: "zoom"
|
|
4105
|
+
});
|
|
4124
4106
|
}
|
|
4125
4107
|
|
|
4126
4108
|
function zoomToObjects(viewer, handles = []) {
|
|
@@ -4128,17 +4110,36 @@ function zoomToObjects(viewer, handles = []) {
|
|
|
4128
4110
|
const objects = [];
|
|
4129
4111
|
viewer.scene.traverseVisible((child => {
|
|
4130
4112
|
var _a;
|
|
4131
|
-
if (handleSet.has((_a = child.userData) === null || _a ===
|
|
4113
|
+
if (handleSet.has((_a = child.userData) === null || _a === void 0 ? void 0 : _a.handle)) objects.push(child);
|
|
4132
4114
|
}));
|
|
4133
4115
|
const extents = objects.reduce(((result, object) => result.expandByObject(object)), new Box3);
|
|
4134
|
-
|
|
4135
|
-
|
|
4116
|
+
const center = extents.getCenter(new Vector3);
|
|
4117
|
+
const distance = extents.getBoundingSphere(new Sphere).radius;
|
|
4118
|
+
const delta = new Vector3(0, 0, 1);
|
|
4119
|
+
delta.applyQuaternion(viewer.camera.quaternion);
|
|
4120
|
+
delta.multiplyScalar(distance * 3);
|
|
4121
|
+
viewer.camera.position.copy(center).add(delta);
|
|
4122
|
+
viewer.target.copy(center);
|
|
4123
|
+
viewer.update();
|
|
4124
|
+
viewer.emitEvent({
|
|
4125
|
+
type: "zoom"
|
|
4126
|
+
});
|
|
4136
4127
|
}
|
|
4137
4128
|
|
|
4138
4129
|
function zoomToSelected(viewer) {
|
|
4139
4130
|
const extents = viewer.selected.reduce(((result, object) => result.expandByObject(object)), new Box3);
|
|
4140
4131
|
if (extents.isEmpty()) extents.copy(viewer.extents);
|
|
4141
|
-
|
|
4132
|
+
const center = extents.getCenter(new Vector3);
|
|
4133
|
+
const distance = extents.getBoundingSphere(new Sphere).radius;
|
|
4134
|
+
const delta = new Vector3(0, 0, 1);
|
|
4135
|
+
delta.applyQuaternion(viewer.camera.quaternion);
|
|
4136
|
+
delta.multiplyScalar(distance * 3);
|
|
4137
|
+
viewer.camera.position.copy(center).add(delta);
|
|
4138
|
+
viewer.target.copy(center);
|
|
4139
|
+
viewer.update();
|
|
4140
|
+
viewer.emitEvent({
|
|
4141
|
+
type: "zoom"
|
|
4142
|
+
});
|
|
4142
4143
|
}
|
|
4143
4144
|
|
|
4144
4145
|
const commands = commandsRegistry("threejs");
|
|
@@ -4257,70 +4258,42 @@ class BackgroundComponent {
|
|
|
4257
4258
|
}
|
|
4258
4259
|
}
|
|
4259
4260
|
|
|
4260
|
-
class
|
|
4261
|
+
class DefaultPositionComponent {
|
|
4261
4262
|
constructor(viewer) {
|
|
4262
|
-
this.geometryEnd =
|
|
4263
|
-
const
|
|
4264
|
-
const
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
this.viewer.
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
this.viewer.camera = sceneCamera.clone();
|
|
4272
|
-
this.viewer.camera.up.set(0, 0, 1);
|
|
4273
|
-
this.viewer.camera.scale.set(1, 1, 1);
|
|
4274
|
-
}
|
|
4275
|
-
const camera = this.viewer.camera;
|
|
4276
|
-
if (camera.isPerspectiveCamera) {
|
|
4277
|
-
camera.aspect = aspect;
|
|
4278
|
-
camera.near = extentsSize / 100;
|
|
4279
|
-
camera.far = extentsSize * 100;
|
|
4280
|
-
camera.updateProjectionMatrix();
|
|
4281
|
-
}
|
|
4282
|
-
if (camera.isOrthographicCamera) {
|
|
4283
|
-
camera.left = camera.bottom * aspect;
|
|
4284
|
-
camera.right = camera.top * aspect;
|
|
4285
|
-
camera.near = 0;
|
|
4286
|
-
camera.far = extentsSize * 100;
|
|
4287
|
-
camera.updateProjectionMatrix();
|
|
4288
|
-
}
|
|
4289
|
-
if (!sceneCamera) {
|
|
4290
|
-
this.viewer.executeCommand("setDefaultViewPosition");
|
|
4291
|
-
}
|
|
4263
|
+
this.geometryEnd = event => {
|
|
4264
|
+
const box = this.viewer.extents;
|
|
4265
|
+
const size = box.getSize(new Vector3).length();
|
|
4266
|
+
this.viewer.camera.near = size / 100;
|
|
4267
|
+
this.viewer.camera.far = size * 100;
|
|
4268
|
+
this.viewer.camera.updateMatrixWorld();
|
|
4269
|
+
this.viewer.camera.updateProjectionMatrix();
|
|
4270
|
+
this.viewer.executeCommand("setDefaultViewPosition", "sw");
|
|
4271
|
+
this.viewer.executeCommand("zoomToExtents");
|
|
4292
4272
|
};
|
|
4293
4273
|
this.viewer = viewer;
|
|
4294
|
-
this.viewer.addEventListener("
|
|
4274
|
+
this.viewer.addEventListener("geometryend", this.geometryEnd);
|
|
4295
4275
|
}
|
|
4296
4276
|
dispose() {
|
|
4297
|
-
this.viewer.removeEventListener("
|
|
4277
|
+
this.viewer.removeEventListener("geometryend", this.geometryEnd);
|
|
4298
4278
|
}
|
|
4299
4279
|
}
|
|
4300
4280
|
|
|
4301
4281
|
class ExtentsComponent {
|
|
4302
4282
|
constructor(viewer) {
|
|
4303
4283
|
this.syncExtents = () => {
|
|
4304
|
-
const extents = new Box3;
|
|
4305
|
-
this.viewer.scene.traverseVisible((object => !object.children.length && extents.expandByObject(object)));
|
|
4284
|
+
const extents = this.viewer.models.reduce(((result, gltf) => result.expandByObject(gltf.scene)), new Box3);
|
|
4306
4285
|
this.viewer.extents.copy(extents);
|
|
4307
4286
|
this.viewer.target.copy(extents.getCenter(new Vector3));
|
|
4308
4287
|
};
|
|
4309
4288
|
this.viewer = viewer;
|
|
4310
|
-
this.viewer.addEventListener("
|
|
4289
|
+
this.viewer.addEventListener("geometryend", this.syncExtents);
|
|
4311
4290
|
this.viewer.addEventListener("clear", this.syncExtents);
|
|
4312
4291
|
this.viewer.on("explode", this.syncExtents);
|
|
4313
|
-
this.viewer.on("isolate", this.syncExtents);
|
|
4314
|
-
this.viewer.on("hide", this.syncExtents);
|
|
4315
|
-
this.viewer.on("showall", this.syncExtents);
|
|
4316
4292
|
}
|
|
4317
4293
|
dispose() {
|
|
4318
|
-
this.viewer.removeEventListener("
|
|
4294
|
+
this.viewer.removeEventListener("geometryend", this.syncExtents);
|
|
4319
4295
|
this.viewer.removeEventListener("clear", this.syncExtents);
|
|
4320
4296
|
this.viewer.off("explode", this.syncExtents);
|
|
4321
|
-
this.viewer.off("isolate", this.syncExtents);
|
|
4322
|
-
this.viewer.off("hide", this.syncExtents);
|
|
4323
|
-
this.viewer.off("showall", this.syncExtents);
|
|
4324
4297
|
}
|
|
4325
4298
|
}
|
|
4326
4299
|
|
|
@@ -4360,17 +4333,8 @@ class ResizeCanvasComponent {
|
|
|
4360
4333
|
this.resizeViewer = entries => {
|
|
4361
4334
|
const {width: width, height: height} = entries[0].contentRect;
|
|
4362
4335
|
if (!width || !height) return;
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
if (camera.isPerspectiveCamera) {
|
|
4366
|
-
camera.aspect = aspect;
|
|
4367
|
-
camera.updateProjectionMatrix();
|
|
4368
|
-
}
|
|
4369
|
-
if (camera.isOrthographicCamera) {
|
|
4370
|
-
camera.left = camera.bottom * aspect;
|
|
4371
|
-
camera.right = camera.top * aspect;
|
|
4372
|
-
camera.updateProjectionMatrix();
|
|
4373
|
-
}
|
|
4336
|
+
this.viewer.camera.aspect = width / height;
|
|
4337
|
+
this.viewer.camera.updateProjectionMatrix();
|
|
4374
4338
|
this.viewer.renderer.setSize(width, height, true);
|
|
4375
4339
|
this.viewer.update(true);
|
|
4376
4340
|
this.viewer.emitEvent({
|
|
@@ -4471,10 +4435,6 @@ class WCSHelper extends Object3D {
|
|
|
4471
4435
|
|
|
4472
4436
|
class WCSHelperComponent {
|
|
4473
4437
|
constructor(viewer) {
|
|
4474
|
-
this.geometryEnd = () => {
|
|
4475
|
-
this.wcsHelper.dispose();
|
|
4476
|
-
this.wcsHelper = new WCSHelper(this.viewer.camera);
|
|
4477
|
-
};
|
|
4478
4438
|
this.viewerRender = () => {
|
|
4479
4439
|
if (!this.viewer.options.showWCS) return;
|
|
4480
4440
|
if (this.viewer.extents.isEmpty()) return;
|
|
@@ -4482,13 +4442,9 @@ class WCSHelperComponent {
|
|
|
4482
4442
|
};
|
|
4483
4443
|
this.wcsHelper = new WCSHelper(viewer.camera);
|
|
4484
4444
|
this.viewer = viewer;
|
|
4485
|
-
this.viewer.addEventListener("databasechunk", this.geometryEnd);
|
|
4486
|
-
this.viewer.addEventListener("drawviewpoint", this.geometryEnd);
|
|
4487
4445
|
this.viewer.addEventListener("render", this.viewerRender);
|
|
4488
4446
|
}
|
|
4489
4447
|
dispose() {
|
|
4490
|
-
this.viewer.removeEventListener("databasechunk", this.geometryEnd);
|
|
4491
|
-
this.viewer.removeEventListener("drawviewpoint", this.geometryEnd);
|
|
4492
4448
|
this.viewer.removeEventListener("render", this.viewerRender);
|
|
4493
4449
|
this.wcsHelper.dispose();
|
|
4494
4450
|
}
|
|
@@ -4502,12 +4458,12 @@ components.registerComponent("LightComponent", (viewer => new LightComponent(vie
|
|
|
4502
4458
|
|
|
4503
4459
|
components.registerComponent("BackgroundComponent", (viewer => new BackgroundComponent(viewer)));
|
|
4504
4460
|
|
|
4505
|
-
components.registerComponent("CameraComponent", (viewer => new CameraComponent(viewer)));
|
|
4506
|
-
|
|
4507
4461
|
components.registerComponent("ResizeCanvasComponent", (viewer => new ResizeCanvasComponent(viewer)));
|
|
4508
4462
|
|
|
4509
4463
|
components.registerComponent("RenderLoopComponent", (viewer => new RenderLoopComponent(viewer)));
|
|
4510
4464
|
|
|
4465
|
+
components.registerComponent("DefaultPositionComponent", (viewer => new DefaultPositionComponent(viewer)));
|
|
4466
|
+
|
|
4511
4467
|
components.registerComponent("SelectionComponent", (viewer => new SelectionComponent(viewer)));
|
|
4512
4468
|
|
|
4513
4469
|
components.registerComponent("WCSHelperComponent", (viewer => new WCSHelperComponent(viewer)));
|
|
@@ -4535,7 +4491,7 @@ class GLTFLoadingManager extends LoadingManager {
|
|
|
4535
4491
|
this.setURLModifier((url => {
|
|
4536
4492
|
const key = decodeURI(url).replace(this.path, "").replace(this.resourcePath, "").replace(/^(\.?\/)/, "");
|
|
4537
4493
|
const dataURL = this.dataURLs.get(key);
|
|
4538
|
-
return dataURL !== null && dataURL !==
|
|
4494
|
+
return dataURL !== null && dataURL !== void 0 ? dataURL : url;
|
|
4539
4495
|
}));
|
|
4540
4496
|
}
|
|
4541
4497
|
dispose() {
|
|
@@ -4619,8 +4575,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4619
4575
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
4620
4576
|
const width = rect.width || 1;
|
|
4621
4577
|
const height = rect.height || 1;
|
|
4622
|
-
|
|
4623
|
-
this.camera = new PerspectiveCamera(45, aspect, .01, 1e3);
|
|
4578
|
+
this.camera = new PerspectiveCamera(45, width / height, .01, 1e3);
|
|
4624
4579
|
this.camera.up.set(0, 0, 1);
|
|
4625
4580
|
this.renderer = new WebGLRenderer({
|
|
4626
4581
|
canvas: canvas,
|
|
@@ -4633,7 +4588,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4633
4588
|
this.canvas = canvas;
|
|
4634
4589
|
this.canvasEvents.forEach((x => canvas.addEventListener(x, this.canvaseventlistener)));
|
|
4635
4590
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
4636
|
-
for (
|
|
4591
|
+
for (let name of components.getComponents().keys()) {
|
|
4637
4592
|
this._components.push(components.createComponent(name, this));
|
|
4638
4593
|
}
|
|
4639
4594
|
this.syncOptions();
|
|
@@ -4694,7 +4649,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4694
4649
|
this.renderer.autoClear = false;
|
|
4695
4650
|
this.renderer.render(this.helpers, this.camera);
|
|
4696
4651
|
this.renderer.clippingPlanes = clippingPlanes;
|
|
4697
|
-
(_b = (_a = this._activeDragger) === null || _a ===
|
|
4652
|
+
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4698
4653
|
const deltaTime = (time - this.renderTime) / 1e3;
|
|
4699
4654
|
this.renderTime = time;
|
|
4700
4655
|
this.emitEvent({
|
|
@@ -4884,7 +4839,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4884
4839
|
newDragger = draggers.createDragger(name, this);
|
|
4885
4840
|
if (newDragger) {
|
|
4886
4841
|
this._activeDragger = newDragger;
|
|
4887
|
-
(_b = (_a = this._activeDragger).initialize) === null || _b ===
|
|
4842
|
+
(_b = (_a = this._activeDragger).initialize) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
4888
4843
|
}
|
|
4889
4844
|
}
|
|
4890
4845
|
const canvas = this.canvas;
|
|
@@ -4959,66 +4914,38 @@ class Viewer extends EventEmitter2 {
|
|
|
4959
4914
|
var _a, _b, _c;
|
|
4960
4915
|
if (!this.renderer) return;
|
|
4961
4916
|
const getVector3FromPoint3d = ({x: x, y: y, z: z}) => new Vector3(x, y, z);
|
|
4962
|
-
const
|
|
4963
|
-
if (
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
this.camera
|
|
4968
|
-
this.camera.top = orthogonal_camera.field_height / 2;
|
|
4969
|
-
this.camera.bottom = -orthogonal_camera.field_height / 2;
|
|
4970
|
-
this.camera.left = this.camera.bottom * aspect;
|
|
4971
|
-
this.camera.right = this.camera.top * aspect;
|
|
4972
|
-
this.camera.near = 0;
|
|
4973
|
-
this.camera.far = extentsSize * 100;
|
|
4974
|
-
this.camera.zoom = orthogonal_camera.view_to_world_scale;
|
|
4975
|
-
this.camera.updateProjectionMatrix();
|
|
4976
|
-
this.camera.up.copy(getVector3FromPoint3d(orthogonal_camera.up_vector));
|
|
4977
|
-
this.camera.position.copy(getVector3FromPoint3d(orthogonal_camera.view_point));
|
|
4978
|
-
this.camera.lookAt(getVector3FromPoint3d(orthogonal_camera.direction).add(this.camera.position));
|
|
4917
|
+
const setPerspectiveCamera = camera => {
|
|
4918
|
+
if (camera) {
|
|
4919
|
+
this.camera.up.copy(getVector3FromPoint3d(camera.up_vector));
|
|
4920
|
+
this.camera.fov = camera.field_of_view;
|
|
4921
|
+
this.camera.position.copy(getVector3FromPoint3d(camera.view_point));
|
|
4922
|
+
this.camera.lookAt(getVector3FromPoint3d(camera.direction).add(this.camera.position));
|
|
4979
4923
|
this.camera.updateMatrixWorld();
|
|
4980
|
-
}
|
|
4981
|
-
};
|
|
4982
|
-
const setPerspectiveCamera = perspective_camera => {
|
|
4983
|
-
if (perspective_camera) {
|
|
4984
|
-
const extentsSize = this.extents.getBoundingSphere(new Sphere).radius * 2;
|
|
4985
|
-
const rendererSize = this.renderer.getSize(new Vector2);
|
|
4986
|
-
const aspect = rendererSize.x / rendererSize.y;
|
|
4987
|
-
this.camera = new PerspectiveCamera;
|
|
4988
|
-
this.camera.fov = perspective_camera.field_of_view;
|
|
4989
|
-
this.camera.aspect = aspect;
|
|
4990
|
-
this.camera.near = extentsSize / 100;
|
|
4991
|
-
this.camera.far = extentsSize * 100;
|
|
4992
4924
|
this.camera.updateProjectionMatrix();
|
|
4993
|
-
this.camera.up.copy(getVector3FromPoint3d(perspective_camera.up_vector));
|
|
4994
|
-
this.camera.position.copy(getVector3FromPoint3d(perspective_camera.view_point));
|
|
4995
|
-
this.camera.lookAt(getVector3FromPoint3d(perspective_camera.direction).add(this.camera.position));
|
|
4996
|
-
this.camera.updateMatrixWorld();
|
|
4997
4925
|
}
|
|
4998
4926
|
};
|
|
4999
4927
|
const setClippingPlanes = clipping_planes => {
|
|
5000
|
-
clipping_planes === null || clipping_planes ===
|
|
4928
|
+
clipping_planes === null || clipping_planes === void 0 ? void 0 : clipping_planes.forEach((clipping_plane => {
|
|
5001
4929
|
const plane = new Plane;
|
|
5002
4930
|
plane.setFromNormalAndCoplanarPoint(getVector3FromPoint3d(clipping_plane.direction), getVector3FromPoint3d(clipping_plane.location));
|
|
5003
4931
|
this.renderer.clippingPlanes.push(plane);
|
|
5004
4932
|
}));
|
|
5005
4933
|
};
|
|
5006
4934
|
const setSelection = selection => {
|
|
5007
|
-
|
|
4935
|
+
this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component => component.handle)));
|
|
5008
4936
|
};
|
|
5009
|
-
const draggerName = (_a = this._activeDragger) === null || _a ===
|
|
4937
|
+
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
5010
4938
|
this.setActiveDragger();
|
|
5011
4939
|
this.clearSlices();
|
|
5012
4940
|
this.clearOverlay();
|
|
5013
4941
|
this.clearSelected();
|
|
5014
4942
|
this.showAll();
|
|
5015
4943
|
this.explode();
|
|
5016
|
-
setOrthogonalCamera(viewpoint.orthogonal_camera);
|
|
5017
4944
|
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
5018
4945
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
5019
4946
|
setSelection(viewpoint.selection);
|
|
5020
4947
|
this._markup.setViewpoint(viewpoint);
|
|
5021
|
-
this.target = getVector3FromPoint3d((_c = (_b = viewpoint.custom_fields) === null || _b ===
|
|
4948
|
+
this.target = getVector3FromPoint3d((_c = (_b = viewpoint.custom_fields) === null || _b === void 0 ? void 0 : _b.camera_target) !== null && _c !== void 0 ? _c : this.target);
|
|
5022
4949
|
this.setActiveDragger(draggerName);
|
|
5023
4950
|
this.emitEvent({
|
|
5024
4951
|
type: "drawviewpoint",
|
|
@@ -5033,24 +4960,12 @@ class Viewer extends EventEmitter2 {
|
|
|
5033
4960
|
y: y,
|
|
5034
4961
|
z: z
|
|
5035
4962
|
});
|
|
5036
|
-
const
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
field_height: this.camera["top"] - this.camera["bottom"],
|
|
5043
|
-
view_to_world_scale: this.camera.zoom
|
|
5044
|
-
}; else return undefined;
|
|
5045
|
-
};
|
|
5046
|
-
const getPerspectiveCamera = () => {
|
|
5047
|
-
if (this.camera["isPerspectiveCamera"]) return {
|
|
5048
|
-
view_point: getPoint3dFromVector3(this.camera.position),
|
|
5049
|
-
direction: getPoint3dFromVector3(this.camera.getWorldDirection(new Vector3)),
|
|
5050
|
-
up_vector: getPoint3dFromVector3(this.camera.up),
|
|
5051
|
-
field_of_view: this.camera["fov"]
|
|
5052
|
-
}; else return undefined;
|
|
5053
|
-
};
|
|
4963
|
+
const getPerspectiveCamera = () => ({
|
|
4964
|
+
view_point: getPoint3dFromVector3(this.camera.position),
|
|
4965
|
+
direction: getPoint3dFromVector3(this.camera.getWorldDirection(new Vector3)),
|
|
4966
|
+
up_vector: getPoint3dFromVector3(this.camera.up),
|
|
4967
|
+
field_of_view: this.camera.fov
|
|
4968
|
+
});
|
|
5054
4969
|
const getClippingPlanes = () => {
|
|
5055
4970
|
const clipping_planes = [];
|
|
5056
4971
|
this.renderer.clippingPlanes.forEach((plane => {
|
|
@@ -5068,7 +4983,6 @@ class Viewer extends EventEmitter2 {
|
|
|
5068
4983
|
const viewpoint = {
|
|
5069
4984
|
custom_fields: {}
|
|
5070
4985
|
};
|
|
5071
|
-
viewpoint.orthogonal_camera = getOrthogonalCamera();
|
|
5072
4986
|
viewpoint.perspective_camera = getPerspectiveCamera();
|
|
5073
4987
|
viewpoint.clipping_planes = getClippingPlanes();
|
|
5074
4988
|
viewpoint.selection = getSelection();
|