use-cannon icon indicating copy to clipboard operation
use-cannon copied to clipboard

Add scaleOverride to useBody props

Open krispya opened this issue 2 years ago • 3 comments

Makes it so you can specifyscaleOverride in the uesBody props. Since most use cases I have for this initialize the scale on mount and then don't touch it, this method ends up being more compact and also lets me use the same scale factor in the body easily. For example:

const [ref, { at }] = useBox(() => {
    const scale = randomInRange(0.65, 1.2)
    return {
      args: [size * scale, size * scale, size * scale],
      mass: 1,
      position: [Math.random() - 0.5, Math.random() * 2, Math.random() - 0.5],
      scaleOverride: [scale, scale, scale],
    }
  })

krispya avatar Apr 17 '22 07:04 krispya

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
use-cannon ✅ Ready (Inspect) Visit Preview Apr 18, 2022 at 2:58AM (UTC)

vercel[bot] avatar Apr 17 '22 07:04 vercel[bot]

I realized I was putting the type in the wrong place. I moved it to the hook and out of the worker.

krispya avatar Apr 18 '22 03:04 krispya

Please resolve merge conflicts.

Also, this doesn't work because the scaleOverride is not being passed to useBody.

bjornstar avatar May 03 '22 14:05 bjornstar