@xeokit/xeokit-sdk 2.6.106 → 2.6.108

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.106",
3
+ "version": "2.6.108",
4
4
  "description": "3D BIM IFC Viewer SDK for AEC engineering applications. Open Source JavaScript Toolkit based on pure WebGL for top performance, real-world coordinates and full double precision",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -312,10 +312,25 @@ export class Label3D {
312
312
  this.__visible = true;
313
313
 
314
314
  this._updatePos = () => {
315
- toClipSpace(camera, this._start, tmpVec4a);
316
- math.mulVec4Scalar(tmpVec4a, 1.0 / tmpVec4a[3]);
317
- toCanvasSpace(scene.canvas.canvas, parentElement, tmpVec4a, tmpVec2a);
318
- this._label.setPos(tmpVec2a[0], tmpVec2a[1]);
315
+ const p0 = tmpVec4a;
316
+ toClipSpace(camera, this._start, p0);
317
+ math.mulVec3Scalar(p0, 1.0 / p0[3]);
318
+
319
+ const outsideFrustum = ((p0[3] < 0)
320
+ ||
321
+ (p0[0] < -1) || (p0[0] > 1)
322
+ ||
323
+ (p0[1] < -1) || (p0[1] > 1)
324
+ ||
325
+ (p0[2] < -1) || (p0[2] > 1));
326
+ const culled = outsideFrustum || scene._sectionPlanesState.sectionPlanes.some(
327
+ plane => plane.active && (math.dotVec3(plane.dir, math.subVec3(plane.pos, this._start, tmpVec3a)) > 0));
328
+
329
+ this._label.setCulled(culled);
330
+ if (! culled) {
331
+ toCanvasSpace(scene.canvas.canvas, parentElement, p0, tmpVec2a);
332
+ this._label.setPos(tmpVec2a[0], tmpVec2a[1]);
333
+ }
319
334
  };
320
335
 
321
336
  const setPosOnWire = (p0, p1, yOff) => {
@@ -491,6 +491,7 @@ class Viewer {
491
491
  const plugin = plugins[i];
492
492
  plugin.destroy();
493
493
  }
494
+ this.metaScene._destroy();
494
495
  this.scene.destroy();
495
496
  }
496
497
  }
@@ -149,6 +149,20 @@ class MetaScene {
149
149
  return metaModel;
150
150
  }
151
151
 
152
+ /**
153
+ * Destroys this MetaScene.
154
+ */
155
+ _destroy() {
156
+ this.viewer = null;
157
+ this.scene = null;
158
+ this.metaModels = {};
159
+ this.propertySets = {};
160
+ this.metaObjects = {};
161
+ this.metaObjectsByType = {};
162
+ this.rootMetaObjects = {};
163
+ this._eventSubs = {};
164
+ }
165
+
152
166
  /**
153
167
  * Removes a {@link MetaModel} from this MetaScene.
154
168
  *
@@ -3341,11 +3341,13 @@ export class SceneModel extends Component {
3341
3341
  if (testNumVisibleLayerPortions && (this.numVisibleLayerPortions === 0)) {
3342
3342
  return;
3343
3343
  }
3344
+ const activeSectionPlanes = this.scene._sectionPlanesState.sectionPlanes.filter(p => p.active);
3344
3345
  const testLayerCull = frameCtx.testAABB;
3345
3346
  const renderFlags = this.renderFlags;
3346
3347
  for (let i = 0, len = renderFlags.visibleLayers.length; i < len; i++) {
3347
3348
  const layer = this.layerList[renderFlags.visibleLayers[i]];
3348
- if ((! testLayerCull) || testLayerCull(layer.getAABB())) {
3349
+ const aabb = layer.getAABB();
3350
+ if (((! testLayerCull) || testLayerCull(aabb)) && activeSectionPlanes.every(p => math.planeAABB3Intersect(p.dir, p.dist, aabb) >= 0)) {
3349
3351
  cb(layer);
3350
3352
  }
3351
3353
  }
@@ -1,4 +1,5 @@
1
1
  export * from "./ContextMenu";
2
+ export * from "./PointerCircle";
2
3
  export * from "./PointerLens";
3
4
  export * from "./MarqueePicker";
4
5
  export * from "./collision"
@@ -117,34 +117,39 @@ export declare class AnnotationsPlugin extends Plugin {
117
117
  * Fires when a annotation is created.
118
118
  * @param {String} event The annotationCreated event
119
119
  * @param {Function} callback Callback fired on the event
120
+ * @returns {String} Subscription id
120
121
  */
121
- on(event: "annotationCreated", callback: (annotationId: string)=> void): void;
122
+ on(event: "annotationCreated", callback: (annotationId: string)=> void): string;
122
123
 
123
124
  /**
124
125
  * Fires when a annotation is destroyed.
125
126
  * @param {String} event The annotationDestroyed event
126
127
  * @param {Function} callback Callback fired on the event
128
+ * @returns {String} Subscription id
127
129
  */
128
- on(event: "annotationDestroyed", callback: (annotationId: string)=> void): void;
130
+ on(event: "annotationDestroyed", callback: (annotationId: string)=> void): string;
129
131
 
130
132
  /**
131
133
  * Fires when a mouse enters a annotation.
132
134
  * @param {String} event The markerMouseEnter event
133
135
  * @param {Function} callback Callback fired on the event
136
+ * @returns {String} Subscription id
134
137
  */
135
- on(event: "markerMouseEnter", callback: (annotation: Annotation)=> void): void;
138
+ on(event: "markerMouseEnter", callback: (annotation: Annotation)=> void): string;
136
139
 
137
140
  /**
138
141
  * Fires when a mouse leave an annotation.
139
142
  * @param {String} event The markerMouseLeave event
140
143
  * @param {Function} callback Callback fired on the event
144
+ * @returns {String} Subscription id
141
145
  */
142
- on(event: "markerMouseLeave", callback: (annotation: Annotation)=> void): void;
146
+ on(event: "markerMouseLeave", callback: (annotation: Annotation)=> void): string;
143
147
 
144
148
  /**
145
149
  * Fires when a mouse leave an annotation.
146
150
  * @param {String} event The markerClicked event
147
151
  * @param {Function} callback Callback fired on the event
152
+ * @returns {String} Subscription id
148
153
  */
149
- on(event: "markerClicked", callback: (annotation: Annotation)=> void): void;
154
+ on(event: "markerClicked", callback: (annotation: Annotation)=> void): string;
150
155
  }
@@ -1,5 +1,6 @@
1
1
  import { Viewer } from "../../../viewer";
2
2
  import { PointerCircle } from "../../../extras/PointerCircle";
3
+ import { CameraControl } from "../../../viewer/scene/CameraControl/CameraControl";
3
4
 
4
5
  type Vec2 = number[]
5
6
  type Vec3 = number[]
@@ -12,4 +13,8 @@ type OnChange<T> = (canvasPos: Vec2, worldPos: T | null) => void;
12
13
  type OnCommit<T> = (canvasPos: Vec2, worldPos: T | null) => void;
13
14
 
14
15
 
15
- declare function touchPointSelector<T>(viewer: Viewer, pointerCircle: PointerCircle, ray2WorldPos: Ray2WorldPos<T>): (onCancel: OnCancel, onChange: OnChange<T>, onCommit: OnCommit<T>) => Cleanup;
16
+ declare function touchPointSelector<T>(viewer: Viewer, pointerCircle: PointerCircle, ray2WorldPos: Ray2WorldPos<T>): (onCancel: OnCancel, onChange: OnChange<T>, onCommit: OnCommit<T>) => Cleanup;
17
+
18
+ export declare addMousePressListener(element: HTMLElement, onChange: (canvasPos: Vec2 | null) => void);
19
+
20
+ export declare addTouchPressListener(element: HTMLElement, cameraControl: CameraControl, pointerCircle: PointerCircle, onChange: (canvasPos: Vec2 | null) => void);
@@ -31,8 +31,15 @@ export declare abstract class Plugin {
31
31
  * Subscribes to an event fired at this Plugin.
32
32
  * @param {String} event The event
33
33
  * @param {Function} callback Callback fired on the event
34
+ * @returns {String} Subscription id
34
35
  */
35
- on(event: string, callback: ()=> void): void;
36
+ on(event: string, callback: ()=> void): string;
37
+
38
+ /**
39
+ * Removes event subscription.
40
+ * @param {String} subId Subscription id
41
+ */
42
+ off(subId: string): void;
36
43
 
37
44
  /**
38
45
  * Fires an event at this Plugin.
@@ -14,6 +14,15 @@ export declare abstract class Entity {
14
14
  */
15
15
  get id(): string | number;
16
16
 
17
+ /**
18
+ * The SceneModel of the SceneModelEntity
19
+ *
20
+ * SceneModelEntity is the only Entity class at the moment, so every Entity is SceneModelEntity.
21
+ */
22
+ model: {
23
+ id?: string
24
+ }
25
+
17
26
  /**
18
27
  * ID of the corresponding object within the originating system, if any.
19
28
  *
@@ -399,6 +408,16 @@ export declare abstract class Entity {
399
408
  */
400
409
  getGeometryData(): {indices: number[],positions:number[]}
401
410
 
411
+ /**
412
+ * Gets volume of the entity.
413
+ */
414
+ get volume(): number;
415
+
416
+ /**
417
+ * Gets surface area of the entity.
418
+ */
419
+ get surfaceArea(): number;
420
+
402
421
  /**
403
422
  * Destroys this Entity.
404
423
  */
@@ -153,7 +153,7 @@ export declare class Input extends Component {
153
153
  * @param callback Called fired on the event
154
154
  * @param scope Scope for the callback
155
155
  */
156
- on(event: "mousedown" | "mouseup" | "mouseclicked" | "dblclick", callback: (canvasCoords: number[]) => void, scope?: any): string;
156
+ on(event: "mousedown" | "mouseup" | "mouseclicked" | "dblclick" | "mousemove", callback: (canvasCoords: number[]) => void, scope?: any): string;
157
157
 
158
158
  /**
159
159
  * Fires on keyboard events
@@ -50,12 +50,37 @@ declare const math: {
50
50
  /**
51
51
  * Normalizes a three-element vector
52
52
  */
53
- normalizeVec3: (v: number[], dest?: any) => number[];
53
+ normalizeVec3: (v: number[], dest?: any) => number[];
54
54
 
55
- /**
56
- * Multiplies each element of a three-element vector by a scalar.
57
- */
58
- mulVec3Scalar: (v: number[], scalar: number, dest?: number[]) => number[];
55
+ /**
56
+ * Adds one three-element vector to another.
57
+ */
58
+ addVec3: (u: number[], v: number[], dest?: number[]) => number[];
59
+
60
+ /**
61
+ * Adds one three-element vector to another.
62
+ */
63
+ subVec3: (u: number[], v: number[], dest?: number[]) => number[];
64
+
65
+ /**
66
+ * Multiplies each element of a three-element vector by a scalar.
67
+ */
68
+ mulVec3Scalar: (v: number[], scalar: number, dest?: number[]) => number[];
69
+
70
+ /**
71
+ * Returns the cross product of two three-element vectors.
72
+ */
73
+ cross3Vec3: (u: number[], v: number[], dest?: number[]) => number[];
74
+
75
+ /**
76
+ * Multiplies the given 4x4 matrix by the given four-element vector.
77
+ */
78
+ mulMat4v4: (m: number[], v: number[], dest?: number[]) => number[];
79
+
80
+ /**
81
+ * Builds normal vectors from positions and indices.
82
+ */
83
+ buildNormals: (positions: number[], indices: number[], normals?: number) => number[];
59
84
  };
60
85
 
61
86
  export {math};
@@ -89,6 +89,8 @@ export declare class Scene extends Component {
89
89
  */
90
90
  on(event: "sectionPlaneDestroyed", callback: (measurement: SectionPlane) => void): void;
91
91
 
92
+ canvas: Component;
93
+
92
94
  /**
93
95
  * The epoch time (in milliseconds since 1970) when this Scene was instantiated.
94
96
  */
@@ -715,6 +717,9 @@ export declare class Scene extends Component {
715
717
  * @param {Number[]} [params.origin] World-space ray origin when ray-picking. Ignored when canvasPos given.
716
718
  * @param {Number[]} [params.direction] World-space ray direction when ray-picking. Also indicates the length of the ray. Ignored when canvasPos given.
717
719
  * @param {Number[]} [params.matrix] 4x4 transformation matrix to define the World-space ray origin and direction, as an alternative to ````origin```` and ````direction````.
720
+ * @param {Number} [params.snapRadius=30] The snap radius, in canvas pixels.
721
+ * @param {boolean} [params.snapToEdge=true] Whether to snap to edge. Only works when `canvasPos` given.
722
+ * @param {boolean} [params.snapToVertex=true] Whether to snap to vertex. Only works when `canvasPos` given.
718
723
  * @param {String[]} [params.includeEntities] IDs of {@link Entity}s to restrict picking to. When given, ignores {@link Entity}s whose IDs are not in this list.
719
724
  * @param {String[]} [params.excludeEntities] IDs of {@link Entity}s to ignore. When given, will pick *through* these {@link Entity}s, as if they were not there.
720
725
  * @param {PickResult} [pickResult] Holds the results of the pick attempt. Will use the Scene's singleton PickResult if you don't supply your own.
@@ -728,6 +733,9 @@ export declare class Scene extends Component {
728
733
  origin?: number[];
729
734
  direction?: number[];
730
735
  matrix?: number[];
736
+ snapRadius?: number;
737
+ snapToEdge?: boolean;
738
+ snapToVertex?: boolean;
731
739
  includeEntities?: string[];
732
740
  excludeEntities?: string[];
733
741
  }, pickResult?: PickResult): PickResult | null;