We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raycaster.intersectObjects() 返回一个数组,每个元素是一个交点对象,每个交点对象都包含以下属性:
Raycaster.intersectObjects()
faces
BufferGeometry
THREE.Vector3
THREE.Vector2
当你需要获取用户点击物体的确切位置,或者根据命中点修改物体表面属性如颜色等操作时,这些信息会非常有用。
The text was updated successfully, but these errors were encountered:
归一化的设备坐标: 范围从-1到1的二维空间,其中,(0,0)指的是屏幕中心,(-1,-1)指的是屏幕的左下角,(1,1)指的是屏幕的右上角
renderer 的 domEle 与屏幕宽高一致的换算:
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1; mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
如果渲染器的尺寸并非全屏,你应该相对于渲染器的宽高(而不是窗口或屏幕的宽高)来计算鼠标位置。并且需要考虑相对于渲染器的偏移。
let rect = rendererDom.getBoundingClientRect(); // 将鼠标位置降维为 device coordinates (-1 to +1) mouse.x = ((event.clientX - rect.left) / rect.width) * 2 - 1; mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
Sorry, something went wrong.
No branches or pull requests
Raycaster.intersectObjects()
返回一个数组,每个元素是一个交点对象,每个交点对象都包含以下属性:faces
数组中相交面的索引。对于BufferGeometry
,这是相交三角形的索引。THREE.Vector3
类型对象。THREE.Vector2
类型的对象,只有在相交的几何体形状有uv属性时苏醒返回。当你需要获取用户点击物体的确切位置,或者根据命中点修改物体表面属性如颜色等操作时,这些信息会非常有用。
The text was updated successfully, but these errors were encountered: