@flighthq/materials 0.2.1-next.701.409c279 → 0.2.1-next.840.857425c
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/dist/customShaderMaterial.d.ts.map +1 -1
- package/dist/customShaderMaterial.js +4 -5
- package/dist/customShaderMaterial.js.map +1 -1
- package/dist/surfaceMaterial.d.ts +4 -4
- package/dist/surfaceMaterial.d.ts.map +1 -1
- package/dist/surfaceMaterial.js +4 -4
- package/dist/surfaceMaterial.js.map +1 -1
- package/package.json +4 -4
- package/src/surfaceMaterial.test.ts +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customShaderMaterial.d.ts","sourceRoot":"","sources":["../src/customShaderMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"customShaderMaterial.d.ts","sourceRoot":"","sources":["../src/customShaderMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAS5D,wBAAgB,0BAA0B,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,GAAG,oBAAoB,CAM/G"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { CustomShaderMaterialKind } from '@flighthq/types';
|
|
2
2
|
import { createSurfaceMaterial } from './surfaceMaterial';
|
|
3
|
-
// User-authored shader material. `shaderKey` references
|
|
4
|
-
//
|
|
5
|
-
// values
|
|
6
|
-
// null bags) so a bare
|
|
7
|
-
// serialization even before a shader key is assigned.
|
|
3
|
+
// User-authored shader material. `shaderKey` references backend-native source registered on the
|
|
4
|
+
// render state (registerGlCustomMaterialShader or registerWgpuCustomMaterialShader); `uniforms`
|
|
5
|
+
// carries flat scalar/vector values and `textures` carries named bindings. All default to their
|
|
6
|
+
// sentinel (empty key, null bags) so a bare material remains structurally valid before registration.
|
|
8
7
|
export function createCustomShaderMaterial(opts) {
|
|
9
8
|
const material = createSurfaceMaterial(CustomShaderMaterialKind, opts);
|
|
10
9
|
material.shaderKey = opts?.shaderKey ?? '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customShaderMaterial.js","sourceRoot":"","sources":["../src/customShaderMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,
|
|
1
|
+
{"version":3,"file":"customShaderMaterial.js","sourceRoot":"","sources":["../src/customShaderMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,gGAAgG;AAChG,gGAAgG;AAChG,gGAAgG;AAChG,qGAAqG;AACrG,MAAM,UAAU,0BAA0B,CAAC,IAA8C;IACvF,MAAM,QAAQ,GAAG,qBAAqB,CAAC,wBAAwB,EAAE,IAAI,CAAyB,CAAC;IAC/F,QAAQ,CAAC,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,EAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,IAAI,CAAC;IAC3C,QAAQ,CAAC,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,IAAI,CAAC;IAC3C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Kind, MaterialAlphaMode, SurfaceMaterial, SurfaceMaterialOptions } from '@flighthq/types';
|
|
2
2
|
export declare function createSurfaceMaterial(kind: Kind, opts?: Readonly<SurfaceMaterialOptions>): SurfaceMaterial;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
3
|
+
export declare function getSurfaceMaterialAlphaMode(source: Readonly<SurfaceMaterial>): MaterialAlphaMode;
|
|
4
|
+
export declare function isSurfaceMaterialBlended(source: Readonly<SurfaceMaterial>): boolean;
|
|
5
|
+
export declare function isSurfaceMaterialMasked(source: Readonly<SurfaceMaterial>): boolean;
|
|
6
|
+
export declare function isSurfaceMaterialOpaque(source: Readonly<SurfaceMaterial>): boolean;
|
|
7
7
|
//# sourceMappingURL=surfaceMaterial.d.ts.map
|
|
@@ -1 +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,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAWnH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAAG,eAAe,CAQ1G;AAKD,wBAAgB,
|
|
1
|
+
{"version":3,"file":"surfaceMaterial.d.ts","sourceRoot":"","sources":["../src/surfaceMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,IAAI,EAAE,iBAAiB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAWnH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAAG,eAAe,CAQ1G;AAKD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,iBAAiB,CAEhG;AAID,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAEnF;AAID,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAElF;AAID,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAElF"}
|
package/dist/surfaceMaterial.js
CHANGED
|
@@ -18,22 +18,22 @@ export function createSurfaceMaterial(kind, opts) {
|
|
|
18
18
|
// Returns the alpha mode of the material. The alpha mode controls how a material resolves
|
|
19
19
|
// coverage: 'opaque' ignores base-color alpha, 'mask' hard-cuts at `alphaCutoff`, 'blend'
|
|
20
20
|
// alpha-blends. Callers typically branch on this to configure blend state.
|
|
21
|
-
export function
|
|
21
|
+
export function getSurfaceMaterialAlphaMode(source) {
|
|
22
22
|
return source.alphaMode;
|
|
23
23
|
}
|
|
24
24
|
// Returns true when the material's alpha mode is 'blend'. Blended materials require a
|
|
25
25
|
// sorted draw order and a GPU blend equation.
|
|
26
|
-
export function
|
|
26
|
+
export function isSurfaceMaterialBlended(source) {
|
|
27
27
|
return source.alphaMode === 'blend';
|
|
28
28
|
}
|
|
29
29
|
// Returns true when the material's alpha mode is 'mask'. Masked materials discard fragments
|
|
30
30
|
// whose alpha is below `alphaCutoff`; no blend state is required.
|
|
31
|
-
export function
|
|
31
|
+
export function isSurfaceMaterialMasked(source) {
|
|
32
32
|
return source.alphaMode === 'mask';
|
|
33
33
|
}
|
|
34
34
|
// Returns true when the material's alpha mode is 'opaque'. Opaque materials ignore the
|
|
35
35
|
// base-color alpha channel; no blend state or discard is required.
|
|
36
|
-
export function
|
|
36
|
+
export function isSurfaceMaterialOpaque(source) {
|
|
37
37
|
return source.alphaMode === 'opaque';
|
|
38
38
|
}
|
|
39
39
|
const DEFAULT_ALPHA_CUTOFF = 0.5;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surfaceMaterial.js","sourceRoot":"","sources":["../src/surfaceMaterial.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,kGAAkG;AAClG,mGAAmG;AACnG,i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,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,SAAS,CAAC,MAAM,CAAC;IACzD,QAAQ,CAAC,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,oBAAoB,CAAC;IACjE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,0FAA0F;AAC1F,0FAA0F;AAC1F,2EAA2E;AAC3E,MAAM,UAAU,2BAA2B,CAAC,MAAiC;IAC3E,OAAO,MAAM,CAAC,SAAS,CAAC;AAC1B,CAAC;AAED,sFAAsF;AACtF,8CAA8C;AAC9C,MAAM,UAAU,wBAAwB,CAAC,MAAiC;IACxE,OAAO,MAAM,CAAC,SAAS,KAAK,OAAO,CAAC;AACtC,CAAC;AAED,4FAA4F;AAC5F,kEAAkE;AAClE,MAAM,UAAU,uBAAuB,CAAC,MAAiC;IACvE,OAAO,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC;AACrC,CAAC;AAED,uFAAuF;AACvF,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,MAAiC;IACvE,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC;AACvC,CAAC;AAED,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,kBAAkB,GAAsB,QAAQ,CAAC;AACvD,MAAM,kBAAkB,GAAc,UAAU,CAAC;AACjD,MAAM,oBAAoB,GAAG,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/materials",
|
|
3
|
-
"version": "0.2.1-next.
|
|
3
|
+
"version": "0.2.1-next.840.857425c",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@flighthq/color": "0.2.1-next.
|
|
36
|
-
"@flighthq/entity": "0.2.1-next.
|
|
37
|
-
"@flighthq/types": "0.2.1-next.
|
|
35
|
+
"@flighthq/color": "0.2.1-next.840.857425c",
|
|
36
|
+
"@flighthq/entity": "0.2.1-next.840.857425c",
|
|
37
|
+
"@flighthq/types": "0.2.1-next.840.857425c"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"typescript": "^5.3.0"
|
|
@@ -2,10 +2,10 @@ import { BlendMode } from '@flighthq/types';
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createSurfaceMaterial,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
getSurfaceMaterialAlphaMode,
|
|
6
|
+
isSurfaceMaterialBlended,
|
|
7
|
+
isSurfaceMaterialMasked,
|
|
8
|
+
isSurfaceMaterialOpaque,
|
|
9
9
|
} from './surfaceMaterial';
|
|
10
10
|
|
|
11
11
|
const TestSurfaceMaterialKind = 'TestSurfaceMaterial';
|
|
@@ -36,45 +36,45 @@ describe('createSurfaceMaterial', () => {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
describe('
|
|
39
|
+
describe('getSurfaceMaterialAlphaMode', () => {
|
|
40
40
|
it('returns the alphaMode of the material', () => {
|
|
41
41
|
const opaque = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
42
|
-
expect(
|
|
42
|
+
expect(getSurfaceMaterialAlphaMode(opaque)).toBe('opaque');
|
|
43
43
|
const blended = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
44
44
|
blended.alphaMode = 'blend';
|
|
45
|
-
expect(
|
|
45
|
+
expect(getSurfaceMaterialAlphaMode(blended)).toBe('blend');
|
|
46
46
|
const masked = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
47
47
|
masked.alphaMode = 'mask';
|
|
48
|
-
expect(
|
|
48
|
+
expect(getSurfaceMaterialAlphaMode(masked)).toBe('mask');
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
describe('
|
|
52
|
+
describe('isSurfaceMaterialBlended', () => {
|
|
53
53
|
it('returns true only for blend mode', () => {
|
|
54
54
|
const opaque = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
55
|
-
expect(
|
|
55
|
+
expect(isSurfaceMaterialBlended(opaque)).toBe(false);
|
|
56
56
|
const blended = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
57
57
|
blended.alphaMode = 'blend';
|
|
58
|
-
expect(
|
|
58
|
+
expect(isSurfaceMaterialBlended(blended)).toBe(true);
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
describe('
|
|
62
|
+
describe('isSurfaceMaterialMasked', () => {
|
|
63
63
|
it('returns true only for mask mode', () => {
|
|
64
64
|
const opaque = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
65
|
-
expect(
|
|
65
|
+
expect(isSurfaceMaterialMasked(opaque)).toBe(false);
|
|
66
66
|
const masked = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
67
67
|
masked.alphaMode = 'mask';
|
|
68
|
-
expect(
|
|
68
|
+
expect(isSurfaceMaterialMasked(masked)).toBe(true);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
describe('
|
|
72
|
+
describe('isSurfaceMaterialOpaque', () => {
|
|
73
73
|
it('returns true only for opaque mode', () => {
|
|
74
74
|
const opaque = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
75
|
-
expect(
|
|
75
|
+
expect(isSurfaceMaterialOpaque(opaque)).toBe(true);
|
|
76
76
|
const blended = createSurfaceMaterial(TestSurfaceMaterialKind);
|
|
77
77
|
blended.alphaMode = 'blend';
|
|
78
|
-
expect(
|
|
78
|
+
expect(isSurfaceMaterialOpaque(blended)).toBe(false);
|
|
79
79
|
});
|
|
80
80
|
});
|