Improve Attribute Resolution Logic for Non-Three.js Properties #3573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that there was a previous commit which left a TODO regarding this issue:
645410e#diff-861bbdd4c9edaf2af00e9759390a2c40190a4a5c9342272be56751a6533ef323R266
Currently, when using attributes in the
aaa-bbb
format on a node, theresolve
function parses them asroot['aaa']['bbb']
. This works well for nested properties on Three.js objects. However, in certain scenarios, if the attribute provided by the user is not a nested property on a Three.js object, it can lead to exceptions.For example, some libraries that provide React inspector functionality (such as react-dev-inspector) add attributes like
data-inspector-line
ordata-inspector-relative-path
to all nodes at compile time to indicate which source file the element originates from. Although nodes within a Canvas are not actually rendered to the DOM, this can still cause conflicts at runtime.Would a better approach be: for attributes in the
aaa-bbb
format, ifaaa
is indeed a property ofroot
, we proceed with the original logic. Ifaaa
is not a property ofroot
, we simply preserve the original attribute name as is?