@xeokit/xeokit-sdk 2.6.32 → 2.6.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.32",
3
+ "version": "2.6.33",
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",
@@ -65,20 +65,23 @@ export class PointerLens {
65
65
  this._lensCursorDiv.style.pointerEvents = "none";
66
66
 
67
67
  this._lensContainer = document.createElement('div');
68
+ this._lensContainerId = cfg.containerId || 'xeokit-lens';
69
+ this._lensContainer.setAttribute("id", this._lensContainerId);
70
+
68
71
  this._lensContainer.style.border = "1px solid black";
69
72
  this._lensContainer.style.background = "white";
70
73
  // this._lensContainer.style.opacity = "0";
71
74
  this._lensContainer.style.borderRadius = "50%";
72
75
  this._lensContainer.style.width = "300px";
73
76
  this._lensContainer.style.height = "300px";
74
- this._lensContainer.style.marginTop = "85px";
75
- this._lensContainer.style.marginLeft = "25px";
77
+
76
78
  this._lensContainer.style.zIndex = "15000";
77
79
  this._lensContainer.style.position = "absolute";
78
80
  this._lensContainer.style.pointerEvents = "none";
79
81
  this._lensContainer.style.visibility = "hidden";
80
82
 
81
83
  this._lensCanvas = document.createElement('canvas');
84
+ this._lensCanvas.id = `${this._lensContainerId}-canvas`;
82
85
  // this._lensCanvas.style.background = "darkblue";
83
86
  this._lensCanvas.style.borderRadius = "50%";
84
87
 
@@ -95,7 +98,12 @@ export class PointerLens {
95
98
 
96
99
  this._canvasPos = null;
97
100
  this._snappedCanvasPos = null;
98
- this._lensPosToggle = true;
101
+ this._lensPosToggle = cfg.lensPosToggle || true;
102
+ this._lensPosToggleAmount = cfg.lensPosToggleAmount || 85;
103
+ this._lensPosMarginLeft = cfg.lensPosMarginLeft || 85;
104
+ this._lensPosMarginTop = cfg.lensPosMarginTop || 25;
105
+ this._lensContainer.style.marginTop = `${this._lensPosMarginTop}px`;
106
+ this._lensContainer.style.marginLeft = `${this._lensPosMarginLeft}px`;
99
107
 
100
108
  this._zoomLevel = cfg.zoomLevel || 2;
101
109
 
@@ -125,12 +133,12 @@ export class PointerLens {
125
133
  const pointerOnLens =
126
134
  this._canvasPos[0] < lensRect.right && this._canvasPos[0] > lensRect.left &&
127
135
  this._canvasPos[1] < lensRect.bottom && this._canvasPos[1] > lensRect.top;
128
- this._lensContainer.style.marginLeft = `25px`;
136
+ this._lensContainer.style.marginLeft = `${this._lensPosMarginLeft}px`;
129
137
  if (pointerOnLens) {
130
138
  if (this._lensPosToggle) {
131
- this._lensContainer.style.marginTop = `${canvasRect.bottom - canvasRect.top - this._lensCanvas.height - 85}px`;
139
+ this._lensContainer.style.marginTop = `${canvasRect.bottom - canvasRect.top - this._lensCanvas.height - this._lensPosToggleAmount}px`;
132
140
  } else {
133
- this._lensContainer.style.marginTop = `85px`;
141
+ this._lensContainer.style.marginTop = `${this._lensPosMarginTop}px`;
134
142
  }
135
143
  this._lensPosToggle = !this._lensPosToggle;
136
144
  }
@@ -6,6 +6,7 @@ import {Component} from "../../viewer/scene/Component.js";
6
6
 
7
7
 
8
8
  const distVec3 = math.vec3();
9
+ const tmpVec3 = math.vec3();
9
10
 
10
11
  const lengthWire = (x1, y1, x2, y2) => {
11
12
  var a = x1 - x2;
@@ -316,6 +317,44 @@ class DistanceMeasurement extends Component {
316
317
  this.labelsVisible = cfg.labelsVisible;
317
318
  this.labelsOnWires = cfg.labelsOnWires;
318
319
  this.useRotationAdjustment = cfg.useRotationAdjustment;
320
+
321
+ /**
322
+ * @type {number[]}
323
+ */
324
+ this._axesBasis = [
325
+ 1, 0, 0, 0,
326
+ 0, 1, 0, 0,
327
+ 0, 0, 1, 0,
328
+ 0, 0, 0, 1,
329
+ ];
330
+ }
331
+
332
+ /**
333
+ * Sets the axes basis for the measurement.
334
+ *
335
+ * The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
336
+ *
337
+ * This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
338
+ *
339
+ * @param {number[]} value
340
+ */
341
+ set axesBasis(value) {
342
+ this._axesBasis = value.slice();
343
+ this._wpDirty = true;
344
+ this._needUpdate(0); // No lag
345
+ }
346
+
347
+ /**
348
+ * Gets the axes basis for the measurement.
349
+ *
350
+ * The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
351
+ *
352
+ * This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
353
+ *
354
+ * @type {number[]}
355
+ */
356
+ get axesBasis() {
357
+ return this._axesBasis;
319
358
  }
320
359
 
321
360
  _update() {
@@ -351,19 +390,30 @@ class DistanceMeasurement extends Component {
351
390
  this._wp[15] = 1.0;
352
391
  }
353
392
  else {
393
+ const delta = math.subVec3(
394
+ this._targetWorld,
395
+ this._originWorld,
396
+ tmpVec3
397
+ );
398
+
399
+ /**
400
+ * The length detected for each measurement axis.
401
+ */
402
+ this._factors = math.transformVec3(this._axesBasis, delta);
403
+
354
404
  this._wp[0] = this._originWorld[0];
355
405
  this._wp[1] = this._originWorld[1];
356
406
  this._wp[2] = this._originWorld[2];
357
407
  this._wp[3] = 1.0;
358
408
 
359
- this._wp[4] = this._targetWorld[0];
360
- this._wp[5] = this._originWorld[1];
361
- this._wp[6] = this._originWorld[2];
409
+ this._wp[4] = this._originWorld[0] + this._axesBasis[0]*this._factors[0];
410
+ this._wp[5] = this._originWorld[1] + this._axesBasis[4]*this._factors[0];
411
+ this._wp[6] = this._originWorld[2] + this._axesBasis[8]*this._factors[0];
362
412
  this._wp[7] = 1.0;
363
413
 
364
- this._wp[8] = this._targetWorld[0];
365
- this._wp[9] = this._targetWorld[1];
366
- this._wp[10] = this._originWorld[2];
414
+ this._wp[8] = this._originWorld[0] + this._axesBasis[0]*this._factors[0]+ this._axesBasis[1]*this._factors[1];
415
+ this._wp[9] = this._originWorld[1] + this._axesBasis[4]*this._factors[0]+ this._axesBasis[5]*this._factors[1];
416
+ this._wp[10] = this._originWorld[2] + this._axesBasis[8]*this._factors[0]+ this._axesBasis[9]*this._factors[1];;
367
417
  this._wp[11] = 1.0;
368
418
 
369
419
  this._wp[12] = this._targetWorld[0];
@@ -525,14 +575,14 @@ class DistanceMeasurement extends Component {
525
575
  }
526
576
 
527
577
  if (!this._xAxisLabelCulled) {
528
- this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
578
+ this._xAxisLabel.setText(tilde + Math.abs(this._factors[0] * scale).toFixed(2) + unitAbbrev);
529
579
  this._xAxisLabel.setCulled(!this.axisVisible);
530
580
  } else {
531
581
  this._xAxisLabel.setCulled(true);
532
582
  }
533
583
 
534
584
  if (!this._yAxisLabelCulled) {
535
- this._yAxisLabel.setText(tilde + Math.abs((this._targetWorld[1] - this._originWorld[1]) * scale).toFixed(2) + unitAbbrev);
585
+ this._yAxisLabel.setText(tilde + Math.abs(this._factors[1] * scale).toFixed(2) + unitAbbrev);
536
586
  this._yAxisLabel.setCulled(!this.axisVisible);
537
587
  } else {
538
588
  this._yAxisLabel.setCulled(true);
@@ -545,7 +595,7 @@ class DistanceMeasurement extends Component {
545
595
  }
546
596
  else {
547
597
  this._zAxisLabel.setPrefix("Z");
548
- this._zAxisLabel.setText(tilde + Math.abs((this._targetWorld[2] - this._originWorld[2]) * scale).toFixed(2) + unitAbbrev);
598
+ this._zAxisLabel.setText(tilde + Math.abs(this._factors[2] * scale).toFixed(2) + unitAbbrev);
549
599
  }
550
600
  this._zAxisLabel.setCulled(!this.axisVisible);
551
601
  } else {
@@ -91,7 +91,7 @@ export class MeshVolume {
91
91
  volume += math.dotVec3(v1, v3);
92
92
  }
93
93
 
94
- return volume;
94
+ return volume / 6;
95
95
  }
96
96
  }
97
97
 
@@ -244,7 +244,9 @@ class VBOInstancingLinesLayer {
244
244
  this._modelMatrixCol1 = [];
245
245
  this._modelMatrixCol2 = [];
246
246
  }
247
- this._state.geometry = null;
247
+ if (!this.model.scene.readableGeometryEnabled) {
248
+ this._state.geometry = null;
249
+ }
248
250
  this._finalized = true;
249
251
  }
250
252
 
@@ -36,7 +36,7 @@ export class VBOInstancingTrianglesLayer {
36
36
  */
37
37
  constructor(cfg) {
38
38
 
39
- // console.info("Creating VBOInstancingTrianglesLayer");
39
+ // console.info("Creating VBOInstancingTrianglesLayer");
40
40
 
41
41
  /**
42
42
  * Owner model
@@ -378,7 +378,9 @@ export class VBOInstancingTrianglesLayer {
378
378
  && !!textureSet
379
379
  && !!textureSet.colorTexture;
380
380
 
381
- this._state.geometry = null;
381
+ if (!this.model.scene.readableGeometryEnabled) {
382
+ this._state.geometry = null;
383
+ }
382
384
 
383
385
  this._finalized = true;
384
386
  }
@@ -705,11 +707,11 @@ export class VBOInstancingTrianglesLayer {
705
707
  this.model.error("portion not found: " + portionId);
706
708
  return;
707
709
  }
708
- const positions = geometry.quantizedPositions;
710
+ const positions = geometry.positionsCompressed;
709
711
  const origin = state.origin;
710
- const offsetX = origin[0] ;
711
- const offsetY = origin[1] ;
712
- const offsetZ = origin[2] ;
712
+ const offsetX = origin[0];
713
+ const offsetY = origin[1];
714
+ const offsetZ = origin[2];
713
715
  const worldPos = tempVec4a;
714
716
  const portionMatrix = portion.matrix;
715
717
  const sceneModelMatrix = this.model.matrix;
@@ -785,7 +787,7 @@ export class VBOInstancingTrianglesLayer {
785
787
  return;
786
788
  }
787
789
  this._updateBackfaceCull(renderFlags, frameCtx);
788
- const useAlphaCutoff = this._state.textureSet && (typeof(this._state.textureSet.alphaCutoff) === "number");
790
+ const useAlphaCutoff = this._state.textureSet && (typeof (this._state.textureSet.alphaCutoff) === "number");
789
791
  if (frameCtx.withSAO && this.model.saoEnabled) {
790
792
  if (frameCtx.pbrEnabled && this.model.pbrEnabled && this._state.pbrSupported) {
791
793
  if (this._renderers.pbrRendererWithSAO) {
@@ -7,6 +7,8 @@ export declare type ContextMenuConfiguration = {
7
7
  enabled?: boolean;
8
8
  /** Whether this ````ContextMenu```` automatically hides whenever we mouse-down or tap anywhere in the page. */
9
9
  hideOnMouseDown?: boolean;
10
+ /** Whether this ````ContextMenu```` automatically hides whenever we call its action. */
11
+ hideOnAction?: boolean;
10
12
  };
11
13
 
12
14
  /**
@@ -47,6 +47,11 @@ export class PointerLens {
47
47
  constructor(viewer: Viewer, cfg?: {
48
48
  active?: boolean;
49
49
  zoomFactor?: number;
50
+ containerId?: string;
51
+ lensPosToggle?: boolean,
52
+ lensPosToggleAmount?: number,
53
+ lensPosMarginLeft?: number,
54
+ lensPosMarginTop?: number;
50
55
  });
51
56
 
52
57
  /**
@@ -137,6 +142,48 @@ export class PointerLens {
137
142
  */
138
143
  get visible(): boolean;
139
144
 
145
+ /**
146
+ * Sets whether the pointer lens container should toggle position when mouse is over it.
147
+ *
148
+ * @param {boolean} lensPosToggle Whether we should toggle position.
149
+ */
150
+ set lensPosToggle(lensPosToggle: boolean);
151
+
152
+ /**
153
+ * Gets whether we should toggle position.
154
+ *
155
+ * @returns {boolean} Whether we should toggle position.
156
+ */
157
+ get lensPosToggle(): boolean;
158
+
159
+ /**
160
+ * Sets whether we toggle position in vertical or horizontal.
161
+ *
162
+ * @param {boolean} lensPosToggleVertical Vertical or horizontal change.
163
+ */
164
+ set lensPosToggleVertical(lensPosToggleVertical: boolean);
165
+
166
+ /**
167
+ * Gets whether we toggle position in vertical or horizontal.
168
+ *
169
+ * @returns {boolean} Vertical or horizontal change.
170
+ */
171
+ get lensPosToggleVertical(): boolean;
172
+
173
+ /**
174
+ * Sets amount of pixels we toggle position.
175
+ *
176
+ * @param {number} lensPosToggleAmount Amount of pixels we toggle position.
177
+ */
178
+ set lensPosToggleAmount(lensPosToggleAmount: number);
179
+
180
+ /**
181
+ * Gets amount of pixels we toggle position.
182
+ *
183
+ * @returns {number} Amount of pixels we toggle position.
184
+ */
185
+ get lensPosToggleAmount(): number;
186
+
140
187
  /**
141
188
  * Destroys this PointerLens.
142
189
  */
@@ -12,6 +12,24 @@ export declare class DistanceMeasurement extends Component {
12
12
  */
13
13
  plugin: DistanceMeasurementsPlugin;
14
14
 
15
+ /**
16
+ * Sets the axes basis for the measurement.
17
+ *
18
+ * The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
19
+ *
20
+ * This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
21
+ */
22
+ set axesBasis(value: number[]);
23
+
24
+ /**
25
+ * Gets the axes basis for the measurement.
26
+ *
27
+ * The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
28
+ *
29
+ * This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
30
+ */
31
+ get axesBasis(): number[];
32
+
15
33
  /**
16
34
  * Sets whether this DistanceMeasurement indicates that its measurement is approximate.
17
35
  *
@@ -200,6 +200,18 @@ export declare class DistanceMeasurementsPlugin extends Plugin {
200
200
  labelsOnWires?: boolean;
201
201
  }): DistanceMeasurement;
202
202
 
203
+ /**
204
+ * Gets whether the distance measurement axis are visible.
205
+ * @returns {Boolean}
206
+ */
207
+ getAxisVisible(): boolean;
208
+
209
+ /**
210
+ * Sets whether the distance measurement axis are visible.
211
+ * @param {Boolean} axisVisible
212
+ */
213
+ setAxisVisible(axisVisible: boolean): void;
214
+
203
215
  /**
204
216
  * Destroys a {@link DistanceMeasurement}.
205
217
  *
@@ -32,6 +32,10 @@ export declare type LoadLASModel = {
32
32
  src?: string;
33
33
  /** The LAS file data, as an alternative to the ````src```` parameter. */
34
34
  las?: ArrayBuffer;
35
+ /** Create entity with this id */
36
+ entityId?: string;
37
+ /** Creates a MetaModel from json */
38
+ metaModelJSON?: any;
35
39
  /** Whether to load metadata for the LAS model. */
36
40
  loadMetadata?: boolean;
37
41
  /** The model's World-space double-precision 3D origin. Use this to position the model within xeokit's World coordinate system, using double-precision coordinates. */
@@ -13,11 +13,11 @@ export declare type NavCubePluginConfiguration = {
13
13
  /** Whether the shadow of the cube is visible. */
14
14
  shadowVisible?: boolean;
15
15
  /** Whether the {@link Camera} flies or jumps to each selected axis or diagonal. */
16
- cameraFly?: string;
16
+ cameraFly?: boolean;
17
17
  /** How much of the field-of-view, in degrees, that the 3D scene should fill the {@link Canvas} when the {@link Camera} moves to an axis or diagonal. */
18
- cameraFitFOV?: string;
18
+ cameraFitFOV?: number;
19
19
  /** When flying the {@link Camera} to each new axis or diagonal, how long, in seconds, that the Camera takes to get there. */
20
- cameraFlyDuration?: string;
20
+ cameraFlyDuration?: number;
21
21
  /** Custom uniform color for the faces of the NavCube. */
22
22
  color?: string;
23
23
  /** Custom color for the front face of the NavCube. Overrides ````color````. */
@@ -131,18 +131,18 @@ export declare class NavCubePlugin extends Plugin {
131
131
  *
132
132
  * Default is ````0.5````.
133
133
  *
134
- * @param {Boolean} value Camera flight duration in seconds.
134
+ * @param {Number} value Camera flight duration in seconds.
135
135
  */
136
- setCameraFlyDuration(value: boolean): void;
136
+ setCameraFlyDuration(value: number): void;
137
137
 
138
138
  /**
139
139
  * When flying the {@link Camera} to each new axis or diagonal, gets how long, in seconds, that the Camera takes to get there.
140
140
  *
141
141
  * Default is ````0.5````.
142
142
  *
143
- * @returns {Boolean} Camera flight duration in seconds.
143
+ * @returns {Number} Camera flight duration in seconds.
144
144
  */
145
- getCameraFlyDuration(): boolean;
145
+ getCameraFlyDuration(): number;
146
146
 
147
147
  /**
148
148
  * Sets whether the NavCube switches between perspective and orthographic projections in synchrony with
@@ -6,6 +6,8 @@ import { StoreyMap } from "./StoreyMap";
6
6
  export declare type StoreyViewsPluginConfiguration = {
7
7
  /** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */
8
8
  id?: string;
9
+ /** Optional configuration, if enabled, the elements of each floor map image will be proportionally resized to encompass the entire image. This leads to varying scales among different floor map images. If disabled, each floor map image will display the model's extents, ensuring a consistent scale across all images */
10
+ fitStoreyMaps? : Boolean;
9
11
  };
10
12
 
11
13
  /**
@@ -116,6 +118,23 @@ export declare class StoreyViewsPlugin extends Plugin {
116
118
  */
117
119
  getStoreyContainingWorldPos(worldPos: number[]): string;
118
120
 
121
+ /**
122
+ * Gets the ID of the storey which's bounding box contains the y point of the world position
123
+ *
124
+ * @param {Number[]} worldPos 3D World-space position.
125
+ * @returns {String} ID of the storey containing the position, or null if the position falls outside all the storeys.
126
+ */
127
+ getStoreyInVerticalRange(worldPos: number[]): string;
128
+
129
+
130
+ /**
131
+ * Gets the ID of the storey that contains the given 3D World-space position.
132
+ *.
133
+ * @param {Number[]} worldPos 3D World-space position.
134
+ * @returns {String} ID of the storey containing the position, or null if the position falls outside all the storeys.
135
+ */
136
+ isPositionAboveOrBelowBuilding(worldPos: number[]): string;
137
+
119
138
  /**
120
139
  * Converts a 3D World-space position to a 2D position within a StoreyMap image.
121
140
  *
@@ -10,6 +10,7 @@ import { VBOSceneModel } from "../models/VBOSceneModel/VBOSceneModel";
10
10
  import { Mesh } from "../mesh";
11
11
  import { Node } from "../nodes";
12
12
  import { Input } from "../input/input";
13
+ import { SectionPlane } from "../sectionPlane/SectionPlane";
13
14
 
14
15
  export declare type TickEvent = {
15
16
  /** The ID of this Scene. */
@@ -74,6 +75,20 @@ export declare class Scene extends Component {
74
75
  */
75
76
  on(event: "tick", callback: (tickEvent: TickEvent) => void, scope?: any): string;
76
77
 
78
+ /**
79
+ * Fires when a section plane is created.
80
+ * @param {String} event The sectionPlaneCreated event
81
+ * @param {Function} callback Callback fired on the event
82
+ */
83
+ on(event: "sectionPlaneCreated", callback: (measurement: SectionPlane) => void): void;
84
+
85
+ /**
86
+ * Fires when a measurement is destroyed.
87
+ * @param {String} event The sectionPlaneDestroyed event
88
+ * @param {Function} callback Callback fired on the event
89
+ */
90
+ on(event: "sectionPlaneDestroyed", callback: (measurement: SectionPlane) => void): void;
91
+
77
92
  /**
78
93
  * The epoch time (in milliseconds since 1970) when this Scene was instantiated.
79
94
  */
@@ -96,6 +111,14 @@ export declare class Scene extends Component {
96
111
  */
97
112
  get objects(): {[key: string]: Entity};
98
113
 
114
+ /**
115
+ * Map of {@link SectionPlane}s that represent sliced section planes.
116
+ *
117
+ * Each {@link SectionPlane} is mapped here by {@link SectionPlane.id}.
118
+ * @type {{String:SectionPlane}}
119
+ */
120
+ get sectionPlanes(): { [key: string]: SectionPlane };
121
+
99
122
  /**
100
123
  * Map of currently visible {@link Entity}s that represent objects.
101
124
  *