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