babylonjs-addons 8.26.1 → 8.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
 
2
2
  declare module "babylonjs-addons/index" {
3
+ export * from "babylonjs-addons/atmosphere/index";
3
4
  export * from "babylonjs-addons/htmlMesh/index";
4
5
  export * from "babylonjs-addons/msdfText/index";
5
6
 
@@ -136,7 +137,7 @@ export class TextRenderer implements IDisposable {
136
137
 
137
138
  }
138
139
  declare module "babylonjs-addons/msdfText/paragraphOptions" {
139
- import { IVector2Like } from "babylonjs/Maths";
140
+ import { IVector2Like } from "babylonjs/Maths/math.like";
140
141
  /** @internal */
141
142
  export type ParagraphOptions = {
142
143
  maxWidth: number;
@@ -752,693 +753,3101 @@ export const FitStrategy: {
752
753
  };
753
754
 
754
755
  }
756
+ declare module "babylonjs-addons/atmosphere/transmittanceLut" {
757
+ import { Atmosphere } from "babylonjs-addons/atmosphere/atmosphere";
758
+ import { DirectionalLight } from "babylonjs/Lights/directionalLight";
759
+ import { IColor3Like, IVector3Like } from "babylonjs/Maths/math.like";
760
+ import { Observable } from "babylonjs/Misc/observable";
761
+ import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
762
+ import "babylonjs-addons/atmosphere/Shaders/fullscreenTriangle.vertex";
763
+ import "babylonjs-addons/atmosphere/Shaders/transmittance.fragment";
764
+ /**
765
+ * The transmittance LUT can be used to get the radiance from an external light source arriving a given point, accounting for atmospheric scattering.
766
+ */
767
+ export class TransmittanceLut {
768
+ /**
769
+ * Listen to this observer to know when the LUT data has been updated.
770
+ * This is typically infrequent (once at startup), but also happens whenever the atmosphere's properties change.
771
+ */
772
+ readonly onUpdatedObservable: Observable<void>;
773
+ private readonly _atmosphere;
774
+ private _lutData;
775
+ private _renderTarget;
776
+ private _effectWrapper;
777
+ private _effectRenderer;
778
+ private _isDirty;
779
+ private _isDisposed;
780
+ /**
781
+ * True if the LUT has been rendered.
782
+ */
783
+ get isDirty(): boolean;
784
+ /**
785
+ * The render target that contains the transmittance LUT.
786
+ * @throws if the LUT has been disposed.
787
+ */
788
+ get renderTarget(): RenderTargetTexture;
789
+ /**
790
+ * Constructs the {@link TransmittanceLut}.
791
+ * @param atmosphere - The atmosphere that owns this LUT.
792
+ */
793
+ constructor(atmosphere: Atmosphere);
794
+ /**
795
+ * Gets the transmittance of an external light through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.
796
+ * The result is always a linear space color.
797
+ * @param directionToLight - The direction to the light source.
798
+ * @param pointRadius - The distance from the origin to the point.
799
+ * @param pointGeocentricNormal - The normal of the point.
800
+ * @param result - The color to write the result to.
801
+ * @returns The result color.
802
+ */
803
+ getTransmittedColorToRef<T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, result: T): T;
804
+ /**
805
+ * Derives light color from the transmittance at a point specified by its distance to the planet center and its geocentric normal.
806
+ * @param light - The light to update.
807
+ * @param pointRadius - The distance from the origin to the point.
808
+ * @param pointGeocentricNormal - The normal of the point.
809
+ */
810
+ updateLightParameters(light: DirectionalLight, pointRadius: number, pointGeocentricNormal: IVector3Like): void;
811
+ /**
812
+ * Renders the LUT if needed.
813
+ * @returns true if the LUT was rendered.
814
+ */
815
+ render(): boolean;
816
+ /**
817
+ * Marks the LUT as needing to be rendered.
818
+ */
819
+ markDirty(): void;
820
+ /**
821
+ * Disposes the LUT and its resources.
822
+ */
823
+ dispose(): void;
824
+ }
825
+
826
+ }
827
+ declare module "babylonjs-addons/atmosphere/sampling" {
828
+ import { IColor4Like } from "babylonjs/Maths/math.like";
829
+ /**
830
+ * Samples the texture data at the given uv coordinate using bilinear interpolation.
831
+ * Note this will not match GPU sampling behavior exactly.
832
+ * Currently assumes clamping behavior.
833
+ * @param u - The u coordinate to sample.
834
+ * @param v - The v coordinate to sample.
835
+ * @param widthPx - The width of the texture in texels.
836
+ * @param heightPx - The height of the texture in texels.
837
+ * @param data - The texture data to sample.
838
+ * @param result - The color to store the sample.
839
+ * @param normalizeFunc - The function to normalize the texel values. Default is to divide by 255.
840
+ * @returns The result color.
841
+ */
842
+ export const Sample2DRgbaToRef: <T extends IColor4Like>(u: number, v: number, widthPx: number, heightPx: number, data: Uint8Array | Uint16Array | Float32Array, result: T, normalizeFunc?: (value: number) => number) => T;
843
+
844
+ }
845
+ declare module "babylonjs-addons/atmosphere/index" {
846
+ export * from "babylonjs-addons/atmosphere/atmosphere";
847
+ export * from "babylonjs-addons/atmosphere/atmosphereOptions";
848
+ export * from "babylonjs-addons/atmosphere/atmospherePhysicalProperties";
849
+ export * from "babylonjs-addons/atmosphere/atmospherePhysicalPropertiesOptions";
850
+ export * from "babylonjs-addons/atmosphere/diffuseSkyIrradianceLut";
851
+ export * from "babylonjs-addons/atmosphere/transmittanceLut";
852
+
853
+ }
854
+ declare module "babylonjs-addons/atmosphere/diffuseSkyIrradianceLut" {
855
+ import { Atmosphere } from "babylonjs-addons/atmosphere/atmosphere";
856
+ import { IColor3Like, IVector3Like } from "babylonjs/Maths/math.like";
857
+ import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
858
+ import "babylonjs-addons/atmosphere/Shaders/diffuseSkyIrradiance.fragment";
859
+ import "babylonjs-addons/atmosphere/Shaders/fullscreenTriangle.vertex";
860
+ /**
861
+ * The diffuse sky irradiance LUT is used to query the diffuse irradiance at a specified position.
862
+ */
863
+ export class DiffuseSkyIrradianceLut {
864
+ private readonly _atmosphere;
865
+ private _renderTarget;
866
+ private _effectWrapper;
867
+ private _effectRenderer;
868
+ private _isDirty;
869
+ private _isDisposed;
870
+ private _lutData;
871
+ /**
872
+ * True if the LUT needs to be rendered.
873
+ */
874
+ get isDirty(): boolean;
875
+ /**
876
+ * True if the LUT has been disposed.
877
+ */
878
+ get isDisposed(): boolean;
879
+ /**
880
+ * The render target used for this LUT.
881
+ * @throws if the LUT has been disposed.
882
+ */
883
+ get renderTarget(): RenderTargetTexture;
884
+ /**
885
+ * True if the LUT data has been read back from the GPU.
886
+ */
887
+ get hasLutData(): boolean;
888
+ /**
889
+ * Constructs the {@link DiffuseSkyIrradianceLut}.
890
+ * @param atmosphere - The atmosphere to use.
891
+ */
892
+ constructor(atmosphere: Atmosphere);
893
+ /**
894
+ * Gets the diffuse sky irradiance for a surface oriented along the geocentric normal.
895
+ * Resulting color is always in linear space.
896
+ * @param directionToLight - The direction to the light in world space.
897
+ * @param radius - The position's distance to the planet origin.
898
+ * @param cameraGeocentricNormal - The geocentric normal of the camera.
899
+ * @param lightIrradiance - The irradiance of the light.
900
+ * @param result - The color to store the result in.
901
+ * @returns The result color.
902
+ */
903
+ getDiffuseSkyIrradianceToRef<T extends IColor3Like>(directionToLight: IVector3Like, radius: number, cameraGeocentricNormal: IVector3Like, lightIrradiance: number, result: T): T;
904
+ /**
905
+ * Renders the LUT.
906
+ * @returns True if the LUT was rendered.
907
+ */
908
+ render(): boolean;
909
+ /**
910
+ * Marks the LUT as needing to be rendered.
911
+ */
912
+ markDirty(): void;
913
+ /**
914
+ * Disposes the LUT.
915
+ */
916
+ dispose(): void;
917
+ }
918
+
919
+ }
920
+ declare module "babylonjs-addons/atmosphere/atmospherePhysicalPropertiesOptions" {
921
+ import { Vector3 } from "babylonjs/Maths/math.vector";
922
+ /**
923
+ * The options for the {@link AtmospherePhysicalProperties} that describe the planet, the atmosphere, and scattering.
924
+ */
925
+ export interface IAtmospherePhysicalPropertiesOptions {
926
+ /**
927
+ * The radius of the planet in kilometers.
928
+ */
929
+ planetRadius?: number;
930
+ /**
931
+ * The minimum camera radius (distance from the planet's center) allowed when rendering the atmosphere.
932
+ * This should be greater than 0.
933
+ * It prevents rendering issues close to the planet's surface.
934
+ */
935
+ planetRadiusOffset?: number;
936
+ /**
937
+ * The thickness of the atmosphere measured in kilometers from the planet's surface to the outer edge of the atmosphere.
938
+ */
939
+ atmosphereThickness?: number;
940
+ /**
941
+ * The scale applied to the Rayleigh scattering.
942
+ */
943
+ rayleighScatteringScale?: number;
944
+ /**
945
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
946
+ */
947
+ peakRayleighScattering?: Vector3;
948
+ /**
949
+ * The scale applied to the Mie scattering.
950
+ */
951
+ mieScatteringScale?: number;
952
+ /**
953
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
954
+ */
955
+ peakMieScattering?: Vector3;
956
+ /**
957
+ * The scale applied to the Mie absorption.
958
+ */
959
+ mieAbsorptionScale?: number;
960
+ /**
961
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
962
+ */
963
+ peakMieAbsorption?: Vector3;
964
+ /**
965
+ * The scale applied to the ozone absorption.
966
+ */
967
+ ozoneAbsorptionScale?: number;
968
+ /**
969
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
970
+ */
971
+ peakOzoneAbsorption?: Vector3;
972
+ }
973
+
974
+ }
975
+ declare module "babylonjs-addons/atmosphere/atmospherePhysicalProperties" {
976
+ import { IAtmospherePhysicalPropertiesOptions } from "babylonjs-addons/atmosphere/atmospherePhysicalPropertiesOptions";
977
+ import { Observable } from "babylonjs/Misc/observable";
978
+ import { Vector3 } from "babylonjs/Maths/math.vector";
979
+ /**
980
+ * Describes the physical properties of the atmosphere. Assumes a spherical planet.
981
+ * - "radius" values describe a distance from the planet's center.
982
+ * - "height" values describe a distance from the planet's surface.
983
+ * - Distances are in kilometers unless otherwise specified. Angles are in radians.
984
+ */
985
+ export class AtmospherePhysicalProperties {
986
+ /**
987
+ * Notification for when properties of the {@link AtmospherePhysicalProperties} are changed.
988
+ */
989
+ readonly onChangedObservable: Observable<AtmospherePhysicalProperties>;
990
+ private _planetRadius;
991
+ private _planetRadiusOffset;
992
+ private _atmosphereThickness;
993
+ private _rayleighScatteringScale;
994
+ private _peakRayleighScattering;
995
+ private _mieScatteringScale;
996
+ private _peakMieScattering;
997
+ private _mieAbsorptionScale;
998
+ private _peakMieAbsorption;
999
+ private _ozoneAbsorptionScale;
1000
+ private _peakOzoneAbsorption;
1001
+ private _planetRadiusWithOffset;
1002
+ private _planetRadiusSquared;
1003
+ private _atmosphereRadius;
1004
+ private _atmosphereRadiusSquared;
1005
+ private _horizonDistanceToAtmosphereEdge;
1006
+ private _horizonDistanceToAtmosphereEdgeSquared;
1007
+ private _rayleighScattering;
1008
+ private _mieScattering;
1009
+ private _mieAbsorption;
1010
+ private _mieExtinction;
1011
+ private _ozoneAbsorption;
1012
+ /**
1013
+ * The radius of the planet in kilometers.
1014
+ */
1015
+ get planetRadius(): number;
1016
+ set planetRadius(value: number);
1017
+ /**
1018
+ * The squared radius of the planet in kilometers.
1019
+ */
1020
+ get planetRadiusSquared(): number;
1021
+ /**
1022
+ * Offset applied to view points near the planet's surface. This should be greater than 0.
1023
+ * It prevents rendering issues close to the planet's surface.
1024
+ */
1025
+ get planetRadiusOffset(): number;
1026
+ set planetRadiusOffset(value: number);
1027
+ /**
1028
+ * This is the {@link planetRadius} with the additional {@link planetRadiusOffset}, in kilometers.
1029
+ */
1030
+ get planetRadiusWithOffset(): number;
1031
+ /**
1032
+ * The thickness of the atmosphere measured in kilometers.
1033
+ */
1034
+ get atmosphereThickness(): number;
1035
+ set atmosphereThickness(value: number);
1036
+ /**
1037
+ * The combined planet radius and atmosphere thickness in kilometers.
1038
+ */
1039
+ get atmosphereRadius(): number;
1040
+ /**
1041
+ * The atmosphere radius squared in kilometers.
1042
+ */
1043
+ get atmosphereRadiusSquared(): number;
1044
+ /**
1045
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere in kilometers.
1046
+ */
1047
+ get horizonDistanceToAtmosphereEdge(): number;
1048
+ /**
1049
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere, squared, in kilometers.
1050
+ */
1051
+ get horizonDistanceToAtmosphereEdgeSquared(): number;
1052
+ /**
1053
+ * The scale applied to {@link peakRayleighScattering}.
1054
+ */
1055
+ get rayleighScatteringScale(): number;
1056
+ set rayleighScatteringScale(value: number);
1057
+ /**
1058
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
1059
+ */
1060
+ get peakRayleighScattering(): Vector3;
1061
+ set peakRayleighScattering(value: Vector3);
1062
+ /**
1063
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
1064
+ * This value cannot be set directly. It is inferred by scaling {@link peakRayleighScattering} by {@link rayleighScatteringScale}.
1065
+ */
1066
+ get rayleighScattering(): Vector3;
1067
+ /**
1068
+ * The scale applied to {@link peakMieScattering}.
1069
+ */
1070
+ get mieScatteringScale(): number;
1071
+ set mieScatteringScale(value: number);
1072
+ /**
1073
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
1074
+ */
1075
+ get peakMieScattering(): Vector3;
1076
+ set peakMieScattering(value: Vector3);
1077
+ /**
1078
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
1079
+ * This value cannot be set directly. It is inferred by scaling {@link mieScatteringScale} by {@link peakMieScattering}.
1080
+ */
1081
+ get mieScattering(): Vector3;
1082
+ /**
1083
+ * The scale applied to {@link peakMieAbsorption}.
1084
+ */
1085
+ get mieAbsorptionScale(): number;
1086
+ set mieAbsorptionScale(value: number);
1087
+ /**
1088
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
1089
+ */
1090
+ get peakMieAbsorption(): Vector3;
1091
+ set peakMieAbsorption(value: Vector3);
1092
+ /**
1093
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
1094
+ * This value cannot be set directly. It is inferred by scaling {@link mieAbsorptionScale} by {@link peakMieAbsorption}.
1095
+ */
1096
+ get mieAbsorption(): Vector3;
1097
+ /**
1098
+ * The Mie extinction per kilometer at sea level for red, green, and blue wavelengths.
1099
+ * This value cannot be set directly. It is inferred by adding the {@link mieAbsorption} to the {@link mieScattering}.
1100
+ */
1101
+ get mieExtinction(): Vector3;
1102
+ /**
1103
+ * The scale applied to {@link peakOzoneAbsorption}.
1104
+ */
1105
+ get ozoneAbsorptionScale(): number;
1106
+ set ozoneAbsorptionScale(value: number);
1107
+ /**
1108
+ * The ozone absorption per kilometer measured at a height corresponding to it's peak concentration,
1109
+ * for red, green, and blue wavelengths.
1110
+ */
1111
+ get peakOzoneAbsorption(): Vector3;
1112
+ set peakOzoneAbsorption(value: Vector3);
1113
+ /**
1114
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
1115
+ * This value cannot be set directly. It is inferred by scaling {@link peakOzoneAbsorption} by {@link ozoneAbsorptionScale}.
1116
+ */
1117
+ get ozoneAbsorption(): Vector3;
1118
+ /**
1119
+ * Constructs the {@link AtmospherePhysicalProperties}.
1120
+ * @param options - The options for the {@link AtmospherePhysicalProperties}.
1121
+ */
1122
+ constructor(options?: IAtmospherePhysicalPropertiesOptions);
1123
+ private _recomputeDimensionalParameters;
1124
+ private _recomputeRayleighScattering;
1125
+ private _recomputeMieScattering;
1126
+ private _recomputeMieAbsorption;
1127
+ private _recomputeMieExtinction;
1128
+ private _recomputeOzoneAbsorption;
1129
+ }
1130
+
1131
+ }
1132
+ declare module "babylonjs-addons/atmosphere/atmospherePerCameraVariables" {
1133
+ import { Camera } from "babylonjs/Cameras/camera";
1134
+ import { IMatrixLike, IVector3Like, IVector4Like } from "babylonjs/Maths/math.like";
1135
+ /**
1136
+ * Variables that are used to render the atmosphere and are computed per-camera.
1137
+ */
1138
+ export class AtmospherePerCameraVariables {
1139
+ private _inverseViewProjectionMatrixWithoutTranslation;
1140
+ private _directionToLightRelativeToCameraGeocentricNormal;
1141
+ private _cosAngleLightToZenith;
1142
+ private _cameraRadius;
1143
+ private _clampedCameraRadius;
1144
+ private _cameraHeight;
1145
+ private _clampedCameraHeight;
1146
+ private _cameraPositionGlobal;
1147
+ private _clampedCameraPositionGlobal;
1148
+ private _cosCameraHorizonAngleFromZenith;
1149
+ private _sinCameraAtmosphereHorizonAngleFromNadir;
1150
+ private _cameraGeocentricNormal;
1151
+ private _cameraForward;
1152
+ private _cameraNearPlane;
1153
+ private _cameraPosition;
1154
+ private _viewport;
1155
+ private _lastViewMatrix;
1156
+ private _lastProjectionMatrix;
1157
+ private _inverseViewMatrixWithoutTranslation;
1158
+ private _inverseProjectionMatrix;
1159
+ /**
1160
+ * The inverse view projection matrix is used to unproject rays.
1161
+ * To avoid precision issues, the translation part of the matrix has been removed.
1162
+ */
1163
+ get inverseViewProjectionMatrixWithoutTranslation(): IMatrixLike;
1164
+ /**
1165
+ * The direction to the light relative to the geocentric normal under the camera.
1166
+ */
1167
+ get directionToLightRelativeToCameraGeocentricNormal(): IVector3Like;
1168
+ /**
1169
+ * The cosine of the angle between the light direction and zenith.
1170
+ */
1171
+ get cosAngleLightToZenith(): number;
1172
+ /**
1173
+ * The distance from the camera to the planet origin in kilometers.
1174
+ */
1175
+ get cameraRadius(): number;
1176
+ /**
1177
+ * The distance from the camera to the planet origin, clamped to the planet radius offset, in kilometers.
1178
+ */
1179
+ get clampedCameraRadius(): number;
1180
+ /**
1181
+ * The height of the camera above the planet surface in kilometers.
1182
+ */
1183
+ get cameraHeight(): number;
1184
+ /**
1185
+ * The height of the camera above the planet surface, clamped to the planet radius offset, in kilometers.
1186
+ */
1187
+ get clampedCameraHeight(): number;
1188
+ /**
1189
+ * The camera position in global space kilometers.
1190
+ */
1191
+ get cameraPositionGlobal(): IVector3Like;
1192
+ /**
1193
+ * The camera position, clamped to the planet radius offset, in global space kilometers.
1194
+ */
1195
+ get clampedCameraPositionGlobal(): IVector3Like;
1196
+ /**
1197
+ * The cosine of the angle from the zenith to the horizon of the planet, measured from the camera position.
1198
+ */
1199
+ get cosCameraHorizonAngleFromZenith(): number;
1200
+ /**
1201
+ * The sine of the angle from the nadir to the horizon of the atmosphere, measured from the camera position.
1202
+ */
1203
+ get sinCameraAtmosphereHorizonAngleFromNadir(): number;
1204
+ /**
1205
+ * The geocentric normal of the camera in global space i.e., the normalization of {@link cameraPositionGlobal}.
1206
+ */
1207
+ get cameraGeocentricNormal(): IVector3Like;
1208
+ /**
1209
+ * The camera's forward direction in world space.
1210
+ */
1211
+ get cameraForward(): IVector3Like;
1212
+ /**
1213
+ * The distance to the near plane of the camera.
1214
+ */
1215
+ get cameraNearPlane(): number;
1216
+ /**
1217
+ * The camera's position in world space.
1218
+ */
1219
+ get cameraPosition(): IVector3Like;
1220
+ /**
1221
+ * The viewport for the camera.
1222
+ */
1223
+ get viewport(): IVector4Like;
1224
+ /**
1225
+ * Updates the variables.
1226
+ * @param camera - The camera to update the variables for.
1227
+ * @param planetRadius - The radius of the planet in kilometers.
1228
+ * @param planetRadiusWithOffset - The radius of the planet with the offset in kilometers.
1229
+ * @param atmosphereRadius - The radius of the atmosphere in kilometers.
1230
+ * @param directionToLight - The direction to the light in world space.
1231
+ * @param originHeight - The height of the origin (distance from planet's surface) in kilometers.
1232
+ */
1233
+ update(camera: Camera, planetRadius: number, planetRadiusWithOffset: number, atmosphereRadius: number, directionToLight: IVector3Like, originHeight: number): void;
1234
+ }
1235
+
1236
+ }
1237
+ declare module "babylonjs-addons/atmosphere/atmospherePBRMaterialPlugin" {
1238
+ import { Atmosphere } from "babylonjs-addons/atmosphere/atmosphere";
1239
+ import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
1240
+ import { Material } from "babylonjs/Materials/material";
1241
+ import { MaterialDefines } from "babylonjs/Materials/materialDefines";
1242
+ import { MaterialPluginBase } from "babylonjs/Materials/materialPluginBase";
1243
+ import { Nullable } from "babylonjs/types";
1244
+ import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
1245
+ class AtmospherePBRMaterialDefines extends MaterialDefines {
1246
+ USE_AERIAL_PERSPECTIVE_LUT: boolean;
1247
+ APPLY_AERIAL_PERSPECTIVE_INTENSITY: boolean;
1248
+ APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS: boolean;
1249
+ /**
1250
+ * Constructs the {@link AtmospherePBRMaterialDefines}.
1251
+ * @param useAerialPerspectiveLut - Whether to use the aerial perspective LUT.
1252
+ */
1253
+ constructor(useAerialPerspectiveLut: boolean);
1254
+ }
1255
+ /**
1256
+ * Adds shading logic to a PBRMaterial that provides radiance, diffuse sky irradiance, and aerial perspective from the atmosphere.
1257
+ */
1258
+ export class AtmospherePBRMaterialPlugin extends MaterialPluginBase {
1259
+ private readonly _atmosphere;
1260
+ private readonly _isAerialPerspectiveEnabled;
1261
+ /**
1262
+ * Constructs the {@link AtmospherePBRMaterialPlugin}.
1263
+ * @param material - The material to apply the plugin to.
1264
+ * @param _atmosphere - The atmosphere to use for shading.
1265
+ * @param _isAerialPerspectiveEnabled - Whether to apply aerial perspective.
1266
+ */
1267
+ constructor(material: Material, _atmosphere: Atmosphere, _isAerialPerspectiveEnabled?: boolean);
1268
+ /**
1269
+ * @override
1270
+ */
1271
+ getUniformBuffersNames(_ubos: string[]): void;
1272
+ /**
1273
+ * @override
1274
+ */
1275
+ getUniforms(): {
1276
+ ubo: {
1277
+ name: string;
1278
+ size: number;
1279
+ type: string;
1280
+ }[];
1281
+ fragment: string;
1282
+ externalUniforms: string[];
1283
+ };
1284
+ /**
1285
+ * @override
1286
+ */
1287
+ isReadyForSubMesh(): boolean;
1288
+ /**
1289
+ * @override
1290
+ */
1291
+ getActiveTextures(_activeTextures: BaseTexture[]): void;
1292
+ /**
1293
+ * @override
1294
+ */
1295
+ bindForSubMesh(uniformBuffer: UniformBuffer): void;
1296
+ /**
1297
+ * @override
1298
+ */
1299
+ prepareDefines(defines: AtmospherePBRMaterialDefines): void;
1300
+ /**
1301
+ * @override
1302
+ */
1303
+ getSamplers(samplers: string[]): void;
1304
+ /**
1305
+ * @override
1306
+ */
1307
+ getCustomCode(shaderType: string): Nullable<Record<string, string>>;
1308
+ }
1309
+ export {};
1310
+
1311
+ }
1312
+ declare module "babylonjs-addons/atmosphere/atmosphereOptions" {
1313
+ import { AtmospherePhysicalProperties } from "babylonjs-addons/atmosphere/atmospherePhysicalProperties";
1314
+ import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
1315
+ import { IColor3Like } from "babylonjs/Maths/math.like";
1316
+ /**
1317
+ * Creation options for the {@link Atmosphere}.
1318
+ */
1319
+ export interface IAtmosphereOptions {
1320
+ /**
1321
+ * The properties that define the atmosphere's composition and size.
1322
+ */
1323
+ physicalProperties?: AtmospherePhysicalProperties;
1324
+ /**
1325
+ * An optional depth texture that will be used by the fullscreen passes that render the sky, aerial perspective, or globe atmosphere.
1326
+ * This enables deferred rendering scenarios, where atmospheric effects need to be composited onto geometry buffers.
1327
+ * Expects infinite far plane on the camera (camera.maxZ = 0) and a non-linear depth to be stored in the red channel.
1328
+ */
1329
+ depthTexture?: BaseTexture;
1330
+ /**
1331
+ * Controls the overall brightness of the atmosphere rendering.
1332
+ * A value of 1.0 is physically correct.
1333
+ */
1334
+ exposure?: number;
1335
+ /**
1336
+ * Whether the light values should be specified in linear space.
1337
+ * Set to true when using PBRMaterials, which expect linear light values.
1338
+ */
1339
+ isLinearSpaceLight?: boolean;
1340
+ /**
1341
+ * Whether the composition of the sky should be in linear space.
1342
+ * Set to true for HDR rendering or when using image post-processes.
1343
+ */
1344
+ isLinearSpaceComposition?: boolean;
1345
+ /**
1346
+ * Whether to apply approximate transmittance to dim surfaces behind the atmosphere.
1347
+ * When true, distant surfaces are dimmed using a grayscale approximation of transmittance.
1348
+ */
1349
+ applyApproximateTransmittance?: boolean;
1350
+ /**
1351
+ * Whether to use the sky view LUT for compositing the sky.
1352
+ * When false, full ray marching is required (slower).
1353
+ */
1354
+ isSkyViewLutEnabled?: boolean;
1355
+ /**
1356
+ * Whether to use the aerial perspective LUT.
1357
+ * When false, full ray marching is required for aerial perspective (slower).
1358
+ */
1359
+ isAerialPerspectiveLutEnabled?: boolean;
1360
+ /**
1361
+ * Radiance bias applied to the aerial perspective.
1362
+ * Positive values brighten the aerial perspective, negative values darken it.
1363
+ * The default is 0 (no change).
1364
+ */
1365
+ aerialPerspectiveRadianceBias?: number;
1366
+ /**
1367
+ * Scale factor for the amount of light transmitted into aerial perspective from the light source.
1368
+ * The default is 1 (no scaling).
1369
+ */
1370
+ aerialPerspectiveTransmittanceScale?: number;
1371
+ /**
1372
+ * Amount of saturation applied to the aerial perspective.
1373
+ * Lower values make the aerial perspective more gray.
1374
+ * The default is 1 (no saturation change).
1375
+ */
1376
+ aerialPerspectiveSaturation?: number;
1377
+ /**
1378
+ * Overall intensity multiplier for the aerial perspective effect.
1379
+ * Higher values increase haziness.
1380
+ * The default is 1 (no intensity change).
1381
+ */
1382
+ aerialPerspectiveIntensity?: number;
1383
+ /**
1384
+ * Whether to use the diffuse sky irradiance LUT.
1385
+ */
1386
+ isDiffuseSkyIrradianceLutEnabled?: boolean;
1387
+ /**
1388
+ * Higher values result in more desaturated diffuse irradiance.
1389
+ * The default is 0 (no desaturation).
1390
+ */
1391
+ diffuseSkyIrradianceDesaturationFactor?: number;
1392
+ /**
1393
+ * Overall intensity multiplier for the diffuse irradiance.
1394
+ * The default is 1 (no intensity change).
1395
+ */
1396
+ diffuseSkyIrradianceIntensity?: number;
1397
+ /**
1398
+ * Controls the intensity of the additional diffuse irradiance amount.
1399
+ */
1400
+ additionalDiffuseSkyIrradianceIntensity?: number;
1401
+ /**
1402
+ * Controls the color of the additional diffuse irradiance amount.
1403
+ */
1404
+ additionalDiffuseSkyIrradianceColor?: IColor3Like;
1405
+ /**
1406
+ * Higher values increase the contribution of multiple scattering to the overall atmosphere.
1407
+ * Default is 1 (no intensity change).
1408
+ */
1409
+ multiScatteringIntensity?: number;
1410
+ /**
1411
+ * Average color of light reflected off the ground.
1412
+ * Affects the multiply scattered light contribution in the atmosphere.
1413
+ */
1414
+ groundAlbedo?: IColor3Like;
1415
+ /**
1416
+ * Minimum color for multiple scattering.
1417
+ * Useful for creating a quick, but not physically accurate, night sky.
1418
+ */
1419
+ minimumMultiScatteringColor?: IColor3Like;
1420
+ /**
1421
+ * Controls the intensity of the {@link minimumMultiScatteringColor}.
1422
+ * Useful for creating a quick, but not physically accurate, night sky.
1423
+ */
1424
+ minimumMultiScatteringIntensity?: number;
1425
+ /**
1426
+ * Height in kilometers of the scene's origin relative to the planet surface.
1427
+ */
1428
+ originHeight?: number;
1429
+ /**
1430
+ * The rendering group ID for the sky compositor.
1431
+ * When specified, the sky will only be rendered for this group.
1432
+ * If not specified, defaults to group 0.
1433
+ */
1434
+ skyRenderingGroup?: number;
1435
+ /**
1436
+ * The rendering group ID for the aerial perspective compositor.
1437
+ * When specified, aerial perspective will only be rendered for this group.
1438
+ * If not specified, defaults to group 0.
1439
+ */
1440
+ aerialPerspectiveRenderingGroup?: number;
1441
+ /**
1442
+ * The rendering group ID for the globe atmosphere compositor.
1443
+ * When specified, the globe atmosphere will only be rendered for this group.
1444
+ * If not specified, defaults to group 0.
1445
+ */
1446
+ globeAtmosphereRenderingGroup?: number;
1447
+ }
1448
+
1449
+ }
1450
+ declare module "babylonjs-addons/atmosphere/atmosphere" {
1451
+ import { AbstractEngine } from "babylonjs/Engines/abstractEngine";
1452
+ import { AtmospherePerCameraVariables } from "babylonjs-addons/atmosphere/atmospherePerCameraVariables";
1453
+ import { AtmospherePhysicalProperties } from "babylonjs-addons/atmosphere/atmospherePhysicalProperties";
1454
+ import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
1455
+ import { Camera } from "babylonjs/Cameras/camera";
1456
+ import { DeepImmutable, Nullable } from "babylonjs/types";
1457
+ import { DiffuseSkyIrradianceLut } from "babylonjs-addons/atmosphere/diffuseSkyIrradianceLut";
1458
+ import { DirectionalLight } from "babylonjs/Lights/directionalLight";
1459
+ import { Effect } from "babylonjs/Materials/effect";
1460
+ import { IAtmosphereOptions } from "babylonjs-addons/atmosphere/atmosphereOptions";
1461
+ import { IColor3Like, IVector3Like } from "babylonjs/Maths/math.like";
1462
+ import { IDisposable, Scene } from "babylonjs/scene";
1463
+ import { Observable } from "babylonjs/Misc/observable";
1464
+ import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
1465
+ import { TransmittanceLut } from "babylonjs-addons/atmosphere/transmittanceLut";
1466
+ import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
1467
+ import "babylonjs-addons/atmosphere/Shaders/compositeAerialPerspective.fragment";
1468
+ import "babylonjs-addons/atmosphere/Shaders/compositeSky.fragment";
1469
+ import "babylonjs-addons/atmosphere/Shaders/compositeGlobeAtmosphere.fragment";
1470
+ import "babylonjs-addons/atmosphere/Shaders/fullscreenTriangle.vertex";
1471
+ import "babylonjs-addons/atmosphere/Shaders/multiScattering.fragment";
1472
+ import "babylonjs-addons/atmosphere/Shaders/skyView.fragment";
1473
+ import "babylonjs-addons/atmosphere/Shaders/aerialPerspective.fragment";
1474
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1475
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1476
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1477
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration";
1478
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/depthFunctions";
1479
+ /**
1480
+ * Renders a physically based atmosphere.
1481
+ * Use {@link IsSupported} to check if the atmosphere is supported before creating an instance.
1482
+ * @experimental
1483
+ */
1484
+ export class Atmosphere implements IDisposable {
1485
+ readonly name: string;
1486
+ readonly scene: Scene;
1487
+ private readonly _directionToLight;
1488
+ private readonly _tempSceneAmbient;
1489
+ private readonly _engine;
1490
+ private _physicalProperties;
1491
+ private _transmittanceLut;
1492
+ private _diffuseSkyIrradianceLut;
1493
+ private _isSkyViewLutEnabled;
1494
+ private _isAerialPerspectiveLutEnabled;
1495
+ private _aerialPerspectiveTransmittanceScale;
1496
+ private _aerialPerspectiveSaturation;
1497
+ private _aerialPerspectiveIntensity;
1498
+ private _aerialPerspectiveRadianceBias;
1499
+ private _diffuseSkyIrradianceDesaturationFactor;
1500
+ private _additionalDiffuseSkyIrradianceIntensity;
1501
+ private _additionalDiffuseSkyIrradianceColor;
1502
+ private _additionalDiffuseSkyIrradiance;
1503
+ private _diffuseSkyIrradianceIntensity;
1504
+ private _multiScatteringIntensity;
1505
+ private _groundAlbedo;
1506
+ private _minimumMultiScatteringColor;
1507
+ private _minimumMultiScatteringIntensity;
1508
+ private _lights;
1509
+ private _atmosphereUbo;
1510
+ private _minimumMultiScattering;
1511
+ private _cameraAtmosphereVariables;
1512
+ private _isLinearSpaceComposition;
1513
+ private _isLinearSpaceLight;
1514
+ private _lightRadianceAtCamera;
1515
+ private _linearLightColor;
1516
+ private _originHeight;
1517
+ private _applyApproximateTransmittance;
1518
+ private _exposure;
1519
+ private _atmosphereUniformBufferAsArray;
1520
+ private _effectRenderer;
1521
+ private _skyRenderingGroup;
1522
+ private _aerialPerspectiveRenderingGroup;
1523
+ private _globeAtmosphereRenderingGroup;
1524
+ private _isEnabled;
1525
+ private _hasRenderedMultiScatteringLut;
1526
+ private _multiScatteringEffectWrapper;
1527
+ private _multiScatteringLutRenderTarget;
1528
+ private _aerialPerspectiveLutEffectWrapper;
1529
+ private _aerialPerspectiveLutEffectRenderer;
1530
+ private _aerialPerspectiveLutRenderTarget;
1531
+ private _skyViewLutEffectWrapper;
1532
+ private _skyViewLutEffectRenderer;
1533
+ private _skyViewLutRenderTarget;
1534
+ private _aerialPerspectiveCompositorEffectWrapper;
1535
+ private _skyCompositorEffectWrapper;
1536
+ private _globeAtmosphereCompositorEffectWrapper;
1537
+ private _onBeforeCameraRenderObserver;
1538
+ private _onBeforeDrawPhaseObserver;
1539
+ private _onAfterRenderingGroupObserver;
1540
+ /**
1541
+ * Checks if the {@link Atmosphere} is supported.
1542
+ * @param engine - The engine to check.
1543
+ * @returns True if the atmosphere is supported, false otherwise.
1544
+ */
1545
+ static IsSupported(engine: AbstractEngine): boolean;
1546
+ /**
1547
+ * Called after the atmosphere variables have been updated for the specified camera.
1548
+ */
1549
+ readonly onAfterUpdateVariablesForCameraObservable: Observable<Camera>;
1550
+ /**
1551
+ * Called immediately before the light variables are finalized.
1552
+ */
1553
+ readonly onBeforeLightVariablesUpdateObservable: Observable<void>;
1554
+ /**
1555
+ * Called before the LUTs are rendered for this camera. This happens after the per-camera UBO update.
1556
+ */
1557
+ readonly onBeforeRenderLutsForCameraObservable: Observable<void>;
1558
+ /**
1559
+ * Called after the LUTs were rendered.
1560
+ */
1561
+ readonly onAfterRenderLutsForCameraObservable: Observable<void>;
1562
+ /**
1563
+ * If provided, this is the depth texture used for composition passes.
1564
+ * Expects an infinite far plane on the camera (camera.maxZ = 0) and the non-linear depth accessible in red channel.
1565
+ * @internal
1566
+ */
1567
+ readonly depthTexture: Nullable<BaseTexture>;
1568
+ /**
1569
+ * Controls the overall brightness of the atmosphere rendering.
1570
+ */
1571
+ get exposure(): number;
1572
+ set exposure(value: number);
1573
+ /**
1574
+ * Affects the overall intensity of the multiple scattering.
1575
+ */
1576
+ get multiScatteringIntensity(): number;
1577
+ set multiScatteringIntensity(value: number);
1578
+ /**
1579
+ * Affects the multiply scattered light contribution in the atmosphere by describing the average light color reflected off the ground.
1580
+ */
1581
+ get groundAlbedo(): DeepImmutable<IColor3Like>;
1582
+ set groundAlbedo(value: DeepImmutable<IColor3Like>);
1583
+ /**
1584
+ * Can be used to clamp the multiple scattering to a minimum value.
1585
+ */
1586
+ get minimumMultiScatteringColor(): DeepImmutable<IColor3Like>;
1587
+ set minimumMultiScatteringColor(value: DeepImmutable<IColor3Like>);
1588
+ /**
1589
+ * This is an additional scaling factor applied to the {@link minimumMultiScatteringColor}.
1590
+ */
1591
+ get minimumMultiScatteringIntensity(): number;
1592
+ set minimumMultiScatteringIntensity(value: number);
1593
+ /**
1594
+ * Can be used to force the diffuse irradiance towards a gray color.
1595
+ */
1596
+ get diffuseSkyIrradianceDesaturationFactor(): number;
1597
+ set diffuseSkyIrradianceDesaturationFactor(value: number);
1598
+ /**
1599
+ * This is an additional amount of irradiance added to the diffuse irradiance.
1600
+ */
1601
+ get additionalDiffuseSkyIrradianceIntensity(): number;
1602
+ set additionalDiffuseSkyIrradianceIntensity(value: number);
1603
+ /**
1604
+ * This is the color for the additional amount of irradiance added to the diffuse irradiance.
1605
+ */
1606
+ get additionalDiffuseSkyIrradianceColor(): DeepImmutable<IColor3Like>;
1607
+ set additionalDiffuseSkyIrradianceColor(value: DeepImmutable<IColor3Like>);
1608
+ /**
1609
+ * The final additional diffuse irradiance, taking into account the intensity and color.
1610
+ */
1611
+ get additionalDiffuseSkyIrradiance(): DeepImmutable<IColor3Like>;
1612
+ /**
1613
+ * The intensity of the diffuse irradiance.
1614
+ */
1615
+ get diffuseSkyIrradianceIntensity(): number;
1616
+ set diffuseSkyIrradianceIntensity(value: number);
1617
+ /**
1618
+ * True if the sky view LUT should be used for compositing the sky instead of a per-pixel ray march.
1619
+ */
1620
+ get isSkyViewLutEnabled(): boolean;
1621
+ set isSkyViewLutEnabled(value: boolean);
1622
+ /**
1623
+ * Gets the sky view LUT render target or null if not enabled.
1624
+ * @returns The render target.
1625
+ */
1626
+ get skyViewLutRenderTarget(): Nullable<RenderTargetTexture>;
1627
+ /**
1628
+ * True if the aerial perspective LUT should be used.
1629
+ * If false, full ray marching would be used instead.
1630
+ */
1631
+ get isAerialPerspectiveLutEnabled(): boolean;
1632
+ set isAerialPerspectiveLutEnabled(value: boolean);
1633
+ /**
1634
+ * Gets the aerial perspective LUT render target or null if not enabled.
1635
+ * @returns The render target.
1636
+ */
1637
+ get aerialPerspectiveLutRenderTarget(): Nullable<RenderTargetTexture>;
1638
+ /**
1639
+ * The intensity of the aerial perspective.
1640
+ */
1641
+ get aerialPerspectiveIntensity(): number;
1642
+ set aerialPerspectiveIntensity(value: number);
1643
+ /**
1644
+ * The amount of light transmitted into aerial perspective.
1645
+ * A scale of 1 is physically correct.
1646
+ */
1647
+ get aerialPerspectiveTransmittanceScale(): number;
1648
+ set aerialPerspectiveTransmittanceScale(value: number);
1649
+ /**
1650
+ * The amount of saturation applied to the aerial perspective.
1651
+ * Reducing to zero desaturates the aerial perspective completely.
1652
+ * A value of 1 has no effect.
1653
+ */
1654
+ get aerialPerspectiveSaturation(): number;
1655
+ set aerialPerspectiveSaturation(value: number);
1656
+ /**
1657
+ * A radiance bias applied to aerial perspective.
1658
+ */
1659
+ get aerialPerspectiveRadianceBias(): number;
1660
+ set aerialPerspectiveRadianceBias(value: number);
1661
+ /**
1662
+ * True if the composition should be in linear space (e.g. for HDR rendering).
1663
+ * Typically linear space is expected when ImageProcessing is enabled via PostProcesses.
1664
+ * False for non-linear output.
1665
+ */
1666
+ get isLinearSpaceComposition(): boolean;
1667
+ set isLinearSpaceComposition(value: boolean);
1668
+ /**
1669
+ * True if the {@link light} value should be specified in linear space.
1670
+ * If using PBRMaterials, light value is expected to be linear.
1671
+ */
1672
+ get isLinearSpaceLight(): boolean;
1673
+ set isLinearSpaceLight(value: boolean);
1674
+ /**
1675
+ * The lookup table for transmittance.
1676
+ */
1677
+ get transmittanceLut(): Nullable<TransmittanceLut>;
1678
+ /**
1679
+ * Gets the multiple scattering LUT render target.
1680
+ * @returns The render target.
1681
+ */
1682
+ get multiScatteringLutRenderTarget(): Nullable<RenderTargetTexture>;
1683
+ /**
1684
+ * The lookup table for diffuse sky irradiance, or null if not enabled.
1685
+ */
1686
+ get diffuseSkyIrradianceLut(): Nullable<DiffuseSkyIrradianceLut>;
1687
+ /**
1688
+ * The properties used to describe the size and optical parameters of the atmosphere.
1689
+ */
1690
+ get physicalProperties(): AtmospherePhysicalProperties;
1691
+ /**
1692
+ * The height in kilometers of the scene's origin.
1693
+ */
1694
+ get originHeight(): number;
1695
+ set originHeight(value: number);
1696
+ /**
1697
+ * When atmospheric scattering is applied to surfaces, if this value is set to true,
1698
+ * a grayscale approximation of the transmittance is used to dim surfaces.
1699
+ *
1700
+ * When set to false, the atmospheric composition does not dim the surfaces behind it.
1701
+ * It is up to the client application to apply transmittance manually.
1702
+ */
1703
+ get applyApproximateTransmittance(): boolean;
1704
+ set applyApproximateTransmittance(value: boolean);
1705
+ /**
1706
+ * The directional lights in the scene which represent the suns illuminating the atmosphere.
1707
+ * Each frame, the color and intensity of the lights are updated based on the camera position and the light's direction.
1708
+ */
1709
+ get lights(): ReadonlyArray<DirectionalLight>;
1710
+ /**
1711
+ * The rendering group ID for the sky compositor.
1712
+ * The sky will only be rendered for this group.
1713
+ */
1714
+ get skyRenderingGroup(): number;
1715
+ set skyRenderingGroup(value: number);
1716
+ /**
1717
+ * The rendering group ID for the aerial perspective compositor.
1718
+ * Aerial perspective will only be rendered for this group.
1719
+ */
1720
+ get aerialPerspectiveRenderingGroup(): number;
1721
+ set aerialPerspectiveRenderingGroup(value: number);
1722
+ /**
1723
+ * The rendering group ID for the globe atmosphere compositor.
1724
+ * The globe atmosphere will only be rendered for this group.
1725
+ */
1726
+ get globeAtmosphereRenderingGroup(): number;
1727
+ set globeAtmosphereRenderingGroup(value: number);
1728
+ /**
1729
+ * Gets the uniform buffer used to store the atmosphere's physical properties.
1730
+ */
1731
+ get uniformBuffer(): UniformBuffer;
1732
+ /**
1733
+ * Gets the camera-related variables for this atmosphere. Updated each frame.
1734
+ */
1735
+ get cameraAtmosphereVariables(): AtmospherePerCameraVariables;
1736
+ private _peakRayleighScatteringMmInternal;
1737
+ private _peakRayleighScatteringKm;
1738
+ private _peakMieScatteringMmInternal;
1739
+ private _peakMieScatteringKm;
1740
+ private _peakMieAbsorptionMmInternal;
1741
+ private _peakMieAbsorptionKm;
1742
+ private _peakOzoneAbsorptionMmInternal;
1743
+ private _peakOzoneAbsorptionKm;
1744
+ private get _planetRadius();
1745
+ private set _planetRadius(value);
1746
+ private get _planetRadiusOffset();
1747
+ private set _planetRadiusOffset(value);
1748
+ private get _atmosphereThickness();
1749
+ private set _atmosphereThickness(value);
1750
+ private get _rayleighScatteringScale();
1751
+ private set _rayleighScatteringScale(value);
1752
+ private get _peakRayleighScatteringMm();
1753
+ private set _peakRayleighScatteringMm(value);
1754
+ private get _mieScatteringScale();
1755
+ private set _mieScatteringScale(value);
1756
+ private get _peakMieScatteringMm();
1757
+ private set _peakMieScatteringMm(value);
1758
+ private get _mieAbsorptionScale();
1759
+ private set _mieAbsorptionScale(value);
1760
+ private get _peakMieAbsorptionMm();
1761
+ private set _peakMieAbsorptionMm(value);
1762
+ private get _ozoneAbsorptionScale();
1763
+ private set _ozoneAbsorptionScale(value);
1764
+ private get _peakOzoneAbsorptionMm();
1765
+ private set _peakOzoneAbsorptionMm(value);
1766
+ /**
1767
+ * Constructs the {@link Atmosphere}.
1768
+ * @param name - The name of this instance.
1769
+ * @param scene - The scene to which the atmosphere will be added.
1770
+ * @param lights - The light sources that illuminate the atmosphere. Currently only supports one light, and that light should be the first light in the scene.
1771
+ * @param options - The options used to create the atmosphere.
1772
+ */
1773
+ constructor(name: string, scene: Scene, lights: DirectionalLight[], options?: IAtmosphereOptions);
1774
+ /**
1775
+ * @override
1776
+ */
1777
+ dispose(): void;
1778
+ /**
1779
+ * True if the atmosphere is enabled.
1780
+ * @returns - True if the atmosphere is enabled.
1781
+ */
1782
+ isEnabled(): boolean;
1783
+ /**
1784
+ * Sets the enabled state of the atmosphere.
1785
+ * @param enabled - True to enable the atmosphere, false to disable it.
1786
+ */
1787
+ setEnabled(enabled: boolean): void;
1788
+ /**
1789
+ * The class name of the {@link Atmosphere}.
1790
+ * @returns - The class name of the atmosphere.
1791
+ */
1792
+ getClassName(): string;
1793
+ /**
1794
+ * Gets the color of a light after being transmitted through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.
1795
+ * NOTE, the result is always a linear space color.
1796
+ * @param directionToLight - The direction of the light.
1797
+ * @param pointRadius - The distance from the planet center to the point in kilometers.
1798
+ * @param pointGeocentricNormal - The geocentric normal at the point i.e., normalize(point - planet center).
1799
+ * @param result - The color to store the result in.
1800
+ * @returns The result color.
1801
+ */
1802
+ getTransmittedColorToRef: <T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, result: T) => T;
1803
+ /**
1804
+ * Gets the diffuse sky irradiance. Result is always in linear space.
1805
+ * @param directionToLight - The direction of the point to the light.
1806
+ * @param pointRadius - The distance from the planet center to the point in kilometers.
1807
+ * @param pointGeocentricNormal - The geocentric normal at the point: normalize(point - planet center).
1808
+ * @param lightIrradiance - The irradiance of the light.
1809
+ * @param result - The color to store the result in.
1810
+ * @returns The result color.
1811
+ */
1812
+ getDiffuseSkyIrradianceToRef: <T extends IColor3Like>(directionToLight: IVector3Like, pointRadius: number, pointGeocentricNormal: IVector3Like, lightIrradiance: number, result: T) => T;
1813
+ /**
1814
+ * Creates a new {@link EffectWrapper} for the multiple scattering LUT
1815
+ * @returns The newly created {@link EffectWrapper}.
1816
+ */
1817
+ private _createMultiScatteringEffectWrapper;
1818
+ /**
1819
+ * Draws the multiple scattering LUT using {@link EffectWrapper} and {@link EffectRenderer}.
1820
+ */
1821
+ private _drawMultiScatteringLut;
1822
+ /**
1823
+ * Draws the aerial perspective compositor using {@link EffectWrapper} and {@link EffectRenderer}.
1824
+ */
1825
+ private _drawAerialPerspectiveCompositor;
1826
+ /**
1827
+ * Draws the sky compositor using {@link EffectWrapper} and {@link EffectRenderer}.
1828
+ */
1829
+ private _drawSkyCompositor;
1830
+ /**
1831
+ * Draws the globe atmosphere compositor using {@link EffectWrapper} and {@link EffectRenderer}.
1832
+ */
1833
+ private _drawGlobeAtmosphereCompositor;
1834
+ private _disposeSkyCompositor;
1835
+ private _disposeAerialPerspectiveCompositor;
1836
+ private _disposeGlobeAtmosphereCompositor;
1837
+ /**
1838
+ * Updates the camera variables that are specific to the atmosphere.
1839
+ * @param camera - The camera to update the variables for.
1840
+ */
1841
+ private _updatePerCameraVariables;
1842
+ /**
1843
+ * Renders the lookup tables, some of which can vary per-camera.
1844
+ * It is expected that updatePerCameraVariables was previously called.
1845
+ */
1846
+ private _renderLutsForCamera;
1847
+ /**
1848
+ * Renders the lookup tables that do not depend on a camera position.
1849
+ */
1850
+ renderGlobalLuts(): void;
1851
+ /**
1852
+ * Binds the atmosphere's uniform buffer to an {@link Effect}.
1853
+ * @param effect - The {@link Effect} to bind the uniform buffer to.
1854
+ */
1855
+ bindUniformBufferToEffect(effect: Effect): void;
1856
+ /**
1857
+ * Updates the atmosphere's uniform buffer.
1858
+ */
1859
+ private _updateUniformBuffer;
1860
+ /**
1861
+ * Draws the aerial perspective LUT using {@link EffectWrapper} and {@link EffectRenderer}.
1862
+ */
1863
+ private _drawAerialPerspectiveLut;
1864
+ /**
1865
+ * Draws the sky view LUT using {@link EffectWrapper} and {@link EffectRenderer}.
1866
+ */
1867
+ private _drawSkyViewLut;
1868
+ }
1869
+
1870
+ }
1871
+ declare module "babylonjs-addons/atmosphere/Shaders/transmittance.fragment" {
1872
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1873
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1874
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1875
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1876
+ /** @internal */
1877
+ export const transmittancePixelShader: {
1878
+ name: string;
1879
+ shader: string;
1880
+ };
1881
+
1882
+ }
1883
+ declare module "babylonjs-addons/atmosphere/Shaders/skyView.fragment" {
1884
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1885
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1886
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1887
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1888
+ /** @internal */
1889
+ export const skyViewPixelShader: {
1890
+ name: string;
1891
+ shader: string;
1892
+ };
1893
+
1894
+ }
1895
+ declare module "babylonjs-addons/atmosphere/Shaders/multiScattering.fragment" {
1896
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1897
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1898
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1899
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1900
+ /** @internal */
1901
+ export const multiScatteringPixelShader: {
1902
+ name: string;
1903
+ shader: string;
1904
+ };
1905
+
1906
+ }
1907
+ declare module "babylonjs-addons/atmosphere/Shaders/fullscreenTriangle.vertex" {
1908
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1909
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1910
+ /** @internal */
1911
+ export const fullscreenTriangleVertexShader: {
1912
+ name: string;
1913
+ shader: string;
1914
+ };
1915
+
1916
+ }
1917
+ declare module "babylonjs-addons/atmosphere/Shaders/diffuseSkyIrradiance.fragment" {
1918
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1919
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1920
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1921
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/depthFunctions";
1922
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1923
+ import "babylonjs/Shaders/ShadersInclude/importanceSampling";
1924
+ import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
1925
+ import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
1926
+ /** @internal */
1927
+ export const diffuseSkyIrradiancePixelShader: {
1928
+ name: string;
1929
+ shader: string;
1930
+ };
1931
+
1932
+ }
1933
+ declare module "babylonjs-addons/atmosphere/Shaders/compositeSky.fragment" {
1934
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1935
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1936
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1937
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/depthFunctions";
1938
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1939
+ /** @internal */
1940
+ export const compositeSkyPixelShader: {
1941
+ name: string;
1942
+ shader: string;
1943
+ };
1944
+
1945
+ }
1946
+ declare module "babylonjs-addons/atmosphere/Shaders/compositeGlobeAtmosphere.fragment" {
1947
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1948
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1949
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1950
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/depthFunctions";
1951
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1952
+ /** @internal */
1953
+ export const compositeGlobeAtmospherePixelShader: {
1954
+ name: string;
1955
+ shader: string;
1956
+ };
1957
+
1958
+ }
1959
+ declare module "babylonjs-addons/atmosphere/Shaders/compositeAerialPerspective.fragment" {
1960
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1961
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1962
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1963
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/depthFunctions";
1964
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1965
+ /** @internal */
1966
+ export const compositeAerialPerspectivePixelShader: {
1967
+ name: string;
1968
+ shader: string;
1969
+ };
1970
+
1971
+ }
1972
+ declare module "babylonjs-addons/atmosphere/Shaders/aerialPerspective.fragment" {
1973
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration";
1974
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration";
1975
+ import "babylonjs/Shaders/ShadersInclude/helperFunctions";
1976
+ import "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions";
1977
+ /** @internal */
1978
+ export const aerialPerspectivePixelShader: {
1979
+ name: string;
1980
+ shader: string;
1981
+ };
1982
+
1983
+ }
1984
+ declare module "babylonjs-addons/atmosphere/Shaders/ShadersInclude/depthFunctions" {
1985
+ /** @internal */
1986
+ export const depthFunctions: {
1987
+ name: string;
1988
+ shader: string;
1989
+ };
1990
+
1991
+ }
1992
+ declare module "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration" {
1993
+ /** @internal */
1994
+ export const atmosphereVertexDeclaration: {
1995
+ name: string;
1996
+ shader: string;
1997
+ };
1998
+
1999
+ }
2000
+ declare module "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration" {
2001
+ /** @internal */
2002
+ export const atmosphereUboDeclaration: {
2003
+ name: string;
2004
+ shader: string;
2005
+ };
2006
+
2007
+ }
2008
+ declare module "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFunctions" {
2009
+ import "babylonjs/Shaders/ShadersInclude/intersectionFunctions";
2010
+ /** @internal */
2011
+ export const atmosphereFunctions: {
2012
+ name: string;
2013
+ shader: string;
2014
+ };
2015
+
2016
+ }
2017
+ declare module "babylonjs-addons/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration" {
2018
+ /** @internal */
2019
+ export const atmosphereFragmentDeclaration: {
2020
+ name: string;
2021
+ shader: string;
2022
+ };
2023
+
2024
+ }
2025
+
2026
+ declare module "babylonjs-addons" {
2027
+ export * from "babylonjs-addons/index";
2028
+ }
2029
+
2030
+
2031
+ declare module ADDONS {
2032
+
2033
+
2034
+ /**
2035
+ * Abstract Node class from Babylon.js
2036
+ */
2037
+ export interface INodeLike {
2038
+ getWorldMatrix(): BABYLON.IMatrixLike;
2039
+ }
2040
+ /**
2041
+ * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
2042
+ * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
2043
+ * #6RLCWP#16
2044
+ * Star wars scroller: #6RLCWP#29
2045
+ * With metrics: #6RLCWP#35
2046
+ * Thickness: #IABMEZ#3
2047
+ * Solar system: #9YCDYC#9
2048
+ * Stroke: #6RLCWP#37
2049
+ */
2050
+ export class TextRenderer implements BABYLON.IDisposable {
2051
+ private readonly _useVAO;
2052
+ private _engine;
2053
+ private _shaderLanguage;
2054
+ private _vertexBuffers;
2055
+ private _spriteBuffer;
2056
+ private _worldBuffer;
2057
+ private _uvBuffer;
2058
+ private _drawWrapperBase;
2059
+ private _vertexArrayObject;
2060
+ private _font;
2061
+ private _charMatrices;
2062
+ private _charUvs;
2063
+ private _isDirty;
2064
+ private _baseLine;
2065
+ private _scalingMatrix;
2066
+ private _fontScaleMatrix;
2067
+ private _offsetMatrix;
2068
+ private _translationMatrix;
2069
+ private _baseMatrix;
2070
+ private _scaledMatrix;
2071
+ private _localMatrix;
2072
+ private _finalMatrix;
2073
+ private _lineMatrix;
2074
+ private _parentWorldMatrix;
2075
+ /**
2076
+ * Gets or sets the color of the text
2077
+ */
2078
+ color: BABYLON.IColor4Like;
2079
+ /**
2080
+ * Gets or sets the color of the stroke around the text
2081
+ */
2082
+ strokeColor: BABYLON.IColor4Like;
2083
+ /**
2084
+ * Gets or sets the width of the stroke around the text (inset)
2085
+ */
2086
+ strokeInsetWidth: number;
2087
+ /**
2088
+ * Gets or sets the width of the stroke around the text (outset)
2089
+ */
2090
+ strokeOutsetWidth: number;
2091
+ /**
2092
+ * Gets or sets the thickness of the text (0 means as defined in the font)
2093
+ * Value must be between -0.5 and 0.5
2094
+ */
2095
+ thicknessControl: number;
2096
+ private _parent;
2097
+ /**
2098
+ * Gets or sets the parent of the text renderer
2099
+ */
2100
+ get parent(): BABYLON.Nullable<INodeLike>;
2101
+ set parent(value: BABYLON.Nullable<INodeLike>);
2102
+ private _transformMatrix;
2103
+ /**
2104
+ * Gets or sets the transform matrix of the text renderer
2105
+ * It will be applied in that order:
2106
+ * parent x transform x paragraph world
2107
+ */
2108
+ get transformMatrix(): BABYLON.IMatrixLike;
2109
+ set transformMatrix(value: BABYLON.IMatrixLike);
2110
+ /**
2111
+ * Gets or sets if the text is billboarded
2112
+ */
2113
+ isBillboard: boolean;
2114
+ /**
2115
+ * Gets or sets if the text is screen projected
2116
+ * This will work only if the text is billboarded
2117
+ */
2118
+ isBillboardScreenProjected: boolean;
2119
+ /**
2120
+ * Gets the number of characters in the text renderer
2121
+ */
2122
+ get characterCount(): number;
2123
+ /**
2124
+ * Gets or sets if the text renderer should ignore the depth buffer
2125
+ * Default is false
2126
+ */
2127
+ ignoreDepthBuffer: boolean;
2128
+ private constructor();
2129
+ private _resizeBuffers;
2130
+ private _setShaders;
2131
+ /**
2132
+ * Add a paragraph of text to the renderer
2133
+ * @param text define the text to add
2134
+ * @param options define the options to use for the paragraph (optional)
2135
+ * @param worldMatrix define the world matrix to use for the paragraph (optional)
2136
+ */
2137
+ addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: BABYLON.IMatrixLike): void;
2138
+ /**
2139
+ * Render the text using the provided view and projection matrices
2140
+ * @param viewMatrix define the view matrix to use
2141
+ * @param projectionMatrix define the projection matrix to use
2142
+ */
2143
+ render(viewMatrix: BABYLON.IMatrixLike, projectionMatrix: BABYLON.IMatrixLike): void;
2144
+ /**
2145
+ * Release associated resources
2146
+ */
2147
+ dispose(): void;
2148
+ /**
2149
+ * Creates a new TextRenderer instance asynchronously
2150
+ * @param font define the font asset to use
2151
+ * @param engine define the engine to use
2152
+ * @returns a promise that resolves to the created TextRenderer instance
2153
+ */
2154
+ static CreateTextRendererAsync(font: FontAsset, engine: BABYLON.AbstractEngine): Promise<TextRenderer>;
2155
+ }
2156
+
2157
+
2158
+ /** @internal */
2159
+ export type ParagraphOptions = {
2160
+ maxWidth: number;
2161
+ lineHeight: number;
2162
+ letterSpacing: number;
2163
+ tabSize: number;
2164
+ whiteSpace: "pre-line";
2165
+ textAlign: "left" | "right" | "center";
2166
+ translate: BABYLON.IVector2Like | undefined;
2167
+ };
2168
+ /** @internal */
2169
+ export var DefaultParagraphOptions: ParagraphOptions;
2170
+
2171
+
2172
+
2173
+
2174
+ /**
2175
+ * Class representing a font asset for SDF (Signed Distance Field) rendering.
2176
+ */
2177
+ export class FontAsset implements BABYLON.IDisposable {
2178
+ private readonly _chars;
2179
+ private readonly _charsRegex;
2180
+ private readonly _kernings;
2181
+ /** @internal */
2182
+ readonly _font: SdfFont;
2183
+ /**
2184
+ * Gets the font scale value
2185
+ */
2186
+ readonly scale: number;
2187
+ /**
2188
+ * Gets the list of used textures
2189
+ */
2190
+ readonly textures: BABYLON.Texture[];
2191
+ /**
2192
+ * Creates a new FontAsset instance.
2193
+ * @param definitionData defines the font data in JSON format.
2194
+ * @param textureUrl defines the url of the texture to use for the font.
2195
+ * @param scene defines the hosting scene.
2196
+ */
2197
+ constructor(definitionData: string, textureUrl: string, scene?: BABYLON.Scene);
2198
+ dispose(): void;
2199
+ private _updateFallbacks;
2200
+ /** @internal */
2201
+ _getChar(charCode: number): BMFontChar;
2202
+ /** @internal */
2203
+ _getKerning(first: number, second: number): number;
2204
+ /** @internal */
2205
+ _unsupportedChars(text: string): string;
2206
+ }
2207
+
2208
+
2209
+ /** @internal */
2210
+ export var msdfVertexShaderWGSL: {
2211
+ name: string;
2212
+ shader: string;
2213
+ };
2214
+
2215
+
2216
+ /** @internal */
2217
+ export var msdfPixelShaderWGSL: {
2218
+ name: string;
2219
+ shader: string;
2220
+ };
2221
+
2222
+
2223
+ /** @internal */
2224
+ export var msdfVertexShader: {
2225
+ name: string;
2226
+ shader: string;
2227
+ };
2228
+
2229
+
2230
+ /** @internal */
2231
+ export var msdfPixelShader: {
2232
+ name: string;
2233
+ shader: string;
2234
+ };
2235
+
2236
+
2237
+ /** @internal */
2238
+ export class SdfTextParagraph {
2239
+ readonly text: string;
2240
+ readonly fontAsset: FontAsset;
2241
+ readonly options: ParagraphOptions;
2242
+ get lineHeight(): number;
2243
+ readonly paragraph: string;
2244
+ readonly lines: SdfTextLine[];
2245
+ readonly width: number;
2246
+ readonly height: number;
2247
+ readonly glyphs: SdfGlyph[];
2248
+ constructor(text: string, fontAsset: FontAsset, options?: Partial<ParagraphOptions>);
2249
+ private _computeMetrics;
2250
+ private _breakLines;
2251
+ private _collapse;
2252
+ private _wrap;
2253
+ }
2254
+
2255
+
2256
+ /** @internal */
2257
+ export type SdfTextLine = {
2258
+ text: string;
2259
+ glyphs: SdfGlyph[];
2260
+ start: number;
2261
+ end: number;
2262
+ width: number;
2263
+ };
2264
+
2265
+
2266
+
2267
+
2268
+ /** @internal */
2269
+ export type SdfGlyph = {
2270
+ char: BMFontChar;
2271
+ /** index of the line */
2272
+ line: number;
2273
+ /** position within the line */
2274
+ position: number;
2275
+ x: number;
2276
+ y: number;
2277
+ };
2278
+
2279
+
2280
+ export type SdfFontDistanceField = {
2281
+ fieldType: "sdf" | "msdf";
2282
+ distanceRange: number;
2283
+ };
2284
+ export type SdfFont = BMFont & {
2285
+ distanceField: SdfFontDistanceField;
2286
+ };
2287
+
2288
+
2289
+ /**
2290
+ * Holds information on how the font was generated.
2291
+ */
2292
+ export type BMFontInfo = {
2293
+ /** The name of the font */
2294
+ face: string;
2295
+ /** The size of the font */
2296
+ size: number;
2297
+ /** The font is bold */
2298
+ bold: number;
2299
+ /** The font is italic */
2300
+ italic: number;
2301
+ /** The charset of the font */
2302
+ charset: string[];
2303
+ /** The charset is unicode */
2304
+ unicode: number;
2305
+ /** The font height stretch in percentage. 100% means no stretch. */
2306
+ stretchH: number;
2307
+ /** Set to 1 if smoothing was turned on. */
2308
+ smooth: number;
2309
+ /** The supersampling level used. 1 means no supersampling was used. */
2310
+ aa: number;
2311
+ /** The padding for each character (up, right, down, left). */
2312
+ padding: [number, number, number, number];
2313
+ /** The spacing for each character (horizontal, vertical). */
2314
+ spacing: [number, number];
2315
+ /**
2316
+ * The outline thickness for the characters.
2317
+ *
2318
+ * @remark missing in msdf-bmfont-xml
2319
+ */
2320
+ outline?: number;
2321
+ };
2322
+ /**
2323
+ * Holds information common to all characters.
2324
+ */
2325
+ export type BMFontCommon = {
2326
+ /** Distance in pixels between each line of text */
2327
+ lineHeight: number;
2328
+ /** The number of pixels from the absolute top of the line to the base of the characters */
2329
+ base: number;
2330
+ /** The width of the texture, normally used to scale the x pos of the character image */
2331
+ scaleW: number;
2332
+ /** The height of the texture, normally used to scale the y pos of the character image */
2333
+ scaleH: number;
2334
+ /** The number of pages in the font */
2335
+ pages: number;
2336
+ /** Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel. */
2337
+ packed: number;
2338
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2339
+ alphaChnl: number;
2340
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2341
+ redChnl: number;
2342
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2343
+ greenChnl: number;
2344
+ /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
2345
+ blueChnl: number;
2346
+ };
2347
+ /** Name of a texture file. There is one for each page in the font. */
2348
+ export type BMFontPages = {
2349
+ [id: number]: string;
2350
+ } & Array<string>;
2351
+ /**
2352
+ * Describes a single character in the font
2353
+ */
2354
+ export type BMFontChar = {
2355
+ /** Character id (charCode) */
2356
+ id: number;
2357
+ /** Left position of the character image in the texture. */
2358
+ x: number;
2359
+ /** Right position of the character image in the texture */
2360
+ y: number;
2361
+ /** Width of the chracter image in the texture */
2362
+ width: number;
2363
+ /** Height of the chracter image in the texture */
2364
+ height: number;
2365
+ /** Horizontal offset to be applied on screen */
2366
+ xoffset: number;
2367
+ /** Vertical offset to be applied on screen */
2368
+ yoffset: number;
2369
+ /** Horizontal advance after the character */
2370
+ xadvance: number;
2371
+ /** Page index where the character image is found */
2372
+ page: number;
2373
+ /** Texture channel where the chracter image is found
2374
+ * - 1 = blue
2375
+ * - 2 = green
2376
+ * - 3 = red
2377
+ * - 8 = alpha
2378
+ * - 15 = all channels
2379
+ */
2380
+ chnl: number;
2381
+ } & BMFontCharExtra;
2382
+ /**
2383
+ * additional context from msdf-bmfont-xml
2384
+ */
2385
+ export type BMFontCharExtra = {
2386
+ /** index of opentype.js glyph */
2387
+ index: number;
2388
+ /** actual character*/
2389
+ char: string;
2390
+ };
2391
+ /**
2392
+ * The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.
2393
+ */
2394
+ export type BMFontKerning = {
2395
+ /** The first character id. */
2396
+ first: number;
2397
+ /** The second character id. */
2398
+ second: number;
2399
+ /** How much the x position should be adjusted when drawing the second character immediately following the first. */
2400
+ amount: number;
2401
+ };
2402
+ /**
2403
+ * Compatible with [msdf-bmfont-xml](https://github.com/soimy/msdf-bmfont-xml)
2404
+ * @see https://www.angelcode.com/products/bmfont/doc/file_format.html
2405
+ */
2406
+ export type BMFont = {
2407
+ /** {@inheritDoc BMFontInfo} */
2408
+ info: BMFontInfo;
2409
+ /** {@inheritDoc BMFontCommon} */
2410
+ common: BMFontCommon;
2411
+ /** {@inheritDoc BMFontPages} */
2412
+ pages: BMFontPages;
2413
+ /** {@inheritDoc BMFontChar} */
2414
+ chars: BMFontChar[];
2415
+ /** {@inheritDoc BMFontKerning} */
2416
+ kernings: BMFontKerning[];
2417
+ };
2418
+
2419
+
2420
+ /**
2421
+ * BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
2422
+ * and receive pointer events directly. It will register the capture triggers and negotiate the capture and
2423
+ * release of pointer events. Curerntly this applies only to HtmlMesh
2424
+ */
2425
+ export class PointerEventsCaptureBehavior implements BABYLON.Behavior<BABYLON.AbstractMesh> {
2426
+ private _captureCallback;
2427
+ private _releaseCallback;
2428
+ /** gets or sets behavior's name */
2429
+ name: string;
2430
+ private _attachedMesh;
2431
+ /** @internal */
2432
+ _captureOnPointerEnter: boolean;
2433
+ /**
2434
+ * Gets or sets the mesh that the behavior is attached to
2435
+ */
2436
+ get attachedMesh(): BABYLON.AbstractMesh | null;
2437
+ set attachedMesh(value: BABYLON.AbstractMesh | null);
2438
+ constructor(_captureCallback: () => void, _releaseCallback: () => void, { captureOnPointerEnter }?: {
2439
+ captureOnPointerEnter?: boolean | undefined;
2440
+ });
2441
+ /**
2442
+ * Set if the behavior should capture pointer events when the pointer enters the mesh
2443
+ */
2444
+ set captureOnPointerEnter(captureOnPointerEnter: boolean);
2445
+ /**
2446
+ * Function called when the behavior needs to be initialized (before attaching it to a target)
2447
+ */
2448
+ init(): void;
2449
+ /**
2450
+ * Called when the behavior is attached to a target
2451
+ * @param mesh defines the target where the behavior is attached to
2452
+ */
2453
+ attach(mesh: BABYLON.AbstractMesh): void;
2454
+ /**
2455
+ * Called when the behavior is detached from its target
2456
+ */
2457
+ detach(): void;
2458
+ /**
2459
+ * Dispose the behavior
2460
+ */
2461
+ dispose(): void;
2462
+ releasePointerEvents(): void;
2463
+ capturePointerEvents(): void;
2464
+ }
2465
+
2466
+
2467
+ type CaptureReleaseCallback = () => void;
2468
+ /**
2469
+ * Get the id of the object currently capturing pointer events
2470
+ * @returns The id of the object currently capturing pointer events
2471
+ * or null if no object is capturing pointer events
2472
+ */
2473
+ export const getCapturingId: () => string | null;
2474
+ /**
2475
+ * Request that the object with the given id capture pointer events. If there is no current
2476
+ * owner, then the request is granted immediately. If there is a current owner, then the request
2477
+ * is queued until the current owner releases pointer events.
2478
+ * @param requestId An id to identify the request. This id will be used to match the capture
2479
+ * request with the release request.
2480
+ * @param captureCallback The callback to call when the request is granted and the object is capturing
2481
+ * @param releaseCallback The callback to call when the object is no longer capturing pointer events
2482
+ */
2483
+ export const requestCapture: (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => void;
2484
+ /**
2485
+ * Release pointer events from the object with the given id. If the object is the current owner
2486
+ * then pointer events are released immediately. If the object is not the current owner, then the
2487
+ * associated capture request is removed from the queue. If there is no matching capture request
2488
+ * in the queue, then the release request is added to a list of unmatched release requests and will
2489
+ * negate the next capture request with the same id. This is to guard against the possibility that
2490
+ * the release request arrived before the capture request.
2491
+ * @param requestId The id which should match the id of the capture request
2492
+ */
2493
+ export const requestRelease: (requestId: string | null) => void;
2494
+ /**
2495
+ * Release pointer events from the current owner
2496
+ */
2497
+ export const releaseCurrent: () => void;
2498
+ }
2499
+
2500
+ interface Window {
2501
+ "pointer-events-capture-debug": boolean | null;
2502
+ }
2503
+ declare module ADDONS {
2504
+
2505
+
2506
+
2507
+
2508
+ /**
2509
+ * A function that compares two submeshes and returns a number indicating which
2510
+ * should be rendered first.
2511
+ */
2512
+ type RenderOrderFunction = (subMeshA: BABYLON.SubMesh, subMeshB: BABYLON.SubMesh) => number;
2513
+ /**
2514
+ * An instance of this is required to render HtmlMeshes in the scene.
2515
+ * if using HtmlMeshes, you must not set render order for group 0 using
2516
+ * scene.setRenderingOrder. You must instead pass the compare functions
2517
+ * to the HtmlMeshRenderer constructor. If you do not, then your render
2518
+ * order will be overwritten if the HtmlMeshRenderer is created after and
2519
+ * the HtmlMeshes will not render correctly (they will appear in front of
2520
+ * meshes that are actually in front of them) if the HtmlMeshRenderer is
2521
+ * created before.
2522
+ */
2523
+ export class HtmlMeshRenderer {
2524
+ /**
2525
+ * Global scale factor applied to the homogeneous `w` component (m[15]) of the
2526
+ * transformation matrix when projecting 3D objects into pixel space.
2527
+ *
2528
+ * This value is used to balance Babylon units against screen pixels, ensuring
2529
+ * that HTML-mapped or screen-space objects appear with the correct relative
2530
+ * size. Adjust with care, as changing it affects the projection scale of all
2531
+ * transformed objects.
2532
+ *
2533
+ * The default value is `0.00001`, which works well when 1 Babylon unit
2534
+ * corresponds to 1 meter, and the typical screen resolution is around
2535
+ * 100 pixels per meter (i.e., 1 pixel per centimeter).
2536
+ */
2537
+ static PROJECTION_SCALE_FACTOR: number;
2538
+ private _containerId?;
2539
+ private _inSceneElements?;
2540
+ private _overlayElements?;
2541
+ private _engine;
2542
+ private _cache;
2543
+ private _width;
2544
+ private _height;
2545
+ private _heightHalf;
2546
+ private _cameraWorldMatrix?;
2547
+ private _temp;
2548
+ private _lastDevicePixelRatio;
2549
+ private _cameraMatrixUpdated;
2550
+ private _previousCanvasDocumentPosition;
2551
+ private _renderObserver;
2552
+ /**
2553
+ * Contruct an instance of HtmlMeshRenderer
2554
+ * @param scene
2555
+ * @param options object containing the following optional properties:
2556
+ * @returns
2557
+ */
2558
+ constructor(scene: BABYLON.Scene, { parentContainerId, _containerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder, }?: {
2559
+ parentContainerId?: string | null;
2560
+ _containerId?: string;
2561
+ defaultOpaqueRenderOrder?: RenderOrderFunction;
2562
+ defaultAlphaTestRenderOrder?: RenderOrderFunction;
2563
+ defaultTransparentRenderOrder?: RenderOrderFunction;
2564
+ enableOverlayRender?: boolean;
2565
+ });
2566
+ /**
2567
+ * Dispose of the HtmlMeshRenderer
2568
+ */
2569
+ dispose(): void;
2570
+ protected _init(scene: BABYLON.Scene, parentContainerId: string | null, enableOverlayRender: boolean, defaultOpaqueRenderOrder: RenderOrderFunction, defaultAlphaTestRenderOrder: RenderOrderFunction, defaultTransparentRenderOrder: RenderOrderFunction): void;
2571
+ private _createRenderLayerElements;
2572
+ protected _getSize(): {
2573
+ width: number;
2574
+ height: number;
2575
+ };
2576
+ protected _setSize(width: number, height: number): void;
2577
+ protected _getCameraCssMatrix(matrix: BABYLON.Matrix): string;
2578
+ protected _getHtmlContentCssMatrix(matrix: BABYLON.Matrix, useRightHandedSystem: boolean): string;
2579
+ protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): BABYLON.Matrix;
2580
+ protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): void;
2581
+ protected _render(scene: BABYLON.Scene, camera: BABYLON.Camera): void;
2582
+ protected _updateBaseScaleFactor(htmlMesh: HtmlMesh): void;
2583
+ protected _updateContainerPositionIfNeeded(): void;
2584
+ protected _onCameraMatrixChanged: (camera: BABYLON.Camera) => void;
2585
+ private _epsilon;
2586
+ private _getAncestorMarginsAndPadding;
2587
+ }
2588
+
755
2589
 
756
- declare module "babylonjs-addons" {
757
- export * from "babylonjs-addons/index";
758
- }
2590
+ /**
2591
+ * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually
2592
+ * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not
2593
+ * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate
2594
+ * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.
2595
+ * In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes
2596
+ * in the scene).
2597
+ * @see https://playground.babylonjs.com/#HVHYJC#5
2598
+ * @see https://playground.babylonjs.com/#B17TC7#112
2599
+ */
2600
+ export class HtmlMesh extends BABYLON.Mesh {
2601
+ /**
2602
+ * Helps identifying a html mesh from a regular mesh
2603
+ */
2604
+ get isHtmlMesh(): boolean;
2605
+ private _enabled;
2606
+ private _ready;
2607
+ /**
2608
+ * @internal
2609
+ */
2610
+ _isCanvasOverlay: boolean;
2611
+ private _requiresUpdate;
2612
+ private _element?;
2613
+ private _width?;
2614
+ private _height?;
2615
+ private _inverseScaleMatrix;
2616
+ private _captureOnPointerEnter;
2617
+ private _pointerEventCaptureBehavior;
2618
+ private _sourceWidth;
2619
+ private _sourceHeight;
2620
+ /**
2621
+ * Return the source width of the content in pixels
2622
+ */
2623
+ get sourceWidth(): number | null;
2624
+ /**
2625
+ * Return the source height of the content in pixels
2626
+ */
2627
+ get sourceHeight(): number | null;
2628
+ private _worldMatrixUpdateObserver;
2629
+ private _fitStrategy;
2630
+ /**
2631
+ * Contruct an instance of HtmlMesh
2632
+ * @param scene
2633
+ * @param id The id of the mesh. Will be used as the id of the HTML element as well.
2634
+ * @param options object with optional parameters
2635
+ */
2636
+ constructor(scene: BABYLON.Scene, id: string, { captureOnPointerEnter, isCanvasOverlay, fitStrategy }?: {
2637
+ captureOnPointerEnter?: boolean | undefined;
2638
+ isCanvasOverlay?: boolean | undefined;
2639
+ fitStrategy?: FitStrategyType | undefined;
2640
+ });
2641
+ /**
2642
+ * The width of the content in pixels
2643
+ */
2644
+ get width(): number | undefined;
2645
+ /**
2646
+ * The height of the content in pixels
2647
+ */
2648
+ get height(): number | undefined;
2649
+ /**
2650
+ * The HTML element that is being rendered as a mesh
2651
+ */
2652
+ get element(): HTMLElement | undefined;
2653
+ /**
2654
+ * True if the mesh has been moved, rotated, or scaled since the last time this
2655
+ * property was read. This property is reset to false after reading.
2656
+ */
2657
+ get requiresUpdate(): boolean;
2658
+ /**
2659
+ * Enable capture for the pointer when entering the mesh area
2660
+ */
2661
+ set captureOnPointerEnter(captureOnPointerEnter: boolean);
2662
+ /**
2663
+ * Disposes of the mesh and the HTML element
2664
+ */
2665
+ dispose(): void;
2666
+ /**
2667
+ * @internal
2668
+ */
2669
+ _markAsUpdated(): void;
2670
+ /**
2671
+ * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.
2672
+ * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the
2673
+ * element content first.
2674
+ * @param element The element to render as a mesh
2675
+ * @param width The width of the mesh in Babylon units
2676
+ * @param height The height of the mesh in Babylon units
2677
+ */
2678
+ setContent(element: HTMLElement, width: number, height: number): void;
2679
+ setEnabled(enabled: boolean): void;
2680
+ /**
2681
+ * Sets the content size in pixels
2682
+ * @param width width of the source
2683
+ * @param height height of the source
2684
+ */
2685
+ setContentSizePx(width: number, height: number): void;
2686
+ protected _setAsReady(ready: boolean): void;
2687
+ protected _doSetEnabled(enabled: boolean): void;
2688
+ protected _updateScaleIfNecessary(): void;
2689
+ protected _createMask(): void;
2690
+ protected _setElementzIndex(zIndex: number): void;
2691
+ /**
2692
+ * Callback used by the PointerEventsCaptureBehavior to capture pointer events
2693
+ */
2694
+ capturePointerEvents(): void;
2695
+ /**
2696
+ * Callback used by the PointerEventsCaptureBehavior to release pointer events
2697
+ */
2698
+ releasePointerEvents(): void;
2699
+ protected _createElement(): HTMLDivElement | undefined;
2700
+ }
759
2701
 
760
2702
 
761
- declare module ADDONS {
2703
+ export type FitStrategyType = {
2704
+ wrapElement(element: HTMLElement): HTMLElement;
2705
+ updateSize(sizingElement: HTMLElement, width: number, height: number): void;
2706
+ };
2707
+ export var FitStrategy: {
2708
+ CONTAIN: FitStrategyType;
2709
+ COVER: FitStrategyType;
2710
+ STRETCH: FitStrategyType;
2711
+ NONE: FitStrategyType;
2712
+ };
762
2713
 
763
2714
 
764
2715
  /**
765
- * Abstract Node class from Babylon.js
2716
+ * The transmittance LUT can be used to get the radiance from an external light source arriving a given point, accounting for atmospheric scattering.
766
2717
  */
767
- export interface INodeLike {
768
- getWorldMatrix(): BABYLON.IMatrixLike;
2718
+ export class TransmittanceLut {
2719
+ /**
2720
+ * Listen to this observer to know when the LUT data has been updated.
2721
+ * This is typically infrequent (once at startup), but also happens whenever the atmosphere's properties change.
2722
+ */
2723
+ readonly onUpdatedObservable: BABYLON.Observable<void>;
2724
+ private readonly _atmosphere;
2725
+ private _lutData;
2726
+ private _renderTarget;
2727
+ private _effectWrapper;
2728
+ private _effectRenderer;
2729
+ private _isDirty;
2730
+ private _isDisposed;
2731
+ /**
2732
+ * True if the LUT has been rendered.
2733
+ */
2734
+ get isDirty(): boolean;
2735
+ /**
2736
+ * The render target that contains the transmittance LUT.
2737
+ * @throws if the LUT has been disposed.
2738
+ */
2739
+ get renderTarget(): BABYLON.RenderTargetTexture;
2740
+ /**
2741
+ * Constructs the {@link TransmittanceLut}.
2742
+ * @param atmosphere - The atmosphere that owns this LUT.
2743
+ */
2744
+ constructor(atmosphere: Atmosphere);
2745
+ /**
2746
+ * Gets the transmittance of an external light through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.
2747
+ * The result is always a linear space color.
2748
+ * @param directionToLight - The direction to the light source.
2749
+ * @param pointRadius - The distance from the origin to the point.
2750
+ * @param pointGeocentricNormal - The normal of the point.
2751
+ * @param result - The color to write the result to.
2752
+ * @returns The result color.
2753
+ */
2754
+ getTransmittedColorToRef<T extends BABYLON.IColor3Like>(directionToLight: BABYLON.IVector3Like, pointRadius: number, pointGeocentricNormal: BABYLON.IVector3Like, result: T): T;
2755
+ /**
2756
+ * Derives light color from the transmittance at a point specified by its distance to the planet center and its geocentric normal.
2757
+ * @param light - The light to update.
2758
+ * @param pointRadius - The distance from the origin to the point.
2759
+ * @param pointGeocentricNormal - The normal of the point.
2760
+ */
2761
+ updateLightParameters(light: BABYLON.DirectionalLight, pointRadius: number, pointGeocentricNormal: BABYLON.IVector3Like): void;
2762
+ /**
2763
+ * Renders the LUT if needed.
2764
+ * @returns true if the LUT was rendered.
2765
+ */
2766
+ render(): boolean;
2767
+ /**
2768
+ * Marks the LUT as needing to be rendered.
2769
+ */
2770
+ markDirty(): void;
2771
+ /**
2772
+ * Disposes the LUT and its resources.
2773
+ */
2774
+ dispose(): void;
769
2775
  }
2776
+
2777
+
770
2778
  /**
771
- * Class used to render text using MSDF (Multi-channel Signed Distance Field) technique
772
- * Thanks a lot to the work of Bhushan_Wagh and zb_sj for their amazing work on MSDF for Babylon.js
773
- * #6RLCWP#16
774
- * Star wars scroller: #6RLCWP#29
775
- * With metrics: #6RLCWP#35
776
- * Thickness: #IABMEZ#3
777
- * Solar system: #9YCDYC#9
778
- * Stroke: #6RLCWP#37
2779
+ * Samples the texture data at the given uv coordinate using bilinear interpolation.
2780
+ * Note this will not match GPU sampling behavior exactly.
2781
+ * Currently assumes clamping behavior.
2782
+ * @param u - The u coordinate to sample.
2783
+ * @param v - The v coordinate to sample.
2784
+ * @param widthPx - The width of the texture in texels.
2785
+ * @param heightPx - The height of the texture in texels.
2786
+ * @param data - The texture data to sample.
2787
+ * @param result - The color to store the sample.
2788
+ * @param normalizeFunc - The function to normalize the texel values. Default is to divide by 255.
2789
+ * @returns The result color.
779
2790
  */
780
- export class TextRenderer implements BABYLON.IDisposable {
781
- private readonly _useVAO;
782
- private _engine;
783
- private _shaderLanguage;
784
- private _vertexBuffers;
785
- private _spriteBuffer;
786
- private _worldBuffer;
787
- private _uvBuffer;
788
- private _drawWrapperBase;
789
- private _vertexArrayObject;
790
- private _font;
791
- private _charMatrices;
792
- private _charUvs;
2791
+ export const Sample2DRgbaToRef: <T extends BABYLON.IColor4Like>(u: number, v: number, widthPx: number, heightPx: number, data: Uint8Array | Uint16Array | Float32Array, result: T, normalizeFunc?: (value: number) => number) => T;
2792
+
2793
+
2794
+
2795
+
2796
+ /**
2797
+ * The diffuse sky irradiance LUT is used to query the diffuse irradiance at a specified position.
2798
+ */
2799
+ export class DiffuseSkyIrradianceLut {
2800
+ private readonly _atmosphere;
2801
+ private _renderTarget;
2802
+ private _effectWrapper;
2803
+ private _effectRenderer;
793
2804
  private _isDirty;
794
- private _baseLine;
795
- private _scalingMatrix;
796
- private _fontScaleMatrix;
797
- private _offsetMatrix;
798
- private _translationMatrix;
799
- private _baseMatrix;
800
- private _scaledMatrix;
801
- private _localMatrix;
802
- private _finalMatrix;
803
- private _lineMatrix;
804
- private _parentWorldMatrix;
2805
+ private _isDisposed;
2806
+ private _lutData;
805
2807
  /**
806
- * Gets or sets the color of the text
2808
+ * True if the LUT needs to be rendered.
807
2809
  */
808
- color: BABYLON.IColor4Like;
2810
+ get isDirty(): boolean;
809
2811
  /**
810
- * Gets or sets the color of the stroke around the text
2812
+ * True if the LUT has been disposed.
811
2813
  */
812
- strokeColor: BABYLON.IColor4Like;
2814
+ get isDisposed(): boolean;
813
2815
  /**
814
- * Gets or sets the width of the stroke around the text (inset)
2816
+ * The render target used for this LUT.
2817
+ * @throws if the LUT has been disposed.
815
2818
  */
816
- strokeInsetWidth: number;
2819
+ get renderTarget(): BABYLON.RenderTargetTexture;
817
2820
  /**
818
- * Gets or sets the width of the stroke around the text (outset)
2821
+ * True if the LUT data has been read back from the GPU.
819
2822
  */
820
- strokeOutsetWidth: number;
2823
+ get hasLutData(): boolean;
821
2824
  /**
822
- * Gets or sets the thickness of the text (0 means as defined in the font)
823
- * Value must be between -0.5 and 0.5
2825
+ * Constructs the {@link DiffuseSkyIrradianceLut}.
2826
+ * @param atmosphere - The atmosphere to use.
824
2827
  */
825
- thicknessControl: number;
826
- private _parent;
2828
+ constructor(atmosphere: Atmosphere);
2829
+ /**
2830
+ * Gets the diffuse sky irradiance for a surface oriented along the geocentric normal.
2831
+ * Resulting color is always in linear space.
2832
+ * @param directionToLight - The direction to the light in world space.
2833
+ * @param radius - The position's distance to the planet origin.
2834
+ * @param cameraGeocentricNormal - The geocentric normal of the camera.
2835
+ * @param lightIrradiance - The irradiance of the light.
2836
+ * @param result - The color to store the result in.
2837
+ * @returns The result color.
2838
+ */
2839
+ getDiffuseSkyIrradianceToRef<T extends BABYLON.IColor3Like>(directionToLight: BABYLON.IVector3Like, radius: number, cameraGeocentricNormal: BABYLON.IVector3Like, lightIrradiance: number, result: T): T;
2840
+ /**
2841
+ * Renders the LUT.
2842
+ * @returns True if the LUT was rendered.
2843
+ */
2844
+ render(): boolean;
2845
+ /**
2846
+ * Marks the LUT as needing to be rendered.
2847
+ */
2848
+ markDirty(): void;
2849
+ /**
2850
+ * Disposes the LUT.
2851
+ */
2852
+ dispose(): void;
2853
+ }
2854
+
2855
+
2856
+ /**
2857
+ * The options for the {@link AtmospherePhysicalProperties} that describe the planet, the atmosphere, and scattering.
2858
+ */
2859
+ export interface IAtmospherePhysicalPropertiesOptions {
2860
+ /**
2861
+ * The radius of the planet in kilometers.
2862
+ */
2863
+ planetRadius?: number;
2864
+ /**
2865
+ * The minimum camera radius (distance from the planet's center) allowed when rendering the atmosphere.
2866
+ * This should be greater than 0.
2867
+ * It prevents rendering issues close to the planet's surface.
2868
+ */
2869
+ planetRadiusOffset?: number;
2870
+ /**
2871
+ * The thickness of the atmosphere measured in kilometers from the planet's surface to the outer edge of the atmosphere.
2872
+ */
2873
+ atmosphereThickness?: number;
2874
+ /**
2875
+ * The scale applied to the Rayleigh scattering.
2876
+ */
2877
+ rayleighScatteringScale?: number;
2878
+ /**
2879
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
2880
+ */
2881
+ peakRayleighScattering?: BABYLON.Vector3;
2882
+ /**
2883
+ * The scale applied to the Mie scattering.
2884
+ */
2885
+ mieScatteringScale?: number;
2886
+ /**
2887
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
2888
+ */
2889
+ peakMieScattering?: BABYLON.Vector3;
2890
+ /**
2891
+ * The scale applied to the Mie absorption.
2892
+ */
2893
+ mieAbsorptionScale?: number;
2894
+ /**
2895
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
2896
+ */
2897
+ peakMieAbsorption?: BABYLON.Vector3;
2898
+ /**
2899
+ * The scale applied to the ozone absorption.
2900
+ */
2901
+ ozoneAbsorptionScale?: number;
2902
+ /**
2903
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
2904
+ */
2905
+ peakOzoneAbsorption?: BABYLON.Vector3;
2906
+ }
2907
+
2908
+
2909
+ /**
2910
+ * Describes the physical properties of the atmosphere. Assumes a spherical planet.
2911
+ * - "radius" values describe a distance from the planet's center.
2912
+ * - "height" values describe a distance from the planet's surface.
2913
+ * - Distances are in kilometers unless otherwise specified. Angles are in radians.
2914
+ */
2915
+ export class AtmospherePhysicalProperties {
2916
+ /**
2917
+ * Notification for when properties of the {@link AtmospherePhysicalProperties} are changed.
2918
+ */
2919
+ readonly onChangedObservable: BABYLON.Observable<AtmospherePhysicalProperties>;
2920
+ private _planetRadius;
2921
+ private _planetRadiusOffset;
2922
+ private _atmosphereThickness;
2923
+ private _rayleighScatteringScale;
2924
+ private _peakRayleighScattering;
2925
+ private _mieScatteringScale;
2926
+ private _peakMieScattering;
2927
+ private _mieAbsorptionScale;
2928
+ private _peakMieAbsorption;
2929
+ private _ozoneAbsorptionScale;
2930
+ private _peakOzoneAbsorption;
2931
+ private _planetRadiusWithOffset;
2932
+ private _planetRadiusSquared;
2933
+ private _atmosphereRadius;
2934
+ private _atmosphereRadiusSquared;
2935
+ private _horizonDistanceToAtmosphereEdge;
2936
+ private _horizonDistanceToAtmosphereEdgeSquared;
2937
+ private _rayleighScattering;
2938
+ private _mieScattering;
2939
+ private _mieAbsorption;
2940
+ private _mieExtinction;
2941
+ private _ozoneAbsorption;
2942
+ /**
2943
+ * The radius of the planet in kilometers.
2944
+ */
2945
+ get planetRadius(): number;
2946
+ set planetRadius(value: number);
2947
+ /**
2948
+ * The squared radius of the planet in kilometers.
2949
+ */
2950
+ get planetRadiusSquared(): number;
2951
+ /**
2952
+ * Offset applied to view points near the planet's surface. This should be greater than 0.
2953
+ * It prevents rendering issues close to the planet's surface.
2954
+ */
2955
+ get planetRadiusOffset(): number;
2956
+ set planetRadiusOffset(value: number);
2957
+ /**
2958
+ * This is the {@link planetRadius} with the additional {@link planetRadiusOffset}, in kilometers.
2959
+ */
2960
+ get planetRadiusWithOffset(): number;
2961
+ /**
2962
+ * The thickness of the atmosphere measured in kilometers.
2963
+ */
2964
+ get atmosphereThickness(): number;
2965
+ set atmosphereThickness(value: number);
2966
+ /**
2967
+ * The combined planet radius and atmosphere thickness in kilometers.
2968
+ */
2969
+ get atmosphereRadius(): number;
2970
+ /**
2971
+ * The atmosphere radius squared in kilometers.
2972
+ */
2973
+ get atmosphereRadiusSquared(): number;
827
2974
  /**
828
- * Gets or sets the parent of the text renderer
2975
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere in kilometers.
829
2976
  */
830
- get parent(): BABYLON.Nullable<INodeLike>;
831
- set parent(value: BABYLON.Nullable<INodeLike>);
832
- private _transformMatrix;
2977
+ get horizonDistanceToAtmosphereEdge(): number;
833
2978
  /**
834
- * Gets or sets the transform matrix of the text renderer
835
- * It will be applied in that order:
836
- * parent x transform x paragraph world
2979
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere, squared, in kilometers.
837
2980
  */
838
- get transformMatrix(): BABYLON.IMatrixLike;
839
- set transformMatrix(value: BABYLON.IMatrixLike);
2981
+ get horizonDistanceToAtmosphereEdgeSquared(): number;
840
2982
  /**
841
- * Gets or sets if the text is billboarded
2983
+ * The scale applied to {@link peakRayleighScattering}.
842
2984
  */
843
- isBillboard: boolean;
2985
+ get rayleighScatteringScale(): number;
2986
+ set rayleighScatteringScale(value: number);
844
2987
  /**
845
- * Gets or sets if the text is screen projected
846
- * This will work only if the text is billboarded
2988
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
847
2989
  */
848
- isBillboardScreenProjected: boolean;
2990
+ get peakRayleighScattering(): BABYLON.Vector3;
2991
+ set peakRayleighScattering(value: BABYLON.Vector3);
849
2992
  /**
850
- * Gets the number of characters in the text renderer
2993
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
2994
+ * This value cannot be set directly. It is inferred by scaling {@link peakRayleighScattering} by {@link rayleighScatteringScale}.
851
2995
  */
852
- get characterCount(): number;
2996
+ get rayleighScattering(): BABYLON.Vector3;
853
2997
  /**
854
- * Gets or sets if the text renderer should ignore the depth buffer
855
- * Default is false
2998
+ * The scale applied to {@link peakMieScattering}.
856
2999
  */
857
- ignoreDepthBuffer: boolean;
858
- private constructor();
859
- private _resizeBuffers;
860
- private _setShaders;
3000
+ get mieScatteringScale(): number;
3001
+ set mieScatteringScale(value: number);
861
3002
  /**
862
- * Add a paragraph of text to the renderer
863
- * @param text define the text to add
864
- * @param options define the options to use for the paragraph (optional)
865
- * @param worldMatrix define the world matrix to use for the paragraph (optional)
3003
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
866
3004
  */
867
- addParagraph(text: string, options?: Partial<ParagraphOptions>, worldMatrix?: BABYLON.IMatrixLike): void;
3005
+ get peakMieScattering(): BABYLON.Vector3;
3006
+ set peakMieScattering(value: BABYLON.Vector3);
868
3007
  /**
869
- * Render the text using the provided view and projection matrices
870
- * @param viewMatrix define the view matrix to use
871
- * @param projectionMatrix define the projection matrix to use
3008
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
3009
+ * This value cannot be set directly. It is inferred by scaling {@link mieScatteringScale} by {@link peakMieScattering}.
872
3010
  */
873
- render(viewMatrix: BABYLON.IMatrixLike, projectionMatrix: BABYLON.IMatrixLike): void;
3011
+ get mieScattering(): BABYLON.Vector3;
874
3012
  /**
875
- * Release associated resources
3013
+ * The scale applied to {@link peakMieAbsorption}.
876
3014
  */
877
- dispose(): void;
3015
+ get mieAbsorptionScale(): number;
3016
+ set mieAbsorptionScale(value: number);
878
3017
  /**
879
- * Creates a new TextRenderer instance asynchronously
880
- * @param font define the font asset to use
881
- * @param engine define the engine to use
882
- * @returns a promise that resolves to the created TextRenderer instance
3018
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
883
3019
  */
884
- static CreateTextRendererAsync(font: FontAsset, engine: BABYLON.AbstractEngine): Promise<TextRenderer>;
885
- }
886
-
887
-
888
- /** @internal */
889
- export type ParagraphOptions = {
890
- maxWidth: number;
891
- lineHeight: number;
892
- letterSpacing: number;
893
- tabSize: number;
894
- whiteSpace: "pre-line";
895
- textAlign: "left" | "right" | "center";
896
- translate: BABYLON.IVector2Like | undefined;
897
- };
898
- /** @internal */
899
- export var DefaultParagraphOptions: ParagraphOptions;
900
-
901
-
902
-
903
-
904
- /**
905
- * Class representing a font asset for SDF (Signed Distance Field) rendering.
906
- */
907
- export class FontAsset implements BABYLON.IDisposable {
908
- private readonly _chars;
909
- private readonly _charsRegex;
910
- private readonly _kernings;
911
- /** @internal */
912
- readonly _font: SdfFont;
3020
+ get peakMieAbsorption(): BABYLON.Vector3;
3021
+ set peakMieAbsorption(value: BABYLON.Vector3);
913
3022
  /**
914
- * Gets the font scale value
3023
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
3024
+ * This value cannot be set directly. It is inferred by scaling {@link mieAbsorptionScale} by {@link peakMieAbsorption}.
915
3025
  */
916
- readonly scale: number;
3026
+ get mieAbsorption(): BABYLON.Vector3;
917
3027
  /**
918
- * Gets the list of used textures
3028
+ * The Mie extinction per kilometer at sea level for red, green, and blue wavelengths.
3029
+ * This value cannot be set directly. It is inferred by adding the {@link mieAbsorption} to the {@link mieScattering}.
919
3030
  */
920
- readonly textures: BABYLON.Texture[];
3031
+ get mieExtinction(): BABYLON.Vector3;
921
3032
  /**
922
- * Creates a new FontAsset instance.
923
- * @param definitionData defines the font data in JSON format.
924
- * @param textureUrl defines the url of the texture to use for the font.
925
- * @param scene defines the hosting scene.
3033
+ * The scale applied to {@link peakOzoneAbsorption}.
926
3034
  */
927
- constructor(definitionData: string, textureUrl: string, scene?: BABYLON.Scene);
928
- dispose(): void;
929
- private _updateFallbacks;
930
- /** @internal */
931
- _getChar(charCode: number): BMFontChar;
932
- /** @internal */
933
- _getKerning(first: number, second: number): number;
934
- /** @internal */
935
- _unsupportedChars(text: string): string;
936
- }
937
-
938
-
939
- /** @internal */
940
- export var msdfVertexShaderWGSL: {
941
- name: string;
942
- shader: string;
943
- };
944
-
945
-
946
- /** @internal */
947
- export var msdfPixelShaderWGSL: {
948
- name: string;
949
- shader: string;
950
- };
951
-
952
-
953
- /** @internal */
954
- export var msdfVertexShader: {
955
- name: string;
956
- shader: string;
957
- };
958
-
959
-
960
- /** @internal */
961
- export var msdfPixelShader: {
962
- name: string;
963
- shader: string;
964
- };
965
-
966
-
967
- /** @internal */
968
- export class SdfTextParagraph {
969
- readonly text: string;
970
- readonly fontAsset: FontAsset;
971
- readonly options: ParagraphOptions;
972
- get lineHeight(): number;
973
- readonly paragraph: string;
974
- readonly lines: SdfTextLine[];
975
- readonly width: number;
976
- readonly height: number;
977
- readonly glyphs: SdfGlyph[];
978
- constructor(text: string, fontAsset: FontAsset, options?: Partial<ParagraphOptions>);
979
- private _computeMetrics;
980
- private _breakLines;
981
- private _collapse;
982
- private _wrap;
983
- }
984
-
985
-
986
- /** @internal */
987
- export type SdfTextLine = {
988
- text: string;
989
- glyphs: SdfGlyph[];
990
- start: number;
991
- end: number;
992
- width: number;
993
- };
994
-
995
-
996
-
997
-
998
- /** @internal */
999
- export type SdfGlyph = {
1000
- char: BMFontChar;
1001
- /** index of the line */
1002
- line: number;
1003
- /** position within the line */
1004
- position: number;
1005
- x: number;
1006
- y: number;
1007
- };
1008
-
1009
-
1010
- export type SdfFontDistanceField = {
1011
- fieldType: "sdf" | "msdf";
1012
- distanceRange: number;
1013
- };
1014
- export type SdfFont = BMFont & {
1015
- distanceField: SdfFontDistanceField;
1016
- };
1017
-
1018
-
1019
- /**
1020
- * Holds information on how the font was generated.
1021
- */
1022
- export type BMFontInfo = {
1023
- /** The name of the font */
1024
- face: string;
1025
- /** The size of the font */
1026
- size: number;
1027
- /** The font is bold */
1028
- bold: number;
1029
- /** The font is italic */
1030
- italic: number;
1031
- /** The charset of the font */
1032
- charset: string[];
1033
- /** The charset is unicode */
1034
- unicode: number;
1035
- /** The font height stretch in percentage. 100% means no stretch. */
1036
- stretchH: number;
1037
- /** Set to 1 if smoothing was turned on. */
1038
- smooth: number;
1039
- /** The supersampling level used. 1 means no supersampling was used. */
1040
- aa: number;
1041
- /** The padding for each character (up, right, down, left). */
1042
- padding: [number, number, number, number];
1043
- /** The spacing for each character (horizontal, vertical). */
1044
- spacing: [number, number];
3035
+ get ozoneAbsorptionScale(): number;
3036
+ set ozoneAbsorptionScale(value: number);
1045
3037
  /**
1046
- * The outline thickness for the characters.
1047
- *
1048
- * @remark missing in msdf-bmfont-xml
3038
+ * The ozone absorption per kilometer measured at a height corresponding to it's peak concentration,
3039
+ * for red, green, and blue wavelengths.
1049
3040
  */
1050
- outline?: number;
1051
- };
1052
- /**
1053
- * Holds information common to all characters.
1054
- */
1055
- export type BMFontCommon = {
1056
- /** Distance in pixels between each line of text */
1057
- lineHeight: number;
1058
- /** The number of pixels from the absolute top of the line to the base of the characters */
1059
- base: number;
1060
- /** The width of the texture, normally used to scale the x pos of the character image */
1061
- scaleW: number;
1062
- /** The height of the texture, normally used to scale the y pos of the character image */
1063
- scaleH: number;
1064
- /** The number of pages in the font */
1065
- pages: number;
1066
- /** Set to 1 if the monochrome characters have been packed into each of the texture channels. In this case alphaChnl describes what is stored in each channel. */
1067
- packed: number;
1068
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1069
- alphaChnl: number;
1070
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1071
- redChnl: number;
1072
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1073
- greenChnl: number;
1074
- /** Set to 0 if the channel holds the glyph data, 1 if it holds the outline, 2 if it holds the glyph and the outline, 3 if its set to zero, and 4 if its set to one. */
1075
- blueChnl: number;
1076
- };
1077
- /** Name of a texture file. There is one for each page in the font. */
1078
- export type BMFontPages = {
1079
- [id: number]: string;
1080
- } & Array<string>;
1081
- /**
1082
- * Describes a single character in the font
1083
- */
1084
- export type BMFontChar = {
1085
- /** Character id (charCode) */
1086
- id: number;
1087
- /** Left position of the character image in the texture. */
1088
- x: number;
1089
- /** Right position of the character image in the texture */
1090
- y: number;
1091
- /** Width of the chracter image in the texture */
1092
- width: number;
1093
- /** Height of the chracter image in the texture */
1094
- height: number;
1095
- /** Horizontal offset to be applied on screen */
1096
- xoffset: number;
1097
- /** Vertical offset to be applied on screen */
1098
- yoffset: number;
1099
- /** Horizontal advance after the character */
1100
- xadvance: number;
1101
- /** Page index where the character image is found */
1102
- page: number;
1103
- /** Texture channel where the chracter image is found
1104
- * - 1 = blue
1105
- * - 2 = green
1106
- * - 3 = red
1107
- * - 8 = alpha
1108
- * - 15 = all channels
3041
+ get peakOzoneAbsorption(): BABYLON.Vector3;
3042
+ set peakOzoneAbsorption(value: BABYLON.Vector3);
3043
+ /**
3044
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
3045
+ * This value cannot be set directly. It is inferred by scaling {@link peakOzoneAbsorption} by {@link ozoneAbsorptionScale}.
1109
3046
  */
1110
- chnl: number;
1111
- } & BMFontCharExtra;
1112
- /**
1113
- * additional context from msdf-bmfont-xml
1114
- */
1115
- export type BMFontCharExtra = {
1116
- /** index of opentype.js glyph */
1117
- index: number;
1118
- /** actual character*/
1119
- char: string;
1120
- };
1121
- /**
1122
- * The kerning information is used to adjust the distance between certain characters, e.g. some characters should be placed closer to each other than others.
1123
- */
1124
- export type BMFontKerning = {
1125
- /** The first character id. */
1126
- first: number;
1127
- /** The second character id. */
1128
- second: number;
1129
- /** How much the x position should be adjusted when drawing the second character immediately following the first. */
1130
- amount: number;
1131
- };
1132
- /**
1133
- * Compatible with [msdf-bmfont-xml](https://github.com/soimy/msdf-bmfont-xml)
1134
- * @see https://www.angelcode.com/products/bmfont/doc/file_format.html
1135
- */
1136
- export type BMFont = {
1137
- /** {@inheritDoc BMFontInfo} */
1138
- info: BMFontInfo;
1139
- /** {@inheritDoc BMFontCommon} */
1140
- common: BMFontCommon;
1141
- /** {@inheritDoc BMFontPages} */
1142
- pages: BMFontPages;
1143
- /** {@inheritDoc BMFontChar} */
1144
- chars: BMFontChar[];
1145
- /** {@inheritDoc BMFontKerning} */
1146
- kernings: BMFontKerning[];
1147
- };
3047
+ get ozoneAbsorption(): BABYLON.Vector3;
3048
+ /**
3049
+ * Constructs the {@link AtmospherePhysicalProperties}.
3050
+ * @param options - The options for the {@link AtmospherePhysicalProperties}.
3051
+ */
3052
+ constructor(options?: IAtmospherePhysicalPropertiesOptions);
3053
+ private _recomputeDimensionalParameters;
3054
+ private _recomputeRayleighScattering;
3055
+ private _recomputeMieScattering;
3056
+ private _recomputeMieAbsorption;
3057
+ private _recomputeMieExtinction;
3058
+ private _recomputeOzoneAbsorption;
3059
+ }
1148
3060
 
1149
3061
 
1150
3062
  /**
1151
- * BABYLON.Behavior for any content that can capture pointer events, i.e. bypass the Babylon pointer event handling
1152
- * and receive pointer events directly. It will register the capture triggers and negotiate the capture and
1153
- * release of pointer events. Curerntly this applies only to HtmlMesh
3063
+ * Variables that are used to render the atmosphere and are computed per-camera.
1154
3064
  */
1155
- export class PointerEventsCaptureBehavior implements BABYLON.Behavior<BABYLON.AbstractMesh> {
1156
- private _captureCallback;
1157
- private _releaseCallback;
1158
- /** gets or sets behavior's name */
1159
- name: string;
1160
- private _attachedMesh;
1161
- /** @internal */
1162
- _captureOnPointerEnter: boolean;
3065
+ export class AtmospherePerCameraVariables {
3066
+ private _inverseViewProjectionMatrixWithoutTranslation;
3067
+ private _directionToLightRelativeToCameraGeocentricNormal;
3068
+ private _cosAngleLightToZenith;
3069
+ private _cameraRadius;
3070
+ private _clampedCameraRadius;
3071
+ private _cameraHeight;
3072
+ private _clampedCameraHeight;
3073
+ private _cameraPositionGlobal;
3074
+ private _clampedCameraPositionGlobal;
3075
+ private _cosCameraHorizonAngleFromZenith;
3076
+ private _sinCameraAtmosphereHorizonAngleFromNadir;
3077
+ private _cameraGeocentricNormal;
3078
+ private _cameraForward;
3079
+ private _cameraNearPlane;
3080
+ private _cameraPosition;
3081
+ private _viewport;
3082
+ private _lastViewMatrix;
3083
+ private _lastProjectionMatrix;
3084
+ private _inverseViewMatrixWithoutTranslation;
3085
+ private _inverseProjectionMatrix;
1163
3086
  /**
1164
- * Gets or sets the mesh that the behavior is attached to
3087
+ * The inverse view projection matrix is used to unproject rays.
3088
+ * To avoid precision issues, the translation part of the matrix has been removed.
1165
3089
  */
1166
- get attachedMesh(): BABYLON.AbstractMesh | null;
1167
- set attachedMesh(value: BABYLON.AbstractMesh | null);
1168
- constructor(_captureCallback: () => void, _releaseCallback: () => void, { captureOnPointerEnter }?: {
1169
- captureOnPointerEnter?: boolean | undefined;
1170
- });
3090
+ get inverseViewProjectionMatrixWithoutTranslation(): BABYLON.IMatrixLike;
1171
3091
  /**
1172
- * Set if the behavior should capture pointer events when the pointer enters the mesh
3092
+ * The direction to the light relative to the geocentric normal under the camera.
1173
3093
  */
1174
- set captureOnPointerEnter(captureOnPointerEnter: boolean);
3094
+ get directionToLightRelativeToCameraGeocentricNormal(): BABYLON.IVector3Like;
1175
3095
  /**
1176
- * Function called when the behavior needs to be initialized (before attaching it to a target)
3096
+ * The cosine of the angle between the light direction and zenith.
1177
3097
  */
1178
- init(): void;
3098
+ get cosAngleLightToZenith(): number;
1179
3099
  /**
1180
- * Called when the behavior is attached to a target
1181
- * @param mesh defines the target where the behavior is attached to
3100
+ * The distance from the camera to the planet origin in kilometers.
1182
3101
  */
1183
- attach(mesh: BABYLON.AbstractMesh): void;
3102
+ get cameraRadius(): number;
1184
3103
  /**
1185
- * Called when the behavior is detached from its target
3104
+ * The distance from the camera to the planet origin, clamped to the planet radius offset, in kilometers.
1186
3105
  */
1187
- detach(): void;
3106
+ get clampedCameraRadius(): number;
1188
3107
  /**
1189
- * Dispose the behavior
3108
+ * The height of the camera above the planet surface in kilometers.
1190
3109
  */
1191
- dispose(): void;
1192
- releasePointerEvents(): void;
1193
- capturePointerEvents(): void;
3110
+ get cameraHeight(): number;
3111
+ /**
3112
+ * The height of the camera above the planet surface, clamped to the planet radius offset, in kilometers.
3113
+ */
3114
+ get clampedCameraHeight(): number;
3115
+ /**
3116
+ * The camera position in global space kilometers.
3117
+ */
3118
+ get cameraPositionGlobal(): BABYLON.IVector3Like;
3119
+ /**
3120
+ * The camera position, clamped to the planet radius offset, in global space kilometers.
3121
+ */
3122
+ get clampedCameraPositionGlobal(): BABYLON.IVector3Like;
3123
+ /**
3124
+ * The cosine of the angle from the zenith to the horizon of the planet, measured from the camera position.
3125
+ */
3126
+ get cosCameraHorizonAngleFromZenith(): number;
3127
+ /**
3128
+ * The sine of the angle from the nadir to the horizon of the atmosphere, measured from the camera position.
3129
+ */
3130
+ get sinCameraAtmosphereHorizonAngleFromNadir(): number;
3131
+ /**
3132
+ * The geocentric normal of the camera in global space i.e., the normalization of {@link cameraPositionGlobal}.
3133
+ */
3134
+ get cameraGeocentricNormal(): BABYLON.IVector3Like;
3135
+ /**
3136
+ * The camera's forward direction in world space.
3137
+ */
3138
+ get cameraForward(): BABYLON.IVector3Like;
3139
+ /**
3140
+ * The distance to the near plane of the camera.
3141
+ */
3142
+ get cameraNearPlane(): number;
3143
+ /**
3144
+ * The camera's position in world space.
3145
+ */
3146
+ get cameraPosition(): BABYLON.IVector3Like;
3147
+ /**
3148
+ * The viewport for the camera.
3149
+ */
3150
+ get viewport(): BABYLON.IVector4Like;
3151
+ /**
3152
+ * Updates the variables.
3153
+ * @param camera - The camera to update the variables for.
3154
+ * @param planetRadius - The radius of the planet in kilometers.
3155
+ * @param planetRadiusWithOffset - The radius of the planet with the offset in kilometers.
3156
+ * @param atmosphereRadius - The radius of the atmosphere in kilometers.
3157
+ * @param directionToLight - The direction to the light in world space.
3158
+ * @param originHeight - The height of the origin (distance from planet's surface) in kilometers.
3159
+ */
3160
+ update(camera: BABYLON.Camera, planetRadius: number, planetRadiusWithOffset: number, atmosphereRadius: number, directionToLight: BABYLON.IVector3Like, originHeight: number): void;
1194
3161
  }
1195
3162
 
1196
3163
 
1197
- type CaptureReleaseCallback = () => void;
1198
- /**
1199
- * Get the id of the object currently capturing pointer events
1200
- * @returns The id of the object currently capturing pointer events
1201
- * or null if no object is capturing pointer events
1202
- */
1203
- export const getCapturingId: () => string | null;
1204
- /**
1205
- * Request that the object with the given id capture pointer events. If there is no current
1206
- * owner, then the request is granted immediately. If there is a current owner, then the request
1207
- * is queued until the current owner releases pointer events.
1208
- * @param requestId An id to identify the request. This id will be used to match the capture
1209
- * request with the release request.
1210
- * @param captureCallback The callback to call when the request is granted and the object is capturing
1211
- * @param releaseCallback The callback to call when the object is no longer capturing pointer events
1212
- */
1213
- export const requestCapture: (requestId: string, captureCallback: CaptureReleaseCallback, releaseCallback: CaptureReleaseCallback) => void;
1214
- /**
1215
- * Release pointer events from the object with the given id. If the object is the current owner
1216
- * then pointer events are released immediately. If the object is not the current owner, then the
1217
- * associated capture request is removed from the queue. If there is no matching capture request
1218
- * in the queue, then the release request is added to a list of unmatched release requests and will
1219
- * negate the next capture request with the same id. This is to guard against the possibility that
1220
- * the release request arrived before the capture request.
1221
- * @param requestId The id which should match the id of the capture request
1222
- */
1223
- export const requestRelease: (requestId: string | null) => void;
3164
+ class AtmospherePBRMaterialDefines extends BABYLON.MaterialDefines {
3165
+ USE_AERIAL_PERSPECTIVE_LUT: boolean;
3166
+ APPLY_AERIAL_PERSPECTIVE_INTENSITY: boolean;
3167
+ APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS: boolean;
3168
+ /**
3169
+ * Constructs the {@link AtmospherePBRMaterialDefines}.
3170
+ * @param useAerialPerspectiveLut - Whether to use the aerial perspective LUT.
3171
+ */
3172
+ constructor(useAerialPerspectiveLut: boolean);
3173
+ }
1224
3174
  /**
1225
- * Release pointer events from the current owner
3175
+ * Adds shading logic to a PBRMaterial that provides radiance, diffuse sky irradiance, and aerial perspective from the atmosphere.
1226
3176
  */
1227
- export const releaseCurrent: () => void;
1228
- }
1229
-
1230
- interface Window {
1231
- "pointer-events-capture-debug": boolean | null;
1232
- }
1233
- declare module ADDONS {
1234
-
1235
-
3177
+ export class AtmospherePBRMaterialPlugin extends BABYLON.MaterialPluginBase {
3178
+ private readonly _atmosphere;
3179
+ private readonly _isAerialPerspectiveEnabled;
3180
+ /**
3181
+ * Constructs the {@link AtmospherePBRMaterialPlugin}.
3182
+ * @param material - The material to apply the plugin to.
3183
+ * @param _atmosphere - The atmosphere to use for shading.
3184
+ * @param _isAerialPerspectiveEnabled - Whether to apply aerial perspective.
3185
+ */
3186
+ constructor(material: BABYLON.Material, _atmosphere: Atmosphere, _isAerialPerspectiveEnabled?: boolean);
3187
+ /**
3188
+ * @override
3189
+ */
3190
+ getUniformBuffersNames(_ubos: string[]): void;
3191
+ /**
3192
+ * @override
3193
+ */
3194
+ getUniforms(): {
3195
+ ubo: {
3196
+ name: string;
3197
+ size: number;
3198
+ type: string;
3199
+ }[];
3200
+ fragment: string;
3201
+ externalUniforms: string[];
3202
+ };
3203
+ /**
3204
+ * @override
3205
+ */
3206
+ isReadyForSubMesh(): boolean;
3207
+ /**
3208
+ * @override
3209
+ */
3210
+ getActiveTextures(_activeTextures: BABYLON.BaseTexture[]): void;
3211
+ /**
3212
+ * @override
3213
+ */
3214
+ bindForSubMesh(uniformBuffer: BABYLON.UniformBuffer): void;
3215
+ /**
3216
+ * @override
3217
+ */
3218
+ prepareDefines(defines: AtmospherePBRMaterialDefines): void;
3219
+ /**
3220
+ * @override
3221
+ */
3222
+ getSamplers(samplers: string[]): void;
3223
+ /**
3224
+ * @override
3225
+ */
3226
+ getCustomCode(shaderType: string): BABYLON.Nullable<Record<string, string>>;
3227
+ }
1236
3228
 
1237
3229
 
1238
3230
  /**
1239
- * A function that compares two submeshes and returns a number indicating which
1240
- * should be rendered first.
1241
- */
1242
- type RenderOrderFunction = (subMeshA: BABYLON.SubMesh, subMeshB: BABYLON.SubMesh) => number;
1243
- /**
1244
- * An instance of this is required to render HtmlMeshes in the scene.
1245
- * if using HtmlMeshes, you must not set render order for group 0 using
1246
- * scene.setRenderingOrder. You must instead pass the compare functions
1247
- * to the HtmlMeshRenderer constructor. If you do not, then your render
1248
- * order will be overwritten if the HtmlMeshRenderer is created after and
1249
- * the HtmlMeshes will not render correctly (they will appear in front of
1250
- * meshes that are actually in front of them) if the HtmlMeshRenderer is
1251
- * created before.
3231
+ * Creation options for the {@link Atmosphere}.
1252
3232
  */
1253
- export class HtmlMeshRenderer {
3233
+ export interface IAtmosphereOptions {
1254
3234
  /**
1255
- * Global scale factor applied to the homogeneous `w` component (m[15]) of the
1256
- * transformation matrix when projecting 3D objects into pixel space.
1257
- *
1258
- * This value is used to balance Babylon units against screen pixels, ensuring
1259
- * that HTML-mapped or screen-space objects appear with the correct relative
1260
- * size. Adjust with care, as changing it affects the projection scale of all
1261
- * transformed objects.
1262
- *
1263
- * The default value is `0.00001`, which works well when 1 Babylon unit
1264
- * corresponds to 1 meter, and the typical screen resolution is around
1265
- * 100 pixels per meter (i.e., 1 pixel per centimeter).
3235
+ * The properties that define the atmosphere's composition and size.
1266
3236
  */
1267
- static PROJECTION_SCALE_FACTOR: number;
1268
- private _containerId?;
1269
- private _inSceneElements?;
1270
- private _overlayElements?;
1271
- private _engine;
1272
- private _cache;
1273
- private _width;
1274
- private _height;
1275
- private _heightHalf;
1276
- private _cameraWorldMatrix?;
1277
- private _temp;
1278
- private _lastDevicePixelRatio;
1279
- private _cameraMatrixUpdated;
1280
- private _previousCanvasDocumentPosition;
1281
- private _renderObserver;
3237
+ physicalProperties?: AtmospherePhysicalProperties;
1282
3238
  /**
1283
- * Contruct an instance of HtmlMeshRenderer
1284
- * @param scene
1285
- * @param options object containing the following optional properties:
1286
- * @returns
3239
+ * An optional depth texture that will be used by the fullscreen passes that render the sky, aerial perspective, or globe atmosphere.
3240
+ * This enables deferred rendering scenarios, where atmospheric effects need to be composited onto geometry buffers.
3241
+ * Expects infinite far plane on the camera (camera.maxZ = 0) and a non-linear depth to be stored in the red channel.
1287
3242
  */
1288
- constructor(scene: BABYLON.Scene, { parentContainerId, _containerId, enableOverlayRender, defaultOpaqueRenderOrder, defaultAlphaTestRenderOrder, defaultTransparentRenderOrder, }?: {
1289
- parentContainerId?: string | null;
1290
- _containerId?: string;
1291
- defaultOpaqueRenderOrder?: RenderOrderFunction;
1292
- defaultAlphaTestRenderOrder?: RenderOrderFunction;
1293
- defaultTransparentRenderOrder?: RenderOrderFunction;
1294
- enableOverlayRender?: boolean;
1295
- });
3243
+ depthTexture?: BABYLON.BaseTexture;
1296
3244
  /**
1297
- * Dispose of the HtmlMeshRenderer
3245
+ * Controls the overall brightness of the atmosphere rendering.
3246
+ * A value of 1.0 is physically correct.
1298
3247
  */
1299
- dispose(): void;
1300
- protected _init(scene: BABYLON.Scene, parentContainerId: string | null, enableOverlayRender: boolean, defaultOpaqueRenderOrder: RenderOrderFunction, defaultAlphaTestRenderOrder: RenderOrderFunction, defaultTransparentRenderOrder: RenderOrderFunction): void;
1301
- private _createRenderLayerElements;
1302
- protected _getSize(): {
1303
- width: number;
1304
- height: number;
1305
- };
1306
- protected _setSize(width: number, height: number): void;
1307
- protected _getCameraCssMatrix(matrix: BABYLON.Matrix): string;
1308
- protected _getHtmlContentCssMatrix(matrix: BABYLON.Matrix, useRightHandedSystem: boolean): string;
1309
- protected _getTransformationMatrix(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): BABYLON.Matrix;
1310
- protected _renderHtmlMesh(htmlMesh: HtmlMesh, useRightHandedSystem: boolean): void;
1311
- protected _render(scene: BABYLON.Scene, camera: BABYLON.Camera): void;
1312
- protected _updateBaseScaleFactor(htmlMesh: HtmlMesh): void;
1313
- protected _updateContainerPositionIfNeeded(): void;
1314
- protected _onCameraMatrixChanged: (camera: BABYLON.Camera) => void;
1315
- private _epsilon;
1316
- private _getAncestorMarginsAndPadding;
3248
+ exposure?: number;
3249
+ /**
3250
+ * Whether the light values should be specified in linear space.
3251
+ * Set to true when using PBRMaterials, which expect linear light values.
3252
+ */
3253
+ isLinearSpaceLight?: boolean;
3254
+ /**
3255
+ * Whether the composition of the sky should be in linear space.
3256
+ * Set to true for HDR rendering or when using image post-processes.
3257
+ */
3258
+ isLinearSpaceComposition?: boolean;
3259
+ /**
3260
+ * Whether to apply approximate transmittance to dim surfaces behind the atmosphere.
3261
+ * When true, distant surfaces are dimmed using a grayscale approximation of transmittance.
3262
+ */
3263
+ applyApproximateTransmittance?: boolean;
3264
+ /**
3265
+ * Whether to use the sky view LUT for compositing the sky.
3266
+ * When false, full ray marching is required (slower).
3267
+ */
3268
+ isSkyViewLutEnabled?: boolean;
3269
+ /**
3270
+ * Whether to use the aerial perspective LUT.
3271
+ * When false, full ray marching is required for aerial perspective (slower).
3272
+ */
3273
+ isAerialPerspectiveLutEnabled?: boolean;
3274
+ /**
3275
+ * Radiance bias applied to the aerial perspective.
3276
+ * Positive values brighten the aerial perspective, negative values darken it.
3277
+ * The default is 0 (no change).
3278
+ */
3279
+ aerialPerspectiveRadianceBias?: number;
3280
+ /**
3281
+ * Scale factor for the amount of light transmitted into aerial perspective from the light source.
3282
+ * The default is 1 (no scaling).
3283
+ */
3284
+ aerialPerspectiveTransmittanceScale?: number;
3285
+ /**
3286
+ * Amount of saturation applied to the aerial perspective.
3287
+ * Lower values make the aerial perspective more gray.
3288
+ * The default is 1 (no saturation change).
3289
+ */
3290
+ aerialPerspectiveSaturation?: number;
3291
+ /**
3292
+ * Overall intensity multiplier for the aerial perspective effect.
3293
+ * Higher values increase haziness.
3294
+ * The default is 1 (no intensity change).
3295
+ */
3296
+ aerialPerspectiveIntensity?: number;
3297
+ /**
3298
+ * Whether to use the diffuse sky irradiance LUT.
3299
+ */
3300
+ isDiffuseSkyIrradianceLutEnabled?: boolean;
3301
+ /**
3302
+ * Higher values result in more desaturated diffuse irradiance.
3303
+ * The default is 0 (no desaturation).
3304
+ */
3305
+ diffuseSkyIrradianceDesaturationFactor?: number;
3306
+ /**
3307
+ * Overall intensity multiplier for the diffuse irradiance.
3308
+ * The default is 1 (no intensity change).
3309
+ */
3310
+ diffuseSkyIrradianceIntensity?: number;
3311
+ /**
3312
+ * Controls the intensity of the additional diffuse irradiance amount.
3313
+ */
3314
+ additionalDiffuseSkyIrradianceIntensity?: number;
3315
+ /**
3316
+ * Controls the color of the additional diffuse irradiance amount.
3317
+ */
3318
+ additionalDiffuseSkyIrradianceColor?: BABYLON.IColor3Like;
3319
+ /**
3320
+ * Higher values increase the contribution of multiple scattering to the overall atmosphere.
3321
+ * Default is 1 (no intensity change).
3322
+ */
3323
+ multiScatteringIntensity?: number;
3324
+ /**
3325
+ * Average color of light reflected off the ground.
3326
+ * Affects the multiply scattered light contribution in the atmosphere.
3327
+ */
3328
+ groundAlbedo?: BABYLON.IColor3Like;
3329
+ /**
3330
+ * Minimum color for multiple scattering.
3331
+ * Useful for creating a quick, but not physically accurate, night sky.
3332
+ */
3333
+ minimumMultiScatteringColor?: BABYLON.IColor3Like;
3334
+ /**
3335
+ * Controls the intensity of the {@link minimumMultiScatteringColor}.
3336
+ * Useful for creating a quick, but not physically accurate, night sky.
3337
+ */
3338
+ minimumMultiScatteringIntensity?: number;
3339
+ /**
3340
+ * Height in kilometers of the scene's origin relative to the planet surface.
3341
+ */
3342
+ originHeight?: number;
3343
+ /**
3344
+ * The rendering group ID for the sky compositor.
3345
+ * When specified, the sky will only be rendered for this group.
3346
+ * If not specified, defaults to group 0.
3347
+ */
3348
+ skyRenderingGroup?: number;
3349
+ /**
3350
+ * The rendering group ID for the aerial perspective compositor.
3351
+ * When specified, aerial perspective will only be rendered for this group.
3352
+ * If not specified, defaults to group 0.
3353
+ */
3354
+ aerialPerspectiveRenderingGroup?: number;
3355
+ /**
3356
+ * The rendering group ID for the globe atmosphere compositor.
3357
+ * When specified, the globe atmosphere will only be rendered for this group.
3358
+ * If not specified, defaults to group 0.
3359
+ */
3360
+ globeAtmosphereRenderingGroup?: number;
1317
3361
  }
1318
3362
 
1319
3363
 
1320
3364
  /**
1321
- * This class represents HTML content that we want to render as though it is part of the scene. The HTML content is actually
1322
- * rendered below the canvas, but a depth mask is created by this class that writes to the depth buffer but does not
1323
- * write to the color buffer, effectively punching a hole in the canvas. CSS transforms are used to scale, translate, and rotate
1324
- * the HTML content so that it matches the camera and mesh orientation. The class supports interactions in editable and non-editable mode.
1325
- * In non-editable mode (the default), events are passed to the HTML content when the pointer is over the mask (and not occluded by other meshes
1326
- * in the scene).
1327
- * @see https://playground.babylonjs.com/#HVHYJC#5
1328
- * @see https://playground.babylonjs.com/#B17TC7#112
3365
+ * Renders a physically based atmosphere.
3366
+ * Use {@link IsSupported} to check if the atmosphere is supported before creating an instance.
3367
+ * @experimental
1329
3368
  */
1330
- export class HtmlMesh extends BABYLON.Mesh {
3369
+ export class Atmosphere implements BABYLON.IDisposable {
3370
+ readonly name: string;
3371
+ readonly scene: BABYLON.Scene;
3372
+ private readonly _directionToLight;
3373
+ private readonly _tempSceneAmbient;
3374
+ private readonly _engine;
3375
+ private _physicalProperties;
3376
+ private _transmittanceLut;
3377
+ private _diffuseSkyIrradianceLut;
3378
+ private _isSkyViewLutEnabled;
3379
+ private _isAerialPerspectiveLutEnabled;
3380
+ private _aerialPerspectiveTransmittanceScale;
3381
+ private _aerialPerspectiveSaturation;
3382
+ private _aerialPerspectiveIntensity;
3383
+ private _aerialPerspectiveRadianceBias;
3384
+ private _diffuseSkyIrradianceDesaturationFactor;
3385
+ private _additionalDiffuseSkyIrradianceIntensity;
3386
+ private _additionalDiffuseSkyIrradianceColor;
3387
+ private _additionalDiffuseSkyIrradiance;
3388
+ private _diffuseSkyIrradianceIntensity;
3389
+ private _multiScatteringIntensity;
3390
+ private _groundAlbedo;
3391
+ private _minimumMultiScatteringColor;
3392
+ private _minimumMultiScatteringIntensity;
3393
+ private _lights;
3394
+ private _atmosphereUbo;
3395
+ private _minimumMultiScattering;
3396
+ private _cameraAtmosphereVariables;
3397
+ private _isLinearSpaceComposition;
3398
+ private _isLinearSpaceLight;
3399
+ private _lightRadianceAtCamera;
3400
+ private _linearLightColor;
3401
+ private _originHeight;
3402
+ private _applyApproximateTransmittance;
3403
+ private _exposure;
3404
+ private _atmosphereUniformBufferAsArray;
3405
+ private _effectRenderer;
3406
+ private _skyRenderingGroup;
3407
+ private _aerialPerspectiveRenderingGroup;
3408
+ private _globeAtmosphereRenderingGroup;
3409
+ private _isEnabled;
3410
+ private _hasRenderedMultiScatteringLut;
3411
+ private _multiScatteringEffectWrapper;
3412
+ private _multiScatteringLutRenderTarget;
3413
+ private _aerialPerspectiveLutEffectWrapper;
3414
+ private _aerialPerspectiveLutEffectRenderer;
3415
+ private _aerialPerspectiveLutRenderTarget;
3416
+ private _skyViewLutEffectWrapper;
3417
+ private _skyViewLutEffectRenderer;
3418
+ private _skyViewLutRenderTarget;
3419
+ private _aerialPerspectiveCompositorEffectWrapper;
3420
+ private _skyCompositorEffectWrapper;
3421
+ private _globeAtmosphereCompositorEffectWrapper;
3422
+ private _onBeforeCameraRenderObserver;
3423
+ private _onBeforeDrawPhaseObserver;
3424
+ private _onAfterRenderingGroupObserver;
1331
3425
  /**
1332
- * Helps identifying a html mesh from a regular mesh
3426
+ * Checks if the {@link Atmosphere} is supported.
3427
+ * @param engine - The engine to check.
3428
+ * @returns True if the atmosphere is supported, false otherwise.
1333
3429
  */
1334
- get isHtmlMesh(): boolean;
1335
- private _enabled;
1336
- private _ready;
3430
+ static IsSupported(engine: BABYLON.AbstractEngine): boolean;
3431
+ /**
3432
+ * Called after the atmosphere variables have been updated for the specified camera.
3433
+ */
3434
+ readonly onAfterUpdateVariablesForCameraObservable: BABYLON.Observable<BABYLON.Camera>;
3435
+ /**
3436
+ * Called immediately before the light variables are finalized.
3437
+ */
3438
+ readonly onBeforeLightVariablesUpdateObservable: BABYLON.Observable<void>;
3439
+ /**
3440
+ * Called before the LUTs are rendered for this camera. This happens after the per-camera UBO update.
3441
+ */
3442
+ readonly onBeforeRenderLutsForCameraObservable: BABYLON.Observable<void>;
3443
+ /**
3444
+ * Called after the LUTs were rendered.
3445
+ */
3446
+ readonly onAfterRenderLutsForCameraObservable: BABYLON.Observable<void>;
1337
3447
  /**
3448
+ * If provided, this is the depth texture used for composition passes.
3449
+ * Expects an infinite far plane on the camera (camera.maxZ = 0) and the non-linear depth accessible in red channel.
1338
3450
  * @internal
1339
3451
  */
1340
- _isCanvasOverlay: boolean;
1341
- private _requiresUpdate;
1342
- private _element?;
1343
- private _width?;
1344
- private _height?;
1345
- private _inverseScaleMatrix;
1346
- private _captureOnPointerEnter;
1347
- private _pointerEventCaptureBehavior;
1348
- private _sourceWidth;
1349
- private _sourceHeight;
3452
+ readonly depthTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
1350
3453
  /**
1351
- * Return the source width of the content in pixels
3454
+ * Controls the overall brightness of the atmosphere rendering.
1352
3455
  */
1353
- get sourceWidth(): number | null;
3456
+ get exposure(): number;
3457
+ set exposure(value: number);
1354
3458
  /**
1355
- * Return the source height of the content in pixels
3459
+ * Affects the overall intensity of the multiple scattering.
1356
3460
  */
1357
- get sourceHeight(): number | null;
1358
- private _worldMatrixUpdateObserver;
1359
- private _fitStrategy;
3461
+ get multiScatteringIntensity(): number;
3462
+ set multiScatteringIntensity(value: number);
1360
3463
  /**
1361
- * Contruct an instance of HtmlMesh
1362
- * @param scene
1363
- * @param id The id of the mesh. Will be used as the id of the HTML element as well.
1364
- * @param options object with optional parameters
3464
+ * Affects the multiply scattered light contribution in the atmosphere by describing the average light color reflected off the ground.
1365
3465
  */
1366
- constructor(scene: BABYLON.Scene, id: string, { captureOnPointerEnter, isCanvasOverlay, fitStrategy }?: {
1367
- captureOnPointerEnter?: boolean | undefined;
1368
- isCanvasOverlay?: boolean | undefined;
1369
- fitStrategy?: FitStrategyType | undefined;
1370
- });
3466
+ get groundAlbedo(): BABYLON.DeepImmutable<BABYLON.IColor3Like>;
3467
+ set groundAlbedo(value: BABYLON.DeepImmutable<BABYLON.IColor3Like>);
1371
3468
  /**
1372
- * The width of the content in pixels
3469
+ * Can be used to clamp the multiple scattering to a minimum value.
1373
3470
  */
1374
- get width(): number | undefined;
3471
+ get minimumMultiScatteringColor(): BABYLON.DeepImmutable<BABYLON.IColor3Like>;
3472
+ set minimumMultiScatteringColor(value: BABYLON.DeepImmutable<BABYLON.IColor3Like>);
1375
3473
  /**
1376
- * The height of the content in pixels
3474
+ * This is an additional scaling factor applied to the {@link minimumMultiScatteringColor}.
1377
3475
  */
1378
- get height(): number | undefined;
3476
+ get minimumMultiScatteringIntensity(): number;
3477
+ set minimumMultiScatteringIntensity(value: number);
1379
3478
  /**
1380
- * The HTML element that is being rendered as a mesh
3479
+ * Can be used to force the diffuse irradiance towards a gray color.
1381
3480
  */
1382
- get element(): HTMLElement | undefined;
3481
+ get diffuseSkyIrradianceDesaturationFactor(): number;
3482
+ set diffuseSkyIrradianceDesaturationFactor(value: number);
1383
3483
  /**
1384
- * True if the mesh has been moved, rotated, or scaled since the last time this
1385
- * property was read. This property is reset to false after reading.
3484
+ * This is an additional amount of irradiance added to the diffuse irradiance.
1386
3485
  */
1387
- get requiresUpdate(): boolean;
3486
+ get additionalDiffuseSkyIrradianceIntensity(): number;
3487
+ set additionalDiffuseSkyIrradianceIntensity(value: number);
1388
3488
  /**
1389
- * Enable capture for the pointer when entering the mesh area
3489
+ * This is the color for the additional amount of irradiance added to the diffuse irradiance.
1390
3490
  */
1391
- set captureOnPointerEnter(captureOnPointerEnter: boolean);
3491
+ get additionalDiffuseSkyIrradianceColor(): BABYLON.DeepImmutable<BABYLON.IColor3Like>;
3492
+ set additionalDiffuseSkyIrradianceColor(value: BABYLON.DeepImmutable<BABYLON.IColor3Like>);
1392
3493
  /**
1393
- * Disposes of the mesh and the HTML element
3494
+ * The final additional diffuse irradiance, taking into account the intensity and color.
3495
+ */
3496
+ get additionalDiffuseSkyIrradiance(): BABYLON.DeepImmutable<BABYLON.IColor3Like>;
3497
+ /**
3498
+ * The intensity of the diffuse irradiance.
3499
+ */
3500
+ get diffuseSkyIrradianceIntensity(): number;
3501
+ set diffuseSkyIrradianceIntensity(value: number);
3502
+ /**
3503
+ * True if the sky view LUT should be used for compositing the sky instead of a per-pixel ray march.
3504
+ */
3505
+ get isSkyViewLutEnabled(): boolean;
3506
+ set isSkyViewLutEnabled(value: boolean);
3507
+ /**
3508
+ * Gets the sky view LUT render target or null if not enabled.
3509
+ * @returns The render target.
3510
+ */
3511
+ get skyViewLutRenderTarget(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
3512
+ /**
3513
+ * True if the aerial perspective LUT should be used.
3514
+ * If false, full ray marching would be used instead.
3515
+ */
3516
+ get isAerialPerspectiveLutEnabled(): boolean;
3517
+ set isAerialPerspectiveLutEnabled(value: boolean);
3518
+ /**
3519
+ * Gets the aerial perspective LUT render target or null if not enabled.
3520
+ * @returns The render target.
3521
+ */
3522
+ get aerialPerspectiveLutRenderTarget(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
3523
+ /**
3524
+ * The intensity of the aerial perspective.
3525
+ */
3526
+ get aerialPerspectiveIntensity(): number;
3527
+ set aerialPerspectiveIntensity(value: number);
3528
+ /**
3529
+ * The amount of light transmitted into aerial perspective.
3530
+ * A scale of 1 is physically correct.
3531
+ */
3532
+ get aerialPerspectiveTransmittanceScale(): number;
3533
+ set aerialPerspectiveTransmittanceScale(value: number);
3534
+ /**
3535
+ * The amount of saturation applied to the aerial perspective.
3536
+ * Reducing to zero desaturates the aerial perspective completely.
3537
+ * A value of 1 has no effect.
3538
+ */
3539
+ get aerialPerspectiveSaturation(): number;
3540
+ set aerialPerspectiveSaturation(value: number);
3541
+ /**
3542
+ * A radiance bias applied to aerial perspective.
3543
+ */
3544
+ get aerialPerspectiveRadianceBias(): number;
3545
+ set aerialPerspectiveRadianceBias(value: number);
3546
+ /**
3547
+ * True if the composition should be in linear space (e.g. for HDR rendering).
3548
+ * Typically linear space is expected when ImageProcessing is enabled via PostProcesses.
3549
+ * False for non-linear output.
3550
+ */
3551
+ get isLinearSpaceComposition(): boolean;
3552
+ set isLinearSpaceComposition(value: boolean);
3553
+ /**
3554
+ * True if the {@link light} value should be specified in linear space.
3555
+ * If using PBRMaterials, light value is expected to be linear.
3556
+ */
3557
+ get isLinearSpaceLight(): boolean;
3558
+ set isLinearSpaceLight(value: boolean);
3559
+ /**
3560
+ * The lookup table for transmittance.
3561
+ */
3562
+ get transmittanceLut(): BABYLON.Nullable<TransmittanceLut>;
3563
+ /**
3564
+ * Gets the multiple scattering LUT render target.
3565
+ * @returns The render target.
3566
+ */
3567
+ get multiScatteringLutRenderTarget(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
3568
+ /**
3569
+ * The lookup table for diffuse sky irradiance, or null if not enabled.
3570
+ */
3571
+ get diffuseSkyIrradianceLut(): BABYLON.Nullable<DiffuseSkyIrradianceLut>;
3572
+ /**
3573
+ * The properties used to describe the size and optical parameters of the atmosphere.
3574
+ */
3575
+ get physicalProperties(): AtmospherePhysicalProperties;
3576
+ /**
3577
+ * The height in kilometers of the scene's origin.
3578
+ */
3579
+ get originHeight(): number;
3580
+ set originHeight(value: number);
3581
+ /**
3582
+ * When atmospheric scattering is applied to surfaces, if this value is set to true,
3583
+ * a grayscale approximation of the transmittance is used to dim surfaces.
3584
+ *
3585
+ * When set to false, the atmospheric composition does not dim the surfaces behind it.
3586
+ * It is up to the client application to apply transmittance manually.
3587
+ */
3588
+ get applyApproximateTransmittance(): boolean;
3589
+ set applyApproximateTransmittance(value: boolean);
3590
+ /**
3591
+ * The directional lights in the scene which represent the suns illuminating the atmosphere.
3592
+ * Each frame, the color and intensity of the lights are updated based on the camera position and the light's direction.
3593
+ */
3594
+ get lights(): ReadonlyArray<BABYLON.DirectionalLight>;
3595
+ /**
3596
+ * The rendering group ID for the sky compositor.
3597
+ * The sky will only be rendered for this group.
3598
+ */
3599
+ get skyRenderingGroup(): number;
3600
+ set skyRenderingGroup(value: number);
3601
+ /**
3602
+ * The rendering group ID for the aerial perspective compositor.
3603
+ * Aerial perspective will only be rendered for this group.
3604
+ */
3605
+ get aerialPerspectiveRenderingGroup(): number;
3606
+ set aerialPerspectiveRenderingGroup(value: number);
3607
+ /**
3608
+ * The rendering group ID for the globe atmosphere compositor.
3609
+ * The globe atmosphere will only be rendered for this group.
3610
+ */
3611
+ get globeAtmosphereRenderingGroup(): number;
3612
+ set globeAtmosphereRenderingGroup(value: number);
3613
+ /**
3614
+ * Gets the uniform buffer used to store the atmosphere's physical properties.
3615
+ */
3616
+ get uniformBuffer(): BABYLON.UniformBuffer;
3617
+ /**
3618
+ * Gets the camera-related variables for this atmosphere. Updated each frame.
3619
+ */
3620
+ get cameraAtmosphereVariables(): AtmospherePerCameraVariables;
3621
+ private _peakRayleighScatteringMmInternal;
3622
+ private _peakRayleighScatteringKm;
3623
+ private _peakMieScatteringMmInternal;
3624
+ private _peakMieScatteringKm;
3625
+ private _peakMieAbsorptionMmInternal;
3626
+ private _peakMieAbsorptionKm;
3627
+ private _peakOzoneAbsorptionMmInternal;
3628
+ private _peakOzoneAbsorptionKm;
3629
+ private get _planetRadius();
3630
+ private set _planetRadius(value);
3631
+ private get _planetRadiusOffset();
3632
+ private set _planetRadiusOffset(value);
3633
+ private get _atmosphereThickness();
3634
+ private set _atmosphereThickness(value);
3635
+ private get _rayleighScatteringScale();
3636
+ private set _rayleighScatteringScale(value);
3637
+ private get _peakRayleighScatteringMm();
3638
+ private set _peakRayleighScatteringMm(value);
3639
+ private get _mieScatteringScale();
3640
+ private set _mieScatteringScale(value);
3641
+ private get _peakMieScatteringMm();
3642
+ private set _peakMieScatteringMm(value);
3643
+ private get _mieAbsorptionScale();
3644
+ private set _mieAbsorptionScale(value);
3645
+ private get _peakMieAbsorptionMm();
3646
+ private set _peakMieAbsorptionMm(value);
3647
+ private get _ozoneAbsorptionScale();
3648
+ private set _ozoneAbsorptionScale(value);
3649
+ private get _peakOzoneAbsorptionMm();
3650
+ private set _peakOzoneAbsorptionMm(value);
3651
+ /**
3652
+ * Constructs the {@link Atmosphere}.
3653
+ * @param name - The name of this instance.
3654
+ * @param scene - The scene to which the atmosphere will be added.
3655
+ * @param lights - The light sources that illuminate the atmosphere. Currently only supports one light, and that light should be the first light in the scene.
3656
+ * @param options - The options used to create the atmosphere.
3657
+ */
3658
+ constructor(name: string, scene: BABYLON.Scene, lights: BABYLON.DirectionalLight[], options?: IAtmosphereOptions);
3659
+ /**
3660
+ * @override
1394
3661
  */
1395
3662
  dispose(): void;
1396
3663
  /**
1397
- * @internal
3664
+ * True if the atmosphere is enabled.
3665
+ * @returns - True if the atmosphere is enabled.
1398
3666
  */
1399
- _markAsUpdated(): void;
3667
+ isEnabled(): boolean;
1400
3668
  /**
1401
- * Sets the content of the element to the specified content adjusting the mesh scale to match and making it visible.
1402
- * If the the specified content is undefined, then it will make the mesh invisible. In either case it will clear the
1403
- * element content first.
1404
- * @param element The element to render as a mesh
1405
- * @param width The width of the mesh in Babylon units
1406
- * @param height The height of the mesh in Babylon units
3669
+ * Sets the enabled state of the atmosphere.
3670
+ * @param enabled - True to enable the atmosphere, false to disable it.
1407
3671
  */
1408
- setContent(element: HTMLElement, width: number, height: number): void;
1409
3672
  setEnabled(enabled: boolean): void;
1410
3673
  /**
1411
- * Sets the content size in pixels
1412
- * @param width width of the source
1413
- * @param height height of the source
3674
+ * The class name of the {@link Atmosphere}.
3675
+ * @returns - The class name of the atmosphere.
1414
3676
  */
1415
- setContentSizePx(width: number, height: number): void;
1416
- protected _setAsReady(ready: boolean): void;
1417
- protected _doSetEnabled(enabled: boolean): void;
1418
- protected _updateScaleIfNecessary(): void;
1419
- protected _createMask(): void;
1420
- protected _setElementzIndex(zIndex: number): void;
3677
+ getClassName(): string;
1421
3678
  /**
1422
- * Callback used by the PointerEventsCaptureBehavior to capture pointer events
3679
+ * Gets the color of a light after being transmitted through the atmosphere to a point specified by its distance to the planet center and its geocentric normal.
3680
+ * NOTE, the result is always a linear space color.
3681
+ * @param directionToLight - The direction of the light.
3682
+ * @param pointRadius - The distance from the planet center to the point in kilometers.
3683
+ * @param pointGeocentricNormal - The geocentric normal at the point i.e., normalize(point - planet center).
3684
+ * @param result - The color to store the result in.
3685
+ * @returns The result color.
1423
3686
  */
1424
- capturePointerEvents(): void;
3687
+ getTransmittedColorToRef: <T extends BABYLON.IColor3Like>(directionToLight: BABYLON.IVector3Like, pointRadius: number, pointGeocentricNormal: BABYLON.IVector3Like, result: T) => T;
1425
3688
  /**
1426
- * Callback used by the PointerEventsCaptureBehavior to release pointer events
3689
+ * Gets the diffuse sky irradiance. Result is always in linear space.
3690
+ * @param directionToLight - The direction of the point to the light.
3691
+ * @param pointRadius - The distance from the planet center to the point in kilometers.
3692
+ * @param pointGeocentricNormal - The geocentric normal at the point: normalize(point - planet center).
3693
+ * @param lightIrradiance - The irradiance of the light.
3694
+ * @param result - The color to store the result in.
3695
+ * @returns The result color.
1427
3696
  */
1428
- releasePointerEvents(): void;
1429
- protected _createElement(): HTMLDivElement | undefined;
3697
+ getDiffuseSkyIrradianceToRef: <T extends BABYLON.IColor3Like>(directionToLight: BABYLON.IVector3Like, pointRadius: number, pointGeocentricNormal: BABYLON.IVector3Like, lightIrradiance: number, result: T) => T;
3698
+ /**
3699
+ * Creates a new {@link EffectWrapper} for the multiple scattering LUT
3700
+ * @returns The newly created {@link EffectWrapper}.
3701
+ */
3702
+ private _createMultiScatteringEffectWrapper;
3703
+ /**
3704
+ * Draws the multiple scattering LUT using {@link EffectWrapper} and {@link EffectRenderer}.
3705
+ */
3706
+ private _drawMultiScatteringLut;
3707
+ /**
3708
+ * Draws the aerial perspective compositor using {@link EffectWrapper} and {@link EffectRenderer}.
3709
+ */
3710
+ private _drawAerialPerspectiveCompositor;
3711
+ /**
3712
+ * Draws the sky compositor using {@link EffectWrapper} and {@link EffectRenderer}.
3713
+ */
3714
+ private _drawSkyCompositor;
3715
+ /**
3716
+ * Draws the globe atmosphere compositor using {@link EffectWrapper} and {@link EffectRenderer}.
3717
+ */
3718
+ private _drawGlobeAtmosphereCompositor;
3719
+ private _disposeSkyCompositor;
3720
+ private _disposeAerialPerspectiveCompositor;
3721
+ private _disposeGlobeAtmosphereCompositor;
3722
+ /**
3723
+ * Updates the camera variables that are specific to the atmosphere.
3724
+ * @param camera - The camera to update the variables for.
3725
+ */
3726
+ private _updatePerCameraVariables;
3727
+ /**
3728
+ * Renders the lookup tables, some of which can vary per-camera.
3729
+ * It is expected that updatePerCameraVariables was previously called.
3730
+ */
3731
+ private _renderLutsForCamera;
3732
+ /**
3733
+ * Renders the lookup tables that do not depend on a camera position.
3734
+ */
3735
+ renderGlobalLuts(): void;
3736
+ /**
3737
+ * Binds the atmosphere's uniform buffer to an {@link BABYLON.Effect}.
3738
+ * @param effect - The {@link BABYLON.Effect} to bind the uniform buffer to.
3739
+ */
3740
+ bindUniformBufferToEffect(effect: BABYLON.Effect): void;
3741
+ /**
3742
+ * Updates the atmosphere's uniform buffer.
3743
+ */
3744
+ private _updateUniformBuffer;
3745
+ /**
3746
+ * Draws the aerial perspective LUT using {@link EffectWrapper} and {@link EffectRenderer}.
3747
+ */
3748
+ private _drawAerialPerspectiveLut;
3749
+ /**
3750
+ * Draws the sky view LUT using {@link EffectWrapper} and {@link EffectRenderer}.
3751
+ */
3752
+ private _drawSkyViewLut;
1430
3753
  }
1431
3754
 
1432
3755
 
1433
- export type FitStrategyType = {
1434
- wrapElement(element: HTMLElement): HTMLElement;
1435
- updateSize(sizingElement: HTMLElement, width: number, height: number): void;
3756
+ /** @internal */
3757
+ export var transmittancePixelShader: {
3758
+ name: string;
3759
+ shader: string;
1436
3760
  };
1437
- export var FitStrategy: {
1438
- CONTAIN: FitStrategyType;
1439
- COVER: FitStrategyType;
1440
- STRETCH: FitStrategyType;
1441
- NONE: FitStrategyType;
3761
+
3762
+
3763
+ /** @internal */
3764
+ export var skyViewPixelShader: {
3765
+ name: string;
3766
+ shader: string;
3767
+ };
3768
+
3769
+
3770
+ /** @internal */
3771
+ export var multiScatteringPixelShader: {
3772
+ name: string;
3773
+ shader: string;
3774
+ };
3775
+
3776
+
3777
+ /** @internal */
3778
+ export var fullscreenTriangleVertexShader: {
3779
+ name: string;
3780
+ shader: string;
3781
+ };
3782
+
3783
+
3784
+ /** @internal */
3785
+ export var diffuseSkyIrradiancePixelShader: {
3786
+ name: string;
3787
+ shader: string;
3788
+ };
3789
+
3790
+
3791
+ /** @internal */
3792
+ export var compositeSkyPixelShader: {
3793
+ name: string;
3794
+ shader: string;
3795
+ };
3796
+
3797
+
3798
+ /** @internal */
3799
+ export var compositeGlobeAtmospherePixelShader: {
3800
+ name: string;
3801
+ shader: string;
3802
+ };
3803
+
3804
+
3805
+ /** @internal */
3806
+ export var compositeAerialPerspectivePixelShader: {
3807
+ name: string;
3808
+ shader: string;
3809
+ };
3810
+
3811
+
3812
+ /** @internal */
3813
+ export var aerialPerspectivePixelShader: {
3814
+ name: string;
3815
+ shader: string;
3816
+ };
3817
+
3818
+
3819
+ /** @internal */
3820
+ export var depthFunctions: {
3821
+ name: string;
3822
+ shader: string;
3823
+ };
3824
+
3825
+
3826
+ /** @internal */
3827
+ export var atmosphereVertexDeclaration: {
3828
+ name: string;
3829
+ shader: string;
3830
+ };
3831
+
3832
+
3833
+ /** @internal */
3834
+ export var atmosphereUboDeclaration: {
3835
+ name: string;
3836
+ shader: string;
3837
+ };
3838
+
3839
+
3840
+ /** @internal */
3841
+ export var atmosphereFunctions: {
3842
+ name: string;
3843
+ shader: string;
3844
+ };
3845
+
3846
+
3847
+ /** @internal */
3848
+ export var atmosphereFragmentDeclaration: {
3849
+ name: string;
3850
+ shader: string;
1442
3851
  };
1443
3852
 
1444
3853