-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed as not planned
Labels
Milestone
Description
Is your feature request related to a problem? Please describe.
Let's say I have a custom material that is shared by two meshes. This material uses the inverse transform of the mesh. In this case, I have no way to send the inverse transform because it's dependent from the actual bound mesh.
When creating an app with Three.js, it's not really an issue because we control the flow of data. However, when wrapping Three.js in another library, it makes it somewhat difficult to share a ShaderMaterial whose parameters aren't independent from the camera / mesh drawn.
Describe the solution you'd like
On the top of my mind:
- Create a
onBeforeRendercallback on the material, that would be in charge of updating per-object uniforms. This is similar
to theonBeforeCompilecallback, but called each time something is rendered with this material.
Describe alternatives you've considered
- Use
onBeforeRenderon each meshes. Annoying because all meshes using this material must be updated and a user would need to attach the callback himself - Clone the material for each mesh
Additional context
This is highly related to the issue #16922. I think the problem is similar.