如何从多个 Graphics3D 对象中选择一个并更改其在 Mathematica 中的坐标?
在问题“ Mathematica 和 MouseListener - 使用 Mma 开发交互式图形的接受答案中 " Sjoerd C de Vries 演示了可以选择 3D 图形中的对象并更改其颜色。
我想知道是否可以(以与上面类似的方式)在具有两个或多个对象(例如两个长方体)的 Graphics3D 中选择一个对象并更改其坐标(通过移动或其他方式) ?
In the accepted answer of question " Mathematica and MouseListener - developing interactive graphics with Mma " Sjoerd C de Vries demonstrates that it is possible to select an object in a 3D graphic and change its color.
I would like to know if it is possible (in a similar fashion as above) in a Graphics3D
with two or more objects (e.g. two cuboids) to select one and change its coordinates (by moving or otherwise)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里部分地重用了 Sjoerd 的代码,但也许是这样的
请注意,这只是在平面上移动长方体,因此您必须旋转边界框才能将它们垂直于该平面移动,但这应该不会太难通过添加修饰键引入第三个维度。
编辑
感谢您的评论。这是上面代码的更新版本。在此版本中,如果立方体碰巧移出边界框,它们会跳回边界框内,这样应该可以解决立方体消失的问题。
I'm partly reusing Sjoerd's code here, but maybe something like this
Note that this just moves the cuboids in a plane so you would have to rotate the bounding box to move them perpendicular to that plane, but it shouldn't be too hard to introduce a third dimensions by adding modifier keys.
Edit
Thanks for the comments. Here's an updated version of the code above. In this version the cubes jump back to within the bounding box if they happen to move outside so that should solve the problem of the disappearing cubes.