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

[Feature / Help Request] Sharing animation sampler input #195

Open
idea-lei opened this issue Sep 27, 2023 · 2 comments
Open

[Feature / Help Request] Sharing animation sampler input #195

idea-lei opened this issue Sep 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@idea-lei
Copy link

First thx for your excellent work!

I would have a request: since gltf itself supports the sampler input sharing, like if I have an assembly, each part will move along the animation with same time frames (0s, 0.1s, 0.2s...) within one accessor. What would be great is to assign the output to each time frame and share the same time line of the entire animation. Thus we could reduce the file size for models with complex animations.

I could not find such an API in your package, or actually the logic may not support this function. (since CurveBuilder has its own key-value pairs).

Again it would be great if you can tell me where do I find the api for this or if you consider to apply this. But it's no big deal, the current version works also fun.

@vpenades
Copy link
Owner

vpenades commented Sep 28, 2023

Hmm... you're right that the time channel accessors could be reused across multiple animations, but it's a double edge sword, because if you want to edit one of the animations afterwards, you could inadvertently edit -all animations-

But it's true that glTF is not an editable format, but a final format, so it makes sense to optimize it in that way.

I guess I could add something that, when writing the glTF to disk, to look for equivalent accessors and "squeeze" them.

I could look into it, but I don't know when I'll have time to it; I have some other gltf tasks on queue... so I'll leave this issue open.

@idea-lei
Copy link
Author

idea-lei commented Sep 28, 2023

That sounds great, or I could help to make a pr.
But as it may affect the current solution, it could be better if you do it alone or we discuss a solution for this and I can then implement the idea. But since I'm not quite familiar with your code, it would take some time and maybe the code style may not correspond.

Here are some general ideas to achieve this:

  1. As you mentioned, at the writing phase, we loop up the shared inputs and merge them into one array. But this will issue an extra traverse of the structure (or mainly the animation frames of each node relevant to the animation.)
  2. When we create a curve using CurveBuilder, we share the input, like the object pool. This will add some properties to the CurveBuilder and will need state management. (or define a new class? would be cleaner) But Since your interfaces (like IConvertibleCurve) are not supporting this, a solution based on this idea could be difficult / ugly...
  3. Like option 2, we create an object pool and in the AddPoint method we check if the new input is corresponding to the inputs in the pool. When writing to the file we check the marker in the CurveBuilder if there is an input array in the pool and use it as accessor.

There are of course other ideas, maybe you can choose one and then I can help or we can further discuss. (Since I need this function asap, I would like to help, of course)

@vpenades vpenades added the enhancement New feature or request label Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants