Skip to content
Discussion options

You must be logged in to vote

You can use the index of the instanced body to refer to it in the API:

const NUMBER_OF_BOXES = 10
const BODY_INDEX = 4

const [ref, api] = useBox(() => ({
  mass: 1,
  args: [0.05, 0.05, 0.05],
  position: [Math.random() - 0.5, Math.random() * 2, Math.random() - 0.5],
}))

useFrame(() => api.at(BODY_INDEX).position.set(1, 1, 1))

return (
  <instancedMesh ref={ref} args={[null, null, NUMBER_OF_BOXES]}>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nedcrow
Comment options

Answer selected by codynova
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants