import { AppObjectEntity } from "@vived/core";
export class Mesh extends AppObjectEntity {
    static addIfMissing(appObj) {
        const existing = appObj.getComponent(this.type);
        if (existing) {
            return existing;
        }
        else {
            return new Mesh(appObj);
        }
    }
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
    get subMeshes() {
        return Array.from(this.subMeshLookup.values());
    }
    addSubMesh(subMesh) {
        if (this.subMeshLookup.has(subMesh.meshPath))
            return;
        this.subMeshLookup.set(subMesh.meshPath, subMesh);
        this.notifyOnChange();
    }
    getSubMeshForPath(path) {
        return this.subMeshLookup.get(path);
    }
    removeMeshPath(path) {
        if (!this.subMeshLookup.has(path))
            return;
        this.subMeshLookup.delete(path);
        this.notifyOnChange();
    }
    constructor(appObject) {
        super(appObject, Mesh.type);
        this.subMeshLookup = new Map();
        this.hasMeshPath = (path) => {
            return this.subMeshLookup.has(path);
        };
    }
}
Mesh.type = "MESH";
//# sourceMappingURL=Mesh.js.map