如何使用 Three.js 获取鼠标悬停时的图像坐标?
我有一个图像,想要使用 Three.js 来制作它,这样当我将鼠标悬停在图像上时,它会给出鼠标所在的坐标(即:图像的左上角是 0,0)
如果可能的话,我还想更进一步,能够旋转该图像,并且当鼠标悬停在图像上时能够获得相同的坐标。
我该如何实现这个目标?我遇到了麻烦。
I have an image and want to use three.js to make it so that when i mouse over the image, it gives me the coordinates the mouse is over (ie: top left corner of the image is 0,0)
If possible, I would also like to take it a step further to be able to rotate that image, and be able to get the same coordinates when mousing over the image.
How do I accomplish this? Im having trouble with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许用画布本地解决这个问题会更好,但它涉及数学。画布仅显示像素,因此您需要跟踪图像。我发现从这个网站 Canvas-pictures 阅读源代码有很大帮助。因此道具应该交给 Addy Osmani
Perhaps it would be better to solve this natively with canvas, but it involves Math. Canvas only display pixels so you need to hold track of the images. I found tremendous help reading the source code from this site Canvas-pictures . Therefore the props should go to Addy Osmani