@inweb/viewer-three 26.1.0 → 26.1.2
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 +16543 -16268
- package/dist/viewer-three.js.map +1 -1
- package/dist/viewer-three.min.js +9 -3
- package/dist/viewer-three.module.js +251 -165
- package/dist/viewer-three.module.js.map +1 -1
- package/lib/Viewer/Viewer.d.ts +34 -34
- package/lib/Viewer/commands/ZoomTo.d.ts +3 -0
- package/lib/Viewer/commands/index.d.ts +14 -8
- package/lib/Viewer/components/CameraComponent.d.ts +8 -0
- package/lib/Viewer/components/WCSHelperComponent.d.ts +1 -0
- package/lib/Viewer/components/index.d.ts +20 -20
- package/lib/Viewer/draggers/OrbitDragger.d.ts +1 -0
- package/lib/Viewer/draggers/index.d.ts +25 -19
- package/package.json +9 -9
- package/src/Viewer/Viewer.ts +112 -50
- package/src/Viewer/commands/Explode.ts +26 -27
- package/src/Viewer/commands/IsolateSelected.ts +6 -15
- package/src/Viewer/commands/SetDefaultViewPosition.ts +4 -4
- package/src/Viewer/{components/DefaultPositionComponent.ts → commands/ZoomTo.ts} +34 -22
- package/src/Viewer/commands/ZoomToExtents.ts +2 -15
- package/src/Viewer/commands/ZoomToObjects.ts +4 -12
- package/src/Viewer/commands/ZoomToSelected.ts +3 -14
- package/src/Viewer/commands/index.ts +14 -8
- package/src/Viewer/components/CameraComponent.ts +78 -0
- package/src/Viewer/components/ExtentsComponent.ts +10 -3
- package/src/Viewer/components/ResizeCanvasComponent.ts +13 -2
- package/src/Viewer/components/WCSHelperComponent.ts +9 -0
- package/src/Viewer/components/index.ts +22 -22
- package/src/Viewer/draggers/OrbitDragger.ts +11 -8
- package/src/Viewer/draggers/index.ts +25 -19
- package/lib/Viewer/components/DefaultPositionComponent.d.ts +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Konva from "konva";
|
|
2
2
|
|
|
3
|
-
import { Line, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide,
|
|
3
|
+
import { Line, Vector3, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh, MeshBasicMaterial, DoubleSide, EventDispatcher, MOUSE, TOUCH, Spherical, Quaternion, Vector2, Plane, Object3D, Matrix4, Vector4, Raycaster, Controls, Clock, Box3, Sphere, MathUtils, 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 === undefined ? undefined : 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 !== undefined ? _a : "#ff0000",
|
|
543
|
+
strokeWidth: (_b = params.width) !== null && _b !== undefined ? _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 !== undefined ? _a : 34,
|
|
651
651
|
fontFamily: this.TEXT_FONT_FAMILY,
|
|
652
|
-
fill: (_b = params.color) !== null && _b !==
|
|
652
|
+
fill: (_b = params.color) !== null && _b !== undefined ? _b : "#ff0000",
|
|
653
653
|
align: "left",
|
|
654
654
|
draggable: true,
|
|
655
|
-
rotation: (_c = params.rotation) !== null && _c !==
|
|
655
|
+
rotation: (_c = params.rotation) !== null && _c !== undefined ? _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 !== undefined ? _a : "#ff0000",
|
|
754
|
+
strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _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 !== undefined ? _c : 200,
|
|
761
|
+
height: (_d = params.height) !== null && _d !== undefined ? _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 !== undefined ? _a : "#ff0000",
|
|
872
|
+
strokeWidth: (_b = params.lineWidth) !== null && _b !== undefined ? _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 !== undefined ? _a : "#ff0000",
|
|
1002
|
+
fill: (_b = params.color) !== null && _b !== undefined ? _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 !== undefined ? _a : 0,
|
|
1143
|
+
height: (_b = params.height) !== null && _b !== undefined ? _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 !== undefined ? _a : 200,
|
|
1254
|
+
height: (_b = params.height) !== null && _b !== undefined ? _b : 200,
|
|
1255
|
+
stroke: (_c = params.color) !== null && _c !== undefined ? _c : "#ff0000",
|
|
1256
|
+
strokeWidth: (_d = params.lineWidth) !== null && _d !== undefined ? _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 !== undefined ? worldTransformer : new WorldTransform;
|
|
1506
1506
|
this._container = container;
|
|
1507
|
-
this._containerEvents = containerEvents !== null && containerEvents !==
|
|
1507
|
+
this._containerEvents = containerEvents !== null && containerEvents !== undefined ? 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 === undefined ? undefined : _a.disconnect();
|
|
1536
1536
|
this._resizeObserver = undefined;
|
|
1537
|
-
(_b = this._markupContainer) === null || _b ===
|
|
1537
|
+
(_b = this._markupContainer) === null || _b === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _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 === undefined ? undefined : _a.delete();
|
|
2298
2298
|
this.clearSelected();
|
|
2299
2299
|
this.removeImageInput();
|
|
2300
2300
|
const konvaImage = new KonvaImage({
|
|
@@ -3049,6 +3049,7 @@ 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;
|
|
3052
3053
|
this.orbit.target.copy(this.viewer.target);
|
|
3053
3054
|
this.orbit.update();
|
|
3054
3055
|
};
|
|
@@ -3103,19 +3104,20 @@ class OrbitDragger {
|
|
|
3103
3104
|
this.orbit.addEventListener("change", this.controlsChange);
|
|
3104
3105
|
this.changed = false;
|
|
3105
3106
|
this.viewer = viewer;
|
|
3106
|
-
this.viewer.
|
|
3107
|
+
this.viewer.addEventListener("databasechunk", this.updateControls);
|
|
3107
3108
|
this.viewer.on("viewposition", this.updateControls);
|
|
3108
|
-
this.viewer.
|
|
3109
|
-
this.viewer.
|
|
3110
|
-
this.viewer.
|
|
3109
|
+
this.viewer.addEventListener("zoom", this.updateControls);
|
|
3110
|
+
this.viewer.addEventListener("drawviewpoint", this.updateControls);
|
|
3111
|
+
this.viewer.addEventListener("contextmenu", this.stopContextMenu);
|
|
3111
3112
|
this.updateControls();
|
|
3112
3113
|
}
|
|
3114
|
+
initialize() {}
|
|
3113
3115
|
dispose() {
|
|
3114
|
-
this.viewer.
|
|
3116
|
+
this.viewer.removeEventListener("databasechunk", this.updateControls);
|
|
3115
3117
|
this.viewer.off("viewposition", this.updateControls);
|
|
3116
|
-
this.viewer.
|
|
3117
|
-
this.viewer.
|
|
3118
|
-
this.viewer.
|
|
3118
|
+
this.viewer.removeEventListener("zoom", this.updateControls);
|
|
3119
|
+
this.viewer.removeEventListener("drawviewpoint", this.updateControls);
|
|
3120
|
+
this.viewer.removeEventListener("contextmenu", this.stopContextMenu);
|
|
3119
3121
|
this.orbit.removeEventListener("start", this.controlsStart);
|
|
3120
3122
|
this.orbit.removeEventListener("change", this.controlsChange);
|
|
3121
3123
|
this.orbit.dispose();
|
|
@@ -3893,45 +3895,43 @@ function createPreview(viewer, type = "image/jpeg", encoderOptions = .25) {
|
|
|
3893
3895
|
return viewer.canvas.toDataURL(type, encoderOptions);
|
|
3894
3896
|
}
|
|
3895
3897
|
|
|
3896
|
-
function
|
|
3898
|
+
function calcExplodeDepth(object, depth) {
|
|
3897
3899
|
let res = depth;
|
|
3898
3900
|
object.children.forEach((x => {
|
|
3899
|
-
const objectDepth =
|
|
3901
|
+
const objectDepth = calcExplodeDepth(x, depth + 1);
|
|
3900
3902
|
if (res < objectDepth) res = objectDepth;
|
|
3901
3903
|
}));
|
|
3902
3904
|
object.originalPosition = object.position.clone();
|
|
3905
|
+
object.originalCenter = (new Box3).setFromObject(object).getCenter(new Vector3);
|
|
3906
|
+
object.isExplodeLocked = depth > 2 && object.children.length === 0;
|
|
3903
3907
|
return res;
|
|
3904
3908
|
}
|
|
3905
3909
|
|
|
3906
|
-
function explodeScene(scene, scale = 0) {
|
|
3910
|
+
function explodeScene(scene, scale = 0, coeff = 4) {
|
|
3907
3911
|
scale /= 100;
|
|
3908
|
-
if (!scene.
|
|
3909
|
-
const maxDepth = scene.
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
object.position.copy(originalPosition);
|
|
3923
|
-
if (scale > 0) {
|
|
3924
|
-
const direction = objectCenter.sub(parentCenter).normalize();
|
|
3925
|
-
object.position.add(direction.add(objectOffset));
|
|
3912
|
+
if (!scene.explodeDepth) scene.explodeDepth = calcExplodeDepth(scene, 1);
|
|
3913
|
+
const maxDepth = scene.explodeDepth;
|
|
3914
|
+
const scaledExplodeDepth = scale * maxDepth + 1;
|
|
3915
|
+
const explodeDepth = 0 | scaledExplodeDepth;
|
|
3916
|
+
const currentSegmentFraction = scaledExplodeDepth - explodeDepth;
|
|
3917
|
+
function explodeObject(object, depth) {
|
|
3918
|
+
object.position.copy(object.originalPosition);
|
|
3919
|
+
if (depth > 0 && depth <= explodeDepth && !object.isExplodeLocked) {
|
|
3920
|
+
let objectScale = scale * coeff;
|
|
3921
|
+
if (depth === explodeDepth) objectScale *= currentSegmentFraction;
|
|
3922
|
+
const parentCenter = object.parent.originalCenter;
|
|
3923
|
+
const objectCenter = object.originalCenter;
|
|
3924
|
+
const objectOffset = objectCenter.clone().sub(parentCenter).multiplyScalar(objectScale);
|
|
3925
|
+
object.position.add(objectOffset);
|
|
3926
3926
|
}
|
|
3927
|
+
object.children.forEach((x => explodeObject(x, depth + 1)));
|
|
3927
3928
|
}
|
|
3928
|
-
|
|
3929
|
-
const sceneCenter = sceneExtents.getCenter(new Vector3);
|
|
3930
|
-
explodeObject(scene, 0, sceneCenter, new Vector3(0, 0, 0));
|
|
3929
|
+
explodeObject(scene, 0);
|
|
3931
3930
|
}
|
|
3932
3931
|
|
|
3933
3932
|
function explode(viewer, index = 0) {
|
|
3934
|
-
viewer.models.forEach((
|
|
3933
|
+
viewer.models.forEach((model => explodeScene(model.scene, index)));
|
|
3934
|
+
viewer.scene.updateMatrixWorld();
|
|
3935
3935
|
viewer.update();
|
|
3936
3936
|
viewer.emitEvent({
|
|
3937
3937
|
type: "explode",
|
|
@@ -3943,6 +3943,40 @@ 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
|
+
|
|
3946
3980
|
const defaultViewPositions = {
|
|
3947
3981
|
top: new Vector3(0, 0, 1),
|
|
3948
3982
|
bottom: new Vector3(0, 0, -1),
|
|
@@ -3960,11 +3994,10 @@ function setDefaultViewPosition(viewer, position) {
|
|
|
3960
3994
|
const direction = defaultViewPositions[position] || defaultViewPositions["sw"];
|
|
3961
3995
|
const center = viewer.extents.getCenter(new Vector3);
|
|
3962
3996
|
const sphere = viewer.extents.getBoundingSphere(new Sphere);
|
|
3963
|
-
const
|
|
3997
|
+
const offset = direction.clone().multiplyScalar(sphere.radius);
|
|
3964
3998
|
const camera = viewer.camera;
|
|
3965
|
-
camera.position.copy(center).add(
|
|
3999
|
+
camera.position.copy(center).add(offset);
|
|
3966
4000
|
camera.lookAt(center);
|
|
3967
|
-
camera.updateProjectionMatrix();
|
|
3968
4001
|
camera.updateMatrixWorld();
|
|
3969
4002
|
viewer.target.copy(center);
|
|
3970
4003
|
viewer.update();
|
|
@@ -3972,7 +4005,7 @@ function setDefaultViewPosition(viewer, position) {
|
|
|
3972
4005
|
type: "viewposition",
|
|
3973
4006
|
data: position
|
|
3974
4007
|
});
|
|
3975
|
-
viewer.
|
|
4008
|
+
zoomTo(viewer, viewer.extents);
|
|
3976
4009
|
}
|
|
3977
4010
|
|
|
3978
4011
|
function getDefaultViewPositions() {
|
|
@@ -3982,14 +4015,14 @@ function getDefaultViewPositions() {
|
|
|
3982
4015
|
function getModels(viewer) {
|
|
3983
4016
|
return viewer.models.map((model => {
|
|
3984
4017
|
var _a;
|
|
3985
|
-
return ((_a = model.userData) === null || _a ===
|
|
4018
|
+
return ((_a = model.userData) === null || _a === undefined ? undefined : _a.handle) || "";
|
|
3986
4019
|
})).filter((handle => handle));
|
|
3987
4020
|
}
|
|
3988
4021
|
|
|
3989
4022
|
function getSelected(viewer) {
|
|
3990
4023
|
return viewer.selected.map((object => {
|
|
3991
4024
|
var _a;
|
|
3992
|
-
return (_a = object.userData) === null || _a ===
|
|
4025
|
+
return (_a = object.userData) === null || _a === undefined ? undefined : _a.handle;
|
|
3993
4026
|
})).filter((handle => handle));
|
|
3994
4027
|
}
|
|
3995
4028
|
|
|
@@ -4010,16 +4043,12 @@ function hideSelected(viewer) {
|
|
|
4010
4043
|
}
|
|
4011
4044
|
|
|
4012
4045
|
function isolateSelected(viewer) {
|
|
4013
|
-
const
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
object.
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
if (canBeIsolated && depth > 0) object.visible = false;
|
|
4020
|
-
return canBeIsolated;
|
|
4021
|
-
}
|
|
4022
|
-
isolateObject(viewer.scene, 0);
|
|
4046
|
+
const visibleSet = new Set;
|
|
4047
|
+
viewer.selected.forEach((object => {
|
|
4048
|
+
visibleSet.add(object);
|
|
4049
|
+
object.traverseAncestors((object2 => visibleSet.add(object2)));
|
|
4050
|
+
}));
|
|
4051
|
+
viewer.scene.traverse((object => object.visible = visibleSet.has(object)));
|
|
4023
4052
|
viewer.update();
|
|
4024
4053
|
viewer.emitEvent({
|
|
4025
4054
|
type: "isolate"
|
|
@@ -4068,7 +4097,7 @@ function setSelected(viewer, handles = []) {
|
|
|
4068
4097
|
const objects = [];
|
|
4069
4098
|
viewer.scene.traverseVisible((child => {
|
|
4070
4099
|
var _a;
|
|
4071
|
-
if (handleSet.has((_a = child.userData) === null || _a ===
|
|
4100
|
+
if (handleSet.has((_a = child.userData) === null || _a === undefined ? undefined : _a.handle)) objects.push(child);
|
|
4072
4101
|
}));
|
|
4073
4102
|
const selection = new SelectionComponent(viewer);
|
|
4074
4103
|
selection.clearSelection();
|
|
@@ -4091,18 +4120,7 @@ function showAll(viewer) {
|
|
|
4091
4120
|
}
|
|
4092
4121
|
|
|
4093
4122
|
function zoomToExtents(viewer) {
|
|
4094
|
-
|
|
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
|
-
});
|
|
4123
|
+
zoomTo(viewer, viewer.extents);
|
|
4106
4124
|
}
|
|
4107
4125
|
|
|
4108
4126
|
function zoomToObjects(viewer, handles = []) {
|
|
@@ -4110,36 +4128,17 @@ function zoomToObjects(viewer, handles = []) {
|
|
|
4110
4128
|
const objects = [];
|
|
4111
4129
|
viewer.scene.traverseVisible((child => {
|
|
4112
4130
|
var _a;
|
|
4113
|
-
if (handleSet.has((_a = child.userData) === null || _a ===
|
|
4131
|
+
if (handleSet.has((_a = child.userData) === null || _a === undefined ? undefined : _a.handle)) objects.push(child);
|
|
4114
4132
|
}));
|
|
4115
4133
|
const extents = objects.reduce(((result, object) => result.expandByObject(object)), new Box3);
|
|
4116
|
-
|
|
4117
|
-
|
|
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
|
-
});
|
|
4134
|
+
if (extents.isEmpty()) extents.copy(viewer.extents);
|
|
4135
|
+
zoomTo(viewer, extents);
|
|
4127
4136
|
}
|
|
4128
4137
|
|
|
4129
4138
|
function zoomToSelected(viewer) {
|
|
4130
4139
|
const extents = viewer.selected.reduce(((result, object) => result.expandByObject(object)), new Box3);
|
|
4131
4140
|
if (extents.isEmpty()) extents.copy(viewer.extents);
|
|
4132
|
-
|
|
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
|
-
});
|
|
4141
|
+
zoomTo(viewer, extents);
|
|
4143
4142
|
}
|
|
4144
4143
|
|
|
4145
4144
|
const commands = commandsRegistry("threejs");
|
|
@@ -4258,42 +4257,70 @@ class BackgroundComponent {
|
|
|
4258
4257
|
}
|
|
4259
4258
|
}
|
|
4260
4259
|
|
|
4261
|
-
class
|
|
4260
|
+
class CameraComponent {
|
|
4262
4261
|
constructor(viewer) {
|
|
4263
|
-
this.geometryEnd =
|
|
4264
|
-
const
|
|
4265
|
-
const
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
this.viewer.
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4262
|
+
this.geometryEnd = () => {
|
|
4263
|
+
const extentsSize = this.viewer.extents.getBoundingSphere(new Sphere).radius * 2;
|
|
4264
|
+
const rendererSize = this.viewer.renderer.getSize(new Vector2);
|
|
4265
|
+
const aspect = rendererSize.x / rendererSize.y;
|
|
4266
|
+
let sceneCamera;
|
|
4267
|
+
this.viewer.scene.traverse((object => {
|
|
4268
|
+
if (object.isCamera) if (!sceneCamera) sceneCamera = object; else if (object.isPerspectiveCamera && sceneCamera.isOrthographicCamera) sceneCamera = object;
|
|
4269
|
+
}));
|
|
4270
|
+
if (sceneCamera) {
|
|
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
|
+
}
|
|
4272
4292
|
};
|
|
4273
4293
|
this.viewer = viewer;
|
|
4274
|
-
this.viewer.addEventListener("
|
|
4294
|
+
this.viewer.addEventListener("databasechunk", this.geometryEnd);
|
|
4275
4295
|
}
|
|
4276
4296
|
dispose() {
|
|
4277
|
-
this.viewer.removeEventListener("
|
|
4297
|
+
this.viewer.removeEventListener("databasechunk", this.geometryEnd);
|
|
4278
4298
|
}
|
|
4279
4299
|
}
|
|
4280
4300
|
|
|
4281
4301
|
class ExtentsComponent {
|
|
4282
4302
|
constructor(viewer) {
|
|
4283
4303
|
this.syncExtents = () => {
|
|
4284
|
-
const extents =
|
|
4304
|
+
const extents = new Box3;
|
|
4305
|
+
this.viewer.scene.traverseVisible((object => !object.children.length && extents.expandByObject(object)));
|
|
4285
4306
|
this.viewer.extents.copy(extents);
|
|
4286
4307
|
this.viewer.target.copy(extents.getCenter(new Vector3));
|
|
4287
4308
|
};
|
|
4288
4309
|
this.viewer = viewer;
|
|
4289
|
-
this.viewer.addEventListener("
|
|
4310
|
+
this.viewer.addEventListener("databasechunk", this.syncExtents);
|
|
4290
4311
|
this.viewer.addEventListener("clear", this.syncExtents);
|
|
4291
4312
|
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);
|
|
4292
4316
|
}
|
|
4293
4317
|
dispose() {
|
|
4294
|
-
this.viewer.removeEventListener("
|
|
4318
|
+
this.viewer.removeEventListener("databasechunk", this.syncExtents);
|
|
4295
4319
|
this.viewer.removeEventListener("clear", this.syncExtents);
|
|
4296
4320
|
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);
|
|
4297
4324
|
}
|
|
4298
4325
|
}
|
|
4299
4326
|
|
|
@@ -4333,8 +4360,17 @@ class ResizeCanvasComponent {
|
|
|
4333
4360
|
this.resizeViewer = entries => {
|
|
4334
4361
|
const {width: width, height: height} = entries[0].contentRect;
|
|
4335
4362
|
if (!width || !height) return;
|
|
4336
|
-
this.viewer.camera
|
|
4337
|
-
|
|
4363
|
+
const camera = this.viewer.camera;
|
|
4364
|
+
const aspect = width / height;
|
|
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
|
+
}
|
|
4338
4374
|
this.viewer.renderer.setSize(width, height, true);
|
|
4339
4375
|
this.viewer.update(true);
|
|
4340
4376
|
this.viewer.emitEvent({
|
|
@@ -4435,6 +4471,10 @@ class WCSHelper extends Object3D {
|
|
|
4435
4471
|
|
|
4436
4472
|
class WCSHelperComponent {
|
|
4437
4473
|
constructor(viewer) {
|
|
4474
|
+
this.geometryEnd = () => {
|
|
4475
|
+
this.wcsHelper.dispose();
|
|
4476
|
+
this.wcsHelper = new WCSHelper(this.viewer.camera);
|
|
4477
|
+
};
|
|
4438
4478
|
this.viewerRender = () => {
|
|
4439
4479
|
if (!this.viewer.options.showWCS) return;
|
|
4440
4480
|
if (this.viewer.extents.isEmpty()) return;
|
|
@@ -4442,9 +4482,13 @@ class WCSHelperComponent {
|
|
|
4442
4482
|
};
|
|
4443
4483
|
this.wcsHelper = new WCSHelper(viewer.camera);
|
|
4444
4484
|
this.viewer = viewer;
|
|
4485
|
+
this.viewer.addEventListener("databasechunk", this.geometryEnd);
|
|
4486
|
+
this.viewer.addEventListener("drawviewpoint", this.geometryEnd);
|
|
4445
4487
|
this.viewer.addEventListener("render", this.viewerRender);
|
|
4446
4488
|
}
|
|
4447
4489
|
dispose() {
|
|
4490
|
+
this.viewer.removeEventListener("databasechunk", this.geometryEnd);
|
|
4491
|
+
this.viewer.removeEventListener("drawviewpoint", this.geometryEnd);
|
|
4448
4492
|
this.viewer.removeEventListener("render", this.viewerRender);
|
|
4449
4493
|
this.wcsHelper.dispose();
|
|
4450
4494
|
}
|
|
@@ -4458,12 +4502,12 @@ components.registerComponent("LightComponent", (viewer => new LightComponent(vie
|
|
|
4458
4502
|
|
|
4459
4503
|
components.registerComponent("BackgroundComponent", (viewer => new BackgroundComponent(viewer)));
|
|
4460
4504
|
|
|
4505
|
+
components.registerComponent("CameraComponent", (viewer => new CameraComponent(viewer)));
|
|
4506
|
+
|
|
4461
4507
|
components.registerComponent("ResizeCanvasComponent", (viewer => new ResizeCanvasComponent(viewer)));
|
|
4462
4508
|
|
|
4463
4509
|
components.registerComponent("RenderLoopComponent", (viewer => new RenderLoopComponent(viewer)));
|
|
4464
4510
|
|
|
4465
|
-
components.registerComponent("DefaultPositionComponent", (viewer => new DefaultPositionComponent(viewer)));
|
|
4466
|
-
|
|
4467
4511
|
components.registerComponent("SelectionComponent", (viewer => new SelectionComponent(viewer)));
|
|
4468
4512
|
|
|
4469
4513
|
components.registerComponent("WCSHelperComponent", (viewer => new WCSHelperComponent(viewer)));
|
|
@@ -4491,7 +4535,7 @@ class GLTFLoadingManager extends LoadingManager {
|
|
|
4491
4535
|
this.setURLModifier((url => {
|
|
4492
4536
|
const key = decodeURI(url).replace(this.path, "").replace(this.resourcePath, "").replace(/^(\.?\/)/, "");
|
|
4493
4537
|
const dataURL = this.dataURLs.get(key);
|
|
4494
|
-
return dataURL !== null && dataURL !==
|
|
4538
|
+
return dataURL !== null && dataURL !== undefined ? dataURL : url;
|
|
4495
4539
|
}));
|
|
4496
4540
|
}
|
|
4497
4541
|
dispose() {
|
|
@@ -4575,7 +4619,8 @@ class Viewer extends EventEmitter2 {
|
|
|
4575
4619
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
4576
4620
|
const width = rect.width || 1;
|
|
4577
4621
|
const height = rect.height || 1;
|
|
4578
|
-
|
|
4622
|
+
const aspect = width / height;
|
|
4623
|
+
this.camera = new PerspectiveCamera(45, aspect, .01, 1e3);
|
|
4579
4624
|
this.camera.up.set(0, 0, 1);
|
|
4580
4625
|
this.renderer = new WebGLRenderer({
|
|
4581
4626
|
canvas: canvas,
|
|
@@ -4588,7 +4633,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4588
4633
|
this.canvas = canvas;
|
|
4589
4634
|
this.canvasEvents.forEach((x => canvas.addEventListener(x, this.canvaseventlistener)));
|
|
4590
4635
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
4591
|
-
for (
|
|
4636
|
+
for (const name of components.getComponents().keys()) {
|
|
4592
4637
|
this._components.push(components.createComponent(name, this));
|
|
4593
4638
|
}
|
|
4594
4639
|
this.syncOptions();
|
|
@@ -4649,7 +4694,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4649
4694
|
this.renderer.autoClear = false;
|
|
4650
4695
|
this.renderer.render(this.helpers, this.camera);
|
|
4651
4696
|
this.renderer.clippingPlanes = clippingPlanes;
|
|
4652
|
-
(_b = (_a = this._activeDragger) === null || _a ===
|
|
4697
|
+
(_b = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.updatePreview) === null || _b === undefined ? undefined : _b.call(_a);
|
|
4653
4698
|
const deltaTime = (time - this.renderTime) / 1e3;
|
|
4654
4699
|
this.renderTime = time;
|
|
4655
4700
|
this.emitEvent({
|
|
@@ -4839,7 +4884,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4839
4884
|
newDragger = draggers.createDragger(name, this);
|
|
4840
4885
|
if (newDragger) {
|
|
4841
4886
|
this._activeDragger = newDragger;
|
|
4842
|
-
(_b = (_a = this._activeDragger).initialize) === null || _b ===
|
|
4887
|
+
(_b = (_a = this._activeDragger).initialize) === null || _b === undefined ? undefined : _b.call(_a);
|
|
4843
4888
|
}
|
|
4844
4889
|
}
|
|
4845
4890
|
const canvas = this.canvas;
|
|
@@ -4914,38 +4959,66 @@ class Viewer extends EventEmitter2 {
|
|
|
4914
4959
|
var _a, _b, _c;
|
|
4915
4960
|
if (!this.renderer) return;
|
|
4916
4961
|
const getVector3FromPoint3d = ({x: x, y: y, z: z}) => new Vector3(x, y, z);
|
|
4917
|
-
const
|
|
4918
|
-
if (
|
|
4919
|
-
this.
|
|
4920
|
-
this.
|
|
4921
|
-
|
|
4922
|
-
this.camera
|
|
4962
|
+
const setOrthogonalCamera = orthogonal_camera => {
|
|
4963
|
+
if (orthogonal_camera) {
|
|
4964
|
+
const extentsSize = this.extents.getBoundingSphere(new Sphere).radius * 2;
|
|
4965
|
+
const rendererSize = this.renderer.getSize(new Vector2);
|
|
4966
|
+
const aspect = rendererSize.x / rendererSize.y;
|
|
4967
|
+
this.camera = new OrthographicCamera;
|
|
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));
|
|
4923
4979
|
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;
|
|
4924
4992
|
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();
|
|
4925
4997
|
}
|
|
4926
4998
|
};
|
|
4927
4999
|
const setClippingPlanes = clipping_planes => {
|
|
4928
|
-
clipping_planes === null || clipping_planes ===
|
|
5000
|
+
clipping_planes === null || clipping_planes === undefined ? undefined : clipping_planes.forEach((clipping_plane => {
|
|
4929
5001
|
const plane = new Plane;
|
|
4930
5002
|
plane.setFromNormalAndCoplanarPoint(getVector3FromPoint3d(clipping_plane.direction), getVector3FromPoint3d(clipping_plane.location));
|
|
4931
5003
|
this.renderer.clippingPlanes.push(plane);
|
|
4932
5004
|
}));
|
|
4933
5005
|
};
|
|
4934
5006
|
const setSelection = selection => {
|
|
4935
|
-
this.setSelected(selection
|
|
5007
|
+
if (selection) this.setSelected(selection.map((component => component.handle)));
|
|
4936
5008
|
};
|
|
4937
|
-
const draggerName = (_a = this._activeDragger) === null || _a ===
|
|
5009
|
+
const draggerName = (_a = this._activeDragger) === null || _a === undefined ? undefined : _a.name;
|
|
4938
5010
|
this.setActiveDragger();
|
|
4939
5011
|
this.clearSlices();
|
|
4940
5012
|
this.clearOverlay();
|
|
4941
5013
|
this.clearSelected();
|
|
4942
5014
|
this.showAll();
|
|
4943
5015
|
this.explode();
|
|
5016
|
+
setOrthogonalCamera(viewpoint.orthogonal_camera);
|
|
4944
5017
|
setPerspectiveCamera(viewpoint.perspective_camera);
|
|
4945
5018
|
setClippingPlanes(viewpoint.clipping_planes);
|
|
4946
5019
|
setSelection(viewpoint.selection);
|
|
4947
5020
|
this._markup.setViewpoint(viewpoint);
|
|
4948
|
-
this.target = getVector3FromPoint3d((_c = (_b = viewpoint.custom_fields) === null || _b ===
|
|
5021
|
+
this.target = getVector3FromPoint3d((_c = (_b = viewpoint.custom_fields) === null || _b === undefined ? undefined : _b.camera_target) !== null && _c !== undefined ? _c : this.target);
|
|
4949
5022
|
this.setActiveDragger(draggerName);
|
|
4950
5023
|
this.emitEvent({
|
|
4951
5024
|
type: "drawviewpoint",
|
|
@@ -4960,12 +5033,24 @@ class Viewer extends EventEmitter2 {
|
|
|
4960
5033
|
y: y,
|
|
4961
5034
|
z: z
|
|
4962
5035
|
});
|
|
4963
|
-
const
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
5036
|
+
const getOrthogonalCamera = () => {
|
|
5037
|
+
if (this.camera["isOrthographicCamera"]) return {
|
|
5038
|
+
view_point: getPoint3dFromVector3(this.camera.position),
|
|
5039
|
+
direction: getPoint3dFromVector3(this.camera.getWorldDirection(new Vector3)),
|
|
5040
|
+
up_vector: getPoint3dFromVector3(this.camera.up),
|
|
5041
|
+
field_width: this.camera["right"] - this.camera["left"],
|
|
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
|
+
};
|
|
4969
5054
|
const getClippingPlanes = () => {
|
|
4970
5055
|
const clipping_planes = [];
|
|
4971
5056
|
this.renderer.clippingPlanes.forEach((plane => {
|
|
@@ -4983,6 +5068,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4983
5068
|
const viewpoint = {
|
|
4984
5069
|
custom_fields: {}
|
|
4985
5070
|
};
|
|
5071
|
+
viewpoint.orthogonal_camera = getOrthogonalCamera();
|
|
4986
5072
|
viewpoint.perspective_camera = getPerspectiveCamera();
|
|
4987
5073
|
viewpoint.clipping_planes = getClippingPlanes();
|
|
4988
5074
|
viewpoint.selection = getSelection();
|