@flighthq/shading 0.2.1-next.652.c550eaa → 0.2.1-next.701.409c279
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createShadedMaterial.d.ts","sourceRoot":"","sources":["../src/createShadedMaterial.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"createShadedMaterial.d.ts","sourceRoot":"","sources":["../src/createShadedMaterial.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAiB7E,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,cAAc,CAgB9F"}
|
|
@@ -8,18 +8,20 @@ import { BlendMode, ShadedMaterialKind } from '@flighthq/types';
|
|
|
8
8
|
// over the shared light block into one program keyed by the stack's define-key. This is the ONLY
|
|
9
9
|
// base modifiers attach to in v1. `diffuse`/`specular` are packed sRgb-albedo RGBA (0xrrggbbaa) and
|
|
10
10
|
// default to opaque white; `shininess` (the specular exponent) defaults to 32; `normalScale` to 1;
|
|
11
|
-
// all maps to null; `modifiers` to an empty stack. The shared SurfaceMaterial trailer
|
|
12
|
-
//
|
|
13
|
-
//
|
|
11
|
+
// all maps to null; `modifiers` to an empty stack. The shared SurfaceMaterial trailer is forwarded from
|
|
12
|
+
// `options` (ShadedMaterialOptions extends SurfaceMaterialOptions), falling back to opaque, single-sided,
|
|
13
|
+
// straight alpha, Normal blend, 0.5 mask cutoff — so a masked/blended ShadedMaterial is expressible at
|
|
14
|
+
// construction, exactly as for BlinnPhong/PBR. The result is an entity (it carries runtime/binding
|
|
15
|
+
// identity), not a plain literal.
|
|
14
16
|
export function createShadedMaterial(options) {
|
|
15
17
|
const material = createEntity({ kind: ShadedMaterialKind });
|
|
16
|
-
material.alphaCutoff = 0.5;
|
|
17
|
-
material.alphaMode = 'opaque';
|
|
18
|
-
material.alphaType = 'straight';
|
|
19
|
-
material.blendMode = BlendMode.Normal;
|
|
18
|
+
material.alphaCutoff = options?.alphaCutoff ?? 0.5;
|
|
19
|
+
material.alphaMode = options?.alphaMode ?? 'opaque';
|
|
20
|
+
material.alphaType = options?.alphaType ?? 'straight';
|
|
21
|
+
material.blendMode = options?.blendMode ?? BlendMode.Normal;
|
|
20
22
|
material.diffuse = options?.diffuse ?? 0xffffffff;
|
|
21
23
|
material.diffuseMap = options?.diffuseMap ?? null;
|
|
22
|
-
material.doubleSided = false;
|
|
24
|
+
material.doubleSided = options?.doubleSided ?? false;
|
|
23
25
|
material.modifiers = options?.modifiers ?? [];
|
|
24
26
|
material.normalMap = options?.normalMap ?? null;
|
|
25
27
|
material.normalScale = options?.normalScale ?? 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createShadedMaterial.js","sourceRoot":"","sources":["../src/createShadedMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,kGAAkG;AAClG,mGAAmG;AACnG,mEAAmE;AAEnE,+FAA+F;AAC/F,qGAAqG;AACrG,iGAAiG;AACjG,oGAAoG;AACpG,mGAAmG;AACnG,
|
|
1
|
+
{"version":3,"file":"createShadedMaterial.js","sourceRoot":"","sources":["../src/createShadedMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,kGAAkG;AAClG,mGAAmG;AACnG,mEAAmE;AAEnE,+FAA+F;AAC/F,qGAAqG;AACrG,iGAAiG;AACjG,oGAAoG;AAC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|
3
|
-
"version": "0.2.1-next.
|
|
3
|
+
"version": "0.2.1-next.701.409c279",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@flighthq/entity": "0.2.1-next.
|
|
36
|
-
"@flighthq/types": "0.2.1-next.
|
|
35
|
+
"@flighthq/entity": "0.2.1-next.701.409c279",
|
|
36
|
+
"@flighthq/types": "0.2.1-next.701.409c279"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "^5.3.0"
|
|
@@ -30,6 +30,13 @@ describe('createShadedMaterial', () => {
|
|
|
30
30
|
expect(material.doubleSided).toBe(false);
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
+
it('forwards the SurfaceMaterial trailer from options (mask/blend expressible at construction)', () => {
|
|
34
|
+
const material = createShadedMaterial({ alphaCutoff: 0.25, alphaMode: 'mask', doubleSided: true });
|
|
35
|
+
expect(material.alphaMode).toBe('mask');
|
|
36
|
+
expect(material.alphaCutoff).toBe(0.25);
|
|
37
|
+
expect(material.doubleSided).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
33
40
|
it('defaults to an empty modifier stack', () => {
|
|
34
41
|
const material = createShadedMaterial();
|
|
35
42
|
expect(material.modifiers).toEqual([]);
|