google-ar / codelab-webxr

Building an augmented reality application with the WebXR Device API
https://codelabs.developers.google.com/codelabs/ar-with-webxr/
Apache License 2.0
171 stars 86 forks source link

How to implement animated 3D objects? (fbx or gtfl) #17

Closed hajop closed 5 years ago

hajop commented 5 years ago

Maybe here is a better place for my problem: (https://github.com/immersive-web/webxr/issues/457)

I need your help. I have done the webxr tutorial with enthusiasm. (https://codelabs.developers.google.com/codelabs/ar-with-webxr/#0)

Now I would like to display animated objects. With blender I animated the object in fbx format and loaded it into an html with the FBXLoader of the three.js library. That works! Unfortunately I did not succeed to use the fbx object with the same FBXLoader in the AR example of the tutorial.

Is there an example for this? Is gtlf object better usable than fbx objects? What needs to be changed in the code so I can use the loader?

Thanks a lot!

three.js FBX Loader:


var loader = new THREE.FBXLoader();
loader.load( 'models/fbx/AR_Tutorial.fbx', function ( object ) {

    mixer = new THREE.AnimationMixer( object );
        var action = mixer.clipAction( object.animations[ 0 ] );
    action.play();

    object.traverse( function ( child ) {

        if ( child.isMesh ) {

               child.castShadow = true;
               child.receiveShadow = true;

         }

        } );

        scene.add( object );

      } );
jsantell commented 5 years ago

Hello! Once parsed, assuming models are exported with compatible features, there is no difference in glTF and FBX during runtime. glTF appears to be best choice moving forward. The three.js tag on stackoverflow is a better place for general three.js questions like this -- good luck!