mylingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
21 lines • 927 B
JavaScript
import { event } from "@lincode/events";
import { createEffect } from "@lincode/reactivity";
import { debounce } from "@lincode/utils";
import { getSelectionLocked } from "../states/useSelectionLocked";
import { getSelectionTarget } from "../states/useSelectionTarget";
import { onSceneGraphChange } from "./onSceneGraphChange";
const [_emitSelectionTarget, onSelectionTarget] = event();
export { onSelectionTarget };
export const emitSelectionTarget = debounce((target, rightClick) => !getSelectionLocked() && _emitSelectionTarget({ target, rightClick }), 0, "trailing");
createEffect(() => {
const target = getSelectionTarget();
if (!target)
return;
const handle = onSceneGraphChange(() => {
!target.outerObject3d.parent && emitSelectionTarget();
});
return () => {
handle.cancel();
};
}, [getSelectionTarget]);
//# sourceMappingURL=onSelectionTarget.js.map