@xeokit/xeokit-sdk 2.6.111 → 2.6.113

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.111",
3
+ "version": "2.6.113",
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",
@@ -323,6 +323,9 @@ class GLTFLoaderPlugin extends Plugin {
323
323
  * @param {Boolean} [params.globalizeObjectIds=false] Indicates whether to globalize each {@link Entity#id} and {@link MetaObject#id}, in case you need to prevent ID clashes with other models.
324
324
  * @param {*} [params.parseOptions={}] Options to pass to loaders.gl parse method, eg. ````{ gltf: { excludeExtensions: { "KHR_texture_transform": false } } }````.
325
325
  * @param {Boolean} [params.entityPerMesh=false] Create an entity for each mesh, instead of grouping leaf meshes under their common entity.
326
+ * @param {*} [params.loadersGl={core,gltf}] Alternative user-provided loaders.gl library.
327
+ * This feature has been tested with loaders.gl 4.3.4 version.
328
+ * Because loaders.gl is supplied externally, xeokit cannot guarantee compatibility with all loaders.gl versions.
326
329
  * @returns {Entity} Entity representing the model, which will have {@link Entity#isModel} set ````true```` and will be registered by {@link Entity#id} in {@link Scene#models}
327
330
  */
328
331
  load(params = {}) {
@@ -108,11 +108,12 @@ function getBasePath(src) {
108
108
  function parseGLTF(plugin, src, gltf, metaModelJSON, options, sceneModel, ok, error) {
109
109
  const spinner = plugin.viewer.scene.canvas.spinner;
110
110
  spinner.processes++;
111
- parse(gltf, GLTFLoader, {
111
+ const loadersGl = options.loadersGl;
112
+ (loadersGl ? loadersGl.core.parse : parse)(gltf, loadersGl ? loadersGl.gltf.GLTFLoader : GLTFLoader, {
112
113
  ...(options.parseOptions || { }),
113
114
  baseUri: options.basePath
114
115
  }).then((gltfData) => {
115
- const processedGLTF = postProcessGLTF(gltfData);
116
+ const processedGLTF = (loadersGl ? loadersGl.gltf.postProcessGLTF : postProcessGLTF)(gltfData);
116
117
  const ctx = {
117
118
  src: src,
118
119
  entityId: options.entityId,
@@ -134,6 +134,9 @@ class ViewCullPlugin extends Plugin {
134
134
  if (cullDirty) {
135
135
  const kdNode = this._kdRoot;
136
136
  if (kdNode) {
137
+ for (let objectIdx = 0, len = this._objectCullStates.numObjects; objectIdx < len; objectIdx++) {
138
+ this._objectCullStates.setObjectViewCulled(objectIdx, false);
139
+ }
137
140
  this._visitKDNode(kdNode);
138
141
  }
139
142
  }
@@ -610,7 +610,7 @@ class XKTLoaderPlugin extends Plugin {
610
610
  * @param {String[]} [cfg.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
611
611
  * @param {String[]} [cfg.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
612
612
  * @param {Boolean} [cfg.excludeUnclassifiedObjects=false] When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). This is useful when we don't want Entitys in the Scene that are not represented within IFC navigation components, such as {@link TreeViewPlugin}.
613
- * @param {Boolean} [cfg.reuseGeometries=true] Indicates whether to enable geometry reuse (````true```` by default) or whether to internally expand
613
+ * @param {Boolean|Function} [cfg.reuseGeometries=true] Indicates whether to enable geometry reuse (````true```` by default) or whether to internally expand, a function will be called with a `{ instanceCount: <number> }` argument.
614
614
  * all geometry instances into batches (````false````), and not use instancing to render them. Setting this ````false```` can significantly
615
615
  * improve Viewer performance for models that have a lot of geometry reuse, but may also increase the amount of
616
616
  * browser and GPU memory they require. See [#769](https://github.com/xeokit/xeokit-sdk/issues/769) for more info.
@@ -878,7 +878,7 @@ class XKTLoaderPlugin extends Plugin {
878
878
  * @type {Boolean}
879
879
  */
880
880
  set reuseGeometries(value) {
881
- this._reuseGeometries = value !== false;
881
+ this._reuseGeometries = value;
882
882
  }
883
883
 
884
884
  /**
@@ -920,9 +920,9 @@ class XKTLoaderPlugin extends Plugin {
920
920
  * Viewer will hide backfaces on watertight meshes, show backfaces on open meshes, and always show backfaces on meshes when we slice them open with {@link SectionPlane}s.
921
921
  * @param {Boolean} [params.excludeUnclassifiedObjects=false] When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). This is useful when we don't want Entitys in the Scene that are not represented within IFC navigation components, such as {@link TreeViewPlugin}.
922
922
  * @param {Boolean} [params.globalizeObjectIds=false] Indicates whether to globalize each {@link Entity#id} and {@link MetaObject#id}, in case you need to prevent ID clashes with other models. See {@link XKTLoaderPlugin#globalizeObjectIds} for more info.
923
- * @param {Boolean} [params.reuseGeometries=true] Indicates whether to enable geometry reuse (````true```` by default) or whether to expand
924
- * all geometry instances into batches (````false````), and not use instancing to render them. Setting this ````false```` can significantly
925
- * improve Viewer performance for models that have excessive geometry reuse, but may also increases the amount of
923
+ * @param {Boolean|Function} [params.reuseGeometries=true] Indicates whether to enable geometry reuse (````true```` by default) or whether to expand
924
+ * all geometry instances into batches (````false````), and not use instancing to render them. A function will be called with a `{ instanceCount: <number> }` argument. Setting this ````false```` can significantly
925
+ * improve Viewer performance for models that have excessive geometry reuse, but may also increase the amount of
926
926
  * browser and GPU memory used by the model. See [#769](https://github.com/xeokit/xeokit-sdk/issues/769) for more info.
927
927
  * @param {Boolean} [params.dtxEnabled=true] When ````true```` (default) use data textures (DTX), where appropriate, to
928
928
  * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
@@ -949,7 +949,8 @@ class XKTLoaderPlugin extends Plugin {
949
949
  const includeIds = params.includeIds || this._includeIds;
950
950
  const objectDefaults = params.objectDefaults || this._objectDefaults;
951
951
 
952
- options.reuseGeometries = (params.reuseGeometries !== null && params.reuseGeometries !== undefined) ? params.reuseGeometries : (this._reuseGeometries !== false);
952
+ const reuseGeometries = params.reuseGeometries ?? this._reuseGeometries;
953
+ options.reuseGeometries = (typeof reuseGeometries !== "function") ? (() => reuseGeometries) : reuseGeometries;
953
954
 
954
955
  if (includeTypes) {
955
956
  options.includeTypesMap = {};
@@ -391,7 +391,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
391
391
 
392
392
  if (!geometryArrays) {
393
393
  geometryArrays = {
394
- batchThisMesh: (!options.reuseGeometries)
394
+ batchThisMesh: (!options.reuseGeometries({ instanceCount: geometryReuseCount }))
395
395
  };
396
396
  const primitiveType = eachGeometryPrimitiveType[geometryIndex];
397
397
  let geometryValid = false;
@@ -384,7 +384,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
384
384
 
385
385
  if (!geometryArrays) {
386
386
  geometryArrays = {
387
- batchThisMesh: (!options.reuseGeometries)
387
+ batchThisMesh: (!options.reuseGeometries({ instanceCount: geometryReuseCount }))
388
388
  };
389
389
  const primitiveType = eachGeometryPrimitiveType[geometryIndex];
390
390
  let geometryValid = false;
@@ -469,7 +469,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
469
469
 
470
470
  if (!geometryArrays) {
471
471
  geometryArrays = {
472
- batchThisMesh: (!options.reuseGeometries)
472
+ batchThisMesh: (!options.reuseGeometries({ instanceCount: geometryReuseCount }))
473
473
  };
474
474
  const primitiveType = eachGeometryPrimitiveType[geometryIndex];
475
475
  const axisLabel = eachGeometryAxisLabel[geometryIndex];
@@ -341,7 +341,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
341
341
  if (!geometryArrays) {
342
342
 
343
343
  geometryArrays = {
344
- batchThisMesh: (!options.reuseGeometries)
344
+ batchThisMesh: (!options.reuseGeometries({ instanceCount: geometryReuseCount }))
345
345
  };
346
346
 
347
347
  const primitiveType = eachGeometryPrimitiveType[geometryIndex];
@@ -297,7 +297,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
297
297
 
298
298
  if (!geometryArrays) {
299
299
  geometryArrays = {
300
- batchThisMesh: (!options.reuseGeometries)
300
+ batchThisMesh: (!options.reuseGeometries({ instanceCount: geometryReuseCount }))
301
301
  };
302
302
  const primitiveType = eachGeometryPrimitiveType[geometryIndex];
303
303
  let geometryValid = false;
@@ -338,7 +338,7 @@ export const getRenderers = (function() {
338
338
  if (primitive === "points") {
339
339
  cache[sceneId] = {
340
340
  colorRenderers: { "sao-": { "vertex": lazy((vars, geo, c) => c(makeColorProgram(vars, geo, null, null))) } },
341
- occlusionRenderer: lazy((vars, geo, c) => c(OcclusionProgram(vars, scene.logarithmicDepthBufferEnabled))),
341
+ occlusionRenderer: lazy((vars, geo, c) => c(OcclusionProgram(vars))),
342
342
  pickDepthRenderer: lazy(makePickDepthProgram),
343
343
  pickMeshRenderer: lazy(makePickMeshProgram),
344
344
  // VBOBatchingPointsShadowRenderer has been implemented by 14e973df6268369b00baef60e468939e062ac320,
@@ -400,7 +400,7 @@ export const getRenderers = (function() {
400
400
  uniform: lazy((vars, geo, c) => c(EdgesProgram(vars, geo, scene.logarithmicDepthBufferEnabled, true)), { vertices: false }),
401
401
  vertex: lazy((vars, geo, c) => c(EdgesProgram(vars, geo, scene.logarithmicDepthBufferEnabled, false)), { vertices: false })
402
402
  },
403
- occlusionRenderer: lazy((vars, geo, c) => c(OcclusionProgram(vars, scene.logarithmicDepthBufferEnabled))),
403
+ occlusionRenderer: lazy((vars, geo, c) => c(OcclusionProgram(vars))),
404
404
  pickDepthRenderer: eager(makePickDepthProgram),
405
405
  pickMeshRenderer: eager(makePickMeshProgram),
406
406
  pickNormalsFlatRenderer: eager((vars, geo, c) => makePickNormalsProgram(vars, geo, c, true)),
@@ -1,11 +1,7 @@
1
- export const OcclusionProgram = function(programVariables, logarithmicDepthBufferEnabled) {
1
+ export const OcclusionProgram = function(programVariables) {
2
2
  const outColor = programVariables.createOutput("vec4", "outColor");
3
3
  return {
4
4
  programName: "Occlusion",
5
- // Logarithmic depth buffer involves an accuracy tradeoff, sacrificing
6
- // accuracy at close range to improve accuracy at long range. This can
7
- // mess up accuracy for occlusion tests, so we'll disable for now.
8
- getLogDepth: false && logarithmicDepthBufferEnabled && (vFragDepth => vFragDepth),
9
5
  renderPassFlag: 0, // COLOR_OPAQUE // Only opaque objects can be occluders
10
6
  appendFragmentOutputs: (src) => src.push(`${outColor} = vec4(0.0, 0.0, 1.0, 1.0);`) // Occluders are blue
11
7
  };
@@ -636,6 +636,8 @@ class Scene extends Component {
636
636
  alphaDepthMask: alphaDepthMask
637
637
  });
638
638
 
639
+ this.canvas._renderer = this._renderer;
640
+
639
641
  this._sectionPlanesState = new (function () {
640
642
 
641
643
  this.sectionPlanes = [];
@@ -1,6 +1,6 @@
1
1
  import {Component} from '../Component.js';
2
2
  import {math} from "../math/math.js";
3
- import {SectionPlane} from "./SectionPlane";
3
+ import {SectionPlane} from "./SectionPlane.js";
4
4
 
5
5
  const tempVec3a = math.vec3();
6
6
 
@@ -132,13 +132,12 @@ export class OcclusionTester {
132
132
  "OcclusionTester",
133
133
  {
134
134
  sectionPlanesState: sectionPlanesState,
135
- getLogDepth: scene.logarithmicDepthBufferEnabled && (vFragDepth => vFragDepth),
136
135
  clippableTest: () => "true",
137
136
  getVertexData: () => {
138
137
  const src = [ ];
139
138
  src.push(`vec4 worldPosition = vec4(${position}, 1.0);`);
140
139
  src.push(`vec4 ${clipPos} = ${projMatrix} * ${viewMatrix} * worldPosition;`);
141
- if ((! scene.logarithmicDepthBufferEnabled) && (scene.markerZOffset < 0.000)) {
140
+ if (scene.markerZOffset < 0.000) {
142
141
  src.push(`${clipPos}.z += ${scene.markerZOffset};`);
143
142
  }
144
143
  return src;
@@ -87,6 +87,20 @@ export declare type LoadGLTFModel = {
87
87
  parseOptions?: any;
88
88
  /** Create an entity for each mesh, instead of grouping leaf meshes under their common entity. */
89
89
  entityPerMesh?: boolean;
90
+ /**
91
+ * Alternative user-provided loaders.gl library.
92
+ * This feature has been tested with loaders.gl 4.3.4 version.
93
+ * Because loaders.gl is supplied externally, xeokit cannot guarantee compatibility with all loaders.gl versions.
94
+ */
95
+ loadersGl?: {
96
+ core: {
97
+ parse: (...args: any[]) => any;
98
+ };
99
+ gltf: {
100
+ GLTFLoader: any;
101
+ postProcessGLTF: (...args: any[]) => any;
102
+ };
103
+ };
90
104
  };
91
105
 
92
106
  /**
@@ -1,5 +1,9 @@
1
1
  import {IFCObjectDefaults, Plugin, VBOSceneModel, Viewer} from "../../viewer";
2
2
 
3
+ type ReuseGeometries =
4
+ | boolean
5
+ | ((geometryConfig: { instanceCount: number }) => boolean);
6
+
3
7
  export declare type XKTLoaderPluginConfiguration = {
4
8
  /** Optional ID for this plugin, so that we can find it within {@link Viewer.plugins}. */
5
9
  id?: string;
@@ -16,7 +20,7 @@ export declare type XKTLoaderPluginConfiguration = {
16
20
  /** When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). This is useful when we don't want Entitys in the Scene that are not represented within IFC navigation components, such as {@link TreeViewPlugin}. */
17
21
  excludeUnclassifiedObjects?: boolean;
18
22
  /** Indicates whether to enable geometry reuse */
19
- reuseGeometries?: boolean;
23
+ reuseGeometries?: ReuseGeometries;
20
24
  /** Maximum geometry batch size, as number of vertices. */
21
25
  maxGeometryBatchSize?: number;
22
26
  };
@@ -74,7 +78,7 @@ export declare type LoadXKTModel = {
74
78
  * all geometry instances into batches (````false````), and not use instancing to render them. Setting this ````false```` can significantly
75
79
  * improve Viewer performance for models that have excessive geometry reuse, but may also increases the amount of
76
80
  * browser and GPU memory used by the model. See [#769](https://github.com/xeokit/xeokit-sdk/issues/769) for more info. */
77
- reuseGeometries?: boolean;
81
+ reuseGeometries?: ReuseGeometries;
78
82
  /** When ````true```` (default) use data textures (DTX), where appropriate, to
79
83
  * represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
80
84
  * to non-textured triangle meshes, and that VBOs are always used for meshes that have textures, line segments, or point
@@ -267,7 +271,7 @@ export declare class XKTLoaderPlugin extends Plugin {
267
271
  *
268
272
  * @type {Boolean}
269
273
  */
270
- set reuseGeometries(arg: boolean);
274
+ set reuseGeometries(arg: ReuseGeometries);
271
275
 
272
276
  /**
273
277
  * Gets whether XKTLoaderPlugin enables geometry reuse when loading models.
@@ -276,7 +280,7 @@ export declare class XKTLoaderPlugin extends Plugin {
276
280
  *
277
281
  * @type {Boolean}
278
282
  */
279
- get reuseGeometries(): boolean;
283
+ get reuseGeometries(): ReuseGeometries;
280
284
 
281
285
  /**
282
286
  * Gets the ````.xkt```` format versions supported by this XKTLoaderPlugin/
@@ -61,14 +61,24 @@ export declare class MetaModel {
61
61
  /**
62
62
  * The {@link PropertySet}s in this MetaModel.
63
63
  */
64
- propertySets: {
65
- String: PropertySet;
66
- };
64
+ propertySets: PropertySet[];
67
65
 
68
66
  /**
69
67
  * The root {@link MetaObject} in this MetaModel's composition structure hierarchy.
70
68
  */
71
- rootMetaObject: MetaObject;
69
+ rootMetaObject: MetaObject | null;
70
+
71
+ /**
72
+ * The root {@link MetaObject}s in this MetaModel's composition structure hierarchy.
73
+ */
74
+ rootMetaObjects: MetaObject[];
75
+
76
+ /**
77
+ * The {@link MetaObject}s in this MetaModel, each mapped to its ID.
78
+ */
79
+ metaObjects: {
80
+ String: MetaObject;
81
+ };
72
82
 
73
83
  /**
74
84
  * Finalizes this MetaModel.