"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GlbModelEntity = exports.GlbModelState = void 0;
exports.makeGlbModelEntity = makeGlbModelEntity;
const core_1 = require("@vived/core");
var GlbModelState;
(function (GlbModelState) {
    GlbModelState["INIT"] = "Initialized";
    GlbModelState["LOADING"] = "Loading";
    GlbModelState["READY"] = "Ready";
    GlbModelState["ERROR"] = "Error";
})(GlbModelState || (exports.GlbModelState = GlbModelState = {}));
class GlbModelEntity extends core_1.AppObjectEntity {
}
exports.GlbModelEntity = GlbModelEntity;
GlbModelEntity.type = "GlbModelEntity";
function makeGlbModelEntity(appObject) {
    return new GlbModelEntityImp(appObject);
}
class GlbModelEntityImp extends GlbModelEntity {
    get id() {
        return this.appObject.id;
    }
    get state() {
        return this._state.val;
    }
    set state(val) {
        this._state.val = val;
    }
    get modelError() {
        return this._error;
    }
    set modelError(val) {
        this._error = val;
        this._state.val = GlbModelState.ERROR;
    }
    constructor(appObject) {
        super(appObject, GlbModelEntity.type);
        this._state = new core_1.MemoizedString(GlbModelState.INIT, this.notifyOnChange);
        this.meshLookup = new Map();
        this.hasMesh = (id) => {
            return this.meshLookup.has(id);
        };
        this.getMesh = (path) => {
            return this.meshLookup.get(path);
        };
        this.addMesh = (mesh) => {
            this.meshLookup.set(mesh.path, mesh);
            this.notifyOnChange();
        };
        this.getAllMeshes = () => {
            return Array.from(this.meshLookup.values());
        };
    }
}
//# sourceMappingURL=GlbModelEntity.js.map