@inweb/viewer-visualize 26.9.2 → 26.9.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-visualize.js +1802 -3707
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +24 -1
- package/dist/viewer-visualize.module.js +899 -1116
- package/dist/viewer-visualize.module.js.map +1 -1
- package/package.json +5 -5
- package/src/Viewer/Viewer.ts +12 -12
|
@@ -1,20 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2025, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { CANVAS_EVENTS, draggersRegistry, commandsRegistry, componentsRegistry, Loader, loadersRegistry, Options } from '@inweb/viewer-core';
|
|
25
|
+
export * from '@inweb/viewer-core';
|
|
26
|
+
import { EventEmitter2 } from '@inweb/eventemitter2';
|
|
27
|
+
import { Markup } from '@inweb/markup';
|
|
28
|
+
export * from '@inweb/markup';
|
|
10
29
|
|
|
11
30
|
class OdaGeAction {
|
|
12
31
|
constructor(module) {
|
|
13
|
-
this.setViewParams = params => {
|
|
32
|
+
this.setViewParams = (params) => {
|
|
14
33
|
var _a;
|
|
15
34
|
const extView = this.m_module.getViewer().getActiveTvExtendedView();
|
|
16
35
|
extView.setView(params.position, params.target, params.upVector, params.viewFieldWidth, params.viewFieldHeight, params.perspective);
|
|
17
|
-
(_a = extView.delete) === null || _a ===
|
|
36
|
+
(_a = extView.delete) === null || _a === void 0 ? void 0 : _a.call(extView);
|
|
18
37
|
};
|
|
19
38
|
this.getViewParams = () => {
|
|
20
39
|
var _a;
|
|
@@ -25,9 +44,9 @@ class OdaGeAction {
|
|
|
25
44
|
upVector: view.upVector,
|
|
26
45
|
viewFieldWidth: view.viewFieldWidth,
|
|
27
46
|
viewFieldHeight: view.viewFieldHeight,
|
|
28
|
-
perspective: view.perspective
|
|
47
|
+
perspective: view.perspective,
|
|
29
48
|
};
|
|
30
|
-
(_a = view.delete) === null || _a ===
|
|
49
|
+
(_a = view.delete) === null || _a === void 0 ? void 0 : _a.call(view);
|
|
31
50
|
return obj;
|
|
32
51
|
};
|
|
33
52
|
this.m_module = module;
|
|
@@ -39,30 +58,30 @@ class OdaGeAction {
|
|
|
39
58
|
return this.getViewer().getMarkupModel();
|
|
40
59
|
}
|
|
41
60
|
copyPoint(point) {
|
|
42
|
-
const p = new this.m_module.Point3d;
|
|
61
|
+
const p = new this.m_module.Point3d();
|
|
43
62
|
p.set(point.x, point.y, point.z);
|
|
44
63
|
return p;
|
|
45
64
|
}
|
|
46
65
|
createVector3d() {
|
|
47
|
-
return new this.m_module.Vector3d;
|
|
66
|
+
return new this.m_module.Vector3d();
|
|
48
67
|
}
|
|
49
68
|
createPoint3d() {
|
|
50
|
-
return new this.m_module.Point3d;
|
|
69
|
+
return new this.m_module.Point3d();
|
|
51
70
|
}
|
|
52
71
|
createMatrix3d() {
|
|
53
|
-
return new this.m_module.Matrix3d;
|
|
72
|
+
return new this.m_module.Matrix3d();
|
|
54
73
|
}
|
|
55
74
|
createPlane() {
|
|
56
|
-
return new this.m_module.OdTvPlane;
|
|
75
|
+
return new this.m_module.OdTvPlane();
|
|
57
76
|
}
|
|
58
77
|
toVector(geVector) {
|
|
59
78
|
return this.m_module.Vector3d.createFromArray(geVector);
|
|
60
79
|
}
|
|
61
80
|
toGeVector(v) {
|
|
62
|
-
return [
|
|
81
|
+
return [v.x, v.y, v.z];
|
|
63
82
|
}
|
|
64
83
|
toGePoint(point) {
|
|
65
|
-
return [
|
|
84
|
+
return [point.x, point.y, point.z];
|
|
66
85
|
}
|
|
67
86
|
toPoint(gePoint) {
|
|
68
87
|
return this.m_module.Point3d.createFromArray(gePoint);
|
|
@@ -82,9 +101,14 @@ class OdaGeAction {
|
|
|
82
101
|
correctCameraTarget() {
|
|
83
102
|
const params = this.getViewParams();
|
|
84
103
|
const ext = this.m_module.getViewer().getActiveExtents();
|
|
85
|
-
const {
|
|
104
|
+
const { min, max } = ext;
|
|
86
105
|
const target = this.toPoint(params.target);
|
|
87
|
-
const contains = target.x >= min.x &&
|
|
106
|
+
const contains = target.x >= min.x &&
|
|
107
|
+
target.y >= min.y &&
|
|
108
|
+
target.z >= min.z &&
|
|
109
|
+
target.x <= max.x &&
|
|
110
|
+
target.y <= max.y &&
|
|
111
|
+
target.z <= max.z;
|
|
88
112
|
if (!contains) {
|
|
89
113
|
params.target = ext.center();
|
|
90
114
|
this.setViewParams(params);
|
|
@@ -93,9 +117,7 @@ class OdaGeAction {
|
|
|
93
117
|
}
|
|
94
118
|
|
|
95
119
|
const CLICK_DELTA = 5;
|
|
96
|
-
|
|
97
120
|
const INTERACTIVITY_FPS = 24;
|
|
98
|
-
|
|
99
121
|
class OdBaseDragger extends OdaGeAction {
|
|
100
122
|
constructor(subject) {
|
|
101
123
|
super(subject.visualizeJs);
|
|
@@ -115,7 +137,7 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
115
137
|
view.endInteractivity();
|
|
116
138
|
const device = this.getViewer().getActiveDevice();
|
|
117
139
|
const canvas = this.m_module.canvas;
|
|
118
|
-
device.invalidate([
|
|
140
|
+
device.invalidate([0, 0, canvas.width, canvas.height]);
|
|
119
141
|
device.delete();
|
|
120
142
|
this.subject.update();
|
|
121
143
|
}
|
|
@@ -123,28 +145,22 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
123
145
|
};
|
|
124
146
|
this.subject = subject;
|
|
125
147
|
this.needInputText = false;
|
|
126
|
-
this.mouseDownPosition = {
|
|
127
|
-
x: 0,
|
|
128
|
-
y: 0
|
|
129
|
-
};
|
|
148
|
+
this.mouseDownPosition = { x: 0, y: 0 };
|
|
130
149
|
this.autoSelect = false;
|
|
131
|
-
this.onmessage = event => this.subject.emitEvent(event);
|
|
150
|
+
this.onmessage = (event) => this.subject.emitEvent(event);
|
|
132
151
|
this.canvasEvents = CANVAS_EVENTS;
|
|
133
152
|
}
|
|
134
153
|
initialize() {
|
|
135
|
-
this.canvasEvents = this.canvasEvents.filter((x => typeof this[x] === "function")
|
|
136
|
-
this.canvasEvents.forEach((x => this[x] = this[x].bind(this)));
|
|
137
|
-
this.canvasEvents.forEach((x => this.subject.on(x, this[x]))
|
|
154
|
+
this.canvasEvents = this.canvasEvents.filter((x) => typeof this[x] === "function");
|
|
155
|
+
this.canvasEvents.forEach((x) => (this[x] = this[x].bind(this)));
|
|
156
|
+
this.canvasEvents.forEach((x) => this.subject.on(x, this[x]));
|
|
138
157
|
this.getViewer().setEnableAutoSelect(!!this.autoSelect);
|
|
139
158
|
}
|
|
140
159
|
dispose() {
|
|
141
|
-
this.canvasEvents.forEach((x => this.subject.off(x, this[x]))
|
|
160
|
+
this.canvasEvents.forEach((x) => this.subject.off(x, this[x]));
|
|
142
161
|
}
|
|
143
162
|
relativeCoords(event) {
|
|
144
|
-
return {
|
|
145
|
-
x: event.offsetX * window.devicePixelRatio,
|
|
146
|
-
y: event.offsetY * window.devicePixelRatio
|
|
147
|
-
};
|
|
163
|
+
return { x: event.offsetX * window.devicePixelRatio, y: event.offsetY * window.devicePixelRatio };
|
|
148
164
|
}
|
|
149
165
|
pointerdown(ev) {
|
|
150
166
|
if (!ev.isPrimary || OdBaseDragger.isGestureActive) {
|
|
@@ -153,10 +169,7 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
153
169
|
ev.target.setPointerCapture(ev.pointerId);
|
|
154
170
|
const relCoord = this.relativeCoords(ev);
|
|
155
171
|
this.isDragging = true;
|
|
156
|
-
this.mouseDownPosition = {
|
|
157
|
-
x: relCoord.x,
|
|
158
|
-
y: relCoord.y
|
|
159
|
-
};
|
|
172
|
+
this.mouseDownPosition = { x: relCoord.x, y: relCoord.y };
|
|
160
173
|
this.start(relCoord.x, relCoord.y, ev.clientX, ev.clientY);
|
|
161
174
|
this.subject.update();
|
|
162
175
|
}
|
|
@@ -201,11 +214,7 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
201
214
|
this.subject.update();
|
|
202
215
|
const selectionSet = viewer.getSelected();
|
|
203
216
|
const handles = this.subject.getSelected();
|
|
204
|
-
this.onmessage({
|
|
205
|
-
type: "select",
|
|
206
|
-
data: selectionSet,
|
|
207
|
-
handles: handles
|
|
208
|
-
});
|
|
217
|
+
this.onmessage({ type: "select", data: selectionSet, handles });
|
|
209
218
|
}
|
|
210
219
|
}
|
|
211
220
|
dblclick(ev) {
|
|
@@ -214,32 +223,30 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
214
223
|
const x = relCoord.x;
|
|
215
224
|
const y = relCoord.y;
|
|
216
225
|
const device = viewer.getActiveDevice();
|
|
217
|
-
const clickView = device.viewAt([
|
|
226
|
+
const clickView = device.viewAt([x, y]);
|
|
218
227
|
if (clickView && !clickView.active) {
|
|
219
228
|
viewer.activeView = clickView;
|
|
220
229
|
clickView.delete();
|
|
221
230
|
this.subject.update();
|
|
222
|
-
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
223
233
|
if (viewer && viewer.getEnableAutoSelect()) {
|
|
224
234
|
const pSelected = viewer.getSelected();
|
|
225
235
|
if (!pSelected.isNull() && pSelected.numItems() !== 0) {
|
|
226
236
|
const itr = pSelected.getIterator();
|
|
227
237
|
const entity = itr.getEntity();
|
|
228
238
|
viewer.zoomToEntity(entity);
|
|
229
|
-
this.onmessage({
|
|
230
|
-
type: "zoomtoentity",
|
|
231
|
-
data: entity
|
|
232
|
-
});
|
|
239
|
+
this.onmessage({ type: "zoomtoentity", data: entity });
|
|
233
240
|
this.subject.update();
|
|
234
|
-
this.deleteAll([
|
|
241
|
+
this.deleteAll([itr, entity]);
|
|
235
242
|
}
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
245
|
device.delete();
|
|
239
246
|
}
|
|
240
|
-
start(x, y, absoluteX = 0, absoluteY = 0) {}
|
|
241
|
-
drag(x, y, absoluteX = 0, absoluteY = 0) {}
|
|
242
|
-
end(x, y, absoluteX = 0, absoluteY = 0) {}
|
|
247
|
+
start(x, y, absoluteX = 0, absoluteY = 0) { }
|
|
248
|
+
drag(x, y, absoluteX = 0, absoluteY = 0) { }
|
|
249
|
+
end(x, y, absoluteX = 0, absoluteY = 0) { }
|
|
243
250
|
getActiveMarkupEntity(entityName) {
|
|
244
251
|
return this.subject.addMarkupEntity(entityName);
|
|
245
252
|
}
|
|
@@ -249,10 +256,10 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
249
256
|
deleteAll(objects) {
|
|
250
257
|
var _a;
|
|
251
258
|
for (const obj of objects) {
|
|
252
|
-
(_a = obj === null || obj ===
|
|
259
|
+
(_a = obj === null || obj === void 0 ? void 0 : obj.delete) === null || _a === void 0 ? void 0 : _a.call(obj);
|
|
253
260
|
}
|
|
254
261
|
}
|
|
255
|
-
updatePreview() {}
|
|
262
|
+
updatePreview() { }
|
|
256
263
|
static set isGestureActive(value) {
|
|
257
264
|
if (OdBaseDragger._isGestureActive === value) {
|
|
258
265
|
return;
|
|
@@ -276,9 +283,7 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
276
283
|
OdBaseDragger._needSkipPointerUp = value;
|
|
277
284
|
}
|
|
278
285
|
}
|
|
279
|
-
|
|
280
286
|
OdBaseDragger._isGestureActive = false;
|
|
281
|
-
|
|
282
287
|
OdBaseDragger._needSkipPointerUp = false;
|
|
283
288
|
|
|
284
289
|
function createHtmlElementIfNeed(element, targetElement, dataTestId) {
|
|
@@ -289,30 +294,24 @@ function createHtmlElementIfNeed(element, targetElement, dataTestId) {
|
|
|
289
294
|
}
|
|
290
295
|
return element;
|
|
291
296
|
}
|
|
292
|
-
|
|
293
297
|
function destroyHtmlElement(element, targetElement) {
|
|
294
298
|
if (element) {
|
|
295
299
|
targetElement.removeChild(element);
|
|
296
300
|
}
|
|
297
301
|
return null;
|
|
298
302
|
}
|
|
299
|
-
|
|
300
303
|
function worldToScreen(gePoint, moduleInstance, viewer) {
|
|
301
304
|
const worldPoint = moduleInstance.Point3d.createFromArray(gePoint);
|
|
302
305
|
const avp = viewer.activeView;
|
|
303
306
|
const mtx = avp.worldToDeviceMatrix;
|
|
304
307
|
const devicePoint = worldPoint.transformBy(mtx);
|
|
305
|
-
const res = {
|
|
306
|
-
x: devicePoint.x / window.devicePixelRatio,
|
|
307
|
-
y: devicePoint.y / window.devicePixelRatio
|
|
308
|
-
};
|
|
308
|
+
const res = { x: devicePoint.x / window.devicePixelRatio, y: devicePoint.y / window.devicePixelRatio };
|
|
309
309
|
mtx.delete();
|
|
310
310
|
worldPoint.delete();
|
|
311
311
|
devicePoint.delete();
|
|
312
312
|
avp.delete();
|
|
313
313
|
return res;
|
|
314
314
|
}
|
|
315
|
-
|
|
316
315
|
function getDistance(gePoint1, gePoint2, moduleInstance) {
|
|
317
316
|
const tvPoint1 = moduleInstance.Point3d.createFromArray(gePoint1);
|
|
318
317
|
const tvPoint2 = moduleInstance.Point3d.createFromArray(gePoint2);
|
|
@@ -321,11 +320,9 @@ function getDistance(gePoint1, gePoint2, moduleInstance) {
|
|
|
321
320
|
tvPoint2.delete();
|
|
322
321
|
return distance;
|
|
323
322
|
}
|
|
324
|
-
|
|
325
323
|
function normalizeFloat(value) {
|
|
326
324
|
return value < 0 ? Math.ceil(value) : Math.floor(value);
|
|
327
325
|
}
|
|
328
|
-
|
|
329
326
|
const lineSegmentsIntersect = (p1, p2, p3, p4) => {
|
|
330
327
|
const a_dx = p2.x - p1.x;
|
|
331
328
|
const a_dy = p2.y - p1.y;
|
|
@@ -333,40 +330,27 @@ const lineSegmentsIntersect = (p1, p2, p3, p4) => {
|
|
|
333
330
|
const b_dy = p4.y - p3.y;
|
|
334
331
|
const s = (-a_dy * (p1.x - p3.x) + a_dx * (p1.y - p3.y)) / (-b_dx * a_dy + a_dx * b_dy);
|
|
335
332
|
const t = (+b_dx * (p1.y - p3.y) - b_dy * (p1.x - p3.x)) / (-b_dx * a_dy + a_dx * b_dy);
|
|
336
|
-
return s >= 0 && s <= 1 && t >= 0 && t <= 1
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
333
|
+
return s >= 0 && s <= 1 && t >= 0 && t <= 1
|
|
334
|
+
? {
|
|
335
|
+
x: normalizeFloat(p1.x + t * a_dx),
|
|
336
|
+
y: normalizeFloat(p1.y + t * a_dy),
|
|
337
|
+
}
|
|
338
|
+
: false;
|
|
340
339
|
};
|
|
341
|
-
|
|
342
340
|
function checkSegmentsIntersect(p1, p2, p3, p4, res) {
|
|
343
341
|
const r = lineSegmentsIntersect(p1, p2, p3, p4);
|
|
344
342
|
if (r) {
|
|
345
343
|
res.push(r);
|
|
346
344
|
}
|
|
347
345
|
}
|
|
348
|
-
|
|
349
346
|
function isInsideRect(p, width, height) {
|
|
350
347
|
return p.x <= width && p.x >= 0 && p.y <= height && p.y >= 0;
|
|
351
348
|
}
|
|
352
|
-
|
|
353
349
|
function getDataForDrawLineWithFixed(p1, p2, width, height) {
|
|
354
|
-
const pLU = {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
};
|
|
358
|
-
const pRU = {
|
|
359
|
-
x: width,
|
|
360
|
-
y: 0
|
|
361
|
-
};
|
|
362
|
-
const pLB = {
|
|
363
|
-
x: 0,
|
|
364
|
-
y: height
|
|
365
|
-
};
|
|
366
|
-
const pRB = {
|
|
367
|
-
x: width,
|
|
368
|
-
y: height
|
|
369
|
-
};
|
|
350
|
+
const pLU = { x: 0, y: 0 };
|
|
351
|
+
const pRU = { x: width, y: 0 };
|
|
352
|
+
const pLB = { x: 0, y: height };
|
|
353
|
+
const pRB = { x: width, y: height };
|
|
370
354
|
const intersects = [];
|
|
371
355
|
checkSegmentsIntersect(p1, p2, pLU, pRU, intersects);
|
|
372
356
|
checkSegmentsIntersect(p1, p2, pLU, pLB, intersects);
|
|
@@ -377,39 +361,35 @@ function getDataForDrawLineWithFixed(p1, p2, width, height) {
|
|
|
377
361
|
if (intersects.length === 0) {
|
|
378
362
|
fixedP1 = p1;
|
|
379
363
|
fixedP2 = p2;
|
|
380
|
-
}
|
|
364
|
+
}
|
|
365
|
+
else if (intersects.length === 1) {
|
|
381
366
|
if (isInsideRect(p1, width, height)) {
|
|
382
367
|
fixedP1 = p1;
|
|
383
368
|
fixedP2 = intersects[0];
|
|
384
|
-
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
385
371
|
fixedP1 = intersects[0];
|
|
386
372
|
fixedP2 = p2;
|
|
387
373
|
}
|
|
388
|
-
}
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
389
376
|
fixedP1 = intersects[0];
|
|
390
377
|
fixedP2 = intersects[1];
|
|
391
378
|
}
|
|
392
379
|
const dx = fixedP2.x - fixedP1.x;
|
|
393
380
|
const dy = fixedP2.y - fixedP1.y;
|
|
394
|
-
let angle = 180 * Math.atan(dy / dx) / Math.PI;
|
|
381
|
+
let angle = (180 * Math.atan(dy / dx)) / Math.PI;
|
|
395
382
|
if (dx < 0) {
|
|
396
383
|
angle -= 180;
|
|
397
384
|
}
|
|
398
385
|
const size = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
|
399
|
-
return {
|
|
400
|
-
angle: angle,
|
|
401
|
-
width: size,
|
|
402
|
-
p1: fixedP1,
|
|
403
|
-
p2: fixedP2
|
|
404
|
-
};
|
|
386
|
+
return { angle, width: size, p1: fixedP1, p2: fixedP2 };
|
|
405
387
|
}
|
|
406
|
-
|
|
407
388
|
function onSetCallback(element, cb) {
|
|
408
389
|
if (element) {
|
|
409
|
-
element.onclick = cb ? () => cb() : () => {};
|
|
390
|
+
element.onclick = cb ? () => cb() : () => { };
|
|
410
391
|
}
|
|
411
392
|
}
|
|
412
|
-
|
|
413
393
|
function onSetSelectivity(element, enable) {
|
|
414
394
|
element.style.pointerEvents = enable ? "auto" : "none";
|
|
415
395
|
}
|
|
@@ -423,14 +403,14 @@ class MeasureLineItem {
|
|
|
423
403
|
this.startPoint = null;
|
|
424
404
|
this.endPoint = null;
|
|
425
405
|
this.unit = "";
|
|
426
|
-
this.scale = 1;
|
|
427
|
-
this.size = 10;
|
|
406
|
+
this.scale = 1.0;
|
|
407
|
+
this.size = 10.0;
|
|
428
408
|
this.lineThickness = 2;
|
|
429
409
|
this.style = {
|
|
430
410
|
border: "2px solid #FFFFFF",
|
|
431
411
|
background: "#009bff",
|
|
432
412
|
color: "white",
|
|
433
|
-
boxShadow: "0 0 10px rgba(0,0,0,0.5)"
|
|
413
|
+
boxShadow: "0 0 10px rgba(0,0,0,0.5)",
|
|
434
414
|
};
|
|
435
415
|
this.htmlElemStartPoint = createHtmlElementIfNeed(this.htmlElemStartPoint, targetElement, "ruler-start");
|
|
436
416
|
this.htmlElemEndPoint = createHtmlElementIfNeed(this.htmlElemEndPoint, targetElement, "ruler-end");
|
|
@@ -460,7 +440,8 @@ class MeasureLineItem {
|
|
|
460
440
|
this.htmlElemStartPoint.style.width = `${pointSize}px`;
|
|
461
441
|
this.htmlElemStartPoint.style.height = `${pointSize}px`;
|
|
462
442
|
this.htmlElemStartPoint.style.boxShadow = this.style.boxShadow;
|
|
463
|
-
}
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
464
445
|
this.htmlElemStartPoint.style.display = "none";
|
|
465
446
|
}
|
|
466
447
|
}
|
|
@@ -480,14 +461,15 @@ class MeasureLineItem {
|
|
|
480
461
|
this.htmlElemEndPoint.style.width = `${pointSize}px`;
|
|
481
462
|
this.htmlElemEndPoint.style.height = `${pointSize}px`;
|
|
482
463
|
this.htmlElemEndPoint.style.boxShadow = this.style.boxShadow;
|
|
483
|
-
}
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
484
466
|
this.htmlElemEndPoint.style.display = "none";
|
|
485
467
|
}
|
|
486
468
|
}
|
|
487
469
|
if (this.endPoint && this.startPoint) {
|
|
488
470
|
const point1 = worldToScreen(this.startPoint, this.moduleInstance, this.viewer);
|
|
489
471
|
const point2 = worldToScreen(this.endPoint, this.moduleInstance, this.viewer);
|
|
490
|
-
const {
|
|
472
|
+
const { p1, p2, angle, width } = getDataForDrawLineWithFixed(point1, point2, rect.width, rect.height);
|
|
491
473
|
const dx = p2.x - p1.x;
|
|
492
474
|
const dy = p2.y - p1.y;
|
|
493
475
|
const height = this.lineThickness;
|
|
@@ -528,7 +510,8 @@ class MeasureLineItem {
|
|
|
528
510
|
this.htmlElemTitle.style.padding = "2px";
|
|
529
511
|
this.htmlElemTitle.style.textAlign = "center";
|
|
530
512
|
this.htmlElemTitle.innerHTML = `${distance}`;
|
|
531
|
-
}
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
532
515
|
this.htmlElemLine.style.display = "none";
|
|
533
516
|
this.htmlElemTitle.style.display = "none";
|
|
534
517
|
}
|
|
@@ -536,7 +519,7 @@ class MeasureLineItem {
|
|
|
536
519
|
}
|
|
537
520
|
getDistance() {
|
|
538
521
|
let distance = getDistance(this.startPoint, this.endPoint, this.moduleInstance);
|
|
539
|
-
if (Math.abs(this.scale - 1) >
|
|
522
|
+
if (Math.abs(this.scale - 1.0) > 10e-5) {
|
|
540
523
|
distance = (distance / this.scale).toFixed(2);
|
|
541
524
|
}
|
|
542
525
|
return distance;
|
|
@@ -593,14 +576,13 @@ class MeasureLineItem {
|
|
|
593
576
|
function renameUnit(table, unit) {
|
|
594
577
|
return table[unit] || unit;
|
|
595
578
|
}
|
|
596
|
-
|
|
597
579
|
class MeasureLineDragger extends OdBaseDragger {
|
|
598
580
|
constructor(subject) {
|
|
599
581
|
var _a;
|
|
600
582
|
super(subject);
|
|
601
583
|
this.lineThickness = 2;
|
|
602
584
|
this.press = false;
|
|
603
|
-
this.gripingRadius = 5;
|
|
585
|
+
this.gripingRadius = 5.0;
|
|
604
586
|
this.firstPoint = null;
|
|
605
587
|
this.secondPoint = null;
|
|
606
588
|
this.renameUnitTable = {
|
|
@@ -614,11 +596,11 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
614
596
|
Miles: "mi",
|
|
615
597
|
Micrometers: "µm",
|
|
616
598
|
MicroInches: "µin",
|
|
617
|
-
Default: "unit"
|
|
599
|
+
Default: "unit",
|
|
618
600
|
};
|
|
619
601
|
this.items = [];
|
|
620
602
|
this.canvasEvents.push("resize");
|
|
621
|
-
this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !==
|
|
603
|
+
this.oldRulerUnit = (_a = subject.options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
622
604
|
this.optionsChange = this.optionsChange.bind(this);
|
|
623
605
|
}
|
|
624
606
|
initialize() {
|
|
@@ -638,7 +620,7 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
638
620
|
this.subject.removeEventListener("optionschange", this.optionsChange);
|
|
639
621
|
}
|
|
640
622
|
updatePreview() {
|
|
641
|
-
this.items.forEach((item => item.update())
|
|
623
|
+
this.items.forEach((item) => item.update());
|
|
642
624
|
}
|
|
643
625
|
resize() {
|
|
644
626
|
const rect = this.m_module.canvas.getBoundingClientRect();
|
|
@@ -673,20 +655,24 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
673
655
|
this.secondPoint = point;
|
|
674
656
|
this.previewMeasureLine.setStartPoint(this.firstPoint);
|
|
675
657
|
this.previewMeasureLine.setEndPoint(this.secondPoint, true);
|
|
676
|
-
}
|
|
658
|
+
}
|
|
659
|
+
else {
|
|
677
660
|
this.firstPoint = point;
|
|
678
661
|
this.previewMeasureLine.setStartPoint(this.firstPoint);
|
|
679
662
|
}
|
|
680
|
-
}
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
681
665
|
this.secondPoint = null;
|
|
682
666
|
this.previewMeasureLine.clear();
|
|
683
667
|
this.previewMeasureLine.setStartPoint(this.firstPoint);
|
|
684
668
|
this.previewMeasureLine.setEndPoint(this.getViewer().screenToWorld(x, y), false);
|
|
685
669
|
}
|
|
686
|
-
}
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
687
672
|
if (point) {
|
|
688
673
|
this.previewMeasureLine.setStartPoint(point);
|
|
689
|
-
}
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
690
676
|
this.previewMeasureLine.clear();
|
|
691
677
|
}
|
|
692
678
|
}
|
|
@@ -718,8 +704,9 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
718
704
|
const multiplier = viewer.getUnitsConversionCoef(fromUnit, toUnit);
|
|
719
705
|
this.conversionFactor = 1 / multiplier;
|
|
720
706
|
item.setConversionFactor(this.conversionFactor);
|
|
721
|
-
}
|
|
722
|
-
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
item.setConversionFactor(1.0);
|
|
723
710
|
}
|
|
724
711
|
this.items.push(item);
|
|
725
712
|
return item;
|
|
@@ -727,82 +714,75 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
727
714
|
optionsChange(event) {
|
|
728
715
|
var _a;
|
|
729
716
|
const options = event.data;
|
|
730
|
-
const toUnitName = (_a = options.rulerUnit) !== null && _a !==
|
|
731
|
-
if (this.oldRulerUnit === toUnitName)
|
|
717
|
+
const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
718
|
+
if (this.oldRulerUnit === toUnitName)
|
|
719
|
+
return;
|
|
732
720
|
this.oldRulerUnit = toUnitName;
|
|
733
721
|
const drawingUnit = this.m_module.getViewer().getUnit();
|
|
734
722
|
const eToUnit = this.getKUnitByName(toUnitName);
|
|
735
723
|
const eFromUnit = this.getKUnitByName(drawingUnit);
|
|
736
|
-
this.items.forEach((item => {
|
|
724
|
+
this.items.forEach((item) => {
|
|
737
725
|
if (toUnitName === "Default") {
|
|
738
726
|
item.setUnit(renameUnit(this.renameUnitTable, drawingUnit));
|
|
739
|
-
item.setConversionFactor(1);
|
|
740
|
-
}
|
|
727
|
+
item.setConversionFactor(1.0);
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
741
730
|
item.setUnit(renameUnit(this.renameUnitTable, toUnitName));
|
|
742
731
|
const multiplier = this.m_module.getViewer().getUnitsConversionCoef(eFromUnit, eToUnit);
|
|
743
732
|
this.conversionFactor = 1 / multiplier;
|
|
744
733
|
item.setConversionFactor(this.conversionFactor);
|
|
745
734
|
}
|
|
746
|
-
})
|
|
735
|
+
});
|
|
747
736
|
}
|
|
748
737
|
getKUnitByName(unitName) {
|
|
749
738
|
let eUnit = this.m_module.Units.kUserDefined;
|
|
750
739
|
switch (unitName) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
break;
|
|
782
|
-
|
|
783
|
-
case "Micrometers":
|
|
784
|
-
eUnit = this.m_module.Units.kMicrometers;
|
|
785
|
-
break;
|
|
786
|
-
|
|
787
|
-
case "MicroInches":
|
|
788
|
-
eUnit = this.m_module.Units.kMicroInches;
|
|
789
|
-
break;
|
|
740
|
+
case "Millimeters":
|
|
741
|
+
eUnit = this.m_module.Units.kMillimeters;
|
|
742
|
+
break;
|
|
743
|
+
case "Centimeters":
|
|
744
|
+
eUnit = this.m_module.Units.kCentimeters;
|
|
745
|
+
break;
|
|
746
|
+
case "Meters":
|
|
747
|
+
eUnit = this.m_module.Units.kMeters;
|
|
748
|
+
break;
|
|
749
|
+
case "Feet":
|
|
750
|
+
eUnit = this.m_module.Units.kFeet;
|
|
751
|
+
break;
|
|
752
|
+
case "Inches":
|
|
753
|
+
eUnit = this.m_module.Units.kInches;
|
|
754
|
+
break;
|
|
755
|
+
case "Yards":
|
|
756
|
+
eUnit = this.m_module.Units.kYards;
|
|
757
|
+
break;
|
|
758
|
+
case "Kilometers":
|
|
759
|
+
eUnit = this.m_module.Units.kKilometers;
|
|
760
|
+
break;
|
|
761
|
+
case "Miles":
|
|
762
|
+
eUnit = this.m_module.Units.kMiles;
|
|
763
|
+
break;
|
|
764
|
+
case "Micrometers":
|
|
765
|
+
eUnit = this.m_module.Units.kMicrometers;
|
|
766
|
+
break;
|
|
767
|
+
case "MicroInches":
|
|
768
|
+
eUnit = this.m_module.Units.kMicroInches;
|
|
769
|
+
break;
|
|
790
770
|
}
|
|
791
771
|
return eUnit;
|
|
792
772
|
}
|
|
793
773
|
}
|
|
794
774
|
|
|
795
|
-
const FocalLengthConst = 42;
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
775
|
+
const FocalLengthConst = 42.0;
|
|
776
|
+
const calcFocalLength = (lensLength, fieldWidth, fieldHeight) => {
|
|
777
|
+
return (lensLength / FocalLengthConst) * Math.sqrt(fieldWidth * fieldWidth + fieldHeight * fieldHeight);
|
|
778
|
+
};
|
|
799
779
|
class OdaWalkDragger extends OdBaseDragger {
|
|
800
780
|
constructor(subject) {
|
|
801
781
|
super(subject);
|
|
802
782
|
this.viewer = undefined;
|
|
803
783
|
this.multiplier = 5;
|
|
804
784
|
this.speed = 1;
|
|
805
|
-
this.keyPressMap = new Set;
|
|
785
|
+
this.keyPressMap = new Set();
|
|
806
786
|
this.keydown = this.keydown.bind(this);
|
|
807
787
|
this.keyup = this.keyup.bind(this);
|
|
808
788
|
this.lastFrameTS = 0;
|
|
@@ -820,17 +800,15 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
820
800
|
this.viewer.setEnableWCS(false);
|
|
821
801
|
const view = this.viewer.activeView;
|
|
822
802
|
const maxDimension = this.getMaxDimension(view);
|
|
823
|
-
this.speed = maxDimension /
|
|
824
|
-
this.subject.emitEvent({
|
|
825
|
-
type: "walkstart"
|
|
826
|
-
});
|
|
803
|
+
this.speed = maxDimension / 30000;
|
|
804
|
+
this.subject.emitEvent({ type: "walkstart" });
|
|
827
805
|
this.viewParams = this.getViewParams();
|
|
828
806
|
this.setViewParams(this.viewParams);
|
|
829
807
|
const model = this.viewer.getActiveModel();
|
|
830
808
|
this.cameraId = model.appendCamera("Camera0");
|
|
831
809
|
this.setupCamera(view);
|
|
832
810
|
model.delete();
|
|
833
|
-
this.cameraWalker = new this.m_module.OdTvCameraWalker;
|
|
811
|
+
this.cameraWalker = new this.m_module.OdTvCameraWalker();
|
|
834
812
|
this.cameraWalker.setCamera(this.cameraId);
|
|
835
813
|
this.subject.update();
|
|
836
814
|
this.enableZoomWheelPreviousValue = this.subject.options.enableZoomWheel;
|
|
@@ -838,7 +816,8 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
838
816
|
}
|
|
839
817
|
dispose() {
|
|
840
818
|
var _a;
|
|
841
|
-
this.oldWCSEnableValue =
|
|
819
|
+
this.oldWCSEnableValue =
|
|
820
|
+
this.oldWCSEnableValue !== undefined ? this.oldWCSEnableValue : this.subject.options.showWCS;
|
|
842
821
|
this.viewer.setEnableWCS(this.oldWCSEnableValue);
|
|
843
822
|
super.dispose();
|
|
844
823
|
this.keyPressMap.clear();
|
|
@@ -852,7 +831,7 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
852
831
|
const model = this.viewer.getActiveModel();
|
|
853
832
|
model.removeEntity(this.cameraId);
|
|
854
833
|
model.delete();
|
|
855
|
-
(_a = this.cameraWalker) === null || _a ===
|
|
834
|
+
(_a = this.cameraWalker) === null || _a === void 0 ? void 0 : _a.delete();
|
|
856
835
|
}
|
|
857
836
|
if (this.viewParams) {
|
|
858
837
|
this.setViewParams(this.viewParams);
|
|
@@ -864,37 +843,30 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
864
843
|
}
|
|
865
844
|
keydown(ev) {
|
|
866
845
|
switch (ev.code) {
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
case "KeyS":
|
|
892
|
-
case "KeyD":
|
|
893
|
-
case "KeyQ":
|
|
894
|
-
case "KeyE":
|
|
895
|
-
this.keyPressMap.add(ev.code);
|
|
896
|
-
if (!this.animationId) this.processMovement(0);
|
|
897
|
-
break;
|
|
846
|
+
case "NumpadSubtract":
|
|
847
|
+
case "Minus":
|
|
848
|
+
if (this.multiplier > 1) {
|
|
849
|
+
this.multiplier = this.multiplier - 1;
|
|
850
|
+
this.subject.emitEvent({ type: "walkspeedchange", data: this.multiplier });
|
|
851
|
+
}
|
|
852
|
+
break;
|
|
853
|
+
case "NumpadAdd":
|
|
854
|
+
case "Equal":
|
|
855
|
+
if (this.multiplier < 10) {
|
|
856
|
+
this.multiplier = this.multiplier + 1;
|
|
857
|
+
this.subject.emitEvent({ type: "walkspeedchange", data: this.multiplier });
|
|
858
|
+
}
|
|
859
|
+
break;
|
|
860
|
+
case "KeyW":
|
|
861
|
+
case "KeyA":
|
|
862
|
+
case "KeyS":
|
|
863
|
+
case "KeyD":
|
|
864
|
+
case "KeyQ":
|
|
865
|
+
case "KeyE":
|
|
866
|
+
this.keyPressMap.add(ev.code);
|
|
867
|
+
if (!this.animationId)
|
|
868
|
+
this.processMovement(0);
|
|
869
|
+
break;
|
|
898
870
|
}
|
|
899
871
|
}
|
|
900
872
|
keyup(ev) {
|
|
@@ -912,58 +884,45 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
912
884
|
const currentDelta = this.multiplier * deltaTS * this.speed;
|
|
913
885
|
for (const keyCode of this.keyPressMap) {
|
|
914
886
|
switch (keyCode) {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
break;
|
|
934
|
-
|
|
935
|
-
case "KeyE":
|
|
936
|
-
this.cameraWalker.moveDown(currentDelta);
|
|
937
|
-
break;
|
|
887
|
+
case "KeyW":
|
|
888
|
+
this.cameraWalker.moveForward(currentDelta);
|
|
889
|
+
break;
|
|
890
|
+
case "KeyS":
|
|
891
|
+
this.cameraWalker.moveBackward(currentDelta);
|
|
892
|
+
break;
|
|
893
|
+
case "KeyA":
|
|
894
|
+
this.cameraWalker.moveLeft(currentDelta);
|
|
895
|
+
break;
|
|
896
|
+
case "KeyD":
|
|
897
|
+
this.cameraWalker.moveRight(currentDelta);
|
|
898
|
+
break;
|
|
899
|
+
case "KeyQ":
|
|
900
|
+
this.cameraWalker.moveUp(currentDelta);
|
|
901
|
+
break;
|
|
902
|
+
case "KeyE":
|
|
903
|
+
this.cameraWalker.moveDown(currentDelta);
|
|
904
|
+
break;
|
|
938
905
|
}
|
|
939
906
|
}
|
|
940
907
|
this.subject.update();
|
|
941
|
-
this.subject.emitEvent({
|
|
942
|
-
type: "changecamera"
|
|
943
|
-
});
|
|
908
|
+
this.subject.emitEvent({ type: "changecamera" });
|
|
944
909
|
}
|
|
945
910
|
this.lastFrameTS = timestamp;
|
|
946
911
|
}
|
|
947
912
|
start(x, y) {
|
|
948
|
-
this.dragPosition = {
|
|
949
|
-
x: x,
|
|
950
|
-
y: y
|
|
951
|
-
};
|
|
913
|
+
this.dragPosition = { x, y };
|
|
952
914
|
}
|
|
953
915
|
drag(x, y) {
|
|
954
916
|
if (this.cameraId && this.isDragging) {
|
|
955
917
|
const dltX = x - this.dragPosition.x;
|
|
956
918
|
const dltY = y - this.dragPosition.y;
|
|
957
|
-
this.dragPosition = {
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
if (dltY !== 0) this.cameraWalker.turnDown(dltY * this.deltaAngle);
|
|
919
|
+
this.dragPosition = { x, y };
|
|
920
|
+
if (dltX !== 0.0)
|
|
921
|
+
this.turnLeft(-dltX * this.deltaAngle);
|
|
922
|
+
if (dltY !== 0.0)
|
|
923
|
+
this.cameraWalker.turnDown(dltY * this.deltaAngle);
|
|
963
924
|
this.subject.update();
|
|
964
|
-
this.subject.emitEvent({
|
|
965
|
-
type: "changecamera"
|
|
966
|
-
});
|
|
925
|
+
this.subject.emitEvent({ type: "changecamera" });
|
|
967
926
|
}
|
|
968
927
|
}
|
|
969
928
|
turnLeft(angle) {
|
|
@@ -972,7 +931,7 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
972
931
|
const up = this.toVector(pCamera.upVector());
|
|
973
932
|
const pos = pCamera.position();
|
|
974
933
|
const rotMatrix = this.createMatrix3d();
|
|
975
|
-
const zAxisVector = [
|
|
934
|
+
const zAxisVector = [0, 0, 1];
|
|
976
935
|
rotMatrix.setToRotation(angle, zAxisVector, pos);
|
|
977
936
|
dir.transformBy(rotMatrix);
|
|
978
937
|
up.transformBy(rotMatrix);
|
|
@@ -986,7 +945,7 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
986
945
|
pCamera.setDisplayTarget(false);
|
|
987
946
|
pCamera.setAutoAdjust(true);
|
|
988
947
|
pCamera.setupCamera(view.viewPosition, target, view.upVector);
|
|
989
|
-
pCamera.setNearClip(false, 1);
|
|
948
|
+
pCamera.setNearClip(false, 1.0);
|
|
990
949
|
pCamera.setFarClip(false, 0);
|
|
991
950
|
pCamera.setViewParameters(view.viewFieldWidth, view.viewFieldHeight, true);
|
|
992
951
|
const focalL = calcFocalLength(view.lensLength, view.viewFieldWidth, view.viewFieldHeight);
|
|
@@ -996,19 +955,19 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
996
955
|
const viewDirVec = viewDirSub.asVector();
|
|
997
956
|
const viewDirVecNormal = viewDirVec.normalize();
|
|
998
957
|
const geViewDir = this.toGeVector(viewDirVecNormal);
|
|
999
|
-
const newGeViewDir = [
|
|
958
|
+
const newGeViewDir = [geViewDir[0] * focalL, geViewDir[1] * focalL, geViewDir[2] * focalL];
|
|
1000
959
|
const pTarget2 = this.toPoint(view.viewTarget);
|
|
1001
960
|
const newGeViewDirPt = this.toPoint(newGeViewDir);
|
|
1002
961
|
const newPos = pTarget2.add(newGeViewDirPt);
|
|
1003
962
|
pCamera.setupCamera(this.toGePoint(newPos), view.viewTarget, view.upVector);
|
|
1004
|
-
this.deleteAll([
|
|
963
|
+
this.deleteAll([pTarget, viewDir, viewDirSub, viewDirVec, viewDirVecNormal, pTarget2, newGeViewDirPt, newPos]);
|
|
1005
964
|
pCamera.assignView(view);
|
|
1006
965
|
pCamera.delete();
|
|
1007
966
|
}
|
|
1008
967
|
getMaxDimension(view) {
|
|
1009
968
|
const [xmax, ymax, zmax] = view.sceneExtents.max();
|
|
1010
969
|
const [xmin, ymin, zmin] = view.sceneExtents.min();
|
|
1011
|
-
const volume = [
|
|
970
|
+
const volume = [xmax - xmin, ymax - ymin, zmax - zmin];
|
|
1012
971
|
return Math.max(...volume);
|
|
1013
972
|
}
|
|
1014
973
|
}
|
|
@@ -1030,25 +989,25 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1030
989
|
plane.set(this.toGePoint(this.m_center), this.m_normal);
|
|
1031
990
|
avp.addCuttingPlane(plane);
|
|
1032
991
|
this.index = avp.numCuttingPlanes() - 1;
|
|
1033
|
-
const {
|
|
992
|
+
const { red, green, blue } = this.subject.options.cuttingPlaneFillColor;
|
|
1034
993
|
avp.setEnableCuttingPlaneFill(true, red, green, blue);
|
|
1035
|
-
avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kHorizontalBars,
|
|
994
|
+
avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kHorizontalBars, 0x0, 0x0, 0x0);
|
|
1036
995
|
this.m_model = this.getModel();
|
|
1037
996
|
this.createPreview();
|
|
1038
|
-
this.deleteAll([
|
|
997
|
+
this.deleteAll([ext, avp, plane]);
|
|
1039
998
|
}
|
|
1040
999
|
dispose() {
|
|
1041
1000
|
super.dispose();
|
|
1042
1001
|
if (this.m_entity) {
|
|
1043
1002
|
this.m_model.removeEntity(this.m_entity);
|
|
1044
|
-
this.deleteAll([
|
|
1003
|
+
this.deleteAll([this.m_model, this.m_entity, this.planePreview, this.m_center]);
|
|
1045
1004
|
this.m_entity = null;
|
|
1046
1005
|
this.planePreview = null;
|
|
1047
1006
|
this.subject.update();
|
|
1048
1007
|
}
|
|
1049
1008
|
}
|
|
1050
1009
|
createNormal() {
|
|
1051
|
-
return [
|
|
1010
|
+
return [0, 0, 0];
|
|
1052
1011
|
}
|
|
1053
1012
|
handleDelta(delta) {
|
|
1054
1013
|
return delta;
|
|
@@ -1059,10 +1018,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1059
1018
|
start(x, y) {
|
|
1060
1019
|
this.press = true;
|
|
1061
1020
|
this.m_last = this.screenToWorld(x, y);
|
|
1062
|
-
this.m_click = {
|
|
1063
|
-
x: x,
|
|
1064
|
-
y: y
|
|
1065
|
-
};
|
|
1021
|
+
this.m_click = { x, y };
|
|
1066
1022
|
}
|
|
1067
1023
|
drag(x, y) {
|
|
1068
1024
|
if (this.press) {
|
|
@@ -1077,7 +1033,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1077
1033
|
const newPlane = plane.set(this.toGePoint(this.m_center), this.m_normal);
|
|
1078
1034
|
const newCutting = avp.updateCuttingPlane(this.index, plane);
|
|
1079
1035
|
this.drawPreview();
|
|
1080
|
-
this.deleteAll([
|
|
1036
|
+
this.deleteAll([avp, plane, oldCenter, delta, oldLast, newPlane, newCutting]);
|
|
1081
1037
|
const device = this.getViewer().getActiveDevice();
|
|
1082
1038
|
device.invalidate(device.getSize());
|
|
1083
1039
|
}
|
|
@@ -1085,12 +1041,12 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1085
1041
|
end(x, y) {
|
|
1086
1042
|
this.press = false;
|
|
1087
1043
|
if (x === this.m_click.x && y === this.m_click.y) {
|
|
1088
|
-
this.m_normal = [
|
|
1044
|
+
this.m_normal = [this.m_normal[0] * -1, this.m_normal[1] * -1, this.m_normal[2] * -1];
|
|
1089
1045
|
const avp = this.getViewer().activeView;
|
|
1090
1046
|
const plane = this.createPlane();
|
|
1091
1047
|
plane.set(this.toGePoint(this.m_center), this.m_normal);
|
|
1092
1048
|
avp.updateCuttingPlane(this.index, plane);
|
|
1093
|
-
this.deleteAll([
|
|
1049
|
+
this.deleteAll([avp, plane, this.m_last]);
|
|
1094
1050
|
const device = this.getViewer().getActiveDevice();
|
|
1095
1051
|
device.invalidate(device.getSize());
|
|
1096
1052
|
}
|
|
@@ -1098,70 +1054,109 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1098
1054
|
createPreview() {
|
|
1099
1055
|
this.m_entity = this.m_model.appendEntity("&CuttingPlanePreview");
|
|
1100
1056
|
const GeometryTypes = this.m_module.GeometryTypes;
|
|
1101
|
-
const transparencyDef = new this.m_module.OdTvTransparencyDef;
|
|
1057
|
+
const transparencyDef = new this.m_module.OdTvTransparencyDef();
|
|
1102
1058
|
const colorDef = new this.m_module.OdTvColorDef(112, 112, 112);
|
|
1103
|
-
transparencyDef.setValue(.9);
|
|
1059
|
+
transparencyDef.setValue(0.9);
|
|
1104
1060
|
const entityPtr = this.m_entity.openObject();
|
|
1105
1061
|
entityPtr.setColor(colorDef, GeometryTypes.kFaces.value);
|
|
1106
1062
|
colorDef.setColor(112, 112, 112);
|
|
1107
1063
|
entityPtr.setColor(colorDef, GeometryTypes.kEdges.value);
|
|
1108
1064
|
entityPtr.setLineWeight(5);
|
|
1109
1065
|
entityPtr.setTransparency(transparencyDef, GeometryTypes.kFaces);
|
|
1110
|
-
transparencyDef.setValue(1);
|
|
1066
|
+
transparencyDef.setValue(1.0);
|
|
1111
1067
|
entityPtr.setTransparency(transparencyDef, GeometryTypes.kEdges);
|
|
1112
1068
|
this.planePreview = entityPtr.appendPolygon(this.getPlanePreviewCoordinate());
|
|
1113
1069
|
const polygonPtr = this.planePreview.openAsPolygon();
|
|
1114
1070
|
polygonPtr.setFilled(true);
|
|
1115
|
-
this.deleteAll([
|
|
1071
|
+
this.deleteAll([transparencyDef, colorDef, entityPtr, polygonPtr, GeometryTypes]);
|
|
1116
1072
|
this.subject.syncOverlay();
|
|
1117
1073
|
}
|
|
1118
1074
|
drawPreview() {
|
|
1119
1075
|
const polygonPtr = this.planePreview.openAsPolygon();
|
|
1120
1076
|
polygonPtr.setPoints(this.getPlanePreviewCoordinate());
|
|
1121
|
-
this.deleteAll([
|
|
1077
|
+
this.deleteAll([polygonPtr]);
|
|
1122
1078
|
this.subject.syncOverlay();
|
|
1123
1079
|
}
|
|
1124
1080
|
}
|
|
1125
1081
|
|
|
1126
1082
|
class OdCuttingPlaneXAxisDragger extends OdBaseCuttingPlaneDragger {
|
|
1127
1083
|
createNormal() {
|
|
1128
|
-
return [
|
|
1084
|
+
return [1, 0, 0];
|
|
1129
1085
|
}
|
|
1130
1086
|
handleDelta(delta) {
|
|
1131
|
-
delta.y = 0;
|
|
1132
|
-
delta.z = 0;
|
|
1087
|
+
delta.y = 0.0;
|
|
1088
|
+
delta.z = 0.0;
|
|
1133
1089
|
return delta;
|
|
1134
1090
|
}
|
|
1135
1091
|
getPlanePreviewCoordinate() {
|
|
1136
|
-
return [
|
|
1092
|
+
return [
|
|
1093
|
+
this.m_center.x,
|
|
1094
|
+
this.m_center.y - this.m_size_y,
|
|
1095
|
+
this.m_center.z - this.m_size_z,
|
|
1096
|
+
this.m_center.x,
|
|
1097
|
+
this.m_center.y + this.m_size_y,
|
|
1098
|
+
this.m_center.z - this.m_size_z,
|
|
1099
|
+
this.m_center.x,
|
|
1100
|
+
this.m_center.y + this.m_size_y,
|
|
1101
|
+
this.m_center.z + this.m_size_z,
|
|
1102
|
+
this.m_center.x,
|
|
1103
|
+
this.m_center.y - this.m_size_y,
|
|
1104
|
+
this.m_center.z + this.m_size_z,
|
|
1105
|
+
];
|
|
1137
1106
|
}
|
|
1138
1107
|
}
|
|
1139
1108
|
|
|
1140
1109
|
class OdCuttingPlaneYAxisDragger extends OdBaseCuttingPlaneDragger {
|
|
1141
1110
|
createNormal() {
|
|
1142
|
-
return [
|
|
1111
|
+
return [0, 1, 0];
|
|
1143
1112
|
}
|
|
1144
1113
|
handleDelta(delta) {
|
|
1145
|
-
delta.x = 0;
|
|
1146
|
-
delta.z = 0;
|
|
1114
|
+
delta.x = 0.0;
|
|
1115
|
+
delta.z = 0.0;
|
|
1147
1116
|
return delta;
|
|
1148
1117
|
}
|
|
1149
1118
|
getPlanePreviewCoordinate() {
|
|
1150
|
-
return [
|
|
1119
|
+
return [
|
|
1120
|
+
this.m_center.x - this.m_size_x,
|
|
1121
|
+
this.m_center.y,
|
|
1122
|
+
this.m_center.z - this.m_size_z,
|
|
1123
|
+
this.m_center.x + this.m_size_x,
|
|
1124
|
+
this.m_center.y,
|
|
1125
|
+
this.m_center.z - this.m_size_z,
|
|
1126
|
+
this.m_center.x + this.m_size_x,
|
|
1127
|
+
this.m_center.y,
|
|
1128
|
+
this.m_center.z + this.m_size_z,
|
|
1129
|
+
this.m_center.x - this.m_size_x,
|
|
1130
|
+
this.m_center.y,
|
|
1131
|
+
this.m_center.z + this.m_size_z,
|
|
1132
|
+
];
|
|
1151
1133
|
}
|
|
1152
1134
|
}
|
|
1153
1135
|
|
|
1154
1136
|
class OdCuttingPlaneZAxisDragger extends OdBaseCuttingPlaneDragger {
|
|
1155
1137
|
createNormal() {
|
|
1156
|
-
return [
|
|
1138
|
+
return [0, 0, 1];
|
|
1157
1139
|
}
|
|
1158
1140
|
handleDelta(delta) {
|
|
1159
|
-
delta.x = 0;
|
|
1160
|
-
delta.y = 0;
|
|
1141
|
+
delta.x = 0.0;
|
|
1142
|
+
delta.y = 0.0;
|
|
1161
1143
|
return delta;
|
|
1162
1144
|
}
|
|
1163
1145
|
getPlanePreviewCoordinate() {
|
|
1164
|
-
return [
|
|
1146
|
+
return [
|
|
1147
|
+
this.m_center.x - this.m_size_x,
|
|
1148
|
+
this.m_center.y - this.m_size_y,
|
|
1149
|
+
this.m_center.z,
|
|
1150
|
+
this.m_center.x + this.m_size_x,
|
|
1151
|
+
this.m_center.y - this.m_size_y,
|
|
1152
|
+
this.m_center.z,
|
|
1153
|
+
this.m_center.x + this.m_size_x,
|
|
1154
|
+
this.m_center.y + this.m_size_y,
|
|
1155
|
+
this.m_center.z,
|
|
1156
|
+
this.m_center.x - this.m_size_x,
|
|
1157
|
+
this.m_center.y + this.m_size_y,
|
|
1158
|
+
this.m_center.z,
|
|
1159
|
+
];
|
|
1165
1160
|
}
|
|
1166
1161
|
}
|
|
1167
1162
|
|
|
@@ -1174,10 +1169,7 @@ class OrbitAction {
|
|
|
1174
1169
|
}
|
|
1175
1170
|
beginAction(x, y) {
|
|
1176
1171
|
this.m_viewCenter = this.getCenter();
|
|
1177
|
-
this.m_startPoint = {
|
|
1178
|
-
x: x,
|
|
1179
|
-
y: y
|
|
1180
|
-
};
|
|
1172
|
+
this.m_startPoint = { x, y };
|
|
1181
1173
|
const view = this.getViewer().activeView;
|
|
1182
1174
|
view.delete();
|
|
1183
1175
|
this._beginInteractivity();
|
|
@@ -1187,8 +1179,8 @@ class OrbitAction {
|
|
|
1187
1179
|
const view = this.getViewer().activeView;
|
|
1188
1180
|
const corners = view.vportRect;
|
|
1189
1181
|
const size = Math.max(Math.abs(corners[2] - corners[0]), Math.abs(corners[3] - corners[1]));
|
|
1190
|
-
const distX = (this.m_startPoint.x - x) * Math.PI / size;
|
|
1191
|
-
const distY = (this.m_startPoint.y - y) * Math.PI / size;
|
|
1182
|
+
const distX = ((this.m_startPoint.x - x) * Math.PI) / size;
|
|
1183
|
+
const distY = ((this.m_startPoint.y - y) * Math.PI) / size;
|
|
1192
1184
|
this.m_startPoint.x = x;
|
|
1193
1185
|
this.m_startPoint.y = y;
|
|
1194
1186
|
const xOrbit = distY;
|
|
@@ -1199,26 +1191,26 @@ class OrbitAction {
|
|
|
1199
1191
|
upVector: view.upVector,
|
|
1200
1192
|
viewFieldWidth: view.viewFieldWidth,
|
|
1201
1193
|
viewFieldHeight: view.viewFieldHeight,
|
|
1202
|
-
perspective: view.perspective
|
|
1194
|
+
perspective: view.perspective,
|
|
1203
1195
|
};
|
|
1204
1196
|
view.delete();
|
|
1205
1197
|
const sideVector = this.getSideVector(viewParams);
|
|
1206
|
-
if (xOrbit !== 0) {
|
|
1198
|
+
if (xOrbit !== 0.0) {
|
|
1207
1199
|
this.calculateXOrbit(viewParams, -xOrbit, sideVector);
|
|
1208
1200
|
}
|
|
1209
|
-
if (yOrbit !== 0) {
|
|
1201
|
+
if (yOrbit !== 0.0) {
|
|
1210
1202
|
this.calculateYOrbit(viewParams, yOrbit, sideVector);
|
|
1211
1203
|
}
|
|
1212
1204
|
sideVector.delete();
|
|
1213
1205
|
const extView = this.getViewer().getActiveTvExtendedView();
|
|
1214
1206
|
extView.setView(viewParams.position, viewParams.target, viewParams.upVector, viewParams.viewFieldWidth, viewParams.viewFieldHeight, viewParams.perspective);
|
|
1215
1207
|
extView.delete();
|
|
1216
|
-
(_b = (_a = this._subject.activeDragger()) === null || _a ===
|
|
1208
|
+
(_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1217
1209
|
this._subject.emitEvent({
|
|
1218
|
-
type: "orbit"
|
|
1210
|
+
type: "orbit",
|
|
1219
1211
|
});
|
|
1220
1212
|
this._subject.emitEvent({
|
|
1221
|
-
type: "changecamera"
|
|
1213
|
+
type: "changecamera",
|
|
1222
1214
|
});
|
|
1223
1215
|
}
|
|
1224
1216
|
endAction() {
|
|
@@ -1232,7 +1224,7 @@ class OrbitAction {
|
|
|
1232
1224
|
const vDirect = direct.asVector();
|
|
1233
1225
|
const vCross = pUpV.crossProduct(vDirect);
|
|
1234
1226
|
const sideVector = vCross.normalize();
|
|
1235
|
-
this.deleteAll([
|
|
1227
|
+
this.deleteAll([direct, pUpV, pTarget, pPosition, vDirect, vCross]);
|
|
1236
1228
|
return sideVector;
|
|
1237
1229
|
}
|
|
1238
1230
|
calculateXOrbit(viewParams, delta, sideVector) {
|
|
@@ -1241,14 +1233,14 @@ class OrbitAction {
|
|
|
1241
1233
|
const pCenter = this.toPoint(this.m_viewCenter);
|
|
1242
1234
|
const rotatePoint = pPoint.rotateByBasePoint(delta, sideVector, pCenter);
|
|
1243
1235
|
viewParams.position = rotatePoint.toArray();
|
|
1244
|
-
this.deleteAll([
|
|
1236
|
+
this.deleteAll([pPoint, pCenter, rotatePoint]);
|
|
1245
1237
|
}
|
|
1246
1238
|
{
|
|
1247
1239
|
const pTarget = this.toPoint(viewParams.target);
|
|
1248
1240
|
const pCenter = this.toPoint(this.m_viewCenter);
|
|
1249
1241
|
const rotatePoint = pTarget.rotateByBasePoint(delta, sideVector, pCenter);
|
|
1250
1242
|
viewParams.target = rotatePoint.toArray();
|
|
1251
|
-
this.deleteAll([
|
|
1243
|
+
this.deleteAll([pTarget, pCenter, rotatePoint]);
|
|
1252
1244
|
}
|
|
1253
1245
|
{
|
|
1254
1246
|
const pPoint = this.toPoint(viewParams.position);
|
|
@@ -1259,7 +1251,7 @@ class OrbitAction {
|
|
|
1259
1251
|
const crossProduct = vUp.crossProduct(sideVector);
|
|
1260
1252
|
const crossProductNormal = crossProduct.normalize();
|
|
1261
1253
|
viewParams.upVector = crossProductNormal.toArray();
|
|
1262
|
-
this.deleteAll([
|
|
1254
|
+
this.deleteAll([pPoint, pTarget, pCenter, pUp, vUp, crossProduct, crossProductNormal]);
|
|
1263
1255
|
}
|
|
1264
1256
|
}
|
|
1265
1257
|
calculateYOrbit(viewParams, delta, sideVector) {
|
|
@@ -1269,7 +1261,7 @@ class OrbitAction {
|
|
|
1269
1261
|
const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
|
|
1270
1262
|
const rotatePoint = pPoint.rotateByBasePoint(delta, zAxis, pCenter);
|
|
1271
1263
|
viewParams.position = rotatePoint.toArray();
|
|
1272
|
-
this.deleteAll([
|
|
1264
|
+
this.deleteAll([zAxis, pPoint, pCenter, rotatePoint]);
|
|
1273
1265
|
}
|
|
1274
1266
|
{
|
|
1275
1267
|
const pTarget = this.toPoint(viewParams.target);
|
|
@@ -1277,7 +1269,7 @@ class OrbitAction {
|
|
|
1277
1269
|
const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
|
|
1278
1270
|
const rotatePoint = pTarget.rotateByBasePoint(delta, zAxis, pCenter);
|
|
1279
1271
|
viewParams.target = rotatePoint.toArray();
|
|
1280
|
-
this.deleteAll([
|
|
1272
|
+
this.deleteAll([zAxis, pTarget, pCenter, rotatePoint]);
|
|
1281
1273
|
}
|
|
1282
1274
|
{
|
|
1283
1275
|
const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
|
|
@@ -1289,7 +1281,7 @@ class OrbitAction {
|
|
|
1289
1281
|
const cross = vUp.crossProduct(side);
|
|
1290
1282
|
const crossNormal = cross.normalize();
|
|
1291
1283
|
viewParams.upVector = crossNormal.toArray();
|
|
1292
|
-
this.deleteAll([
|
|
1284
|
+
this.deleteAll([zAxis, pTarget, pPoint, side, pUp, vUp, cross, crossNormal]);
|
|
1293
1285
|
}
|
|
1294
1286
|
}
|
|
1295
1287
|
getCenter() {
|
|
@@ -1299,15 +1291,19 @@ class OrbitAction {
|
|
|
1299
1291
|
if (!pSet.isNull() && pSet.numItems() !== 0) {
|
|
1300
1292
|
const itr = pSet.getIterator();
|
|
1301
1293
|
let ext, entId, extSelected;
|
|
1302
|
-
for (
|
|
1294
|
+
for (; !itr.done(); itr.step()) {
|
|
1303
1295
|
entId = itr.getEntity();
|
|
1304
1296
|
ext = entId.getWCSExtents();
|
|
1305
|
-
if (extSelected)
|
|
1297
|
+
if (extSelected)
|
|
1298
|
+
extSelected.addExt(ext);
|
|
1299
|
+
else
|
|
1300
|
+
extSelected = ext;
|
|
1306
1301
|
}
|
|
1307
1302
|
center = extSelected.center();
|
|
1308
1303
|
extSelected.delete();
|
|
1309
1304
|
itr.delete();
|
|
1310
|
-
}
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1311
1307
|
center = viewer.getActiveExtents().center();
|
|
1312
1308
|
}
|
|
1313
1309
|
return center;
|
|
@@ -1324,7 +1320,7 @@ class OrbitAction {
|
|
|
1324
1320
|
deleteAll(objects) {
|
|
1325
1321
|
var _a;
|
|
1326
1322
|
for (const obj of objects) {
|
|
1327
|
-
(_a = obj === null || obj ===
|
|
1323
|
+
(_a = obj === null || obj === void 0 ? void 0 : obj.delete) === null || _a === void 0 ? void 0 : _a.call(obj);
|
|
1328
1324
|
}
|
|
1329
1325
|
}
|
|
1330
1326
|
}
|
|
@@ -1367,15 +1363,12 @@ class PanAction {
|
|
|
1367
1363
|
}
|
|
1368
1364
|
beginAction(x, y, absoluteX, absoluteY) {
|
|
1369
1365
|
this._m_start = this.screenToWorld(x, y);
|
|
1370
|
-
this._deltaScreenPosition = {
|
|
1371
|
-
x: absoluteX,
|
|
1372
|
-
y: absoluteY
|
|
1373
|
-
};
|
|
1366
|
+
this._deltaScreenPosition = { x: absoluteX, y: absoluteY };
|
|
1374
1367
|
this._beginInteractivity();
|
|
1375
1368
|
}
|
|
1376
1369
|
action(x, y, absoluteX, absoluteY) {
|
|
1377
1370
|
var _a, _b;
|
|
1378
|
-
const {Vector3d
|
|
1371
|
+
const { Vector3d } = this._m_module;
|
|
1379
1372
|
const params = this._getViewParams();
|
|
1380
1373
|
const pt = this.screenToWorld(x, y);
|
|
1381
1374
|
const ptSub = this._m_start.sub(pt);
|
|
@@ -1391,21 +1384,18 @@ class PanAction {
|
|
|
1391
1384
|
targetWithDelta.delete();
|
|
1392
1385
|
position.delete();
|
|
1393
1386
|
positionWithDelta.delete();
|
|
1394
|
-
(_b = (_a = this._subject.activeDragger()) === null || _a ===
|
|
1387
|
+
(_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1395
1388
|
this._subject.emitEvent({
|
|
1396
1389
|
type: "pan",
|
|
1397
1390
|
x: absoluteX,
|
|
1398
1391
|
y: absoluteY,
|
|
1399
1392
|
dX: absoluteX - this._deltaScreenPosition.x,
|
|
1400
|
-
dY: absoluteY - this._deltaScreenPosition.y
|
|
1393
|
+
dY: absoluteY - this._deltaScreenPosition.y,
|
|
1401
1394
|
});
|
|
1402
1395
|
this._subject.emitEvent({
|
|
1403
|
-
type: "changecamera"
|
|
1396
|
+
type: "changecamera",
|
|
1404
1397
|
});
|
|
1405
|
-
this._deltaScreenPosition = {
|
|
1406
|
-
x: absoluteX,
|
|
1407
|
-
y: absoluteY
|
|
1408
|
-
};
|
|
1398
|
+
this._deltaScreenPosition = { x: absoluteX, y: absoluteY };
|
|
1409
1399
|
}
|
|
1410
1400
|
endAction() {
|
|
1411
1401
|
this._endInteractivity();
|
|
@@ -1447,15 +1437,15 @@ class ZoomAction {
|
|
|
1447
1437
|
const viewer = this._m_module.getViewer();
|
|
1448
1438
|
viewer.zoomAt(zoomFactor, x, y);
|
|
1449
1439
|
this._subject.deviceAutoRegeneration();
|
|
1450
|
-
(_b = (_a = this._subject.activeDragger()) === null || _a ===
|
|
1440
|
+
(_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1451
1441
|
this._subject.emitEvent({
|
|
1452
1442
|
type: "zoomat",
|
|
1453
1443
|
data: zoomFactor,
|
|
1454
1444
|
x: absoluteX,
|
|
1455
|
-
y: absoluteY
|
|
1445
|
+
y: absoluteY,
|
|
1456
1446
|
});
|
|
1457
1447
|
this._subject.emitEvent({
|
|
1458
|
-
type: "changecamera"
|
|
1448
|
+
type: "changecamera",
|
|
1459
1449
|
});
|
|
1460
1450
|
}
|
|
1461
1451
|
}
|
|
@@ -1479,8 +1469,8 @@ class OdZoomDragger extends OdBaseDragger {
|
|
|
1479
1469
|
drag(x, y) {
|
|
1480
1470
|
const dltY = y - this.prevY;
|
|
1481
1471
|
this.prevY = y;
|
|
1482
|
-
if (this.press && Math.abs(dltY) >=
|
|
1483
|
-
const ZOOM_SPEED = .975;
|
|
1472
|
+
if (this.press && Math.abs(dltY) >= 10e-6) {
|
|
1473
|
+
const ZOOM_SPEED = 0.975;
|
|
1484
1474
|
const zoomFactor = dltY > 0 ? 1 / ZOOM_SPEED : ZOOM_SPEED;
|
|
1485
1475
|
this._zoomAction.action(this.pressX, this.pressY, zoomFactor, this.absoluteX, this.absoluteY);
|
|
1486
1476
|
}
|
|
@@ -1492,11 +1482,10 @@ class OdZoomDragger extends OdBaseDragger {
|
|
|
1492
1482
|
}
|
|
1493
1483
|
|
|
1494
1484
|
const INTERACTIVITY_TIME_OUT = 100;
|
|
1495
|
-
|
|
1496
1485
|
class OdZoomWheelDragger extends OdBaseDragger {
|
|
1497
1486
|
constructor(subject) {
|
|
1498
1487
|
super(subject);
|
|
1499
|
-
this.canvasEvents = [
|
|
1488
|
+
this.canvasEvents = ["wheel"];
|
|
1500
1489
|
this._zoomAction = new ZoomAction(this.m_module, this.subject);
|
|
1501
1490
|
this._endInteractivityTimeOutId = undefined;
|
|
1502
1491
|
this._isEnableInteractivityMode = false;
|
|
@@ -1507,8 +1496,8 @@ class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
1507
1496
|
}
|
|
1508
1497
|
event = event || window.event;
|
|
1509
1498
|
event.preventDefault();
|
|
1510
|
-
const zoomIn = this.subject.options.reverseZoomWheel ? .925 : 1 / .925;
|
|
1511
|
-
const zoomOut = this.subject.options.reverseZoomWheel ? 1 / .925 : .925;
|
|
1499
|
+
const zoomIn = this.subject.options.reverseZoomWheel ? 0.925 : 1 / 0.925;
|
|
1500
|
+
const zoomOut = this.subject.options.reverseZoomWheel ? 1 / 0.925 : 0.925;
|
|
1512
1501
|
const viewer = this.getViewer();
|
|
1513
1502
|
if (viewer) {
|
|
1514
1503
|
const zoomFactor = event.deltaY > 0 ? zoomIn : zoomOut;
|
|
@@ -1528,11 +1517,11 @@ class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
1528
1517
|
clearTimeout(this._endInteractivityTimeOutId);
|
|
1529
1518
|
}
|
|
1530
1519
|
this.subject.update(true);
|
|
1531
|
-
this._endInteractivityTimeOutId = setTimeout((
|
|
1520
|
+
this._endInteractivityTimeOutId = setTimeout(() => {
|
|
1532
1521
|
this._endInteractivityTimeOutId = undefined;
|
|
1533
1522
|
this.endInteractivity();
|
|
1534
1523
|
this._isEnableInteractivityMode = false;
|
|
1535
|
-
}
|
|
1524
|
+
}, INTERACTIVITY_TIME_OUT);
|
|
1536
1525
|
}
|
|
1537
1526
|
}
|
|
1538
1527
|
dispose() {
|
|
@@ -1546,12 +1535,12 @@ class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
1546
1535
|
|
|
1547
1536
|
class OdSelectionFrame {
|
|
1548
1537
|
constructor() {
|
|
1549
|
-
this.m_start = [
|
|
1550
|
-
this.m_end = [
|
|
1538
|
+
this.m_start = [0, 0, 0];
|
|
1539
|
+
this.m_end = [0, 0, 0];
|
|
1551
1540
|
this.m_model = null;
|
|
1552
1541
|
}
|
|
1553
1542
|
createPoint3d() {
|
|
1554
|
-
return new this.m_module.Point3d;
|
|
1543
|
+
return new this.m_module.Point3d();
|
|
1555
1544
|
}
|
|
1556
1545
|
init(instance, model) {
|
|
1557
1546
|
this.m_module = instance;
|
|
@@ -1607,7 +1596,8 @@ class OdSelectionFrame {
|
|
|
1607
1596
|
entityPtr.setLineWeight(2);
|
|
1608
1597
|
this.m_frame = entityPtr.appendPolygon(this.toDoubleArray(points));
|
|
1609
1598
|
entityPtr.delete();
|
|
1610
|
-
}
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1611
1601
|
this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(points));
|
|
1612
1602
|
}
|
|
1613
1603
|
}
|
|
@@ -1625,7 +1615,7 @@ class OdZoomWindowDragger extends OdBaseDragger {
|
|
|
1625
1615
|
this.autoSelect = true;
|
|
1626
1616
|
this.press = false;
|
|
1627
1617
|
this.needInputText = false;
|
|
1628
|
-
this.m_frame = new OdSelectionFrame;
|
|
1618
|
+
this.m_frame = new OdSelectionFrame();
|
|
1629
1619
|
this.m_frame.init(this.m_module, this.getModel());
|
|
1630
1620
|
}
|
|
1631
1621
|
start(x, y) {
|
|
@@ -1665,10 +1655,7 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1665
1655
|
start(x, y) {
|
|
1666
1656
|
this.press = true;
|
|
1667
1657
|
this.m_viewCenter = this.getCenter();
|
|
1668
|
-
this.m_startPoint = {
|
|
1669
|
-
x: x,
|
|
1670
|
-
y: y
|
|
1671
|
-
};
|
|
1658
|
+
this.m_startPoint = { x, y };
|
|
1672
1659
|
const view = this.getViewer().activeView;
|
|
1673
1660
|
this.startCameraParams = this.getViewParams();
|
|
1674
1661
|
const corners = view.vportRect;
|
|
@@ -1685,40 +1672,43 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1685
1672
|
dX *= Math.PI / this.m_delta;
|
|
1686
1673
|
dY *= Math.PI / this.m_delta;
|
|
1687
1674
|
this.setDefaultViewParams();
|
|
1688
|
-
const {
|
|
1675
|
+
const { Vector3d, Matrix3d } = this.m_module;
|
|
1689
1676
|
const target = Vector3d.createFromArray(this.startCameraParams.target);
|
|
1690
1677
|
const offset = Vector3d.createFromArray(this.startCameraParams.position).sub(target);
|
|
1691
1678
|
const dir = offset.normalize();
|
|
1692
|
-
const zMatrix = new Matrix3d;
|
|
1679
|
+
const zMatrix = new Matrix3d();
|
|
1693
1680
|
zMatrix.setToIdentity();
|
|
1694
|
-
const xMatrix = new Matrix3d;
|
|
1681
|
+
const xMatrix = new Matrix3d();
|
|
1695
1682
|
xMatrix.setToIdentity();
|
|
1696
|
-
const yAxis = Vector3d.createFromArray([
|
|
1683
|
+
const yAxis = Vector3d.createFromArray([dir.x, dir.y, dir.z]);
|
|
1697
1684
|
const zAxis = Vector3d.createFromArray(this.startCameraParams.upVector);
|
|
1698
1685
|
const xAxis = yAxis.crossProduct(zAxis);
|
|
1699
|
-
let xyDir = Vector3d.createFromArray([
|
|
1700
|
-
if (xyDir.length() <=
|
|
1686
|
+
let xyDir = Vector3d.createFromArray([yAxis.x, yAxis.y, 0]);
|
|
1687
|
+
if (xyDir.length() <= 0.00001) {
|
|
1701
1688
|
xyDir.set(-xAxis.y, xAxis.x, 0);
|
|
1702
|
-
}
|
|
1689
|
+
}
|
|
1690
|
+
else {
|
|
1703
1691
|
xyDir = xyDir.normalize();
|
|
1704
1692
|
}
|
|
1705
|
-
const xyAngle = Math.sign(xyDir.dotProduct(Vector3d.createFromArray([
|
|
1693
|
+
const xyAngle = Math.sign(xyDir.dotProduct(Vector3d.createFromArray([-1, 0, 0]))) *
|
|
1694
|
+
xyDir.angleTo(Vector3d.createFromArray([0, 1, 0]));
|
|
1706
1695
|
dX -= xyAngle;
|
|
1707
|
-
let yzDir = Vector3d.createFromArray([
|
|
1696
|
+
let yzDir = Vector3d.createFromArray([dir.x, dir.y, 0]);
|
|
1708
1697
|
let yzAngle = 0;
|
|
1709
|
-
if (yzDir.length() <=
|
|
1710
|
-
yzAngle = -dir.z * Math.PI / 2;
|
|
1711
|
-
}
|
|
1698
|
+
if (yzDir.length() <= 0.00001) {
|
|
1699
|
+
yzAngle = (-dir.z * Math.PI) / 2;
|
|
1700
|
+
}
|
|
1701
|
+
else {
|
|
1712
1702
|
yzDir = yzDir.normalize();
|
|
1713
1703
|
yzAngle = -yzDir.angleTo(dir);
|
|
1714
1704
|
}
|
|
1715
1705
|
dY -= yzAngle;
|
|
1716
|
-
zMatrix.setToRotation(-dX, [
|
|
1706
|
+
zMatrix.setToRotation(-dX, [0, 0, 1], [0, 0, 0]);
|
|
1717
1707
|
const xAngle = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, dY));
|
|
1718
|
-
xMatrix.setToRotation(xAngle, [
|
|
1708
|
+
xMatrix.setToRotation(xAngle, [1, 0, 0], [0, 0, 0]);
|
|
1719
1709
|
const endMatrix = zMatrix.postMultBy(xMatrix);
|
|
1720
|
-
let pos = Vector3d.createFromArray([
|
|
1721
|
-
const up = Vector3d.createFromArray([
|
|
1710
|
+
let pos = Vector3d.createFromArray([0, 1, 0]).transformBy(endMatrix);
|
|
1711
|
+
const up = Vector3d.createFromArray([0, 0, 1]).transformBy(endMatrix);
|
|
1722
1712
|
pos.setLength(offset.length());
|
|
1723
1713
|
pos = target.add(pos);
|
|
1724
1714
|
const current = this.getViewParams();
|
|
@@ -1743,7 +1733,8 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1743
1733
|
ext.delete();
|
|
1744
1734
|
ext = obj.getExtents();
|
|
1745
1735
|
obj.delete();
|
|
1746
|
-
}
|
|
1736
|
+
}
|
|
1737
|
+
else if (entId.getType() === 2) {
|
|
1747
1738
|
const obj = entId.openObjectAsInsert();
|
|
1748
1739
|
const extTuple = obj.getExtents();
|
|
1749
1740
|
ext.delete();
|
|
@@ -1760,48 +1751,38 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1760
1751
|
}
|
|
1761
1752
|
|
|
1762
1753
|
const draggers = draggersRegistry("visualizejs");
|
|
1763
|
-
|
|
1764
|
-
draggers.registerDragger("
|
|
1765
|
-
|
|
1766
|
-
draggers.registerDragger("
|
|
1767
|
-
|
|
1768
|
-
draggers.registerDragger("
|
|
1769
|
-
|
|
1770
|
-
draggers.registerDragger("
|
|
1771
|
-
|
|
1772
|
-
draggers.registerDragger("
|
|
1773
|
-
|
|
1774
|
-
draggers.registerDragger("OrbitAroundBuilding", (viewer => new OrbitAroundBuildingDragger(viewer)));
|
|
1775
|
-
|
|
1776
|
-
draggers.registerDragger("MeasureLine", (viewer => new MeasureLineDragger(viewer)));
|
|
1777
|
-
|
|
1778
|
-
draggers.registerDragger("CuttingPlaneXAxis", (viewer => new OdCuttingPlaneXAxisDragger(viewer)));
|
|
1779
|
-
|
|
1780
|
-
draggers.registerDragger("CuttingPlaneYAxis", (viewer => new OdCuttingPlaneYAxisDragger(viewer)));
|
|
1781
|
-
|
|
1782
|
-
draggers.registerDragger("CuttingPlaneZAxis", (viewer => new OdCuttingPlaneZAxisDragger(viewer)));
|
|
1783
|
-
|
|
1784
|
-
draggers.registerDragger("Walk", (viewer => new OdaWalkDragger(viewer)));
|
|
1754
|
+
draggers.registerDragger("Pan", (viewer) => new OdPanDragger(viewer));
|
|
1755
|
+
draggers.registerDragger("Orbit", (viewer) => new OdOrbitDragger(viewer));
|
|
1756
|
+
draggers.registerDragger("Zoom", (viewer) => new OdZoomDragger(viewer));
|
|
1757
|
+
draggers.registerDragger("ZoomWindow", (viewer) => new OdZoomWindowDragger(viewer));
|
|
1758
|
+
draggers.registerDragger("ZoomWheel", (viewer) => new OdZoomWheelDragger(viewer));
|
|
1759
|
+
draggers.registerDragger("OrbitAroundBuilding", (viewer) => new OrbitAroundBuildingDragger(viewer));
|
|
1760
|
+
draggers.registerDragger("MeasureLine", (viewer) => new MeasureLineDragger(viewer));
|
|
1761
|
+
draggers.registerDragger("CuttingPlaneXAxis", (viewer) => new OdCuttingPlaneXAxisDragger(viewer));
|
|
1762
|
+
draggers.registerDragger("CuttingPlaneYAxis", (viewer) => new OdCuttingPlaneYAxisDragger(viewer));
|
|
1763
|
+
draggers.registerDragger("CuttingPlaneZAxis", (viewer) => new OdCuttingPlaneZAxisDragger(viewer));
|
|
1764
|
+
draggers.registerDragger("Walk", (viewer) => new OdaWalkDragger(viewer));
|
|
1785
1765
|
|
|
1786
1766
|
const composeMatrixFromTransform = (transform, modelCenter, visLib) => {
|
|
1787
|
-
const {
|
|
1788
|
-
const translateMatrix = new visLib.Matrix3d;
|
|
1789
|
-
translateMatrix.setTranslation([
|
|
1790
|
-
const rotateMatrix = new visLib.Matrix3d;
|
|
1791
|
-
rotateMatrix.setToRotation(rotation.angle, [
|
|
1792
|
-
const scaleMatrix = new visLib.Matrix3d;
|
|
1767
|
+
const { translate, scale, rotation } = transform;
|
|
1768
|
+
const translateMatrix = new visLib.Matrix3d();
|
|
1769
|
+
translateMatrix.setTranslation([translate.x, translate.y, translate.z]);
|
|
1770
|
+
const rotateMatrix = new visLib.Matrix3d();
|
|
1771
|
+
rotateMatrix.setToRotation(rotation.angle, [rotation.x, rotation.y, rotation.z], modelCenter);
|
|
1772
|
+
const scaleMatrix = new visLib.Matrix3d();
|
|
1793
1773
|
scaleMatrix.setToScaling(scale, modelCenter);
|
|
1794
1774
|
return rotateMatrix.postMultBy(translateMatrix).postMultBy(scaleMatrix);
|
|
1795
1775
|
};
|
|
1796
|
-
|
|
1797
1776
|
function applyModelTransform(viewer, model) {
|
|
1798
1777
|
var _a;
|
|
1799
|
-
if (!viewer.visualizeJs)
|
|
1800
|
-
|
|
1778
|
+
if (!viewer.visualizeJs)
|
|
1779
|
+
return;
|
|
1780
|
+
if (!model.getModelTransformMatrix)
|
|
1781
|
+
return;
|
|
1801
1782
|
const visLib = viewer.visLib();
|
|
1802
1783
|
const visViewer = viewer.visViewer();
|
|
1803
1784
|
const modelItr = visViewer.getModelIterator();
|
|
1804
|
-
for (
|
|
1785
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
1805
1786
|
const modelPtr = modelItr.getModel();
|
|
1806
1787
|
const transform = model.getModelTransformMatrix(modelPtr.getDatabaseHandle());
|
|
1807
1788
|
if (transform) {
|
|
@@ -1812,7 +1793,7 @@ function applyModelTransform(viewer, model) {
|
|
|
1812
1793
|
}
|
|
1813
1794
|
}
|
|
1814
1795
|
modelItr.delete();
|
|
1815
|
-
(_a = visViewer.clearViewExtentsCache) === null || _a ===
|
|
1796
|
+
(_a = visViewer.clearViewExtentsCache) === null || _a === void 0 ? void 0 : _a.call(visViewer);
|
|
1816
1797
|
viewer.update();
|
|
1817
1798
|
}
|
|
1818
1799
|
|
|
@@ -1821,75 +1802,79 @@ function clearMarkup(viewer) {
|
|
|
1821
1802
|
}
|
|
1822
1803
|
|
|
1823
1804
|
function clearSelected(viewer) {
|
|
1824
|
-
if (!viewer.visualizeJs)
|
|
1805
|
+
if (!viewer.visualizeJs)
|
|
1806
|
+
return;
|
|
1825
1807
|
const visViewer = viewer.visViewer();
|
|
1826
1808
|
visViewer.unselect();
|
|
1827
1809
|
viewer.update();
|
|
1828
|
-
viewer.emitEvent({
|
|
1829
|
-
type: "select",
|
|
1830
|
-
data: undefined,
|
|
1831
|
-
handles: []
|
|
1832
|
-
});
|
|
1810
|
+
viewer.emitEvent({ type: "select", data: undefined, handles: [] });
|
|
1833
1811
|
}
|
|
1834
1812
|
|
|
1835
1813
|
function clearSlices(viewer) {
|
|
1836
1814
|
viewer.clearSlices();
|
|
1837
1815
|
}
|
|
1838
1816
|
|
|
1839
|
-
function createPreview(viewer, type = "image/jpeg", encoderOptions = .25) {
|
|
1817
|
+
function createPreview(viewer, type = "image/jpeg", encoderOptions = 0.25) {
|
|
1840
1818
|
var _a;
|
|
1841
|
-
if (!viewer.visualizeJs)
|
|
1842
|
-
|
|
1819
|
+
if (!viewer.visualizeJs)
|
|
1820
|
+
return "";
|
|
1821
|
+
return ((_a = viewer.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, encoderOptions)) || "";
|
|
1843
1822
|
}
|
|
1844
1823
|
|
|
1845
1824
|
function explode(viewer, index = 0) {
|
|
1846
|
-
if (!viewer.visualizeJs)
|
|
1825
|
+
if (!viewer.visualizeJs)
|
|
1826
|
+
return;
|
|
1847
1827
|
const visViewer = viewer.visViewer();
|
|
1848
1828
|
visViewer.explode(index);
|
|
1849
1829
|
viewer.update();
|
|
1850
|
-
viewer.emitEvent({
|
|
1851
|
-
type: "explode",
|
|
1852
|
-
data: index
|
|
1853
|
-
});
|
|
1830
|
+
viewer.emitEvent({ type: "explode", data: index });
|
|
1854
1831
|
}
|
|
1855
|
-
|
|
1856
1832
|
function collect(viewer) {
|
|
1857
1833
|
explode(viewer, 0);
|
|
1858
1834
|
}
|
|
1859
1835
|
|
|
1860
1836
|
function getDefaultViewPositions(viewer) {
|
|
1861
|
-
if (!viewer.visualizeJs)
|
|
1837
|
+
if (!viewer.visualizeJs)
|
|
1838
|
+
return [];
|
|
1862
1839
|
const visLib = viewer.visLib();
|
|
1863
1840
|
const defViewPos = visLib.DefaultViewPosition;
|
|
1864
|
-
return Object.keys(defViewPos).filter((x => x !== "values")
|
|
1841
|
+
return Object.keys(defViewPos).filter((x) => x !== "values");
|
|
1865
1842
|
}
|
|
1866
1843
|
|
|
1867
1844
|
function getModels(viewer) {
|
|
1868
|
-
if (!viewer.visualizeJs)
|
|
1845
|
+
if (!viewer.visualizeJs)
|
|
1846
|
+
return [];
|
|
1869
1847
|
const visViewer = viewer.visViewer();
|
|
1870
1848
|
const handles = [];
|
|
1871
1849
|
const modelItr = visViewer.getModelIterator();
|
|
1872
|
-
for (
|
|
1850
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
1873
1851
|
const modelPtr = modelItr.getModel();
|
|
1874
|
-
if (modelPtr.getName()[0] !== "$")
|
|
1852
|
+
if (modelPtr.getName()[0] !== "$")
|
|
1853
|
+
handles.push(modelPtr.getDatabaseHandle());
|
|
1875
1854
|
}
|
|
1876
1855
|
modelItr.delete();
|
|
1877
1856
|
return handles;
|
|
1878
1857
|
}
|
|
1879
1858
|
|
|
1880
1859
|
function getSelected(viewer) {
|
|
1881
|
-
if (!viewer.visualizeJs)
|
|
1860
|
+
if (!viewer.visualizeJs)
|
|
1861
|
+
return [];
|
|
1882
1862
|
const visViewer = viewer.visViewer();
|
|
1883
1863
|
const handles = [];
|
|
1884
1864
|
const selectionSet = visViewer.getSelected();
|
|
1885
1865
|
if (!selectionSet.isNull() && selectionSet.numItems() !== 0) {
|
|
1886
1866
|
const itr = selectionSet.getIterator();
|
|
1887
|
-
for (
|
|
1867
|
+
for (; !itr.done(); itr.step()) {
|
|
1888
1868
|
const entityId = itr.getEntity();
|
|
1889
|
-
const entityPtr = entityId.getType() === 1
|
|
1869
|
+
const entityPtr = entityId.getType() === 1
|
|
1870
|
+
? entityId.openObject()
|
|
1871
|
+
: entityId.getType() === 2
|
|
1872
|
+
? entityId.openObjectAsInsert()
|
|
1873
|
+
: null;
|
|
1890
1874
|
if (entityPtr) {
|
|
1891
1875
|
const handle = entityPtr.getNativeDatabaseHandle();
|
|
1892
|
-
if (handle !== "-1")
|
|
1876
|
+
if (handle !== "-1")
|
|
1877
|
+
handles.push(handle);
|
|
1893
1878
|
entityPtr.delete();
|
|
1894
1879
|
}
|
|
1895
1880
|
}
|
|
@@ -1899,42 +1884,36 @@ function getSelected(viewer) {
|
|
|
1899
1884
|
}
|
|
1900
1885
|
|
|
1901
1886
|
function hideSelected(viewer) {
|
|
1902
|
-
if (!viewer.visualizeJs)
|
|
1887
|
+
if (!viewer.visualizeJs)
|
|
1888
|
+
return;
|
|
1903
1889
|
const visViewer = viewer.visViewer();
|
|
1904
1890
|
visViewer.hideSelectedObjects(false);
|
|
1905
1891
|
viewer.update();
|
|
1906
|
-
viewer.emitEvent({
|
|
1907
|
-
|
|
1908
|
-
});
|
|
1909
|
-
viewer.emitEvent({
|
|
1910
|
-
type: "select",
|
|
1911
|
-
data: undefined,
|
|
1912
|
-
handles: []
|
|
1913
|
-
});
|
|
1892
|
+
viewer.emitEvent({ type: "hide" });
|
|
1893
|
+
viewer.emitEvent({ type: "select", data: undefined, handles: [] });
|
|
1914
1894
|
}
|
|
1915
1895
|
|
|
1916
1896
|
function isolateSelected(viewer) {
|
|
1917
|
-
if (!viewer.visualizeJs)
|
|
1897
|
+
if (!viewer.visualizeJs)
|
|
1898
|
+
return;
|
|
1918
1899
|
const visViewer = viewer.visViewer();
|
|
1919
1900
|
visViewer.isolateSelectedObjects(false);
|
|
1920
1901
|
viewer.update();
|
|
1921
|
-
viewer.emitEvent({
|
|
1922
|
-
type: "isolate"
|
|
1923
|
-
});
|
|
1902
|
+
viewer.emitEvent({ type: "isolate" });
|
|
1924
1903
|
}
|
|
1925
1904
|
|
|
1926
1905
|
function regenerateAll(viewer) {
|
|
1927
|
-
if (!viewer.visualizeJs)
|
|
1906
|
+
if (!viewer.visualizeJs)
|
|
1907
|
+
return;
|
|
1928
1908
|
const visViewer = viewer.visViewer();
|
|
1929
1909
|
visViewer.regenAll();
|
|
1930
1910
|
viewer.update();
|
|
1931
|
-
viewer.emit({
|
|
1932
|
-
type: "regenerateall"
|
|
1933
|
-
});
|
|
1911
|
+
viewer.emit({ type: "regenerateall" });
|
|
1934
1912
|
}
|
|
1935
1913
|
|
|
1936
1914
|
function resetView(viewer) {
|
|
1937
|
-
if (!viewer.visualizeJs)
|
|
1915
|
+
if (!viewer.visualizeJs)
|
|
1916
|
+
return;
|
|
1938
1917
|
viewer.executeCommand("setActiveDragger");
|
|
1939
1918
|
viewer.executeCommand("clearSlices");
|
|
1940
1919
|
viewer.executeCommand("clearOverlay");
|
|
@@ -1944,28 +1923,23 @@ function resetView(viewer) {
|
|
|
1944
1923
|
viewer.executeCommand("explode", 0);
|
|
1945
1924
|
viewer.executeCommand("zoomToExtents", true);
|
|
1946
1925
|
viewer.executeCommand("k3DViewSW");
|
|
1947
|
-
viewer.emit({
|
|
1948
|
-
type: "resetview"
|
|
1949
|
-
});
|
|
1926
|
+
viewer.emit({ type: "resetview" });
|
|
1950
1927
|
}
|
|
1951
1928
|
|
|
1952
1929
|
function selectModel(viewer, handle) {
|
|
1953
|
-
if (!viewer.visualizeJs)
|
|
1930
|
+
if (!viewer.visualizeJs)
|
|
1931
|
+
return;
|
|
1954
1932
|
const visViewer = viewer.visViewer();
|
|
1955
1933
|
const activeView = visViewer.activeView;
|
|
1956
1934
|
const modelItr = visViewer.getModelIterator();
|
|
1957
|
-
for (
|
|
1935
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
1958
1936
|
const modelPtr = modelItr.getModel();
|
|
1959
1937
|
if (modelPtr.getDatabaseHandle() === handle) {
|
|
1960
|
-
const selectionSet = activeView.selectCrossing([
|
|
1938
|
+
const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
|
|
1961
1939
|
visViewer.setSelected(selectionSet);
|
|
1962
1940
|
const handles = viewer.getSelected();
|
|
1963
1941
|
viewer.update();
|
|
1964
|
-
viewer.emitEvent({
|
|
1965
|
-
type: "select",
|
|
1966
|
-
data: selectionSet,
|
|
1967
|
-
handles: handles
|
|
1968
|
-
});
|
|
1942
|
+
viewer.emitEvent({ type: "select", data: selectionSet, handles });
|
|
1969
1943
|
selectionSet.delete();
|
|
1970
1944
|
break;
|
|
1971
1945
|
}
|
|
@@ -1978,16 +1952,14 @@ function setActiveDragger(viewer, dragger = "") {
|
|
|
1978
1952
|
}
|
|
1979
1953
|
|
|
1980
1954
|
function setDefaultViewPosition(viewer, position = "") {
|
|
1981
|
-
if (!viewer.visualizeJs)
|
|
1955
|
+
if (!viewer.visualizeJs)
|
|
1956
|
+
return;
|
|
1982
1957
|
const visLib = viewer.visLib();
|
|
1983
1958
|
const visViewer = viewer.visViewer();
|
|
1984
1959
|
const defViewPos = visLib.DefaultViewPosition;
|
|
1985
1960
|
visViewer.setDefaultViewPositionWithAnimation(defViewPos[position]);
|
|
1986
1961
|
viewer.update();
|
|
1987
|
-
viewer.emit({
|
|
1988
|
-
type: "viewposition",
|
|
1989
|
-
data: position
|
|
1990
|
-
});
|
|
1962
|
+
viewer.emit({ type: "viewposition", data: position });
|
|
1991
1963
|
}
|
|
1992
1964
|
|
|
1993
1965
|
function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
@@ -1995,36 +1967,34 @@ function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
|
1995
1967
|
}
|
|
1996
1968
|
|
|
1997
1969
|
function setSelected(viewer, handles = []) {
|
|
1998
|
-
if (!viewer.visualizeJs)
|
|
1970
|
+
if (!viewer.visualizeJs)
|
|
1971
|
+
return;
|
|
1999
1972
|
const visLib = viewer.visLib();
|
|
2000
1973
|
const visViewer = viewer.visViewer();
|
|
2001
|
-
const selectionSet = new visLib.OdTvSelectionSet;
|
|
2002
|
-
handles === null || handles ===
|
|
1974
|
+
const selectionSet = new visLib.OdTvSelectionSet();
|
|
1975
|
+
handles === null || handles === void 0 ? void 0 : handles.forEach((handle) => {
|
|
2003
1976
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
2004
|
-
if (!entityId.isNull())
|
|
2005
|
-
|
|
1977
|
+
if (!entityId.isNull())
|
|
1978
|
+
selectionSet.appendEntity(entityId);
|
|
1979
|
+
});
|
|
2006
1980
|
visViewer.setSelected(selectionSet);
|
|
2007
1981
|
viewer.update();
|
|
2008
|
-
viewer.emitEvent({
|
|
2009
|
-
type: "select",
|
|
2010
|
-
data: selectionSet,
|
|
2011
|
-
handles: handles
|
|
2012
|
-
});
|
|
1982
|
+
viewer.emitEvent({ type: "select", data: selectionSet, handles });
|
|
2013
1983
|
selectionSet.delete();
|
|
2014
1984
|
}
|
|
2015
1985
|
|
|
2016
1986
|
function showAll(viewer) {
|
|
2017
|
-
if (!viewer.visualizeJs)
|
|
1987
|
+
if (!viewer.visualizeJs)
|
|
1988
|
+
return;
|
|
2018
1989
|
const visViewer = viewer.visViewer();
|
|
2019
1990
|
visViewer.unisolateSelectedObjects(false);
|
|
2020
1991
|
viewer.update();
|
|
2021
|
-
viewer.emitEvent({
|
|
2022
|
-
type: "showall"
|
|
2023
|
-
});
|
|
1992
|
+
viewer.emitEvent({ type: "showall" });
|
|
2024
1993
|
}
|
|
2025
1994
|
|
|
2026
1995
|
function zoomToExtents(viewer, force = false, animate = viewer.options.cameraAnimation) {
|
|
2027
|
-
if (!viewer.visualizeJs)
|
|
1996
|
+
if (!viewer.visualizeJs)
|
|
1997
|
+
return;
|
|
2028
1998
|
const visViewer = viewer.visViewer();
|
|
2029
1999
|
const saveEnableAmination = visViewer.getEnableAnimation();
|
|
2030
2000
|
visViewer.setEnableAnimation(animate);
|
|
@@ -2033,57 +2003,55 @@ function zoomToExtents(viewer, force = false, animate = viewer.options.cameraAni
|
|
|
2033
2003
|
visViewer.setEnableAnimation(saveEnableAmination);
|
|
2034
2004
|
viewer.deviceAutoRegeneration();
|
|
2035
2005
|
viewer.update();
|
|
2036
|
-
viewer.emitEvent({
|
|
2037
|
-
type: "zoom"
|
|
2038
|
-
});
|
|
2006
|
+
viewer.emitEvent({ type: "zoom" });
|
|
2039
2007
|
}
|
|
2040
2008
|
|
|
2041
2009
|
function zoomToObjects(viewer, handles = []) {
|
|
2042
2010
|
var _a;
|
|
2043
|
-
if (!viewer.visualizeJs)
|
|
2011
|
+
if (!viewer.visualizeJs)
|
|
2012
|
+
return;
|
|
2044
2013
|
const visLib = viewer.visLib();
|
|
2045
2014
|
const visViewer = viewer.visViewer();
|
|
2046
|
-
const selectionSet = new visLib.OdTvSelectionSet;
|
|
2047
|
-
handles.forEach((handle => {
|
|
2015
|
+
const selectionSet = new visLib.OdTvSelectionSet();
|
|
2016
|
+
handles.forEach((handle) => {
|
|
2048
2017
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
2049
|
-
if (!entityId.isNull())
|
|
2050
|
-
|
|
2051
|
-
|
|
2018
|
+
if (!entityId.isNull())
|
|
2019
|
+
selectionSet.appendEntity(entityId);
|
|
2020
|
+
});
|
|
2021
|
+
(_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
|
|
2052
2022
|
viewer.deviceAutoRegeneration();
|
|
2053
2023
|
viewer.update();
|
|
2054
|
-
viewer.emitEvent({
|
|
2055
|
-
type: "zoom"
|
|
2056
|
-
});
|
|
2024
|
+
viewer.emitEvent({ type: "zoom" });
|
|
2057
2025
|
selectionSet.delete();
|
|
2058
2026
|
}
|
|
2059
2027
|
|
|
2060
2028
|
function zoomToSelected(viewer) {
|
|
2061
2029
|
var _a;
|
|
2062
|
-
if (!viewer.visualizeJs)
|
|
2030
|
+
if (!viewer.visualizeJs)
|
|
2031
|
+
return;
|
|
2063
2032
|
const visViewer = viewer.visViewer();
|
|
2064
2033
|
const selectionSet = visViewer.getSelected();
|
|
2065
|
-
(_a = visViewer.zoomToObjects) === null || _a ===
|
|
2034
|
+
(_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
|
|
2066
2035
|
viewer.deviceAutoRegeneration();
|
|
2067
2036
|
viewer.update();
|
|
2068
|
-
viewer.emitEvent({
|
|
2069
|
-
type: "zoom"
|
|
2070
|
-
});
|
|
2037
|
+
viewer.emitEvent({ type: "zoom" });
|
|
2071
2038
|
}
|
|
2072
2039
|
|
|
2073
2040
|
function isTemplateModel(modelPtr) {
|
|
2074
2041
|
return modelPtr.getName()[0] === "$";
|
|
2075
2042
|
}
|
|
2076
|
-
|
|
2077
2043
|
async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
2078
2044
|
var _a;
|
|
2079
|
-
if (!viewer.visualizeJs)
|
|
2080
|
-
|
|
2045
|
+
if (!viewer.visualizeJs)
|
|
2046
|
+
return;
|
|
2047
|
+
if (!model.getModelTransformMatrix)
|
|
2048
|
+
return;
|
|
2081
2049
|
const visLib = viewer.visLib();
|
|
2082
2050
|
const visViewer = viewer.visViewer();
|
|
2083
2051
|
const viewExt = visViewer.getActiveExtents();
|
|
2084
2052
|
const centralPoint = viewExt.center();
|
|
2085
2053
|
const modelItr = visViewer.getModelIterator();
|
|
2086
|
-
for (
|
|
2054
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
2087
2055
|
const modelPtr = modelItr.getModel();
|
|
2088
2056
|
if (!isTemplateModel(modelPtr)) {
|
|
2089
2057
|
const ext = modelPtr.getExtents();
|
|
@@ -2091,26 +2059,28 @@ async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
|
2091
2059
|
ext.transformBy(modelPtr.getUnitsMatrix());
|
|
2092
2060
|
const unitsMatrixInvert = modelPtr.getUnitsMatrix().invert();
|
|
2093
2061
|
const center = ext.center();
|
|
2094
|
-
const scale = 1;
|
|
2095
|
-
const scaleMatrix = new visLib.Matrix3d;
|
|
2096
|
-
const translateMatrix = new visLib.Matrix3d;
|
|
2097
|
-
translateMatrix.setTranslation([
|
|
2062
|
+
const scale = 1.0;
|
|
2063
|
+
const scaleMatrix = new visLib.Matrix3d();
|
|
2064
|
+
const translateMatrix = new visLib.Matrix3d();
|
|
2065
|
+
translateMatrix.setTranslation([
|
|
2066
|
+
centralPoint[0] - center[0],
|
|
2067
|
+
centralPoint[1] - center[1],
|
|
2068
|
+
centralPoint[2] - center[2],
|
|
2069
|
+
]);
|
|
2098
2070
|
scaleMatrix.setToScaling(scale, centralPoint);
|
|
2099
|
-
const resMatrixWithUnits = unitsMatrixInvert
|
|
2071
|
+
const resMatrixWithUnits = unitsMatrixInvert
|
|
2072
|
+
.postMultBy(scaleMatrix)
|
|
2073
|
+
.postMultBy(translateMatrix)
|
|
2074
|
+
.postMultBy(unitsMatrix);
|
|
2100
2075
|
const resScale = resMatrixWithUnits.scale();
|
|
2101
2076
|
const transform = {
|
|
2102
2077
|
translate: {
|
|
2103
2078
|
x: resMatrixWithUnits.get(0, 3) - (1 - resScale) * center[0],
|
|
2104
2079
|
y: resMatrixWithUnits.get(1, 3) - (1 - resScale) * center[1],
|
|
2105
|
-
z: resMatrixWithUnits.get(2, 3) - (1 - resScale) * center[2]
|
|
2080
|
+
z: resMatrixWithUnits.get(2, 3) - (1 - resScale) * center[2],
|
|
2106
2081
|
},
|
|
2107
|
-
rotation: {
|
|
2108
|
-
|
|
2109
|
-
y: 0,
|
|
2110
|
-
z: 1,
|
|
2111
|
-
angle: 0
|
|
2112
|
-
},
|
|
2113
|
-
scale: resScale
|
|
2082
|
+
rotation: { x: 0, y: 0, z: 1, angle: 0.0 },
|
|
2083
|
+
scale: resScale,
|
|
2114
2084
|
};
|
|
2115
2085
|
const matrix = composeMatrixFromTransform(transform, center, visLib);
|
|
2116
2086
|
modelPtr.setModelingMatrix(matrix, true);
|
|
@@ -2120,84 +2090,47 @@ async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
|
2120
2090
|
modelPtr.delete();
|
|
2121
2091
|
}
|
|
2122
2092
|
modelItr.delete();
|
|
2123
|
-
(_a = visViewer.clearViewExtentsCache) === null || _a ===
|
|
2093
|
+
(_a = visViewer.clearViewExtentsCache) === null || _a === void 0 ? void 0 : _a.call(visViewer);
|
|
2124
2094
|
viewer.update();
|
|
2125
2095
|
}
|
|
2126
2096
|
|
|
2127
2097
|
const commands = commandsRegistry("visualizejs");
|
|
2128
|
-
|
|
2129
2098
|
commands.registerCommand("applyModelTransform", applyModelTransform);
|
|
2130
|
-
|
|
2131
2099
|
commands.registerCommand("clearMarkup", clearMarkup);
|
|
2132
|
-
|
|
2133
2100
|
commands.registerCommand("clearSelected", clearSelected);
|
|
2134
|
-
|
|
2135
2101
|
commands.registerCommand("clearSlices", clearSlices);
|
|
2136
|
-
|
|
2137
2102
|
commands.registerCommand("createPreview", createPreview);
|
|
2138
|
-
|
|
2139
2103
|
commands.registerCommand("explode", explode);
|
|
2140
|
-
|
|
2141
2104
|
commands.registerCommand("collect", collect);
|
|
2142
|
-
|
|
2143
2105
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
2144
|
-
|
|
2145
2106
|
commands.registerCommand("getModels", getModels);
|
|
2146
|
-
|
|
2147
2107
|
commands.registerCommand("getSelected", getSelected);
|
|
2148
|
-
|
|
2149
2108
|
commands.registerCommand("hideSelected", hideSelected);
|
|
2150
|
-
|
|
2151
2109
|
commands.registerCommand("isolateSelected", isolateSelected);
|
|
2152
|
-
|
|
2153
2110
|
commands.registerCommand("regenerateAll", regenerateAll);
|
|
2154
|
-
|
|
2155
2111
|
commands.registerCommand("resetView", resetView);
|
|
2156
|
-
|
|
2157
2112
|
commands.registerCommand("selectModel", selectModel);
|
|
2158
|
-
|
|
2159
2113
|
commands.registerCommand("setActiveDragger", setActiveDragger);
|
|
2160
|
-
|
|
2161
2114
|
commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
2162
|
-
|
|
2163
2115
|
commands.registerCommand("setMarkupColor", setMarkupColor);
|
|
2164
|
-
|
|
2165
2116
|
commands.registerCommand("setSelected", setSelected);
|
|
2166
|
-
|
|
2167
2117
|
commands.registerCommand("showAll", showAll);
|
|
2168
|
-
|
|
2169
2118
|
commands.registerCommand("zoomToExtents", zoomToExtents);
|
|
2170
|
-
|
|
2171
2119
|
commands.registerCommand("zoomToObjects", zoomToObjects);
|
|
2172
|
-
|
|
2173
2120
|
commands.registerCommand("zoomToSelected", zoomToSelected);
|
|
2174
|
-
|
|
2175
2121
|
commands.registerCommand("autoTransformAllModelsToCentralPoint", autoTransformAllModelsToCentralPoint);
|
|
2176
|
-
|
|
2177
|
-
commands.registerCommand("
|
|
2178
|
-
|
|
2179
|
-
commands.registerCommand("
|
|
2180
|
-
|
|
2181
|
-
commands.registerCommand("
|
|
2182
|
-
|
|
2183
|
-
commands.registerCommand("
|
|
2184
|
-
|
|
2185
|
-
commands.registerCommand("
|
|
2186
|
-
|
|
2187
|
-
commands.registerCommand("k3DViewBack", (viewer => setDefaultViewPosition(viewer, "k3DViewBack")));
|
|
2188
|
-
|
|
2189
|
-
commands.registerCommand("k3DViewSE", (viewer => setDefaultViewPosition(viewer, "k3DViewSE")));
|
|
2190
|
-
|
|
2191
|
-
commands.registerCommand("k3DViewSW", (viewer => setDefaultViewPosition(viewer, "k3DViewSW")));
|
|
2192
|
-
|
|
2193
|
-
commands.registerCommand("k3DViewNE", (viewer => setDefaultViewPosition(viewer, "k3DViewNE")));
|
|
2194
|
-
|
|
2195
|
-
commands.registerCommand("k3DViewNW", (viewer => setDefaultViewPosition(viewer, "k3DViewNW")));
|
|
2196
|
-
|
|
2122
|
+
commands.registerCommand("k3DViewTop", (viewer) => setDefaultViewPosition(viewer, "k3DViewTop"));
|
|
2123
|
+
commands.registerCommand("k3DViewBottom", (viewer) => setDefaultViewPosition(viewer, "k3DViewBottom"));
|
|
2124
|
+
commands.registerCommand("k3DViewLeft", (viewer) => setDefaultViewPosition(viewer, "k3DViewLeft"));
|
|
2125
|
+
commands.registerCommand("k3DViewRight", (viewer) => setDefaultViewPosition(viewer, "k3DViewRight"));
|
|
2126
|
+
commands.registerCommand("k3DViewFront", (viewer) => setDefaultViewPosition(viewer, "k3DViewFront"));
|
|
2127
|
+
commands.registerCommand("k3DViewBack", (viewer) => setDefaultViewPosition(viewer, "k3DViewBack"));
|
|
2128
|
+
commands.registerCommand("k3DViewSE", (viewer) => setDefaultViewPosition(viewer, "k3DViewSE"));
|
|
2129
|
+
commands.registerCommand("k3DViewSW", (viewer) => setDefaultViewPosition(viewer, "k3DViewSW"));
|
|
2130
|
+
commands.registerCommand("k3DViewNE", (viewer) => setDefaultViewPosition(viewer, "k3DViewNE"));
|
|
2131
|
+
commands.registerCommand("k3DViewNW", (viewer) => setDefaultViewPosition(viewer, "k3DViewNW"));
|
|
2197
2132
|
commands.registerCommandAlias("clearMarkup", "clearOverlay");
|
|
2198
|
-
|
|
2199
2133
|
commands.registerCommandAlias("clearSelected", "unselect");
|
|
2200
|
-
|
|
2201
2134
|
commands.registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
2202
2135
|
|
|
2203
2136
|
class RenderLoopComponent {
|
|
@@ -2205,10 +2138,7 @@ class RenderLoopComponent {
|
|
|
2205
2138
|
this.animate = (time = 0) => {
|
|
2206
2139
|
this.requestId = requestAnimationFrame(this.animate);
|
|
2207
2140
|
this.viewer.render(time);
|
|
2208
|
-
this.viewer.emitEvent({
|
|
2209
|
-
type: "animate",
|
|
2210
|
-
time: time
|
|
2211
|
-
});
|
|
2141
|
+
this.viewer.emitEvent({ type: "animate", time });
|
|
2212
2142
|
};
|
|
2213
2143
|
this.viewer = viewer;
|
|
2214
2144
|
this.animate();
|
|
@@ -2220,9 +2150,10 @@ class RenderLoopComponent {
|
|
|
2220
2150
|
|
|
2221
2151
|
class ResizeCanvasComponent {
|
|
2222
2152
|
constructor(viewer) {
|
|
2223
|
-
this.resizeViewer = entries => {
|
|
2224
|
-
const {
|
|
2225
|
-
if (!width || !height)
|
|
2153
|
+
this.resizeViewer = (entries) => {
|
|
2154
|
+
const { width, height } = entries[0].contentRect;
|
|
2155
|
+
if (!width || !height)
|
|
2156
|
+
return;
|
|
2226
2157
|
this.viewer.setSize(width, height);
|
|
2227
2158
|
};
|
|
2228
2159
|
this.viewer = viewer;
|
|
@@ -2248,14 +2179,12 @@ class ZoomWheelComponent {
|
|
|
2248
2179
|
}
|
|
2249
2180
|
|
|
2250
2181
|
var GestureAction;
|
|
2251
|
-
|
|
2252
|
-
(function(GestureAction) {
|
|
2182
|
+
(function (GestureAction) {
|
|
2253
2183
|
GestureAction[GestureAction["None"] = 0] = "None";
|
|
2254
2184
|
GestureAction[GestureAction["Orbit"] = 1] = "Orbit";
|
|
2255
2185
|
GestureAction[GestureAction["Pan"] = 2] = "Pan";
|
|
2256
2186
|
GestureAction[GestureAction["Zoom"] = 3] = "Zoom";
|
|
2257
2187
|
})(GestureAction || (GestureAction = {}));
|
|
2258
|
-
|
|
2259
2188
|
class GestureManager extends OdBaseDragger {
|
|
2260
2189
|
get isSingleTouchEnabled() {
|
|
2261
2190
|
return this._isSingleTouchEnabled;
|
|
@@ -2265,8 +2194,8 @@ class GestureManager extends OdBaseDragger {
|
|
|
2265
2194
|
}
|
|
2266
2195
|
constructor(subject) {
|
|
2267
2196
|
super(subject);
|
|
2268
|
-
this._previousEvents = new Map;
|
|
2269
|
-
this._currentEvents = new Map;
|
|
2197
|
+
this._previousEvents = new Map();
|
|
2198
|
+
this._currentEvents = new Map();
|
|
2270
2199
|
this._lastGestureAction = GestureAction.None;
|
|
2271
2200
|
this._maxInitialDistanceDifference = 30 * window.devicePixelRatio;
|
|
2272
2201
|
this._isSingleTouchEnabled = false;
|
|
@@ -2283,7 +2212,7 @@ class GestureManager extends OdBaseDragger {
|
|
|
2283
2212
|
const point1 = this.relativeCoords(events.get(keys[1]));
|
|
2284
2213
|
return {
|
|
2285
2214
|
x: Math.floor((point0.x + point1.x) / 2),
|
|
2286
|
-
y: Math.floor((point0.y + point1.y) / 2)
|
|
2215
|
+
y: Math.floor((point0.y + point1.y) / 2),
|
|
2287
2216
|
};
|
|
2288
2217
|
}
|
|
2289
2218
|
getFirstPoint(events) {
|
|
@@ -2333,12 +2262,14 @@ class GestureManager extends OdBaseDragger {
|
|
|
2333
2262
|
const currentDistanceEqualsInitialDistance = Math.abs(this._initialDistance - currentDistance) <= this._maxInitialDistanceDifference;
|
|
2334
2263
|
if (currentDistanceEqualsInitialDistance) {
|
|
2335
2264
|
this.executePanAction(this.getMiddlePoint(this._currentEvents));
|
|
2336
|
-
}
|
|
2265
|
+
}
|
|
2266
|
+
else {
|
|
2337
2267
|
if (previousDistance !== -1 && currentDistance !== previousDistance) {
|
|
2338
2268
|
this.executeZoomAction(currentDistance, previousDistance);
|
|
2339
2269
|
}
|
|
2340
2270
|
}
|
|
2341
|
-
}
|
|
2271
|
+
}
|
|
2272
|
+
else if (this._currentEvents.size === 1 && this.isSingleTouchEnabled) {
|
|
2342
2273
|
this.executeOrbitAction(this.getFirstPoint(this._currentEvents));
|
|
2343
2274
|
}
|
|
2344
2275
|
}
|
|
@@ -2375,12 +2306,14 @@ class GestureManager extends OdBaseDragger {
|
|
|
2375
2306
|
this.subject.update();
|
|
2376
2307
|
}
|
|
2377
2308
|
executeEndAction(gestureAction) {
|
|
2378
|
-
if (gestureAction === GestureAction.Orbit)
|
|
2379
|
-
|
|
2309
|
+
if (gestureAction === GestureAction.Orbit)
|
|
2310
|
+
this._orbitAction.endAction();
|
|
2311
|
+
if (gestureAction === GestureAction.Pan)
|
|
2312
|
+
this._panAction.endAction();
|
|
2380
2313
|
OdBaseDragger.isGestureActive = false;
|
|
2381
2314
|
}
|
|
2382
2315
|
needIgnoreEvent(event) {
|
|
2383
|
-
return !this.subject.options.enableZoomWheel || !this.subject.options.enableGestures || !this.eventIsTouchEvent(event);
|
|
2316
|
+
return (!this.subject.options.enableZoomWheel || !this.subject.options.enableGestures || !this.eventIsTouchEvent(event));
|
|
2384
2317
|
}
|
|
2385
2318
|
eventIsTouchEvent(event) {
|
|
2386
2319
|
return event.pointerType === "touch" || event.pointerType === "";
|
|
@@ -2436,14 +2369,10 @@ class GestureManagerComponent {
|
|
|
2436
2369
|
}
|
|
2437
2370
|
|
|
2438
2371
|
const components = componentsRegistry("visualizejs");
|
|
2439
|
-
|
|
2440
|
-
components.registerComponent("
|
|
2441
|
-
|
|
2442
|
-
components.registerComponent("
|
|
2443
|
-
|
|
2444
|
-
components.registerComponent("ZoomWheelComponent", (viewer => new ZoomWheelComponent(viewer)));
|
|
2445
|
-
|
|
2446
|
-
components.registerComponent("GestureManagerComponent", (viewer => new GestureManagerComponent(viewer)));
|
|
2372
|
+
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
2373
|
+
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|
|
2374
|
+
components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComponent(viewer));
|
|
2375
|
+
components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
|
|
2447
2376
|
|
|
2448
2377
|
class FileLoader {
|
|
2449
2378
|
constructor() {
|
|
@@ -2465,10 +2394,12 @@ class FileLoader {
|
|
|
2465
2394
|
const request = new Request(file, {
|
|
2466
2395
|
headers: new Headers(this.requestHeader),
|
|
2467
2396
|
credentials: this.withCredentials ? "include" : "same-origin",
|
|
2468
|
-
signal: this.abortSignal
|
|
2397
|
+
signal: this.abortSignal,
|
|
2469
2398
|
});
|
|
2470
|
-
return fetch(request)
|
|
2471
|
-
|
|
2399
|
+
return fetch(request)
|
|
2400
|
+
.then((response) => {
|
|
2401
|
+
if (!response.ok)
|
|
2402
|
+
throw new Error(`Failed to fetch "${response.url}", status ${response.status}`);
|
|
2472
2403
|
const contentLength = response.headers.get("X-File-Size") || response.headers.get("Content-Length");
|
|
2473
2404
|
const total = parseInt(contentLength || "", 10) || 0;
|
|
2474
2405
|
const lengthComputable = total > 0;
|
|
@@ -2478,45 +2409,40 @@ class FileLoader {
|
|
|
2478
2409
|
let loaded = 0;
|
|
2479
2410
|
try {
|
|
2480
2411
|
while (true) {
|
|
2481
|
-
const {
|
|
2482
|
-
if (done)
|
|
2412
|
+
const { done, value } = await reader.read();
|
|
2413
|
+
if (done)
|
|
2414
|
+
break;
|
|
2483
2415
|
if (onProgress) {
|
|
2484
2416
|
loaded += value.byteLength;
|
|
2485
|
-
onProgress(new ProgressEvent("progress", {
|
|
2486
|
-
lengthComputable: lengthComputable,
|
|
2487
|
-
loaded: loaded,
|
|
2488
|
-
total: total
|
|
2489
|
-
}));
|
|
2417
|
+
onProgress(new ProgressEvent("progress", { lengthComputable, loaded, total }));
|
|
2490
2418
|
}
|
|
2491
2419
|
controller.enqueue(value);
|
|
2492
2420
|
}
|
|
2493
2421
|
controller.close();
|
|
2494
|
-
}
|
|
2422
|
+
}
|
|
2423
|
+
catch (e) {
|
|
2495
2424
|
controller.error(e);
|
|
2496
2425
|
}
|
|
2497
|
-
}
|
|
2426
|
+
},
|
|
2498
2427
|
});
|
|
2499
2428
|
return new Response(stream);
|
|
2500
|
-
})
|
|
2429
|
+
})
|
|
2430
|
+
.then((response) => response.arrayBuffer());
|
|
2501
2431
|
}
|
|
2502
2432
|
if (file instanceof globalThis.File) {
|
|
2503
|
-
return new Promise((
|
|
2504
|
-
const reader = new FileReader;
|
|
2433
|
+
return new Promise((resolve, reject) => {
|
|
2434
|
+
const reader = new FileReader();
|
|
2505
2435
|
reader.onload = () => resolve(reader.result);
|
|
2506
2436
|
reader.onerror = () => reject(reader.error);
|
|
2507
2437
|
reader.onprogress = onProgress;
|
|
2508
|
-
reader.readAsArrayBuffer(new Blob([
|
|
2509
|
-
})
|
|
2438
|
+
reader.readAsArrayBuffer(new Blob([file]));
|
|
2439
|
+
});
|
|
2510
2440
|
}
|
|
2511
2441
|
if (onProgress) {
|
|
2512
2442
|
const total = file.byteLength;
|
|
2513
2443
|
const lengthComputable = total > 0;
|
|
2514
2444
|
const loaded = total;
|
|
2515
|
-
onProgress(new ProgressEvent("progress", {
|
|
2516
|
-
lengthComputable: lengthComputable,
|
|
2517
|
-
loaded: loaded,
|
|
2518
|
-
total: total
|
|
2519
|
-
}));
|
|
2445
|
+
onProgress(new ProgressEvent("progress", { lengthComputable, loaded, total }));
|
|
2520
2446
|
}
|
|
2521
2447
|
return Promise.resolve(file);
|
|
2522
2448
|
}
|
|
@@ -2528,41 +2454,37 @@ class VSFFileLoader extends Loader {
|
|
|
2528
2454
|
this.viewer = viewer;
|
|
2529
2455
|
}
|
|
2530
2456
|
isSupport(file, format) {
|
|
2531
|
-
return (typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2457
|
+
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2458
|
+
/vsf$/i.test(format));
|
|
2532
2459
|
}
|
|
2533
2460
|
async load(file, format, params) {
|
|
2534
|
-
if (!this.viewer.visualizeJs)
|
|
2461
|
+
if (!this.viewer.visualizeJs)
|
|
2462
|
+
return this;
|
|
2535
2463
|
const visViewer = this.viewer.visViewer();
|
|
2536
|
-
const progress = event => {
|
|
2537
|
-
const {
|
|
2464
|
+
const progress = (event) => {
|
|
2465
|
+
const { lengthComputable, loaded, total } = event;
|
|
2538
2466
|
const progress = lengthComputable ? loaded / total : 1;
|
|
2539
|
-
this.viewer.emitEvent({
|
|
2540
|
-
type: "geometryprogress",
|
|
2541
|
-
data: progress,
|
|
2542
|
-
file: file
|
|
2543
|
-
});
|
|
2467
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file });
|
|
2544
2468
|
};
|
|
2545
|
-
const loader = new FileLoader;
|
|
2469
|
+
const loader = new FileLoader();
|
|
2546
2470
|
loader.setRequestHeader(params.requestHeader);
|
|
2547
2471
|
loader.setWithCredentials(params.withCredentials);
|
|
2548
2472
|
loader.setAbortSignal(this.abortController.signal);
|
|
2549
2473
|
const arrayBuffer = await loader.load(file, progress);
|
|
2550
2474
|
const data = new Uint8Array(arrayBuffer);
|
|
2551
|
-
if (!this.viewer.visualizeJs)
|
|
2475
|
+
if (!this.viewer.visualizeJs)
|
|
2476
|
+
return this;
|
|
2552
2477
|
try {
|
|
2553
2478
|
visViewer.parseFile(data);
|
|
2554
|
-
}
|
|
2479
|
+
}
|
|
2480
|
+
catch (error) {
|
|
2555
2481
|
console.error("VSF parse error.", error);
|
|
2556
2482
|
throw error;
|
|
2557
2483
|
}
|
|
2558
2484
|
this.viewer.syncOptions();
|
|
2559
2485
|
this.viewer.syncOverlay();
|
|
2560
2486
|
this.viewer.update(true);
|
|
2561
|
-
this.viewer.emitEvent({
|
|
2562
|
-
type: "databasechunk",
|
|
2563
|
-
data: data,
|
|
2564
|
-
file: file
|
|
2565
|
-
});
|
|
2487
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file });
|
|
2566
2488
|
return this;
|
|
2567
2489
|
}
|
|
2568
2490
|
}
|
|
@@ -2573,30 +2495,31 @@ class VSFCloudLoader extends Loader {
|
|
|
2573
2495
|
this.viewer = viewer;
|
|
2574
2496
|
}
|
|
2575
2497
|
isSupport(file, format) {
|
|
2576
|
-
return typeof file === "object" &&
|
|
2498
|
+
return (typeof file === "object" &&
|
|
2499
|
+
typeof file.database === "string" &&
|
|
2500
|
+
typeof file.downloadResource === "function" &&
|
|
2501
|
+
/.data$/i.test(file.database));
|
|
2577
2502
|
}
|
|
2578
2503
|
async load(model, format) {
|
|
2579
|
-
if (!this.viewer.visualizeJs)
|
|
2504
|
+
if (!this.viewer.visualizeJs)
|
|
2505
|
+
return this;
|
|
2580
2506
|
const visViewer = this.viewer.visViewer();
|
|
2581
|
-
const filesToDownload = [
|
|
2507
|
+
const filesToDownload = [model.database, ...model.geometry];
|
|
2582
2508
|
console.time("File load time");
|
|
2583
2509
|
for (let i = 0; i < filesToDownload.length; i++) {
|
|
2584
2510
|
const dataId = filesToDownload[i];
|
|
2585
|
-
const progress = progress => {
|
|
2511
|
+
const progress = (progress) => {
|
|
2586
2512
|
const data = (i + progress) / filesToDownload.length;
|
|
2587
|
-
this.viewer.emitEvent({
|
|
2588
|
-
type: "geometryprogress",
|
|
2589
|
-
data: data,
|
|
2590
|
-
file: model.file,
|
|
2591
|
-
model: model
|
|
2592
|
-
});
|
|
2513
|
+
this.viewer.emitEvent({ type: "geometryprogress", data, file: model.file, model });
|
|
2593
2514
|
};
|
|
2594
2515
|
const arrayBuffer = await model.downloadResource(dataId, progress, this.abortController.signal);
|
|
2595
2516
|
const data = new Uint8Array(arrayBuffer);
|
|
2596
|
-
if (!this.viewer.visualizeJs)
|
|
2517
|
+
if (!this.viewer.visualizeJs)
|
|
2518
|
+
return this;
|
|
2597
2519
|
try {
|
|
2598
2520
|
visViewer.parseStream(data);
|
|
2599
|
-
}
|
|
2521
|
+
}
|
|
2522
|
+
catch (error) {
|
|
2600
2523
|
console.error("VSF parse error.", error);
|
|
2601
2524
|
throw error;
|
|
2602
2525
|
}
|
|
@@ -2604,20 +2527,11 @@ class VSFCloudLoader extends Loader {
|
|
|
2604
2527
|
this.viewer.syncOptions();
|
|
2605
2528
|
this.viewer.syncOverlay();
|
|
2606
2529
|
this.viewer.update(true);
|
|
2607
|
-
this.viewer.emitEvent({
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
file: model.file,
|
|
2611
|
-
model: model
|
|
2612
|
-
});
|
|
2613
|
-
} else {
|
|
2530
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
|
|
2531
|
+
}
|
|
2532
|
+
else {
|
|
2614
2533
|
this.viewer.update();
|
|
2615
|
-
this.viewer.emitEvent({
|
|
2616
|
-
type: "geometrychunk",
|
|
2617
|
-
data: data,
|
|
2618
|
-
file: model.file,
|
|
2619
|
-
model: model
|
|
2620
|
-
});
|
|
2534
|
+
this.viewer.emitEvent({ type: "geometrychunk", data, file: model.file, model });
|
|
2621
2535
|
}
|
|
2622
2536
|
}
|
|
2623
2537
|
console.timeEnd("File load time");
|
|
@@ -2631,41 +2545,37 @@ class VSFXFileLoader extends Loader {
|
|
|
2631
2545
|
this.viewer = viewer;
|
|
2632
2546
|
}
|
|
2633
2547
|
isSupport(file, format) {
|
|
2634
|
-
return (typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2548
|
+
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2549
|
+
/vsfx$/i.test(format));
|
|
2635
2550
|
}
|
|
2636
2551
|
async load(file, format, params) {
|
|
2637
|
-
if (!this.viewer.visualizeJs)
|
|
2552
|
+
if (!this.viewer.visualizeJs)
|
|
2553
|
+
return this;
|
|
2638
2554
|
const visViewer = this.viewer.visViewer();
|
|
2639
|
-
const progress = event => {
|
|
2640
|
-
const {
|
|
2555
|
+
const progress = (event) => {
|
|
2556
|
+
const { lengthComputable, loaded, total } = event;
|
|
2641
2557
|
const progress = lengthComputable ? loaded / total : 1;
|
|
2642
|
-
this.viewer.emitEvent({
|
|
2643
|
-
type: "geometryprogress",
|
|
2644
|
-
data: progress,
|
|
2645
|
-
file: file
|
|
2646
|
-
});
|
|
2558
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file });
|
|
2647
2559
|
};
|
|
2648
|
-
const loader = new FileLoader;
|
|
2560
|
+
const loader = new FileLoader();
|
|
2649
2561
|
loader.setRequestHeader(params.requestHeader);
|
|
2650
2562
|
loader.setWithCredentials(params.withCredentials);
|
|
2651
2563
|
loader.setAbortSignal(this.abortController.signal);
|
|
2652
2564
|
const arrayBuffer = await loader.load(file, progress);
|
|
2653
2565
|
const data = new Uint8Array(arrayBuffer);
|
|
2654
|
-
if (!this.viewer.visualizeJs)
|
|
2566
|
+
if (!this.viewer.visualizeJs)
|
|
2567
|
+
return this;
|
|
2655
2568
|
try {
|
|
2656
2569
|
visViewer.parseVsfx(data);
|
|
2657
|
-
}
|
|
2570
|
+
}
|
|
2571
|
+
catch (error) {
|
|
2658
2572
|
console.error("VSFX parse error.", error);
|
|
2659
2573
|
throw error;
|
|
2660
2574
|
}
|
|
2661
2575
|
this.viewer.syncOptions();
|
|
2662
2576
|
this.viewer.syncOverlay();
|
|
2663
2577
|
this.viewer.update(true);
|
|
2664
|
-
this.viewer.emitEvent({
|
|
2665
|
-
type: "databasechunk",
|
|
2666
|
-
data: data,
|
|
2667
|
-
file: file
|
|
2668
|
-
});
|
|
2578
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file });
|
|
2669
2579
|
return this;
|
|
2670
2580
|
}
|
|
2671
2581
|
}
|
|
@@ -2676,55 +2586,48 @@ class VSFXCloudLoader extends Loader {
|
|
|
2676
2586
|
this.viewer = viewer;
|
|
2677
2587
|
}
|
|
2678
2588
|
isSupport(file) {
|
|
2679
|
-
return typeof file === "object" &&
|
|
2589
|
+
return (typeof file === "object" &&
|
|
2590
|
+
typeof file.database === "string" &&
|
|
2591
|
+
typeof file.downloadResource === "function" &&
|
|
2592
|
+
/.vsfx$/i.test(file.database) &&
|
|
2593
|
+
this.viewer.options.enableStreamingMode === false);
|
|
2680
2594
|
}
|
|
2681
2595
|
async load(model, format, params = {}) {
|
|
2682
|
-
if (!this.viewer.visualizeJs)
|
|
2596
|
+
if (!this.viewer.visualizeJs)
|
|
2597
|
+
return Promise.resolve(this);
|
|
2683
2598
|
const visViewer = this.viewer.visViewer();
|
|
2684
|
-
const progress = progress => {
|
|
2685
|
-
this.viewer.emitEvent({
|
|
2686
|
-
type: "geometryprogress",
|
|
2687
|
-
data: progress,
|
|
2688
|
-
file: model.file,
|
|
2689
|
-
model: model
|
|
2690
|
-
});
|
|
2599
|
+
const progress = (progress) => {
|
|
2600
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
2691
2601
|
};
|
|
2692
2602
|
console.time("File load time");
|
|
2693
2603
|
const arrayBuffer = await model.downloadResource(model.database, progress, this.abortController.signal);
|
|
2694
2604
|
const data = new Uint8Array(arrayBuffer);
|
|
2695
|
-
if (!this.viewer.visualizeJs)
|
|
2605
|
+
if (!this.viewer.visualizeJs)
|
|
2606
|
+
return this;
|
|
2696
2607
|
try {
|
|
2697
2608
|
visViewer.parseVsfx(data);
|
|
2698
|
-
}
|
|
2609
|
+
}
|
|
2610
|
+
catch (error) {
|
|
2699
2611
|
console.error("VSFX parse error.", error);
|
|
2700
2612
|
throw error;
|
|
2701
2613
|
}
|
|
2702
2614
|
this.viewer.syncOptions();
|
|
2703
2615
|
this.viewer.syncOverlay();
|
|
2704
2616
|
this.viewer.update(true);
|
|
2705
|
-
this.viewer.emitEvent({
|
|
2706
|
-
type: "databasechunk",
|
|
2707
|
-
data: data,
|
|
2708
|
-
file: model.file,
|
|
2709
|
-
model: model
|
|
2710
|
-
});
|
|
2617
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
|
|
2711
2618
|
console.timeEnd("File load time");
|
|
2712
2619
|
return this;
|
|
2713
2620
|
}
|
|
2714
2621
|
}
|
|
2715
2622
|
|
|
2716
|
-
const DELAY_TIME_MULTIPLEXER = 2;
|
|
2717
|
-
|
|
2718
|
-
const START_UPDATE_TIME = 1e3;
|
|
2719
|
-
|
|
2623
|
+
const DELAY_TIME_MULTIPLEXER = 2.0;
|
|
2624
|
+
const START_UPDATE_TIME = 1000;
|
|
2720
2625
|
var UpdateType;
|
|
2721
|
-
|
|
2722
|
-
(function(UpdateType) {
|
|
2626
|
+
(function (UpdateType) {
|
|
2723
2627
|
UpdateType[UpdateType["kDelay"] = 0] = "kDelay";
|
|
2724
2628
|
UpdateType[UpdateType["kNormal"] = 1] = "kNormal";
|
|
2725
2629
|
UpdateType[UpdateType["kForce"] = 2] = "kForce";
|
|
2726
2630
|
})(UpdateType || (UpdateType = {}));
|
|
2727
|
-
|
|
2728
2631
|
class UpdateController {
|
|
2729
2632
|
constructor() {
|
|
2730
2633
|
this.lastUpdate = 0;
|
|
@@ -2751,32 +2654,37 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2751
2654
|
this.viewer = viewer;
|
|
2752
2655
|
}
|
|
2753
2656
|
isSupport(file) {
|
|
2754
|
-
return typeof file === "object" &&
|
|
2657
|
+
return (typeof file === "object" &&
|
|
2658
|
+
typeof file.database === "string" &&
|
|
2659
|
+
typeof file.downloadResource === "function" &&
|
|
2660
|
+
/.vsfx$/i.test(file.database) &&
|
|
2661
|
+
this.viewer.options.enableStreamingMode === true &&
|
|
2662
|
+
this.viewer.options.enablePartialMode === false &&
|
|
2663
|
+
!/.rcs$/i.test(file.name));
|
|
2755
2664
|
}
|
|
2756
2665
|
async load(model) {
|
|
2757
|
-
if (!this.viewer.visualizeJs)
|
|
2666
|
+
if (!this.viewer.visualizeJs)
|
|
2667
|
+
return this;
|
|
2758
2668
|
const visLib = this.viewer.visLib();
|
|
2759
2669
|
const visViewer = this.viewer.visViewer();
|
|
2760
|
-
const updateController = new UpdateController;
|
|
2670
|
+
const updateController = new UpdateController();
|
|
2761
2671
|
updateController.initialize(this.viewer);
|
|
2762
2672
|
let isFireDatabaseChunk = false;
|
|
2763
2673
|
const chunkLoadHandler = (progress, chunk) => {
|
|
2764
|
-
if (!this.viewer.visualizeJs)
|
|
2674
|
+
if (!this.viewer.visualizeJs)
|
|
2675
|
+
return;
|
|
2765
2676
|
let status;
|
|
2766
2677
|
try {
|
|
2767
2678
|
status = visViewer.parseVsfx(chunk);
|
|
2768
|
-
}
|
|
2679
|
+
}
|
|
2680
|
+
catch (error) {
|
|
2769
2681
|
console.error("VSFX parse error.", error);
|
|
2770
2682
|
throw error;
|
|
2771
2683
|
}
|
|
2772
|
-
this.viewer.emitEvent({
|
|
2773
|
-
type: "geometryprogress",
|
|
2774
|
-
data: progress,
|
|
2775
|
-
file: model.file,
|
|
2776
|
-
model: model
|
|
2777
|
-
});
|
|
2684
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
2778
2685
|
let isDatabaseChunk = false;
|
|
2779
|
-
if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
|
|
2686
|
+
if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
|
|
2687
|
+
(status === visLib.DatabaseStreamStatus.Complete && !isFireDatabaseChunk)) {
|
|
2780
2688
|
isFireDatabaseChunk = true;
|
|
2781
2689
|
isDatabaseChunk = true;
|
|
2782
2690
|
}
|
|
@@ -2784,20 +2692,11 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2784
2692
|
this.viewer.syncOptions();
|
|
2785
2693
|
this.viewer.syncOverlay();
|
|
2786
2694
|
updateController.update(UpdateType.kForce);
|
|
2787
|
-
this.viewer.emitEvent({
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
file: model.file,
|
|
2791
|
-
model: model
|
|
2792
|
-
});
|
|
2793
|
-
} else {
|
|
2695
|
+
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
2696
|
+
}
|
|
2697
|
+
else {
|
|
2794
2698
|
updateController.update(UpdateType.kDelay);
|
|
2795
|
-
this.viewer.emitEvent({
|
|
2796
|
-
type: "geometrychunk",
|
|
2797
|
-
data: chunk,
|
|
2798
|
-
file: model.file,
|
|
2799
|
-
model: model
|
|
2800
|
-
});
|
|
2699
|
+
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
2801
2700
|
}
|
|
2802
2701
|
};
|
|
2803
2702
|
console.time("File load time");
|
|
@@ -2809,79 +2708,68 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2809
2708
|
}
|
|
2810
2709
|
|
|
2811
2710
|
const PENDING_REQUESTS_SIZE = 50;
|
|
2812
|
-
|
|
2813
2711
|
const PENDING_REQUESTS_TIMEOUT = 250;
|
|
2814
|
-
|
|
2815
2712
|
class VSFXCloudPartialLoader extends Loader {
|
|
2816
2713
|
constructor(viewer) {
|
|
2817
2714
|
super();
|
|
2818
2715
|
this.viewer = viewer;
|
|
2819
|
-
this.abortControllerForRequestMap = new Map;
|
|
2716
|
+
this.abortControllerForRequestMap = new Map();
|
|
2820
2717
|
}
|
|
2821
2718
|
isSupport(file) {
|
|
2822
|
-
return typeof file === "object" &&
|
|
2719
|
+
return (typeof file === "object" &&
|
|
2720
|
+
typeof file.database === "string" &&
|
|
2721
|
+
typeof file.downloadResource === "function" &&
|
|
2722
|
+
typeof file.downloadResourceRange === "function" &&
|
|
2723
|
+
/.vsfx$/i.test(file.database) &&
|
|
2724
|
+
(this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
|
|
2823
2725
|
}
|
|
2824
2726
|
async load(model, format) {
|
|
2825
|
-
if (!this.viewer.visualizeJs)
|
|
2727
|
+
if (!this.viewer.visualizeJs)
|
|
2728
|
+
return this;
|
|
2826
2729
|
const visViewer = this.viewer.visViewer();
|
|
2827
2730
|
let servicePartAborted = false;
|
|
2828
|
-
const pendingRequestsMap = new Map;
|
|
2731
|
+
const pendingRequestsMap = new Map();
|
|
2829
2732
|
let pendingRequestsTimerId = 0;
|
|
2830
2733
|
const pendingRequestsAbortHandler = () => clearTimeout(pendingRequestsTimerId);
|
|
2831
|
-
const pendingRequestsAbortController = new AbortController;
|
|
2734
|
+
const pendingRequestsAbortController = new AbortController();
|
|
2832
2735
|
this.abortControllerForRequestMap.set(0, pendingRequestsAbortController);
|
|
2833
|
-
const updateController = new UpdateController;
|
|
2736
|
+
const updateController = new UpdateController();
|
|
2834
2737
|
updateController.initialize(this.viewer);
|
|
2835
2738
|
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
2836
2739
|
const chunkLoadHandler = (progress, chunk, requestId = 0) => {
|
|
2837
|
-
if (!this.viewer.visualizeJs)
|
|
2740
|
+
if (!this.viewer.visualizeJs)
|
|
2741
|
+
return;
|
|
2838
2742
|
let isDatabaseChunk;
|
|
2839
2743
|
try {
|
|
2840
2744
|
isDatabaseChunk = visViewer.parseVsfxInPartialMode(requestId, chunk);
|
|
2841
|
-
}
|
|
2745
|
+
}
|
|
2746
|
+
catch (error) {
|
|
2842
2747
|
console.error("VSFX parse error.", error);
|
|
2843
2748
|
throw error;
|
|
2844
2749
|
}
|
|
2845
|
-
this.viewer.emitEvent({
|
|
2846
|
-
type: "geometryprogress",
|
|
2847
|
-
data: progress,
|
|
2848
|
-
file: model.file,
|
|
2849
|
-
model: model
|
|
2850
|
-
});
|
|
2750
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
2851
2751
|
if (isDatabaseChunk) {
|
|
2852
2752
|
this.viewer.syncOptions();
|
|
2853
2753
|
this.viewer.syncOverlay();
|
|
2854
2754
|
updateController.update(UpdateType.kForce);
|
|
2855
|
-
this.viewer.emitEvent({
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
file: model.file,
|
|
2859
|
-
model: model
|
|
2860
|
-
});
|
|
2861
|
-
} else {
|
|
2755
|
+
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
2756
|
+
}
|
|
2757
|
+
else {
|
|
2862
2758
|
updateController.update(UpdateType.kDelay);
|
|
2863
|
-
this.viewer.emitEvent({
|
|
2864
|
-
type: "geometrychunk",
|
|
2865
|
-
data: chunk,
|
|
2866
|
-
file: model.file,
|
|
2867
|
-
model: model
|
|
2868
|
-
});
|
|
2759
|
+
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
2869
2760
|
}
|
|
2870
2761
|
};
|
|
2871
2762
|
const downloadResourceRange = async (dataId, requestId, ranges) => {
|
|
2872
|
-
const abortCtrl = new AbortController;
|
|
2763
|
+
const abortCtrl = new AbortController();
|
|
2873
2764
|
this.abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
2874
2765
|
try {
|
|
2875
2766
|
await model.downloadResourceRange(dataId, requestId, ranges, chunkLoadHandler, abortCtrl.signal);
|
|
2876
|
-
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
});
|
|
2883
|
-
} finally {
|
|
2884
|
-
ranges.forEach((range => visViewer.onRequestResponseComplete(range.requestId)));
|
|
2767
|
+
}
|
|
2768
|
+
catch (error) {
|
|
2769
|
+
this.viewer.emitEvent({ type: "geometryerror", data: error, file: model.file, model });
|
|
2770
|
+
}
|
|
2771
|
+
finally {
|
|
2772
|
+
ranges.forEach((range) => visViewer.onRequestResponseComplete(range.requestId));
|
|
2885
2773
|
this.abortControllerForRequestMap.delete(requestId);
|
|
2886
2774
|
updateController.update(UpdateType.kNormal);
|
|
2887
2775
|
}
|
|
@@ -2891,16 +2779,16 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2891
2779
|
for (let i = 0; i < records.size(); i++) {
|
|
2892
2780
|
const record = records.get(i);
|
|
2893
2781
|
ranges.push({
|
|
2894
|
-
requestId
|
|
2782
|
+
requestId,
|
|
2895
2783
|
begin: Number(record.begin),
|
|
2896
|
-
end: Number(record.end) - 1
|
|
2784
|
+
end: Number(record.end) - 1,
|
|
2897
2785
|
});
|
|
2898
2786
|
record.delete();
|
|
2899
2787
|
}
|
|
2900
2788
|
return ranges;
|
|
2901
2789
|
};
|
|
2902
2790
|
const objectHandler = {
|
|
2903
|
-
onServicePartReceived: bHasIndex => {
|
|
2791
|
+
onServicePartReceived: (bHasIndex) => {
|
|
2904
2792
|
if (bHasIndex) {
|
|
2905
2793
|
servicePartAborted = true;
|
|
2906
2794
|
this.abortController.abort();
|
|
@@ -2913,13 +2801,14 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2913
2801
|
onFullLoaded: () => {
|
|
2914
2802
|
updateController.update(UpdateType.kNormal);
|
|
2915
2803
|
},
|
|
2916
|
-
onRequestResponseParsed: requestId => {
|
|
2804
|
+
onRequestResponseParsed: (requestId) => {
|
|
2917
2805
|
this.abortControllerForRequestMap.delete(requestId);
|
|
2918
2806
|
updateController.update(UpdateType.kNormal);
|
|
2919
2807
|
},
|
|
2920
|
-
onRequestAborted: requestId => {
|
|
2808
|
+
onRequestAborted: (requestId) => {
|
|
2921
2809
|
const abortCtrl = this.abortControllerForRequestMap.get(requestId);
|
|
2922
|
-
if (abortCtrl)
|
|
2810
|
+
if (abortCtrl)
|
|
2811
|
+
abortCtrl.abort();
|
|
2923
2812
|
},
|
|
2924
2813
|
onRequestResourceFile: (requestId, _, records) => {
|
|
2925
2814
|
const dataId = `${model.fileId}${model.file.type}`;
|
|
@@ -2932,10 +2821,7 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2932
2821
|
requestNumber = pendingRequest.number;
|
|
2933
2822
|
}
|
|
2934
2823
|
if (requestNumber <= 5) {
|
|
2935
|
-
pendingRequestsMap.set(dataId, {
|
|
2936
|
-
ranges: [],
|
|
2937
|
-
number: requestNumber + 1
|
|
2938
|
-
});
|
|
2824
|
+
pendingRequestsMap.set(dataId, { ranges: [], number: requestNumber + 1 });
|
|
2939
2825
|
downloadResourceRange(dataId, requestId, ranges);
|
|
2940
2826
|
return;
|
|
2941
2827
|
}
|
|
@@ -2945,68 +2831,53 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2945
2831
|
window.clearTimeout(pendingRequestsTimerId);
|
|
2946
2832
|
pendingRequestsTimerId = 0;
|
|
2947
2833
|
}
|
|
2948
|
-
pendingRequestsMap.set(dataId, {
|
|
2949
|
-
ranges: [],
|
|
2950
|
-
number: requestNumber + 1
|
|
2951
|
-
});
|
|
2834
|
+
pendingRequestsMap.set(dataId, { ranges: [], number: requestNumber + 1 });
|
|
2952
2835
|
downloadResourceRange(dataId, requestId, pendingRanges);
|
|
2953
2836
|
return;
|
|
2954
2837
|
}
|
|
2955
|
-
pendingRequestsMap.set(dataId, {
|
|
2956
|
-
ranges: pendingRanges,
|
|
2957
|
-
number: requestNumber + 1
|
|
2958
|
-
});
|
|
2838
|
+
pendingRequestsMap.set(dataId, { ranges: pendingRanges, number: requestNumber + 1 });
|
|
2959
2839
|
if (pendingRequestsTimerId === 0) {
|
|
2960
|
-
pendingRequestsTimerId = window.setTimeout((
|
|
2840
|
+
pendingRequestsTimerId = window.setTimeout(() => {
|
|
2961
2841
|
pendingRequestsAbortController.signal.removeEventListener("abort", pendingRequestsAbortHandler);
|
|
2962
2842
|
pendingRequestsTimerId = 0;
|
|
2963
|
-
pendingRequestsMap.forEach((
|
|
2843
|
+
pendingRequestsMap.forEach((request, dataId) => {
|
|
2964
2844
|
if (request.ranges.length > 0) {
|
|
2965
|
-
pendingRequestsMap.set(dataId, {
|
|
2966
|
-
ranges: [],
|
|
2967
|
-
number: request.number + 1
|
|
2968
|
-
});
|
|
2845
|
+
pendingRequestsMap.set(dataId, { ranges: [], number: request.number + 1 });
|
|
2969
2846
|
downloadResourceRange(dataId, requestId, request.ranges);
|
|
2970
2847
|
}
|
|
2971
|
-
})
|
|
2972
|
-
}
|
|
2973
|
-
pendingRequestsAbortController.signal.addEventListener("abort", pendingRequestsAbortHandler, {
|
|
2974
|
-
once: true
|
|
2975
|
-
});
|
|
2848
|
+
});
|
|
2849
|
+
}, PENDING_REQUESTS_TIMEOUT);
|
|
2850
|
+
pendingRequestsAbortController.signal.addEventListener("abort", pendingRequestsAbortHandler, { once: true });
|
|
2976
2851
|
}
|
|
2977
|
-
}
|
|
2852
|
+
},
|
|
2978
2853
|
};
|
|
2979
2854
|
visViewer.attachPartialResolver(objectHandler);
|
|
2980
2855
|
try {
|
|
2981
2856
|
await model.downloadResource(model.database, chunkLoadHandler, this.abortController.signal);
|
|
2982
|
-
}
|
|
2857
|
+
}
|
|
2858
|
+
catch (error) {
|
|
2983
2859
|
window.clearTimeout(pendingRequestsTimerId);
|
|
2984
|
-
if (!servicePartAborted)
|
|
2860
|
+
if (!servicePartAborted)
|
|
2861
|
+
throw error;
|
|
2985
2862
|
}
|
|
2986
2863
|
return this;
|
|
2987
2864
|
}
|
|
2988
2865
|
cancel() {
|
|
2989
2866
|
super.cancel();
|
|
2990
|
-
this.abortControllerForRequestMap.forEach((controller => controller.abort())
|
|
2867
|
+
this.abortControllerForRequestMap.forEach((controller) => controller.abort());
|
|
2991
2868
|
}
|
|
2992
2869
|
}
|
|
2993
2870
|
|
|
2994
2871
|
const loaders = loadersRegistry("visualizejs");
|
|
2995
|
-
|
|
2996
|
-
loaders.registerLoader("vsf-
|
|
2997
|
-
|
|
2998
|
-
loaders.registerLoader("
|
|
2999
|
-
|
|
3000
|
-
loaders.registerLoader("vsfx-
|
|
3001
|
-
|
|
3002
|
-
loaders.registerLoader("vsfx-cloud", (viewer => new VSFXCloudLoader(viewer)));
|
|
3003
|
-
|
|
3004
|
-
loaders.registerLoader("vsfx-cloud-streaming", (viewer => new VSFXCloudStreamingLoader(viewer)));
|
|
3005
|
-
|
|
3006
|
-
loaders.registerLoader("vsfx-cloud-partial", (viewer => new VSFXCloudPartialLoader(viewer)));
|
|
2872
|
+
loaders.registerLoader("vsf-file", (viewer) => new VSFFileLoader(viewer));
|
|
2873
|
+
loaders.registerLoader("vsf-cloud", (viewer) => new VSFCloudLoader(viewer));
|
|
2874
|
+
loaders.registerLoader("vsfx-file", (viewer) => new VSFXFileLoader(viewer));
|
|
2875
|
+
loaders.registerLoader("vsfx-cloud", (viewer) => new VSFXCloudLoader(viewer));
|
|
2876
|
+
loaders.registerLoader("vsfx-cloud-streaming", (viewer) => new VSFXCloudStreamingLoader(viewer));
|
|
2877
|
+
loaders.registerLoader("vsfx-cloud-partial", (viewer) => new VSFXCloudPartialLoader(viewer));
|
|
3007
2878
|
|
|
3008
2879
|
function loadScript(url, params = {}) {
|
|
3009
|
-
return new Promise((
|
|
2880
|
+
return new Promise((resolve, reject) => {
|
|
3010
2881
|
const script = document.createElement("script");
|
|
3011
2882
|
script.src = url;
|
|
3012
2883
|
script.async = true;
|
|
@@ -3017,40 +2888,38 @@ function loadScript(url, params = {}) {
|
|
|
3017
2888
|
reject(new Error(`GET ${url} failed to load script`));
|
|
3018
2889
|
};
|
|
3019
2890
|
document.body.appendChild(script);
|
|
3020
|
-
})
|
|
2891
|
+
});
|
|
3021
2892
|
}
|
|
3022
|
-
|
|
3023
2893
|
function loadVisuazlizeJsScript(url, params) {
|
|
3024
2894
|
if (window["getVisualizeLibInst"]) {
|
|
3025
2895
|
const script = window["getVisualizeLibInst"].script;
|
|
3026
2896
|
if (script) {
|
|
3027
|
-
if (script.src === url)
|
|
2897
|
+
if (script.src === url)
|
|
2898
|
+
return Promise.resolve(script);
|
|
3028
2899
|
script.remove();
|
|
3029
2900
|
}
|
|
3030
2901
|
delete window["getVisualizeLibInst"];
|
|
3031
2902
|
}
|
|
3032
2903
|
return loadScript(url, params);
|
|
3033
2904
|
}
|
|
3034
|
-
|
|
3035
2905
|
const loadVisualizeJs = async (url, onprogress, params = {}) => {
|
|
3036
2906
|
const script = await loadVisuazlizeJsScript(url, params);
|
|
3037
|
-
return await new Promise((
|
|
2907
|
+
return await new Promise((resolve, reject) => {
|
|
3038
2908
|
const options = {
|
|
3039
2909
|
urlMemFile: url + ".wasm",
|
|
3040
2910
|
TOTAL_MEMORY: 134217728,
|
|
3041
|
-
onprogress
|
|
2911
|
+
onprogress,
|
|
3042
2912
|
};
|
|
3043
2913
|
const instance = window["getVisualizeLibInst"](options);
|
|
3044
2914
|
instance.loadWasmError = reject;
|
|
3045
|
-
instance.postRun.push((
|
|
2915
|
+
instance.postRun.push(() => {
|
|
3046
2916
|
window["getVisualizeLibInst"].script = script;
|
|
3047
2917
|
resolve(instance);
|
|
3048
|
-
})
|
|
3049
|
-
})
|
|
2918
|
+
});
|
|
2919
|
+
});
|
|
3050
2920
|
};
|
|
3051
2921
|
|
|
3052
2922
|
const MARKUP_ENTITY_LINE = "$MarkupTempEntity_Line";
|
|
3053
|
-
|
|
3054
2923
|
class OdaLineDragger extends OdBaseDragger {
|
|
3055
2924
|
constructor(subject) {
|
|
3056
2925
|
super(subject);
|
|
@@ -3064,7 +2933,7 @@ class OdaLineDragger extends OdBaseDragger {
|
|
|
3064
2933
|
}
|
|
3065
2934
|
start(x, y) {
|
|
3066
2935
|
const point = this.getViewer().screenToWorld(x, y);
|
|
3067
|
-
this.drawPoints = [
|
|
2936
|
+
this.drawPoints = [point[0], point[1], point[2]];
|
|
3068
2937
|
}
|
|
3069
2938
|
drag(x, y) {
|
|
3070
2939
|
if (this.isDragging) {
|
|
@@ -3095,7 +2964,6 @@ class OdaLineDragger extends OdBaseDragger {
|
|
|
3095
2964
|
}
|
|
3096
2965
|
|
|
3097
2966
|
const MARKUP_ENTITY_TEXT = "$MarkupTempEntity_Text";
|
|
3098
|
-
|
|
3099
2967
|
class OdaTextDragger extends OdBaseDragger {
|
|
3100
2968
|
constructor(subject) {
|
|
3101
2969
|
super(subject);
|
|
@@ -3105,7 +2973,7 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3105
2973
|
dispose() {
|
|
3106
2974
|
var _a;
|
|
3107
2975
|
super.dispose();
|
|
3108
|
-
(_a = this.textRef) === null || _a ===
|
|
2976
|
+
(_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
3109
2977
|
this.textRef = null;
|
|
3110
2978
|
}
|
|
3111
2979
|
_finishInput() {
|
|
@@ -3113,7 +2981,7 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3113
2981
|
if (this.textRef && this.textRef.value.trimLeft()) {
|
|
3114
2982
|
this._updateFrame();
|
|
3115
2983
|
}
|
|
3116
|
-
(_a = this.textRef) === null || _a ===
|
|
2984
|
+
(_a = this.textRef) === null || _a === void 0 ? void 0 : _a.remove();
|
|
3117
2985
|
this.textRef = null;
|
|
3118
2986
|
}
|
|
3119
2987
|
start(x, y, absoluteX, absoluteY) {
|
|
@@ -3124,7 +2992,7 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3124
2992
|
this.textRef.style.display = "block";
|
|
3125
2993
|
this.textRef.style.top = absoluteY + "px";
|
|
3126
2994
|
this.textRef.style.left = absoluteX + "px";
|
|
3127
|
-
this.textRef.onkeypress = event => {
|
|
2995
|
+
this.textRef.onkeypress = (event) => {
|
|
3128
2996
|
if (event.key === "Enter") {
|
|
3129
2997
|
event.preventDefault();
|
|
3130
2998
|
this._finishInput();
|
|
@@ -3134,7 +3002,8 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3134
3002
|
this.press = true;
|
|
3135
3003
|
this.m_center = this.screenToWorld(x, y + this.TEXT_HEIGHT_ALIGN);
|
|
3136
3004
|
this.needInputText = true;
|
|
3137
|
-
}
|
|
3005
|
+
}
|
|
3006
|
+
else {
|
|
3138
3007
|
this._finishInput();
|
|
3139
3008
|
}
|
|
3140
3009
|
}
|
|
@@ -3146,18 +3015,18 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3146
3015
|
const target = this.toPoint(view.viewTarget);
|
|
3147
3016
|
const eyeToWorld = view.eyeToWorldMatrix;
|
|
3148
3017
|
const eyeDir = pos.sub(target).asVector();
|
|
3149
|
-
const xDir = this.toVector([
|
|
3018
|
+
const xDir = this.toVector([1.0, 0.0, 0.0]);
|
|
3150
3019
|
const direction = xDir.transformBy(eyeToWorld);
|
|
3151
3020
|
const mtrx = this.createMatrix3d();
|
|
3152
3021
|
mtrx.setToWorldToPlane(this.toGeVector(eyeDir));
|
|
3153
3022
|
direction.transformBy(mtrx);
|
|
3154
3023
|
const angel = -Math.atan2(-direction.y, direction.x);
|
|
3155
|
-
const textSize = .02;
|
|
3156
|
-
let textScale = 1;
|
|
3024
|
+
const textSize = 0.02;
|
|
3025
|
+
let textScale = 1.0;
|
|
3157
3026
|
const projMtrx = view.projectionMatrix;
|
|
3158
3027
|
const mtrxNumber = projMtrx.get(1, 1);
|
|
3159
|
-
const tol =
|
|
3160
|
-
if (!(mtrxNumber < tol && mtrxNumber > -
|
|
3028
|
+
const tol = 1.0e-6;
|
|
3029
|
+
if (!(mtrxNumber < tol && mtrxNumber > -tol)) {
|
|
3161
3030
|
textScale = 1 / mtrxNumber;
|
|
3162
3031
|
}
|
|
3163
3032
|
const geomData = entityPtr.appendText(this.toGePoint(this.m_center), this.textRef.value.trimLeft());
|
|
@@ -3173,11 +3042,7 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3173
3042
|
|
|
3174
3043
|
class VisualizeMarkup {
|
|
3175
3044
|
constructor() {
|
|
3176
|
-
this._markupColor = {
|
|
3177
|
-
r: 255,
|
|
3178
|
-
g: 0,
|
|
3179
|
-
b: 0
|
|
3180
|
-
};
|
|
3045
|
+
this._markupColor = { r: 255, g: 0, b: 0 };
|
|
3181
3046
|
this.lineWidth = 4;
|
|
3182
3047
|
this.fontSize = 34;
|
|
3183
3048
|
}
|
|
@@ -3186,10 +3051,11 @@ class VisualizeMarkup {
|
|
|
3186
3051
|
this._viewer.registerDragger("Line", OdaLineDragger);
|
|
3187
3052
|
this._viewer.registerDragger("Text", OdaTextDragger);
|
|
3188
3053
|
}
|
|
3189
|
-
dispose() {}
|
|
3190
|
-
syncOverlay() {}
|
|
3054
|
+
dispose() { }
|
|
3055
|
+
syncOverlay() { }
|
|
3191
3056
|
clearOverlay() {
|
|
3192
|
-
if (!this._viewer.visualizeJs)
|
|
3057
|
+
if (!this._viewer.visualizeJs)
|
|
3058
|
+
return;
|
|
3193
3059
|
const visViewer = this._viewer.visViewer();
|
|
3194
3060
|
const model = visViewer.getMarkupModel();
|
|
3195
3061
|
model.clearEntities();
|
|
@@ -3199,23 +3065,17 @@ class VisualizeMarkup {
|
|
|
3199
3065
|
return this._markupColor;
|
|
3200
3066
|
}
|
|
3201
3067
|
setMarkupColor(r, g, b) {
|
|
3202
|
-
const color = {
|
|
3203
|
-
r: r,
|
|
3204
|
-
g: g,
|
|
3205
|
-
b: b
|
|
3206
|
-
};
|
|
3068
|
+
const color = { r, g, b };
|
|
3207
3069
|
this._markupColor = color;
|
|
3208
|
-
this._viewer.emitEvent({
|
|
3209
|
-
type: "changemarkupcolor",
|
|
3210
|
-
data: color
|
|
3211
|
-
});
|
|
3070
|
+
this._viewer.emitEvent({ type: "changemarkupcolor", data: color });
|
|
3212
3071
|
}
|
|
3213
3072
|
colorizeAllMarkup(r = 255, g = 0, b = 0) {
|
|
3214
|
-
if (!this._viewer.visualizeJs)
|
|
3073
|
+
if (!this._viewer.visualizeJs)
|
|
3074
|
+
return;
|
|
3215
3075
|
const visViewer = this._viewer.visViewer();
|
|
3216
3076
|
const model = visViewer.getMarkupModel();
|
|
3217
3077
|
const itr = model.getEntitiesIterator();
|
|
3218
|
-
for (
|
|
3078
|
+
for (; !itr.done(); itr.step()) {
|
|
3219
3079
|
const entityId = itr.getEntity();
|
|
3220
3080
|
const entityPtr = entityId.openObject();
|
|
3221
3081
|
const entityName = entityPtr.getName();
|
|
@@ -3232,21 +3092,18 @@ class VisualizeMarkup {
|
|
|
3232
3092
|
}
|
|
3233
3093
|
setViewpoint(viewpoint) {
|
|
3234
3094
|
function getLogicalPoint3dAsArray(point3d) {
|
|
3235
|
-
return [
|
|
3095
|
+
return [point3d.x, point3d.y, point3d.z];
|
|
3236
3096
|
}
|
|
3237
3097
|
function getPoint3d(module, gePoint) {
|
|
3238
3098
|
return module.Point3d.createFromArray(gePoint);
|
|
3239
3099
|
}
|
|
3240
|
-
if (!this._viewer.visualizeJs)
|
|
3100
|
+
if (!this._viewer.visualizeJs)
|
|
3101
|
+
return;
|
|
3241
3102
|
const visLib = this._viewer.visLib();
|
|
3242
3103
|
const visViewer = this._viewer.visViewer();
|
|
3243
3104
|
const activeView = visViewer.activeView;
|
|
3244
3105
|
this._viewer.syncOverlay();
|
|
3245
|
-
const markupColor = viewpoint.custom_fields.markup_color || {
|
|
3246
|
-
r: 255,
|
|
3247
|
-
g: 0,
|
|
3248
|
-
b: 0
|
|
3249
|
-
};
|
|
3106
|
+
const markupColor = viewpoint.custom_fields.markup_color || { r: 255, g: 0, b: 0 };
|
|
3250
3107
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
3251
3108
|
if (viewpoint.lines) {
|
|
3252
3109
|
for (const line of viewpoint.lines) {
|
|
@@ -3281,22 +3138,20 @@ class VisualizeMarkup {
|
|
|
3281
3138
|
this._viewer.update();
|
|
3282
3139
|
}
|
|
3283
3140
|
getViewpoint(viewpoint) {
|
|
3284
|
-
if (!this._viewer.visualizeJs)
|
|
3141
|
+
if (!this._viewer.visualizeJs)
|
|
3142
|
+
return {};
|
|
3285
3143
|
function getLogicalPoint3dFromArray(array) {
|
|
3286
|
-
return {
|
|
3287
|
-
x: array[0],
|
|
3288
|
-
y: array[1],
|
|
3289
|
-
z: array[2]
|
|
3290
|
-
};
|
|
3144
|
+
return { x: array[0], y: array[1], z: array[2] };
|
|
3291
3145
|
}
|
|
3292
3146
|
const visLib = this._viewer.visLib();
|
|
3293
3147
|
const visViewer = this._viewer.visViewer();
|
|
3294
|
-
if (!viewpoint)
|
|
3148
|
+
if (!viewpoint)
|
|
3149
|
+
viewpoint = {};
|
|
3295
3150
|
viewpoint.lines = [];
|
|
3296
3151
|
viewpoint.texts = [];
|
|
3297
3152
|
const model = visViewer.getMarkupModel();
|
|
3298
3153
|
const itr = model.getEntitiesIterator();
|
|
3299
|
-
for (
|
|
3154
|
+
for (; !itr.done(); itr.step()) {
|
|
3300
3155
|
const entityId = itr.getEntity();
|
|
3301
3156
|
const entityPtr = entityId.openObject();
|
|
3302
3157
|
const entityName = entityPtr.getName();
|
|
@@ -3310,21 +3165,22 @@ class VisualizeMarkup {
|
|
|
3310
3165
|
const polylinePtr = geometryId.openAsPolyline();
|
|
3311
3166
|
const points = polylinePtr.getPoints();
|
|
3312
3167
|
const line = {
|
|
3313
|
-
points: []
|
|
3168
|
+
points: [],
|
|
3314
3169
|
};
|
|
3315
3170
|
for (const point of points) {
|
|
3316
3171
|
line.points.push(getLogicalPoint3dFromArray(point));
|
|
3317
3172
|
}
|
|
3318
3173
|
viewpoint.lines.push(line);
|
|
3319
3174
|
polylinePtr.delete();
|
|
3320
|
-
}
|
|
3175
|
+
}
|
|
3176
|
+
else if (entityName === MARKUP_ENTITY_TEXT) {
|
|
3321
3177
|
const textPtr = geometryId.openAsText();
|
|
3322
3178
|
const position = textPtr.getPosition();
|
|
3323
3179
|
const text = {
|
|
3324
3180
|
position: getLogicalPoint3dFromArray(position),
|
|
3325
3181
|
text: textPtr.getString(),
|
|
3326
3182
|
angle: textPtr.getRotation(),
|
|
3327
|
-
text_size: textPtr.getTextSize()
|
|
3183
|
+
text_size: textPtr.getTextSize(),
|
|
3328
3184
|
};
|
|
3329
3185
|
viewpoint.texts.push(text);
|
|
3330
3186
|
textPtr.delete();
|
|
@@ -3333,10 +3189,10 @@ class VisualizeMarkup {
|
|
|
3333
3189
|
}
|
|
3334
3190
|
itr.delete();
|
|
3335
3191
|
viewpoint.snapshot = {
|
|
3336
|
-
data: visLib.canvas.toDataURL("image/jpeg", .25)
|
|
3192
|
+
data: visLib.canvas.toDataURL("image/jpeg", 0.25),
|
|
3337
3193
|
};
|
|
3338
3194
|
viewpoint.custom_fields = {
|
|
3339
|
-
markup_color: this.getMarkupColor()
|
|
3195
|
+
markup_color: this.getMarkupColor(),
|
|
3340
3196
|
};
|
|
3341
3197
|
return viewpoint;
|
|
3342
3198
|
}
|
|
@@ -3352,33 +3208,29 @@ class VisualizeMarkup {
|
|
|
3352
3208
|
getSelectedObjects() {
|
|
3353
3209
|
return [];
|
|
3354
3210
|
}
|
|
3355
|
-
selectObjects(objects) {}
|
|
3356
|
-
clearSelected() {}
|
|
3211
|
+
selectObjects(objects) { }
|
|
3212
|
+
clearSelected() { }
|
|
3357
3213
|
}
|
|
3358
3214
|
|
|
3359
3215
|
class MarkupFactory {
|
|
3360
3216
|
static createMarkup(markupType = "Konva") {
|
|
3361
3217
|
let markup;
|
|
3362
3218
|
switch (markupType) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
default:
|
|
3372
|
-
throw new Error("Error during Markup initialization. Unknown Markup type.");
|
|
3219
|
+
case "Konva":
|
|
3220
|
+
markup = new Markup();
|
|
3221
|
+
break;
|
|
3222
|
+
case "Visualize":
|
|
3223
|
+
markup = new VisualizeMarkup();
|
|
3224
|
+
break;
|
|
3225
|
+
default:
|
|
3226
|
+
throw new Error("Error during Markup initialization. Unknown Markup type.");
|
|
3373
3227
|
}
|
|
3374
3228
|
return markup;
|
|
3375
3229
|
}
|
|
3376
3230
|
}
|
|
3377
3231
|
|
|
3378
3232
|
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
3379
|
-
|
|
3380
|
-
const isExist = value => value !== undefined && value !== null;
|
|
3381
|
-
|
|
3233
|
+
const isExist = (value) => value !== undefined && value !== null;
|
|
3382
3234
|
class Viewer extends EventEmitter2 {
|
|
3383
3235
|
constructor(client, params = {}) {
|
|
3384
3236
|
var _a;
|
|
@@ -3392,8 +3244,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3392
3244
|
this._components = [];
|
|
3393
3245
|
this._renderTime = 0;
|
|
3394
3246
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
3395
|
-
this.canvaseventlistener = event => this.emit(event);
|
|
3396
|
-
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !==
|
|
3247
|
+
this.canvaseventlistener = (event) => this.emit(event);
|
|
3248
|
+
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
3397
3249
|
this._renderNeeded = false;
|
|
3398
3250
|
this._isRunAsyncUpdate = false;
|
|
3399
3251
|
this.render = this.render.bind(this);
|
|
@@ -3415,7 +3267,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3415
3267
|
return this;
|
|
3416
3268
|
}
|
|
3417
3269
|
async initialize(canvas, onProgress) {
|
|
3418
|
-
this.addEventListener("optionschange", (event => this.syncOptions(event.data))
|
|
3270
|
+
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
3419
3271
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
3420
3272
|
const width = rect.width || 1;
|
|
3421
3273
|
const height = rect.height || 1;
|
|
@@ -3427,29 +3279,20 @@ class Viewer extends EventEmitter2 {
|
|
|
3427
3279
|
canvas.style.touchAction = "none";
|
|
3428
3280
|
this._visualizeTimestamp = Date.now();
|
|
3429
3281
|
const visualizeTimestamp = this._visualizeTimestamp;
|
|
3430
|
-
const visualizeJs = await loadVisualizeJs(this.visualizeJsUrl, (event => {
|
|
3431
|
-
const {
|
|
3432
|
-
if (onProgress)
|
|
3433
|
-
lengthComputable: true,
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
type: "initializeprogress",
|
|
3439
|
-
data: loaded / total,
|
|
3440
|
-
loaded: loaded,
|
|
3441
|
-
total: total
|
|
3442
|
-
});
|
|
3443
|
-
}), {
|
|
3444
|
-
crossOrigin: this._crossOrigin
|
|
3445
|
-
});
|
|
3446
|
-
if (visualizeTimestamp !== this._visualizeTimestamp) throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");
|
|
3282
|
+
const visualizeJs = await loadVisualizeJs(this.visualizeJsUrl, (event) => {
|
|
3283
|
+
const { loaded, total } = event;
|
|
3284
|
+
if (onProgress)
|
|
3285
|
+
onProgress(new ProgressEvent("progress", { lengthComputable: true, loaded, total }));
|
|
3286
|
+
this.emitEvent({ type: "initializeprogress", data: loaded / total, loaded, total });
|
|
3287
|
+
}, { crossOrigin: this._crossOrigin });
|
|
3288
|
+
if (visualizeTimestamp !== this._visualizeTimestamp)
|
|
3289
|
+
throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");
|
|
3447
3290
|
this._visualizeJs = visualizeJs;
|
|
3448
3291
|
this._visualizeJs.canvas = canvas;
|
|
3449
3292
|
this._viewer = visualizeJs.Viewer.create();
|
|
3450
3293
|
this._viewer.resize(0, canvas.width, canvas.height, 0);
|
|
3451
3294
|
this.canvas = canvas;
|
|
3452
|
-
this.canvasEvents.forEach((x => canvas.addEventListener(x, this.canvaseventlistener))
|
|
3295
|
+
this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
|
|
3453
3296
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
3454
3297
|
for (const name of components.getComponents().keys()) {
|
|
3455
3298
|
this._components.push(components.createComponent(name, this));
|
|
@@ -3458,27 +3301,24 @@ class Viewer extends EventEmitter2 {
|
|
|
3458
3301
|
this.syncOverlay();
|
|
3459
3302
|
this._renderTime = performance.now();
|
|
3460
3303
|
this.render(this._renderTime);
|
|
3461
|
-
this.emitEvent({
|
|
3462
|
-
type: "initialize"
|
|
3463
|
-
});
|
|
3304
|
+
this.emitEvent({ type: "initialize" });
|
|
3464
3305
|
return this;
|
|
3465
3306
|
}
|
|
3466
3307
|
dispose() {
|
|
3467
3308
|
this.cancel();
|
|
3468
3309
|
this.clear();
|
|
3469
|
-
this.emitEvent({
|
|
3470
|
-
type: "dispose"
|
|
3471
|
-
});
|
|
3310
|
+
this.emitEvent({ type: "dispose" });
|
|
3472
3311
|
this.removeAllListeners();
|
|
3473
3312
|
this.setActiveDragger();
|
|
3474
|
-
this._components.forEach((component => component.dispose())
|
|
3313
|
+
this._components.forEach((component) => component.dispose());
|
|
3475
3314
|
this._components = [];
|
|
3476
3315
|
this._markup.dispose();
|
|
3477
3316
|
if (this.canvas) {
|
|
3478
|
-
this.canvasEvents.forEach((x => this.canvas.removeEventListener(x, this.canvaseventlistener))
|
|
3317
|
+
this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
|
|
3479
3318
|
this.canvas = undefined;
|
|
3480
3319
|
}
|
|
3481
|
-
if (this._viewer)
|
|
3320
|
+
if (this._viewer)
|
|
3321
|
+
this._viewer.clear();
|
|
3482
3322
|
this._visualizeJs = undefined;
|
|
3483
3323
|
this._visualizeTimestamp = undefined;
|
|
3484
3324
|
this._viewer = undefined;
|
|
@@ -3488,7 +3328,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3488
3328
|
return !!this.visualizeJs;
|
|
3489
3329
|
}
|
|
3490
3330
|
setSize(width, height, updateStyle = true) {
|
|
3491
|
-
if (!this.visualizeJs)
|
|
3331
|
+
if (!this.visualizeJs)
|
|
3332
|
+
return;
|
|
3492
3333
|
this.canvas.width = Math.round(width * window.devicePixelRatio);
|
|
3493
3334
|
this.canvas.height = Math.round(height * window.devicePixelRatio);
|
|
3494
3335
|
if (updateStyle) {
|
|
@@ -3497,72 +3338,68 @@ class Viewer extends EventEmitter2 {
|
|
|
3497
3338
|
}
|
|
3498
3339
|
this._viewer.resize(0, this.canvas.width, this.canvas.height, 0);
|
|
3499
3340
|
this.update(true);
|
|
3500
|
-
this.emitEvent({
|
|
3501
|
-
type: "resize",
|
|
3502
|
-
width: width,
|
|
3503
|
-
height: height
|
|
3504
|
-
});
|
|
3341
|
+
this.emitEvent({ type: "resize", width, height });
|
|
3505
3342
|
}
|
|
3506
3343
|
render(time) {
|
|
3507
3344
|
var _a, _b;
|
|
3508
|
-
if (!this.visualizeJs)
|
|
3509
|
-
|
|
3345
|
+
if (!this.visualizeJs)
|
|
3346
|
+
return;
|
|
3347
|
+
if (this._isRunAsyncUpdate)
|
|
3348
|
+
return;
|
|
3510
3349
|
const renderNeeded = this.visViewer().isRunningAnimation() || this._renderNeeded;
|
|
3511
|
-
if (!renderNeeded)
|
|
3512
|
-
|
|
3513
|
-
|
|
3350
|
+
if (!renderNeeded)
|
|
3351
|
+
return;
|
|
3352
|
+
if (!time)
|
|
3353
|
+
time = performance.now();
|
|
3354
|
+
const deltaTime = (time - this._renderTime) / 1000;
|
|
3514
3355
|
this._renderTime = time;
|
|
3515
3356
|
this._renderNeeded = !this.visViewer().getActiveDevice().isValid();
|
|
3516
3357
|
this.visViewer().update();
|
|
3517
|
-
(_b = (_a = this._activeDragger) === null || _a ===
|
|
3518
|
-
this.emitEvent({
|
|
3519
|
-
type: "render",
|
|
3520
|
-
time: time,
|
|
3521
|
-
deltaTime: deltaTime
|
|
3522
|
-
});
|
|
3358
|
+
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3359
|
+
this.emitEvent({ type: "render", time, deltaTime });
|
|
3523
3360
|
}
|
|
3524
3361
|
resize() {
|
|
3525
3362
|
console.warn("Viewer.resize() has been deprecated since 26.9 and will be removed in a future release, use Viewer.setSize() instead.");
|
|
3526
|
-
if (!this.visualizeJs)
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3363
|
+
if (!this.visualizeJs)
|
|
3364
|
+
return this;
|
|
3365
|
+
if (!this.canvas.parentElement)
|
|
3366
|
+
return this;
|
|
3367
|
+
const { width, height } = this.canvas.parentElement.getBoundingClientRect();
|
|
3368
|
+
if (!width || !height)
|
|
3369
|
+
return this;
|
|
3530
3370
|
this.setSize(width, height);
|
|
3531
3371
|
return this;
|
|
3532
3372
|
}
|
|
3533
3373
|
update(force = false) {
|
|
3534
3374
|
if (this._enableAutoUpdate) {
|
|
3535
3375
|
this._renderNeeded = true;
|
|
3536
|
-
if (force)
|
|
3376
|
+
if (force)
|
|
3377
|
+
this.render();
|
|
3537
3378
|
}
|
|
3538
|
-
this.emitEvent({
|
|
3539
|
-
type: "update",
|
|
3540
|
-
data: force
|
|
3541
|
-
});
|
|
3379
|
+
this.emitEvent({ type: "update", data: force });
|
|
3542
3380
|
}
|
|
3543
3381
|
scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
|
|
3544
|
-
return new Promise((
|
|
3545
|
-
setTimeout((
|
|
3382
|
+
return new Promise((resolve, reject) => {
|
|
3383
|
+
setTimeout(() => {
|
|
3546
3384
|
var _a, _b, _c;
|
|
3547
3385
|
try {
|
|
3548
3386
|
if (this._enableAutoUpdate) {
|
|
3549
3387
|
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
3550
3388
|
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3551
3389
|
}
|
|
3552
|
-
this.emitEvent({
|
|
3553
|
-
type: "update",
|
|
3554
|
-
data: false
|
|
3555
|
-
});
|
|
3390
|
+
this.emitEvent({ type: "update", data: false });
|
|
3556
3391
|
resolve();
|
|
3557
|
-
}
|
|
3392
|
+
}
|
|
3393
|
+
catch (e) {
|
|
3558
3394
|
console.error(e);
|
|
3559
3395
|
reject();
|
|
3560
3396
|
}
|
|
3561
|
-
}
|
|
3562
|
-
})
|
|
3397
|
+
}, 0);
|
|
3398
|
+
});
|
|
3563
3399
|
}
|
|
3564
3400
|
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
3565
|
-
if (!this.visualizeJs)
|
|
3401
|
+
if (!this.visualizeJs)
|
|
3402
|
+
return;
|
|
3566
3403
|
this._isRunAsyncUpdate = true;
|
|
3567
3404
|
try {
|
|
3568
3405
|
const device = this.visViewer().getActiveDevice();
|
|
@@ -3570,9 +3407,11 @@ class Viewer extends EventEmitter2 {
|
|
|
3570
3407
|
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
3571
3408
|
}
|
|
3572
3409
|
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
3573
|
-
}
|
|
3410
|
+
}
|
|
3411
|
+
catch (e) {
|
|
3574
3412
|
console.error(e);
|
|
3575
|
-
}
|
|
3413
|
+
}
|
|
3414
|
+
finally {
|
|
3576
3415
|
this._isRunAsyncUpdate = false;
|
|
3577
3416
|
}
|
|
3578
3417
|
}
|
|
@@ -3586,18 +3425,21 @@ class Viewer extends EventEmitter2 {
|
|
|
3586
3425
|
return this._viewer;
|
|
3587
3426
|
}
|
|
3588
3427
|
syncOpenCloudVisualStyle() {
|
|
3589
|
-
if (!this.visualizeJs)
|
|
3428
|
+
if (!this.visualizeJs)
|
|
3429
|
+
return this;
|
|
3590
3430
|
const visLib = this.visLib();
|
|
3591
3431
|
const visViewer = this.visViewer();
|
|
3592
3432
|
const device = visViewer.getActiveDevice();
|
|
3593
|
-
if (device.isNull())
|
|
3433
|
+
if (device.isNull())
|
|
3434
|
+
return this;
|
|
3594
3435
|
const view = device.getActiveView();
|
|
3595
3436
|
view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
|
|
3596
3437
|
view.setDefaultLightingIntensity(1.25);
|
|
3597
3438
|
let visualStyleId;
|
|
3598
3439
|
try {
|
|
3599
3440
|
visualStyleId = visViewer.findVisualStyle("OpenCloud");
|
|
3600
|
-
}
|
|
3441
|
+
}
|
|
3442
|
+
catch {
|
|
3601
3443
|
visualStyleId = undefined;
|
|
3602
3444
|
}
|
|
3603
3445
|
if (!visualStyleId || visualStyleId.isNull()) {
|
|
@@ -3620,12 +3462,14 @@ class Viewer extends EventEmitter2 {
|
|
|
3620
3462
|
return this;
|
|
3621
3463
|
}
|
|
3622
3464
|
syncOptions(options = this.options) {
|
|
3623
|
-
if (!this.visualizeJs)
|
|
3465
|
+
if (!this.visualizeJs)
|
|
3466
|
+
return this;
|
|
3624
3467
|
this.syncOpenCloudVisualStyle();
|
|
3625
3468
|
const visLib = this.visLib();
|
|
3626
3469
|
const visViewer = this.visViewer();
|
|
3627
3470
|
const device = visViewer.getActiveDevice();
|
|
3628
|
-
if (device.isNull())
|
|
3471
|
+
if (device.isNull())
|
|
3472
|
+
return this;
|
|
3629
3473
|
if (options.showWCS !== visViewer.getEnableWCS()) {
|
|
3630
3474
|
visViewer.setEnableWCS(options.showWCS);
|
|
3631
3475
|
}
|
|
@@ -3640,7 +3484,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3640
3484
|
if (options.shadows !== visViewer.shadows) {
|
|
3641
3485
|
visViewer.shadows = options.shadows;
|
|
3642
3486
|
const canvas = visLib.canvas;
|
|
3643
|
-
device.invalidate([
|
|
3487
|
+
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
3644
3488
|
}
|
|
3645
3489
|
if (options.groundShadow !== visViewer.groundShadow) {
|
|
3646
3490
|
visViewer.groundShadow = options.groundShadow;
|
|
@@ -3672,11 +3516,12 @@ class Viewer extends EventEmitter2 {
|
|
|
3672
3516
|
return this;
|
|
3673
3517
|
}
|
|
3674
3518
|
syncHighlightingOptions(options = this.options) {
|
|
3675
|
-
if (!this.visualizeJs)
|
|
3519
|
+
if (!this.visualizeJs)
|
|
3520
|
+
return this;
|
|
3676
3521
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
3677
3522
|
const visLib = this.visLib();
|
|
3678
3523
|
const visViewer = this.visViewer();
|
|
3679
|
-
const {
|
|
3524
|
+
const { Entry, OdTvRGBColorDef } = visLib;
|
|
3680
3525
|
const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
|
|
3681
3526
|
const highlightStylePtr = highlightStyleId.openObject();
|
|
3682
3527
|
if (isExist(params.facesColor)) {
|
|
@@ -3705,20 +3550,20 @@ class Viewer extends EventEmitter2 {
|
|
|
3705
3550
|
const device = visViewer.getActiveDevice();
|
|
3706
3551
|
if (!device.isNull()) {
|
|
3707
3552
|
const canvas = visLib.canvas;
|
|
3708
|
-
device.invalidate([
|
|
3553
|
+
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
3709
3554
|
device.delete();
|
|
3710
3555
|
}
|
|
3711
3556
|
return this;
|
|
3712
3557
|
}
|
|
3713
3558
|
get draggers() {
|
|
3714
|
-
return [
|
|
3559
|
+
return [...draggers.getDraggers().keys()];
|
|
3715
3560
|
}
|
|
3716
3561
|
get components() {
|
|
3717
|
-
return [
|
|
3562
|
+
return [...components.getComponents().keys()];
|
|
3718
3563
|
}
|
|
3719
3564
|
registerDragger(name, dragger) {
|
|
3720
3565
|
console.warn("Viewer.registerDragger() has been deprecated since 25.12 and will be removed in a future release, use draggers('visualizejs').registerDragger() instead.");
|
|
3721
|
-
draggers.registerDragger(name, (viewer => new dragger(viewer))
|
|
3566
|
+
draggers.registerDragger(name, (viewer) => new dragger(viewer));
|
|
3722
3567
|
}
|
|
3723
3568
|
activeDragger() {
|
|
3724
3569
|
return this._activeDragger;
|
|
@@ -3736,18 +3581,17 @@ class Viewer extends EventEmitter2 {
|
|
|
3736
3581
|
newDragger = draggers.createDragger(name, this);
|
|
3737
3582
|
if (newDragger) {
|
|
3738
3583
|
this._activeDragger = newDragger;
|
|
3739
|
-
(_b = (_a = this._activeDragger).initialize) === null || _b ===
|
|
3584
|
+
(_b = (_a = this._activeDragger).initialize) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3740
3585
|
}
|
|
3741
3586
|
}
|
|
3742
3587
|
const canvas = this.canvas;
|
|
3743
3588
|
if (canvas) {
|
|
3744
|
-
if (oldDragger)
|
|
3745
|
-
|
|
3589
|
+
if (oldDragger)
|
|
3590
|
+
canvas.classList.remove(`oda-cursor-${oldDragger.name.toLowerCase()}`);
|
|
3591
|
+
if (newDragger)
|
|
3592
|
+
canvas.classList.add(`oda-cursor-${newDragger.name.toLowerCase()}`);
|
|
3746
3593
|
}
|
|
3747
|
-
this.emitEvent({
|
|
3748
|
-
type: "changeactivedragger",
|
|
3749
|
-
data: name
|
|
3750
|
-
});
|
|
3594
|
+
this.emitEvent({ type: "changeactivedragger", data: name });
|
|
3751
3595
|
this.update();
|
|
3752
3596
|
}
|
|
3753
3597
|
return this._activeDragger;
|
|
@@ -3760,10 +3604,11 @@ class Viewer extends EventEmitter2 {
|
|
|
3760
3604
|
}
|
|
3761
3605
|
}
|
|
3762
3606
|
getComponent(name) {
|
|
3763
|
-
return this._components.find((component => component.name === name)
|
|
3607
|
+
return this._components.find((component) => component.name === name);
|
|
3764
3608
|
}
|
|
3765
3609
|
clearSlices() {
|
|
3766
|
-
if (!this.visualizeJs)
|
|
3610
|
+
if (!this.visualizeJs)
|
|
3611
|
+
return;
|
|
3767
3612
|
const visViewer = this.visViewer();
|
|
3768
3613
|
const activeView = visViewer.activeView;
|
|
3769
3614
|
activeView.removeCuttingPlanes();
|
|
@@ -3771,12 +3616,14 @@ class Viewer extends EventEmitter2 {
|
|
|
3771
3616
|
this.update();
|
|
3772
3617
|
}
|
|
3773
3618
|
clearOverlay() {
|
|
3774
|
-
if (!this.visualizeJs)
|
|
3619
|
+
if (!this.visualizeJs)
|
|
3620
|
+
return;
|
|
3775
3621
|
this._markup.clearOverlay();
|
|
3776
3622
|
this.update();
|
|
3777
3623
|
}
|
|
3778
3624
|
syncOverlay() {
|
|
3779
|
-
if (!this.visualizeJs)
|
|
3625
|
+
if (!this.visualizeJs)
|
|
3626
|
+
return;
|
|
3780
3627
|
const visViewer = this.visViewer();
|
|
3781
3628
|
const activeView = visViewer.activeView;
|
|
3782
3629
|
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
@@ -3800,7 +3647,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3800
3647
|
this.update();
|
|
3801
3648
|
}
|
|
3802
3649
|
is3D() {
|
|
3803
|
-
if (!this.visualizeJs)
|
|
3650
|
+
if (!this.visualizeJs)
|
|
3651
|
+
return false;
|
|
3804
3652
|
const visViewer = this.visViewer();
|
|
3805
3653
|
const ext = visViewer.getActiveExtents();
|
|
3806
3654
|
const min = ext.min();
|
|
@@ -3809,49 +3657,36 @@ class Viewer extends EventEmitter2 {
|
|
|
3809
3657
|
return extHeight !== 0;
|
|
3810
3658
|
}
|
|
3811
3659
|
screenToWorld(position) {
|
|
3812
|
-
if (!this.visualizeJs)
|
|
3813
|
-
x: position.x,
|
|
3814
|
-
y: position.y,
|
|
3815
|
-
z: 0
|
|
3816
|
-
};
|
|
3660
|
+
if (!this.visualizeJs)
|
|
3661
|
+
return { x: position.x, y: position.y, z: 0 };
|
|
3817
3662
|
const activeView = this.visViewer().activeView;
|
|
3818
3663
|
const worldPoint = activeView.transformScreenToWorld(position.x * window.devicePixelRatio, position.y * window.devicePixelRatio);
|
|
3819
|
-
const result = {
|
|
3820
|
-
x: worldPoint[0],
|
|
3821
|
-
y: worldPoint[1],
|
|
3822
|
-
z: worldPoint[2]
|
|
3823
|
-
};
|
|
3664
|
+
const result = { x: worldPoint[0], y: worldPoint[1], z: worldPoint[2] };
|
|
3824
3665
|
activeView.delete();
|
|
3825
3666
|
return result;
|
|
3826
3667
|
}
|
|
3827
3668
|
worldToScreen(position) {
|
|
3828
|
-
if (!this.visualizeJs)
|
|
3829
|
-
x: position.x,
|
|
3830
|
-
y: position.y
|
|
3831
|
-
};
|
|
3669
|
+
if (!this.visualizeJs)
|
|
3670
|
+
return { x: position.x, y: position.y };
|
|
3832
3671
|
const activeView = this.visViewer().activeView;
|
|
3833
3672
|
const devicePoint = activeView.transformWorldToScreen(position.x, position.y, position.z);
|
|
3834
|
-
const result = {
|
|
3835
|
-
x: devicePoint[0] / window.devicePixelRatio,
|
|
3836
|
-
y: devicePoint[1] / window.devicePixelRatio
|
|
3837
|
-
};
|
|
3673
|
+
const result = { x: devicePoint[0] / window.devicePixelRatio, y: devicePoint[1] / window.devicePixelRatio };
|
|
3838
3674
|
activeView.delete();
|
|
3839
3675
|
return result;
|
|
3840
3676
|
}
|
|
3841
3677
|
getScale() {
|
|
3842
|
-
const result = {
|
|
3843
|
-
x: 1,
|
|
3844
|
-
y: 1,
|
|
3845
|
-
z: 1
|
|
3846
|
-
};
|
|
3678
|
+
const result = { x: 1.0, y: 1.0, z: 1.0 };
|
|
3847
3679
|
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
3848
|
-
const tolerance =
|
|
3680
|
+
const tolerance = 1.0e-6;
|
|
3849
3681
|
const x = projMatrix.get(0, 0);
|
|
3850
|
-
if (x > tolerance || x < -
|
|
3682
|
+
if (x > tolerance || x < -tolerance)
|
|
3683
|
+
result.x = 1 / x;
|
|
3851
3684
|
const y = projMatrix.get(1, 1);
|
|
3852
|
-
if (y > tolerance || y < -
|
|
3685
|
+
if (y > tolerance || y < -tolerance)
|
|
3686
|
+
result.y = 1 / y;
|
|
3853
3687
|
const z = projMatrix.get(2, 2);
|
|
3854
|
-
if (z > tolerance || z < -
|
|
3688
|
+
if (z > tolerance || z < -tolerance)
|
|
3689
|
+
result.z = 1 / z;
|
|
3855
3690
|
return result;
|
|
3856
3691
|
}
|
|
3857
3692
|
getSelected() {
|
|
@@ -3880,19 +3715,25 @@ class Viewer extends EventEmitter2 {
|
|
|
3880
3715
|
}
|
|
3881
3716
|
async loadReferences(model) {
|
|
3882
3717
|
var _a;
|
|
3883
|
-
if (!this.visualizeJs)
|
|
3884
|
-
|
|
3885
|
-
if (!
|
|
3886
|
-
|
|
3887
|
-
(
|
|
3718
|
+
if (!this.visualizeJs)
|
|
3719
|
+
return this;
|
|
3720
|
+
if (!this.client)
|
|
3721
|
+
return this;
|
|
3722
|
+
if (!model.getReferences)
|
|
3723
|
+
return this;
|
|
3724
|
+
const abortController = new AbortController();
|
|
3725
|
+
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
3888
3726
|
this._abortControllerForReferences = abortController;
|
|
3889
3727
|
let references = [];
|
|
3890
|
-
await model
|
|
3728
|
+
await model
|
|
3729
|
+
.getReferences(abortController.signal)
|
|
3730
|
+
.then((data) => (references = data.references))
|
|
3731
|
+
.catch((e) => console.error("Cannot load model references.", e));
|
|
3891
3732
|
for (const file of references) {
|
|
3892
|
-
await this.client
|
|
3893
|
-
|
|
3894
|
-
return (_a = this.visualizeJs) === null || _a ===
|
|
3895
|
-
|
|
3733
|
+
await this.client
|
|
3734
|
+
.downloadFile(file.id, undefined, abortController.signal)
|
|
3735
|
+
.then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
|
|
3736
|
+
.catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
|
|
3896
3737
|
}
|
|
3897
3738
|
return this;
|
|
3898
3739
|
}
|
|
@@ -3900,7 +3741,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3900
3741
|
this.executeCommand("applyModelTransform", model);
|
|
3901
3742
|
}
|
|
3902
3743
|
applySceneGraphSettings(options = this.options) {
|
|
3903
|
-
if (!this.visualizeJs)
|
|
3744
|
+
if (!this.visualizeJs)
|
|
3745
|
+
return;
|
|
3904
3746
|
const visLib = this.visLib();
|
|
3905
3747
|
const visViewer = this.visViewer();
|
|
3906
3748
|
const device = visViewer.getActiveDevice();
|
|
@@ -3911,48 +3753,39 @@ class Viewer extends EventEmitter2 {
|
|
|
3911
3753
|
this.update();
|
|
3912
3754
|
}
|
|
3913
3755
|
async open(file, params = {}) {
|
|
3914
|
-
if (!this.visualizeJs)
|
|
3756
|
+
if (!this.visualizeJs)
|
|
3757
|
+
return this;
|
|
3915
3758
|
this.cancel();
|
|
3916
3759
|
this.clear();
|
|
3917
|
-
this.emitEvent({
|
|
3918
|
-
type: "open",
|
|
3919
|
-
file: file
|
|
3920
|
-
});
|
|
3760
|
+
this.emitEvent({ type: "open", file });
|
|
3921
3761
|
let model = file;
|
|
3922
3762
|
if (model && typeof model.getModels === "function") {
|
|
3923
3763
|
const models = await model.getModels();
|
|
3924
|
-
model = models.find((model => model.default)
|
|
3764
|
+
model = models.find((model) => model.default) || models[0] || file;
|
|
3925
3765
|
}
|
|
3926
|
-
if (!model)
|
|
3766
|
+
if (!model)
|
|
3767
|
+
throw new Error(`Format not supported`);
|
|
3927
3768
|
let format = params.format;
|
|
3928
|
-
if (!format && typeof model.type === "string")
|
|
3929
|
-
|
|
3930
|
-
if (!format && file
|
|
3769
|
+
if (!format && typeof model.type === "string")
|
|
3770
|
+
format = model.type.split(".").pop();
|
|
3771
|
+
if (!format && typeof file === "string")
|
|
3772
|
+
format = file.split(".").pop();
|
|
3773
|
+
if (!format && file instanceof globalThis.File)
|
|
3774
|
+
format = file.name.split(".").pop();
|
|
3931
3775
|
const loader = loaders.createLoader(this, model, format);
|
|
3932
|
-
if (!loader)
|
|
3776
|
+
if (!loader)
|
|
3777
|
+
throw new Error(`Format not supported`);
|
|
3933
3778
|
this.loaders.push(loader);
|
|
3934
|
-
this.emitEvent({
|
|
3935
|
-
type: "geometrystart",
|
|
3936
|
-
file: file,
|
|
3937
|
-
model: model
|
|
3938
|
-
});
|
|
3779
|
+
this.emitEvent({ type: "geometrystart", file, model });
|
|
3939
3780
|
try {
|
|
3940
3781
|
await this.loadReferences(model);
|
|
3941
3782
|
await loader.load(model, format, params);
|
|
3942
|
-
}
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
data: error,
|
|
3946
|
-
file: file,
|
|
3947
|
-
model: model
|
|
3948
|
-
});
|
|
3783
|
+
}
|
|
3784
|
+
catch (error) {
|
|
3785
|
+
this.emitEvent({ type: "geometryerror", data: error, file, model });
|
|
3949
3786
|
throw error;
|
|
3950
3787
|
}
|
|
3951
|
-
this.emitEvent({
|
|
3952
|
-
type: "geometryend",
|
|
3953
|
-
file: file,
|
|
3954
|
-
model: model
|
|
3955
|
-
});
|
|
3788
|
+
this.emitEvent({ type: "geometryend", file, model });
|
|
3956
3789
|
if (this.visualizeJs) {
|
|
3957
3790
|
this.applyModelTransformMatrix(model);
|
|
3958
3791
|
this.applySceneGraphSettings();
|
|
@@ -3961,119 +3794,78 @@ class Viewer extends EventEmitter2 {
|
|
|
3961
3794
|
}
|
|
3962
3795
|
openVsfFile(buffer) {
|
|
3963
3796
|
console.warn("Viewer.openVsfFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
3964
|
-
if (!this.visualizeJs)
|
|
3797
|
+
if (!this.visualizeJs)
|
|
3798
|
+
return this;
|
|
3965
3799
|
this.cancel();
|
|
3966
3800
|
this.clear();
|
|
3967
|
-
this.emitEvent({
|
|
3968
|
-
type: "open",
|
|
3969
|
-
file: buffer
|
|
3970
|
-
});
|
|
3801
|
+
this.emitEvent({ type: "open", file: "", buffer });
|
|
3971
3802
|
const visViewer = this.visViewer();
|
|
3972
|
-
this.emitEvent({
|
|
3973
|
-
type: "geometrystart",
|
|
3974
|
-
file: buffer
|
|
3975
|
-
});
|
|
3803
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
3976
3804
|
try {
|
|
3977
3805
|
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
3978
3806
|
visViewer.parseFile(data);
|
|
3979
3807
|
this.syncOptions();
|
|
3980
3808
|
this.syncOverlay();
|
|
3981
3809
|
this.update(true);
|
|
3982
|
-
this.emitEvent({
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
});
|
|
3987
|
-
this.emitEvent({
|
|
3988
|
-
type: "databasechunk",
|
|
3989
|
-
data: data,
|
|
3990
|
-
file: buffer
|
|
3991
|
-
});
|
|
3992
|
-
} catch (error) {
|
|
3993
|
-
this.emitEvent({
|
|
3994
|
-
type: "geometryerror",
|
|
3995
|
-
data: error,
|
|
3996
|
-
file: buffer
|
|
3997
|
-
});
|
|
3810
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
3811
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
3812
|
+
}
|
|
3813
|
+
catch (error) {
|
|
3814
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
3998
3815
|
throw error;
|
|
3999
3816
|
}
|
|
4000
|
-
this.emitEvent({
|
|
4001
|
-
type: "geometryend",
|
|
4002
|
-
file: buffer
|
|
4003
|
-
});
|
|
3817
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4004
3818
|
return this;
|
|
4005
3819
|
}
|
|
4006
3820
|
openVsfxFile(buffer) {
|
|
4007
3821
|
console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
4008
|
-
if (!this.visualizeJs)
|
|
3822
|
+
if (!this.visualizeJs)
|
|
3823
|
+
return this;
|
|
4009
3824
|
this.cancel();
|
|
4010
3825
|
this.clear();
|
|
4011
|
-
this.emitEvent({
|
|
4012
|
-
type: "open",
|
|
4013
|
-
file: buffer
|
|
4014
|
-
});
|
|
3826
|
+
this.emitEvent({ type: "open", file: "", buffer });
|
|
4015
3827
|
const visViewer = this.visViewer();
|
|
4016
|
-
this.emitEvent({
|
|
4017
|
-
type: "geometrystart",
|
|
4018
|
-
file: buffer
|
|
4019
|
-
});
|
|
3828
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
4020
3829
|
try {
|
|
4021
3830
|
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
4022
3831
|
visViewer.parseVsfx(data);
|
|
4023
3832
|
this.syncOptions();
|
|
4024
3833
|
this.syncOverlay();
|
|
4025
3834
|
this.update(true);
|
|
4026
|
-
this.emitEvent({
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
});
|
|
4031
|
-
this.emitEvent({
|
|
4032
|
-
type: "databasechunk",
|
|
4033
|
-
data: data,
|
|
4034
|
-
file: buffer
|
|
4035
|
-
});
|
|
4036
|
-
} catch (error) {
|
|
4037
|
-
this.emitEvent({
|
|
4038
|
-
type: "geometryerror",
|
|
4039
|
-
data: error,
|
|
4040
|
-
file: buffer
|
|
4041
|
-
});
|
|
3835
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
3836
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
3837
|
+
}
|
|
3838
|
+
catch (error) {
|
|
3839
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4042
3840
|
throw error;
|
|
4043
3841
|
}
|
|
4044
|
-
this.emitEvent({
|
|
4045
|
-
type: "geometryend",
|
|
4046
|
-
file: buffer
|
|
4047
|
-
});
|
|
3842
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4048
3843
|
return this;
|
|
4049
3844
|
}
|
|
4050
3845
|
cancel() {
|
|
4051
3846
|
var _a;
|
|
4052
|
-
(_a = this._abortControllerForReferences) === null || _a ===
|
|
3847
|
+
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
4053
3848
|
this._abortControllerForReferences = undefined;
|
|
4054
|
-
this.loaders.forEach((loader => loader.cancel())
|
|
4055
|
-
this.emitEvent({
|
|
4056
|
-
type: "cancel"
|
|
4057
|
-
});
|
|
3849
|
+
this.loaders.forEach((loader) => loader.cancel());
|
|
3850
|
+
this.emitEvent({ type: "cancel" });
|
|
4058
3851
|
return this;
|
|
4059
3852
|
}
|
|
4060
3853
|
clear() {
|
|
4061
|
-
if (!this.visualizeJs)
|
|
3854
|
+
if (!this.visualizeJs)
|
|
3855
|
+
return this;
|
|
4062
3856
|
const visViewer = this.visViewer();
|
|
4063
3857
|
this.setActiveDragger();
|
|
4064
3858
|
this.clearSlices();
|
|
4065
3859
|
this.clearOverlay();
|
|
4066
3860
|
this.clearSelected();
|
|
4067
|
-
this.loaders.forEach((loader => loader.dispose())
|
|
3861
|
+
this.loaders.forEach((loader) => loader.dispose());
|
|
4068
3862
|
this.loaders = [];
|
|
4069
3863
|
visViewer.clear();
|
|
4070
3864
|
visViewer.createLocalDatabase();
|
|
4071
3865
|
this.syncOptions();
|
|
4072
3866
|
this.syncOverlay();
|
|
4073
3867
|
this.update(true);
|
|
4074
|
-
this.emitEvent({
|
|
4075
|
-
type: "clear"
|
|
4076
|
-
});
|
|
3868
|
+
this.emitEvent({ type: "clear" });
|
|
4077
3869
|
return this;
|
|
4078
3870
|
}
|
|
4079
3871
|
getMarkupColor() {
|
|
@@ -4092,7 +3884,8 @@ class Viewer extends EventEmitter2 {
|
|
|
4092
3884
|
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
4093
3885
|
}
|
|
4094
3886
|
addMarkupEntity(entityName) {
|
|
4095
|
-
if (!this.visualizeJs)
|
|
3887
|
+
if (!this.visualizeJs)
|
|
3888
|
+
return null;
|
|
4096
3889
|
this.syncOverlay();
|
|
4097
3890
|
const visViewer = this.visViewer();
|
|
4098
3891
|
const model = visViewer.getMarkupModel();
|
|
@@ -4107,8 +3900,9 @@ class Viewer extends EventEmitter2 {
|
|
|
4107
3900
|
}
|
|
4108
3901
|
drawViewpoint(viewpoint) {
|
|
4109
3902
|
var _a;
|
|
4110
|
-
if (!this.visualizeJs)
|
|
4111
|
-
|
|
3903
|
+
if (!this.visualizeJs)
|
|
3904
|
+
return;
|
|
3905
|
+
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
4112
3906
|
this.setActiveDragger();
|
|
4113
3907
|
this.clearSlices();
|
|
4114
3908
|
this.clearOverlay();
|
|
@@ -4120,35 +3914,26 @@ class Viewer extends EventEmitter2 {
|
|
|
4120
3914
|
this.setSelection(viewpoint.selection);
|
|
4121
3915
|
this._markup.setViewpoint(viewpoint);
|
|
4122
3916
|
this.setActiveDragger(draggerName);
|
|
4123
|
-
this.emitEvent({
|
|
4124
|
-
type: "drawviewpoint",
|
|
4125
|
-
data: viewpoint
|
|
4126
|
-
});
|
|
3917
|
+
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
4127
3918
|
this.update();
|
|
4128
3919
|
}
|
|
4129
3920
|
createViewpoint() {
|
|
4130
|
-
if (!this.visualizeJs)
|
|
3921
|
+
if (!this.visualizeJs)
|
|
3922
|
+
return {};
|
|
4131
3923
|
const viewpoint = {};
|
|
4132
3924
|
viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
|
|
4133
3925
|
viewpoint.clipping_planes = this.getClippingPlanes();
|
|
4134
3926
|
viewpoint.selection = this.getSelection();
|
|
4135
|
-
viewpoint.description =
|
|
3927
|
+
viewpoint.description = new Date().toDateString();
|
|
4136
3928
|
this._markup.getViewpoint(viewpoint);
|
|
4137
|
-
this.emitEvent({
|
|
4138
|
-
type: "createviewpoint",
|
|
4139
|
-
data: viewpoint
|
|
4140
|
-
});
|
|
3929
|
+
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
4141
3930
|
return viewpoint;
|
|
4142
3931
|
}
|
|
4143
3932
|
getPoint3dFromArray(array) {
|
|
4144
|
-
return {
|
|
4145
|
-
x: array[0],
|
|
4146
|
-
y: array[1],
|
|
4147
|
-
z: array[2]
|
|
4148
|
-
};
|
|
3933
|
+
return { x: array[0], y: array[1], z: array[2] };
|
|
4149
3934
|
}
|
|
4150
3935
|
getLogicalPoint3dAsArray(point3d) {
|
|
4151
|
-
return [
|
|
3936
|
+
return [point3d.x, point3d.y, point3d.z];
|
|
4152
3937
|
}
|
|
4153
3938
|
getOrthogonalCameraSettings() {
|
|
4154
3939
|
const visViewer = this.visViewer();
|
|
@@ -4159,7 +3944,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4159
3944
|
up_vector: this.getPoint3dFromArray(activeView.upVector),
|
|
4160
3945
|
field_width: activeView.viewFieldWidth,
|
|
4161
3946
|
field_height: activeView.viewFieldHeight,
|
|
4162
|
-
view_to_world_scale: 1
|
|
3947
|
+
view_to_world_scale: 1,
|
|
4163
3948
|
};
|
|
4164
3949
|
}
|
|
4165
3950
|
setOrthogonalCameraSettings(settings) {
|
|
@@ -4178,7 +3963,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4178
3963
|
const cuttingPlane = activeView.getCuttingPlane(i);
|
|
4179
3964
|
const clipping_plane = {
|
|
4180
3965
|
location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
|
|
4181
|
-
direction: this.getPoint3dFromArray(cuttingPlane.normal())
|
|
3966
|
+
direction: this.getPoint3dFromArray(cuttingPlane.normal()),
|
|
4182
3967
|
};
|
|
4183
3968
|
clipping_planes.push(clipping_plane);
|
|
4184
3969
|
}
|
|
@@ -4189,20 +3974,18 @@ class Viewer extends EventEmitter2 {
|
|
|
4189
3974
|
const visViewer = this.visViewer();
|
|
4190
3975
|
const activeView = visViewer.activeView;
|
|
4191
3976
|
for (const clipping_plane of clipping_planes) {
|
|
4192
|
-
const cuttingPlane = new (this.visLib().OdTvPlane);
|
|
3977
|
+
const cuttingPlane = new (this.visLib().OdTvPlane)();
|
|
4193
3978
|
cuttingPlane.set(this.getLogicalPoint3dAsArray(clipping_plane.location), this.getLogicalPoint3dAsArray(clipping_plane.direction));
|
|
4194
3979
|
activeView.addCuttingPlane(cuttingPlane);
|
|
4195
|
-
activeView.setEnableCuttingPlaneFill(true,
|
|
3980
|
+
activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
|
|
4196
3981
|
}
|
|
4197
3982
|
}
|
|
4198
3983
|
}
|
|
4199
3984
|
getSelection() {
|
|
4200
|
-
return this.getSelected().map((handle => ({
|
|
4201
|
-
handle: handle
|
|
4202
|
-
})));
|
|
3985
|
+
return this.getSelected().map((handle) => ({ handle }));
|
|
4203
3986
|
}
|
|
4204
3987
|
setSelection(selection) {
|
|
4205
|
-
this.setSelected(selection === null || selection ===
|
|
3988
|
+
this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
|
|
4206
3989
|
}
|
|
4207
3990
|
executeCommand(id, ...args) {
|
|
4208
3991
|
return commands.executeCommand(id, this, ...args);
|
|
@@ -4211,7 +3994,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4211
3994
|
const visViewer = this.visViewer();
|
|
4212
3995
|
const device = visViewer.getActiveDevice();
|
|
4213
3996
|
const coef = device.getOptionDouble(this.visLib().DeviceOptions.kRegenCoef);
|
|
4214
|
-
if (coef > 1) {
|
|
3997
|
+
if (coef > 1.0) {
|
|
4215
3998
|
visViewer.regenAll();
|
|
4216
3999
|
this.update();
|
|
4217
4000
|
}
|