@flighthq/materials 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/classicMaterials.d.ts +5 -0
  2. package/dist/classicMaterials.d.ts.map +1 -0
  3. package/dist/classicMaterials.js +39 -0
  4. package/dist/classicMaterials.js.map +1 -0
  5. package/dist/color.d.ts +23 -0
  6. package/dist/color.d.ts.map +1 -0
  7. package/dist/color.js +291 -0
  8. package/dist/color.js.map +1 -0
  9. package/dist/colorTransform.d.ts +18 -0
  10. package/dist/colorTransform.d.ts.map +1 -0
  11. package/dist/colorTransform.js +119 -0
  12. package/dist/colorTransform.js.map +1 -0
  13. package/dist/colorTransformMaterial.d.ts +4 -0
  14. package/dist/colorTransformMaterial.d.ts.map +1 -0
  15. package/dist/colorTransformMaterial.js +18 -0
  16. package/dist/colorTransformMaterial.js.map +1 -0
  17. package/dist/index.d.ts +12 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +12 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/material.d.ts +6 -0
  22. package/dist/material.d.ts.map +1 -0
  23. package/dist/material.js +73 -0
  24. package/dist/material.js.map +1 -0
  25. package/dist/materialPresets.d.ts +13 -0
  26. package/dist/materialPresets.d.ts.map +1 -0
  27. package/dist/materialPresets.js +118 -0
  28. package/dist/materialPresets.js.map +1 -0
  29. package/dist/materialValidation.d.ts +7 -0
  30. package/dist/materialValidation.d.ts.map +1 -0
  31. package/dist/materialValidation.js +52 -0
  32. package/dist/materialValidation.js.map +1 -0
  33. package/dist/pbrExtensionMaterials.d.ts +9 -0
  34. package/dist/pbrExtensionMaterials.d.ts.map +1 -0
  35. package/dist/pbrExtensionMaterials.js +93 -0
  36. package/dist/pbrExtensionMaterials.js.map +1 -0
  37. package/dist/pbrMaterials.d.ts +6 -0
  38. package/dist/pbrMaterials.d.ts.map +1 -0
  39. package/dist/pbrMaterials.js +134 -0
  40. package/dist/pbrMaterials.js.map +1 -0
  41. package/dist/surfaceMaterial.d.ts +7 -0
  42. package/dist/surfaceMaterial.d.ts.map +1 -0
  43. package/dist/surfaceMaterial.js +41 -0
  44. package/dist/surfaceMaterial.js.map +1 -0
  45. package/dist/unlitMaterials.d.ts +10 -0
  46. package/dist/unlitMaterials.d.ts.map +1 -0
  47. package/dist/unlitMaterials.js +66 -0
  48. package/dist/unlitMaterials.js.map +1 -0
  49. package/package.json +38 -0
  50. package/src/classicMaterials.test.ts +48 -0
  51. package/src/color.test.ts +383 -0
  52. package/src/colorTransform.test.ts +384 -0
  53. package/src/colorTransformMaterial.test.ts +26 -0
  54. package/src/material.test.ts +110 -0
  55. package/src/materialPresets.test.ts +125 -0
  56. package/src/materialValidation.test.ts +130 -0
  57. package/src/pbrExtensionMaterials.test.ts +123 -0
  58. package/src/pbrMaterials.test.ts +91 -0
  59. package/src/surfaceMaterial.test.ts +69 -0
  60. package/src/unlitMaterials.test.ts +127 -0
@@ -0,0 +1,6 @@
1
+ import type { Kind, Material } from '@flighthq/types';
2
+ export declare function cloneMaterial(source: Readonly<Material>): Material;
3
+ export declare function copyMaterial(out: Material, source: Readonly<Material>): void;
4
+ export declare function createMaterial(kind: Kind): Material;
5
+ export declare function equalsMaterial(a: Readonly<Material>, b: Readonly<Material>): boolean;
6
+ //# sourceMappingURL=material.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../src/material.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAiC,MAAM,iBAAiB,CAAC;AASrF,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAIlE;AAOD,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAG5E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,CAEnD;AAMD,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,OAAO,CAgBpF"}
@@ -0,0 +1,73 @@
1
+ import { createEntity } from '@flighthq/entity';
2
+ import { UniformColorTransformMaterialKind } from '@flighthq/types';
3
+ import { cloneColorTransform, equalsColorTransform } from './colorTransform';
4
+ // Structural shallow clone of any material entity. Scalar fields and kind are copied by
5
+ // value; Texture/map handle references are shared (they are not owned by the material).
6
+ // The sub-entity `colorTransform` of UniformColorTransformMaterial is deep-cloned so the
7
+ // two materials do not share mutable transform state.
8
+ export function cloneMaterial(source) {
9
+ const clone = createEntity({ kind: source.kind });
10
+ copyMaterialFields(clone, source, source.kind);
11
+ return clone;
12
+ }
13
+ // Structural copy for pooling and reuse. Writes all own enumerable fields from `source`
14
+ // onto `out`. Map handles are shared by reference; the `colorTransform` sub-entity of a
15
+ // UniformColorTransformMaterial is deep-copied. Alias-safe: reads all inputs before
16
+ // writing (each field is independent, but `colorTransform` is copied first to avoid a
17
+ // partial write if `out === source`).
18
+ export function copyMaterial(out, source) {
19
+ if (out === source)
20
+ return;
21
+ copyMaterialFields(out, source, source.kind);
22
+ }
23
+ export function createMaterial(kind) {
24
+ return createEntity({ kind });
25
+ }
26
+ // Structural equality for dedup, pooling, and serialization round-trips — NOT the batch
27
+ // flush path (batching keys on material by reference). Compares own enumerable data fields
28
+ // by value for scalars and kind strings, and by reference for Texture/map handles.
29
+ // UniformColorTransformMaterial gets deep equality on its colorTransform sub-entity.
30
+ export function equalsMaterial(a, b) {
31
+ if (a === b)
32
+ return true;
33
+ if (a.kind !== b.kind)
34
+ return false;
35
+ if (a.kind === UniformColorTransformMaterialKind) {
36
+ return equalsColorTransform(a.colorTransform, b.colorTransform);
37
+ }
38
+ const aFields = a;
39
+ const bFields = b;
40
+ for (const key of Object.keys(aFields)) {
41
+ if (key === 'kind')
42
+ continue;
43
+ if (aFields[key] !== bFields[key])
44
+ return false;
45
+ }
46
+ return true;
47
+ }
48
+ // Internal helper — writes all own enumerable data fields from `src` onto `dst`. Skips
49
+ // the `kind` field (already set on `dst` at construction). Handles the `standard` sub-block
50
+ // and `colorTransform` sub-entity by shallow-field copy; all other values are assigned.
51
+ function copyMaterialFields(dst, src, kind) {
52
+ const dstFields = dst;
53
+ const srcFields = src;
54
+ for (const key of Object.keys(srcFields)) {
55
+ if (key === 'kind')
56
+ continue;
57
+ const value = srcFields[key];
58
+ if (key === 'colorTransform' && value != null && typeof value === 'object') {
59
+ // Deep-copy the ColorTransform sub-entity so the clone is independent.
60
+ dstFields[key] = cloneColorTransform(value);
61
+ }
62
+ else if (key === 'standard' && value != null && typeof value === 'object') {
63
+ // Shallow-copy the StandardPbrMaterialProperties block into an existing or new object.
64
+ dstFields[key] = { ...value };
65
+ }
66
+ else {
67
+ dstFields[key] = value;
68
+ }
69
+ }
70
+ // Ensure `kind` is always the source kind (createEntity may set it, but verify).
71
+ dstFields['kind'] = kind;
72
+ }
73
+ //# sourceMappingURL=material.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material.js","sourceRoot":"","sources":["../src/material.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,wFAAwF;AACxF,wFAAwF;AACxF,yFAAyF;AACzF,sDAAsD;AACtD,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAa,CAAC;IAC9D,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC;AACf,CAAC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AS,GAAG,GAAyC,CAAC;IAC5D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACzC,IAAI,GAAG,KAAK,MAAM;YAAE,SAAS;QAC7B,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,IAAI,GAAG,KAAK,gBAAgB,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC3E,uEAAuE;YACvE,SAAS,CAAC,GAAG,CAAC,GAAG,mBAAmB,CAAC,KAAc,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,GAAG,KAAK,UAAU,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5E,uFAAuF;YACvF,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,GAAI,KAAgB,EAAE,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;IACD,iFAAiF;IACjF,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { StandardPbrMaterial, TransmissionVolumePbrMaterial } from '@flighthq/types';
2
+ export declare function createAluminumStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
3
+ export declare function createCarbonStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
4
+ export declare function createGlassTransmissionVolumePbrMaterial(opts?: Readonly<Partial<TransmissionVolumePbrMaterial>>): TransmissionVolumePbrMaterial;
5
+ export declare function createGoldStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
6
+ export declare function createIronStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
7
+ export declare function createMarbleStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
8
+ export declare function createPlasticStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
9
+ export declare function createRubberStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
10
+ export declare function createSilverStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
11
+ export declare function createSkinStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
12
+ export declare function createWoodStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
13
+ //# sourceMappingURL=materialPresets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materialPresets.d.ts","sourceRoot":"","sources":["../src/materialPresets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAc1F,wBAAgB,iCAAiC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOpH;AAID,wBAAgB,+BAA+B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOlH;AAID,wBAAgB,wCAAwC,CACtD,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACtD,6BAA6B,CAM/B;AAID,wBAAgB,6BAA6B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOhH;AAID,wBAAgB,6BAA6B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOhH;AAID,wBAAgB,+BAA+B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOlH;AAID,wBAAgB,gCAAgC,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOnH;AAID,wBAAgB,+BAA+B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOlH;AAID,wBAAgB,+BAA+B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOlH;AAID,wBAAgB,6BAA6B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOhH;AAID,wBAAgB,6BAA6B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAOhH"}
@@ -0,0 +1,118 @@
1
+ import { createTransmissionVolumePbrMaterial } from './pbrExtensionMaterials';
2
+ import { createStandardPbrMaterial } from './pbrMaterials';
3
+ // Named presets for common real-world materials using glTF metallic-roughness PBR values.
4
+ // These are thin wrappers over `createStandardPbrMaterial` / `createTransmissionVolumePbrMaterial`
5
+ // with canonical default parameters. Each function is individually tree-shakable.
6
+ //
7
+ // IOR and specular-tint values follow the glTF PBR extensions specification and standard
8
+ // material-science references (BRDF Explorer, Substance Painter's material presets, etc.).
9
+ // Brushed aluminum: moderate roughness, fully metallic, warm gray base.
10
+ // Metallic: 1 · roughness: 0.35 · baseColor: 0xB0B0B0
11
+ export function createAluminumStandardPbrMaterial(opts) {
12
+ return createStandardPbrMaterial({
13
+ baseColor: 0xb0b0b0ff,
14
+ metallic: 1,
15
+ roughness: 0.35,
16
+ ...opts,
17
+ });
18
+ }
19
+ // Solid carbon / black matte: very dark, dielectric, rough.
20
+ // Metallic: 0 · roughness: 0.95 · baseColor: 0x1A1A1A
21
+ export function createCarbonStandardPbrMaterial(opts) {
22
+ return createStandardPbrMaterial({
23
+ baseColor: 0x1a1a1aff,
24
+ metallic: 0,
25
+ roughness: 0.95,
26
+ ...opts,
27
+ });
28
+ }
29
+ // Clear glass preset (use with TransmissionVolumePbrMaterial for transmission).
30
+ // Metallic: 0 · roughness: 0.0 · IOR: 1.5 · transmission: 1 · baseColor: white.
31
+ export function createGlassTransmissionVolumePbrMaterial(opts) {
32
+ return createTransmissionVolumePbrMaterial({
33
+ ior: 1.5,
34
+ transmission: 1,
35
+ ...opts,
36
+ });
37
+ }
38
+ // Gold: fully metallic, moderate roughness, warm saturated base color.
39
+ // Metallic: 1 · roughness: 0.25 · baseColor: 0xFFD700 (gold yellow in sRGB)
40
+ export function createGoldStandardPbrMaterial(opts) {
41
+ return createStandardPbrMaterial({
42
+ baseColor: 0xffd700ff,
43
+ metallic: 1,
44
+ roughness: 0.25,
45
+ ...opts,
46
+ });
47
+ }
48
+ // Iron / cast iron: metallic, moderately rough, dark gray.
49
+ // Metallic: 1 · roughness: 0.7 · baseColor: 0x444444
50
+ export function createIronStandardPbrMaterial(opts) {
51
+ return createStandardPbrMaterial({
52
+ baseColor: 0x444444ff,
53
+ metallic: 1,
54
+ roughness: 0.7,
55
+ ...opts,
56
+ });
57
+ }
58
+ // Marble: dielectric, very smooth, white with a hint of gray.
59
+ // Metallic: 0 · roughness: 0.05 · baseColor: 0xF5F5F5
60
+ export function createMarbleStandardPbrMaterial(opts) {
61
+ return createStandardPbrMaterial({
62
+ baseColor: 0xf5f5f5ff,
63
+ metallic: 0,
64
+ roughness: 0.05,
65
+ ...opts,
66
+ });
67
+ }
68
+ // Hard glossy plastic: dielectric, smooth, neutral.
69
+ // Metallic: 0 · roughness: 0.05 · baseColor: 0xFFFFFF (caller supplies tint via baseColor override)
70
+ export function createPlasticStandardPbrMaterial(opts) {
71
+ return createStandardPbrMaterial({
72
+ baseColor: 0xffffffff,
73
+ metallic: 0,
74
+ roughness: 0.05,
75
+ ...opts,
76
+ });
77
+ }
78
+ // Matte rubber: dielectric, very rough, dark.
79
+ // Metallic: 0 · roughness: 0.9 · baseColor: 0x1C1C1C
80
+ export function createRubberStandardPbrMaterial(opts) {
81
+ return createStandardPbrMaterial({
82
+ baseColor: 0x1c1c1cff,
83
+ metallic: 0,
84
+ roughness: 0.9,
85
+ ...opts,
86
+ });
87
+ }
88
+ // Silver: fully metallic, polished.
89
+ // Metallic: 1 · roughness: 0.1 · baseColor: 0xC0C0C0
90
+ export function createSilverStandardPbrMaterial(opts) {
91
+ return createStandardPbrMaterial({
92
+ baseColor: 0xc0c0c0ff,
93
+ metallic: 1,
94
+ roughness: 0.1,
95
+ ...opts,
96
+ });
97
+ }
98
+ // Skin (light tone): dielectric, slight roughness, warm pinkish base.
99
+ // Metallic: 0 · roughness: 0.4 · baseColor: 0xFFCC99 (a neutral Caucasian tone in sRGB)
100
+ export function createSkinStandardPbrMaterial(opts) {
101
+ return createStandardPbrMaterial({
102
+ baseColor: 0xffcc99ff,
103
+ metallic: 0,
104
+ roughness: 0.4,
105
+ ...opts,
106
+ });
107
+ }
108
+ // Wood (unfinished): dielectric, rough, medium brown.
109
+ // Metallic: 0 · roughness: 0.8 · baseColor: 0x8B5A2B
110
+ export function createWoodStandardPbrMaterial(opts) {
111
+ return createStandardPbrMaterial({
112
+ baseColor: 0x8b5a2bff,
113
+ metallic: 0,
114
+ roughness: 0.8,
115
+ ...opts,
116
+ });
117
+ }
118
+ //# sourceMappingURL=materialPresets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materialPresets.js","sourceRoot":"","sources":["../src/materialPresets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAE3D,0FAA0F;AAC1F,mGAAmG;AACnG,kFAAkF;AAClF,EAAE;AACF,yFAAyF;AAC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G,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAED,oDAAoD;AACpD,oGAAoG;AACpG,MAAM,UAAU,gCAAgC,CAAC,IAA6C;IAC5F,OAAO,yBAAyB,CAAC;QAC/B,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,IAAI;QACf,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAED,8CAA8C;AAC9C,qDAAqD;AACrD,MAAM,UAAU,+BAA+B,CAAC,IAA6C;IAC3F,OAAO,yBAAyB,CAAC;QAC/B,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,GAAG;QACd,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAED,oCAAoC;AACpC,qDAAqD;AACrD,MAAM,UAAU,+BAA+B,CAAC,IAA6C;IAC3F,OAAO,yBAAyB,CAAC;QAC/B,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,GAAG;QACd,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAED,sEAAsE;AACtE,wFAAwF;AACxF,MAAM,UAAU,6BAA6B,CAAC,IAA6C;IACzF,OAAO,yBAAyB,CAAC;QAC/B,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,GAAG;QACd,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC;AAED,sDAAsD;AACtD,qDAAqD;AACrD,MAAM,UAAU,6BAA6B,CAAC,IAA6C;IACzF,OAAO,yBAAyB,CAAC;QAC/B,SAAS,EAAE,UAAU;QACrB,QAAQ,EAAE,CAAC;QACX,SAAS,EAAE,GAAG;QACd,GAAG,IAAI;KACR,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { StandardPbrMaterialProperties } from '@flighthq/types';
2
+ export declare function clampStandardPbrMaterialProperties(out: StandardPbrMaterialProperties): StandardPbrMaterialProperties;
3
+ export declare function isValidMaterialClearcoat(value: number): boolean;
4
+ export declare function isValidMaterialIor(value: number): boolean;
5
+ export declare function isValidMaterialIridescenceThickness(value: number): boolean;
6
+ export declare function isValidMaterialWeight(value: number): boolean;
7
+ //# sourceMappingURL=materialValidation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materialValidation.d.ts","sourceRoot":"","sources":["../src/materialValidation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAYrE,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,6BAA6B,GAAG,6BAA6B,CAOpH;AAKD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/D;AAMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAMD,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE1E;AAKD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D"}
@@ -0,0 +1,52 @@
1
+ // Clamps all metallic-roughness scalar fields of a StandardPbrMaterialProperties block to
2
+ // their physically-valid ranges in place. Writes directly to `out`:
3
+ // - `metallic` → [0, 1]
4
+ // - `roughness` → [0, 1]
5
+ // - `occlusionStrength` → [0, 1]
6
+ // - `emissiveStrength` → [0, ∞) (clamps below 0 only; no upper bound for HDR emissive)
7
+ // - `normalScale` → [0, ∞) (clamps below 0 only)
8
+ // Map references and the `baseColor`/`emissive` packed-int colors are not modified —
9
+ // those are validated by the caller (map handles come from the resource system; packed
10
+ // colors use the full 0xRRGGBBAA range). Returns `out` for chaining.
11
+ export function clampStandardPbrMaterialProperties(out) {
12
+ out.metallic = Math.min(1, Math.max(0, out.metallic));
13
+ out.roughness = Math.min(1, Math.max(0, out.roughness));
14
+ out.occlusionStrength = Math.min(1, Math.max(0, out.occlusionStrength));
15
+ out.emissiveStrength = Math.max(0, out.emissiveStrength);
16
+ out.normalScale = Math.max(0, out.normalScale);
17
+ return out;
18
+ }
19
+ // Returns true when `value` is in the clearcoat range [0, 1]. glTF KHR_materials_clearcoat
20
+ // defines `clearcoatFactor` as a linear weight in [0, 1]; values outside this range are invalid.
21
+ // Returns false for NaN, Infinity, and out-of-range values. Does not throw.
22
+ export function isValidMaterialClearcoat(value) {
23
+ return Number.isFinite(value) && value >= 0 && value <= 1;
24
+ }
25
+ // Returns true when `value` is a physically-valid IOR (index of refraction) — i.e. a finite
26
+ // number in [1.0, 5.0]. Values outside this range are not meaningful for standard dielectric
27
+ // BRDF models (the glTF KHR_materials_transmission / KHR_materials_ior specs both gate on IOR ≥ 1).
28
+ // Returns false for NaN, Infinity, and out-of-range values. Does not throw.
29
+ export function isValidMaterialIor(value) {
30
+ return Number.isFinite(value) && value >= MIN_MATERIAL_IOR && value <= MAX_MATERIAL_IOR;
31
+ }
32
+ // Returns true when `value` is a valid iridescence-layer thickness in nanometers. The glTF
33
+ // KHR_materials_iridescence spec requires thickness ≥ 0 nm; the standard display range
34
+ // (thin-film interference) is [0, 1000] nm. Values above 1000 are physically unusual (no
35
+ // observable iridescence). Returns false for negative, NaN, and Infinite values. Does not throw.
36
+ export function isValidMaterialIridescenceThickness(value) {
37
+ return Number.isFinite(value) && value >= 0;
38
+ }
39
+ // Returns true when `value` is a valid normalized weight in [0, 1] — used for transmission,
40
+ // sheen strength, anisotropy strength, and other parameters that represent a fractional blend
41
+ // or strength factor. Returns false for NaN, Infinity, and out-of-range values. Does not throw.
42
+ export function isValidMaterialWeight(value) {
43
+ return Number.isFinite(value) && value >= 0 && value <= 1;
44
+ }
45
+ // Minimum IOR value physically meaningful for a real material. Below this threshold, a
46
+ // material would allow light to travel faster than in vacuum (n < 1 is only possible for
47
+ // metamaterials). Water is ~1.33, glass ~1.5, diamond ~2.4.
48
+ const MIN_MATERIAL_IOR = 1.0;
49
+ // Maximum IOR value clamped by glTF KHR_materials_ior spec (physical materials range ≤ ~5).
50
+ // Diamond is ~2.4; higher values are exotic / computationally unstable in standard BRDF models.
51
+ const MAX_MATERIAL_IOR = 5.0;
52
+ //# sourceMappingURL=materialValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materialValidation.js","sourceRoot":"","sources":["../src/materialValidation.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,oEAAoE;AACpE,mCAAmC;AACnC,mCAAmC;AACnC,mCAAmC;AACnC,0FAA0F;AAC1F,yDAAyD;AACzD,qFAAqF;AACrF,uFAAuF;AACvF,qEAAqE;AACrE,MAAM,UAAU,kCAAkC,CAAC,GAAkC;IACnF,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;IACxD,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACxE,GAAG,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACzD,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2FAA2F;AAC3F,iGAAiG;AACjG,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED,4FAA4F;AAC5F,6FAA6F;AAC7F,oGAAoG;AACpG,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,gBAAgB,IAAI,KAAK,IAAI,gBAAgB,CAAC;AAC1F,CAAC;AAED,2FAA2F;AAC3F,uFAAuF;AACvF,yFAAyF;AACzF,iGAAiG;AACjG,MAAM,UAAU,mCAAmC,CAAC,KAAa;IAC/D,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,4FAA4F;AAC5F,8FAA8F;AAC9F,gGAAgG;AAChG,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED,uFAAuF;AACvF,yFAAyF;AACzF,4DAA4D;AAC5D,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,4FAA4F;AAC5F,gGAAgG;AAChG,MAAM,gBAAgB,GAAG,GAAG,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { AnisotropyPbrMaterial, ClearcoatPbrMaterial, IridescencePbrMaterial, SheenPbrMaterial, SpecularPbrMaterial, SubsurfacePbrMaterial, TransmissionVolumePbrMaterial } from '@flighthq/types';
2
+ export declare function createAnisotropyPbrMaterial(opts?: Readonly<Partial<AnisotropyPbrMaterial>>): AnisotropyPbrMaterial;
3
+ export declare function createClearcoatPbrMaterial(opts?: Readonly<Partial<ClearcoatPbrMaterial>>): ClearcoatPbrMaterial;
4
+ export declare function createIridescencePbrMaterial(opts?: Readonly<Partial<IridescencePbrMaterial>>): IridescencePbrMaterial;
5
+ export declare function createSheenPbrMaterial(opts?: Readonly<Partial<SheenPbrMaterial>>): SheenPbrMaterial;
6
+ export declare function createSpecularPbrMaterial(opts?: Readonly<Partial<SpecularPbrMaterial>>): SpecularPbrMaterial;
7
+ export declare function createSubsurfacePbrMaterial(opts?: Readonly<Partial<SubsurfacePbrMaterial>>): SubsurfacePbrMaterial;
8
+ export declare function createTransmissionVolumePbrMaterial(opts?: Readonly<Partial<TransmissionVolumePbrMaterial>>): TransmissionVolumePbrMaterial;
9
+ //# sourceMappingURL=pbrExtensionMaterials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbrExtensionMaterials.d.ts","sourceRoot":"","sources":["../src/pbrExtensionMaterials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AAiBzB,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,qBAAqB,CAOlH;AAKD,wBAAgB,0BAA0B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAG,oBAAoB,CAS/G;AAKD,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC,GAAG,sBAAsB,CAUrH;AAID,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,gBAAgB,CAQnG;AAID,wBAAgB,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAQ5G;AAKD,wBAAgB,2BAA2B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,qBAAqB,CASlH;AAMD,wBAAgB,mCAAmC,CACjD,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACtD,6BAA6B,CAW/B"}
@@ -0,0 +1,93 @@
1
+ import { AnisotropyPbrMaterialKind, ClearcoatPbrMaterialKind, IridescencePbrMaterialKind, SheenPbrMaterialKind, SpecularPbrMaterialKind, SubsurfacePbrMaterialKind, TransmissionVolumePbrMaterialKind, } from '@flighthq/types';
2
+ import { createStandardPbrMaterialProperties } from './pbrMaterials';
3
+ import { createSurfaceMaterial } from './surfaceMaterial';
4
+ // KHR_materials_anisotropy: a directionally-stretched specular lobe. `anisotropyStrength`
5
+ // defaults to 0 (isotropic), `anisotropyRotation` to 0, the map to null. Composes a default
6
+ // `standard` block.
7
+ export function createAnisotropyPbrMaterial(opts) {
8
+ const material = createSurfaceMaterial(AnisotropyPbrMaterialKind);
9
+ material.anisotropyMap = opts?.anisotropyMap ?? null;
10
+ material.anisotropyRotation = opts?.anisotropyRotation ?? 0;
11
+ material.anisotropyStrength = opts?.anisotropyStrength ?? 0;
12
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
13
+ return material;
14
+ }
15
+ // KHR_materials_clearcoat: a second specular lobe over the base PBR layer. `clearcoat` defaults
16
+ // to 0 (disabled), `clearcoatRoughness` to 0, all maps to null. Composes a default `standard`
17
+ // block.
18
+ export function createClearcoatPbrMaterial(opts) {
19
+ const material = createSurfaceMaterial(ClearcoatPbrMaterialKind);
20
+ material.clearcoat = opts?.clearcoat ?? 0;
21
+ material.clearcoatMap = opts?.clearcoatMap ?? null;
22
+ material.clearcoatNormalMap = opts?.clearcoatNormalMap ?? null;
23
+ material.clearcoatRoughness = opts?.clearcoatRoughness ?? 0;
24
+ material.clearcoatRoughnessMap = opts?.clearcoatRoughnessMap ?? null;
25
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
26
+ return material;
27
+ }
28
+ // KHR_materials_iridescence: thin-film interference. `iridescence` defaults to 0 (disabled),
29
+ // `iridescenceIor` to 1.3, the thickness range to glTF's 100–400 nm, all maps to null.
30
+ // Composes a default `standard` block.
31
+ export function createIridescencePbrMaterial(opts) {
32
+ const material = createSurfaceMaterial(IridescencePbrMaterialKind);
33
+ material.iridescence = opts?.iridescence ?? 0;
34
+ material.iridescenceIor = opts?.iridescenceIor ?? 1.3;
35
+ material.iridescenceMap = opts?.iridescenceMap ?? null;
36
+ material.iridescenceThicknessMap = opts?.iridescenceThicknessMap ?? null;
37
+ material.iridescenceThicknessMax = opts?.iridescenceThicknessMax ?? 400;
38
+ material.iridescenceThicknessMin = opts?.iridescenceThicknessMin ?? 100;
39
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
40
+ return material;
41
+ }
42
+ // KHR_materials_sheen: a retroreflective cloth/fabric lobe. `sheenColor` defaults to opaque
43
+ // black (disabled), `sheenRoughness` to 0, maps to null. Composes a default `standard` block.
44
+ export function createSheenPbrMaterial(opts) {
45
+ const material = createSurfaceMaterial(SheenPbrMaterialKind);
46
+ material.sheenColor = opts?.sheenColor ?? 0x000000ff;
47
+ material.sheenColorMap = opts?.sheenColorMap ?? null;
48
+ material.sheenRoughness = opts?.sheenRoughness ?? 0;
49
+ material.sheenRoughnessMap = opts?.sheenRoughnessMap ?? null;
50
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
51
+ return material;
52
+ }
53
+ // KHR_materials_specular: independent dielectric specular strength and tint. `specular` defaults
54
+ // to 1 (full), `specularColor` to white, maps to null. Composes a default `standard` block.
55
+ export function createSpecularPbrMaterial(opts) {
56
+ const material = createSurfaceMaterial(SpecularPbrMaterialKind);
57
+ material.specular = opts?.specular ?? 1;
58
+ material.specularColor = opts?.specularColor ?? 0xffffffff;
59
+ material.specularColorMap = opts?.specularColorMap ?? null;
60
+ material.specularMap = opts?.specularMap ?? null;
61
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
62
+ return material;
63
+ }
64
+ // Flight subsurface-scattering extension (wrapped-diffuse approximation). `subsurface` defaults
65
+ // to 0 (disabled), `subsurfaceColor` to white, `thickness` to 0, maps to null. Composes a
66
+ // default `standard` block.
67
+ export function createSubsurfacePbrMaterial(opts) {
68
+ const material = createSurfaceMaterial(SubsurfacePbrMaterialKind);
69
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
70
+ material.subsurface = opts?.subsurface ?? 0;
71
+ material.subsurfaceColor = opts?.subsurfaceColor ?? 0xffffffff;
72
+ material.subsurfaceMap = opts?.subsurfaceMap ?? null;
73
+ material.thickness = opts?.thickness ?? 0;
74
+ material.thicknessMap = opts?.thicknessMap ?? null;
75
+ return material;
76
+ }
77
+ // KHR_materials_transmission + KHR_materials_volume: refractive, see-through surfaces.
78
+ // `transmission` defaults to 0 (opaque), `thickness` to 0, `attenuationColor` to white,
79
+ // `attenuationDistance` to Infinity (no absorption), `ior` to glTF's 1.5, maps to null.
80
+ // Composes a default `standard` block.
81
+ export function createTransmissionVolumePbrMaterial(opts) {
82
+ const material = createSurfaceMaterial(TransmissionVolumePbrMaterialKind);
83
+ material.attenuationColor = opts?.attenuationColor ?? 0xffffffff;
84
+ material.attenuationDistance = opts?.attenuationDistance ?? Infinity;
85
+ material.ior = opts?.ior ?? 1.5;
86
+ material.standard = opts?.standard ?? createStandardPbrMaterialProperties();
87
+ material.thickness = opts?.thickness ?? 0;
88
+ material.thicknessMap = opts?.thicknessMap ?? null;
89
+ material.transmission = opts?.transmission ?? 0;
90
+ material.transmissionMap = opts?.transmissionMap ?? null;
91
+ return material;
92
+ }
93
+ //# sourceMappingURL=pbrExtensionMaterials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbrExtensionMaterials.js","sourceRoot":"","sources":["../src/pbrExtensionMaterials.ts"],"names":[],"mappings":"AASA,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,EAC1B,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,mCAAmC,EAAE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G,IAAI,EAAE,gBAAgB,IAAI,UAAU,CAAC;IACjE,QAAQ,CAAC,mBAAmB,GAAG,IAAI,EAAE,mBAAmB,IAAI,QAAQ,CAAC;IACrE,QAAQ,CAAC,GAAG,GAAG,IAAI,EAAE,GAAG,IAAI,GAAG,CAAC;IAChC,QAAQ,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,mCAAmC,EAAE,CAAC;IAC5E,QAAQ,CAAC,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC;IAC1C,QAAQ,CAAC,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,IAAI,CAAC;IACnD,QAAQ,CAAC,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,CAAC,CAAC;IAChD,QAAQ,CAAC,eAAe,GAAG,IAAI,EAAE,eAAe,IAAI,IAAI,CAAC;IACzD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { SpecularGlossinessPbrMaterial, StandardPbrMaterial, StandardPbrMaterialProperties } from '@flighthq/types';
2
+ export declare function convertSpecularGlossinessToStandardPbr(out: StandardPbrMaterialProperties, source: Readonly<SpecularGlossinessPbrMaterial>): void;
3
+ export declare function createSpecularGlossinessPbrMaterial(opts?: Readonly<Partial<SpecularGlossinessPbrMaterial>>): SpecularGlossinessPbrMaterial;
4
+ export declare function createStandardPbrMaterial(opts?: Readonly<Partial<StandardPbrMaterial>>): StandardPbrMaterial;
5
+ export declare function createStandardPbrMaterialProperties(opts?: Readonly<Partial<StandardPbrMaterialProperties>>): StandardPbrMaterialProperties;
6
+ //# sourceMappingURL=pbrMaterials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbrMaterials.d.ts","sourceRoot":"","sources":["../src/pbrMaterials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,iBAAiB,CAAC;AAkBzB,wBAAgB,sCAAsC,CACpD,GAAG,EAAE,6BAA6B,EAClC,MAAM,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GAC9C,IAAI,CAmDN;AAKD,wBAAgB,mCAAmC,CACjD,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACtD,6BAA6B,CAe/B;AAKD,wBAAgB,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAI5G;AAKD,wBAAgB,mCAAmC,CACjD,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC,GACtD,6BAA6B,CAI/B"}
@@ -0,0 +1,134 @@
1
+ import { SpecularGlossinessPbrMaterialKind, StandardPbrMaterialKind } from '@flighthq/types';
2
+ import { unpackColorToLinear } from './color';
3
+ import { createSurfaceMaterial } from './surfaceMaterial';
4
+ // Converts a legacy specular-glossiness material to a metallic-roughness property block.
5
+ // Writes `out` with the computed base-color, metallic, and roughness values. The conversion
6
+ // is the canonical KHR_materials_pbrSpecularGlossiness → metallic-roughness approximation:
7
+ // roughness = 1 - glossiness
8
+ // metallic = max(specularLinear) above the dielectric threshold (~ 0.04 F0)
9
+ // baseColor = blend of diffuse and inferred albedo based on metallic estimate
10
+ // Lossiness: the conversion is an approximation — metal/dielectric separation derived from
11
+ // the specular luma cannot fully recover the original material on every surface. Document
12
+ // the approximation when surfacing the output to users.
13
+ // Map assignments: diffuseMap → baseColorMap; specularGlossinessMap → metallicRoughnessMap
14
+ // (packing semantics differ — the renderer must remap channels). normalMap, occlusionMap,
15
+ // emissiveMap, normalScale, occlusionStrength, and emissiveStrength are forwarded unchanged.
16
+ export function convertSpecularGlossinessToStandardPbr(out, source) {
17
+ // Read all input values into locals before writing (alias-safe).
18
+ const diffuse = source.diffuse;
19
+ const specular = source.specular;
20
+ const glossiness = source.glossiness;
21
+ const diffuseMap = source.diffuseMap;
22
+ const specularGlossinessMap = source.specularGlossinessMap;
23
+ const emissive = source.emissive;
24
+ const emissiveMap = source.emissiveMap;
25
+ const emissiveStrength = source.emissiveStrength;
26
+ const normalMap = source.normalMap;
27
+ const normalScale = source.normalScale;
28
+ const occlusionMap = source.occlusionMap;
29
+ const occlusionStrength = source.occlusionStrength;
30
+ // Unpack the specular color to linear to compute F0 luminance for the metallic estimate.
31
+ const specLinear = scratchLinear;
32
+ unpackColorToLinear(specLinear, specular);
33
+ const specR = specLinear[0];
34
+ const specG = specLinear[1];
35
+ const specB = specLinear[2];
36
+ // Perceived luminance of the specular F0 (Rec. 709 weights).
37
+ const specLuma = 0.2126 * specR + 0.7152 * specG + 0.0722 * specB;
38
+ // The dielectric F0 threshold: ~0.04 (4% reflectance). A specular luma above this is
39
+ // characteristic of metallic response; we map linearly from 0 → 1.
40
+ const DIELECTRIC_F0 = 0.04;
41
+ const metallic = Math.min(1, Math.max(0, (specLuma - DIELECTRIC_F0) / (1 - DIELECTRIC_F0)));
42
+ // Base color: for metals the diffuse is the albedo; for dielectrics it is the diffuse.
43
+ // Blend: baseColor = lerp(diffuse * (1 - specLuma), diffuse, metallic).
44
+ const diffLinear = scratchLinear2;
45
+ unpackColorToLinear(diffLinear, diffuse);
46
+ const diffR = diffLinear[0];
47
+ const diffG = diffLinear[1];
48
+ const diffB = diffLinear[2];
49
+ const diffA = diffLinear[3];
50
+ // Approximate base color in linear, then repack to sRGB RGBA.
51
+ const baseR = diffR * (1 - specLuma * (1 - metallic));
52
+ const baseG = diffG * (1 - specLuma * (1 - metallic));
53
+ const baseB = diffB * (1 - specLuma * (1 - metallic));
54
+ const baseColor = packLinear(baseR, baseG, baseB, diffA);
55
+ out.baseColor = baseColor;
56
+ out.baseColorMap = diffuseMap;
57
+ out.emissive = emissive;
58
+ out.emissiveMap = emissiveMap;
59
+ out.emissiveStrength = emissiveStrength;
60
+ out.metallic = metallic;
61
+ out.metallicRoughnessMap = specularGlossinessMap;
62
+ out.normalMap = normalMap;
63
+ out.normalScale = normalScale;
64
+ out.occlusionMap = occlusionMap;
65
+ out.occlusionStrength = occlusionStrength;
66
+ out.roughness = 1 - glossiness;
67
+ }
68
+ // Legacy specular-glossiness PBR material (converted to metallic-roughness at bind). `diffuse`
69
+ // defaults to white, `specular` to white, `glossiness` to 1, `emissive` to opaque black,
70
+ // `emissiveStrength` to 1, `normalScale`/`occlusionStrength` to 1, all maps to null.
71
+ export function createSpecularGlossinessPbrMaterial(opts) {
72
+ const material = createSurfaceMaterial(SpecularGlossinessPbrMaterialKind);
73
+ material.diffuse = opts?.diffuse ?? 0xffffffff;
74
+ material.diffuseMap = opts?.diffuseMap ?? null;
75
+ material.emissive = opts?.emissive ?? 0x000000ff;
76
+ material.emissiveMap = opts?.emissiveMap ?? null;
77
+ material.emissiveStrength = opts?.emissiveStrength ?? 1;
78
+ material.glossiness = opts?.glossiness ?? 1;
79
+ material.normalMap = opts?.normalMap ?? null;
80
+ material.normalScale = opts?.normalScale ?? 1;
81
+ material.occlusionMap = opts?.occlusionMap ?? null;
82
+ material.occlusionStrength = opts?.occlusionStrength ?? 1;
83
+ material.specular = opts?.specular ?? 0xffffffff;
84
+ material.specularGlossinessMap = opts?.specularGlossinessMap ?? null;
85
+ return material;
86
+ }
87
+ // Core glTF metallic-roughness PBR material. Defaults: white `baseColor`, fully dielectric
88
+ // (`metallic` 0) and fully rough (`roughness` 1), opaque-black `emissive` at unit strength,
89
+ // unit `normalScale`/`occlusionStrength`, all maps null.
90
+ export function createStandardPbrMaterial(opts) {
91
+ const material = createSurfaceMaterial(StandardPbrMaterialKind);
92
+ assignStandardPbrMaterialProperties(material, opts);
93
+ return material;
94
+ }
95
+ // Builds the reusable StandardPbrMaterialProperties block that PBR-extension materials compose
96
+ // into their `standard` field (D4). Same defaults as createStandardPbrMaterial, without a kind
97
+ // or the surface trailer.
98
+ export function createStandardPbrMaterialProperties(opts) {
99
+ const properties = {};
100
+ assignStandardPbrMaterialProperties(properties, opts);
101
+ return properties;
102
+ }
103
+ // Writes the metallic-roughness property defaults (overridden by `opts`) onto `target`. Shared
104
+ // by the StandardPbrMaterial constructor and the standalone property-block constructor.
105
+ function assignStandardPbrMaterialProperties(target, opts) {
106
+ target.baseColor = opts?.baseColor ?? 0xffffffff;
107
+ target.baseColorMap = opts?.baseColorMap ?? null;
108
+ target.emissive = opts?.emissive ?? 0x000000ff;
109
+ target.emissiveMap = opts?.emissiveMap ?? null;
110
+ target.emissiveStrength = opts?.emissiveStrength ?? 1;
111
+ target.metallic = opts?.metallic ?? 0;
112
+ target.metallicRoughnessMap = opts?.metallicRoughnessMap ?? null;
113
+ target.normalMap = opts?.normalMap ?? null;
114
+ target.normalScale = opts?.normalScale ?? 1;
115
+ target.occlusionMap = opts?.occlusionMap ?? null;
116
+ target.occlusionStrength = opts?.occlusionStrength ?? 1;
117
+ target.roughness = opts?.roughness ?? 1;
118
+ }
119
+ // IEC 61966-2-1 inverse OETF for a single linear channel in [0, 1] → 8-bit sRGB.
120
+ function linearChannelToSrgb8(value) {
121
+ const srgb = value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
122
+ return Math.round(Math.min(1, Math.max(0, srgb)) * 0xff);
123
+ }
124
+ // Pack four linear [0,1] channels back to a 0xRRGGBBAA packed sRGB integer.
125
+ function packLinear(r, g, b, a) {
126
+ return (((linearChannelToSrgb8(r) << 24) |
127
+ (linearChannelToSrgb8(g) << 16) |
128
+ (linearChannelToSrgb8(b) << 8) |
129
+ Math.round(a * 0xff)) >>>
130
+ 0);
131
+ }
132
+ const scratchLinear = [0, 0, 0, 0];
133
+ const scratchLinear2 = [0, 0, 0, 0];
134
+ //# sourceMappingURL=pbrMaterials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pbrMaterials.js","sourceRoot":"","sources":["../src/pbrMaterials.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iCAAiC,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,m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AC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Kind, MaterialAlphaMode, SurfaceMaterial } from '@flighthq/types';
2
+ export declare function createSurfaceMaterial(kind: Kind): SurfaceMaterial;
3
+ export declare function getMaterialAlphaMode(source: Readonly<SurfaceMaterial>): MaterialAlphaMode;
4
+ export declare function isMaterialBlended(source: Readonly<SurfaceMaterial>): boolean;
5
+ export declare function isMaterialMasked(source: Readonly<SurfaceMaterial>): boolean;
6
+ export declare function isMaterialOpaque(source: Readonly<SurfaceMaterial>): boolean;
7
+ //# sourceMappingURL=surfaceMaterial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"surfaceMaterial.d.ts","sourceRoot":"","sources":["../src/surfaceMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,IAAI,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAS3F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAQjE;AAKD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,iBAAiB,CAEzF;AAID,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAE5E;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAE3E;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAE3E"}