@xeokit/xeokit-sdk 2.6.14 → 2.6.17

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.
@@ -10639,6 +10639,9 @@ class Marker extends Component {
10639
10639
  return;
10640
10640
  }
10641
10641
  this._occludable = occludable;
10642
+ if (this._occludable) {
10643
+ this._renderer.markerWorldPosUpdated(this);
10644
+ }
10642
10645
  }
10643
10646
 
10644
10647
  /**
@@ -17212,7 +17215,6 @@ class OcclusionTester {
17212
17215
  markerWorldPosUpdated(marker) {
17213
17216
  const occlusionLayer = this._markersToOcclusionLayersMap[marker.id];
17214
17217
  if (!occlusionLayer) {
17215
- marker.error("Marker has not been added to OcclusionTester");
17216
17218
  return;
17217
17219
  }
17218
17220
  const originHash = marker.origin.join();
@@ -86586,6 +86588,7 @@ class DistanceMeasurement extends Component {
86586
86588
  this.lengthLabelEnabled = cfg.lengthLabelEnabled;
86587
86589
  this.labelsVisible = cfg.labelsVisible;
86588
86590
  this.labelsOnWires = cfg.labelsOnWires;
86591
+ this.useRotationAdjustment = cfg.useRotationAdjustment;
86589
86592
  }
86590
86593
 
86591
86594
  _update() {
@@ -86599,7 +86602,7 @@ class DistanceMeasurement extends Component {
86599
86602
  if (this._wpDirty) {
86600
86603
 
86601
86604
  this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 1);
86602
- if(this._measurementOrientation === 'Vertical'){
86605
+ if(this._measurementOrientation === 'Vertical' && this.useRotationAdjustment){
86603
86606
  this._wp[0] = this._originWorld[0];
86604
86607
  this._wp[1] = this._originWorld[1];
86605
86608
  this._wp[2] = this._originWorld[2];
@@ -88179,304 +88182,322 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
88179
88182
  * ````
88180
88183
  */
88181
88184
  class DistanceMeasurementsPlugin extends Plugin {
88185
+ /**
88186
+ * @constructor
88187
+ * @param {Viewer} viewer The Viewer.
88188
+ * @param {Object} [cfg] Plugin configuration.
88189
+ * @param {String} [cfg.id="DistanceMeasurements"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
88190
+ * @param {Number} [cfg.labelMinAxisLength=25] The minimum length, in pixels, of an axis wire beyond which its label is shown.
88191
+ * @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
88192
+ * @param {boolean} [cfg.defaultVisible=true] The default value of the DistanceMeasurements `visible` property.
88193
+ * @param {boolean} [cfg.defaultOriginVisible=true] The default value of the DistanceMeasurements `originVisible` property.
88194
+ * @param {boolean} [cfg.defaultTargetVisible=true] The default value of the DistanceMeasurements `targetVisible` property.
88195
+ * @param {boolean} [cfg.defaultWireVisible=true] The default value of the DistanceMeasurements `wireVisible` property.
88196
+ * @param {boolean} [cfg.defaultLabelsVisible=true] The default value of the DistanceMeasurements `labelsVisible` property.
88197
+ * @param {boolean} [cfg.defaultXLabelEnabled=true] The default value of the DistanceMeasurements `xLabelEnabled` property.
88198
+ * @param {boolean} [cfg.defaultYLabelEnabled=true] The default value of the DistanceMeasurements `yLabelEnabled` property.
88199
+ * @param {boolean} [cfg.defaultZLabelEnabled=true] The default value of the DistanceMeasurements `zLabelEnabled` property.
88200
+ * @param {boolean} [cfg.defaultLengthLabelEnabled=true] The default value of the DistanceMeasurements `lengthLabelEnabled` property.
88201
+ * @param {boolean} [cfg.defaultAxisVisible=true] The default value of the DistanceMeasurements `axisVisible` property.
88202
+ * @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
88203
+ * @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
88204
+ * @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
88205
+ * @param {boolean} [cfg.useRotationAdjustment=false] The default value of DistanceMeasurements `useRotationAdjustment` property.
88206
+ * @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
88207
+ * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
88208
+ * @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
88209
+ * @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
88210
+ */
88211
+ constructor(viewer, cfg = {}) {
88212
+ super("DistanceMeasurements", viewer);
88213
+
88214
+ this._pointerLens = cfg.pointerLens;
88215
+
88216
+ this._container = cfg.container || document.body;
88217
+
88218
+ this._defaultControl = null;
88219
+
88220
+ this._measurements = {};
88221
+
88222
+ this.labelMinAxisLength = cfg.labelMinAxisLength;
88223
+ this.defaultVisible = cfg.defaultVisible !== false;
88224
+ this.defaultOriginVisible = cfg.defaultOriginVisible !== false;
88225
+ this.defaultTargetVisible = cfg.defaultTargetVisible !== false;
88226
+ this.defaultWireVisible = cfg.defaultWireVisible !== false;
88227
+ this.defaultXLabelEnabled = cfg.defaultXLabelEnabled !== false;
88228
+ this.defaultYLabelEnabled = cfg.defaultYLabelEnabled !== false;
88229
+ this.defaultZLabelEnabled = cfg.defaultZLabelEnabled !== false;
88230
+ this.defaultLengthLabelEnabled = cfg.defaultLengthLabelEnabled !== false;
88231
+ this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
88232
+ this.defaultAxisVisible = cfg.defaultAxisVisible !== false;
88233
+ this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
88234
+ this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
88235
+ this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
88236
+ this.defaultColor =cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
88237
+ this.zIndex = cfg.zIndex || 10000;
88238
+ this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
88239
+ this.useRotationAdjustment = cfg.useRotationAdjustment !== undefined ? cfg.useRotationAdjustment !== false : false;
88240
+
88241
+ this._onMouseOver = (event, measurement) => {
88242
+ this.fire("mouseOver", {
88243
+ plugin: this,
88244
+ distanceMeasurement: measurement,
88245
+ measurement,
88246
+ event,
88247
+ });
88248
+ };
88182
88249
 
88183
- /**
88184
- * @constructor
88185
- * @param {Viewer} viewer The Viewer.
88186
- * @param {Object} [cfg] Plugin configuration.
88187
- * @param {String} [cfg.id="DistanceMeasurements"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
88188
- * @param {Number} [cfg.labelMinAxisLength=25] The minimum length, in pixels, of an axis wire beyond which its label is shown.
88189
- * @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
88190
- * @param {boolean} [cfg.defaultVisible=true] The default value of the DistanceMeasurements `visible` property.
88191
- * @param {boolean} [cfg.defaultOriginVisible=true] The default value of the DistanceMeasurements `originVisible` property.
88192
- * @param {boolean} [cfg.defaultTargetVisible=true] The default value of the DistanceMeasurements `targetVisible` property.
88193
- * @param {boolean} [cfg.defaultWireVisible=true] The default value of the DistanceMeasurements `wireVisible` property.
88194
- * @param {boolean} [cfg.defaultLabelsVisible=true] The default value of the DistanceMeasurements `labelsVisible` property.
88195
- * @param {boolean} [cfg.defaultXLabelEnabled=true] The default value of the DistanceMeasurements `xLabelEnabled` property.
88196
- * @param {boolean} [cfg.defaultYLabelEnabled=true] The default value of the DistanceMeasurements `yLabelEnabled` property.
88197
- * @param {boolean} [cfg.defaultZLabelEnabled=true] The default value of the DistanceMeasurements `zLabelEnabled` property.
88198
- * @param {boolean} [cfg.defaultLengthLabelEnabled=true] The default value of the DistanceMeasurements `lengthLabelEnabled` property.
88199
- * @param {boolean} [cfg.defaultAxisVisible=true] The default value of the DistanceMeasurements `axisVisible` property.
88200
- * @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
88201
- * @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
88202
- * @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
88203
- * @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
88204
- * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
88205
- * @param {boolean} [cfg.defaultLabelsOnWires=true] The default value of the DistanceMeasurements `labelsOnWires` property.
88206
- * @param {PointerCircle} [cfg.pointerLens] A PointerLens to help the user position the pointer. This can be shared with other plugins.
88207
- */
88208
- constructor(viewer, cfg = {}) {
88209
-
88210
- super("DistanceMeasurements", viewer);
88211
-
88212
- this._pointerLens = cfg.pointerLens;
88213
-
88214
- this._container = cfg.container || document.body;
88215
-
88216
- this._defaultControl = null;
88217
-
88218
- this._measurements = {};
88219
-
88220
- this.labelMinAxisLength = cfg.labelMinAxisLength;
88221
- this.defaultVisible = cfg.defaultVisible !== false;
88222
- this.defaultOriginVisible = cfg.defaultOriginVisible !== false;
88223
- this.defaultTargetVisible = cfg.defaultTargetVisible !== false;
88224
- this.defaultWireVisible = cfg.defaultWireVisible !== false;
88225
- this.defaultXLabelEnabled = cfg.defaultXLabelEnabled !== false;
88226
- this.defaultYLabelEnabled = cfg.defaultYLabelEnabled !== false;
88227
- this.defaultZLabelEnabled = cfg.defaultZLabelEnabled !== false;
88228
- this.defaultLengthLabelEnabled = cfg.defaultLengthLabelEnabled !== false;
88229
- this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
88230
- this.defaultAxisVisible = cfg.defaultAxisVisible !== false;
88231
- this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
88232
- this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
88233
- this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
88234
- this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
88235
- this.zIndex = cfg.zIndex || 10000;
88236
- this.defaultLabelsOnWires = cfg.defaultLabelsOnWires !== false;
88237
-
88238
- this._onMouseOver = (event, measurement) => {
88239
- this.fire("mouseOver", {
88240
- plugin: this,
88241
- distanceMeasurement: measurement,
88242
- measurement,
88243
- event
88244
- });
88245
- };
88246
-
88247
- this._onMouseLeave = (event, measurement) => {
88248
- this.fire("mouseLeave", {
88249
- plugin: this,
88250
- distanceMeasurement: measurement,
88251
- measurement,
88252
- event
88253
- });
88254
- };
88255
-
88256
- this._onContextMenu = (event, measurement) => {
88257
- this.fire("contextMenu", {
88258
- plugin: this,
88259
- distanceMeasurement: measurement,
88260
- measurement,
88261
- event
88262
- });
88263
- };
88264
- }
88265
-
88266
- /**
88267
- * Gets the plugin's HTML container element, if any.
88268
- * @returns {*|HTMLElement|HTMLElement}
88269
- */
88270
- getContainerElement() {
88271
- return this._container;
88272
- }
88273
-
88274
- /**
88275
- * @private
88276
- */
88277
- send(name, value) {
88278
-
88279
- }
88280
-
88281
- /**
88282
- * Gets the PointerLens attached to this DistanceMeasurementsPlugin.
88283
- * @returns {PointerCircle}
88284
- */
88285
- get pointerLens() {
88286
- return this._pointerLens;
88287
- }
88288
-
88289
- /**
88290
- * Gets the default {@link DistanceMeasurementsControl}.
88291
- *
88292
- * @type {DistanceMeasurementsControl}
88293
- * @deprecated
88294
- */
88295
- get control() {
88296
- if (!this._defaultControl) {
88297
- this._defaultControl = new DistanceMeasurementsMouseControl(this, {});
88298
- }
88299
- return this._defaultControl;
88300
- }
88301
-
88302
- /**
88303
- * Gets the existing {@link DistanceMeasurement}s, each mapped to its {@link DistanceMeasurement#id}.
88304
- *
88305
- * @type {{String:DistanceMeasurement}}
88306
- */
88307
- get measurements() {
88308
- return this._measurements;
88309
- }
88310
-
88311
- /**
88312
- * Sets the minimum length, in pixels, of an axis wire beyond which its label is shown.
88313
- *
88314
- * The axis wire's label is not shown when its length is less than this value.
88315
- *
88316
- * This is ````25```` pixels by default.
88317
- *
88318
- * Must not be less than ````1````.
88319
- *
88320
- * @type {number}
88321
- */
88322
- set labelMinAxisLength(labelMinAxisLength) {
88323
- if (labelMinAxisLength < 1) {
88324
- this.error("labelMinAxisLength must be >= 1; defaulting to 25");
88325
- labelMinAxisLength = 25;
88326
- }
88327
- this._labelMinAxisLength = labelMinAxisLength || 25;
88328
- }
88329
-
88330
- /**
88331
- * Gets the minimum length, in pixels, of an axis wire beyond which its label is shown.
88332
- * @returns {number}
88333
- */
88334
- get labelMinAxisLength() {
88335
- return this._labelMinAxisLength;
88336
- }
88250
+ this._onMouseLeave = (event, measurement) => {
88251
+ this.fire("mouseLeave", {
88252
+ plugin: this,
88253
+ distanceMeasurement: measurement,
88254
+ measurement,
88255
+ event,
88256
+ });
88257
+ };
88337
88258
 
88338
- /**
88339
- * Creates a {@link DistanceMeasurement}.
88340
- *
88341
- * The DistanceMeasurement is then registered by {@link DistanceMeasurement#id} in {@link DistanceMeasurementsPlugin#measurements}.
88342
- *
88343
- * @param {Object} params {@link DistanceMeasurement} configuration.
88344
- * @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}.
88345
- * @param {Number[]} params.origin.worldPos Origin World-space 3D position.
88346
- * @param {Entity} params.origin.entity Origin Entity.
88347
- * @param {Number[]} params.target.worldPos Target World-space 3D position.
88348
- * @param {Entity} params.target.entity Target Entity.
88349
- * @param {Boolean} [params.visible=true] Whether to initially show the {@link DistanceMeasurement}.
88350
- * @param {Boolean} [params.originVisible=true] Whether to initially show the {@link DistanceMeasurement} origin.
88351
- * @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
88352
- * @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88353
- * @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88354
- * @param {Boolean} [params.xAxisVisible=true] Whether to initially show the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88355
- * @param {Boolean} [params.yAxisVisible=true] Whether to initially show the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88356
- * @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88357
- * @param {Boolean} [params.xLabelEnabled=true] Whether to initially show the x label.
88358
- * @param {Boolean} [params.yLabelEnabled=true] Whether to initially show the y label.
88359
- * @param {Boolean} [params.zLabelEnabled=true] Whether to initially show the z label.
88360
- * @param {Boolean} [params.lengthLabelEnabled=true] Whether to initially show the length label.
88361
- * @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
88362
- * @param {Boolean} [params.lengthLabelVisible=true] Whether to initially show the labels.
88363
- * @param {string} [params.color] The color of the length dot, wire and label.
88364
- * @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
88365
- * @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
88366
- */
88367
- createMeasurement(params = {}) {
88368
- if (this.viewer.scene.components[params.id]) {
88369
- this.error("Viewer scene component with this ID already exists: " + params.id);
88370
- delete params.id;
88371
- }
88372
- const origin = params.origin;
88373
- const target = params.target;
88374
- const measurement = new DistanceMeasurement(this, {
88375
- id: params.id,
88376
- plugin: this,
88377
- container: this._container,
88378
- origin: {
88379
- entity: origin.entity,
88380
- worldPos: origin.worldPos
88381
- },
88382
- target: {
88383
- entity: target.entity,
88384
- worldPos: target.worldPos
88385
- },
88386
- visible: params.visible,
88387
- wireVisible: params.wireVisible,
88388
- axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
88389
- xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
88390
- yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
88391
- zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
88392
- xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
88393
- yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
88394
- zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
88395
- lengthLabelEnabled: params.lengthLabelEnabled !== false && this.defaultLengthLabelEnabled !== false,
88396
- labelsVisible: params.labelsVisible !== false && this.defaultLabelsVisible !== false,
88397
- originVisible: params.originVisible,
88398
- targetVisible: params.targetVisible,
88399
- color: params.color,
88400
- labelsOnWires: params.labelsOnWires !== false && this.defaultLabelsOnWires !== false,
88401
- onMouseOver: this._onMouseOver,
88402
- onMouseLeave: this._onMouseLeave,
88403
- onContextMenu: this._onContextMenu
88404
- });
88405
- this._measurements[measurement.id] = measurement;
88406
- measurement.clickable = true;
88407
- measurement.on("destroyed", () => {
88408
- delete this._measurements[measurement.id];
88409
- });
88410
- this.fire("measurementCreated", measurement);
88411
- return measurement;
88412
- }
88259
+ this._onContextMenu = (event, measurement) => {
88260
+ this.fire("contextMenu", {
88261
+ plugin: this,
88262
+ distanceMeasurement: measurement,
88263
+ measurement,
88264
+ event,
88265
+ });
88266
+ };
88267
+ }
88413
88268
 
88414
- /**
88415
- * Destroys a {@link DistanceMeasurement}.
88416
- *
88417
- * @param {String} id ID of DistanceMeasurement to destroy.
88418
- */
88419
- destroyMeasurement(id) {
88420
- const measurement = this._measurements[id];
88421
- if (!measurement) {
88422
- this.log("DistanceMeasurement not found: " + id);
88423
- return;
88424
- }
88425
- measurement.destroy();
88426
- this.fire("measurementDestroyed", measurement);
88269
+ /**
88270
+ * Gets the plugin's HTML container element, if any.
88271
+ * @returns {*|HTMLElement|HTMLElement}
88272
+ */
88273
+ getContainerElement() {
88274
+ return this._container;
88275
+ }
88276
+
88277
+ /**
88278
+ * @private
88279
+ */
88280
+ send(name, value) {}
88281
+
88282
+ /**
88283
+ * Gets the PointerLens attached to this DistanceMeasurementsPlugin.
88284
+ * @returns {PointerCircle}
88285
+ */
88286
+ get pointerLens() {
88287
+ return this._pointerLens;
88288
+ }
88289
+
88290
+ /**
88291
+ * Gets the default {@link DistanceMeasurementsControl}.
88292
+ *
88293
+ * @type {DistanceMeasurementsControl}
88294
+ * @deprecated
88295
+ */
88296
+ get control() {
88297
+ if (!this._defaultControl) {
88298
+ this._defaultControl = new DistanceMeasurementsMouseControl(this, {});
88299
+ }
88300
+ return this._defaultControl;
88301
+ }
88302
+
88303
+ /**
88304
+ * Gets the existing {@link DistanceMeasurement}s, each mapped to its {@link DistanceMeasurement#id}.
88305
+ *
88306
+ * @type {{String:DistanceMeasurement}}
88307
+ */
88308
+ get measurements() {
88309
+ return this._measurements;
88310
+ }
88311
+
88312
+ /**
88313
+ * Sets the minimum length, in pixels, of an axis wire beyond which its label is shown.
88314
+ *
88315
+ * The axis wire's label is not shown when its length is less than this value.
88316
+ *
88317
+ * This is ````25```` pixels by default.
88318
+ *
88319
+ * Must not be less than ````1````.
88320
+ *
88321
+ * @type {number}
88322
+ */
88323
+ set labelMinAxisLength(labelMinAxisLength) {
88324
+ if (labelMinAxisLength < 1) {
88325
+ this.error("labelMinAxisLength must be >= 1; defaulting to 25");
88326
+ labelMinAxisLength = 25;
88327
+ }
88328
+ this._labelMinAxisLength = labelMinAxisLength || 25;
88329
+ }
88330
+
88331
+ /**
88332
+ * Gets the minimum length, in pixels, of an axis wire beyond which its label is shown.
88333
+ * @returns {number}
88334
+ */
88335
+ get labelMinAxisLength() {
88336
+ return this._labelMinAxisLength;
88337
+ }
88338
+
88339
+ /**
88340
+ * Sets whether the measurement added is rotation adjusted or not.
88341
+ *
88342
+ * @type {boolean}
88343
+ */
88344
+ set useRotationAdjustment(_useRotationAdjustment) {
88345
+ _useRotationAdjustment = _useRotationAdjustment !== undefined ? Boolean(_useRotationAdjustment) : false;
88346
+ this._useRotationAdjustment = _useRotationAdjustment;
88347
+ }
88348
+
88349
+ /**
88350
+ * Gets whether the measurement added is rotation adjusted or not.
88351
+ * @returns {number}
88352
+ */
88353
+ get useRotationAdjustment(){
88354
+ return this._useRotationAdjustment;
88355
+ }
88356
+ /**
88357
+ * Creates a {@link DistanceMeasurement}.
88358
+ *
88359
+ * The DistanceMeasurement is then registered by {@link DistanceMeasurement#id} in {@link DistanceMeasurementsPlugin#measurements}.
88360
+ *
88361
+ * @param {Object} params {@link DistanceMeasurement} configuration.
88362
+ * @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}.
88363
+ * @param {Number[]} params.origin.worldPos Origin World-space 3D position.
88364
+ * @param {Entity} params.origin.entity Origin Entity.
88365
+ * @param {Number[]} params.target.worldPos Target World-space 3D position.
88366
+ * @param {Entity} params.target.entity Target Entity.
88367
+ * @param {Boolean} [params.visible=true] Whether to initially show the {@link DistanceMeasurement}.
88368
+ * @param {Boolean} [params.originVisible=true] Whether to initially show the {@link DistanceMeasurement} origin.
88369
+ * @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
88370
+ * @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88371
+ * @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88372
+ * @param {Boolean} [params.xAxisVisible=true] Whether to initially show the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88373
+ * @param {Boolean} [params.yAxisVisible=true] Whether to initially show the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88374
+ * @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88375
+ * @param {Boolean} [params.xLabelEnabled=true] Whether to initially show the x label.
88376
+ * @param {Boolean} [params.yLabelEnabled=true] Whether to initially show the y label.
88377
+ * @param {Boolean} [params.zLabelEnabled=true] Whether to initially show the z label.
88378
+ * @param {Boolean} [params.lengthLabelEnabled=true] Whether to initially show the length label.
88379
+ * @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
88380
+ * @param {Boolean} [params.lengthLabelVisible=true] Whether to initially show the labels.
88381
+ * @param {string} [params.color] The color of the length dot, wire and label.
88382
+ * @param {Boolean} [params.labelsOnWires=true] Determines if labels will be set on wires or one below the other.
88383
+ * @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
88384
+ */
88385
+ createMeasurement(params = {}) {
88386
+ if (this.viewer.scene.components[params.id]) {
88387
+ this.error(
88388
+ "Viewer scene component with this ID already exists: " + params.id
88389
+ );
88390
+ delete params.id;
88391
+ }
88392
+ const origin = params.origin;
88393
+ const target = params.target;
88394
+ const measurement = new DistanceMeasurement(this, {
88395
+ id: params.id,
88396
+ plugin: this,
88397
+ container: this._container,
88398
+ origin: {
88399
+ entity: origin.entity,
88400
+ worldPos: origin.worldPos,
88401
+ },
88402
+ target: {
88403
+ entity: target.entity,
88404
+ worldPos: target.worldPos,
88405
+ },
88406
+ visible: params.visible,
88407
+ wireVisible: params.wireVisible,
88408
+ axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
88409
+ xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
88410
+ yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
88411
+ zAxisVisibld: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
88412
+ xLabelEnabled: params.xLabelEnabled !== false && this.defaultXLabelEnabled !== false,
88413
+ yLabelEnabled: params.yLabelEnabled !== false && this.defaultYLabelEnabled !== false,
88414
+ zLabelEnabled: params.zLabelEnabled !== false && this.defaultZLabelEnabled !== false,
88415
+ lengthLabelEnabled: params.lengthLabelEnabled !== false && this.defaultLengthLabelEnabled !== false,
88416
+ labelsVisible: params.labelsVisible !== false && this.defaultLabelsVisible !== false,
88417
+ useRotationAdjustment: this.useRotationAdjustment,
88418
+ originVisible: params.originVisible,
88419
+ targetVisible: params.targetVisible,
88420
+ color: params.color,
88421
+ labelsOnWires:params.labelsOnWires !== false && this.defaultLabelsOnWires !== false,
88422
+ onMouseOver: this._onMouseOver,
88423
+ onMouseLeave: this._onMouseLeave,
88424
+ onContextMenu: this._onContextMenu,
88425
+ });
88426
+ this._measurements[measurement.id] = measurement;
88427
+ measurement.clickable = true;
88428
+ measurement.on("destroyed", () => {
88429
+ delete this._measurements[measurement.id];
88430
+ });
88431
+ this.fire("measurementCreated", measurement);
88432
+ return measurement;
88433
+ }
88434
+
88435
+ /**
88436
+ * Destroys a {@link DistanceMeasurement}.
88437
+ *
88438
+ * @param {String} id ID of DistanceMeasurement to destroy.
88439
+ */
88440
+ destroyMeasurement(id) {
88441
+ const measurement = this._measurements[id];
88442
+ if (!measurement) {
88443
+ this.log("DistanceMeasurement not found: " + id);
88444
+ return;
88427
88445
  }
88446
+ measurement.destroy();
88447
+ this.fire("measurementDestroyed", measurement);
88448
+ }
88428
88449
 
88429
- /**
88430
- * Shows all or hides the distance label of each {@link DistanceMeasurement}.
88431
- *
88432
- * @param {Boolean} labelsShown Whether or not to show the labels.
88433
- */
88434
- setLabelsShown(labelsShown) {
88435
- for (const [key, measurement] of Object.entries(this.measurements)) {
88436
- measurement.labelShown = labelsShown;
88437
- }
88450
+ /**
88451
+ * Shows all or hides the distance label of each {@link DistanceMeasurement}.
88452
+ *
88453
+ * @param {Boolean} labelsShown Whether or not to show the labels.
88454
+ */
88455
+ setLabelsShown(labelsShown) {
88456
+ for (const [key, measurement] of Object.entries(this.measurements)) {
88457
+ measurement.labelShown = labelsShown;
88438
88458
  }
88459
+ }
88439
88460
 
88440
- /**
88441
- * Shows all or hides the axis wires of each {@link DistanceMeasurement}.
88442
- *
88443
- * @param {Boolean} labelsShown Whether or not to show the axis wires.
88444
- */
88445
- setAxisVisible(axisVisible) {
88446
- for (const [key, measurement] of Object.entries(this.measurements)) {
88447
- measurement.axisVisible = axisVisible;
88448
- }
88449
- this.defaultAxisVisible = axisVisible;
88461
+ /**
88462
+ * Shows all or hides the axis wires of each {@link DistanceMeasurement}.
88463
+ *
88464
+ * @param {Boolean} labelsShown Whether or not to show the axis wires.
88465
+ */
88466
+ setAxisVisible(axisVisible) {
88467
+ for (const [key, measurement] of Object.entries(this.measurements)) {
88468
+ measurement.axisVisible = axisVisible;
88450
88469
  }
88470
+ this.defaultAxisVisible = axisVisible;
88471
+ }
88451
88472
 
88452
- /**
88453
- * Gets if the axis wires of each {@link DistanceMeasurement} are visible.
88454
- *
88455
- * @returns {Boolean} Whether or not the axis wires are visible.
88456
- */
88457
- getAxisVisible() {
88458
- return this.defaultAxisVisible;
88459
- }
88473
+ /**
88474
+ * Gets if the axis wires of each {@link DistanceMeasurement} are visible.
88475
+ *
88476
+ * @returns {Boolean} Whether or not the axis wires are visible.
88477
+ */
88478
+ getAxisVisible() {
88479
+ return this.defaultAxisVisible;
88480
+ }
88460
88481
 
88461
- /**
88462
- * Destroys all {@link DistanceMeasurement}s.
88463
- */
88464
- clear() {
88465
- const ids = Object.keys(this._measurements);
88466
- for (var i = 0, len = ids.length; i < len; i++) {
88467
- this.destroyMeasurement(ids[i]);
88468
- }
88482
+ /**
88483
+ * Destroys all {@link DistanceMeasurement}s.
88484
+ */
88485
+ clear() {
88486
+ const ids = Object.keys(this._measurements);
88487
+ for (var i = 0, len = ids.length; i < len; i++) {
88488
+ this.destroyMeasurement(ids[i]);
88469
88489
  }
88490
+ }
88470
88491
 
88471
- /**
88472
- * Destroys this DistanceMeasurementsPlugin.
88473
- *
88474
- * Destroys all {@link DistanceMeasurement}s first.
88475
- */
88476
- destroy() {
88477
- this.clear();
88478
- super.destroy();
88479
- }
88492
+ /**
88493
+ * Destroys this DistanceMeasurementsPlugin.
88494
+ *
88495
+ * Destroys all {@link DistanceMeasurement}s first.
88496
+ */
88497
+ destroy() {
88498
+ this.clear();
88499
+ super.destroy();
88500
+ }
88480
88501
  }
88481
88502
 
88482
88503
  const WAITING_FOR_ORIGIN_TOUCH_START = 0;
@@ -135463,7 +135484,7 @@ class LASLoaderPlugin extends Plugin {
135463
135484
  }
135464
135485
 
135465
135486
  function readIntensities(attributesIntensity) {
135466
- const intensities = attributesIntensity.intensity;
135487
+ const intensities = attributesIntensity.value;
135467
135488
  const colorsCompressedSize = intensities.length * 4;
135468
135489
  const colorsCompressed = new Uint8Array(colorsCompressedSize);
135469
135490
  for (let i = 0, j = 0, len = intensities.length; i < len; i++, j += 4) {
@@ -135648,7 +135669,7 @@ class LASLoaderPlugin extends Plugin {
135648
135669
 
135649
135670
  function chunkArray(array, chunkSize) {
135650
135671
  if (chunkSize >= array.length) {
135651
- return array;
135672
+ return [array];
135652
135673
  }
135653
135674
  let result = [];
135654
135675
  for (let i = 0; i < array.length; i += chunkSize) {