7

I have created a 3d animated model, which I managed to run in threejs.

var loader = new THREE.FBXLoader();
loader.load( 'model.fbx', function ( object ) {              
     object.mixer = new THREE.AnimationMixer( object );
     mixers.push( object.mixer );
     console.log(object.animations.length);
     var action = object.mixer.clipAction( object.animations[ 0 ] );
     action.play();
     object.traverse( function ( child ) { 
       if ( child.isMesh ) { 
          child.castShadow = true;
          child.receiveShadow = true; 
       } 
     });
     scene.add( object );
});

It works perfectly fine on threejs, but how can I use it in aframe, I am trying to create AR app. I am not getting enough documentation, in AFrame I can display obj model on marker but aframe-extras doesn't seem to work, but Threejs FBX loader works fine. I need help to display threejs scene on on marker scan.

Chamin Wickramarathna
  • 1,672
  • 2
  • 20
  • 34
Omkar Frozen
  • 157
  • 9
  • If `fbx-model` isn't working you may want to file a bug against aframe extras, including the model. The model, and the particular version of `THREE.FBXLoader` being used in A-Frame, are probably the key things here. – Don McCurdy Mar 06 '18 at 18:49

2 Answers2

2

I used FBX2glTF to convert model to glTF and worked fine for me. https://github.com/facebookincubator/FBX2glTF

ngokevin
  • 12,980
  • 2
  • 38
  • 84
1

Regarding the topic: 3D models in a-frame

Try using the three.js JSON, or glTF formats. Both formats are recommended by the a-frame team in the docs.

I remember Don McCurdy pointing out that the fbx models are complicated and hard to interpret, that's why JSON formats came to webGL.

While working with ar.js i remember having no problems using Three.js JSON models with multiple animations, as well as glTF static/one-animation models.

You can easily export you model to gltf using khronos, or kupomans exporters, and three.js JSON using this one.

Furthermore, the glTF models work with the core a-frame library, without any additions !


Regarding fbx's, i've never got them to work properly, so since the other ones are designed for webGL i'd try them out.

Piotr Adam Milewski
  • 14,150
  • 3
  • 21
  • 42