sceneComponent.d.ts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. import type { Scene } from "./scene";
  2. import type { SmartArrayNoDuplicate } from "./Misc/smartArray";
  3. import type { Nullable } from "./types";
  4. import type { PickingInfo } from "./Collisions/pickingInfo";
  5. import type { AbstractScene } from "./abstractScene";
  6. import type { IPointerEvent } from "./Events/deviceInputEvents";
  7. import type { Mesh } from "./Meshes/mesh";
  8. import type { Effect } from "./Materials/effect";
  9. import type { Camera } from "./Cameras/camera";
  10. import type { AbstractMesh } from "./Meshes/abstractMesh";
  11. import type { SubMesh } from "./Meshes/subMesh";
  12. import type { RenderTargetTexture } from "./Materials/Textures/renderTargetTexture";
  13. /**
  14. * Groups all the scene component constants in one place to ease maintenance.
  15. * @internal
  16. */
  17. export declare class SceneComponentConstants {
  18. static readonly NAME_EFFECTLAYER = "EffectLayer";
  19. static readonly NAME_LAYER = "Layer";
  20. static readonly NAME_LENSFLARESYSTEM = "LensFlareSystem";
  21. static readonly NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  22. static readonly NAME_PARTICLESYSTEM = "ParticleSystem";
  23. static readonly NAME_GAMEPAD = "Gamepad";
  24. static readonly NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  25. static readonly NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  26. static readonly NAME_PREPASSRENDERER = "PrePassRenderer";
  27. static readonly NAME_DEPTHRENDERER = "DepthRenderer";
  28. static readonly NAME_DEPTHPEELINGRENDERER = "DepthPeelingRenderer";
  29. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  30. static readonly NAME_SPRITE = "Sprite";
  31. static readonly NAME_SUBSURFACE = "SubSurface";
  32. static readonly NAME_OUTLINERENDERER = "Outline";
  33. static readonly NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  34. static readonly NAME_SHADOWGENERATOR = "ShadowGenerator";
  35. static readonly NAME_OCTREE = "Octree";
  36. static readonly NAME_PHYSICSENGINE = "PhysicsEngine";
  37. static readonly NAME_AUDIO = "Audio";
  38. static readonly NAME_FLUIDRENDERER = "FluidRenderer";
  39. static readonly STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  40. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  41. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  42. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  43. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  44. static readonly STEP_BEFORECAMERADRAW_PREPASS = 0;
  45. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER = 1;
  46. static readonly STEP_BEFORECAMERADRAW_LAYER = 2;
  47. static readonly STEP_BEFORERENDERTARGETDRAW_PREPASS = 0;
  48. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER = 1;
  49. static readonly STEP_BEFORERENDERINGMESH_PREPASS = 0;
  50. static readonly STEP_BEFORERENDERINGMESH_OUTLINE = 1;
  51. static readonly STEP_AFTERRENDERINGMESH_PREPASS = 0;
  52. static readonly STEP_AFTERRENDERINGMESH_OUTLINE = 1;
  53. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  54. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  55. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  56. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  57. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  58. static readonly STEP_BEFORECLEAR_PREPASS = 1;
  59. static readonly STEP_BEFORERENDERTARGETCLEAR_PREPASS = 0;
  60. static readonly STEP_AFTERRENDERTARGETDRAW_PREPASS = 0;
  61. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER = 1;
  62. static readonly STEP_AFTERCAMERADRAW_PREPASS = 0;
  63. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER = 1;
  64. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 2;
  65. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 3;
  66. static readonly STEP_AFTERCAMERADRAW_LAYER = 4;
  67. static readonly STEP_AFTERCAMERADRAW_FLUIDRENDERER = 5;
  68. static readonly STEP_AFTERCAMERAPOSTPROCESS_LAYER = 0;
  69. static readonly STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER = 0;
  70. static readonly STEP_AFTERRENDER_AUDIO = 0;
  71. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 0;
  72. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  73. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 2;
  74. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  75. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  76. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER = 1;
  77. static readonly STEP_POINTERMOVE_SPRITE = 0;
  78. static readonly STEP_POINTERDOWN_SPRITE = 0;
  79. static readonly STEP_POINTERUP_SPRITE = 0;
  80. }
  81. /**
  82. * This represents a scene component.
  83. *
  84. * This is used to decouple the dependency the scene is having on the different workloads like
  85. * layers, post processes...
  86. */
  87. export interface ISceneComponent {
  88. /**
  89. * The name of the component. Each component must have a unique name.
  90. */
  91. name: string;
  92. /**
  93. * The scene the component belongs to.
  94. */
  95. scene: Scene;
  96. /**
  97. * Register the component to one instance of a scene.
  98. */
  99. register(): void;
  100. /**
  101. * Rebuilds the elements related to this component in case of
  102. * context lost for instance.
  103. */
  104. rebuild(): void;
  105. /**
  106. * Disposes the component and the associated ressources.
  107. */
  108. dispose(): void;
  109. }
  110. /**
  111. * This represents a SERIALIZABLE scene component.
  112. *
  113. * This extends Scene Component to add Serialization methods on top.
  114. */
  115. export interface ISceneSerializableComponent extends ISceneComponent {
  116. /**
  117. * Adds all the elements from the container to the scene
  118. * @param container the container holding the elements
  119. */
  120. addFromContainer(container: AbstractScene): void;
  121. /**
  122. * Removes all the elements in the container from the scene
  123. * @param container contains the elements to remove
  124. * @param dispose if the removed element should be disposed (default: false)
  125. */
  126. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127. /**
  128. * Serializes the component data to the specified json object
  129. * @param serializationObject The object to serialize to
  130. */
  131. serialize(serializationObject: any): void;
  132. }
  133. /**
  134. * Strong typing of a Mesh related stage step action
  135. */
  136. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  137. /**
  138. * Strong typing of a Evaluate Sub Mesh related stage step action
  139. */
  140. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  141. /**
  142. * Strong typing of a pre active Mesh related stage step action
  143. */
  144. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  145. /**
  146. * Strong typing of a Camera related stage step action
  147. */
  148. export type CameraStageAction = (camera: Camera) => void;
  149. /**
  150. * Strong typing of a Camera Frame buffer related stage step action
  151. */
  152. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  153. /**
  154. * Strong typing of a Render Target related stage step action
  155. */
  156. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture, faceIndex?: number, layer?: number) => void;
  157. /**
  158. * Strong typing of a RenderingGroup related stage step action
  159. */
  160. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  161. /**
  162. * Strong typing of a Mesh Render related stage step action
  163. */
  164. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: any, effect: Nullable<Effect>) => void;
  165. /**
  166. * Strong typing of a simple stage step action
  167. */
  168. export type SimpleStageAction = () => void;
  169. /**
  170. * Strong typing of a render target action.
  171. */
  172. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  173. /**
  174. * Strong typing of a pointer move action.
  175. */
  176. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: Nullable<HTMLElement>) => Nullable<PickingInfo>;
  177. /**
  178. * Strong typing of a pointer up/down action.
  179. */
  180. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: IPointerEvent, doubleClick: boolean) => Nullable<PickingInfo>;
  181. /**
  182. * Representation of a stage in the scene (Basically a list of ordered steps)
  183. * @internal
  184. */
  185. export declare class Stage<T extends Function> extends Array<{
  186. index: number;
  187. component: ISceneComponent;
  188. action: T;
  189. }> {
  190. /**
  191. * Hide ctor from the rest of the world.
  192. * @param items The items to add.
  193. */
  194. private constructor();
  195. /**
  196. * Creates a new Stage.
  197. * @returns A new instance of a Stage
  198. */
  199. static Create<T extends Function>(): Stage<T>;
  200. /**
  201. * Registers a step in an ordered way in the targeted stage.
  202. * @param index Defines the position to register the step in
  203. * @param component Defines the component attached to the step
  204. * @param action Defines the action to launch during the step
  205. */
  206. registerStep(index: number, component: ISceneComponent, action: T): void;
  207. /**
  208. * Clears all the steps from the stage.
  209. */
  210. clear(): void;
  211. }