webarkit / ARnft-threejs

A rendering package for https://github.com/webarkit/ARnft
GNU General Public License v3.0
22 stars 7 forks source link

GLTF Animation not working #16

Closed bagidea closed 2 years ago

bagidea commented 2 years ago

Hello I'm add gltf model and play animation mixer, But ot not working. I'm using GLTFLoader and Animation Mixer. then I add model by NFTaddTJS. After my tracking my models show but not play animation. Thank you

kalwalt commented 2 years ago

Hello I'm add gltf model and play animation mixer, But ot not working. I'm using GLTFLoader and Animation Mixer. then I add model by NFTaddTJS. After my tracking my models show but not play animation. Thank you

it could be caused for different reasons. Can you post the model or the code?

denisTrubicin93 commented 2 years ago

Hi. I have the same problem. The animation of the rig does not work. santa3.zip

denisTrubicin93 commented 2 years ago

In the console you can see that the model has no animation, but in fact there is image

kalwalt commented 2 years ago

@bagidea @denisTrubicin93 animations are not working because is not implemented yet. Inside https://github.com/webarkit/ARnft-threejs/blob/16543652f7c2f01fe546b4709b8aa105fcadcab7/src/markermedia/NFTaddTJS.ts#L98 i should add something like:

var animation = gltf.animations[0];
var mixer = new THREE.AnimationMixer(model);
mixers.push(mixer);
var action = mixer.clipAction(animation);
action.play();

I will test when i have a bit of time. :smile:

kalwalt commented 2 years ago

I'm working on this branch https://github.com/webarkit/ARnft-threejs/tree/feature-addmodel-animations, i will let you know when it's ready.

kalwalt commented 2 years ago

I created a PR https://github.com/webarkit/ARnft-threejs/pull/28, feel free to comment also there.

kalwalt commented 2 years ago

I made a working example thanks to the code in #29, see the addModelWithCallback method. You can test the examples/arNFT_gltf_flamingo_example.html in PR https://github.com/webarkit/ARnft/pull/246.

kalwalt commented 2 years ago

This is merged in the master now!