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

Animations: storing key frames in typed arrays #13434

Closed
wants to merge 1 commit into from

Conversation

myfreeer
Copy link
Contributor

Keyframes in Babylon.js are stored with array of objects. Some animations exported with millions of key frames, with the object mode, it would take more memory than stored with typed arrays, like Float32Array.
Without the object per frame, it would be much harder for features like per-frame interpolation and tangent to be implemented, so this could be an optional feature for those suffering too many keyframes without these advanced features.
For AnimationCurveEditor it is hard to fully adapt it to CompactAnimation, maybe the fast way it to convert CompactAnimation to Animation, and replace all possible usage to converted animation.

Not supported yet:

  • CUBICSPLINE animation with tangent
  • per-frame interpolation or tangent
  • serializing GLTF animation with quantization and 4-bytes alignment

Forum link:
https://forum.babylonjs.com/t/animations-storing-key-frames-in-typed-arrays/36566

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2023

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2023

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13434/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2023

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13434/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 16, 2023

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13434/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 16, 2023

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13434/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@Popov72
Copy link
Contributor

Popov72 commented Jan 16, 2023

It's quite a mammoth PR!

I'm not really proficient with the animation system of Babylon.js, so I'm not sure I can help a lot on the structural/architectural review side... However, I can always review the code itself!

Also, I think our animation system will possibly(/probably?) undergo some changes in the next weeks or months, so I wonder if it's the right time for such a big update to the system...

cc @bghgary, @sebavan, @deltakosh, @RaananW

@RaananW
Copy link
Member

RaananW commented Jan 16, 2023

Wow!
Thank you so much for all the work.
It will take me some time to review everything. I didn't follow the topic on the forum, in the entire context there?

From quickly browsing the changes, it seems like some changes were made to central processes like the gltf loading process. are there any breaking changes here?

@sebavan sebavan marked this pull request as draft January 16, 2023 19:45
@sebavan
Copy link
Member

sebavan commented Jan 16, 2023

Let me convert as a draft during the discussions to prevent any accidental merges

@myfreeer
Copy link
Contributor Author

From quickly browsing the changes, it seems like some changes were made to central processes like the gltf loading process. are there any breaking changes here?

In gltf loader, a flag _preferCompactAnimations is added to control whether to prefer CompactAnimation over Animation on parsing GLTF animations, so users can choose to have less memory usage or maximum compatiblity.

@myfreeer myfreeer force-pushed the compact-animation branch 2 times, most recently from f23ac1e to 53de25e Compare January 29, 2023 13:13
@bjsplat
Copy link
Collaborator

bjsplat commented Jan 29, 2023

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13434/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

Keyframes in Babylon.js are stored with array of objects. Some animations exported with millions of key frames, with the object mode, it would take more memory than stored with typed arrays, like Float32Array.
Without the object per frame, it would be much harder for features like per-frame interpolation and tangent to be implemented, so this could be an optional feature for those suffering too many keyframes without these advanced features.
For AnimationCurveEditor it is hard to fully adapt it to CompactAnimation, maybe the fast way it to convert CompactAnimation to Animation, and replace all possible usage to converted animation.

Not supported yet:
* CUBICSPLINE animation with tangent
* per-frame interpolation or tangent
* serializing GLTF animation with quantization and 4-bytes alignment

Forum link:
https://forum.babylonjs.com/t/animations-storing-key-frames-in-typed-arrays/36566
@sebavan
Copy link
Member

sebavan commented Feb 13, 2023

Long overdue update. @myfreeer you can not imagine how many discussions you helped us having in the core team regarding this topic :-) and this is for the best !!!

Basically, we would like to use a system similar to what you are proposing here for our overall animation system :-) Unfortunately, we are too close to our 6.0 release to integrate those changes now and we would like them to be fully back compatible and working with all our feature set.

What I propose is to close this PR and let @Popov72 integrate your changes as part of a broader revamp starting as soon as 6.0 will be released (in a couple months).

You can track the issue here: #13534

Big thanks for the great contribution and sorry again we can not integrate immediately, hope it does not disrupt your plans too much.

@sebavan sebavan closed this Feb 13, 2023
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

Successfully merging this pull request may close these issues.

None yet

5 participants