@woosh/meep-engine 2.130.0 → 2.131.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.
- package/package.json +1 -1
- package/src/core/color/illuminant/D65_spd_analytical.d.ts +12 -0
- package/src/core/color/illuminant/D65_spd_analytical.d.ts.map +1 -0
- package/src/core/color/illuminant/D65_spd_analytical.js +70 -0
- package/src/core/color/illuminant/D65_spd_tabulated.d.ts +13 -0
- package/src/core/color/illuminant/D65_spd_tabulated.d.ts.map +1 -0
- package/src/core/color/illuminant/D65_spd_tabulated.js +105 -0
- package/src/core/color/sRGB/sRGB_cmf.d.ts +11 -0
- package/src/core/color/sRGB/sRGB_cmf.d.ts.map +1 -0
- package/src/core/color/sRGB/sRGB_cmf.js +22 -0
- package/src/core/color/xyz/xyz_cmf_tabulated.d.ts +22 -0
- package/src/core/color/xyz/xyz_cmf_tabulated.d.ts.map +1 -0
- package/src/core/color/xyz/xyz_cmf_tabulated.js +212 -0
- package/src/core/color/xyz/xyz_cmf_wyman.d.ts +13 -0
- package/src/core/color/xyz/xyz_cmf_wyman.d.ts.map +1 -0
- package/src/core/color/xyz/xyz_cmf_wyman.js +65 -0
- package/src/core/color/xyz/xyz_to_rgb.d.ts +3 -3
- package/src/core/color/xyz/xyz_to_rgb.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_to_rgb.js +2 -2
- package/src/core/math/complex/complex_add.d.ts +8 -0
- package/src/core/math/complex/complex_add.d.ts.map +1 -0
- package/src/core/math/complex/complex_add.js +11 -0
- package/src/core/math/complex/complex_div.d.ts +8 -0
- package/src/core/math/complex/complex_div.d.ts.map +1 -0
- package/src/core/math/complex/complex_div.js +12 -0
- package/src/core/math/complex/complex_mul.d.ts +8 -0
- package/src/core/math/complex/complex_mul.d.ts.map +1 -0
- package/src/core/math/complex/complex_mul.js +10 -0
- package/src/core/math/complex/complex_sub.d.ts +8 -0
- package/src/core/math/complex/complex_sub.d.ts.map +1 -0
- package/src/core/math/complex/complex_sub.js +10 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD.d.ts +41 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD.d.ts.map +1 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD.js +125 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.d.ts +160 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.d.ts.map +1 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.js +215 -0
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.d.ts +18 -0
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.d.ts.map +1 -0
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.js +151 -0
- package/src/core/math/physics/mie/compute_lorenz_mie_optical_properties.d.ts +12 -0
- package/src/core/math/physics/mie/compute_lorenz_mie_optical_properties.d.ts.map +1 -0
- package/src/core/math/physics/mie/compute_lorenz_mie_optical_properties.js +363 -0
- package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.d.ts +15 -0
- package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.d.ts.map +1 -0
- package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.js +148 -0
- package/src/core/math/physics/mie/ri_air.d.ts +7 -0
- package/src/core/math/physics/mie/ri_air.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_air.js +69 -0
- package/src/core/math/physics/mie/ri_ammonium_sulfate.d.ts +7 -0
- package/src/core/math/physics/mie/ri_ammonium_sulfate.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_ammonium_sulfate.js +140 -0
- package/src/core/math/physics/mie/ri_brine.d.ts +7 -0
- package/src/core/math/physics/mie/ri_brine.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_brine.js +145 -0
- package/src/core/math/physics/mie/ri_dust.d.ts +7 -0
- package/src/core/math/physics/mie/ri_dust.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_dust.js +153 -0
- package/src/core/math/physics/mie/ri_pollen.d.ts +7 -0
- package/src/core/math/physics/mie/ri_pollen.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_pollen.js +146 -0
- package/src/core/math/physics/mie/ri_smoke.d.ts +7 -0
- package/src/core/math/physics/mie/ri_smoke.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_smoke.js +151 -0
- package/src/core/math/physics/mie/ri_soot.d.ts +7 -0
- package/src/core/math/physics/mie/ri_soot.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_soot.js +148 -0
- package/src/core/math/physics/mie/ri_water.d.ts +7 -0
- package/src/core/math/physics/mie/ri_water.d.ts.map +1 -0
- package/src/core/math/physics/mie/ri_water.js +148 -0
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.
|
|
8
|
+
"version": "2.131.1",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the analytical D65 SPD, normalized to 100.0 at 560 nm.
|
|
3
|
+
* Returns 0 outside [300, 830] nm.
|
|
4
|
+
*
|
|
5
|
+
* Note: not true D65, if you need accuracy - use {@link D65_spd_tabulated} instead
|
|
6
|
+
*
|
|
7
|
+
* @param {number} wavelength_nm
|
|
8
|
+
* @returns {number}
|
|
9
|
+
* @see D65_spd_tabulated
|
|
10
|
+
*/
|
|
11
|
+
export function D65_spd_analytical(wavelength_nm: number): number;
|
|
12
|
+
//# sourceMappingURL=D65_spd_analytical.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"D65_spd_analytical.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/illuminant/D65_spd_analytical.js"],"names":[],"mappings":"AA+CA;;;;;;;;;GASG;AACH,kDAJW,MAAM,GACJ,MAAM,CAelB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Analytical approximation of the CIE D65 Spectral Power Distribution (SPD)
|
|
3
|
+
* using Planck's Law for a blackbody at the CCT of D65 (6504 K).
|
|
4
|
+
*
|
|
5
|
+
* This provides a close approximation to the shape of the D65 curve and is
|
|
6
|
+
* normalized to 100.0 at 560 nm to match the CIE standard.
|
|
7
|
+
*
|
|
8
|
+
* Note: The official D65 standard ({@link D65_spd_tabulated}) is based on measurements
|
|
9
|
+
* and is not a perfect blackbody. This function is the standard
|
|
10
|
+
* *physical approximation*.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const D65_ANALYTIC_T = 6504.0; // CCT for D65 in Kelvin
|
|
14
|
+
const D65_ANALYTIC_C2 = 1.438776877e-2; // Second radiation constant (m·K)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Calculates the un-normalized spectral power for a given wavelength.
|
|
18
|
+
* @param {number} lambda_m Wavelength in meters
|
|
19
|
+
* @param {number} T Temperature in Kelvin
|
|
20
|
+
* @returns {number} Relative spectral power
|
|
21
|
+
*/
|
|
22
|
+
function planckian_radiance(lambda_m, T) {
|
|
23
|
+
const lambda_T = lambda_m * T;
|
|
24
|
+
const exponent = D65_ANALYTIC_C2 / lambda_T;
|
|
25
|
+
|
|
26
|
+
// Handle high exponents to prevent Math.exp from returning Infinity
|
|
27
|
+
if (exponent > 80.0) {
|
|
28
|
+
return 0.0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const lambda_5 = Math.pow(lambda_m, 5);
|
|
32
|
+
|
|
33
|
+
// This can be simplified to just (1/lambda_5) because the
|
|
34
|
+
// rest of the numerator is a constant we are normalizing away.
|
|
35
|
+
const radiance = (1.0 / lambda_5) / (Math.exp(exponent) - 1.0);
|
|
36
|
+
|
|
37
|
+
return radiance;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Pre-calculate the normalization factor:
|
|
41
|
+
// This is the un-normalized value of the function at 560nm (560e-9 m),
|
|
42
|
+
// which is the wavelength where D65 is defined to be 100.
|
|
43
|
+
const NORM_WAVELENGTH_M = 560e-9;
|
|
44
|
+
const UNNORMALIZED_VALUE_AT_560 = planckian_radiance(NORM_WAVELENGTH_M, D65_ANALYTIC_T);
|
|
45
|
+
const NORMALIZATION_FACTOR = 1 / (UNNORMALIZED_VALUE_AT_560 / 100.0);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns the analytical D65 SPD, normalized to 100.0 at 560 nm.
|
|
50
|
+
* Returns 0 outside [300, 830] nm.
|
|
51
|
+
*
|
|
52
|
+
* Note: not true D65, if you need accuracy - use {@link D65_spd_tabulated} instead
|
|
53
|
+
*
|
|
54
|
+
* @param {number} wavelength_nm
|
|
55
|
+
* @returns {number}
|
|
56
|
+
* @see D65_spd_tabulated
|
|
57
|
+
*/
|
|
58
|
+
export function D65_spd_analytical(wavelength_nm) {
|
|
59
|
+
|
|
60
|
+
if (wavelength_nm < 300 || wavelength_nm > 830) {
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const lambda_m = wavelength_nm * 1.0e-9; // Convert nm to meters
|
|
65
|
+
|
|
66
|
+
const radiance = planckian_radiance(lambda_m, D65_ANALYTIC_T);
|
|
67
|
+
|
|
68
|
+
// Return the value, normalized
|
|
69
|
+
return radiance * NORMALIZATION_FACTOR;
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear-interpolated D65 SPD at the given wavelength.
|
|
3
|
+
* Returns 0 outside [300, 830] nm.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: results are normalized to 100 instead of 1
|
|
6
|
+
*
|
|
7
|
+
* @param {number} wavelength_nm
|
|
8
|
+
* @returns {number}
|
|
9
|
+
*/
|
|
10
|
+
export function D65_spd_tabulated(wavelength_nm: number): number;
|
|
11
|
+
export const D65_MIN_NM: 300;
|
|
12
|
+
export const D65_MAX_NM: 830;
|
|
13
|
+
//# sourceMappingURL=D65_spd_tabulated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"D65_spd_tabulated.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/illuminant/D65_spd_tabulated.js"],"names":[],"mappings":"AAyEA;;;;;;;;GAQG;AACH,iDAHW,MAAM,GACJ,MAAM,CAwBlB;AArGD,6BAA8B;AAC9B,6BAA8B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { lerp } from "../../math/lerp.js";
|
|
3
|
+
|
|
4
|
+
export const D65_MIN_NM = 300;
|
|
5
|
+
export const D65_MAX_NM = 830;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* CIE Standard Illuminant D65 Spectral Power Distribution (SPD)
|
|
9
|
+
* Source: CVRL (Colour & Vision Research Laboratory)
|
|
10
|
+
* Wavelength range: 300–830 nm in 1 nm steps.
|
|
11
|
+
* Units are relative; use appropriate normalization constant when integrating.
|
|
12
|
+
*
|
|
13
|
+
* 300..830 inclusive → 531 samples
|
|
14
|
+
*
|
|
15
|
+
* @see http://www.cvrl.org/cie.htm
|
|
16
|
+
*/
|
|
17
|
+
const D65_VALUES = new Float32Array([
|
|
18
|
+
0.0341, 0.36014, 0.68618, 1.01222, 1.33826, 1.6643, 1.99034, 2.31638, 2.64242, 2.96846,
|
|
19
|
+
3.2945, 4.98865, 6.6828, 8.37695, 10.0711, 11.7652, 13.4594, 15.1535, 16.8477, 18.5418,
|
|
20
|
+
20.236, 21.9177, 23.5995, 25.2812, 26.963, 28.6447, 30.3265, 32.0082, 33.69, 35.3717,
|
|
21
|
+
37.0535, 37.343, 37.6326, 37.9221, 38.2116, 38.5011, 38.7907, 39.0802, 39.3697, 39.6593,
|
|
22
|
+
39.9488, 40.4451, 40.9414, 41.4377, 41.934, 42.4302, 42.9265, 43.4228, 43.9191, 44.4154,
|
|
23
|
+
44.9117, 45.0844, 45.257, 45.4297, 45.6023, 45.775, 45.9477, 46.1203, 46.293, 46.4656,
|
|
24
|
+
46.6383, 47.1834, 47.7285, 48.2735, 48.8186, 49.3637, 49.9088, 50.4539, 50.9989, 51.544,
|
|
25
|
+
52.0891, 51.8777, 51.6664, 51.455, 51.2437, 51.0323, 50.8209, 50.6096, 50.3982, 50.1869,
|
|
26
|
+
49.9755, 50.4428, 50.91, 51.3773, 51.8446, 52.3118, 52.7791, 53.2464, 53.7137, 54.1809,
|
|
27
|
+
54.6482, 57.4589, 60.2695, 63.0802, 65.8909, 68.7015, 71.5122, 74.3229, 77.1336, 79.9442,
|
|
28
|
+
82.7549, 83.628, 84.5011, 85.3742, 86.2473, 87.1204, 87.9936, 88.8667, 89.7398, 90.6129,
|
|
29
|
+
91.486, 91.6806, 91.8752, 92.0697, 92.2643, 92.4589, 92.6535, 92.8481, 93.0426, 93.2372,
|
|
30
|
+
93.4318, 92.7568, 92.0819, 91.4069, 90.732, 90.057, 89.3821, 88.7071, 88.0322, 87.3572,
|
|
31
|
+
86.6823, 88.5006, 90.3188, 92.1371, 93.9554, 95.7736, 97.5919, 99.4102, 101.228, 103.047,
|
|
32
|
+
104.865, 106.079, 107.294, 108.508, 109.722, 110.936, 112.151, 113.365, 114.579, 115.794,
|
|
33
|
+
117.008, 117.088, 117.169, 117.249, 117.33, 117.41, 117.49, 117.571, 117.651, 117.732,
|
|
34
|
+
117.812, 117.517, 117.222, 116.927, 116.632, 116.336, 116.041, 115.746, 115.451, 115.156,
|
|
35
|
+
114.861, 114.967, 115.073, 115.18, 115.286, 115.392, 115.498, 115.604, 115.711, 115.817,
|
|
36
|
+
115.923, 115.212, 114.501, 113.789, 113.078, 112.367, 111.656, 110.945, 110.233, 109.522,
|
|
37
|
+
108.811, 108.865, 108.92, 108.974, 109.028, 109.082, 109.137, 109.191, 109.245, 109.3,
|
|
38
|
+
109.354, 109.199, 109.044, 108.888, 108.733, 108.578, 108.423, 108.268, 108.112, 107.957,
|
|
39
|
+
107.802, 107.501, 107.2, 106.898, 106.597, 106.296, 105.995, 105.694, 105.392, 105.091,
|
|
40
|
+
104.79, 105.08, 105.37, 105.66, 105.95, 106.239, 106.529, 106.819, 107.109, 107.399,
|
|
41
|
+
107.689, 107.361, 107.032, 106.704, 106.375, 106.047, 105.719, 105.39, 105.062, 104.733,
|
|
42
|
+
104.405, 104.369, 104.333, 104.297, 104.261, 104.225, 104.19, 104.154, 104.118, 104.082,
|
|
43
|
+
104.046, 103.641, 103.237, 102.832, 102.428, 102.023, 101.618, 101.214, 100.809, 100.405,
|
|
44
|
+
100.0, 99.6334, 99.2668, 98.9003, 98.5337, 98.1671, 97.8005, 97.4339, 97.0674, 96.7008,
|
|
45
|
+
96.3342, 96.2796, 96.225, 96.1703, 96.1157, 96.0611, 96.0065, 95.9519, 95.8972, 95.8426,
|
|
46
|
+
95.788, 95.0778, 94.3675, 93.6573, 92.947, 92.2368, 91.5266, 90.8163, 90.1061, 89.3958,
|
|
47
|
+
88.6856, 88.8177, 88.9497, 89.0818, 89.2138, 89.3459, 89.478, 89.61, 89.7421, 89.8741,
|
|
48
|
+
90.0062, 89.9655, 89.9248, 89.8841, 89.8434, 89.8026, 89.7619, 89.7212, 89.6805, 89.6398,
|
|
49
|
+
89.5991, 89.4091, 89.219, 89.029, 88.8389, 88.6489, 88.4589, 88.2688, 88.0788, 87.8887,
|
|
50
|
+
87.6987, 87.2577, 86.8167, 86.3757, 85.9347, 85.4936, 85.0526, 84.6116, 84.1706, 83.7296,
|
|
51
|
+
83.2886, 83.3297, 83.3707, 83.4118, 83.4528, 83.4939, 83.535, 83.576, 83.6171, 83.6581,
|
|
52
|
+
83.6992, 83.332, 82.9647, 82.5975, 82.2302, 81.863, 81.4958, 81.1285, 80.7613, 80.394,
|
|
53
|
+
80.0268, 80.0456, 80.0644, 80.0831, 80.1019, 80.1207, 80.1395, 80.1583, 80.177, 80.1958,
|
|
54
|
+
80.2146, 80.4209, 80.6272, 80.8336, 81.0399, 81.2462, 81.4525, 81.6588, 81.8652, 82.0715,
|
|
55
|
+
82.2778, 81.8784, 81.4791, 81.0797, 80.6804, 80.281, 79.8816, 79.4823, 79.0829, 78.6836,
|
|
56
|
+
78.2842, 77.4279, 76.5716, 75.7153, 74.859, 74.0027, 73.1465, 72.2902, 71.4339, 70.5776,
|
|
57
|
+
69.7213, 69.9101, 70.0989, 70.2876, 70.4764, 70.6652, 70.854, 71.0428, 71.2315, 71.4203,
|
|
58
|
+
71.6091, 71.8831, 72.1571, 72.4311, 72.7051, 72.979, 73.253, 73.527, 73.801, 74.075,
|
|
59
|
+
74.349, 73.0745, 71.8, 70.5255, 69.251, 67.9765, 66.702, 65.4275, 64.153, 62.8785,
|
|
60
|
+
61.604, 62.4322, 63.2603, 64.0885, 64.9166, 65.7448, 66.573, 67.4011, 68.2293, 69.0574,
|
|
61
|
+
69.8856, 70.4057, 70.9259, 71.446, 71.9662, 72.4863, 73.0064, 73.5266, 74.0467, 74.5669,
|
|
62
|
+
75.087, 73.9376, 72.7881, 71.6387, 70.4893, 69.3398, 68.1904, 67.041, 65.8916, 64.7421,
|
|
63
|
+
63.5927, 61.8752, 60.1578, 58.4403, 56.7229, 55.0054, 53.288, 51.5705, 49.8531, 48.1356,
|
|
64
|
+
46.4182, 48.4569, 50.4956, 52.5344, 54.5731, 56.6118, 58.6505, 60.6892, 62.728, 64.7667,
|
|
65
|
+
66.8054, 66.4631, 66.1209, 65.7786, 65.4364, 65.0941, 64.7518, 64.4096, 64.0673, 63.7251,
|
|
66
|
+
63.3828, 63.4749, 63.567, 63.6592, 63.7513, 63.8434, 63.9355, 64.0276, 64.1198, 64.2119,
|
|
67
|
+
64.304, 63.8188, 63.3336, 62.8484, 62.3632, 61.8779, 61.3927, 60.9075, 60.4223, 59.9371,
|
|
68
|
+
59.4519, 58.7026, 57.9533, 57.204, 56.4547, 55.7054, 54.9562, 54.2069, 53.4576, 52.7083,
|
|
69
|
+
51.959, 52.5072, 53.0553, 53.6035, 54.1516, 54.6998, 55.248, 55.7961, 56.3443, 56.8924,
|
|
70
|
+
57.4406, 57.7278, 58.015, 58.3022, 58.5894, 58.8765, 59.1637, 59.4509, 59.7381, 60.0253,
|
|
71
|
+
60.3125
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Linear-interpolated D65 SPD at the given wavelength.
|
|
76
|
+
* Returns 0 outside [300, 830] nm.
|
|
77
|
+
*
|
|
78
|
+
* NOTE: results are normalized to 100 instead of 1
|
|
79
|
+
*
|
|
80
|
+
* @param {number} wavelength_nm
|
|
81
|
+
* @returns {number}
|
|
82
|
+
*/
|
|
83
|
+
export function D65_spd_tabulated(wavelength_nm) {
|
|
84
|
+
assert.isNumber(wavelength_nm, 'wavelength_nm');
|
|
85
|
+
assert.isFinite(wavelength_nm, 'wavelength_nm');
|
|
86
|
+
assert.greaterThan(wavelength_nm, 0, 'wavelength_nm > 0');
|
|
87
|
+
|
|
88
|
+
if (wavelength_nm <= D65_MIN_NM || wavelength_nm >= D65_MAX_NM) {
|
|
89
|
+
|
|
90
|
+
if (wavelength_nm === D65_MIN_NM) return D65_VALUES[0];
|
|
91
|
+
|
|
92
|
+
if (wavelength_nm === D65_MAX_NM) return D65_VALUES[D65_VALUES.length - 1];
|
|
93
|
+
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const w = wavelength_nm;
|
|
98
|
+
|
|
99
|
+
const i0 = Math.floor(w) - D65_MIN_NM; // index for integer nm below w
|
|
100
|
+
const frac = w - Math.floor(w);
|
|
101
|
+
|
|
102
|
+
const v0 = D65_VALUES[i0];
|
|
103
|
+
const v1 = D65_VALUES[i0 + 1];
|
|
104
|
+
return lerp(v0, v1, frac);
|
|
105
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color-Matching Function, for sRGB
|
|
3
|
+
*
|
|
4
|
+
* Prefer to integrate in XYZ space and then perform the conversion to sRGB
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]} result
|
|
7
|
+
* @param {number} wavelength_nm in nanometers (1e-9)
|
|
8
|
+
* @returns {number[]} the input `result` parameter, returned for convenience
|
|
9
|
+
*/
|
|
10
|
+
export function sRGB_cmf(result: number[], wavelength_nm: number): number[];
|
|
11
|
+
//# sourceMappingURL=sRGB_cmf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sRGB_cmf.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/sRGB_cmf.js"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,iCAJW,MAAM,EAAE,iBACR,MAAM,GACJ,MAAM,EAAE,CAWpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { xyz_cmf_wyman } from "../xyz/xyz_cmf_wyman.js";
|
|
2
|
+
import { xyz_to_rgb } from "../xyz/xyz_to_rgb.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Color-Matching Function, for sRGB
|
|
6
|
+
*
|
|
7
|
+
* Prefer to integrate in XYZ space and then perform the conversion to sRGB
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]} result
|
|
10
|
+
* @param {number} wavelength_nm in nanometers (1e-9)
|
|
11
|
+
* @returns {number[]} the input `result` parameter, returned for convenience
|
|
12
|
+
*/
|
|
13
|
+
export function sRGB_cmf(result, wavelength_nm) {
|
|
14
|
+
|
|
15
|
+
xyz_cmf_wyman(result, wavelength_nm); // x̄, ȳ, z̄
|
|
16
|
+
// Convert per-wavelength XYZ to per-wavelength “RGB sensitivities”
|
|
17
|
+
|
|
18
|
+
xyz_to_rgb(result, result);
|
|
19
|
+
// result now holds R̄, Ḡ, B̄
|
|
20
|
+
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear-interpolated CIE 1931 2° CMFs at the given wavelength.
|
|
3
|
+
* Returns 0 outside [360, 830] nm.
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} out length>=3
|
|
6
|
+
* @param {number} wavelength_nm wavelength in nanometers
|
|
7
|
+
* @returns {number[]} out
|
|
8
|
+
*/
|
|
9
|
+
export function xyz_cmf_tabulated(out: number[], wavelength_nm: number): number[];
|
|
10
|
+
/**
|
|
11
|
+
* CIE 1931 2° XYZ color matching functions (tabulated, CVRL)
|
|
12
|
+
*
|
|
13
|
+
* Source: CVRL (Colour & Vision Research Laboratory), 1 nm steps.
|
|
14
|
+
* Wavelength range: 360–830 nm inclusive.
|
|
15
|
+
* Values are unweighted CMFs (no illuminant). Weighting by SPD (e.g., D65)
|
|
16
|
+
* should be applied by the caller during spectral integration when needed.
|
|
17
|
+
*
|
|
18
|
+
* @see http://www.cvrl.org/cie.htm
|
|
19
|
+
*/
|
|
20
|
+
export const XYZ_CMF_MIN_NM: 360;
|
|
21
|
+
export const XYZ_CMF_MAX_NM: 830;
|
|
22
|
+
//# sourceMappingURL=xyz_cmf_tabulated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xyz_cmf_tabulated.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/xyz_cmf_tabulated.js"],"names":[],"mappings":"AA0KA;;;;;;;GAOG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,GACJ,MAAM,EAAE,CAmCpB;AAjND;;;;;;;;;GASG;AAEH,iCAAkC;AAClC,iCAAkC"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { lerp } from "../../math/lerp.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CIE 1931 2° XYZ color matching functions (tabulated, CVRL)
|
|
5
|
+
*
|
|
6
|
+
* Source: CVRL (Colour & Vision Research Laboratory), 1 nm steps.
|
|
7
|
+
* Wavelength range: 360–830 nm inclusive.
|
|
8
|
+
* Values are unweighted CMFs (no illuminant). Weighting by SPD (e.g., D65)
|
|
9
|
+
* should be applied by the caller during spectral integration when needed.
|
|
10
|
+
*
|
|
11
|
+
* @see http://www.cvrl.org/cie.htm
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export const XYZ_CMF_MIN_NM = 360;
|
|
15
|
+
export const XYZ_CMF_MAX_NM = 830;
|
|
16
|
+
|
|
17
|
+
// Tabulated x̄(λ), ȳ(λ), z̄(λ) at 1 nm spacing from 360..830 nm inclusive
|
|
18
|
+
// Length = 471 samples
|
|
19
|
+
const X_BAR = new Float32Array([
|
|
20
|
+
0.0001299, 0.000145847, 0.000163802, 0.000184004, 0.00020669, 0.0002321, 0.000260728, 0.000293075, 0.000329388, 0.000369914,
|
|
21
|
+
0.0004149, 0.000464159, 0.000518986, 0.000581854, 0.000655235, 0.0007416, 0.00084503, 0.000964527, 0.001094949, 0.001231154,
|
|
22
|
+
0.001368, 0.00150205, 0.001642328, 0.001802382, 0.001995757, 0.002236, 0.002535385, 0.002892603, 0.003300829, 0.003753236,
|
|
23
|
+
0.004243, 0.004762389, 0.005330048, 0.005978712, 0.006741117, 0.00765, 0.008751373, 0.01002888, 0.0114217, 0.01286901,
|
|
24
|
+
0.01431, 0.01570443, 0.01714744, 0.01878122, 0.02074801, 0.02319, 0.02620736, 0.02978248, 0.03388092, 0.03846824,
|
|
25
|
+
0.04351, 0.0489956, 0.0550226, 0.0617188, 0.069212, 0.07763, 0.08695811, 0.09717672, 0.1084063, 0.1207672,
|
|
26
|
+
0.13438, 0.1493582, 0.1653957, 0.1819831, 0.198611, 0.21477, 0.2301868, 0.2448797, 0.2587773, 0.2718079,
|
|
27
|
+
0.2839, 0.2949438, 0.3048965, 0.3137873, 0.3216454, 0.3285, 0.3343513, 0.3392101, 0.3431213, 0.3461296,
|
|
28
|
+
0.34828, 0.3495999, 0.3501474, 0.350013, 0.349287, 0.34806, 0.3463733, 0.3442624, 0.3418088, 0.3390941,
|
|
29
|
+
0.3362, 0.3331977, 0.3300411, 0.3266357, 0.3228868, 0.3187, 0.3140251, 0.308884, 0.3032904, 0.2972579,
|
|
30
|
+
0.2908, 0.2839701, 0.2767214, 0.2689178, 0.2604227, 0.2511, 0.2408475, 0.2298512, 0.2184072, 0.2068115,
|
|
31
|
+
0.19536, 0.1842136, 0.1733273, 0.1626881, 0.1522833, 0.1421, 0.1321786, 0.1225696, 0.1132752, 0.1042979,
|
|
32
|
+
0.09564, 0.08729955, 0.07930804, 0.07171776, 0.06458099, 0.05795001, 0.05186211, 0.04628152, 0.04115088, 0.03641283,
|
|
33
|
+
0.03201, 0.0279172, 0.0241444, 0.020687, 0.0175404, 0.0147, 0.01216179, 0.00991996, 0.00796724, 0.006296346,
|
|
34
|
+
0.0049, 0.003777173, 0.00294532, 0.00242488, 0.002236293, 0.0024, 0.00292552, 0.00383656, 0.00517484, 0.00698208,
|
|
35
|
+
0.0093, 0.01214949, 0.01553588, 0.01947752, 0.02399277, 0.0291, 0.03481485, 0.04112016, 0.04798504, 0.05537861,
|
|
36
|
+
0.06327, 0.07163501, 0.08046224, 0.08973996, 0.09945645, 0.1096, 0.1201674, 0.1311145, 0.1423679, 0.1538542,
|
|
37
|
+
0.1655, 0.1772571, 0.18914, 0.2011694, 0.2133658, 0.2257499, 0.2383209, 0.2510668, 0.2639922, 0.2771017,
|
|
38
|
+
0.2904, 0.3038912, 0.3175726, 0.3314384, 0.3454828, 0.3597, 0.3740839, 0.3886396, 0.4033784, 0.4183115,
|
|
39
|
+
0.4334499, 0.4487953, 0.464336, 0.480064, 0.4959713, 0.5120501, 0.5282959, 0.5446916, 0.5612094, 0.5778215,
|
|
40
|
+
0.5945, 0.6112209, 0.6279758, 0.6447602, 0.6615697, 0.6784, 0.6952392, 0.7120586, 0.7288284, 0.7455188,
|
|
41
|
+
0.7621, 0.7785432, 0.7948256, 0.8109264, 0.8268248, 0.8425, 0.8579325, 0.8730816, 0.8878944, 0.9023181,
|
|
42
|
+
0.9163, 0.9297995, 0.9427984, 0.9552776, 0.9672179, 0.9786, 0.9893856, 0.9995488, 1.0090892, 1.0180064,
|
|
43
|
+
1.0263, 1.0339827, 1.040986, 1.047188, 1.0524667, 1.0567, 1.0597944, 1.0617992, 1.0628068, 1.0629096,
|
|
44
|
+
1.0622, 1.0607352, 1.0584436, 1.0552244, 1.0509768, 1.0456, 1.0390369, 1.0313608, 1.0226662, 1.0130477,
|
|
45
|
+
1.0026, 0.9913675, 0.9793314, 0.9664916, 0.9528479, 0.9384, 0.923194, 0.907244, 0.890502, 0.87292,
|
|
46
|
+
0.8544499, 0.835084, 0.814946, 0.794186, 0.772954, 0.7514, 0.7295836, 0.7075888, 0.6856022, 0.6638104,
|
|
47
|
+
0.6424, 0.6215149, 0.6011138, 0.5811052, 0.5613977, 0.5419, 0.5225995, 0.5035464, 0.4847436, 0.4661939,
|
|
48
|
+
0.4479, 0.4298613, 0.412098, 0.394644, 0.3775333, 0.3608, 0.3444563, 0.3285168, 0.3130192, 0.2980011,
|
|
49
|
+
0.2835, 0.2695448, 0.2561184, 0.2431896, 0.2307272, 0.2187, 0.2070971, 0.1959232, 0.1851708, 0.1748323,
|
|
50
|
+
0.1649, 0.1553667, 0.14623, 0.13749, 0.1291467, 0.1212, 0.1136397, 0.106465, 0.09969044, 0.09333061,
|
|
51
|
+
0.0874, 0.08190096, 0.07680428, 0.07207712, 0.06768664, 0.0636, 0.05980685, 0.05628216, 0.05297104, 0.04981861,
|
|
52
|
+
0.04677, 0.04378405, 0.04087536, 0.03807264, 0.03540461, 0.0329, 0.03056419, 0.02838056, 0.02634484, 0.02445275,
|
|
53
|
+
0.0227, 0.02108429, 0.01959988, 0.01823732, 0.01698717, 0.01584, 0.01479064, 0.01383132, 0.01294868, 0.0121292,
|
|
54
|
+
0.01135916, 0.01062935, 0.009938846, 0.009288422, 0.008678854, 0.008110916, 0.007582388, 0.007088746, 0.006627313, 0.006195408,
|
|
55
|
+
0.005790346, 0.005409826, 0.005052583, 0.004717512, 0.004403507, 0.004109457, 0.003833913, 0.003575748, 0.003334342, 0.003109075,
|
|
56
|
+
0.002899327, 0.002704348, 0.00252302, 0.002354168, 0.002196616, 0.00204919, 0.00191096, 0.001781438, 0.00166011, 0.001546459,
|
|
57
|
+
0.001439971, 0.001340042, 0.001246275, 0.001158471, 0.00107643, 0.000999949, 0.000928736, 0.000862433, 0.00080075, 0.000743396,
|
|
58
|
+
0.000690079, 0.000640516, 0.000594502, 0.000551865, 0.000512429, 0.000476021, 0.000442454, 0.000411512, 0.000382981, 0.000356649,
|
|
59
|
+
0.000332301, 0.000309759, 0.000288887, 0.000269539, 0.000251568, 0.000234826, 0.000219171, 0.000204526, 0.000190841, 0.000178065,
|
|
60
|
+
0.000166151, 0.000155024, 0.000144622, 0.00013491, 0.000125852, 0.000117413, 0.000109552, 0.000102225, 9.53945E-05, 8.90239E-05,
|
|
61
|
+
8.30753E-05, 7.75127E-05, 7.2313E-05, 6.74578E-05, 6.29284E-05, 5.87065E-05, 5.47703E-05, 5.10992E-05, 4.76765E-05, 4.44857E-05,
|
|
62
|
+
4.15099E-05, 3.87332E-05, 3.6142E-05, 3.37235E-05, 3.14649E-05, 2.93533E-05, 2.73757E-05, 2.55243E-05, 2.37938E-05, 2.21787E-05,
|
|
63
|
+
2.06738E-05, 1.92723E-05, 1.79664E-05, 1.67499E-05, 1.56165E-05, 1.45598E-05, 1.35739E-05, 1.26544E-05, 1.17972E-05, 1.09984E-05,
|
|
64
|
+
1.0254E-05, 9.55965E-06, 8.91204E-06, 8.30836E-06, 7.74577E-06, 7.22146E-06, 6.73248E-06, 6.27642E-06, 5.8513E-06, 5.45512E-06,
|
|
65
|
+
5.08587E-06, 4.74147E-06, 4.42024E-06, 4.12078E-06, 3.84172E-06, 3.58165E-06, 3.33913E-06, 3.11295E-06, 2.90212E-06, 2.70565E-06,
|
|
66
|
+
2.52253E-06, 2.35173E-06, 2.19242E-06, 2.0439E-06, 1.9055E-06, 1.77651E-06, 1.65622E-06, 1.54402E-06, 1.43944E-06, 1.34198E-06,
|
|
67
|
+
1.25114E-06,
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
const Y_BAR = new Float32Array([
|
|
71
|
+
0.000003917, 4.39358E-06, 4.9296E-06, 5.53214E-06, 6.20825E-06, 0.000006965, 7.81322E-06, 8.76734E-06, 9.83984E-06, 1.10432E-05,
|
|
72
|
+
0.00001239, 1.38864E-05, 1.55573E-05, 1.7443E-05, 1.95838E-05, 0.00002202, 2.48397E-05, 2.80413E-05, 3.1531E-05, 3.52152E-05,
|
|
73
|
+
0.000039, 4.28264E-05, 4.69146E-05, 5.15896E-05, 5.71764E-05, 0.000064, 7.23442E-05, 8.22122E-05, 9.35082E-05, 0.000106136,
|
|
74
|
+
0.00012, 0.000134984, 0.000151492, 0.000170208, 0.000191816, 0.000217, 0.000246907, 0.00028124, 0.00031852, 0.000357267,
|
|
75
|
+
0.000396, 0.000433715, 0.000473024, 0.000517876, 0.000572219, 0.00064, 0.00072456, 0.0008255, 0.00094116, 0.00106988,
|
|
76
|
+
0.00121, 0.001362091, 0.001530752, 0.001720368, 0.001935323, 0.00218, 0.0024548, 0.002764, 0.0031178, 0.0035264,
|
|
77
|
+
0.004, 0.00454624, 0.00515932, 0.00582928, 0.00654616, 0.0073, 0.008086507, 0.00890872, 0.00976768, 0.01066443,
|
|
78
|
+
0.0116, 0.01257317, 0.01358272, 0.01462968, 0.01571509, 0.01684, 0.01800736, 0.01921448, 0.02045392, 0.02171824,
|
|
79
|
+
0.023, 0.02429461, 0.02561024, 0.02695857, 0.02835125, 0.0298, 0.03131083, 0.03288368, 0.03452112, 0.03622571,
|
|
80
|
+
0.038, 0.03984667, 0.041768, 0.043766, 0.04584267, 0.048, 0.05024368, 0.05257304, 0.05498056, 0.05745872,
|
|
81
|
+
0.06, 0.06260197, 0.06527752, 0.06804208, 0.07091109, 0.0739, 0.077016, 0.0802664, 0.0836668, 0.0872328,
|
|
82
|
+
0.09098, 0.09491755, 0.09904584, 0.1033674, 0.1078846, 0.1126, 0.117532, 0.1226744, 0.1279928, 0.1334528,
|
|
83
|
+
0.13902, 0.1446764, 0.1504693, 0.1564619, 0.1627177, 0.1693, 0.1762431, 0.1835581, 0.1912735, 0.199418,
|
|
84
|
+
0.20802, 0.2171199, 0.2267345, 0.2368571, 0.2474812, 0.2586, 0.2701849, 0.2822939, 0.2950505, 0.308578,
|
|
85
|
+
0.323, 0.3384021, 0.3546858, 0.3716986, 0.3892875, 0.4073, 0.4256299, 0.4443096, 0.4633944, 0.4829395,
|
|
86
|
+
0.503, 0.5235693, 0.544512, 0.56569, 0.5869653, 0.6082, 0.6293456, 0.6503068, 0.6708752, 0.6908424,
|
|
87
|
+
0.71, 0.7281852, 0.7454636, 0.7619694, 0.7778368, 0.7932, 0.8081104, 0.8224962, 0.8363068, 0.8494916,
|
|
88
|
+
0.862, 0.8738108, 0.8849624, 0.8954936, 0.9054432, 0.9148501, 0.9237348, 0.9320924, 0.9399226, 0.9472252,
|
|
89
|
+
0.954, 0.9602561, 0.9660074, 0.9712606, 0.9760225, 0.9803, 0.9840924, 0.9874182, 0.9903128, 0.9928116,
|
|
90
|
+
0.9949501, 0.9967108, 0.9980983, 0.999112, 0.9997482, 1, 0.9998567, 0.9993046, 0.9983255, 0.9968987,
|
|
91
|
+
0.995, 0.9926005, 0.9897426, 0.9864444, 0.9827241, 0.9786, 0.9740837, 0.9691712, 0.9638568, 0.9581349,
|
|
92
|
+
0.952, 0.9454504, 0.9384992, 0.9311628, 0.9234576, 0.9154, 0.9070064, 0.8982772, 0.8892048, 0.8797816,
|
|
93
|
+
0.87, 0.8598613, 0.849392, 0.838622, 0.8275813, 0.8163, 0.8047947, 0.793082, 0.781192, 0.7691547,
|
|
94
|
+
0.757, 0.7447541, 0.7324224, 0.7200036, 0.7074965, 0.6949, 0.6822192, 0.6694716, 0.6566744, 0.6438448,
|
|
95
|
+
0.631, 0.6181555, 0.6053144, 0.5924756, 0.5796379, 0.5668, 0.5539611, 0.5411372, 0.5283528, 0.5156323,
|
|
96
|
+
0.503, 0.4904688, 0.4780304, 0.4656776, 0.4534032, 0.4412, 0.42908, 0.417036, 0.405032, 0.393032,
|
|
97
|
+
0.381, 0.3689184, 0.3568272, 0.3447768, 0.3328176, 0.321, 0.3093381, 0.2978504, 0.2865936, 0.2756245,
|
|
98
|
+
0.265, 0.2547632, 0.2448896, 0.2353344, 0.2260528, 0.217, 0.2081616, 0.1995488, 0.1911552, 0.1829744,
|
|
99
|
+
0.175, 0.1672235, 0.1596464, 0.1522776, 0.1451259, 0.1382, 0.1315003, 0.1250248, 0.1187792, 0.1127691,
|
|
100
|
+
0.107, 0.1014762, 0.09618864, 0.09112296, 0.08626485, 0.0816, 0.07712064, 0.07282552, 0.06871008, 0.06476976,
|
|
101
|
+
0.061, 0.05739621, 0.05395504, 0.05067376, 0.04754965, 0.04458, 0.04175872, 0.03908496, 0.03656384, 0.03420048,
|
|
102
|
+
0.032, 0.02996261, 0.02807664, 0.02632936, 0.02470805, 0.0232, 0.02180077, 0.02050112, 0.01928108, 0.01812069,
|
|
103
|
+
0.017, 0.01590379, 0.01483718, 0.01381068, 0.01283478, 0.01192, 0.01106831, 0.01027339, 0.009533311, 0.008846157,
|
|
104
|
+
0.00821, 0.007623781, 0.007085424, 0.006591476, 0.006138485, 0.005723, 0.005343059, 0.004995796, 0.004676404, 0.004380075,
|
|
105
|
+
0.004102, 0.003838453, 0.003589099, 0.003354219, 0.003134093, 0.002929, 0.002738139, 0.002559876, 0.002393244, 0.002237275,
|
|
106
|
+
0.002091, 0.001953587, 0.00182458, 0.00170358, 0.001590187, 0.001484, 0.001384496, 0.001291268, 0.001204092, 0.001122744,
|
|
107
|
+
0.001047, 0.00097659, 0.000911109, 0.000850133, 0.000793238, 0.00074, 0.000690083, 0.00064331, 0.000599496, 0.000558455,
|
|
108
|
+
0.00052, 0.000483914, 0.000450053, 0.000418345, 0.000388718, 0.0003611, 0.000335384, 0.00031144, 0.000289166, 0.000268454,
|
|
109
|
+
0.0002492, 0.000231302, 0.000214686, 0.000199288, 0.000185048, 0.0001719, 0.000159778, 0.000148604, 0.000138302, 0.000128793,
|
|
110
|
+
0.00012, 0.00011186, 0.000104322, 9.73356E-05, 9.08459E-05, 0.0000848, 7.91467E-05, 0.000073858, 0.000068916, 6.43027E-05,
|
|
111
|
+
0.00006, 5.59819E-05, 5.22256E-05, 4.87184E-05, 4.54475E-05, 0.0000424, 3.9561E-05, 3.69151E-05, 3.44487E-05, 3.21482E-05,
|
|
112
|
+
0.00003, 2.79913E-05, 2.61136E-05, 2.43602E-05, 2.27246E-05, 0.0000212, 1.97786E-05, 1.84529E-05, 1.72169E-05, 1.60646E-05,
|
|
113
|
+
0.00001499, 1.39873E-05, 1.30516E-05, 1.21782E-05, 1.13625E-05, 0.0000106, 9.88588E-06, 9.2173E-06, 8.59236E-06, 8.00913E-06,
|
|
114
|
+
7.4657E-06, 6.95957E-06, 6.488E-06, 6.0487E-06, 5.6394E-06, 5.2578E-06, 4.90177E-06, 4.56972E-06, 4.26019E-06, 3.97174E-06,
|
|
115
|
+
3.7029E-06, 3.45216E-06, 3.2183E-06, 3.0003E-06, 2.79714E-06, 2.6078E-06, 2.43122E-06, 2.26653E-06, 2.11301E-06, 1.96994E-06,
|
|
116
|
+
1.8366E-06, 1.71223E-06, 1.59623E-06, 1.48809E-06, 1.38731E-06, 1.2934E-06, 1.20582E-06, 1.12414E-06, 1.04801E-06, 9.77058E-07,
|
|
117
|
+
9.1093E-07, 8.49251E-07, 7.91721E-07, 7.3809E-07, 6.8811E-07, 6.4153E-07, 5.9809E-07, 5.57575E-07, 5.19808E-07, 4.84612E-07,
|
|
118
|
+
4.5181E-07,
|
|
119
|
+
]);
|
|
120
|
+
|
|
121
|
+
const Z_BAR = new Float32Array([
|
|
122
|
+
0.0006061, 0.000680879, 0.000765146, 0.000860012, 0.000966593, 0.001086, 0.001220586, 0.001372729, 0.001543579, 0.001734286,
|
|
123
|
+
0.001946, 0.002177777, 0.002435809, 0.002731953, 0.003078064, 0.003486, 0.003975227, 0.00454088, 0.00515832, 0.005802907,
|
|
124
|
+
0.006450001, 0.007083216, 0.007745488, 0.008501152, 0.009414544, 0.01054999, 0.0119658, 0.01365587, 0.01558805, 0.01773015,
|
|
125
|
+
0.02005001, 0.02251136, 0.02520288, 0.02827972, 0.03189704, 0.03621, 0.04143771, 0.04750372, 0.05411988, 0.06099803,
|
|
126
|
+
0.06785001, 0.07448632, 0.08136156, 0.08915364, 0.09854048, 0.1102, 0.1246133, 0.1417017, 0.1613035, 0.1832568,
|
|
127
|
+
0.2074, 0.2336921, 0.2626114, 0.2947746, 0.3307985, 0.3713, 0.4162091, 0.4654642, 0.5196948, 0.5795303,
|
|
128
|
+
0.6456, 0.7184838, 0.7967133, 0.8778459, 0.959439, 1.0390501, 1.1153673, 1.1884971, 1.2581233, 1.3239296,
|
|
129
|
+
1.3856, 1.4426352, 1.4948035, 1.5421903, 1.5848807, 1.62296, 1.6564048, 1.6852959, 1.7098745, 1.7303821,
|
|
130
|
+
1.74706, 1.7600446, 1.7696233, 1.7762637, 1.7804334, 1.7826, 1.7829682, 1.7816998, 1.7791982, 1.7758671,
|
|
131
|
+
1.77211, 1.7682589, 1.764039, 1.7589438, 1.7524663, 1.7441, 1.7335595, 1.7208581, 1.7059369, 1.6887372,
|
|
132
|
+
1.6692, 1.6475287, 1.6234127, 1.5960223, 1.564528, 1.5281, 1.4861114, 1.4395215, 1.3898799, 1.3387362,
|
|
133
|
+
1.28764, 1.2374223, 1.1878243, 1.1387611, 1.090148, 1.0419, 0.9941976, 0.9473473, 0.9014531, 0.8566193,
|
|
134
|
+
0.8129501, 0.7705173, 0.7294448, 0.6899136, 0.6521049, 0.6162, 0.5823286, 0.5504162, 0.5203376, 0.4919673,
|
|
135
|
+
0.46518, 0.4399246, 0.4161836, 0.3938822, 0.3729459, 0.3533, 0.3348578, 0.3175521, 0.3013375, 0.2861686,
|
|
136
|
+
0.272, 0.2588171, 0.2464838, 0.2347718, 0.2234533, 0.2123, 0.2011692, 0.1901196, 0.1792254, 0.1685608,
|
|
137
|
+
0.1582, 0.1481383, 0.1383758, 0.1289942, 0.1200751, 0.1117, 0.1039048, 0.09666748, 0.08998272, 0.08384531,
|
|
138
|
+
0.07824999, 0.07320899, 0.06867816, 0.06456784, 0.06078835, 0.05725001, 0.05390435, 0.05074664, 0.04775276, 0.04489859,
|
|
139
|
+
0.04216, 0.03950728, 0.03693564, 0.03445836, 0.03208872, 0.02984, 0.02771181, 0.02569444, 0.02378716, 0.02198925,
|
|
140
|
+
0.0203, 0.01871805, 0.01724036, 0.01586364, 0.01458461, 0.0134, 0.01230723, 0.01130188, 0.01037792, 0.009529306,
|
|
141
|
+
0.008749999, 0.0080352, 0.0073816, 0.0067854, 0.0062428, 0.005749999, 0.0053036, 0.0048998, 0.0045342, 0.0042024,
|
|
142
|
+
0.0039, 0.0036232, 0.0033706, 0.0031414, 0.0029348, 0.002749999, 0.0025852, 0.0024386, 0.0023094, 0.0021968,
|
|
143
|
+
0.0021, 0.002017733, 0.0019482, 0.0018898, 0.001840933, 0.0018, 0.001766267, 0.0017378, 0.0017112, 0.001683067,
|
|
144
|
+
0.001650001, 0.001610133, 0.0015644, 0.0015136, 0.001458533, 0.0014, 0.001336667, 0.00127, 0.001205, 0.001146667,
|
|
145
|
+
0.0011, 0.0010688, 0.0010494, 0.0010356, 0.0010212, 0.001, 0.00096864, 0.00092992, 0.00088688, 0.00084256,
|
|
146
|
+
0.0008, 0.00076096, 0.00072368, 0.00068592, 0.00064544, 0.0006, 0.000547867, 0.0004916, 0.0004354, 0.000383467,
|
|
147
|
+
0.00034, 0.000307253, 0.00028316, 0.00026544, 0.000251813, 0.00024, 0.000229547, 0.00022064, 0.00021196, 0.000202187,
|
|
148
|
+
0.00019, 0.000174213, 0.00015564, 0.00013596, 0.000116853, 0.0001, 8.61333E-05, 0.0000746, 0.000065, 5.69333E-05,
|
|
149
|
+
5E-05, 0.00004416, 0.00003948, 0.00003572, 0.00003264, 0.00003, 2.76533E-05, 0.00002556, 0.00002364, 2.18133E-05,
|
|
150
|
+
0.00002, 1.81333E-05, 0.0000162, 0.0000142, 1.21333E-05, 0.00001, 7.73333E-06, 0.0000054, 0.0000032, 1.33333E-06,
|
|
151
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
152
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
153
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
154
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
155
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
156
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
157
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
158
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
159
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
160
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
161
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
162
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
163
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
164
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
165
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
166
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
167
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
168
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Linear-interpolated CIE 1931 2° CMFs at the given wavelength.
|
|
173
|
+
* Returns 0 outside [360, 830] nm.
|
|
174
|
+
*
|
|
175
|
+
* @param {number[]} out length>=3
|
|
176
|
+
* @param {number} wavelength_nm wavelength in nanometers
|
|
177
|
+
* @returns {number[]} out
|
|
178
|
+
*/
|
|
179
|
+
export function xyz_cmf_tabulated(out, wavelength_nm) {
|
|
180
|
+
if (wavelength_nm <= XYZ_CMF_MIN_NM || wavelength_nm >= XYZ_CMF_MAX_NM) {
|
|
181
|
+
if (wavelength_nm === XYZ_CMF_MIN_NM) {
|
|
182
|
+
out[0] = X_BAR[0];
|
|
183
|
+
out[1] = Y_BAR[0];
|
|
184
|
+
out[2] = Z_BAR[0];
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
if (wavelength_nm === XYZ_CMF_MAX_NM) {
|
|
188
|
+
const last = X_BAR.length - 1;
|
|
189
|
+
out[0] = X_BAR[last];
|
|
190
|
+
out[1] = Y_BAR[last];
|
|
191
|
+
out[2] = Z_BAR[last];
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
out[0] = 0; out[1] = 0; out[2] = 0; return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const w = wavelength_nm;
|
|
198
|
+
const i0 = Math.floor(w) - XYZ_CMF_MIN_NM; // index for integer nm below w
|
|
199
|
+
const frac = w - Math.floor(w);
|
|
200
|
+
|
|
201
|
+
const x0 = X_BAR[i0];
|
|
202
|
+
const x1 = X_BAR[i0 + 1];
|
|
203
|
+
const y0 = Y_BAR[i0];
|
|
204
|
+
const y1 = Y_BAR[i0 + 1];
|
|
205
|
+
const z0 = Z_BAR[i0];
|
|
206
|
+
const z1 = Z_BAR[i0 + 1];
|
|
207
|
+
|
|
208
|
+
out[0] = lerp(x0, x1, frac);
|
|
209
|
+
out[1] = lerp(y0, y1, frac);
|
|
210
|
+
out[2] = lerp(z0, z1, frac);
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color-Matching Function in CIE XYZ space.
|
|
3
|
+
*
|
|
4
|
+
* Compute CIE 1931 2° x̄(λ), ȳ(λ), z̄(λ) using Wyman et al. analytic fits.
|
|
5
|
+
*
|
|
6
|
+
* This is the "multi-lobe" fit. The absolute error magnitude is under 0.05 across the spectrum according to the paper.
|
|
7
|
+
*
|
|
8
|
+
* @param {number[]} out length>=3
|
|
9
|
+
* @param {number} wavelength_nm wavelength in nanometers
|
|
10
|
+
* @returns {number[]} out
|
|
11
|
+
*/
|
|
12
|
+
export function xyz_cmf_wyman(out: number[], wavelength_nm: number): number[];
|
|
13
|
+
//# sourceMappingURL=xyz_cmf_wyman.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xyz_cmf_wyman.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/xyz_cmf_wyman.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,mCAJW,MAAM,EAAE,iBACR,MAAM,GACJ,MAAM,EAAE,CAqCpB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CIE 1931 2° XYZ color matching functions (analytic approximation)
|
|
3
|
+
*
|
|
4
|
+
* Implementation based on:
|
|
5
|
+
* Wyman, Sloan, Shirley (2013), "Simple Analytic Approximations to the CIE 1931 XYZ Color Matching Functions"
|
|
6
|
+
* JCGT 2(2), 2013. http://jcgt.org/published/0002/02/01/
|
|
7
|
+
*
|
|
8
|
+
* Valid primarily over 380–780 nm. Outside this range, the functions return 0.
|
|
9
|
+
* Returns unweighted CMFs (no illuminant). Weighting by illuminant SPD (e.g., D65)
|
|
10
|
+
* should be applied by the caller during spectral integration when needed.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Helper for asymmetric Gaussian term from Wyman et al.
|
|
14
|
+
function gaussAsym(w, w0, sigmaL, sigmaR) {
|
|
15
|
+
const t = (w - w0) * (w < w0 ? sigmaL : sigmaR);
|
|
16
|
+
return Math.exp(-0.5 * t * t);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Color-Matching Function in CIE XYZ space.
|
|
21
|
+
*
|
|
22
|
+
* Compute CIE 1931 2° x̄(λ), ȳ(λ), z̄(λ) using Wyman et al. analytic fits.
|
|
23
|
+
*
|
|
24
|
+
* This is the "multi-lobe" fit. The absolute error magnitude is under 0.05 across the spectrum according to the paper.
|
|
25
|
+
*
|
|
26
|
+
* @param {number[]} out length>=3
|
|
27
|
+
* @param {number} wavelength_nm wavelength in nanometers
|
|
28
|
+
* @returns {number[]} out
|
|
29
|
+
*/
|
|
30
|
+
export function xyz_cmf_wyman(out, wavelength_nm) {
|
|
31
|
+
const w = wavelength_nm;
|
|
32
|
+
|
|
33
|
+
// Return zeros outside the modeled range
|
|
34
|
+
if (w < 380 || w > 780) {
|
|
35
|
+
|
|
36
|
+
out[0] = 0;
|
|
37
|
+
out[1] = 0;
|
|
38
|
+
out[2] = 0;
|
|
39
|
+
|
|
40
|
+
return out;
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// x̄(λ)
|
|
45
|
+
const x =
|
|
46
|
+
+ 0.362 * gaussAsym(w, 442.0, 0.0624, 0.0374)
|
|
47
|
+
+ 1.056 * gaussAsym(w, 599.8, 0.0264, 0.0323)
|
|
48
|
+
- 0.065 * gaussAsym(w, 501.1, 0.0490, 0.0382);
|
|
49
|
+
|
|
50
|
+
// ȳ(λ)
|
|
51
|
+
const y =
|
|
52
|
+
+ 0.821 * gaussAsym(w, 568.8, 0.0213, 0.0247)
|
|
53
|
+
+ 0.286 * gaussAsym(w, 530.9, 0.0613, 0.0322);
|
|
54
|
+
|
|
55
|
+
// z̄(λ)
|
|
56
|
+
const z =
|
|
57
|
+
+ 1.217 * gaussAsym(w, 437.0, 0.0845, 0.0278)
|
|
58
|
+
+ 0.681 * gaussAsym(w, 459.0, 0.0385, 0.0725);
|
|
59
|
+
|
|
60
|
+
out[0] = x;
|
|
61
|
+
out[1] = y;
|
|
62
|
+
out[2] = z;
|
|
63
|
+
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* CIE color model to linear RGB
|
|
3
3
|
* Assumes D65 standard illuminant
|
|
4
4
|
* @see https://www.image-engineering.de/library/technotes/958-how-to-convert-between-srgb-and-ciexyz
|
|
5
|
-
* @param {vec3} out
|
|
6
|
-
* @param {vec3} input
|
|
5
|
+
* @param {vec3|number[]|Float32Array} out
|
|
6
|
+
* @param {vec3|number[]|Float32Array} input
|
|
7
7
|
*/
|
|
8
|
-
export function xyz_to_rgb(out: vec3, input: vec3): void;
|
|
8
|
+
export function xyz_to_rgb(out: vec3 | number[] | Float32Array, input: vec3 | number[] | Float32Array): void;
|
|
9
9
|
//# sourceMappingURL=xyz_to_rgb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xyz_to_rgb.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/xyz_to_rgb.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"xyz_to_rgb.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/xyz_to_rgb.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,gCAHW,OAAK,MAAM,EAAE,GAAC,YAAY,SAC1B,OAAK,MAAM,EAAE,GAAC,YAAY,QAUpC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* CIE color model to linear RGB
|
|
3
3
|
* Assumes D65 standard illuminant
|
|
4
4
|
* @see https://www.image-engineering.de/library/technotes/958-how-to-convert-between-srgb-and-ciexyz
|
|
5
|
-
* @param {vec3} out
|
|
6
|
-
* @param {vec3} input
|
|
5
|
+
* @param {vec3|number[]|Float32Array} out
|
|
6
|
+
* @param {vec3|number[]|Float32Array} input
|
|
7
7
|
*/
|
|
8
8
|
export function xyz_to_rgb(out, input) {
|
|
9
9
|
const x = input[0];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex_add.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/complex/complex_add.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oCAJW,MAAM,EAAE,KACR,MAAM,EAAE,KACR,MAAM,EAAE,QAKlB"}
|