Hi, I’m working with version r86 of threejs.
I’m wrote a simple demo which loads a skinned character with animation using colladaloader2
(https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/ColladaLoader2.js)
Animations tracks work properly until I assign a new MeshPhongMaterial to the child mesh of the character hierachy.
When I do that, the animation doesn’t work and the mesh appears with a different scale (as if it’s not bound to the skeleton). The material is OK as the color of he mesh does change as expected
This is the relevant part of my code:
var mat1= new THREE.MeshPhongMaterial({ color:0xAA4444 });
loader.load(file,
function ( collada ) {
mesh=collada.scene;
scene.add(mesh);
mixer = new THREE.AnimationMixer( mesh );
clips = collada.animations;
clips.forEach( function ( clip ) {
mixer.clipAction( clip ).play();
} );
mesh.traverse(function (child) {
if (child instanceof THREE.Mesh && child.material) {
child.material=mat1;
}
});
},
function(){
//console.log("onLoad");
},
function(){
console.log("Error loading Model ...");
});
Does Anyone have any idea, why this happens?
I really need to replace the original mesh material by code.