@forgeax/engine-gltf 0.1.33 → 0.1.34
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/bridge.d.ts +0 -7
- package/dist/bridge.d.ts.map +1 -1
- package/dist/importer-entry.mjs +1 -4
- package/dist/importer-entry.mjs.map +1 -1
- package/dist/index.mjs +1 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/__tests__/bridge.unit.test.ts +12 -8
- package/src/bridge.ts +2 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/engine-gltf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"LICENSE"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@forgeax/engine-animation": "0.1.
|
|
39
|
-
"@forgeax/engine-geometry": "0.1.
|
|
40
|
-
"@forgeax/engine-import": "0.1.
|
|
41
|
-
"@forgeax/engine-math": "0.1.
|
|
42
|
-
"@forgeax/engine-pack": "0.1.
|
|
43
|
-
"@forgeax/engine-scene": "0.1.
|
|
44
|
-
"@forgeax/engine-types": "0.1.
|
|
38
|
+
"@forgeax/engine-animation": "0.1.34",
|
|
39
|
+
"@forgeax/engine-geometry": "0.1.34",
|
|
40
|
+
"@forgeax/engine-import": "0.1.34",
|
|
41
|
+
"@forgeax/engine-math": "0.1.34",
|
|
42
|
+
"@forgeax/engine-pack": "0.1.34",
|
|
43
|
+
"@forgeax/engine-scene": "0.1.34",
|
|
44
|
+
"@forgeax/engine-types": "0.1.34",
|
|
45
45
|
"@webgpu/types": "^0.1.71",
|
|
46
46
|
"meshoptimizer": "^0.20.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@forgeax/engine-assets-runtime": "0.1.
|
|
50
|
-
"@forgeax/engine-picking": "0.1.
|
|
51
|
-
"@forgeax/engine-render": "0.1.
|
|
52
|
-
"@forgeax/engine-runtime": "0.1.
|
|
49
|
+
"@forgeax/engine-assets-runtime": "0.1.34",
|
|
50
|
+
"@forgeax/engine-picking": "0.1.34",
|
|
51
|
+
"@forgeax/engine-render": "0.1.34",
|
|
52
|
+
"@forgeax/engine-runtime": "0.1.34",
|
|
53
53
|
"@types/node": "^20.14.0"
|
|
54
54
|
},
|
|
55
55
|
"forgeax": {
|
|
@@ -133,7 +133,6 @@ const STANDARD_MATERIAL: GltfMaterialIr = {
|
|
|
133
133
|
const ctx = {
|
|
134
134
|
meshHandles: new Map([[0, fakeMeshHandle(1)]]),
|
|
135
135
|
materialHandles: new Map([[0, fakeMaterialHandle(7)]]),
|
|
136
|
-
instanceCollectionIdsByNodeIndex: new Map([[0, 41]]),
|
|
137
136
|
};
|
|
138
137
|
|
|
139
138
|
describe('bridge-name-instances.test.ts', () => {
|
|
@@ -177,16 +176,19 @@ const STANDARD_MATERIAL: GltfMaterialIr = {
|
|
|
177
176
|
});
|
|
178
177
|
});
|
|
179
178
|
|
|
180
|
-
describe('bridge.ts Instances
|
|
181
|
-
it('attaches
|
|
179
|
+
describe('bridge.ts Instances attachment (M4 w11/w12)', () => {
|
|
180
|
+
it('AC-10 attaches Instances with transforms.length === N*16', () => {
|
|
182
181
|
const scene = gltfDocToSceneAsset(baseDoc(), ctx);
|
|
183
182
|
const node = scene.entities['node-0'];
|
|
184
183
|
expect(node?.components.Instances).toBeDefined();
|
|
185
184
|
const inst = node?.components.Instances;
|
|
186
|
-
|
|
185
|
+
if (inst !== undefined) {
|
|
186
|
+
const transforms = inst.transforms as Float32Array;
|
|
187
|
+
expect(transforms.length).toBe(4 * 16);
|
|
188
|
+
}
|
|
187
189
|
});
|
|
188
190
|
|
|
189
|
-
it('
|
|
191
|
+
it('AC-10 transforms identity is byte-equal to importer composed buffer', () => {
|
|
190
192
|
const seed = new Float32Array(4 * 16);
|
|
191
193
|
for (let i = 0; i < seed.length; i++) seed[i] = i;
|
|
192
194
|
const doc: GltfDoc = {
|
|
@@ -199,7 +201,7 @@ const STANDARD_MATERIAL: GltfMaterialIr = {
|
|
|
199
201
|
],
|
|
200
202
|
};
|
|
201
203
|
const scene = gltfDocToSceneAsset(doc, ctx);
|
|
202
|
-
expect(scene.entities['node-0']?.components.Instances).toEqual({
|
|
204
|
+
expect(scene.entities['node-0']?.components.Instances).toEqual({ transforms: seed });
|
|
203
205
|
});
|
|
204
206
|
|
|
205
207
|
it('AC-11 1 entity carries MeshFilter+MeshRenderer+Instances (no flatten)', () => {
|
|
@@ -222,12 +224,14 @@ const STANDARD_MATERIAL: GltfMaterialIr = {
|
|
|
222
224
|
expect(scene.entities['node-0']?.components.Instances).toBeUndefined();
|
|
223
225
|
});
|
|
224
226
|
|
|
225
|
-
it('
|
|
227
|
+
it('preserves authored instancing without a Renderer', () => {
|
|
226
228
|
const scene = gltfDocToSceneAsset(baseDoc(), {
|
|
227
229
|
meshHandles: ctx.meshHandles,
|
|
228
230
|
materialHandles: ctx.materialHandles,
|
|
229
231
|
});
|
|
230
|
-
expect(scene.entities['node-0']?.components.Instances).
|
|
232
|
+
expect(scene.entities['node-0']?.components.Instances).toEqual({
|
|
233
|
+
transforms: baseDoc().nodes[0]?.instancing?.transforms,
|
|
234
|
+
});
|
|
231
235
|
});
|
|
232
236
|
});
|
|
233
237
|
});
|
package/src/bridge.ts
CHANGED
|
@@ -458,13 +458,6 @@ export interface GltfBridgeContext {
|
|
|
458
458
|
* matching SkinAsset.jointPaths against the spawn subtree to fill Skin.joints[].
|
|
459
459
|
*/
|
|
460
460
|
readonly skeletonGuidBySkinIndex?: ReadonlyMap<number, string>;
|
|
461
|
-
/**
|
|
462
|
-
* glTF node index -> a live renderer-owned instance collection identity.
|
|
463
|
-
* The bridge is intentionally pure and cannot mint collection ids or copy
|
|
464
|
-
* matrix bytes into ECS. Runtime consumers create collections through their
|
|
465
|
-
* Renderer first, then provide this map when lowering the SceneAsset.
|
|
466
|
-
*/
|
|
467
|
-
readonly instanceCollectionIdsByNodeIndex?: ReadonlyMap<number, number>;
|
|
468
461
|
}
|
|
469
462
|
|
|
470
463
|
interface MutableSceneEntity {
|
|
@@ -711,16 +704,9 @@ export function gltfDocToSceneAsset(doc: GltfDoc, ctx: GltfBridgeContext): Scene
|
|
|
711
704
|
components.MeshRenderer = { materials: [] };
|
|
712
705
|
}
|
|
713
706
|
|
|
714
|
-
//
|
|
715
|
-
// only carries the renderer-owned identity; IR matrix bytes stay in the
|
|
716
|
-
// caller's collection and never become an ECS managed array. Build-time
|
|
717
|
-
// consumers that do not have a Renderer omit this optional association and
|
|
718
|
-
// must materialise the collection at their runtime boundary.
|
|
707
|
+
// Scene authoring preserves instance matrices without a Renderer.
|
|
719
708
|
if (ir.instancing !== undefined) {
|
|
720
|
-
|
|
721
|
-
if (collectionId !== undefined) {
|
|
722
|
-
components.Instances = { collectionId };
|
|
723
|
-
}
|
|
709
|
+
components.Instances = { transforms: ir.instancing.transforms };
|
|
724
710
|
}
|
|
725
711
|
|
|
726
712
|
if (isCamera) {
|