reflectionProbe.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
  2. import { Vector3 } from "../Maths/math.vector";
  3. import type { AbstractMesh } from "../Meshes/abstractMesh";
  4. import type { Nullable } from "../types";
  5. import { AbstractScene } from "../abstractScene";
  6. import type { Scene } from "../scene";
  7. declare module "../abstractScene" {
  8. interface AbstractScene {
  9. /**
  10. * The list of reflection probes added to the scene
  11. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/reflectionProbes
  12. */
  13. reflectionProbes: Array<ReflectionProbe>;
  14. /**
  15. * Removes the given reflection probe from this scene.
  16. * @param toRemove The reflection probe to remove
  17. * @returns The index of the removed reflection probe
  18. */
  19. removeReflectionProbe(toRemove: ReflectionProbe): number;
  20. /**
  21. * Adds the given reflection probe to this scene.
  22. * @param newReflectionProbe The reflection probe to add
  23. */
  24. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  25. }
  26. }
  27. /**
  28. * Class used to generate realtime reflection / refraction cube textures
  29. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/reflectionProbes
  30. */
  31. export declare class ReflectionProbe {
  32. /** defines the name of the probe */
  33. name: string;
  34. private _scene;
  35. private _renderTargetTexture;
  36. private _projectionMatrix;
  37. private _viewMatrix;
  38. private _target;
  39. private _add;
  40. private _attachedMesh;
  41. private _invertYAxis;
  42. private _sceneUBOs;
  43. private _currentSceneUBO;
  44. /** Gets or sets probe position (center of the cube map) */
  45. position: Vector3;
  46. /**
  47. * Gets or sets an object used to store user defined information for the reflection probe.
  48. */
  49. metadata: any;
  50. /** @internal */
  51. _parentContainer: Nullable<AbstractScene>;
  52. /**
  53. * Creates a new reflection probe
  54. * @param name defines the name of the probe
  55. * @param size defines the texture resolution (for each face)
  56. * @param scene defines the hosting scene
  57. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58. * @param useFloat defines if HDR data (float data) should be used to store colors (false by default)
  59. * @param linearSpace defines if the probe should be generated in linear space or not (false by default)
  60. */
  61. constructor(
  62. /** defines the name of the probe */
  63. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean, linearSpace?: boolean);
  64. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65. get samples(): number;
  66. set samples(value: number);
  67. /** Gets or sets the refresh rate to use (on every frame by default) */
  68. get refreshRate(): number;
  69. set refreshRate(value: number);
  70. /**
  71. * Gets the hosting scene
  72. * @returns a Scene
  73. */
  74. getScene(): Scene;
  75. /** Gets the internal CubeTexture used to render to */
  76. get cubeTexture(): RenderTargetTexture;
  77. /** Gets or sets the list of meshes to render */
  78. get renderList(): Nullable<AbstractMesh[]>;
  79. set renderList(value: Nullable<AbstractMesh[]>);
  80. /**
  81. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  82. * @param mesh defines the mesh to attach to
  83. */
  84. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  85. /**
  86. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  87. * @param renderingGroupId The rendering group id corresponding to its index
  88. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89. */
  90. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91. /**
  92. * Clean all associated resources
  93. */
  94. dispose(): void;
  95. /**
  96. * Converts the reflection probe information to a readable string for debug purpose.
  97. * @param fullDetails Supports for multiple levels of logging within scene loading
  98. * @returns the human readable reflection probe info
  99. */
  100. toString(fullDetails?: boolean): string;
  101. /**
  102. * Get the class name of the refection probe.
  103. * @returns "ReflectionProbe"
  104. */
  105. getClassName(): string;
  106. /**
  107. * Serialize the reflection probe to a JSON representation we can easily use in the respective Parse function.
  108. * @returns The JSON representation of the texture
  109. */
  110. serialize(): any;
  111. /**
  112. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  113. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114. * @param scene Define the scene the parsed reflection probe should be instantiated in
  115. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116. * @returns The parsed reflection probe if successful
  117. */
  118. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119. }