@xeokit/xeokit-sdk 2.6.13 → 2.6.16
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 +330 -291
- package/dist/xeokit-sdk.es.js +330 -291
- package/dist/xeokit-sdk.es5.js +117 -109
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +2 -2
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +2 -1
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.js +290 -272
- package/src/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.js +22 -2
- package/src/plugins/LASLoaderPlugin/LASLoaderPlugin.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xeokit/xeokit-sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.16",
|
|
4
4
|
"description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
|
|
5
5
|
"module": "./dist/xeokit-sdk.es.js",
|
|
6
6
|
"main": "./dist/xeokit-sdk.cjs.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"docs": "rm -Rf ./docs/*; ./node_modules/.bin/esdoc",
|
|
12
12
|
"typedocs": "rm -Rf ./docs/*; typedoc --tsconfig tsconfig.json",
|
|
13
13
|
"publish": "npm publish --access public",
|
|
14
|
-
"changelog": "auto-changelog --commit-limit false --package --template changelog-template.hbs"
|
|
14
|
+
"changelog": "git fetch all; auto-changelog --commit-limit false --package --template changelog-template.hbs"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -318,6 +318,7 @@ class DistanceMeasurement extends Component {
|
|
|
318
318
|
this.lengthLabelEnabled = cfg.lengthLabelEnabled;
|
|
319
319
|
this.labelsVisible = cfg.labelsVisible;
|
|
320
320
|
this.labelsOnWires = cfg.labelsOnWires;
|
|
321
|
+
this.useRotationAdjustment = cfg.useRotationAdjustment;
|
|
321
322
|
}
|
|
322
323
|
|
|
323
324
|
_update() {
|
|
@@ -331,7 +332,7 @@ class DistanceMeasurement extends Component {
|
|
|
331
332
|
if (this._wpDirty) {
|
|
332
333
|
|
|
333
334
|
this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 1);
|
|
334
|
-
if(this._measurementOrientation === 'Vertical'){
|
|
335
|
+
if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){
|
|
335
336
|
this._wp[0] = this._originWorld[0];
|
|
336
337
|
this._wp[1] = this._originWorld[1];
|
|
337
338
|
this._wp[2] = this._originWorld[2];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {Plugin} from "../../viewer/Plugin.js";
|
|
2
|
-
import {DistanceMeasurement} from "./DistanceMeasurement.js";
|
|
3
|
-
import {DistanceMeasurementsMouseControl} from "./DistanceMeasurementsMouseControl.js";
|
|
1
|
+
import { Plugin } from "../../viewer/Plugin.js";
|
|
2
|
+
import { DistanceMeasurement } from "./DistanceMeasurement.js";
|
|
3
|
+
import { DistanceMeasurementsMouseControl } from "./DistanceMeasurementsMouseControl.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* {@link Viewer} plugin for measuring point-to-point distances.
|
|
@@ -263,304 +263,322 @@ import {DistanceMeasurementsMouseControl} from "./DistanceMeasurementsMouseContr
|
|
|
263
263
|
* ````
|
|
264
264
|
*/
|
|
265
265
|
class DistanceMeasurementsPlugin extends Plugin {
|
|
266
|
+
/**
|
|
267
|
+
* @constructor
|
|
268
|
+
* @param {Viewer} viewer The Viewer.
|
|
269
|
+
* @param {Object} [cfg] Plugin configuration.
|
|
270
|
+
* @param {String} [cfg.id="DistanceMeasurements"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
271
|
+
* @param {Number} [cfg.labelMinAxisLength=25] The minimum length, in pixels, of an axis wire beyond which its label is shown.
|
|
272
|
+
* @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
|
|
273
|
+
* @param {boolean} [cfg.defaultVisible=true] The default value of the DistanceMeasurements `visible` property.
|
|
274
|
+
* @param {boolean} [cfg.defaultOriginVisible=true] The default value of the DistanceMeasurements `originVisible` property.
|
|
275
|
+
* @param {boolean} [cfg.defaultTargetVisible=true] The default value of the DistanceMeasurements `targetVisible` property.
|
|
276
|
+
* @param {boolean} [cfg.defaultWireVisible=true] The default value of the DistanceMeasurements `wireVisible` property.
|
|
277
|
+
* @param {boolean} [cfg.defaultLabelsVisible=true] The default value of the DistanceMeasurements `labelsVisible` property.
|
|
278
|
+
* @param {boolean} [cfg.defaultXLabelEnabled=true] The default value of the DistanceMeasurements `xLabelEnabled` property.
|
|
279
|
+
* @param {boolean} [cfg.defaultYLabelEnabled=true] The default value of the DistanceMeasurements `yLabelEnabled` property.
|
|
280
|
+
* @param {boolean} [cfg.defaultZLabelEnabled=true] The default value of the DistanceMeasurements `zLabelEnabled` property.
|
|
281
|
+
* @param {boolean} [cfg.defaultLengthLabelEnabled=true] The default value of the DistanceMeasurements `lengthLabelEnabled` property.
|
|
282
|
+
* @param {boolean} [cfg.defaultAxisVisible=true] The default value of the DistanceMeasurements `axisVisible` property.
|
|
283
|
+
* @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
|
|
284
|
+
* @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
|
|
285
|
+
* @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
|
|
286
|
+
* @param {boolean} [cfg.useRotationAdjustment=false] The default value of DistanceMeasurements `useRotationAdjustment` property.
|
|
287
|
+
* @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
|
|
288
|
+
* @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
|
|
289
|
+
* @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
|
|
290
|
+
* @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
|
|
291
|
+
*/
|
|
292
|
+
constructor(viewer, cfg = {}) {
|
|
293
|
+
super("DistanceMeasurements", viewer);
|
|
266
294
|
|
|
267
|
-
|
|
268
|
-
* @constructor
|
|
269
|
-
* @param {Viewer} viewer The Viewer.
|
|
270
|
-
* @param {Object} [cfg] Plugin configuration.
|
|
271
|
-
* @param {String} [cfg.id="DistanceMeasurements"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
272
|
-
* @param {Number} [cfg.labelMinAxisLength=25] The minimum length, in pixels, of an axis wire beyond which its label is shown.
|
|
273
|
-
* @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
|
|
274
|
-
* @param {boolean} [cfg.defaultVisible=true] The default value of the DistanceMeasurements `visible` property.
|
|
275
|
-
* @param {boolean} [cfg.defaultOriginVisible=true] The default value of the DistanceMeasurements `originVisible` property.
|
|
276
|
-
* @param {boolean} [cfg.defaultTargetVisible=true] The default value of the DistanceMeasurements `targetVisible` property.
|
|
277
|
-
* @param {boolean} [cfg.defaultWireVisible=true] The default value of the DistanceMeasurements `wireVisible` property.
|
|
278
|
-
* @param {boolean} [cfg.defaultLabelsVisible=true] The default value of the DistanceMeasurements `labelsVisible` property.
|
|
279
|
-
* @param {boolean} [cfg.defaultXLabelEnabled=true] The default value of the DistanceMeasurements `xLabelEnabled` property.
|
|
280
|
-
* @param {boolean} [cfg.defaultYLabelEnabled=true] The default value of the DistanceMeasurements `yLabelEnabled` property.
|
|
281
|
-
* @param {boolean} [cfg.defaultZLabelEnabled=true] The default value of the DistanceMeasurements `zLabelEnabled` property.
|
|
282
|
-
* @param {boolean} [cfg.defaultLengthLabelEnabled=true] The default value of the DistanceMeasurements `lengthLabelEnabled` property.
|
|
283
|
-
* @param {boolean} [cfg.defaultAxisVisible=true] The default value of the DistanceMeasurements `axisVisible` property.
|
|
284
|
-
* @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
|
|
285
|
-
* @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
|
|
286
|
-
* @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
|
|
287
|
-
* @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
|
|
288
|
-
* @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
|
|
289
|
-
* @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
|
|
290
|
-
* @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
|
|
291
|
-
*/
|
|
292
|
-
constructor(viewer, cfg = {}) {
|
|
295
|
+
this._pointerLens = cfg.pointerLens;
|
|
293
296
|
|
|
294
|
-
|
|
297
|
+
this._container = cfg.container || document.body;
|
|
295
298
|
|
|
296
|
-
|
|
299
|
+
this._defaultControl = null;
|
|
297
300
|
|
|
298
|
-
|
|
301
|
+
this._measurements = {};
|
|
299
302
|
|
|
300
|
-
|
|
303
|
+
this.labelMinAxisLength = cfg.labelMinAxisLength;
|
|
304
|
+
this.defaultVisible = cfg.defaultVisible !== false;
|
|
305
|
+
this.defaultOriginVisible = cfg.defaultOriginVisible !== false;
|
|
306
|
+
this.defaultTargetVisible = cfg.defaultTargetVisible !== false;
|
|
307
|
+
this.defaultWireVisible = cfg.defaultWireVisible !== false;
|
|
308
|
+
this.defaultXLabelEnabled = cfg.defaultXLabelEnabled !== false;
|
|
309
|
+
this.defaultYLabelEnabled = cfg.defaultYLabelEnabled !== false;
|
|
310
|
+
this.defaultZLabelEnabled = cfg.defaultZLabelEnabled !== false;
|
|
311
|
+
this.defaultLengthLabelEnabled = cfg.defaultLengthLabelEnabled !== false;
|
|
312
|
+
this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
|
|
313
|
+
this.defaultAxisVisible = cfg.defaultAxisVisible !== false;
|
|
314
|
+
this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
|
|
315
|
+
this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
|
|
316
|
+
this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
|
|
317
|
+
this.defaultColor =cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
|
|
318
|
+
this.zIndex = cfg.zIndex || 10000;
|
|
319
|
+
this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
|
|
320
|
+
this.useRotationAdjustment = cfg.useRotationAdjustment !== undefined ? cfg.useRotationAdjustment !== false : false;
|
|
301
321
|
|
|
302
|
-
|
|
322
|
+
this._onMouseOver = (event, measurement) => {
|
|
323
|
+
this.fire("mouseOver", {
|
|
324
|
+
plugin: this,
|
|
325
|
+
distanceMeasurement: measurement,
|
|
326
|
+
measurement,
|
|
327
|
+
event,
|
|
328
|
+
});
|
|
329
|
+
};
|
|
303
330
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
this
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.defaultLengthLabelEnabled = cfg.defaultLengthLabelEnabled !== false;
|
|
313
|
-
this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
|
|
314
|
-
this.defaultAxisVisible = cfg.defaultAxisVisible !== false;
|
|
315
|
-
this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
|
|
316
|
-
this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
|
|
317
|
-
this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
|
|
318
|
-
this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
|
|
319
|
-
this.zIndex = cfg.zIndex || 10000;
|
|
320
|
-
this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
|
|
331
|
+
this._onMouseLeave = (event, measurement) => {
|
|
332
|
+
this.fire("mouseLeave", {
|
|
333
|
+
plugin: this,
|
|
334
|
+
distanceMeasurement: measurement,
|
|
335
|
+
measurement,
|
|
336
|
+
event,
|
|
337
|
+
});
|
|
338
|
+
};
|
|
321
339
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
340
|
+
this._onContextMenu = (event, measurement) => {
|
|
341
|
+
this.fire("contextMenu", {
|
|
342
|
+
plugin: this,
|
|
343
|
+
distanceMeasurement: measurement,
|
|
344
|
+
measurement,
|
|
345
|
+
event,
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
}
|
|
330
349
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
};
|
|
350
|
+
/**
|
|
351
|
+
* Gets the plugin's HTML container element, if any.
|
|
352
|
+
* @returns {*|HTMLElement|HTMLElement}
|
|
353
|
+
*/
|
|
354
|
+
getContainerElement() {
|
|
355
|
+
return this._container;
|
|
356
|
+
}
|
|
339
357
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
measurement,
|
|
345
|
-
event
|
|
346
|
-
});
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Gets the plugin's HTML container element, if any.
|
|
352
|
-
* @returns {*|HTMLElement|HTMLElement}
|
|
353
|
-
*/
|
|
354
|
-
getContainerElement() {
|
|
355
|
-
return this._container;
|
|
356
|
-
}
|
|
358
|
+
/**
|
|
359
|
+
* @private
|
|
360
|
+
*/
|
|
361
|
+
send(name, value) {}
|
|
357
362
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
363
|
+
/**
|
|
364
|
+
* Gets the PointerLens attached to this DistanceMeasurementsPlugin.
|
|
365
|
+
* @returns {PointerCircle}
|
|
366
|
+
*/
|
|
367
|
+
get pointerLens() {
|
|
368
|
+
return this._pointerLens;
|
|
369
|
+
}
|
|
364
370
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Gets the default {@link DistanceMeasurementsControl}.
|
|
373
|
+
*
|
|
374
|
+
* @type {DistanceMeasurementsControl}
|
|
375
|
+
* @deprecated
|
|
376
|
+
*/
|
|
377
|
+
get control() {
|
|
378
|
+
if (!this._defaultControl) {
|
|
379
|
+
this._defaultControl = new DistanceMeasurementsMouseControl(this, {});
|
|
371
380
|
}
|
|
381
|
+
return this._defaultControl;
|
|
382
|
+
}
|
|
372
383
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
this._defaultControl = new DistanceMeasurementsMouseControl(this, {});
|
|
382
|
-
}
|
|
383
|
-
return this._defaultControl;
|
|
384
|
-
}
|
|
384
|
+
/**
|
|
385
|
+
* Gets the existing {@link DistanceMeasurement}s, each mapped to its {@link DistanceMeasurement#id}.
|
|
386
|
+
*
|
|
387
|
+
* @type {{String:DistanceMeasurement}}
|
|
388
|
+
*/
|
|
389
|
+
get measurements() {
|
|
390
|
+
return this._measurements;
|
|
391
|
+
}
|
|
385
392
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
+
/**
|
|
394
|
+
* Sets the minimum length, in pixels, of an axis wire beyond which its label is shown.
|
|
395
|
+
*
|
|
396
|
+
* The axis wire's label is not shown when its length is less than this value.
|
|
397
|
+
*
|
|
398
|
+
* This is ````25```` pixels by default.
|
|
399
|
+
*
|
|
400
|
+
* Must not be less than ````1````.
|
|
401
|
+
*
|
|
402
|
+
* @type {number}
|
|
403
|
+
*/
|
|
404
|
+
set labelMinAxisLength(labelMinAxisLength) {
|
|
405
|
+
if (labelMinAxisLength < 1) {
|
|
406
|
+
this.error("labelMinAxisLength must be >= 1; defaulting to 25");
|
|
407
|
+
labelMinAxisLength = 25;
|
|
393
408
|
}
|
|
409
|
+
this._labelMinAxisLength = labelMinAxisLength || 25;
|
|
410
|
+
}
|
|
394
411
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
* Must not be less than ````1````.
|
|
403
|
-
*
|
|
404
|
-
* @type {number}
|
|
405
|
-
*/
|
|
406
|
-
set labelMinAxisLength(labelMinAxisLength) {
|
|
407
|
-
if (labelMinAxisLength < 1) {
|
|
408
|
-
this.error("labelMinAxisLength must be >= 1; defaulting to 25");
|
|
409
|
-
labelMinAxisLength = 25;
|
|
410
|
-
}
|
|
411
|
-
this._labelMinAxisLength = labelMinAxisLength || 25;
|
|
412
|
-
}
|
|
412
|
+
/**
|
|
413
|
+
* Gets the minimum length, in pixels, of an axis wire beyond which its label is shown.
|
|
414
|
+
* @returns {number}
|
|
415
|
+
*/
|
|
416
|
+
get labelMinAxisLength() {
|
|
417
|
+
return this._labelMinAxisLength;
|
|
418
|
+
}
|
|
413
419
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
420
|
+
/**
|
|
421
|
+
* Sets whether the measurement added is rotation adjusted or not.
|
|
422
|
+
*
|
|
423
|
+
* @type {boolean}
|
|
424
|
+
*/
|
|
425
|
+
set useRotationAdjustment(_useRotationAdjustment) {
|
|
426
|
+
_useRotationAdjustment = _useRotationAdjustment !== undefined ? Boolean(_useRotationAdjustment) : false;
|
|
427
|
+
this._useRotationAdjustment = _useRotationAdjustment;
|
|
428
|
+
}
|
|
421
429
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
worldPos: origin.worldPos
|
|
465
|
-
},
|
|
466
|
-
target: {
|
|
467
|
-
entity: target.entity,
|
|
468
|
-
worldPos: target.worldPos
|
|
469
|
-
},
|
|
470
|
-
visible: params.visible,
|
|
471
|
-
wireVisible: params.wireVisible,
|
|
472
|
-
axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
|
|
473
|
-
xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
|
|
474
|
-
yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
|
|
475
|
-
zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
|
|
476
|
-
xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
|
|
477
|
-
yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
|
|
478
|
-
zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
|
|
479
|
-
lengthLabelEnabled: params.lengthLabelEnabled !== false && this.defaultLengthLabelEnabled !== false,
|
|
480
|
-
labelsVisible: params.labelsVisible !== false && this.defaultLabelsVisible !== false,
|
|
481
|
-
originVisible: params.originVisible,
|
|
482
|
-
targetVisible: params.targetVisible,
|
|
483
|
-
color: params.color,
|
|
484
|
-
labelsOnWires: params.labelsOnWires !== false && this.defaultLabelsOnWires !== false,
|
|
485
|
-
onMouseOver: this._onMouseOver,
|
|
486
|
-
onMouseLeave: this._onMouseLeave,
|
|
487
|
-
onContextMenu: this._onContextMenu
|
|
488
|
-
});
|
|
489
|
-
this._measurements[measurement.id] = measurement;
|
|
490
|
-
measurement.clickable = true;
|
|
491
|
-
measurement.on("destroyed", () => {
|
|
492
|
-
delete this._measurements[measurement.id];
|
|
493
|
-
});
|
|
494
|
-
this.fire("measurementCreated", measurement);
|
|
495
|
-
return measurement;
|
|
430
|
+
/**
|
|
431
|
+
* Gets whether the measurement added is rotation adjusted or not.
|
|
432
|
+
* @returns {number}
|
|
433
|
+
*/
|
|
434
|
+
get useRotationAdjustment(){
|
|
435
|
+
return this._useRotationAdjustment;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Creates a {@link DistanceMeasurement}.
|
|
439
|
+
*
|
|
440
|
+
* The DistanceMeasurement is then registered by {@link DistanceMeasurement#id} in {@link DistanceMeasurementsPlugin#measurements}.
|
|
441
|
+
*
|
|
442
|
+
* @param {Object} params {@link DistanceMeasurement} configuration.
|
|
443
|
+
* @param {String} params.id Unique ID to assign to {@link DistanceMeasurement#id}. The DistanceMeasurement will be registered by this in {@link DistanceMeasurementsPlugin#measurements} and {@link Scene.components}. Must be unique among all components in the {@link Viewer}.
|
|
444
|
+
* @param {Number[]} params.origin.worldPos Origin World-space 3D position.
|
|
445
|
+
* @param {Entity} params.origin.entity Origin Entity.
|
|
446
|
+
* @param {Number[]} params.target.worldPos Target World-space 3D position.
|
|
447
|
+
* @param {Entity} params.target.entity Target Entity.
|
|
448
|
+
* @param {Boolean} [params.visible=true] Whether to initially show the {@link DistanceMeasurement}.
|
|
449
|
+
* @param {Boolean} [params.originVisible=true] Whether to initially show the {@link DistanceMeasurement} origin.
|
|
450
|
+
* @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
|
|
451
|
+
* @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
|
|
452
|
+
* @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
|
|
453
|
+
* @param {Boolean} [params.xAxisVisible=true] Whether to initially show the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
|
|
454
|
+
* @param {Boolean} [params.yAxisVisible=true] Whether to initially show the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
|
|
455
|
+
* @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
|
|
456
|
+
* @param {Boolean} [params.xLabelEnabled=true] Whether to initially show the x label.
|
|
457
|
+
* @param {Boolean} [params.yLabelEnabled=true] Whether to initially show the y label.
|
|
458
|
+
* @param {Boolean} [params.zLabelEnabled=true] Whether to initially show the z label.
|
|
459
|
+
* @param {Boolean} [params.lengthLabelEnabled=true] Whether to initially show the length label.
|
|
460
|
+
* @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
|
|
461
|
+
* @param {Boolean} [params.lengthLabelVisible=true] Whether to initially show the labels.
|
|
462
|
+
* @param {string} [params.color] The color of the length dot, wire and label.
|
|
463
|
+
* @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
|
|
464
|
+
* @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
|
|
465
|
+
*/
|
|
466
|
+
createMeasurement(params = {}) {
|
|
467
|
+
if (this.viewer.scene.components[params.id]) {
|
|
468
|
+
this.error(
|
|
469
|
+
"Viewer scene component with this ID already exists: " + params.id
|
|
470
|
+
);
|
|
471
|
+
delete params.id;
|
|
496
472
|
}
|
|
473
|
+
const origin = params.origin;
|
|
474
|
+
const target = params.target;
|
|
475
|
+
const measurement = new DistanceMeasurement(this, {
|
|
476
|
+
id: params.id,
|
|
477
|
+
plugin: this,
|
|
478
|
+
container: this._container,
|
|
479
|
+
origin: {
|
|
480
|
+
entity: origin.entity,
|
|
481
|
+
worldPos: origin.worldPos,
|
|
482
|
+
},
|
|
483
|
+
target: {
|
|
484
|
+
entity: target.entity,
|
|
485
|
+
worldPos: target.worldPos,
|
|
486
|
+
},
|
|
487
|
+
visible: params.visible,
|
|
488
|
+
wireVisible: params.wireVisible,
|
|
489
|
+
axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
|
|
490
|
+
xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
|
|
491
|
+
yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
|
|
492
|
+
zAxisVisibld: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
|
|
493
|
+
xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
|
|
494
|
+
yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
|
|
495
|
+
zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
|
|
496
|
+
lengthLabelEnabled: params.lengthLabelEnabled !== false && this.defaultLengthLabelEnabled !== false,
|
|
497
|
+
labelsVisible: params.labelsVisible !== false && this.defaultLabelsVisible !== false,
|
|
498
|
+
useRotationAdjustment: this.useRotationAdjustment,
|
|
499
|
+
originVisible: params.originVisible,
|
|
500
|
+
targetVisible: params.targetVisible,
|
|
501
|
+
color: params.color,
|
|
502
|
+
labelsOnWires:params.labelsOnWires !== false && this.defaultLabelsOnWires !== false,
|
|
503
|
+
onMouseOver: this._onMouseOver,
|
|
504
|
+
onMouseLeave: this._onMouseLeave,
|
|
505
|
+
onContextMenu: this._onContextMenu,
|
|
506
|
+
});
|
|
507
|
+
this._measurements[measurement.id] = measurement;
|
|
508
|
+
measurement.clickable = true;
|
|
509
|
+
measurement.on("destroyed", () => {
|
|
510
|
+
delete this._measurements[measurement.id];
|
|
511
|
+
});
|
|
512
|
+
this.fire("measurementCreated", measurement);
|
|
513
|
+
return measurement;
|
|
514
|
+
}
|
|
497
515
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
509
|
-
measurement.destroy();
|
|
510
|
-
this.fire("measurementDestroyed", measurement);
|
|
516
|
+
/**
|
|
517
|
+
* Destroys a {@link DistanceMeasurement}.
|
|
518
|
+
*
|
|
519
|
+
* @param {String} id ID of DistanceMeasurement to destroy.
|
|
520
|
+
*/
|
|
521
|
+
destroyMeasurement(id) {
|
|
522
|
+
const measurement = this._measurements[id];
|
|
523
|
+
if (!measurement) {
|
|
524
|
+
this.log("DistanceMeasurement not found: " + id);
|
|
525
|
+
return;
|
|
511
526
|
}
|
|
527
|
+
measurement.destroy();
|
|
528
|
+
this.fire("measurementDestroyed", measurement);
|
|
529
|
+
}
|
|
512
530
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
531
|
+
/**
|
|
532
|
+
* Shows all or hides the distance label of each {@link DistanceMeasurement}.
|
|
533
|
+
*
|
|
534
|
+
* @param {Boolean} labelsShown Whether or not to show the labels.
|
|
535
|
+
*/
|
|
536
|
+
setLabelsShown(labelsShown) {
|
|
537
|
+
for (const [key, measurement] of Object.entries(this.measurements)) {
|
|
538
|
+
measurement.labelShown = labelsShown;
|
|
522
539
|
}
|
|
540
|
+
}
|
|
523
541
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
533
|
-
this.defaultAxisVisible = axisVisible;
|
|
542
|
+
/**
|
|
543
|
+
* Shows all or hides the axis wires of each {@link DistanceMeasurement}.
|
|
544
|
+
*
|
|
545
|
+
* @param {Boolean} labelsShown Whether or not to show the axis wires.
|
|
546
|
+
*/
|
|
547
|
+
setAxisVisible(axisVisible) {
|
|
548
|
+
for (const [key, measurement] of Object.entries(this.measurements)) {
|
|
549
|
+
measurement.axisVisible = axisVisible;
|
|
534
550
|
}
|
|
551
|
+
this.defaultAxisVisible = axisVisible;
|
|
552
|
+
}
|
|
535
553
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
554
|
+
/**
|
|
555
|
+
* Gets if the axis wires of each {@link DistanceMeasurement} are visible.
|
|
556
|
+
*
|
|
557
|
+
* @returns {Boolean} Whether or not the axis wires are visible.
|
|
558
|
+
*/
|
|
559
|
+
getAxisVisible() {
|
|
560
|
+
return this.defaultAxisVisible;
|
|
561
|
+
}
|
|
544
562
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
563
|
+
/**
|
|
564
|
+
* Destroys all {@link DistanceMeasurement}s.
|
|
565
|
+
*/
|
|
566
|
+
clear() {
|
|
567
|
+
const ids = Object.keys(this._measurements);
|
|
568
|
+
for (var i = 0, len = ids.length; i < len; i++) {
|
|
569
|
+
this.destroyMeasurement(ids[i]);
|
|
553
570
|
}
|
|
571
|
+
}
|
|
554
572
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
573
|
+
/**
|
|
574
|
+
* Destroys this DistanceMeasurementsPlugin.
|
|
575
|
+
*
|
|
576
|
+
* Destroys all {@link DistanceMeasurement}s first.
|
|
577
|
+
*/
|
|
578
|
+
destroy() {
|
|
579
|
+
this.clear();
|
|
580
|
+
super.destroy();
|
|
581
|
+
}
|
|
564
582
|
}
|
|
565
583
|
|
|
566
|
-
export {DistanceMeasurementsPlugin}
|
|
584
|
+
export { DistanceMeasurementsPlugin };
|