Files
armorpaint/Sources/arm/CamBall.hx
T
luboslenco 3db67d94b0 Brush nodes
2018-02-26 00:20:12 +01:00

46 lines
997 B
Haxe

package arm;
import iron.Trait;
import iron.system.Input;
import iron.math.Vec4;
@:keep
class CamBall extends Trait {
public static var moved = false;
public function new() {
super();
notifyOnUpdate(update);
}
function update() {
if (Input.occupied) return;
if (!UITrait.uienabled) return;
if (UITrait.isScrolling) return;
if (UITrait.isDragging) return;
if (UITrait.cameraType != 0) return;
if (!object.visible) return;
var mouse = Input.getMouse();
var kb = Input.getKeyboard();
// Paint bounds
if (mouse.x > iron.App.w()) return;
// if (UINodes.show && mouse.y > UINodes.wy) return;
if (mouse.down("right") || (mouse.down("left") && kb.down("ctrl"))) {
UITrait.dirty = true;
// Rotate
object.transform.rotate(new Vec4(0, 0, 1), mouse.movementX / 100);
object.transform.buildMatrix();
var v = object.transform.right();
v.normalize();
object.transform.rotate(v, mouse.movementY / 100);
object.transform.buildMatrix();
}
}
}