@woosh/meep-engine 2.131.13 → 2.131.16
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/README.md +2 -2
- package/package.json +1 -1
- package/src/core/codegen/LineBuilder.d.ts +4 -2
- package/src/core/codegen/LineBuilder.d.ts.map +1 -1
- package/src/core/codegen/LineBuilder.js +5 -2
- package/src/core/color/YCbCr/YCbCr_to_rgb_uint24.d.ts +6 -5
- package/src/core/color/YCbCr/YCbCr_to_rgb_uint24.d.ts.map +1 -1
- package/src/core/color/YCbCr/YCbCr_to_rgb_uint24.js +19 -13
- package/src/core/color/YCbCr/rgb_to_YCbCr_uint24.d.ts +6 -5
- package/src/core/color/YCbCr/rgb_to_YCbCr_uint24.d.ts.map +1 -1
- package/src/core/color/YCbCr/rgb_to_YCbCr_uint24.js +18 -10
- package/src/core/color/illuminant/D65_spd_analytical.d.ts.map +1 -1
- package/src/core/color/illuminant/D65_spd_analytical.js +1 -25
- package/src/core/color/illuminant/planckian_radiance.d.ts +8 -0
- package/src/core/color/illuminant/planckian_radiance.d.ts.map +1 -0
- package/src/core/color/illuminant/planckian_radiance.js +33 -0
- package/src/core/color/kelvin/kelvin_to_rgb.d.ts +8 -4
- package/src/core/color/kelvin/kelvin_to_rgb.d.ts.map +1 -1
- package/src/core/color/kelvin/kelvin_to_rgb.js +9 -4
- package/src/core/color/rgb_to_luminance.d.ts +7 -4
- package/src/core/color/rgb_to_luminance.d.ts.map +1 -1
- package/src/core/color/rgb_to_luminance.js +8 -5
- package/src/core/color/sRGB/linear_to_sRGB.d.ts +6 -1
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +5 -0
- package/src/core/color/sRGB/sRGB_to_linear.d.ts +3 -2
- package/src/core/color/sRGB/sRGB_to_linear.d.ts.map +1 -1
- package/src/core/color/sRGB/sRGB_to_linear.js +2 -1
- package/src/core/color/xyz/xyz_cmf_tabulated.d.ts.map +1 -1
- package/src/core/color/xyz/xyz_cmf_tabulated.js +174 -175
- package/src/core/math/frexp.d.ts.map +1 -1
- package/src/core/math/frexp.js +1 -0
- package/src/core/model/node-graph/visual/NodeDescriptionVisualRegistry.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/NodeDescriptionVisualRegistry.js +5 -7
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +10 -12
- package/src/core/model/node-graph/visual/NodeVisualData.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/NodeVisualData.js +16 -17
- package/src/core/model/node-graph/visual/PortVisualData.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/PortVisualData.js +7 -9
- package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.d.ts +2 -1
- package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/BoxLayoutSpec.js +14 -14
- package/src/core/model/node-graph/visual/layout/ConnectedBoxLayouter.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/ConnectedBoxLayouter.js +21 -23
- package/src/core/model/node-graph/visual/layout/ConnectionEndpointLayoutSpec.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/ConnectionEndpointLayoutSpec.js +10 -12
- package/src/core/model/node-graph/visual/layout/ConnectionLayoutSpec.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/layout/ConnectionLayoutSpec.js +10 -14
- package/src/engine/asset/preloader/AssetPreloader.d.ts +1 -1
- package/src/engine/asset/preloader/AssetPreloader.d.ts.map +1 -1
- package/src/engine/asset/preloader/AssetPreloader.js +22 -24
- package/src/engine/ecs/storage/BinaryBufferDeSerializer.js +1 -1
- package/src/engine/graphics/particles/node-based/codegen/CodeContext.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/codegen/CodeContext.js +7 -10
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionModule.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionModule.js +30 -32
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionModuleReference.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionModuleReference.js +10 -12
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionModuleRegistry.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionModuleRegistry.js +5 -8
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionParameterSpecification.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionParameterSpecification.js +10 -12
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/codegen/modules/FunctionSignature.js +11 -13
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeBinding.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeBinding.js +12 -12
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts +8 -18
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/particle/ParticleAttributeSpecification.js +9 -11
- package/src/engine/graphics/particles/node-based/particle/ParticleSpecification.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/particle/ParticleSpecification.js +34 -36
- package/src/engine/graphics/particles/node-based/rendering/ParticleRenderCommand.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/rendering/ParticleRenderCommand.js +10 -12
- package/src/engine/graphics/particles/node-based/rendering/ParticleRenderSpecification.d.ts.map +1 -1
- package/src/engine/graphics/particles/node-based/rendering/ParticleRenderSpecification.js +6 -8
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +123 -124
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +32 -30
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.d.ts +7 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js +6 -6
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.js +5 -9
- package/src/engine/graphics/particles/particular/engine/parameter/ParticleParameter.d.ts +10 -10
- package/src/engine/graphics/particles/particular/engine/parameter/ParticleParameter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParticleParameter.js +36 -29
- package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.js +29 -33
- package/src/view/View.d.ts.map +1 -1
- package/src/view/View.js +4 -6
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleRenderProfile.d.ts +0 -14
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleRenderProfile.d.ts.map +0 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleRenderProfile.js +0 -18
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleRendererType.d.ts +0 -8
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleRendererType.d.ts.map +0 -1
- package/src/engine/graphics/particles/particular/engine/emitter/ParticleRendererType.js +0 -10
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterSheet.d.ts +0 -38
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterSheet.d.ts.map +0 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterSheet.js +0 -278
package/README.md
CHANGED
|
@@ -14,13 +14,13 @@ To help get you started, various samples are provided under `/samples` folder. F
|
|
|
14
14
|
## Quality
|
|
15
15
|
|
|
16
16
|
### Testing
|
|
17
|
-
Meep is covered by 2,
|
|
17
|
+
Meep is covered by 2,944 handwritten unit tests, reaching 90%+ coverage in `core` and 40%+ coverage total.
|
|
18
18
|
|
|
19
19
|
The aim is to [ensure quality](https://about.codecov.io/blog/the-case-against-100-code-coverage/). As a result, the tests are written to cover complex code first and to exhaustively validate critical algorithms.
|
|
20
20
|
Most of the test code is significantly larger than the code that is being tested.
|
|
21
21
|
|
|
22
22
|
### Assertions
|
|
23
|
-
Meep is covered by 3,
|
|
23
|
+
Meep is covered by 3,968 asserts. [Assertions](https://en.wikipedia.org/wiki/Assertion_(software_development)) provide very extensive pre- and post-condition checks throughout the engine.
|
|
24
24
|
Asserts are intended primarily for development builds.
|
|
25
25
|
To remove asserts in Vite builds, you can use `@rollup/plugin-strip` package like so:
|
|
26
26
|
|
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.131.
|
|
8
|
+
"version": "2.131.16",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default LineBuilder;
|
|
2
2
|
/**
|
|
3
3
|
* Useful for generating formatted snippets of code.
|
|
4
|
+
*
|
|
4
5
|
* @example
|
|
5
6
|
* const b = new LineBuilder();
|
|
6
7
|
* b.add("function hello(){");
|
|
@@ -38,9 +39,10 @@ declare class LineBuilder {
|
|
|
38
39
|
*/
|
|
39
40
|
get count(): number;
|
|
40
41
|
/**
|
|
41
|
-
* Substring test
|
|
42
|
-
*
|
|
42
|
+
* Substring test on a per-line basis.
|
|
43
|
+
* A match can only span a single line, so multi-line matches will not be found.
|
|
43
44
|
* @param {string} term
|
|
45
|
+
* @return {boolean} true if the term was found at least once, false otherwise
|
|
44
46
|
*/
|
|
45
47
|
containsSubstring(term: string): boolean;
|
|
46
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/LineBuilder.js"],"names":[],"mappings":";AAgCA
|
|
1
|
+
{"version":3,"file":"LineBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/LineBuilder.js"],"names":[],"mappings":";AAgCA;;;;;;;;;;;;;;GAcG;AACH;IAoLI;;;;OAIG;IACH,sBAJW,MAAM,mBACN,MAAM,GACJ,WAAW,CAuBvB;IAhMD;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,qBAAqC;IAErC;;;OAGG;IACH,oBAEC;IAED;;;;;OAKG;IACH,wBAHW,MAAM,GACL,OAAO,CAoBlB;IAED;;;OAGG;IACH,UAFa,WAAW,CAKvB;IAED;;;OAGG;IACH,UAFa,WAAW,CAQvB;IAED;;;;;OAKG;IACH,eAHW,MAAM,GACJ,WAAW,CASvB;IAED;;;;;;;;;;;OAWG;IACH,aATW,MAAM,GACJ,IAAI,CAmBhB;IAED;;;OAGG;IACH,gBAFW,WAAW,QAiBrB;IAED,cAGC;IAED;;;OAGG;IACH,SAFa,MAAM,CAyBlB;IA8BD,mBAEC;;CACJ"}
|
|
@@ -32,6 +32,7 @@ const DEFAULT_INDENT_SPACES = 4;
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Useful for generating formatted snippets of code.
|
|
35
|
+
*
|
|
35
36
|
* @example
|
|
36
37
|
* const b = new LineBuilder();
|
|
37
38
|
* b.add("function hello(){");
|
|
@@ -83,9 +84,10 @@ class LineBuilder {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
/**
|
|
86
|
-
* Substring test
|
|
87
|
-
*
|
|
87
|
+
* Substring test on a per-line basis.
|
|
88
|
+
* A match can only span a single line, so multi-line matches will not be found.
|
|
88
89
|
* @param {string} term
|
|
90
|
+
* @return {boolean} true if the term was found at least once, false otherwise
|
|
89
91
|
*/
|
|
90
92
|
containsSubstring(term) {
|
|
91
93
|
assert.isString(term, 'term');
|
|
@@ -99,6 +101,7 @@ class LineBuilder {
|
|
|
99
101
|
const termIndex = line.text.indexOf(term);
|
|
100
102
|
|
|
101
103
|
if (termIndex !== -1) {
|
|
104
|
+
// match
|
|
102
105
|
return true;
|
|
103
106
|
}
|
|
104
107
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param {number}
|
|
5
|
-
* @param {number}
|
|
6
|
-
* @
|
|
2
|
+
* Converts YCbCr (Rec. 709) to RGB.
|
|
3
|
+
*
|
|
4
|
+
* @param {number} Y Luma (0-255)
|
|
5
|
+
* @param {number} Cb Blue Difference (0-255)
|
|
6
|
+
* @param {number} Cr Red Difference (0-255)
|
|
7
|
+
* @returns {number} packed 24-bit integer: 0xRRGGBB
|
|
7
8
|
*/
|
|
8
9
|
export function YCbCr_to_rgb_uint24(Y: number, Cb: number, Cr: number): number;
|
|
9
10
|
//# sourceMappingURL=YCbCr_to_rgb_uint24.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YCbCr_to_rgb_uint24.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/YCbCr/YCbCr_to_rgb_uint24.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"YCbCr_to_rgb_uint24.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/YCbCr/YCbCr_to_rgb_uint24.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,uCALW,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAgBlB"}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
+
import { clamp } from "../../math/clamp.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param {number}
|
|
5
|
-
* @param {number}
|
|
6
|
-
* @
|
|
4
|
+
* Converts YCbCr (Rec. 709) to RGB.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} Y Luma (0-255)
|
|
7
|
+
* @param {number} Cb Blue Difference (0-255)
|
|
8
|
+
* @param {number} Cr Red Difference (0-255)
|
|
9
|
+
* @returns {number} packed 24-bit integer: 0xRRGGBB
|
|
7
10
|
*/
|
|
8
11
|
export function YCbCr_to_rgb_uint24(Y, Cb, Cr) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
12
|
+
const C_red = Cr - 128;
|
|
13
|
+
const C_blue = Cb - 128;
|
|
14
|
+
|
|
15
|
+
// Rec. 709 Inverse Coefficients
|
|
16
|
+
// R = Y + 1.5748 * Cr
|
|
17
|
+
// G = Y - 0.1873 * Cb - 0.4681 * Cr
|
|
18
|
+
// B = Y + 1.8556 * Cb
|
|
11
19
|
|
|
12
|
-
const r = Y +
|
|
13
|
-
const g = Y -
|
|
14
|
-
const b = Y +
|
|
20
|
+
const r = clamp(Math.round(Y + 1.5748 * C_red), 0, 255);
|
|
21
|
+
const g = clamp(Math.round(Y - 0.1873 * C_blue - 0.4681 * C_red), 0, 255);
|
|
22
|
+
const b = clamp(Math.round(Y + 1.8556 * C_blue), 0, 255);
|
|
15
23
|
|
|
16
|
-
return ((r << 16)
|
|
17
|
-
| ((g << 8) & 0xFF00)
|
|
18
|
-
| (b & 0xFF);
|
|
24
|
+
return ((r << 16) | (g << 8) | b) >>> 0;
|
|
19
25
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Converts RGB to YCbCr (Rec. 709 / HDTV Full Range).
|
|
2
3
|
*
|
|
3
|
-
* @param r
|
|
4
|
-
* @param g
|
|
5
|
-
* @param b
|
|
6
|
-
* @return {number}
|
|
4
|
+
* @param {number} r Red (0-255)
|
|
5
|
+
* @param {number} g Green (0-255)
|
|
6
|
+
* @param {number} b Blue (0-255)
|
|
7
|
+
* @return {number} packed 24-bit integer: 0xYYCbCr
|
|
7
8
|
*/
|
|
8
|
-
export function rgb_to_YCbCr_uint24(r:
|
|
9
|
+
export function rgb_to_YCbCr_uint24(r: number, g: number, b: number): number;
|
|
9
10
|
//# sourceMappingURL=rgb_to_YCbCr_uint24.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rgb_to_YCbCr_uint24.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/YCbCr/rgb_to_YCbCr_uint24.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rgb_to_YCbCr_uint24.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/YCbCr/rgb_to_YCbCr_uint24.js"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,uCALW,MAAM,KACN,MAAM,KACN,MAAM,GACL,MAAM,CAcjB"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
|
+
import { clamp } from "../../math/clamp.js";
|
|
2
|
+
import { rgb_to_luminance } from "../rgb_to_luminance.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
5
|
+
* Converts RGB to YCbCr (Rec. 709 / HDTV Full Range).
|
|
2
6
|
*
|
|
3
|
-
* @param r
|
|
4
|
-
* @param g
|
|
5
|
-
* @param b
|
|
6
|
-
* @return {number}
|
|
7
|
+
* @param {number} r Red (0-255)
|
|
8
|
+
* @param {number} g Green (0-255)
|
|
9
|
+
* @param {number} b Blue (0-255)
|
|
10
|
+
* @return {number} packed 24-bit integer: 0xYYCbCr
|
|
7
11
|
*/
|
|
8
12
|
export function rgb_to_YCbCr_uint24(r, g, b) {
|
|
9
|
-
const Y =
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
const Y = clamp(Math.round(rgb_to_luminance(r,g,b)), 0, 255);
|
|
14
|
+
|
|
15
|
+
// Rec. 709 Chroma Coefficients
|
|
16
|
+
// Derived from: 0.5 / (1 - Kb) and 0.5 / (1 - Kr)
|
|
17
|
+
|
|
18
|
+
const Cb = clamp(Math.round(-0.1146 * r - 0.3854 * g + 0.5000 * b + 128), 0, 255);
|
|
19
|
+
const Cr = clamp(Math.round(0.5000 * r - 0.4542 * g - 0.0458 * b + 128), 0, 255);
|
|
12
20
|
|
|
13
|
-
return (
|
|
14
|
-
| (
|
|
15
|
-
| (Cr
|
|
21
|
+
return (Y << 16)
|
|
22
|
+
| (Cb << 8)
|
|
23
|
+
| (Cr);
|
|
16
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D65_spd_analytical.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/illuminant/D65_spd_analytical.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"D65_spd_analytical.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/illuminant/D65_spd_analytical.js"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AACH,kDAJW,MAAM,GACJ,MAAM,CAelB"}
|
|
@@ -9,33 +9,9 @@
|
|
|
9
9
|
* and is not a perfect blackbody. This function is the standard
|
|
10
10
|
* *physical approximation*.
|
|
11
11
|
*/
|
|
12
|
+
import { planckian_radiance } from "./planckian_radiance.js";
|
|
12
13
|
|
|
13
14
|
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
15
|
|
|
40
16
|
// Pre-calculate the normalization factor:
|
|
41
17
|
// This is the un-normalized value of the function at 560nm (560e-9 m),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the spectral radiance power of a black body for a given wavelength.
|
|
3
|
+
* @param {number} lambda_m Wavelength in meters
|
|
4
|
+
* @param {number} T Temperature in Kelvin
|
|
5
|
+
* @returns {number} Relative spectral power
|
|
6
|
+
*/
|
|
7
|
+
export function planckian_radiance(lambda_m: number, T: number): number;
|
|
8
|
+
//# sourceMappingURL=planckian_radiance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planckian_radiance.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/illuminant/planckian_radiance.js"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,6CAJW,MAAM,KACN,MAAM,GACJ,MAAM,CAmBlB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Second radiation constant (m·K)
|
|
3
|
+
*
|
|
4
|
+
* `c2 = (h*c) / (kb)`
|
|
5
|
+
*
|
|
6
|
+
* Value is meters Kelvin (m*K).
|
|
7
|
+
*/
|
|
8
|
+
const PLANCK_C2 = 1.438776877e-2;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Calculates the spectral radiance power of a black body for a given wavelength.
|
|
12
|
+
* @param {number} lambda_m Wavelength in meters
|
|
13
|
+
* @param {number} T Temperature in Kelvin
|
|
14
|
+
* @returns {number} Relative spectral power
|
|
15
|
+
*/
|
|
16
|
+
export function planckian_radiance(lambda_m, T) {
|
|
17
|
+
const lambda_T = lambda_m * T;
|
|
18
|
+
const exponent = PLANCK_C2 / lambda_T;
|
|
19
|
+
|
|
20
|
+
// Handle high exponents to prevent Math.exp from returning Infinity
|
|
21
|
+
if (exponent > 80.0) { // exp(80) = ~5.5e34
|
|
22
|
+
// this would pull denominator to extremely high values, effectively driving the result towards 0
|
|
23
|
+
return 0.0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const lambda_5 = Math.pow(lambda_m, 5);
|
|
27
|
+
|
|
28
|
+
// This can be simplified to just (1/lambda_5) because the
|
|
29
|
+
// rest of the numerator is a constant we are normalizing away.
|
|
30
|
+
const radiance = (1.0 / lambda_5) / (Math.exp(exponent) - 1.0);
|
|
31
|
+
|
|
32
|
+
return radiance;
|
|
33
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @
|
|
4
|
-
*
|
|
5
|
-
* @param {number[]} result RGB output
|
|
2
|
+
*
|
|
3
|
+
* Note: if you will need to covert the output to linear space ({@link sRGB_to_linear}) if you intend to perform any mixing on the color.
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} result RGB output The output is in non-linear (gamma corrected) space
|
|
6
6
|
* @param {number} result_offset
|
|
7
7
|
* @param {number} temperature in Kelvin
|
|
8
|
+
*
|
|
9
|
+
* @see https://www.zombieprototypes.com/?p=210
|
|
10
|
+
* @see https://tannerhelland.com/2012/09/18/convert-temperature-rgb-algorithm-code.html
|
|
11
|
+
* @see sRGB_to_linear
|
|
8
12
|
*/
|
|
9
13
|
export function kelvin_to_rgb(result: number[], result_offset: number, temperature: number): void;
|
|
10
14
|
//# sourceMappingURL=kelvin_to_rgb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kelvin_to_rgb.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/kelvin/kelvin_to_rgb.js"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"kelvin_to_rgb.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/kelvin/kelvin_to_rgb.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,sCARW,MAAM,EAAE,iBACR,MAAM,eACN,MAAM,QAuDhB"}
|
|
@@ -2,12 +2,16 @@ import { assert } from "../../assert.js";
|
|
|
2
2
|
import { clamp01 } from "../../math/clamp01.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
* @param {number[]} result RGB output
|
|
5
|
+
*
|
|
6
|
+
* Note: if you will need to covert the output to linear space ({@link sRGB_to_linear}) if you intend to perform any mixing on the color.
|
|
7
|
+
*
|
|
8
|
+
* @param {number[]} result RGB output The output is in non-linear (gamma corrected) space
|
|
9
9
|
* @param {number} result_offset
|
|
10
10
|
* @param {number} temperature in Kelvin
|
|
11
|
+
*
|
|
12
|
+
* @see https://www.zombieprototypes.com/?p=210
|
|
13
|
+
* @see https://tannerhelland.com/2012/09/18/convert-temperature-rgb-algorithm-code.html
|
|
14
|
+
* @see sRGB_to_linear
|
|
11
15
|
*/
|
|
12
16
|
export function kelvin_to_rgb(
|
|
13
17
|
result,
|
|
@@ -26,6 +30,7 @@ export function kelvin_to_rgb(
|
|
|
26
30
|
const t = temperature / 100;
|
|
27
31
|
|
|
28
32
|
if (t <= 66) {
|
|
33
|
+
|
|
29
34
|
r = 1;
|
|
30
35
|
|
|
31
36
|
g = clamp01(
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Calculates Luminance (perceived brightness) using modern Rec.709 coefficients.
|
|
2
3
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param {number}
|
|
6
|
-
* @
|
|
4
|
+
* Matches sRGB and HDTV standards.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} r Red component (linear or gamma-corrected)
|
|
7
|
+
* @param {number} g Green component (linear or gamma-corrected)
|
|
8
|
+
* @param {number} b Blue component (linear or gamma-corrected)
|
|
9
|
+
* @return {number} The calculated luma value
|
|
7
10
|
*/
|
|
8
11
|
export function rgb_to_luminance(r: number, g: number, b: number): number;
|
|
9
12
|
//# sourceMappingURL=rgb_to_luminance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rgb_to_luminance.d.ts","sourceRoot":"","sources":["../../../../src/core/color/rgb_to_luminance.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"rgb_to_luminance.d.ts","sourceRoot":"","sources":["../../../../src/core/color/rgb_to_luminance.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,oCALW,MAAM,KACN,MAAM,KACN,MAAM,GACL,MAAM,CAIjB"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Calculates Luminance (perceived brightness) using modern Rec.709 coefficients.
|
|
2
3
|
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param {number}
|
|
6
|
-
* @
|
|
4
|
+
* Matches sRGB and HDTV standards.
|
|
5
|
+
*
|
|
6
|
+
* @param {number} r Red component (linear or gamma-corrected)
|
|
7
|
+
* @param {number} g Green component (linear or gamma-corrected)
|
|
8
|
+
* @param {number} b Blue component (linear or gamma-corrected)
|
|
9
|
+
* @return {number} The calculated luma value
|
|
7
10
|
*/
|
|
8
11
|
export function rgb_to_luminance(r, g, b) {
|
|
9
|
-
return 0.
|
|
12
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
10
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear_to_sRGB.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/linear_to_sRGB.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"linear_to_sRGB.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/linear_to_sRGB.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACL,MAAM,CAQjB;AAED;;;;;;GAMG;AACH,uCALW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,iBAC1B,MAAM,SACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,QAahB"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {number} c
|
|
4
|
-
* @return {number
|
|
4
|
+
* @return {number}
|
|
5
5
|
*/
|
|
6
|
-
export function convert_channel_sRGB_to_linear(c: number): number
|
|
6
|
+
export function convert_channel_sRGB_to_linear(c: number): number;
|
|
7
7
|
/**
|
|
8
|
+
* Colors in normalized scale (0...1) instead of unsigned byte (0...255) so make sure you scale your values appropriately.
|
|
8
9
|
*
|
|
9
10
|
* @param {number[]} output
|
|
10
11
|
* @param {number} output_offset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sRGB_to_linear.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/sRGB_to_linear.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACL,MAAM,
|
|
1
|
+
{"version":3,"file":"sRGB_to_linear.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/sRGB/sRGB_to_linear.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,kDAHW,MAAM,GACL,MAAM,CAQjB;AAED;;;;;;;GAOG;AACH,uCALW,MAAM,EAAE,iBACR,MAAM,SACN,MAAM,EAAE,gBACR,MAAM,QAchB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
*
|
|
3
3
|
* @param {number} c
|
|
4
|
-
* @return {number
|
|
4
|
+
* @return {number}
|
|
5
5
|
*/
|
|
6
6
|
export function convert_channel_sRGB_to_linear(c) {
|
|
7
7
|
if (c < 0.04045) {
|
|
@@ -12,6 +12,7 @@ export function convert_channel_sRGB_to_linear(c) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
+
* Colors in normalized scale (0...1) instead of unsigned byte (0...255) so make sure you scale your values appropriately.
|
|
15
16
|
*
|
|
16
17
|
* @param {number[]} output
|
|
17
18
|
* @param {number} output_offset
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xyz_cmf_tabulated.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/xyz_cmf_tabulated.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xyz_cmf_tabulated.d.ts","sourceRoot":"","sources":["../../../../../src/core/color/xyz/xyz_cmf_tabulated.js"],"names":[],"mappings":"AA6KA;;;;;;;GAOG;AACH,uCAJW,MAAM,EAAE,iBACR,MAAM,GACJ,MAAM,EAAE,CA+BpB;AAhND;;;;;;;;;GASG;AAEH,iCAAkC;AAClC,iCAAkC"}
|