@xeokit/xeokit-sdk 2.6.23 → 2.6.25
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/xeokit-sdk.cjs.js +937 -628
- package/dist/xeokit-sdk.es.js +937 -629
- package/dist/xeokit-sdk.es5.js +939 -744
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +25 -34
- package/src/plugins/AngleMeasurementsPlugin/index.js +24 -4
- package/src/plugins/AnnotationsPlugin/Annotation.js +31 -0
- package/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +9 -24
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +17 -23
- package/src/plugins/DistanceMeasurementsPlugin/index.js +24 -4
- package/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +0 -1
- package/src/plugins/ZonesPlugin/index.js +28 -52
- package/src/plugins/lib/html/Dot.js +18 -18
- package/src/plugins/lib/ui/index.js +110 -88
- package/src/viewer/scene/geometry/builders/index.js +2 -1
- package/src/viewer/scene/marker/Marker.js +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Dot3D} from "../lib/ui/index.js";
|
|
2
2
|
import {Wire} from "../lib/html/Wire.js";
|
|
3
|
-
import {Dot} from "../lib/html/Dot.js";
|
|
4
3
|
import {Label} from "../lib/html/Label.js";
|
|
5
4
|
import {math} from "../../viewer/scene/math/math.js";
|
|
6
5
|
import {Component} from "../../viewer/scene/Component.js";
|
|
@@ -37,10 +36,6 @@ class AngleMeasurement extends Component {
|
|
|
37
36
|
|
|
38
37
|
var scene = this.plugin.viewer.scene;
|
|
39
38
|
|
|
40
|
-
this._originMarker = new Marker(scene, cfg.origin);
|
|
41
|
-
this._cornerMarker = new Marker(scene, cfg.corner);
|
|
42
|
-
this._targetMarker = new Marker(scene, cfg.target);
|
|
43
|
-
|
|
44
39
|
this._originWorld = math.vec3();
|
|
45
40
|
this._cornerWorld = math.vec3();
|
|
46
41
|
this._targetWorld = math.vec3();
|
|
@@ -80,7 +75,7 @@ class AngleMeasurement extends Component {
|
|
|
80
75
|
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousemove', event));
|
|
81
76
|
};
|
|
82
77
|
|
|
83
|
-
this._originDot = new
|
|
78
|
+
this._originDot = new Dot3D(scene, cfg.origin, this._container, {
|
|
84
79
|
fillColor: this._color,
|
|
85
80
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
86
81
|
onMouseOver,
|
|
@@ -91,7 +86,7 @@ class AngleMeasurement extends Component {
|
|
|
91
86
|
onMouseMove,
|
|
92
87
|
onContextMenu
|
|
93
88
|
});
|
|
94
|
-
this._cornerDot = new
|
|
89
|
+
this._cornerDot = new Dot3D(scene, cfg.corner, this._container, {
|
|
95
90
|
fillColor: this._color,
|
|
96
91
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
97
92
|
onMouseOver,
|
|
@@ -102,7 +97,7 @@ class AngleMeasurement extends Component {
|
|
|
102
97
|
onMouseMove,
|
|
103
98
|
onContextMenu
|
|
104
99
|
});
|
|
105
|
-
this._targetDot = new
|
|
100
|
+
this._targetDot = new Dot3D(scene, cfg.target, this._container, {
|
|
106
101
|
fillColor: this._color,
|
|
107
102
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
108
103
|
onMouseOver,
|
|
@@ -169,19 +164,19 @@ class AngleMeasurement extends Component {
|
|
|
169
164
|
this._labelsVisible = false;
|
|
170
165
|
this._clickable = false;
|
|
171
166
|
|
|
172
|
-
this.
|
|
167
|
+
this._originDot.on("worldPos", (value) => {
|
|
173
168
|
this._originWorld.set(value || [0, 0, 0]);
|
|
174
169
|
this._wpDirty = true;
|
|
175
170
|
this._needUpdate(0); // No lag
|
|
176
171
|
});
|
|
177
172
|
|
|
178
|
-
this.
|
|
173
|
+
this._cornerDot.on("worldPos", (value) => {
|
|
179
174
|
this._cornerWorld.set(value || [0, 0, 0]);
|
|
180
175
|
this._wpDirty = true;
|
|
181
176
|
this._needUpdate(0); // No lag
|
|
182
177
|
});
|
|
183
178
|
|
|
184
|
-
this.
|
|
179
|
+
this._targetDot.on("worldPos", (value) => {
|
|
185
180
|
this._targetWorld.set(value || [0, 0, 0]);
|
|
186
181
|
this._wpDirty = true;
|
|
187
182
|
this._needUpdate(0); // No lag
|
|
@@ -287,9 +282,9 @@ class AngleMeasurement extends Component {
|
|
|
287
282
|
if (this._cpDirty) {
|
|
288
283
|
|
|
289
284
|
const near = -0.3;
|
|
290
|
-
const zOrigin = this.
|
|
291
|
-
const zCorner = this.
|
|
292
|
-
const zTarget = this.
|
|
285
|
+
const zOrigin = this._originDot.viewPos[2];
|
|
286
|
+
const zCorner = this._cornerDot.viewPos[2];
|
|
287
|
+
const zTarget = this._targetDot.viewPos[2];
|
|
293
288
|
|
|
294
289
|
if (zOrigin > near || zCorner > near || zTarget > near) {
|
|
295
290
|
|
|
@@ -326,10 +321,6 @@ class AngleMeasurement extends Component {
|
|
|
326
321
|
j += 2;
|
|
327
322
|
}
|
|
328
323
|
|
|
329
|
-
this._originDot.setPos(cp[0], cp[1]);
|
|
330
|
-
this._cornerDot.setPos(cp[2], cp[3]);
|
|
331
|
-
this._targetDot.setPos(cp[4], cp[5]);
|
|
332
|
-
|
|
333
324
|
this._originWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
334
325
|
this._targetWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
|
|
335
326
|
|
|
@@ -410,30 +401,30 @@ class AngleMeasurement extends Component {
|
|
|
410
401
|
}
|
|
411
402
|
|
|
412
403
|
/**
|
|
413
|
-
* Gets the origin {@link
|
|
404
|
+
* Gets the origin {@link Dot3D}.
|
|
414
405
|
*
|
|
415
|
-
* @type {
|
|
406
|
+
* @type {Dot3D}
|
|
416
407
|
*/
|
|
417
408
|
get origin() {
|
|
418
|
-
return this.
|
|
409
|
+
return this._originDot;
|
|
419
410
|
}
|
|
420
411
|
|
|
421
412
|
/**
|
|
422
|
-
* Gets the corner {@link
|
|
413
|
+
* Gets the corner {@link Dot3D}.
|
|
423
414
|
*
|
|
424
|
-
* @type {
|
|
415
|
+
* @type {Dot3D}
|
|
425
416
|
*/
|
|
426
417
|
get corner() {
|
|
427
|
-
return this.
|
|
418
|
+
return this._cornerDot;
|
|
428
419
|
}
|
|
429
420
|
|
|
430
421
|
/**
|
|
431
|
-
* Gets the target {@link
|
|
422
|
+
* Gets the target {@link Dot3D}.
|
|
432
423
|
*
|
|
433
|
-
* @type {
|
|
424
|
+
* @type {Dot3D}
|
|
434
425
|
*/
|
|
435
426
|
get target() {
|
|
436
|
-
return this.
|
|
427
|
+
return this._targetDot;
|
|
437
428
|
}
|
|
438
429
|
|
|
439
430
|
/**
|
|
@@ -503,7 +494,7 @@ class AngleMeasurement extends Component {
|
|
|
503
494
|
}
|
|
504
495
|
|
|
505
496
|
/**
|
|
506
|
-
* Sets if the origin {@link
|
|
497
|
+
* Sets if the origin {@link Dot3D} is visible.
|
|
507
498
|
*
|
|
508
499
|
* @type {Boolean}
|
|
509
500
|
*/
|
|
@@ -516,7 +507,7 @@ class AngleMeasurement extends Component {
|
|
|
516
507
|
}
|
|
517
508
|
|
|
518
509
|
/**
|
|
519
|
-
* Gets if the origin {@link
|
|
510
|
+
* Gets if the origin {@link Dot3D} is visible.
|
|
520
511
|
*
|
|
521
512
|
* @type {Boolean}
|
|
522
513
|
*/
|
|
@@ -525,7 +516,7 @@ class AngleMeasurement extends Component {
|
|
|
525
516
|
}
|
|
526
517
|
|
|
527
518
|
/**
|
|
528
|
-
* Sets if the corner {@link
|
|
519
|
+
* Sets if the corner {@link Dot3D} is visible.
|
|
529
520
|
*
|
|
530
521
|
* @type {Boolean}
|
|
531
522
|
*/
|
|
@@ -538,7 +529,7 @@ class AngleMeasurement extends Component {
|
|
|
538
529
|
}
|
|
539
530
|
|
|
540
531
|
/**
|
|
541
|
-
* Gets if the corner {@link
|
|
532
|
+
* Gets if the corner {@link Dot3D} is visible.
|
|
542
533
|
*
|
|
543
534
|
* @type {Boolean}
|
|
544
535
|
*/
|
|
@@ -547,7 +538,7 @@ class AngleMeasurement extends Component {
|
|
|
547
538
|
}
|
|
548
539
|
|
|
549
540
|
/**
|
|
550
|
-
* Sets if the target {@link
|
|
541
|
+
* Sets if the target {@link Dot3D} is visible.
|
|
551
542
|
*
|
|
552
543
|
* @type {Boolean}
|
|
553
544
|
*/
|
|
@@ -560,7 +551,7 @@ class AngleMeasurement extends Component {
|
|
|
560
551
|
}
|
|
561
552
|
|
|
562
553
|
/**
|
|
563
|
-
* Gets if the target {@link
|
|
554
|
+
* Gets if the target {@link Dot3D} is visible.
|
|
564
555
|
*
|
|
565
556
|
* @type {Boolean}
|
|
566
557
|
*/
|
|
@@ -4,6 +4,7 @@ export * from "./AngleMeasurementsMouseControl.js";
|
|
|
4
4
|
export * from "./AngleMeasurementsTouchControl.js";
|
|
5
5
|
|
|
6
6
|
import {Component} from "../../viewer/scene/Component.js";
|
|
7
|
+
import {math} from "../../viewer/scene/math/math.js";
|
|
7
8
|
import {activateDraggableDots} from "../../../src/plugins/lib/ui/index.js";
|
|
8
9
|
|
|
9
10
|
class AngleMeasurementEditControl extends Component {
|
|
@@ -28,11 +29,30 @@ class AngleMeasurementEditControl extends Component {
|
|
|
28
29
|
viewer: viewer,
|
|
29
30
|
handleMouseEvents: handleMouseEvents,
|
|
30
31
|
handleTouchEvents: handleTouchEvents,
|
|
31
|
-
snapping: cfg.snapping,
|
|
32
32
|
pointerLens: cfg.pointerLens,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
dots: [ measurement.origin, measurement.corner, measurement.target ],
|
|
34
|
+
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
35
|
+
const tryPickWorldPos = snap => {
|
|
36
|
+
const pickResult = viewer.scene.pick({
|
|
37
|
+
canvasPos: canvasPos,
|
|
38
|
+
snapToEdge: snap,
|
|
39
|
+
snapToVertex: snap,
|
|
40
|
+
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// If - when snapping - no pick found, then try w/o snapping
|
|
44
|
+
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return tryPickWorldPos(!!cfg.snapping);
|
|
48
|
+
},
|
|
49
|
+
onEnd: (initPos, dot) => {
|
|
50
|
+
const changed = ! math.compareVec3(initPos, dot.worldPos);
|
|
51
|
+
if (changed) {
|
|
52
|
+
this.fire("edited");
|
|
53
|
+
}
|
|
54
|
+
return changed;
|
|
55
|
+
}
|
|
36
56
|
});
|
|
37
57
|
|
|
38
58
|
const destroyCb = measurement.on("destroyed", cleanup);
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import {math} from '../../viewer/scene/math/math.js';
|
|
1
2
|
import {Marker} from "../../viewer/scene/marker/Marker.js";
|
|
2
3
|
import {utils} from "../../viewer/scene/utils.js";
|
|
3
4
|
|
|
5
|
+
const tempVec3a = math.vec3();
|
|
6
|
+
const tempVec3b = math.vec3();
|
|
7
|
+
const tempVec3c = math.vec3();
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* A {@link Marker} with an HTML label attached to it, managed by an {@link AnnotationsPlugin}.
|
|
6
11
|
*
|
|
@@ -40,6 +45,9 @@ class Annotation extends Marker {
|
|
|
40
45
|
this._marker.addEventListener("click", this._onMouseClickedExternalMarker = () => {
|
|
41
46
|
this.plugin.fire("markerClicked", this);
|
|
42
47
|
});
|
|
48
|
+
this._marker.addEventListener("contextmenu", this._onContextMenuExtenalMarker = () => {
|
|
49
|
+
this.plugin.fire("contextmenu", this);
|
|
50
|
+
});
|
|
43
51
|
this._marker.addEventListener("mouseenter", this._onMouseEnterExternalMarker = () => {
|
|
44
52
|
this.plugin.fire("markerMouseEnter", this);
|
|
45
53
|
});
|
|
@@ -159,6 +167,10 @@ class Annotation extends Marker {
|
|
|
159
167
|
this._marker.addEventListener("click", () => {
|
|
160
168
|
this.plugin.fire("markerClicked", this);
|
|
161
169
|
});
|
|
170
|
+
this._marker.addEventListener("contextmenu", e => {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
this.plugin.fire("contextmenu", this);
|
|
173
|
+
});
|
|
162
174
|
this._marker.addEventListener("mouseenter", () => {
|
|
163
175
|
this.plugin.fire("markerMouseEnter", this);
|
|
164
176
|
});
|
|
@@ -220,6 +232,24 @@ class Annotation extends Marker {
|
|
|
220
232
|
return template;
|
|
221
233
|
}
|
|
222
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Sets the Marker's worldPos and entity properties based on passed {@link PickResult}
|
|
237
|
+
*
|
|
238
|
+
* @param {PickResult} pickResult A PickResult to position the Marker at.
|
|
239
|
+
*/
|
|
240
|
+
setFromPickResult(pickResult) {
|
|
241
|
+
if (!pickResult.worldPos || !pickResult.worldNormal) {
|
|
242
|
+
this.error("Param 'pickResult' does not have both worldPos and worldNormal");
|
|
243
|
+
} else {
|
|
244
|
+
const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a);
|
|
245
|
+
const offset = (this.plugin && this.plugin.surfaceOffset) || 0;
|
|
246
|
+
const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b);
|
|
247
|
+
const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c);
|
|
248
|
+
this.entity = pickResult.entity;
|
|
249
|
+
this.worldPos = offsetWorldPos;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
223
253
|
/**
|
|
224
254
|
* Sets whether or not to show this Annotation's marker.
|
|
225
255
|
*
|
|
@@ -350,6 +380,7 @@ class Annotation extends Marker {
|
|
|
350
380
|
this._marker = null;
|
|
351
381
|
} else {
|
|
352
382
|
this._marker.removeEventListener("click", this._onMouseClickedExternalMarker);
|
|
383
|
+
this._marker.removeEventListener("contextmenu", this._onContextMenuExtenalMarker);
|
|
353
384
|
this._marker.removeEventListener("mouseenter", this._onMouseEnterExternalMarker);
|
|
354
385
|
this._marker.removeEventListener("mouseleave", this._onMouseLeaveExternalMarker);
|
|
355
386
|
this._marker = null;
|
|
@@ -3,10 +3,6 @@ import {Annotation} from "./Annotation.js";
|
|
|
3
3
|
import {utils} from "../../viewer/scene/utils.js";
|
|
4
4
|
import {math} from "../../viewer/scene/math/math.js";
|
|
5
5
|
|
|
6
|
-
const tempVec3a = math.vec3();
|
|
7
|
-
const tempVec3b = math.vec3();
|
|
8
|
-
const tempVec3c = math.vec3();
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* {@link Viewer} plugin that creates {@link Annotation}s.
|
|
12
8
|
*
|
|
@@ -481,24 +477,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
481
477
|
this.error("Viewer component with this ID already exists: " + params.id);
|
|
482
478
|
delete params.id;
|
|
483
479
|
}
|
|
484
|
-
var worldPos;
|
|
485
|
-
var entity;
|
|
486
|
-
params.pickResult = params.pickResult || params.pickRecord;
|
|
487
|
-
if (params.pickResult) {
|
|
488
|
-
const pickResult = params.pickResult;
|
|
489
|
-
if (!pickResult.worldPos || !pickResult.worldNormal) {
|
|
490
|
-
this.error("Param 'pickResult' does not have both worldPos and worldNormal");
|
|
491
|
-
} else {
|
|
492
|
-
const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a);
|
|
493
|
-
const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, this._surfaceOffset, tempVec3b);
|
|
494
|
-
const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c);
|
|
495
|
-
worldPos = offsetWorldPos;
|
|
496
|
-
entity = pickResult.entity;
|
|
497
|
-
}
|
|
498
|
-
} else {
|
|
499
|
-
worldPos = params.worldPos;
|
|
500
|
-
entity = params.entity;
|
|
501
|
-
}
|
|
502
480
|
|
|
503
481
|
var markerElement = null;
|
|
504
482
|
if (params.markerElementId) {
|
|
@@ -519,8 +497,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
519
497
|
const annotation = new Annotation(this.viewer.scene, {
|
|
520
498
|
id: params.id,
|
|
521
499
|
plugin: this,
|
|
522
|
-
entity: entity,
|
|
523
|
-
worldPos: worldPos,
|
|
524
500
|
container: this._container,
|
|
525
501
|
markerElement: markerElement,
|
|
526
502
|
labelElement: labelElement,
|
|
@@ -536,6 +512,15 @@ class AnnotationsPlugin extends Plugin {
|
|
|
536
512
|
projection: params.projection,
|
|
537
513
|
visible: (params.visible !== false)
|
|
538
514
|
});
|
|
515
|
+
|
|
516
|
+
params.pickResult = params.pickResult || params.pickRecord;
|
|
517
|
+
if (params.pickResult) {
|
|
518
|
+
annotation.setFromPickResult(params.pickResult);
|
|
519
|
+
} else {
|
|
520
|
+
annotation.entity = params.entity;
|
|
521
|
+
annotation.worldPos = params.worldPos;
|
|
522
|
+
}
|
|
523
|
+
|
|
539
524
|
this.annotations[annotation.id] = annotation;
|
|
540
525
|
annotation.on("destroyed", () => {
|
|
541
526
|
delete this.annotations[annotation.id];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Dot3D} from "../lib/ui/index.js";
|
|
2
2
|
import {Wire} from "../lib/html/Wire.js";
|
|
3
|
-
import {Dot} from "../lib/html/Dot.js";
|
|
4
3
|
import {Label} from "../lib/html/Label.js";
|
|
5
4
|
import {math} from "../../viewer/scene/math/math.js";
|
|
6
5
|
import {Component} from "../../viewer/scene/Component.js";
|
|
@@ -50,8 +49,6 @@ class DistanceMeasurement extends Component {
|
|
|
50
49
|
this._eventSubs = {};
|
|
51
50
|
|
|
52
51
|
var scene = this.plugin.viewer.scene;
|
|
53
|
-
this._originMarker = new Marker(scene, cfg.origin);
|
|
54
|
-
this._targetMarker = new Marker(scene, cfg.target);
|
|
55
52
|
|
|
56
53
|
this._originWorld = math.vec3();
|
|
57
54
|
this._targetWorld = math.vec3();
|
|
@@ -97,7 +94,7 @@ class DistanceMeasurement extends Component {
|
|
|
97
94
|
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
98
95
|
};
|
|
99
96
|
|
|
100
|
-
this._originDot = new
|
|
97
|
+
this._originDot = new Dot3D(scene, cfg.origin, this._container, {
|
|
101
98
|
fillColor: this._color,
|
|
102
99
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
103
100
|
onMouseOver,
|
|
@@ -109,7 +106,7 @@ class DistanceMeasurement extends Component {
|
|
|
109
106
|
onContextMenu
|
|
110
107
|
});
|
|
111
108
|
|
|
112
|
-
this._targetDot = new
|
|
109
|
+
this._targetDot = new Dot3D(scene, cfg.target, this._container, {
|
|
113
110
|
fillColor: this._color,
|
|
114
111
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
115
112
|
onMouseOver,
|
|
@@ -256,13 +253,13 @@ class DistanceMeasurement extends Component {
|
|
|
256
253
|
this._labelsOnWires = false;
|
|
257
254
|
this._clickable = false;
|
|
258
255
|
|
|
259
|
-
this.
|
|
256
|
+
this._originDot.on("worldPos", (value) => {
|
|
260
257
|
this._originWorld.set(value || [0,0,0]);
|
|
261
258
|
this._wpDirty = true;
|
|
262
259
|
this._needUpdate(0); // No lag
|
|
263
260
|
});
|
|
264
261
|
|
|
265
|
-
this.
|
|
262
|
+
this._targetDot.on("worldPos", (value) => {
|
|
266
263
|
this._targetWorld.set(value || [0,0,0]);
|
|
267
264
|
this._wpDirty = true;
|
|
268
265
|
this._needUpdate(0); // No lag
|
|
@@ -424,8 +421,8 @@ class DistanceMeasurement extends Component {
|
|
|
424
421
|
}
|
|
425
422
|
|
|
426
423
|
const near = -0.3;
|
|
427
|
-
const vpz1 = this.
|
|
428
|
-
const vpz2 = this.
|
|
424
|
+
const vpz1 = this._originDot.viewPos[2];
|
|
425
|
+
const vpz2 = this._targetDot.viewPos[2];
|
|
429
426
|
|
|
430
427
|
if (vpz1 > near || vpz2 > near) {
|
|
431
428
|
|
|
@@ -474,9 +471,6 @@ class DistanceMeasurement extends Component {
|
|
|
474
471
|
j += 2;
|
|
475
472
|
}
|
|
476
473
|
|
|
477
|
-
this._originDot.setPos(cp[0], cp[1]);
|
|
478
|
-
this._targetDot.setPos(cp[6], cp[7]);
|
|
479
|
-
|
|
480
474
|
this._lengthWire.setStartAndEnd(cp[0], cp[1], cp[6], cp[7]);
|
|
481
475
|
|
|
482
476
|
this._xAxisWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
@@ -618,21 +612,21 @@ class DistanceMeasurement extends Component {
|
|
|
618
612
|
}
|
|
619
613
|
|
|
620
614
|
/**
|
|
621
|
-
* Gets the origin {@link
|
|
615
|
+
* Gets the origin {@link Dot3D}.
|
|
622
616
|
*
|
|
623
|
-
* @type {
|
|
617
|
+
* @type {Dot3D}
|
|
624
618
|
*/
|
|
625
619
|
get origin() {
|
|
626
|
-
return this.
|
|
620
|
+
return this._originDot;
|
|
627
621
|
}
|
|
628
622
|
|
|
629
623
|
/**
|
|
630
|
-
* Gets the target {@link
|
|
624
|
+
* Gets the target {@link Dot3D}.
|
|
631
625
|
*
|
|
632
|
-
* @type {
|
|
626
|
+
* @type {Dot3D}
|
|
633
627
|
*/
|
|
634
628
|
get target() {
|
|
635
|
-
return this.
|
|
629
|
+
return this._targetDot;
|
|
636
630
|
}
|
|
637
631
|
|
|
638
632
|
/**
|
|
@@ -701,7 +695,7 @@ class DistanceMeasurement extends Component {
|
|
|
701
695
|
}
|
|
702
696
|
|
|
703
697
|
/**
|
|
704
|
-
* Sets if the origin {@link
|
|
698
|
+
* Sets if the origin {@link Dot3D} is visible.
|
|
705
699
|
*
|
|
706
700
|
* @type {Boolean}
|
|
707
701
|
*/
|
|
@@ -712,7 +706,7 @@ class DistanceMeasurement extends Component {
|
|
|
712
706
|
}
|
|
713
707
|
|
|
714
708
|
/**
|
|
715
|
-
* Gets if the origin {@link
|
|
709
|
+
* Gets if the origin {@link Dot3D} is visible.
|
|
716
710
|
*
|
|
717
711
|
* @type {Boolean}
|
|
718
712
|
*/
|
|
@@ -721,7 +715,7 @@ class DistanceMeasurement extends Component {
|
|
|
721
715
|
}
|
|
722
716
|
|
|
723
717
|
/**
|
|
724
|
-
* Sets if the target {@link
|
|
718
|
+
* Sets if the target {@link Dot3D} is visible.
|
|
725
719
|
*
|
|
726
720
|
* @type {Boolean}
|
|
727
721
|
*/
|
|
@@ -732,7 +726,7 @@ class DistanceMeasurement extends Component {
|
|
|
732
726
|
}
|
|
733
727
|
|
|
734
728
|
/**
|
|
735
|
-
* Gets if the target {@link
|
|
729
|
+
* Gets if the target {@link Dot3D} is visible.
|
|
736
730
|
*
|
|
737
731
|
* @type {Boolean}
|
|
738
732
|
*/
|
|
@@ -4,6 +4,7 @@ export * from "./DistanceMeasurementsMouseControl.js";
|
|
|
4
4
|
export * from "./DistanceMeasurementsTouchControl.js";
|
|
5
5
|
|
|
6
6
|
import {Component} from "../../viewer/scene/Component.js";
|
|
7
|
+
import {math} from "../../viewer/scene/math/math.js";
|
|
7
8
|
import {activateDraggableDots} from "../../../src/plugins/lib/ui/index.js";
|
|
8
9
|
|
|
9
10
|
class DistanceMeasurementEditControl extends Component {
|
|
@@ -28,11 +29,30 @@ class DistanceMeasurementEditControl extends Component {
|
|
|
28
29
|
viewer: viewer,
|
|
29
30
|
handleMouseEvents: handleMouseEvents,
|
|
30
31
|
handleTouchEvents: handleTouchEvents,
|
|
31
|
-
snapping: cfg.snapping,
|
|
32
32
|
pointerLens: cfg.pointerLens,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
dots: [ measurement.origin, measurement.target ],
|
|
34
|
+
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
35
|
+
const tryPickWorldPos = snap => {
|
|
36
|
+
const pickResult = viewer.scene.pick({
|
|
37
|
+
canvasPos: canvasPos,
|
|
38
|
+
snapToEdge: snap,
|
|
39
|
+
snapToVertex: snap,
|
|
40
|
+
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// If - when snapping - no pick found, then try w/o snapping
|
|
44
|
+
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return tryPickWorldPos(!!cfg.snapping);
|
|
48
|
+
},
|
|
49
|
+
onEnd: (initPos, dot) => {
|
|
50
|
+
const changed = ! math.compareVec3(initPos, dot.worldPos);
|
|
51
|
+
if (changed) {
|
|
52
|
+
this.fire("edited");
|
|
53
|
+
}
|
|
54
|
+
return changed;
|
|
55
|
+
}
|
|
36
56
|
});
|
|
37
57
|
|
|
38
58
|
const destroyCb = measurement.on("destroyed", cleanup);
|
|
@@ -7,7 +7,7 @@ import {PhongMaterial} from "../../viewer/scene/materials/PhongMaterial.js";
|
|
|
7
7
|
import {math} from "../../viewer/scene/math/math.js";
|
|
8
8
|
import {Mesh} from "../../viewer/scene/mesh/Mesh.js";
|
|
9
9
|
import {Dot} from "../lib/html/Dot.js";
|
|
10
|
-
import {
|
|
10
|
+
import {activateDraggableDots, Dot3D, transformToNode} from "../../../src/plugins/lib/ui/index.js";
|
|
11
11
|
|
|
12
12
|
const hex2rgb = function(color) {
|
|
13
13
|
const rgb = idx => parseInt(color.substr(idx + 1, 2), 16) / 255;
|
|
@@ -1612,26 +1612,19 @@ export class ZonesPolysurfaceTouchControl extends Component {
|
|
|
1612
1612
|
|
|
1613
1613
|
export class ZoneEditControl extends Component {
|
|
1614
1614
|
constructor(zone, cfg, handleMouseEvents, handleTouchEvents) {
|
|
1615
|
-
|
|
1616
|
-
const
|
|
1615
|
+
const viewer = zone.plugin.viewer;
|
|
1616
|
+
const scene = viewer.scene;
|
|
1617
|
+
super(scene);
|
|
1617
1618
|
|
|
1618
1619
|
const altitude = zone._geometry.altitude;
|
|
1619
|
-
const pointerLens = cfg && cfg.pointerLens;
|
|
1620
|
-
const updatePointerLens = (pointerLens
|
|
1621
|
-
? function(canvasPos) {
|
|
1622
|
-
pointerLens.visible = !! canvasPos;
|
|
1623
|
-
if (canvasPos)
|
|
1624
|
-
{
|
|
1625
|
-
pointerLens.canvasPos = canvasPos;
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
: () => { });
|
|
1629
1620
|
|
|
1630
1621
|
const dots = zone._geometry.planeCoordinates.map(planeCoord => {
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1634
|
-
|
|
1622
|
+
const dotParent = scene.canvas.canvas.ownerDocument.body;
|
|
1623
|
+
const dot = new Dot3D(scene, {}, dotParent, { fillColor: zone._color });
|
|
1624
|
+
dot.worldPos = math.vec3([ planeCoord[0], altitude, planeCoord[1] ]);
|
|
1625
|
+
dot.on("worldPos", function() {
|
|
1626
|
+
planeCoord[0] = dot.worldPos[0];
|
|
1627
|
+
planeCoord[1] = dot.worldPos[2];
|
|
1635
1628
|
try {
|
|
1636
1629
|
zone._rebuildMesh();
|
|
1637
1630
|
} catch (e) {
|
|
@@ -1640,46 +1633,29 @@ export class ZoneEditControl extends Component {
|
|
|
1640
1633
|
zone._zoneMesh = null;
|
|
1641
1634
|
}
|
|
1642
1635
|
}
|
|
1643
|
-
};
|
|
1644
|
-
|
|
1645
|
-
const dot = createDraggableDot3D({
|
|
1646
|
-
handleMouseEvents: handleMouseEvents,
|
|
1647
|
-
handleTouchEvents: handleTouchEvents,
|
|
1648
|
-
viewer: zone.plugin.viewer,
|
|
1649
|
-
worldPos: math.vec3([ planeCoord[0], altitude, planeCoord[1] ]),
|
|
1650
|
-
color: zone._color,
|
|
1651
|
-
ray2WorldPos: (orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
1652
|
-
onStart: () => {
|
|
1653
|
-
initWorldPos = dot.getWorldPos().slice();
|
|
1654
|
-
initPlaneCoord = planeCoord.slice();
|
|
1655
|
-
set_other_dots_active(false, dot);
|
|
1656
|
-
},
|
|
1657
|
-
onMove: (canvasPos, worldPos) => {
|
|
1658
|
-
updatePointerLens(canvasPos);
|
|
1659
|
-
setPlaneCoord([ worldPos[0], worldPos[2] ]);
|
|
1660
|
-
},
|
|
1661
|
-
onEnd: () => {
|
|
1662
|
-
if (zone._zoneMesh)
|
|
1663
|
-
{
|
|
1664
|
-
self.fire("edited");
|
|
1665
|
-
}
|
|
1666
|
-
else
|
|
1667
|
-
{
|
|
1668
|
-
dot.setWorldPos(initWorldPos);
|
|
1669
|
-
setPlaneCoord(initPlaneCoord);
|
|
1670
|
-
}
|
|
1671
|
-
updatePointerLens(null);
|
|
1672
|
-
set_other_dots_active(true, dot);
|
|
1673
|
-
}
|
|
1674
1636
|
});
|
|
1675
1637
|
return dot;
|
|
1676
1638
|
});
|
|
1677
|
-
|
|
1678
|
-
|
|
1639
|
+
|
|
1640
|
+
const cleanupDrag = activateDraggableDots({
|
|
1641
|
+
viewer: viewer,
|
|
1642
|
+
handleMouseEvents: handleMouseEvents,
|
|
1643
|
+
handleTouchEvents: handleTouchEvents,
|
|
1644
|
+
pointerLens: cfg && cfg.pointerLens,
|
|
1645
|
+
dots: dots,
|
|
1646
|
+
ray2WorldPos: (orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
1647
|
+
onEnd: (initPos, dot) => {
|
|
1648
|
+
if (zone._zoneMesh)
|
|
1649
|
+
{
|
|
1650
|
+
this.fire("edited");
|
|
1651
|
+
}
|
|
1652
|
+
return !! zone._zoneMesh;
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1679
1655
|
|
|
1680
1656
|
const cleanup = function() {
|
|
1681
|
-
|
|
1682
|
-
|
|
1657
|
+
cleanupDrag();
|
|
1658
|
+
dots.forEach(d => d.destroy());
|
|
1683
1659
|
};
|
|
1684
1660
|
|
|
1685
1661
|
const destroyCb = zone.on("destroyed", cleanup);
|