OrbitCamera.hx 967 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package arm;
  2. class OrbitCamera extends armory.Trait {
  3. public static var enabled = false;
  4. public function new() {
  5. super();
  6. notifyOnUpdate(function() {
  7. if (iron.system.Input.occupied) return;
  8. if (!UITrait.uienabled) return;
  9. if (UITrait.isScrolling) return;
  10. if (UITrait.isDragging) return;
  11. if (UITrait.cameraType != 0) return;
  12. var mouse = armory.system.Input.getMouse();
  13. if (mouse.x > iron.App.w()) return;
  14. // if (UINodes.show && mouse.y > UINodes.wy) return;
  15. var keyboard = armory.system.Input.getKeyboard();
  16. var camera = cast(object, iron.object.CameraObject);
  17. if (mouse.wheelDelta != 0) {
  18. UITrait.dirty = true;
  19. camera.move(camera.look(), mouse.wheelDelta * (-0.1));
  20. }
  21. if (mouse.down("middle") || (mouse.down("right") && keyboard.down("space"))) {
  22. UITrait.dirty = true;
  23. camera.transform.loc.addf(-mouse.movementX / 150, 0.0, mouse.movementY / 150);
  24. camera.buildMatrix();
  25. }
  26. });
  27. }
  28. }