@xeokit/xeokit-sdk 2.6.63 → 2.6.65

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.
Files changed (27) hide show
  1. package/dist/xeokit-sdk.cjs.js +592 -1237
  2. package/dist/xeokit-sdk.es.js +592 -1237
  3. package/dist/xeokit-sdk.es5.js +155 -197
  4. package/dist/xeokit-sdk.min.cjs.js +5 -5
  5. package/dist/xeokit-sdk.min.es.js +5 -5
  6. package/dist/xeokit-sdk.min.es5.js +4 -4
  7. package/package.json +1 -1
  8. package/src/extras/PointerLens/PointerLens.js +27 -46
  9. package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.js +29 -20
  10. package/src/plugins/AnnotationsPlugin/Annotation.js +3 -0
  11. package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +27 -33
  12. package/src/plugins/SectionPlanesPlugin/Control.js +462 -1142
  13. package/src/plugins/TreeViewPlugin/TreeViewPlugin.js +10 -4
  14. package/src/plugins/lib/html/MenuEvent.js +3 -1
  15. package/src/viewer/scene/model/dtx/triangles/DTXTrianglesLayer.js +1 -2
  16. package/src/viewer/scene/model/vbo/instancing/lines/VBOInstancingLinesLayer.js +1 -1
  17. package/types/plugins/AngleMeasurementsPlugin/index.d.ts +2 -1
  18. package/types/plugins/CityJSONLoaderPlugin/CityJSONLoaderPlugin.d.ts +4 -0
  19. package/types/plugins/DotBIMLoaderPlugin/DotBIMLoaderPlugin.d.ts +121 -0
  20. package/types/plugins/DotBIMLoaderPlugin/index.d.ts +1 -0
  21. package/types/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.d.ts +4 -0
  22. package/types/plugins/LASLoaderPlugin/LASLoaderPlugin.d.ts +4 -0
  23. package/types/plugins/STLLoaderPlugin/STLLoaderPlugin.d.ts +4 -0
  24. package/types/plugins/TreeViewPlugin/TreeViewPlugin.d.ts +4 -0
  25. package/types/plugins/WebIFCLoaderPlugin/WebIFCLoaderPlugin.d.ts +4 -0
  26. package/types/plugins/XKTLoaderPlugin/XKTLoaderPlugin.d.ts +19 -1
  27. package/types/plugins/index.d.ts +1 -0
@@ -1,5 +1,5 @@
1
- import {Plugin} from "../../viewer/Plugin.js";
2
- import {RenderService} from "./RenderService.js";
1
+ import { Plugin } from "../../viewer/Plugin.js";
2
+ import { RenderService } from "./RenderService.js";
3
3
 
4
4
  const treeViews = [];
5
5
 
@@ -363,6 +363,8 @@ export class TreeViewPlugin extends Plugin {
363
363
  * @param {RenderService} [cfg.renderService] Optional {@link RenderService} to use. Defaults to the {@link TreeViewPlugin}'s default {@link RenderService}.
364
364
  * @param {Boolean} [cfg.showIndeterminate=false] When true, will show indeterminate state for checkboxes when some but not all child nodes are checked
365
365
  * @param {Boolean} [cfg.showProjectNode=false] When true, will show top level project node when hierarchy is set to "storeys"
366
+ * @param {Function} [cfg.elevationSortFunction] Optional function to replace the default elevation sort function. The function should take two nodes and return -1, 0 or 1.
367
+ * @param {Function} [cfg.defaultSortFunction] Optional function to replace the default sort function. The function should take two nodes and return -1, 0 or 1.
366
368
  */
367
369
  constructor(viewer, cfg = {}) {
368
370
 
@@ -416,6 +418,8 @@ export class TreeViewPlugin extends Plugin {
416
418
  this._renderService = cfg.renderService || new RenderService();
417
419
  this._showIndeterminate = cfg.showIndeterminate ?? false;
418
420
  this._showProjectNode = cfg.showProjectNode ?? false;
421
+ this._elevationSortFunction = cfg.elevationSortFunction ?? undefined;
422
+ this._defaultSortFunction = cfg.defaultSortFunction ?? undefined;
419
423
 
420
424
  if (!this._renderService) {
421
425
  throw new Error('TreeViewPlugin: no render service set');
@@ -1229,9 +1233,11 @@ export class TreeViewPlugin extends Plugin {
1229
1233
  }
1230
1234
  const firstChild = children[0];
1231
1235
  if ((this._hierarchy === "storeys" || this._hierarchy === "containment") && firstChild.type === "IfcBuildingStorey") {
1232
- children.sort(this._getSpatialSortFunc());
1236
+ if (this._elevationSortFunction) children.sort(this._elevationSortFunction);
1237
+ else children.sort(this._getSpatialSortFunc());
1233
1238
  } else {
1234
- children.sort(this._alphaSortFunc);
1239
+ if (this._defaultSortFunction) children.sort(this._defaultSortFunction)
1240
+ else children.sort(this._alphaSortFunc);
1235
1241
  }
1236
1242
  for (let i = 0, len = children.length; i < len; i++) {
1237
1243
  const node = children[i];
@@ -1,6 +1,7 @@
1
1
  import { os } from "../../../viewer/utils/os.js";
2
2
 
3
- export function addContextMenuListener(elem, callback) {
3
+ //failCallback will be called when the press is not long enough to considered a long press
4
+ export function addContextMenuListener(elem, callback, failCallback = () => {}) {
4
5
  if (!elem || !callback) return;
5
6
 
6
7
  let timeout = null;
@@ -54,6 +55,7 @@ export function addContextMenuListener(elem, callback) {
54
55
  const touchEndHandler = (event) => {
55
56
  event.preventDefault();
56
57
  if (timeout) {
58
+ failCallback(event);
57
59
  clearTimeout(timeout);
58
60
  timeout = null;
59
61
  }
@@ -1122,8 +1122,7 @@ export class DTXTrianglesLayer {
1122
1122
  worldPos[2] = positions[i + 2];
1123
1123
  worldPos[3] = 1.0;
1124
1124
  math.decompressPosition(worldPos, positionsDecodeMatrix);
1125
- math.transformPoint4(this.model.worldMatrix, worldPos, worldPos);
1126
- math.transformPoint4(this.model.worldMatrix, worldPos, worldPos);
1125
+ math.mulMat4v4(this.model.worldMatrix, worldPos, worldPos);
1127
1126
  worldPos[0] += offsetX;
1128
1127
  worldPos[1] += offsetY;
1129
1128
  worldPos[2] += offsetZ;
@@ -497,7 +497,7 @@ class VBOInstancingLinesLayer {
497
497
 
498
498
  let pickFlag = (visible && !culled && pickable) ? RENDER_PASSES.PICK : RENDER_PASSES.NOT_RENDERED;
499
499
 
500
- const clippableFlag = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 255 : 0;
500
+ const clippableFlag = !!(flags & ENTITY_FLAGS.CLIPPABLE) ? 1 : 0;
501
501
 
502
502
  let vertFlag = 0;
503
503
  vertFlag |= colorFlag;
@@ -1,3 +1,4 @@
1
1
  export * from "./AngleMeasurementsPlugin";
2
2
  export * from "./AngleMeasurementsControl";
3
- export * from "./AngleMeasurementsMouseControl";
3
+ export * from "./AngleMeasurementsMouseControl";
4
+ export * from "./AngleMeasurementsTouchControl";
@@ -10,6 +10,10 @@ export declare interface ICityJSONDefaultDataSource {
10
10
  * @param {Function} error Callback fired on error.
11
11
  */
12
12
  getCityJSON(src: string | number, ok: (json: any)=> void, error: (e: Error)=> void): void;
13
+
14
+ get cacheBuster(): boolean;
15
+
16
+ set cacheBuster(value: boolean);
13
17
  }
14
18
 
15
19
  export declare type CityJSONLoaderPluginConfiguration = {
@@ -0,0 +1,121 @@
1
+ import {IFCObjectDefaults, Plugin, VBOSceneModel, Viewer} from "../../viewer";
2
+
3
+ export declare interface IDotBIMDefaultDataSource {
4
+ /**
5
+ * Gets the contents of the given ````.xkt```` file in an arraybuffer.
6
+ *
7
+ * @param {String|Number} dotBIMSrc Path or ID of an ````.bim```` file.
8
+ * @param {Function} ok Callback fired on success, argument is the ````.xkt```` file in an arraybuffer.
9
+ * @param {Function} error Callback fired on error.
10
+ */
11
+ getDotBIM(dotBIMSrc: string | number, ok: (buffer: ArrayBuffer) => void, error: (e: Error) => void): void;
12
+
13
+ get cacheBuster(): boolean;
14
+
15
+ set cacheBuster(value: boolean);
16
+ }
17
+
18
+ export declare type DotBIMLoaderPluginConfiguration = {
19
+ /** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */
20
+ id?: string;
21
+ /** Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}.*/
22
+ objectDefaults?: IFCObjectDefaults;
23
+ /** A custom data source through which the XKTLoaderPlugin can load model and metadata files. Defaults to an instance of {@link DotBIMDefaultDataSource}, which loads uover HTTP. */
24
+ dataSource?: IDotBIMDefaultDataSource;
25
+ };
26
+
27
+
28
+ /**
29
+ * @param {Number[]} [params.rotation=[0,0,0]] The model's orientation, as Euler angles given in degrees, for each of the X, Y and Z axis.
30
+ * @param {Boolean} [params.backfaces=true] When true, always show backfaces, even on objects for which the .BIM material is single-sided. When false, only show backfaces on geometries whenever the .BIM material is double-sided.
31
+ * @param {Boolean} [params.dtxEnabled=true] When ````true```` (default) use data textures (DTX), where appropriate, to
32
+ * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
33
+ * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
34
+ * primitives. Only works while {@link DTX#enabled} is also ````true````.
35
+ */
36
+ export declare type LoadDotBIMModel = {
37
+ /** ID to assign to the root {@link Entity#id}, unique among all components in the Viewer's {@link Scene}, generated automatically by default. */
38
+ id?: string;
39
+ /** Path to a .BIM file, as an alternative to the ````bim```` parameter. */
40
+ src?: string;
41
+ /** .BIM JSON, as an alternative to the ````src```` parameter. */
42
+ bim?: any;
43
+ /** Map of initial default states for each loaded {@link Entity} that represents an object. Default value is {@link IFCObjectDefaults}. */
44
+ objectDefaults?: object;
45
+ /** When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject.type} values in this list. */
46
+ includeTypes?: string[]
47
+ /** When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject.type} values in this list. */
48
+ excludeTypes?: string[];
49
+ /** The double-precision World-space origin of the model's coordinates. */
50
+ origin?: number[];
51
+ /** The single-precision position, relative to ````origin````. */
52
+ position?: number[];
53
+ /** The model's scale. */
54
+ scale?: number[];
55
+ /** The model's orientation, given as Euler angles in degrees, for each of the X, Y and Z axis. */
56
+ rotation?: number[];
57
+ /** When true, always show backfaces, even on objects for which the .BIM material is single-sided. When false, only show backfaces on geometries whenever the .BIM material is double-sided. */
58
+ backfaces?: boolean;
59
+ /** When ````true```` (default) use data textures (DTX), where appropriate, to
60
+ * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
61
+ * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
62
+ * primitives. Only works while {@link DTX#enabled} is also ````true````. */
63
+ dtxEnabled?: boolean;
64
+ };
65
+
66
+ export declare class DotBIMLoaderPlugin extends Plugin {
67
+ /**
68
+ * @constructor
69
+ *
70
+ * @param {Viewer} viewer The Viewer.
71
+ * @param {DotBIMLoaderPluginConfiguration} cfg Plugin configuration.
72
+ */
73
+ constructor(viewer: Viewer, cfg?: DotBIMLoaderPluginConfiguration);
74
+
75
+ /**
76
+ * Sets a custom data source through which the DotBIMLoaderPlugin can .BIM files.
77
+ *
78
+ * Default value is {@link DotBIMDefaultDataSource}, which loads via an XMLHttpRequest.
79
+ *
80
+ * @type {IXKTDefaultDataSource}
81
+ */
82
+ set dataSource(arg: IDotBIMDefaultDataSource);
83
+
84
+ /**
85
+ * Gets the custom data source through which the DotBIMLoaderPlugin can load .BIM files.
86
+ *
87
+ * Default value is {@link DotBIMDefaultDataSource}, which loads via an XMLHttpRequest.
88
+ *
89
+ * @type {IXKTDefaultDataSource}
90
+ */
91
+ get dataSource(): IDotBIMDefaultDataSource;
92
+
93
+ /**
94
+ * Sets map of initial default states for each loaded {@link Entity} that represents an object.
95
+ *
96
+ * @type {IFCObjectDefaults}
97
+ */
98
+ set objectDefaults(arg: IFCObjectDefaults);
99
+
100
+ /**
101
+ * Gets map of initial default states for each loaded {@link Entity} that represents an object.
102
+ *
103
+ * @type {IFCObjectDefaults}
104
+ */
105
+ get objectDefaults(): IFCObjectDefaults;
106
+
107
+ /**
108
+ * Loads a .BIM model from a file into this DotBIMLoaderPlugin's {@link Viewer}.
109
+ *
110
+ * @param {LoadBIMModel} params Loading parameters.
111
+ * @returns {VBOSceneModel} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
112
+ */
113
+
114
+ /**
115
+ * Loads a .BIM model from a file into this DotBIMLoaderPlugin's {@link Viewer}.
116
+ *
117
+ * @param {LoadDotBIMModel} params Loading parameters.
118
+ * @returns {VBOSceneModel} Entity representing the model, which will have {@link Entity.isModel} set ````true```` and will be registered by {@link Entity.id} in {@link Scene.models}.
119
+ */
120
+ load(params: LoadDotBIMModel): VBOSceneModel;
121
+ }
@@ -0,0 +1 @@
1
+ export * from "./DotBIMLoaderPlugin";
@@ -31,6 +31,10 @@ export declare interface IGLTFDefaultDataSource {
31
31
  * @param {Function} error Fired on error while loading the glTF binary asset.
32
32
  */
33
33
  getArrayBuffer(glTFSrc: string | number, binarySrc: string | number, ok: Function, error: Function): void;
34
+
35
+ get cacheBuster(): boolean;
36
+
37
+ set cacheBuster(value: boolean);
34
38
  }
35
39
 
36
40
  export declare type GLTFLoaderPluginConfiguration = {
@@ -10,6 +10,10 @@ export declare interface ILASDefaultDataSource {
10
10
  * @param {Function} error Callback fired on error.
11
11
  */
12
12
  getLAS(src: string | number, ok: (LAS: ArrayBuffer) => void, error: (e: Error) => void): void;
13
+
14
+ get cacheBuster(): boolean;
15
+
16
+ set cacheBuster(value: boolean);
13
17
  }
14
18
 
15
19
  export declare type LASLoaderPluginConfiguration = {
@@ -9,6 +9,10 @@ export declare interface ISTLDefaultDataSource {
9
9
  * @param {Function} error Fired on error while loading the STL file.
10
10
  */
11
11
  getSTL(src: string | number, ok: Function, error: Function): void;
12
+
13
+ get cacheBuster(): boolean;
14
+
15
+ set cacheBuster(value: boolean);
12
16
  }
13
17
 
14
18
  export declare type STLLoaderPluginCOnfiguration = {
@@ -21,6 +21,10 @@ export declare type TreeViewPluginConfiguration = {
21
21
  renderService?: ITreeViewRenderService;
22
22
  /** When true, will show indeterminate state for checkboxes when some but not all child nodes are checked */
23
23
  showIndeterminate?: boolean;
24
+ /** Optional function to replace the default elevation sort function. The function should take two nodes and return -1, 0 or 1. */
25
+ elevationSortFunction?: (node1: TreeViewNode, node2: TreeViewNode) => number;
26
+ /** Optional function to replace the default sort function. The function should take two nodes and return -1, 0 or 1. */
27
+ defaultSortFunction?: (node1: TreeViewNode, node2: TreeViewNode) => number;
24
28
  };
25
29
 
26
30
  /**
@@ -13,6 +13,10 @@ import { ModelStats } from "../index";
13
13
  * @param {Function} error Callback fired on error.
14
14
  */
15
15
  getIFC(src: string | number, ok: (buffer: ArrayBuffer)=> void, error: (e: Error)=> void): void;
16
+
17
+ get cacheBuster(): boolean;
18
+
19
+ set cacheBuster(value: boolean);
16
20
  }
17
21
 
18
22
  export declare type WebIFCLoaderPluginConfiguration = {
@@ -56,14 +56,28 @@ export declare type LoadXKTModel = {
56
56
  saoEnabled?: boolean;
57
57
  /** Indicates if physically-based rendering (PBR) will apply to the model. Only works when {@link Scene.pbrEnabled} is also ````true````. */
58
58
  pbrEnabled?: boolean;
59
+ /** Indicates if base color texture rendering is enabled for the model. Overridden by ````pbrEnabled````. Only works when {@link Scene#colorTextureEnabled} is also ````true````. */
60
+ colorTextureEnabled?: boolean;
59
61
  /** When we set this ````true````, then we force rendering of backfaces for the model. */
60
62
  backfaces?: boolean;
61
63
  /** When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). */
62
64
  excludeUnclassifiedObjects?: boolean;
63
65
  /** Indicates whether to globalize each {@link Entity.id} and {@link MetaObject.id}, in case you need to prevent ID clashes with other models. */
64
66
  globalizeObjectIds?: boolean;
65
- /** Indicates whether to enable geometry reuse */
67
+ /** Indicates whether to enable geometry reuse (````true```` by default) or whether to expand
68
+ * all geometry instances into batches (````false````), and not use instancing to render them. Setting this ````false```` can significantly
69
+ * improve Viewer performance for models that have excessive geometry reuse, but may also increases the amount of
70
+ * browser and GPU memory used by the model. See [#769](https://github.com/xeokit/xeokit-sdk/issues/769) for more info. */
66
71
  reuseGeometries?: boolean;
72
+ /** When ````true```` (default) use data textures (DTX), where appropriate, to
73
+ * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
74
+ * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
75
+ * primitives. Only works while {@link DTX#enabled} is also ````true````. */
76
+ dtxEnabled?: boolean;
77
+ /** Specifies the rendering order for the model. This is used to control the order in which
78
+ * SceneModels are drawn when they have transparent objects, to give control over the order in which those objects are blended within the transparent
79
+ * render pass. */
80
+ renderOrder?: number;
67
81
  }
68
82
 
69
83
  export declare interface IXKTDefaultDataSource {
@@ -84,6 +98,10 @@ export declare interface IXKTDefaultDataSource {
84
98
  * @param {Function} error Callback fired on error.
85
99
  */
86
100
  getXKT(src: string | number, ok: (buffer: ArrayBuffer) => void, error: (e: Error) => void): void;
101
+
102
+ get cacheBuster(): boolean;
103
+
104
+ set cacheBuster(value: boolean);
87
105
  }
88
106
 
89
107
  /**
@@ -4,6 +4,7 @@ export * from "./AxisGizmoPlugin";
4
4
  export * from "./BCFViewpointsPlugin";
5
5
  export * from "./CityJSONLoaderPlugin";
6
6
  export * from "./DistanceMeasurementsPlugin";
7
+ export * from "./DotBIMLoaderPlugin";
7
8
  export * from "./FastNavPlugin";
8
9
  export * from "./GLTFLoaderPlugin";
9
10
  export * from "./LASLoaderPlugin";