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

Clip.fromThree() to create Clip from Three.js AnimationClip #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ArsenicBismuth
Copy link

@ArsenicBismuth ArsenicBismuth commented Aug 21, 2023

Just a simple utility to add more method to create ossos.Clip(), need the armature of the source model to get the bone mapping data.

@ArsenicBismuth ArsenicBismuth changed the title Clip.fromThree() to convert from Three.js clip Clip.fromThree() to create Clip from Three.js AnimationClip Aug 21, 2023
@trusktr
Copy link

trusktr commented Apr 25, 2024

This is a great idea. If Clip/etc will be library agnostic though, it may need to be in a separate utility though, f.e. ThreeClipUtils.fromThree(threeAnimClip) would return a Clip. Otherwise, we'd also have to add the method for Babylon in the same class, and for Playcanvas, etc, coupling all libraries together (import Clip and you get all the rendering libraries, massive download).

let track : ITrack; // Animator Track
for ( const t of anim.tracks ) {

switch ( t.constructor.name ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encountered issues with the minified bundle when using constructor.name, as the bundler sometimes changes object names, leading to crashes. A possible solution is to adjust the bundler settings and use Terser. However, if there's a way to avoid relying on constructor.name, it might prevent this issue. Just wanted to share in case it's helpful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The safest solution I think might be to use instanceof conditions. There is only two Track types in ossos but more in 3js. Something it should be easy to just do

if( t instanceof VectorKeyframeTrack ) track = new Vec3Track();
else if( t instanceof QuaternionKeyframeTrack ) track = new QuatTrack();
else continue;

I've rebuilt the animation system for the next version of ossos, So there are big changes in alot of places.
https://github.com/sketchpunklabs/ossos/tree/ossos_next

@sketchpunk
Copy link
Contributor

No engine specific things will be built into the library as one of the goals is to be engine agnostic. Like 3js, lots of the extra bits will be in an example folder or maybe some sort sub engine specific utility library people can use.

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.

4 participants