adds shortcut for anchoring

This commit is contained in:
bhushan6
2023-08-15 03:50:43 +05:30
parent aa84c597dd
commit ea14c48ef5
2 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ export const Scene = () => {
const room = useStore((state) => state.liveblocks.room);
const self = useStore((state) => state.self);
// useAnchorShorcuts(anchorX, anchorZ, set);
useAnchorShorcuts();
const addBrick = (e) => {
e.stopPropagation();
+9 -5
View File
@@ -1,20 +1,24 @@
import useKeyboardShortcut from "use-keyboard-shortcut";
import { useStore } from "../store";
export const useAnchorShorcuts = () => {
const setAnchorX = useStore((state) => state.setAnchorX);
const setAnchorZ = useStore((state) => state.setAnchorZ);
export const useAnchorShorcuts = (anchorX, anchorZ, set) => {
const anchorXPlus = () => {
set({ anchorX: anchorX + 1 });
setAnchorX(useStore.getState().anchorX + 1);
};
const anchorXMinus = () => {
set({ anchorX: anchorX - 1 });
setAnchorX(useStore.getState().anchorX - 1);
};
const anchorZPlus = () => {
set({ anchorZ: anchorZ - 1 });
setAnchorZ(useStore.getState().anchorZ + 1);
};
const anchorZMinus = () => {
set({ anchorZ: anchorZ + 1 });
setAnchorZ(useStore.getState().anchorZ - 1);
};
useKeyboardShortcut(["D"], anchorXPlus, {