@xeokit/xeokit-sdk 2.6.22 → 2.6.23
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 +387 -162
- package/dist/xeokit-sdk.es.js +384 -163
- package/dist/xeokit-sdk.es5.js +682 -662
- 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/AngleMeasurementsMouseControl.js +2 -2
- package/src/plugins/AngleMeasurementsPlugin/index.js +59 -1
- package/src/plugins/DistanceMeasurementsPlugin/index.js +59 -1
- package/src/plugins/ZonesPlugin/index.js +13 -160
- package/src/plugins/lib/ui/index.js +264 -0
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -12386,10 +12386,10 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
12386
12386
|
}
|
|
12387
12387
|
|
|
12388
12388
|
_destroyMarkerDiv() {
|
|
12389
|
-
if (this.
|
|
12389
|
+
if (this.markerDiv) {
|
|
12390
12390
|
const element = document.getElementById('myMarkerDiv');
|
|
12391
12391
|
element.parentNode.removeChild(element);
|
|
12392
|
-
this.
|
|
12392
|
+
this.markerDiv = null;
|
|
12393
12393
|
}
|
|
12394
12394
|
}
|
|
12395
12395
|
|
|
@@ -14103,6 +14103,320 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
|
|
|
14103
14103
|
}
|
|
14104
14104
|
}
|
|
14105
14105
|
|
|
14106
|
+
const nop = () => { };
|
|
14107
|
+
|
|
14108
|
+
function transformToNode(from, to, vec) {
|
|
14109
|
+
const fromRec = from.getBoundingClientRect();
|
|
14110
|
+
const toRec = to.getBoundingClientRect();
|
|
14111
|
+
vec[0] += fromRec.left - toRec.left;
|
|
14112
|
+
vec[1] += fromRec.top - toRec.top;
|
|
14113
|
+
}
|
|
14114
|
+
function createDraggableDot3D(cfg) {
|
|
14115
|
+
const extractCFG = function(propName, defaultValue) {
|
|
14116
|
+
if (propName in cfg) {
|
|
14117
|
+
return cfg[propName];
|
|
14118
|
+
} else if (defaultValue !== undefined) {
|
|
14119
|
+
return defaultValue;
|
|
14120
|
+
} else {
|
|
14121
|
+
throw "config missing: " + propName;
|
|
14122
|
+
}
|
|
14123
|
+
};
|
|
14124
|
+
|
|
14125
|
+
const viewer = extractCFG("viewer");
|
|
14126
|
+
const worldPos = extractCFG("worldPos");
|
|
14127
|
+
const color = extractCFG("color");
|
|
14128
|
+
const ray2WorldPos = extractCFG("ray2WorldPos");
|
|
14129
|
+
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
14130
|
+
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
14131
|
+
const onStart = extractCFG("onStart", nop);
|
|
14132
|
+
const onMove = extractCFG("onMove", nop);
|
|
14133
|
+
const onEnd = extractCFG("onEnd", nop);
|
|
14134
|
+
|
|
14135
|
+
const scene = viewer.scene;
|
|
14136
|
+
const canvas = scene.canvas.canvas;
|
|
14137
|
+
|
|
14138
|
+
const marker = new Marker(scene, {});
|
|
14139
|
+
|
|
14140
|
+
const pickWorldPos = canvasPos => {
|
|
14141
|
+
const origin = math.vec3();
|
|
14142
|
+
const direction = math.vec3();
|
|
14143
|
+
math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
|
|
14144
|
+
return ray2WorldPos(origin, direction, canvasPos);
|
|
14145
|
+
};
|
|
14146
|
+
|
|
14147
|
+
const onChange = event => {
|
|
14148
|
+
const canvasPos = math.vec2([ event.clientX, event.clientY ]);
|
|
14149
|
+
transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
|
|
14150
|
+
|
|
14151
|
+
const worldPos = pickWorldPos(canvasPos);
|
|
14152
|
+
marker.worldPos = worldPos;
|
|
14153
|
+
updateDotPos();
|
|
14154
|
+
onMove(canvasPos, worldPos);
|
|
14155
|
+
};
|
|
14156
|
+
|
|
14157
|
+
let currentDrag = null;
|
|
14158
|
+
|
|
14159
|
+
const onDragMove = function(event) {
|
|
14160
|
+
const e = currentDrag.matchesEvent(event);
|
|
14161
|
+
if (e)
|
|
14162
|
+
{
|
|
14163
|
+
onChange(e);
|
|
14164
|
+
}
|
|
14165
|
+
};
|
|
14166
|
+
|
|
14167
|
+
const onDragEnd = function(event) {
|
|
14168
|
+
const e = currentDrag.matchesEvent(event);
|
|
14169
|
+
if (e)
|
|
14170
|
+
{
|
|
14171
|
+
dot.setOpacity(idleOpacity);
|
|
14172
|
+
currentDrag.cleanup();
|
|
14173
|
+
onChange(e);
|
|
14174
|
+
onEnd();
|
|
14175
|
+
}
|
|
14176
|
+
};
|
|
14177
|
+
|
|
14178
|
+
const startDrag = function(matchesEvent, cleanupHandlers) {
|
|
14179
|
+
if (currentDrag) {
|
|
14180
|
+
currentDrag.cleanup();
|
|
14181
|
+
}
|
|
14182
|
+
|
|
14183
|
+
dot.setOpacity(1.0);
|
|
14184
|
+
dot.setClickable(false);
|
|
14185
|
+
viewer.cameraControl.active = false;
|
|
14186
|
+
|
|
14187
|
+
currentDrag = {
|
|
14188
|
+
matchesEvent: matchesEvent,
|
|
14189
|
+
cleanup: function() {
|
|
14190
|
+
currentDrag = null;
|
|
14191
|
+
dot.setClickable(true);
|
|
14192
|
+
viewer.cameraControl.active = true;
|
|
14193
|
+
cleanupHandlers();
|
|
14194
|
+
}
|
|
14195
|
+
};
|
|
14196
|
+
|
|
14197
|
+
onStart();
|
|
14198
|
+
};
|
|
14199
|
+
|
|
14200
|
+
const dotCfg = { fillColor: color };
|
|
14201
|
+
|
|
14202
|
+
if (handleMouseEvents)
|
|
14203
|
+
{
|
|
14204
|
+
dotCfg.onMouseOver = () => (! currentDrag) && dot.setOpacity(1.0);
|
|
14205
|
+
dotCfg.onMouseLeave = () => (! currentDrag) && dot.setOpacity(idleOpacity);
|
|
14206
|
+
dotCfg.onMouseDown = event => {
|
|
14207
|
+
if (event.which === 1)
|
|
14208
|
+
{
|
|
14209
|
+
canvas.addEventListener("mousemove", onDragMove);
|
|
14210
|
+
canvas.addEventListener("mouseup", onDragEnd);
|
|
14211
|
+
startDrag(
|
|
14212
|
+
event => (event.which === 1) && event,
|
|
14213
|
+
() => {
|
|
14214
|
+
canvas.removeEventListener("mousemove", onDragMove);
|
|
14215
|
+
canvas.removeEventListener("mouseup", onDragEnd);
|
|
14216
|
+
});
|
|
14217
|
+
}
|
|
14218
|
+
};
|
|
14219
|
+
}
|
|
14220
|
+
|
|
14221
|
+
if (handleTouchEvents)
|
|
14222
|
+
{
|
|
14223
|
+
let touchStartId;
|
|
14224
|
+
dotCfg.onTouchstart = event => {
|
|
14225
|
+
event.preventDefault();
|
|
14226
|
+
if (event.touches.length === 1)
|
|
14227
|
+
{
|
|
14228
|
+
touchStartId = event.touches[0].identifier;
|
|
14229
|
+
startDrag(
|
|
14230
|
+
event => [...event.changedTouches].find(e => e.identifier === touchStartId),
|
|
14231
|
+
() => { touchStartId = null; });
|
|
14232
|
+
}
|
|
14233
|
+
};
|
|
14234
|
+
dotCfg.onTouchmove = event => {
|
|
14235
|
+
event.preventDefault();
|
|
14236
|
+
onDragMove(event);
|
|
14237
|
+
};
|
|
14238
|
+
dotCfg.onTouchend = event => {
|
|
14239
|
+
event.preventDefault();
|
|
14240
|
+
onDragEnd(event);
|
|
14241
|
+
};
|
|
14242
|
+
}
|
|
14243
|
+
|
|
14244
|
+
const dotParent = canvas.ownerDocument.body;
|
|
14245
|
+
const dot = new Dot(dotParent, dotCfg);
|
|
14246
|
+
|
|
14247
|
+
const idleOpacity = 0.5;
|
|
14248
|
+
dot.setOpacity(idleOpacity);
|
|
14249
|
+
|
|
14250
|
+
const updateDotPos = function() {
|
|
14251
|
+
const pos = marker.canvasPos.slice();
|
|
14252
|
+
transformToNode(canvas, dotParent, pos);
|
|
14253
|
+
dot.setPos(pos[0], pos[1]);
|
|
14254
|
+
};
|
|
14255
|
+
|
|
14256
|
+
marker.worldPos = worldPos;
|
|
14257
|
+
updateDotPos();
|
|
14258
|
+
|
|
14259
|
+
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
14260
|
+
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
14261
|
+
|
|
14262
|
+
return {
|
|
14263
|
+
setActive: value => dot.setClickable(value),
|
|
14264
|
+
getWorldPos: () => marker.worldPos,
|
|
14265
|
+
setWorldPos: pos => { marker.worldPos = pos; updateDotPos(); },
|
|
14266
|
+
destroy: function() {
|
|
14267
|
+
currentDrag && currentDrag.cleanup();
|
|
14268
|
+
scene.camera.off(onViewMatrix);
|
|
14269
|
+
scene.camera.off(onProjMatrix);
|
|
14270
|
+
marker.destroy();
|
|
14271
|
+
dot.destroy();
|
|
14272
|
+
}
|
|
14273
|
+
};
|
|
14274
|
+
}
|
|
14275
|
+
function activateDraggableDots(cfg) {
|
|
14276
|
+
const extractCFG = function(propName, defaultValue) {
|
|
14277
|
+
if (propName in cfg) {
|
|
14278
|
+
return cfg[propName];
|
|
14279
|
+
} else if (defaultValue !== undefined) {
|
|
14280
|
+
return defaultValue;
|
|
14281
|
+
} else {
|
|
14282
|
+
throw "config missing: " + propName;
|
|
14283
|
+
}
|
|
14284
|
+
};
|
|
14285
|
+
|
|
14286
|
+
const viewer = extractCFG("viewer");
|
|
14287
|
+
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
14288
|
+
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
14289
|
+
const snapping = extractCFG("snapping");
|
|
14290
|
+
const pointerLens = extractCFG("pointerLens", null);
|
|
14291
|
+
const color = extractCFG("color");
|
|
14292
|
+
const markers = extractCFG("markers");
|
|
14293
|
+
const onEdit = extractCFG("onEdit", nop);
|
|
14294
|
+
|
|
14295
|
+
const updatePointerLens = (pointerLens
|
|
14296
|
+
? function(canvasPos) {
|
|
14297
|
+
pointerLens.visible = !! canvasPos;
|
|
14298
|
+
if (canvasPos)
|
|
14299
|
+
{
|
|
14300
|
+
pointerLens.canvasPos = canvasPos;
|
|
14301
|
+
}
|
|
14302
|
+
}
|
|
14303
|
+
: () => { });
|
|
14304
|
+
|
|
14305
|
+
const dots = markers.map(marker => {
|
|
14306
|
+
let initDotPos, initMarkerPos;
|
|
14307
|
+
const setCoord = coord => marker.worldPos = coord;
|
|
14308
|
+
|
|
14309
|
+
const dot = createDraggableDot3D({
|
|
14310
|
+
handleMouseEvents: handleMouseEvents,
|
|
14311
|
+
handleTouchEvents: handleTouchEvents,
|
|
14312
|
+
viewer: viewer,
|
|
14313
|
+
worldPos: marker.worldPos,
|
|
14314
|
+
color: color,
|
|
14315
|
+
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
14316
|
+
const tryPickWorldPos = snap => {
|
|
14317
|
+
const pickResult = viewer.scene.pick({
|
|
14318
|
+
canvasPos: canvasPos,
|
|
14319
|
+
snapToEdge: snap,
|
|
14320
|
+
snapToVertex: snap,
|
|
14321
|
+
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
14322
|
+
});
|
|
14323
|
+
|
|
14324
|
+
// If - when snapping - no pick found, then try w/o snapping
|
|
14325
|
+
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
14326
|
+
};
|
|
14327
|
+
|
|
14328
|
+
return tryPickWorldPos(!!snapping) || initDotPos;
|
|
14329
|
+
},
|
|
14330
|
+
onStart: () => {
|
|
14331
|
+
initDotPos = dot.getWorldPos().slice();
|
|
14332
|
+
initMarkerPos = marker.worldPos.slice();
|
|
14333
|
+
setOtherDotsActive(false, dot);
|
|
14334
|
+
},
|
|
14335
|
+
onMove: (canvasPos, worldPos) => {
|
|
14336
|
+
updatePointerLens(canvasPos);
|
|
14337
|
+
setCoord(worldPos);
|
|
14338
|
+
},
|
|
14339
|
+
onEnd: () => {
|
|
14340
|
+
if (! math.compareVec3(initMarkerPos, marker.worldPos))
|
|
14341
|
+
{
|
|
14342
|
+
onEdit();
|
|
14343
|
+
}
|
|
14344
|
+
else
|
|
14345
|
+
{
|
|
14346
|
+
dot.setWorldPos(initDotPos);
|
|
14347
|
+
setCoord(initMarkerPos);
|
|
14348
|
+
}
|
|
14349
|
+
updatePointerLens(null);
|
|
14350
|
+
setOtherDotsActive(true, dot);
|
|
14351
|
+
}
|
|
14352
|
+
});
|
|
14353
|
+
return dot;
|
|
14354
|
+
});
|
|
14355
|
+
|
|
14356
|
+
const setOtherDotsActive = (active, dot) => dots.forEach(d => (d !== dot) && d.setActive(active));
|
|
14357
|
+
setOtherDotsActive(true);
|
|
14358
|
+
|
|
14359
|
+
return function() {
|
|
14360
|
+
dots.forEach(m => m.destroy());
|
|
14361
|
+
updatePointerLens(null);
|
|
14362
|
+
};
|
|
14363
|
+
}
|
|
14364
|
+
|
|
14365
|
+
class AngleMeasurementEditControl extends Component {
|
|
14366
|
+
|
|
14367
|
+
/**
|
|
14368
|
+
* Edits {@link AngleMeasurement} with mouse and/or touch input.
|
|
14369
|
+
*
|
|
14370
|
+
* @param {AngleMeasurement} [measurement] The AngleMeasurement to edit.
|
|
14371
|
+
* @param [cfg] Configuration
|
|
14372
|
+
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor.
|
|
14373
|
+
* @param {boolean} [cfg.snapping] Whether to enable snap-to-vertex and snap-to-edge.
|
|
14374
|
+
* @param {boolean} [handleMouseEvents] Whether to hangle mouse input.
|
|
14375
|
+
* @param {boolean} [handleTouchEvents] Whether to hangle touch input.
|
|
14376
|
+
*/
|
|
14377
|
+
constructor(measurement, cfg, handleMouseEvents, handleTouchEvents) {
|
|
14378
|
+
|
|
14379
|
+
const viewer = measurement.plugin.viewer;
|
|
14380
|
+
|
|
14381
|
+
super(viewer.scene);
|
|
14382
|
+
|
|
14383
|
+
const cleanup = activateDraggableDots({
|
|
14384
|
+
viewer: viewer,
|
|
14385
|
+
handleMouseEvents: handleMouseEvents,
|
|
14386
|
+
handleTouchEvents: handleTouchEvents,
|
|
14387
|
+
snapping: cfg.snapping,
|
|
14388
|
+
pointerLens: cfg.pointerLens,
|
|
14389
|
+
color: measurement.color,
|
|
14390
|
+
markers: [ measurement.origin, measurement.corner, measurement.target ],
|
|
14391
|
+
onEdit: () => this.fire("edited")
|
|
14392
|
+
});
|
|
14393
|
+
|
|
14394
|
+
const destroyCb = measurement.on("destroyed", cleanup);
|
|
14395
|
+
|
|
14396
|
+
this._deactivate = function() {
|
|
14397
|
+
measurement.off("destroyed", destroyCb);
|
|
14398
|
+
cleanup();
|
|
14399
|
+
};
|
|
14400
|
+
}
|
|
14401
|
+
|
|
14402
|
+
deactivate() {
|
|
14403
|
+
this._deactivate();
|
|
14404
|
+
super.destroy();
|
|
14405
|
+
}
|
|
14406
|
+
}
|
|
14407
|
+
|
|
14408
|
+
class AngleMeasurementEditMouseControl extends AngleMeasurementEditControl {
|
|
14409
|
+
constructor(zone, cfg) {
|
|
14410
|
+
super(zone, cfg, true, false);
|
|
14411
|
+
}
|
|
14412
|
+
}
|
|
14413
|
+
|
|
14414
|
+
class AngleMeasurementEditTouchControl extends AngleMeasurementEditControl {
|
|
14415
|
+
constructor(zone, cfg) {
|
|
14416
|
+
super(zone, cfg, false, true);
|
|
14417
|
+
}
|
|
14418
|
+
}
|
|
14419
|
+
|
|
14106
14420
|
/**
|
|
14107
14421
|
* A {@link Marker} with an HTML label attached to it, managed by an {@link AnnotationsPlugin}.
|
|
14108
14422
|
*
|
|
@@ -89363,6 +89677,61 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
|
|
|
89363
89677
|
}
|
|
89364
89678
|
}
|
|
89365
89679
|
|
|
89680
|
+
class DistanceMeasurementEditControl extends Component {
|
|
89681
|
+
|
|
89682
|
+
/**
|
|
89683
|
+
* Edits {@link DistanceMeasurement} with mouse and/or touch input.
|
|
89684
|
+
*
|
|
89685
|
+
* @param {DistanceMeasurement} [measurement] The DistanceMeasurement to edit.
|
|
89686
|
+
* @param [cfg] Configuration
|
|
89687
|
+
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor.
|
|
89688
|
+
* @param {boolean} [cfg.snapping] Whether to enable snap-to-vertex and snap-to-edge.
|
|
89689
|
+
* @param {boolean} [handleMouseEvents] Whether to hangle mouse input.
|
|
89690
|
+
* @param {boolean} [handleTouchEvents] Whether to hangle touch input.
|
|
89691
|
+
*/
|
|
89692
|
+
constructor(measurement, cfg, handleMouseEvents, handleTouchEvents) {
|
|
89693
|
+
|
|
89694
|
+
const viewer = measurement.plugin.viewer;
|
|
89695
|
+
|
|
89696
|
+
super(viewer.scene);
|
|
89697
|
+
|
|
89698
|
+
const cleanup = activateDraggableDots({
|
|
89699
|
+
viewer: viewer,
|
|
89700
|
+
handleMouseEvents: handleMouseEvents,
|
|
89701
|
+
handleTouchEvents: handleTouchEvents,
|
|
89702
|
+
snapping: cfg.snapping,
|
|
89703
|
+
pointerLens: cfg.pointerLens,
|
|
89704
|
+
color: measurement.color,
|
|
89705
|
+
markers: [ measurement.origin, measurement.target ],
|
|
89706
|
+
onEdit: () => this.fire("edited")
|
|
89707
|
+
});
|
|
89708
|
+
|
|
89709
|
+
const destroyCb = measurement.on("destroyed", cleanup);
|
|
89710
|
+
|
|
89711
|
+
this._deactivate = function() {
|
|
89712
|
+
measurement.off("destroyed", destroyCb);
|
|
89713
|
+
cleanup();
|
|
89714
|
+
};
|
|
89715
|
+
}
|
|
89716
|
+
|
|
89717
|
+
deactivate() {
|
|
89718
|
+
this._deactivate();
|
|
89719
|
+
super.destroy();
|
|
89720
|
+
}
|
|
89721
|
+
}
|
|
89722
|
+
|
|
89723
|
+
class DistanceMeasurementEditMouseControl extends DistanceMeasurementEditControl {
|
|
89724
|
+
constructor(zone, cfg) {
|
|
89725
|
+
super(zone, cfg, true, false);
|
|
89726
|
+
}
|
|
89727
|
+
}
|
|
89728
|
+
|
|
89729
|
+
class DistanceMeasurementEditTouchControl extends DistanceMeasurementEditControl {
|
|
89730
|
+
constructor(zone, cfg) {
|
|
89731
|
+
super(zone, cfg, false, true);
|
|
89732
|
+
}
|
|
89733
|
+
}
|
|
89734
|
+
|
|
89366
89735
|
/**
|
|
89367
89736
|
* {@link Viewer} plugin that makes interaction smoother with large models, by temporarily switching
|
|
89368
89737
|
* the Viewer to faster, lower-quality rendering modes whenever we interact.
|
|
@@ -137935,13 +138304,6 @@ const hex2rgb = function(color) {
|
|
|
137935
138304
|
return [ rgb(0), rgb(2), rgb(4) ];
|
|
137936
138305
|
};
|
|
137937
138306
|
|
|
137938
|
-
const transformToNode = function(from, to, vec) {
|
|
137939
|
-
const fromRec = from.getBoundingClientRect();
|
|
137940
|
-
const toRec = to.getBoundingClientRect();
|
|
137941
|
-
vec[0] += fromRec.left - toRec.left;
|
|
137942
|
-
vec[1] += fromRec.top - toRec.top;
|
|
137943
|
-
};
|
|
137944
|
-
|
|
137945
138307
|
const triangulateEarClipping = function(planeCoords) {
|
|
137946
138308
|
|
|
137947
138309
|
const polygonVertices = [ ];
|
|
@@ -138044,148 +138406,6 @@ const triangulateEarClipping = function(planeCoords) {
|
|
|
138044
138406
|
return [ planeCoords, baseTriangles ];
|
|
138045
138407
|
};
|
|
138046
138408
|
|
|
138047
|
-
const draggableDot3D = function(handleMouseEvents, handleTouchEvents, viewer, worldPos, color, ray2WorldPos, onStart, onMove, onEnd) {
|
|
138048
|
-
const scene = viewer.scene;
|
|
138049
|
-
const canvas = scene.canvas.canvas;
|
|
138050
|
-
|
|
138051
|
-
const marker = new Marker(scene, {});
|
|
138052
|
-
|
|
138053
|
-
const pickWorldPos = canvasPos => {
|
|
138054
|
-
const origin = math.vec3();
|
|
138055
|
-
const direction = math.vec3();
|
|
138056
|
-
math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
|
|
138057
|
-
return ray2WorldPos(origin, direction);
|
|
138058
|
-
};
|
|
138059
|
-
|
|
138060
|
-
const onChange = event => {
|
|
138061
|
-
const canvasPos = math.vec2([ event.clientX, event.clientY ]);
|
|
138062
|
-
transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
|
|
138063
|
-
|
|
138064
|
-
const worldPos = pickWorldPos(canvasPos);
|
|
138065
|
-
marker.worldPos = worldPos;
|
|
138066
|
-
updateDotPos();
|
|
138067
|
-
onMove(canvasPos, worldPos);
|
|
138068
|
-
};
|
|
138069
|
-
|
|
138070
|
-
let currentDrag = null;
|
|
138071
|
-
|
|
138072
|
-
const onDragMove = function(event) {
|
|
138073
|
-
const e = currentDrag.matchesEvent(event);
|
|
138074
|
-
if (e)
|
|
138075
|
-
{
|
|
138076
|
-
onChange(e);
|
|
138077
|
-
}
|
|
138078
|
-
};
|
|
138079
|
-
|
|
138080
|
-
const onDragEnd = function(event) {
|
|
138081
|
-
const e = currentDrag.matchesEvent(event);
|
|
138082
|
-
if (e)
|
|
138083
|
-
{
|
|
138084
|
-
dot.setOpacity(idleOpacity);
|
|
138085
|
-
currentDrag.cleanup();
|
|
138086
|
-
onChange(e);
|
|
138087
|
-
onEnd();
|
|
138088
|
-
}
|
|
138089
|
-
};
|
|
138090
|
-
|
|
138091
|
-
const startDrag = function(matchesEvent, cleanupHandlers) {
|
|
138092
|
-
if (currentDrag) {
|
|
138093
|
-
currentDrag.cleanup();
|
|
138094
|
-
}
|
|
138095
|
-
|
|
138096
|
-
dot.setOpacity(1.0);
|
|
138097
|
-
dot.setClickable(false);
|
|
138098
|
-
viewer.cameraControl.active = false;
|
|
138099
|
-
|
|
138100
|
-
currentDrag = {
|
|
138101
|
-
matchesEvent: matchesEvent,
|
|
138102
|
-
cleanup: function() {
|
|
138103
|
-
currentDrag = null;
|
|
138104
|
-
dot.setClickable(true);
|
|
138105
|
-
viewer.cameraControl.active = true;
|
|
138106
|
-
cleanupHandlers();
|
|
138107
|
-
}
|
|
138108
|
-
};
|
|
138109
|
-
|
|
138110
|
-
onStart();
|
|
138111
|
-
};
|
|
138112
|
-
|
|
138113
|
-
const dotCfg = { fillColor: color };
|
|
138114
|
-
|
|
138115
|
-
if (handleMouseEvents)
|
|
138116
|
-
{
|
|
138117
|
-
dotCfg.onMouseOver = () => (! currentDrag) && dot.setOpacity(1.0);
|
|
138118
|
-
dotCfg.onMouseLeave = () => (! currentDrag) && dot.setOpacity(idleOpacity);
|
|
138119
|
-
dotCfg.onMouseDown = event => {
|
|
138120
|
-
if (event.which === 1)
|
|
138121
|
-
{
|
|
138122
|
-
canvas.addEventListener("mousemove", onDragMove);
|
|
138123
|
-
canvas.addEventListener("mouseup", onDragEnd);
|
|
138124
|
-
startDrag(
|
|
138125
|
-
event => (event.which === 1) && event,
|
|
138126
|
-
() => {
|
|
138127
|
-
canvas.removeEventListener("mousemove", onDragMove);
|
|
138128
|
-
canvas.removeEventListener("mouseup", onDragEnd);
|
|
138129
|
-
});
|
|
138130
|
-
}
|
|
138131
|
-
};
|
|
138132
|
-
}
|
|
138133
|
-
|
|
138134
|
-
if (handleTouchEvents)
|
|
138135
|
-
{
|
|
138136
|
-
let touchStartId;
|
|
138137
|
-
dotCfg.onTouchstart = event => {
|
|
138138
|
-
event.preventDefault();
|
|
138139
|
-
if (event.touches.length === 1)
|
|
138140
|
-
{
|
|
138141
|
-
touchStartId = event.touches[0].identifier;
|
|
138142
|
-
startDrag(
|
|
138143
|
-
event => [...event.changedTouches].find(e => e.identifier === touchStartId),
|
|
138144
|
-
() => { touchStartId = null; });
|
|
138145
|
-
}
|
|
138146
|
-
};
|
|
138147
|
-
dotCfg.onTouchmove = event => {
|
|
138148
|
-
event.preventDefault();
|
|
138149
|
-
onDragMove(event);
|
|
138150
|
-
};
|
|
138151
|
-
dotCfg.onTouchend = event => {
|
|
138152
|
-
event.preventDefault();
|
|
138153
|
-
onDragEnd(event);
|
|
138154
|
-
};
|
|
138155
|
-
}
|
|
138156
|
-
|
|
138157
|
-
const dotParent = canvas.ownerDocument.body;
|
|
138158
|
-
const dot = new Dot(dotParent, dotCfg);
|
|
138159
|
-
|
|
138160
|
-
const idleOpacity = 0.5;
|
|
138161
|
-
dot.setOpacity(idleOpacity);
|
|
138162
|
-
|
|
138163
|
-
const updateDotPos = function() {
|
|
138164
|
-
const pos = marker.canvasPos.slice();
|
|
138165
|
-
transformToNode(canvas, dotParent, pos);
|
|
138166
|
-
dot.setPos(pos[0], pos[1]);
|
|
138167
|
-
};
|
|
138168
|
-
|
|
138169
|
-
marker.worldPos = worldPos;
|
|
138170
|
-
updateDotPos();
|
|
138171
|
-
|
|
138172
|
-
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
138173
|
-
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
138174
|
-
|
|
138175
|
-
return {
|
|
138176
|
-
setActive: value => dot.setClickable(value),
|
|
138177
|
-
getWorldPos: () => marker.worldPos,
|
|
138178
|
-
setWorldPos: pos => { marker.worldPos = pos; updateDotPos(); },
|
|
138179
|
-
destroy: function() {
|
|
138180
|
-
currentDrag && currentDrag.cleanup();
|
|
138181
|
-
scene.camera.off(onViewMatrix);
|
|
138182
|
-
scene.camera.off(onProjMatrix);
|
|
138183
|
-
marker.destroy();
|
|
138184
|
-
dot.destroy();
|
|
138185
|
-
}
|
|
138186
|
-
};
|
|
138187
|
-
};
|
|
138188
|
-
|
|
138189
138409
|
const marker3D = function(scene, color) {
|
|
138190
138410
|
const canvas = scene.canvas.canvas;
|
|
138191
138411
|
|
|
@@ -139686,23 +139906,23 @@ class ZoneEditControl extends Component {
|
|
|
139686
139906
|
}
|
|
139687
139907
|
};
|
|
139688
139908
|
|
|
139689
|
-
const dot =
|
|
139690
|
-
handleMouseEvents,
|
|
139691
|
-
handleTouchEvents,
|
|
139692
|
-
zone.plugin.viewer,
|
|
139693
|
-
math.vec3([ planeCoord[0], altitude, planeCoord[1] ]),
|
|
139694
|
-
zone._color,
|
|
139695
|
-
(orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
139696
|
-
() => {
|
|
139909
|
+
const dot = createDraggableDot3D({
|
|
139910
|
+
handleMouseEvents: handleMouseEvents,
|
|
139911
|
+
handleTouchEvents: handleTouchEvents,
|
|
139912
|
+
viewer: zone.plugin.viewer,
|
|
139913
|
+
worldPos: math.vec3([ planeCoord[0], altitude, planeCoord[1] ]),
|
|
139914
|
+
color: zone._color,
|
|
139915
|
+
ray2WorldPos: (orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
139916
|
+
onStart: () => {
|
|
139697
139917
|
initWorldPos = dot.getWorldPos().slice();
|
|
139698
139918
|
initPlaneCoord = planeCoord.slice();
|
|
139699
139919
|
set_other_dots_active(false, dot);
|
|
139700
139920
|
},
|
|
139701
|
-
(canvasPos, worldPos) => {
|
|
139921
|
+
onMove: (canvasPos, worldPos) => {
|
|
139702
139922
|
updatePointerLens(canvasPos);
|
|
139703
139923
|
setPlaneCoord([ worldPos[0], worldPos[2] ]);
|
|
139704
139924
|
},
|
|
139705
|
-
() => {
|
|
139925
|
+
onEnd: () => {
|
|
139706
139926
|
if (zone._zoneMesh)
|
|
139707
139927
|
{
|
|
139708
139928
|
self.fire("edited");
|
|
@@ -139714,7 +139934,8 @@ class ZoneEditControl extends Component {
|
|
|
139714
139934
|
}
|
|
139715
139935
|
updatePointerLens(null);
|
|
139716
139936
|
set_other_dots_active(true, dot);
|
|
139717
|
-
}
|
|
139937
|
+
}
|
|
139938
|
+
});
|
|
139718
139939
|
return dot;
|
|
139719
139940
|
});
|
|
139720
139941
|
const set_other_dots_active = (active, dot) => dots.forEach(d => (d !== dot) && d.setActive(active));
|
|
@@ -139939,6 +140160,8 @@ class ZoneTranslateTouchControl extends ZoneTranslateControl {
|
|
|
139939
140160
|
|
|
139940
140161
|
exports.AlphaFormat = AlphaFormat;
|
|
139941
140162
|
exports.AmbientLight = AmbientLight;
|
|
140163
|
+
exports.AngleMeasurementEditMouseControl = AngleMeasurementEditMouseControl;
|
|
140164
|
+
exports.AngleMeasurementEditTouchControl = AngleMeasurementEditTouchControl;
|
|
139942
140165
|
exports.AngleMeasurementsControl = AngleMeasurementsControl;
|
|
139943
140166
|
exports.AngleMeasurementsMouseControl = AngleMeasurementsMouseControl;
|
|
139944
140167
|
exports.AngleMeasurementsPlugin = AngleMeasurementsPlugin;
|
|
@@ -139963,6 +140186,8 @@ exports.DefaultLoadingManager = DefaultLoadingManager;
|
|
|
139963
140186
|
exports.DepthFormat = DepthFormat;
|
|
139964
140187
|
exports.DepthStencilFormat = DepthStencilFormat;
|
|
139965
140188
|
exports.DirLight = DirLight;
|
|
140189
|
+
exports.DistanceMeasurementEditMouseControl = DistanceMeasurementEditMouseControl;
|
|
140190
|
+
exports.DistanceMeasurementEditTouchControl = DistanceMeasurementEditTouchControl;
|
|
139966
140191
|
exports.DistanceMeasurementsControl = DistanceMeasurementsControl;
|
|
139967
140192
|
exports.DistanceMeasurementsMouseControl = DistanceMeasurementsMouseControl;
|
|
139968
140193
|
exports.DistanceMeasurementsPlugin = DistanceMeasurementsPlugin;
|