I want to make some light effect, as the post FBX keyframe animation support? here said, the fbx is not work. so I achieve it manualy.
The parent mesh object has for child, 01,02,03,04, they use the same material lightMat, which use a texture light.png, half of this picture is black and half is bright, so I change the texture.offset to 0.5/0 to achieve light on/off, this is my code:
for(var i=0; i< 4; ++i) {
var child = this.childrenObj[i]
var texture = child.material.map
if(i< nFlash) {
texture.offset.x = 0.5;
console.log("light")
}
else {
texture.offset.x = 0;
console.log("dark")
}
texture.needsUpdate = true;
// child.material.needsUpdate = true;
}
But it seem if I change one child’s texure offset , another three material 's texture 's offset will also be changed
I know in unity, there is .material and .sharedMaterial, but it do not exist in three.js
Create new material do not work event
var textureLoader = new THREE.TextureLoader();
this.childrenObj = [];
var self = this;
var texture1 = textureLoader.load(imgName, function(texture) {
for(var i=0; i< children.length; ++i) {
var child = self.meshObj.getObjectByName(children[i])
child.material = new THREE.MeshBasicMaterial({map: texture})
child.material.needsUpdate = true;
self.childrenObj.push(child)
}
});