"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TexturalEnvironmentPM = void 0;
exports.makeTexturalEnvironmentPM = makeTexturalEnvironmentPM;
const core_1 = require("@vived/core");
const Environment_1 = require("../Entities/Environment");
class TexturalEnvironmentPM extends core_1.AppObjectPM {
}
exports.TexturalEnvironmentPM = TexturalEnvironmentPM;
TexturalEnvironmentPM.type = "TexturalEnvironmentPM";
TexturalEnvironmentPM.get = (appObjects) => (0, core_1.getSingletonComponent)(TexturalEnvironmentPM.type, appObjects);
function makeTexturalEnvironmentPM(appObject) {
    return new TexturalEnvironmentPMImp(appObject);
}
class TexturalEnvironmentPMImp extends TexturalEnvironmentPM {
    vmsAreEqual(a, b) {
        return a === b;
    }
    get entity() {
        return this.getCachedSingleton(Environment_1.EnvironmentEntity.type);
    }
    constructor(appObject) {
        super(appObject, TexturalEnvironmentPM.type);
        this.onEntityChange = () => {
            if (!this.entity)
                return;
            this.doUpdateView(this.entity.currentEnvironment);
        };
        this.entity?.addChangeObserver(this.onEntityChange);
        this.onEntityChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=TexturalEnvironmentPM.js.map