-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Track glTF associations for node, material and texture #19359
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
Conversation
b53db68 to
12d942f
Compare
|
Rebased to pick up some upstream changes. |
donmccurdy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This structure looks good to me, and complements the getDependency() API and upcoming plugin API well, I think. Any concerns @takahirox?
examples/jsm/loaders/GLTFLoader.js
Outdated
|
|
||
| assignExtrasToUserData( node, nodeDef ); | ||
|
|
||
| parser.associations.set( node, { type: 'nodes', index: nodeIndex } ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this line seems a bit out of place in the middle of the nodeDef assignments, perhaps move it below the matrix/TRS block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
I'll merge this for now. If @takahirox has any concerns we can address them in other PRs. |
|
Thanks! |
|
@donmccurdy Synced the js file: 475efec |
|
Sorry I didn't notice the review request for a while. Thanks @mrdoob for notifying me. Unfortunately it's very difficult for me to read through the long discussion, but it sounds good to me to provide a way to get a corresponding index in glTF. I haven't thought deeply yet but perhaps it'd be ok for the new extension system. If we see any problems while we will be moving forward the new system, let's discuss then. One minor thing is whether we should clear the association map in |
|
|
|
I agree with clarifying accessibilities (public or private). And making parser.parse(url1).then(gltf => {
...
});
// calling .parse() before completing parsing the first one
// can unexpectedly clears the cache.
parser.parse(url2).then(gltf => {
...
});The new extension system will expose parser instance to extension devs. So I'd like to discuss in the detail about what methods should be public and how we make the others private while we will be moving it forward. And I'd like to hear other devs opinions because this PR is already closed. |
Yeah I realized it complements the plugin system well while I was writing a plugin in which I wanted to find a glTF definition associated with a certain already generated Three.js object. I'm thinking if we can add Mesh associations to the structure. In most cases currently associated gltf.mesh(.primitive) can be found from a Three.js Mesh by first finding a node (Mesh itself or its parents) and an associated glTF node definition, and then getting glTF mesh definition with But sometimes finding would be difficult. For example a glTF node definition has a mesh property and also an extension which produces another mesh. A Three.js Mesh can't be (easily) detected which it is made from What do you think of adding Mesh associations to the structure? |
|
That complexity is why it was omitted I think, yes. Or for another example, would a glTF mesh with 4 primitives mean the associations mapping has 4 THREE.Mesh instances mapped to the same glTF mesh? Or something else? It isn't particularly easy. :/ I'm OK with adding that if we have clear use cases to help us design it usefully. |
|
Then in your example, the four Mesh instances will map to the same glTF mesh but different glTF primitive. A problem, if we add mesh association, is that from {
type: 'nodes',
index: nodeIndex
}to {
node: {
index: nodeIndex
}
}The latter structure can store multiple mappings. Regarding use case, my use case is traverse scenes in And I found another problem of finding associated glTF mesh or primitive from Three.js Mesh. Currently finding them relies on scene graph so if user or plugin changes the graph, the associated glTF mesh or primitive is very difficult to be found. |
This change proposes keeping track of some associations between glTF dependencies and the Three.js instances that are created from them.
The use case addressed by this change is described in more detail in #19257. After discussion with @donmccurdy , it was agreed that we should start with nodes and materials. In pursuing this change, I realized that textures have the same ambiguity case as materials, so I also included textures in this change.
Thank you for considering this change!
Fixes #19257