const sectionHome = document.querySelector('#section-home')
let isScrolling = false
let targetRotation = new THREE.Euler(-4.75, 0, Math.PI / -2);
let transitionSpeed = 0.005; // Adjust this for the desired speed
function doSomething(){
if (!isScrolling) {
isScrolling = true
const initialRotation = model.rotation.clone();
let startTime = null;
function updateRotation(timestamp) {
if (!startTime) startTime = timestamp;
const elapsedTime = timestamp - startTime;
const progress = Math.min(elapsedTime / (1000 * transitionSpeed), 1);
// Use lerp to interpolate rotation smoothly
const newRotation = new THREE.Euler().copy(initialRotation).lerp(targetRotation, progress);
model.rotation.copy(newRotation);
if (progress < 1) {
requestAnimationFrame(updateRotation);
}
}
requestAnimationFrame(updateRotation);
}
}
sectionHome.addEventListener('scroll', doSomething)
Console is throwing an error, Uncaught TypeError: (intermediate value).copy(...).lerp is not a function
, and I have no idea why this is happening. Anybody have an idea?