Filament: .glb animation

Created on 17 Dec 2020  路  2Comments  路  Source: google/filament

Hello!

I ran example for c++ - "gltf_viewer", I can see my model, and if the model has animation, it starts automatically and it works fine.

I鈥檓 trying to do the same without using FilamentApp, that's possible, right?

I can load the model, but I can鈥檛 run the animation, how can I do that?

maybe exist some instruction/guide or another example?

Most helpful comment

The following is an example of the JavaScript API for your reference.
https://github.com/google/filament/blob/main/web/samples/animation.html#L75-L79

if (this.animator) {
    const ms = Date.now() - this.animationStartTime;
    this.animator.applyAnimation(0, ms / 1000);
    this.animator.updateBoneMatrices();
}

If you have multiple animations included, the following may be helpful.
https://github.com/cx20/gltf-test/blob/master/examples/filament/index.js#L163-L166

if (this.animator) {
    const ms = Date.now() - this.animationStartTime;
    for (let i = 0; i < this.asset.getAnimator().getAnimationCount(); i++ ) {
        this.animator.applyAnimation(i, ms / 1000);
        this.animator.updateBoneMatrices();
    }
}

All 2 comments

The following is an example of the JavaScript API for your reference.
https://github.com/google/filament/blob/main/web/samples/animation.html#L75-L79

if (this.animator) {
    const ms = Date.now() - this.animationStartTime;
    this.animator.applyAnimation(0, ms / 1000);
    this.animator.updateBoneMatrices();
}

If you have multiple animations included, the following may be helpful.
https://github.com/cx20/gltf-test/blob/master/examples/filament/index.js#L163-L166

if (this.animator) {
    const ms = Date.now() - this.animationStartTime;
    for (let i = 0; i < this.asset.getAnimator().getAnimationCount(); i++ ) {
        this.animator.applyAnimation(i, ms / 1000);
        this.animator.updateBoneMatrices();
    }
}

thank you!

it is a great example, and I found another useful example
https://github.com/google/filament/blob/dcca236f6058b61a9a6aa07bfe4ac53b1cdd05e5/libs/gltfio/include/gltfio/AssetLoader.h#L80-L120

maybe it will be useful for somebody else

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hemantkadamata picture hemantkadamata  路  3Comments

dakom picture dakom  路  5Comments

rfebbo picture rfebbo  路  3Comments

cx20 picture cx20  路  8Comments

cx20 picture cx20  路  5Comments