@woosh/meep-engine 2.162.0 → 2.163.1

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,44 +1,45 @@
1
- import {
2
- sky_hosek_compute_irradiance_by_direction,
3
- sky_hosek_precompute
4
- } from "../sky/hosek/sky_hosek_compute_irradiance_by_direction.js";
5
- import { vec3 } from "gl-matrix";
6
- import { array_copy } from "../../../../core/collection/array/array_copy.js";
7
- import { max2 } from "../../../../core/math/max2.js";
8
-
9
- export function make_sky_hosek(sun = [0, 1, 0], turbidity = 1, overcast = 0, albedo = [0, 0, 0]) {
10
- const coeffs = new Float32Array(27);
11
- const rad = new Float32Array([1, 1, 1]);
12
- const sun_position = new Float32Array([sun[0], sun[2], sun[1]]);
13
-
14
- vec3.normalize(sun_position, sun_position);
15
-
16
- sky_hosek_precompute(coeffs, rad, sun_position, turbidity, albedo, overcast);
17
-
18
- const v3 = [];
19
-
20
- const value_scale = 8e-5;
21
-
22
- return (result, result_offset, direction, direction_offset) => {
23
- const d_x = direction[direction_offset];
24
- const d_z = direction[direction_offset + 2];
25
- const d_y = direction[direction_offset + 1];
26
-
27
- sky_hosek_compute_irradiance_by_direction(
28
- v3, coeffs, rad, sun_position,
29
- d_z ,
30
- d_x ,
31
- d_y ,
32
- );
33
-
34
- vec3.scale(v3, v3, value_scale);
35
-
36
- // clamp sky contribution
37
- v3[0] = max2(0, v3[0]);
38
- v3[1] = max2(0, v3[1]);
39
- v3[2] = max2(0, v3[2]);
40
-
41
-
42
- array_copy(v3, 0, result, result_offset, 3);
43
- }
44
- }
1
+ import {
2
+ sky_hosek_compute_irradiance_by_direction,
3
+ sky_hosek_precompute
4
+ } from "../sky/hosek/sky_hosek_compute_irradiance_by_direction.js";
5
+ import { v3_array_scale } from "../../../../core/geom/vec3/v3_array_scale.js";
6
+ import { v3_array_normalize } from "../../../../core/geom/vec3/v3_array_normalize.js";
7
+ import { array_copy } from "../../../../core/collection/array/array_copy.js";
8
+ import { max2 } from "../../../../core/math/max2.js";
9
+
10
+ export function make_sky_hosek(sun = [0, 1, 0], turbidity = 1, overcast = 0, albedo = [0, 0, 0]) {
11
+ const coeffs = new Float32Array(27);
12
+ const rad = new Float32Array([1, 1, 1]);
13
+ const sun_position = new Float32Array([sun[0], sun[1], sun[2]]);
14
+
15
+ v3_array_normalize(sun_position, 0, sun_position, 0);
16
+
17
+ sky_hosek_precompute(coeffs, rad, sun_position, turbidity, albedo, overcast);
18
+
19
+ const v3 = [];
20
+
21
+ const value_scale = 8e-5;
22
+
23
+ return (result, result_offset, direction, direction_offset) => {
24
+ const d_x = direction[direction_offset];
25
+ const d_y = direction[direction_offset + 1];
26
+ const d_z = direction[direction_offset + 2];
27
+
28
+ sky_hosek_compute_irradiance_by_direction(
29
+ v3, coeffs, rad, sun_position,
30
+ d_x,
31
+ d_y,
32
+ d_z,
33
+ );
34
+
35
+ v3_array_scale(v3, 0, v3, 0, value_scale);
36
+
37
+ // clamp sky contribution
38
+ v3[0] = max2(0, v3[0]);
39
+ v3[1] = max2(0, v3[1]);
40
+ v3[2] = max2(0, v3[2]);
41
+
42
+
43
+ array_copy(v3, 0, result, result_offset, 3);
44
+ }
45
+ }
@@ -1,24 +1,22 @@
1
- /// <reference types="gl-matrix/index.js" />
2
1
  /**
3
2
  * @see https://github.com/andrewwillmott/sun-sky/blob/master/SunSky.cpp
4
3
  * @param {number[]} mCoeffsXYZ output, float[3][9], Hosek 9-term distribution coefficients
5
4
  * @param {number[]} mRadXYZ output, vec3, Overall average radiance
6
- * @param {vec3} sun_direction
5
+ * @param {number[]|Float32Array} sun_direction direction to the sun, engine frame (+Y up)
7
6
  * @param {number} turbidity should be between 1 and 10
8
- * @param {vec3} rgbAlbedo albedo in linear color space (make sure it's not sRGB)
7
+ * @param {number[]|Float32Array} rgbAlbedo albedo in linear color space (make sure it's not sRGB)
9
8
  * @param {number} overcast
10
9
  */
11
- export function sky_hosek_precompute(mCoeffsXYZ: number[], mRadXYZ: number[], sun_direction: vec3, turbidity: number, rgbAlbedo: vec3, overcast: number): void;
10
+ export function sky_hosek_precompute(mCoeffsXYZ: number[], mRadXYZ: number[], sun_direction: number[] | Float32Array, turbidity: number, rgbAlbedo: number[] | Float32Array, overcast: number): void;
12
11
  /**
13
12
  *
14
13
  * @param {number[]|Float32Array} out vec3 in RGB color space
15
14
  * @param {number[]|Float32Array} mCoeffsXYZ float[3][9]
16
15
  * @param {number[]|Float32Array} mRadXYZ vec3
17
- * @param {number[]|Float32Array} mToSun vec3
16
+ * @param {number[]|Float32Array} mToSun vec3, direction to the sun, engine frame (+Y up)
18
17
  * @param {number} direction_x
19
- * @param {number} direction_y
18
+ * @param {number} direction_y up axis (engine +Y up)
20
19
  * @param {number} direction_z
21
20
  */
22
21
  export function sky_hosek_compute_irradiance_by_direction(out: number[] | Float32Array, mCoeffsXYZ: number[] | Float32Array, mRadXYZ: number[] | Float32Array, mToSun: number[] | Float32Array, direction_x: number, direction_y: number, direction_z: number): void;
23
- import { vec3 } from "gl-matrix";
24
22
  //# sourceMappingURL=sky_hosek_compute_irradiance_by_direction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sky_hosek_compute_irradiance_by_direction.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js"],"names":[],"mappings":";AA+NA;;;;;;;;GAQG;AACH,iDAPW,MAAM,EAAE,WACR,MAAM,EAAE,iBACR,IAAI,aACJ,MAAM,aACN,IAAI,YACJ,MAAM,QA4HhB;AAGD;;;;;;;;;GASG;AACH,+DARW,MAAM,EAAE,GAAC,YAAY,cACrB,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,EAAE,GAAC,YAAY,UACrB,MAAM,EAAE,GAAC,YAAY,eACrB,MAAM,eACN,MAAM,eACN,MAAM,QA6BhB;qBAxYoB,WAAW"}
1
+ {"version":3,"file":"sky_hosek_compute_irradiance_by_direction.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js"],"names":[],"mappings":"AAyNA;;;;;;;;GAQG;AACH,iDAPW,MAAM,EAAE,WACR,MAAM,EAAE,iBACR,MAAM,EAAE,GAAC,YAAY,aACrB,MAAM,aACN,MAAM,EAAE,GAAC,YAAY,YACrB,MAAM,QAgHhB;AAGD;;;;;;;;;GASG;AACH,+DARW,MAAM,EAAE,GAAC,YAAY,cACrB,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,EAAE,GAAC,YAAY,UACrB,MAAM,EAAE,GAAC,YAAY,eACrB,MAAM,eACN,MAAM,eACN,MAAM,QAwChB"}