ArcBall axis trait prop

This commit is contained in:
tong 2021-07-24 11:32:36 +02:00
parent ce75516c59
commit 13cf22ecc2

View file

@ -6,6 +6,9 @@ import iron.math.Vec4;
class ArcBall extends Trait {
@prop
public var axis = new Vec4(0, 0, 1);
public function new() {
super();
@ -17,10 +20,8 @@ class ArcBall extends Trait {
var mouse = Input.getMouse();
if (mouse.down()) {
object.transform.rotate(new Vec4(0, 0, 1), -mouse.movementX / 100);
object.transform.buildMatrix();
object.transform.rotate(axis, -mouse.movementX / 100);
object.transform.rotate(object.transform.world.right(), -mouse.movementY / 100);
object.transform.buildMatrix();
}
}
}