Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Mar 13, 2024
1 parent 7016055 commit 6389a60
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 159 deletions.
51 changes: 28 additions & 23 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80723,6 +80723,8 @@ class SceneModel extends Component {
this._vboBatchingLayers = {};
this._dtxLayers = {};

this._meshList = [];

this.layerList = []; // For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
this._entityList = [];

Expand All @@ -80732,11 +80734,9 @@ class SceneModel extends Component {
this._textureSets = {};
this._transforms = {};
this._meshes = {};
this._unusedMeshes = {};
this._entities = {};

this._scheduledMeshes = {};
this._meshesCfgsBeforeMeshCreation = {};

/** @private **/
this.renderFlags = new RenderFlags();

Expand Down Expand Up @@ -82305,7 +82305,7 @@ class SceneModel extends Component {
* @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
* @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
* @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
* @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
* @returns {SceneModelMesh} The new mesh.
*/
createMesh(cfg) {

Expand All @@ -82314,7 +82314,7 @@ class SceneModel extends Component {
return false;
}

if (this._scheduledMeshes[cfg.id]) {
if (this._meshes[cfg.id]) {
this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
return false;
}
Expand Down Expand Up @@ -82634,17 +82634,7 @@ class SceneModel extends Component {

cfg.numPrimitives = this._getNumPrimitives(cfg);

this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;

return true;
}

_createDefaultIndices(numIndices) {
const indices = [];
for (let i = 0; i < numIndices; i++) {
indices.push(i);
}
return indices;
return this._createMesh(cfg);
}

_createMesh(cfg) {
Expand Down Expand Up @@ -82676,6 +82666,9 @@ class SceneModel extends Component {
cfg.meshMatrix = cfg.transform.worldMatrix;
}
mesh.portionId = mesh.layer.createPortion(mesh, cfg);
this._meshes[cfg.id] = mesh;
this._unusedMeshes[cfg.id] = mesh;
this._meshList.push(mesh);
return mesh;
}

Expand Down Expand Up @@ -83036,19 +83029,15 @@ class SceneModel extends Component {
const meshId = cfg.meshIds[i];
let mesh = this._meshes[meshId]; // Trying to get already created mesh
if (!mesh) { // Checks if there is already created mesh for this meshId
let meshCfg = this._meshesCfgsBeforeMeshCreation[meshId]; // Trying to get already created cfg
if (!meshCfg) { // Checks if there is already created cfg for this meshId
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
continue;
}
mesh = this._createMesh(meshCfg); // There is no such mesh yet, but there is already created cfg, so it creates this mesh
this._meshes[cfg.id] = mesh; // Now it will also add this mesh to dictionary of created meshes
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
continue;
}
if (mesh.parent) {
this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
continue;
}
meshes.push(mesh);
delete this._unusedMeshes[meshId];
}
const lodCullable = true;
const entity = new SceneModelEntity(
Expand All @@ -83072,6 +83061,7 @@ class SceneModel extends Component {
if (this.destroyed) {
return;
}
this._createDummyEntityForUnusedMeshes();
for (let i = 0, len = this.layerList.length; i < len; i++) {
const layer = this.layerList[i];
layer.finalize();
Expand Down Expand Up @@ -83148,6 +83138,21 @@ class SceneModel extends Component {
}
}

/** @private */
_createDummyEntityForUnusedMeshes() {
const unusedMeshIds = Object.keys(this._unusedMeshes);
if (unusedMeshIds.length > 0) {
const entityId = `${this.id}-dummyEntityForUnusedMeshes`;
this.warn(`Creating dummy SceneModelEntity "${entityId}" for unused SceneMeshes: [${unusedMeshIds.join(",")}]`);
this.createEntity({
id: entityId,
meshIds: unusedMeshIds,
isObject: true
});
}
this._unusedMeshes = {};
}

_getActiveSectionPlanesForLayer(layer) {
const renderFlags = this.renderFlags;
const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
Expand Down
51 changes: 28 additions & 23 deletions dist/xeokit-sdk.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -80719,6 +80719,8 @@ class SceneModel extends Component {
this._vboBatchingLayers = {};
this._dtxLayers = {};

this._meshList = [];

this.layerList = []; // For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
this._entityList = [];

Expand All @@ -80728,11 +80730,9 @@ class SceneModel extends Component {
this._textureSets = {};
this._transforms = {};
this._meshes = {};
this._unusedMeshes = {};
this._entities = {};

this._scheduledMeshes = {};
this._meshesCfgsBeforeMeshCreation = {};

/** @private **/
this.renderFlags = new RenderFlags();

Expand Down Expand Up @@ -82301,7 +82301,7 @@ class SceneModel extends Component {
* @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
* @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
* @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
* @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
* @returns {SceneModelMesh} The new mesh.
*/
createMesh(cfg) {

Expand All @@ -82310,7 +82310,7 @@ class SceneModel extends Component {
return false;
}

if (this._scheduledMeshes[cfg.id]) {
if (this._meshes[cfg.id]) {
this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
return false;
}
Expand Down Expand Up @@ -82630,17 +82630,7 @@ class SceneModel extends Component {

cfg.numPrimitives = this._getNumPrimitives(cfg);

this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;

return true;
}

_createDefaultIndices(numIndices) {
const indices = [];
for (let i = 0; i < numIndices; i++) {
indices.push(i);
}
return indices;
return this._createMesh(cfg);
}

_createMesh(cfg) {
Expand Down Expand Up @@ -82672,6 +82662,9 @@ class SceneModel extends Component {
cfg.meshMatrix = cfg.transform.worldMatrix;
}
mesh.portionId = mesh.layer.createPortion(mesh, cfg);
this._meshes[cfg.id] = mesh;
this._unusedMeshes[cfg.id] = mesh;
this._meshList.push(mesh);
return mesh;
}

Expand Down Expand Up @@ -83032,19 +83025,15 @@ class SceneModel extends Component {
const meshId = cfg.meshIds[i];
let mesh = this._meshes[meshId]; // Trying to get already created mesh
if (!mesh) { // Checks if there is already created mesh for this meshId
let meshCfg = this._meshesCfgsBeforeMeshCreation[meshId]; // Trying to get already created cfg
if (!meshCfg) { // Checks if there is already created cfg for this meshId
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
continue;
}
mesh = this._createMesh(meshCfg); // There is no such mesh yet, but there is already created cfg, so it creates this mesh
this._meshes[cfg.id] = mesh; // Now it will also add this mesh to dictionary of created meshes
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`); // There is no such cfg
continue;
}
if (mesh.parent) {
this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
continue;
}
meshes.push(mesh);
delete this._unusedMeshes[meshId];
}
const lodCullable = true;
const entity = new SceneModelEntity(
Expand All @@ -83068,6 +83057,7 @@ class SceneModel extends Component {
if (this.destroyed) {
return;
}
this._createDummyEntityForUnusedMeshes();
for (let i = 0, len = this.layerList.length; i < len; i++) {
const layer = this.layerList[i];
layer.finalize();
Expand Down Expand Up @@ -83144,6 +83134,21 @@ class SceneModel extends Component {
}
}

/** @private */
_createDummyEntityForUnusedMeshes() {
const unusedMeshIds = Object.keys(this._unusedMeshes);
if (unusedMeshIds.length > 0) {
const entityId = `${this.id}-dummyEntityForUnusedMeshes`;
this.warn(`Creating dummy SceneModelEntity "${entityId}" for unused SceneMeshes: [${unusedMeshIds.join(",")}]`);
this.createEntity({
id: entityId,
meshIds: unusedMeshIds,
isObject: true
});
}
this._unusedMeshes = {};
}

_getActiveSectionPlanesForLayer(layer) {
const renderFlags = this.renderFlags;
const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
Expand Down
Loading

0 comments on commit 6389a60

Please sign in to comment.