directionalLight.d.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import type { Camera } from "../Cameras/camera";
  2. import type { Scene } from "../scene";
  3. import { Matrix, Vector3 } from "../Maths/math.vector";
  4. import type { AbstractMesh } from "../Meshes/abstractMesh";
  5. import { Light } from "./light";
  6. import { ShadowLight } from "./shadowLight";
  7. import type { Effect } from "../Materials/effect";
  8. /**
  9. * A directional light is defined by a direction (what a surprise!).
  10. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  11. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  12. * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction
  13. */
  14. export declare class DirectionalLight extends ShadowLight {
  15. private _shadowFrustumSize;
  16. /**
  17. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  18. */
  19. get shadowFrustumSize(): number;
  20. /**
  21. * Specifies a fix frustum size for the shadow generation.
  22. */
  23. set shadowFrustumSize(value: number);
  24. private _shadowOrthoScale;
  25. /**
  26. * Gets the shadow projection scale against the optimal computed one.
  27. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  28. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  29. */
  30. get shadowOrthoScale(): number;
  31. /**
  32. * Sets the shadow projection scale against the optimal computed one.
  33. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  34. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  35. */
  36. set shadowOrthoScale(value: number);
  37. /**
  38. * Automatically compute the projection matrix to best fit (including all the casters)
  39. * on each frame.
  40. */
  41. autoUpdateExtends: boolean;
  42. /**
  43. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  44. * on each frame. autoUpdateExtends must be set to true for this to work
  45. */
  46. autoCalcShadowZBounds: boolean;
  47. private _orthoLeft;
  48. private _orthoRight;
  49. private _orthoTop;
  50. private _orthoBottom;
  51. /**
  52. * Gets or sets the orthoLeft property used to build the light frustum
  53. */
  54. get orthoLeft(): number;
  55. set orthoLeft(left: number);
  56. /**
  57. * Gets or sets the orthoRight property used to build the light frustum
  58. */
  59. get orthoRight(): number;
  60. set orthoRight(right: number);
  61. /**
  62. * Gets or sets the orthoTop property used to build the light frustum
  63. */
  64. get orthoTop(): number;
  65. set orthoTop(top: number);
  66. /**
  67. * Gets or sets the orthoBottom property used to build the light frustum
  68. */
  69. get orthoBottom(): number;
  70. set orthoBottom(bottom: number);
  71. /**
  72. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  73. * The directional light is emitted from everywhere in the given direction.
  74. * It can cast shadows.
  75. * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction
  76. * @param name The friendly name of the light
  77. * @param direction The direction of the light
  78. * @param scene The scene the light belongs to
  79. */
  80. constructor(name: string, direction: Vector3, scene?: Scene);
  81. /**
  82. * Returns the string "DirectionalLight".
  83. * @returns The class name
  84. */
  85. getClassName(): string;
  86. /**
  87. * Returns the integer 1.
  88. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  89. */
  90. getTypeID(): number;
  91. /**
  92. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  93. * Returns the DirectionalLight Shadow projection matrix.
  94. * @param matrix
  95. * @param viewMatrix
  96. * @param renderList
  97. */
  98. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  99. /**
  100. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101. * Returns the DirectionalLight Shadow projection matrix.
  102. * @param matrix
  103. */
  104. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105. /**
  106. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  107. * Returns the DirectionalLight Shadow projection matrix.
  108. * @param matrix
  109. * @param viewMatrix
  110. * @param renderList
  111. */
  112. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113. protected _buildUniformLayout(): void;
  114. /**
  115. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  116. * @param effect The effect to update
  117. * @param lightIndex The index of the light in the effect to update
  118. * @returns The directional light
  119. */
  120. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  121. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122. /**
  123. * Gets the minZ used for shadow according to both the scene and the light.
  124. *
  125. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  126. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  127. * (when not using reverse depth buffer / NDC half Z range)
  128. * @param activeCamera The camera we are returning the min for
  129. * @returns the depth min z
  130. */
  131. getDepthMinZ(activeCamera: Camera): number;
  132. /**
  133. * Gets the maxZ used for shadow according to both the scene and the light.
  134. *
  135. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  136. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  137. * (when not using reverse depth buffer / NDC half Z range)
  138. * @param activeCamera The camera we are returning the max for
  139. * @returns the depth max z
  140. */
  141. getDepthMaxZ(activeCamera: Camera): number;
  142. /**
  143. * Prepares the list of defines specific to the light type.
  144. * @param defines the list of defines
  145. * @param lightIndex defines the index of the light for the effect
  146. */
  147. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  148. }