@forgeax/engine-picking 0.1.27 → 0.1.29
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/package.json +10 -10
- package/src/__tests__/pick-vertex.unit.test.ts +24 -10
- package/src/__tests__/pick.test.ts +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgeax/engine-picking",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@forgeax/engine-assets-runtime": "0.1.
|
|
26
|
-
"@forgeax/engine-ecs": "0.1.
|
|
27
|
-
"@forgeax/engine-math": "0.1.
|
|
28
|
-
"@forgeax/engine-render": "0.1.
|
|
29
|
-
"@forgeax/engine-runtime": "0.1.
|
|
30
|
-
"@forgeax/engine-scene": "0.1.
|
|
31
|
-
"@forgeax/engine-types": "0.1.
|
|
25
|
+
"@forgeax/engine-assets-runtime": "0.1.29",
|
|
26
|
+
"@forgeax/engine-ecs": "0.1.29",
|
|
27
|
+
"@forgeax/engine-math": "0.1.29",
|
|
28
|
+
"@forgeax/engine-render": "0.1.29",
|
|
29
|
+
"@forgeax/engine-runtime": "0.1.29",
|
|
30
|
+
"@forgeax/engine-scene": "0.1.29",
|
|
31
|
+
"@forgeax/engine-types": "0.1.29"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@forgeax/engine-pack": "0.1.
|
|
35
|
-
"@forgeax/engine-shader": "0.1.
|
|
34
|
+
"@forgeax/engine-pack": "0.1.29",
|
|
35
|
+
"@forgeax/engine-shader": "0.1.29"
|
|
36
36
|
},
|
|
37
37
|
"forgeax": {
|
|
38
38
|
"metrics": {
|
|
@@ -59,6 +59,20 @@ interface Scene {
|
|
|
59
59
|
material: Handle<'MaterialAsset', 'shared'>;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// The test meshes below intentionally keep their interleaved vertex buffers
|
|
63
|
+
// padded to the canonical position/normal/uv/tangent stride. Empty typed
|
|
64
|
+
// arrays are the geometry layout SSOT's presence sentinels; retaining them in
|
|
65
|
+
// the fixture makes the declared projection agree with the buffer stride.
|
|
66
|
+
const EMPTY_ATTRIBUTE = new Float32Array(0);
|
|
67
|
+
function interleavedAttributes(position: Float32Array | Uint16Array): VertexAttributeMap {
|
|
68
|
+
return {
|
|
69
|
+
position,
|
|
70
|
+
normal: EMPTY_ATTRIBUTE,
|
|
71
|
+
uv: EMPTY_ATTRIBUTE,
|
|
72
|
+
tangent: EMPTY_ATTRIBUTE,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
62
76
|
function makeScene(): Scene {
|
|
63
77
|
const world = new World();
|
|
64
78
|
const assets = new AssetRegistry(makeMockShaderRegistry());
|
|
@@ -118,7 +132,7 @@ function registerTriangle(scene: Scene): Handle<'MeshAsset', 'shared'> {
|
|
|
118
132
|
kind: 'mesh',
|
|
119
133
|
vertices: v,
|
|
120
134
|
indices: new Uint16Array([0, 1, 2]),
|
|
121
|
-
attributes:
|
|
135
|
+
attributes: interleavedAttributes(positions),
|
|
122
136
|
submeshes: [
|
|
123
137
|
{ indexOffset: 0, indexCount: 3, vertexCount: 3, topology: 'triangle-list', materialSlot: 0 },
|
|
124
138
|
],
|
|
@@ -208,7 +222,7 @@ function registerCube(scene: Scene): Handle<'MeshAsset', 'shared'> {
|
|
|
208
222
|
kind: 'mesh',
|
|
209
223
|
vertices: v,
|
|
210
224
|
indices,
|
|
211
|
-
attributes:
|
|
225
|
+
attributes: interleavedAttributes(positions),
|
|
212
226
|
submeshes: [
|
|
213
227
|
{
|
|
214
228
|
indexOffset: 0,
|
|
@@ -248,7 +262,7 @@ function registerSkinnedTriangle(scene: Scene): Handle<'MeshAsset', 'shared'> {
|
|
|
248
262
|
v[i * 18 + 17] = skinWeight[i * 4 + 3] as number;
|
|
249
263
|
}
|
|
250
264
|
const attrs: VertexAttributeMap = {
|
|
251
|
-
|
|
265
|
+
...interleavedAttributes(positions),
|
|
252
266
|
skinIndex,
|
|
253
267
|
skinWeight,
|
|
254
268
|
};
|
|
@@ -1024,7 +1038,7 @@ describe('w6: degradation input + builtin fallback', () => {
|
|
|
1024
1038
|
kind: 'mesh',
|
|
1025
1039
|
vertices: v,
|
|
1026
1040
|
indices: new Uint16Array([0, 1, 2, 3]),
|
|
1027
|
-
attributes:
|
|
1041
|
+
attributes: interleavedAttributes(positions),
|
|
1028
1042
|
submeshes: [
|
|
1029
1043
|
{
|
|
1030
1044
|
indexOffset: 0,
|
|
@@ -1074,7 +1088,7 @@ describe('w6: degradation input + builtin fallback', () => {
|
|
|
1074
1088
|
kind: 'mesh',
|
|
1075
1089
|
vertices: v,
|
|
1076
1090
|
indices: new Uint16Array([0, 1, 2]),
|
|
1077
|
-
attributes:
|
|
1091
|
+
attributes: interleavedAttributes(positions),
|
|
1078
1092
|
submeshes: [
|
|
1079
1093
|
{
|
|
1080
1094
|
indexOffset: 0,
|
|
@@ -1151,7 +1165,7 @@ describe('w6: degradation input + builtin fallback', () => {
|
|
|
1151
1165
|
const result = scene.assets.catalog<MeshAsset>(AssetGuid.format(AssetGuid.random()), {
|
|
1152
1166
|
kind: 'mesh',
|
|
1153
1167
|
vertices: v,
|
|
1154
|
-
attributes:
|
|
1168
|
+
attributes: interleavedAttributes(positions),
|
|
1155
1169
|
submeshes: [
|
|
1156
1170
|
{
|
|
1157
1171
|
indexOffset: 0,
|
|
@@ -1194,7 +1208,7 @@ describe('w6: degradation input + builtin fallback', () => {
|
|
|
1194
1208
|
const result = scene.assets.catalog<MeshAsset>(AssetGuid.format(AssetGuid.random()), {
|
|
1195
1209
|
kind: 'mesh',
|
|
1196
1210
|
vertices: v,
|
|
1197
|
-
attributes:
|
|
1211
|
+
attributes: interleavedAttributes(positions),
|
|
1198
1212
|
submeshes: [
|
|
1199
1213
|
{
|
|
1200
1214
|
indexOffset: 0,
|
|
@@ -1249,7 +1263,7 @@ describe('w6: degradation input + builtin fallback', () => {
|
|
|
1249
1263
|
kind: 'mesh',
|
|
1250
1264
|
vertices: v,
|
|
1251
1265
|
indices: new Uint16Array([0, 1, 2]),
|
|
1252
|
-
attributes:
|
|
1266
|
+
attributes: interleavedAttributes(positions),
|
|
1253
1267
|
submeshes: [
|
|
1254
1268
|
{
|
|
1255
1269
|
indexOffset: 0,
|
|
@@ -1298,7 +1312,7 @@ describe('w6: degradation input + builtin fallback', () => {
|
|
|
1298
1312
|
kind: 'mesh',
|
|
1299
1313
|
vertices: v,
|
|
1300
1314
|
indices: new Uint16Array([0, 1, 2]),
|
|
1301
|
-
attributes:
|
|
1315
|
+
attributes: interleavedAttributes(positions),
|
|
1302
1316
|
submeshes: [
|
|
1303
1317
|
{
|
|
1304
1318
|
indexOffset: 0,
|
|
@@ -1539,7 +1553,7 @@ describe('w7: pickVertex full-scene', () => {
|
|
|
1539
1553
|
kind: 'mesh',
|
|
1540
1554
|
vertices: v,
|
|
1541
1555
|
indices: new Uint16Array([0, 1, 2]),
|
|
1542
|
-
attributes:
|
|
1556
|
+
attributes: interleavedAttributes(positions),
|
|
1543
1557
|
submeshes: [
|
|
1544
1558
|
{
|
|
1545
1559
|
indexOffset: 0,
|
|
@@ -25,6 +25,21 @@ import { pickVertex, pickVertexOnEntity } from '../pick-vertex';
|
|
|
25
25
|
import { viewportToWorld } from '../viewport-to-world';
|
|
26
26
|
import { makeMockShaderRegistry } from './helpers/mock-shader-registry';
|
|
27
27
|
|
|
28
|
+
const EMPTY_ATTRIBUTE = new Float32Array(0);
|
|
29
|
+
function interleavedAttributes(position: Float32Array): {
|
|
30
|
+
position: Float32Array;
|
|
31
|
+
normal: Float32Array;
|
|
32
|
+
uv: Float32Array;
|
|
33
|
+
tangent: Float32Array;
|
|
34
|
+
} {
|
|
35
|
+
return {
|
|
36
|
+
position,
|
|
37
|
+
normal: EMPTY_ATTRIBUTE,
|
|
38
|
+
uv: EMPTY_ATTRIBUTE,
|
|
39
|
+
tangent: EMPTY_ATTRIBUTE,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
28
43
|
// --- from pick.test.ts ---
|
|
29
44
|
// pick.test.ts — feat-20260529-picking-raycasting-screen-to-entity M3 / w12 (TDD red).
|
|
30
45
|
//
|
|
@@ -119,7 +134,7 @@ function registerBox(world: World, assets: AssetRegistry): Handle<'MeshAsset', '
|
|
|
119
134
|
kind: 'mesh',
|
|
120
135
|
vertices,
|
|
121
136
|
indices: new Uint16Array([0, 1, 2]),
|
|
122
|
-
attributes:
|
|
137
|
+
attributes: interleavedAttributes(positions),
|
|
123
138
|
submeshes: [
|
|
124
139
|
{
|
|
125
140
|
indexOffset: 0,
|