@inweb/viewer-visualize 26.9.3 → 26.9.5
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 +997 -2723
- package/dist/viewer-visualize.js.map +1 -1
- package/dist/viewer-visualize.min.js +24 -1
- package/dist/viewer-visualize.module.js +1075 -1082
- package/dist/viewer-visualize.module.js.map +1 -1
- package/lib/Viewer/Draggers/OdaFlyDragger.d.ts +31 -0
- package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +2 -0
- package/package.json +5 -5
- package/src/Viewer/Draggers/OdaFlyDragger.ts +292 -0
- package/src/Viewer/Draggers/OdaWalkDragger.ts +27 -2
- package/src/Viewer/Draggers/index.ts +2 -0
|
@@ -1,16 +1,35 @@
|
|
|
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);
|
|
@@ -25,7 +44,7 @@ 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
49
|
(_a = view.delete) === null || _a === void 0 ? void 0 : _a.call(view);
|
|
31
50
|
return obj;
|
|
@@ -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
|
}
|
|
@@ -252,7 +259,7 @@ class OdBaseDragger extends OdaGeAction {
|
|
|
252
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,7 +596,7 @@ 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");
|
|
@@ -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;
|
|
@@ -728,16 +715,18 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
728
715
|
var _a;
|
|
729
716
|
const options = event.data;
|
|
730
717
|
const toUnitName = (_a = options.rulerUnit) !== null && _a !== void 0 ? _a : "Default";
|
|
731
|
-
if (this.oldRulerUnit === toUnitName)
|
|
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;
|
|
@@ -748,61 +737,52 @@ class MeasureLineDragger extends OdBaseDragger {
|
|
|
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$1 = 42.0;
|
|
776
|
+
const calcFocalLength$1 = (lensLength, fieldWidth, fieldHeight) => {
|
|
777
|
+
return (lensLength / FocalLengthConst$1) * 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();
|
|
@@ -864,37 +843,251 @@ 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
|
-
|
|
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;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
keyup(ev) {
|
|
873
|
+
this.keyPressMap.delete(ev.code);
|
|
874
|
+
if (this.keyPressMap.size < 1 && this.animationId) {
|
|
875
|
+
window.cancelAnimationFrame(this.animationId);
|
|
876
|
+
this.animationId = undefined;
|
|
877
|
+
this.lastFrameTS = 0;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
processMovement(timestamp) {
|
|
881
|
+
this.animationId = requestAnimationFrame(this.processMovement);
|
|
882
|
+
if (this.lastFrameTS !== 0) {
|
|
883
|
+
const deltaTS = timestamp - this.lastFrameTS;
|
|
884
|
+
const currentDelta = this.multiplier * deltaTS * this.speed;
|
|
885
|
+
for (const keyCode of this.keyPressMap) {
|
|
886
|
+
switch (keyCode) {
|
|
887
|
+
case "KeyW":
|
|
888
|
+
this.moveForward(currentDelta);
|
|
889
|
+
break;
|
|
890
|
+
case "KeyS":
|
|
891
|
+
this.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;
|
|
905
|
+
}
|
|
886
906
|
}
|
|
887
|
-
|
|
907
|
+
this.subject.update();
|
|
908
|
+
this.subject.emitEvent({ type: "changecamera" });
|
|
909
|
+
}
|
|
910
|
+
this.lastFrameTS = timestamp;
|
|
911
|
+
}
|
|
912
|
+
start(x, y) {
|
|
913
|
+
this.dragPosition = { x, y };
|
|
914
|
+
}
|
|
915
|
+
drag(x, y) {
|
|
916
|
+
if (this.cameraId && this.isDragging) {
|
|
917
|
+
const dltX = x - this.dragPosition.x;
|
|
918
|
+
const dltY = y - this.dragPosition.y;
|
|
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);
|
|
924
|
+
this.subject.update();
|
|
925
|
+
this.subject.emitEvent({ type: "changecamera" });
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
moveForward(currentDelta) {
|
|
929
|
+
const { Vector3d } = this.m_module;
|
|
930
|
+
const camera = this.cameraWalker.camera().openObjectAsCamera();
|
|
931
|
+
const target = Vector3d.createFromArray(camera.target());
|
|
932
|
+
const dir = Vector3d.createFromArray(camera.direction());
|
|
933
|
+
const up = Vector3d.createFromArray(camera.upVector());
|
|
934
|
+
const pos = Vector3d.createFromArray(camera.position());
|
|
935
|
+
let move = Vector3d.createFromArray([dir.x, dir.y, 0]);
|
|
936
|
+
if (Math.abs(dir.x) > 0.001 && Math.abs(dir.y) > 0.001) {
|
|
937
|
+
move.setToProduct(move.normalize(), currentDelta);
|
|
938
|
+
}
|
|
939
|
+
else {
|
|
940
|
+
move = Vector3d.createFromArray([0, currentDelta, 0]);
|
|
941
|
+
}
|
|
942
|
+
let newPos = pos.add(move);
|
|
943
|
+
let newTarget = target.add(move);
|
|
944
|
+
camera.setupCamera(newPos.toArray(), newTarget.toArray(), up.toArray());
|
|
945
|
+
}
|
|
946
|
+
moveBackward(currentDelta) {
|
|
947
|
+
this.moveForward(-currentDelta);
|
|
948
|
+
}
|
|
949
|
+
turnLeft(angle) {
|
|
950
|
+
const pCamera = this.cameraWalker.camera().openObjectAsCamera();
|
|
951
|
+
const dir = this.toVector(pCamera.direction());
|
|
952
|
+
const up = this.toVector(pCamera.upVector());
|
|
953
|
+
const pos = pCamera.position();
|
|
954
|
+
const rotMatrix = this.createMatrix3d();
|
|
955
|
+
const zAxisVector = [0, 0, 1];
|
|
956
|
+
rotMatrix.setToRotation(angle, zAxisVector, pos);
|
|
957
|
+
dir.transformBy(rotMatrix);
|
|
958
|
+
up.transformBy(rotMatrix);
|
|
959
|
+
pCamera.setupCameraByDirection(pos, dir.toArray(), up.toArray());
|
|
960
|
+
pCamera.delete();
|
|
961
|
+
}
|
|
962
|
+
setupCamera(view) {
|
|
963
|
+
const pCamera = this.cameraId.openObjectAsCamera();
|
|
964
|
+
const target = view.viewTarget;
|
|
965
|
+
pCamera.setDisplayGlyph(false);
|
|
966
|
+
pCamera.setDisplayTarget(false);
|
|
967
|
+
pCamera.setAutoAdjust(true);
|
|
968
|
+
pCamera.setupCamera(view.viewPosition, target, view.upVector);
|
|
969
|
+
pCamera.setNearClip(false, 1.0);
|
|
970
|
+
pCamera.setFarClip(false, 0);
|
|
971
|
+
pCamera.setViewParameters(view.viewFieldWidth, view.viewFieldHeight, true);
|
|
972
|
+
const focalL = calcFocalLength$1(view.lensLength, view.viewFieldWidth, view.viewFieldHeight);
|
|
973
|
+
const pTarget = this.toPoint(view.viewTarget);
|
|
974
|
+
const viewDir = this.toPoint(view.viewPosition);
|
|
975
|
+
const viewDirSub = viewDir.sub(pTarget);
|
|
976
|
+
const viewDirVec = viewDirSub.asVector();
|
|
977
|
+
const viewDirVecNormal = viewDirVec.normalize();
|
|
978
|
+
const geViewDir = this.toGeVector(viewDirVecNormal);
|
|
979
|
+
const newGeViewDir = [geViewDir[0] * focalL, geViewDir[1] * focalL, geViewDir[2] * focalL];
|
|
980
|
+
const pTarget2 = this.toPoint(view.viewTarget);
|
|
981
|
+
const newGeViewDirPt = this.toPoint(newGeViewDir);
|
|
982
|
+
const newPos = pTarget2.add(newGeViewDirPt);
|
|
983
|
+
pCamera.setupCamera(this.toGePoint(newPos), view.viewTarget, view.upVector);
|
|
984
|
+
this.deleteAll([pTarget, viewDir, viewDirSub, viewDirVec, viewDirVecNormal, pTarget2, newGeViewDirPt, newPos]);
|
|
985
|
+
pCamera.assignView(view);
|
|
986
|
+
pCamera.delete();
|
|
987
|
+
}
|
|
988
|
+
getMaxDimension(view) {
|
|
989
|
+
const [xmax, ymax, zmax] = view.sceneExtents.max();
|
|
990
|
+
const [xmin, ymin, zmin] = view.sceneExtents.min();
|
|
991
|
+
const volume = [xmax - xmin, ymax - ymin, zmax - zmin];
|
|
992
|
+
return Math.max(...volume);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
888
995
|
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
996
|
+
const FocalLengthConst = 42.0;
|
|
997
|
+
const calcFocalLength = (lensLength, fieldWidth, fieldHeight) => {
|
|
998
|
+
return (lensLength / FocalLengthConst) * Math.sqrt(fieldWidth * fieldWidth + fieldHeight * fieldHeight);
|
|
999
|
+
};
|
|
1000
|
+
class OdaFlyDragger extends OdBaseDragger {
|
|
1001
|
+
constructor(subject) {
|
|
1002
|
+
super(subject);
|
|
1003
|
+
this.viewer = undefined;
|
|
1004
|
+
this.multiplier = 5;
|
|
1005
|
+
this.speed = 1;
|
|
1006
|
+
this.keyPressMap = new Set();
|
|
1007
|
+
this.keydown = this.keydown.bind(this);
|
|
1008
|
+
this.keyup = this.keyup.bind(this);
|
|
1009
|
+
this.lastFrameTS = 0;
|
|
1010
|
+
this.animationId = undefined;
|
|
1011
|
+
this.processMovement = this.processMovement.bind(this);
|
|
1012
|
+
this.deltaAngle = Math.PI / 3600;
|
|
1013
|
+
this.autoSelect = true;
|
|
1014
|
+
}
|
|
1015
|
+
initialize() {
|
|
1016
|
+
super.initialize();
|
|
1017
|
+
this.viewer = this.getViewer();
|
|
1018
|
+
window.addEventListener("keydown", this.keydown, false);
|
|
1019
|
+
window.addEventListener("keyup", this.keyup, false);
|
|
1020
|
+
this.oldWCSEnableValue = this.viewer.getEnableWCS();
|
|
1021
|
+
this.viewer.setEnableWCS(false);
|
|
1022
|
+
const view = this.viewer.activeView;
|
|
1023
|
+
const maxDimension = this.getMaxDimension(view);
|
|
1024
|
+
this.speed = maxDimension / 30000;
|
|
1025
|
+
this.subject.emitEvent({ type: "flystart" });
|
|
1026
|
+
this.viewParams = this.getViewParams();
|
|
1027
|
+
this.setViewParams(this.viewParams);
|
|
1028
|
+
const model = this.viewer.getActiveModel();
|
|
1029
|
+
this.cameraId = model.appendCamera("Camera0");
|
|
1030
|
+
this.setupCamera(view);
|
|
1031
|
+
model.delete();
|
|
1032
|
+
this.cameraFlyer = new this.m_module.OdTvCameraWalker();
|
|
1033
|
+
this.cameraFlyer.setCamera(this.cameraId);
|
|
1034
|
+
this.subject.update();
|
|
1035
|
+
this.enableZoomWheelPreviousValue = this.subject.options.enableZoomWheel;
|
|
1036
|
+
this.subject.options.enableZoomWheel = false;
|
|
1037
|
+
}
|
|
1038
|
+
dispose() {
|
|
1039
|
+
var _a;
|
|
1040
|
+
this.oldWCSEnableValue =
|
|
1041
|
+
this.oldWCSEnableValue !== undefined ? this.oldWCSEnableValue : this.subject.options.showWCS;
|
|
1042
|
+
this.viewer.setEnableWCS(this.oldWCSEnableValue);
|
|
1043
|
+
super.dispose();
|
|
1044
|
+
this.keyPressMap.clear();
|
|
1045
|
+
window.removeEventListener("keydown", this.keydown);
|
|
1046
|
+
window.removeEventListener("keyup", this.keyup);
|
|
1047
|
+
if (this.animationId) {
|
|
1048
|
+
window.cancelAnimationFrame(this.animationId);
|
|
1049
|
+
this.animationId = undefined;
|
|
1050
|
+
}
|
|
1051
|
+
if (this.cameraId) {
|
|
1052
|
+
const model = this.viewer.getActiveModel();
|
|
1053
|
+
model.removeEntity(this.cameraId);
|
|
1054
|
+
model.delete();
|
|
1055
|
+
(_a = this.cameraFlyer) === null || _a === void 0 ? void 0 : _a.delete();
|
|
1056
|
+
}
|
|
1057
|
+
if (this.viewParams) {
|
|
1058
|
+
this.setViewParams(this.viewParams);
|
|
1059
|
+
const avp = this.viewer.activeView;
|
|
1060
|
+
avp.delete();
|
|
1061
|
+
}
|
|
1062
|
+
this.subject.update(true);
|
|
1063
|
+
this.subject.options.enableZoomWheel = this.enableZoomWheelPreviousValue;
|
|
1064
|
+
}
|
|
1065
|
+
keydown(ev) {
|
|
1066
|
+
switch (ev.code) {
|
|
1067
|
+
case "NumpadSubtract":
|
|
1068
|
+
case "Minus":
|
|
1069
|
+
if (this.multiplier > 1) {
|
|
1070
|
+
this.multiplier = this.multiplier - 1;
|
|
1071
|
+
this.subject.emitEvent({ type: "flyspeedchange", data: this.multiplier });
|
|
1072
|
+
}
|
|
1073
|
+
break;
|
|
1074
|
+
case "NumpadAdd":
|
|
1075
|
+
case "Equal":
|
|
1076
|
+
if (this.multiplier < 10) {
|
|
1077
|
+
this.multiplier = this.multiplier + 1;
|
|
1078
|
+
this.subject.emitEvent({ type: "flyspeedchange", data: this.multiplier });
|
|
1079
|
+
}
|
|
1080
|
+
break;
|
|
1081
|
+
case "KeyW":
|
|
1082
|
+
case "KeyA":
|
|
1083
|
+
case "KeyS":
|
|
1084
|
+
case "KeyD":
|
|
1085
|
+
case "KeyQ":
|
|
1086
|
+
case "KeyE":
|
|
1087
|
+
this.keyPressMap.add(ev.code);
|
|
1088
|
+
if (!this.animationId)
|
|
1089
|
+
this.processMovement(0);
|
|
1090
|
+
break;
|
|
898
1091
|
}
|
|
899
1092
|
}
|
|
900
1093
|
keyup(ev) {
|
|
@@ -912,67 +1105,54 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
912
1105
|
const currentDelta = this.multiplier * deltaTS * this.speed;
|
|
913
1106
|
for (const keyCode of this.keyPressMap) {
|
|
914
1107
|
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;
|
|
1108
|
+
case "KeyW":
|
|
1109
|
+
this.cameraFlyer.moveForward(currentDelta);
|
|
1110
|
+
break;
|
|
1111
|
+
case "KeyS":
|
|
1112
|
+
this.cameraFlyer.moveBackward(currentDelta);
|
|
1113
|
+
break;
|
|
1114
|
+
case "KeyA":
|
|
1115
|
+
this.cameraFlyer.moveLeft(currentDelta);
|
|
1116
|
+
break;
|
|
1117
|
+
case "KeyD":
|
|
1118
|
+
this.cameraFlyer.moveRight(currentDelta);
|
|
1119
|
+
break;
|
|
1120
|
+
case "KeyQ":
|
|
1121
|
+
this.cameraFlyer.moveUp(currentDelta);
|
|
1122
|
+
break;
|
|
1123
|
+
case "KeyE":
|
|
1124
|
+
this.cameraFlyer.moveDown(currentDelta);
|
|
1125
|
+
break;
|
|
938
1126
|
}
|
|
939
1127
|
}
|
|
940
1128
|
this.subject.update();
|
|
941
|
-
this.subject.emitEvent({
|
|
942
|
-
type: "changecamera"
|
|
943
|
-
});
|
|
1129
|
+
this.subject.emitEvent({ type: "changecamera" });
|
|
944
1130
|
}
|
|
945
1131
|
this.lastFrameTS = timestamp;
|
|
946
1132
|
}
|
|
947
1133
|
start(x, y) {
|
|
948
|
-
this.dragPosition = {
|
|
949
|
-
x: x,
|
|
950
|
-
y: y
|
|
951
|
-
};
|
|
1134
|
+
this.dragPosition = { x, y };
|
|
952
1135
|
}
|
|
953
1136
|
drag(x, y) {
|
|
954
1137
|
if (this.cameraId && this.isDragging) {
|
|
955
1138
|
const dltX = x - this.dragPosition.x;
|
|
956
1139
|
const dltY = y - this.dragPosition.y;
|
|
957
|
-
this.dragPosition = {
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
if (dltY !== 0) this.cameraWalker.turnDown(dltY * this.deltaAngle);
|
|
1140
|
+
this.dragPosition = { x, y };
|
|
1141
|
+
if (dltX !== 0.0)
|
|
1142
|
+
this.turnLeft(-dltX * this.deltaAngle);
|
|
1143
|
+
if (dltY !== 0.0)
|
|
1144
|
+
this.cameraFlyer.turnDown(dltY * this.deltaAngle);
|
|
963
1145
|
this.subject.update();
|
|
964
|
-
this.subject.emitEvent({
|
|
965
|
-
type: "changecamera"
|
|
966
|
-
});
|
|
1146
|
+
this.subject.emitEvent({ type: "changecamera" });
|
|
967
1147
|
}
|
|
968
1148
|
}
|
|
969
1149
|
turnLeft(angle) {
|
|
970
|
-
const pCamera = this.
|
|
1150
|
+
const pCamera = this.cameraFlyer.camera().openObjectAsCamera();
|
|
971
1151
|
const dir = this.toVector(pCamera.direction());
|
|
972
1152
|
const up = this.toVector(pCamera.upVector());
|
|
973
1153
|
const pos = pCamera.position();
|
|
974
1154
|
const rotMatrix = this.createMatrix3d();
|
|
975
|
-
const zAxisVector = [
|
|
1155
|
+
const zAxisVector = [0, 0, 1];
|
|
976
1156
|
rotMatrix.setToRotation(angle, zAxisVector, pos);
|
|
977
1157
|
dir.transformBy(rotMatrix);
|
|
978
1158
|
up.transformBy(rotMatrix);
|
|
@@ -986,7 +1166,7 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
986
1166
|
pCamera.setDisplayTarget(false);
|
|
987
1167
|
pCamera.setAutoAdjust(true);
|
|
988
1168
|
pCamera.setupCamera(view.viewPosition, target, view.upVector);
|
|
989
|
-
pCamera.setNearClip(false, 1);
|
|
1169
|
+
pCamera.setNearClip(false, 1.0);
|
|
990
1170
|
pCamera.setFarClip(false, 0);
|
|
991
1171
|
pCamera.setViewParameters(view.viewFieldWidth, view.viewFieldHeight, true);
|
|
992
1172
|
const focalL = calcFocalLength(view.lensLength, view.viewFieldWidth, view.viewFieldHeight);
|
|
@@ -996,19 +1176,19 @@ class OdaWalkDragger extends OdBaseDragger {
|
|
|
996
1176
|
const viewDirVec = viewDirSub.asVector();
|
|
997
1177
|
const viewDirVecNormal = viewDirVec.normalize();
|
|
998
1178
|
const geViewDir = this.toGeVector(viewDirVecNormal);
|
|
999
|
-
const newGeViewDir = [
|
|
1179
|
+
const newGeViewDir = [geViewDir[0] * focalL, geViewDir[1] * focalL, geViewDir[2] * focalL];
|
|
1000
1180
|
const pTarget2 = this.toPoint(view.viewTarget);
|
|
1001
1181
|
const newGeViewDirPt = this.toPoint(newGeViewDir);
|
|
1002
1182
|
const newPos = pTarget2.add(newGeViewDirPt);
|
|
1003
1183
|
pCamera.setupCamera(this.toGePoint(newPos), view.viewTarget, view.upVector);
|
|
1004
|
-
this.deleteAll([
|
|
1184
|
+
this.deleteAll([pTarget, viewDir, viewDirSub, viewDirVec, viewDirVecNormal, pTarget2, newGeViewDirPt, newPos]);
|
|
1005
1185
|
pCamera.assignView(view);
|
|
1006
1186
|
pCamera.delete();
|
|
1007
1187
|
}
|
|
1008
1188
|
getMaxDimension(view) {
|
|
1009
1189
|
const [xmax, ymax, zmax] = view.sceneExtents.max();
|
|
1010
1190
|
const [xmin, ymin, zmin] = view.sceneExtents.min();
|
|
1011
|
-
const volume = [
|
|
1191
|
+
const volume = [xmax - xmin, ymax - ymin, zmax - zmin];
|
|
1012
1192
|
return Math.max(...volume);
|
|
1013
1193
|
}
|
|
1014
1194
|
}
|
|
@@ -1030,25 +1210,25 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1030
1210
|
plane.set(this.toGePoint(this.m_center), this.m_normal);
|
|
1031
1211
|
avp.addCuttingPlane(plane);
|
|
1032
1212
|
this.index = avp.numCuttingPlanes() - 1;
|
|
1033
|
-
const {
|
|
1213
|
+
const { red, green, blue } = this.subject.options.cuttingPlaneFillColor;
|
|
1034
1214
|
avp.setEnableCuttingPlaneFill(true, red, green, blue);
|
|
1035
|
-
avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kHorizontalBars,
|
|
1215
|
+
avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kHorizontalBars, 0x0, 0x0, 0x0);
|
|
1036
1216
|
this.m_model = this.getModel();
|
|
1037
1217
|
this.createPreview();
|
|
1038
|
-
this.deleteAll([
|
|
1218
|
+
this.deleteAll([ext, avp, plane]);
|
|
1039
1219
|
}
|
|
1040
1220
|
dispose() {
|
|
1041
1221
|
super.dispose();
|
|
1042
1222
|
if (this.m_entity) {
|
|
1043
1223
|
this.m_model.removeEntity(this.m_entity);
|
|
1044
|
-
this.deleteAll([
|
|
1224
|
+
this.deleteAll([this.m_model, this.m_entity, this.planePreview, this.m_center]);
|
|
1045
1225
|
this.m_entity = null;
|
|
1046
1226
|
this.planePreview = null;
|
|
1047
1227
|
this.subject.update();
|
|
1048
1228
|
}
|
|
1049
1229
|
}
|
|
1050
1230
|
createNormal() {
|
|
1051
|
-
return [
|
|
1231
|
+
return [0, 0, 0];
|
|
1052
1232
|
}
|
|
1053
1233
|
handleDelta(delta) {
|
|
1054
1234
|
return delta;
|
|
@@ -1059,10 +1239,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1059
1239
|
start(x, y) {
|
|
1060
1240
|
this.press = true;
|
|
1061
1241
|
this.m_last = this.screenToWorld(x, y);
|
|
1062
|
-
this.m_click = {
|
|
1063
|
-
x: x,
|
|
1064
|
-
y: y
|
|
1065
|
-
};
|
|
1242
|
+
this.m_click = { x, y };
|
|
1066
1243
|
}
|
|
1067
1244
|
drag(x, y) {
|
|
1068
1245
|
if (this.press) {
|
|
@@ -1077,7 +1254,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1077
1254
|
const newPlane = plane.set(this.toGePoint(this.m_center), this.m_normal);
|
|
1078
1255
|
const newCutting = avp.updateCuttingPlane(this.index, plane);
|
|
1079
1256
|
this.drawPreview();
|
|
1080
|
-
this.deleteAll([
|
|
1257
|
+
this.deleteAll([avp, plane, oldCenter, delta, oldLast, newPlane, newCutting]);
|
|
1081
1258
|
const device = this.getViewer().getActiveDevice();
|
|
1082
1259
|
device.invalidate(device.getSize());
|
|
1083
1260
|
}
|
|
@@ -1085,12 +1262,12 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1085
1262
|
end(x, y) {
|
|
1086
1263
|
this.press = false;
|
|
1087
1264
|
if (x === this.m_click.x && y === this.m_click.y) {
|
|
1088
|
-
this.m_normal = [
|
|
1265
|
+
this.m_normal = [this.m_normal[0] * -1, this.m_normal[1] * -1, this.m_normal[2] * -1];
|
|
1089
1266
|
const avp = this.getViewer().activeView;
|
|
1090
1267
|
const plane = this.createPlane();
|
|
1091
1268
|
plane.set(this.toGePoint(this.m_center), this.m_normal);
|
|
1092
1269
|
avp.updateCuttingPlane(this.index, plane);
|
|
1093
|
-
this.deleteAll([
|
|
1270
|
+
this.deleteAll([avp, plane, this.m_last]);
|
|
1094
1271
|
const device = this.getViewer().getActiveDevice();
|
|
1095
1272
|
device.invalidate(device.getSize());
|
|
1096
1273
|
}
|
|
@@ -1098,70 +1275,109 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
|
|
|
1098
1275
|
createPreview() {
|
|
1099
1276
|
this.m_entity = this.m_model.appendEntity("&CuttingPlanePreview");
|
|
1100
1277
|
const GeometryTypes = this.m_module.GeometryTypes;
|
|
1101
|
-
const transparencyDef = new this.m_module.OdTvTransparencyDef;
|
|
1278
|
+
const transparencyDef = new this.m_module.OdTvTransparencyDef();
|
|
1102
1279
|
const colorDef = new this.m_module.OdTvColorDef(112, 112, 112);
|
|
1103
|
-
transparencyDef.setValue(.9);
|
|
1280
|
+
transparencyDef.setValue(0.9);
|
|
1104
1281
|
const entityPtr = this.m_entity.openObject();
|
|
1105
1282
|
entityPtr.setColor(colorDef, GeometryTypes.kFaces.value);
|
|
1106
1283
|
colorDef.setColor(112, 112, 112);
|
|
1107
1284
|
entityPtr.setColor(colorDef, GeometryTypes.kEdges.value);
|
|
1108
1285
|
entityPtr.setLineWeight(5);
|
|
1109
1286
|
entityPtr.setTransparency(transparencyDef, GeometryTypes.kFaces);
|
|
1110
|
-
transparencyDef.setValue(1);
|
|
1287
|
+
transparencyDef.setValue(1.0);
|
|
1111
1288
|
entityPtr.setTransparency(transparencyDef, GeometryTypes.kEdges);
|
|
1112
1289
|
this.planePreview = entityPtr.appendPolygon(this.getPlanePreviewCoordinate());
|
|
1113
1290
|
const polygonPtr = this.planePreview.openAsPolygon();
|
|
1114
1291
|
polygonPtr.setFilled(true);
|
|
1115
|
-
this.deleteAll([
|
|
1292
|
+
this.deleteAll([transparencyDef, colorDef, entityPtr, polygonPtr, GeometryTypes]);
|
|
1116
1293
|
this.subject.syncOverlay();
|
|
1117
1294
|
}
|
|
1118
1295
|
drawPreview() {
|
|
1119
1296
|
const polygonPtr = this.planePreview.openAsPolygon();
|
|
1120
1297
|
polygonPtr.setPoints(this.getPlanePreviewCoordinate());
|
|
1121
|
-
this.deleteAll([
|
|
1298
|
+
this.deleteAll([polygonPtr]);
|
|
1122
1299
|
this.subject.syncOverlay();
|
|
1123
1300
|
}
|
|
1124
1301
|
}
|
|
1125
1302
|
|
|
1126
1303
|
class OdCuttingPlaneXAxisDragger extends OdBaseCuttingPlaneDragger {
|
|
1127
1304
|
createNormal() {
|
|
1128
|
-
return [
|
|
1305
|
+
return [1, 0, 0];
|
|
1129
1306
|
}
|
|
1130
1307
|
handleDelta(delta) {
|
|
1131
|
-
delta.y = 0;
|
|
1132
|
-
delta.z = 0;
|
|
1308
|
+
delta.y = 0.0;
|
|
1309
|
+
delta.z = 0.0;
|
|
1133
1310
|
return delta;
|
|
1134
1311
|
}
|
|
1135
1312
|
getPlanePreviewCoordinate() {
|
|
1136
|
-
return [
|
|
1313
|
+
return [
|
|
1314
|
+
this.m_center.x,
|
|
1315
|
+
this.m_center.y - this.m_size_y,
|
|
1316
|
+
this.m_center.z - this.m_size_z,
|
|
1317
|
+
this.m_center.x,
|
|
1318
|
+
this.m_center.y + this.m_size_y,
|
|
1319
|
+
this.m_center.z - this.m_size_z,
|
|
1320
|
+
this.m_center.x,
|
|
1321
|
+
this.m_center.y + this.m_size_y,
|
|
1322
|
+
this.m_center.z + this.m_size_z,
|
|
1323
|
+
this.m_center.x,
|
|
1324
|
+
this.m_center.y - this.m_size_y,
|
|
1325
|
+
this.m_center.z + this.m_size_z,
|
|
1326
|
+
];
|
|
1137
1327
|
}
|
|
1138
1328
|
}
|
|
1139
1329
|
|
|
1140
1330
|
class OdCuttingPlaneYAxisDragger extends OdBaseCuttingPlaneDragger {
|
|
1141
1331
|
createNormal() {
|
|
1142
|
-
return [
|
|
1332
|
+
return [0, 1, 0];
|
|
1143
1333
|
}
|
|
1144
1334
|
handleDelta(delta) {
|
|
1145
|
-
delta.x = 0;
|
|
1146
|
-
delta.z = 0;
|
|
1335
|
+
delta.x = 0.0;
|
|
1336
|
+
delta.z = 0.0;
|
|
1147
1337
|
return delta;
|
|
1148
1338
|
}
|
|
1149
1339
|
getPlanePreviewCoordinate() {
|
|
1150
|
-
return [
|
|
1340
|
+
return [
|
|
1341
|
+
this.m_center.x - this.m_size_x,
|
|
1342
|
+
this.m_center.y,
|
|
1343
|
+
this.m_center.z - this.m_size_z,
|
|
1344
|
+
this.m_center.x + this.m_size_x,
|
|
1345
|
+
this.m_center.y,
|
|
1346
|
+
this.m_center.z - this.m_size_z,
|
|
1347
|
+
this.m_center.x + this.m_size_x,
|
|
1348
|
+
this.m_center.y,
|
|
1349
|
+
this.m_center.z + this.m_size_z,
|
|
1350
|
+
this.m_center.x - this.m_size_x,
|
|
1351
|
+
this.m_center.y,
|
|
1352
|
+
this.m_center.z + this.m_size_z,
|
|
1353
|
+
];
|
|
1151
1354
|
}
|
|
1152
1355
|
}
|
|
1153
1356
|
|
|
1154
1357
|
class OdCuttingPlaneZAxisDragger extends OdBaseCuttingPlaneDragger {
|
|
1155
1358
|
createNormal() {
|
|
1156
|
-
return [
|
|
1359
|
+
return [0, 0, 1];
|
|
1157
1360
|
}
|
|
1158
1361
|
handleDelta(delta) {
|
|
1159
|
-
delta.x = 0;
|
|
1160
|
-
delta.y = 0;
|
|
1362
|
+
delta.x = 0.0;
|
|
1363
|
+
delta.y = 0.0;
|
|
1161
1364
|
return delta;
|
|
1162
1365
|
}
|
|
1163
1366
|
getPlanePreviewCoordinate() {
|
|
1164
|
-
return [
|
|
1367
|
+
return [
|
|
1368
|
+
this.m_center.x - this.m_size_x,
|
|
1369
|
+
this.m_center.y - this.m_size_y,
|
|
1370
|
+
this.m_center.z,
|
|
1371
|
+
this.m_center.x + this.m_size_x,
|
|
1372
|
+
this.m_center.y - this.m_size_y,
|
|
1373
|
+
this.m_center.z,
|
|
1374
|
+
this.m_center.x + this.m_size_x,
|
|
1375
|
+
this.m_center.y + this.m_size_y,
|
|
1376
|
+
this.m_center.z,
|
|
1377
|
+
this.m_center.x - this.m_size_x,
|
|
1378
|
+
this.m_center.y + this.m_size_y,
|
|
1379
|
+
this.m_center.z,
|
|
1380
|
+
];
|
|
1165
1381
|
}
|
|
1166
1382
|
}
|
|
1167
1383
|
|
|
@@ -1174,10 +1390,7 @@ class OrbitAction {
|
|
|
1174
1390
|
}
|
|
1175
1391
|
beginAction(x, y) {
|
|
1176
1392
|
this.m_viewCenter = this.getCenter();
|
|
1177
|
-
this.m_startPoint = {
|
|
1178
|
-
x: x,
|
|
1179
|
-
y: y
|
|
1180
|
-
};
|
|
1393
|
+
this.m_startPoint = { x, y };
|
|
1181
1394
|
const view = this.getViewer().activeView;
|
|
1182
1395
|
view.delete();
|
|
1183
1396
|
this._beginInteractivity();
|
|
@@ -1187,8 +1400,8 @@ class OrbitAction {
|
|
|
1187
1400
|
const view = this.getViewer().activeView;
|
|
1188
1401
|
const corners = view.vportRect;
|
|
1189
1402
|
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;
|
|
1403
|
+
const distX = ((this.m_startPoint.x - x) * Math.PI) / size;
|
|
1404
|
+
const distY = ((this.m_startPoint.y - y) * Math.PI) / size;
|
|
1192
1405
|
this.m_startPoint.x = x;
|
|
1193
1406
|
this.m_startPoint.y = y;
|
|
1194
1407
|
const xOrbit = distY;
|
|
@@ -1199,14 +1412,14 @@ class OrbitAction {
|
|
|
1199
1412
|
upVector: view.upVector,
|
|
1200
1413
|
viewFieldWidth: view.viewFieldWidth,
|
|
1201
1414
|
viewFieldHeight: view.viewFieldHeight,
|
|
1202
|
-
perspective: view.perspective
|
|
1415
|
+
perspective: view.perspective,
|
|
1203
1416
|
};
|
|
1204
1417
|
view.delete();
|
|
1205
1418
|
const sideVector = this.getSideVector(viewParams);
|
|
1206
|
-
if (xOrbit !== 0) {
|
|
1419
|
+
if (xOrbit !== 0.0) {
|
|
1207
1420
|
this.calculateXOrbit(viewParams, -xOrbit, sideVector);
|
|
1208
1421
|
}
|
|
1209
|
-
if (yOrbit !== 0) {
|
|
1422
|
+
if (yOrbit !== 0.0) {
|
|
1210
1423
|
this.calculateYOrbit(viewParams, yOrbit, sideVector);
|
|
1211
1424
|
}
|
|
1212
1425
|
sideVector.delete();
|
|
@@ -1215,10 +1428,10 @@ class OrbitAction {
|
|
|
1215
1428
|
extView.delete();
|
|
1216
1429
|
(_b = (_a = this._subject.activeDragger()) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1217
1430
|
this._subject.emitEvent({
|
|
1218
|
-
type: "orbit"
|
|
1431
|
+
type: "orbit",
|
|
1219
1432
|
});
|
|
1220
1433
|
this._subject.emitEvent({
|
|
1221
|
-
type: "changecamera"
|
|
1434
|
+
type: "changecamera",
|
|
1222
1435
|
});
|
|
1223
1436
|
}
|
|
1224
1437
|
endAction() {
|
|
@@ -1232,7 +1445,7 @@ class OrbitAction {
|
|
|
1232
1445
|
const vDirect = direct.asVector();
|
|
1233
1446
|
const vCross = pUpV.crossProduct(vDirect);
|
|
1234
1447
|
const sideVector = vCross.normalize();
|
|
1235
|
-
this.deleteAll([
|
|
1448
|
+
this.deleteAll([direct, pUpV, pTarget, pPosition, vDirect, vCross]);
|
|
1236
1449
|
return sideVector;
|
|
1237
1450
|
}
|
|
1238
1451
|
calculateXOrbit(viewParams, delta, sideVector) {
|
|
@@ -1241,14 +1454,14 @@ class OrbitAction {
|
|
|
1241
1454
|
const pCenter = this.toPoint(this.m_viewCenter);
|
|
1242
1455
|
const rotatePoint = pPoint.rotateByBasePoint(delta, sideVector, pCenter);
|
|
1243
1456
|
viewParams.position = rotatePoint.toArray();
|
|
1244
|
-
this.deleteAll([
|
|
1457
|
+
this.deleteAll([pPoint, pCenter, rotatePoint]);
|
|
1245
1458
|
}
|
|
1246
1459
|
{
|
|
1247
1460
|
const pTarget = this.toPoint(viewParams.target);
|
|
1248
1461
|
const pCenter = this.toPoint(this.m_viewCenter);
|
|
1249
1462
|
const rotatePoint = pTarget.rotateByBasePoint(delta, sideVector, pCenter);
|
|
1250
1463
|
viewParams.target = rotatePoint.toArray();
|
|
1251
|
-
this.deleteAll([
|
|
1464
|
+
this.deleteAll([pTarget, pCenter, rotatePoint]);
|
|
1252
1465
|
}
|
|
1253
1466
|
{
|
|
1254
1467
|
const pPoint = this.toPoint(viewParams.position);
|
|
@@ -1259,7 +1472,7 @@ class OrbitAction {
|
|
|
1259
1472
|
const crossProduct = vUp.crossProduct(sideVector);
|
|
1260
1473
|
const crossProductNormal = crossProduct.normalize();
|
|
1261
1474
|
viewParams.upVector = crossProductNormal.toArray();
|
|
1262
|
-
this.deleteAll([
|
|
1475
|
+
this.deleteAll([pPoint, pTarget, pCenter, pUp, vUp, crossProduct, crossProductNormal]);
|
|
1263
1476
|
}
|
|
1264
1477
|
}
|
|
1265
1478
|
calculateYOrbit(viewParams, delta, sideVector) {
|
|
@@ -1269,7 +1482,7 @@ class OrbitAction {
|
|
|
1269
1482
|
const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
|
|
1270
1483
|
const rotatePoint = pPoint.rotateByBasePoint(delta, zAxis, pCenter);
|
|
1271
1484
|
viewParams.position = rotatePoint.toArray();
|
|
1272
|
-
this.deleteAll([
|
|
1485
|
+
this.deleteAll([zAxis, pPoint, pCenter, rotatePoint]);
|
|
1273
1486
|
}
|
|
1274
1487
|
{
|
|
1275
1488
|
const pTarget = this.toPoint(viewParams.target);
|
|
@@ -1277,7 +1490,7 @@ class OrbitAction {
|
|
|
1277
1490
|
const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
|
|
1278
1491
|
const rotatePoint = pTarget.rotateByBasePoint(delta, zAxis, pCenter);
|
|
1279
1492
|
viewParams.target = rotatePoint.toArray();
|
|
1280
|
-
this.deleteAll([
|
|
1493
|
+
this.deleteAll([zAxis, pTarget, pCenter, rotatePoint]);
|
|
1281
1494
|
}
|
|
1282
1495
|
{
|
|
1283
1496
|
const zAxis = this.toVector(this._m_module.Vector3d.kZAxis);
|
|
@@ -1289,7 +1502,7 @@ class OrbitAction {
|
|
|
1289
1502
|
const cross = vUp.crossProduct(side);
|
|
1290
1503
|
const crossNormal = cross.normalize();
|
|
1291
1504
|
viewParams.upVector = crossNormal.toArray();
|
|
1292
|
-
this.deleteAll([
|
|
1505
|
+
this.deleteAll([zAxis, pTarget, pPoint, side, pUp, vUp, cross, crossNormal]);
|
|
1293
1506
|
}
|
|
1294
1507
|
}
|
|
1295
1508
|
getCenter() {
|
|
@@ -1299,15 +1512,19 @@ class OrbitAction {
|
|
|
1299
1512
|
if (!pSet.isNull() && pSet.numItems() !== 0) {
|
|
1300
1513
|
const itr = pSet.getIterator();
|
|
1301
1514
|
let ext, entId, extSelected;
|
|
1302
|
-
for (
|
|
1515
|
+
for (; !itr.done(); itr.step()) {
|
|
1303
1516
|
entId = itr.getEntity();
|
|
1304
1517
|
ext = entId.getWCSExtents();
|
|
1305
|
-
if (extSelected)
|
|
1518
|
+
if (extSelected)
|
|
1519
|
+
extSelected.addExt(ext);
|
|
1520
|
+
else
|
|
1521
|
+
extSelected = ext;
|
|
1306
1522
|
}
|
|
1307
1523
|
center = extSelected.center();
|
|
1308
1524
|
extSelected.delete();
|
|
1309
1525
|
itr.delete();
|
|
1310
|
-
}
|
|
1526
|
+
}
|
|
1527
|
+
else {
|
|
1311
1528
|
center = viewer.getActiveExtents().center();
|
|
1312
1529
|
}
|
|
1313
1530
|
return center;
|
|
@@ -1367,15 +1584,12 @@ class PanAction {
|
|
|
1367
1584
|
}
|
|
1368
1585
|
beginAction(x, y, absoluteX, absoluteY) {
|
|
1369
1586
|
this._m_start = this.screenToWorld(x, y);
|
|
1370
|
-
this._deltaScreenPosition = {
|
|
1371
|
-
x: absoluteX,
|
|
1372
|
-
y: absoluteY
|
|
1373
|
-
};
|
|
1587
|
+
this._deltaScreenPosition = { x: absoluteX, y: absoluteY };
|
|
1374
1588
|
this._beginInteractivity();
|
|
1375
1589
|
}
|
|
1376
1590
|
action(x, y, absoluteX, absoluteY) {
|
|
1377
1591
|
var _a, _b;
|
|
1378
|
-
const {Vector3d
|
|
1592
|
+
const { Vector3d } = this._m_module;
|
|
1379
1593
|
const params = this._getViewParams();
|
|
1380
1594
|
const pt = this.screenToWorld(x, y);
|
|
1381
1595
|
const ptSub = this._m_start.sub(pt);
|
|
@@ -1397,15 +1611,12 @@ class PanAction {
|
|
|
1397
1611
|
x: absoluteX,
|
|
1398
1612
|
y: absoluteY,
|
|
1399
1613
|
dX: absoluteX - this._deltaScreenPosition.x,
|
|
1400
|
-
dY: absoluteY - this._deltaScreenPosition.y
|
|
1614
|
+
dY: absoluteY - this._deltaScreenPosition.y,
|
|
1401
1615
|
});
|
|
1402
1616
|
this._subject.emitEvent({
|
|
1403
|
-
type: "changecamera"
|
|
1617
|
+
type: "changecamera",
|
|
1404
1618
|
});
|
|
1405
|
-
this._deltaScreenPosition = {
|
|
1406
|
-
x: absoluteX,
|
|
1407
|
-
y: absoluteY
|
|
1408
|
-
};
|
|
1619
|
+
this._deltaScreenPosition = { x: absoluteX, y: absoluteY };
|
|
1409
1620
|
}
|
|
1410
1621
|
endAction() {
|
|
1411
1622
|
this._endInteractivity();
|
|
@@ -1452,10 +1663,10 @@ class ZoomAction {
|
|
|
1452
1663
|
type: "zoomat",
|
|
1453
1664
|
data: zoomFactor,
|
|
1454
1665
|
x: absoluteX,
|
|
1455
|
-
y: absoluteY
|
|
1666
|
+
y: absoluteY,
|
|
1456
1667
|
});
|
|
1457
1668
|
this._subject.emitEvent({
|
|
1458
|
-
type: "changecamera"
|
|
1669
|
+
type: "changecamera",
|
|
1459
1670
|
});
|
|
1460
1671
|
}
|
|
1461
1672
|
}
|
|
@@ -1479,8 +1690,8 @@ class OdZoomDragger extends OdBaseDragger {
|
|
|
1479
1690
|
drag(x, y) {
|
|
1480
1691
|
const dltY = y - this.prevY;
|
|
1481
1692
|
this.prevY = y;
|
|
1482
|
-
if (this.press && Math.abs(dltY) >=
|
|
1483
|
-
const ZOOM_SPEED = .975;
|
|
1693
|
+
if (this.press && Math.abs(dltY) >= 10e-6) {
|
|
1694
|
+
const ZOOM_SPEED = 0.975;
|
|
1484
1695
|
const zoomFactor = dltY > 0 ? 1 / ZOOM_SPEED : ZOOM_SPEED;
|
|
1485
1696
|
this._zoomAction.action(this.pressX, this.pressY, zoomFactor, this.absoluteX, this.absoluteY);
|
|
1486
1697
|
}
|
|
@@ -1492,11 +1703,10 @@ class OdZoomDragger extends OdBaseDragger {
|
|
|
1492
1703
|
}
|
|
1493
1704
|
|
|
1494
1705
|
const INTERACTIVITY_TIME_OUT = 100;
|
|
1495
|
-
|
|
1496
1706
|
class OdZoomWheelDragger extends OdBaseDragger {
|
|
1497
1707
|
constructor(subject) {
|
|
1498
1708
|
super(subject);
|
|
1499
|
-
this.canvasEvents = [
|
|
1709
|
+
this.canvasEvents = ["wheel"];
|
|
1500
1710
|
this._zoomAction = new ZoomAction(this.m_module, this.subject);
|
|
1501
1711
|
this._endInteractivityTimeOutId = undefined;
|
|
1502
1712
|
this._isEnableInteractivityMode = false;
|
|
@@ -1507,8 +1717,8 @@ class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
1507
1717
|
}
|
|
1508
1718
|
event = event || window.event;
|
|
1509
1719
|
event.preventDefault();
|
|
1510
|
-
const zoomIn = this.subject.options.reverseZoomWheel ? .925 : 1 / .925;
|
|
1511
|
-
const zoomOut = this.subject.options.reverseZoomWheel ? 1 / .925 : .925;
|
|
1720
|
+
const zoomIn = this.subject.options.reverseZoomWheel ? 0.925 : 1 / 0.925;
|
|
1721
|
+
const zoomOut = this.subject.options.reverseZoomWheel ? 1 / 0.925 : 0.925;
|
|
1512
1722
|
const viewer = this.getViewer();
|
|
1513
1723
|
if (viewer) {
|
|
1514
1724
|
const zoomFactor = event.deltaY > 0 ? zoomIn : zoomOut;
|
|
@@ -1546,12 +1756,12 @@ class OdZoomWheelDragger extends OdBaseDragger {
|
|
|
1546
1756
|
|
|
1547
1757
|
class OdSelectionFrame {
|
|
1548
1758
|
constructor() {
|
|
1549
|
-
this.m_start = [
|
|
1550
|
-
this.m_end = [
|
|
1759
|
+
this.m_start = [0, 0, 0];
|
|
1760
|
+
this.m_end = [0, 0, 0];
|
|
1551
1761
|
this.m_model = null;
|
|
1552
1762
|
}
|
|
1553
1763
|
createPoint3d() {
|
|
1554
|
-
return new this.m_module.Point3d;
|
|
1764
|
+
return new this.m_module.Point3d();
|
|
1555
1765
|
}
|
|
1556
1766
|
init(instance, model) {
|
|
1557
1767
|
this.m_module = instance;
|
|
@@ -1607,7 +1817,8 @@ class OdSelectionFrame {
|
|
|
1607
1817
|
entityPtr.setLineWeight(2);
|
|
1608
1818
|
this.m_frame = entityPtr.appendPolygon(this.toDoubleArray(points));
|
|
1609
1819
|
entityPtr.delete();
|
|
1610
|
-
}
|
|
1820
|
+
}
|
|
1821
|
+
else {
|
|
1611
1822
|
this.m_frame.openAsPolygon().setPoints(this.toDoubleArray(points));
|
|
1612
1823
|
}
|
|
1613
1824
|
}
|
|
@@ -1625,7 +1836,7 @@ class OdZoomWindowDragger extends OdBaseDragger {
|
|
|
1625
1836
|
this.autoSelect = true;
|
|
1626
1837
|
this.press = false;
|
|
1627
1838
|
this.needInputText = false;
|
|
1628
|
-
this.m_frame = new OdSelectionFrame;
|
|
1839
|
+
this.m_frame = new OdSelectionFrame();
|
|
1629
1840
|
this.m_frame.init(this.m_module, this.getModel());
|
|
1630
1841
|
}
|
|
1631
1842
|
start(x, y) {
|
|
@@ -1665,10 +1876,7 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1665
1876
|
start(x, y) {
|
|
1666
1877
|
this.press = true;
|
|
1667
1878
|
this.m_viewCenter = this.getCenter();
|
|
1668
|
-
this.m_startPoint = {
|
|
1669
|
-
x: x,
|
|
1670
|
-
y: y
|
|
1671
|
-
};
|
|
1879
|
+
this.m_startPoint = { x, y };
|
|
1672
1880
|
const view = this.getViewer().activeView;
|
|
1673
1881
|
this.startCameraParams = this.getViewParams();
|
|
1674
1882
|
const corners = view.vportRect;
|
|
@@ -1685,40 +1893,43 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1685
1893
|
dX *= Math.PI / this.m_delta;
|
|
1686
1894
|
dY *= Math.PI / this.m_delta;
|
|
1687
1895
|
this.setDefaultViewParams();
|
|
1688
|
-
const {
|
|
1896
|
+
const { Vector3d, Matrix3d } = this.m_module;
|
|
1689
1897
|
const target = Vector3d.createFromArray(this.startCameraParams.target);
|
|
1690
1898
|
const offset = Vector3d.createFromArray(this.startCameraParams.position).sub(target);
|
|
1691
1899
|
const dir = offset.normalize();
|
|
1692
|
-
const zMatrix = new Matrix3d;
|
|
1900
|
+
const zMatrix = new Matrix3d();
|
|
1693
1901
|
zMatrix.setToIdentity();
|
|
1694
|
-
const xMatrix = new Matrix3d;
|
|
1902
|
+
const xMatrix = new Matrix3d();
|
|
1695
1903
|
xMatrix.setToIdentity();
|
|
1696
|
-
const yAxis = Vector3d.createFromArray([
|
|
1904
|
+
const yAxis = Vector3d.createFromArray([dir.x, dir.y, dir.z]);
|
|
1697
1905
|
const zAxis = Vector3d.createFromArray(this.startCameraParams.upVector);
|
|
1698
1906
|
const xAxis = yAxis.crossProduct(zAxis);
|
|
1699
|
-
let xyDir = Vector3d.createFromArray([
|
|
1700
|
-
if (xyDir.length() <=
|
|
1907
|
+
let xyDir = Vector3d.createFromArray([yAxis.x, yAxis.y, 0]);
|
|
1908
|
+
if (xyDir.length() <= 0.00001) {
|
|
1701
1909
|
xyDir.set(-xAxis.y, xAxis.x, 0);
|
|
1702
|
-
}
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1703
1912
|
xyDir = xyDir.normalize();
|
|
1704
1913
|
}
|
|
1705
|
-
const xyAngle = Math.sign(xyDir.dotProduct(Vector3d.createFromArray([
|
|
1914
|
+
const xyAngle = Math.sign(xyDir.dotProduct(Vector3d.createFromArray([-1, 0, 0]))) *
|
|
1915
|
+
xyDir.angleTo(Vector3d.createFromArray([0, 1, 0]));
|
|
1706
1916
|
dX -= xyAngle;
|
|
1707
|
-
let yzDir = Vector3d.createFromArray([
|
|
1917
|
+
let yzDir = Vector3d.createFromArray([dir.x, dir.y, 0]);
|
|
1708
1918
|
let yzAngle = 0;
|
|
1709
|
-
if (yzDir.length() <=
|
|
1710
|
-
yzAngle = -dir.z * Math.PI / 2;
|
|
1711
|
-
}
|
|
1919
|
+
if (yzDir.length() <= 0.00001) {
|
|
1920
|
+
yzAngle = (-dir.z * Math.PI) / 2;
|
|
1921
|
+
}
|
|
1922
|
+
else {
|
|
1712
1923
|
yzDir = yzDir.normalize();
|
|
1713
1924
|
yzAngle = -yzDir.angleTo(dir);
|
|
1714
1925
|
}
|
|
1715
1926
|
dY -= yzAngle;
|
|
1716
|
-
zMatrix.setToRotation(-dX, [
|
|
1927
|
+
zMatrix.setToRotation(-dX, [0, 0, 1], [0, 0, 0]);
|
|
1717
1928
|
const xAngle = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, dY));
|
|
1718
|
-
xMatrix.setToRotation(xAngle, [
|
|
1929
|
+
xMatrix.setToRotation(xAngle, [1, 0, 0], [0, 0, 0]);
|
|
1719
1930
|
const endMatrix = zMatrix.postMultBy(xMatrix);
|
|
1720
|
-
let pos = Vector3d.createFromArray([
|
|
1721
|
-
const up = Vector3d.createFromArray([
|
|
1931
|
+
let pos = Vector3d.createFromArray([0, 1, 0]).transformBy(endMatrix);
|
|
1932
|
+
const up = Vector3d.createFromArray([0, 0, 1]).transformBy(endMatrix);
|
|
1722
1933
|
pos.setLength(offset.length());
|
|
1723
1934
|
pos = target.add(pos);
|
|
1724
1935
|
const current = this.getViewParams();
|
|
@@ -1743,7 +1954,8 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1743
1954
|
ext.delete();
|
|
1744
1955
|
ext = obj.getExtents();
|
|
1745
1956
|
obj.delete();
|
|
1746
|
-
}
|
|
1957
|
+
}
|
|
1958
|
+
else if (entId.getType() === 2) {
|
|
1747
1959
|
const obj = entId.openObjectAsInsert();
|
|
1748
1960
|
const extTuple = obj.getExtents();
|
|
1749
1961
|
ext.delete();
|
|
@@ -1760,48 +1972,39 @@ class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
|
1760
1972
|
}
|
|
1761
1973
|
|
|
1762
1974
|
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("
|
|
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));
|
|
1975
|
+
draggers.registerDragger("Pan", (viewer) => new OdPanDragger(viewer));
|
|
1976
|
+
draggers.registerDragger("Orbit", (viewer) => new OdOrbitDragger(viewer));
|
|
1977
|
+
draggers.registerDragger("Zoom", (viewer) => new OdZoomDragger(viewer));
|
|
1978
|
+
draggers.registerDragger("ZoomWindow", (viewer) => new OdZoomWindowDragger(viewer));
|
|
1979
|
+
draggers.registerDragger("ZoomWheel", (viewer) => new OdZoomWheelDragger(viewer));
|
|
1980
|
+
draggers.registerDragger("OrbitAroundBuilding", (viewer) => new OrbitAroundBuildingDragger(viewer));
|
|
1981
|
+
draggers.registerDragger("MeasureLine", (viewer) => new MeasureLineDragger(viewer));
|
|
1982
|
+
draggers.registerDragger("CuttingPlaneXAxis", (viewer) => new OdCuttingPlaneXAxisDragger(viewer));
|
|
1983
|
+
draggers.registerDragger("CuttingPlaneYAxis", (viewer) => new OdCuttingPlaneYAxisDragger(viewer));
|
|
1984
|
+
draggers.registerDragger("CuttingPlaneZAxis", (viewer) => new OdCuttingPlaneZAxisDragger(viewer));
|
|
1985
|
+
draggers.registerDragger("Walk", (viewer) => new OdaWalkDragger(viewer));
|
|
1986
|
+
draggers.registerDragger("Fly", (viewer) => new OdaFlyDragger(viewer));
|
|
1785
1987
|
|
|
1786
1988
|
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;
|
|
1989
|
+
const { translate, scale, rotation } = transform;
|
|
1990
|
+
const translateMatrix = new visLib.Matrix3d();
|
|
1991
|
+
translateMatrix.setTranslation([translate.x, translate.y, translate.z]);
|
|
1992
|
+
const rotateMatrix = new visLib.Matrix3d();
|
|
1993
|
+
rotateMatrix.setToRotation(rotation.angle, [rotation.x, rotation.y, rotation.z], modelCenter);
|
|
1994
|
+
const scaleMatrix = new visLib.Matrix3d();
|
|
1793
1995
|
scaleMatrix.setToScaling(scale, modelCenter);
|
|
1794
1996
|
return rotateMatrix.postMultBy(translateMatrix).postMultBy(scaleMatrix);
|
|
1795
1997
|
};
|
|
1796
|
-
|
|
1797
1998
|
function applyModelTransform(viewer, model) {
|
|
1798
1999
|
var _a;
|
|
1799
|
-
if (!viewer.visualizeJs)
|
|
1800
|
-
|
|
2000
|
+
if (!viewer.visualizeJs)
|
|
2001
|
+
return;
|
|
2002
|
+
if (!model.getModelTransformMatrix)
|
|
2003
|
+
return;
|
|
1801
2004
|
const visLib = viewer.visLib();
|
|
1802
2005
|
const visViewer = viewer.visViewer();
|
|
1803
2006
|
const modelItr = visViewer.getModelIterator();
|
|
1804
|
-
for (
|
|
2007
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
1805
2008
|
const modelPtr = modelItr.getModel();
|
|
1806
2009
|
const transform = model.getModelTransformMatrix(modelPtr.getDatabaseHandle());
|
|
1807
2010
|
if (transform) {
|
|
@@ -1821,75 +2024,79 @@ function clearMarkup(viewer) {
|
|
|
1821
2024
|
}
|
|
1822
2025
|
|
|
1823
2026
|
function clearSelected(viewer) {
|
|
1824
|
-
if (!viewer.visualizeJs)
|
|
2027
|
+
if (!viewer.visualizeJs)
|
|
2028
|
+
return;
|
|
1825
2029
|
const visViewer = viewer.visViewer();
|
|
1826
2030
|
visViewer.unselect();
|
|
1827
2031
|
viewer.update();
|
|
1828
|
-
viewer.emitEvent({
|
|
1829
|
-
type: "select",
|
|
1830
|
-
data: undefined,
|
|
1831
|
-
handles: []
|
|
1832
|
-
});
|
|
2032
|
+
viewer.emitEvent({ type: "select", data: undefined, handles: [] });
|
|
1833
2033
|
}
|
|
1834
2034
|
|
|
1835
2035
|
function clearSlices(viewer) {
|
|
1836
2036
|
viewer.clearSlices();
|
|
1837
2037
|
}
|
|
1838
2038
|
|
|
1839
|
-
function createPreview(viewer, type = "image/jpeg", encoderOptions = .25) {
|
|
2039
|
+
function createPreview(viewer, type = "image/jpeg", encoderOptions = 0.25) {
|
|
1840
2040
|
var _a;
|
|
1841
|
-
if (!viewer.visualizeJs)
|
|
2041
|
+
if (!viewer.visualizeJs)
|
|
2042
|
+
return "";
|
|
1842
2043
|
return ((_a = viewer.canvas) === null || _a === void 0 ? void 0 : _a.toDataURL(type, encoderOptions)) || "";
|
|
1843
2044
|
}
|
|
1844
2045
|
|
|
1845
2046
|
function explode(viewer, index = 0) {
|
|
1846
|
-
if (!viewer.visualizeJs)
|
|
2047
|
+
if (!viewer.visualizeJs)
|
|
2048
|
+
return;
|
|
1847
2049
|
const visViewer = viewer.visViewer();
|
|
1848
2050
|
visViewer.explode(index);
|
|
1849
2051
|
viewer.update();
|
|
1850
|
-
viewer.emitEvent({
|
|
1851
|
-
type: "explode",
|
|
1852
|
-
data: index
|
|
1853
|
-
});
|
|
2052
|
+
viewer.emitEvent({ type: "explode", data: index });
|
|
1854
2053
|
}
|
|
1855
|
-
|
|
1856
2054
|
function collect(viewer) {
|
|
1857
2055
|
explode(viewer, 0);
|
|
1858
2056
|
}
|
|
1859
2057
|
|
|
1860
2058
|
function getDefaultViewPositions(viewer) {
|
|
1861
|
-
if (!viewer.visualizeJs)
|
|
2059
|
+
if (!viewer.visualizeJs)
|
|
2060
|
+
return [];
|
|
1862
2061
|
const visLib = viewer.visLib();
|
|
1863
2062
|
const defViewPos = visLib.DefaultViewPosition;
|
|
1864
|
-
return Object.keys(defViewPos).filter(x => x !== "values");
|
|
2063
|
+
return Object.keys(defViewPos).filter((x) => x !== "values");
|
|
1865
2064
|
}
|
|
1866
2065
|
|
|
1867
2066
|
function getModels(viewer) {
|
|
1868
|
-
if (!viewer.visualizeJs)
|
|
2067
|
+
if (!viewer.visualizeJs)
|
|
2068
|
+
return [];
|
|
1869
2069
|
const visViewer = viewer.visViewer();
|
|
1870
2070
|
const handles = [];
|
|
1871
2071
|
const modelItr = visViewer.getModelIterator();
|
|
1872
|
-
for (
|
|
2072
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
1873
2073
|
const modelPtr = modelItr.getModel();
|
|
1874
|
-
if (modelPtr.getName()[0] !== "$")
|
|
2074
|
+
if (modelPtr.getName()[0] !== "$")
|
|
2075
|
+
handles.push(modelPtr.getDatabaseHandle());
|
|
1875
2076
|
}
|
|
1876
2077
|
modelItr.delete();
|
|
1877
2078
|
return handles;
|
|
1878
2079
|
}
|
|
1879
2080
|
|
|
1880
2081
|
function getSelected(viewer) {
|
|
1881
|
-
if (!viewer.visualizeJs)
|
|
2082
|
+
if (!viewer.visualizeJs)
|
|
2083
|
+
return [];
|
|
1882
2084
|
const visViewer = viewer.visViewer();
|
|
1883
2085
|
const handles = [];
|
|
1884
2086
|
const selectionSet = visViewer.getSelected();
|
|
1885
2087
|
if (!selectionSet.isNull() && selectionSet.numItems() !== 0) {
|
|
1886
2088
|
const itr = selectionSet.getIterator();
|
|
1887
|
-
for (
|
|
2089
|
+
for (; !itr.done(); itr.step()) {
|
|
1888
2090
|
const entityId = itr.getEntity();
|
|
1889
|
-
const entityPtr = entityId.getType() === 1
|
|
2091
|
+
const entityPtr = entityId.getType() === 1
|
|
2092
|
+
? entityId.openObject()
|
|
2093
|
+
: entityId.getType() === 2
|
|
2094
|
+
? entityId.openObjectAsInsert()
|
|
2095
|
+
: null;
|
|
1890
2096
|
if (entityPtr) {
|
|
1891
2097
|
const handle = entityPtr.getNativeDatabaseHandle();
|
|
1892
|
-
if (handle !== "-1")
|
|
2098
|
+
if (handle !== "-1")
|
|
2099
|
+
handles.push(handle);
|
|
1893
2100
|
entityPtr.delete();
|
|
1894
2101
|
}
|
|
1895
2102
|
}
|
|
@@ -1899,42 +2106,36 @@ function getSelected(viewer) {
|
|
|
1899
2106
|
}
|
|
1900
2107
|
|
|
1901
2108
|
function hideSelected(viewer) {
|
|
1902
|
-
if (!viewer.visualizeJs)
|
|
2109
|
+
if (!viewer.visualizeJs)
|
|
2110
|
+
return;
|
|
1903
2111
|
const visViewer = viewer.visViewer();
|
|
1904
2112
|
visViewer.hideSelectedObjects(false);
|
|
1905
2113
|
viewer.update();
|
|
1906
|
-
viewer.emitEvent({
|
|
1907
|
-
|
|
1908
|
-
});
|
|
1909
|
-
viewer.emitEvent({
|
|
1910
|
-
type: "select",
|
|
1911
|
-
data: undefined,
|
|
1912
|
-
handles: []
|
|
1913
|
-
});
|
|
2114
|
+
viewer.emitEvent({ type: "hide" });
|
|
2115
|
+
viewer.emitEvent({ type: "select", data: undefined, handles: [] });
|
|
1914
2116
|
}
|
|
1915
2117
|
|
|
1916
2118
|
function isolateSelected(viewer) {
|
|
1917
|
-
if (!viewer.visualizeJs)
|
|
2119
|
+
if (!viewer.visualizeJs)
|
|
2120
|
+
return;
|
|
1918
2121
|
const visViewer = viewer.visViewer();
|
|
1919
2122
|
visViewer.isolateSelectedObjects(false);
|
|
1920
2123
|
viewer.update();
|
|
1921
|
-
viewer.emitEvent({
|
|
1922
|
-
type: "isolate"
|
|
1923
|
-
});
|
|
2124
|
+
viewer.emitEvent({ type: "isolate" });
|
|
1924
2125
|
}
|
|
1925
2126
|
|
|
1926
2127
|
function regenerateAll(viewer) {
|
|
1927
|
-
if (!viewer.visualizeJs)
|
|
2128
|
+
if (!viewer.visualizeJs)
|
|
2129
|
+
return;
|
|
1928
2130
|
const visViewer = viewer.visViewer();
|
|
1929
2131
|
visViewer.regenAll();
|
|
1930
2132
|
viewer.update();
|
|
1931
|
-
viewer.emit({
|
|
1932
|
-
type: "regenerateall"
|
|
1933
|
-
});
|
|
2133
|
+
viewer.emit({ type: "regenerateall" });
|
|
1934
2134
|
}
|
|
1935
2135
|
|
|
1936
2136
|
function resetView(viewer) {
|
|
1937
|
-
if (!viewer.visualizeJs)
|
|
2137
|
+
if (!viewer.visualizeJs)
|
|
2138
|
+
return;
|
|
1938
2139
|
viewer.executeCommand("setActiveDragger");
|
|
1939
2140
|
viewer.executeCommand("clearSlices");
|
|
1940
2141
|
viewer.executeCommand("clearOverlay");
|
|
@@ -1944,28 +2145,23 @@ function resetView(viewer) {
|
|
|
1944
2145
|
viewer.executeCommand("explode", 0);
|
|
1945
2146
|
viewer.executeCommand("zoomToExtents", true);
|
|
1946
2147
|
viewer.executeCommand("k3DViewSW");
|
|
1947
|
-
viewer.emit({
|
|
1948
|
-
type: "resetview"
|
|
1949
|
-
});
|
|
2148
|
+
viewer.emit({ type: "resetview" });
|
|
1950
2149
|
}
|
|
1951
2150
|
|
|
1952
2151
|
function selectModel(viewer, handle) {
|
|
1953
|
-
if (!viewer.visualizeJs)
|
|
2152
|
+
if (!viewer.visualizeJs)
|
|
2153
|
+
return;
|
|
1954
2154
|
const visViewer = viewer.visViewer();
|
|
1955
2155
|
const activeView = visViewer.activeView;
|
|
1956
2156
|
const modelItr = visViewer.getModelIterator();
|
|
1957
|
-
for (
|
|
2157
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
1958
2158
|
const modelPtr = modelItr.getModel();
|
|
1959
2159
|
if (modelPtr.getDatabaseHandle() === handle) {
|
|
1960
|
-
const selectionSet = activeView.selectCrossing([
|
|
2160
|
+
const selectionSet = activeView.selectCrossing([0, 9999, 9999, 0], modelPtr);
|
|
1961
2161
|
visViewer.setSelected(selectionSet);
|
|
1962
2162
|
const handles = viewer.getSelected();
|
|
1963
2163
|
viewer.update();
|
|
1964
|
-
viewer.emitEvent({
|
|
1965
|
-
type: "select",
|
|
1966
|
-
data: selectionSet,
|
|
1967
|
-
handles: handles
|
|
1968
|
-
});
|
|
2164
|
+
viewer.emitEvent({ type: "select", data: selectionSet, handles });
|
|
1969
2165
|
selectionSet.delete();
|
|
1970
2166
|
break;
|
|
1971
2167
|
}
|
|
@@ -1978,16 +2174,14 @@ function setActiveDragger(viewer, dragger = "") {
|
|
|
1978
2174
|
}
|
|
1979
2175
|
|
|
1980
2176
|
function setDefaultViewPosition(viewer, position = "") {
|
|
1981
|
-
if (!viewer.visualizeJs)
|
|
2177
|
+
if (!viewer.visualizeJs)
|
|
2178
|
+
return;
|
|
1982
2179
|
const visLib = viewer.visLib();
|
|
1983
2180
|
const visViewer = viewer.visViewer();
|
|
1984
2181
|
const defViewPos = visLib.DefaultViewPosition;
|
|
1985
2182
|
visViewer.setDefaultViewPositionWithAnimation(defViewPos[position]);
|
|
1986
2183
|
viewer.update();
|
|
1987
|
-
viewer.emit({
|
|
1988
|
-
type: "viewposition",
|
|
1989
|
-
data: position
|
|
1990
|
-
});
|
|
2184
|
+
viewer.emit({ type: "viewposition", data: position });
|
|
1991
2185
|
}
|
|
1992
2186
|
|
|
1993
2187
|
function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
@@ -1995,36 +2189,34 @@ function setMarkupColor(viewer, r = 255, g = 0, b = 0) {
|
|
|
1995
2189
|
}
|
|
1996
2190
|
|
|
1997
2191
|
function setSelected(viewer, handles = []) {
|
|
1998
|
-
if (!viewer.visualizeJs)
|
|
2192
|
+
if (!viewer.visualizeJs)
|
|
2193
|
+
return;
|
|
1999
2194
|
const visLib = viewer.visLib();
|
|
2000
2195
|
const visViewer = viewer.visViewer();
|
|
2001
|
-
const selectionSet = new visLib.OdTvSelectionSet;
|
|
2002
|
-
handles === null || handles === void 0 ? void 0 : handles.forEach(handle => {
|
|
2196
|
+
const selectionSet = new visLib.OdTvSelectionSet();
|
|
2197
|
+
handles === null || handles === void 0 ? void 0 : handles.forEach((handle) => {
|
|
2003
2198
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
2004
|
-
if (!entityId.isNull())
|
|
2199
|
+
if (!entityId.isNull())
|
|
2200
|
+
selectionSet.appendEntity(entityId);
|
|
2005
2201
|
});
|
|
2006
2202
|
visViewer.setSelected(selectionSet);
|
|
2007
2203
|
viewer.update();
|
|
2008
|
-
viewer.emitEvent({
|
|
2009
|
-
type: "select",
|
|
2010
|
-
data: selectionSet,
|
|
2011
|
-
handles: handles
|
|
2012
|
-
});
|
|
2204
|
+
viewer.emitEvent({ type: "select", data: selectionSet, handles });
|
|
2013
2205
|
selectionSet.delete();
|
|
2014
2206
|
}
|
|
2015
2207
|
|
|
2016
2208
|
function showAll(viewer) {
|
|
2017
|
-
if (!viewer.visualizeJs)
|
|
2209
|
+
if (!viewer.visualizeJs)
|
|
2210
|
+
return;
|
|
2018
2211
|
const visViewer = viewer.visViewer();
|
|
2019
2212
|
visViewer.unisolateSelectedObjects(false);
|
|
2020
2213
|
viewer.update();
|
|
2021
|
-
viewer.emitEvent({
|
|
2022
|
-
type: "showall"
|
|
2023
|
-
});
|
|
2214
|
+
viewer.emitEvent({ type: "showall" });
|
|
2024
2215
|
}
|
|
2025
2216
|
|
|
2026
2217
|
function zoomToExtents(viewer, force = false, animate = viewer.options.cameraAnimation) {
|
|
2027
|
-
if (!viewer.visualizeJs)
|
|
2218
|
+
if (!viewer.visualizeJs)
|
|
2219
|
+
return;
|
|
2028
2220
|
const visViewer = viewer.visViewer();
|
|
2029
2221
|
const saveEnableAmination = visViewer.getEnableAnimation();
|
|
2030
2222
|
visViewer.setEnableAnimation(animate);
|
|
@@ -2033,57 +2225,55 @@ function zoomToExtents(viewer, force = false, animate = viewer.options.cameraAni
|
|
|
2033
2225
|
visViewer.setEnableAnimation(saveEnableAmination);
|
|
2034
2226
|
viewer.deviceAutoRegeneration();
|
|
2035
2227
|
viewer.update();
|
|
2036
|
-
viewer.emitEvent({
|
|
2037
|
-
type: "zoom"
|
|
2038
|
-
});
|
|
2228
|
+
viewer.emitEvent({ type: "zoom" });
|
|
2039
2229
|
}
|
|
2040
2230
|
|
|
2041
2231
|
function zoomToObjects(viewer, handles = []) {
|
|
2042
2232
|
var _a;
|
|
2043
|
-
if (!viewer.visualizeJs)
|
|
2233
|
+
if (!viewer.visualizeJs)
|
|
2234
|
+
return;
|
|
2044
2235
|
const visLib = viewer.visLib();
|
|
2045
2236
|
const visViewer = viewer.visViewer();
|
|
2046
|
-
const selectionSet = new visLib.OdTvSelectionSet;
|
|
2047
|
-
handles.forEach(handle => {
|
|
2237
|
+
const selectionSet = new visLib.OdTvSelectionSet();
|
|
2238
|
+
handles.forEach((handle) => {
|
|
2048
2239
|
const entityId = visViewer.getEntityByOriginalHandle(handle + "");
|
|
2049
|
-
if (!entityId.isNull())
|
|
2240
|
+
if (!entityId.isNull())
|
|
2241
|
+
selectionSet.appendEntity(entityId);
|
|
2050
2242
|
});
|
|
2051
2243
|
(_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
|
|
2052
2244
|
viewer.deviceAutoRegeneration();
|
|
2053
2245
|
viewer.update();
|
|
2054
|
-
viewer.emitEvent({
|
|
2055
|
-
type: "zoom"
|
|
2056
|
-
});
|
|
2246
|
+
viewer.emitEvent({ type: "zoom" });
|
|
2057
2247
|
selectionSet.delete();
|
|
2058
2248
|
}
|
|
2059
2249
|
|
|
2060
2250
|
function zoomToSelected(viewer) {
|
|
2061
2251
|
var _a;
|
|
2062
|
-
if (!viewer.visualizeJs)
|
|
2252
|
+
if (!viewer.visualizeJs)
|
|
2253
|
+
return;
|
|
2063
2254
|
const visViewer = viewer.visViewer();
|
|
2064
2255
|
const selectionSet = visViewer.getSelected();
|
|
2065
2256
|
(_a = visViewer.zoomToObjects) === null || _a === void 0 ? void 0 : _a.call(visViewer, selectionSet);
|
|
2066
2257
|
viewer.deviceAutoRegeneration();
|
|
2067
2258
|
viewer.update();
|
|
2068
|
-
viewer.emitEvent({
|
|
2069
|
-
type: "zoom"
|
|
2070
|
-
});
|
|
2259
|
+
viewer.emitEvent({ type: "zoom" });
|
|
2071
2260
|
}
|
|
2072
2261
|
|
|
2073
2262
|
function isTemplateModel(modelPtr) {
|
|
2074
2263
|
return modelPtr.getName()[0] === "$";
|
|
2075
2264
|
}
|
|
2076
|
-
|
|
2077
2265
|
async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
2078
2266
|
var _a;
|
|
2079
|
-
if (!viewer.visualizeJs)
|
|
2080
|
-
|
|
2267
|
+
if (!viewer.visualizeJs)
|
|
2268
|
+
return;
|
|
2269
|
+
if (!model.getModelTransformMatrix)
|
|
2270
|
+
return;
|
|
2081
2271
|
const visLib = viewer.visLib();
|
|
2082
2272
|
const visViewer = viewer.visViewer();
|
|
2083
2273
|
const viewExt = visViewer.getActiveExtents();
|
|
2084
2274
|
const centralPoint = viewExt.center();
|
|
2085
2275
|
const modelItr = visViewer.getModelIterator();
|
|
2086
|
-
for (
|
|
2276
|
+
for (; !modelItr.done(); modelItr.step()) {
|
|
2087
2277
|
const modelPtr = modelItr.getModel();
|
|
2088
2278
|
if (!isTemplateModel(modelPtr)) {
|
|
2089
2279
|
const ext = modelPtr.getExtents();
|
|
@@ -2091,26 +2281,28 @@ async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
|
2091
2281
|
ext.transformBy(modelPtr.getUnitsMatrix());
|
|
2092
2282
|
const unitsMatrixInvert = modelPtr.getUnitsMatrix().invert();
|
|
2093
2283
|
const center = ext.center();
|
|
2094
|
-
const scale = 1;
|
|
2095
|
-
const scaleMatrix = new visLib.Matrix3d;
|
|
2096
|
-
const translateMatrix = new visLib.Matrix3d;
|
|
2097
|
-
translateMatrix.setTranslation([
|
|
2284
|
+
const scale = 1.0;
|
|
2285
|
+
const scaleMatrix = new visLib.Matrix3d();
|
|
2286
|
+
const translateMatrix = new visLib.Matrix3d();
|
|
2287
|
+
translateMatrix.setTranslation([
|
|
2288
|
+
centralPoint[0] - center[0],
|
|
2289
|
+
centralPoint[1] - center[1],
|
|
2290
|
+
centralPoint[2] - center[2],
|
|
2291
|
+
]);
|
|
2098
2292
|
scaleMatrix.setToScaling(scale, centralPoint);
|
|
2099
|
-
const resMatrixWithUnits = unitsMatrixInvert
|
|
2293
|
+
const resMatrixWithUnits = unitsMatrixInvert
|
|
2294
|
+
.postMultBy(scaleMatrix)
|
|
2295
|
+
.postMultBy(translateMatrix)
|
|
2296
|
+
.postMultBy(unitsMatrix);
|
|
2100
2297
|
const resScale = resMatrixWithUnits.scale();
|
|
2101
2298
|
const transform = {
|
|
2102
2299
|
translate: {
|
|
2103
2300
|
x: resMatrixWithUnits.get(0, 3) - (1 - resScale) * center[0],
|
|
2104
2301
|
y: resMatrixWithUnits.get(1, 3) - (1 - resScale) * center[1],
|
|
2105
|
-
z: resMatrixWithUnits.get(2, 3) - (1 - resScale) * center[2]
|
|
2302
|
+
z: resMatrixWithUnits.get(2, 3) - (1 - resScale) * center[2],
|
|
2106
2303
|
},
|
|
2107
|
-
rotation: {
|
|
2108
|
-
|
|
2109
|
-
y: 0,
|
|
2110
|
-
z: 1,
|
|
2111
|
-
angle: 0
|
|
2112
|
-
},
|
|
2113
|
-
scale: resScale
|
|
2304
|
+
rotation: { x: 0, y: 0, z: 1, angle: 0.0 },
|
|
2305
|
+
scale: resScale,
|
|
2114
2306
|
};
|
|
2115
2307
|
const matrix = composeMatrixFromTransform(transform, center, visLib);
|
|
2116
2308
|
modelPtr.setModelingMatrix(matrix, true);
|
|
@@ -2125,79 +2317,42 @@ async function autoTransformAllModelsToCentralPoint(viewer, model) {
|
|
|
2125
2317
|
}
|
|
2126
2318
|
|
|
2127
2319
|
const commands = commandsRegistry("visualizejs");
|
|
2128
|
-
|
|
2129
2320
|
commands.registerCommand("applyModelTransform", applyModelTransform);
|
|
2130
|
-
|
|
2131
2321
|
commands.registerCommand("clearMarkup", clearMarkup);
|
|
2132
|
-
|
|
2133
2322
|
commands.registerCommand("clearSelected", clearSelected);
|
|
2134
|
-
|
|
2135
2323
|
commands.registerCommand("clearSlices", clearSlices);
|
|
2136
|
-
|
|
2137
2324
|
commands.registerCommand("createPreview", createPreview);
|
|
2138
|
-
|
|
2139
2325
|
commands.registerCommand("explode", explode);
|
|
2140
|
-
|
|
2141
2326
|
commands.registerCommand("collect", collect);
|
|
2142
|
-
|
|
2143
2327
|
commands.registerCommand("getDefaultViewPositions", getDefaultViewPositions);
|
|
2144
|
-
|
|
2145
2328
|
commands.registerCommand("getModels", getModels);
|
|
2146
|
-
|
|
2147
2329
|
commands.registerCommand("getSelected", getSelected);
|
|
2148
|
-
|
|
2149
2330
|
commands.registerCommand("hideSelected", hideSelected);
|
|
2150
|
-
|
|
2151
2331
|
commands.registerCommand("isolateSelected", isolateSelected);
|
|
2152
|
-
|
|
2153
2332
|
commands.registerCommand("regenerateAll", regenerateAll);
|
|
2154
|
-
|
|
2155
2333
|
commands.registerCommand("resetView", resetView);
|
|
2156
|
-
|
|
2157
2334
|
commands.registerCommand("selectModel", selectModel);
|
|
2158
|
-
|
|
2159
2335
|
commands.registerCommand("setActiveDragger", setActiveDragger);
|
|
2160
|
-
|
|
2161
2336
|
commands.registerCommand("setDefaultViewPosition", setDefaultViewPosition);
|
|
2162
|
-
|
|
2163
2337
|
commands.registerCommand("setMarkupColor", setMarkupColor);
|
|
2164
|
-
|
|
2165
2338
|
commands.registerCommand("setSelected", setSelected);
|
|
2166
|
-
|
|
2167
2339
|
commands.registerCommand("showAll", showAll);
|
|
2168
|
-
|
|
2169
2340
|
commands.registerCommand("zoomToExtents", zoomToExtents);
|
|
2170
|
-
|
|
2171
2341
|
commands.registerCommand("zoomToObjects", zoomToObjects);
|
|
2172
|
-
|
|
2173
2342
|
commands.registerCommand("zoomToSelected", zoomToSelected);
|
|
2174
|
-
|
|
2175
2343
|
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
|
-
|
|
2344
|
+
commands.registerCommand("k3DViewTop", (viewer) => setDefaultViewPosition(viewer, "k3DViewTop"));
|
|
2345
|
+
commands.registerCommand("k3DViewBottom", (viewer) => setDefaultViewPosition(viewer, "k3DViewBottom"));
|
|
2346
|
+
commands.registerCommand("k3DViewLeft", (viewer) => setDefaultViewPosition(viewer, "k3DViewLeft"));
|
|
2347
|
+
commands.registerCommand("k3DViewRight", (viewer) => setDefaultViewPosition(viewer, "k3DViewRight"));
|
|
2348
|
+
commands.registerCommand("k3DViewFront", (viewer) => setDefaultViewPosition(viewer, "k3DViewFront"));
|
|
2349
|
+
commands.registerCommand("k3DViewBack", (viewer) => setDefaultViewPosition(viewer, "k3DViewBack"));
|
|
2350
|
+
commands.registerCommand("k3DViewSE", (viewer) => setDefaultViewPosition(viewer, "k3DViewSE"));
|
|
2351
|
+
commands.registerCommand("k3DViewSW", (viewer) => setDefaultViewPosition(viewer, "k3DViewSW"));
|
|
2352
|
+
commands.registerCommand("k3DViewNE", (viewer) => setDefaultViewPosition(viewer, "k3DViewNE"));
|
|
2353
|
+
commands.registerCommand("k3DViewNW", (viewer) => setDefaultViewPosition(viewer, "k3DViewNW"));
|
|
2197
2354
|
commands.registerCommandAlias("clearMarkup", "clearOverlay");
|
|
2198
|
-
|
|
2199
2355
|
commands.registerCommandAlias("clearSelected", "unselect");
|
|
2200
|
-
|
|
2201
2356
|
commands.registerCommandAlias("zoomToExtents", "zoomExtents");
|
|
2202
2357
|
|
|
2203
2358
|
class RenderLoopComponent {
|
|
@@ -2205,10 +2360,7 @@ class RenderLoopComponent {
|
|
|
2205
2360
|
this.animate = (time = 0) => {
|
|
2206
2361
|
this.requestId = requestAnimationFrame(this.animate);
|
|
2207
2362
|
this.viewer.render(time);
|
|
2208
|
-
this.viewer.emitEvent({
|
|
2209
|
-
type: "animate",
|
|
2210
|
-
time: time
|
|
2211
|
-
});
|
|
2363
|
+
this.viewer.emitEvent({ type: "animate", time });
|
|
2212
2364
|
};
|
|
2213
2365
|
this.viewer = viewer;
|
|
2214
2366
|
this.animate();
|
|
@@ -2220,9 +2372,10 @@ class RenderLoopComponent {
|
|
|
2220
2372
|
|
|
2221
2373
|
class ResizeCanvasComponent {
|
|
2222
2374
|
constructor(viewer) {
|
|
2223
|
-
this.resizeViewer = entries => {
|
|
2224
|
-
const {
|
|
2225
|
-
if (!width || !height)
|
|
2375
|
+
this.resizeViewer = (entries) => {
|
|
2376
|
+
const { width, height } = entries[0].contentRect;
|
|
2377
|
+
if (!width || !height)
|
|
2378
|
+
return;
|
|
2226
2379
|
this.viewer.setSize(width, height);
|
|
2227
2380
|
};
|
|
2228
2381
|
this.viewer = viewer;
|
|
@@ -2248,14 +2401,12 @@ class ZoomWheelComponent {
|
|
|
2248
2401
|
}
|
|
2249
2402
|
|
|
2250
2403
|
var GestureAction;
|
|
2251
|
-
|
|
2252
|
-
(function(GestureAction) {
|
|
2404
|
+
(function (GestureAction) {
|
|
2253
2405
|
GestureAction[GestureAction["None"] = 0] = "None";
|
|
2254
2406
|
GestureAction[GestureAction["Orbit"] = 1] = "Orbit";
|
|
2255
2407
|
GestureAction[GestureAction["Pan"] = 2] = "Pan";
|
|
2256
2408
|
GestureAction[GestureAction["Zoom"] = 3] = "Zoom";
|
|
2257
2409
|
})(GestureAction || (GestureAction = {}));
|
|
2258
|
-
|
|
2259
2410
|
class GestureManager extends OdBaseDragger {
|
|
2260
2411
|
get isSingleTouchEnabled() {
|
|
2261
2412
|
return this._isSingleTouchEnabled;
|
|
@@ -2265,8 +2416,8 @@ class GestureManager extends OdBaseDragger {
|
|
|
2265
2416
|
}
|
|
2266
2417
|
constructor(subject) {
|
|
2267
2418
|
super(subject);
|
|
2268
|
-
this._previousEvents = new Map;
|
|
2269
|
-
this._currentEvents = new Map;
|
|
2419
|
+
this._previousEvents = new Map();
|
|
2420
|
+
this._currentEvents = new Map();
|
|
2270
2421
|
this._lastGestureAction = GestureAction.None;
|
|
2271
2422
|
this._maxInitialDistanceDifference = 30 * window.devicePixelRatio;
|
|
2272
2423
|
this._isSingleTouchEnabled = false;
|
|
@@ -2283,7 +2434,7 @@ class GestureManager extends OdBaseDragger {
|
|
|
2283
2434
|
const point1 = this.relativeCoords(events.get(keys[1]));
|
|
2284
2435
|
return {
|
|
2285
2436
|
x: Math.floor((point0.x + point1.x) / 2),
|
|
2286
|
-
y: Math.floor((point0.y + point1.y) / 2)
|
|
2437
|
+
y: Math.floor((point0.y + point1.y) / 2),
|
|
2287
2438
|
};
|
|
2288
2439
|
}
|
|
2289
2440
|
getFirstPoint(events) {
|
|
@@ -2333,12 +2484,14 @@ class GestureManager extends OdBaseDragger {
|
|
|
2333
2484
|
const currentDistanceEqualsInitialDistance = Math.abs(this._initialDistance - currentDistance) <= this._maxInitialDistanceDifference;
|
|
2334
2485
|
if (currentDistanceEqualsInitialDistance) {
|
|
2335
2486
|
this.executePanAction(this.getMiddlePoint(this._currentEvents));
|
|
2336
|
-
}
|
|
2487
|
+
}
|
|
2488
|
+
else {
|
|
2337
2489
|
if (previousDistance !== -1 && currentDistance !== previousDistance) {
|
|
2338
2490
|
this.executeZoomAction(currentDistance, previousDistance);
|
|
2339
2491
|
}
|
|
2340
2492
|
}
|
|
2341
|
-
}
|
|
2493
|
+
}
|
|
2494
|
+
else if (this._currentEvents.size === 1 && this.isSingleTouchEnabled) {
|
|
2342
2495
|
this.executeOrbitAction(this.getFirstPoint(this._currentEvents));
|
|
2343
2496
|
}
|
|
2344
2497
|
}
|
|
@@ -2375,12 +2528,14 @@ class GestureManager extends OdBaseDragger {
|
|
|
2375
2528
|
this.subject.update();
|
|
2376
2529
|
}
|
|
2377
2530
|
executeEndAction(gestureAction) {
|
|
2378
|
-
if (gestureAction === GestureAction.Orbit)
|
|
2379
|
-
|
|
2531
|
+
if (gestureAction === GestureAction.Orbit)
|
|
2532
|
+
this._orbitAction.endAction();
|
|
2533
|
+
if (gestureAction === GestureAction.Pan)
|
|
2534
|
+
this._panAction.endAction();
|
|
2380
2535
|
OdBaseDragger.isGestureActive = false;
|
|
2381
2536
|
}
|
|
2382
2537
|
needIgnoreEvent(event) {
|
|
2383
|
-
return !this.subject.options.enableZoomWheel || !this.subject.options.enableGestures || !this.eventIsTouchEvent(event);
|
|
2538
|
+
return (!this.subject.options.enableZoomWheel || !this.subject.options.enableGestures || !this.eventIsTouchEvent(event));
|
|
2384
2539
|
}
|
|
2385
2540
|
eventIsTouchEvent(event) {
|
|
2386
2541
|
return event.pointerType === "touch" || event.pointerType === "";
|
|
@@ -2436,14 +2591,10 @@ class GestureManagerComponent {
|
|
|
2436
2591
|
}
|
|
2437
2592
|
|
|
2438
2593
|
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));
|
|
2594
|
+
components.registerComponent("ResizeCanvasComponent", (viewer) => new ResizeCanvasComponent(viewer));
|
|
2595
|
+
components.registerComponent("RenderLoopComponent", (viewer) => new RenderLoopComponent(viewer));
|
|
2596
|
+
components.registerComponent("ZoomWheelComponent", (viewer) => new ZoomWheelComponent(viewer));
|
|
2597
|
+
components.registerComponent("GestureManagerComponent", (viewer) => new GestureManagerComponent(viewer));
|
|
2447
2598
|
|
|
2448
2599
|
class FileLoader {
|
|
2449
2600
|
constructor() {
|
|
@@ -2465,10 +2616,12 @@ class FileLoader {
|
|
|
2465
2616
|
const request = new Request(file, {
|
|
2466
2617
|
headers: new Headers(this.requestHeader),
|
|
2467
2618
|
credentials: this.withCredentials ? "include" : "same-origin",
|
|
2468
|
-
signal: this.abortSignal
|
|
2619
|
+
signal: this.abortSignal,
|
|
2469
2620
|
});
|
|
2470
|
-
return fetch(request)
|
|
2471
|
-
|
|
2621
|
+
return fetch(request)
|
|
2622
|
+
.then((response) => {
|
|
2623
|
+
if (!response.ok)
|
|
2624
|
+
throw new Error(`Failed to fetch "${response.url}", status ${response.status}`);
|
|
2472
2625
|
const contentLength = response.headers.get("X-File-Size") || response.headers.get("Content-Length");
|
|
2473
2626
|
const total = parseInt(contentLength || "", 10) || 0;
|
|
2474
2627
|
const lengthComputable = total > 0;
|
|
@@ -2478,45 +2631,40 @@ class FileLoader {
|
|
|
2478
2631
|
let loaded = 0;
|
|
2479
2632
|
try {
|
|
2480
2633
|
while (true) {
|
|
2481
|
-
const {
|
|
2482
|
-
if (done)
|
|
2634
|
+
const { done, value } = await reader.read();
|
|
2635
|
+
if (done)
|
|
2636
|
+
break;
|
|
2483
2637
|
if (onProgress) {
|
|
2484
2638
|
loaded += value.byteLength;
|
|
2485
|
-
onProgress(new ProgressEvent("progress", {
|
|
2486
|
-
lengthComputable: lengthComputable,
|
|
2487
|
-
loaded: loaded,
|
|
2488
|
-
total: total
|
|
2489
|
-
}));
|
|
2639
|
+
onProgress(new ProgressEvent("progress", { lengthComputable, loaded, total }));
|
|
2490
2640
|
}
|
|
2491
2641
|
controller.enqueue(value);
|
|
2492
2642
|
}
|
|
2493
2643
|
controller.close();
|
|
2494
|
-
}
|
|
2644
|
+
}
|
|
2645
|
+
catch (e) {
|
|
2495
2646
|
controller.error(e);
|
|
2496
2647
|
}
|
|
2497
|
-
}
|
|
2648
|
+
},
|
|
2498
2649
|
});
|
|
2499
2650
|
return new Response(stream);
|
|
2500
|
-
})
|
|
2651
|
+
})
|
|
2652
|
+
.then((response) => response.arrayBuffer());
|
|
2501
2653
|
}
|
|
2502
2654
|
if (file instanceof globalThis.File) {
|
|
2503
2655
|
return new Promise((resolve, reject) => {
|
|
2504
|
-
const reader = new FileReader;
|
|
2656
|
+
const reader = new FileReader();
|
|
2505
2657
|
reader.onload = () => resolve(reader.result);
|
|
2506
2658
|
reader.onerror = () => reject(reader.error);
|
|
2507
2659
|
reader.onprogress = onProgress;
|
|
2508
|
-
reader.readAsArrayBuffer(new Blob([
|
|
2660
|
+
reader.readAsArrayBuffer(new Blob([file]));
|
|
2509
2661
|
});
|
|
2510
2662
|
}
|
|
2511
2663
|
if (onProgress) {
|
|
2512
2664
|
const total = file.byteLength;
|
|
2513
2665
|
const lengthComputable = total > 0;
|
|
2514
2666
|
const loaded = total;
|
|
2515
|
-
onProgress(new ProgressEvent("progress", {
|
|
2516
|
-
lengthComputable: lengthComputable,
|
|
2517
|
-
loaded: loaded,
|
|
2518
|
-
total: total
|
|
2519
|
-
}));
|
|
2667
|
+
onProgress(new ProgressEvent("progress", { lengthComputable, loaded, total }));
|
|
2520
2668
|
}
|
|
2521
2669
|
return Promise.resolve(file);
|
|
2522
2670
|
}
|
|
@@ -2528,41 +2676,37 @@ class VSFFileLoader extends Loader {
|
|
|
2528
2676
|
this.viewer = viewer;
|
|
2529
2677
|
}
|
|
2530
2678
|
isSupport(file, format) {
|
|
2531
|
-
return (typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2679
|
+
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2680
|
+
/vsf$/i.test(format));
|
|
2532
2681
|
}
|
|
2533
2682
|
async load(file, format, params) {
|
|
2534
|
-
if (!this.viewer.visualizeJs)
|
|
2683
|
+
if (!this.viewer.visualizeJs)
|
|
2684
|
+
return this;
|
|
2535
2685
|
const visViewer = this.viewer.visViewer();
|
|
2536
|
-
const progress = event => {
|
|
2537
|
-
const {
|
|
2686
|
+
const progress = (event) => {
|
|
2687
|
+
const { lengthComputable, loaded, total } = event;
|
|
2538
2688
|
const progress = lengthComputable ? loaded / total : 1;
|
|
2539
|
-
this.viewer.emitEvent({
|
|
2540
|
-
type: "geometryprogress",
|
|
2541
|
-
data: progress,
|
|
2542
|
-
file: file
|
|
2543
|
-
});
|
|
2689
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file });
|
|
2544
2690
|
};
|
|
2545
|
-
const loader = new FileLoader;
|
|
2691
|
+
const loader = new FileLoader();
|
|
2546
2692
|
loader.setRequestHeader(params.requestHeader);
|
|
2547
2693
|
loader.setWithCredentials(params.withCredentials);
|
|
2548
2694
|
loader.setAbortSignal(this.abortController.signal);
|
|
2549
2695
|
const arrayBuffer = await loader.load(file, progress);
|
|
2550
2696
|
const data = new Uint8Array(arrayBuffer);
|
|
2551
|
-
if (!this.viewer.visualizeJs)
|
|
2697
|
+
if (!this.viewer.visualizeJs)
|
|
2698
|
+
return this;
|
|
2552
2699
|
try {
|
|
2553
2700
|
visViewer.parseFile(data);
|
|
2554
|
-
}
|
|
2701
|
+
}
|
|
2702
|
+
catch (error) {
|
|
2555
2703
|
console.error("VSF parse error.", error);
|
|
2556
2704
|
throw error;
|
|
2557
2705
|
}
|
|
2558
2706
|
this.viewer.syncOptions();
|
|
2559
2707
|
this.viewer.syncOverlay();
|
|
2560
2708
|
this.viewer.update(true);
|
|
2561
|
-
this.viewer.emitEvent({
|
|
2562
|
-
type: "databasechunk",
|
|
2563
|
-
data: data,
|
|
2564
|
-
file: file
|
|
2565
|
-
});
|
|
2709
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file });
|
|
2566
2710
|
return this;
|
|
2567
2711
|
}
|
|
2568
2712
|
}
|
|
@@ -2573,30 +2717,31 @@ class VSFCloudLoader extends Loader {
|
|
|
2573
2717
|
this.viewer = viewer;
|
|
2574
2718
|
}
|
|
2575
2719
|
isSupport(file, format) {
|
|
2576
|
-
return typeof file === "object" &&
|
|
2720
|
+
return (typeof file === "object" &&
|
|
2721
|
+
typeof file.database === "string" &&
|
|
2722
|
+
typeof file.downloadResource === "function" &&
|
|
2723
|
+
/.data$/i.test(file.database));
|
|
2577
2724
|
}
|
|
2578
2725
|
async load(model, format) {
|
|
2579
|
-
if (!this.viewer.visualizeJs)
|
|
2726
|
+
if (!this.viewer.visualizeJs)
|
|
2727
|
+
return this;
|
|
2580
2728
|
const visViewer = this.viewer.visViewer();
|
|
2581
|
-
const filesToDownload = [
|
|
2729
|
+
const filesToDownload = [model.database, ...model.geometry];
|
|
2582
2730
|
console.time("File load time");
|
|
2583
2731
|
for (let i = 0; i < filesToDownload.length; i++) {
|
|
2584
2732
|
const dataId = filesToDownload[i];
|
|
2585
|
-
const progress = progress => {
|
|
2733
|
+
const progress = (progress) => {
|
|
2586
2734
|
const data = (i + progress) / filesToDownload.length;
|
|
2587
|
-
this.viewer.emitEvent({
|
|
2588
|
-
type: "geometryprogress",
|
|
2589
|
-
data: data,
|
|
2590
|
-
file: model.file,
|
|
2591
|
-
model: model
|
|
2592
|
-
});
|
|
2735
|
+
this.viewer.emitEvent({ type: "geometryprogress", data, file: model.file, model });
|
|
2593
2736
|
};
|
|
2594
2737
|
const arrayBuffer = await model.downloadResource(dataId, progress, this.abortController.signal);
|
|
2595
2738
|
const data = new Uint8Array(arrayBuffer);
|
|
2596
|
-
if (!this.viewer.visualizeJs)
|
|
2739
|
+
if (!this.viewer.visualizeJs)
|
|
2740
|
+
return this;
|
|
2597
2741
|
try {
|
|
2598
2742
|
visViewer.parseStream(data);
|
|
2599
|
-
}
|
|
2743
|
+
}
|
|
2744
|
+
catch (error) {
|
|
2600
2745
|
console.error("VSF parse error.", error);
|
|
2601
2746
|
throw error;
|
|
2602
2747
|
}
|
|
@@ -2604,20 +2749,11 @@ class VSFCloudLoader extends Loader {
|
|
|
2604
2749
|
this.viewer.syncOptions();
|
|
2605
2750
|
this.viewer.syncOverlay();
|
|
2606
2751
|
this.viewer.update(true);
|
|
2607
|
-
this.viewer.emitEvent({
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
file: model.file,
|
|
2611
|
-
model: model
|
|
2612
|
-
});
|
|
2613
|
-
} else {
|
|
2752
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
|
|
2753
|
+
}
|
|
2754
|
+
else {
|
|
2614
2755
|
this.viewer.update();
|
|
2615
|
-
this.viewer.emitEvent({
|
|
2616
|
-
type: "geometrychunk",
|
|
2617
|
-
data: data,
|
|
2618
|
-
file: model.file,
|
|
2619
|
-
model: model
|
|
2620
|
-
});
|
|
2756
|
+
this.viewer.emitEvent({ type: "geometrychunk", data, file: model.file, model });
|
|
2621
2757
|
}
|
|
2622
2758
|
}
|
|
2623
2759
|
console.timeEnd("File load time");
|
|
@@ -2631,41 +2767,37 @@ class VSFXFileLoader extends Loader {
|
|
|
2631
2767
|
this.viewer = viewer;
|
|
2632
2768
|
}
|
|
2633
2769
|
isSupport(file, format) {
|
|
2634
|
-
return (typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2770
|
+
return ((typeof file === "string" || file instanceof globalThis.File || file instanceof ArrayBuffer) &&
|
|
2771
|
+
/vsfx$/i.test(format));
|
|
2635
2772
|
}
|
|
2636
2773
|
async load(file, format, params) {
|
|
2637
|
-
if (!this.viewer.visualizeJs)
|
|
2774
|
+
if (!this.viewer.visualizeJs)
|
|
2775
|
+
return this;
|
|
2638
2776
|
const visViewer = this.viewer.visViewer();
|
|
2639
|
-
const progress = event => {
|
|
2640
|
-
const {
|
|
2777
|
+
const progress = (event) => {
|
|
2778
|
+
const { lengthComputable, loaded, total } = event;
|
|
2641
2779
|
const progress = lengthComputable ? loaded / total : 1;
|
|
2642
|
-
this.viewer.emitEvent({
|
|
2643
|
-
type: "geometryprogress",
|
|
2644
|
-
data: progress,
|
|
2645
|
-
file: file
|
|
2646
|
-
});
|
|
2780
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file });
|
|
2647
2781
|
};
|
|
2648
|
-
const loader = new FileLoader;
|
|
2782
|
+
const loader = new FileLoader();
|
|
2649
2783
|
loader.setRequestHeader(params.requestHeader);
|
|
2650
2784
|
loader.setWithCredentials(params.withCredentials);
|
|
2651
2785
|
loader.setAbortSignal(this.abortController.signal);
|
|
2652
2786
|
const arrayBuffer = await loader.load(file, progress);
|
|
2653
2787
|
const data = new Uint8Array(arrayBuffer);
|
|
2654
|
-
if (!this.viewer.visualizeJs)
|
|
2788
|
+
if (!this.viewer.visualizeJs)
|
|
2789
|
+
return this;
|
|
2655
2790
|
try {
|
|
2656
2791
|
visViewer.parseVsfx(data);
|
|
2657
|
-
}
|
|
2792
|
+
}
|
|
2793
|
+
catch (error) {
|
|
2658
2794
|
console.error("VSFX parse error.", error);
|
|
2659
2795
|
throw error;
|
|
2660
2796
|
}
|
|
2661
2797
|
this.viewer.syncOptions();
|
|
2662
2798
|
this.viewer.syncOverlay();
|
|
2663
2799
|
this.viewer.update(true);
|
|
2664
|
-
this.viewer.emitEvent({
|
|
2665
|
-
type: "databasechunk",
|
|
2666
|
-
data: data,
|
|
2667
|
-
file: file
|
|
2668
|
-
});
|
|
2800
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file });
|
|
2669
2801
|
return this;
|
|
2670
2802
|
}
|
|
2671
2803
|
}
|
|
@@ -2676,55 +2808,48 @@ class VSFXCloudLoader extends Loader {
|
|
|
2676
2808
|
this.viewer = viewer;
|
|
2677
2809
|
}
|
|
2678
2810
|
isSupport(file) {
|
|
2679
|
-
return typeof file === "object" &&
|
|
2811
|
+
return (typeof file === "object" &&
|
|
2812
|
+
typeof file.database === "string" &&
|
|
2813
|
+
typeof file.downloadResource === "function" &&
|
|
2814
|
+
/.vsfx$/i.test(file.database) &&
|
|
2815
|
+
this.viewer.options.enableStreamingMode === false);
|
|
2680
2816
|
}
|
|
2681
2817
|
async load(model, format, params = {}) {
|
|
2682
|
-
if (!this.viewer.visualizeJs)
|
|
2818
|
+
if (!this.viewer.visualizeJs)
|
|
2819
|
+
return Promise.resolve(this);
|
|
2683
2820
|
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
|
-
});
|
|
2821
|
+
const progress = (progress) => {
|
|
2822
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
2691
2823
|
};
|
|
2692
2824
|
console.time("File load time");
|
|
2693
2825
|
const arrayBuffer = await model.downloadResource(model.database, progress, this.abortController.signal);
|
|
2694
2826
|
const data = new Uint8Array(arrayBuffer);
|
|
2695
|
-
if (!this.viewer.visualizeJs)
|
|
2827
|
+
if (!this.viewer.visualizeJs)
|
|
2828
|
+
return this;
|
|
2696
2829
|
try {
|
|
2697
2830
|
visViewer.parseVsfx(data);
|
|
2698
|
-
}
|
|
2831
|
+
}
|
|
2832
|
+
catch (error) {
|
|
2699
2833
|
console.error("VSFX parse error.", error);
|
|
2700
2834
|
throw error;
|
|
2701
2835
|
}
|
|
2702
2836
|
this.viewer.syncOptions();
|
|
2703
2837
|
this.viewer.syncOverlay();
|
|
2704
2838
|
this.viewer.update(true);
|
|
2705
|
-
this.viewer.emitEvent({
|
|
2706
|
-
type: "databasechunk",
|
|
2707
|
-
data: data,
|
|
2708
|
-
file: model.file,
|
|
2709
|
-
model: model
|
|
2710
|
-
});
|
|
2839
|
+
this.viewer.emitEvent({ type: "databasechunk", data, file: model.file, model });
|
|
2711
2840
|
console.timeEnd("File load time");
|
|
2712
2841
|
return this;
|
|
2713
2842
|
}
|
|
2714
2843
|
}
|
|
2715
2844
|
|
|
2716
|
-
const DELAY_TIME_MULTIPLEXER = 2;
|
|
2717
|
-
|
|
2718
|
-
const START_UPDATE_TIME = 1e3;
|
|
2719
|
-
|
|
2845
|
+
const DELAY_TIME_MULTIPLEXER = 2.0;
|
|
2846
|
+
const START_UPDATE_TIME = 1000;
|
|
2720
2847
|
var UpdateType;
|
|
2721
|
-
|
|
2722
|
-
(function(UpdateType) {
|
|
2848
|
+
(function (UpdateType) {
|
|
2723
2849
|
UpdateType[UpdateType["kDelay"] = 0] = "kDelay";
|
|
2724
2850
|
UpdateType[UpdateType["kNormal"] = 1] = "kNormal";
|
|
2725
2851
|
UpdateType[UpdateType["kForce"] = 2] = "kForce";
|
|
2726
2852
|
})(UpdateType || (UpdateType = {}));
|
|
2727
|
-
|
|
2728
2853
|
class UpdateController {
|
|
2729
2854
|
constructor() {
|
|
2730
2855
|
this.lastUpdate = 0;
|
|
@@ -2751,32 +2876,37 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2751
2876
|
this.viewer = viewer;
|
|
2752
2877
|
}
|
|
2753
2878
|
isSupport(file) {
|
|
2754
|
-
return typeof file === "object" &&
|
|
2879
|
+
return (typeof file === "object" &&
|
|
2880
|
+
typeof file.database === "string" &&
|
|
2881
|
+
typeof file.downloadResource === "function" &&
|
|
2882
|
+
/.vsfx$/i.test(file.database) &&
|
|
2883
|
+
this.viewer.options.enableStreamingMode === true &&
|
|
2884
|
+
this.viewer.options.enablePartialMode === false &&
|
|
2885
|
+
!/.rcs$/i.test(file.name));
|
|
2755
2886
|
}
|
|
2756
2887
|
async load(model) {
|
|
2757
|
-
if (!this.viewer.visualizeJs)
|
|
2888
|
+
if (!this.viewer.visualizeJs)
|
|
2889
|
+
return this;
|
|
2758
2890
|
const visLib = this.viewer.visLib();
|
|
2759
2891
|
const visViewer = this.viewer.visViewer();
|
|
2760
|
-
const updateController = new UpdateController;
|
|
2892
|
+
const updateController = new UpdateController();
|
|
2761
2893
|
updateController.initialize(this.viewer);
|
|
2762
2894
|
let isFireDatabaseChunk = false;
|
|
2763
2895
|
const chunkLoadHandler = (progress, chunk) => {
|
|
2764
|
-
if (!this.viewer.visualizeJs)
|
|
2896
|
+
if (!this.viewer.visualizeJs)
|
|
2897
|
+
return;
|
|
2765
2898
|
let status;
|
|
2766
2899
|
try {
|
|
2767
2900
|
status = visViewer.parseVsfx(chunk);
|
|
2768
|
-
}
|
|
2901
|
+
}
|
|
2902
|
+
catch (error) {
|
|
2769
2903
|
console.error("VSFX parse error.", error);
|
|
2770
2904
|
throw error;
|
|
2771
2905
|
}
|
|
2772
|
-
this.viewer.emitEvent({
|
|
2773
|
-
type: "geometryprogress",
|
|
2774
|
-
data: progress,
|
|
2775
|
-
file: model.file,
|
|
2776
|
-
model: model
|
|
2777
|
-
});
|
|
2906
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
2778
2907
|
let isDatabaseChunk = false;
|
|
2779
|
-
if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
|
|
2908
|
+
if (status === visLib.DatabaseStreamStatus.ReadyServiceData ||
|
|
2909
|
+
(status === visLib.DatabaseStreamStatus.Complete && !isFireDatabaseChunk)) {
|
|
2780
2910
|
isFireDatabaseChunk = true;
|
|
2781
2911
|
isDatabaseChunk = true;
|
|
2782
2912
|
}
|
|
@@ -2784,20 +2914,11 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2784
2914
|
this.viewer.syncOptions();
|
|
2785
2915
|
this.viewer.syncOverlay();
|
|
2786
2916
|
updateController.update(UpdateType.kForce);
|
|
2787
|
-
this.viewer.emitEvent({
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
file: model.file,
|
|
2791
|
-
model: model
|
|
2792
|
-
});
|
|
2793
|
-
} else {
|
|
2917
|
+
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
2918
|
+
}
|
|
2919
|
+
else {
|
|
2794
2920
|
updateController.update(UpdateType.kDelay);
|
|
2795
|
-
this.viewer.emitEvent({
|
|
2796
|
-
type: "geometrychunk",
|
|
2797
|
-
data: chunk,
|
|
2798
|
-
file: model.file,
|
|
2799
|
-
model: model
|
|
2800
|
-
});
|
|
2921
|
+
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
2801
2922
|
}
|
|
2802
2923
|
};
|
|
2803
2924
|
console.time("File load time");
|
|
@@ -2809,79 +2930,68 @@ class VSFXCloudStreamingLoader extends Loader {
|
|
|
2809
2930
|
}
|
|
2810
2931
|
|
|
2811
2932
|
const PENDING_REQUESTS_SIZE = 50;
|
|
2812
|
-
|
|
2813
2933
|
const PENDING_REQUESTS_TIMEOUT = 250;
|
|
2814
|
-
|
|
2815
2934
|
class VSFXCloudPartialLoader extends Loader {
|
|
2816
2935
|
constructor(viewer) {
|
|
2817
2936
|
super();
|
|
2818
2937
|
this.viewer = viewer;
|
|
2819
|
-
this.abortControllerForRequestMap = new Map;
|
|
2938
|
+
this.abortControllerForRequestMap = new Map();
|
|
2820
2939
|
}
|
|
2821
2940
|
isSupport(file) {
|
|
2822
|
-
return typeof file === "object" &&
|
|
2941
|
+
return (typeof file === "object" &&
|
|
2942
|
+
typeof file.database === "string" &&
|
|
2943
|
+
typeof file.downloadResource === "function" &&
|
|
2944
|
+
typeof file.downloadResourceRange === "function" &&
|
|
2945
|
+
/.vsfx$/i.test(file.database) &&
|
|
2946
|
+
(this.viewer.options.enablePartialMode === true || /.rcs$/i.test(file.name)));
|
|
2823
2947
|
}
|
|
2824
2948
|
async load(model, format) {
|
|
2825
|
-
if (!this.viewer.visualizeJs)
|
|
2949
|
+
if (!this.viewer.visualizeJs)
|
|
2950
|
+
return this;
|
|
2826
2951
|
const visViewer = this.viewer.visViewer();
|
|
2827
2952
|
let servicePartAborted = false;
|
|
2828
|
-
const pendingRequestsMap = new Map;
|
|
2953
|
+
const pendingRequestsMap = new Map();
|
|
2829
2954
|
let pendingRequestsTimerId = 0;
|
|
2830
2955
|
const pendingRequestsAbortHandler = () => clearTimeout(pendingRequestsTimerId);
|
|
2831
|
-
const pendingRequestsAbortController = new AbortController;
|
|
2956
|
+
const pendingRequestsAbortController = new AbortController();
|
|
2832
2957
|
this.abortControllerForRequestMap.set(0, pendingRequestsAbortController);
|
|
2833
|
-
const updateController = new UpdateController;
|
|
2958
|
+
const updateController = new UpdateController();
|
|
2834
2959
|
updateController.initialize(this.viewer);
|
|
2835
2960
|
visViewer.memoryLimit = this.viewer.options.memoryLimit;
|
|
2836
2961
|
const chunkLoadHandler = (progress, chunk, requestId = 0) => {
|
|
2837
|
-
if (!this.viewer.visualizeJs)
|
|
2962
|
+
if (!this.viewer.visualizeJs)
|
|
2963
|
+
return;
|
|
2838
2964
|
let isDatabaseChunk;
|
|
2839
2965
|
try {
|
|
2840
2966
|
isDatabaseChunk = visViewer.parseVsfxInPartialMode(requestId, chunk);
|
|
2841
|
-
}
|
|
2967
|
+
}
|
|
2968
|
+
catch (error) {
|
|
2842
2969
|
console.error("VSFX parse error.", error);
|
|
2843
2970
|
throw error;
|
|
2844
2971
|
}
|
|
2845
|
-
this.viewer.emitEvent({
|
|
2846
|
-
type: "geometryprogress",
|
|
2847
|
-
data: progress,
|
|
2848
|
-
file: model.file,
|
|
2849
|
-
model: model
|
|
2850
|
-
});
|
|
2972
|
+
this.viewer.emitEvent({ type: "geometryprogress", data: progress, file: model.file, model });
|
|
2851
2973
|
if (isDatabaseChunk) {
|
|
2852
2974
|
this.viewer.syncOptions();
|
|
2853
2975
|
this.viewer.syncOverlay();
|
|
2854
2976
|
updateController.update(UpdateType.kForce);
|
|
2855
|
-
this.viewer.emitEvent({
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
file: model.file,
|
|
2859
|
-
model: model
|
|
2860
|
-
});
|
|
2861
|
-
} else {
|
|
2977
|
+
this.viewer.emitEvent({ type: "databasechunk", data: chunk, file: model.file, model });
|
|
2978
|
+
}
|
|
2979
|
+
else {
|
|
2862
2980
|
updateController.update(UpdateType.kDelay);
|
|
2863
|
-
this.viewer.emitEvent({
|
|
2864
|
-
type: "geometrychunk",
|
|
2865
|
-
data: chunk,
|
|
2866
|
-
file: model.file,
|
|
2867
|
-
model: model
|
|
2868
|
-
});
|
|
2981
|
+
this.viewer.emitEvent({ type: "geometrychunk", data: chunk, file: model.file, model });
|
|
2869
2982
|
}
|
|
2870
2983
|
};
|
|
2871
2984
|
const downloadResourceRange = async (dataId, requestId, ranges) => {
|
|
2872
|
-
const abortCtrl = new AbortController;
|
|
2985
|
+
const abortCtrl = new AbortController();
|
|
2873
2986
|
this.abortControllerForRequestMap.set(requestId, abortCtrl);
|
|
2874
2987
|
try {
|
|
2875
2988
|
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));
|
|
2989
|
+
}
|
|
2990
|
+
catch (error) {
|
|
2991
|
+
this.viewer.emitEvent({ type: "geometryerror", data: error, file: model.file, model });
|
|
2992
|
+
}
|
|
2993
|
+
finally {
|
|
2994
|
+
ranges.forEach((range) => visViewer.onRequestResponseComplete(range.requestId));
|
|
2885
2995
|
this.abortControllerForRequestMap.delete(requestId);
|
|
2886
2996
|
updateController.update(UpdateType.kNormal);
|
|
2887
2997
|
}
|
|
@@ -2891,16 +3001,16 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2891
3001
|
for (let i = 0; i < records.size(); i++) {
|
|
2892
3002
|
const record = records.get(i);
|
|
2893
3003
|
ranges.push({
|
|
2894
|
-
requestId
|
|
3004
|
+
requestId,
|
|
2895
3005
|
begin: Number(record.begin),
|
|
2896
|
-
end: Number(record.end) - 1
|
|
3006
|
+
end: Number(record.end) - 1,
|
|
2897
3007
|
});
|
|
2898
3008
|
record.delete();
|
|
2899
3009
|
}
|
|
2900
3010
|
return ranges;
|
|
2901
3011
|
};
|
|
2902
3012
|
const objectHandler = {
|
|
2903
|
-
onServicePartReceived: bHasIndex => {
|
|
3013
|
+
onServicePartReceived: (bHasIndex) => {
|
|
2904
3014
|
if (bHasIndex) {
|
|
2905
3015
|
servicePartAborted = true;
|
|
2906
3016
|
this.abortController.abort();
|
|
@@ -2913,13 +3023,14 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2913
3023
|
onFullLoaded: () => {
|
|
2914
3024
|
updateController.update(UpdateType.kNormal);
|
|
2915
3025
|
},
|
|
2916
|
-
onRequestResponseParsed: requestId => {
|
|
3026
|
+
onRequestResponseParsed: (requestId) => {
|
|
2917
3027
|
this.abortControllerForRequestMap.delete(requestId);
|
|
2918
3028
|
updateController.update(UpdateType.kNormal);
|
|
2919
3029
|
},
|
|
2920
|
-
onRequestAborted: requestId => {
|
|
3030
|
+
onRequestAborted: (requestId) => {
|
|
2921
3031
|
const abortCtrl = this.abortControllerForRequestMap.get(requestId);
|
|
2922
|
-
if (abortCtrl)
|
|
3032
|
+
if (abortCtrl)
|
|
3033
|
+
abortCtrl.abort();
|
|
2923
3034
|
},
|
|
2924
3035
|
onRequestResourceFile: (requestId, _, records) => {
|
|
2925
3036
|
const dataId = `${model.fileId}${model.file.type}`;
|
|
@@ -2932,10 +3043,7 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2932
3043
|
requestNumber = pendingRequest.number;
|
|
2933
3044
|
}
|
|
2934
3045
|
if (requestNumber <= 5) {
|
|
2935
|
-
pendingRequestsMap.set(dataId, {
|
|
2936
|
-
ranges: [],
|
|
2937
|
-
number: requestNumber + 1
|
|
2938
|
-
});
|
|
3046
|
+
pendingRequestsMap.set(dataId, { ranges: [], number: requestNumber + 1 });
|
|
2939
3047
|
downloadResourceRange(dataId, requestId, ranges);
|
|
2940
3048
|
return;
|
|
2941
3049
|
}
|
|
@@ -2945,65 +3053,50 @@ class VSFXCloudPartialLoader extends Loader {
|
|
|
2945
3053
|
window.clearTimeout(pendingRequestsTimerId);
|
|
2946
3054
|
pendingRequestsTimerId = 0;
|
|
2947
3055
|
}
|
|
2948
|
-
pendingRequestsMap.set(dataId, {
|
|
2949
|
-
ranges: [],
|
|
2950
|
-
number: requestNumber + 1
|
|
2951
|
-
});
|
|
3056
|
+
pendingRequestsMap.set(dataId, { ranges: [], number: requestNumber + 1 });
|
|
2952
3057
|
downloadResourceRange(dataId, requestId, pendingRanges);
|
|
2953
3058
|
return;
|
|
2954
3059
|
}
|
|
2955
|
-
pendingRequestsMap.set(dataId, {
|
|
2956
|
-
ranges: pendingRanges,
|
|
2957
|
-
number: requestNumber + 1
|
|
2958
|
-
});
|
|
3060
|
+
pendingRequestsMap.set(dataId, { ranges: pendingRanges, number: requestNumber + 1 });
|
|
2959
3061
|
if (pendingRequestsTimerId === 0) {
|
|
2960
3062
|
pendingRequestsTimerId = window.setTimeout(() => {
|
|
2961
3063
|
pendingRequestsAbortController.signal.removeEventListener("abort", pendingRequestsAbortHandler);
|
|
2962
3064
|
pendingRequestsTimerId = 0;
|
|
2963
3065
|
pendingRequestsMap.forEach((request, dataId) => {
|
|
2964
3066
|
if (request.ranges.length > 0) {
|
|
2965
|
-
pendingRequestsMap.set(dataId, {
|
|
2966
|
-
ranges: [],
|
|
2967
|
-
number: request.number + 1
|
|
2968
|
-
});
|
|
3067
|
+
pendingRequestsMap.set(dataId, { ranges: [], number: request.number + 1 });
|
|
2969
3068
|
downloadResourceRange(dataId, requestId, request.ranges);
|
|
2970
3069
|
}
|
|
2971
3070
|
});
|
|
2972
3071
|
}, PENDING_REQUESTS_TIMEOUT);
|
|
2973
|
-
pendingRequestsAbortController.signal.addEventListener("abort", pendingRequestsAbortHandler, {
|
|
2974
|
-
once: true
|
|
2975
|
-
});
|
|
3072
|
+
pendingRequestsAbortController.signal.addEventListener("abort", pendingRequestsAbortHandler, { once: true });
|
|
2976
3073
|
}
|
|
2977
|
-
}
|
|
3074
|
+
},
|
|
2978
3075
|
};
|
|
2979
3076
|
visViewer.attachPartialResolver(objectHandler);
|
|
2980
3077
|
try {
|
|
2981
3078
|
await model.downloadResource(model.database, chunkLoadHandler, this.abortController.signal);
|
|
2982
|
-
}
|
|
3079
|
+
}
|
|
3080
|
+
catch (error) {
|
|
2983
3081
|
window.clearTimeout(pendingRequestsTimerId);
|
|
2984
|
-
if (!servicePartAborted)
|
|
3082
|
+
if (!servicePartAborted)
|
|
3083
|
+
throw error;
|
|
2985
3084
|
}
|
|
2986
3085
|
return this;
|
|
2987
3086
|
}
|
|
2988
3087
|
cancel() {
|
|
2989
3088
|
super.cancel();
|
|
2990
|
-
this.abortControllerForRequestMap.forEach(controller => controller.abort());
|
|
3089
|
+
this.abortControllerForRequestMap.forEach((controller) => controller.abort());
|
|
2991
3090
|
}
|
|
2992
3091
|
}
|
|
2993
3092
|
|
|
2994
3093
|
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));
|
|
3094
|
+
loaders.registerLoader("vsf-file", (viewer) => new VSFFileLoader(viewer));
|
|
3095
|
+
loaders.registerLoader("vsf-cloud", (viewer) => new VSFCloudLoader(viewer));
|
|
3096
|
+
loaders.registerLoader("vsfx-file", (viewer) => new VSFXFileLoader(viewer));
|
|
3097
|
+
loaders.registerLoader("vsfx-cloud", (viewer) => new VSFXCloudLoader(viewer));
|
|
3098
|
+
loaders.registerLoader("vsfx-cloud-streaming", (viewer) => new VSFXCloudStreamingLoader(viewer));
|
|
3099
|
+
loaders.registerLoader("vsfx-cloud-partial", (viewer) => new VSFXCloudPartialLoader(viewer));
|
|
3007
3100
|
|
|
3008
3101
|
function loadScript(url, params = {}) {
|
|
3009
3102
|
return new Promise((resolve, reject) => {
|
|
@@ -3019,26 +3112,25 @@ function loadScript(url, params = {}) {
|
|
|
3019
3112
|
document.body.appendChild(script);
|
|
3020
3113
|
});
|
|
3021
3114
|
}
|
|
3022
|
-
|
|
3023
3115
|
function loadVisuazlizeJsScript(url, params) {
|
|
3024
3116
|
if (window["getVisualizeLibInst"]) {
|
|
3025
3117
|
const script = window["getVisualizeLibInst"].script;
|
|
3026
3118
|
if (script) {
|
|
3027
|
-
if (script.src === url)
|
|
3119
|
+
if (script.src === url)
|
|
3120
|
+
return Promise.resolve(script);
|
|
3028
3121
|
script.remove();
|
|
3029
3122
|
}
|
|
3030
3123
|
delete window["getVisualizeLibInst"];
|
|
3031
3124
|
}
|
|
3032
3125
|
return loadScript(url, params);
|
|
3033
3126
|
}
|
|
3034
|
-
|
|
3035
3127
|
const loadVisualizeJs = async (url, onprogress, params = {}) => {
|
|
3036
3128
|
const script = await loadVisuazlizeJsScript(url, params);
|
|
3037
3129
|
return await new Promise((resolve, reject) => {
|
|
3038
3130
|
const options = {
|
|
3039
3131
|
urlMemFile: url + ".wasm",
|
|
3040
3132
|
TOTAL_MEMORY: 134217728,
|
|
3041
|
-
onprogress
|
|
3133
|
+
onprogress,
|
|
3042
3134
|
};
|
|
3043
3135
|
const instance = window["getVisualizeLibInst"](options);
|
|
3044
3136
|
instance.loadWasmError = reject;
|
|
@@ -3050,7 +3142,6 @@ const loadVisualizeJs = async (url, onprogress, params = {}) => {
|
|
|
3050
3142
|
};
|
|
3051
3143
|
|
|
3052
3144
|
const MARKUP_ENTITY_LINE = "$MarkupTempEntity_Line";
|
|
3053
|
-
|
|
3054
3145
|
class OdaLineDragger extends OdBaseDragger {
|
|
3055
3146
|
constructor(subject) {
|
|
3056
3147
|
super(subject);
|
|
@@ -3064,7 +3155,7 @@ class OdaLineDragger extends OdBaseDragger {
|
|
|
3064
3155
|
}
|
|
3065
3156
|
start(x, y) {
|
|
3066
3157
|
const point = this.getViewer().screenToWorld(x, y);
|
|
3067
|
-
this.drawPoints = [
|
|
3158
|
+
this.drawPoints = [point[0], point[1], point[2]];
|
|
3068
3159
|
}
|
|
3069
3160
|
drag(x, y) {
|
|
3070
3161
|
if (this.isDragging) {
|
|
@@ -3095,7 +3186,6 @@ class OdaLineDragger extends OdBaseDragger {
|
|
|
3095
3186
|
}
|
|
3096
3187
|
|
|
3097
3188
|
const MARKUP_ENTITY_TEXT = "$MarkupTempEntity_Text";
|
|
3098
|
-
|
|
3099
3189
|
class OdaTextDragger extends OdBaseDragger {
|
|
3100
3190
|
constructor(subject) {
|
|
3101
3191
|
super(subject);
|
|
@@ -3124,7 +3214,7 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3124
3214
|
this.textRef.style.display = "block";
|
|
3125
3215
|
this.textRef.style.top = absoluteY + "px";
|
|
3126
3216
|
this.textRef.style.left = absoluteX + "px";
|
|
3127
|
-
this.textRef.onkeypress = event => {
|
|
3217
|
+
this.textRef.onkeypress = (event) => {
|
|
3128
3218
|
if (event.key === "Enter") {
|
|
3129
3219
|
event.preventDefault();
|
|
3130
3220
|
this._finishInput();
|
|
@@ -3134,7 +3224,8 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3134
3224
|
this.press = true;
|
|
3135
3225
|
this.m_center = this.screenToWorld(x, y + this.TEXT_HEIGHT_ALIGN);
|
|
3136
3226
|
this.needInputText = true;
|
|
3137
|
-
}
|
|
3227
|
+
}
|
|
3228
|
+
else {
|
|
3138
3229
|
this._finishInput();
|
|
3139
3230
|
}
|
|
3140
3231
|
}
|
|
@@ -3146,17 +3237,17 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3146
3237
|
const target = this.toPoint(view.viewTarget);
|
|
3147
3238
|
const eyeToWorld = view.eyeToWorldMatrix;
|
|
3148
3239
|
const eyeDir = pos.sub(target).asVector();
|
|
3149
|
-
const xDir = this.toVector([
|
|
3240
|
+
const xDir = this.toVector([1.0, 0.0, 0.0]);
|
|
3150
3241
|
const direction = xDir.transformBy(eyeToWorld);
|
|
3151
3242
|
const mtrx = this.createMatrix3d();
|
|
3152
3243
|
mtrx.setToWorldToPlane(this.toGeVector(eyeDir));
|
|
3153
3244
|
direction.transformBy(mtrx);
|
|
3154
3245
|
const angel = -Math.atan2(-direction.y, direction.x);
|
|
3155
|
-
const textSize = .02;
|
|
3156
|
-
let textScale = 1;
|
|
3246
|
+
const textSize = 0.02;
|
|
3247
|
+
let textScale = 1.0;
|
|
3157
3248
|
const projMtrx = view.projectionMatrix;
|
|
3158
3249
|
const mtrxNumber = projMtrx.get(1, 1);
|
|
3159
|
-
const tol =
|
|
3250
|
+
const tol = 1.0e-6;
|
|
3160
3251
|
if (!(mtrxNumber < tol && mtrxNumber > -tol)) {
|
|
3161
3252
|
textScale = 1 / mtrxNumber;
|
|
3162
3253
|
}
|
|
@@ -3173,11 +3264,7 @@ class OdaTextDragger extends OdBaseDragger {
|
|
|
3173
3264
|
|
|
3174
3265
|
class VisualizeMarkup {
|
|
3175
3266
|
constructor() {
|
|
3176
|
-
this._markupColor = {
|
|
3177
|
-
r: 255,
|
|
3178
|
-
g: 0,
|
|
3179
|
-
b: 0
|
|
3180
|
-
};
|
|
3267
|
+
this._markupColor = { r: 255, g: 0, b: 0 };
|
|
3181
3268
|
this.lineWidth = 4;
|
|
3182
3269
|
this.fontSize = 34;
|
|
3183
3270
|
}
|
|
@@ -3186,10 +3273,11 @@ class VisualizeMarkup {
|
|
|
3186
3273
|
this._viewer.registerDragger("Line", OdaLineDragger);
|
|
3187
3274
|
this._viewer.registerDragger("Text", OdaTextDragger);
|
|
3188
3275
|
}
|
|
3189
|
-
dispose() {}
|
|
3190
|
-
syncOverlay() {}
|
|
3276
|
+
dispose() { }
|
|
3277
|
+
syncOverlay() { }
|
|
3191
3278
|
clearOverlay() {
|
|
3192
|
-
if (!this._viewer.visualizeJs)
|
|
3279
|
+
if (!this._viewer.visualizeJs)
|
|
3280
|
+
return;
|
|
3193
3281
|
const visViewer = this._viewer.visViewer();
|
|
3194
3282
|
const model = visViewer.getMarkupModel();
|
|
3195
3283
|
model.clearEntities();
|
|
@@ -3199,23 +3287,17 @@ class VisualizeMarkup {
|
|
|
3199
3287
|
return this._markupColor;
|
|
3200
3288
|
}
|
|
3201
3289
|
setMarkupColor(r, g, b) {
|
|
3202
|
-
const color = {
|
|
3203
|
-
r: r,
|
|
3204
|
-
g: g,
|
|
3205
|
-
b: b
|
|
3206
|
-
};
|
|
3290
|
+
const color = { r, g, b };
|
|
3207
3291
|
this._markupColor = color;
|
|
3208
|
-
this._viewer.emitEvent({
|
|
3209
|
-
type: "changemarkupcolor",
|
|
3210
|
-
data: color
|
|
3211
|
-
});
|
|
3292
|
+
this._viewer.emitEvent({ type: "changemarkupcolor", data: color });
|
|
3212
3293
|
}
|
|
3213
3294
|
colorizeAllMarkup(r = 255, g = 0, b = 0) {
|
|
3214
|
-
if (!this._viewer.visualizeJs)
|
|
3295
|
+
if (!this._viewer.visualizeJs)
|
|
3296
|
+
return;
|
|
3215
3297
|
const visViewer = this._viewer.visViewer();
|
|
3216
3298
|
const model = visViewer.getMarkupModel();
|
|
3217
3299
|
const itr = model.getEntitiesIterator();
|
|
3218
|
-
for (
|
|
3300
|
+
for (; !itr.done(); itr.step()) {
|
|
3219
3301
|
const entityId = itr.getEntity();
|
|
3220
3302
|
const entityPtr = entityId.openObject();
|
|
3221
3303
|
const entityName = entityPtr.getName();
|
|
@@ -3232,21 +3314,18 @@ class VisualizeMarkup {
|
|
|
3232
3314
|
}
|
|
3233
3315
|
setViewpoint(viewpoint) {
|
|
3234
3316
|
function getLogicalPoint3dAsArray(point3d) {
|
|
3235
|
-
return [
|
|
3317
|
+
return [point3d.x, point3d.y, point3d.z];
|
|
3236
3318
|
}
|
|
3237
3319
|
function getPoint3d(module, gePoint) {
|
|
3238
3320
|
return module.Point3d.createFromArray(gePoint);
|
|
3239
3321
|
}
|
|
3240
|
-
if (!this._viewer.visualizeJs)
|
|
3322
|
+
if (!this._viewer.visualizeJs)
|
|
3323
|
+
return;
|
|
3241
3324
|
const visLib = this._viewer.visLib();
|
|
3242
3325
|
const visViewer = this._viewer.visViewer();
|
|
3243
3326
|
const activeView = visViewer.activeView;
|
|
3244
3327
|
this._viewer.syncOverlay();
|
|
3245
|
-
const markupColor = viewpoint.custom_fields.markup_color || {
|
|
3246
|
-
r: 255,
|
|
3247
|
-
g: 0,
|
|
3248
|
-
b: 0
|
|
3249
|
-
};
|
|
3328
|
+
const markupColor = viewpoint.custom_fields.markup_color || { r: 255, g: 0, b: 0 };
|
|
3250
3329
|
this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
|
|
3251
3330
|
if (viewpoint.lines) {
|
|
3252
3331
|
for (const line of viewpoint.lines) {
|
|
@@ -3281,22 +3360,20 @@ class VisualizeMarkup {
|
|
|
3281
3360
|
this._viewer.update();
|
|
3282
3361
|
}
|
|
3283
3362
|
getViewpoint(viewpoint) {
|
|
3284
|
-
if (!this._viewer.visualizeJs)
|
|
3363
|
+
if (!this._viewer.visualizeJs)
|
|
3364
|
+
return {};
|
|
3285
3365
|
function getLogicalPoint3dFromArray(array) {
|
|
3286
|
-
return {
|
|
3287
|
-
x: array[0],
|
|
3288
|
-
y: array[1],
|
|
3289
|
-
z: array[2]
|
|
3290
|
-
};
|
|
3366
|
+
return { x: array[0], y: array[1], z: array[2] };
|
|
3291
3367
|
}
|
|
3292
3368
|
const visLib = this._viewer.visLib();
|
|
3293
3369
|
const visViewer = this._viewer.visViewer();
|
|
3294
|
-
if (!viewpoint)
|
|
3370
|
+
if (!viewpoint)
|
|
3371
|
+
viewpoint = {};
|
|
3295
3372
|
viewpoint.lines = [];
|
|
3296
3373
|
viewpoint.texts = [];
|
|
3297
3374
|
const model = visViewer.getMarkupModel();
|
|
3298
3375
|
const itr = model.getEntitiesIterator();
|
|
3299
|
-
for (
|
|
3376
|
+
for (; !itr.done(); itr.step()) {
|
|
3300
3377
|
const entityId = itr.getEntity();
|
|
3301
3378
|
const entityPtr = entityId.openObject();
|
|
3302
3379
|
const entityName = entityPtr.getName();
|
|
@@ -3310,21 +3387,22 @@ class VisualizeMarkup {
|
|
|
3310
3387
|
const polylinePtr = geometryId.openAsPolyline();
|
|
3311
3388
|
const points = polylinePtr.getPoints();
|
|
3312
3389
|
const line = {
|
|
3313
|
-
points: []
|
|
3390
|
+
points: [],
|
|
3314
3391
|
};
|
|
3315
3392
|
for (const point of points) {
|
|
3316
3393
|
line.points.push(getLogicalPoint3dFromArray(point));
|
|
3317
3394
|
}
|
|
3318
3395
|
viewpoint.lines.push(line);
|
|
3319
3396
|
polylinePtr.delete();
|
|
3320
|
-
}
|
|
3397
|
+
}
|
|
3398
|
+
else if (entityName === MARKUP_ENTITY_TEXT) {
|
|
3321
3399
|
const textPtr = geometryId.openAsText();
|
|
3322
3400
|
const position = textPtr.getPosition();
|
|
3323
3401
|
const text = {
|
|
3324
3402
|
position: getLogicalPoint3dFromArray(position),
|
|
3325
3403
|
text: textPtr.getString(),
|
|
3326
3404
|
angle: textPtr.getRotation(),
|
|
3327
|
-
text_size: textPtr.getTextSize()
|
|
3405
|
+
text_size: textPtr.getTextSize(),
|
|
3328
3406
|
};
|
|
3329
3407
|
viewpoint.texts.push(text);
|
|
3330
3408
|
textPtr.delete();
|
|
@@ -3333,10 +3411,10 @@ class VisualizeMarkup {
|
|
|
3333
3411
|
}
|
|
3334
3412
|
itr.delete();
|
|
3335
3413
|
viewpoint.snapshot = {
|
|
3336
|
-
data: visLib.canvas.toDataURL("image/jpeg", .25)
|
|
3414
|
+
data: visLib.canvas.toDataURL("image/jpeg", 0.25),
|
|
3337
3415
|
};
|
|
3338
3416
|
viewpoint.custom_fields = {
|
|
3339
|
-
markup_color: this.getMarkupColor()
|
|
3417
|
+
markup_color: this.getMarkupColor(),
|
|
3340
3418
|
};
|
|
3341
3419
|
return viewpoint;
|
|
3342
3420
|
}
|
|
@@ -3352,33 +3430,29 @@ class VisualizeMarkup {
|
|
|
3352
3430
|
getSelectedObjects() {
|
|
3353
3431
|
return [];
|
|
3354
3432
|
}
|
|
3355
|
-
selectObjects(objects) {}
|
|
3356
|
-
clearSelected() {}
|
|
3433
|
+
selectObjects(objects) { }
|
|
3434
|
+
clearSelected() { }
|
|
3357
3435
|
}
|
|
3358
3436
|
|
|
3359
3437
|
class MarkupFactory {
|
|
3360
3438
|
static createMarkup(markupType = "Konva") {
|
|
3361
3439
|
let markup;
|
|
3362
3440
|
switch (markupType) {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
default:
|
|
3372
|
-
throw new Error("Error during Markup initialization. Unknown Markup type.");
|
|
3441
|
+
case "Konva":
|
|
3442
|
+
markup = new Markup();
|
|
3443
|
+
break;
|
|
3444
|
+
case "Visualize":
|
|
3445
|
+
markup = new VisualizeMarkup();
|
|
3446
|
+
break;
|
|
3447
|
+
default:
|
|
3448
|
+
throw new Error("Error during Markup initialization. Unknown Markup type.");
|
|
3373
3449
|
}
|
|
3374
3450
|
return markup;
|
|
3375
3451
|
}
|
|
3376
3452
|
}
|
|
3377
3453
|
|
|
3378
3454
|
const OVERLAY_VIEW_NAME = "$OVERLAY_VIEW_NAME";
|
|
3379
|
-
|
|
3380
|
-
const isExist = value => value !== undefined && value !== null;
|
|
3381
|
-
|
|
3455
|
+
const isExist = (value) => value !== undefined && value !== null;
|
|
3382
3456
|
class Viewer extends EventEmitter2 {
|
|
3383
3457
|
constructor(client, params = {}) {
|
|
3384
3458
|
var _a;
|
|
@@ -3392,7 +3466,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3392
3466
|
this._components = [];
|
|
3393
3467
|
this._renderTime = 0;
|
|
3394
3468
|
this.canvasEvents = CANVAS_EVENTS.slice();
|
|
3395
|
-
this.canvaseventlistener = event => this.emit(event);
|
|
3469
|
+
this.canvaseventlistener = (event) => this.emit(event);
|
|
3396
3470
|
this._enableAutoUpdate = (_a = params.enableAutoUpdate) !== null && _a !== void 0 ? _a : true;
|
|
3397
3471
|
this._renderNeeded = false;
|
|
3398
3472
|
this._isRunAsyncUpdate = false;
|
|
@@ -3415,7 +3489,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3415
3489
|
return this;
|
|
3416
3490
|
}
|
|
3417
3491
|
async initialize(canvas, onProgress) {
|
|
3418
|
-
this.addEventListener("optionschange", event => this.syncOptions(event.data));
|
|
3492
|
+
this.addEventListener("optionschange", (event) => this.syncOptions(event.data));
|
|
3419
3493
|
const rect = canvas.parentElement.getBoundingClientRect();
|
|
3420
3494
|
const width = rect.width || 1;
|
|
3421
3495
|
const height = rect.height || 1;
|
|
@@ -3427,29 +3501,20 @@ class Viewer extends EventEmitter2 {
|
|
|
3427
3501
|
canvas.style.touchAction = "none";
|
|
3428
3502
|
this._visualizeTimestamp = Date.now();
|
|
3429
3503
|
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?");
|
|
3504
|
+
const visualizeJs = await loadVisualizeJs(this.visualizeJsUrl, (event) => {
|
|
3505
|
+
const { loaded, total } = event;
|
|
3506
|
+
if (onProgress)
|
|
3507
|
+
onProgress(new ProgressEvent("progress", { lengthComputable: true, loaded, total }));
|
|
3508
|
+
this.emitEvent({ type: "initializeprogress", data: loaded / total, loaded, total });
|
|
3509
|
+
}, { crossOrigin: this._crossOrigin });
|
|
3510
|
+
if (visualizeTimestamp !== this._visualizeTimestamp)
|
|
3511
|
+
throw new Error("Viewer error: dispose() was called before initialize() completed. Are you using React strict mode?");
|
|
3447
3512
|
this._visualizeJs = visualizeJs;
|
|
3448
3513
|
this._visualizeJs.canvas = canvas;
|
|
3449
3514
|
this._viewer = visualizeJs.Viewer.create();
|
|
3450
3515
|
this._viewer.resize(0, canvas.width, canvas.height, 0);
|
|
3451
3516
|
this.canvas = canvas;
|
|
3452
|
-
this.canvasEvents.forEach(x => canvas.addEventListener(x, this.canvaseventlistener));
|
|
3517
|
+
this.canvasEvents.forEach((x) => canvas.addEventListener(x, this.canvaseventlistener));
|
|
3453
3518
|
this._markup.initialize(this.canvas, this.canvasEvents, this, this);
|
|
3454
3519
|
for (const name of components.getComponents().keys()) {
|
|
3455
3520
|
this._components.push(components.createComponent(name, this));
|
|
@@ -3458,27 +3523,24 @@ class Viewer extends EventEmitter2 {
|
|
|
3458
3523
|
this.syncOverlay();
|
|
3459
3524
|
this._renderTime = performance.now();
|
|
3460
3525
|
this.render(this._renderTime);
|
|
3461
|
-
this.emitEvent({
|
|
3462
|
-
type: "initialize"
|
|
3463
|
-
});
|
|
3526
|
+
this.emitEvent({ type: "initialize" });
|
|
3464
3527
|
return this;
|
|
3465
3528
|
}
|
|
3466
3529
|
dispose() {
|
|
3467
3530
|
this.cancel();
|
|
3468
3531
|
this.clear();
|
|
3469
|
-
this.emitEvent({
|
|
3470
|
-
type: "dispose"
|
|
3471
|
-
});
|
|
3532
|
+
this.emitEvent({ type: "dispose" });
|
|
3472
3533
|
this.removeAllListeners();
|
|
3473
3534
|
this.setActiveDragger();
|
|
3474
|
-
this._components.forEach(component => component.dispose());
|
|
3535
|
+
this._components.forEach((component) => component.dispose());
|
|
3475
3536
|
this._components = [];
|
|
3476
3537
|
this._markup.dispose();
|
|
3477
3538
|
if (this.canvas) {
|
|
3478
|
-
this.canvasEvents.forEach(x => this.canvas.removeEventListener(x, this.canvaseventlistener));
|
|
3539
|
+
this.canvasEvents.forEach((x) => this.canvas.removeEventListener(x, this.canvaseventlistener));
|
|
3479
3540
|
this.canvas = undefined;
|
|
3480
3541
|
}
|
|
3481
|
-
if (this._viewer)
|
|
3542
|
+
if (this._viewer)
|
|
3543
|
+
this._viewer.clear();
|
|
3482
3544
|
this._visualizeJs = undefined;
|
|
3483
3545
|
this._visualizeTimestamp = undefined;
|
|
3484
3546
|
this._viewer = undefined;
|
|
@@ -3488,7 +3550,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3488
3550
|
return !!this.visualizeJs;
|
|
3489
3551
|
}
|
|
3490
3552
|
setSize(width, height, updateStyle = true) {
|
|
3491
|
-
if (!this.visualizeJs)
|
|
3553
|
+
if (!this.visualizeJs)
|
|
3554
|
+
return;
|
|
3492
3555
|
this.canvas.width = Math.round(width * window.devicePixelRatio);
|
|
3493
3556
|
this.canvas.height = Math.round(height * window.devicePixelRatio);
|
|
3494
3557
|
if (updateStyle) {
|
|
@@ -3497,48 +3560,45 @@ class Viewer extends EventEmitter2 {
|
|
|
3497
3560
|
}
|
|
3498
3561
|
this._viewer.resize(0, this.canvas.width, this.canvas.height, 0);
|
|
3499
3562
|
this.update(true);
|
|
3500
|
-
this.emitEvent({
|
|
3501
|
-
type: "resize",
|
|
3502
|
-
width: width,
|
|
3503
|
-
height: height
|
|
3504
|
-
});
|
|
3563
|
+
this.emitEvent({ type: "resize", width, height });
|
|
3505
3564
|
}
|
|
3506
3565
|
render(time) {
|
|
3507
3566
|
var _a, _b;
|
|
3508
|
-
if (!this.visualizeJs)
|
|
3509
|
-
|
|
3567
|
+
if (!this.visualizeJs)
|
|
3568
|
+
return;
|
|
3569
|
+
if (this._isRunAsyncUpdate)
|
|
3570
|
+
return;
|
|
3510
3571
|
const renderNeeded = this.visViewer().isRunningAnimation() || this._renderNeeded;
|
|
3511
|
-
if (!renderNeeded)
|
|
3512
|
-
|
|
3513
|
-
|
|
3572
|
+
if (!renderNeeded)
|
|
3573
|
+
return;
|
|
3574
|
+
if (!time)
|
|
3575
|
+
time = performance.now();
|
|
3576
|
+
const deltaTime = (time - this._renderTime) / 1000;
|
|
3514
3577
|
this._renderTime = time;
|
|
3515
3578
|
this._renderNeeded = !this.visViewer().getActiveDevice().isValid();
|
|
3516
3579
|
this.visViewer().update();
|
|
3517
3580
|
(_b = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.updatePreview) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3518
|
-
this.emitEvent({
|
|
3519
|
-
type: "render",
|
|
3520
|
-
time: time,
|
|
3521
|
-
deltaTime: deltaTime
|
|
3522
|
-
});
|
|
3581
|
+
this.emitEvent({ type: "render", time, deltaTime });
|
|
3523
3582
|
}
|
|
3524
3583
|
resize() {
|
|
3525
3584
|
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
|
-
|
|
3585
|
+
if (!this.visualizeJs)
|
|
3586
|
+
return this;
|
|
3587
|
+
if (!this.canvas.parentElement)
|
|
3588
|
+
return this;
|
|
3589
|
+
const { width, height } = this.canvas.parentElement.getBoundingClientRect();
|
|
3590
|
+
if (!width || !height)
|
|
3591
|
+
return this;
|
|
3530
3592
|
this.setSize(width, height);
|
|
3531
3593
|
return this;
|
|
3532
3594
|
}
|
|
3533
3595
|
update(force = false) {
|
|
3534
3596
|
if (this._enableAutoUpdate) {
|
|
3535
3597
|
this._renderNeeded = true;
|
|
3536
|
-
if (force)
|
|
3598
|
+
if (force)
|
|
3599
|
+
this.render();
|
|
3537
3600
|
}
|
|
3538
|
-
this.emitEvent({
|
|
3539
|
-
type: "update",
|
|
3540
|
-
data: force
|
|
3541
|
-
});
|
|
3601
|
+
this.emitEvent({ type: "update", data: force });
|
|
3542
3602
|
}
|
|
3543
3603
|
scheduleUpdateAsync(maxScheduleUpdateTimeInMs = 50) {
|
|
3544
3604
|
return new Promise((resolve, reject) => {
|
|
@@ -3549,12 +3609,10 @@ class Viewer extends EventEmitter2 {
|
|
|
3549
3609
|
(_a = this.visViewer()) === null || _a === void 0 ? void 0 : _a.update(maxScheduleUpdateTimeInMs);
|
|
3550
3610
|
(_c = (_b = this._activeDragger) === null || _b === void 0 ? void 0 : _b.updatePreview) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
3551
3611
|
}
|
|
3552
|
-
this.emitEvent({
|
|
3553
|
-
type: "update",
|
|
3554
|
-
data: false
|
|
3555
|
-
});
|
|
3612
|
+
this.emitEvent({ type: "update", data: false });
|
|
3556
3613
|
resolve();
|
|
3557
|
-
}
|
|
3614
|
+
}
|
|
3615
|
+
catch (e) {
|
|
3558
3616
|
console.error(e);
|
|
3559
3617
|
reject();
|
|
3560
3618
|
}
|
|
@@ -3562,7 +3620,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3562
3620
|
});
|
|
3563
3621
|
}
|
|
3564
3622
|
async updateAsync(maxScheduleUpdateTimeInMs = 50, maxScheduleUpdateCount = 50) {
|
|
3565
|
-
if (!this.visualizeJs)
|
|
3623
|
+
if (!this.visualizeJs)
|
|
3624
|
+
return;
|
|
3566
3625
|
this._isRunAsyncUpdate = true;
|
|
3567
3626
|
try {
|
|
3568
3627
|
const device = this.visViewer().getActiveDevice();
|
|
@@ -3570,9 +3629,11 @@ class Viewer extends EventEmitter2 {
|
|
|
3570
3629
|
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
3571
3630
|
}
|
|
3572
3631
|
await this.scheduleUpdateAsync(maxScheduleUpdateTimeInMs);
|
|
3573
|
-
}
|
|
3632
|
+
}
|
|
3633
|
+
catch (e) {
|
|
3574
3634
|
console.error(e);
|
|
3575
|
-
}
|
|
3635
|
+
}
|
|
3636
|
+
finally {
|
|
3576
3637
|
this._isRunAsyncUpdate = false;
|
|
3577
3638
|
}
|
|
3578
3639
|
}
|
|
@@ -3586,18 +3647,21 @@ class Viewer extends EventEmitter2 {
|
|
|
3586
3647
|
return this._viewer;
|
|
3587
3648
|
}
|
|
3588
3649
|
syncOpenCloudVisualStyle() {
|
|
3589
|
-
if (!this.visualizeJs)
|
|
3650
|
+
if (!this.visualizeJs)
|
|
3651
|
+
return this;
|
|
3590
3652
|
const visLib = this.visLib();
|
|
3591
3653
|
const visViewer = this.visViewer();
|
|
3592
3654
|
const device = visViewer.getActiveDevice();
|
|
3593
|
-
if (device.isNull())
|
|
3655
|
+
if (device.isNull())
|
|
3656
|
+
return this;
|
|
3594
3657
|
const view = device.getActiveView();
|
|
3595
3658
|
view.enableDefaultLighting(true, visLib.DefaultLightingType.kTwoLights);
|
|
3596
3659
|
view.setDefaultLightingIntensity(1.25);
|
|
3597
3660
|
let visualStyleId;
|
|
3598
3661
|
try {
|
|
3599
3662
|
visualStyleId = visViewer.findVisualStyle("OpenCloud");
|
|
3600
|
-
}
|
|
3663
|
+
}
|
|
3664
|
+
catch {
|
|
3601
3665
|
visualStyleId = undefined;
|
|
3602
3666
|
}
|
|
3603
3667
|
if (!visualStyleId || visualStyleId.isNull()) {
|
|
@@ -3620,12 +3684,14 @@ class Viewer extends EventEmitter2 {
|
|
|
3620
3684
|
return this;
|
|
3621
3685
|
}
|
|
3622
3686
|
syncOptions(options = this.options) {
|
|
3623
|
-
if (!this.visualizeJs)
|
|
3687
|
+
if (!this.visualizeJs)
|
|
3688
|
+
return this;
|
|
3624
3689
|
this.syncOpenCloudVisualStyle();
|
|
3625
3690
|
const visLib = this.visLib();
|
|
3626
3691
|
const visViewer = this.visViewer();
|
|
3627
3692
|
const device = visViewer.getActiveDevice();
|
|
3628
|
-
if (device.isNull())
|
|
3693
|
+
if (device.isNull())
|
|
3694
|
+
return this;
|
|
3629
3695
|
if (options.showWCS !== visViewer.getEnableWCS()) {
|
|
3630
3696
|
visViewer.setEnableWCS(options.showWCS);
|
|
3631
3697
|
}
|
|
@@ -3640,7 +3706,7 @@ class Viewer extends EventEmitter2 {
|
|
|
3640
3706
|
if (options.shadows !== visViewer.shadows) {
|
|
3641
3707
|
visViewer.shadows = options.shadows;
|
|
3642
3708
|
const canvas = visLib.canvas;
|
|
3643
|
-
device.invalidate([
|
|
3709
|
+
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
3644
3710
|
}
|
|
3645
3711
|
if (options.groundShadow !== visViewer.groundShadow) {
|
|
3646
3712
|
visViewer.groundShadow = options.groundShadow;
|
|
@@ -3672,11 +3738,12 @@ class Viewer extends EventEmitter2 {
|
|
|
3672
3738
|
return this;
|
|
3673
3739
|
}
|
|
3674
3740
|
syncHighlightingOptions(options = this.options) {
|
|
3675
|
-
if (!this.visualizeJs)
|
|
3741
|
+
if (!this.visualizeJs)
|
|
3742
|
+
return this;
|
|
3676
3743
|
const params = options.enableCustomHighlight ? options : Options.defaults();
|
|
3677
3744
|
const visLib = this.visLib();
|
|
3678
3745
|
const visViewer = this.visViewer();
|
|
3679
|
-
const {
|
|
3746
|
+
const { Entry, OdTvRGBColorDef } = visLib;
|
|
3680
3747
|
const highlightStyleId = visViewer.findHighlightStyle("Web_Default");
|
|
3681
3748
|
const highlightStylePtr = highlightStyleId.openObject();
|
|
3682
3749
|
if (isExist(params.facesColor)) {
|
|
@@ -3705,20 +3772,20 @@ class Viewer extends EventEmitter2 {
|
|
|
3705
3772
|
const device = visViewer.getActiveDevice();
|
|
3706
3773
|
if (!device.isNull()) {
|
|
3707
3774
|
const canvas = visLib.canvas;
|
|
3708
|
-
device.invalidate([
|
|
3775
|
+
device.invalidate([0, canvas.width, canvas.height, 0]);
|
|
3709
3776
|
device.delete();
|
|
3710
3777
|
}
|
|
3711
3778
|
return this;
|
|
3712
3779
|
}
|
|
3713
3780
|
get draggers() {
|
|
3714
|
-
return [
|
|
3781
|
+
return [...draggers.getDraggers().keys()];
|
|
3715
3782
|
}
|
|
3716
3783
|
get components() {
|
|
3717
|
-
return [
|
|
3784
|
+
return [...components.getComponents().keys()];
|
|
3718
3785
|
}
|
|
3719
3786
|
registerDragger(name, dragger) {
|
|
3720
3787
|
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));
|
|
3788
|
+
draggers.registerDragger(name, (viewer) => new dragger(viewer));
|
|
3722
3789
|
}
|
|
3723
3790
|
activeDragger() {
|
|
3724
3791
|
return this._activeDragger;
|
|
@@ -3741,13 +3808,12 @@ class Viewer extends EventEmitter2 {
|
|
|
3741
3808
|
}
|
|
3742
3809
|
const canvas = this.canvas;
|
|
3743
3810
|
if (canvas) {
|
|
3744
|
-
if (oldDragger)
|
|
3745
|
-
|
|
3811
|
+
if (oldDragger)
|
|
3812
|
+
canvas.classList.remove(`oda-cursor-${oldDragger.name.toLowerCase()}`);
|
|
3813
|
+
if (newDragger)
|
|
3814
|
+
canvas.classList.add(`oda-cursor-${newDragger.name.toLowerCase()}`);
|
|
3746
3815
|
}
|
|
3747
|
-
this.emitEvent({
|
|
3748
|
-
type: "changeactivedragger",
|
|
3749
|
-
data: name
|
|
3750
|
-
});
|
|
3816
|
+
this.emitEvent({ type: "changeactivedragger", data: name });
|
|
3751
3817
|
this.update();
|
|
3752
3818
|
}
|
|
3753
3819
|
return this._activeDragger;
|
|
@@ -3760,10 +3826,11 @@ class Viewer extends EventEmitter2 {
|
|
|
3760
3826
|
}
|
|
3761
3827
|
}
|
|
3762
3828
|
getComponent(name) {
|
|
3763
|
-
return this._components.find(component => component.name === name);
|
|
3829
|
+
return this._components.find((component) => component.name === name);
|
|
3764
3830
|
}
|
|
3765
3831
|
clearSlices() {
|
|
3766
|
-
if (!this.visualizeJs)
|
|
3832
|
+
if (!this.visualizeJs)
|
|
3833
|
+
return;
|
|
3767
3834
|
const visViewer = this.visViewer();
|
|
3768
3835
|
const activeView = visViewer.activeView;
|
|
3769
3836
|
activeView.removeCuttingPlanes();
|
|
@@ -3771,12 +3838,14 @@ class Viewer extends EventEmitter2 {
|
|
|
3771
3838
|
this.update();
|
|
3772
3839
|
}
|
|
3773
3840
|
clearOverlay() {
|
|
3774
|
-
if (!this.visualizeJs)
|
|
3841
|
+
if (!this.visualizeJs)
|
|
3842
|
+
return;
|
|
3775
3843
|
this._markup.clearOverlay();
|
|
3776
3844
|
this.update();
|
|
3777
3845
|
}
|
|
3778
3846
|
syncOverlay() {
|
|
3779
|
-
if (!this.visualizeJs)
|
|
3847
|
+
if (!this.visualizeJs)
|
|
3848
|
+
return;
|
|
3780
3849
|
const visViewer = this.visViewer();
|
|
3781
3850
|
const activeView = visViewer.activeView;
|
|
3782
3851
|
let overlayView = visViewer.getViewByName(OVERLAY_VIEW_NAME);
|
|
@@ -3800,7 +3869,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3800
3869
|
this.update();
|
|
3801
3870
|
}
|
|
3802
3871
|
is3D() {
|
|
3803
|
-
if (!this.visualizeJs)
|
|
3872
|
+
if (!this.visualizeJs)
|
|
3873
|
+
return false;
|
|
3804
3874
|
const visViewer = this.visViewer();
|
|
3805
3875
|
const ext = visViewer.getActiveExtents();
|
|
3806
3876
|
const min = ext.min();
|
|
@@ -3809,49 +3879,36 @@ class Viewer extends EventEmitter2 {
|
|
|
3809
3879
|
return extHeight !== 0;
|
|
3810
3880
|
}
|
|
3811
3881
|
screenToWorld(position) {
|
|
3812
|
-
if (!this.visualizeJs)
|
|
3813
|
-
x: position.x,
|
|
3814
|
-
y: position.y,
|
|
3815
|
-
z: 0
|
|
3816
|
-
};
|
|
3882
|
+
if (!this.visualizeJs)
|
|
3883
|
+
return { x: position.x, y: position.y, z: 0 };
|
|
3817
3884
|
const activeView = this.visViewer().activeView;
|
|
3818
3885
|
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
|
-
};
|
|
3886
|
+
const result = { x: worldPoint[0], y: worldPoint[1], z: worldPoint[2] };
|
|
3824
3887
|
activeView.delete();
|
|
3825
3888
|
return result;
|
|
3826
3889
|
}
|
|
3827
3890
|
worldToScreen(position) {
|
|
3828
|
-
if (!this.visualizeJs)
|
|
3829
|
-
x: position.x,
|
|
3830
|
-
y: position.y
|
|
3831
|
-
};
|
|
3891
|
+
if (!this.visualizeJs)
|
|
3892
|
+
return { x: position.x, y: position.y };
|
|
3832
3893
|
const activeView = this.visViewer().activeView;
|
|
3833
3894
|
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
|
-
};
|
|
3895
|
+
const result = { x: devicePoint[0] / window.devicePixelRatio, y: devicePoint[1] / window.devicePixelRatio };
|
|
3838
3896
|
activeView.delete();
|
|
3839
3897
|
return result;
|
|
3840
3898
|
}
|
|
3841
3899
|
getScale() {
|
|
3842
|
-
const result = {
|
|
3843
|
-
x: 1,
|
|
3844
|
-
y: 1,
|
|
3845
|
-
z: 1
|
|
3846
|
-
};
|
|
3900
|
+
const result = { x: 1.0, y: 1.0, z: 1.0 };
|
|
3847
3901
|
const projMatrix = this.visViewer().activeView.projectionMatrix;
|
|
3848
|
-
const tolerance =
|
|
3902
|
+
const tolerance = 1.0e-6;
|
|
3849
3903
|
const x = projMatrix.get(0, 0);
|
|
3850
|
-
if (x > tolerance || x < -tolerance)
|
|
3904
|
+
if (x > tolerance || x < -tolerance)
|
|
3905
|
+
result.x = 1 / x;
|
|
3851
3906
|
const y = projMatrix.get(1, 1);
|
|
3852
|
-
if (y > tolerance || y < -tolerance)
|
|
3907
|
+
if (y > tolerance || y < -tolerance)
|
|
3908
|
+
result.y = 1 / y;
|
|
3853
3909
|
const z = projMatrix.get(2, 2);
|
|
3854
|
-
if (z > tolerance || z < -tolerance)
|
|
3910
|
+
if (z > tolerance || z < -tolerance)
|
|
3911
|
+
result.z = 1 / z;
|
|
3855
3912
|
return result;
|
|
3856
3913
|
}
|
|
3857
3914
|
getSelected() {
|
|
@@ -3880,19 +3937,25 @@ class Viewer extends EventEmitter2 {
|
|
|
3880
3937
|
}
|
|
3881
3938
|
async loadReferences(model) {
|
|
3882
3939
|
var _a;
|
|
3883
|
-
if (!this.visualizeJs)
|
|
3884
|
-
|
|
3885
|
-
if (!
|
|
3886
|
-
|
|
3940
|
+
if (!this.visualizeJs)
|
|
3941
|
+
return this;
|
|
3942
|
+
if (!this.client)
|
|
3943
|
+
return this;
|
|
3944
|
+
if (!model.getReferences)
|
|
3945
|
+
return this;
|
|
3946
|
+
const abortController = new AbortController();
|
|
3887
3947
|
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
3888
3948
|
this._abortControllerForReferences = abortController;
|
|
3889
3949
|
let references = [];
|
|
3890
|
-
await model
|
|
3950
|
+
await model
|
|
3951
|
+
.getReferences(abortController.signal)
|
|
3952
|
+
.then((data) => (references = data.references))
|
|
3953
|
+
.catch((e) => console.error("Cannot load model references.", e));
|
|
3891
3954
|
for (const file of references) {
|
|
3892
|
-
await this.client
|
|
3893
|
-
|
|
3894
|
-
return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer));
|
|
3895
|
-
|
|
3955
|
+
await this.client
|
|
3956
|
+
.downloadFile(file.id, undefined, abortController.signal)
|
|
3957
|
+
.then((arrayBuffer) => { var _a; return (_a = this.visualizeJs) === null || _a === void 0 ? void 0 : _a.getViewer().addEmbeddedFile(file.name, new Uint8Array(arrayBuffer)); })
|
|
3958
|
+
.catch((e) => console.error(`Cannot load reference file ${file.name}.`, e));
|
|
3896
3959
|
}
|
|
3897
3960
|
return this;
|
|
3898
3961
|
}
|
|
@@ -3900,7 +3963,8 @@ class Viewer extends EventEmitter2 {
|
|
|
3900
3963
|
this.executeCommand("applyModelTransform", model);
|
|
3901
3964
|
}
|
|
3902
3965
|
applySceneGraphSettings(options = this.options) {
|
|
3903
|
-
if (!this.visualizeJs)
|
|
3966
|
+
if (!this.visualizeJs)
|
|
3967
|
+
return;
|
|
3904
3968
|
const visLib = this.visLib();
|
|
3905
3969
|
const visViewer = this.visViewer();
|
|
3906
3970
|
const device = visViewer.getActiveDevice();
|
|
@@ -3911,48 +3975,39 @@ class Viewer extends EventEmitter2 {
|
|
|
3911
3975
|
this.update();
|
|
3912
3976
|
}
|
|
3913
3977
|
async open(file, params = {}) {
|
|
3914
|
-
if (!this.visualizeJs)
|
|
3978
|
+
if (!this.visualizeJs)
|
|
3979
|
+
return this;
|
|
3915
3980
|
this.cancel();
|
|
3916
3981
|
this.clear();
|
|
3917
|
-
this.emitEvent({
|
|
3918
|
-
type: "open",
|
|
3919
|
-
file: file
|
|
3920
|
-
});
|
|
3982
|
+
this.emitEvent({ type: "open", file });
|
|
3921
3983
|
let model = file;
|
|
3922
3984
|
if (model && typeof model.getModels === "function") {
|
|
3923
3985
|
const models = await model.getModels();
|
|
3924
|
-
model = models.find(model => model.default) || models[0] || file;
|
|
3986
|
+
model = models.find((model) => model.default) || models[0] || file;
|
|
3925
3987
|
}
|
|
3926
|
-
if (!model)
|
|
3988
|
+
if (!model)
|
|
3989
|
+
throw new Error(`Format not supported`);
|
|
3927
3990
|
let format = params.format;
|
|
3928
|
-
if (!format && typeof model.type === "string")
|
|
3929
|
-
|
|
3930
|
-
if (!format && file
|
|
3991
|
+
if (!format && typeof model.type === "string")
|
|
3992
|
+
format = model.type.split(".").pop();
|
|
3993
|
+
if (!format && typeof file === "string")
|
|
3994
|
+
format = file.split(".").pop();
|
|
3995
|
+
if (!format && file instanceof globalThis.File)
|
|
3996
|
+
format = file.name.split(".").pop();
|
|
3931
3997
|
const loader = loaders.createLoader(this, model, format);
|
|
3932
|
-
if (!loader)
|
|
3998
|
+
if (!loader)
|
|
3999
|
+
throw new Error(`Format not supported`);
|
|
3933
4000
|
this.loaders.push(loader);
|
|
3934
|
-
this.emitEvent({
|
|
3935
|
-
type: "geometrystart",
|
|
3936
|
-
file: file,
|
|
3937
|
-
model: model
|
|
3938
|
-
});
|
|
4001
|
+
this.emitEvent({ type: "geometrystart", file, model });
|
|
3939
4002
|
try {
|
|
3940
4003
|
await this.loadReferences(model);
|
|
3941
4004
|
await loader.load(model, format, params);
|
|
3942
|
-
}
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
data: error,
|
|
3946
|
-
file: file,
|
|
3947
|
-
model: model
|
|
3948
|
-
});
|
|
4005
|
+
}
|
|
4006
|
+
catch (error) {
|
|
4007
|
+
this.emitEvent({ type: "geometryerror", data: error, file, model });
|
|
3949
4008
|
throw error;
|
|
3950
4009
|
}
|
|
3951
|
-
this.emitEvent({
|
|
3952
|
-
type: "geometryend",
|
|
3953
|
-
file: file,
|
|
3954
|
-
model: model
|
|
3955
|
-
});
|
|
4010
|
+
this.emitEvent({ type: "geometryend", file, model });
|
|
3956
4011
|
if (this.visualizeJs) {
|
|
3957
4012
|
this.applyModelTransformMatrix(model);
|
|
3958
4013
|
this.applySceneGraphSettings();
|
|
@@ -3961,131 +4016,78 @@ class Viewer extends EventEmitter2 {
|
|
|
3961
4016
|
}
|
|
3962
4017
|
openVsfFile(buffer) {
|
|
3963
4018
|
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)
|
|
4019
|
+
if (!this.visualizeJs)
|
|
4020
|
+
return this;
|
|
3965
4021
|
this.cancel();
|
|
3966
4022
|
this.clear();
|
|
3967
|
-
this.emitEvent({
|
|
3968
|
-
type: "open",
|
|
3969
|
-
file: "",
|
|
3970
|
-
buffer: buffer
|
|
3971
|
-
});
|
|
4023
|
+
this.emitEvent({ type: "open", file: "", buffer });
|
|
3972
4024
|
const visViewer = this.visViewer();
|
|
3973
|
-
this.emitEvent({
|
|
3974
|
-
type: "geometrystart",
|
|
3975
|
-
file: "",
|
|
3976
|
-
buffer: buffer
|
|
3977
|
-
});
|
|
4025
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
3978
4026
|
try {
|
|
3979
4027
|
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
3980
4028
|
visViewer.parseFile(data);
|
|
3981
4029
|
this.syncOptions();
|
|
3982
4030
|
this.syncOverlay();
|
|
3983
4031
|
this.update(true);
|
|
3984
|
-
this.emitEvent({
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
});
|
|
3990
|
-
this.emitEvent({
|
|
3991
|
-
type: "databasechunk",
|
|
3992
|
-
data: data,
|
|
3993
|
-
file: "",
|
|
3994
|
-
buffer: buffer
|
|
3995
|
-
});
|
|
3996
|
-
} catch (error) {
|
|
3997
|
-
this.emitEvent({
|
|
3998
|
-
type: "geometryerror",
|
|
3999
|
-
data: error,
|
|
4000
|
-
file: "",
|
|
4001
|
-
buffer: buffer
|
|
4002
|
-
});
|
|
4032
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
4033
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
4034
|
+
}
|
|
4035
|
+
catch (error) {
|
|
4036
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4003
4037
|
throw error;
|
|
4004
4038
|
}
|
|
4005
|
-
this.emitEvent({
|
|
4006
|
-
type: "geometryend",
|
|
4007
|
-
file: "",
|
|
4008
|
-
buffer: buffer
|
|
4009
|
-
});
|
|
4039
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4010
4040
|
return this;
|
|
4011
4041
|
}
|
|
4012
4042
|
openVsfxFile(buffer) {
|
|
4013
4043
|
console.warn("Viewer.openVsfxFile() has been deprecated since 26.4 and will be removed in a future release, use Viewer.open() instead.");
|
|
4014
|
-
if (!this.visualizeJs)
|
|
4044
|
+
if (!this.visualizeJs)
|
|
4045
|
+
return this;
|
|
4015
4046
|
this.cancel();
|
|
4016
4047
|
this.clear();
|
|
4017
|
-
this.emitEvent({
|
|
4018
|
-
type: "open",
|
|
4019
|
-
file: "",
|
|
4020
|
-
buffer: buffer
|
|
4021
|
-
});
|
|
4048
|
+
this.emitEvent({ type: "open", file: "", buffer });
|
|
4022
4049
|
const visViewer = this.visViewer();
|
|
4023
|
-
this.emitEvent({
|
|
4024
|
-
type: "geometrystart",
|
|
4025
|
-
file: "",
|
|
4026
|
-
buffer: buffer
|
|
4027
|
-
});
|
|
4050
|
+
this.emitEvent({ type: "geometrystart", file: "", buffer });
|
|
4028
4051
|
try {
|
|
4029
4052
|
const data = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
4030
4053
|
visViewer.parseVsfx(data);
|
|
4031
4054
|
this.syncOptions();
|
|
4032
4055
|
this.syncOverlay();
|
|
4033
4056
|
this.update(true);
|
|
4034
|
-
this.emitEvent({
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
});
|
|
4040
|
-
this.emitEvent({
|
|
4041
|
-
type: "databasechunk",
|
|
4042
|
-
data: data,
|
|
4043
|
-
file: "",
|
|
4044
|
-
buffer: buffer
|
|
4045
|
-
});
|
|
4046
|
-
} catch (error) {
|
|
4047
|
-
this.emitEvent({
|
|
4048
|
-
type: "geometryerror",
|
|
4049
|
-
data: error,
|
|
4050
|
-
file: "",
|
|
4051
|
-
buffer: buffer
|
|
4052
|
-
});
|
|
4057
|
+
this.emitEvent({ type: "geometryprogress", data: 1, file: "", buffer });
|
|
4058
|
+
this.emitEvent({ type: "databasechunk", data, file: "", buffer });
|
|
4059
|
+
}
|
|
4060
|
+
catch (error) {
|
|
4061
|
+
this.emitEvent({ type: "geometryerror", data: error, file: "", buffer });
|
|
4053
4062
|
throw error;
|
|
4054
4063
|
}
|
|
4055
|
-
this.emitEvent({
|
|
4056
|
-
type: "geometryend",
|
|
4057
|
-
file: "",
|
|
4058
|
-
buffer: buffer
|
|
4059
|
-
});
|
|
4064
|
+
this.emitEvent({ type: "geometryend", file: "", buffer });
|
|
4060
4065
|
return this;
|
|
4061
4066
|
}
|
|
4062
4067
|
cancel() {
|
|
4063
4068
|
var _a;
|
|
4064
4069
|
(_a = this._abortControllerForReferences) === null || _a === void 0 ? void 0 : _a.abort();
|
|
4065
4070
|
this._abortControllerForReferences = undefined;
|
|
4066
|
-
this.loaders.forEach(loader => loader.cancel());
|
|
4067
|
-
this.emitEvent({
|
|
4068
|
-
type: "cancel"
|
|
4069
|
-
});
|
|
4071
|
+
this.loaders.forEach((loader) => loader.cancel());
|
|
4072
|
+
this.emitEvent({ type: "cancel" });
|
|
4070
4073
|
return this;
|
|
4071
4074
|
}
|
|
4072
4075
|
clear() {
|
|
4073
|
-
if (!this.visualizeJs)
|
|
4076
|
+
if (!this.visualizeJs)
|
|
4077
|
+
return this;
|
|
4074
4078
|
const visViewer = this.visViewer();
|
|
4075
4079
|
this.setActiveDragger();
|
|
4076
4080
|
this.clearSlices();
|
|
4077
4081
|
this.clearOverlay();
|
|
4078
4082
|
this.clearSelected();
|
|
4079
|
-
this.loaders.forEach(loader => loader.dispose());
|
|
4083
|
+
this.loaders.forEach((loader) => loader.dispose());
|
|
4080
4084
|
this.loaders = [];
|
|
4081
4085
|
visViewer.clear();
|
|
4082
4086
|
visViewer.createLocalDatabase();
|
|
4083
4087
|
this.syncOptions();
|
|
4084
4088
|
this.syncOverlay();
|
|
4085
4089
|
this.update(true);
|
|
4086
|
-
this.emitEvent({
|
|
4087
|
-
type: "clear"
|
|
4088
|
-
});
|
|
4090
|
+
this.emitEvent({ type: "clear" });
|
|
4089
4091
|
return this;
|
|
4090
4092
|
}
|
|
4091
4093
|
getMarkupColor() {
|
|
@@ -4104,7 +4106,8 @@ class Viewer extends EventEmitter2 {
|
|
|
4104
4106
|
this._markup.colorizeSelectedMarkups(r, g, b);
|
|
4105
4107
|
}
|
|
4106
4108
|
addMarkupEntity(entityName) {
|
|
4107
|
-
if (!this.visualizeJs)
|
|
4109
|
+
if (!this.visualizeJs)
|
|
4110
|
+
return null;
|
|
4108
4111
|
this.syncOverlay();
|
|
4109
4112
|
const visViewer = this.visViewer();
|
|
4110
4113
|
const model = visViewer.getMarkupModel();
|
|
@@ -4119,7 +4122,8 @@ class Viewer extends EventEmitter2 {
|
|
|
4119
4122
|
}
|
|
4120
4123
|
drawViewpoint(viewpoint) {
|
|
4121
4124
|
var _a;
|
|
4122
|
-
if (!this.visualizeJs)
|
|
4125
|
+
if (!this.visualizeJs)
|
|
4126
|
+
return;
|
|
4123
4127
|
const draggerName = (_a = this._activeDragger) === null || _a === void 0 ? void 0 : _a.name;
|
|
4124
4128
|
this.setActiveDragger();
|
|
4125
4129
|
this.clearSlices();
|
|
@@ -4132,35 +4136,26 @@ class Viewer extends EventEmitter2 {
|
|
|
4132
4136
|
this.setSelection(viewpoint.selection);
|
|
4133
4137
|
this._markup.setViewpoint(viewpoint);
|
|
4134
4138
|
this.setActiveDragger(draggerName);
|
|
4135
|
-
this.emitEvent({
|
|
4136
|
-
type: "drawviewpoint",
|
|
4137
|
-
data: viewpoint
|
|
4138
|
-
});
|
|
4139
|
+
this.emitEvent({ type: "drawviewpoint", data: viewpoint });
|
|
4139
4140
|
this.update();
|
|
4140
4141
|
}
|
|
4141
4142
|
createViewpoint() {
|
|
4142
|
-
if (!this.visualizeJs)
|
|
4143
|
+
if (!this.visualizeJs)
|
|
4144
|
+
return {};
|
|
4143
4145
|
const viewpoint = {};
|
|
4144
4146
|
viewpoint.orthogonal_camera = this.getOrthogonalCameraSettings();
|
|
4145
4147
|
viewpoint.clipping_planes = this.getClippingPlanes();
|
|
4146
4148
|
viewpoint.selection = this.getSelection();
|
|
4147
|
-
viewpoint.description =
|
|
4149
|
+
viewpoint.description = new Date().toDateString();
|
|
4148
4150
|
this._markup.getViewpoint(viewpoint);
|
|
4149
|
-
this.emitEvent({
|
|
4150
|
-
type: "createviewpoint",
|
|
4151
|
-
data: viewpoint
|
|
4152
|
-
});
|
|
4151
|
+
this.emitEvent({ type: "createviewpoint", data: viewpoint });
|
|
4153
4152
|
return viewpoint;
|
|
4154
4153
|
}
|
|
4155
4154
|
getPoint3dFromArray(array) {
|
|
4156
|
-
return {
|
|
4157
|
-
x: array[0],
|
|
4158
|
-
y: array[1],
|
|
4159
|
-
z: array[2]
|
|
4160
|
-
};
|
|
4155
|
+
return { x: array[0], y: array[1], z: array[2] };
|
|
4161
4156
|
}
|
|
4162
4157
|
getLogicalPoint3dAsArray(point3d) {
|
|
4163
|
-
return [
|
|
4158
|
+
return [point3d.x, point3d.y, point3d.z];
|
|
4164
4159
|
}
|
|
4165
4160
|
getOrthogonalCameraSettings() {
|
|
4166
4161
|
const visViewer = this.visViewer();
|
|
@@ -4171,7 +4166,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4171
4166
|
up_vector: this.getPoint3dFromArray(activeView.upVector),
|
|
4172
4167
|
field_width: activeView.viewFieldWidth,
|
|
4173
4168
|
field_height: activeView.viewFieldHeight,
|
|
4174
|
-
view_to_world_scale: 1
|
|
4169
|
+
view_to_world_scale: 1,
|
|
4175
4170
|
};
|
|
4176
4171
|
}
|
|
4177
4172
|
setOrthogonalCameraSettings(settings) {
|
|
@@ -4190,7 +4185,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4190
4185
|
const cuttingPlane = activeView.getCuttingPlane(i);
|
|
4191
4186
|
const clipping_plane = {
|
|
4192
4187
|
location: this.getPoint3dFromArray(cuttingPlane.getOrigin()),
|
|
4193
|
-
direction: this.getPoint3dFromArray(cuttingPlane.normal())
|
|
4188
|
+
direction: this.getPoint3dFromArray(cuttingPlane.normal()),
|
|
4194
4189
|
};
|
|
4195
4190
|
clipping_planes.push(clipping_plane);
|
|
4196
4191
|
}
|
|
@@ -4201,20 +4196,18 @@ class Viewer extends EventEmitter2 {
|
|
|
4201
4196
|
const visViewer = this.visViewer();
|
|
4202
4197
|
const activeView = visViewer.activeView;
|
|
4203
4198
|
for (const clipping_plane of clipping_planes) {
|
|
4204
|
-
const cuttingPlane = new (this.visLib().OdTvPlane);
|
|
4199
|
+
const cuttingPlane = new (this.visLib().OdTvPlane)();
|
|
4205
4200
|
cuttingPlane.set(this.getLogicalPoint3dAsArray(clipping_plane.location), this.getLogicalPoint3dAsArray(clipping_plane.direction));
|
|
4206
4201
|
activeView.addCuttingPlane(cuttingPlane);
|
|
4207
|
-
activeView.setEnableCuttingPlaneFill(true,
|
|
4202
|
+
activeView.setEnableCuttingPlaneFill(true, 0x66, 0x66, 0x66);
|
|
4208
4203
|
}
|
|
4209
4204
|
}
|
|
4210
4205
|
}
|
|
4211
4206
|
getSelection() {
|
|
4212
|
-
return this.getSelected().map(handle => ({
|
|
4213
|
-
handle: handle
|
|
4214
|
-
}));
|
|
4207
|
+
return this.getSelected().map((handle) => ({ handle }));
|
|
4215
4208
|
}
|
|
4216
4209
|
setSelection(selection) {
|
|
4217
|
-
this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map(component => component.handle));
|
|
4210
|
+
this.setSelected(selection === null || selection === void 0 ? void 0 : selection.map((component) => component.handle));
|
|
4218
4211
|
}
|
|
4219
4212
|
executeCommand(id, ...args) {
|
|
4220
4213
|
return commands.executeCommand(id, this, ...args);
|
|
@@ -4223,7 +4216,7 @@ class Viewer extends EventEmitter2 {
|
|
|
4223
4216
|
const visViewer = this.visViewer();
|
|
4224
4217
|
const device = visViewer.getActiveDevice();
|
|
4225
4218
|
const coef = device.getOptionDouble(this.visLib().DeviceOptions.kRegenCoef);
|
|
4226
|
-
if (coef > 1) {
|
|
4219
|
+
if (coef > 1.0) {
|
|
4227
4220
|
visViewer.regenAll();
|
|
4228
4221
|
this.update();
|
|
4229
4222
|
}
|