Hello there,
I came accross a very strange and specific issue using threejs + gsap.
I’m working with threejs and using a timeline to animate textures offsets (it moves the texture on a 3d sphere).
Everything works well but I need to be able to switch from a texture to another at certain points of the animation.
I want to reuse the same material but switch to another image at a certain position.
To do so I decided to use “.call” to trigger a function (setTexture).
Problem is when I'm doing this, the animation for that material is not playing anymore. The texture has switched but the “y” offset value is not updated.
(When I'm just using setTexture without gsap, I'm able to switch my texture and it's still animated so the problem doesn't seems to come from here)
Anyway, here is the code I'm using
var setTexture = function(material, texture){
material.map = new THREE.TextureLoader().load(texture.map);
console.log('test')
}
// setTexture(sphere.material[0], textures[1]);
tl.call(setTexture, [sphere.material[0], textures[1]], "1")
tl.fromTo(sphere.material[0].map.offset, {y:-1},{y:1, duration:2}, "2");
tl.fromTo(sphere.material[2].map.offset, {y:-1},{y:1, duration:8}, "10");
tl.fromTo(sphere.material[1].map.offset, {y:-1},{y:1, duration:8}, "11");
tl.fromTo(sphere.material[3].map.offset, {y:-1},{y:1, duration:8}, "13");
tl.fromTo(sphere.material[0].map.offset, {y:-1},{y:1, duration:8}, "16");
Many thanks for you help !!
B