Add configurable area asset budgets

This commit is contained in:
2026-08-04 12:28:43 +08:00
parent f78080bbfa
commit 463cb06be4
18 changed files with 443 additions and 42 deletions

View File

@@ -54,6 +54,7 @@ cp config/examples/template.json config/areas/my-area.json
| `osm2streets` | | 见下 | 透传给 osm2streets 的选项 |
| `blender` | | 见下 | Blender 侧选项 |
| `compress` | | 见下 | 显式 `compress` 阶段的 GLB 压缩选项 |
| `budget` | | 见下 | 区域 GLB 性能与体量预算 |
| `outputs` | | 从 `id` 推导 | 输出路径覆盖,逃生舱 |
**路径一律绝对**`normalizeAreaConfig` 对每一项都做 `path.resolve`,相对路径会
@@ -132,6 +133,23 @@ cp config/examples/template.json config/areas/my-area.json
| `effort` | `80` | WebP 编码 effort范围 `0..100` |
| `meshopt` | `false` | 是否追加 `EXT_meshopt_compression`。开启前要单独验证 Cesium 兼容性 |
### `budget`
`budget``diagnose:area``check:area` 和 Cesium / compress manifest 共用的 GLB
限制。未配置时采用全局默认;用户字段统一用 MB 或整数,归一化后内部使用 bytes / counts
| 字段 | 默认 | 说明 |
|---|---:|---|
| `glbSizeMb` | `25` | GLB 文件总大小MB |
| `nodes` | `1000` | GLB node 数量 |
| `images` | `24` | GLB image 数量 |
| `triangles` | `250000` | node 实例化后的 render triangles不是唯一 mesh 的静态 triangles |
| `embeddedImageBytesMb` | `20` | GLB 内嵌图片字节MB |
| `reason` | `""` | 任一值高于默认时必填,记录区域例外原因 |
所有数值必须为正数,`nodes` / `images` / `triangles` 必须为正整数。收紧任何默认值不需要
`reason`;放宽任一默认值而没有非空 `reason` 会在配置归一化时失败。
### `outputs`(逃生舱)
默认全部从 `id` 推导为 `<outputRoot>/<id>/<fileStem>.<ext>`。需要定制时逐项覆盖:
@@ -165,7 +183,9 @@ cp config/examples/template.json config/areas/my-area.json
3. 若要传给低层脚本,加进 `writeDerivedConfig``derivedConfig` 对象
4. 若是数值,在消费侧加 `Number.isFinite` + 范围校验,**在任何副作用之前**
5. 更新 `config/examples/template.json`
6. 更新本文档的字段表
6. 若字段影响区域质量门,确认 `diagnose:area``check:area` 和 stage manifest 共用同一
个评估 helper不能在入口脚本各自比较阈值
7. 更新本文档的字段表
若新字段产出新文件,同时在 `outputs` 里加一行路径推导。

View File

@@ -323,6 +323,7 @@ node scripts/check-area.js [--config config/areas/<area>.json]
| Cesium GLB / metadata / preview 缺失或类型错误 | failure |
| metadata JSON 损坏 | failure |
| GLB size / nodes / images 超保守预算 | failure |
| GLB render triangles / embedded image bytes 超保守预算 | failure |
| expected stage manifest 缺失、损坏或 stale | failure |
| stage manifest warning 内容包含 budget exceeded | failure |
| QGIS preview 缺失 | warning不阻断 |
@@ -481,6 +482,7 @@ File records use this shape:
- `summary.glb.fileBytes`
- `summary.glb.counts`
- `summary.glb.extensionsUsed`
- `summary.budget`effective limits、usage 和 violationswarnings 来自同一个预算评估
`cesium` 会调用 preview 生成函数,但 preview HTML / route / vehicle model 的 freshness
所有权属于独立 `preview` manifest。否则单跑 `--stages preview` 会把 Cesium manifest
@@ -512,6 +514,7 @@ File records use this shape:
- `summary.options`
- `summary.compressionRatio`
- `summary.savedBytes`
- `summary.budget`:压缩 GLB 的 effective limits、usage 和 violations
Manifest files are written atomically via `*.tmp` then `renameSync`.
@@ -524,7 +527,7 @@ Manifest files are written atomically via `*.tmp` then `renameSync`.
| Manifest output 文件缺失 | 写入时抛错;诊断时报告 stale/missing |
| Manifest JSON 无法解析 | 诊断报告 invalid warning |
| Manifest 记录的 input / output sha/bytes 与当前文件不同 | 诊断报告 stale warning |
| GLB size / nodes / images 超保守预算 | manifest `warnings[]` 记录,诊断继续独立报警 |
| GLB size / nodes / images / render triangles / embedded image bytes 超保守预算 | manifest `warnings[]` 记录,诊断继续独立报警 |
| `intermediates` 后留有旧 reimport manifest | 成功后删除旧 reimport manifest |
| `reimport` 后留有旧 intermediates manifest | 成功后删除旧 intermediates manifest |