@onerjs/addons 8.25.3 → 8.25.5

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.
Files changed (81) hide show
  1. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.d.ts +5 -0
  2. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js +12 -0
  3. package/atmosphere/Shaders/ShadersInclude/atmosphereFragmentDeclaration.js.map +1 -0
  4. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.d.ts +6 -0
  5. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js +234 -0
  6. package/atmosphere/Shaders/ShadersInclude/atmosphereFunctions.js.map +1 -0
  7. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.d.ts +5 -0
  8. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js +12 -0
  9. package/atmosphere/Shaders/ShadersInclude/atmosphereUboDeclaration.js.map +1 -0
  10. package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.d.ts +5 -0
  11. package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.js +12 -0
  12. package/atmosphere/Shaders/ShadersInclude/atmosphereVertexDeclaration.js.map +1 -0
  13. package/atmosphere/Shaders/ShadersInclude/depthFunctions.d.ts +5 -0
  14. package/atmosphere/Shaders/ShadersInclude/depthFunctions.js +19 -0
  15. package/atmosphere/Shaders/ShadersInclude/depthFunctions.js.map +1 -0
  16. package/atmosphere/Shaders/aerialPerspective.fragment.d.ts +9 -0
  17. package/atmosphere/Shaders/aerialPerspective.fragment.js +25 -0
  18. package/atmosphere/Shaders/aerialPerspective.fragment.js.map +1 -0
  19. package/atmosphere/Shaders/compositeAerialPerspective.fragment.d.ts +10 -0
  20. package/atmosphere/Shaders/compositeAerialPerspective.fragment.js +72 -0
  21. package/atmosphere/Shaders/compositeAerialPerspective.fragment.js.map +1 -0
  22. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.d.ts +10 -0
  23. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js +96 -0
  24. package/atmosphere/Shaders/compositeGlobeAtmosphere.fragment.js.map +1 -0
  25. package/atmosphere/Shaders/compositeSky.fragment.d.ts +10 -0
  26. package/atmosphere/Shaders/compositeSky.fragment.js +75 -0
  27. package/atmosphere/Shaders/compositeSky.fragment.js.map +1 -0
  28. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.d.ts +13 -0
  29. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js +49 -0
  30. package/atmosphere/Shaders/diffuseSkyIrradiance.fragment.js.map +1 -0
  31. package/atmosphere/Shaders/fullscreenTriangle.vertex.d.ts +7 -0
  32. package/atmosphere/Shaders/fullscreenTriangle.vertex.js +31 -0
  33. package/atmosphere/Shaders/fullscreenTriangle.vertex.js.map +1 -0
  34. package/atmosphere/Shaders/multiScattering.fragment.d.ts +9 -0
  35. package/atmosphere/Shaders/multiScattering.fragment.js +21 -0
  36. package/atmosphere/Shaders/multiScattering.fragment.js.map +1 -0
  37. package/atmosphere/Shaders/skyView.fragment.d.ts +9 -0
  38. package/atmosphere/Shaders/skyView.fragment.js +20 -0
  39. package/atmosphere/Shaders/skyView.fragment.js.map +1 -0
  40. package/atmosphere/Shaders/transmittance.fragment.d.ts +9 -0
  41. package/atmosphere/Shaders/transmittance.fragment.js +20 -0
  42. package/atmosphere/Shaders/transmittance.fragment.js.map +1 -0
  43. package/atmosphere/atmosphere.d.ts +418 -0
  44. package/atmosphere/atmosphere.js +1446 -0
  45. package/atmosphere/atmosphere.js.map +1 -0
  46. package/atmosphere/atmosphereOptions.d.ts +135 -0
  47. package/atmosphere/atmosphereOptions.js +4 -0
  48. package/atmosphere/atmosphereOptions.js.map +1 -0
  49. package/atmosphere/atmospherePBRMaterialPlugin.d.ts +72 -0
  50. package/atmosphere/atmospherePBRMaterialPlugin.js +230 -0
  51. package/atmosphere/atmospherePBRMaterialPlugin.js.map +1 -0
  52. package/atmosphere/atmospherePerCameraVariables.d.ts +102 -0
  53. package/atmosphere/atmospherePerCameraVariables.js +189 -0
  54. package/atmosphere/atmospherePerCameraVariables.js.map +1 -0
  55. package/atmosphere/atmospherePhysicalProperties.d.ts +154 -0
  56. package/atmosphere/atmospherePhysicalProperties.js +305 -0
  57. package/atmosphere/atmospherePhysicalProperties.js.map +1 -0
  58. package/atmosphere/atmospherePhysicalPropertiesOptions.d.ts +52 -0
  59. package/atmosphere/atmospherePhysicalPropertiesOptions.js +4 -0
  60. package/atmosphere/atmospherePhysicalPropertiesOptions.js.map +1 -0
  61. package/atmosphere/diffuseSkyIrradianceLut.d.ts +63 -0
  62. package/atmosphere/diffuseSkyIrradianceLut.js +199 -0
  63. package/atmosphere/diffuseSkyIrradianceLut.js.map +1 -0
  64. package/atmosphere/index.d.ts +6 -0
  65. package/atmosphere/index.js +9 -0
  66. package/atmosphere/index.js.map +1 -0
  67. package/atmosphere/sampling.d.ts +15 -0
  68. package/atmosphere/sampling.js +89 -0
  69. package/atmosphere/sampling.js.map +1 -0
  70. package/atmosphere/test/unit/sampling.test.d.ts +1 -0
  71. package/atmosphere/test/unit/sampling.test.js +77 -0
  72. package/atmosphere/test/unit/sampling.test.js.map +1 -0
  73. package/atmosphere/transmittanceLut.d.ts +68 -0
  74. package/atmosphere/transmittanceLut.js +207 -0
  75. package/atmosphere/transmittanceLut.js.map +1 -0
  76. package/index.d.ts +1 -0
  77. package/index.js +1 -0
  78. package/index.js.map +1 -1
  79. package/msdfText/paragraphOptions.d.ts +1 -1
  80. package/msdfText/paragraphOptions.js.map +1 -1
  81. package/package.json +2 -2
@@ -0,0 +1,154 @@
1
+ import type { IAtmospherePhysicalPropertiesOptions } from "./atmospherePhysicalPropertiesOptions.js";
2
+ import { Observable } from "@onerjs/core/Misc/observable.js";
3
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
4
+ /**
5
+ * Describes the physical properties of the atmosphere. Assumes a spherical planet.
6
+ * - "radius" values describe a distance from the planet's center.
7
+ * - "height" values describe a distance from the planet's surface.
8
+ * - Distances are in kilometers unless otherwise specified. Angles are in radians.
9
+ */
10
+ export declare class AtmospherePhysicalProperties {
11
+ /**
12
+ * Notification for when properties of the {@link AtmospherePhysicalProperties} are changed.
13
+ */
14
+ readonly onChangedObservable: Observable<AtmospherePhysicalProperties>;
15
+ private _planetRadius;
16
+ private _planetRadiusOffset;
17
+ private _atmosphereThickness;
18
+ private _rayleighScatteringScale;
19
+ private _peakRayleighScattering;
20
+ private _mieScatteringScale;
21
+ private _peakMieScattering;
22
+ private _mieAbsorptionScale;
23
+ private _peakMieAbsorption;
24
+ private _ozoneAbsorptionScale;
25
+ private _peakOzoneAbsorption;
26
+ private _planetRadiusWithOffset;
27
+ private _planetRadiusSquared;
28
+ private _atmosphereRadius;
29
+ private _atmosphereRadiusSquared;
30
+ private _horizonDistanceToAtmosphereEdge;
31
+ private _horizonDistanceToAtmosphereEdgeSquared;
32
+ private _rayleighScattering;
33
+ private _mieScattering;
34
+ private _mieAbsorption;
35
+ private _mieExtinction;
36
+ private _ozoneAbsorption;
37
+ /**
38
+ * The radius of the planet in kilometers.
39
+ */
40
+ get planetRadius(): number;
41
+ set planetRadius(value: number);
42
+ /**
43
+ * The squared radius of the planet in kilometers.
44
+ */
45
+ get planetRadiusSquared(): number;
46
+ /**
47
+ * Offset applied to view points near the planet's surface. This should be greater than 0.
48
+ * It prevents rendering issues close to the planet's surface.
49
+ */
50
+ get planetRadiusOffset(): number;
51
+ set planetRadiusOffset(value: number);
52
+ /**
53
+ * This is the {@link planetRadius} with the additional {@link planetRadiusOffset}, in kilometers.
54
+ */
55
+ get planetRadiusWithOffset(): number;
56
+ /**
57
+ * The thickness of the atmosphere measured in kilometers.
58
+ */
59
+ get atmosphereThickness(): number;
60
+ set atmosphereThickness(value: number);
61
+ /**
62
+ * The combined planet radius and atmosphere thickness in kilometers.
63
+ */
64
+ get atmosphereRadius(): number;
65
+ /**
66
+ * The atmosphere radius squared in kilometers.
67
+ */
68
+ get atmosphereRadiusSquared(): number;
69
+ /**
70
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere in kilometers.
71
+ */
72
+ get horizonDistanceToAtmosphereEdge(): number;
73
+ /**
74
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere, squared, in kilometers.
75
+ */
76
+ get horizonDistanceToAtmosphereEdgeSquared(): number;
77
+ /**
78
+ * The scale applied to {@link peakRayleighScattering}.
79
+ */
80
+ get rayleighScatteringScale(): number;
81
+ set rayleighScatteringScale(value: number);
82
+ /**
83
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
84
+ */
85
+ get peakRayleighScattering(): Vector3;
86
+ set peakRayleighScattering(value: Vector3);
87
+ /**
88
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
89
+ * This value cannot be set directly. It is inferred by scaling {@link peakRayleighScattering} by {@link rayleighScatteringScale}.
90
+ */
91
+ get rayleighScattering(): Vector3;
92
+ /**
93
+ * The scale applied to {@link peakMieScattering}.
94
+ */
95
+ get mieScatteringScale(): number;
96
+ set mieScatteringScale(value: number);
97
+ /**
98
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
99
+ */
100
+ get peakMieScattering(): Vector3;
101
+ set peakMieScattering(value: Vector3);
102
+ /**
103
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
104
+ * This value cannot be set directly. It is inferred by scaling {@link mieScatteringScale} by {@link peakMieScattering}.
105
+ */
106
+ get mieScattering(): Vector3;
107
+ /**
108
+ * The scale applied to {@link peakMieAbsorption}.
109
+ */
110
+ get mieAbsorptionScale(): number;
111
+ set mieAbsorptionScale(value: number);
112
+ /**
113
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
114
+ */
115
+ get peakMieAbsorption(): Vector3;
116
+ set peakMieAbsorption(value: Vector3);
117
+ /**
118
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
119
+ * This value cannot be set directly. It is inferred by scaling {@link mieAbsorptionScale} by {@link peakMieAbsorption}.
120
+ */
121
+ get mieAbsorption(): Vector3;
122
+ /**
123
+ * The Mie extinction per kilometer at sea level for red, green, and blue wavelengths.
124
+ * This value cannot be set directly. It is inferred by adding the {@link mieAbsorption} to the {@link mieScattering}.
125
+ */
126
+ get mieExtinction(): Vector3;
127
+ /**
128
+ * The scale applied to {@link peakOzoneAbsorption}.
129
+ */
130
+ get ozoneAbsorptionScale(): number;
131
+ set ozoneAbsorptionScale(value: number);
132
+ /**
133
+ * The ozone absorption per kilometer measured at a height corresponding to it's peak concentration,
134
+ * for red, green, and blue wavelengths.
135
+ */
136
+ get peakOzoneAbsorption(): Vector3;
137
+ set peakOzoneAbsorption(value: Vector3);
138
+ /**
139
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
140
+ * This value cannot be set directly. It is inferred by scaling {@link peakOzoneAbsorption} by {@link ozoneAbsorptionScale}.
141
+ */
142
+ get ozoneAbsorption(): Vector3;
143
+ /**
144
+ * Constructs the {@link AtmospherePhysicalProperties}.
145
+ * @param options - The options for the {@link AtmospherePhysicalProperties}.
146
+ */
147
+ constructor(options?: IAtmospherePhysicalPropertiesOptions);
148
+ private _recomputeDimensionalParameters;
149
+ private _recomputeRayleighScattering;
150
+ private _recomputeMieScattering;
151
+ private _recomputeMieAbsorption;
152
+ private _recomputeMieExtinction;
153
+ private _recomputeOzoneAbsorption;
154
+ }
@@ -0,0 +1,305 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // MIT License
3
+ import { Observable } from "@onerjs/core/Misc/observable.js";
4
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
5
+ const DefaultPlanetRadius = 6360.0;
6
+ const DefaultPlanetRadiusOffset = 0.01;
7
+ const DefaultAtmosphereThickness = 100.0;
8
+ // The scattering and absorption values are per kilometer measured at sea level.
9
+ const DefaultPeakRayleighScattering = new Vector3(0.005802, 0.013558, 0.0331);
10
+ const DefaultPeakMieScattering = new Vector3(0.003996, 0.003996, 0.003996);
11
+ const DefaultPeakMieAbsorption = new Vector3(0.000444, 0.000444, 0.000444);
12
+ const DefaultPeakOzoneAbsorption = new Vector3(0.00065, 0.001881, 0.000085);
13
+ /**
14
+ * Describes the physical properties of the atmosphere. Assumes a spherical planet.
15
+ * - "radius" values describe a distance from the planet's center.
16
+ * - "height" values describe a distance from the planet's surface.
17
+ * - Distances are in kilometers unless otherwise specified. Angles are in radians.
18
+ */
19
+ export class AtmospherePhysicalProperties {
20
+ /**
21
+ * The radius of the planet in kilometers.
22
+ */
23
+ get planetRadius() {
24
+ return this._planetRadius;
25
+ }
26
+ set planetRadius(value) {
27
+ if (this._planetRadius !== value) {
28
+ this._planetRadius = value;
29
+ this._recomputeDimensionalParameters();
30
+ this.onChangedObservable.notifyObservers(this);
31
+ }
32
+ }
33
+ /**
34
+ * The squared radius of the planet in kilometers.
35
+ */
36
+ get planetRadiusSquared() {
37
+ return this._planetRadiusSquared;
38
+ }
39
+ /**
40
+ * Offset applied to view points near the planet's surface. This should be greater than 0.
41
+ * It prevents rendering issues close to the planet's surface.
42
+ */
43
+ get planetRadiusOffset() {
44
+ return this._planetRadiusOffset;
45
+ }
46
+ set planetRadiusOffset(value) {
47
+ if (this._planetRadiusOffset !== value) {
48
+ this._planetRadiusOffset = value;
49
+ this._recomputeDimensionalParameters();
50
+ this.onChangedObservable.notifyObservers(this);
51
+ }
52
+ }
53
+ /**
54
+ * This is the {@link planetRadius} with the additional {@link planetRadiusOffset}, in kilometers.
55
+ */
56
+ get planetRadiusWithOffset() {
57
+ return this._planetRadiusWithOffset;
58
+ }
59
+ /**
60
+ * The thickness of the atmosphere measured in kilometers.
61
+ */
62
+ get atmosphereThickness() {
63
+ return this._atmosphereThickness;
64
+ }
65
+ set atmosphereThickness(value) {
66
+ if (this._atmosphereThickness !== value) {
67
+ this._atmosphereThickness = value;
68
+ this._recomputeDimensionalParameters();
69
+ this.onChangedObservable.notifyObservers(this);
70
+ }
71
+ }
72
+ /**
73
+ * The combined planet radius and atmosphere thickness in kilometers.
74
+ */
75
+ get atmosphereRadius() {
76
+ return this._atmosphereRadius;
77
+ }
78
+ /**
79
+ * The atmosphere radius squared in kilometers.
80
+ */
81
+ get atmosphereRadiusSquared() {
82
+ return this._atmosphereRadiusSquared;
83
+ }
84
+ /**
85
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere in kilometers.
86
+ */
87
+ get horizonDistanceToAtmosphereEdge() {
88
+ return this._horizonDistanceToAtmosphereEdge;
89
+ }
90
+ /**
91
+ * Horizon distance from the planet's surface to the outer edge of the atmosphere, squared, in kilometers.
92
+ */
93
+ get horizonDistanceToAtmosphereEdgeSquared() {
94
+ return this._horizonDistanceToAtmosphereEdgeSquared;
95
+ }
96
+ /**
97
+ * The scale applied to {@link peakRayleighScattering}.
98
+ */
99
+ get rayleighScatteringScale() {
100
+ return this._rayleighScatteringScale;
101
+ }
102
+ set rayleighScatteringScale(value) {
103
+ if (this._rayleighScatteringScale !== value) {
104
+ this._rayleighScatteringScale = value;
105
+ this._recomputeRayleighScattering();
106
+ this.onChangedObservable.notifyObservers(this);
107
+ }
108
+ }
109
+ /**
110
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
111
+ */
112
+ get peakRayleighScattering() {
113
+ return this._peakRayleighScattering;
114
+ }
115
+ set peakRayleighScattering(value) {
116
+ if (!this._peakRayleighScattering.equals(value)) {
117
+ this._peakRayleighScattering.copyFrom(value);
118
+ this._recomputeRayleighScattering();
119
+ this.onChangedObservable.notifyObservers(this);
120
+ }
121
+ }
122
+ /**
123
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
124
+ * This value cannot be set directly. It is inferred by scaling {@link peakRayleighScattering} by {@link rayleighScatteringScale}.
125
+ */
126
+ get rayleighScattering() {
127
+ return this._rayleighScattering;
128
+ }
129
+ /**
130
+ * The scale applied to {@link peakMieScattering}.
131
+ */
132
+ get mieScatteringScale() {
133
+ return this._mieScatteringScale;
134
+ }
135
+ set mieScatteringScale(value) {
136
+ if (this._mieScatteringScale !== value) {
137
+ this._mieScatteringScale = value;
138
+ this._recomputeMieScattering();
139
+ this.onChangedObservable.notifyObservers(this);
140
+ }
141
+ }
142
+ /**
143
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
144
+ */
145
+ get peakMieScattering() {
146
+ return this._peakMieScattering;
147
+ }
148
+ set peakMieScattering(value) {
149
+ if (!this._peakMieScattering.equals(value)) {
150
+ this._peakMieScattering.copyFrom(value);
151
+ this._recomputeMieScattering();
152
+ this.onChangedObservable.notifyObservers(this);
153
+ }
154
+ }
155
+ /**
156
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
157
+ * This value cannot be set directly. It is inferred by scaling {@link mieScatteringScale} by {@link peakMieScattering}.
158
+ */
159
+ get mieScattering() {
160
+ return this._mieScattering;
161
+ }
162
+ /**
163
+ * The scale applied to {@link peakMieAbsorption}.
164
+ */
165
+ get mieAbsorptionScale() {
166
+ return this._mieAbsorptionScale;
167
+ }
168
+ set mieAbsorptionScale(value) {
169
+ if (this._mieAbsorptionScale !== value) {
170
+ this._mieAbsorptionScale = value;
171
+ this._recomputeMieAbsorption();
172
+ this.onChangedObservable.notifyObservers(this);
173
+ }
174
+ }
175
+ /**
176
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
177
+ */
178
+ get peakMieAbsorption() {
179
+ return this._peakMieAbsorption;
180
+ }
181
+ set peakMieAbsorption(value) {
182
+ if (!this._peakMieAbsorption.equals(value)) {
183
+ this._peakMieAbsorption.copyFrom(value);
184
+ this._recomputeMieAbsorption();
185
+ this.onChangedObservable.notifyObservers(this);
186
+ }
187
+ }
188
+ /**
189
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
190
+ * This value cannot be set directly. It is inferred by scaling {@link mieAbsorptionScale} by {@link peakMieAbsorption}.
191
+ */
192
+ get mieAbsorption() {
193
+ return this._mieAbsorption;
194
+ }
195
+ /**
196
+ * The Mie extinction per kilometer at sea level for red, green, and blue wavelengths.
197
+ * This value cannot be set directly. It is inferred by adding the {@link mieAbsorption} to the {@link mieScattering}.
198
+ */
199
+ get mieExtinction() {
200
+ return this._mieExtinction;
201
+ }
202
+ /**
203
+ * The scale applied to {@link peakOzoneAbsorption}.
204
+ */
205
+ get ozoneAbsorptionScale() {
206
+ return this._ozoneAbsorptionScale;
207
+ }
208
+ set ozoneAbsorptionScale(value) {
209
+ if (this._ozoneAbsorptionScale !== value) {
210
+ this._ozoneAbsorptionScale = value;
211
+ this._recomputeOzoneAbsorption();
212
+ this.onChangedObservable.notifyObservers(this);
213
+ }
214
+ }
215
+ /**
216
+ * The ozone absorption per kilometer measured at a height corresponding to it's peak concentration,
217
+ * for red, green, and blue wavelengths.
218
+ */
219
+ get peakOzoneAbsorption() {
220
+ return this._peakOzoneAbsorption;
221
+ }
222
+ set peakOzoneAbsorption(value) {
223
+ if (!this._peakOzoneAbsorption.equals(value)) {
224
+ this._peakOzoneAbsorption.copyFrom(value);
225
+ this._recomputeOzoneAbsorption();
226
+ this.onChangedObservable.notifyObservers(this);
227
+ }
228
+ }
229
+ /**
230
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
231
+ * This value cannot be set directly. It is inferred by scaling {@link peakOzoneAbsorption} by {@link ozoneAbsorptionScale}.
232
+ */
233
+ get ozoneAbsorption() {
234
+ return this._ozoneAbsorption;
235
+ }
236
+ /**
237
+ * Constructs the {@link AtmospherePhysicalProperties}.
238
+ * @param options - The options for the {@link AtmospherePhysicalProperties}.
239
+ */
240
+ constructor(options) {
241
+ /**
242
+ * Notification for when properties of the {@link AtmospherePhysicalProperties} are changed.
243
+ */
244
+ this.onChangedObservable = new Observable();
245
+ this._peakRayleighScattering = new Vector3();
246
+ this._peakMieScattering = new Vector3();
247
+ this._peakMieAbsorption = new Vector3();
248
+ this._peakOzoneAbsorption = new Vector3();
249
+ // Inferred values.
250
+ this._planetRadiusWithOffset = 0;
251
+ this._planetRadiusSquared = 0;
252
+ this._atmosphereRadius = 0;
253
+ this._atmosphereRadiusSquared = 0;
254
+ this._horizonDistanceToAtmosphereEdge = 0;
255
+ this._horizonDistanceToAtmosphereEdgeSquared = 0;
256
+ this._rayleighScattering = new Vector3();
257
+ this._mieScattering = new Vector3();
258
+ this._mieAbsorption = new Vector3();
259
+ this._mieExtinction = new Vector3();
260
+ this._ozoneAbsorption = new Vector3();
261
+ this._planetRadius = options?.planetRadius ?? DefaultPlanetRadius;
262
+ this._planetRadiusOffset = options?.planetRadiusOffset ?? DefaultPlanetRadiusOffset;
263
+ this._atmosphereThickness = options?.atmosphereThickness ?? DefaultAtmosphereThickness;
264
+ this._rayleighScatteringScale = options?.rayleighScatteringScale ?? 1.0;
265
+ this._peakRayleighScattering.copyFrom(options?.peakRayleighScattering ?? DefaultPeakRayleighScattering);
266
+ this._mieScatteringScale = options?.mieScatteringScale ?? 1.0;
267
+ this._peakMieScattering.copyFrom(options?.peakMieScattering ?? DefaultPeakMieScattering);
268
+ this._mieAbsorptionScale = options?.mieAbsorptionScale ?? 1.0;
269
+ this._peakMieAbsorption.copyFrom(options?.peakMieAbsorption ?? DefaultPeakMieAbsorption);
270
+ this._ozoneAbsorptionScale = options?.ozoneAbsorptionScale ?? 1.0;
271
+ this._peakOzoneAbsorption.copyFrom(options?.peakOzoneAbsorption ?? DefaultPeakOzoneAbsorption);
272
+ // Compute inferred values.
273
+ this._recomputeDimensionalParameters();
274
+ this._recomputeRayleighScattering();
275
+ this._recomputeMieScattering();
276
+ this._recomputeMieAbsorption();
277
+ this._recomputeOzoneAbsorption();
278
+ }
279
+ _recomputeDimensionalParameters() {
280
+ this._planetRadiusWithOffset = this._planetRadius + this._planetRadiusOffset;
281
+ this._planetRadiusSquared = this._planetRadius * this._planetRadius;
282
+ this._atmosphereRadius = this._planetRadius + this._atmosphereThickness;
283
+ this._atmosphereRadiusSquared = this._atmosphereRadius * this._atmosphereRadius;
284
+ this._horizonDistanceToAtmosphereEdgeSquared = this._atmosphereRadiusSquared - this._planetRadiusSquared;
285
+ this._horizonDistanceToAtmosphereEdge = Math.sqrt(this._horizonDistanceToAtmosphereEdgeSquared);
286
+ }
287
+ _recomputeRayleighScattering() {
288
+ this._peakRayleighScattering.scaleToRef(this._rayleighScatteringScale, this._rayleighScattering);
289
+ }
290
+ _recomputeMieScattering() {
291
+ this._peakMieScattering.scaleToRef(this._mieScatteringScale, this._mieScattering);
292
+ this._recomputeMieExtinction();
293
+ }
294
+ _recomputeMieAbsorption() {
295
+ this._peakMieAbsorption.scaleToRef(this._mieAbsorptionScale, this._mieAbsorption);
296
+ this._recomputeMieExtinction();
297
+ }
298
+ _recomputeMieExtinction() {
299
+ this._mieAbsorption.addToRef(this._mieScattering, this._mieExtinction);
300
+ }
301
+ _recomputeOzoneAbsorption() {
302
+ this._peakOzoneAbsorption.scaleToRef(this._ozoneAbsorptionScale, this._ozoneAbsorption);
303
+ }
304
+ }
305
+ //# sourceMappingURL=atmospherePhysicalProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atmospherePhysicalProperties.js","sourceRoot":"","sources":["../../../../dev/addons/src/atmosphere/atmospherePhysicalProperties.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,cAAc;AAGd,OAAO,EAAE,UAAU,EAAE,wCAA6B;AAClD,OAAO,EAAE,OAAO,EAAE,0CAA+B;AAEjD,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEzC,gFAAgF;AAChF,MAAM,6BAA6B,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC9E,MAAM,wBAAwB,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC3E,MAAM,wBAAwB,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC3E,MA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rG,CAAC;IAEO,uBAAuB;QAC3B,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAClF,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACnC,CAAC;IAEO,uBAAuB;QAC3B,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAClF,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACnC,CAAC;IAEO,uBAAuB;QAC3B,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3E,CAAC;IAEO,yBAAyB;QAC7B,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5F,CAAC;CACJ","sourcesContent":["// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { IAtmospherePhysicalPropertiesOptions } from \"./atmospherePhysicalPropertiesOptions\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\nconst DefaultPlanetRadius = 6360.0;\r\nconst DefaultPlanetRadiusOffset = 0.01;\r\nconst DefaultAtmosphereThickness = 100.0;\r\n\r\n// The scattering and absorption values are per kilometer measured at sea level.\r\nconst DefaultPeakRayleighScattering = new Vector3(0.005802, 0.013558, 0.0331);\r\nconst DefaultPeakMieScattering = new Vector3(0.003996, 0.003996, 0.003996);\r\nconst DefaultPeakMieAbsorption = new Vector3(0.000444, 0.000444, 0.000444);\r\nconst DefaultPeakOzoneAbsorption = new Vector3(0.00065, 0.001881, 0.000085);\r\n\r\n/**\r\n * Describes the physical properties of the atmosphere. Assumes a spherical planet.\r\n * - \"radius\" values describe a distance from the planet's center.\r\n * - \"height\" values describe a distance from the planet's surface.\r\n * - Distances are in kilometers unless otherwise specified. Angles are in radians.\r\n */\r\nexport class AtmospherePhysicalProperties {\r\n /**\r\n * Notification for when properties of the {@link AtmospherePhysicalProperties} are changed.\r\n */\r\n public readonly onChangedObservable = new Observable<AtmospherePhysicalProperties>();\r\n\r\n private _planetRadius: number;\r\n private _planetRadiusOffset: number;\r\n private _atmosphereThickness: number;\r\n private _rayleighScatteringScale: number;\r\n private _peakRayleighScattering = new Vector3();\r\n private _mieScatteringScale: number;\r\n private _peakMieScattering = new Vector3();\r\n private _mieAbsorptionScale: number;\r\n private _peakMieAbsorption = new Vector3();\r\n private _ozoneAbsorptionScale: number;\r\n private _peakOzoneAbsorption = new Vector3();\r\n\r\n // Inferred values.\r\n private _planetRadiusWithOffset = 0;\r\n private _planetRadiusSquared = 0;\r\n private _atmosphereRadius = 0;\r\n private _atmosphereRadiusSquared = 0;\r\n private _horizonDistanceToAtmosphereEdge = 0;\r\n private _horizonDistanceToAtmosphereEdgeSquared = 0;\r\n private _rayleighScattering = new Vector3();\r\n private _mieScattering = new Vector3();\r\n private _mieAbsorption = new Vector3();\r\n private _mieExtinction = new Vector3();\r\n private _ozoneAbsorption = new Vector3();\r\n\r\n /**\r\n * The radius of the planet in kilometers.\r\n */\r\n public get planetRadius(): number {\r\n return this._planetRadius;\r\n }\r\n public set planetRadius(value: number) {\r\n if (this._planetRadius !== value) {\r\n this._planetRadius = value;\r\n this._recomputeDimensionalParameters();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The squared radius of the planet in kilometers.\r\n */\r\n public get planetRadiusSquared(): number {\r\n return this._planetRadiusSquared;\r\n }\r\n\r\n /**\r\n * Offset applied to view points near the planet's surface. This should be greater than 0.\r\n * It prevents rendering issues close to the planet's surface.\r\n */\r\n public get planetRadiusOffset(): number {\r\n return this._planetRadiusOffset;\r\n }\r\n public set planetRadiusOffset(value: number) {\r\n if (this._planetRadiusOffset !== value) {\r\n this._planetRadiusOffset = value;\r\n this._recomputeDimensionalParameters();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * This is the {@link planetRadius} with the additional {@link planetRadiusOffset}, in kilometers.\r\n */\r\n public get planetRadiusWithOffset(): number {\r\n return this._planetRadiusWithOffset;\r\n }\r\n\r\n /**\r\n * The thickness of the atmosphere measured in kilometers.\r\n */\r\n public get atmosphereThickness(): number {\r\n return this._atmosphereThickness;\r\n }\r\n public set atmosphereThickness(value: number) {\r\n if (this._atmosphereThickness !== value) {\r\n this._atmosphereThickness = value;\r\n this._recomputeDimensionalParameters();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The combined planet radius and atmosphere thickness in kilometers.\r\n */\r\n public get atmosphereRadius(): number {\r\n return this._atmosphereRadius;\r\n }\r\n\r\n /**\r\n * The atmosphere radius squared in kilometers.\r\n */\r\n public get atmosphereRadiusSquared(): number {\r\n return this._atmosphereRadiusSquared;\r\n }\r\n\r\n /**\r\n * Horizon distance from the planet's surface to the outer edge of the atmosphere in kilometers.\r\n */\r\n public get horizonDistanceToAtmosphereEdge(): number {\r\n return this._horizonDistanceToAtmosphereEdge;\r\n }\r\n\r\n /**\r\n * Horizon distance from the planet's surface to the outer edge of the atmosphere, squared, in kilometers.\r\n */\r\n public get horizonDistanceToAtmosphereEdgeSquared(): number {\r\n return this._horizonDistanceToAtmosphereEdgeSquared;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakRayleighScattering}.\r\n */\r\n public get rayleighScatteringScale(): number {\r\n return this._rayleighScatteringScale;\r\n }\r\n public set rayleighScatteringScale(value: number) {\r\n if (this._rayleighScatteringScale !== value) {\r\n this._rayleighScatteringScale = value;\r\n this._recomputeRayleighScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n public get peakRayleighScattering(): Vector3 {\r\n return this._peakRayleighScattering;\r\n }\r\n public set peakRayleighScattering(value: Vector3) {\r\n if (!this._peakRayleighScattering.equals(value)) {\r\n this._peakRayleighScattering.copyFrom(value);\r\n this._recomputeRayleighScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link peakRayleighScattering} by {@link rayleighScatteringScale}.\r\n */\r\n public get rayleighScattering(): Vector3 {\r\n return this._rayleighScattering;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakMieScattering}.\r\n */\r\n public get mieScatteringScale(): number {\r\n return this._mieScatteringScale;\r\n }\r\n public set mieScatteringScale(value: number) {\r\n if (this._mieScatteringScale !== value) {\r\n this._mieScatteringScale = value;\r\n this._recomputeMieScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n public get peakMieScattering(): Vector3 {\r\n return this._peakMieScattering;\r\n }\r\n public set peakMieScattering(value: Vector3) {\r\n if (!this._peakMieScattering.equals(value)) {\r\n this._peakMieScattering.copyFrom(value);\r\n this._recomputeMieScattering();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link mieScatteringScale} by {@link peakMieScattering}.\r\n */\r\n public get mieScattering(): Vector3 {\r\n return this._mieScattering;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakMieAbsorption}.\r\n */\r\n public get mieAbsorptionScale(): number {\r\n return this._mieAbsorptionScale;\r\n }\r\n public set mieAbsorptionScale(value: number) {\r\n if (this._mieAbsorptionScale !== value) {\r\n this._mieAbsorptionScale = value;\r\n this._recomputeMieAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n public get peakMieAbsorption(): Vector3 {\r\n return this._peakMieAbsorption;\r\n }\r\n public set peakMieAbsorption(value: Vector3) {\r\n if (!this._peakMieAbsorption.equals(value)) {\r\n this._peakMieAbsorption.copyFrom(value);\r\n this._recomputeMieAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link mieAbsorptionScale} by {@link peakMieAbsorption}.\r\n */\r\n public get mieAbsorption(): Vector3 {\r\n return this._mieAbsorption;\r\n }\r\n\r\n /**\r\n * The Mie extinction per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by adding the {@link mieAbsorption} to the {@link mieScattering}.\r\n */\r\n public get mieExtinction(): Vector3 {\r\n return this._mieExtinction;\r\n }\r\n\r\n /**\r\n * The scale applied to {@link peakOzoneAbsorption}.\r\n */\r\n public get ozoneAbsorptionScale(): number {\r\n return this._ozoneAbsorptionScale;\r\n }\r\n public set ozoneAbsorptionScale(value: number) {\r\n if (this._ozoneAbsorptionScale !== value) {\r\n this._ozoneAbsorptionScale = value;\r\n this._recomputeOzoneAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The ozone absorption per kilometer measured at a height corresponding to it's peak concentration,\r\n * for red, green, and blue wavelengths.\r\n */\r\n public get peakOzoneAbsorption(): Vector3 {\r\n return this._peakOzoneAbsorption;\r\n }\r\n public set peakOzoneAbsorption(value: Vector3) {\r\n if (!this._peakOzoneAbsorption.equals(value)) {\r\n this._peakOzoneAbsorption.copyFrom(value);\r\n this._recomputeOzoneAbsorption();\r\n this.onChangedObservable.notifyObservers(this);\r\n }\r\n }\r\n\r\n /**\r\n * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n * This value cannot be set directly. It is inferred by scaling {@link peakOzoneAbsorption} by {@link ozoneAbsorptionScale}.\r\n */\r\n public get ozoneAbsorption(): Vector3 {\r\n return this._ozoneAbsorption;\r\n }\r\n\r\n /**\r\n * Constructs the {@link AtmospherePhysicalProperties}.\r\n * @param options - The options for the {@link AtmospherePhysicalProperties}.\r\n */\r\n constructor(options?: IAtmospherePhysicalPropertiesOptions) {\r\n this._planetRadius = options?.planetRadius ?? DefaultPlanetRadius;\r\n this._planetRadiusOffset = options?.planetRadiusOffset ?? DefaultPlanetRadiusOffset;\r\n this._atmosphereThickness = options?.atmosphereThickness ?? DefaultAtmosphereThickness;\r\n this._rayleighScatteringScale = options?.rayleighScatteringScale ?? 1.0;\r\n this._peakRayleighScattering.copyFrom(options?.peakRayleighScattering ?? DefaultPeakRayleighScattering);\r\n this._mieScatteringScale = options?.mieScatteringScale ?? 1.0;\r\n this._peakMieScattering.copyFrom(options?.peakMieScattering ?? DefaultPeakMieScattering);\r\n this._mieAbsorptionScale = options?.mieAbsorptionScale ?? 1.0;\r\n this._peakMieAbsorption.copyFrom(options?.peakMieAbsorption ?? DefaultPeakMieAbsorption);\r\n this._ozoneAbsorptionScale = options?.ozoneAbsorptionScale ?? 1.0;\r\n this._peakOzoneAbsorption.copyFrom(options?.peakOzoneAbsorption ?? DefaultPeakOzoneAbsorption);\r\n\r\n // Compute inferred values.\r\n this._recomputeDimensionalParameters();\r\n this._recomputeRayleighScattering();\r\n this._recomputeMieScattering();\r\n this._recomputeMieAbsorption();\r\n this._recomputeOzoneAbsorption();\r\n }\r\n\r\n private _recomputeDimensionalParameters(): void {\r\n this._planetRadiusWithOffset = this._planetRadius + this._planetRadiusOffset;\r\n this._planetRadiusSquared = this._planetRadius * this._planetRadius;\r\n this._atmosphereRadius = this._planetRadius + this._atmosphereThickness;\r\n this._atmosphereRadiusSquared = this._atmosphereRadius * this._atmosphereRadius;\r\n this._horizonDistanceToAtmosphereEdgeSquared = this._atmosphereRadiusSquared - this._planetRadiusSquared;\r\n this._horizonDistanceToAtmosphereEdge = Math.sqrt(this._horizonDistanceToAtmosphereEdgeSquared);\r\n }\r\n\r\n private _recomputeRayleighScattering(): void {\r\n this._peakRayleighScattering.scaleToRef(this._rayleighScatteringScale, this._rayleighScattering);\r\n }\r\n\r\n private _recomputeMieScattering(): void {\r\n this._peakMieScattering.scaleToRef(this._mieScatteringScale, this._mieScattering);\r\n this._recomputeMieExtinction();\r\n }\r\n\r\n private _recomputeMieAbsorption(): void {\r\n this._peakMieAbsorption.scaleToRef(this._mieAbsorptionScale, this._mieAbsorption);\r\n this._recomputeMieExtinction();\r\n }\r\n\r\n private _recomputeMieExtinction(): void {\r\n this._mieAbsorption.addToRef(this._mieScattering, this._mieExtinction);\r\n }\r\n\r\n private _recomputeOzoneAbsorption(): void {\r\n this._peakOzoneAbsorption.scaleToRef(this._ozoneAbsorptionScale, this._ozoneAbsorption);\r\n }\r\n}\r\n"]}
@@ -0,0 +1,52 @@
1
+ import type { Vector3 } from "@onerjs/core/Maths/math.vector.js";
2
+ /**
3
+ * The options for the {@link AtmospherePhysicalProperties} that describe the planet, the atmosphere, and scattering.
4
+ */
5
+ export interface IAtmospherePhysicalPropertiesOptions {
6
+ /**
7
+ * The radius of the planet in kilometers.
8
+ */
9
+ planetRadius?: number;
10
+ /**
11
+ * The minimum camera radius (distance from the planet's center) allowed when rendering the atmosphere.
12
+ * This should be greater than 0.
13
+ * It prevents rendering issues close to the planet's surface.
14
+ */
15
+ planetRadiusOffset?: number;
16
+ /**
17
+ * The thickness of the atmosphere measured in kilometers from the planet's surface to the outer edge of the atmosphere.
18
+ */
19
+ atmosphereThickness?: number;
20
+ /**
21
+ * The scale applied to the Rayleigh scattering.
22
+ */
23
+ rayleighScatteringScale?: number;
24
+ /**
25
+ * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.
26
+ */
27
+ peakRayleighScattering?: Vector3;
28
+ /**
29
+ * The scale applied to the Mie scattering.
30
+ */
31
+ mieScatteringScale?: number;
32
+ /**
33
+ * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.
34
+ */
35
+ peakMieScattering?: Vector3;
36
+ /**
37
+ * The scale applied to the Mie absorption.
38
+ */
39
+ mieAbsorptionScale?: number;
40
+ /**
41
+ * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.
42
+ */
43
+ peakMieAbsorption?: Vector3;
44
+ /**
45
+ * The scale applied to the ozone absorption.
46
+ */
47
+ ozoneAbsorptionScale?: number;
48
+ /**
49
+ * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.
50
+ */
51
+ peakOzoneAbsorption?: Vector3;
52
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // MIT License
3
+ export {};
4
+ //# sourceMappingURL=atmospherePhysicalPropertiesOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atmospherePhysicalPropertiesOptions.js","sourceRoot":"","sources":["../../../../dev/addons/src/atmosphere/atmospherePhysicalPropertiesOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,cAAc","sourcesContent":["// Copyright (c) Microsoft Corporation.\r\n// MIT License\r\n\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * The options for the {@link AtmospherePhysicalProperties} that describe the planet, the atmosphere, and scattering.\r\n */\r\nexport interface IAtmospherePhysicalPropertiesOptions {\r\n /**\r\n * The radius of the planet in kilometers.\r\n */\r\n planetRadius?: number;\r\n\r\n /**\r\n * The minimum camera radius (distance from the planet's center) allowed when rendering the atmosphere.\r\n * This should be greater than 0.\r\n * It prevents rendering issues close to the planet's surface.\r\n */\r\n planetRadiusOffset?: number;\r\n\r\n /**\r\n * The thickness of the atmosphere measured in kilometers from the planet's surface to the outer edge of the atmosphere.\r\n */\r\n atmosphereThickness?: number;\r\n\r\n /**\r\n * The scale applied to the Rayleigh scattering.\r\n */\r\n rayleighScatteringScale?: number;\r\n\r\n /**\r\n * The Rayleigh scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n peakRayleighScattering?: Vector3;\r\n\r\n /**\r\n * The scale applied to the Mie scattering.\r\n */\r\n mieScatteringScale?: number;\r\n\r\n /**\r\n * The Mie scattering per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n peakMieScattering?: Vector3;\r\n\r\n /**\r\n * The scale applied to the Mie absorption.\r\n */\r\n mieAbsorptionScale?: number;\r\n\r\n /**\r\n * The Mie absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n peakMieAbsorption?: Vector3;\r\n\r\n /**\r\n * The scale applied to the ozone absorption.\r\n */\r\n ozoneAbsorptionScale?: number;\r\n\r\n /**\r\n * The ozone absorption per kilometer at sea level for red, green, and blue wavelengths.\r\n */\r\n peakOzoneAbsorption?: Vector3;\r\n}\r\n"]}
@@ -0,0 +1,63 @@
1
+ import type { Atmosphere } from "./atmosphere.js";
2
+ import type { IColor3Like, IVector3Like } from "@onerjs/core/Maths/math.like.js";
3
+ import { RenderTargetTexture } from "@onerjs/core/Materials/Textures/renderTargetTexture.js";
4
+ import "./Shaders/diffuseSkyIrradiance.fragment.js";
5
+ import "./Shaders/fullscreenTriangle.vertex.js";
6
+ /**
7
+ * The diffuse sky irradiance LUT is used to query the diffuse irradiance at a specified position.
8
+ */
9
+ export declare class DiffuseSkyIrradianceLut {
10
+ private readonly _atmosphere;
11
+ private _renderTarget;
12
+ private _effectWrapper;
13
+ private _effectRenderer;
14
+ private _isDirty;
15
+ private _isDisposed;
16
+ private _lutData;
17
+ /**
18
+ * True if the LUT needs to be rendered.
19
+ */
20
+ get isDirty(): boolean;
21
+ /**
22
+ * True if the LUT has been disposed.
23
+ */
24
+ get isDisposed(): boolean;
25
+ /**
26
+ * The render target used for this LUT.
27
+ * @throws if the LUT has been disposed.
28
+ */
29
+ get renderTarget(): RenderTargetTexture;
30
+ /**
31
+ * True if the LUT data has been read back from the GPU.
32
+ */
33
+ get hasLutData(): boolean;
34
+ /**
35
+ * Constructs the {@link DiffuseSkyIrradianceLut}.
36
+ * @param atmosphere - The atmosphere to use.
37
+ */
38
+ constructor(atmosphere: Atmosphere);
39
+ /**
40
+ * Gets the diffuse sky irradiance for a surface oriented along the geocentric normal.
41
+ * Resulting color is always in linear space.
42
+ * @param directionToLight - The direction to the light in world space.
43
+ * @param radius - The position's distance to the planet origin.
44
+ * @param cameraGeocentricNormal - The geocentric normal of the camera.
45
+ * @param lightIrradiance - The irradiance of the light.
46
+ * @param result - The color to store the result in.
47
+ * @returns The result color.
48
+ */
49
+ getDiffuseSkyIrradianceToRef<T extends IColor3Like>(directionToLight: IVector3Like, radius: number, cameraGeocentricNormal: IVector3Like, lightIrradiance: number, result: T): T;
50
+ /**
51
+ * Renders the LUT.
52
+ * @returns True if the LUT was rendered.
53
+ */
54
+ render(): boolean;
55
+ /**
56
+ * Marks the LUT as needing to be rendered.
57
+ */
58
+ markDirty(): void;
59
+ /**
60
+ * Disposes the LUT.
61
+ */
62
+ dispose(): void;
63
+ }