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

UniformUtils does not set needsUpdate to true for Texture uniforms #23572

Closed
FarazzShaikh opened this issue Feb 23, 2022 · 2 comments
Closed

Comments

@FarazzShaikh
Copy link
Contributor

Describe the bug

As explained by the docs, when a texture is cloned, the needsUpdate flag must be set to true. Else, the texture appears black.

UnifromUtils.clone and by extension, UnifromUtils.merge, do not set this flag even though they clone Texture and other uniform types.

dst[ u ][ p ] = property.clone();

Easy fix, will PR in the morning if this is indeed a bug and not intended.

To Reproduce

  1. Create a unifrom object with a texture property
  2. Clone the unifrom
  3. Use cloned unifrom, the texture will appear black.

Code

// Works
material.uniforms.u_map.value = texture;

// Doesnt work (texture is black)
const clonedUifroms = UniformsUtils.clone(material.uniforms);
material.uniforms.u_map.value = clonedUifroms.u_map.value;

// To fix
material.uniforms.u_map.value.needsUpdate = true;

Live example

CodeSandbox

Expected behavior

The "To fix" line shouldn't be required, UniformsUtils.clone should set needsUpdate automatically.

Platform:

  • Device: [Desktop]
  • OS: [Windows]
  • Browser: [Chrome]
  • Three.js version: [0.138.0]
@WestLangley
Copy link
Collaborator

See #22718 (comment)

@FarazzShaikh
Copy link
Contributor Author

Fair enough, cheers!

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