babylon.interpolateValueAction.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 InterpolateValueAction = (function (_super) {
  10. __extends(InterpolateValueAction, _super);
  11. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations) {
  12. if (duration === void 0) { duration = 1000; }
  13. _super.call(this, triggerOptions, condition);
  14. this.propertyPath = propertyPath;
  15. this.value = value;
  16. this.duration = duration;
  17. this.stopOtherAnimations = stopOtherAnimations;
  18. this._target = target;
  19. }
  20. InterpolateValueAction.prototype._prepare = function () {
  21. this._target = this._getEffectiveTarget(this._target, this.propertyPath);
  22. this._property = this._getProperty(this.propertyPath);
  23. };
  24. InterpolateValueAction.prototype.execute = function () {
  25. var scene = this._actionManager.getScene();
  26. var keys = [
  27. {
  28. frame: 0,
  29. value: this._target[this._property]
  30. }, {
  31. frame: 100,
  32. value: this.value
  33. }
  34. ];
  35. var dataType;
  36. if (typeof this.value === "number") {
  37. dataType = BABYLON.Animation.ANIMATIONTYPE_FLOAT;
  38. }
  39. else if (this.value instanceof BABYLON.Color3) {
  40. dataType = BABYLON.Animation.ANIMATIONTYPE_COLOR3;
  41. }
  42. else if (this.value instanceof BABYLON.Vector3) {
  43. dataType = BABYLON.Animation.ANIMATIONTYPE_VECTOR3;
  44. }
  45. else if (this.value instanceof BABYLON.Matrix) {
  46. dataType = BABYLON.Animation.ANIMATIONTYPE_MATRIX;
  47. }
  48. else if (this.value instanceof BABYLON.Quaternion) {
  49. dataType = BABYLON.Animation.ANIMATIONTYPE_QUATERNION;
  50. }
  51. else {
  52. BABYLON.Tools.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  53. return;
  54. }
  55. var animation = new BABYLON.Animation("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
  56. animation.setKeys(keys);
  57. if (this.stopOtherAnimations) {
  58. scene.stopAnimation(this._target);
  59. }
  60. scene.beginDirectAnimation(this._target, [animation], 0, 100);
  61. };
  62. return InterpolateValueAction;
  63. })(BABYLON.Action);
  64. BABYLON.InterpolateValueAction = InterpolateValueAction;
  65. })(BABYLON || (BABYLON = {}));
  66. //# sourceMappingURL=babylon.interpolateValueAction.js.map