簡體   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