繁体   English   中英

WebGL和Three.js中的Z轴协调

[英]Z-Axis Coordination in WebGL and Three.js

我正在尝试使用WebGL和Three.js,但是如何在移动鼠标时计算Z轴坐标?

我将其用于X和Y:

  function getCoord(e) {
      X = e.layerX - canvas.offsetLeft;
      Y = e.layerY - canvas.offsetTop;
  }

如何获得Z坐标?

编辑:我找到了这个例子,但我自己却无法解决... https://github.com/mrdoob/three.js/blob/master/examples/webgl_interactive_voxelpainter.html

谢谢

这是答案...

function onDocumentMouseMove( event ) {
     event.preventDefault();
     mouse2D.x = ( event.clientX / window.innerWidth ) * 2 - 1;
     mouse2D.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
}

function render() {
     mouse3D = projector.unprojectVector( mouse2D.clone(), camera );
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM