three.js 相機跟隨鼠標移動


相機跟隨鼠標移動

代碼

var startY,endY;
        var isDown = false;
        var changeBefore = 0;
        function addTouchListener() {
            document.onmousedown = function (event) {
                startY = event.clientY;
                isDown = true;
            };
            document.onmouseup = function(event){
                isDown = false;
            };
            document.onmousemove = function (event) {
                if (isDown) {
                    if(changeBefore != 0){
                        if(changeBefore > event.clientY){
                            camera.position.y = camera.position.y + 20;
                        }else{
                            camera.position.y = camera.position.y - 20;
                        }
                    }
                    endY = event.clientY;
                    changeBefore = endY;
                }
            };
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM