Merge pull request #2285 from tong/arcball-improvements

ArcBall axis trait prop
This commit is contained in:
Lubos Lenco 2021-07-31 20:07:16 +02:00 committed by GitHub
commit aeffd76b75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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();
}
}
}