@bitmagic/world-forger 0.1.0
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/artifact-types.d.ts +295 -0
- package/dist/artifact-types.d.ts.map +1 -0
- package/dist/artifact-types.js +17 -0
- package/dist/artifact-types.js.map +1 -0
- package/dist/forge-constants.d.ts +106 -0
- package/dist/forge-constants.d.ts.map +1 -0
- package/dist/forge-constants.js +111 -0
- package/dist/forge-constants.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +26 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +14 -0
- package/dist/log.js.map +1 -0
- package/dist/pipeline/archetype-skips.d.ts +57 -0
- package/dist/pipeline/archetype-skips.d.ts.map +1 -0
- package/dist/pipeline/archetype-skips.js +51 -0
- package/dist/pipeline/archetype-skips.js.map +1 -0
- package/dist/pipeline/artifact-store.d.ts +4 -0
- package/dist/pipeline/artifact-store.d.ts.map +1 -0
- package/dist/pipeline/artifact-store.js +10 -0
- package/dist/pipeline/artifact-store.js.map +1 -0
- package/dist/pipeline/asset-catalog.d.ts +27 -0
- package/dist/pipeline/asset-catalog.d.ts.map +1 -0
- package/dist/pipeline/asset-catalog.js +47 -0
- package/dist/pipeline/asset-catalog.js.map +1 -0
- package/dist/pipeline/create-level-archetypes.d.ts +45 -0
- package/dist/pipeline/create-level-archetypes.d.ts.map +1 -0
- package/dist/pipeline/create-level-archetypes.js +197 -0
- package/dist/pipeline/create-level-archetypes.js.map +1 -0
- package/dist/pipeline/deps.d.ts +72 -0
- package/dist/pipeline/deps.d.ts.map +1 -0
- package/dist/pipeline/deps.js +2 -0
- package/dist/pipeline/deps.js.map +1 -0
- package/dist/pipeline/errors.d.ts +10 -0
- package/dist/pipeline/errors.d.ts.map +1 -0
- package/dist/pipeline/errors.js +13 -0
- package/dist/pipeline/errors.js.map +1 -0
- package/dist/pipeline/forged-work-store.d.ts +46 -0
- package/dist/pipeline/forged-work-store.d.ts.map +1 -0
- package/dist/pipeline/forged-work-store.js +69 -0
- package/dist/pipeline/forged-work-store.js.map +1 -0
- package/dist/pipeline/index.d.ts +36 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +36 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/job-types.d.ts +145 -0
- package/dist/pipeline/job-types.d.ts.map +1 -0
- package/dist/pipeline/job-types.js +2 -0
- package/dist/pipeline/job-types.js.map +1 -0
- package/dist/pipeline/level-registry.d.ts +57 -0
- package/dist/pipeline/level-registry.d.ts.map +1 -0
- package/dist/pipeline/level-registry.js +108 -0
- package/dist/pipeline/level-registry.js.map +1 -0
- package/dist/pipeline/model-types.d.ts +51 -0
- package/dist/pipeline/model-types.d.ts.map +1 -0
- package/dist/pipeline/model-types.js +2 -0
- package/dist/pipeline/model-types.js.map +1 -0
- package/dist/pipeline/persist-level.d.ts +82 -0
- package/dist/pipeline/persist-level.d.ts.map +1 -0
- package/dist/pipeline/persist-level.js +201 -0
- package/dist/pipeline/persist-level.js.map +1 -0
- package/dist/pipeline/place-and-persist-level.d.ts +83 -0
- package/dist/pipeline/place-and-persist-level.d.ts.map +1 -0
- package/dist/pipeline/place-and-persist-level.js +405 -0
- package/dist/pipeline/place-and-persist-level.js.map +1 -0
- package/dist/pipeline/request-id.d.ts +7 -0
- package/dist/pipeline/request-id.d.ts.map +1 -0
- package/dist/pipeline/request-id.js +10 -0
- package/dist/pipeline/request-id.js.map +1 -0
- package/dist/pipeline/spawn-points.d.ts +47 -0
- package/dist/pipeline/spawn-points.d.ts.map +1 -0
- package/dist/pipeline/spawn-points.js +100 -0
- package/dist/pipeline/spawn-points.js.map +1 -0
- package/dist/pipeline/starter-scatter.d.ts +34 -0
- package/dist/pipeline/starter-scatter.d.ts.map +1 -0
- package/dist/pipeline/starter-scatter.js +49 -0
- package/dist/pipeline/starter-scatter.js.map +1 -0
- package/dist/pipeline/storage-types.d.ts +48 -0
- package/dist/pipeline/storage-types.d.ts.map +1 -0
- package/dist/pipeline/storage-types.js +19 -0
- package/dist/pipeline/storage-types.js.map +1 -0
- package/dist/pipeline/transport-types.d.ts +35 -0
- package/dist/pipeline/transport-types.d.ts.map +1 -0
- package/dist/pipeline/transport-types.js +2 -0
- package/dist/pipeline/transport-types.js.map +1 -0
- package/dist/pipeline/voxelize-level.d.ts +24 -0
- package/dist/pipeline/voxelize-level.d.ts.map +1 -0
- package/dist/pipeline/voxelize-level.js +63 -0
- package/dist/pipeline/voxelize-level.js.map +1 -0
- package/dist/pipeline/world-json-source.d.ts +78 -0
- package/dist/pipeline/world-json-source.d.ts.map +1 -0
- package/dist/pipeline/world-json-source.js +2 -0
- package/dist/pipeline/world-json-source.js.map +1 -0
- package/dist/pipeline/world-json-types.d.ts +104 -0
- package/dist/pipeline/world-json-types.d.ts.map +1 -0
- package/dist/pipeline/world-json-types.js +15 -0
- package/dist/pipeline/world-json-types.js.map +1 -0
- package/dist/terrain-height-grid.d.ts +45 -0
- package/dist/terrain-height-grid.d.ts.map +1 -0
- package/dist/terrain-height-grid.js +50 -0
- package/dist/terrain-height-grid.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* World-space terrain height grid — the bridge that lets objects placed AFTER
|
|
3
|
+
* a forge (e.g. collectibles the coding/asset agent scatters via the voxel CLI)
|
|
4
|
+
* sit on the forged surface instead of the world floor.
|
|
5
|
+
*
|
|
6
|
+
* The forge knows each prop's exact ground height because it samples its own
|
|
7
|
+
* GLB-space `Heightfield` and maps the result to world space with the level
|
|
8
|
+
* transform (see `forge-world.ts`). Agent-driven placements happen later, in a
|
|
9
|
+
* separate process, with no access to that in-memory heightfield — and a
|
|
10
|
+
* placement raycast can't help because the freshly-forged terrain only loads
|
|
11
|
+
* after the session reload. So the forge persists THIS grid (a sidecar next to
|
|
12
|
+
* world.json); the CLI samples it to resolve `placeOnTerrain` Y the same way
|
|
13
|
+
* the forge resolved its props.
|
|
14
|
+
*
|
|
15
|
+
* The grid is the carved heightfield expressed in WORLD coordinates. Because the
|
|
16
|
+
* level transform is affine and axis-aligned (uniform scale + translate, no
|
|
17
|
+
* rotation — see `marker-transform.ts`), a GLB-regular grid maps to a
|
|
18
|
+
* world-regular grid, so the conversion is a per-vertex scale/translate.
|
|
19
|
+
*
|
|
20
|
+
* The GRID and its SAMPLER live on the publishable side, because the host that
|
|
21
|
+
* writes the sidecar and the tools that read it are CLIENTS of the forge, not
|
|
22
|
+
* part of it. The producer — `heightfieldToWorldGrid`, which needs the forge's
|
|
23
|
+
* own heightfield and level transform — stays with the geometry, in the private
|
|
24
|
+
* package's module of the same name.
|
|
25
|
+
*/
|
|
26
|
+
/** Sidecar filename written next to world.json. The CLI hardcodes the same name. */
|
|
27
|
+
export const FORGED_HEIGHTFIELD_FILE = 'forged-heightfield.json';
|
|
28
|
+
/**
|
|
29
|
+
* Bilinear height sample in world space, clamped to the grid edge. Mirrors
|
|
30
|
+
* `heightfield.ts` `heightAt` so the CLI's sampler and this one agree.
|
|
31
|
+
*/
|
|
32
|
+
export function sampleWorldHeight(g, x, z) {
|
|
33
|
+
const fx = (x - g.minX) / g.cellSize;
|
|
34
|
+
const fz = (z - g.minZ) / g.cellSize;
|
|
35
|
+
const cx = Math.min(Math.max(fx, 0), g.nx - 1e-9);
|
|
36
|
+
const cz = Math.min(Math.max(fz, 0), g.nz - 1e-9);
|
|
37
|
+
const i = Math.floor(cx);
|
|
38
|
+
const j = Math.floor(cz);
|
|
39
|
+
const tx = cx - i;
|
|
40
|
+
const tz = cz - j;
|
|
41
|
+
const stride = g.nx + 1;
|
|
42
|
+
const h00 = g.heights[j * stride + i];
|
|
43
|
+
const h10 = g.heights[j * stride + i + 1];
|
|
44
|
+
const h01 = g.heights[(j + 1) * stride + i];
|
|
45
|
+
const h11 = g.heights[(j + 1) * stride + i + 1];
|
|
46
|
+
const a = h00 + (h10 - h00) * tx;
|
|
47
|
+
const b = h01 + (h11 - h01) * tx;
|
|
48
|
+
return a + (b - a) * tz;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=terrain-height-grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terrain-height-grid.js","sourceRoot":"","sources":["../src/terrain-height-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,oFAAoF;AACpF,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAejE;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAmB,EAAE,CAAS,EAAE,CAAS;IACzE,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IACrC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IACrC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClB,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACxB,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAE,CAAC;IACvC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;IAC3C,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAE,CAAC;IAC7C,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;IACjD,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;IACjC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AAC1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bitmagic/world-forger",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Client half of the Bitmagic world forger: the forged-level artifact schema, the host seams, and the browser pipeline steps that bake archetypes, bake a level and place its instances.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./*.js": {
|
|
15
|
+
"types": "./dist/*.d.ts",
|
|
16
|
+
"default": "./dist/*.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@eslint/js": "^9.38.0",
|
|
27
|
+
"@types/jest": "^29.5.0",
|
|
28
|
+
"@types/node": "^24.9.1",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^8.46.2",
|
|
30
|
+
"@typescript-eslint/parser": "^8.46.2",
|
|
31
|
+
"eslint": "^9.38.0",
|
|
32
|
+
"jest": "^29.7.0",
|
|
33
|
+
"ts-jest": "^29.4.5",
|
|
34
|
+
"typescript": "^5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"jest": {
|
|
37
|
+
"preset": "ts-jest/presets/default-esm",
|
|
38
|
+
"extensionsToTreatAsEsm": [
|
|
39
|
+
".ts"
|
|
40
|
+
],
|
|
41
|
+
"transform": {
|
|
42
|
+
"^.+\\.ts$": [
|
|
43
|
+
"ts-jest",
|
|
44
|
+
{
|
|
45
|
+
"useESM": true,
|
|
46
|
+
"tsconfig": {
|
|
47
|
+
"target": "ES2020",
|
|
48
|
+
"module": "ES2020",
|
|
49
|
+
"moduleResolution": "node",
|
|
50
|
+
"verbatimModuleSyntax": false,
|
|
51
|
+
"esModuleInterop": true
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"moduleNameMapper": {
|
|
57
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
58
|
+
},
|
|
59
|
+
"testEnvironment": "node",
|
|
60
|
+
"testMatch": [
|
|
61
|
+
"**/__tests__/**/*.test.ts"
|
|
62
|
+
],
|
|
63
|
+
"maxWorkers": "50%"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
67
|
+
"build": "pnpm run clean && tsc",
|
|
68
|
+
"check": "pnpm run lint && pnpm run build",
|
|
69
|
+
"lint": "eslint src --cache",
|
|
70
|
+
"test": "jest"
|
|
71
|
+
}
|
|
72
|
+
}
|