armory/Sources/armory/trait/ArcBall.hx

28 lines
494 B
Haxe
Raw Permalink Normal View History

2016-10-02 19:52:40 +02:00
package armory.trait;
import iron.Trait;
import iron.system.Input;
import iron.math.Vec4;
class ArcBall extends Trait {
2021-07-24 11:32:36 +02:00
@prop
public var axis = new Vec4(0, 0, 1);
2016-10-02 19:52:40 +02:00
public function new() {
super();
notifyOnUpdate(update);
}
function update() {
if (Input.occupied) return;
2017-04-10 21:17:17 +02:00
var mouse = Input.getMouse();
if (mouse.down()) {
2021-07-24 11:32:36 +02:00
object.transform.rotate(axis, -mouse.movementX / 100);
2017-07-14 18:07:30 +02:00
object.transform.rotate(object.transform.world.right(), -mouse.movementY / 100);
2016-10-02 19:52:40 +02:00
}
}
}