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

Changing a <Material />'s key prop doesn't attach new material, remove old one #615

Open
5 tasks done
andretchen0 opened this issue Apr 1, 2024 · 0 comments
Open
5 tasks done
Labels
p2-to-be-discussed Enhancement under consideration (priority) pending-triage Ticket is pending to be prioritised

Comments

@andretchen0
Copy link
Contributor

andretchen0 commented Apr 1, 2024

Expected

In this <template /> ...

<template>
  <TresCanvas>
    <TresMesh>
      ... 
      <MyMaterial :prop="myProp" />
    </TresMesh>
  </TresCanvas>
</template>

... if changing :prop changes the material :key:

  • the existing material should be removed from the parent.
  • the rerendered material should be attached to the parent.

Bug

  • The existing material is not removed from the parent.
  • The new material is not attached to the parent.

What happens instead

  • The existing material remains on the parent.
  • A new material is created.
  • The new material is not attached.

Changing the :prop again leads to:

  • The new material is disposed.
  • Another new material is created.

Context

Working on updating MeshReflectionMaterial from Cientos. It's based on this Drei component.

Both components use the key prop to force a rerender/recompile. Drei | Cientos

Using the key to force rerendering/recompiling currently doesn't work in the Cientos component.

Rerendering/recompiling the material's shader is required here for full reactivity.

Reproduction

https://stackblitz.com/edit/tresjs-basic-a7wxyh?file=src%2Fcomponents%2FTheExperience.vue

Steps to reproduce

See Stackblitz.

System Info

all platforms

Used Package Manager

npm

Code of Conduct

@andretchen0 andretchen0 changed the title Changing a <Material />'s key prop doesn't attach new material or remove/dispose old one Changing a <Material />'s key prop doesn't attach new material, remove old one Apr 1, 2024
@alvarosabu alvarosabu added pending-triage Ticket is pending to be prioritised p2-to-be-discussed Enhancement under consideration (priority) labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-to-be-discussed Enhancement under consideration (priority) pending-triage Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

2 participants