import { create } from "zustand";
import { immer } from "zustand/middleware/immer";
import * as THREE from "three";

type SceneStore = {
    camState: {
        position: THREE.Vector3;
        target: THREE.Vector3;
    };
    setCamera: (pos: THREE.Vector3, target: THREE.Vector3) => void;
};

export const useSceneStore = create<SceneStore>()(
    immer((set) => ({
        camState: {
            position: new THREE.Vector3(0, 5, 10),
            target: new THREE.Vector3(0, 0, 0),
        },

        setCamera: (pos, target) =>
            set((state) => {
                state.camState.position.copy(pos);

                state.camState.target.copy(target);
            }),
    }))
);
