Skip to content

Latest commit

 

History

History
43 lines (38 loc) · 1.01 KB

merged.mdx

File metadata and controls

43 lines (38 loc) · 1.01 KB
title
Merged
  • This creates instances for existing meshes and allows you to use them cheaply in the same scene graph. Each type will cost you exactly one draw call, no matter how many you use. meshes has to be a collection of pre-existing THREE.Mesh objects.

    <Merged meshes={[box, sphere]}>
      {(Box, Sphere) => (
        <>
          <Box position={[-2, -2, 0]} color="red" />
          <Box position={[-3, -3, 0]} color="tomato" />
          <Sphere scale={0.7} position={[2, 1, 0]} color="green" />
          <Sphere scale={0.7} position={[3, 2, 0]} color="teal" />
        </>
      )}
    </Merged>

    You may also use object notation, which is good for loaded models.

    function Model({ url }) {
      const { nodes } = useGLTF(url)
      return (
        <Merged meshes={nodes}>
          {({ Screw, Filter, Pipe }) => (
            <>
              <Screw />
              <Filter position={[1, 2, 3]} />
              <Pipe position={[4, 5, 6]} />
            </>
          )}
        </Merged>
      )
    }