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