lolia
June 7, 2021, 6:57pm
1
Hi, have a nice day, i try to find a way to play animation with scroll using gsap
like
let scrollingTL = gsap.timeline({
scrollTrigger: {
trigger: canvas,
start: 'top top',
end: '+=500%',
pin: true,
scrub: true,
onUpdate: function () {
camera.updateProjectionMatrix();
}
},
})
scrollingTL
.from(mesh.animation, {
}, 0)
any help plz?
Does the following topic solve your issue? The questions seem to be quite similar.
hi everyone, about Three.js + Gsap ScrollTrigger.
I want to make that when the mouse scrolls down, the model can rotate.
When I use **let tween = gsap.to(camera.position, {x: 0.1 })** the model can move, but the speed is too fast… and it is not so natural and smooth
thanks~~
my code:
//場景 相機 渲染器 (scene, camera, renderer)
let container;
let canvas;
let camera;
let renderer;
let scene;
let mountain;
let controls;
function init() {
// container = document.querySelector(".app");
//選擇容器 c…
lolia
June 8, 2021, 8:45am
3
Oh i am sorry if i explain wrong , but my english is bad , i mean play mesh animation based on scroll , this animation
mixer = new THREE.AnimationMixer(gltf.scene)
const action = mixer.clipAction(gltf.animations[0])
action.play()
Do you mean you want to trigger the animation at a certain scroll position?
lolia
June 8, 2021, 9:04am
6
Yes, something like this .
Try it like so: https://jsfiddle.net/2q7z63ot/
The idea is to add an onEnter()
callback function which is executed when the scroll position moves forward past the start. Use it to start your animation. If you want to execute this callback only once, set the respective configuration property to true
.
The callback and the property are documented right here: Docs - GreenSock
1 Like
lolia
June 9, 2021, 10:44am
8
Yes but when i set the animation on enter all animation loaded in one time, i need to load animation based on scroll , is that can be made ? plz
@lolia try like this…?
let oldValue = 0;
window.addEventListener('scroll' , function(e){
var newValue = window.pageYOffset;
if(oldValue - newValue < 0){
mixer.update( (newValue - oldValue) / 250 );
}
else if(oldValue - newValue > 0){
mixer.update( (newValue - oldValue ) / 250 ) ;
}
oldValue = newValue;
});
2 Likes
lolia
June 9, 2021, 2:45pm
10
Lawrence3DPK:
@lolia try like this…?
Yes i try this but i want to use gsap for more control
peet88
July 24, 2022, 10:46pm
11
This is not working on mobile - the timing is completely off as is the animation.