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.
js App. Sketchfab's API gives you programmatic access to the largest collection of glTF 3D models on the web.
The three. js library offers loaders for numerous file formats like FBX, Collada as well as OBJ but the recommended format for importing and exporting data is glTF. The great thing about glTF file format is that it is very compact and can be easily transmitted and also loading very fast.
three. js is a JavaScript-based WebGL engine that can run GPU-powered games and other graphics-powered apps straight from the browser. The three. js library provides many features and APIs for drawing 3D scenes in your browser.
I used FBX2glTF to convert model to glTF and worked fine for me. https://github.com/facebookincubator/FBX2glTF
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With