首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >three.js获取鼠标在纹理上的协同

问three.js获取鼠标在纹理上的协同
EN

Stack Overflow用户
提问于 2013-05-05 04:53:43
回答 1查看 1.6K关注 0票数 0

我想创建一个像这样的交互式全景图:

http://mrdoob.github.io/three.js/examples/webgl_panorama_equirectangular.html

但我想让用户与之交互。

是否有可能在鼠标移动时从纹理中获取坐标,以使用three.js创建类似3d图像的地图?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2013-05-06 06:20:27

检查这个:Translating mouse location to Object coordinates

当找到光线相交的三角形时,您可以收集这些三角形顶点的3d坐标和UV。有了足够的数据来计算交点的UV位置。

伪代码:

代码语言:javascript
复制
x0 = mouse.x; y0 = mouse.y;
vec3 samplePoint = unproject(x0, y0);  // returns (x, y, near-plane-z) coords
ray.origin = camera.position;
ray.direction = samplePoint - camera.position;
var triangleComplexObj = check_for_intersections( scene, ray );  // returns triangle, it's vertices and their UV and 3d coord and intersection coord
calulateUV( triangleComplexObj , triangleComplexObj.intersectionPoint );

理解起来可能有点复杂,但应该可以解决问题。希望这能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16378862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档