This pen should be easier to compare with the skew example.
The timing needs to be improved but apart from that this seems to working ! BIG THANKS @OSUblake !! https://codepen.io/orion_prime/pen/KKmGwEE
One thing i would like is for gsap to update a single value(scrollObj.velocity) then use that value to update multiple objects in the scene.(The number of objects getting tilted is dynamic)
let scrollObj = { velocity: 0 }
i achieved this by the timeline's onupdate callback,
which calls the tiltboxes function,
which applies velocity as rotation on each box.
does this seem fine ? are there any redflags or tips ?
let currentTilt = clamp(self.getVelocity() / 100);
function tiltBoxes(){
meshGroup.children.forEach(element => {
element.rotation.z =- scrollObj.velocity
})
}
if (Math.abs(currentTilt) > Math.abs(camera.rotation.x)) {
gsap.killTweensOf(camera.rotation);
gsap.timeline({onUpdate:tiltBoxes})
.to(scrollObj, {
velocity: THREE.MathUtils.degToRad(currentTilt),
duration: 0.5,
})
.to(scrollObj, {
velocity: 0,
duration: 0.5,
})
}