@xeokit/xeokit-sdk 2.6.111 → 2.6.112

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.112",
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;