zoukankan      html  css  js  c++  java
  • three.js 物体随鼠标移动

    代码

         var startX,endX;
    var isDown = false;
            var changeBefore = 0;
            function addTouchListener() {
                document.onmousedown = function (event) {
                    startX = event.clientX;
                    isDown = true;
                };
                document.onmouseup = function(event){
                    isDown = false;
                };
                document.onmousemove = function (event) {
                    if (isDown) {
                        if(changeBefore != 0){
                            if(changeBefore > event.clientX){
                                mesh.rotation.y = mesh.rotation.y + 0.1;
                            }else{
                                mesh.rotation.y = mesh.rotation.y - 0.1;
                            }
                        }
                        endX = event.clientX;
                        changeBefore = endX;
                    }
                };
            }

     mesh改成自己的几何体,页面用

    requestAnimationFrame( animate );
    刷新
  • 相关阅读:
    产品经理经常犯的错误李可按
    skills_hive
    skills_office
    skills_idea
    skills_linux
    skills_ubuntu
    skills_git
    skills_redis
    skills_centos
    problems_hive
  • 原文地址:https://www.cnblogs.com/chenyi4/p/12465630.html
Copyright © 2011-2022 走看看