Spacetime-Meta / spacetime-sdk

The spacetime-sdk is a turnkey virtual environment package for building in the Spacetime Metaverse
https://www.spacetimemeta.io/metaverse/spawn-planet
MIT License
11 stars 2 forks source link

Separate avatar and animation loading logic #47

Closed Liquid-Blocks closed 2 years ago

Liquid-Blocks commented 2 years ago

In the AvatarController, the avatar loading is nested inside the animation loading logic. This implementation makes it quite difficult to manipulate the animations and allow custom animations.

We want the avatar loading and the animation loading to be separate methods:

This implementation will allow more granular control on the animations down the line. In the next phase, all we need to do for custom animations, is create access methods to the AvatarController.animations object.

Image

Image

codeeMadness commented 2 years ago

Hi @Liquid-Blocks,

So basically we will create these methods as below:

Is that correct?

Liquid-Blocks commented 2 years ago

Yes that is correct, sorry for the slow response

codeeMadness commented 2 years ago

Hi @Liquid-Blocks,

While implementing, I notice that animation loading must use object.scene which comes from avatar loading callback. Is it fine if I call animation loading inside avatar loading callback?

Liquid-Blocks commented 2 years ago

Hi @codeeMadness, that is a good question, I think the best would be to save the loading result in a class attribute and try to pass the Object.scene as an argument of the animation loading so that it can be its own independent method.

codeeMadness commented 2 years ago

Hi @Liquid-Blocks , Your suggestion is fine. However, the callback in loading avatar usually called after animations loading, I also tried with Promise, but it always load animation first. I guess they both run the callback, so these process will run in synchronize way.

OK, so this is my implementation so far: image

Liquid-Blocks commented 2 years ago

It could stay like this for now since we don't have any case where it is pertinent to load an avatar without the animations.

We can do further experimentation with the callbacks when the need arises

codeeMadness commented 2 years ago

Hi @Liquid-Blocks , I have changed a little bit. We will pass animation loading as a callback for avatar loading. So we can load avatar with or without animations and otherwise. Please take a look at PR and you can see.

Liquid-Blocks commented 2 years ago

branch was merged