Skip to content
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

Import Animation .glb files to existing GLTF model? #450

Open
marcspraragen opened this issue Jun 13, 2019 · 9 comments
Open

Import Animation .glb files to existing GLTF model? #450

marcspraragen opened this issue Jun 13, 2019 · 9 comments
Assignees

Comments

@marcspraragen
Copy link

I'm wondering if there is support and/or sample scenes for importing separate animation .glb files at runtime and applying them to an existing GLTF model component in the scene?
Thanks!

@anupamdas2012
Copy link

hey, lol. saw you over at the TriLib forums. Guessing you gave up on it? :) Have you been able to get this GLTF loader working on android by any chance? Im having zero luck.

@marcspraragen
Copy link
Author

Hey, there doesn't seem to be a sample to work from but I'm still experimenting. :)

@AdamMitchell-ms
Copy link
Contributor

Hi @marcspraragen,

This isn't something that is built in, but I think you should be able to accomplish it with UnityGLTF. If you load scene in a glb which contains a mesh that has an animation attached to it, then it will load as a Unity animation. Then should be able to copy that animation onto another mesh.

@marcspraragen
Copy link
Author

Thanks Adam! The other possibility I was looking for applying an animation was merging a model .gltf with a model-less animation .gltf at runtime. Does (or could, with some tweaking) RootMergeComponent script cover this case?

@AdamMitchell-ms
Copy link
Contributor

This is not possible right now. Side note, are these valid gltfs?
Looking at the spec, animation channel targets must specify a node. And I think that node needs to be in the same gltf to be valid.
https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#channel
https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#animations

That aside, if you wanted to accomplish this, then you'd need to:

  • Make GLTFSceneImporter.ConstructClip public or expose a public function that calls it.
  • Come up with some way to retarget the animation's referenced nodes to the nodes from another file.
    • See the call to GetNode() inside ConstructClip(). Maybe have ConstructClip take in a function to get a node given a node id. By default it will call GetNode() as it does now.

If you do the work to enable something like this, please send a pull request to get it into master branch so others can benefit from it.

@marcspraragen
Copy link
Author

Thanks for your reply! I will definitely share any successful updates.

@marcspraragen
Copy link
Author

marcspraragen commented Jan 15, 2020

Any updates on this capability? We have worked around it by leaving all animations in one file per the spec

@nipundavid
Copy link

nipundavid commented Jun 3, 2020

Oh finally, someone has tried on what I am stuck for a week now. So the case is the same as me. I want to apply an animation from one GLTF file to another. I don't want to bloat my main mesh while loading the main scene.

Any update on this issue? @marcspraragen
Screenshot of my files below (will give a better perspective)
issue

I can do this same in the Sandbox provided by BabylonJS, if they can do it I am sure there would be something that I have missed.

Link - https://drive.google.com/file/d/1VV9CeVitHk31aZ71ejI9-FZdRwDgGDu1/view?usp=sharing

@marcspraragen
Copy link
Author

We tried quite a bit to transplant / construct animated clips between imported scenes and their nodes, but it ended up being unreliable. Also, it's hard to test because even though UnityGLTF is open source, GLTF spec is too much of a black box (I'm guessing that factor has stumped many other efforts here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants