actions reactored. multi-tick action support

This commit is contained in:
azykov@mail.ru
2026-06-12 11:46:42 +03:00
parent 36f76efdd7
commit 20a4edad5a
35 changed files with 1047 additions and 373 deletions
@@ -61,24 +61,11 @@ export const ObjectViewInternal = function ({ object, objectType, ref, ...props
useEffect(
() => {
return reaction(
() => gameObj.pendingActions.impulse,
(impulse) => {
if (!impulse || !rbRef.current)
return;
// eslint-disable-next-line prefer-const
let { direction, amplitude } = impulse;
amplitude *= 100;
const v = { x: direction[0] * amplitude, y: direction[1] * amplitude, z: direction[2] * amplitude };
rbRef.current.applyImpulse(v, true);
runInAction(() => {
gameObj.pendingActions.impulse = undefined;
});
},
);
runInAction(() => { gameObj.rb = () => rbRef.current; });
return () => { runInAction(() => { gameObj.rb = () => null; }); };
},
[gameObj.pendingActions, object.id]
// eslint-disable-next-line react-hooks/exhaustive-deps
[object.id],
);
function handleClick(e: ThreeEvent<MouseEvent>) {