add support for programmatically and efficiently removing objects, better API and more CI automation

This commit is contained in:
Yeicor
2024-03-10 17:30:34 +01:00
parent 88e1167b57
commit 49df7af970
16 changed files with 217 additions and 146 deletions

View File

@@ -82,10 +82,13 @@ export class NetworkManager extends EventTarget {
private foundModel(name: string, hash: string | null, url: string, isRemove: boolean) {
let prevHash = this.knownObjectHashes[name];
let hashToCheck = hash + (isRemove ? "-remove" : "");
// console.debug("Found model", name, "with hash", hash, "and previous hash", prevHash);
if (!hash || hashToCheck !== prevHash) {
this.knownObjectHashes[name] = hash;
if (!hash || hash !== prevHash || isRemove) {
if (!isRemove) {
this.knownObjectHashes[name] = hash;
} else {
delete this.knownObjectHashes[name];
}
let newModel = new NetworkUpdateEventModel(name, url, hash, isRemove);
this.bufferedUpdates.push(newModel);

View File

@@ -35,6 +35,7 @@ export class SceneMgr {
private static async reloadHelpers(sceneUrl: Ref<string>, document: Document, reloadScene: boolean): Promise<Document> {
let bb = SceneMgr.getBoundingBox(document);
if (!bb) return document;
// Create the helper axes and grid box
let helpersDoc = new Document();
@@ -45,7 +46,8 @@ export class SceneMgr {
return await SceneMgr.loadModel(sceneUrl, document, extrasNameValueHelpers, helpersUrl, false, reloadScene);
}
static getBoundingBox(document: Document): Box3 {
static getBoundingBox(document: Document): Box3 | null {
if (document.getRoot().listNodes().length === 0) return null;
// Get bounding box of the model and use it to set the size of the helpers
let bbMin: number[] = [1e6, 1e6, 1e6];
let bbMax: number[] = [-1e6, -1e6, -1e6];