Reputation: 8817
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 });
});
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);
});
Upvotes: 1
Views: 1652
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