Hi,
I a group of mesh and I'm animating some attributes on scroll, like scale, rotation, position etc. with a timeline and ScrollTrigger, and it works fine.
tlHero.to(
canvas.group.rotation,
{
y: `-=${Math.PI * 0.26}`,
x: `+=${Math.PI * 0.26}`,
},
0);
tlHero.to(
canvas.group.position,
{
x: "-=1",
},
0
);
The starting rotation values of the group of mesh are:
canvas.group.position.x = 1.43;
canvas.group.position.y = 0.85;
canvas.group.rotation.x = Math.PI * -0.14;
canvas.group.rotation.y = Math.PI * -0.34;
Now I want to add also a mouse move animation where I animate the rotation and position of the group, also this one works:
onMouseMove() {
this.cursor.x = event.clientX / window.innerWidth - 0.5;
this.cursor.y = event.clientY / window.innerHeight - 0.5;
gsap.to(canvas.group.position, {
x: 1.43 + this.cursor.x * 0.02,
y: 0.85 + this.cursor.y * 0.02,
duration: 1,
});
gsap.to(canvas.group.rotation, {
x: Math.PI * -0.14 - this.cursor.y * 0.04,
y: Math.PI * -0.34 - this.cursor.x * 0.04,
duration: 1,
});
}
Now the question is: how can I combine the mouse movement and ScrollTrigger animation?
This is an example of what I want to achieve:
https://crosswire.unseen.co/
As you can see there is a mouse movement effect where some objects of the scene are moving and the scroll started always from the right position.
Thanks in advance for your help!