babylon.directActions.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var SwitchBooleanAction = (function (_super) {
  10. __extends(SwitchBooleanAction, _super);
  11. function SwitchBooleanAction(trigger, targetType, targetName, propertyPath, condition) {
  12. _super.call(this, trigger, condition);
  13. this.targetType = targetType;
  14. this.targetName = targetName;
  15. this.propertyPath = propertyPath;
  16. }
  17. SwitchBooleanAction.prototype._prepare = function () {
  18. this._target = this._getTarget(this.targetType, this.targetName);
  19. this._target = this._getEffectiveTarget(this._target, this.propertyPath);
  20. this._property = this._getProperty(this.propertyPath);
  21. };
  22. SwitchBooleanAction.prototype.execute = function () {
  23. this._target[this._property] = !this._target[this._property];
  24. };
  25. return SwitchBooleanAction;
  26. })(BABYLON.Action);
  27. BABYLON.SwitchBooleanAction = SwitchBooleanAction;
  28. var SetValueAction = (function (_super) {
  29. __extends(SetValueAction, _super);
  30. function SetValueAction(trigger, targetType, targetName, propertyPath, value, condition) {
  31. _super.call(this, trigger, condition);
  32. this.targetType = targetType;
  33. this.targetName = targetName;
  34. this.propertyPath = propertyPath;
  35. this.value = value;
  36. }
  37. SetValueAction.prototype._prepare = function () {
  38. this._target = this._getTarget(this.targetType, this.targetName);
  39. this._target = this._getEffectiveTarget(this._target, this.propertyPath);
  40. this._property = this._getProperty(this.propertyPath);
  41. };
  42. SetValueAction.prototype.execute = function () {
  43. this._target[this._property] = this.value;
  44. };
  45. return SetValueAction;
  46. })(BABYLON.Action);
  47. BABYLON.SetValueAction = SetValueAction;
  48. var PlayAnimationAction = (function (_super) {
  49. __extends(PlayAnimationAction, _super);
  50. function PlayAnimationAction(trigger, targetType, targetName, from, to, loop, condition) {
  51. _super.call(this, trigger, condition);
  52. this.targetType = targetType;
  53. this.targetName = targetName;
  54. this.from = from;
  55. this.to = to;
  56. this.loop = loop;
  57. }
  58. PlayAnimationAction.prototype._prepare = function () {
  59. this._target = this._getTarget(this.targetType, this.targetName);
  60. };
  61. PlayAnimationAction.prototype.execute = function () {
  62. var scene = this._actionManager.getScene();
  63. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  64. };
  65. return PlayAnimationAction;
  66. })(BABYLON.Action);
  67. BABYLON.PlayAnimationAction = PlayAnimationAction;
  68. var StopAnimationAction = (function (_super) {
  69. __extends(StopAnimationAction, _super);
  70. function StopAnimationAction(trigger, targetType, targetName, condition) {
  71. _super.call(this, trigger, condition);
  72. this.targetType = targetType;
  73. this.targetName = targetName;
  74. }
  75. StopAnimationAction.prototype._prepare = function () {
  76. this._target = this._getTarget(this.targetType, this.targetName);
  77. };
  78. StopAnimationAction.prototype.execute = function () {
  79. var scene = this._actionManager.getScene();
  80. scene.stopAnimation(this._target);
  81. };
  82. return StopAnimationAction;
  83. })(BABYLON.Action);
  84. BABYLON.StopAnimationAction = StopAnimationAction;
  85. var ExecuteCodeAction = (function (_super) {
  86. __extends(ExecuteCodeAction, _super);
  87. function ExecuteCodeAction(trigger, func, condition) {
  88. _super.call(this, trigger, condition);
  89. this.func = func;
  90. }
  91. ExecuteCodeAction.prototype.execute = function () {
  92. this.func();
  93. };
  94. return ExecuteCodeAction;
  95. })(BABYLON.Action);
  96. BABYLON.ExecuteCodeAction = ExecuteCodeAction;
  97. var SetParentAction = (function (_super) {
  98. __extends(SetParentAction, _super);
  99. function SetParentAction(trigger, targetType, targetName, parentType, parentName, condition) {
  100. _super.call(this, trigger, condition);
  101. this.targetType = targetType;
  102. this.targetName = targetName;
  103. this.parentType = parentType;
  104. this.parentName = parentName;
  105. }
  106. SetParentAction.prototype._prepare = function () {
  107. this._target = this._getTarget(this.targetType, this.targetName);
  108. this._parent = this._getTarget(this.parentType, this.parentName);
  109. };
  110. SetParentAction.prototype.execute = function () {
  111. if (this._target.parent === this._parent) {
  112. return;
  113. }
  114. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  115. invertParentWorldMatrix.invert();
  116. this._target.position = BABYLON.Vector3.TransformCoordinates(this._target.position, invertParentWorldMatrix);
  117. this._target.parent = this._parent;
  118. };
  119. return SetParentAction;
  120. })(BABYLON.Action);
  121. BABYLON.SetParentAction = SetParentAction;
  122. })(BABYLON || (BABYLON = {}));
  123. //# sourceMappingURL=babylon.directActions.js.map