cyberia 3.0.1 → 3.0.2
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/.github/workflows/engine-cyberia.cd.yml +1 -0
- package/CHANGELOG.md +56 -1
- package/CLI-HELP.md +2 -4
- package/README.md +139 -0
- package/bin/build.js +5 -0
- package/bin/cyberia.js +385 -71
- package/bin/deploy.js +18 -26
- package/bin/file.js +3 -0
- package/bin/index.js +385 -71
- package/conf.js +32 -3
- package/deployment.yaml +2 -2
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
- package/manifests/ipfs/configmap.yaml +7 -0
- package/package.json +8 -8
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.controller.js +2 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.model.js +7 -0
- package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +93 -2
- package/src/api/file/file.controller.js +3 -13
- package/src/api/file/file.ref.json +0 -21
- package/src/api/ipfs/ipfs.controller.js +104 -0
- package/src/api/ipfs/ipfs.model.js +71 -0
- package/src/api/ipfs/ipfs.router.js +31 -0
- package/src/api/ipfs/ipfs.service.js +193 -0
- package/src/api/object-layer/README.md +139 -0
- package/src/api/object-layer/object-layer.controller.js +3 -0
- package/src/api/object-layer/object-layer.model.js +15 -1
- package/src/api/object-layer/object-layer.router.js +6 -10
- package/src/api/object-layer/object-layer.service.js +311 -182
- package/src/cli/cluster.js +30 -38
- package/src/cli/index.js +0 -1
- package/src/cli/run.js +14 -0
- package/src/client/components/core/LoadingAnimation.js +2 -3
- package/src/client/components/core/Modal.js +1 -1
- package/src/client/components/cyberia/ObjectLayerEngineModal.js +4 -5
- package/src/client/components/cyberia/ObjectLayerEngineViewer.js +280 -29
- package/src/client/services/ipfs/ipfs.service.js +144 -0
- package/src/client/services/object-layer/object-layer.management.js +161 -8
- package/src/index.js +1 -1
- package/src/runtime/express/Express.js +1 -1
- package/src/server/auth.js +18 -18
- package/src/server/ipfs-client.js +433 -0
- package/src/server/object-layer.js +649 -18
- package/src/server/semantic-layer-generator.js +1083 -0
- package/src/server/shape-generator.js +952 -0
- package/test/shape-generator.test.js +457 -0
- package/bin/ssl.js +0 -63
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { DataBaseProvider } from '../../db/DataBaseProvider.js';
|
|
2
|
+
import { loggerFactory } from '../../server/logger.js';
|
|
3
|
+
import { DataQuery } from '../../server/data-query.js';
|
|
4
|
+
import { IpfsClient } from '../../server/ipfs-client.js';
|
|
5
|
+
import { IpfsDto } from './ipfs.model.js';
|
|
6
|
+
|
|
7
|
+
const logger = loggerFactory(import.meta);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create (or upsert) an IPFS pin record for a given user + CID pair.
|
|
11
|
+
* This is a helper consumed by other services (ObjectLayer, AtlasSpriteSheet, …)
|
|
12
|
+
* so they don't need to know about the Ipfs model directly.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} opts
|
|
15
|
+
* @param {string} opts.cid – IPFS Content Identifier.
|
|
16
|
+
* @param {string} opts.userId – Mongoose ObjectId string of the owning user.
|
|
17
|
+
* @param {object} opts.options – Router options ({ host, path }) for DB lookup.
|
|
18
|
+
* @returns {Promise<import('mongoose').Document>}
|
|
19
|
+
*/
|
|
20
|
+
const createPinRecord = async ({ cid, userId, options }) => {
|
|
21
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
22
|
+
|
|
23
|
+
// Upsert: if a record for this user + CID already exists, just touch it.
|
|
24
|
+
const record = await Ipfs.findOneAndUpdate(
|
|
25
|
+
{ cid, userId },
|
|
26
|
+
{ cid, userId },
|
|
27
|
+
{ upsert: true, new: true, setDefaultsOnInsert: true },
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
logger.info(`IPFS pin record upserted – CID: ${cid}, userId: ${userId}`);
|
|
31
|
+
return record;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Remove all DB pin records for a CID, then best-effort unpin from IPFS node/cluster.
|
|
36
|
+
* Always deletes the DB records first so that even if the IPFS node is unreachable
|
|
37
|
+
* the database stays clean.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} cid – IPFS Content Identifier to clean up.
|
|
40
|
+
* @param {object} options – Router options ({ host, path }) for DB lookup.
|
|
41
|
+
* @returns {Promise<void>}
|
|
42
|
+
*/
|
|
43
|
+
const removePinRecordsAndUnpin = async (cid, options) => {
|
|
44
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
45
|
+
|
|
46
|
+
// 1. Remove all DB pin records for this CID first
|
|
47
|
+
await Ipfs.deleteMany({ cid });
|
|
48
|
+
logger.info(`Removed all IPFS pin records for CID: ${cid}`);
|
|
49
|
+
|
|
50
|
+
// 2. Best-effort unpin from IPFS node/cluster (ignore "not pinned" errors)
|
|
51
|
+
try {
|
|
52
|
+
await IpfsClient.unpinCid(cid);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
logger.warn(`Best-effort IPFS unpin failed for CID ${cid}: ${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const IpfsService = {
|
|
59
|
+
/** Expose helpers so other modules can import them directly. */
|
|
60
|
+
createPinRecord,
|
|
61
|
+
removePinRecordsAndUnpin,
|
|
62
|
+
|
|
63
|
+
// ──────────────────────────────────────────────
|
|
64
|
+
// Standard CRUD
|
|
65
|
+
// ──────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
post: async (req, res, options) => {
|
|
68
|
+
/** @type {import('./ipfs.model.js').IpfsModel} */
|
|
69
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
70
|
+
|
|
71
|
+
// Accept { cid, userId? } in body.
|
|
72
|
+
// If userId is omitted, fall back to the authenticated user.
|
|
73
|
+
const body = { ...req.body };
|
|
74
|
+
if (!body.userId && req.auth && req.auth.user) {
|
|
75
|
+
body.userId = req.auth.user._id;
|
|
76
|
+
}
|
|
77
|
+
// Strip pinType if sent by legacy clients
|
|
78
|
+
delete body.pinType;
|
|
79
|
+
|
|
80
|
+
return await new Ipfs(body).save();
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
get: async (req, res, options) => {
|
|
84
|
+
/** @type {import('./ipfs.model.js').IpfsModel} */
|
|
85
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
86
|
+
|
|
87
|
+
if (req.params.id) {
|
|
88
|
+
return await Ipfs.findById(req.params.id).select(IpfsDto.select.get()).populate(IpfsDto.populate.user());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { query, sort, skip, limit, page } = DataQuery.parse(req.query);
|
|
92
|
+
|
|
93
|
+
const [data, total] = await Promise.all([
|
|
94
|
+
Ipfs.find(query)
|
|
95
|
+
.select(IpfsDto.select.get())
|
|
96
|
+
.sort(sort)
|
|
97
|
+
.limit(limit)
|
|
98
|
+
.skip(skip)
|
|
99
|
+
.populate(IpfsDto.populate.user()),
|
|
100
|
+
Ipfs.countDocuments(query),
|
|
101
|
+
]);
|
|
102
|
+
|
|
103
|
+
const totalPages = Math.ceil(total / limit);
|
|
104
|
+
return { data, total, page, totalPages };
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
put: async (req, res, options) => {
|
|
108
|
+
/** @type {import('./ipfs.model.js').IpfsModel} */
|
|
109
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
110
|
+
return await Ipfs.findByIdAndUpdate(req.params.id, req.body, { new: true });
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
delete: async (req, res, options) => {
|
|
114
|
+
/** @type {import('./ipfs.model.js').IpfsModel} */
|
|
115
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
116
|
+
|
|
117
|
+
if (req.params.id) {
|
|
118
|
+
const record = await Ipfs.findById(req.params.id);
|
|
119
|
+
if (record) {
|
|
120
|
+
// Remove DB record first, then best-effort unpin
|
|
121
|
+
await Ipfs.findByIdAndDelete(req.params.id);
|
|
122
|
+
try {
|
|
123
|
+
// Only unpin from IPFS if no other records reference this CID
|
|
124
|
+
const remaining = await Ipfs.countDocuments({ cid: record.cid });
|
|
125
|
+
if (remaining === 0) {
|
|
126
|
+
await IpfsClient.unpinCid(record.cid);
|
|
127
|
+
}
|
|
128
|
+
} catch (err) {
|
|
129
|
+
logger.warn(`Failed to unpin CID ${record.cid} from IPFS node: ${err.message}`);
|
|
130
|
+
}
|
|
131
|
+
return record;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return await Ipfs.deleteMany();
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// ──────────────────────────────────────────────
|
|
140
|
+
// Pin / Unpin helpers (called via controller)
|
|
141
|
+
// ──────────────────────────────────────────────
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* POST /ipfs/pin – add content to IPFS, pin it, and create a DB record.
|
|
145
|
+
* Body: { data: <string|object>, userId? }
|
|
146
|
+
*/
|
|
147
|
+
pin: async (req, res, options) => {
|
|
148
|
+
const userId = req.body.userId || (req.auth && req.auth.user ? req.auth.user._id : undefined);
|
|
149
|
+
if (!userId) throw new Error('userId is required to create a pin record');
|
|
150
|
+
|
|
151
|
+
const content = typeof req.body.data === 'string' ? req.body.data : JSON.stringify(req.body.data);
|
|
152
|
+
const result = await IpfsClient.addToIpfs(Buffer.from(content, 'utf-8'), req.body.filename || 'data');
|
|
153
|
+
|
|
154
|
+
if (!result) throw new Error('IPFS node is unreachable – content was not pinned');
|
|
155
|
+
|
|
156
|
+
const record = await createPinRecord({
|
|
157
|
+
cid: result.cid,
|
|
158
|
+
userId,
|
|
159
|
+
options,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
return { cid: result.cid, size: result.size, record };
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* DELETE /ipfs/pin/:cid – unpin a CID and remove the DB record for the current user.
|
|
167
|
+
*/
|
|
168
|
+
unpin: async (req, res, options) => {
|
|
169
|
+
const Ipfs = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Ipfs;
|
|
170
|
+
const userId = req.auth && req.auth.user ? req.auth.user._id : undefined;
|
|
171
|
+
const cid = req.params.cid || req.params.id;
|
|
172
|
+
|
|
173
|
+
const record = await Ipfs.findOne({ cid, ...(userId ? { userId } : {}) });
|
|
174
|
+
if (!record) throw new Error(`No pin record found for CID ${cid}`);
|
|
175
|
+
|
|
176
|
+
// Remove DB record first
|
|
177
|
+
await Ipfs.findByIdAndDelete(record._id);
|
|
178
|
+
|
|
179
|
+
// Only unpin from the IPFS node when nobody else has a record for this CID
|
|
180
|
+
const remaining = await Ipfs.countDocuments({ cid });
|
|
181
|
+
if (remaining === 0) {
|
|
182
|
+
try {
|
|
183
|
+
await IpfsClient.unpinCid(cid);
|
|
184
|
+
} catch (err) {
|
|
185
|
+
logger.warn(`Best-effort IPFS unpin failed for CID ${cid}: ${err.message}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return { success: true, cid };
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export { IpfsService, createPinRecord, removePinRecordsAndUnpin };
|
|
@@ -24,12 +24,14 @@ Key features:
|
|
|
24
24
|
|
|
25
25
|
- Walks the asset directory structure and processes PNG/GIF files.
|
|
26
26
|
- Produces `frame_matrix` and `map_color` arrays from images.
|
|
27
|
+
- **Procedurally generates object layers** from semantic item-id descriptors with deterministic seeds and temporal coherence.
|
|
27
28
|
- Saves processed objects to the `ObjectLayer` model with top-level references to `ObjectLayerRenderFrames`.
|
|
28
29
|
- Creates separate `ObjectLayerRenderFrames` documents for render data.
|
|
29
30
|
- Links ObjectLayers to AtlasSpriteSheet documents via top-level `atlasSpriteSheetId`.
|
|
30
31
|
- Generates unique UUID v4 seeds (via `crypto.randomUUID()`) for SHA256 hash uniqueness.
|
|
31
32
|
- Generates SHA256 hash using `fast-json-stable-stringify` for deterministic serialization.
|
|
32
33
|
- Reconstructs PNG frames from stored tile data for debugging.
|
|
34
|
+
- Writes static asset PNGs, atlas sprite sheets, and metadata to the conventional directory structure.
|
|
33
35
|
|
|
34
36
|
## Getting Started
|
|
35
37
|
|
|
@@ -68,6 +70,104 @@ cyberia ol --import skin,floor
|
|
|
68
70
|
cyberia ol --import all
|
|
69
71
|
```
|
|
70
72
|
|
|
73
|
+
### Procedural generation with `--generate`
|
|
74
|
+
|
|
75
|
+
Produces semantically consistent object layers with controlled, reproducible variation and short-term temporal coherence (consecutive frames stay visually consistent). Uses the parametric shape generator and object layer engine under the hood.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Generate a desert floor tile (single frame, auto seed)
|
|
79
|
+
cyberia ol floor-desert --generate
|
|
80
|
+
|
|
81
|
+
# Full control: 3 frames, explicit seed, density
|
|
82
|
+
cyberia ol floor-desert --generate --count 3 --seed fx-42 --frame-index 0 --frame-count 3 --density 0.5
|
|
83
|
+
|
|
84
|
+
# Grass terrain, sparse, 5 frames
|
|
85
|
+
cyberia ol floor-grass --generate --seed meadow-7 --frame-count 5 --density 0.3
|
|
86
|
+
|
|
87
|
+
# Water surface, dense, high element count
|
|
88
|
+
cyberia ol floor-water --generate --seed ocean-1 --count 5 --density 0.8 --frame-count 4
|
|
89
|
+
|
|
90
|
+
# Stone cobblestone
|
|
91
|
+
cyberia ol floor-stone --generate --seed cobble-99 --count 4 --density 0.6
|
|
92
|
+
|
|
93
|
+
# Lava flow, 3-frame animation
|
|
94
|
+
cyberia ol floor-lava --generate --seed magma-3 --frame-count 3 --density 0.7
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**`--generate` options:**
|
|
98
|
+
|
|
99
|
+
| Option | Default | Description |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `--seed <str>` | auto UUID | Deterministic seed string. Same seed → same output. |
|
|
102
|
+
| `--count <n>` | `3` | Shape element count multiplier per layer. |
|
|
103
|
+
| `--frame-index <n>` | `0` | Starting frame index. |
|
|
104
|
+
| `--frame-count <n>` | `1` | Number of consecutive frames to generate. |
|
|
105
|
+
| `--density <f>` | `0.5` | Overall density factor (`0`–`1`). Lower = sparser. |
|
|
106
|
+
|
|
107
|
+
**Available semantic item-id prefixes:**
|
|
108
|
+
|
|
109
|
+
| Prefix | Type | Tags | Palette |
|
|
110
|
+
|---|---|---|---|
|
|
111
|
+
| `floor-desert` | floor | sand, dune, arid | warm ochres, sand tones |
|
|
112
|
+
| `floor-grass` | floor | grass, meadow, earth | greens, earth browns |
|
|
113
|
+
| `floor-water` | floor | water, ocean, wave | blues, foam whites |
|
|
114
|
+
| `floor-stone` | floor | stone, rock, cobble | greys, warm/cool stone |
|
|
115
|
+
| `floor-lava` | floor | lava, magma, fire | reds, oranges, dark crust |
|
|
116
|
+
| `skin-*` | skin | character, body | skin tones, clothing darks |
|
|
117
|
+
|
|
118
|
+
#### How generation works
|
|
119
|
+
|
|
120
|
+
Each item-id maps to a **semantic descriptor** that provides `semanticTags`, `paletteHints`, `preferredShapes`, and named **layer specs** (e.g. `base`, `dunes`, `rocks`, `tufts` for `floor-desert`).
|
|
121
|
+
|
|
122
|
+
**Seed derivation** — deterministic at every level:
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
layerSeed = hash(seed + ':' + itemId + ':' + layerKey)
|
|
126
|
+
frameSeed = hash(layerSeed + ':' + frameIndex)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Temporal coherence** — shape topology (which shapes, how many, where) is locked to `layerSeed` and never changes between frames. Only smooth, low-frequency noise perturbations (position jitter, slight rotation/scale wobble) are derived from `frameSeed`, so frame N and N+1 differ by ~2% of cells.
|
|
130
|
+
|
|
131
|
+
**Layer naming** — every generated layer gets an id: `<itemId>-<layerKey>` (e.g. `floor-desert-dunes`).
|
|
132
|
+
|
|
133
|
+
**Generation pipeline per layer:**
|
|
134
|
+
|
|
135
|
+
1. Pick generator type (`noise-field` for base fills, `shape` for element placement).
|
|
136
|
+
2. Select palette colors deterministically from `paletteHints` with per-element `colorShift`.
|
|
137
|
+
3. For shape layers: pick shape via weighted `preferredShapes`, compute stable base transform `(x, y, scale, rotation)`, apply frame-level smooth noise.
|
|
138
|
+
4. Stamp shapes onto a 24×24 grid via `intCoords` rasterization from the parametric shape generator.
|
|
139
|
+
5. Composite all layers into a final `frame_matrix` + unified `colors` palette.
|
|
140
|
+
|
|
141
|
+
**Variability factors per layer:**
|
|
142
|
+
`scaleVariance`, `rotationVariance`, `colorShift`, `jitter`, `noiseLevel`, `detailLevel`, `sparsity` — small, deterministic variations that keep each generation unique but semantically coherent.
|
|
143
|
+
|
|
144
|
+
#### What `--generate` persists
|
|
145
|
+
|
|
146
|
+
The full pipeline runs automatically:
|
|
147
|
+
|
|
148
|
+
1. **Static assets** — PNGs written to `./src/client/public/cyberia/assets/{type}/{itemId}/{dirCode}/{frame}.png` + `metadata.json`.
|
|
149
|
+
2. **MongoDB** — `ObjectLayerRenderFrames` + `ObjectLayer` documents created with SHA-256 hash.
|
|
150
|
+
3. **Atlas sprite sheet** — generated, saved to `File` + `AtlasSpriteSheet` collections, and linked via `atlasSpriteSheetId`.
|
|
151
|
+
|
|
152
|
+
#### Reproducibility example
|
|
153
|
+
|
|
154
|
+
Running the same command twice produces byte-identical output:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Run 1
|
|
158
|
+
cyberia ol floor-desert --generate --seed fx-42 --count 3 --frame-count 2
|
|
159
|
+
|
|
160
|
+
# Run 2 (identical output)
|
|
161
|
+
cyberia ol floor-desert --generate --seed fx-42 --count 3 --frame-count 2
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Different seeds produce different but semantically consistent results:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cyberia ol floor-desert --generate --seed fx-42 # variant A
|
|
168
|
+
cyberia ol floor-desert --generate --seed fx-99 # variant B (same style, different arrangement)
|
|
169
|
+
```
|
|
170
|
+
|
|
71
171
|
## Visualize a processed frame
|
|
72
172
|
|
|
73
173
|
Reconstructs and opens a PNG from the database-stored frame data. Requires item-id as the first positional argument, followed by direction and frame index in the format `[direction]_[frameIndex]`.
|
|
@@ -178,6 +278,45 @@ cyberia ol anon --to-atlas-sprite-sheet
|
|
|
178
278
|
cyberia ol anon --show-atlas-sprite-sheet
|
|
179
279
|
```
|
|
180
280
|
|
|
281
|
+
### Procedural Generation Pipeline
|
|
282
|
+
|
|
283
|
+
Generate an object layer entirely from a semantic descriptor — no source PNGs needed:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# 1. Generate a 3-frame desert floor with explicit seed
|
|
287
|
+
cyberia ol floor-desert --generate --seed fx-42 --frame-count 3 --density 0.5
|
|
288
|
+
|
|
289
|
+
# 2. Inspect the generated frame
|
|
290
|
+
cyberia ol floor-desert --show-frame 08_0
|
|
291
|
+
|
|
292
|
+
# 3. View the auto-generated atlas
|
|
293
|
+
cyberia ol floor-desert --show-atlas-sprite-sheet
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Batch Procedural Generation
|
|
297
|
+
|
|
298
|
+
Generate a full tileset family with consistent seeds:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
cyberia ol floor-desert --generate --seed world-1 --frame-count 3
|
|
302
|
+
cyberia ol floor-grass --generate --seed world-1 --frame-count 3
|
|
303
|
+
cyberia ol floor-water --generate --seed world-1 --frame-count 4
|
|
304
|
+
cyberia ol floor-stone --generate --seed world-1 --frame-count 2
|
|
305
|
+
cyberia ol floor-lava --generate --seed world-1 --frame-count 3
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Exploring Seed Variations
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# Same item, different seeds — compare visual output
|
|
312
|
+
cyberia ol floor-desert --generate --seed alpha --frame-count 1
|
|
313
|
+
cyberia ol floor-desert --generate --seed beta --frame-count 1
|
|
314
|
+
cyberia ol floor-desert --generate --seed gamma --frame-count 1
|
|
315
|
+
|
|
316
|
+
# Inspect each
|
|
317
|
+
cyberia ol floor-desert --show-frame 08_0
|
|
318
|
+
```
|
|
319
|
+
|
|
181
320
|
### Debugging Asset Issues
|
|
182
321
|
|
|
183
322
|
```bash
|
|
@@ -21,6 +21,8 @@ const ObjectLayerController = {
|
|
|
21
21
|
},
|
|
22
22
|
get: async (req, res, options) => {
|
|
23
23
|
try {
|
|
24
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
25
|
+
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
|
|
24
26
|
const result = await ObjectLayerService.get(req, res, options);
|
|
25
27
|
return res.status(200).json({
|
|
26
28
|
status: 'success',
|
|
@@ -37,6 +39,7 @@ const ObjectLayerController = {
|
|
|
37
39
|
generateWebp: async (req, res, options) => {
|
|
38
40
|
try {
|
|
39
41
|
const result = await ObjectLayerService.generateWebp(req, res, options);
|
|
42
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
40
43
|
res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
|
|
41
44
|
res.setHeader('Content-Type', 'image/webp');
|
|
42
45
|
res.setHeader(
|
|
@@ -52,6 +52,8 @@ const ItemSchema = new Schema(
|
|
|
52
52
|
* @property {Data.Stats} data.stats - Statistical attributes of the object layer
|
|
53
53
|
* @property {Data.Item} data.item - Item information this layer represents
|
|
54
54
|
* @property {string} data.seed - Random UUID for unique state generation
|
|
55
|
+
* @property {string} [data.atlasSpriteSheetCid] - IPFS Content Identifier for the consolidated atlas sprite sheet PNG
|
|
56
|
+
* @property {string} [cid] - IPFS Content Identifier for the object layer data JSON (fast-json-stable-stringify)
|
|
55
57
|
* @property {Types.ObjectId} objectLayerRenderFramesId - Reference to ObjectLayerRenderFrames document
|
|
56
58
|
* @property {Types.ObjectId} atlasSpriteSheetId - Reference to AtlasSpriteSheet document
|
|
57
59
|
* @property {string} sha256 - SHA-256 hash of the object layer data
|
|
@@ -72,7 +74,9 @@ const ObjectLayerSchema = new Schema(
|
|
|
72
74
|
'Please provide a valid UUID v4',
|
|
73
75
|
],
|
|
74
76
|
},
|
|
77
|
+
atlasSpriteSheetCid: { type: String, default: '', trim: true },
|
|
75
78
|
},
|
|
79
|
+
cid: { type: String, default: '', trim: true },
|
|
76
80
|
objectLayerRenderFramesId: { type: Schema.Types.ObjectId, ref: 'ObjectLayerRenderFrames' },
|
|
77
81
|
atlasSpriteSheetId: { type: Schema.Types.ObjectId, ref: 'AtlasSpriteSheet' },
|
|
78
82
|
sha256: {
|
|
@@ -115,6 +119,7 @@ ObjectLayerSchema.pre('save', function (next) {
|
|
|
115
119
|
if (!this.data.stats || !this.data.item || !this.data.seed || !this.sha256) {
|
|
116
120
|
throw new Error('Missing required fields');
|
|
117
121
|
}
|
|
122
|
+
// cid (object layer data JSON) and data.atlasSpriteSheetCid (atlas PNG) are optional – default to ''
|
|
118
123
|
next();
|
|
119
124
|
});
|
|
120
125
|
|
|
@@ -126,7 +131,14 @@ const ProviderSchema = ObjectLayerSchema;
|
|
|
126
131
|
const ObjectLayerDto = {
|
|
127
132
|
select: {
|
|
128
133
|
get: () => {
|
|
129
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
_id: 1,
|
|
136
|
+
'data.item': 1,
|
|
137
|
+
'data.atlasSpriteSheetCid': 1,
|
|
138
|
+
cid: 1,
|
|
139
|
+
objectLayerRenderFramesId: 1,
|
|
140
|
+
atlasSpriteSheetId: 1,
|
|
141
|
+
};
|
|
130
142
|
},
|
|
131
143
|
getMetadata: () => {
|
|
132
144
|
return {
|
|
@@ -134,6 +146,8 @@ const ObjectLayerDto = {
|
|
|
134
146
|
'data.item': 1,
|
|
135
147
|
'data.stats': 1,
|
|
136
148
|
'data.seed': 1,
|
|
149
|
+
'data.atlasSpriteSheetCid': 1,
|
|
150
|
+
cid: 1,
|
|
137
151
|
objectLayerRenderFramesId: 1,
|
|
138
152
|
atlasSpriteSheetId: 1,
|
|
139
153
|
sha256: 1,
|
|
@@ -20,16 +20,12 @@ const ObjectLayerRouter = (options) => {
|
|
|
20
20
|
`/generate-webp/:itemType/:itemId/:directionCode`,
|
|
21
21
|
async (req, res) => await ObjectLayerController.generateWebp(req, res, options),
|
|
22
22
|
);
|
|
23
|
-
router.get(`/render/:id`,
|
|
24
|
-
router.get(`/metadata/:id`,
|
|
25
|
-
router.get(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
router.get(`/:id`, authMiddleware, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
31
|
-
router.get(`/:id`, authMiddleware, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
32
|
-
router.get(`/`, authMiddleware, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
23
|
+
router.get(`/render/:id`, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
24
|
+
router.get(`/metadata/:id`, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
25
|
+
router.get(`/frame-counts/:id`, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
26
|
+
router.get(`/:id`, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
27
|
+
router.get(`/:id`, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
28
|
+
router.get(`/`, async (req, res) => await ObjectLayerController.get(req, res, options));
|
|
33
29
|
router.put(
|
|
34
30
|
`/:id/frame-image/:itemType/:itemId/:directionCode`,
|
|
35
31
|
authMiddleware,
|