智慧水务管理系统 - 精河县供水工程综合管理平台

PrimitiveState.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // @ts-check
  2. /**
  3. * The states that describe the lifecycle of a <code>Primitive</code>, as
  4. * represented by the <code>primitive._state</code>.
  5. *
  6. * The state transitions are triggered by calls to the <code>update</code>
  7. * function, but the actual state changes may happen asynchronously if the
  8. * <code>asynchronous</code> flag of the primitive was set to
  9. * <code>true</code>.
  10. *
  11. * @enum {number}
  12. * @private
  13. */
  14. const PrimitiveState = {
  15. /**
  16. * The initial state of a primitive.
  17. *
  18. * Note that this does NOT mean that the primitive is "ready", as indicated
  19. * by the <code>_ready</code> property. It means the opposite: Nothing was
  20. * done with the primitive at all.
  21. *
  22. * For primitives that are created with the <code>asynchronous:true</code>
  23. * setting and that are in this state, the <code>update</code> call starts
  24. * the creation of the geometry using web workers, and the primitive goes
  25. * into the <code>CREATING</code> state.
  26. *
  27. * For synchronously created primitives, this state never matters. They will
  28. * go into the COMBINED (or FAILED) state directly due to a call to the
  29. * <code>update</code> function, if they are not yet FAILED, COMBINED,
  30. * or COMPLETE.
  31. */
  32. READY: 0,
  33. /**
  34. * The process of creating the primitive geometry is ongoing.
  35. *
  36. * A primitive can only ever be in this state when it was created
  37. * with the <code>asynchronous:true</code> setting.
  38. *
  39. * It means that web workers are currently creating the geometry
  40. * of the primitive.
  41. *
  42. * When the geometry creation succeeds, then the primitive will go
  43. * into the CREATED state. Otherwise, it will go into the FAILED
  44. * state. Both will happen asynchronously.
  45. *
  46. * The <code>update</code> function has to be called regularly
  47. * until either of these states is reached.
  48. */
  49. CREATING: 1,
  50. /**
  51. * The geometry for the primitive has been created.
  52. *
  53. * A primitive can only ever be in this state when it was created
  54. * with the <code>asynchronous:true</code> setting.
  55. *
  56. * It means that web workers have (asynchronously) finished the
  57. * creation of the geometry, but further (asynchronous) processing
  58. * is necessary: If a primitive is determined to be in this state
  59. * during a call to <code>update</code>, an asynchronous process
  60. * is triggered to "combine" the geometry, meaning that the primitive
  61. * will go into the COMBINING state.
  62. */
  63. CREATED: 2,
  64. /**
  65. * The asynchronous creation of the geometry has been finished, but the
  66. * asynchronous process of combining the geometry has not finished yet.
  67. *
  68. * A primitive can only ever be in this state when it was created
  69. * with the <code>asynchronous:true</code> setting.
  70. *
  71. * It means that whatever is done with
  72. * <code>PrimitivePipeline.packCombineGeometryParameters</code> has
  73. * not finished yet. When combining the geometry succeeds, the
  74. * primitive will go into the COMBINED state. Otherwise, it will
  75. * go into the FAILED state.
  76. */
  77. COMBINING: 3,
  78. /**
  79. * The geometry data is in a form that can be uploaded to the GPU.
  80. *
  81. * For <i>synchronous</i> primitives, this means that the geometry
  82. * has been created (synchronously) due to the first call to the
  83. * <code>update</code> function.
  84. *
  85. * For <i>asynchronous</i> primitives, this means that the asynchronous
  86. * creation of the geometry and the asynchronous combination of the
  87. * geometry have both finished.
  88. *
  89. * The <code>update</code> function has to be called regularly until
  90. * this state is reached. When it is reached, the <code>update</code>
  91. * call will cause the transition into the COMPLETE state.
  92. */
  93. COMBINED: 4,
  94. /**
  95. * The geometry has been created and uploaded to the GPU.
  96. *
  97. * When this state is reached, it eventually causes the <code>_ready</code>
  98. * flag of the primitive to become <code>true</code>.
  99. *
  100. * Note: Setting the <code>ready</code> flag does NOT happen in the
  101. * <code>update</code> call: It only happens after rendering the next
  102. * frame!
  103. *
  104. * Note: This state does not mean that nothing has to be done
  105. * anymore (so the work is not "complete"). When the primitive is in
  106. * this state, the <code>update</code> function still has to be
  107. * called regularly.
  108. */
  109. COMPLETE: 5,
  110. /**
  111. * The creation of the primitive failed.
  112. *
  113. * When this state is reached, it eventually causes the <code>_ready</code>
  114. * flag of the primitive to become <code>true</code>.
  115. *
  116. * Note: Setting the <code>ready</code> flag does NOT happen in the
  117. * <code>update</code> call: It only happens after rendering the next
  118. * frame!
  119. *
  120. * This state can be reached when the (synchronous or asynchronous)
  121. * creation of the geometry, or the (asynchronous) combination of
  122. * the geometry caused any form of error.
  123. *
  124. * It may or may not imply the presence of the <code>_error</code> property.
  125. * When the <code>_error</code> property is present on a FAILED primitive,
  126. * this error will be thrown during the <code>update</code> call. When it
  127. * is not present for a FAILED primitive, then the <code>update</code> call
  128. * will do nothing.
  129. */
  130. FAILED: 6,
  131. };
  132. Object.freeze(PrimitiveState);
  133. export default PrimitiveState;