abstractActionManager.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Abstract class used to decouple action Manager from scene and meshes.
  3. * Do not instantiate.
  4. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions
  5. */
  6. export class AbstractActionManager {
  7. constructor() {
  8. /** Gets the cursor to use when hovering items */
  9. this.hoverCursor = "";
  10. /** Gets the list of actions */
  11. this.actions = [];
  12. /**
  13. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  14. */
  15. this.isRecursive = false;
  16. }
  17. /**
  18. * Does exist one action manager with at least one trigger
  19. **/
  20. static get HasTriggers() {
  21. for (const t in AbstractActionManager.Triggers) {
  22. if (Object.prototype.hasOwnProperty.call(AbstractActionManager.Triggers, t)) {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. /**
  29. * Does exist one action manager with at least one pick trigger
  30. **/
  31. static get HasPickTriggers() {
  32. for (const t in AbstractActionManager.Triggers) {
  33. if (Object.prototype.hasOwnProperty.call(AbstractActionManager.Triggers, t)) {
  34. const tAsInt = parseInt(t);
  35. if (tAsInt >= 1 && tAsInt <= 7) {
  36. return true;
  37. }
  38. }
  39. }
  40. return false;
  41. }
  42. /**
  43. * Does exist one action manager that handles actions of a given trigger
  44. * @param trigger defines the trigger to be tested
  45. * @returns a boolean indicating whether the trigger is handled by at least one action manager
  46. **/
  47. static HasSpecificTrigger(trigger) {
  48. for (const t in AbstractActionManager.Triggers) {
  49. if (Object.prototype.hasOwnProperty.call(AbstractActionManager.Triggers, t)) {
  50. const tAsInt = parseInt(t);
  51. if (tAsInt === trigger) {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. }
  59. /** Gets the list of active triggers */
  60. AbstractActionManager.Triggers = {};
  61. //# sourceMappingURL=abstractActionManager.js.map