如何提供对象的交互式旋转?
在 Three.js 中,有各种控件,例如 TrackballControls,可以让用户控制相机。这很棒,但我希望用户能够旋转场景的一部分(例如分子),而不旋转场景的其余部分(例如不同的分子或光源)。
关于如何做到这一点有什么建议吗?
我想知道,如果我向 TrackballControls() 构造函数提供一个不同的对象而不是相机......它会旋转该对象吗?似乎不太可能...
In Three.js, there are various Controls, such as TrackballControls, that let the user control the camera. This is great, but I want the user to be able to rotate a part of the scene (e.g. a molecule) without rotating the rest of the scene (e.g. a different molecule, or a light source).
Any suggestions on how to do that?
I wonder, if I supplied a different object to the TrackballControls() constructor instead of the camera... would it just rotate that object?? Seems unlikely...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要旋转对象,您应该设置其旋转坐标,因此一旦渲染,其视觉效果就会相应更新。要一次仅旋转一个对象,请将用户输入绑定到该特定对象旋转参数。
检查此示例,您可以在其中使用鼠标或触摸输入旋转一个立方体:
http://mrdoob.github.com/third.js/examples/canvas_geometry_cube.html
这个,它展示了如何使用鼠标选择对象:
http://mrdoob.github.com/third.js/examples/canvas_interactive_cubes_tween.html
To rotate an object you should set its rotation coordinates, so once it's rendered its visual will be updated accordingly. To rotate just one object a time, bind the user input to that particular object rotation parameters.
Check this example, where you can rotate one cube with mouse or touch inputs:
http://mrdoob.github.com/three.js/examples/canvas_geometry_cube.html
And this one, which shows how to select objects using the mouse:
http://mrdoob.github.com/three.js/examples/canvas_interactive_cubes_tween.html