three.js, 특정 각도에 항상 수렴하도록 하는 코드

const tick = () => {
    timer.update()
    const deltaTime = Math.min(1 / 30, timer.getDelta())

    const wantedDegree = 0;
    mesh.rotation.x += 
        (THREE.MathUtils.degToRad(wantedDegree) - mesh.rotation.x) * deltaTime
 
    // Render
    renderPipeline.render()
}

위의 코드는 mesh를 x축에 대한 rotation이 변경될 경우 점진적으로 wantedDegree 값으로 복구하도록 하는 코드입니다. 이 코드는 각도 뿐만 아니라 일반적인 값에도 적용할 수 있습니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다