import { watch as s } from "vue";
import { cloneDeep as a, isEqual as r } from "lodash";
import { Vector3 as o } from "@babylonjs/core";
const h = (u, d, t, m, c) => {
  s(
    () => a(u.option.scene),
    (e, i) => {
      !r(e, i) && t && t.value.updateScene(e);
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.skybox),
    (e, i) => {
      r(e, i) || t.value.setSkybox();
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.meshs.url),
    (e, i) => {
      !r(e, i) && t && (t.value.dispose(), t.value = new m(
        c.value,
        u.option,
        u.useEvents
      ).run());
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.meshs.position),
    (e, i) => {
      !r(e, i) && t && t.value.gs && t.value.gs.position.set(e[0], e[1], e[2]);
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.meshs.scaling),
    (e, i) => {
      !r(e, i) && t && t.value.gs && t.value.gs.scaling.set(e[0], e[1], e[2]);
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.meshs.rotation),
    (e, i) => {
      !r(e, i) && t && t.value.gs && (t.value.gs.rotation = new o(e[0], e[1], e[2]));
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.camera),
    (e, i) => {
      !r(e, i) && t && t.value.updateCamera(e);
    },
    {
      deep: !0
    }
  ), s(
    () => a(u.option.camera.autoRadius),
    (e, i) => {
      !r(e, i) && t && t.value.createCamera(u.option.camera, t.value.scene);
    },
    {
      deep: !0
    }
  );
};
export {
  h as useWatch
};
