When I use useRef
for access a mesh, I can change its position as this:
const [boxRef] = useRef();
...
boxRef.current.position.setX(boxRef.current.position.x + 1);
And it works! But when I use useBox
from Cannon.js to give it a physic, it doesn't:
const [boxRef] = useBox(() => ({
mass: 1,
position: [0, 4, 0],
velocity: [0, 1, 0],
}));
...
boxRef.current.position.setX(boxRef.current.position.x + 1);
Use the second argument of
useBox
: