Closed andretchen0 closed 2 months ago
Name | Link |
---|---|
Latest commit | c7e111cb0f24e7527bab865bcc1fd00288611ec2 |
Latest deploy log | https://app.netlify.com/sites/tresjs-docs/deploys/6632cb78113cde00084836ac |
Deploy Preview | https://deploy-preview-672--tresjs-docs.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Problem
on*
callbacks – e.g.,onBeforeRender
– are methods on THREE Objects. In plain THREE, these can be overridden by users.Currently in TresJS, a prop like
on-before-render="..."
calls the default function – which does nothing:It should instead set the function.
Solution
Add a predicate in
src/core/nodeOps.ts
where, forprop-name="value"
:prop-name
starts withon
object[propName]
is a functionvalue
is a functionIn this limited case,
value
will replaceobject[propName]
.A unit test and a playground were also added.
Context
This is a more targeted approach than R3F. There's a good chance that this could be absorbed into a more general predicate in a future refactor.
But the predicate is kept tight here to avoid unexpected behavior elsewhere.
Closes #360