demkovych
demkovych

Reputation: 8817

Three JS | Collada loader textures

I have problem with threeJS collada loader. I receive dae model with all textures from backend. After, i parse images (textures) and create materials array.

let materials = [];
textures.forEach((texture) => {
  let loadedTexture = THREE.ImageUtils.loadTexture(texture.url);
  let material = new THREE.MeshPhongMaterial({ map: loadedTexture });
});

enter image description here

Then I load dae model and try to append my array with materials:

colladaLoader.load(daeModelFile, (collada) => {
  let model = collada.scene;

  dae.traverse( ( child ) => {
    if ( child instanceof THREE.Mesh ) {
      child.material = materials;
    }
  });

  mainScene.add(model);
});

But instead of this: enter image description here

I received this one: enter image description here

Upvotes: 1

Views: 1652

Answers (1)

Mugen87
Mugen87

Reputation: 31026

If you are loading a dae file with THREE.ColladaLoader2, it is not necessary to manually apply the textures. This is done by the loader. Please check out the source code of this example:

https://threejs.org/examples/webgl_loader_collada.html

BTW: Don't use THREE.ColladaLoader anymore. This is an old implementation that will be replaced with THREE.ColladaLoader2 in the next release.

R87

Upvotes: 1

Related Questions