abstractEngine.query.d.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import type { PerfCounter } from "../../Misc/perfCounter";
  2. import type { Nullable } from "../../types";
  3. /** @internal */
  4. export type OcclusionQuery = WebGLQuery | number;
  5. /** @internal */
  6. export declare class _OcclusionDataStorage {
  7. /** @internal */
  8. occlusionInternalRetryCounter: number;
  9. /** @internal */
  10. isOcclusionQueryInProgress: boolean;
  11. /** @internal */
  12. isOccluded: boolean;
  13. /** @internal */
  14. occlusionRetryCount: number;
  15. /** @internal */
  16. occlusionType: number;
  17. /** @internal */
  18. occlusionQueryAlgorithmType: number;
  19. /** @internal */
  20. forceRenderingWhenOccluded: boolean;
  21. }
  22. declare module "../../Engines/abstractEngine" {
  23. interface AbstractEngine {
  24. /**
  25. * Get the performance counter associated with the frame time computation
  26. * @returns the perf counter
  27. */
  28. getGPUFrameTimeCounter(): Nullable<PerfCounter>;
  29. /**
  30. * Enable or disable the GPU frame time capture
  31. * @param value True to enable, false to disable
  32. */
  33. captureGPUFrameTime(value: boolean): void;
  34. /**
  35. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  36. * @returns the new query
  37. */
  38. createQuery(): Nullable<OcclusionQuery>;
  39. /**
  40. * Delete and release a webGL query
  41. * @param query defines the query to delete
  42. * @returns the current engine
  43. */
  44. deleteQuery(query: OcclusionQuery): AbstractEngine /**
  45. * Check if a given query has resolved and got its value
  46. * @param query defines the query to check
  47. * @returns true if the query got its value
  48. */;
  49. isQueryResultAvailable(query: OcclusionQuery): boolean;
  50. /**
  51. * Gets the value of a given query
  52. * @param query defines the query to check
  53. * @returns the value of the query
  54. */
  55. getQueryResult(query: OcclusionQuery): number;
  56. /**
  57. * Initiates an occlusion query
  58. * @param algorithmType defines the algorithm to use
  59. * @param query defines the query to use
  60. * @returns the current engine
  61. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  62. */
  63. beginOcclusionQuery(algorithmType: number, query: OcclusionQuery): boolean;
  64. /**
  65. * Ends an occlusion query
  66. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  67. * @param algorithmType defines the algorithm to use
  68. * @returns the current engine
  69. */
  70. endOcclusionQuery(algorithmType: number): AbstractEngine;
  71. }
  72. }
  73. declare module "../../Meshes/abstractMesh" {
  74. interface AbstractMesh {
  75. /**
  76. * Backing filed
  77. * @internal
  78. */
  79. __occlusionDataStorage: _OcclusionDataStorage;
  80. /**
  81. * Access property
  82. * @internal
  83. */
  84. _occlusionDataStorage: _OcclusionDataStorage;
  85. /**
  86. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retrieved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decides to show or hide the object.
  87. * The default value is -1 which means don't break the query and wait till the result
  88. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  89. */
  90. occlusionRetryCount: number;
  91. /**
  92. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  93. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query within the Mesh.
  94. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  95. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  96. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  97. */
  98. occlusionType: number;
  99. /**
  100. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  101. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  102. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  103. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  104. */
  105. occlusionQueryAlgorithmType: number;
  106. /**
  107. * Gets or sets whether the mesh is occluded or not, it is used also to set the initial state of the mesh to be occluded or not
  108. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  109. */
  110. isOccluded: boolean;
  111. /**
  112. * Flag to check the progress status of the query
  113. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  114. */
  115. isOcclusionQueryInProgress: boolean;
  116. /**
  117. * Flag to force rendering the mesh even if occluded
  118. * @see https://doc.babylonjs.com/features/featuresDeepDive/occlusionQueries
  119. */
  120. forceRenderingWhenOccluded: boolean;
  121. }
  122. }