FrameState.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*global define*/
  2. define([
  3. './SceneMode'
  4. ], function(
  5. SceneMode) {
  6. "use strict";
  7. /**
  8. * State information about the current frame. An instance of this class
  9. * is provided to update functions.
  10. *
  11. * @param {CreditDisplay} creditDisplay Handles adding and removing credits from an HTML element
  12. *
  13. * @alias FrameState
  14. * @constructor
  15. *
  16. * @private
  17. */
  18. var FrameState = function(creditDisplay) {
  19. /**
  20. * The current mode of the scene.
  21. * @type {SceneMode}
  22. * @default {@link SceneMode.SCENE3D}
  23. */
  24. this.mode = SceneMode.SCENE3D;
  25. /**
  26. * The current morph transition time between 2D/Columbus View and 3D,
  27. * with 0.0 being 2D or Columbus View and 1.0 being 3D.
  28. *
  29. * @type {Number}
  30. */
  31. this.morphTime = SceneMode.getMorphTime(SceneMode.SCENE3D);
  32. /**
  33. * The current frame number.
  34. *
  35. * @type {Number}
  36. * @default 0
  37. */
  38. this.frameNumber = 0;
  39. /**
  40. * The scene's current time.
  41. *
  42. * @type {JulianDate}
  43. * @default undefined
  44. */
  45. this.time = undefined;
  46. /**
  47. * The map projection to use in 2D and Columbus View modes.
  48. *
  49. * @type {MapProjection}
  50. * @default undefined
  51. */
  52. this.mapProjection = undefined;
  53. /**
  54. * The current camera.
  55. * @type {Camera}
  56. * @default undefined
  57. */
  58. this.camera = undefined;
  59. /**
  60. * The culling volume.
  61. * @type {CullingVolume}
  62. * @default undefined
  63. */
  64. this.cullingVolume = undefined;
  65. /**
  66. * The current occluder.
  67. * @type {Occluder}
  68. * @default undefined
  69. */
  70. this.occluder = undefined;
  71. this.passes = {
  72. /**
  73. * <code>true</code> if the primitive should update for a render pass, <code>false</code> otherwise.
  74. * @type {Boolean}
  75. * @default false
  76. */
  77. render : false,
  78. /**
  79. * <code>true</code> if the primitive should update for a picking pass, <code>false</code> otherwise.
  80. * @type {Boolean}
  81. * @default false
  82. */
  83. pick : false
  84. };
  85. /**
  86. * The credit display.
  87. * @type {CreditDisplay}
  88. */
  89. this.creditDisplay = creditDisplay;
  90. /**
  91. * An array of functions to be called at the end of the frame. This array
  92. * will be cleared after each frame.
  93. * <p>
  94. * This allows queueing up events in <code>update</code> functions and
  95. * firing them at a time when the subscribers are free to change the
  96. * scene state, e.g., manipulate the camera, instead of firing events
  97. * directly in <code>update</code> functions.
  98. * </p>
  99. *
  100. * @type {FrameState~AfterRenderCallback[]}
  101. *
  102. * @example
  103. * frameState.afterRender.push(function() {
  104. * // take some action, raise an event, etc.
  105. * });
  106. */
  107. this.afterRender = [];
  108. /**
  109. * Gets whether or not to optimized for 3D only.
  110. * @type {Boolean}
  111. * @default false
  112. */
  113. this.scene3DOnly = false;
  114. };
  115. /**
  116. * A function that will be called at the end of the frame.
  117. * @callback FrameState~AfterRenderCallback
  118. */
  119. return FrameState;
  120. });