@flighthq/materials 0.5.1-next.973.788d3d7 → 0.6.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.
- package/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/anisotropyPbrExtension.d.ts +2 -1
- package/dist/anisotropyPbrExtension.d.ts.map +1 -1
- package/dist/anisotropyPbrExtension.js +5 -5
- package/dist/anisotropyPbrExtension.js.map +1 -1
- package/dist/classicMaterials.d.ts +1 -1
- package/dist/classicMaterials.d.ts.map +1 -1
- package/dist/classicMaterials.js +5 -5
- package/dist/classicMaterials.js.map +1 -1
- package/dist/clearcoatPbrExtension.d.ts +2 -1
- package/dist/clearcoatPbrExtension.d.ts.map +1 -1
- package/dist/clearcoatPbrExtension.js +5 -5
- package/dist/clearcoatPbrExtension.js.map +1 -1
- package/dist/colorScaleBias.d.ts +2 -1
- package/dist/colorScaleBias.d.ts.map +1 -1
- package/dist/colorScaleBias.js +2 -2
- package/dist/colorScaleBias.js.map +1 -1
- package/dist/contract.d.ts +33 -30
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +33 -30
- package/dist/contract.js.map +1 -1
- package/dist/contract.materials-types.d.ts +56 -0
- package/dist/contract.materials-types.d.ts.map +1 -0
- package/dist/contract.materials-types.js +25 -0
- package/dist/contract.materials-types.js.map +1 -0
- package/dist/customShaderMaterial.d.ts +1 -1
- package/dist/customShaderMaterial.d.ts.map +1 -1
- package/dist/customShaderMaterial.js +3 -3
- package/dist/customShaderMaterial.js.map +1 -1
- package/dist/enableMaterialConversionGuards.d.ts +4 -0
- package/dist/enableMaterialConversionGuards.d.ts.map +1 -0
- package/dist/enableMaterialConversionGuards.js +29 -0
- package/dist/enableMaterialConversionGuards.js.map +1 -0
- package/dist/explainMaterialConversion.d.ts +4 -0
- package/dist/explainMaterialConversion.d.ts.map +1 -0
- package/dist/explainMaterialConversion.js +33 -0
- package/dist/explainMaterialConversion.js.map +1 -0
- package/dist/extendedPbrMaterial.d.ts +1 -1
- package/dist/extendedPbrMaterial.d.ts.map +1 -1
- package/dist/extendedPbrMaterial.js +4 -4
- package/dist/extendedPbrMaterial.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/iridescencePbrExtension.d.ts +2 -1
- package/dist/iridescencePbrExtension.d.ts.map +1 -1
- package/dist/iridescencePbrExtension.js +5 -5
- package/dist/iridescencePbrExtension.js.map +1 -1
- package/dist/material.d.ts +2 -1
- package/dist/material.d.ts.map +1 -1
- package/dist/material.js +3 -3
- package/dist/material.js.map +1 -1
- package/dist/material3d.d.ts +8 -0
- package/dist/material3d.d.ts.map +1 -0
- package/dist/{surfaceMaterial.js → material3d.js} +10 -10
- package/dist/material3d.js.map +1 -0
- package/dist/materialPresets.d.ts +1 -1
- package/dist/materialPresets.d.ts.map +1 -1
- package/dist/materialPresets.js +3 -3
- package/dist/materialPresets.js.map +1 -1
- package/dist/materialValidation.d.ts +1 -1
- package/dist/materialValidation.d.ts.map +1 -1
- package/dist/pbrExtension.d.ts +1 -1
- package/dist/pbrExtension.d.ts.map +1 -1
- package/dist/pbrMaterials.d.ts +4 -1
- package/dist/pbrMaterials.d.ts.map +1 -1
- package/dist/pbrMaterials.js +32 -26
- package/dist/pbrMaterials.js.map +1 -1
- package/dist/phongToPbr.d.ts +1 -1
- package/dist/phongToPbr.d.ts.map +1 -1
- package/dist/phongToPbr.js +7 -1
- package/dist/phongToPbr.js.map +1 -1
- package/dist/sheenPbrExtension.d.ts +2 -1
- package/dist/sheenPbrExtension.d.ts.map +1 -1
- package/dist/sheenPbrExtension.js +5 -5
- package/dist/sheenPbrExtension.js.map +1 -1
- package/dist/specularPbrExtension.d.ts +2 -1
- package/dist/specularPbrExtension.d.ts.map +1 -1
- package/dist/specularPbrExtension.js +5 -5
- package/dist/specularPbrExtension.js.map +1 -1
- package/dist/standardMaterial.d.ts +2 -1
- package/dist/standardMaterial.d.ts.map +1 -1
- package/dist/standardMaterial.js +3 -3
- package/dist/standardMaterial.js.map +1 -1
- package/dist/transmissionVolumePbrExtension.d.ts +2 -1
- package/dist/transmissionVolumePbrExtension.d.ts.map +1 -1
- package/dist/transmissionVolumePbrExtension.js +5 -5
- package/dist/transmissionVolumePbrExtension.js.map +1 -1
- package/dist/types/AnisotropyPbrExtension.d.ts +11 -0
- package/dist/types/AnisotropyPbrExtension.d.ts.map +1 -0
- package/dist/types/AnisotropyPbrExtension.js +2 -0
- package/dist/types/AnisotropyPbrExtension.js.map +1 -0
- package/dist/types/BlendMode.d.ts +10 -0
- package/dist/types/BlendMode.d.ts.map +1 -0
- package/dist/types/BlendMode.js +24 -0
- package/dist/types/BlendMode.js.map +1 -0
- package/dist/types/BlinnPhongMaterial.d.ts +15 -0
- package/dist/types/BlinnPhongMaterial.d.ts.map +1 -0
- package/dist/types/BlinnPhongMaterial.js +2 -0
- package/dist/types/BlinnPhongMaterial.js.map +1 -0
- package/dist/types/ClearcoatPbrExtension.d.ts +16 -0
- package/dist/types/ClearcoatPbrExtension.d.ts.map +1 -0
- package/dist/types/ClearcoatPbrExtension.js +2 -0
- package/dist/types/ClearcoatPbrExtension.js.map +1 -0
- package/dist/types/CustomShaderMaterial.d.ts +10 -0
- package/dist/types/CustomShaderMaterial.d.ts.map +1 -0
- package/dist/types/CustomShaderMaterial.js +2 -0
- package/dist/types/CustomShaderMaterial.js.map +1 -0
- package/dist/types/DepthMaterial.d.ts +8 -0
- package/dist/types/DepthMaterial.d.ts.map +1 -0
- package/dist/types/DepthMaterial.js +2 -0
- package/dist/types/DepthMaterial.js.map +1 -0
- package/dist/types/EmissiveMaterial.d.ts +10 -0
- package/dist/types/EmissiveMaterial.d.ts.map +1 -0
- package/dist/types/EmissiveMaterial.js +2 -0
- package/dist/types/EmissiveMaterial.js.map +1 -0
- package/dist/types/ExtendedPbrMaterial.d.ts +10 -0
- package/dist/types/ExtendedPbrMaterial.d.ts.map +1 -0
- package/dist/types/ExtendedPbrMaterial.js +2 -0
- package/dist/types/ExtendedPbrMaterial.js.map +1 -0
- package/dist/types/GlassExtendedPbrMaterialOptions.d.ts +8 -0
- package/dist/types/GlassExtendedPbrMaterialOptions.d.ts.map +1 -0
- package/dist/types/GlassExtendedPbrMaterialOptions.js +2 -0
- package/dist/types/GlassExtendedPbrMaterialOptions.js.map +1 -0
- package/dist/types/IridescencePbrExtension.d.ts +15 -0
- package/dist/types/IridescencePbrExtension.d.ts.map +1 -0
- package/dist/types/IridescencePbrExtension.js +2 -0
- package/dist/types/IridescencePbrExtension.js.map +1 -0
- package/dist/types/LambertMaterial.d.ts +11 -0
- package/dist/types/LambertMaterial.d.ts.map +1 -0
- package/dist/types/LambertMaterial.js +2 -0
- package/dist/types/LambertMaterial.js.map +1 -0
- package/dist/types/MatcapMaterial.d.ts +9 -0
- package/dist/types/MatcapMaterial.d.ts.map +1 -0
- package/dist/types/MatcapMaterial.js +2 -0
- package/dist/types/MatcapMaterial.js.map +1 -0
- package/dist/types/Material.d.ts +12 -0
- package/dist/types/Material.d.ts.map +1 -0
- package/dist/types/Material.js +2 -0
- package/dist/types/Material.js.map +1 -0
- package/dist/types/Material2D.d.ts +5 -0
- package/dist/types/Material2D.d.ts.map +1 -0
- package/dist/types/Material2D.js +2 -0
- package/dist/types/Material2D.js.map +1 -0
- package/dist/types/Material3D.d.ts +11 -0
- package/dist/types/Material3D.d.ts.map +1 -0
- package/dist/types/Material3D.js +2 -0
- package/dist/types/Material3D.js.map +1 -0
- package/dist/types/Material3DOptions.d.ts +9 -0
- package/dist/types/Material3DOptions.d.ts.map +1 -0
- package/dist/types/Material3DOptions.js +2 -0
- package/dist/types/Material3DOptions.js.map +1 -0
- package/dist/types/MaterialConversionExplanation.d.ts +7 -0
- package/dist/types/MaterialConversionExplanation.d.ts.map +1 -0
- package/dist/types/MaterialConversionExplanation.js +2 -0
- package/dist/types/MaterialConversionExplanation.js.map +1 -0
- package/dist/types/NormalMaterial.d.ts +9 -0
- package/dist/types/NormalMaterial.d.ts.map +1 -0
- package/dist/types/NormalMaterial.js +2 -0
- package/dist/types/NormalMaterial.js.map +1 -0
- package/dist/types/PbrExtension.d.ts +7 -0
- package/dist/types/PbrExtension.d.ts.map +1 -0
- package/dist/types/PbrExtension.js +2 -0
- package/dist/types/PbrExtension.js.map +1 -0
- package/dist/types/PhongMaterial.d.ts +14 -0
- package/dist/types/PhongMaterial.d.ts.map +1 -0
- package/dist/types/PhongMaterial.js +2 -0
- package/dist/types/PhongMaterial.js.map +1 -0
- package/dist/types/SheenPbrExtension.d.ts +13 -0
- package/dist/types/SheenPbrExtension.d.ts.map +1 -0
- package/dist/types/SheenPbrExtension.js +2 -0
- package/dist/types/SheenPbrExtension.js.map +1 -0
- package/dist/types/SpecularGlossinessPbrMaterial.d.ts +19 -0
- package/dist/types/SpecularGlossinessPbrMaterial.d.ts.map +1 -0
- package/dist/types/SpecularGlossinessPbrMaterial.js +2 -0
- package/dist/types/SpecularGlossinessPbrMaterial.js.map +1 -0
- package/dist/types/SpecularPbrExtension.d.ts +13 -0
- package/dist/types/SpecularPbrExtension.d.ts.map +1 -0
- package/dist/types/SpecularPbrExtension.js +2 -0
- package/dist/types/SpecularPbrExtension.js.map +1 -0
- package/dist/types/StandardMaterial.d.ts +7 -0
- package/dist/types/StandardMaterial.d.ts.map +1 -0
- package/dist/types/StandardMaterial.js +2 -0
- package/dist/types/StandardMaterial.js.map +1 -0
- package/dist/types/StandardPbrMaterial.d.ts +22 -0
- package/dist/types/StandardPbrMaterial.d.ts.map +1 -0
- package/dist/types/StandardPbrMaterial.js +2 -0
- package/dist/types/StandardPbrMaterial.js.map +1 -0
- package/dist/types/TintMaterialData.d.ts +5 -0
- package/dist/types/TintMaterialData.d.ts.map +1 -0
- package/dist/types/TintMaterialData.js +2 -0
- package/dist/types/TintMaterialData.js.map +1 -0
- package/dist/types/ToonMaterial.d.ts +11 -0
- package/dist/types/ToonMaterial.d.ts.map +1 -0
- package/dist/types/ToonMaterial.js +2 -0
- package/dist/types/ToonMaterial.js.map +1 -0
- package/dist/types/TransmissionVolumePbrExtension.d.ts +16 -0
- package/dist/types/TransmissionVolumePbrExtension.d.ts.map +1 -0
- package/dist/types/TransmissionVolumePbrExtension.js +2 -0
- package/dist/types/TransmissionVolumePbrExtension.js.map +1 -0
- package/dist/types/UnlitMaterial.d.ts +9 -0
- package/dist/types/UnlitMaterial.d.ts.map +1 -0
- package/dist/types/UnlitMaterial.js +2 -0
- package/dist/types/UnlitMaterial.js.map +1 -0
- package/dist/types/VertexColorMaterial.d.ts +7 -0
- package/dist/types/VertexColorMaterial.d.ts.map +1 -0
- package/dist/types/VertexColorMaterial.js +2 -0
- package/dist/types/VertexColorMaterial.js.map +1 -0
- package/dist/types/WireframeMaterial.d.ts +8 -0
- package/dist/types/WireframeMaterial.d.ts.map +1 -0
- package/dist/types/WireframeMaterial.js +2 -0
- package/dist/types/WireframeMaterial.js.map +1 -0
- package/dist/types/WrappedDiffusePbrExtension.d.ts +14 -0
- package/dist/types/WrappedDiffusePbrExtension.d.ts.map +1 -0
- package/dist/types/WrappedDiffusePbrExtension.js +2 -0
- package/dist/types/WrappedDiffusePbrExtension.js.map +1 -0
- package/dist/unlitMaterials.d.ts +1 -1
- package/dist/unlitMaterials.d.ts.map +1 -1
- package/dist/unlitMaterials.js +10 -10
- package/dist/unlitMaterials.js.map +1 -1
- package/dist/wrappedDiffusePbrExtension.d.ts +2 -1
- package/dist/wrappedDiffusePbrExtension.d.ts.map +1 -1
- package/dist/wrappedDiffusePbrExtension.js +5 -5
- package/dist/wrappedDiffusePbrExtension.js.map +1 -1
- package/package.json +9 -5
- package/src/anisotropyPbrExtension.test.ts +2 -2
- package/src/classicMaterials.test.ts +6 -4
- package/src/clearcoatPbrExtension.test.ts +2 -2
- package/src/colorScaleBias.test.ts +30 -6
- package/src/customShaderMaterial.test.ts +6 -4
- package/src/enableMaterialConversionGuards.test.ts +96 -0
- package/src/explainMaterialConversion.test.ts +55 -0
- package/src/extendedPbrMaterial.test.ts +7 -7
- package/src/iridescencePbrExtension.test.ts +9 -4
- package/src/material.test.ts +8 -6
- package/src/material3d.test.ts +78 -0
- package/src/materialPresets.test.ts +2 -3
- package/src/materialValidation.test.ts +6 -3
- package/src/pbrExtension.test.ts +1 -1
- package/src/pbrMaterials.test.ts +47 -9
- package/src/phongToPbr.test.ts +7 -5
- package/src/sheenPbrExtension.test.ts +2 -2
- package/src/specularPbrExtension.test.ts +2 -2
- package/src/standardMaterial.test.ts +2 -3
- package/src/transmissionVolumePbrExtension.test.ts +5 -3
- package/src/unlitMaterials.test.ts +2 -3
- package/src/wrappedDiffusePbrExtension.test.ts +3 -2
- package/dist/surfaceMaterial.d.ts +0 -7
- package/dist/surfaceMaterial.d.ts.map +0 -1
- package/dist/surfaceMaterial.js.map +0 -1
- package/src/surfaceMaterial.test.ts +0 -79
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlitMaterials.d.ts","sourceRoot":"","sources":["../src/unlitMaterials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,
|
|
1
|
+
{"version":3,"file":"unlitMaterials.d.ts","sourceRoot":"","sources":["../src/unlitMaterials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAevC,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,aAAa,CAK1F;AAID,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,gBAAgB,CAMnG;AAID,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,cAAc,CAK7F;AAGD,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,cAAc,CAK7F;AAID,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,YAAY,CAOvF;AAID,wBAAgB,mBAAmB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,aAAa,CAK1F;AAGD,wBAAgB,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,mBAAmB,CAI5G;AAGD,wBAAgB,uBAAuB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,iBAAiB,CAKtG"}
|
package/dist/unlitMaterials.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DepthMaterialKind, EmissiveMaterialKind, MatcapMaterialKind, NormalMaterialKind, ToonMaterialKind, UnlitMaterialKind, VertexColorMaterialKind, WireframeMaterialKind, } from '
|
|
2
|
-
import {
|
|
1
|
+
import { DepthMaterialKind, EmissiveMaterialKind, MatcapMaterialKind, NormalMaterialKind, ToonMaterialKind, UnlitMaterialKind, VertexColorMaterialKind, WireframeMaterialKind, } from './contract.materials-types.js';
|
|
2
|
+
import { createMaterial3D } from './material3d.js';
|
|
3
3
|
// Depth-output pass material. `near`/`far` default to a unit range; the depth pass overrides
|
|
4
4
|
// them with the camera's range when used as pass infrastructure.
|
|
5
5
|
export function createDepthMaterial(opts) {
|
|
6
|
-
const material =
|
|
6
|
+
const material = createMaterial3D(DepthMaterialKind, opts);
|
|
7
7
|
material.far = opts?.far ?? 1;
|
|
8
8
|
material.near = opts?.near ?? 0;
|
|
9
9
|
return material;
|
|
@@ -11,7 +11,7 @@ export function createDepthMaterial(opts) {
|
|
|
11
11
|
// Self-illuminating, lighting-independent material. `emissive` defaults to white,
|
|
12
12
|
// `emissiveStrength` to 1 (> 1 drives bloom on GPU backends), the map to null.
|
|
13
13
|
export function createEmissiveMaterial(opts) {
|
|
14
|
-
const material =
|
|
14
|
+
const material = createMaterial3D(EmissiveMaterialKind, opts);
|
|
15
15
|
material.emissive = opts?.emissive ?? 0xffffffff;
|
|
16
16
|
material.emissiveMap = opts?.emissiveMap ?? null;
|
|
17
17
|
material.emissiveStrength = opts?.emissiveStrength ?? 1;
|
|
@@ -20,14 +20,14 @@ export function createEmissiveMaterial(opts) {
|
|
|
20
20
|
// Material-capture (matcap) material: a prebaked lit sphere sampled by the view-space normal.
|
|
21
21
|
// `matcap` defaults to null, `tint` to white. Lighting-independent.
|
|
22
22
|
export function createMatcapMaterial(opts) {
|
|
23
|
-
const material =
|
|
23
|
+
const material = createMaterial3D(MatcapMaterialKind, opts);
|
|
24
24
|
material.matcap = opts?.matcap ?? null;
|
|
25
25
|
material.tint = opts?.tint ?? 0xffffffff;
|
|
26
26
|
return material;
|
|
27
27
|
}
|
|
28
28
|
// Normal-output pass material. `normalMap` defaults to null, `normalScale` to 1.
|
|
29
29
|
export function createNormalMaterial(opts) {
|
|
30
|
-
const material =
|
|
30
|
+
const material = createMaterial3D(NormalMaterialKind, opts);
|
|
31
31
|
material.normalMap = opts?.normalMap ?? null;
|
|
32
32
|
material.normalScale = opts?.normalScale ?? 1;
|
|
33
33
|
return material;
|
|
@@ -35,7 +35,7 @@ export function createNormalMaterial(opts) {
|
|
|
35
35
|
// Cel-shaded material: diffuse N·L quantized through a 1D ramp into stepped bands. `baseColor`
|
|
36
36
|
// defaults to white, maps to null, `steps` to 3 (the band count used when no ramp is bound).
|
|
37
37
|
export function createToonMaterial(opts) {
|
|
38
|
-
const material =
|
|
38
|
+
const material = createMaterial3D(ToonMaterialKind, opts);
|
|
39
39
|
material.baseColor = opts?.baseColor ?? 0xffffffff;
|
|
40
40
|
material.baseColorMap = opts?.baseColorMap ?? null;
|
|
41
41
|
material.ramp = opts?.ramp ?? null;
|
|
@@ -45,20 +45,20 @@ export function createToonMaterial(opts) {
|
|
|
45
45
|
// Lighting-independent flat-color material. `baseColor` defaults to white and the universal sampled
|
|
46
46
|
// map (still, video, or produced target) defaults to null.
|
|
47
47
|
export function createUnlitMaterial(opts) {
|
|
48
|
-
const material =
|
|
48
|
+
const material = createMaterial3D(UnlitMaterialKind, opts);
|
|
49
49
|
material.baseColor = opts?.baseColor ?? 0xffffffff;
|
|
50
50
|
material.baseColorMap = opts?.baseColorMap ?? null;
|
|
51
51
|
return material;
|
|
52
52
|
}
|
|
53
53
|
// Uses the mesh's `color0` vertex attribute as unlit surface color. `tint` defaults to white.
|
|
54
54
|
export function createVertexColorMaterial(opts) {
|
|
55
|
-
const material =
|
|
55
|
+
const material = createMaterial3D(VertexColorMaterialKind, opts);
|
|
56
56
|
material.tint = opts?.tint ?? 0xffffffff;
|
|
57
57
|
return material;
|
|
58
58
|
}
|
|
59
59
|
// Edge-only debug material. `color` defaults to white, `thickness` to 1 pixel. No maps.
|
|
60
60
|
export function createWireframeMaterial(opts) {
|
|
61
|
-
const material =
|
|
61
|
+
const material = createMaterial3D(WireframeMaterialKind, opts);
|
|
62
62
|
material.color = opts?.color ?? 0xffffffff;
|
|
63
63
|
material.thickness = opts?.thickness ?? 1;
|
|
64
64
|
return material;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlitMaterials.js","sourceRoot":"","sources":["../src/unlitMaterials.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACt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,GAAG,gBAAgB,CAAC,uBAAuB,EAAE,IAAI,CAAwB,CAAC;IACxF,QAAQ,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,UAAU,CAAC;IACzC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,uBAAuB,CAAC,IAA2C;IACjF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,qBAAqB,EAAE,IAAI,CAAsB,CAAC;IACpF,QAAQ,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,UAAU,CAAC;IAC3C,QAAQ,CAAC,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC;IAC1C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
2
|
+
import type { WrappedDiffusePbrExtension } from './contract.materials-types.ts';
|
|
2
3
|
export declare function createWrappedDiffusePbrExtension(opts?: Readonly<Partial<WrappedDiffusePbrExtension>>): WrappedDiffusePbrExtension;
|
|
3
4
|
export declare function initializeWrappedDiffusePbrExtension(out: EntityConstruction<WrappedDiffusePbrExtension>, opts?: Readonly<Partial<WrappedDiffusePbrExtension>>): void;
|
|
4
5
|
export declare function isValidWrappedDiffusePbrExtension(value: Readonly<WrappedDiffusePbrExtension>): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrappedDiffusePbrExtension.d.ts","sourceRoot":"","sources":["../src/wrappedDiffusePbrExtension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"wrappedDiffusePbrExtension.d.ts","sourceRoot":"","sources":["../src/wrappedDiffusePbrExtension.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAKhF,wBAAgB,gCAAgC,CAC9C,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,GACnD,0BAA0B,CAI5B;AAED,wBAAgB,oCAAoC,CAClD,GAAG,EAAE,kBAAkB,CAAC,0BAA0B,CAAC,EACnD,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,GACnD,IAAI,CASN;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAAG,OAAO,CAQtG"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import { WrappedDiffusePbrExtensionKind } from '
|
|
3
|
-
import { isValidMaterialWeight } from './materialValidation';
|
|
4
|
-
import { isValidPbrUvSet } from './pbrExtension';
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { WrappedDiffusePbrExtensionKind } from './contract.materials-types.js';
|
|
3
|
+
import { isValidMaterialWeight } from './materialValidation.js';
|
|
4
|
+
import { isValidPbrUvSet } from './pbrExtension.js';
|
|
5
5
|
export function createWrappedDiffusePbrExtension(opts) {
|
|
6
6
|
const out = allocateEntity();
|
|
7
7
|
initializeWrappedDiffusePbrExtension(out, opts);
|
|
8
|
-
return
|
|
8
|
+
return out;
|
|
9
9
|
}
|
|
10
10
|
export function initializeWrappedDiffusePbrExtension(out, opts) {
|
|
11
11
|
out.kind = WrappedDiffusePbrExtensionKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrappedDiffusePbrExtension.js","sourceRoot":"","sources":["../src/wrappedDiffusePbrExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"wrappedDiffusePbrExtension.js","sourceRoot":"","sources":["../src/wrappedDiffusePbrExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,E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C,CAC9C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/materials",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,18 +32,22 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
34
|
"clean": "tsc -b --clean",
|
|
35
|
+
"generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-materials --package materials",
|
|
36
|
+
"generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-materials --package materials --check",
|
|
35
37
|
"test": "vitest run --config vitest.config.ts",
|
|
36
38
|
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
39
|
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
40
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
43
|
-
"@flighthq/
|
|
43
|
+
"@flighthq/adjustments": "0.6.0",
|
|
44
|
+
"@flighthq/color": "0.6.0",
|
|
45
|
+
"@flighthq/entity": "0.6.0",
|
|
46
|
+
"@flighthq/log": "0.6.0",
|
|
47
|
+
"@flighthq/texture": "0.6.0"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
|
-
"typescript": "^
|
|
50
|
+
"typescript": "^7.0.2"
|
|
47
51
|
},
|
|
48
52
|
"description": "Color transform and material utilities",
|
|
49
53
|
"sideEffects": false
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EntityRuntimeKey } from '@flighthq/
|
|
1
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createAnisotropyPbrExtension,
|
|
5
5
|
initializeAnisotropyPbrExtension,
|
|
6
6
|
isValidAnisotropyPbrExtension,
|
|
7
|
-
} from './anisotropyPbrExtension';
|
|
7
|
+
} from './anisotropyPbrExtension.ts';
|
|
8
8
|
|
|
9
9
|
describe('createAnisotropyPbrExtension', () => {
|
|
10
10
|
it('creates an Entity with canonical defaults and per-map UV selection', () => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { createBlinnPhongMaterial, createLambertMaterial, createPhongMaterial } from './classicMaterials';
|
|
1
|
+
import { createBlinnPhongMaterial, createLambertMaterial, createPhongMaterial } from './classicMaterials.ts';
|
|
2
|
+
import { BlinnPhongMaterialKind, LambertMaterialKind, PhongMaterialKind } from './contract.materials-types.ts';
|
|
4
3
|
|
|
5
4
|
describe('createBlinnPhongMaterial', () => {
|
|
6
5
|
it('creates a white Blinn-Phong material with a shininess of 32', () => {
|
|
@@ -18,7 +17,10 @@ describe('createBlinnPhongMaterial', () => {
|
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
it('forwards the surface trailer so an alpha-mapped cutout is expressible through the constructor', () => {
|
|
21
|
-
const material = createBlinnPhongMaterial({
|
|
20
|
+
const material = createBlinnPhongMaterial({
|
|
21
|
+
alphaCutoff: 0.3,
|
|
22
|
+
alphaMode: 'mask',
|
|
23
|
+
});
|
|
22
24
|
expect(material.alphaMode).toBe('mask');
|
|
23
25
|
expect(material.alphaCutoff).toBe(0.3);
|
|
24
26
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { EntityRuntimeKey } from '@flighthq/
|
|
1
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createClearcoatPbrExtension,
|
|
5
5
|
initializeClearcoatPbrExtension,
|
|
6
6
|
isValidClearcoatPbrExtension,
|
|
7
|
-
} from './clearcoatPbrExtension';
|
|
7
|
+
} from './clearcoatPbrExtension.ts';
|
|
8
8
|
|
|
9
9
|
describe('createClearcoatPbrExtension', () => {
|
|
10
10
|
it('creates an Entity with an explicit normal scale and independent UV sets', () => {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
setColorScaleBiasBiasRgba,
|
|
18
18
|
} from '@flighthq/materials/contract';
|
|
19
19
|
|
|
20
|
-
import { initializeColorScaleBias } from './colorScaleBias';
|
|
20
|
+
import { initializeColorScaleBias } from './colorScaleBias.ts';
|
|
21
21
|
|
|
22
22
|
describe('cloneColorScaleBias', () => {
|
|
23
23
|
it('returns a new object with identical values', () => {
|
|
@@ -40,7 +40,12 @@ describe('concatColorScaleBias', () => {
|
|
|
40
40
|
it('composes two setColorScaleBiasIdentity transforms into setColorScaleBiasIdentity', () => {
|
|
41
41
|
const a = createColorScaleBias();
|
|
42
42
|
const b = createColorScaleBias();
|
|
43
|
-
const out = createColorScaleBias({
|
|
43
|
+
const out = createColorScaleBias({
|
|
44
|
+
redScale: 0,
|
|
45
|
+
greenScale: 0,
|
|
46
|
+
blueScale: 0,
|
|
47
|
+
alphaScale: 0,
|
|
48
|
+
});
|
|
44
49
|
concatColorScaleBias(out, a, b);
|
|
45
50
|
expect(out.redScale).toBe(1);
|
|
46
51
|
expect(out.greenScale).toBe(1);
|
|
@@ -140,7 +145,12 @@ describe('concatColorScaleBias', () => {
|
|
|
140
145
|
|
|
141
146
|
describe('copyColorScaleBias', () => {
|
|
142
147
|
it('copies all fields from source to out', () => {
|
|
143
|
-
const source = createColorScaleBias({
|
|
148
|
+
const source = createColorScaleBias({
|
|
149
|
+
redScale: 0.5,
|
|
150
|
+
greenBias: 128,
|
|
151
|
+
alphaScale: 0.8,
|
|
152
|
+
blueBias: 64,
|
|
153
|
+
});
|
|
144
154
|
const out = createColorScaleBias();
|
|
145
155
|
copyColorScaleBias(out, source);
|
|
146
156
|
expect(out.redScale).toBe(0.5);
|
|
@@ -281,7 +291,11 @@ describe('equalsColorScaleBiasScales', () => {
|
|
|
281
291
|
|
|
282
292
|
describe('getColorScaleBiasBiasRgb', () => {
|
|
283
293
|
it('packs red, green, blue biases into a single integer', () => {
|
|
284
|
-
const ct = createColorScaleBias({
|
|
294
|
+
const ct = createColorScaleBias({
|
|
295
|
+
redBias: 1,
|
|
296
|
+
greenBias: 0x80 / 255,
|
|
297
|
+
blueBias: 0x10 / 255,
|
|
298
|
+
});
|
|
285
299
|
const packed = getColorScaleBiasBiasRgb(ct);
|
|
286
300
|
expect((packed >> 16) & 0xff).toBe(0xff);
|
|
287
301
|
expect((packed >> 8) & 0xff).toBe(0x80);
|
|
@@ -336,7 +350,12 @@ describe('invertColorScaleBias', () => {
|
|
|
336
350
|
});
|
|
337
351
|
|
|
338
352
|
it('negates biases', () => {
|
|
339
|
-
const source = createColorScaleBias({
|
|
353
|
+
const source = createColorScaleBias({
|
|
354
|
+
redBias: 64,
|
|
355
|
+
greenBias: -32,
|
|
356
|
+
blueBias: 128,
|
|
357
|
+
alphaBias: -10,
|
|
358
|
+
});
|
|
340
359
|
const out = createColorScaleBias();
|
|
341
360
|
invertColorScaleBias(out, source);
|
|
342
361
|
expect(out.redBias).toBe(-64);
|
|
@@ -435,7 +454,12 @@ describe('setColorScaleBiasBiasRgba', () => {
|
|
|
435
454
|
});
|
|
436
455
|
describe('setColorScaleBiasIdentity', () => {
|
|
437
456
|
it('resets scales to 1 and biases to 0', () => {
|
|
438
|
-
const ct = createColorScaleBias({
|
|
457
|
+
const ct = createColorScaleBias({
|
|
458
|
+
redScale: 0.5,
|
|
459
|
+
greenBias: 128,
|
|
460
|
+
alphaScale: 0,
|
|
461
|
+
blueBias: 64,
|
|
462
|
+
});
|
|
439
463
|
setColorScaleBiasIdentity(ct);
|
|
440
464
|
expect(ct.redScale).toBe(1);
|
|
441
465
|
expect(ct.greenScale).toBe(1);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CustomShaderMaterialKind } from '
|
|
2
|
-
|
|
3
|
-
import { createCustomShaderMaterial } from './customShaderMaterial';
|
|
1
|
+
import { CustomShaderMaterialKind } from './contract.materials-types.ts';
|
|
2
|
+
import { createCustomShaderMaterial } from './customShaderMaterial.ts';
|
|
4
3
|
|
|
5
4
|
describe('createCustomShaderMaterial', () => {
|
|
6
5
|
it('creates a custom shader material with default sentinel values', () => {
|
|
@@ -13,7 +12,10 @@ describe('createCustomShaderMaterial', () => {
|
|
|
13
12
|
|
|
14
13
|
it('applies overrides', () => {
|
|
15
14
|
const uniforms = { u_time: 1.5, u_scale: [2, 3] };
|
|
16
|
-
const material = createCustomShaderMaterial({
|
|
15
|
+
const material = createCustomShaderMaterial({
|
|
16
|
+
shaderKey: 'myShader',
|
|
17
|
+
uniforms,
|
|
18
|
+
});
|
|
17
19
|
expect(material.shaderKey).toBe('myShader');
|
|
18
20
|
expect(material.uniforms).toBe(uniforms);
|
|
19
21
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { addLogSink, createLogState, createMemoryLogSink, getMemoryLogSinkEntries } from '@flighthq/log/contract';
|
|
2
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
3
|
+
import type { LogEntry } from '@flighthq/log/contract';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { createPhongMaterial } from './classicMaterials.ts';
|
|
7
|
+
import { disableMaterialConversionGuards, enableMaterialConversionGuards } from './enableMaterialConversionGuards.ts';
|
|
8
|
+
import {
|
|
9
|
+
convertSpecularGlossinessToStandardPbr,
|
|
10
|
+
createSpecularGlossinessPbrMaterial,
|
|
11
|
+
createStandardPbrMaterial,
|
|
12
|
+
} from './pbrMaterials.ts';
|
|
13
|
+
import { convertPhongToStandardPbrMaterial } from './phongToPbr.ts';
|
|
14
|
+
|
|
15
|
+
// logOnce dedupes by key for the life of its LogState, so each test gets a fresh state — otherwise the
|
|
16
|
+
// first test to warn under a given key would silence every later one.
|
|
17
|
+
let logState: LogState;
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
logState = createLogState();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
disableMaterialConversionGuards();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const texture = {} as never;
|
|
28
|
+
|
|
29
|
+
function captureLog(run: () => void): readonly LogEntry[] {
|
|
30
|
+
const sink = createMemoryLogSink(8);
|
|
31
|
+
addLogSink(logState, sink.sink);
|
|
32
|
+
run();
|
|
33
|
+
const entries: LogEntry[] = [];
|
|
34
|
+
getMemoryLogSinkEntries(entries, sink);
|
|
35
|
+
return entries;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function messageOf(entry: Readonly<LogEntry>): string {
|
|
39
|
+
const data = entry.data;
|
|
40
|
+
return typeof data === 'string' ? data : String(data.message);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('disableMaterialConversionGuards', () => {
|
|
44
|
+
it('restores the silent conversion', () => {
|
|
45
|
+
const entries = captureLog(() => {
|
|
46
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
47
|
+
disableMaterialConversionGuards();
|
|
48
|
+
convertPhongToStandardPbrMaterial(createPhongMaterial({ specularMap: texture }));
|
|
49
|
+
});
|
|
50
|
+
expect(entries).toEqual([]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('enableMaterialConversionGuards', () => {
|
|
55
|
+
it('WARNS when the spec-gloss conversion drops its packed map, telling the caller to bake', () => {
|
|
56
|
+
const entries = captureLog(() => {
|
|
57
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
58
|
+
convertSpecularGlossinessToStandardPbr(
|
|
59
|
+
createStandardPbrMaterial(),
|
|
60
|
+
createSpecularGlossinessPbrMaterial({ specularGlossinessMap: texture }),
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
expect(entries).toHaveLength(1);
|
|
64
|
+
expect(messageOf(entries[0])).toContain('convertSpecularGlossinessToStandardPbr');
|
|
65
|
+
// The remedy has to be in the message, or the reader learns only that something vanished.
|
|
66
|
+
expect(messageOf(entries[0])).toContain('Bake');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('WARNS SEPARATELY for the Phong conversion, so one does not silence the other', () => {
|
|
70
|
+
const entries = captureLog(() => {
|
|
71
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
72
|
+
convertSpecularGlossinessToStandardPbr(
|
|
73
|
+
createStandardPbrMaterial(),
|
|
74
|
+
createSpecularGlossinessPbrMaterial({ specularGlossinessMap: texture }),
|
|
75
|
+
);
|
|
76
|
+
convertPhongToStandardPbrMaterial(createPhongMaterial({ specularMap: texture }));
|
|
77
|
+
});
|
|
78
|
+
// logOnce is keyed per conversion: two converters dropping maps in one process must both be heard.
|
|
79
|
+
expect(entries).toHaveLength(2);
|
|
80
|
+
expect(messageOf(entries[1])).toContain('convertPhongToStandardPbrMaterial');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('stays SILENT when the conversion loses nothing', () => {
|
|
84
|
+
const entries = captureLog(() => {
|
|
85
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
86
|
+
convertSpecularGlossinessToStandardPbr(createStandardPbrMaterial(), createSpecularGlossinessPbrMaterial());
|
|
87
|
+
convertPhongToStandardPbrMaterial(createPhongMaterial());
|
|
88
|
+
});
|
|
89
|
+
expect(entries).toEqual([]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('stays SILENT without the guard — the production default', () => {
|
|
93
|
+
const entries = captureLog(() => convertPhongToStandardPbrMaterial(createPhongMaterial({ specularMap: texture })));
|
|
94
|
+
expect(entries).toEqual([]);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { createPhongMaterial } from './classicMaterials.ts';
|
|
4
|
+
import { explainPhongConversion, explainSpecularGlossinessConversion } from './explainMaterialConversion.ts';
|
|
5
|
+
import { createSpecularGlossinessPbrMaterial } from './pbrMaterials.ts';
|
|
6
|
+
|
|
7
|
+
const texture = {} as never;
|
|
8
|
+
|
|
9
|
+
describe('explainPhongConversion', () => {
|
|
10
|
+
it('names specularMap as dropped, because standard PBR has no slot for that quantity', () => {
|
|
11
|
+
const phong = createPhongMaterial({ specularMap: texture });
|
|
12
|
+
expect(explainPhongConversion(phong)).toEqual({
|
|
13
|
+
droppedMaps: ['specularMap'],
|
|
14
|
+
reason: 'unsupported-by-target-model',
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('reports an empty list when there is nothing to lose', () => {
|
|
19
|
+
// The case a caller has to be able to tell apart from the lossy one: a lossless conversion and a
|
|
20
|
+
// lossy one must not read the same.
|
|
21
|
+
expect(explainPhongConversion(createPhongMaterial())).toEqual({
|
|
22
|
+
droppedMaps: [],
|
|
23
|
+
reason: null,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('explainSpecularGlossinessConversion', () => {
|
|
29
|
+
it('names the packed map and why no assignment could have preserved it', () => {
|
|
30
|
+
const source = createSpecularGlossinessPbrMaterial({
|
|
31
|
+
specularGlossinessMap: texture,
|
|
32
|
+
});
|
|
33
|
+
// incompatible-channel-semantics, not unsupported: the target HAS a texture slot, but assigning to
|
|
34
|
+
// it would be wrong rather than lossy — specular/glossiness and metallic/roughness pack different
|
|
35
|
+
// quantities. That distinction is what tells a caller to bake rather than to look for a copy.
|
|
36
|
+
expect(explainSpecularGlossinessConversion(source)).toEqual({
|
|
37
|
+
droppedMaps: ['specularGlossinessMap'],
|
|
38
|
+
reason: 'incompatible-channel-semantics',
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('reports an empty list for a factor-only source', () => {
|
|
43
|
+
expect(explainSpecularGlossinessConversion(createSpecularGlossinessPbrMaterial())).toEqual({
|
|
44
|
+
droppedMaps: [],
|
|
45
|
+
reason: null,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('retains nothing, so repeated queries agree', () => {
|
|
50
|
+
const source = createSpecularGlossinessPbrMaterial({
|
|
51
|
+
specularGlossinessMap: texture,
|
|
52
|
+
});
|
|
53
|
+
expect(explainSpecularGlossinessConversion(source)).toEqual(explainSpecularGlossinessConversion(source));
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { allocateEntity
|
|
2
|
-
import { ExtendedPbrMaterialKind } from '@flighthq/types/contract';
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
3
2
|
|
|
4
|
-
import { createClearcoatPbrExtension } from './clearcoatPbrExtension';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { createClearcoatPbrExtension } from './clearcoatPbrExtension.ts';
|
|
4
|
+
import { ExtendedPbrMaterialKind } from './contract.materials-types.ts';
|
|
5
|
+
import { createExtendedPbrMaterial } from './extendedPbrMaterial.ts';
|
|
6
|
+
import { createStandardPbrMaterialProperties } from './pbrMaterials.ts';
|
|
7
7
|
|
|
8
8
|
describe('createExtendedPbrMaterial', () => {
|
|
9
9
|
it('composes a standard property block with an ordered extension list', () => {
|
|
@@ -11,9 +11,9 @@ describe('createExtendedPbrMaterial', () => {
|
|
|
11
11
|
const extensions = [
|
|
12
12
|
createClearcoatPbrExtension(),
|
|
13
13
|
(() => {
|
|
14
|
-
const out = allocateEntity<any>();
|
|
14
|
+
const out = allocateEntity<any>() as any;
|
|
15
15
|
out.kind = 'VendorPbrExtension';
|
|
16
|
-
return
|
|
16
|
+
return out;
|
|
17
17
|
})(),
|
|
18
18
|
];
|
|
19
19
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { EntityRuntimeKey } from '@flighthq/
|
|
1
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createIridescencePbrExtension,
|
|
5
5
|
initializeIridescencePbrExtension,
|
|
6
6
|
isValidIridescencePbrExtension,
|
|
7
|
-
} from './iridescencePbrExtension';
|
|
7
|
+
} from './iridescencePbrExtension.ts';
|
|
8
8
|
|
|
9
9
|
describe('createIridescencePbrExtension', () => {
|
|
10
10
|
it('creates an Entity with glTF thickness defaults and independent UV sets', () => {
|
|
11
|
-
const value = createIridescencePbrExtension({
|
|
11
|
+
const value = createIridescencePbrExtension({
|
|
12
|
+
iridescenceThicknessMapUvSet: 1,
|
|
13
|
+
});
|
|
12
14
|
expect(EntityRuntimeKey in value).toBe(true);
|
|
13
15
|
expect(value.iridescenceIor).toBe(1.3);
|
|
14
16
|
expect(value.iridescenceThicknessMin).toBe(100);
|
|
@@ -29,7 +31,10 @@ describe('isValidIridescencePbrExtension', () => {
|
|
|
29
31
|
expect(isValidIridescencePbrExtension(createIridescencePbrExtension({ iridescenceIor: 0.5 }))).toBe(false);
|
|
30
32
|
expect(
|
|
31
33
|
isValidIridescencePbrExtension(
|
|
32
|
-
createIridescencePbrExtension({
|
|
34
|
+
createIridescencePbrExtension({
|
|
35
|
+
iridescenceThicknessMax: 100,
|
|
36
|
+
iridescenceThicknessMin: 200,
|
|
37
|
+
}),
|
|
33
38
|
),
|
|
34
39
|
).toBe(false);
|
|
35
40
|
const invalidUv = createIridescencePbrExtension();
|
package/src/material.test.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { BlinnPhongMaterial, StandardPbrMaterial } from '
|
|
2
|
-
import { BlinnPhongMaterialKind, StandardPbrMaterialKind } from '
|
|
3
|
-
|
|
1
|
+
import type { BlinnPhongMaterial, StandardPbrMaterial } from './contract.materials-types.ts';
|
|
2
|
+
import { BlinnPhongMaterialKind, StandardPbrMaterialKind } from './contract.materials-types.ts';
|
|
4
3
|
import {
|
|
5
4
|
cloneMaterial,
|
|
6
5
|
copyMaterial,
|
|
@@ -8,8 +7,8 @@ import {
|
|
|
8
7
|
equalsMaterial,
|
|
9
8
|
getMaterialOfKind,
|
|
10
9
|
initializeMaterial,
|
|
11
|
-
} from './material';
|
|
12
|
-
import { createStandardPbrMaterial } from './pbrMaterials';
|
|
10
|
+
} from './material.ts';
|
|
11
|
+
import { createStandardPbrMaterial } from './pbrMaterials.ts';
|
|
13
12
|
|
|
14
13
|
const TestMaterialKind = 'TestMaterial';
|
|
15
14
|
const OtherMaterialKind = 'OtherMaterial';
|
|
@@ -22,7 +21,10 @@ describe('cloneMaterial', () => {
|
|
|
22
21
|
expect(clone.kind).toBe(TestMaterialKind);
|
|
23
22
|
});
|
|
24
23
|
it('copies scalar fields from a standard PBR material', () => {
|
|
25
|
-
const original = createStandardPbrMaterial({
|
|
24
|
+
const original = createStandardPbrMaterial({
|
|
25
|
+
metallic: 0.5,
|
|
26
|
+
roughness: 0.25,
|
|
27
|
+
});
|
|
26
28
|
const clone = cloneMaterial(original);
|
|
27
29
|
const clonePbr = clone as StandardPbrMaterial;
|
|
28
30
|
expect(clonePbr.metallic).toBe(0.5);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { BlendMode } from './contract.materials-types.ts';
|
|
2
|
+
import {
|
|
3
|
+
createMaterial3D,
|
|
4
|
+
getMaterial3DAlphaMode,
|
|
5
|
+
isMaterial3DBlended,
|
|
6
|
+
isMaterial3DMasked,
|
|
7
|
+
isMaterial3DOpaque,
|
|
8
|
+
} from './material3d.ts';
|
|
9
|
+
|
|
10
|
+
const TestMaterial3DKind = 'TestMaterial3D';
|
|
11
|
+
|
|
12
|
+
describe('createMaterial3D', () => {
|
|
13
|
+
it('carries the given kind', () => {
|
|
14
|
+
expect(createMaterial3D(TestMaterial3DKind).kind).toBe(TestMaterial3DKind);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('defaults the shared trailer to an opaque, single-sided surface', () => {
|
|
18
|
+
const material = createMaterial3D(TestMaterial3DKind);
|
|
19
|
+
expect(material.alphaMode).toBe('opaque');
|
|
20
|
+
expect(material.alphaCutoff).toBe(0.5);
|
|
21
|
+
expect(material.blendMode).toBe(BlendMode.Normal);
|
|
22
|
+
expect(material.doubleSided).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('forwards the shared trailer fields from opts', () => {
|
|
26
|
+
const material = createMaterial3D(TestMaterial3DKind, {
|
|
27
|
+
alphaCutoff: 0.25,
|
|
28
|
+
alphaMode: 'mask',
|
|
29
|
+
doubleSided: true,
|
|
30
|
+
});
|
|
31
|
+
expect(material.alphaMode).toBe('mask');
|
|
32
|
+
expect(material.alphaCutoff).toBe(0.25);
|
|
33
|
+
expect(material.doubleSided).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('getMaterial3DAlphaMode', () => {
|
|
38
|
+
it('returns the alphaMode of the material', () => {
|
|
39
|
+
const opaque = createMaterial3D(TestMaterial3DKind);
|
|
40
|
+
expect(getMaterial3DAlphaMode(opaque)).toBe('opaque');
|
|
41
|
+
const blended = createMaterial3D(TestMaterial3DKind);
|
|
42
|
+
blended.alphaMode = 'blend';
|
|
43
|
+
expect(getMaterial3DAlphaMode(blended)).toBe('blend');
|
|
44
|
+
const masked = createMaterial3D(TestMaterial3DKind);
|
|
45
|
+
masked.alphaMode = 'mask';
|
|
46
|
+
expect(getMaterial3DAlphaMode(masked)).toBe('mask');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('isMaterial3DBlended', () => {
|
|
51
|
+
it('returns true only for blend mode', () => {
|
|
52
|
+
const opaque = createMaterial3D(TestMaterial3DKind);
|
|
53
|
+
expect(isMaterial3DBlended(opaque)).toBe(false);
|
|
54
|
+
const blended = createMaterial3D(TestMaterial3DKind);
|
|
55
|
+
blended.alphaMode = 'blend';
|
|
56
|
+
expect(isMaterial3DBlended(blended)).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('isMaterial3DMasked', () => {
|
|
61
|
+
it('returns true only for mask mode', () => {
|
|
62
|
+
const opaque = createMaterial3D(TestMaterial3DKind);
|
|
63
|
+
expect(isMaterial3DMasked(opaque)).toBe(false);
|
|
64
|
+
const masked = createMaterial3D(TestMaterial3DKind);
|
|
65
|
+
masked.alphaMode = 'mask';
|
|
66
|
+
expect(isMaterial3DMasked(masked)).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('isMaterial3DOpaque', () => {
|
|
71
|
+
it('returns true only for opaque mode', () => {
|
|
72
|
+
const opaque = createMaterial3D(TestMaterial3DKind);
|
|
73
|
+
expect(isMaterial3DOpaque(opaque)).toBe(true);
|
|
74
|
+
const blended = createMaterial3D(TestMaterial3DKind);
|
|
75
|
+
blended.alphaMode = 'blend';
|
|
76
|
+
expect(isMaterial3DOpaque(blended)).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
});
|