1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package my3d;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import my3d._math3d._transform;
public class _scene3d {
private _transform tf;
private double ax, ay;
public _scene3d() {
tf = new _transform(0, 0, 0, 0, 0, 0);
}
public _transform get_transform() { return tf; }
public void angle(double ax, double ay) {
this.ax = ax; this.ay = ay;
_math3d.eular(ax, ay, 0, tf.ori);
}
public void position(double x, double y, double z) {
_math3d.set_vector(x, y, z, tf.pos);
}
public static interface _angle_listener {
public void angle_changed();
}
public void add_angle_listener(Scene scene, _angle_listener lis) {
scene.setOnKeyPressed((e) -> {
KeyCode key = e.getCode();
switch (key) {
case UP: angle(ax + 5, ay); break;
case DOWN: angle(ax - 5, ay); break;
case LEFT: angle(ax, ay + 5); break;
case RIGHT: angle(ax, ay - 5); break;
default: return;
}
lis.angle_changed();
});
}
}