@flighthq/materials 0.5.1-next.3308.79ae053 → 0.5.1-next.4305.c5b7dc0
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/enableMaterialConversionGuards.d.ts +2 -1
- package/dist/enableMaterialConversionGuards.d.ts.map +1 -1
- package/dist/enableMaterialConversionGuards.js +6 -5
- package/dist/enableMaterialConversionGuards.js.map +1 -1
- package/dist/pbrMaterials.d.ts.map +1 -1
- package/dist/pbrMaterials.js +11 -24
- package/dist/pbrMaterials.js.map +1 -1
- package/package.json +5 -5
- package/src/enableMaterialConversionGuards.test.ts +20 -22
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/materials`. The `@fl
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/materials@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/materials@0.5.1-next.4305.c5b7dc0](https://github.com/flighthq/flight/tree/c5b7dc0276d23e5772eb5aa05cdff1a91777141f/packages/materials)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/c5b7dc0276d23e5772eb5aa05cdff1a91777141f/LICENSE.md)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
1
2
|
export declare function disableMaterialConversionGuards(): void;
|
|
2
|
-
export declare function enableMaterialConversionGuards(): void;
|
|
3
|
+
export declare function enableMaterialConversionGuards(logState: LogState, clock: () => number): void;
|
|
3
4
|
//# sourceMappingURL=enableMaterialConversionGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableMaterialConversionGuards.d.ts","sourceRoot":"","sources":["../src/enableMaterialConversionGuards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"enableMaterialConversionGuards.d.ts","sourceRoot":"","sources":["../src/enableMaterialConversionGuards.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOvD,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAUD,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,MAAM,GAAG,IAAI,CAI5F"}
|
|
@@ -11,15 +11,16 @@ export function disableMaterialConversionGuards() {
|
|
|
11
11
|
// the conversion and the remedy.
|
|
12
12
|
//
|
|
13
13
|
// Not calling this — the production default — costs the conversion nothing: the messages and the
|
|
14
|
-
// `@flighthq/log` dependency live only in this separately-imported module.
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// `@flighthq/log` dependency live only in this separately-imported module. Warnings go to the
|
|
15
|
+
// caller-owned `logState`, stamped with `clock()` at the moment a conversion drops a map. Idempotent.
|
|
16
|
+
export function enableMaterialConversionGuards(logState, clock) {
|
|
17
|
+
setMaterialConversionGuard((explanation, conversion) => warnMaterialConversionDrop(logState, clock(), explanation, conversion));
|
|
17
18
|
}
|
|
18
|
-
function warnMaterialConversionDrop(explanation, conversion) {
|
|
19
|
+
function warnMaterialConversionDrop(logState, nowMs, explanation, conversion) {
|
|
19
20
|
const maps = explanation.droppedMaps.join(', ');
|
|
20
21
|
// Keyed by conversion so two different converters each get heard once, rather than the first one
|
|
21
22
|
// silencing the second for the rest of the process.
|
|
22
|
-
logOnce(`materials:conversion-dropped-map:${conversion}`, LogLevel.Warn, {
|
|
23
|
+
logOnce(logState, nowMs, `materials:conversion-dropped-map:${conversion}`, LogLevel.Warn, {
|
|
23
24
|
message: explanation.reason === 'incompatible-channel-semantics'
|
|
24
25
|
? `${conversion} discarded ${maps}: its channels pack different quantities than the target slot, so no assignment preserves meaning. Bake the texture into the target's own layout and pass it explicitly.`
|
|
25
26
|
: `${conversion} discarded ${maps}: the target material model has no slot for that quantity. Supply the nearest target map explicitly if the surface needs it.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableMaterialConversionGuards.js","sourceRoot":"","sources":["../src/enableMaterialConversionGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"enableMaterialConversionGuards.js","sourceRoot":"","sources":["../src/enableMaterialConversionGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,yDAAyD;AACzD,MAAM,UAAU,+BAA+B;IAC7C,0BAA0B,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,oGAAoG;AACpG,kGAAkG;AAClG,wGAAwG;AACxG,iCAAiC;AACjC,EAAE;AACF,iGAAiG;AACjG,8FAA8F;AAC9F,sGAAsG;AACtG,MAAM,UAAU,8BAA8B,CAAC,QAAkB,EAAE,KAAmB;IACpF,0BAA0B,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CACrD,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,CAAC,CACvE,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B,CACjC,QAAkB,EAClB,KAAa,EACb,WAAoD,EACpD,UAAkB;IAElB,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,iGAAiG;IACjG,oDAAoD;IACpD,OAAO,CACL,QAAQ,EACR,KAAK,EACL,oCAAoC,UAAU,EAAE,EAChD,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,WAAW,CAAC,MAAM,KAAK,gCAAgC;YACrD,CAAC,CAAC,GAAG,UAAU,cAAc,IAAI,0KAA0K;YAC3M,CAAC,CAAC,GAAG,UAAU,cAAc,IAAI,8HAA8H;KACpK,EACD,WAAW,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrMaterials.d.ts","sourceRoot":"","sources":["../src/pbrMaterials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAoBlC,wBAAgB,sCAAsC,CACpD,GAAG,EAAE,6BAA6B,EAClC,MAAM,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GAC9C,IAAI,CA0DN;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,qBAAqB,CAAC,6BAA6B,EAAE,YAAY,CAAC,CAIpE;
|
|
1
|
+
{"version":3,"file":"pbrMaterials.d.ts","sourceRoot":"","sources":["../src/pbrMaterials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,6BAA6B,EAC7B,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,0BAA0B,CAAC;AAoBlC,wBAAgB,sCAAsC,CACpD,GAAG,EAAE,6BAA6B,EAClC,MAAM,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GAC9C,IAAI,CA0DN;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,qBAAqB,CAAC,6BAA6B,EAAE,YAAY,CAAC,CAIpE;AA6BD,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,QAAQ,CAAC,6BAA6B,CAAC,EACpD,UAAU,EAAE,MAAM,GACjB,IAAI,CAEN;AAKD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,uBAAuB,GAAG,IAAI,GAAG,IAAI,CAEtF"}
|
package/dist/pbrMaterials.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unpackColorToLinear } from '@flighthq/color/contract';
|
|
1
|
+
import { allocateLinearColor, packLinearChannelsToColor, unpackColorToLinear } from '@flighthq/color/contract';
|
|
2
2
|
import { SpecularGlossinessPbrMaterialKind, StandardPbrMaterialKind } from '@flighthq/types/contract';
|
|
3
3
|
import { explainSpecularGlossinessConversion } from "./explainMaterialConversion.js";
|
|
4
4
|
import { createMaterial3D } from "./material3d.js";
|
|
@@ -32,9 +32,9 @@ export function convertSpecularGlossinessToStandardPbr(out, source) {
|
|
|
32
32
|
// Unpack the specular color to linear to compute F0 luminance for the metallic estimate.
|
|
33
33
|
const specLinear = scratchLinear;
|
|
34
34
|
unpackColorToLinear(specLinear, specular);
|
|
35
|
-
const specR = specLinear
|
|
36
|
-
const specG = specLinear
|
|
37
|
-
const specB = specLinear
|
|
35
|
+
const specR = specLinear.r;
|
|
36
|
+
const specG = specLinear.g;
|
|
37
|
+
const specB = specLinear.b;
|
|
38
38
|
// Perceived luminance of the specular F0 (Rec. 709 weights).
|
|
39
39
|
const specLuma = 0.2126 * specR + 0.7152 * specG + 0.0722 * specB;
|
|
40
40
|
// The dielectric F0 threshold: ~0.04 (4% reflectance). A specular luma above this is
|
|
@@ -45,15 +45,15 @@ export function convertSpecularGlossinessToStandardPbr(out, source) {
|
|
|
45
45
|
// Blend: baseColor = lerp(diffuse * (1 - specLuma), diffuse, metallic).
|
|
46
46
|
const diffLinear = scratchLinear2;
|
|
47
47
|
unpackColorToLinear(diffLinear, diffuse);
|
|
48
|
-
const diffR = diffLinear
|
|
49
|
-
const diffG = diffLinear
|
|
50
|
-
const diffB = diffLinear
|
|
51
|
-
const diffA = diffLinear
|
|
48
|
+
const diffR = diffLinear.r;
|
|
49
|
+
const diffG = diffLinear.g;
|
|
50
|
+
const diffB = diffLinear.b;
|
|
51
|
+
const diffA = diffLinear.a;
|
|
52
52
|
// Approximate base color in linear, then repack to sRGB RGBA.
|
|
53
53
|
const baseR = diffR * (1 - specLuma * (1 - metallic));
|
|
54
54
|
const baseG = diffG * (1 - specLuma * (1 - metallic));
|
|
55
55
|
const baseB = diffB * (1 - specLuma * (1 - metallic));
|
|
56
|
-
const baseColor =
|
|
56
|
+
const baseColor = packLinearChannelsToColor(baseR, baseG, baseB, diffA);
|
|
57
57
|
// Specular-glossiness carries no dedicated coverage map; leave the standard block's alpha map
|
|
58
58
|
// empty so the converted material's alpha comes from baseColor/baseColorMap alone.
|
|
59
59
|
out.alphaMap = null;
|
|
@@ -127,21 +127,8 @@ function assignStandardPbrMaterialProperties(target, opts) {
|
|
|
127
127
|
target.occlusionStrength = opts?.occlusionStrength ?? 1;
|
|
128
128
|
target.roughness = opts?.roughness ?? 1;
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const srgb = value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
|
|
133
|
-
return Math.round(Math.min(1, Math.max(0, srgb)) * 0xff);
|
|
134
|
-
}
|
|
135
|
-
// Pack four linear [0,1] channels back to a 0xRRGGBBAA packed sRGB integer.
|
|
136
|
-
function packLinear(r, g, b, a) {
|
|
137
|
-
return (((linearChannelToSrgb8(r) << 24) |
|
|
138
|
-
(linearChannelToSrgb8(g) << 16) |
|
|
139
|
-
(linearChannelToSrgb8(b) << 8) |
|
|
140
|
-
Math.round(a * 0xff)) >>>
|
|
141
|
-
0);
|
|
142
|
-
}
|
|
143
|
-
const scratchLinear = [0, 0, 0, 0];
|
|
144
|
-
const scratchLinear2 = [0, 0, 0, 0];
|
|
130
|
+
const scratchLinear = allocateLinearColor();
|
|
131
|
+
const scratchLinear2 = allocateLinearColor();
|
|
145
132
|
// Routes one dropped-map explanation to the installed guard, or nowhere when none is installed. Both
|
|
146
133
|
// converters report through this rather than reaching for the module slot themselves, so the seam has
|
|
147
134
|
// exactly one caller-visible shape.
|
package/dist/pbrMaterials.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbrMaterials.js","sourceRoot":"","sources":["../src/pbrMaterials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAS/
|
|
1
|
+
{"version":3,"file":"pbrMaterials.js","sourceRoot":"","sources":["../src/pbrMaterials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAS/G,OAAO,EAAE,iCAAiC,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEtG,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,yFAAyF;AACzF,4FAA4F;AAC5F,2FAA2F;AAC3F,gCAAgC;AAChC,gFAAgF;AAChF,iFAAiF;AACjF,2FAA2F;AAC3F,0FAA0F;AAC1F,wDAAwD;AACxD,qGAAqG;AACrG,qGAAqG;AACrG,wGAAwG;AACxG,iG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AAC,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,IAAI,CAAC;IAC3C,MAAM,CAAC,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,YAAY,GAAG,IAAI,EAAE,YAAY,IAAI,IAAI,CAAC;IACjD,MAAM,CAAC,iBAAiB,GAAG,IAAI,EAAE,iBAAiB,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAC;AAC5C,MAAM,cAAc,GAAG,mBAAmB,EAAE,CAAC;AAE7C,qGAAqG;AACrG,sGAAsG;AACtG,oCAAoC;AACpC,MAAM,UAAU,4BAA4B,CAC1C,WAAoD,EACpD,UAAkB;IAElB,gBAAgB,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;AAC9C,CAAC;AAED,sGAAsG;AACtG,8FAA8F;AAC9F,wGAAwG;AACxG,MAAM,UAAU,0BAA0B,CAAC,KAAqC;IAC9E,gBAAgB,GAAG,KAAK,CAAC;AAC3B,CAAC;AAED,IAAI,gBAAgB,GAAmC,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/materials",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.4305.c5b7dc0",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.5.1-next.
|
|
42
|
-
"@flighthq/entity": "0.5.1-next.
|
|
43
|
-
"@flighthq/log": "0.5.1-next.
|
|
44
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/color": "0.5.1-next.4305.c5b7dc0",
|
|
42
|
+
"@flighthq/entity": "0.5.1-next.4305.c5b7dc0",
|
|
43
|
+
"@flighthq/log": "0.5.1-next.4305.c5b7dc0",
|
|
44
|
+
"@flighthq/types": "0.5.1-next.4305.c5b7dc0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^5.3.0"
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
clearLogOnceKeys,
|
|
4
|
-
createMemoryLogSink,
|
|
5
|
-
getMemoryLogSinkEntries,
|
|
6
|
-
removeLogSink,
|
|
7
|
-
} from '@flighthq/log/contract';
|
|
1
|
+
import { addLogSink, createLogState, createMemoryLogSink, getMemoryLogSinkEntries } from '@flighthq/log/contract';
|
|
2
|
+
import type { LogState } from '@flighthq/log/contract';
|
|
8
3
|
import type { LogEntry } from '@flighthq/types/contract';
|
|
9
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
10
5
|
|
|
11
6
|
import { createPhongMaterial } from './classicMaterials.ts';
|
|
12
7
|
import { disableMaterialConversionGuards, enableMaterialConversionGuards } from './enableMaterialConversionGuards.ts';
|
|
@@ -17,24 +12,27 @@ import {
|
|
|
17
12
|
} from './pbrMaterials.ts';
|
|
18
13
|
import { convertPhongToStandardPbrMaterial } from './phongToPbr.ts';
|
|
19
14
|
|
|
20
|
-
// logOnce dedupes by key for the life of
|
|
21
|
-
//
|
|
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
|
+
|
|
22
23
|
afterEach(() => {
|
|
23
24
|
disableMaterialConversionGuards();
|
|
24
|
-
clearLogOnceKeys();
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
const texture = {} as never;
|
|
28
28
|
|
|
29
29
|
function captureLog(run: () => void): readonly LogEntry[] {
|
|
30
30
|
const sink = createMemoryLogSink(8);
|
|
31
|
-
addLogSink(sink.sink);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
removeLogSink(sink.sink);
|
|
37
|
-
}
|
|
31
|
+
addLogSink(logState, sink.sink);
|
|
32
|
+
run();
|
|
33
|
+
const entries: LogEntry[] = [];
|
|
34
|
+
getMemoryLogSinkEntries(entries, sink);
|
|
35
|
+
return entries;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
function messageOf(entry: Readonly<LogEntry>): string {
|
|
@@ -45,7 +43,7 @@ function messageOf(entry: Readonly<LogEntry>): string {
|
|
|
45
43
|
describe('disableMaterialConversionGuards', () => {
|
|
46
44
|
it('restores the silent conversion', () => {
|
|
47
45
|
const entries = captureLog(() => {
|
|
48
|
-
enableMaterialConversionGuards();
|
|
46
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
49
47
|
disableMaterialConversionGuards();
|
|
50
48
|
convertPhongToStandardPbrMaterial(createPhongMaterial({ specularMap: texture }));
|
|
51
49
|
});
|
|
@@ -56,7 +54,7 @@ describe('disableMaterialConversionGuards', () => {
|
|
|
56
54
|
describe('enableMaterialConversionGuards', () => {
|
|
57
55
|
it('WARNS when the spec-gloss conversion drops its packed map, telling the caller to bake', () => {
|
|
58
56
|
const entries = captureLog(() => {
|
|
59
|
-
enableMaterialConversionGuards();
|
|
57
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
60
58
|
convertSpecularGlossinessToStandardPbr(
|
|
61
59
|
createStandardPbrMaterial(),
|
|
62
60
|
createSpecularGlossinessPbrMaterial({ specularGlossinessMap: texture }),
|
|
@@ -70,7 +68,7 @@ describe('enableMaterialConversionGuards', () => {
|
|
|
70
68
|
|
|
71
69
|
it('WARNS SEPARATELY for the Phong conversion, so one does not silence the other', () => {
|
|
72
70
|
const entries = captureLog(() => {
|
|
73
|
-
enableMaterialConversionGuards();
|
|
71
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
74
72
|
convertSpecularGlossinessToStandardPbr(
|
|
75
73
|
createStandardPbrMaterial(),
|
|
76
74
|
createSpecularGlossinessPbrMaterial({ specularGlossinessMap: texture }),
|
|
@@ -84,7 +82,7 @@ describe('enableMaterialConversionGuards', () => {
|
|
|
84
82
|
|
|
85
83
|
it('stays SILENT when the conversion loses nothing', () => {
|
|
86
84
|
const entries = captureLog(() => {
|
|
87
|
-
enableMaterialConversionGuards();
|
|
85
|
+
enableMaterialConversionGuards(logState, () => 0);
|
|
88
86
|
convertSpecularGlossinessToStandardPbr(createStandardPbrMaterial(), createSpecularGlossinessPbrMaterial());
|
|
89
87
|
convertPhongToStandardPbrMaterial(createPhongMaterial());
|
|
90
88
|
});
|