react-three-fiber icon indicating copy to clipboard operation
react-three-fiber copied to clipboard

Support translation of geometries

Open kwyntes opened this issue 1 year ago • 0 comments

Right now to translate a geometry we need to take a ref and call the translate function in a useEffect hook.

I'd like to be able to apply a translation through JSX directly.

// now
const ref = useRef<PlaneGeometry>(null!)
useEffect(() => {
  ref.current.translate(sz / 2, -sz / 2, 0)
}, [])

return (
  <mesh>
    <planeGeometry args={[sz, sz]} ref={ref} />
    {/* ... */}
  </mesh>
);

// proposal
return (
  <mesh>
    <planeGeometry args={[sz, sz]} translation={[sz / 2, -sz / 2, 0]} />
    {/* ... */}
  </mesh>
)

kwyntes avatar Feb 16 '24 14:02 kwyntes