@forgeax/engine-gltf 0.1.24 → 0.1.25
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/importer-entry.mjs +6 -4
- package/dist/importer-entry.mjs.map +1 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/__tests__/bridge-material-values.unit.test.ts +23 -0
- package/src/__tests__/gltf.unit.test.ts +9 -0
- package/src/bridge.ts +7 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/engine-gltf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
"LICENSE"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@forgeax/engine-animation": "0.1.
|
|
42
|
-
"@forgeax/engine-geometry": "0.1.
|
|
43
|
-
"@forgeax/engine-import": "0.1.
|
|
44
|
-
"@forgeax/engine-math": "0.1.
|
|
45
|
-
"@forgeax/engine-pack": "0.1.
|
|
46
|
-
"@forgeax/engine-scene": "0.1.
|
|
47
|
-
"@forgeax/engine-types": "0.1.
|
|
41
|
+
"@forgeax/engine-animation": "0.1.25",
|
|
42
|
+
"@forgeax/engine-geometry": "0.1.25",
|
|
43
|
+
"@forgeax/engine-import": "0.1.25",
|
|
44
|
+
"@forgeax/engine-math": "0.1.25",
|
|
45
|
+
"@forgeax/engine-pack": "0.1.25",
|
|
46
|
+
"@forgeax/engine-scene": "0.1.25",
|
|
47
|
+
"@forgeax/engine-types": "0.1.25",
|
|
48
48
|
"@webgpu/types": "^0.1.71",
|
|
49
49
|
"meshoptimizer": "^0.20.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@forgeax/engine-assets-runtime": "0.1.
|
|
53
|
-
"@forgeax/engine-picking": "0.1.
|
|
54
|
-
"@forgeax/engine-render": "0.1.
|
|
55
|
-
"@forgeax/engine-runtime": "0.1.
|
|
52
|
+
"@forgeax/engine-assets-runtime": "0.1.25",
|
|
53
|
+
"@forgeax/engine-picking": "0.1.25",
|
|
54
|
+
"@forgeax/engine-render": "0.1.25",
|
|
55
|
+
"@forgeax/engine-runtime": "0.1.25",
|
|
56
56
|
"@types/node": "^20.14.0"
|
|
57
57
|
},
|
|
58
58
|
"forgeax": {
|
|
@@ -4,6 +4,29 @@ import { toMaterialAsset } from '../bridge.js';
|
|
|
4
4
|
import type { GltfMaterialIr } from '../parse-gltf.js';
|
|
5
5
|
|
|
6
6
|
describe('glTF material bridge values', () => {
|
|
7
|
+
it('publishes a parent-bearing child with only inherited contract and authored values', () => {
|
|
8
|
+
const standardRootGuid = '01a065d4-47dd-789f-96b4-36b9326abc02' as unknown as AssetGuid;
|
|
9
|
+
const material = toMaterialAsset(
|
|
10
|
+
{
|
|
11
|
+
baseColorFactor: [0.5, 0.75, 0.25, 1],
|
|
12
|
+
metallicFactor: 0.5,
|
|
13
|
+
roughnessFactor: 0.7,
|
|
14
|
+
} as unknown as GltfMaterialIr,
|
|
15
|
+
{ standardRootGuid },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(material).toEqual({
|
|
19
|
+
kind: 'material',
|
|
20
|
+
parent: standardRootGuid,
|
|
21
|
+
values: {
|
|
22
|
+
baseColor: [0.5, 0.75, 0.25, 1],
|
|
23
|
+
metallic: 0.5,
|
|
24
|
+
roughness: 0.7,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
expect(Object.keys(material).sort()).toEqual(['kind', 'parent', 'values']);
|
|
28
|
+
});
|
|
29
|
+
|
|
7
30
|
it('preserves all four base-color channels for factor and texture composition', () => {
|
|
8
31
|
const factor = [0.5, 0.75, 0.25, 0.4] as const;
|
|
9
32
|
const material = toMaterialAsset({
|
|
@@ -1840,6 +1840,15 @@ function unwrapReimport(result: ReturnType<typeof reimportReuseMeta>) {
|
|
|
1840
1840
|
expect(mat).toBeDefined();
|
|
1841
1841
|
const parentRefs = mat?.refs.filter((r) => r.sourceField?.fieldName === 'parent');
|
|
1842
1842
|
expect(parentRefs?.map((ref) => ref.guid)).toEqual(['019e2cc6-0c86-79da-aa76-b0984c86d4ff']);
|
|
1843
|
+
expect(mat?.payload).toMatchObject({
|
|
1844
|
+
kind: 'material',
|
|
1845
|
+
parent: '019e2cc6-0c86-79da-aa76-b0984c86d4ff',
|
|
1846
|
+
});
|
|
1847
|
+
expect(Object.keys((mat?.payload ?? {}) as Record<string, unknown>).sort()).toEqual([
|
|
1848
|
+
'kind',
|
|
1849
|
+
'parent',
|
|
1850
|
+
'values',
|
|
1851
|
+
]);
|
|
1843
1852
|
});
|
|
1844
1853
|
|
|
1845
1854
|
it('(e) material refs texture edges: sourceField.componentName="<material>" and fieldName is texture slot', async () => {
|
package/src/bridge.ts
CHANGED
|
@@ -1169,16 +1169,16 @@ export function toMaterialAsset(mat: GltfMaterialIr, ctx?: MaterialBridgeContext
|
|
|
1169
1169
|
},
|
|
1170
1170
|
};
|
|
1171
1171
|
|
|
1172
|
+
const child = !rootContract.extended && ctx?.standardRootGuid !== undefined;
|
|
1172
1173
|
return {
|
|
1173
1174
|
kind: 'material',
|
|
1174
|
-
|
|
1175
|
-
...(!rootContract.extended && ctx?.standardRootGuid !== undefined
|
|
1175
|
+
...(child
|
|
1176
1176
|
? { parent: ctx.standardRootGuid }
|
|
1177
|
-
: {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1177
|
+
: {
|
|
1178
|
+
colorSpace: 'linear' as const,
|
|
1179
|
+
passes: [pass] as [typeof pass, ...(typeof pass)[]],
|
|
1180
|
+
parameters: standardMaterialParameters(rootContract.names),
|
|
1181
|
+
}),
|
|
1182
1182
|
values,
|
|
1183
1183
|
};
|
|
1184
1184
|
}
|