@xeokit/xeokit-sdk 2.6.23 → 2.6.26
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 +1010 -642
- package/dist/xeokit-sdk.es.js +1010 -643
- package/dist/xeokit-sdk.es5.js +962 -751
- 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 +78 -9
- 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/CameraControl/CameraControl.js +20 -0
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +1 -1
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +2 -2
- package/src/viewer/scene/geometry/builders/index.js +2 -1
- package/src/viewer/scene/marker/Marker.js +9 -3
- package/src/viewer/scene/scene/Scene.js +4 -3
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.d.ts +81 -1
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +81 -0
|
@@ -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);
|
|
@@ -97,6 +97,24 @@ class Dot {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
if (cfg.onTouchstart) {
|
|
101
|
+
dotClickable.addEventListener('touchstart', (event) => {
|
|
102
|
+
cfg.onTouchstart(event, this);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (cfg.onTouchmove) {
|
|
107
|
+
dotClickable.addEventListener('touchmove', (event) => {
|
|
108
|
+
cfg.onTouchmove(event, this);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (cfg.onTouchend) {
|
|
113
|
+
dotClickable.addEventListener('touchend', (event) => {
|
|
114
|
+
cfg.onTouchend(event, this);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
if (cfg.onContextMenu) {
|
|
101
119
|
if(os.isIphoneSafari()){
|
|
102
120
|
dotClickable.addEventListener('touchstart', (event) => {
|
|
@@ -136,24 +154,6 @@ class Dot {
|
|
|
136
154
|
|
|
137
155
|
}
|
|
138
156
|
|
|
139
|
-
if (cfg.onTouchstart) {
|
|
140
|
-
dotClickable.addEventListener('touchstart', (event) => {
|
|
141
|
-
cfg.onTouchstart(event, this);
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (cfg.onTouchmove) {
|
|
146
|
-
dotClickable.addEventListener('touchmove', (event) => {
|
|
147
|
-
cfg.onTouchmove(event, this);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (cfg.onTouchend) {
|
|
152
|
-
dotClickable.addEventListener('touchend', (event) => {
|
|
153
|
-
cfg.onTouchend(event, this);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
157
|
this.setPos(cfg.x || 0, cfg.y || 0);
|
|
158
158
|
this.setFillColor(cfg.fillColor);
|
|
159
159
|
this.setBorderColor(cfg.borderColor);
|
|
@@ -11,7 +11,82 @@ export function transformToNode(from, to, vec) {
|
|
|
11
11
|
vec[1] += fromRec.top - toRec.top;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export
|
|
14
|
+
export class Dot3D extends Marker {
|
|
15
|
+
constructor(scene, markerCfg, parentElement, cfg = {}) {
|
|
16
|
+
super(scene, markerCfg);
|
|
17
|
+
|
|
18
|
+
const handler = (cfgEvent, componentEvent) => {
|
|
19
|
+
return event => {
|
|
20
|
+
if (cfgEvent) {
|
|
21
|
+
cfgEvent(event);
|
|
22
|
+
}
|
|
23
|
+
this.fire(componentEvent, event, true);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
this._dot = new Dot(parentElement, {
|
|
27
|
+
fillColor: cfg.fillColor,
|
|
28
|
+
zIndex: cfg.zIndex,
|
|
29
|
+
onMouseOver: handler(cfg.onMouseOver, "mouseover"),
|
|
30
|
+
onMouseLeave: handler(cfg.onMouseLeave, "mouseleave"),
|
|
31
|
+
onMouseWheel: handler(cfg.onMouseWheel, "wheel"),
|
|
32
|
+
onMouseDown: handler(cfg.onMouseDown, "mousedown"),
|
|
33
|
+
onMouseUp: handler(cfg.onMouseUp, "mouseup"),
|
|
34
|
+
onMouseMove: handler(cfg.onMouseMove, "mousemove"),
|
|
35
|
+
onTouchstart: handler(cfg.onTouchstart, "touchstart"),
|
|
36
|
+
onTouchmove: handler(cfg.onTouchmove, "touchmove"),
|
|
37
|
+
onTouchend: handler(cfg.onTouchend, "touchend"),
|
|
38
|
+
onContextMenu: handler(cfg.onContextMenu, "contextmenu")
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const updateDotPos = () => {
|
|
42
|
+
const pos = this.canvasPos.slice();
|
|
43
|
+
transformToNode(scene.canvas.canvas, parentElement, pos);
|
|
44
|
+
this._dot.setPos(pos[0], pos[1]);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.on("worldPos", updateDotPos);
|
|
48
|
+
|
|
49
|
+
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
50
|
+
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
51
|
+
this._cleanup = () => {
|
|
52
|
+
scene.camera.off(onViewMatrix);
|
|
53
|
+
scene.camera.off(onProjMatrix);
|
|
54
|
+
this._dot.destroy();
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setClickable(value) {
|
|
59
|
+
this._dot.setClickable(value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setCulled(value) {
|
|
63
|
+
this._dot.setCulled(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setFillColor(value) {
|
|
67
|
+
this._dot.setFillColor(value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
setHighlighted(value) {
|
|
71
|
+
this._dot.setHighlighted(value);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setOpacity(value) {
|
|
75
|
+
this._dot.setOpacity(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setVisible(value) {
|
|
79
|
+
this._dot.setVisible(value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
destroy() {
|
|
83
|
+
this._cleanup();
|
|
84
|
+
super.destroy();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function activateDraggableDot(dot, cfg) {
|
|
15
90
|
const extractCFG = function(propName, defaultValue) {
|
|
16
91
|
if (propName in cfg) {
|
|
17
92
|
return cfg[propName];
|
|
@@ -23,8 +98,6 @@ export function createDraggableDot3D(cfg) {
|
|
|
23
98
|
};
|
|
24
99
|
|
|
25
100
|
const viewer = extractCFG("viewer");
|
|
26
|
-
const worldPos = extractCFG("worldPos");
|
|
27
|
-
const color = extractCFG("color");
|
|
28
101
|
const ray2WorldPos = extractCFG("ray2WorldPos");
|
|
29
102
|
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
30
103
|
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
@@ -35,8 +108,6 @@ export function createDraggableDot3D(cfg) {
|
|
|
35
108
|
const scene = viewer.scene;
|
|
36
109
|
const canvas = scene.canvas.canvas;
|
|
37
110
|
|
|
38
|
-
const marker = new Marker(scene, {});
|
|
39
|
-
|
|
40
111
|
const pickWorldPos = canvasPos => {
|
|
41
112
|
const origin = math.vec3();
|
|
42
113
|
const direction = math.vec3();
|
|
@@ -47,11 +118,7 @@ export function createDraggableDot3D(cfg) {
|
|
|
47
118
|
const onChange = event => {
|
|
48
119
|
const canvasPos = math.vec2([ event.clientX, event.clientY ]);
|
|
49
120
|
transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
|
|
50
|
-
|
|
51
|
-
const worldPos = pickWorldPos(canvasPos);
|
|
52
|
-
marker.worldPos = worldPos;
|
|
53
|
-
updateDotPos();
|
|
54
|
-
onMove(canvasPos, worldPos);
|
|
121
|
+
onMove(canvasPos, pickWorldPos(canvasPos));
|
|
55
122
|
};
|
|
56
123
|
|
|
57
124
|
let currentDrag = null;
|
|
@@ -97,13 +164,17 @@ export function createDraggableDot3D(cfg) {
|
|
|
97
164
|
onStart();
|
|
98
165
|
};
|
|
99
166
|
|
|
100
|
-
const
|
|
167
|
+
const cleanupDotHandlers = [ ];
|
|
168
|
+
const dot_on = function(event, callback) {
|
|
169
|
+
const id = dot.on(event, callback);
|
|
170
|
+
cleanupDotHandlers.push(() => dot.off(id));
|
|
171
|
+
};
|
|
101
172
|
|
|
102
173
|
if (handleMouseEvents)
|
|
103
174
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
175
|
+
dot_on("mouseover", () => (! currentDrag) && dot.setOpacity(1.0));
|
|
176
|
+
dot_on("mouseleave", () => (! currentDrag) && dot.setOpacity(idleOpacity));
|
|
177
|
+
dot_on("mousedown", event => {
|
|
107
178
|
if (event.which === 1)
|
|
108
179
|
{
|
|
109
180
|
canvas.addEventListener("mousemove", onDragMove);
|
|
@@ -115,13 +186,13 @@ export function createDraggableDot3D(cfg) {
|
|
|
115
186
|
canvas.removeEventListener("mouseup", onDragEnd);
|
|
116
187
|
});
|
|
117
188
|
}
|
|
118
|
-
};
|
|
189
|
+
});
|
|
119
190
|
}
|
|
120
191
|
|
|
121
192
|
if (handleTouchEvents)
|
|
122
193
|
{
|
|
123
194
|
let touchStartId;
|
|
124
|
-
|
|
195
|
+
dot_on("touchstart", event => {
|
|
125
196
|
event.preventDefault();
|
|
126
197
|
if (event.touches.length === 1)
|
|
127
198
|
{
|
|
@@ -130,46 +201,24 @@ export function createDraggableDot3D(cfg) {
|
|
|
130
201
|
event => [...event.changedTouches].find(e => e.identifier === touchStartId),
|
|
131
202
|
() => { touchStartId = null; });
|
|
132
203
|
}
|
|
133
|
-
};
|
|
134
|
-
|
|
204
|
+
});
|
|
205
|
+
dot_on("touchmove", event => {
|
|
135
206
|
event.preventDefault();
|
|
136
207
|
onDragMove(event);
|
|
137
|
-
};
|
|
138
|
-
|
|
208
|
+
});
|
|
209
|
+
dot_on("touchend", event => {
|
|
139
210
|
event.preventDefault();
|
|
140
211
|
onDragEnd(event);
|
|
141
|
-
};
|
|
212
|
+
});
|
|
142
213
|
}
|
|
143
214
|
|
|
144
|
-
const
|
|
145
|
-
const dot = new Dot(dotParent, dotCfg);
|
|
146
|
-
|
|
147
|
-
const idleOpacity = 0.5;
|
|
215
|
+
const idleOpacity = 0.8;
|
|
148
216
|
dot.setOpacity(idleOpacity);
|
|
149
217
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
dot.
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
marker.worldPos = worldPos;
|
|
157
|
-
updateDotPos();
|
|
158
|
-
|
|
159
|
-
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
160
|
-
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
setActive: value => dot.setClickable(value),
|
|
164
|
-
getWorldPos: () => marker.worldPos,
|
|
165
|
-
setWorldPos: pos => { marker.worldPos = pos; updateDotPos(); },
|
|
166
|
-
destroy: function() {
|
|
167
|
-
currentDrag && currentDrag.cleanup();
|
|
168
|
-
scene.camera.off(onViewMatrix);
|
|
169
|
-
scene.camera.off(onProjMatrix);
|
|
170
|
-
marker.destroy();
|
|
171
|
-
dot.destroy();
|
|
172
|
-
}
|
|
218
|
+
return function() {
|
|
219
|
+
currentDrag && currentDrag.cleanup();
|
|
220
|
+
cleanupDotHandlers.forEach(c => c());
|
|
221
|
+
dot.setOpacity(1.0);
|
|
173
222
|
};
|
|
174
223
|
};
|
|
175
224
|
|
|
@@ -187,11 +236,10 @@ export function activateDraggableDots(cfg) {
|
|
|
187
236
|
const viewer = extractCFG("viewer");
|
|
188
237
|
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
189
238
|
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
190
|
-
const snapping = extractCFG("snapping");
|
|
191
239
|
const pointerLens = extractCFG("pointerLens", null);
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
const
|
|
240
|
+
const dots = extractCFG("dots");
|
|
241
|
+
const ray2WorldPos = extractCFG("ray2WorldPos");
|
|
242
|
+
const onEnd = extractCFG("onEnd", nop);
|
|
195
243
|
|
|
196
244
|
const updatePointerLens = (pointerLens
|
|
197
245
|
? function(canvasPos) {
|
|
@@ -203,62 +251,36 @@ export function activateDraggableDots(cfg) {
|
|
|
203
251
|
}
|
|
204
252
|
: () => { });
|
|
205
253
|
|
|
206
|
-
const
|
|
207
|
-
let
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const dot = createDraggableDot3D({
|
|
254
|
+
const cleanups = dots.map(dot => {
|
|
255
|
+
let initPos;
|
|
256
|
+
return activateDraggableDot(dot, {
|
|
211
257
|
handleMouseEvents: handleMouseEvents,
|
|
212
258
|
handleTouchEvents: handleTouchEvents,
|
|
213
259
|
viewer: viewer,
|
|
214
|
-
|
|
215
|
-
color: color,
|
|
216
|
-
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
217
|
-
const tryPickWorldPos = snap => {
|
|
218
|
-
const pickResult = viewer.scene.pick({
|
|
219
|
-
canvasPos: canvasPos,
|
|
220
|
-
snapToEdge: snap,
|
|
221
|
-
snapToVertex: snap,
|
|
222
|
-
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// If - when snapping - no pick found, then try w/o snapping
|
|
226
|
-
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
return tryPickWorldPos(!!snapping) || initDotPos;
|
|
230
|
-
},
|
|
260
|
+
ray2WorldPos: (orig, dir, canvasPos) => (ray2WorldPos(orig, dir, canvasPos) || initPos),
|
|
231
261
|
onStart: () => {
|
|
232
|
-
|
|
233
|
-
initMarkerPos = marker.worldPos.slice();
|
|
262
|
+
initPos = dot.worldPos.slice();
|
|
234
263
|
setOtherDotsActive(false, dot);
|
|
235
264
|
},
|
|
236
265
|
onMove: (canvasPos, worldPos) => {
|
|
237
266
|
updatePointerLens(canvasPos);
|
|
238
|
-
|
|
267
|
+
dot.worldPos = worldPos;
|
|
239
268
|
},
|
|
240
269
|
onEnd: () => {
|
|
241
|
-
if (!
|
|
242
|
-
|
|
243
|
-
onEdit();
|
|
244
|
-
}
|
|
245
|
-
else
|
|
246
|
-
{
|
|
247
|
-
dot.setWorldPos(initDotPos);
|
|
248
|
-
setCoord(initMarkerPos);
|
|
270
|
+
if (! onEnd(initPos, dot)) {
|
|
271
|
+
dot.worldPos = initPos;
|
|
249
272
|
}
|
|
250
273
|
updatePointerLens(null);
|
|
251
274
|
setOtherDotsActive(true, dot);
|
|
252
275
|
}
|
|
253
276
|
});
|
|
254
|
-
return dot;
|
|
255
277
|
});
|
|
256
278
|
|
|
257
|
-
const setOtherDotsActive = (active, dot) => dots.forEach(d => (d !== dot) && d.
|
|
279
|
+
const setOtherDotsActive = (active, dot) => dots.forEach(d => (d !== dot) && d.setClickable(active));
|
|
258
280
|
setOtherDotsActive(true);
|
|
259
281
|
|
|
260
282
|
return function() {
|
|
261
|
-
|
|
283
|
+
cleanups.forEach(c => c());
|
|
262
284
|
updatePointerLens(null);
|
|
263
285
|
};
|
|
264
286
|
}
|
|
@@ -649,6 +649,8 @@ class CameraControl extends Component {
|
|
|
649
649
|
snapToEdge: DEFAULT_SNAP_EDGE,
|
|
650
650
|
snapRadius: DEFAULT_SNAP_PICK_RADIUS,
|
|
651
651
|
|
|
652
|
+
keyboardEnabledOnlyIfMouseover: true,
|
|
653
|
+
|
|
652
654
|
// Rotation
|
|
653
655
|
|
|
654
656
|
dragRotationRate: 360.0,
|
|
@@ -959,6 +961,24 @@ class CameraControl extends Component {
|
|
|
959
961
|
get snapRadius() {
|
|
960
962
|
return this._configs.snapRadius;
|
|
961
963
|
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* If `true`, the keyboard shortcuts are enabled ONLY if the mouse is over the canvas.
|
|
967
|
+
*
|
|
968
|
+
* @param {boolean} value
|
|
969
|
+
*/
|
|
970
|
+
set keyboardEnabledOnlyIfMouseover(value) {
|
|
971
|
+
this._configs.keyboardEnabledOnlyIfMouseover = !!value;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Gets whether the keyboard shortcuts are enabled ONLY if the mouse is over the canvas or ALWAYS.
|
|
976
|
+
*
|
|
977
|
+
* @returns {boolean}
|
|
978
|
+
*/
|
|
979
|
+
get keyboardEnabledOnlyIfMouseover() {
|
|
980
|
+
return this._configs.keyboardEnabledOnlyIfMouseover;
|
|
981
|
+
}
|
|
962
982
|
|
|
963
983
|
/**
|
|
964
984
|
* Sets the current navigation mode.
|
|
@@ -22,7 +22,7 @@ class KeyboardPanRotateDollyHandler {
|
|
|
22
22
|
if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
if (!states.mouseover) {
|
|
25
|
+
if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
keyDownMap[keyCode] = true;
|
|
@@ -53,7 +53,7 @@ class KeyboardPanRotateDollyHandler {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (!states.mouseover) {
|
|
56
|
+
if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -6,4 +6,5 @@ export * from "./buildPlaneGeometry.js";
|
|
|
6
6
|
export * from "./buildSphereGeometry.js";
|
|
7
7
|
export * from "./buildTorusGeometry.js";
|
|
8
8
|
export * from "./buildVectorTextGeometry.js";
|
|
9
|
-
export * from "./buildPolylineGeometry.js";
|
|
9
|
+
export * from "./buildPolylineGeometry.js";
|
|
10
|
+
export * from "./buildLineGeometry.js";
|
|
@@ -196,11 +196,17 @@ class Marker extends Component {
|
|
|
196
196
|
return;
|
|
197
197
|
}
|
|
198
198
|
if (this._onEntityDestroyed !== null) {
|
|
199
|
-
this._entity.model
|
|
199
|
+
if (this._entity.model) {
|
|
200
|
+
this._entity.model.off(this._onEntityDestroyed);
|
|
201
|
+
} else {
|
|
202
|
+
this._entity.off(this._onEntityDestroyed);
|
|
203
|
+
}
|
|
200
204
|
this._onEntityDestroyed = null;
|
|
201
205
|
}
|
|
202
206
|
if (this._onEntityModelDestroyed !== null) {
|
|
203
|
-
this._entity.model
|
|
207
|
+
if (this._entity.model) {
|
|
208
|
+
this._entity.model.off(this._onEntityModelDestroyed);
|
|
209
|
+
}
|
|
204
210
|
this._onEntityModelDestroyed = null;
|
|
205
211
|
}
|
|
206
212
|
}
|
|
@@ -212,7 +218,7 @@ class Marker extends Component {
|
|
|
212
218
|
this._onEntityModelDestroyed = null;
|
|
213
219
|
});
|
|
214
220
|
} else {
|
|
215
|
-
this._onEntityDestroyed = this._entity.
|
|
221
|
+
this._onEntityDestroyed = this._entity.on("destroyed", () => {
|
|
216
222
|
this._entity = null;
|
|
217
223
|
this._onEntityDestroyed = null;
|
|
218
224
|
});
|
|
@@ -2099,10 +2099,10 @@ class Scene extends Component {
|
|
|
2099
2099
|
*/
|
|
2100
2100
|
get center() {
|
|
2101
2101
|
if (this._aabbDirty || !this._center) {
|
|
2102
|
-
|
|
2102
|
+
const aabb = this.aabb;
|
|
2103
|
+
if (!this._center) {
|
|
2103
2104
|
this._center = math.vec3();
|
|
2104
2105
|
}
|
|
2105
|
-
const aabb = this.aabb;
|
|
2106
2106
|
this._center[0] = (aabb[0] + aabb[3]) / 2;
|
|
2107
2107
|
this._center[1] = (aabb[1] + aabb[4]) / 2;
|
|
2108
2108
|
this._center[2] = (aabb[2] + aabb[5]) / 2;
|
|
@@ -2177,6 +2177,7 @@ class Scene extends Component {
|
|
|
2177
2177
|
this._aabb[4] = ymax;
|
|
2178
2178
|
this._aabb[5] = zmax;
|
|
2179
2179
|
this._aabbDirty = false;
|
|
2180
|
+
this._center = null;
|
|
2180
2181
|
}
|
|
2181
2182
|
return this._aabb;
|
|
2182
2183
|
}
|
|
@@ -2832,4 +2833,4 @@ class Scene extends Component {
|
|
|
2832
2833
|
}
|
|
2833
2834
|
}
|
|
2834
2835
|
|
|
2835
|
-
export {Scene};
|
|
2836
|
+
export {Scene};
|
|
@@ -17,6 +17,58 @@ export declare type AngleMeasurementsPluginConfiguration = {
|
|
|
17
17
|
zIndex?: number;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Event fire by {@link AngleMeasurementsPlugin} when mouse enters over an {@link AngleMeasurement}.
|
|
22
|
+
*/
|
|
23
|
+
export declare type AngleMeasurementMouseOverEvent = {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The plugin.
|
|
27
|
+
*/
|
|
28
|
+
plugin: AngleMeasurementsPlugin;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The measurement.
|
|
32
|
+
*/
|
|
33
|
+
angleMeasurement: AngleMeasurement;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The measurement.
|
|
37
|
+
*/
|
|
38
|
+
measurement: AngleMeasurement;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The original mouse event.
|
|
42
|
+
*/
|
|
43
|
+
event: MouseEvent;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Event fire by {@link AngleMeasurementsPlugin} when mouse leaves an {@link AngleMeasurement}.
|
|
48
|
+
*/
|
|
49
|
+
export declare type AngleMeasurementMouseLeaveEvent = {
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The plugin.
|
|
53
|
+
*/
|
|
54
|
+
plugin: AngleMeasurementsPlugin;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The measurement.
|
|
58
|
+
*/
|
|
59
|
+
angleMeasurement: AngleMeasurement;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The measurement.
|
|
63
|
+
*/
|
|
64
|
+
measurement: AngleMeasurement;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The original mouse event.
|
|
68
|
+
*/
|
|
69
|
+
event: MouseEvent;
|
|
70
|
+
}
|
|
71
|
+
|
|
20
72
|
/**
|
|
21
73
|
* {@link Viewer} plugin for measuring angles.
|
|
22
74
|
*/
|
|
@@ -87,7 +139,35 @@ export declare class AngleMeasurementsPlugin extends Plugin {
|
|
|
87
139
|
*/
|
|
88
140
|
clear(): void;
|
|
89
141
|
|
|
90
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Fires when mouse is over a measurement.
|
|
144
|
+
* @param {String} event The mouseOver event
|
|
145
|
+
* @param {Function} callback Callback fired on the event
|
|
146
|
+
*/
|
|
147
|
+
on(event: "mouseOver", callback: (event: AngleMeasurementMouseOverEvent)=> void): string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Fires when mouse leaves a measurement.
|
|
151
|
+
* @param {String} event The mouseLeave event
|
|
152
|
+
* @param {Function} callback Callback fired on the event
|
|
153
|
+
*/
|
|
154
|
+
on(event: "mouseLeave", callback: (event: AngleMeasurementMouseLeaveEvent)=> void): string;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Fires when a context menu is to be opened on a measurement.
|
|
158
|
+
* @param {String} event The contextMenu event
|
|
159
|
+
* @param {Function} callback Callback fired on the event
|
|
160
|
+
*/
|
|
161
|
+
on(event: "contextMenu", callback: (measurement: AngleMeasurement)=> void): string;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Fires when a measurement is completed.
|
|
165
|
+
* @param {String} event The measurementEnd event
|
|
166
|
+
* @param {Function} callback Callback fired on the event
|
|
167
|
+
*/
|
|
168
|
+
on(event: "measurementStart", callback: (measurement: AngleMeasurement)=> void): string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
91
171
|
* Fires when a measurement is created.
|
|
92
172
|
* @param {String} event The measurementCreated event
|
|
93
173
|
* @param {Function} callback Callback fired on the event
|