aframecolladawebxr

How to use a collada model with aframe-v1.1.0.min


I have been using a-frame since 2018 to show my scenographies to the directors I work for. I used the colladas files for my objects and everything was working great and my textures were as I wanted. But since the webxr (aframe-v1.1.0.min) appeared it is no longer possible to use collada I have tried the Gltf files but it is too heavy and not satisfactory. So I wanted to know how to put collada back into the a-frame scipts. I tried: "collada-model-legacy.js" with "ColladaLoader.js" in another folder but it doesn't work. Do you have a solution? Thank you


Solution

  • You can use any of the loaders from the three.js repository - also the ColladaLoader.

    You could create a wrapper component, which will use threejs loader and add the model to the scene:

    AFRAME.registerComponent("foo", {
      init: function() {
        const el = this.el;
        // create a loader
        const loader = new THREE.ColladaLoader();
        // load the model
        loader.load("MODEL_URL", function(model) {
          el.object3D.add(collada.scene);
        })
      }
    })
    

    A simple example could be this component (check it out with static and animated collada models here)