babylon.interpolateValueAction.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. {
  32. frame: 100,
  33. value: this.value
  34. }
  35. ];
  36. var dataType;
  37. if (typeof this.value === "number") {
  38. dataType = BABYLON.Animation.ANIMATIONTYPE_FLOAT;
  39. }
  40. else if (this.value instanceof BABYLON.Color3) {
  41. dataType = BABYLON.Animation.ANIMATIONTYPE_COLOR3;
  42. }
  43. else if (this.value instanceof BABYLON.Vector3) {
  44. dataType = BABYLON.Animation.ANIMATIONTYPE_VECTOR3;
  45. }
  46. else if (this.value instanceof BABYLON.Matrix) {
  47. dataType = BABYLON.Animation.ANIMATIONTYPE_MATRIX;
  48. }
  49. else if (this.value instanceof BABYLON.Quaternion) {
  50. dataType = BABYLON.Animation.ANIMATIONTYPE_QUATERNION;
  51. }
  52. else {
  53. BABYLON.Tools.Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  54. return;
  55. }
  56. var animation = new BABYLON.Animation("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT);
  57. animation.setKeys(keys);
  58. if (this.stopOtherAnimations) {
  59. scene.stopAnimation(this._target);
  60. }
  61. scene.beginDirectAnimation(this._target, [animation], 0, 100);
  62. };
  63. return InterpolateValueAction;
  64. })(BABYLON.Action);
  65. BABYLON.InterpolateValueAction = InterpolateValueAction;
  66. })(BABYLON || (BABYLON = {}));
  67. //# sourceMappingURL=babylon.interpolateValueAction.js.map