简体   繁体   English

如何使用鼠标与Java3D元素进行交互?

[英]How to interact with Java3D elements using mouse?

I want the user to be able to change the length of a cylinder by clicking-and-dragging his mouse. 我希望用户能够通过单击并拖动鼠标来更改圆柱的长度。 How should I start on this ? 我应该如何开始呢? Any form of help would be great. 任何形式的帮助都会很棒。

Check out the example code here . 在此处查看示例代码。 The basic idea is: 基本思想是:

  • Use mousePressed() listener to detect a mouse press. 使用mousePressed()侦听器可检测到鼠标按下。
  • Use Java3D picking API to detect if mouse press intersected shape. 使用Java3D Picking API来检测鼠标按下是否与形状相交。
  • Use mouseDragged() listener to detect amount of change and update your shape accordingly. 使用mouseDragged()侦听器来检测变化量并相应地更新形状。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM