700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > three.js 在手机端移动转向 可做场景漫游

three.js 在手机端移动转向 可做场景漫游

时间:2021-09-05 03:56:16

相关推荐

three.js 在手机端移动转向 可做场景漫游

先把几个函数发上来,完整代码等解耦后再完善

单手指点击屏幕前进,双手指点击后退 左右滑动专向

this.onTouchStart=function( event ) {isUserInteracting = true;var clientX = event.clientX || event.touches[ 0 ].clientX;var clientY = event.clientY || event.touches[ 0 ].clientY;onMouseDownMouseX = clientX;onMouseDownMouseY = clientY;onMouseDownLon = lon;onMouseDownLat = lat;if ( this.domElement !== document ) {this.domElement.focus();}event.preventDefault(); //防止违约event.stopPropagation(); //停止传播if ( this.activeLook ) {var touch = event.targetTouches[0];touchstartY=touch.pageX;switch ( event.touches.length ) {case 1:this.moveForward = true;break;case 2:this.moveBackward = true; break;default:}}this.mouseDragOn = true; //鼠标拖动console.log("touchstart");}this.onTouchEnd=function( event ) {console.log("touchend");isUserInteracting = false;//console.log(event.touches.length);this.moveForward = false; this.moveBackward = false; this.mouseDragOn = false;}this.onTouchMove=function( event ) {console.log("touchmove");if ( isUserInteracting === true ) {var clientX = event.clientX || event.touches[ 0 ].clientX;var clientY = event.clientY || event.touches[ 0 ].clientY;lon = ( onMouseDownMouseX - clientX ) * 0.1 + onMouseDownLon;lat = ( clientY - onMouseDownMouseY ) * 0.1 + onMouseDownLat;}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。