使用鼠标将3D对象拖动3D对象。

发布于 2025-01-25 08:39:31 字数 526 浏览 2 评论 0原文

我试图在墙壁上实现一个物体的运动,而不仅仅是一个平面。在此示例,一个对象通过以下方式拖动墙壁:

intersects = raycaster.intersectObjects([walls]);
object.position.copy(intersects[0].point);

但是,使用此方法,对象,对象跳跃因为对象的中心移至鼠标。有一个相关问题并且有用的JSFIDDLE用于在没有跳跃的一个平面上拖动的JSFIDDLE,请帮助我将其修改为倍数飞机(墙壁)?谢谢

I am trying to achieve movement of an object on walls, instead of only one plane. In this example, an object dragged on walls by using:

intersects = raycaster.intersectObjects([walls]);
object.position.copy(intersects[0].point);

However, with this method, the object jumps because the object's center moves to the mouse. There is a related question and helpful JSFiddle for dragging on one plane without jumpin Would you please help me to modify it for multiples planes (walls)? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

a√萤火虫的光℡ 2025-02-01 08:39:31

阅读了您的评论后,我认为您要寻找的是您希望对象为该位置动画。您可以做几种方法。 “三j”的方法是将其移动每个帧(在动画/更新循环中)。您可以使用 vector3.lerp 通过存储相交[0] .point作为您的目标位置,并将您的object.position.position.position转到每个帧。另一个选项是使用动画库(例如AnimeJS或GSAP)。

After reading your comment, I think what you're looking for is you want the object to animate to the position. You can do this a few ways. The "threejs" way is to move it each frame (within the animate/update loop). You could do this with Vector3.lerp by storing intersects[0].point as your target location and lerping your object.position to it each frame. Another option is to use an animation library like animejs or gsap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文