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(..., onLoad) callback receives incorrect values #1969

Open
jwueller opened this issue May 30, 2024 · 0 comments · May be fixed by #1970
Open

useTexture(..., onLoad) callback receives incorrect values #1969

jwueller opened this issue May 30, 2024 · 0 comments · May be fixed by #1970
Labels
bug Something isn't working

Comments

@jwueller
Copy link

  • three version: 0.164.1
  • @react-three/fiber version: 8.16.6
  • @react-three/drei version: 9.105.6
  • node version: v22.2.0
  • npm (or yarn) version: 1.22.22

Problem description:

The types declare that the callback receives the same type that's returned from the hook itself. However, that's not the case, and it will never receive a record object.

Relevant code:

const returnedTextures = useTexture(
    {map: 'color.jpg', normalMap: 'normal.png'},
    (callbackTextures) => {
        // callbackTextures can never be an object here, and always produces and
        // array, as opposed to returnedTextures, which correctly adheres to the
        // declared type.
    },
);

Suggested solution:

Fix the callback to adhere to the declared type. I will provide a PR for this.

@jwueller jwueller added the bug Something isn't working label May 30, 2024
@jwueller jwueller changed the title useTexture(..., onLoad callback receives incorrect values useTexture(..., onLoad) callback receives incorrect values May 30, 2024
jwueller added a commit to jwueller/drei that referenced this issue May 30, 2024
@jwueller jwueller linked a pull request May 30, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant