@xeokit/xeokit-sdk 2.6.0-beta-2 → 2.6.0-beta-4

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.
@@ -10843,14 +10843,13 @@ class Dot {
10843
10843
  this._x = 0;
10844
10844
  this._y = 0;
10845
10845
 
10846
- this._visible = true;
10847
10846
  this._dot = document.createElement('div');
10848
10847
  this._dot.className += this._dot.className ? ' viewer-ruler-dot' : 'viewer-ruler-dot';
10849
10848
 
10850
10849
  this._dotClickable = document.createElement('div');
10851
10850
  this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
10852
10851
 
10853
- this._visible = true;
10852
+ this._visible = !!cfg.visible;
10854
10853
  this._culled = false;
10855
10854
 
10856
10855
  var dot = this._dot;
@@ -80724,6 +80723,8 @@ class SceneModel extends Component {
80724
80723
  this._vboBatchingLayers = {};
80725
80724
  this._dtxLayers = {};
80726
80725
 
80726
+ this._meshList = [];
80727
+
80727
80728
  this.layerList = []; // For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
80728
80729
  this._entityList = [];
80729
80730
 
@@ -80733,11 +80734,9 @@ class SceneModel extends Component {
80733
80734
  this._textureSets = {};
80734
80735
  this._transforms = {};
80735
80736
  this._meshes = {};
80737
+ this._unusedMeshes = {};
80736
80738
  this._entities = {};
80737
80739
 
80738
- this._scheduledMeshes = {};
80739
- this._meshesCfgsBeforeMeshCreation = {};
80740
-
80741
80740
  /** @private **/
80742
80741
  this.renderFlags = new RenderFlags();
80743
80742
 
@@ -82306,7 +82305,7 @@ class SceneModel extends Component {
82306
82305
  * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
82307
82306
  * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
82308
82307
  * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
82309
- * @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
82308
+ * @returns {SceneModelMesh} The new mesh.
82310
82309
  */
82311
82310
  createMesh(cfg) {
82312
82311
 
@@ -82315,7 +82314,7 @@ class SceneModel extends Component {
82315
82314
  return false;
82316
82315
  }
82317
82316
 
82318
- if (this._scheduledMeshes[cfg.id]) {
82317
+ if (this._meshes[cfg.id]) {
82319
82318
  this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
82320
82319
  return false;
82321
82320
  }
@@ -82635,17 +82634,7 @@ class SceneModel extends Component {
82635
82634
 
82636
82635
  cfg.numPrimitives = this._getNumPrimitives(cfg);
82637
82636
 
82638
- this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;
82639
-
82640
- return true;
82641
- }
82642
-
82643
- _createDefaultIndices(numIndices) {
82644
- const indices = [];
82645
- for (let i = 0; i < numIndices; i++) {
82646
- indices.push(i);
82647
- }
82648
- return indices;
82637
+ return this._createMesh(cfg);
82649
82638
  }
82650
82639
 
82651
82640
  _createMesh(cfg) {
@@ -82677,6 +82666,9 @@ class SceneModel extends Component {
82677
82666
  cfg.meshMatrix = cfg.transform.worldMatrix;
82678
82667
  }
82679
82668
  mesh.portionId = mesh.layer.createPortion(mesh, cfg);
82669
+ this._meshes[cfg.id] = mesh;
82670
+ this._unusedMeshes[cfg.id] = mesh;
82671
+ this._meshList.push(mesh);
82680
82672
  return mesh;
82681
82673
  }
82682
82674
 
@@ -83037,19 +83029,15 @@ class SceneModel extends Component {
83037
83029
  const meshId = cfg.meshIds[i];
83038
83030
  let mesh = this._meshes[meshId]; // Trying to get already created mesh
83039
83031
  if (!mesh) { // Checks if there is already created mesh for this meshId
83040
- let meshCfg = this._meshesCfgsBeforeMeshCreation[meshId]; // Trying to get already created cfg
83041
- if (!meshCfg) { // Checks if there is already created cfg for this meshId
83042
- this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
83043
- continue;
83044
- }
83045
- mesh = this._createMesh(meshCfg); // There is no such mesh yet, but there is already created cfg, so it creates this mesh
83046
- this._meshes[cfg.id] = mesh; // Now it will also add this mesh to dictionary of created meshes
83032
+ this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
83033
+ continue;
83047
83034
  }
83048
83035
  if (mesh.parent) {
83049
83036
  this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
83050
83037
  continue;
83051
83038
  }
83052
83039
  meshes.push(mesh);
83040
+ delete this._unusedMeshes[meshId];
83053
83041
  }
83054
83042
  const lodCullable = true;
83055
83043
  const entity = new SceneModelEntity(
@@ -83073,6 +83061,7 @@ class SceneModel extends Component {
83073
83061
  if (this.destroyed) {
83074
83062
  return;
83075
83063
  }
83064
+ this._createDummyEntityForUnusedMeshes();
83076
83065
  for (let i = 0, len = this.layerList.length; i < len; i++) {
83077
83066
  const layer = this.layerList[i];
83078
83067
  layer.finalize();
@@ -83149,6 +83138,21 @@ class SceneModel extends Component {
83149
83138
  }
83150
83139
  }
83151
83140
 
83141
+ /** @private */
83142
+ _createDummyEntityForUnusedMeshes() {
83143
+ const unusedMeshIds = Object.keys(this._unusedMeshes);
83144
+ if (unusedMeshIds.length > 0) {
83145
+ const entityId = `${this.id}-dummyEntityForUnusedMeshes`;
83146
+ this.warn(`Creating dummy SceneModelEntity "${entityId}" for unused SceneMeshes: [${unusedMeshIds.join(",")}]`);
83147
+ this.createEntity({
83148
+ id: entityId,
83149
+ meshIds: unusedMeshIds,
83150
+ isObject: true
83151
+ });
83152
+ }
83153
+ this._unusedMeshes = {};
83154
+ }
83155
+
83152
83156
  _getActiveSectionPlanesForLayer(layer) {
83153
83157
  const renderFlags = this.renderFlags;
83154
83158
  const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
@@ -10839,14 +10839,13 @@ class Dot {
10839
10839
  this._x = 0;
10840
10840
  this._y = 0;
10841
10841
 
10842
- this._visible = true;
10843
10842
  this._dot = document.createElement('div');
10844
10843
  this._dot.className += this._dot.className ? ' viewer-ruler-dot' : 'viewer-ruler-dot';
10845
10844
 
10846
10845
  this._dotClickable = document.createElement('div');
10847
10846
  this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
10848
10847
 
10849
- this._visible = true;
10848
+ this._visible = !!cfg.visible;
10850
10849
  this._culled = false;
10851
10850
 
10852
10851
  var dot = this._dot;
@@ -80720,6 +80719,8 @@ class SceneModel extends Component {
80720
80719
  this._vboBatchingLayers = {};
80721
80720
  this._dtxLayers = {};
80722
80721
 
80722
+ this._meshList = [];
80723
+
80723
80724
  this.layerList = []; // For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
80724
80725
  this._entityList = [];
80725
80726
 
@@ -80729,11 +80730,9 @@ class SceneModel extends Component {
80729
80730
  this._textureSets = {};
80730
80731
  this._transforms = {};
80731
80732
  this._meshes = {};
80733
+ this._unusedMeshes = {};
80732
80734
  this._entities = {};
80733
80735
 
80734
- this._scheduledMeshes = {};
80735
- this._meshesCfgsBeforeMeshCreation = {};
80736
-
80737
80736
  /** @private **/
80738
80737
  this.renderFlags = new RenderFlags();
80739
80738
 
@@ -82302,7 +82301,7 @@ class SceneModel extends Component {
82302
82301
  * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
82303
82302
  * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
82304
82303
  * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
82305
- * @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
82304
+ * @returns {SceneModelMesh} The new mesh.
82306
82305
  */
82307
82306
  createMesh(cfg) {
82308
82307
 
@@ -82311,7 +82310,7 @@ class SceneModel extends Component {
82311
82310
  return false;
82312
82311
  }
82313
82312
 
82314
- if (this._scheduledMeshes[cfg.id]) {
82313
+ if (this._meshes[cfg.id]) {
82315
82314
  this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
82316
82315
  return false;
82317
82316
  }
@@ -82631,17 +82630,7 @@ class SceneModel extends Component {
82631
82630
 
82632
82631
  cfg.numPrimitives = this._getNumPrimitives(cfg);
82633
82632
 
82634
- this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;
82635
-
82636
- return true;
82637
- }
82638
-
82639
- _createDefaultIndices(numIndices) {
82640
- const indices = [];
82641
- for (let i = 0; i < numIndices; i++) {
82642
- indices.push(i);
82643
- }
82644
- return indices;
82633
+ return this._createMesh(cfg);
82645
82634
  }
82646
82635
 
82647
82636
  _createMesh(cfg) {
@@ -82673,6 +82662,9 @@ class SceneModel extends Component {
82673
82662
  cfg.meshMatrix = cfg.transform.worldMatrix;
82674
82663
  }
82675
82664
  mesh.portionId = mesh.layer.createPortion(mesh, cfg);
82665
+ this._meshes[cfg.id] = mesh;
82666
+ this._unusedMeshes[cfg.id] = mesh;
82667
+ this._meshList.push(mesh);
82676
82668
  return mesh;
82677
82669
  }
82678
82670
 
@@ -83033,19 +83025,15 @@ class SceneModel extends Component {
83033
83025
  const meshId = cfg.meshIds[i];
83034
83026
  let mesh = this._meshes[meshId]; // Trying to get already created mesh
83035
83027
  if (!mesh) { // Checks if there is already created mesh for this meshId
83036
- let meshCfg = this._meshesCfgsBeforeMeshCreation[meshId]; // Trying to get already created cfg
83037
- if (!meshCfg) { // Checks if there is already created cfg for this meshId
83038
- this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
83039
- continue;
83040
- }
83041
- mesh = this._createMesh(meshCfg); // There is no such mesh yet, but there is already created cfg, so it creates this mesh
83042
- this._meshes[cfg.id] = mesh; // Now it will also add this mesh to dictionary of created meshes
83028
+ this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
83029
+ continue;
83043
83030
  }
83044
83031
  if (mesh.parent) {
83045
83032
  this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
83046
83033
  continue;
83047
83034
  }
83048
83035
  meshes.push(mesh);
83036
+ delete this._unusedMeshes[meshId];
83049
83037
  }
83050
83038
  const lodCullable = true;
83051
83039
  const entity = new SceneModelEntity(
@@ -83069,6 +83057,7 @@ class SceneModel extends Component {
83069
83057
  if (this.destroyed) {
83070
83058
  return;
83071
83059
  }
83060
+ this._createDummyEntityForUnusedMeshes();
83072
83061
  for (let i = 0, len = this.layerList.length; i < len; i++) {
83073
83062
  const layer = this.layerList[i];
83074
83063
  layer.finalize();
@@ -83145,6 +83134,21 @@ class SceneModel extends Component {
83145
83134
  }
83146
83135
  }
83147
83136
 
83137
+ /** @private */
83138
+ _createDummyEntityForUnusedMeshes() {
83139
+ const unusedMeshIds = Object.keys(this._unusedMeshes);
83140
+ if (unusedMeshIds.length > 0) {
83141
+ const entityId = `${this.id}-dummyEntityForUnusedMeshes`;
83142
+ this.warn(`Creating dummy SceneModelEntity "${entityId}" for unused SceneMeshes: [${unusedMeshIds.join(",")}]`);
83143
+ this.createEntity({
83144
+ id: entityId,
83145
+ meshIds: unusedMeshIds,
83146
+ isObject: true
83147
+ });
83148
+ }
83149
+ this._unusedMeshes = {};
83150
+ }
83151
+
83148
83152
  _getActiveSectionPlanesForLayer(layer) {
83149
83153
  const renderFlags = this.renderFlags;
83150
83154
  const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;