Skip to content

Commit

Permalink
Merge pull request #1753 from xeokit/fix-metaobject-metamodel-links
Browse files Browse the repository at this point in the history
[FIX] Fix missing MetaObject->metaModels links
  • Loading branch information
xeolabs authored Dec 3, 2024
2 parents f917b00 + b0c99e9 commit cf38a3b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/viewer/metadata/MetaModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ class MetaModel {
this.rootMetaObjects.push(metaObject);
metaScene.rootMetaObjects[id] = metaObject;
}
metaObject.metaModels.push(this);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/viewer/metadata/MetaScene.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {MetaModel} from "./MetaModel.js";
import {MetaObject} from "./MetaObject.js";
import {PropertySet} from "./PropertySet.js";
import {math} from "../scene/math/math.js";

/**
* @desc Metadata corresponding to a {@link Scene}.
Expand Down Expand Up @@ -188,13 +187,14 @@ class MetaScene {
if (metaModel.metaObjects) {
for (let i = 0, len = metaModel.metaObjects.length; i < len; i++) {
const metaObject = metaModel.metaObjects[i];
const type = metaObject.type;
const id = metaObject.id;
if (metaObject.metaModels.length === 1&& metaObject.metaModels[0].id === metaModelId) { // MetaObject owned only by this model, delete
if (metaObject.metaModels.length === 1 && metaObject.metaModels[0].id === metaModelId) { // MetaObject owned only by this model, delete
delete this.metaObjects[id];
if (!metaObject.parent) {
delete this.rootMetaObjects[id];
}
} else {
metaObject.metaModels = metaObject.metaModels.filter(metaModel => metaModel.id !== metaModelId);
}
}
}
Expand Down

0 comments on commit cf38a3b

Please sign in to comment.