import { makeAppObjectRepo } from "@vived/core";
import { Vector3 } from "@vived/core";
import { makeStickableEntity } from "../../Stick/Entities/Stickable";
import { Transform3D } from "../../Transform3D/Entities/Transform3D";
import { makeChannelModelEntity } from "../Entities";
import { makeModelObjectsAreStickablePM } from "./ModelObjectsAreStickablePM";
function makeTestRig() {
    const appObjects = makeAppObjectRepo();
    const appObj = appObjects.getOrCreate("appObj");
    const ao = appObjects.getOrCreate("ChannelModel");
    const channelModel = makeChannelModelEntity(ao);
    const pm = makeModelObjectsAreStickablePM(ao);
    const modelObject1 = channelModel.addModelObject("modelId1");
    const modelObject2 = channelModel.addModelObject("modelId2");
    const sm1Transform = Transform3D.addIfMissing(modelObject1.appObject);
    const sm2Transform = Transform3D.addIfMissing(modelObject2.appObject);
    makeStickableEntity(modelObject1.appObject);
    makeStickableEntity(modelObject2.appObject);
    sm1Transform.addChangeObserver(modelObject1.notifyOnChange);
    sm2Transform.addChangeObserver(modelObject2.notifyOnChange);
    return { appObj, appObjects, pm, sm1Transform, sm2Transform };
}
describe("Model Objects are are stickable PM", () => {
    it("Sets the last vm on construction", () => {
        const { pm } = makeTestRig();
        expect(pm.lastVM).not.toBeUndefined();
    });
    it("Updates the view when a dissectable mesh changes it's position", () => {
        const { pm, sm1Transform } = makeTestRig();
        expect(pm.lastVM).toEqual(false);
        sm1Transform.localPosition = new Vector3(1, 2, 3);
        expect(pm.lastVM).toEqual(true);
    });
    it("Compares the VMs", () => {
        const { pm } = makeTestRig();
        expect(pm.vmsAreEqual(true, true)).toEqual(true);
        expect(pm.vmsAreEqual(false, false)).toEqual(true);
        expect(pm.vmsAreEqual(false, true)).toEqual(false);
        expect(pm.vmsAreEqual(true, false)).toEqual(false);
    });
});
//# sourceMappingURL=ModelObjectsAreStickablePM.test.js.map