Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Jan 20, 2024
1 parent a8299d4 commit 0cddbea
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 65 deletions.
54 changes: 29 additions & 25 deletions dist/xeokit-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80323,8 +80323,6 @@ 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 @@ -80337,6 +80335,7 @@ class SceneModel extends Component {
this._entities = {};

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

/** @private **/
this.renderFlags = new RenderFlags();
Expand Down Expand Up @@ -81867,7 +81866,7 @@ class SceneModel extends Component {
/**
* Creates a new {@link SceneModelMesh} within this SceneModel.
*
* * Stores the new SceneModelMesh in {@link SceneModel#meshes}.
* * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
* * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
* various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
* with {@link SceneModel#createGeometry}.
Expand Down Expand Up @@ -81902,18 +81901,18 @@ 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 {SceneModelMesh} The new mesh.
* @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
*/
createMesh(cfg) {

if (cfg.id === undefined || cfg.id === null) {
this.error("[createMesh] SceneModel.createMesh() config missing: id");
return;
return false;
}

if (this._scheduledMeshes[cfg.id]) {
this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
return;
return false;
}

const instancing = (cfg.geometryId !== undefined);
Expand All @@ -81928,31 +81927,31 @@ class SceneModel extends Component {
}
if (cfg.primitive !== "points" && cfg.primitive !== "lines" && cfg.primitive !== "triangles" && cfg.primitive !== "solid" && cfg.primitive !== "surface") {
this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`);
return;
return false;
}
if (!cfg.positions && !cfg.positionsCompressed && !cfg.buckets) {
this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");
return null;
return false;
}
if (cfg.positions && (cfg.positionsDecodeMatrix || cfg.positionsDecodeBoundary)) {
this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");
return null;
return false;
}
if (cfg.positionsCompressed && !cfg.positionsDecodeMatrix && !cfg.positionsDecodeBoundary) {
this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");
return null;
return false;
}
if (cfg.uvCompressed && !cfg.uvDecodeMatrix) {
this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");
return null;
return false;
}
if (!cfg.buckets && !cfg.indices && cfg.primitive !== "points") {
this.error(`Param expected: indices (required for '${cfg.primitive}' primitive type)`);
return null;
return false;
}
if ((cfg.matrix || cfg.position || cfg.rotation || cfg.scale) && (cfg.positionsCompressed || cfg.positionsDecodeBoundary)) {
this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");
return null;
return false;
}

const useDTX = (!!this._dtxEnabled && (cfg.primitive === "triangles"
Expand Down Expand Up @@ -82117,7 +82116,7 @@ class SceneModel extends Component {
cfg.textureSet = this._textureSets[cfg.textureSetId];
if (!cfg.textureSet) {
this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
return;
return false;
}
}
}
Expand All @@ -82128,13 +82127,13 @@ class SceneModel extends Component {

if (cfg.positions || cfg.positionsCompressed || cfg.indices || cfg.edgeIndices || cfg.normals || cfg.normalsCompressed || cfg.uv || cfg.uvCompressed || cfg.positionsDecodeMatrix) {
this.error(`Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)`);
return;
return false;
}

cfg.geometry = this._geometries[cfg.geometryId];
if (!cfg.geometry) {
this.error(`[createMesh] Geometry not found: ${cfg.geometryId} - ensure that you create it first with createGeometry()`);
return;
return false;
}

cfg.origin = cfg.origin ? math.addVec3(this._origin, cfg.origin, math.vec3()) : this._origin;
Expand All @@ -82148,7 +82147,7 @@ class SceneModel extends Component {

if (!cfg.transform) {
this.error(`[createMesh] Transform not found: ${cfg.transformId} - ensure that you create it first with createTransform()`);
return;
return false;
}

cfg.aabb = cfg.geometry.aabb;
Expand Down Expand Up @@ -82216,15 +82215,17 @@ class SceneModel extends Component {
cfg.textureSet = this._textureSets[cfg.textureSetId];
// if (!cfg.textureSet) {
// this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
// return;
// return false;
// }
}
}
}

cfg.numPrimitives = this._getNumPrimitives(cfg);

return this._createMesh(cfg);
this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;

return true;
}

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

Expand Down Expand Up @@ -82616,10 +82615,15 @@ class SceneModel extends Component {
let meshes = [];
for (let i = 0, len = cfg.meshIds.length; i < len; i++) {
const meshId = cfg.meshIds[i];
const mesh = this._meshes[meshId];
if (!mesh) {
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`);
continue;
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
}
if (mesh.parent) {
this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
Expand Down
52 changes: 28 additions & 24 deletions dist/xeokit-sdk.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -80319,8 +80319,6 @@ 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 @@ -80333,6 +80331,7 @@ class SceneModel extends Component {
this._entities = {};

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

/** @private **/
this.renderFlags = new RenderFlags();
Expand Down Expand Up @@ -81863,7 +81862,7 @@ class SceneModel extends Component {
/**
* Creates a new {@link SceneModelMesh} within this SceneModel.
*
* * Stores the new SceneModelMesh in {@link SceneModel#meshes}.
* * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
* * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
* various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
* with {@link SceneModel#createGeometry}.
Expand Down Expand Up @@ -81898,18 +81897,18 @@ 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 {SceneModelMesh} The new mesh.
* @returns {Boolean} True if mesh was successfully created, else false if an error occurred.
*/
createMesh(cfg) {

if (cfg.id === undefined || cfg.id === null) {
this.error("[createMesh] SceneModel.createMesh() config missing: id");
return;
return false;
}

if (this._scheduledMeshes[cfg.id]) {
this.error(`[createMesh] SceneModel already has a mesh with this ID: ${cfg.id}`);
return;
return false;
}

const instancing = (cfg.geometryId !== undefined);
Expand All @@ -81924,31 +81923,31 @@ class SceneModel extends Component {
}
if (cfg.primitive !== "points" && cfg.primitive !== "lines" && cfg.primitive !== "triangles" && cfg.primitive !== "solid" && cfg.primitive !== "surface") {
this.error(`Unsupported value for 'primitive': '${primitive}' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'.`);
return;
return false;
}
if (!cfg.positions && !cfg.positionsCompressed && !cfg.buckets) {
this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");
return null;
return false;
}
if (cfg.positions && (cfg.positionsDecodeMatrix || cfg.positionsDecodeBoundary)) {
this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");
return null;
return false;
}
if (cfg.positionsCompressed && !cfg.positionsDecodeMatrix && !cfg.positionsDecodeBoundary) {
this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");
return null;
return false;
}
if (cfg.uvCompressed && !cfg.uvDecodeMatrix) {
this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");
return null;
return false;
}
if (!cfg.buckets && !cfg.indices && cfg.primitive !== "points") {
this.error(`Param expected: indices (required for '${cfg.primitive}' primitive type)`);
return null;
return false;
}
if ((cfg.matrix || cfg.position || cfg.rotation || cfg.scale) && (cfg.positionsCompressed || cfg.positionsDecodeBoundary)) {
this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");
return null;
return false;
}

const useDTX = (!!this._dtxEnabled && (cfg.primitive === "triangles"
Expand Down Expand Up @@ -82113,7 +82112,7 @@ class SceneModel extends Component {
cfg.textureSet = this._textureSets[cfg.textureSetId];
if (!cfg.textureSet) {
this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
return;
return false;
}
}
}
Expand All @@ -82124,13 +82123,13 @@ class SceneModel extends Component {

if (cfg.positions || cfg.positionsCompressed || cfg.indices || cfg.edgeIndices || cfg.normals || cfg.normalsCompressed || cfg.uv || cfg.uvCompressed || cfg.positionsDecodeMatrix) {
this.error(`Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)`);
return;
return false;
}

cfg.geometry = this._geometries[cfg.geometryId];
if (!cfg.geometry) {
this.error(`[createMesh] Geometry not found: ${cfg.geometryId} - ensure that you create it first with createGeometry()`);
return;
return false;
}

cfg.origin = cfg.origin ? math.addVec3(this._origin, cfg.origin, math.vec3()) : this._origin;
Expand All @@ -82144,7 +82143,7 @@ class SceneModel extends Component {

if (!cfg.transform) {
this.error(`[createMesh] Transform not found: ${cfg.transformId} - ensure that you create it first with createTransform()`);
return;
return false;
}

cfg.aabb = cfg.geometry.aabb;
Expand Down Expand Up @@ -82212,15 +82211,17 @@ class SceneModel extends Component {
cfg.textureSet = this._textureSets[cfg.textureSetId];
// if (!cfg.textureSet) {
// this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
// return;
// return false;
// }
}
}
}

cfg.numPrimitives = this._getNumPrimitives(cfg);

return this._createMesh(cfg);
this._meshesCfgsBeforeMeshCreation[cfg.id] = cfg;

return true;
}

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

Expand Down Expand Up @@ -82612,10 +82611,15 @@ class SceneModel extends Component {
let meshes = [];
for (let i = 0, len = cfg.meshIds.length; i < len; i++) {
const meshId = cfg.meshIds[i];
const mesh = this._meshes[meshId];
let mesh = this._meshes[meshId];
if (!mesh) {
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`);
continue;
let meshCfg = this._meshesCfgsBeforeMeshCreation[meshId];
if (!meshCfg) {
this.error(`Mesh with this ID not found: "${meshId}" - ignoring this mesh`);
continue;
}
mesh = this._createMesh(meshCfg);
this._meshes[cfg.id] = mesh;
}
if (mesh.parent) {
this.error(`Mesh with ID "${meshId}" already belongs to object with ID "${mesh.parent.id}" - ignoring this mesh`);
Expand Down
Loading

0 comments on commit 0cddbea

Please sign in to comment.