25 lines
745 B
TypeScript
25 lines
745 B
TypeScript
|
import { create } from 'zustand';
|
||
|
import { immer } from 'zustand/middleware/immer';
|
||
|
import * as THREE from 'three';
|
||
|
|
||
|
interface SelectedEventSphereState {
|
||
|
selectedEventSphere: THREE.Mesh | null;
|
||
|
setSelectedEventSphere: (mesh: THREE.Mesh | null) => void;
|
||
|
clearSelectedEventSphere: () => void;
|
||
|
}
|
||
|
|
||
|
export const useSelectedEventSphere = create<SelectedEventSphereState>()(
|
||
|
immer((set) => ({
|
||
|
selectedEventSphere: null,
|
||
|
setSelectedEventSphere: (mesh) => {
|
||
|
set((state) => {
|
||
|
state.selectedEventSphere = mesh;
|
||
|
});
|
||
|
},
|
||
|
clearSelectedEventSphere: () => {
|
||
|
set((state) => {
|
||
|
state.selectedEventSphere = null;
|
||
|
});
|
||
|
},
|
||
|
}))
|
||
|
);
|