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

useTexture does not work in child components #877

Closed
AndreasFaust opened this issue Dec 1, 2024 · 5 comments
Closed

useTexture does not work in child components #877

AndreasFaust opened this issue Dec 1, 2024 · 5 comments

Comments

@AndreasFaust
Copy link

AndreasFaust commented Dec 1, 2024

Describe the bug

When I use useTexture in the same component as TresCanvas, it works fine.
When I put the same configuration in a child component, it stops working without throwing an error.
The whole child component is not rendered.

Is this a bug or am I doing something wrong?

Reproduction

https://stackblitz.com/edit/nuxt-starter-f4k5xz?file=README.md

@AndreasFaust
Copy link
Author

It seems to successfully load the texture, but then something goes wrong.

@andretchen0
Copy link
Contributor

Hey @AndreasFaust ,

useTexture returns a Promise, which is awaited in ChildComponent. You'll need to wrap ChildComponent in a <Suspense />.

@andretchen0
Copy link
Contributor

Closing as done.

Here's the working StackBlitz:

https://stackblitz.com/edit/nuxt-starter-6gmpkp?file=components%2FScene.vue

Feel free to reopen if there's still a problem.

@andretchen0
Copy link
Contributor

Closing as "won't fix".

Here's the working StackBlitz:

https://stackblitz.com/edit/nuxt-starter-6gmpkp?file=components%2FScene.vue

Feel free to reopen if there's still a problem.

@andretchen0 andretchen0 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2024
@AndreasFaust
Copy link
Author

Thank you so much!

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

2 participants