actions reactored. multi-tick action support
This commit is contained in:
@@ -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>) {
|
||||
|
||||
Reference in New Issue
Block a user