-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
GLTFLoader: Callback for when asset was read #12761
Conversation
Currently there is absolutely no possibility to access the asset property from the loaded GLTF. This here is one idea how it could look like. It is similar like "onAfterRender" etc where the developer just have to hook on the function to get the value. Opinions regarding naming etc are welcome. Also should we rather call this callback right after checking for the supported version or before? The downside of the current code is that your callback won't be called if the GLTF version isn't supported, but then you normally won't have any need for the information in ```assets```...
An other possibility (and probably the better) is to put the parser.parse( function ( scene, scenes, cameras, animations, asset ) { // also set 'asset'
console.timeEnd( 'GLTFLoader' );
var glTF = {
scene: scene,
scenes: scenes,
cameras: cameras,
animations: animations,
asset: asset // this line is new
};
onLoad( glTF );
}, onError ); |
Voting for |
Curious why this is needed? We're hoping to make the loader more extensible in the future; see #11682; I imagine we would revert this change when that happens.. Of the two approaches I do prefer including a property on the returned object, though. |
thinking more about it, I'm happy with the |
@donmccurdy |
@cnspaha there has been an upstream change, could you rebase this branch? |
# Conflicts: # examples/js/loaders/GLTFLoader.js
@donmccurdy |
No problem, this looks good. 👍 |
var cameras = dependencies.cameras || []; | ||
|
||
onLoad( scene, scenes, cameras, animations ); | ||
onLoad( scene, scenes, cameras, animations, asset ); |
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.
What about passing json
directly?
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.
would be possible of course, but then we would pass the whole GLTF data back.
In my opinion this is a bit of overkill so I would stick with the asset
. Or are there any other values in the GLTF which would be good to know as caller of the loader? I am not so familiar with the structure of the GLTF format
I see. Well, if @donmccurdy is cool with this I'm cool with this 😊 |
Thanks! |
This might be worth considering; added a comment on #11682 to revisit later. |
Currently there is absolutely no possibility to access the asset property from the loaded GLTF.
This here is one idea how it could look like. It is similar like "onAfterRender" etc where the developer just have to hook on the function to get the value.
Opinions regarding naming etc are welcome.
Also should we rather call this callback right after checking for the supported version or before? The downside of the current code is that your callback won't be called if the GLTF version isn't supported, but then you normally won't have any need for the information in ```assets``...