Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make output clonable by default? #200

Open
wiredmatt opened this issue May 27, 2023 · 0 comments
Open

Make output clonable by default? #200

wiredmatt opened this issue May 27, 2023 · 0 comments

Comments

@wiredmatt
Copy link

wiredmatt commented May 27, 2023

Maybe I'm missing something but by using the generated JSX as is you can't create multiple instances of the same model.

This will just pick the last and render that one (the one with key 3), but not the others:

export const ModelViewer = () => {
  return (
    <>
      <OrbitControls />
      <group>
        {[1, 2, 3].map((i) => (
          <MyModel key={i} position={[i, i, i]} />
        ))}
      </group>
    </>
  );
};

Could be fixed by just changing these lines in the generated file:

const group = useRef<THREE.Group>();
  const { materials, animations, scene } = useGLTF(
    "/mymodel.glb"
  ) as GLTFResult;

const clone = useMemo(() => SkeletonUtils.clone(scene), [scene]);
const { nodes } = useGraph(clone) as GLTFResult;

I don't know if this wasn't included for some reason, but shouldn't it be a built-in option in the CLI?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant