Compare commits
16
Commits
96a99a671b
...
ddd15f68b3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddd15f68b3 | ||
|
|
aa5b1f85c8 | ||
|
|
761a52646c | ||
|
|
f13d890ffb | ||
|
|
41a0e81a6f | ||
|
|
eff7a01b2b | ||
|
|
0102ffbb3c | ||
|
|
f2b8d79f5d | ||
|
|
db0fba5bb5 | ||
|
|
c925890848 | ||
|
|
f385009043 | ||
|
|
b4a81331e8 | ||
|
|
e0cdf9e00b | ||
|
|
0790cbd0a9 | ||
|
|
b68be063ad | ||
|
|
d26921c6d1 |
No files matched your search
@@ -54,7 +54,7 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
| `turnLaneArrows` | | 见下 | 从 OSM `turn:lanes:*` 生成自定义车道箭头的发布开关 |
|
| `turnLaneArrows` | | 见下 | 从 OSM `turn:lanes:*` 生成自定义车道箭头的发布开关 |
|
||||||
| `osm2streets` | | 见下 | 透传给 osm2streets 的选项 |
|
| `osm2streets` | | 见下 | 透传给 osm2streets 的选项 |
|
||||||
| `blender` | | 见下 | Blender 侧选项 |
|
| `blender` | | 见下 | Blender 侧选项 |
|
||||||
| `compress` | | 见下 | 显式 `compress` 阶段的 GLB 压缩选项 |
|
| `compress` | | 见下 | 默认交付压缩阶段的 GLB 压缩选项 |
|
||||||
| `budget` | | 见下 | 区域 GLB 性能与体量预算 |
|
| `budget` | | 见下 | 区域 GLB 性能与体量预算 |
|
||||||
| `outputs` | | 从 `id` 推导 | 输出路径覆盖,逃生舱 |
|
| `outputs` | | 从 `id` 推导 | 输出路径覆盖,逃生舱 |
|
||||||
|
|
||||||
@@ -68,12 +68,14 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
| `intermediates` | `true` | 旧名 `qgis` 仍被接受 |
|
| `intermediates` | `true` | 旧名 `qgis` 仍被接受 |
|
||||||
| `blender` | `true` | |
|
| `blender` | `true` | |
|
||||||
| `cesium` | `true` | |
|
| `cesium` | `true` | |
|
||||||
|
| `compress` | `true` | 压缩 staged GLB,供随后发布使用 |
|
||||||
|
| `package` | `true` | 将通过校验的静态模型原子发布到 `package/` |
|
||||||
|
| `preview` | `true` | 基于已发布 package 写验证预览及 `_preview/` 动态资源 |
|
||||||
|
|
||||||
`reimport`、`preview` 和 `compress` **在这里配也没用**——`normalizeAreaConfig` 把它们
|
`reimport` **在这里配也没用**——`normalizeAreaConfig` 把它硬编码为 `false`,只能靠
|
||||||
硬编码为 `false`,只能靠 `--stages` 显式请求。
|
`--stages` 显式请求。`compress`、`package` 和 `preview` 始终默认开启。
|
||||||
|
|
||||||
> 恢复动作(reimport)、补丁动作(preview)和替代产物动作(compress)不该被一份
|
> 恢复动作(reimport)不该被一份配置文件变成默认行为;压缩、发布和验证预览是标准交付链的一部分。
|
||||||
> 配置文件变成默认行为。
|
|
||||||
|
|
||||||
`--stages` 会整体覆盖这里的默认值。
|
`--stages` 会整体覆盖这里的默认值。
|
||||||
|
|
||||||
@@ -133,8 +135,9 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
|
|
||||||
### `compress`
|
### `compress`
|
||||||
|
|
||||||
只影响显式 `--stages compress`。默认压缩链是 texture resize + WebP transcode,
|
完整构建和显式 `--stages compress` 都使用此配置。默认压缩链是 texture resize + WebP
|
||||||
不覆盖默认 `<area-id>.glb`。
|
transcode,成功后替换**package staging** 中的主 GLB 与 manifest;未压缩源只保留在构建临时目录。
|
||||||
|
只有随后的 `package` 阶段才会原子发布到 `package/`。
|
||||||
|
|
||||||
| 字段 | 默认 | 说明 |
|
| 字段 | 默认 | 说明 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
@@ -162,14 +165,16 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
|
|
||||||
### `outputs`(逃生舱)
|
### `outputs`(逃生舱)
|
||||||
|
|
||||||
默认全部从 `id` 推导为 `<outputRoot>/<id>/<fileStem>.<ext>`。需要定制时逐项覆盖:
|
默认全部从 `id` 推导。发布给下游的静态资产固定在
|
||||||
|
`<outputRoot>/<id>/package/`(含 `models/` 与可控信号灯 `runtime/`),临时静态资产在
|
||||||
|
`_pipeline/package-staging/`,预览专用车辆/路线资源在 `<outputRoot>/<id>/_preview/`。需要定制时逐项覆盖:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"outputs": {
|
"outputs": {
|
||||||
"areaDir": "/absolute/path/to/custom-area",
|
"areaDir": "/absolute/path/to/custom-area",
|
||||||
"blend": "/absolute/path/to/custom.blend",
|
"blend": "/absolute/path/to/custom.blend",
|
||||||
"glb": "/absolute/path/to/custom.glb",
|
"packageDir": "/absolute/path/to/custom-package",
|
||||||
"cesiumPreview": "/absolute/path/to/custom-preview.html"
|
"cesiumPreview": "/absolute/path/to/custom-preview.html"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,9 +182,13 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
|
|
||||||
可覆盖的键(`scripts/lib/area-config.js`):`areaDir`、`fileStem`、`geojsonDir`、`gpkg`、
|
可覆盖的键(`scripts/lib/area-config.js`):`areaDir`、`fileStem`、`geojsonDir`、`gpkg`、
|
||||||
`qgisProject`、`qgisPreview`、`blend`、`render`、`glb`、`metadata`、`cesiumPreview`、
|
`qgisProject`、`qgisPreview`、`blend`、`render`、`glb`、`metadata`、`cesiumPreview`、
|
||||||
`compressedFileStem`、`compressedGlb`、`compressedMetadata`、`compressedCesiumPreview`、
|
|
||||||
`vehicleRoute`、`vehicleModel`、`pipelineDir`、`stageManifestDir`。
|
`vehicleRoute`、`vehicleModel`、`pipelineDir`、`stageManifestDir`。
|
||||||
|
|
||||||
|
静态发布路径另有 `packageDir`、`packageStagingDir`、`packageManifest`、
|
||||||
|
`packageStagingManifest`、`packageModelDir`、`packageStagingModelDir` 与
|
||||||
|
`packagePrimaryGlb`;预览路径另有 `previewDir` 与 `previewDescriptor`。除非在迁移旧调用,
|
||||||
|
不要覆盖 `glb` / `metadata`:它们是 staging 内部路径,不是下游资产入口。
|
||||||
|
|
||||||
**优先改 `fileStem` 或 `areaDir`**——它们能一次性影响全部派生路径。逐个覆盖容易漏。
|
**优先改 `fileStem` 或 `areaDir`**——它们能一次性影响全部派生路径。逐个覆盖容易漏。
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -221,7 +230,8 @@ cp config/examples/template.json config/areas/my-area.json
|
|||||||
| 布尔字段用 `\|\|` 兜底 | `false` 被翻转 |
|
| 布尔字段用 `\|\|` 兜底 | `false` 被翻转 |
|
||||||
| 给新字段造顶层平铺别名 | 扩大历史包袱 |
|
| 给新字段造顶层平铺别名 | 扩大历史包袱 |
|
||||||
| 逐个覆盖 `outputs` 而不用 `fileStem` | 漏掉某个产物路径 |
|
| 逐个覆盖 `outputs` 而不用 `fileStem` | 漏掉某个产物路径 |
|
||||||
| 在 `stages` 里配 `reimport` / `preview` / `compress` | 无效,被硬编码为 false |
|
| 将 `glb` / `metadata` 当作下游入口 | 它们位于 staging;应只读取 `package/manifest.json` |
|
||||||
|
| 在 `stages` 里配 `reimport` | 无效,被硬编码为 false |
|
||||||
| 加数值字段不做范围校验 | 错配置在中途才崩,输出已被破坏 |
|
| 加数值字段不做范围校验 | 错配置在中途才崩,输出已被破坏 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -21,13 +21,14 @@
|
|||||||
全部是 CommonJS(`package.json` 的 `"type": "commonjs"`),无构建步骤、无 TypeScript、
|
全部是 CommonJS(`package.json` 的 `"type": "commonjs"`),无构建步骤、无 TypeScript、
|
||||||
零运行时依赖(唯一依赖 `osm2streets-js-node` 只被 `build-osm2streets-qgis.js` 用)。
|
零运行时依赖(唯一依赖 `osm2streets-js-node` 只被 `build-osm2streets-qgis.js` 用)。
|
||||||
|
|
||||||
## 可选 GLB 压缩阶段
|
## 默认 GLB 压缩阶段
|
||||||
|
|
||||||
### 1. Scope / Trigger
|
### 1. Scope / Trigger
|
||||||
|
|
||||||
`compress` 是显式请求的替代产物阶段,不属于 `all`,也不覆盖默认 `<area-id>.glb`。
|
`compress` 是完整构建的默认阶段,位于 `cesium` 与 `package` 之间。它在
|
||||||
它用于在已有 Cesium GLB 上生成并列压缩 GLB、metadata 和预览页。当前主路径是
|
`_pipeline/package-staging/` 的主 GLB 上执行 texture resize + WebP transcode,并替换 staged
|
||||||
texture resize + WebP transcode。
|
主 GLB 与 staged manifest;不触碰已发布的 `package/`,也不重写 preview HTML。未压缩版本只在
|
||||||
|
`<areaDir>/_pipeline/compress-*` 临时目录中存在,成功或失败后都会清理。
|
||||||
|
|
||||||
`scripts/compress-glb.js` 是该阶段调用的低层脚本,也可单独运行做实验。
|
`scripts/compress-glb.js` 是该阶段调用的低层脚本,也可单独运行做实验。
|
||||||
|
|
||||||
@@ -62,20 +63,17 @@ npm run compress:glb -- --input in.glb --output out.glb [options]
|
|||||||
### 3. Contracts
|
### 3. Contracts
|
||||||
|
|
||||||
- 输入必须是现有 `.glb` 文件;`--output` 必须不同于 `--input`。
|
- 输入必须是现有 `.glb` 文件;`--output` 必须不同于 `--input`。
|
||||||
- 输出是并列压缩 GLB;默认构建产物不被替换。
|
- 低层脚本仍输出到与输入不同的路径;`build-area.js` 使用临时输入/输出路径,避免原地压缩。
|
||||||
- `compress` 阶段依赖默认 `glb`、`metadata` 和 `cesiumPreview` 已存在。
|
- `compress` 阶段依赖 staged `glb` 与 `metadata` 已存在,并在全部临时交付文件生成和校验后
|
||||||
|
以 `renameSync` 替换它们。
|
||||||
- 默认链固定为 `gltf-transform resize -> gltf-transform webp`。
|
- 默认链固定为 `gltf-transform resize -> gltf-transform webp`。
|
||||||
- `compress` 阶段默认 `textureSize=768`;低层脚本单独运行时默认 `--texture-size 1024`。
|
- `compress` 阶段默认 `textureSize=768`;低层脚本单独运行时默认 `--texture-size 1024`。
|
||||||
- `build-area.js` 默认写:
|
- `build-area.js` 不会写并列 `-compressed-*` 交付物;`package` 是唯一能发布静态文件到
|
||||||
- `<fileStem>-compressed-webp768.glb`
|
`package/` 的阶段。
|
||||||
- `<fileStem>-compressed-webp768.json`
|
- staged manifest 的 `assets[*].uri` 必须保持 package-relative,如 `models/<area>.glb`;分类
|
||||||
- `<fileStem>-compressed-webp768-cesium-preview.html`
|
layer GLB 必须原样保留。
|
||||||
- 伴生 metadata 的 `asset` 与 `id="main"` 资产 URL 改为压缩 GLB 文件名;其余资产(包括
|
|
||||||
`category="semantic"` 的 Cesium 分类检查 GLB)必须原样保留。
|
|
||||||
- preview HTML 只替换 `window.OSM_ASSET_PREVIEW_CONFIG` 的 `glbName` /
|
|
||||||
`metadataName` 和 loading 文案,不改 preview runtime。
|
|
||||||
- 成功时 stdout 打印 `GLB_COMPRESS_DONE <json>`,包含压缩前后大小、image /
|
- 成功时 stdout 打印 `GLB_COMPRESS_DONE <json>`,包含压缩前后大小、image /
|
||||||
non-image bytes、结构计数、扩展、metadata / preview 输出路径。
|
non-image bytes、结构计数、扩展与 metadata 输出路径。
|
||||||
|
|
||||||
### 4. Validation & Error Matrix
|
### 4. Validation & Error Matrix
|
||||||
|
|
||||||
@@ -86,27 +84,24 @@ npm run compress:glb -- --input in.glb --output out.glb [options]
|
|||||||
| `--output` 等于 `--input` | 抛错,避免覆盖源 GLB |
|
| `--output` 等于 `--input` | 抛错,避免覆盖源 GLB |
|
||||||
| 数值参数超范围 | 抛错并指出合法范围 |
|
| 数值参数超范围 | 抛错并指出合法范围 |
|
||||||
| `gltf-transform` 退出非零 | 抛错并带上 status / signal |
|
| `gltf-transform` 退出非零 | 抛错并带上 status / signal |
|
||||||
| `--preview` 没有 `--metadata` | 抛错,因为 preview 必须指向存在的 metadata |
|
| `--stages compress` 但 staged manifest 不存在 | `Cesium metadata not found: <path>` |
|
||||||
| preview HTML 找不到配置块 | 抛错,不做猜测替换 |
|
|
||||||
| `--stages compress` 但默认 preview 不存在 | `Cesium preview not found: <path>` |
|
|
||||||
|
|
||||||
### 5. Good/Base/Bad Cases
|
### 5. Good/Base/Bad Cases
|
||||||
|
|
||||||
- Good: `--stages cesium,compress` 先重导默认 GLB,再生成并列压缩产物。
|
- Good: 默认构建先导出 Cesium,再压缩 staged 资产,最后由 `package` 发布。
|
||||||
- Good: `--texture-size 768 --metadata --preview` 生成压缩 GLB、metadata、HTML,
|
- Good: `--stages compress` 对已有 staged 交付物重新压缩,临时源 GLB 不会留在输出目录。
|
||||||
源 GLB 保持不变。
|
|
||||||
- Base: 只传 `--input --output` 生成压缩 GLB,不生成伴生文件。
|
- Base: 只传 `--input --output` 生成压缩 GLB,不生成伴生文件。
|
||||||
- Bad: 使用 `--meshopt` 后没有做 Cesium 兼容性验证就当默认产物发布。
|
- Bad: 使用 `--meshopt` 后没有做 Cesium 兼容性验证就当默认产物发布。
|
||||||
|
|
||||||
### 6. Tests Required
|
### 6. Tests Required
|
||||||
|
|
||||||
- `node --check scripts/compress-glb.js`
|
- `node --check scripts/compress-glb.js`
|
||||||
- `npm run test:compress-glb`:断言压缩 metadata 只替换主资产,不丢失语义资产。
|
- `npm run test:compress-glb`:断言压缩 manifest 只替换主资产,不丢失语义 layer。
|
||||||
- `node --check scripts/build-area.js`
|
- `node --check scripts/build-area.js`
|
||||||
- 对目标区域跑一次 `npm run compress:glb -- ... --metadata --preview`
|
- 对目标区域跑一次 `npm run compress:glb -- ... --metadata`
|
||||||
- 对目标区域跑一次 `npm run build:area -- --stages compress`
|
- 对目标区域跑一次默认 `npm run build:area`
|
||||||
- `node scripts/glb-digest.js <compressed.glb>` 确认可解析结构和扩展
|
- `node scripts/glb-digest.js <area>.glb` 确认可解析结构和扩展
|
||||||
- 浏览器/Cesium 预览压缩 HTML,确认 `EXT_texture_webp` 在目标环境可加载
|
- 浏览器/Cesium 预览标准 HTML,确认 `EXT_texture_webp` 在目标环境可加载
|
||||||
|
|
||||||
### 7. Wrong vs Correct
|
### 7. Wrong vs Correct
|
||||||
|
|
||||||
@@ -116,10 +111,110 @@ Wrong:
|
|||||||
npm run compress:glb -- --input outputs/a/a.glb --output outputs/a/a.glb
|
npm run compress:glb -- --input outputs/a/a.glb --output outputs/a/a.glb
|
||||||
```
|
```
|
||||||
|
|
||||||
Correct:
|
Correct for the low-level script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run compress:glb -- --input outputs/a/a.glb --output outputs/a/a-compressed-webp768.glb
|
npm run compress:glb -- --input outputs/a/a.glb --output /tmp/a-compressed.glb
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 可复用资产包发布
|
||||||
|
|
||||||
|
### 1. Scope / Trigger
|
||||||
|
|
||||||
|
`package` 将已验证的 static staging 提升为下游可消费的唯一交付边界:
|
||||||
|
`<areaDir>/package/`。它不复制大文件到第二个发布目录;成功时将整个 staging 目录原子 rename
|
||||||
|
为 package。车辆、路线和动态信号属于预览能力,必须留在 `<areaDir>/_preview/`,不能进入 package。
|
||||||
|
|
||||||
|
### 2. Signatures
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build:area -- --config config/areas/<area>.json --stages cesium,compress,package
|
||||||
|
npm run build:area -- --config config/areas/<area>.json --stages preview
|
||||||
|
node scripts/test-package-contract.js
|
||||||
|
node scripts/test-package-examples.js
|
||||||
|
```
|
||||||
|
|
||||||
|
下游入口永远是:
|
||||||
|
|
||||||
|
```text
|
||||||
|
outputs/<area>/package/manifest.json
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Contracts
|
||||||
|
|
||||||
|
发布 manifest 使用 `schema: "osm-asset-package/v1"`,至少包含:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"schema": "osm-asset-package/v1",
|
||||||
|
"packageVersion": "1.0.0",
|
||||||
|
"areaId": "example",
|
||||||
|
"coordinateSystem": { "axes": "ENU", "units": "meters", "x": "east", "y": "north", "z": "up" },
|
||||||
|
"placement": { "longitude": 114.3, "latitude": 30.5, "height": 0, "headingCorrectionDegrees": -90 },
|
||||||
|
"bounds": { "minLon": 114.2, "minLat": 30.4, "maxLon": 114.4, "maxLat": 30.6 },
|
||||||
|
"assets": [{
|
||||||
|
"id": "main",
|
||||||
|
"role": "scene",
|
||||||
|
"category": "scene",
|
||||||
|
"uri": "models/example.glb",
|
||||||
|
"defaultLoad": true,
|
||||||
|
"integrity": { "bytes": 123, "sha256": "..." }
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `coordinateSystem` 固定为 ENU meters,`placement` 是 WGS84 锚点与 heading correction。
|
||||||
|
- 必须恰有一个 `role="scene"` / `category="scene"` / `defaultLoad=true` 主资产;roads、buildings、
|
||||||
|
vegetation、water 是 `role="layer"` 且 `defaultLoad=false` 的可选语义层。
|
||||||
|
- `assets[*].uri` 与 `runtime[*].uri` 只能是包内正向相对路径,禁止绝对路径、反斜杠和 `..`。
|
||||||
|
- `runtime` 声明可编程运行时资产;当前至少包含 `traffic-signals` 锚点 JSON、
|
||||||
|
`traffic-signals-dynamic` 灯珠 GLB,以及两个 `traffic-signals-countdown-*` 倒计时 GLB。
|
||||||
|
它们是资产包的一部分,不属于 `_preview/`。
|
||||||
|
- `package` 在晋升前调用 `validateManifest()`;再为每个模型写 bytes 与 SHA-256,然后复验。
|
||||||
|
- `package` 是唯一拥有最终 package file records 的 stage。`cesium` / `compress` 只能拥有 staging
|
||||||
|
或计算摘要,不能留下指向最终 package 文件的 outputs record。
|
||||||
|
- 下游代码和 preview 都从 manifest URL 解析 `assets[*].uri`。参考
|
||||||
|
`examples/cesium-asset-package.js` 与 `examples/three-asset-package.js`。
|
||||||
|
|
||||||
|
### 4. Validation & Error Matrix
|
||||||
|
|
||||||
|
| 条件 | 结果 |
|
||||||
|
|---|---|
|
||||||
|
| staging manifest 缺失或无效 JSON | `package` 失败,不替换上次成功 package |
|
||||||
|
| URI 是绝对路径、含 `..` 或 `\\` | `validateManifest()` 失败 |
|
||||||
|
| ENU / WGS84 字段缺失或越界 | `validateManifest()` 失败 |
|
||||||
|
| 没有或多于一个 scene asset | `validateManifest()` 失败 |
|
||||||
|
| manifest 声明的模型文件缺失 | `validateManifest()` 失败 |
|
||||||
|
| rename 发布异常 | 尝试恢复 `<package>.previous`,保留原 package |
|
||||||
|
|
||||||
|
### 5. Good/Base/Bad Cases
|
||||||
|
|
||||||
|
- Good: 下游只带走 `package/`,按 manifest 的 WGS84 placement 放置主模型,按需加载 layer。
|
||||||
|
- Base: 只有 main scene 的区域仍是合法 package;没有几何的语义类别不写空 GLB。
|
||||||
|
- Bad: 将 `_preview/` 的车辆模型或路线加进 package;它们是本项目的验证运行时,信号灯 runtime 则必须发布。
|
||||||
|
|
||||||
|
### 6. Tests Required
|
||||||
|
|
||||||
|
- `npm run test:package-contract`:schema、URI、placement、唯一 scene 和模型存在性。
|
||||||
|
- `npm run test:package-examples`:Cesium / Three.js resolver 都相对 manifest 解析 URI。
|
||||||
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages cesium,compress,package,preview`
|
||||||
|
- `npm run check:area -- --config config/areas/nantaizi-lake-innovation-valley.json`
|
||||||
|
- 将 `package/` 复制到其他目录后,重新运行 manifest validator;所有 `assets[*].uri` 必须仍能解析。
|
||||||
|
|
||||||
|
### 7. Wrong vs Correct
|
||||||
|
|
||||||
|
Wrong:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const modelUrl = asset.uri; // Relative to preview HTML by accident.
|
||||||
|
```
|
||||||
|
|
||||||
|
Correct:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const modelUrl = new URL(asset.uri, new URL(manifestUrl, window.location.href)).href;
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -607,7 +702,7 @@ const gate = classifyAreaQuality(result);
|
|||||||
### 1. Scope / Trigger
|
### 1. Scope / Trigger
|
||||||
|
|
||||||
Stage manifest 是区域构建阶段或独立验证通过后的机器可读产物契约。它覆盖预检记录与完整区域链:
|
Stage manifest 是区域构建阶段或独立验证通过后的机器可读产物契约。它覆盖预检记录与完整区域链:
|
||||||
`preflight`、`intermediates`、`reimport`、`blender`、`cesium`、`preview` 和 `compress`。
|
`preflight`、`intermediates`、`reimport`、`blender`、`cesium`、`compress`、`package` 和 `preview`。
|
||||||
它用于诊断产物是否存在、是否 stale、体量是否超预算,以及后续 `check:area` /
|
它用于诊断产物是否存在、是否 stale、体量是否超预算,以及后续 `check:area` /
|
||||||
增量构建判断。
|
增量构建判断。
|
||||||
|
|
||||||
@@ -629,6 +724,7 @@ Manifest 路径固定:
|
|||||||
<areaDir>/_pipeline/stages/cesium.manifest.json
|
<areaDir>/_pipeline/stages/cesium.manifest.json
|
||||||
<areaDir>/_pipeline/stages/preview.manifest.json
|
<areaDir>/_pipeline/stages/preview.manifest.json
|
||||||
<areaDir>/_pipeline/stages/compress.manifest.json
|
<areaDir>/_pipeline/stages/compress.manifest.json
|
||||||
|
<areaDir>/_pipeline/stages/package.manifest.json
|
||||||
```
|
```
|
||||||
|
|
||||||
代码入口:
|
代码入口:
|
||||||
@@ -721,9 +817,18 @@ File records use this shape:
|
|||||||
- `summary.glb.extensionsUsed`
|
- `summary.glb.extensionsUsed`
|
||||||
- `summary.budget`:effective limits、usage 和 violations;warnings 来自同一个预算评估
|
- `summary.budget`:effective limits、usage 和 violations;warnings 来自同一个预算评估
|
||||||
|
|
||||||
`cesium` 会调用 preview 生成函数,但 preview HTML / route / vehicle model 的 freshness
|
`cesium` 只拥有 staging 内的静态模型与 manifest;完成后必须依次由 `compress`、`package`
|
||||||
所有权属于独立 `preview` manifest。否则单跑 `--stages preview` 会把 Cesium manifest
|
交付。preview HTML / route / vehicle model 的 freshness 所有权属于独立 `preview` manifest。
|
||||||
错误判 stale。
|
|
||||||
|
`compress` manifest 不记录最终文件 records:它们位于可被 `package` rename 的 staging 目录。
|
||||||
|
`package` manifest 是唯一记录 `package/manifest.json`、主 GLB 与 package 目录的 stage manifest,
|
||||||
|
避免发布后 compress manifest 因路径迁移而立刻 stale。
|
||||||
|
|
||||||
|
`package` manifest:
|
||||||
|
|
||||||
|
- `inputs.stagingManifest`:发布后的同一 manifest 文件记录
|
||||||
|
- `outputs.packageDir`、`outputs.manifest`、`outputs.primaryGlb`
|
||||||
|
- `summary.assets` 与 `summary.packageDir`
|
||||||
|
|
||||||
### Preview Assembly Boundary
|
### Preview Assembly Boundary
|
||||||
|
|
||||||
@@ -758,14 +863,11 @@ runtime 与 HTML,并写 preview manifest。预览内容实现不得回流到
|
|||||||
|
|
||||||
`compress` manifest:
|
`compress` manifest:
|
||||||
|
|
||||||
- `inputs.glb`
|
- `outputs.glb`
|
||||||
- `inputs.metadata`
|
- `outputs.metadata`
|
||||||
- `inputs.cesiumPreview`
|
- `outputs.cesiumPreview`
|
||||||
- `outputs.compressedGlb`
|
|
||||||
- `outputs.compressedMetadata`
|
|
||||||
- `outputs.compressedCesiumPreview`
|
|
||||||
- `summary.sourceGlb`
|
- `summary.sourceGlb`
|
||||||
- `summary.compressedGlb`
|
- `summary.glb`
|
||||||
- `summary.options`
|
- `summary.options`
|
||||||
- `summary.compressionRatio`
|
- `summary.compressionRatio`
|
||||||
- `summary.savedBytes`
|
- `summary.savedBytes`
|
||||||
@@ -791,8 +893,8 @@ Manifest files are written atomically via `*.tmp` then `renameSync`.
|
|||||||
- Good: `--stages intermediates` 成功后写 `intermediates.manifest.json`,诊断显示
|
- Good: `--stages intermediates` 成功后写 `intermediates.manifest.json`,诊断显示
|
||||||
`ok intermediates`。
|
`ok intermediates`。
|
||||||
- Good: `--stages blender` 成功后写 `blender.manifest.json`,诊断显示 `ok blender`。
|
- Good: `--stages blender` 成功后写 `blender.manifest.json`,诊断显示 `ok blender`。
|
||||||
- Good: `--stages cesium` 成功后写 `cesium.manifest.json` 和 `preview.manifest.json`。
|
- Good: `--stages cesium,compress,package,preview` 成功后依序写四份各自拥有的 manifest。
|
||||||
- Good: `--stages preview` 只更新 preview manifest,不让 cesium manifest stale。
|
- Good: `--stages preview` 只更新 preview manifest,不让 package manifest stale。
|
||||||
- Good: `--stages compress` 成功后写 `compress.manifest.json`,summary 记录压缩比和节省字节。
|
- Good: `--stages compress` 成功后写 `compress.manifest.json`,summary 记录压缩比和节省字节。
|
||||||
- Base: 旧产物没有当前 ownership 路径的 manifest,诊断显示 expected manifest missing,
|
- Base: 旧产物没有当前 ownership 路径的 manifest,诊断显示 expected manifest missing,
|
||||||
提示重跑对应阶段。
|
提示重跑对应阶段。
|
||||||
@@ -811,6 +913,7 @@ Manifest files are written atomically via `*.tmp` then `renameSync`.
|
|||||||
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages intermediates`
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages intermediates`
|
||||||
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender`
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages blender`
|
||||||
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages cesium`
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages cesium`
|
||||||
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages compress,package,preview`
|
||||||
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages preview`
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages preview`
|
||||||
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages compress`
|
- `npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages compress`
|
||||||
- `npm run diagnose:area -- --config config/areas/nantaizi-lake-innovation-valley.json`
|
- `npm run diagnose:area -- --config config/areas/nantaizi-lake-innovation-valley.json`
|
||||||
@@ -929,15 +1032,16 @@ gpkg: path.resolve(outputOverrides.gpkg || path.join(areaDir, `${fileStem}.gpkg`
|
|||||||
| `intermediates` | OSM → osm2streets GeoJSON → GeoPackage → QGIS 工程 + 预览图 | `.osm` | `osm2streets_web_out/`、`.gpkg`、`.qgz`、`-preview.png` |
|
| `intermediates` | OSM → osm2streets GeoJSON → GeoPackage → QGIS 工程 + 预览图 | `.osm` | `osm2streets_web_out/`、`.gpkg`、`.qgz`、`-preview.png` |
|
||||||
| `reimport` | GeoPackage → GeoJSON(**反向**) | `.gpkg` | `osm2streets_web_out/` |
|
| `reimport` | GeoPackage → GeoJSON(**反向**) | `.gpkg` | `osm2streets_web_out/` |
|
||||||
| `blender` | OSM + GeoJSON → 场景 | `.osm`、`osm2streets_web_out/` | `.blend`、`.png` |
|
| `blender` | OSM + GeoJSON → 场景 | `.osm`、`osm2streets_web_out/` | `.blend`、`.png` |
|
||||||
| `cesium` | 场景 → GLB + 元数据 + 预览页 | `.blend` | `.glb`、`.json`、预览 HTML 及其静态资源 |
|
| `cesium` | 场景 → static staging GLB + manifest | `.blend` | `_pipeline/package-staging/models/*.glb`、staged manifest;动态 GLB 到 `_preview/` |
|
||||||
| `preview` | 只补生成预览页 | `.glb`、`.json` | 预览 HTML 及其静态资源 |
|
| `compress` | 压缩 Cesium staging 主模型 | staged `.glb`、manifest | 压缩 staged `.glb`、manifest |
|
||||||
| `compress` | 生成并列压缩 Cesium 产物 | `.glb`、`.json`、默认预览 HTML | `-compressed-webp*.glb/json/html` |
|
| `package` | 校验并原子发布静态资产包 | staging manifest 与 models | `package/manifest.json`、`package/models/*.glb` |
|
||||||
|
| `preview` | 用已发布 manifest 生成验证预览 | `package/manifest.json`、动态输入 | 预览 HTML、静态 runtime、`_preview/` 动态资源 |
|
||||||
|
|
||||||
调度是顶层的阶段 `if`(`build-area.js` 开头),顺序固定,**阶段之间不传内存状态,
|
调度是顶层的阶段 `if`(`build-area.js` 开头),顺序固定,**阶段之间不传内存状态,
|
||||||
只通过磁盘产物耦合**。这就是单跑某个阶段能work 的原因。
|
只通过磁盘产物耦合**。这就是单跑某个阶段能work 的原因。
|
||||||
|
|
||||||
`cesium` 阶段结束时会直接调 `writeCesiumPreview(area)`(`build-area.js:285`),所以
|
完整构建中 `preview` 在 `package` 后运行。单跑 `preview` 用于已发布 package 但想重生成
|
||||||
`preview` 只在"已有 GLB、只想重生成 HTML"时才需要单独跑。
|
验证 UI 或 `_preview/` 动态资源的情况。
|
||||||
|
|
||||||
### 别名
|
### 别名
|
||||||
|
|
||||||
@@ -952,11 +1056,11 @@ gpkg: path.resolve(outputOverrides.gpkg || path.join(areaDir, `${fileStem}.gpkg`
|
|||||||
```js
|
```js
|
||||||
// 'reimport' is deliberately absent from 'all': it is a recovery step for
|
// 'reimport' is deliberately absent from 'all': it is a recovery step for
|
||||||
// hand-edited GeoPackages, never part of a full build. build-area.js:159-160
|
// hand-edited GeoPackages, never part of a full build. build-area.js:159-160
|
||||||
all: ["intermediates", "blender", "cesium"],
|
all: ["intermediates", "blender", "cesium", "compress", "package", "preview"],
|
||||||
```
|
```
|
||||||
|
|
||||||
`preview` 同样不在 `all` 里——`cesium` 已经包含它。`compress` 也不在 `all` 里——
|
`compress`、`package`、`preview` 均在 `all` 中,确保完整构建以压缩后的可复用静态 package
|
||||||
它生成的是替代压缩产物,不是 baseline GLB。
|
以及可运行的验证预览交付。
|
||||||
|
|
||||||
### `intermediates` 与 `reimport` 互斥
|
### `intermediates` 与 `reimport` 互斥
|
||||||
|
|
||||||
@@ -966,9 +1070,8 @@ all: ["intermediates", "blender", "cesium"],
|
|||||||
|
|
||||||
这是**显式拒绝而不是警告**——两者同时开,无论谁先跑,另一个的工作都白做。
|
这是**显式拒绝而不是警告**——两者同时开,无论谁先跑,另一个的工作都白做。
|
||||||
|
|
||||||
`normalizeAreaConfig` 里 `stages.reimport`、`stages.preview` 和 `stages.compress` 硬编码为 `false`,
|
`normalizeAreaConfig` 里只有 `stages.reimport` 硬编码为 `false`,只能靠 `--stages` 显式请求;
|
||||||
**不能从配置文件打开**,只能靠 `--stages` 显式请求。
|
`stages.compress`、`stages.package` 和 `stages.preview` 为默认 `true`。
|
||||||
恢复动作、补丁动作和替代产物动作都不该被一份配置文件变成默认行为。
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -1005,7 +1108,7 @@ parity 校验依赖 stage 的 stdout 标记来判断阶段是否跑到(如 `SC
|
|||||||
| 在阶段函数里现拼输出路径 | 路径规则出现第二份定义 |
|
| 在阶段函数里现拼输出路径 | 路径规则出现第二份定义 |
|
||||||
| 低层脚本直接读 `config/areas/*.json` | 打破两层配置边界 |
|
| 低层脚本直接读 `config/areas/*.json` | 打破两层配置边界 |
|
||||||
| 布尔配置用 `\|\|` 兜底 | `false` 被翻转成默认值 |
|
| 布尔配置用 `\|\|` 兜底 | `false` 被翻转成默认值 |
|
||||||
| 让 `reimport` / `preview` 能从配置文件默认开启 | 恢复动作变成常规行为 |
|
| 让 `reimport` 能从配置文件默认开启 | 恢复动作变成常规行为 |
|
||||||
| 新阶段忘了 `ensureFile` 前置校验 | 单跑时报底层堆栈而非人话 |
|
| 新阶段忘了 `ensureFile` 前置校验 | 单跑时报底层堆栈而非人话 |
|
||||||
| 改 stage 的 stdout 标记 | 静默破坏 parity 契约 |
|
| 改 stage 的 stdout 标记 | 静默破坏 parity 契约 |
|
||||||
| 顺手把多份 `parseArgs` 合并 | 扩大 diff,且独立入口的独立性是刻意的 |
|
| 顺手把多份 `parseArgs` 合并 | 扩大 diff,且独立入口的独立性是刻意的 |
|
||||||
|
|||||||
@@ -51,17 +51,21 @@ config/areas/<id>.json
|
|||||||
│ → _pipeline/stages/blender.manifest.json
|
│ → _pipeline/stages/blender.manifest.json
|
||||||
│
|
│
|
||||||
├─[cesium]────────▶ Blender + blender/export_cesium.py
|
├─[cesium]────────▶ Blender + blender/export_cesium.py
|
||||||
│ 读 .blend → <id>.glb + <id>.json
|
│ 读 .blend → _pipeline/package-staging/models/<id>.glb
|
||||||
│ → 并自动执行 preview
|
│ + staged manifest,动态预览 GLB 写入 _preview/
|
||||||
│ → _pipeline/stages/cesium.manifest.json
|
│ → _pipeline/stages/cesium.manifest.json
|
||||||
│
|
│
|
||||||
├─[preview]───────▶ 生成 <id>-cesium-preview.html
|
├─[compress]──────▶ 压缩 staging 内主 GLB 并更新 staged manifest
|
||||||
│ + 拷贝 lib/cesium-preview.{js,css}
|
│ → _pipeline/stages/compress.manifest.json
|
||||||
│ + 车辆巡航路线与模型
|
|
||||||
│ → _pipeline/stages/preview.manifest.json
|
|
||||||
│
|
│
|
||||||
└─[compress]──────▶ 生成并列压缩 GLB / metadata / preview
|
├─[package]───────▶ 校验 manifest 与全部静态模型,原子发布 package/
|
||||||
→ _pipeline/stages/compress.manifest.json
|
│ → package/manifest.json + package/models/*.glb
|
||||||
|
│ → _pipeline/stages/package.manifest.json
|
||||||
|
│
|
||||||
|
└─[preview]───────▶ 生成 <id>-cesium-preview.html
|
||||||
|
│ + 拷贝 lib/cesium-preview.{js,css}
|
||||||
|
+ _preview/ 车辆巡航路线、模型、动态信号
|
||||||
|
│ → _pipeline/stages/preview.manifest.json
|
||||||
```
|
```
|
||||||
|
|
||||||
**阶段之间只通过磁盘产物耦合**,不传内存状态。这是单跑任意阶段能work 的前提。
|
**阶段之间只通过磁盘产物耦合**,不传内存状态。这是单跑任意阶段能work 的前提。
|
||||||
@@ -87,7 +91,7 @@ config/areas/<id>.json
|
|||||||
|
|
||||||
| 文件 | 行数 | 职责 |
|
| 文件 | 行数 | 职责 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `build-area.js` | 约 530 | 主入口:区域配置读取、阶段调度、preview 文件写入和 stage manifest ownership |
|
| `build-area.js` | 主入口:区域配置读取、阶段调度、package 发布、preview 文件写入和 stage manifest ownership |
|
||||||
| `diagnose-area.js` | 36 | 快速诊断入口:调用共享 area diagnostics 并打印完整报告 |
|
| `diagnose-area.js` | 36 | 快速诊断入口:调用共享 area diagnostics 并打印完整报告 |
|
||||||
| `check-area.js` | 74 | 区域质量门入口:调用共享 area diagnostics,输出 PASS/FAIL 并设置退出码 |
|
| `check-area.js` | 74 | 区域质量门入口:调用共享 area diagnostics,输出 PASS/FAIL 并设置退出码 |
|
||||||
| `lib/area-diagnostics.js` | 776 | 共享区域诊断事实源:OSM、产物、metadata、stage manifest、GLB digest 和质量门分类 |
|
| `lib/area-diagnostics.js` | 776 | 共享区域诊断事实源:OSM、产物、metadata、stage manifest、GLB digest 和质量门分类 |
|
||||||
@@ -99,6 +103,7 @@ config/areas/<id>.json
|
|||||||
| `lib/vehicle-route.js` | 约 180 | 从 OSM 提取确定性预览巡航路线 |
|
| `lib/vehicle-route.js` | 约 180 | 从 OSM 提取确定性预览巡航路线 |
|
||||||
| `lib/vehicle-model.js` | 约 150 | 生成内嵌 buffer 的预览车辆 glTF |
|
| `lib/vehicle-model.js` | 约 150 | 生成内嵌 buffer 的预览车辆 glTF |
|
||||||
| `lib/area-preview.js` | 约 110 | 复制 preview runtime、生成 HTML 与转义配置注入 |
|
| `lib/area-preview.js` | 约 110 | 复制 preview runtime、生成 HTML 与转义配置注入 |
|
||||||
|
| `lib/package-contract.js` | package manifest 校验、相对 URI 与 SHA-256 完整性记录 |
|
||||||
| `lib/cesium-preview.js` / `.css` | 672 / 230 | 预览页运行时,见 [../preview/](../preview/index.md) |
|
| `lib/cesium-preview.js` / `.css` | 672 / 230 | 预览页运行时,见 [../preview/](../preview/index.md) |
|
||||||
| `normalize-lane-arrows.py` | 182 | 合并 osm2streets 的三角网箭头(跑在 QGIS Python 里) |
|
| `normalize-lane-arrows.py` | 182 | 合并 osm2streets 的三角网箭头(跑在 QGIS Python 里) |
|
||||||
| `parity.js` | 270 | 产物一致性校验驱动 |
|
| `parity.js` | 270 | 产物一致性校验驱动 |
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
## 定位
|
## 定位
|
||||||
|
|
||||||
预览层是**验证性的,不是产物本身**。它加载 `cesium` 阶段导出的 `.glb` + `.json`,
|
预览层是**验证性的,不是产物本身**。它加载 `package/manifest.json`,用来确认已发布资产
|
||||||
用来确认资产在真实 Cesium 里的样子。改这一层**不会**改变 Blender/GLB 主资产。
|
在真实 Cesium 里的样子。改这一层**不会**改变 package 内的 Blender/GLB 静态资产。
|
||||||
|
|
||||||
车辆巡航同理——README 里写明它是"用于验证高精度巡航可用性的预览层功能"。
|
车辆巡航同理——README 里写明它是"用于验证高精度巡航可用性的预览层功能"。
|
||||||
|
|
||||||
@@ -53,9 +53,14 @@ const config = window.OSM_ASSET_PREVIEW_CONFIG || {}; // :4
|
|||||||
**加一个新的可配置项**:`cesiumPreviewHtml()` 里加进注入的 JSON,JS 侧从 `config` 读,
|
**加一个新的可配置项**:`cesiumPreviewHtml()` 里加进注入的 JSON,JS 侧从 `config` 读,
|
||||||
两边都要动。
|
两边都要动。
|
||||||
|
|
||||||
`build-area.js` 只保留 GLB / metadata 依赖检查、写入顺序和 preview manifest ownership;
|
`glbName` 与 `metadataName` 都是 `package/manifest.json`。浏览器读取 package manifest 后,
|
||||||
|
每个 `assets[*].uri` 必须相对**manifest 文件**解析,绝不能相对 preview HTML 解析;否则将
|
||||||
|
错误请求 `outputs/<area>/models/...` 而不是 `outputs/<area>/package/models/...`。
|
||||||
|
|
||||||
|
`build-area.js` 只保留已发布 package / 动态输入的依赖检查、写入顺序和 preview manifest ownership;
|
||||||
不要把 HTML 模板、runtime copy 或转义实现移回阶段调度器。路线 JSON 与车辆 glTF 分别由
|
不要把 HTML 模板、runtime copy 或转义实现移回阶段调度器。路线 JSON 与车辆 glTF 分别由
|
||||||
`vehicle-route.js` 和 `vehicle-model.js` 生成,二者都是不启动外部工具的 Node 模块。
|
`vehicle-route.js` 和 `vehicle-model.js` 生成,二者都是不启动外部工具的 Node 模块。
|
||||||
|
交通信号灯 runtime 则从 package manifest 的 `runtime` 读取;预览只负责驱动其状态,不拥有这些文件。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -185,6 +190,21 @@ let baseStatus = "";
|
|||||||
这会让用户误判材质和模型质量。若确实需要性能模式,应做成显式开关,而不是默认牺牲
|
这会让用户误判材质和模型质量。若确实需要性能模式,应做成显式开关,而不是默认牺牲
|
||||||
预览清晰度。
|
预览清晰度。
|
||||||
|
|
||||||
|
### 车辆事件仅属于预览会话
|
||||||
|
|
||||||
|
点击车辆的信息卡可在 `normal`、`breakdown`、`accident` 三态间切换。这是验证交互,
|
||||||
|
不得写入 `package/`、路线 JSON 或 OSM。状态必须附着在 `addCruiseVehicle()` 返回的记录上;
|
||||||
|
`createTrafficAwarePositions()` 只在状态为 `normal` 时推进已有的 route distance,恢复正常从
|
||||||
|
当前停点继续。
|
||||||
|
|
||||||
|
- `breakdown`:黄色扳手 label,路线保留原色。
|
||||||
|
- `accident`:红色警示 label,路线设为红色。
|
||||||
|
- `normal`:隐藏 label,恢复原路线颜色。
|
||||||
|
|
||||||
|
车辆实体以 `properties.vehicleId` 标识;点击拾取必须只处理此属性,不能把静态模型、路线或
|
||||||
|
信号灯当作车辆。Cesium InfoBox 在本预览中关闭,信息卡必须使用 HTML/CSS,并把新增 DOM 句柄
|
||||||
|
集中在 `cesium-preview.js` 顶部。
|
||||||
|
|
||||||
### 单资产 vs 多资产的开关
|
### 单资产 vs 多资产的开关
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/cli-and-stages.md","reason":"Verify package stage ordering, manifest freshness, and external-tool boundaries."}
|
||||||
|
{"file":".trellis/spec/config/index.md","reason":"Verify all new output paths remain centralized in area-config."}
|
||||||
|
{"file":".trellis/spec/preview/index.md","reason":"Verify preview remains a consumer of package assets, not part of the published package."}
|
||||||
|
{"file":".trellis/spec/guides/artifact-parity-guide.md","reason":"Assess intentional output-contract changes and asset verification scope."}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# Asset Package Contract Design
|
||||||
|
|
||||||
|
## Product Boundary
|
||||||
|
|
||||||
|
`outputs/<area-id>/` remains the build workspace. Its `package/` child is the only
|
||||||
|
publishable subtree and may be copied unchanged to another project. The package has
|
||||||
|
no dependency on the parent directory, repository checkout, absolute local paths,
|
||||||
|
QGIS, Blender, or the Cesium preview.
|
||||||
|
|
||||||
|
```
|
||||||
|
outputs/<area-id>/
|
||||||
|
package/ # publishable boundary
|
||||||
|
manifest.json # asset-package/v1
|
||||||
|
models/
|
||||||
|
<area-id>.glb # compressed complete static scene
|
||||||
|
roads.glb
|
||||||
|
buildings.glb
|
||||||
|
vegetation.glb
|
||||||
|
water.glb
|
||||||
|
<area-id>-cesium-preview.html # local verification only
|
||||||
|
_preview/ # vehicles, routes, dynamic signal runtime
|
||||||
|
_pipeline/ # staging, manifests and build diagnostics
|
||||||
|
osm2streets_web_out/, *.gpkg, *.qgz, *.blend, *.png
|
||||||
|
```
|
||||||
|
|
||||||
|
The package does not duplicate the GLBs: Cesium export and compression target the
|
||||||
|
package model paths. Build staging lives under `_pipeline/` and is removed before a
|
||||||
|
successful package is published.
|
||||||
|
|
||||||
|
## Manifest v1
|
||||||
|
|
||||||
|
The JSON root uses `schema: "osm-asset-package/v1"`. Required top-level fields are:
|
||||||
|
|
||||||
|
| Field | Contract |
|
||||||
|
|---|---|
|
||||||
|
| `schema`, `packageVersion`, `areaId` | Stable identity and schema evolution point |
|
||||||
|
| `coordinateSystem` | Literal local ENU contract: X east, Y north, Z up, meters |
|
||||||
|
| `placement` | WGS84 anchor longitude/latitude/height plus heading correction degrees |
|
||||||
|
| `bounds` | WGS84 `minLon`, `minLat`, `maxLon`, `maxLat` |
|
||||||
|
| `assets` | Deterministic list of declared publishable assets |
|
||||||
|
| `sceneStats` | Optional descriptive OSM-derived counts, not loading-critical |
|
||||||
|
|
||||||
|
Each asset has `id`, `role`, `category`, `uri`, and `defaultLoad`. `uri` is a
|
||||||
|
forward-slash relative path inside `package/`; it must not be absolute, start with
|
||||||
|
`/`, contain `..`, or resolve outside the package. Roles are `scene` for the complete
|
||||||
|
static scene and `layer` for separately loadable semantic subsets. Categories are
|
||||||
|
fixed in v1: `scene`, `roads`, `buildings`, `vegetation`, `water`.
|
||||||
|
|
||||||
|
`models/<area-id>.glb` is the only `scene` entry and defaults to load. Layer GLBs are
|
||||||
|
optional alternatives for selective loading and default off; consumers must not load
|
||||||
|
both the complete scene and overlapping layers unless intentionally composing them.
|
||||||
|
|
||||||
|
The manifest deliberately excludes `source_osm`, `source_geojson`, arbitrary Cesium
|
||||||
|
JavaScript, vehicle routes, vehicle models, dynamic signal states, countdown models,
|
||||||
|
preview runtime paths, build timestamps and desktop paths. File digests and sizes may
|
||||||
|
be added under an optional `integrity` object only after they are computed from final
|
||||||
|
compressed files.
|
||||||
|
|
||||||
|
## Pipeline Design
|
||||||
|
|
||||||
|
### 1. Static export seed
|
||||||
|
|
||||||
|
`blender/export_cesium.py` continues to own static GLB generation, WGS84 bounds,
|
||||||
|
anchor and semantic collection selection. It must emit data suitable for a manifest
|
||||||
|
seed, not a preview metadata document. Static traffic-signal geometry already in the
|
||||||
|
main scene remains part of the static scene; animated traffic signal and countdown
|
||||||
|
collections are not package assets.
|
||||||
|
|
||||||
|
### 2. Package staging and compression
|
||||||
|
|
||||||
|
The build orchestrator owns output paths through `normalizeAreaConfig()`. It adds
|
||||||
|
explicit package paths and exports static GLBs to a package staging directory beneath
|
||||||
|
`_pipeline/`. Compression works only on staged package files and rewrites the staged
|
||||||
|
manifest's main GLB URI after successful compression. It never needs to copy or alter
|
||||||
|
preview HTML.
|
||||||
|
|
||||||
|
After path validation, file existence checks, and manifest validation, the package
|
||||||
|
stage promotes the whole staging directory to `outputs/<area-id>/package/`. Promotion
|
||||||
|
is directory-level and replaces a previous package only after the new one is valid.
|
||||||
|
On failure, the previous published package remains usable and staging is retained or
|
||||||
|
reported for diagnosis according to existing pipeline failure conventions.
|
||||||
|
|
||||||
|
### 3. Preview adapter
|
||||||
|
|
||||||
|
The existing Cesium preview remains a verification tool outside the package. It reads
|
||||||
|
the package manifest via its relative path, then loads preview-only route, vehicle and
|
||||||
|
dynamic-signal descriptors from `_preview/`. Dynamic traffic assets are declared in a
|
||||||
|
preview-specific descriptor, never appended to package `assets`. This preserves
|
||||||
|
existing high-precision cruise validation without making it a downstream requirement.
|
||||||
|
|
||||||
|
### 4. Stage and compatibility behavior
|
||||||
|
|
||||||
|
Canonical order becomes `intermediates/reimport -> blender -> cesium -> compress ->
|
||||||
|
package -> preview`. `package` is included in the full default build and is callable
|
||||||
|
explicitly to validate/publish existing staged static exports. `preview` stays an
|
||||||
|
optional/verification stage, not a package dependency.
|
||||||
|
|
||||||
|
Existing `npm run build:area -- --config ... --stages ...` remains supported. Root
|
||||||
|
level legacy GLB/JSON/HTML files are not deleted by the migration; they are not read
|
||||||
|
as a fallback by the new package contract. A clean full build produces the package as
|
||||||
|
the canonical downstream asset source.
|
||||||
|
|
||||||
|
## Consumer Examples
|
||||||
|
|
||||||
|
Examples live in repository source, outside individual packages:
|
||||||
|
|
||||||
|
- Cesium: fetch `manifest.json`, derive the ENU frame from `placement`, apply heading
|
||||||
|
correction, then load `assets` by `uri`.
|
||||||
|
- Three.js: load the selected model URL relative to the manifest URL; expose the same
|
||||||
|
ENU placement object to the host application's georeferencing adapter. It must not
|
||||||
|
imply that Three.js alone converts ENU to WGS84.
|
||||||
|
|
||||||
|
Both examples load the complete scene and demonstrate selecting a single `layer`.
|
||||||
|
They validate that URLs are resolved relative to the manifest rather than the current
|
||||||
|
page or repository root.
|
||||||
|
|
||||||
|
## Validation and Rollback
|
||||||
|
|
||||||
|
Unit tests validate schema fields, category/role legality, package-relative URI rules,
|
||||||
|
and rejection of omitted/extra files. An integration fixture constructs a minimal
|
||||||
|
package and verifies that Cesium and Three.js example resolvers choose identical
|
||||||
|
relative URLs and placement values. A target-area package test checks final compressed
|
||||||
|
GLB parsing and manifest references.
|
||||||
|
|
||||||
|
The package stage writes a stage manifest containing only final published records and
|
||||||
|
their integrity. Diagnostic checks distinguish missing package, invalid package, and
|
||||||
|
stale package. Rollback is to the prior `package/` directory; legacy preview outputs
|
||||||
|
remain untouched throughout rollout.
|
||||||
|
|
||||||
|
## Deferred Decisions
|
||||||
|
|
||||||
|
- Rich per-feature semantics, routing graph delivery and simulation inputs are not in
|
||||||
|
v1; they should be introduced through a later schema version only when a downstream
|
||||||
|
consumer requires them.
|
||||||
|
- Asset coverage improvements are downstream of this contract work.
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{"file":".trellis/spec/pipeline/cli-and-stages.md","reason":"Stage ordering, manifests, external-command boundary, and compression contracts."}
|
||||||
|
{"file":".trellis/spec/config/index.md","reason":"Area output-path normalization and configuration contract."}
|
||||||
|
{"file":".trellis/spec/preview/index.md","reason":"Preview config injection and browser runtime compatibility."}
|
||||||
|
{"file":".trellis/spec/guides/cross-layer-thinking-guide.md","reason":"Blender-to-Node-to-browser coordinate and artifact contract risks."}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
# Asset Package Contract Implementation Plan
|
||||||
|
|
||||||
|
## Phase 0: Contract Lock-In
|
||||||
|
|
||||||
|
- [ ] Add a package-contract module that owns v1 schema constants, allowed roles and
|
||||||
|
categories, URI containment validation, manifest construction and validation.
|
||||||
|
- [ ] Add focused unit fixtures for valid manifests and each invalid condition:
|
||||||
|
missing schema/placement/bounds, malformed coordinates, invalid role/category,
|
||||||
|
absolute or traversing URI, duplicate asset ID, missing primary scene, and referenced
|
||||||
|
file outside the package.
|
||||||
|
- [ ] Document `package/` as the sole downstream boundary in README and pipeline/config
|
||||||
|
specs; retain a clear distinction between release assets and preview artifacts.
|
||||||
|
|
||||||
|
Gate: manifest v1 can be created and structurally validated without invoking Blender,
|
||||||
|
Cesium or QGIS.
|
||||||
|
|
||||||
|
## Phase 1: Package Paths and Static Export
|
||||||
|
|
||||||
|
- [ ] Extend `scripts/lib/area-config.js` with paths for `packageDir`, package manifest,
|
||||||
|
package model directory, primary GLB and semantic layer GLBs; keep all path derivation
|
||||||
|
in this module.
|
||||||
|
- [ ] Change `blender/export_cesium.py` metadata output to a static manifest seed:
|
||||||
|
bounds, ENU placement and static scene/layer declarations only. Remove local source
|
||||||
|
paths and inline Cesium source code from the published data.
|
||||||
|
- [ ] Direct static GLB output to package staging paths and retain dynamic signal/countdown
|
||||||
|
output as preview-only paths outside package staging.
|
||||||
|
- [ ] Update `build-area.js`, semantic asset checks, stage manifests and diagnostics to
|
||||||
|
consume the new path contract rather than constructing paths locally.
|
||||||
|
|
||||||
|
Gate: a Cesium export produces a valid static manifest seed and every declared static
|
||||||
|
asset exists under package staging; no preview-only asset appears in it.
|
||||||
|
|
||||||
|
## Phase 2: Compression and Atomic Publication
|
||||||
|
|
||||||
|
- [ ] Refactor the default compression stage to operate on staged package files,
|
||||||
|
preserving the final manifest shape while replacing only the primary GLB bytes and
|
||||||
|
integrity data.
|
||||||
|
- [ ] Add a `package` stage after `compress`; validate every asset and atomically promote
|
||||||
|
staging to `outputs/<area-id>/package/`.
|
||||||
|
- [ ] Update canonical stage ordering, `all`, interactive CLI labels and defaults.
|
||||||
|
- [ ] Ensure a failed compression/package validation never replaces an existing published
|
||||||
|
package; record diagnostics sufficient to identify the failed source/staging path.
|
||||||
|
|
||||||
|
Gate: a full build creates one publishable package with compressed primary GLB and no
|
||||||
|
duplicate static GLBs at the area root.
|
||||||
|
|
||||||
|
## Phase 3: Preview Adapter and Compatibility
|
||||||
|
|
||||||
|
- [ ] Change preview HTML generation to reference `package/manifest.json` relative to
|
||||||
|
the area output root.
|
||||||
|
- [ ] Move route/vehicle/dynamic-signal discovery into a preview-only descriptor beneath
|
||||||
|
`_preview/`, and make `cesium-preview.js` merge it after loading the package manifest.
|
||||||
|
- [ ] Preserve existing preview controls and graceful behavior when preview-only data is
|
||||||
|
absent; preview must still render the package static scene.
|
||||||
|
- [ ] Update `diagnose:area`, `check:area` and stage manifest freshness to distinguish
|
||||||
|
package artifacts from preview-only files.
|
||||||
|
|
||||||
|
Gate: the local Cesium preview loads the published package and continues to show
|
||||||
|
optional cruise/dynamic preview content without adding either to package manifest.
|
||||||
|
|
||||||
|
## Phase 4: Downstream Consumption Proof
|
||||||
|
|
||||||
|
- [ ] Add Cesium example code that resolves the manifest URL, validates placement and
|
||||||
|
loads the full scene or selected layers.
|
||||||
|
- [ ] Add Three.js example code with a manifest-relative resolver and an explicit ENU
|
||||||
|
placement handoff to the host's georeferencing integration.
|
||||||
|
- [ ] Add automated resolver tests so neither example can regress to page-relative,
|
||||||
|
desktop-absolute or repository-relative URLs.
|
||||||
|
- [ ] Publish consumer documentation including overlap rules for complete scene vs layers.
|
||||||
|
|
||||||
|
Gate: examples run from a copied `package/` directory and require no files outside it.
|
||||||
|
|
||||||
|
## Phase 5: Full Verification and Migration
|
||||||
|
|
||||||
|
- [ ] Run focused Node tests for package schema, stage resolution, compression metadata,
|
||||||
|
preview behavior, diagnostics and asset budgets.
|
||||||
|
- [ ] Run the full default build for the primary area, then `check:area` and package
|
||||||
|
integrity validation.
|
||||||
|
- [ ] Inspect the packaged GLB structure and validate the Cesium example in browser;
|
||||||
|
verify Three.js resolver output with the same manifest.
|
||||||
|
- [ ] Capture expected intentional output-contract changes in docs/changelog and update
|
||||||
|
relevant Trellis pipeline/config/preview specs.
|
||||||
|
- [ ] Preserve legacy root-level artifacts during rollout; document that downstream
|
||||||
|
consumers must migrate to `package/manifest.json` rather than treating legacy files
|
||||||
|
as fallback.
|
||||||
|
|
||||||
|
## High-Risk Boundaries
|
||||||
|
|
||||||
|
- `blender/export_cesium.py` to Node: static metadata fields and semantic asset file
|
||||||
|
names are a cross-runtime contract.
|
||||||
|
- Node packaging to preview runtime: preview-only dynamic data must never silently enter
|
||||||
|
the package manifest.
|
||||||
|
- Compression to publication: paths must remain package-relative and a partial write must
|
||||||
|
not replace the last valid package.
|
||||||
|
- Consumers: ENU axes and heading correction are load-bearing; examples must not create
|
||||||
|
a second, incompatible georeferencing convention.
|
||||||
|
|
||||||
|
## Validation Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run test:build-stages
|
||||||
|
npm run test:compress-glb
|
||||||
|
npm run test:preview-assets
|
||||||
|
npm run test:budgets
|
||||||
|
npm run test:preflight
|
||||||
|
npm run check:area -- --config config/areas/nantaizi-lake-innovation-valley.json
|
||||||
|
node scripts/glb-digest.js outputs/nantaizi-lake-innovation-valley/package/models/nantaizi-lake-innovation-valley.glb
|
||||||
|
```
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# Reusable asset package contract
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
将当前面向 Cesium 预览的区域输出升级为可由多个下游项目稳定消费的静态资产包。资产包
|
||||||
|
必须有版本化 manifest、仅使用包内相对引用,并明确发布资产与本项目调试/预览产物的边界。
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- `blender/export_cesium.py` 已生成 `<area>.json`,包含主 GLB、roads/buildings/
|
||||||
|
vegetation/water 分层 GLB、WGS84 anchor、ENU 坐标约定、heading correction 和 OSM bounds。
|
||||||
|
- 该 JSON 同时包含桌面绝对 `source_osm` / `source_geojson` 路径、Cesium 代码片段,以及
|
||||||
|
动态信号灯和倒计时预览资产;因此不是可发布的下游契约。
|
||||||
|
- `outputs/<area>/` 还包含 QGIS、GeoJSON、Blender、Cesium HTML/runtime、车辆巡航和自检文件;
|
||||||
|
它是构建工作目录,不是干净的发布目录。
|
||||||
|
- 当前默认 Cesium GLB 已在构建末端压缩,且 metadata 中的资产 URL 使用同目录相对文件名。
|
||||||
|
- 项目目标是生成可复用资产;交通仿真、跟车和信号调度属于下游运行时能力,不属于资产包首版。
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1:定义一个版本化 `manifest.json` v1,描述区域 ID、WGS84 anchor、ENU 轴向与 heading
|
||||||
|
correction、WGS84 bounds、发布资产、语义类别和包内相对路径。
|
||||||
|
- R2:资产包只含可复用的静态交付资产;主场景和道路、建筑、植被、水体等分层模型必须有
|
||||||
|
明确的角色、加载语义和默认行为。
|
||||||
|
- R3:manifest 和包内文件不得包含桌面绝对路径、构建临时目录、Cesium HTML/runtime、
|
||||||
|
QGIS、GeoJSON、`.blend`、车辆巡航或动态交通信号调度依赖。
|
||||||
|
- R4:在不破坏现有区域预览、诊断和构建中间产物的前提下,增加明确的资产包发布阶段。
|
||||||
|
- R5:提供 Cesium 与 Three.js 的最小加载示例,均从 manifest 读取包内相对 URL,并按相同的
|
||||||
|
WGS84/ENU 契约放置主场景或分层资产。
|
||||||
|
- R6:定义发布资产、可选静态资产和本项目仅检查产物的分类规则,并由测试验证。
|
||||||
|
- R7:完整构建后的资产包应可独立复制到其他项目,而无需本仓库的 `outputs` 目录结构或本地路径。
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] 目标区域生成一个可独立分发的资产包目录,其中仅有 manifest 和 manifest 引用的发布资产。
|
||||||
|
- [ ] manifest 的 schema version、坐标契约、bounds、所有资产类别和 URL 可由程序校验。
|
||||||
|
- [ ] 所有 manifest URL 都是安全的包内相对路径;不得含绝对路径、`..` 或未声明文件。
|
||||||
|
- [ ] 主 GLB 与每个发布分层资产都能在 Cesium 和 Three.js 示例中按 manifest 正确放置与加载。
|
||||||
|
- [ ] 车辆、巡航路线、Cesium preview HTML/runtime、QGIS/GeoJSON/`.blend` 和动态信号调度资产
|
||||||
|
不会进入发布包。
|
||||||
|
- [ ] 既有 `outputs/<area>/` 预览工作流继续可用,现有非交互 build 命令保持兼容。
|
||||||
|
- [ ] 发布包缺文件、manifest 路径越界、坐标字段无效或资产类别不合法时,构建/校验非零退出。
|
||||||
|
|
||||||
|
## Proposed Delivery Phases
|
||||||
|
|
||||||
|
1. 契约与目录边界:冻结 manifest v1 schema、发布目录结构、资产角色和坐标定义。
|
||||||
|
2. 资产包发布阶段:从现有 Cesium 导出与压缩结果收集、校验并写入独立包目录。
|
||||||
|
3. 下游消费证明:Cesium / Three.js 示例仅依赖 manifest 与包内容,并覆盖主场景和按类别加载。
|
||||||
|
4. 质量门与迁移:增加结构、路径隔离、坐标和加载验证;保留旧预览输出并记录迁移规则。
|
||||||
|
|
||||||
|
## Key Decision
|
||||||
|
|
||||||
|
- 发布包根目录固定为 `outputs/<area-id>/package/`。该目录是可整体复制给下游项目的唯一
|
||||||
|
发布边界;GLB 和 manifest 直接生成或移动到这里,避免与工作目录再保留一套大模型副本。
|
||||||
|
本项目的预览页可通过包内相对路径读取发布资产,但 HTML/runtime 本身不属于发布包。
|
||||||
|
|
||||||
|
## Out Of Scope
|
||||||
|
|
||||||
|
- 交通流、车辆行为、信号相位控制、路口调度和其他运行时仿真。
|
||||||
|
- 在本任务中扩展 OSM 到建筑、路灯、标志、植被等资产覆盖率或生成质量。
|
||||||
|
- 删除既有 `outputs/<area>/` 中由用户保留的历史调试产物。
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "asset-package-contract",
|
||||||
|
"name": "asset-package-contract",
|
||||||
|
"title": "Reusable asset package contract",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-11",
|
||||||
|
"completedAt": "2026-08-12",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "main",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# Interactive Area Build CLI Design
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
Add a zero-dependency terminal interface for choosing an area configuration and one or more existing
|
||||||
|
pipeline stages. It delegates execution to the existing `build-area.js` entry point and does not change
|
||||||
|
the pipeline's stage implementations or generated artifacts.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```text
|
||||||
|
npm run build
|
||||||
|
-> scripts/interactive-build.js
|
||||||
|
-> terminal menus (TTY only)
|
||||||
|
-> node scripts/build-area.js --config <area> --stages <canonical-list>
|
||||||
|
-> existing build pipeline
|
||||||
|
```
|
||||||
|
|
||||||
|
Extract the stage metadata, aliases, canonical execution order, and mutual-exclusion validation from
|
||||||
|
`build-area.js` into a CommonJS module under `scripts/lib/`. Both the interactive script and
|
||||||
|
`build-area.js` consume this module, making the menu's options the same source of truth as execution.
|
||||||
|
|
||||||
|
## Interaction
|
||||||
|
|
||||||
|
1. Discover and sort `config/areas/*.json`; present a single-select area menu.
|
||||||
|
2. Present a multi-select stage menu with descriptions and selection markers.
|
||||||
|
3. Arrow keys move focus, space toggles, enter confirms, and Ctrl-C/Escape cancels.
|
||||||
|
4. The menu prevents or reports the `intermediates`/`reimport` conflict before spawning a build.
|
||||||
|
5. The selected stages are normalized to canonical pipeline order and passed to `build-area.js`.
|
||||||
|
|
||||||
|
The interactive entry requires both stdin and stdout to be TTYs. Otherwise it exits non-zero with an
|
||||||
|
instruction to use `npm run build:area -- --config ... --stages ...`; it never falls back to defaults.
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
- `build-area.js` remains the execution owner and keeps its CLI flags and defaults.
|
||||||
|
- `npm run build:area` continues to invoke it directly.
|
||||||
|
- `npm run build` changes only from the former default build alias to the interactive wrapper.
|
||||||
|
- A successful `cesium` selection continues to generate preview output through the existing behavior;
|
||||||
|
selecting `preview` explicitly remains valid for a standalone preview refresh.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
- Unit-test stage normalization, alias expansion, ordering, and mutual exclusion.
|
||||||
|
- Unit-test config discovery and non-TTY refusal without launching a build.
|
||||||
|
- Syntax-check both CLI entry scripts.
|
||||||
|
- Manually exercise the menu in a TTY: select an area, select unordered stages, confirm the canonical
|
||||||
|
command preview, and cancel before execution.
|
||||||
|
|
||||||
|
## Risks And Rollback
|
||||||
|
|
||||||
|
Raw terminal input must always restore raw mode and cursor state on confirmation, cancellation, and
|
||||||
|
errors. The wrapper only spawns the unchanged existing build script, so rollback is deleting the new
|
||||||
|
interactive entry and restoring the `build` package script.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Interactive Area Build CLI Implementation Plan
|
||||||
|
|
||||||
|
1. Extract stage definitions, aliases, canonical ordering, and conflict validation from
|
||||||
|
`scripts/build-area.js` into a shared CommonJS module.
|
||||||
|
2. Update `build-area.js` to consume the shared resolver without changing non-interactive semantics.
|
||||||
|
3. Add `scripts/interactive-build.js` with TTY detection, area discovery, raw-mode selection menus,
|
||||||
|
cancellation handling, and child-process delegation to `build-area.js`.
|
||||||
|
4. Change `package.json` so `npm run build` calls the new interactive script while `build:area` remains
|
||||||
|
unchanged.
|
||||||
|
5. Add focused Node tests for stage planning and non-TTY behavior; do not invoke Blender, QGIS, or a
|
||||||
|
real area build in tests.
|
||||||
|
6. Run syntax checks, the focused tests, existing preflight/preview tests, and manually exercise the
|
||||||
|
interactive flow in a TTY.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# Interactive area build CLI
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
提供一个交互式区域构建入口,减少手写 `npm run build:area -- --config ... --stages ...`
|
||||||
|
的频率;用户可选择区域和一个或多个构建阶段,CLI 按既有阶段约束执行。
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- 当前 `scripts/build-area.js` 支持 `intermediates`、`reimport`、`blender`、`cesium`、
|
||||||
|
`preview` 与 `compress` 六个阶段,并接受逗号分隔的 `--stages`。
|
||||||
|
- `intermediates` 与 `reimport` 互斥:前者会从 OSM 重建 GeoPackage,后者回导 QGIS 编辑。
|
||||||
|
- 执行顺序固定为 `intermediates/reimport -> blender -> cesium -> preview -> compress`;
|
||||||
|
`cesium` 当前会自动写入 preview 产物。
|
||||||
|
- 项目没有终端交互依赖;现有命令行调用必须继续可用于脚本和自动化。
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- R1:提供交互式入口,列出可用区域配置并允许用户选择目标区域。
|
||||||
|
- R2:交互式入口允许一次选择多个阶段,并清晰展示阶段名称与用途。
|
||||||
|
- R3:选择互斥阶段时必须阻止执行并解释原因;不得静默选择其中之一。
|
||||||
|
- R4:执行多个阶段时必须使用既有依赖顺序,而非用户勾选顺序。
|
||||||
|
- R5:保留 `npm run build:area -- --config ... --stages ...` 的现有非交互行为与语义。
|
||||||
|
- R6:无 TTY、取消输入或无效输入时必须安全退出,不启动任何构建。
|
||||||
|
- R7:TTY 交互使用方向键移动、空格多选、回车确认;菜单应显示当前选择状态。
|
||||||
|
- R8:`npm run build` 启动交互式入口;`npm run build:area` 继续保留为非交互入口。
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] 用户可从终端选择区域和多项阶段,无需手写配置路径或逗号分隔阶段名。
|
||||||
|
- [ ] 选择 `intermediates` 与 `reimport` 时,CLI 明确报互斥错误且不运行构建。
|
||||||
|
- [ ] 选择乱序的多个阶段时,实际执行顺序仍遵循既有管线顺序。
|
||||||
|
- [ ] 既有非交互 `build:area` 调用保持兼容。
|
||||||
|
- [ ] 取消或在非交互环境调用不会触发构建。
|
||||||
|
- [ ] 用户可用方向键、空格和回车完成区域及阶段选择。
|
||||||
|
- [ ] `npm run build` 启动交互菜单,`npm run build:area` 的现有调用保持不变。
|
||||||
|
|
||||||
|
## Key Decisions
|
||||||
|
|
||||||
|
- 采用终端原生多选菜单,而非输入逗号分隔编号;避免引入运行时依赖。
|
||||||
|
- `npm run build` 作为日常交互入口;`npm run build:area` 继续服务自动化和精确调用。
|
||||||
|
|
||||||
|
## Out Of Scope
|
||||||
|
|
||||||
|
- 修改各 stage 的构建业务逻辑、依赖关系或产物格式。
|
||||||
|
- 将巡航路线、QGIS 图层编辑或区域配置编辑纳入本次交互流程。
|
||||||
|
- GUI 或浏览器界面的构建控制台。
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Keep `prd.md` focused on requirements, constraints, and acceptance criteria.
|
||||||
|
- Lightweight tasks can remain PRD-only.
|
||||||
|
- For complex tasks, add `design.md` for technical design and `implement.md` for execution planning before `task.py start`.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "interactive-area-cli",
|
||||||
|
"name": "interactive-area-cli",
|
||||||
|
"title": "Interactive area build CLI",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-11",
|
||||||
|
"completedAt": "2026-08-11",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "main",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# Design: Vehicle Incident And Information Preview
|
||||||
|
|
||||||
|
## Boundary
|
||||||
|
|
||||||
|
This is browser-only Cesium preview state. It changes neither generated OSM data nor `package/` assets.
|
||||||
|
Vehicle routes and models remain `_preview/` resources; refresh resets all vehicle event state.
|
||||||
|
|
||||||
|
## Data Model
|
||||||
|
|
||||||
|
Each object returned by `addCruiseVehicle()` gains:
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
id: "vehicle-1",
|
||||||
|
modelName: "car_a01_002",
|
||||||
|
status: "normal" | "breakdown" | "accident",
|
||||||
|
incidentNote: "",
|
||||||
|
motion: { state },
|
||||||
|
markerEntity
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The current route distance remains the single motion source. The clock tick leaves it unchanged while
|
||||||
|
status is not `normal`; returning to normal resumes from that position.
|
||||||
|
|
||||||
|
## Interaction Flow
|
||||||
|
|
||||||
|
1. Vehicle Cesium Entities carry a `vehicleId` property.
|
||||||
|
2. A `ScreenSpaceEventHandler` picks a clicked entity, resolves its vehicle, synchronizes the existing
|
||||||
|
vehicle selector, and opens a positioned information card.
|
||||||
|
3. The card displays vehicle number, model family, route label/length, configured speed, state, and note.
|
||||||
|
4. Card controls set normal/breakdown/accident and persist only in the in-memory vehicle object.
|
||||||
|
5. State changes update marker visibility, the route material, card content, and Cesium render request.
|
||||||
|
|
||||||
|
## Visual Contract
|
||||||
|
|
||||||
|
- Normal: no marker; original route color; motion active.
|
||||||
|
- Breakdown: yellow wrench label above the vehicle; route retains its original color; motion frozen.
|
||||||
|
- Accident: red warning-triangle label above the vehicle; route material becomes red; motion frozen.
|
||||||
|
- Marker positions use the same vehicle `CallbackProperty`, so they move with the vehicle before an event
|
||||||
|
and remain at the incident location while stopped.
|
||||||
|
|
||||||
|
## Compatibility And Risks
|
||||||
|
|
||||||
|
- Picking must ignore routes, static models, and signal entities.
|
||||||
|
- No route must retain the existing disabled cruise controls and never show a card.
|
||||||
|
- The card must be HTML/CSS UI, not Cesium InfoBox, because the viewer deliberately disables InfoBox.
|
||||||
|
- The feature must not alter signal runtime behavior or vehicle asset URLs.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"_example": "Fill with {\"file\": \"<path>\", \"reason\": \"<why>\"}. Put spec/research files only — no code paths. Run `python3 .trellis/scripts/get_context.py --mode packages` to list available specs. Delete this line once real entries are added."}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
1. Add an initially hidden vehicle information card to `area-preview.js` and responsive card styles to
|
||||||
|
`cesium-preview.css`.
|
||||||
|
2. Extend the browser runtime vehicle records with stable identity, parsed model metadata, incident status,
|
||||||
|
note, and a marker entity.
|
||||||
|
3. Gate route-distance advancement on normal state; add status transition helper for marker, route material,
|
||||||
|
and card refresh.
|
||||||
|
4. Add Cesium click picking and card controls. Keep the existing selector synchronized for follow/route use.
|
||||||
|
5. Add focused assertions to `test-preview-assets.js` for card wiring, status behavior, and marker/route
|
||||||
|
contracts.
|
||||||
|
6. Run syntax checks, preview test, stage test, target-area preview regeneration, and `check:area`.
|
||||||
|
|
||||||
|
## Rollback
|
||||||
|
|
||||||
|
Revert only the preview HTML/CSS/runtime/test files. No package, Blender, route, or OSM product files should
|
||||||
|
need rollback.
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Vehicle incident and information preview
|
||||||
|
|
||||||
|
## Goal
|
||||||
|
|
||||||
|
在 Cesium 验证预览中,让使用者能够查看每辆巡航车辆的基础信息,并人为标记车辆事故/故障状态,直观看到该状态对车辆和路线展示的影响。
|
||||||
|
|
||||||
|
## Confirmed Facts
|
||||||
|
|
||||||
|
- 车辆是 `scripts/lib/cesium-preview.js` 创建的 Cesium Entity;当前已有车型、路线、巡航速度、
|
||||||
|
跟随、显隐与路线选择。
|
||||||
|
- 车辆模型和路线都属于 `_preview/` 验证资源,不是 area package 的下游资产契约。
|
||||||
|
- 当前不存在车辆业务资料、事故状态、碰撞检测或自动事件推演。
|
||||||
|
- 项目定位是资产生成与验证,不能将交通流/事故仿真作为本任务的范围。
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- 每辆预览车辆必须有稳定的显示编号、车型、当前路线、设定速度和行驶状态。
|
||||||
|
- 点击场景中的车辆后,必须弹出该车辆的信息卡,展示基础信息与当前事件状态;信息卡内完成状态与说明编辑。
|
||||||
|
- 使用者必须能将选中车辆在正常、故障和事故状态之间切换,并能提供简短事件说明。
|
||||||
|
- 故障和事故是不同状态:二者均停止巡航;故障使用黄色标记,事故使用红色标记并提示路线中断。
|
||||||
|
- 故障使用车辆顶部黄色扳手标记;事故使用红色警示三角标记,并将该车辆当前路线改为红色。
|
||||||
|
- 非正常车辆必须有可见的场景标记;恢复正常后继续按既有路线巡航。
|
||||||
|
- 事故/故障仅在当前浏览器预览会话中存在;刷新或重建预览后不保留。
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
- 自动碰撞检测、车辆间物理碰撞、自动事故生成。
|
||||||
|
- 信号配时、交通流、调度策略或持久化事件记录。
|
||||||
|
- 向 `package/` 加入车辆、路线或事故数据。
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
|
||||||
|
- [ ] 用户可点击任一可见车辆,弹出其基础信息、状态和事件说明;现有车辆选择控件仍可用于路线和跟随。
|
||||||
|
- [ ] 用户可标记故障或事故,并看到车辆停止、状态文本和明显的场景标记。
|
||||||
|
- [ ] 故障显示黄色扳手;事故显示红色警示三角且当前路线变红。
|
||||||
|
- [ ] 用户可恢复正常,车辆继续其现有路线;其他车辆不受影响。
|
||||||
|
- [ ] 无可用路线时,车辆信息和事故控件按既有禁用语义处理。
|
||||||
|
- [ ] 预览资产、路线与现有信号灯 runtime 继续可加载;不新增下游 package 内容。
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"id": "vehicle-incident-info",
|
||||||
|
"name": "vehicle-incident-info",
|
||||||
|
"title": "Vehicle incident and information preview",
|
||||||
|
"description": "",
|
||||||
|
"status": "completed",
|
||||||
|
"dev_type": null,
|
||||||
|
"scope": null,
|
||||||
|
"package": null,
|
||||||
|
"priority": "P2",
|
||||||
|
"creator": "dingkang",
|
||||||
|
"assignee": "dingkang",
|
||||||
|
"createdAt": "2026-08-12",
|
||||||
|
"completedAt": "2026-08-12",
|
||||||
|
"branch": null,
|
||||||
|
"base_branch": "main",
|
||||||
|
"worktree_path": null,
|
||||||
|
"commit": null,
|
||||||
|
"pr_url": null,
|
||||||
|
"subtasks": [],
|
||||||
|
"children": [],
|
||||||
|
"parent": null,
|
||||||
|
"relatedFiles": [],
|
||||||
|
"notes": "",
|
||||||
|
"meta": {}
|
||||||
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
<!-- @@@auto:current-status -->
|
<!-- @@@auto:current-status -->
|
||||||
- **Active File**: `journal-1.md`
|
- **Active File**: `journal-1.md`
|
||||||
- **Total Sessions**: 27
|
- **Total Sessions**: 30
|
||||||
- **Last Active**: 2026-08-07
|
- **Last Active**: 2026-08-12
|
||||||
<!-- @@@/auto:current-status -->
|
<!-- @@@/auto:current-status -->
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<!-- @@@auto:active-documents -->
|
<!-- @@@auto:active-documents -->
|
||||||
| File | Lines | Status |
|
| File | Lines | Status |
|
||||||
|------|-------|--------|
|
|------|-------|--------|
|
||||||
| `journal-1.md` | ~575 | Active |
|
| `journal-1.md` | ~642 | Active |
|
||||||
<!-- @@@/auto:active-documents -->
|
<!-- @@@/auto:active-documents -->
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -29,6 +29,9 @@
|
|||||||
<!-- @@@auto:session-history -->
|
<!-- @@@auto:session-history -->
|
||||||
| # | Date | Title | Commits | Branch |
|
| # | Date | Title | Commits | Branch |
|
||||||
|---|------|-------|---------|--------|
|
|---|------|-------|---------|--------|
|
||||||
|
| 30 | 2026-08-12 | Add vehicle incident preview cards | `761a526` | `main` |
|
||||||
|
| 29 | 2026-08-12 | Publish reusable area asset packages | `f385009`, `c925890`, `db0fba5`, `f2b8d79`, `0102ffb` | `main` |
|
||||||
|
| 28 | 2026-08-11 | 默认压缩交付 | `0790cbd` | `main` |
|
||||||
| 27 | 2026-08-07 | QGIS traffic signal editing and countdown stability | `e153a1c` | `main` |
|
| 27 | 2026-08-07 | QGIS traffic signal editing and countdown stability | `e153a1c` | `main` |
|
||||||
| 26 | 2026-08-07 | 交通信号拓扑与部分构建同步修复 | `1c077a3` | `main` |
|
| 26 | 2026-08-07 | 交通信号拓扑与部分构建同步修复 | `1c077a3` | `main` |
|
||||||
| 25 | 2026-08-06 | Cesium traffic signal countdowns | `0e1574f` | `main` |
|
| 25 | 2026-08-06 | Cesium traffic signal countdowns | `0e1574f` | `main` |
|
||||||
|
|||||||
@@ -573,3 +573,70 @@ Implemented editable traffic signal assemblies in QGIS with stable IDs, position
|
|||||||
### Status
|
### Status
|
||||||
|
|
||||||
[OK] **Completed**
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 28: 默认压缩交付
|
||||||
|
|
||||||
|
**Date**: 2026-08-11
|
||||||
|
**Task**: 默认压缩交付
|
||||||
|
**Branch**: `main`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
将 GLB 压缩纳入默认构建并使用标准产物路径交付,移除并列压缩输出契约;同步诊断、测试与文档。
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `0790cbd` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 29: Publish reusable area asset packages
|
||||||
|
|
||||||
|
**Date**: 2026-08-12
|
||||||
|
**Task**: Publish reusable area asset packages
|
||||||
|
**Branch**: `main`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Published the reusable osm-asset-package/v1 contract, moved static models under package/, kept dynamic cruise and signal assets in _preview/, fixed preview manifest-relative loading, and verified the target area quality gate.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `f385009` | (see git log) |
|
||||||
|
| `c925890` | (see git log) |
|
||||||
|
| `db0fba5` | (see git log) |
|
||||||
|
| `f2b8d79` | (see git log) |
|
||||||
|
| `0102ffb` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
|
|
||||||
|
|
||||||
|
## Session 30: Add vehicle incident preview cards
|
||||||
|
|
||||||
|
**Date**: 2026-08-12
|
||||||
|
**Task**: Add vehicle incident preview cards
|
||||||
|
**Branch**: `main`
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Added click-to-open vehicle information cards with normal, breakdown, and accident preview-only states, floating vehicle-anchored cards, route and motion changes, plus bundled repair and warning icons.
|
||||||
|
|
||||||
|
### Git Commits
|
||||||
|
|
||||||
|
| Hash | Message |
|
||||||
|
|------|---------|
|
||||||
|
| `761a526` | (see git log) |
|
||||||
|
|
||||||
|
### Status
|
||||||
|
|
||||||
|
[OK] **Completed**
|
||||||
@@ -4,15 +4,19 @@
|
|||||||
|
|
||||||
## 目标产物
|
## 目标产物
|
||||||
|
|
||||||
每个区域默认输出到 `outputs/<area-id>/`:
|
每个区域默认输出到 `outputs/<area-id>/`。其中只有 `package/` 是可复制给下游的发布边界:
|
||||||
|
|
||||||
|
- `package/manifest.json`:版本化 `osm-asset-package/v1` manifest,声明 WGS84 anchor、ENU(X east/Y north/Z up,米)、heading correction 和包内模型 URL
|
||||||
|
- `package/models/<area-id>.glb`:完整静态场景;`roads.glb`、`buildings.glb`、`vegetation.glb`、`water.glb` 是可选重叠分层,默认不要与完整场景同时加载
|
||||||
|
|
||||||
|
其余内容仍是本项目工作目录:
|
||||||
|
|
||||||
- `<area-id>.blend`:Blender 场景,包含道路、建筑、水体、植被等
|
- `<area-id>.blend`:Blender 场景,包含道路、建筑、水体、植被等
|
||||||
- `<area-id>.png`:Blender 预览渲染
|
- `<area-id>.png`:Blender 预览渲染
|
||||||
- `<area-id>.glb`:Cesium 可加载的完整 3D 模型(基线产物)
|
- `<area-id>.glb`:Cesium 可加载的完整 3D 模型(默认压缩交付产物)
|
||||||
- `<area-id>-roads.glb`、`-buildings.glb`、`-vegetation.glb`、`-water.glb`:Cesium 分类检查用的辅助模型
|
- `<area-id>-roads.glb`、`-buildings.glb`、`-vegetation.glb`、`-water.glb`:Cesium 分类检查用的辅助模型
|
||||||
- `<area-id>.json`:Cesium 放置元数据和示例代码
|
- `<area-id>.json`:Cesium 放置元数据和示例代码
|
||||||
- `<area-id>-cesium-preview.html`:Cesium 本地预览页
|
- `<area-id>-cesium-preview.html`:Cesium 本地预览页
|
||||||
- `<area-id>-compressed-webp768.glb/json/html`:显式 `compress` 阶段生成的可选压缩预览产物
|
|
||||||
- `osm2streets_web_out/`:osm2streets GeoJSON 中间层
|
- `osm2streets_web_out/`:osm2streets GeoJSON 中间层
|
||||||
- `<area-id>.gpkg` / `<area-id>.qgz` / `<area-id>-preview.png`:QGIS 调试资产
|
- `<area-id>.gpkg` / `<area-id>.qgz` / `<area-id>-preview.png`:QGIS 调试资产
|
||||||
|
|
||||||
@@ -37,12 +41,14 @@ npm install
|
|||||||
|
|
||||||
## 主流程
|
## 主流程
|
||||||
|
|
||||||
默认构建南台子湖创新谷样例:
|
交互式选择区域和构建阶段:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
使用方向键移动、空格多选阶段、回车开始构建;`intermediates` 与 `reimport` 不能同时选择。
|
||||||
|
|
||||||
指定区域配置:
|
指定区域配置:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -60,15 +66,14 @@ npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json
|
|||||||
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages reimport
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages reimport
|
||||||
```
|
```
|
||||||
|
|
||||||
`intermediates` 会生成 osm2streets GeoJSON、GeoPackage、QGIS 工程和 QGIS 预览图。`blender` 使用 OSM 和 osm2streets GeoJSON 生成 `.blend`/`.png`。`cesium` 从 `.blend` 导出 `.glb`/`.json`,并生成 Cesium 预览 HTML。`preview` 只在已有 `.glb/.json` 时补生成 HTML。`compress` 从已有 `.glb/.json/html` 生成并列压缩产物,不覆盖默认 GLB。`reimport` 把手工编辑过的 GeoPackage 回导为 GeoJSON,不含在 `all` 里,详见 [QGIS 手工修正工作流](#qgis-手工修正工作流)。
|
`intermediates` 会生成 osm2streets GeoJSON、GeoPackage、QGIS 工程和 QGIS 预览图。`blender` 使用 OSM 和 osm2streets GeoJSON 生成 `.blend`/`.png`。`cesium` 从 `.blend` 导出包 staging,`compress` 压缩 staging 主 GLB,`package` 校验并原子发布 `package/`,`preview` 生成仅用于本地验证的 HTML 和 `_preview/` 动态描述符。`reimport` 把手工编辑过的 GeoPackage 回导为 GeoJSON,不含在 `all` 里,详见 [QGIS 手工修正工作流](#qgis-手工修正工作流)。
|
||||||
|
|
||||||
Cesium 预览默认显示完整场景。点击 `Inspect` 后会按道路、建筑、绿化与设施、水体加载辅助 GLB;该模式用于单独检查生成结果,主 GLB 仍是完整场景和下游使用的基线。
|
Cesium 预览默认显示完整场景。点击 `Inspect` 后会按道路、建筑、绿化与设施、水体加载辅助 GLB;该模式用于单独检查生成结果,主 GLB 是压缩后的下游交付资产。
|
||||||
压缩预览同样保留这些分类检查资产;重跑 `compress` 后应打开新生成的压缩预览 HTML。
|
|
||||||
|
|
||||||
`compress` 不含在 `all` 里,也不能从配置文件默认开启。需要重导出 Cesium 后立刻生成压缩产物时,显式跑:
|
`compress` 包含在完整构建的默认阶段和 `all` 中。需要对已有标准产物重新压缩时,可以显式跑:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages cesium,compress
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages compress
|
||||||
```
|
```
|
||||||
|
|
||||||
## 区域诊断
|
## 区域诊断
|
||||||
@@ -209,8 +214,7 @@ QGIS road-layer knobs:
|
|||||||
"areaDir": "/absolute/path/to/custom-area",
|
"areaDir": "/absolute/path/to/custom-area",
|
||||||
"blend": "/absolute/path/to/custom.blend",
|
"blend": "/absolute/path/to/custom.blend",
|
||||||
"glb": "/absolute/path/to/custom.glb",
|
"glb": "/absolute/path/to/custom.glb",
|
||||||
"cesiumPreview": "/absolute/path/to/custom-preview.html",
|
"cesiumPreview": "/absolute/path/to/custom-preview.html"
|
||||||
"compressedGlb": "/absolute/path/to/custom-compressed.glb"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -275,8 +279,8 @@ Cesium GLB 低层导出:
|
|||||||
|
|
||||||
## 压缩 GLB
|
## 压缩 GLB
|
||||||
|
|
||||||
推荐使用显式 `compress` 阶段。它不会覆盖默认 `<area-id>.glb`,只生成并列的压缩 GLB、
|
完整构建默认运行 `compress`。它将未压缩 Cesium 导出复制到 `_pipeline` 下的临时目录,
|
||||||
metadata 和预览页:
|
压缩成功后才替换标准 `<area-id>.glb`、`.json` 和预览页;最终输出目录不保留并列压缩文件:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build:area -- \
|
npm run build:area -- \
|
||||||
@@ -289,7 +293,7 @@ npm run build:area -- \
|
|||||||
```bash
|
```bash
|
||||||
npm run compress:glb -- \
|
npm run compress:glb -- \
|
||||||
--input outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley.glb \
|
--input outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley.glb \
|
||||||
--output outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley-compressed-webp768.glb \
|
--output /tmp/nantaizi-lake-innovation-valley-compressed.glb \
|
||||||
--texture-size 768 \
|
--texture-size 768 \
|
||||||
--metadata outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley.json \
|
--metadata outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley.json \
|
||||||
--preview outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley-cesium-preview.html
|
--preview outputs/nantaizi-lake-innovation-valley/nantaizi-lake-innovation-valley-cesium-preview.html
|
||||||
@@ -310,7 +314,7 @@ npm run compress:glb -- \
|
|||||||
南台子湖创新谷当前可直接使用下面这条命令:
|
南台子湖创新谷当前可直接使用下面这条命令:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build -- --config config/areas/nantaizi-lake-innovation-valley.json --stages reimport,blender,cesium
|
npm run build:area -- --config config/areas/nantaizi-lake-innovation-valley.json --stages reimport,blender,cesium
|
||||||
```
|
```
|
||||||
|
|
||||||
`reimport` 阶段(`scripts/reimport-gpkg.js`)做两件事:
|
`reimport` 阶段(`scripts/reimport-gpkg.js`)做两件事:
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
+22
-45
@@ -579,7 +579,8 @@ def export_glb(filepath, meshes):
|
|||||||
|
|
||||||
def semantic_asset_specs(glb_path, meshes):
|
def semantic_asset_specs(glb_path, meshes):
|
||||||
"""Derive optional inspection assets from the scene's named collections."""
|
"""Derive optional inspection assets from the scene's named collections."""
|
||||||
stem, extension = os.path.splitext(glb_path)
|
model_dir, filename = os.path.split(glb_path)
|
||||||
|
_, extension = os.path.splitext(filename)
|
||||||
by_collection = {}
|
by_collection = {}
|
||||||
for collection in bpy.context.scene.collection.children:
|
for collection in bpy.context.scene.collection.children:
|
||||||
by_collection[collection.name] = set(collection.all_objects)
|
by_collection[collection.name] = set(collection.all_objects)
|
||||||
@@ -592,7 +593,7 @@ def semantic_asset_specs(glb_path, meshes):
|
|||||||
subset = [obj for obj in meshes if obj in objects]
|
subset = [obj for obj in meshes if obj in objects]
|
||||||
if not subset:
|
if not subset:
|
||||||
continue
|
continue
|
||||||
path = stem + "-" + asset_id + extension
|
path = os.path.join(model_dir, asset_id + extension)
|
||||||
specs.append({
|
specs.append({
|
||||||
"id": asset_id,
|
"id": asset_id,
|
||||||
"label": label,
|
"label": label,
|
||||||
@@ -673,42 +674,27 @@ def export(args):
|
|||||||
center_lat = (bounds["min_lat"] + bounds["max_lat"]) / 2.0
|
center_lat = (bounds["min_lat"] + bounds["max_lat"]) / 2.0
|
||||||
else:
|
else:
|
||||||
center_lon = center_lat = 0.0
|
center_lon = center_lat = 0.0
|
||||||
|
area_id = os.path.splitext(os.path.basename(args["glb"]))[0]
|
||||||
|
runtime_assets = []
|
||||||
|
if args.get("dynamic_glb"):
|
||||||
|
runtime_assets.append({"id": "traffic-signals-dynamic", "type": "traffic-signal-lenses", "uri": "runtime/traffic-signals-dynamic.glb"})
|
||||||
|
if args.get("countdown_0_glb"):
|
||||||
|
runtime_assets.append({"id": "traffic-signals-countdown-0", "type": "traffic-signal-countdown", "phaseGroup": 0, "uri": "runtime/traffic-signals-countdown-0.glb"})
|
||||||
|
if args.get("countdown_1_glb"):
|
||||||
|
runtime_assets.append({"id": "traffic-signals-countdown-1", "type": "traffic-signal-countdown", "phaseGroup": 1, "uri": "runtime/traffic-signals-countdown-1.glb"})
|
||||||
metadata = {
|
metadata = {
|
||||||
"asset": os.path.basename(args["glb"]),
|
"schema": "osm-asset-package/v1",
|
||||||
"assets": [{
|
"packageVersion": "1.0.0",
|
||||||
"id": "main",
|
"areaId": area_id,
|
||||||
"label": "Scene",
|
"coordinateSystem": {"axes": "ENU", "units": "meters", "x": "east", "y": "north", "z": "up"},
|
||||||
"type": "model",
|
"placement": {"longitude": center_lon, "latitude": center_lat, "height": 0.35, "headingCorrectionDegrees": -90.0},
|
||||||
"url": os.path.basename(args["glb"]),
|
"bounds": {"minLon": bounds.get("min_lon", center_lon), "minLat": bounds.get("min_lat", center_lat), "maxLon": bounds.get("max_lon", center_lon), "maxLat": bounds.get("max_lat", center_lat)},
|
||||||
"enabled": True,
|
"assets": [{"id": "main", "role": "scene", "category": "scene", "uri": "models/" + os.path.basename(args["glb"]), "defaultLoad": True}] + [{
|
||||||
}, {
|
"id": asset["id"], "role": "layer", "category": asset["id"],
|
||||||
"id": "traffic-dynamic",
|
"uri": "models/" + os.path.basename(asset["path"]), "defaultLoad": False,
|
||||||
"label": "Traffic signals dynamic",
|
|
||||||
"type": "model",
|
|
||||||
"url": os.path.basename(args["dynamic_glb"]) if args.get("dynamic_glb") and dynamic_meshes else "",
|
|
||||||
"enabled": True,
|
|
||||||
"category": "dynamic",
|
|
||||||
}, {
|
|
||||||
"id": "traffic-countdown-0", "label": "Traffic countdown group 0", "type": "model",
|
|
||||||
"url": os.path.basename(args["countdown_0_glb"]), "enabled": True, "category": "countdown", "phaseGroup": 0,
|
|
||||||
}, {
|
|
||||||
"id": "traffic-countdown-1", "label": "Traffic countdown group 1", "type": "model",
|
|
||||||
"url": os.path.basename(args["countdown_1_glb"]), "enabled": True, "category": "countdown", "phaseGroup": 1,
|
|
||||||
}] + [{
|
|
||||||
"id": asset["id"],
|
|
||||||
"label": asset["label"],
|
|
||||||
"type": "model",
|
|
||||||
"url": os.path.basename(asset["path"]),
|
|
||||||
"enabled": False,
|
|
||||||
"category": "semantic",
|
|
||||||
} for asset in semantic_assets],
|
} for asset in semantic_assets],
|
||||||
"coordinate_system": "local ENU meters (X east, Y north, Z up)",
|
"runtime": runtime_assets,
|
||||||
"heading_correction_degrees": -90.0,
|
"sceneStats": {
|
||||||
"anchor": {"longitude": center_lon, "latitude": center_lat, "height": 0.35},
|
|
||||||
"bounds": bounds,
|
|
||||||
"source_osm": scene.get("source_osm", ""),
|
|
||||||
"source_geojson": scene.get("source_geojson", ""),
|
|
||||||
"scene_stats": {
|
|
||||||
"buildings": scene.get("building_count", 0),
|
"buildings": scene.get("building_count", 0),
|
||||||
"industrial_buildings": scene.get("industrial_building_count", 0),
|
"industrial_buildings": scene.get("industrial_building_count", 0),
|
||||||
"lake_polygons": scene.get("lake_count", 0),
|
"lake_polygons": scene.get("lake_count", 0),
|
||||||
@@ -717,15 +703,6 @@ def export(args):
|
|||||||
"scrub_polygons": scene.get("scrub_count", 0),
|
"scrub_polygons": scene.get("scrub_count", 0),
|
||||||
"fountains": scene.get("fountain_count", 0),
|
"fountains": scene.get("fountain_count", 0),
|
||||||
},
|
},
|
||||||
"cesium_js": (
|
|
||||||
"const p = Cesium.Cartesian3.fromDegrees(" +
|
|
||||||
f"{center_lon:.8f}, {center_lat:.8f}, 0.35);\n" +
|
|
||||||
"const enu = Cesium.Transforms.eastNorthUpToFixedFrame(p);\n" +
|
|
||||||
"const correction = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(-90.0));\n" +
|
|
||||||
"const modelMatrix = Cesium.Matrix4.multiplyByMatrix3(enu, correction, new Cesium.Matrix4());\n" +
|
|
||||||
"Cesium.Model.fromGltfAsync({ url: '" + os.path.basename(args["glb"]) +
|
|
||||||
"', modelMatrix }).then(model => viewer.scene.primitives.add(model));"
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
os.makedirs(os.path.dirname(args["metadata"]), exist_ok=True)
|
os.makedirs(os.path.dirname(args["metadata"]), exist_ok=True)
|
||||||
with open(args["metadata"], "w", encoding="utf-8") as handle:
|
with open(args["metadata"], "w", encoding="utf-8") as handle:
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
function resolveAsset(manifestUrl, manifest, id = "main") {
|
||||||
|
const asset = manifest.assets.find((candidate) => candidate.id === id);
|
||||||
|
if (!asset) throw new Error(`Unknown asset '${id}'`);
|
||||||
|
return new URL(asset.uri, manifestUrl).href;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveRuntime(manifestUrl, manifest, id) {
|
||||||
|
const runtime = (manifest.runtime || []).find((candidate) => candidate.id === id);
|
||||||
|
if (!runtime) throw new Error(`Unknown runtime asset '${id}'`);
|
||||||
|
return new URL(runtime.uri, manifestUrl).href;
|
||||||
|
}
|
||||||
|
|
||||||
|
function placement(manifest) {
|
||||||
|
return { ...manifest.placement, coordinateSystem: manifest.coordinateSystem };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { resolveAsset, resolveRuntime, placement };
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const { resolveAsset, resolveRuntime, placement } = require("./asset-package-resolver");
|
||||||
|
|
||||||
|
async function loadPackage(viewer, manifestUrl, assetId = "main") {
|
||||||
|
const manifest = await fetch(manifestUrl).then((response) => {
|
||||||
|
if (!response.ok) throw new Error(`Could not load manifest: ${response.status}`);
|
||||||
|
return response.json();
|
||||||
|
});
|
||||||
|
const p = placement(manifest);
|
||||||
|
const origin = Cesium.Cartesian3.fromDegrees(p.longitude, p.latitude, p.height);
|
||||||
|
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
|
||||||
|
const rotation = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(p.headingCorrectionDegrees));
|
||||||
|
const modelMatrix = Cesium.Matrix4.multiplyByMatrix3(enu, rotation, new Cesium.Matrix4());
|
||||||
|
const model = await Cesium.Model.fromGltfAsync({ url: resolveAsset(manifestUrl, manifest, assetId), modelMatrix });
|
||||||
|
viewer.scene.primitives.add(model);
|
||||||
|
return { manifest, model, placement: p, runtime: (id) => resolveRuntime(manifestUrl, manifest, id) };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { loadPackage };
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const { resolveAsset, resolveRuntime, placement } = require("./asset-package-resolver");
|
||||||
|
|
||||||
|
async function loadPackage(loader, manifestUrl, assetId = "main", handoffEnuPlacement) {
|
||||||
|
const manifest = await fetch(manifestUrl).then((response) => {
|
||||||
|
if (!response.ok) throw new Error(`Could not load manifest: ${response.status}`);
|
||||||
|
return response.json();
|
||||||
|
});
|
||||||
|
const scene = await loader.loadAsync(resolveAsset(manifestUrl, manifest, assetId));
|
||||||
|
// Three.js does not georeference local ENU itself; the embedding host owns it.
|
||||||
|
const enuPlacement = placement(manifest);
|
||||||
|
if (handoffEnuPlacement) handoffEnuPlacement(enuPlacement, scene.scene);
|
||||||
|
return { manifest, scene: scene.scene, placement: enuPlacement, runtime: (id) => resolveRuntime(manifestUrl, manifest, id) };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { loadPackage };
|
||||||
Generated
+411
@@ -8,14 +8,425 @@
|
|||||||
"name": "osm-asset-pipeline",
|
"name": "osm-asset-pipeline",
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@inquirer/prompts": "^8.5.2",
|
||||||
"osm2streets-js-node": "0.1.4"
|
"osm2streets-js-node": "0.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@inquirer/ansi": {
|
||||||
|
"version": "2.0.7",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/ansi/-/ansi-2.0.7.tgz",
|
||||||
|
"integrity": "sha512-3eTuUO1vH2cZm2ZKHeQxnOqlTi9EfZDGgIe3BL3I4u+rJHocr9Fz86M4fjYABPvFnQG/gGK551HqDiIcETwU6Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/checkbox": {
|
||||||
|
"version": "5.2.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/checkbox/-/checkbox-5.2.1.tgz",
|
||||||
|
"integrity": "sha512-b6xmA/VlTe0ZgDQHDui+Nav470u7u49nRd8/iuhOcQPO9Ch7lGuogydhi2VOmNlZ+zXcM8IcPuNSwQcdJaF/kw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/ansi": "^2.0.7",
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/figures": "^2.0.7",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/confirm": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/confirm/-/confirm-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-eb8DBZcz/2qHWQda4rk2JiQk5h9QV/cVHi1yjt0f69WFZMRFn0sJTye3EAP8icut8UDMjQPsaH5KbcOogefrFQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/core": {
|
||||||
|
"version": "11.2.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/core/-/core-11.2.1.tgz",
|
||||||
|
"integrity": "sha512-Qd6GJT1yVyrZZCfN8W2qKF5ApmqryXRhRKCuip8h01x2w/esJQ2XIYc6f9abMIHgKQdBfFTSOdbHRLAhuM09UA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/ansi": "^2.0.7",
|
||||||
|
"@inquirer/figures": "^2.0.7",
|
||||||
|
"@inquirer/type": "^4.0.7",
|
||||||
|
"cli-width": "^4.1.0",
|
||||||
|
"fast-wrap-ansi": "^0.2.0",
|
||||||
|
"mute-stream": "^3.0.0",
|
||||||
|
"signal-exit": "^4.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/editor": {
|
||||||
|
"version": "5.2.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/editor/-/editor-5.2.2.tgz",
|
||||||
|
"integrity": "sha512-ZRVd/oD+sYsUd5zVm0NflqEzlqfYCyHNsqkHl2oWXEUHs12tCbcSFi+wVFEvD8+LGRaMUsVrE7qeo6lSG/S1Vg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/external-editor": "^3.0.3",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/expand": {
|
||||||
|
"version": "5.1.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/expand/-/expand-5.1.1.tgz",
|
||||||
|
"integrity": "sha512-YmQpenjbFSHAK3sOd44puHh3V1KXXr+JiNpUztoSQ4drLh2rTVzTap/YtlAVu/5xavifIlBfNEzJ/neZJ1a/1g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/external-editor": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/external-editor/-/external-editor-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-6thf5I8q7lZwzGLAxPaaGEREEkZ3nyePPDQ1oyobblxmEE8mqTLguScP7pDjUTAibiyb4hfXl+qjUEJ+di/aNA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"chardet": "^2.1.1",
|
||||||
|
"iconv-lite": "^0.7.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/figures": {
|
||||||
|
"version": "2.0.7",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/figures/-/figures-2.0.7.tgz",
|
||||||
|
"integrity": "sha512-aJ8TBPOGB6f/2qziPfElISTCEd5XOYTFckA2SGjhNmiKzfK/u4ot3v0DUzGVdUnKjN10EqnnEPck36BkyfLnJw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/input": {
|
||||||
|
"version": "5.1.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/input/-/input-5.1.2.tgz",
|
||||||
|
"integrity": "sha512-9K/DDBSQpOyZSkt6sOVP9Vo0TR7atX2kuILsUu0x3wVcVbe97lJwIJKMLdMw25tDYuXl/qp6erT0Xs1rfmcfZg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/number": {
|
||||||
|
"version": "4.1.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/number/-/number-4.1.1.tgz",
|
||||||
|
"integrity": "sha512-XF4IXAbPnGPgw0wsbC/i2tPcyfdZgDpUlhsqU0SfT4IRIGWha6Xm9VRgN5yYxJq+jnyXlfXI/nQ3ulfk0iEICA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/password": {
|
||||||
|
"version": "5.1.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/password/-/password-5.1.1.tgz",
|
||||||
|
"integrity": "sha512-3XBfF7DAsp5qeDsvN5Rd1HmbNokVvEQoUM0QLrRcybC9nX96w3Pbmu7qUsb3IT3J3jBvs2+mTXaKHOUsgHMLzg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/ansi": "^2.0.7",
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/prompts": {
|
||||||
|
"version": "8.5.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/prompts/-/prompts-8.5.2.tgz",
|
||||||
|
"integrity": "sha512-IYR/3C/paEVVQYQvdDlFZVjRCJVYHHON0XXMH91KO9GSxs0TdKYWlUdvfQl2EfAHDxUaN3IBffkE/BDTh5nJ6g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/checkbox": "^5.2.1",
|
||||||
|
"@inquirer/confirm": "^6.1.1",
|
||||||
|
"@inquirer/editor": "^5.2.2",
|
||||||
|
"@inquirer/expand": "^5.1.1",
|
||||||
|
"@inquirer/input": "^5.1.2",
|
||||||
|
"@inquirer/number": "^4.1.1",
|
||||||
|
"@inquirer/password": "^5.1.1",
|
||||||
|
"@inquirer/rawlist": "^5.3.1",
|
||||||
|
"@inquirer/search": "^4.2.1",
|
||||||
|
"@inquirer/select": "^5.2.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/rawlist": {
|
||||||
|
"version": "5.3.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/rawlist/-/rawlist-5.3.1.tgz",
|
||||||
|
"integrity": "sha512-QqdTqQddL3qPX/PPrjobpsO25NZ4dWXgTLenrR445L2ptLEYE6Z+PD5c5CNDJNx4ugRgELAIpSIJxZaO2jJ2Og==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/search": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/search/-/search-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-xJj8QWKRSrfKoBIITLZK61dD3zwo0Rz11fgDImku30/Oe81zMdIdGgrLY2h6RkJ+KZ/GhNYIRMKnH/62qBTA5g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/figures": "^2.0.7",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/select": {
|
||||||
|
"version": "5.2.1",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/select/-/select-5.2.1.tgz",
|
||||||
|
"integrity": "sha512-FlDndEUww8m7BfukO2nJa25vhD+H5jxxCv4oGioKqzyWz3nPHhhw4LKdYRSlXuAx7DsdWia7iyaBPKKS95Evfw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@inquirer/ansi": "^2.0.7",
|
||||||
|
"@inquirer/core": "^11.2.1",
|
||||||
|
"@inquirer/figures": "^2.0.7",
|
||||||
|
"@inquirer/type": "^4.0.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@inquirer/type": {
|
||||||
|
"version": "4.0.7",
|
||||||
|
"resolved": "http://172.16.1.86:4873/@inquirer/type/-/type-4.0.7.tgz",
|
||||||
|
"integrity": "sha512-t28inv14nMQ1PhKpsJPY+kEs/c00qzeCOS2gTNRyTjG5d6qsVA2fItxW4hkvGZ5lvanGLdtCzVIx5dwdRpN1+g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=23.5.0 || ^22.13.0 || ^20.17.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/node": ">=18"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/node": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/chardet": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/chardet/-/chardet-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-rddelWYNPRrXq6PtNEN2S3f6t9ILzvqaN5pVgi4kqt9jHQaXIial9PznB5iSPVlQSLNaaH22ItWz3EJtQ10+OA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/cli-width": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/cli-width/-/cli-width-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fast-string-truncated-width": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "http://172.16.1.86:4873/fast-string-truncated-width/-/fast-string-truncated-width-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-0jjjIEL6+0jag3l2XWWizO64/aZVtpiGE3t0Zgqxv0DPuxiMjvB3M24fCyhZUO4KomJQPj3LTSUnDP3GpdwC0g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/fast-string-width": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/fast-string-width/-/fast-string-width-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-gX8LrtNEI5hq8DVUfRQMbr5lpaS4nMIWV+7XEbXk2b8kiQIizgnlr12B4dA3ZEx3308ze0O4Q1R+cHts8kyUJg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"fast-string-truncated-width": "^3.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/fast-wrap-ansi": {
|
||||||
|
"version": "0.2.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/fast-wrap-ansi/-/fast-wrap-ansi-0.2.2.tgz",
|
||||||
|
"integrity": "sha512-7F2Fl+TjRSenLqlU3UjSH0iyqopqoZIu7eZVpEirP2g1GtWa2G/ecEmBdgz31+Mxr+ELclgg6sokpSFIQiZ02Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"fast-string-width": "^3.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/iconv-lite": {
|
||||||
|
"version": "0.7.3",
|
||||||
|
"resolved": "http://172.16.1.86:4873/iconv-lite/-/iconv-lite-0.7.3.tgz",
|
||||||
|
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/express"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mute-stream": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/mute-stream/-/mute-stream-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.17.0 || >=22.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/osm2streets-js-node": {
|
"node_modules/osm2streets-js-node": {
|
||||||
"version": "0.1.4",
|
"version": "0.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/osm2streets-js-node/-/osm2streets-js-node-0.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/osm2streets-js-node/-/osm2streets-js-node-0.1.4.tgz",
|
||||||
"integrity": "sha512-JjS6qJJjrrlEKEZxqV4s/N4qU0YfvdMUasdvfoyYCmZxEpNKAYjpuZeWJWeLEcGOqhu+YuV3YDIk9jgvMU0kKQ==",
|
"integrity": "sha512-JjS6qJJjrrlEKEZxqV4s/N4qU0YfvdMUasdvfoyYCmZxEpNKAYjpuZeWJWeLEcGOqhu+YuV3YDIk9jgvMU0kKQ==",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
|
},
|
||||||
|
"node_modules/safer-buffer": {
|
||||||
|
"version": "2.1.2",
|
||||||
|
"resolved": "http://172.16.1.86:4873/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/signal-exit": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "http://172.16.1.86:4873/signal-exit/-/signal-exit-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-1
@@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node scripts/build-area.js",
|
"build": "node scripts/interactive-build.js",
|
||||||
"build:area": "node scripts/build-area.js",
|
"build:area": "node scripts/build-area.js",
|
||||||
"build:qgis": "node scripts/build-osm2streets-qgis.js",
|
"build:qgis": "node scripts/build-osm2streets-qgis.js",
|
||||||
"check:area": "node scripts/check-area.js",
|
"check:area": "node scripts/check-area.js",
|
||||||
@@ -12,14 +12,18 @@
|
|||||||
"diagnose:area": "node scripts/diagnose-area.js",
|
"diagnose:area": "node scripts/diagnose-area.js",
|
||||||
"preflight:area": "node scripts/preflight-area.js",
|
"preflight:area": "node scripts/preflight-area.js",
|
||||||
"test:preflight": "node scripts/test-area-preflight.js",
|
"test:preflight": "node scripts/test-area-preflight.js",
|
||||||
|
"test:build-stages": "node scripts/test-build-stages.js",
|
||||||
"test:budgets": "node scripts/test-asset-budgets.js",
|
"test:budgets": "node scripts/test-asset-budgets.js",
|
||||||
"test:preview-assets": "node scripts/test-preview-assets.js",
|
"test:preview-assets": "node scripts/test-preview-assets.js",
|
||||||
"test:compress-glb": "node scripts/test-compress-glb.js",
|
"test:compress-glb": "node scripts/test-compress-glb.js",
|
||||||
|
"test:package-contract": "node scripts/test-package-contract.js",
|
||||||
|
"test:package-examples": "node scripts/test-package-examples.js",
|
||||||
"test:turn-lane-arrows": "node scripts/test-turn-lane-arrows.js",
|
"test:turn-lane-arrows": "node scripts/test-turn-lane-arrows.js",
|
||||||
"test:traffic-signals": "node scripts/test-traffic-signals.js",
|
"test:traffic-signals": "node scripts/test-traffic-signals.js",
|
||||||
"render:turn-lane-arrow-samples": "node scripts/render-turn-lane-arrow-samples.js"
|
"render:turn-lane-arrow-samples": "node scripts/render-turn-lane-arrow-samples.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@inquirer/prompts": "^8.5.2",
|
||||||
"osm2streets-js-node": "0.1.4"
|
"osm2streets-js-node": "0.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+127
-133
@@ -4,6 +4,8 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const { spawnSync } = require("child_process");
|
const { spawnSync } = require("child_process");
|
||||||
const { readAreaConfig } = require("./lib/area-config");
|
const { readAreaConfig } = require("./lib/area-config");
|
||||||
|
const { resolveStages } = require("./lib/build-stages");
|
||||||
|
const { validateManifest, addIntegrity } = require("./lib/package-contract");
|
||||||
const { blenderExecutable: resolveBlenderExecutable } = require("./lib/tool-paths");
|
const { blenderExecutable: resolveBlenderExecutable } = require("./lib/tool-paths");
|
||||||
const {
|
const {
|
||||||
SCENE_LAYERS,
|
SCENE_LAYERS,
|
||||||
@@ -41,15 +43,6 @@ const requestedStages = args.stages
|
|||||||
: null;
|
: null;
|
||||||
const stages = resolveStages(area.stages, requestedStages);
|
const stages = resolveStages(area.stages, requestedStages);
|
||||||
|
|
||||||
// intermediates deletes and rebuilds the GeoPackage from OSM, which is exactly
|
|
||||||
// the manual work reimport exists to recover. Refuse the combination instead of
|
|
||||||
// silently letting one undo the other.
|
|
||||||
if (stages.intermediates && stages.reimport) {
|
|
||||||
throw new Error(
|
|
||||||
"Stages 'intermediates' and 'reimport' are mutually exclusive: " +
|
|
||||||
"intermediates rebuilds the GeoPackage from OSM and would discard the QGIS edits reimport reads back.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Area: ${area.id}`);
|
console.log(`Area: ${area.id}`);
|
||||||
console.log(`Config: ${configPath}`);
|
console.log(`Config: ${configPath}`);
|
||||||
@@ -67,12 +60,15 @@ if (stages.blender) {
|
|||||||
if (stages.cesium) {
|
if (stages.cesium) {
|
||||||
exportCesium(area);
|
exportCesium(area);
|
||||||
}
|
}
|
||||||
if (stages.preview) {
|
|
||||||
writeCesiumPreview(area);
|
|
||||||
}
|
|
||||||
if (stages.compress) {
|
if (stages.compress) {
|
||||||
compressCesiumGlb(area);
|
compressCesiumGlb(area);
|
||||||
}
|
}
|
||||||
|
if (stages.package) {
|
||||||
|
publishPackage(area);
|
||||||
|
}
|
||||||
|
if (stages.preview) {
|
||||||
|
writeCesiumPreview(area);
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Done.");
|
console.log("Done.");
|
||||||
|
|
||||||
@@ -100,49 +96,6 @@ function splitList(value) {
|
|||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveStages(defaults, requested) {
|
|
||||||
if (!requested) return defaults;
|
|
||||||
// 'reimport' is deliberately absent from 'all': it is a recovery step for
|
|
||||||
// hand-edited GeoPackages, never part of a full build.
|
|
||||||
// 'compress' is also absent from 'all': it creates an alternate Cesium GLB,
|
|
||||||
// not the baseline asset.
|
|
||||||
const aliases = {
|
|
||||||
all: ["intermediates", "blender", "cesium"],
|
|
||||||
qgis: ["intermediates"],
|
|
||||||
osm2streets: ["intermediates"],
|
|
||||||
geojson: ["intermediates"],
|
|
||||||
intermediate: ["intermediates"],
|
|
||||||
intermediates: ["intermediates"],
|
|
||||||
reimport: ["reimport"],
|
|
||||||
gpkg: ["reimport"],
|
|
||||||
blender: ["blender"],
|
|
||||||
scene: ["blender"],
|
|
||||||
cesium: ["cesium"],
|
|
||||||
glb: ["cesium"],
|
|
||||||
preview: ["preview"],
|
|
||||||
html: ["preview"],
|
|
||||||
cesiumPreview: ["preview"],
|
|
||||||
compress: ["compress"],
|
|
||||||
compression: ["compress"],
|
|
||||||
compressedCesium: ["compress"],
|
|
||||||
};
|
|
||||||
const out = {
|
|
||||||
intermediates: false,
|
|
||||||
reimport: false,
|
|
||||||
blender: false,
|
|
||||||
cesium: false,
|
|
||||||
preview: false,
|
|
||||||
compress: false,
|
|
||||||
};
|
|
||||||
for (const stage of requested) {
|
|
||||||
const mapped = aliases[stage];
|
|
||||||
if (!mapped) {
|
|
||||||
throw new Error(`Unknown stage '${stage}'. Use intermediates, reimport, blender, cesium, preview, compress, or all.`);
|
|
||||||
}
|
|
||||||
for (const key of mapped) out[key] = true;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
function writeDerivedConfig(area) {
|
function writeDerivedConfig(area) {
|
||||||
fs.mkdirSync(area.outputs.pipelineDir, { recursive: true });
|
fs.mkdirSync(area.outputs.pipelineDir, { recursive: true });
|
||||||
@@ -324,8 +277,12 @@ function exportCesium(area) {
|
|||||||
ensureFile(blenderExecutable(area), "Blender executable");
|
ensureFile(blenderExecutable(area), "Blender executable");
|
||||||
ensureFile(area.outputs.blend, "Blend scene");
|
ensureFile(area.outputs.blend, "Blend scene");
|
||||||
ensureFile(path.join(repoRoot, "blender", "export_cesium.py"), "Cesium exporter");
|
ensureFile(path.join(repoRoot, "blender", "export_cesium.py"), "Cesium exporter");
|
||||||
|
fs.rmSync(area.outputs.packageStagingDir, { recursive: true, force: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.glb), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.glb), { recursive: true });
|
||||||
fs.mkdirSync(path.dirname(area.outputs.metadata), { recursive: true });
|
fs.mkdirSync(path.dirname(area.outputs.metadata), { recursive: true });
|
||||||
|
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsDynamicGlb), { recursive: true });
|
||||||
|
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsCountdown0Glb), { recursive: true });
|
||||||
|
fs.mkdirSync(path.dirname(area.outputs.trafficSignalsCountdown1Glb), { recursive: true });
|
||||||
|
|
||||||
console.log("Stage: cesium");
|
console.log("Stage: cesium");
|
||||||
const started = Date.now();
|
const started = Date.now();
|
||||||
@@ -353,7 +310,6 @@ function exportCesium(area) {
|
|||||||
ensureFile(area.outputs.trafficSignalsCountdown0Glb, "Traffic countdown group 0 GLB");
|
ensureFile(area.outputs.trafficSignalsCountdown0Glb, "Traffic countdown group 0 GLB");
|
||||||
ensureFile(area.outputs.trafficSignalsCountdown1Glb, "Traffic countdown group 1 GLB");
|
ensureFile(area.outputs.trafficSignalsCountdown1Glb, "Traffic countdown group 1 GLB");
|
||||||
const semanticAssets = semanticAssetRecords(area);
|
const semanticAssets = semanticAssetRecords(area);
|
||||||
writeCesiumPreview(area);
|
|
||||||
const finished = Date.now();
|
const finished = Date.now();
|
||||||
const digest = glbDigest(area.outputs.glb);
|
const digest = glbDigest(area.outputs.glb);
|
||||||
writeStageManifest(area, {
|
writeStageManifest(area, {
|
||||||
@@ -385,8 +341,8 @@ function semanticAssetRecords(area) {
|
|||||||
const assets = Array.isArray(metadata.assets) ? metadata.assets : [];
|
const assets = Array.isArray(metadata.assets) ? metadata.assets : [];
|
||||||
const records = {};
|
const records = {};
|
||||||
for (const asset of assets) {
|
for (const asset of assets) {
|
||||||
if (asset.category !== "semantic") continue;
|
if (asset.role !== "layer") continue;
|
||||||
const file = path.join(area.outputs.areaDir, asset.url);
|
const file = path.resolve(area.outputs.packageStagingDir, asset.uri);
|
||||||
ensureFile(file, `Cesium semantic asset '${asset.id}'`);
|
ensureFile(file, `Cesium semantic asset '${asset.id}'`);
|
||||||
records[asset.id] = fileRecord(file);
|
records[asset.id] = fileRecord(file);
|
||||||
}
|
}
|
||||||
@@ -396,75 +352,111 @@ function semanticAssetRecords(area) {
|
|||||||
function compressCesiumGlb(area) {
|
function compressCesiumGlb(area) {
|
||||||
ensureFile(area.outputs.glb, "Cesium GLB");
|
ensureFile(area.outputs.glb, "Cesium GLB");
|
||||||
ensureFile(area.outputs.metadata, "Cesium metadata");
|
ensureFile(area.outputs.metadata, "Cesium metadata");
|
||||||
ensureFile(area.outputs.cesiumPreview, "Cesium preview");
|
|
||||||
ensureFile(path.join(repoRoot, "scripts", "compress-glb.js"), "GLB compressor");
|
ensureFile(path.join(repoRoot, "scripts", "compress-glb.js"), "GLB compressor");
|
||||||
fs.mkdirSync(path.dirname(area.outputs.compressedGlb), { recursive: true });
|
|
||||||
fs.mkdirSync(path.dirname(area.outputs.compressedMetadata), { recursive: true });
|
|
||||||
fs.mkdirSync(path.dirname(area.outputs.compressedCesiumPreview), { recursive: true });
|
|
||||||
|
|
||||||
const compressArgs = [
|
|
||||||
path.join(repoRoot, "scripts", "compress-glb.js"),
|
|
||||||
"--input",
|
|
||||||
area.outputs.glb,
|
|
||||||
"--output",
|
|
||||||
area.outputs.compressedGlb,
|
|
||||||
"--texture-size",
|
|
||||||
String(area.compress.textureSize),
|
|
||||||
"--quality",
|
|
||||||
String(area.compress.quality),
|
|
||||||
"--effort",
|
|
||||||
String(area.compress.effort),
|
|
||||||
"--metadata",
|
|
||||||
area.outputs.metadata,
|
|
||||||
"--metadata-output",
|
|
||||||
area.outputs.compressedMetadata,
|
|
||||||
"--preview",
|
|
||||||
area.outputs.cesiumPreview,
|
|
||||||
"--preview-output",
|
|
||||||
area.outputs.compressedCesiumPreview,
|
|
||||||
];
|
|
||||||
if (area.compress.meshopt) {
|
|
||||||
compressArgs.push("--meshopt");
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("Stage: compress (Cesium GLB texture resize + WebP)");
|
|
||||||
const started = Date.now();
|
const started = Date.now();
|
||||||
const startedAt = new Date(started).toISOString();
|
const startedAt = new Date(started).toISOString();
|
||||||
runCommand(process.execPath, compressArgs, "compress");
|
fs.mkdirSync(area.outputs.pipelineDir, { recursive: true });
|
||||||
const finished = Date.now();
|
const temporaryDir = fs.mkdtempSync(path.join(area.outputs.pipelineDir, "compress-"));
|
||||||
const sourceDigest = glbDigest(area.outputs.glb);
|
|
||||||
const compressedDigest = glbDigest(area.outputs.compressedGlb);
|
// The compressor rejects an in-place transform. Preserve the exporter output
|
||||||
writeStageManifest(area, {
|
// in a temporary directory, then atomically promote the compressed delivery.
|
||||||
stage: "compress",
|
const sourceDir = path.join(temporaryDir, "source");
|
||||||
status: "ok",
|
const outputDir = path.join(temporaryDir, "delivery");
|
||||||
config: configPath,
|
const stagedSourceGlb = path.join(sourceDir, path.basename(area.outputs.glb));
|
||||||
startedAt,
|
const stagedSourceMetadata = path.join(sourceDir, path.basename(area.outputs.metadata));
|
||||||
finishedAt: new Date(finished).toISOString(),
|
const stagedDeliveryGlb = path.join(outputDir, path.basename(area.outputs.glb));
|
||||||
durationMs: finished - started,
|
const stagedDeliveryMetadata = path.join(outputDir, path.basename(area.outputs.metadata));
|
||||||
inputs: {
|
try {
|
||||||
glb: fileRecord(area.outputs.glb),
|
fs.mkdirSync(sourceDir, { recursive: true });
|
||||||
metadata: fileRecord(area.outputs.metadata),
|
fs.copyFileSync(area.outputs.glb, stagedSourceGlb);
|
||||||
cesiumPreview: fileRecord(area.outputs.cesiumPreview),
|
fs.copyFileSync(area.outputs.metadata, stagedSourceMetadata);
|
||||||
},
|
const sourceDigest = glbDigest(stagedSourceGlb);
|
||||||
outputs: {
|
const compressArgs = [
|
||||||
compressedGlb: fileRecord(area.outputs.compressedGlb),
|
path.join(repoRoot, "scripts", "compress-glb.js"),
|
||||||
compressedMetadata: fileRecord(area.outputs.compressedMetadata),
|
"--input", stagedSourceGlb,
|
||||||
compressedCesiumPreview: fileRecord(area.outputs.compressedCesiumPreview),
|
"--output", stagedDeliveryGlb,
|
||||||
},
|
"--texture-size", String(area.compress.textureSize),
|
||||||
summary: {
|
"--quality", String(area.compress.quality),
|
||||||
sourceGlb: glbSummary(sourceDigest),
|
"--effort", String(area.compress.effort),
|
||||||
compressedGlb: glbSummary(compressedDigest),
|
"--metadata", stagedSourceMetadata,
|
||||||
budget: evaluateGlbBudget(compressedDigest, area.budget),
|
"--metadata-output", stagedDeliveryMetadata,
|
||||||
options: {
|
];
|
||||||
textureSize: area.compress.textureSize,
|
if (area.compress.meshopt) compressArgs.push("--meshopt");
|
||||||
quality: area.compress.quality,
|
|
||||||
effort: area.compress.effort,
|
console.log("Stage: compress (Cesium GLB texture resize + WebP)");
|
||||||
meshopt: area.compress.meshopt,
|
runCommand(process.execPath, compressArgs, "compress");
|
||||||
|
ensureFile(stagedDeliveryGlb, "Compressed delivery GLB");
|
||||||
|
ensureFile(stagedDeliveryMetadata, "Compressed delivery metadata");
|
||||||
|
const compressedDigest = glbDigest(stagedDeliveryGlb);
|
||||||
|
fs.renameSync(stagedDeliveryGlb, area.outputs.glb);
|
||||||
|
fs.renameSync(stagedDeliveryMetadata, area.outputs.metadata);
|
||||||
|
const finished = Date.now();
|
||||||
|
writeStageManifest(area, {
|
||||||
|
stage: "compress",
|
||||||
|
status: "ok",
|
||||||
|
config: configPath,
|
||||||
|
startedAt,
|
||||||
|
finishedAt: new Date(finished).toISOString(),
|
||||||
|
durationMs: finished - started,
|
||||||
|
inputs: {},
|
||||||
|
// package promotes these staged files, so only its manifest owns final paths.
|
||||||
|
outputs: {},
|
||||||
|
summary: {
|
||||||
|
sourceGlb: glbSummary(sourceDigest),
|
||||||
|
glb: glbSummary(compressedDigest),
|
||||||
|
budget: evaluateGlbBudget(compressedDigest, area.budget),
|
||||||
|
options: {
|
||||||
|
textureSize: area.compress.textureSize,
|
||||||
|
quality: area.compress.quality,
|
||||||
|
effort: area.compress.effort,
|
||||||
|
meshopt: area.compress.meshopt,
|
||||||
|
},
|
||||||
|
compressionRatio: Number((compressedDigest.fileBytes / sourceDigest.fileBytes).toFixed(4)),
|
||||||
|
savedBytes: sourceDigest.fileBytes - compressedDigest.fileBytes,
|
||||||
},
|
},
|
||||||
compressionRatio: Number((compressedDigest.fileBytes / sourceDigest.fileBytes).toFixed(4)),
|
warnings: glbBudgetWarnings("Compressed", compressedDigest, area.budget),
|
||||||
savedBytes: sourceDigest.fileBytes - compressedDigest.fileBytes,
|
});
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(temporaryDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function publishPackage(area) {
|
||||||
|
ensureFile(area.outputs.packageStagingManifest, "Staged package manifest");
|
||||||
|
ensureFile(area.outputs.trafficSignals, "Traffic signal anchors");
|
||||||
|
const started = Date.now();
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(area.outputs.packageStagingManifest, "utf8"));
|
||||||
|
fs.mkdirSync(area.outputs.packageStagingRuntimeDir, { recursive: true });
|
||||||
|
fs.copyFileSync(area.outputs.trafficSignals, area.outputs.packageStagingTrafficSignals);
|
||||||
|
manifest.runtime = Array.isArray(manifest.runtime) ? manifest.runtime : [];
|
||||||
|
if (!manifest.runtime.some((runtime) => runtime.id === "traffic-signals")) {
|
||||||
|
manifest.runtime.push({ id: "traffic-signals", type: "traffic-signal-anchors", uri: "runtime/traffic-signals.json" });
|
||||||
|
}
|
||||||
|
validateManifest(manifest, area.outputs.packageStagingDir);
|
||||||
|
addIntegrity(manifest, area.outputs.packageStagingDir);
|
||||||
|
fs.writeFileSync(area.outputs.packageStagingManifest, `${JSON.stringify(manifest, null, 2)}\n`);
|
||||||
|
validateManifest(manifest, area.outputs.packageStagingDir);
|
||||||
|
const backup = `${area.outputs.packageDir}.previous`;
|
||||||
|
fs.rmSync(backup, { recursive: true, force: true });
|
||||||
|
try {
|
||||||
|
if (fs.existsSync(area.outputs.packageDir)) fs.renameSync(area.outputs.packageDir, backup);
|
||||||
|
fs.renameSync(area.outputs.packageStagingDir, area.outputs.packageDir);
|
||||||
|
fs.rmSync(backup, { recursive: true, force: true });
|
||||||
|
} catch (error) {
|
||||||
|
if (!fs.existsSync(area.outputs.packageDir) && fs.existsSync(backup)) fs.renameSync(backup, area.outputs.packageDir);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
const finished = Date.now();
|
||||||
|
writeStageManifest(area, {
|
||||||
|
stage: "package", status: "ok", config: configPath,
|
||||||
|
startedAt: new Date(started).toISOString(), finishedAt: new Date(finished).toISOString(), durationMs: finished - started,
|
||||||
|
inputs: { stagingManifest: fileRecord(path.join(area.outputs.packageDir, "manifest.json")) },
|
||||||
|
outputs: {
|
||||||
|
packageDir: fileRecord(area.outputs.packageDir),
|
||||||
|
manifest: fileRecord(area.outputs.packageManifest),
|
||||||
|
primaryGlb: fileRecord(area.outputs.packagePrimaryGlb),
|
||||||
},
|
},
|
||||||
warnings: glbBudgetWarnings("Compressed", compressedDigest, area.budget),
|
summary: { assets: manifest.assets.length, packageDir: area.outputs.packageDir }, warnings: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,9 +482,8 @@ function runCommand(command, commandArgs, stage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function writeCesiumPreview(area) {
|
function writeCesiumPreview(area) {
|
||||||
ensureFile(area.outputs.glb, "Cesium GLB");
|
ensureFile(area.outputs.packageManifest, "Published asset package manifest");
|
||||||
ensureFile(area.outputs.metadata, "Cesium metadata");
|
ensureFile(area.outputs.packageTrafficSignals, "Published traffic signal anchors");
|
||||||
ensureFile(area.outputs.trafficSignals, "Traffic signal anchors");
|
|
||||||
const lanePolygons = path.join(area.outputs.geojsonDir, "lane_polygons.geojson");
|
const lanePolygons = path.join(area.outputs.geojsonDir, "lane_polygons.geojson");
|
||||||
const network = path.join(area.outputs.geojsonDir, "network.json");
|
const network = path.join(area.outputs.geojsonDir, "network.json");
|
||||||
const intersectionSurface = path.join(area.outputs.geojsonDir, "intersection_surface.geojson");
|
const intersectionSurface = path.join(area.outputs.geojsonDir, "intersection_surface.geojson");
|
||||||
@@ -508,11 +499,14 @@ function writeCesiumPreview(area) {
|
|||||||
writeVehicleRoute(area, vehicleRoute);
|
writeVehicleRoute(area, vehicleRoute);
|
||||||
const vehicleModelNames = writeVehicleModel(area);
|
const vehicleModelNames = writeVehicleModel(area);
|
||||||
writeCesiumPreviewSupportFiles(path.dirname(htmlPath));
|
writeCesiumPreviewSupportFiles(path.dirname(htmlPath));
|
||||||
const glbName = path.basename(area.outputs.glb);
|
const glbName = "package/manifest.json";
|
||||||
const metadataName = path.basename(area.outputs.metadata);
|
const metadataName = "package/manifest.json";
|
||||||
const routeName = path.basename(area.outputs.vehicleRoute);
|
const routeName = previewRelativePath(area.outputs.areaDir, area.outputs.vehicleRoute);
|
||||||
const vehicleModelName = path.basename(area.outputs.vehicleModel);
|
const vehicleModelName = previewRelativePath(area.outputs.areaDir, area.outputs.vehicleModel);
|
||||||
fs.writeFileSync(htmlPath, cesiumPreviewHtml(glbName, metadataName, routeName, vehicleModelName, area.id, vehicleModelNames, previewRelativePath(area.outputs.areaDir, area.outputs.trafficSignals)));
|
const descriptor = { routeName: previewRelativePath(area.outputs.areaDir, area.outputs.vehicleRoute), vehicleModelName: previewRelativePath(area.outputs.areaDir, area.outputs.vehicleModel), vehicleModelNames: vehicleModelNames.map((name) => `_preview/${name}`), trafficSignalsName: "package/runtime/traffic-signals.json", assets: [] };
|
||||||
|
fs.mkdirSync(area.outputs.previewDir, { recursive: true });
|
||||||
|
fs.writeFileSync(area.outputs.previewDescriptor, `${JSON.stringify(descriptor, null, 2)}\n`);
|
||||||
|
fs.writeFileSync(htmlPath, cesiumPreviewHtml(glbName, metadataName, routeName, vehicleModelName, area.id, vehicleModelNames.map((name) => `_preview/${name}`), "package/runtime/traffic-signals.json", "_preview/descriptor.json"));
|
||||||
console.log(`Cesium preview: ${htmlPath}`);
|
console.log(`Cesium preview: ${htmlPath}`);
|
||||||
const finished = Date.now();
|
const finished = Date.now();
|
||||||
writeStageManifest(area, {
|
writeStageManifest(area, {
|
||||||
@@ -525,8 +519,8 @@ function writeCesiumPreview(area) {
|
|||||||
inputs: {
|
inputs: {
|
||||||
config: fileRecord(configPath),
|
config: fileRecord(configPath),
|
||||||
osm: fileRecord(area.input),
|
osm: fileRecord(area.input),
|
||||||
glb: fileRecord(area.outputs.glb),
|
glb: fileRecord(area.outputs.packagePrimaryGlb),
|
||||||
metadata: fileRecord(area.outputs.metadata),
|
metadata: fileRecord(area.outputs.packageManifest),
|
||||||
lanePolygons: fileRecord(lanePolygons),
|
lanePolygons: fileRecord(lanePolygons),
|
||||||
network: fileRecord(network),
|
network: fileRecord(network),
|
||||||
intersectionSurface: fileRecord(intersectionSurface),
|
intersectionSurface: fileRecord(intersectionSurface),
|
||||||
@@ -537,7 +531,7 @@ function writeCesiumPreview(area) {
|
|||||||
cesiumPreview: fileRecord(area.outputs.cesiumPreview),
|
cesiumPreview: fileRecord(area.outputs.cesiumPreview),
|
||||||
vehicleRoute: fileRecord(area.outputs.vehicleRoute),
|
vehicleRoute: fileRecord(area.outputs.vehicleRoute),
|
||||||
vehicleModel: fileRecord(area.outputs.vehicleModel),
|
vehicleModel: fileRecord(area.outputs.vehicleModel),
|
||||||
trafficSignals: fileRecord(area.outputs.trafficSignals),
|
trafficSignals: fileRecord(area.outputs.packageTrafficSignals),
|
||||||
},
|
},
|
||||||
summary: previewSummary(area),
|
summary: previewSummary(area),
|
||||||
warnings: [],
|
warnings: [],
|
||||||
|
|||||||
+6
-11
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Experimental GLB compression wrapper. Keeps the source GLB intact and writes
|
// GLB compression wrapper. The caller supplies distinct input and output files;
|
||||||
// a separate compressed artifact for visual comparison in Cesium.
|
// build-area.js uses staging files before promoting the compressed delivery.
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
@@ -143,30 +143,25 @@ function previewOutputPath(output, explicitPath) {
|
|||||||
function writeCompressedMetadata(sourceMetadata, outputGlb, outputMetadata) {
|
function writeCompressedMetadata(sourceMetadata, outputGlb, outputMetadata) {
|
||||||
const metadata = JSON.parse(fs.readFileSync(sourceMetadata, "utf8"));
|
const metadata = JSON.parse(fs.readFileSync(sourceMetadata, "utf8"));
|
||||||
const glbName = path.basename(outputGlb);
|
const glbName = path.basename(outputGlb);
|
||||||
metadata.asset = glbName;
|
if (metadata.asset !== undefined) metadata.asset = glbName;
|
||||||
const assets = Array.isArray(metadata.assets) ? metadata.assets : [];
|
const assets = Array.isArray(metadata.assets) ? metadata.assets : [];
|
||||||
const main = assets.find((asset) => asset.id === "main");
|
const main = assets.find((asset) => asset.id === "main");
|
||||||
metadata.assets = assets.length
|
metadata.assets = assets.length
|
||||||
? assets.map((asset) => asset.id === "main" ? {
|
? assets.map((asset) => asset.id === "main" ? {
|
||||||
...asset,
|
...asset,
|
||||||
label: "Compressed Scene",
|
label: "Compressed Scene",
|
||||||
url: glbName,
|
...(Object.hasOwn(asset, "uri") ? { uri: `models/${glbName}`, defaultLoad: true } : { url: glbName, enabled: true }),
|
||||||
enabled: true,
|
|
||||||
} : asset)
|
} : asset)
|
||||||
: [{
|
: [{
|
||||||
id: "main",
|
id: "main",
|
||||||
label: "Compressed Scene",
|
label: "Compressed Scene",
|
||||||
type: "model",
|
role: "scene", category: "scene", uri: `models/${glbName}`, defaultLoad: true,
|
||||||
url: glbName,
|
|
||||||
enabled: true,
|
|
||||||
}];
|
}];
|
||||||
if (!main && assets.length) {
|
if (!main && assets.length) {
|
||||||
metadata.assets.unshift({
|
metadata.assets.unshift({
|
||||||
id: "main",
|
id: "main",
|
||||||
label: "Compressed Scene",
|
label: "Compressed Scene",
|
||||||
type: "model",
|
role: "scene", category: "scene", uri: `models/${glbName}`, defaultLoad: true,
|
||||||
url: glbName,
|
|
||||||
enabled: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (typeof metadata.cesium_js === "string") {
|
if (typeof metadata.cesium_js === "string") {
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const { spawnSync } = require("child_process");
|
||||||
|
const { STAGES, resolveStages, canonicalStages } = require("./lib/build-stages");
|
||||||
|
|
||||||
|
const repoRoot = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
|
function areaConfigs() {
|
||||||
|
return fs.readdirSync(path.join(repoRoot, "config", "areas"))
|
||||||
|
.filter((file) => file.endsWith(".json"))
|
||||||
|
.sort()
|
||||||
|
.map((file) => path.join(repoRoot, "config", "areas", file));
|
||||||
|
}
|
||||||
|
|
||||||
|
function requireTty(input = process.stdin, output = process.stdout) {
|
||||||
|
if (!input.isTTY || !output.isTTY) throw new Error("Interactive build requires a TTY. Use npm run build:area -- --config <area> --stages <stages> instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
requireTty();
|
||||||
|
const configs = areaConfigs();
|
||||||
|
if (!configs.length) throw new Error("No area configs found in config/areas.");
|
||||||
|
const { select, checkbox } = await import("@inquirer/prompts");
|
||||||
|
const config = await select({
|
||||||
|
message: "Choose an area",
|
||||||
|
choices: configs.map((file) => ({ name: path.basename(file, ".json"), value: file })),
|
||||||
|
});
|
||||||
|
const chosen = await checkbox({
|
||||||
|
message: "Choose build stages",
|
||||||
|
choices: STAGES.map((stage) => ({ name: `${stage.id} - ${stage.description}`, value: stage.id })),
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
if (!chosen.length) throw new Error("Choose at least one build stage.");
|
||||||
|
const stages = canonicalStages(resolveStages({}, chosen));
|
||||||
|
console.log(`Area: ${path.basename(config)}`);
|
||||||
|
console.log(`Stages: ${stages.join(", ")}`);
|
||||||
|
const result = spawnSync(process.execPath, [path.join(__dirname, "build-area.js"), "--config", config, "--stages", stages.join(",")], { stdio: "inherit" });
|
||||||
|
if (result.error) throw result.error;
|
||||||
|
process.exitCode = result.status || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require.main === module) main().catch((error) => {
|
||||||
|
if (error.name !== "ExitPromptError") console.error(`Error: ${error.message}`);
|
||||||
|
process.exitCode = error.name === "ExitPromptError" ? 0 : 1;
|
||||||
|
});
|
||||||
|
module.exports = { areaConfigs, requireTty };
|
||||||
+29
-22
@@ -25,9 +25,12 @@ function normalizeAreaConfig(raw, options = {}) {
|
|||||||
const fileStem = outputOverrides.fileStem || id;
|
const fileStem = outputOverrides.fileStem || id;
|
||||||
const compress = normalizeCompressConfig(raw.compress);
|
const compress = normalizeCompressConfig(raw.compress);
|
||||||
const budget = normalizeBudgetConfig(raw.budget);
|
const budget = normalizeBudgetConfig(raw.budget);
|
||||||
const compressedFileStem = outputOverrides.compressedFileStem ||
|
|
||||||
`${fileStem}-compressed-webp${compress.textureSize}${compress.meshopt ? "-meshopt" : ""}`;
|
|
||||||
const pipelineDir = path.resolve(outputOverrides.pipelineDir || path.join(areaDir, "_pipeline"));
|
const pipelineDir = path.resolve(outputOverrides.pipelineDir || path.join(areaDir, "_pipeline"));
|
||||||
|
const packageDir = path.resolve(outputOverrides.packageDir || path.join(areaDir, "package"));
|
||||||
|
const packageStagingDir = path.resolve(outputOverrides.packageStagingDir || path.join(pipelineDir, "package-staging"));
|
||||||
|
const packageRuntimeDir = path.resolve(outputOverrides.packageRuntimeDir || path.join(packageDir, "runtime"));
|
||||||
|
const packageStagingRuntimeDir = path.resolve(outputOverrides.packageStagingRuntimeDir || path.join(packageStagingDir, "runtime"));
|
||||||
|
const previewDir = path.resolve(outputOverrides.previewDir || path.join(areaDir, "_preview"));
|
||||||
const geojsonDir = path.resolve(outputOverrides.geojsonDir || path.join(areaDir, "osm2streets_web_out"));
|
const geojsonDir = path.resolve(outputOverrides.geojsonDir || path.join(areaDir, "osm2streets_web_out"));
|
||||||
const outputs = {
|
const outputs = {
|
||||||
areaDir,
|
areaDir,
|
||||||
@@ -37,27 +40,30 @@ function normalizeAreaConfig(raw, options = {}) {
|
|||||||
qgisPreview: path.resolve(outputOverrides.qgisPreview || path.join(areaDir, `${fileStem}-preview.png`)),
|
qgisPreview: path.resolve(outputOverrides.qgisPreview || path.join(areaDir, `${fileStem}-preview.png`)),
|
||||||
blend: path.resolve(outputOverrides.blend || path.join(areaDir, `${fileStem}.blend`)),
|
blend: path.resolve(outputOverrides.blend || path.join(areaDir, `${fileStem}.blend`)),
|
||||||
render: path.resolve(outputOverrides.render || path.join(areaDir, `${fileStem}.png`)),
|
render: path.resolve(outputOverrides.render || path.join(areaDir, `${fileStem}.png`)),
|
||||||
glb: path.resolve(outputOverrides.glb || path.join(areaDir, `${fileStem}.glb`)),
|
// Published static assets are staged first and promoted by the package stage.
|
||||||
trafficSignalsDynamicGlb: path.resolve(
|
packageDir,
|
||||||
outputOverrides.trafficSignalsDynamicGlb || path.join(areaDir, `${fileStem}-traffic-signals-dynamic.glb`),
|
packageStagingDir,
|
||||||
),
|
packageManifest: path.resolve(outputOverrides.packageManifest || path.join(packageDir, "manifest.json")),
|
||||||
trafficSignalsCountdown0Glb: path.resolve(outputOverrides.trafficSignalsCountdown0Glb || path.join(areaDir, `${fileStem}-traffic-signals-countdown-0.glb`)),
|
packageStagingManifest: path.resolve(outputOverrides.packageStagingManifest || path.join(packageStagingDir, "manifest.json")),
|
||||||
trafficSignalsCountdown1Glb: path.resolve(outputOverrides.trafficSignalsCountdown1Glb || path.join(areaDir, `${fileStem}-traffic-signals-countdown-1.glb`)),
|
packageModelDir: path.resolve(outputOverrides.packageModelDir || path.join(packageDir, "models")),
|
||||||
metadata: path.resolve(outputOverrides.metadata || path.join(areaDir, `${fileStem}.json`)),
|
packageStagingModelDir: path.resolve(outputOverrides.packageStagingModelDir || path.join(packageStagingDir, "models")),
|
||||||
|
packagePrimaryGlb: path.resolve(outputOverrides.packagePrimaryGlb || path.join(packageDir, "models", `${fileStem}.glb`)),
|
||||||
|
glb: path.resolve(outputOverrides.glb || path.join(packageStagingDir, "models", `${fileStem}.glb`)),
|
||||||
|
packageRuntimeDir,
|
||||||
|
packageStagingRuntimeDir,
|
||||||
|
trafficSignalsDynamicGlb: path.resolve(outputOverrides.trafficSignalsDynamicGlb || path.join(packageStagingRuntimeDir, "traffic-signals-dynamic.glb")),
|
||||||
|
trafficSignalsCountdown0Glb: path.resolve(outputOverrides.trafficSignalsCountdown0Glb || path.join(packageStagingRuntimeDir, "traffic-signals-countdown-0.glb")),
|
||||||
|
trafficSignalsCountdown1Glb: path.resolve(outputOverrides.trafficSignalsCountdown1Glb || path.join(packageStagingRuntimeDir, "traffic-signals-countdown-1.glb")),
|
||||||
|
packageTrafficSignals: path.resolve(outputOverrides.packageTrafficSignals || path.join(packageRuntimeDir, "traffic-signals.json")),
|
||||||
|
packageStagingTrafficSignals: path.resolve(outputOverrides.packageStagingTrafficSignals || path.join(packageStagingRuntimeDir, "traffic-signals.json")),
|
||||||
|
metadata: path.resolve(outputOverrides.metadata || path.join(packageStagingDir, "manifest.json")),
|
||||||
cesiumPreview: path.resolve(
|
cesiumPreview: path.resolve(
|
||||||
outputOverrides.cesiumPreview || path.join(areaDir, `${fileStem}-cesium-preview.html`),
|
outputOverrides.cesiumPreview || path.join(areaDir, `${fileStem}-cesium-preview.html`),
|
||||||
),
|
),
|
||||||
compressedGlb: path.resolve(
|
previewDir,
|
||||||
outputOverrides.compressedGlb || path.join(areaDir, `${compressedFileStem}.glb`),
|
previewDescriptor: path.resolve(outputOverrides.previewDescriptor || path.join(previewDir, "descriptor.json")),
|
||||||
),
|
vehicleRoute: path.resolve(outputOverrides.vehicleRoute || path.join(previewDir, `${fileStem}-vehicle-route.json`)),
|
||||||
compressedMetadata: path.resolve(
|
vehicleModel: path.resolve(outputOverrides.vehicleModel || path.join(previewDir, `${fileStem}-vehicle-car.gltf`)),
|
||||||
outputOverrides.compressedMetadata || path.join(areaDir, `${compressedFileStem}.json`),
|
|
||||||
),
|
|
||||||
compressedCesiumPreview: path.resolve(
|
|
||||||
outputOverrides.compressedCesiumPreview || path.join(areaDir, `${compressedFileStem}-cesium-preview.html`),
|
|
||||||
),
|
|
||||||
vehicleRoute: path.resolve(outputOverrides.vehicleRoute || path.join(areaDir, `${fileStem}-vehicle-route.json`)),
|
|
||||||
vehicleModel: path.resolve(outputOverrides.vehicleModel || path.join(areaDir, `${fileStem}-vehicle-car.gltf`)),
|
|
||||||
trafficSignalAssemblies: path.resolve(
|
trafficSignalAssemblies: path.resolve(
|
||||||
outputOverrides.trafficSignalAssemblies || path.join(geojsonDir, "traffic_signal_assemblies.geojson"),
|
outputOverrides.trafficSignalAssemblies || path.join(geojsonDir, "traffic_signal_assemblies.geojson"),
|
||||||
),
|
),
|
||||||
@@ -79,8 +85,9 @@ function normalizeAreaConfig(raw, options = {}) {
|
|||||||
blender: raw.stages?.blender ?? true,
|
blender: raw.stages?.blender ?? true,
|
||||||
cesium: raw.stages?.cesium ?? true,
|
cesium: raw.stages?.cesium ?? true,
|
||||||
reimport: false,
|
reimport: false,
|
||||||
preview: false,
|
preview: true,
|
||||||
compress: false,
|
compress: true,
|
||||||
|
package: true,
|
||||||
},
|
},
|
||||||
qgis: {
|
qgis: {
|
||||||
arrowScale: raw.qgis?.arrowScale ?? raw.arrowScale ?? 0.8,
|
arrowScale: raw.qgis?.arrowScale ?? raw.arrowScale ?? 0.8,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const {
|
|||||||
layerFile,
|
layerFile,
|
||||||
} = require("./scene-layers");
|
} = require("./scene-layers");
|
||||||
const { digest: glbDigest } = require("../glb-digest");
|
const { digest: glbDigest } = require("../glb-digest");
|
||||||
|
const { validateManifest } = require("./package-contract");
|
||||||
const {
|
const {
|
||||||
BUDGETS,
|
BUDGETS,
|
||||||
evaluateGlbBudget,
|
evaluateGlbBudget,
|
||||||
@@ -31,8 +32,8 @@ function analyzeArea(configPath, options = {}) {
|
|||||||
const artifacts = artifactStatus(area);
|
const artifacts = artifactStatus(area);
|
||||||
const manifests = stageManifestStatus(area, resolvedConfig);
|
const manifests = stageManifestStatus(area, resolvedConfig);
|
||||||
const metadataWarnings = [];
|
const metadataWarnings = [];
|
||||||
const metadata = metadataSummary(area.outputs.metadata, metadataWarnings);
|
const metadata = metadataSummary(area.outputs.packageManifest, metadataWarnings);
|
||||||
const glb = fs.existsSync(area.outputs.glb) ? glbDigest(area.outputs.glb) : null;
|
const glb = fs.existsSync(area.outputs.packagePrimaryGlb) ? glbDigest(area.outputs.packagePrimaryGlb) : null;
|
||||||
const warnings = [
|
const warnings = [
|
||||||
...metadataWarnings,
|
...metadataWarnings,
|
||||||
...collectWarnings(area, osm, artifacts, manifests, glb, metadata),
|
...collectWarnings(area, osm, artifacts, manifests, glb, metadata),
|
||||||
@@ -328,15 +329,12 @@ function artifactStatus(area) {
|
|||||||
["QGIS project", area.outputs.qgisProject, true, "file"],
|
["QGIS project", area.outputs.qgisProject, true, "file"],
|
||||||
["QGIS preview", area.outputs.qgisPreview, true, "file"],
|
["QGIS preview", area.outputs.qgisPreview, true, "file"],
|
||||||
["Traffic signal assemblies", area.outputs.trafficSignalAssemblies, true, "file"],
|
["Traffic signal assemblies", area.outputs.trafficSignalAssemblies, true, "file"],
|
||||||
["Traffic signal runtime", area.outputs.trafficSignals, true, "file"],
|
["Traffic signal runtime", area.outputs.packageTrafficSignals, true, "file"],
|
||||||
["Blend scene", area.outputs.blend, true, "file"],
|
["Blend scene", area.outputs.blend, true, "file"],
|
||||||
["Render PNG", area.outputs.render, true, "file"],
|
["Render PNG", area.outputs.render, true, "file"],
|
||||||
["Cesium GLB", area.outputs.glb, true, "file"],
|
["Package manifest", area.outputs.packageManifest, true, "file"],
|
||||||
["Cesium metadata", area.outputs.metadata, true, "file"],
|
["Package primary GLB", area.outputs.packagePrimaryGlb, true, "file"],
|
||||||
["Cesium preview", area.outputs.cesiumPreview, true, "file"],
|
["Cesium preview", area.outputs.cesiumPreview, true, "file"],
|
||||||
["Compressed GLB", area.outputs.compressedGlb, false, "file"],
|
|
||||||
["Compressed metadata", area.outputs.compressedMetadata, false, "file"],
|
|
||||||
["Compressed preview", area.outputs.compressedCesiumPreview, false, "file"],
|
|
||||||
];
|
];
|
||||||
return entries.map(([label, file, expected, type]) => {
|
return entries.map(([label, file, expected, type]) => {
|
||||||
const exists = fs.existsSync(file);
|
const exists = fs.existsSync(file);
|
||||||
@@ -362,6 +360,7 @@ function metadataSummary(file, warnings) {
|
|||||||
if (!fs.existsSync(file)) return null;
|
if (!fs.existsSync(file)) return null;
|
||||||
try {
|
try {
|
||||||
const metadata = JSON.parse(fs.readFileSync(file, "utf8"));
|
const metadata = JSON.parse(fs.readFileSync(file, "utf8"));
|
||||||
|
if (metadata.schema === "osm-asset-package/v1") validateManifest(metadata, path.dirname(file));
|
||||||
return {
|
return {
|
||||||
asset: metadata.asset || null,
|
asset: metadata.asset || null,
|
||||||
assets: Array.isArray(metadata.assets) ? metadata.assets.length : 0,
|
assets: Array.isArray(metadata.assets) ? metadata.assets.length : 0,
|
||||||
@@ -374,6 +373,7 @@ function metadataSummary(file, warnings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stageManifestStatus(area, configPath = null) {
|
function stageManifestStatus(area, configPath = null) {
|
||||||
|
const compressionComplete = fs.existsSync(stageManifestPath(area, "compress"));
|
||||||
const reimportManifest = stageManifestPath(area, "reimport");
|
const reimportManifest = stageManifestPath(area, "reimport");
|
||||||
const hasReimportManifest = fs.existsSync(reimportManifest);
|
const hasReimportManifest = fs.existsSync(reimportManifest);
|
||||||
const derivedConfig = path.join(area.outputs.pipelineDir, "osm2streets-qgis.config.json");
|
const derivedConfig = path.join(area.outputs.pipelineDir, "osm2streets-qgis.config.json");
|
||||||
@@ -403,7 +403,7 @@ function stageManifestStatus(area, configPath = null) {
|
|||||||
geojsonDir: area.outputs.geojsonDir,
|
geojsonDir: area.outputs.geojsonDir,
|
||||||
...sceneGeojsonFiles(area),
|
...sceneGeojsonFiles(area),
|
||||||
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
|
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
|
||||||
trafficSignals: area.outputs.trafficSignals,
|
trafficSignals: area.outputs.packageTrafficSignals,
|
||||||
gpkg: area.outputs.gpkg,
|
gpkg: area.outputs.gpkg,
|
||||||
qgisProject: area.outputs.qgisProject,
|
qgisProject: area.outputs.qgisProject,
|
||||||
qgisPreview: optionalExpectedFile(area.outputs.qgisPreview),
|
qgisPreview: optionalExpectedFile(area.outputs.qgisPreview),
|
||||||
@@ -421,7 +421,7 @@ function stageManifestStatus(area, configPath = null) {
|
|||||||
geojsonDir: area.outputs.geojsonDir,
|
geojsonDir: area.outputs.geojsonDir,
|
||||||
...sceneGeojsonFiles(area),
|
...sceneGeojsonFiles(area),
|
||||||
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
|
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
|
||||||
trafficSignals: area.outputs.trafficSignals,
|
trafficSignals: area.outputs.packageTrafficSignals,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -433,7 +433,7 @@ function stageManifestStatus(area, configPath = null) {
|
|||||||
geojsonDir: area.outputs.geojsonDir,
|
geojsonDir: area.outputs.geojsonDir,
|
||||||
...sceneGeojsonFiles(area),
|
...sceneGeojsonFiles(area),
|
||||||
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
|
trafficSignalAssemblies: area.outputs.trafficSignalAssemblies,
|
||||||
trafficSignals: area.outputs.trafficSignals,
|
trafficSignals: area.outputs.packageTrafficSignals,
|
||||||
},
|
},
|
||||||
outputs: {
|
outputs: {
|
||||||
blend: area.outputs.blend,
|
blend: area.outputs.blend,
|
||||||
@@ -446,7 +446,7 @@ function stageManifestStatus(area, configPath = null) {
|
|||||||
inputs: {
|
inputs: {
|
||||||
blend: area.outputs.blend,
|
blend: area.outputs.blend,
|
||||||
},
|
},
|
||||||
outputs: {
|
outputs: compressionComplete ? {} : {
|
||||||
glb: area.outputs.glb,
|
glb: area.outputs.glb,
|
||||||
metadata: area.outputs.metadata,
|
metadata: area.outputs.metadata,
|
||||||
},
|
},
|
||||||
@@ -457,15 +457,20 @@ function stageManifestStatus(area, configPath = null) {
|
|||||||
inputs: {
|
inputs: {
|
||||||
...(configPath ? { config: configPath } : {}),
|
...(configPath ? { config: configPath } : {}),
|
||||||
osm: area.input,
|
osm: area.input,
|
||||||
glb: area.outputs.glb,
|
...(compressionComplete ? {} : {
|
||||||
metadata: area.outputs.metadata,
|
glb: area.outputs.glb,
|
||||||
|
metadata: area.outputs.metadata,
|
||||||
|
}),
|
||||||
lanePolygons: path.join(area.outputs.geojsonDir, "lane_polygons.geojson"),
|
lanePolygons: path.join(area.outputs.geojsonDir, "lane_polygons.geojson"),
|
||||||
network: path.join(area.outputs.geojsonDir, "network.json"),
|
network: path.join(area.outputs.geojsonDir, "network.json"),
|
||||||
intersectionSurface: path.join(area.outputs.geojsonDir, "intersection_surface.geojson"),
|
intersectionSurface: path.join(area.outputs.geojsonDir, "intersection_surface.geojson"),
|
||||||
previewCss: path.join(path.resolve(__dirname, ".."), "lib", "cesium-preview.css"),
|
previewCss: path.join(path.resolve(__dirname, ".."), "lib", "cesium-preview.css"),
|
||||||
previewJs: path.join(path.resolve(__dirname, ".."), "lib", "cesium-preview.js"),
|
previewJs: path.join(path.resolve(__dirname, ".."), "lib", "cesium-preview.js"),
|
||||||
},
|
},
|
||||||
outputs: {
|
outputs: compressionComplete ? {
|
||||||
|
vehicleRoute: area.outputs.vehicleRoute,
|
||||||
|
vehicleModel: area.outputs.vehicleModel,
|
||||||
|
} : {
|
||||||
cesiumPreview: area.outputs.cesiumPreview,
|
cesiumPreview: area.outputs.cesiumPreview,
|
||||||
vehicleRoute: area.outputs.vehicleRoute,
|
vehicleRoute: area.outputs.vehicleRoute,
|
||||||
vehicleModel: area.outputs.vehicleModel,
|
vehicleModel: area.outputs.vehicleModel,
|
||||||
@@ -473,16 +478,18 @@ function stageManifestStatus(area, configPath = null) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
stage: "compress",
|
stage: "compress",
|
||||||
expected: fs.existsSync(area.outputs.compressedGlb),
|
expected: fs.existsSync(stageManifestPath(area, "compress")),
|
||||||
inputs: {
|
inputs: {},
|
||||||
glb: area.outputs.glb,
|
outputs: {},
|
||||||
metadata: area.outputs.metadata,
|
},
|
||||||
cesiumPreview: area.outputs.cesiumPreview,
|
{
|
||||||
},
|
stage: "package",
|
||||||
|
expected: fs.existsSync(area.outputs.packageManifest),
|
||||||
|
inputs: {},
|
||||||
outputs: {
|
outputs: {
|
||||||
compressedGlb: area.outputs.compressedGlb,
|
packageDir: area.outputs.packageDir,
|
||||||
compressedMetadata: area.outputs.compressedMetadata,
|
manifest: area.outputs.packageManifest,
|
||||||
compressedCesiumPreview: area.outputs.compressedCesiumPreview,
|
primaryGlb: area.outputs.packagePrimaryGlb,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -749,7 +756,7 @@ function classifyAreaQuality(result) {
|
|||||||
warnings.push(`OSM ways reference ${osm.ways.missingNodeRefs} missing node(s).`);
|
warnings.push(`OSM ways reference ${osm.ways.missingNodeRefs} missing node(s).`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fatalArtifacts = new Set(["Cesium GLB", "Cesium metadata", "Cesium preview"]);
|
const fatalArtifacts = new Set(["Package manifest", "Package primary GLB", "Cesium preview"]);
|
||||||
for (const artifact of artifacts) {
|
for (const artifact of artifacts) {
|
||||||
if (fatalArtifacts.has(artifact.label)) {
|
if (fatalArtifacts.has(artifact.label)) {
|
||||||
if (!artifact.exists) {
|
if (!artifact.exists) {
|
||||||
|
|||||||
@@ -4,8 +4,13 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
function writeCesiumPreviewSupportFiles(outDir) {
|
function writeCesiumPreviewSupportFiles(outDir) {
|
||||||
for (const file of ["cesium-preview.css", "cesium-preview.js"]) {
|
const files = [
|
||||||
const source = path.join(__dirname, file);
|
[path.join(__dirname, "cesium-preview.css"), "cesium-preview.css"],
|
||||||
|
[path.join(__dirname, "cesium-preview.js"), "cesium-preview.js"],
|
||||||
|
[path.join(__dirname, "..", "..", "assets", "preview", "vehicle-breakdown.png"), "vehicle-breakdown.png"],
|
||||||
|
[path.join(__dirname, "..", "..", "assets", "preview", "vehicle-accident.png"), "vehicle-accident.png"],
|
||||||
|
];
|
||||||
|
for (const [source, file] of files) {
|
||||||
if (!fs.existsSync(source)) {
|
if (!fs.existsSync(source)) {
|
||||||
throw new Error(`Cesium preview support file '${file}' not found: ${source}`);
|
throw new Error(`Cesium preview support file '${file}' not found: ${source}`);
|
||||||
}
|
}
|
||||||
@@ -13,7 +18,7 @@ function writeCesiumPreviewSupportFiles(outDir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cesiumPreviewHtml(glbName, metadataName, routeName, vehicleModelName, areaId, vehicleModelNames = [], trafficSignalsName = null) {
|
function cesiumPreviewHtml(glbName, metadataName, routeName, vehicleModelName, areaId, vehicleModelNames = [], trafficSignalsName = null, previewDescriptorName = null) {
|
||||||
const previewConfig = {
|
const previewConfig = {
|
||||||
areaId,
|
areaId,
|
||||||
glbName,
|
glbName,
|
||||||
@@ -22,6 +27,7 @@ function cesiumPreviewHtml(glbName, metadataName, routeName, vehicleModelName, a
|
|||||||
vehicleModelName,
|
vehicleModelName,
|
||||||
vehicleModelNames,
|
vehicleModelNames,
|
||||||
trafficSignalsName,
|
trafficSignalsName,
|
||||||
|
previewDescriptorName,
|
||||||
};
|
};
|
||||||
return `<!doctype html>
|
return `<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
@@ -68,6 +74,21 @@ function cesiumPreviewHtml(glbName, metadataName, routeName, vehicleModelName, a
|
|||||||
</div>
|
</div>
|
||||||
<div id="diagnostics">Loading diagnostics...</div>
|
<div id="diagnostics">Loading diagnostics...</div>
|
||||||
<div id="status">Loading ${escapeHtml(glbName)}...</div>
|
<div id="status">Loading ${escapeHtml(glbName)}...</div>
|
||||||
|
<aside id="vehicleInfoCard" class="hidden" aria-live="polite">
|
||||||
|
<div class="vehicle-card-heading">
|
||||||
|
<strong id="vehicleInfoTitle">Vehicle</strong>
|
||||||
|
<button id="closeVehicleInfo" type="button" aria-label="Close vehicle information">Close</button>
|
||||||
|
</div>
|
||||||
|
<dl id="vehicleInfoDetails"></dl>
|
||||||
|
<label class="vehicle-card-field">Event note
|
||||||
|
<textarea id="vehicleIncidentNote" rows="2" maxlength="160" placeholder="Optional note"></textarea>
|
||||||
|
</label>
|
||||||
|
<div class="vehicle-card-actions" role="group" aria-label="Vehicle status">
|
||||||
|
<button type="button" data-vehicle-status="normal">Normal</button>
|
||||||
|
<button type="button" data-vehicle-status="breakdown">Breakdown</button>
|
||||||
|
<button type="button" data-vehicle-status="accident">Accident</button>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
<div id="loadingOverlay">
|
<div id="loadingOverlay">
|
||||||
<div class="loading-card">
|
<div class="loading-card">
|
||||||
<div class="loading-spinner" aria-hidden="true"></div>
|
<div class="loading-spinner" aria-hidden="true"></div>
|
||||||
@@ -105,11 +126,11 @@ function escapeScriptJson(value) {
|
|||||||
function previewSummary(area) {
|
function previewSummary(area) {
|
||||||
const route = JSON.parse(fs.readFileSync(area.outputs.vehicleRoute, "utf8"));
|
const route = JSON.parse(fs.readFileSync(area.outputs.vehicleRoute, "utf8"));
|
||||||
return {
|
return {
|
||||||
glbName: path.basename(area.outputs.glb),
|
glbName: "package/manifest.json",
|
||||||
metadataName: path.basename(area.outputs.metadata),
|
metadataName: "package/manifest.json",
|
||||||
routeName: path.basename(area.outputs.vehicleRoute),
|
routeName: path.relative(area.outputs.areaDir, area.outputs.vehicleRoute).split(path.sep).join("/"),
|
||||||
vehicleModelName: path.basename(area.outputs.vehicleModel),
|
vehicleModelName: path.relative(area.outputs.areaDir, area.outputs.vehicleModel).split(path.sep).join("/"),
|
||||||
trafficSignalsName: path.relative(area.outputs.areaDir, area.outputs.trafficSignals).split(path.sep).join("/"),
|
trafficSignalsName: "package/runtime/traffic-signals.json",
|
||||||
routeSegments: Array.isArray(route.segments) ? route.segments.length : null,
|
routeSegments: Array.isArray(route.segments) ? route.segments.length : null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const STAGES = [
|
||||||
|
{ id: "intermediates", label: "OSM / QGIS intermediates", description: "Rebuild GeoJSON and GeoPackage from OSM" },
|
||||||
|
{ id: "reimport", label: "Reimport QGIS edits", description: "Copy GeoPackage layers back to GeoJSON" },
|
||||||
|
{ id: "blender", label: "Blender scene", description: "Generate the editable scene and render" },
|
||||||
|
{ id: "cesium", label: "Cesium export", description: "Export static package staging assets" },
|
||||||
|
{ id: "compress", label: "Compress staged package", description: "Compress the staged primary GLB" },
|
||||||
|
{ id: "package", label: "Publish asset package", description: "Validate and atomically publish package/" },
|
||||||
|
{ id: "preview", label: "Preview refresh", description: "Regenerate local verification preview and dynamic assets" },
|
||||||
|
];
|
||||||
|
|
||||||
|
const ALIASES = {
|
||||||
|
all: ["intermediates", "blender", "cesium", "compress", "package", "preview"],
|
||||||
|
qgis: ["intermediates"], osm2streets: ["intermediates"], geojson: ["intermediates"], intermediate: ["intermediates"],
|
||||||
|
intermediates: ["intermediates"], reimport: ["reimport"], gpkg: ["reimport"], blender: ["blender"], scene: ["blender"],
|
||||||
|
cesium: ["cesium"], glb: ["cesium"], preview: ["preview"], html: ["preview"], cesiumPreview: ["preview"],
|
||||||
|
compress: ["compress"], compression: ["compress"], compressedCesium: ["compress"],
|
||||||
|
package: ["package"], publish: ["package"], assetPackage: ["package"],
|
||||||
|
};
|
||||||
|
|
||||||
|
function resolveStages(defaults, requested) {
|
||||||
|
const selected = requested || Object.keys(defaults).filter((key) => defaults[key]);
|
||||||
|
const result = Object.fromEntries(STAGES.map(({ id }) => [id, false]));
|
||||||
|
for (const stage of selected) {
|
||||||
|
const mapped = ALIASES[stage];
|
||||||
|
if (!mapped) throw new Error(`Unknown stage '${stage}'. Use ${stageNames().join(", ")}, or all.`);
|
||||||
|
for (const id of mapped) result[id] = true;
|
||||||
|
}
|
||||||
|
assertCompatible(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertCompatible(stages) {
|
||||||
|
if (stages.intermediates && stages.reimport) {
|
||||||
|
throw new Error("Stages 'intermediates' and 'reimport' are mutually exclusive: intermediates rebuilds the GeoPackage from OSM and would discard the QGIS edits reimport reads back.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stageNames() { return STAGES.map(({ id }) => id); }
|
||||||
|
function canonicalStages(stages) { return stageNames().filter((id) => stages[id]); }
|
||||||
|
|
||||||
|
module.exports = { STAGES, resolveStages, canonicalStages, stageNames };
|
||||||
@@ -20,7 +20,8 @@ body.scene-ready #cesiumContainer {
|
|||||||
|
|
||||||
#controls,
|
#controls,
|
||||||
#diagnostics,
|
#diagnostics,
|
||||||
#status {
|
#status,
|
||||||
|
#vehicleInfoCard {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
@@ -160,6 +161,96 @@ body.scene-error .loading-bar span {
|
|||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#vehicleInfoCard {
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: min(300px, calc(100vw - 24px));
|
||||||
|
padding: 10px 12px;
|
||||||
|
transform: translate(-50%, calc(-100% - 18px));
|
||||||
|
transform-origin: bottom center;
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#vehicleInfoCard::after {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
bottom: -7px;
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
content: "";
|
||||||
|
transform: translateX(-50%) rotate(45deg);
|
||||||
|
background: rgba(20, 24, 28, 0.82);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vehicle-card-heading,
|
||||||
|
.vehicle-card-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vehicle-card-heading strong {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#vehicleInfoCard button {
|
||||||
|
height: 27px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 0 8px;
|
||||||
|
background: #f2f5f7;
|
||||||
|
color: #111;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#vehicleInfoDetails {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 88px 1fr;
|
||||||
|
gap: 4px 8px;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#vehicleInfoDetails dt {
|
||||||
|
color: rgba(255, 255, 255, 0.62);
|
||||||
|
}
|
||||||
|
|
||||||
|
#vehicleInfoDetails dd {
|
||||||
|
margin: 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vehicle-card-field {
|
||||||
|
display: grid;
|
||||||
|
gap: 4px;
|
||||||
|
color: rgba(255, 255, 255, 0.78);
|
||||||
|
}
|
||||||
|
|
||||||
|
#vehicleIncidentNote {
|
||||||
|
box-sizing: border-box;
|
||||||
|
width: 100%;
|
||||||
|
resize: vertical;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.30);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 6px;
|
||||||
|
background: rgba(255, 255, 255, 0.12);
|
||||||
|
color: #fff;
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vehicle-card-actions {
|
||||||
|
justify-content: flex-start;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vehicle-card-actions button[data-vehicle-status="breakdown"] {
|
||||||
|
background: #f3c84b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vehicle-card-actions button[data-vehicle-status="accident"] {
|
||||||
|
background: #e95950;
|
||||||
|
}
|
||||||
|
|
||||||
#controls button,
|
#controls button,
|
||||||
#controls select {
|
#controls select {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
@@ -285,4 +376,5 @@ body.scene-error .loading-bar span {
|
|||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,12 @@
|
|||||||
const toggleFps = document.getElementById("toggleFps");
|
const toggleFps = document.getElementById("toggleFps");
|
||||||
const toggleDiagnostics = document.getElementById("toggleDiagnostics");
|
const toggleDiagnostics = document.getElementById("toggleDiagnostics");
|
||||||
const assetToggles = document.getElementById("assetToggles");
|
const assetToggles = document.getElementById("assetToggles");
|
||||||
|
const vehicleInfoCard = document.getElementById("vehicleInfoCard");
|
||||||
|
const vehicleInfoTitle = document.getElementById("vehicleInfoTitle");
|
||||||
|
const vehicleInfoDetails = document.getElementById("vehicleInfoDetails");
|
||||||
|
const vehicleIncidentNote = document.getElementById("vehicleIncidentNote");
|
||||||
|
const closeVehicleInfo = document.getElementById("closeVehicleInfo");
|
||||||
|
const vehicleStatusButtons = Array.from(document.querySelectorAll("[data-vehicle-status]"));
|
||||||
// The exported road surface sits at the 0.35m scene anchor plus 0.03m.
|
// The exported road surface sits at the 0.35m scene anchor plus 0.03m.
|
||||||
// Vehicle models have their wheels at local Y=0, so keep them just clear
|
// Vehicle models have their wheels at local Y=0, so keep them just clear
|
||||||
// of the asphalt instead of using the old visibly floating 1.15m height.
|
// of the asphalt instead of using the old visibly floating 1.15m height.
|
||||||
@@ -40,6 +46,8 @@
|
|||||||
async function main() {
|
async function main() {
|
||||||
setLoadingMessage("Loading scene", config.areaId || "");
|
setLoadingMessage("Loading scene", config.areaId || "");
|
||||||
const metadata = await fetchJson(config.metadataName);
|
const metadata = await fetchJson(config.metadataName);
|
||||||
|
const descriptor = config.previewDescriptorName ? await fetchOptionalJson(config.previewDescriptorName) : null;
|
||||||
|
adaptPackageManifest(metadata, descriptor);
|
||||||
const routeData = await fetchOptionalJson(config.routeName);
|
const routeData = await fetchOptionalJson(config.routeName);
|
||||||
const signalData = await fetchOptionalJson(config.trafficSignalsName);
|
const signalData = await fetchOptionalJson(config.trafficSignalsName);
|
||||||
const placement = scenePlacement(metadata);
|
const placement = scenePlacement(metadata);
|
||||||
@@ -54,6 +62,7 @@
|
|||||||
buildAssetToggles(assets);
|
buildAssetToggles(assets);
|
||||||
buildSemanticToggles(viewer, assets, placement);
|
buildSemanticToggles(viewer, assets, placement);
|
||||||
bindRuntimeControls(viewer, assets, cruise, cameras, placement, trafficSignals);
|
bindRuntimeControls(viewer, assets, cruise, cameras, placement, trafficSignals);
|
||||||
|
bindVehicleInfoCard(viewer, cruise);
|
||||||
startDiagnostics(viewer, metadata, assets, cruise, placement, trafficSignals);
|
startDiagnostics(viewer, metadata, assets, cruise, placement, trafficSignals);
|
||||||
cameras.overview();
|
cameras.overview();
|
||||||
baseStatus = summaryText(metadata, assets, cruise);
|
baseStatus = summaryText(metadata, assets, cruise);
|
||||||
@@ -145,11 +154,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scenePlacement(metadata) {
|
function scenePlacement(metadata) {
|
||||||
const anchor = metadata.anchor || {};
|
const anchor = metadata.anchor || metadata.placement || {};
|
||||||
const longitude = Number(anchor.longitude || 0);
|
const longitude = Number(anchor.longitude || 0);
|
||||||
const latitude = Number(anchor.latitude || 0);
|
const latitude = Number(anchor.latitude || 0);
|
||||||
const height = Number(anchor.height || 0);
|
const height = Number(anchor.height || 0);
|
||||||
const heading = Number(metadata.heading_correction_degrees || 0);
|
const heading = Number(metadata.heading_correction_degrees ?? metadata.placement?.headingCorrectionDegrees ?? 0);
|
||||||
const position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
|
const position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
|
||||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||||
const correction = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(heading));
|
const correction = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(heading));
|
||||||
@@ -164,6 +173,28 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalizedAssets(metadata) {
|
function normalizedAssets(metadata) {
|
||||||
|
if (metadata.schema === "osm-asset-package/v1") {
|
||||||
|
const staticAssets = metadata.assets.map((asset) => ({
|
||||||
|
id: asset.id,
|
||||||
|
label: asset.id,
|
||||||
|
type: "model",
|
||||||
|
// Package URIs are relative to manifest.json, not the preview HTML.
|
||||||
|
url: new URL(asset.uri, new URL(config.metadataName, window.location.href)).href,
|
||||||
|
enabled: asset.defaultLoad,
|
||||||
|
category: asset.category,
|
||||||
|
semantic: asset.role === "layer",
|
||||||
|
}));
|
||||||
|
const runtimeAssets = (metadata.runtime || []).filter((asset) => asset.type !== "traffic-signal-anchors").map((asset) => ({
|
||||||
|
id: asset.id,
|
||||||
|
label: asset.id,
|
||||||
|
type: "model",
|
||||||
|
url: new URL(asset.uri, new URL(config.metadataName, window.location.href)).href,
|
||||||
|
enabled: true,
|
||||||
|
category: asset.type === "traffic-signal-lenses" ? "dynamic" : asset.type === "traffic-signal-countdown" ? "countdown" : asset.type,
|
||||||
|
phaseGroup: asset.phaseGroup,
|
||||||
|
}));
|
||||||
|
return staticAssets.concat(runtimeAssets, metadata.previewAssets || []);
|
||||||
|
}
|
||||||
const assets = Array.isArray(metadata.assets) && metadata.assets.length
|
const assets = Array.isArray(metadata.assets) && metadata.assets.length
|
||||||
? metadata.assets
|
? metadata.assets
|
||||||
: [{
|
: [{
|
||||||
@@ -176,6 +207,15 @@
|
|||||||
return assets.filter((asset) => (asset.type || "model") === "model" && asset.url);
|
return assets.filter((asset) => (asset.type || "model") === "model" && asset.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function adaptPackageManifest(metadata, descriptor) {
|
||||||
|
if (metadata.schema !== "osm-asset-package/v1") return;
|
||||||
|
metadata.anchor = metadata.placement;
|
||||||
|
metadata.heading_correction_degrees = metadata.placement.headingCorrectionDegrees;
|
||||||
|
metadata.scene_stats = metadata.sceneStats || {};
|
||||||
|
metadata.bounds = { min_lon: metadata.bounds.minLon, min_lat: metadata.bounds.minLat, max_lon: metadata.bounds.maxLon, max_lat: metadata.bounds.maxLat };
|
||||||
|
if (descriptor?.assets) metadata.previewAssets = descriptor.assets;
|
||||||
|
}
|
||||||
|
|
||||||
// One broken entry in metadata.assets should not blank the whole preview, so
|
// One broken entry in metadata.assets should not blank the whole preview, so
|
||||||
// failures are collected and surfaced in the diagnostics panel instead.
|
// failures are collected and surfaced in the diagnostics panel instead.
|
||||||
async function loadSceneAssets(viewer, metadata, placement) {
|
async function loadSceneAssets(viewer, metadata, placement) {
|
||||||
@@ -187,7 +227,7 @@
|
|||||||
loaded.push(entry);
|
loaded.push(entry);
|
||||||
// Semantic assets are inspection aids. Defer their network and GPU cost
|
// Semantic assets are inspection aids. Defer their network and GPU cost
|
||||||
// until the user explicitly switches out of the normal scene view.
|
// until the user explicitly switches out of the normal scene view.
|
||||||
if (entry.category === "semantic") continue;
|
if (entry.semantic || entry.enabled === false) continue;
|
||||||
await loadAsset(viewer, entry, placement);
|
await loadAsset(viewer, entry, placement);
|
||||||
}
|
}
|
||||||
if (!loaded.some((asset) => asset.model && asset.category !== "semantic")) {
|
if (!loaded.some((asset) => asset.model && asset.category !== "semantic")) {
|
||||||
@@ -693,7 +733,8 @@
|
|||||||
|
|
||||||
function addCruiseVehicle(viewer, segment, index, start, speed, signalData, vehicleModelName) {
|
function addCruiseVehicle(viewer, segment, index, start, speed, signalData, vehicleModelName) {
|
||||||
const route = prepareRoute(segment, signalData);
|
const route = prepareRoute(segment, signalData);
|
||||||
const trafficMotion = createTrafficAwarePositions(viewer, route, start, speed);
|
let record = null;
|
||||||
|
const trafficMotion = createTrafficAwarePositions(viewer, route, start, speed, () => record?.status === "normal");
|
||||||
const positions = trafficMotion.positions;
|
const positions = trafficMotion.positions;
|
||||||
const flat = [];
|
const flat = [];
|
||||||
for (const coord of segment.coordinates) {
|
for (const coord of segment.coordinates) {
|
||||||
@@ -728,14 +769,41 @@
|
|||||||
minimumPixelSize: 0
|
minimumPixelSize: 0
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
record = {
|
||||||
|
id: "vehicle-" + (index + 1),
|
||||||
entity: vehicle,
|
entity: vehicle,
|
||||||
routeEntity,
|
routeEntity,
|
||||||
positions,
|
positions,
|
||||||
route,
|
route,
|
||||||
segment,
|
segment,
|
||||||
label: routeLabel(segment, index),
|
label: routeLabel(segment, index),
|
||||||
|
modelName: vehicleModelLabel(vehicleModelName),
|
||||||
|
status: "normal",
|
||||||
|
incidentNote: "",
|
||||||
|
motion: trafficMotion,
|
||||||
|
routeColor,
|
||||||
|
markerEntity: null,
|
||||||
};
|
};
|
||||||
|
vehicle.properties = new Cesium.PropertyBag({ vehicleId: record.id });
|
||||||
|
record.markerEntity = viewer.entities.add({
|
||||||
|
name: "Vehicle incident marker " + (index + 1),
|
||||||
|
position: positions,
|
||||||
|
billboard: {
|
||||||
|
image: "",
|
||||||
|
show: false,
|
||||||
|
width: 36,
|
||||||
|
height: 44,
|
||||||
|
pixelOffset: new Cesium.Cartesian2(0, -40),
|
||||||
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||||
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return record;
|
||||||
|
}
|
||||||
|
|
||||||
|
function vehicleModelLabel(name) {
|
||||||
|
const file = String(name || "").split("/").pop().replace(/\.gltf$/i, "");
|
||||||
|
return file.replace(/^.*-vehicle-/, "").replaceAll("_", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
function routeLabel(route, index) {
|
function routeLabel(route, index) {
|
||||||
@@ -756,6 +824,96 @@
|
|||||||
return cruise.vehicles[cruise.state.selectedIndex] || cruise.vehicles[0];
|
return cruise.vehicles[cruise.state.selectedIndex] || cruise.vehicles[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function vehicleById(cruise, id) {
|
||||||
|
return cruise.vehicles.find((vehicle) => vehicle.id === id) || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setVehicleStatus(viewer, vehicle, status) {
|
||||||
|
if (!vehicle || !["normal", "breakdown", "accident"].includes(status)) return;
|
||||||
|
vehicle.status = status;
|
||||||
|
const incident = status !== "normal";
|
||||||
|
const accident = status === "accident";
|
||||||
|
vehicle.markerEntity.billboard.image = status === "breakdown"
|
||||||
|
? "vehicle-breakdown.png"
|
||||||
|
: accident ? "vehicle-accident.png" : "";
|
||||||
|
vehicle.markerEntity.billboard.show = incident;
|
||||||
|
vehicle.routeEntity.polyline.material = accident ? Cesium.Color.RED : vehicle.routeColor;
|
||||||
|
if (viewer.scene.requestRender) viewer.scene.requestRender();
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindVehicleInfoCard(viewer, cruise) {
|
||||||
|
if (!vehicleInfoCard || !cruise.vehicles.length) return;
|
||||||
|
let activeVehicle = null;
|
||||||
|
const render = () => {
|
||||||
|
if (!activeVehicle) return;
|
||||||
|
vehicleInfoTitle.textContent = activeVehicle.label;
|
||||||
|
vehicleIncidentNote.value = activeVehicle.incidentNote;
|
||||||
|
const details = [
|
||||||
|
["Vehicle", activeVehicle.id],
|
||||||
|
["Model", activeVehicle.modelName],
|
||||||
|
["Route", activeVehicle.label],
|
||||||
|
["Speed", cruise.baseSpeed + " m/s"],
|
||||||
|
["Status", activeVehicle.status],
|
||||||
|
];
|
||||||
|
vehicleInfoDetails.replaceChildren(...details.flatMap(([term, value]) => {
|
||||||
|
const dt = document.createElement("dt");
|
||||||
|
const dd = document.createElement("dd");
|
||||||
|
dt.textContent = term;
|
||||||
|
dd.textContent = value;
|
||||||
|
return [dt, dd];
|
||||||
|
}));
|
||||||
|
for (const button of vehicleStatusButtons) {
|
||||||
|
button.disabled = button.dataset.vehicleStatus === activeVehicle.status;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const open = (vehicle) => {
|
||||||
|
activeVehicle = vehicle;
|
||||||
|
const index = cruise.vehicles.indexOf(vehicle);
|
||||||
|
cruise.state.selectedIndex = index;
|
||||||
|
vehicleSelect.value = String(index);
|
||||||
|
syncSelectedRouteVisibility(cruise);
|
||||||
|
vehicleInfoCard.classList.remove("hidden");
|
||||||
|
render();
|
||||||
|
};
|
||||||
|
const positionCard = () => {
|
||||||
|
if (!activeVehicle || vehicleInfoCard.classList.contains("hidden")) return;
|
||||||
|
const position = activeVehicle.entity.position?.getValue(viewer.clock.currentTime);
|
||||||
|
const windowPosition = position && Cesium.SceneTransforms.worldToWindowCoordinates(viewer.scene, position);
|
||||||
|
if (!windowPosition) {
|
||||||
|
vehicleInfoCard.classList.add("hidden");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const margin = 12;
|
||||||
|
const width = vehicleInfoCard.offsetWidth || 300;
|
||||||
|
const x = Cesium.Math.clamp(windowPosition.x, margin + width / 2, window.innerWidth - margin - width / 2);
|
||||||
|
vehicleInfoCard.style.left = x + "px";
|
||||||
|
vehicleInfoCard.style.top = Math.max(windowPosition.y, margin + 20) + "px";
|
||||||
|
};
|
||||||
|
closeVehicleInfo.addEventListener("click", () => {
|
||||||
|
activeVehicle = null;
|
||||||
|
vehicleInfoCard.classList.add("hidden");
|
||||||
|
});
|
||||||
|
vehicleIncidentNote.addEventListener("input", () => {
|
||||||
|
if (activeVehicle) activeVehicle.incidentNote = vehicleIncidentNote.value.trim();
|
||||||
|
});
|
||||||
|
for (const button of vehicleStatusButtons) {
|
||||||
|
button.addEventListener("click", () => {
|
||||||
|
if (!activeVehicle) return;
|
||||||
|
setVehicleStatus(viewer, activeVehicle, button.dataset.vehicleStatus);
|
||||||
|
render();
|
||||||
|
setStatus(activeVehicle.label + " " + activeVehicle.status);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
||||||
|
handler.setInputAction((movement) => {
|
||||||
|
const picked = viewer.scene.pick(movement.position);
|
||||||
|
const id = picked?.id?.properties?.vehicleId?.getValue?.();
|
||||||
|
const vehicle = vehicleById(cruise, id);
|
||||||
|
if (vehicle) open(vehicle);
|
||||||
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||||
|
viewer.scene.postRender.addEventListener(positionCard);
|
||||||
|
}
|
||||||
|
|
||||||
function prepareRoute(segment, signalData) {
|
function prepareRoute(segment, signalData) {
|
||||||
const distances = [0.0];
|
const distances = [0.0];
|
||||||
for (let i = 1; i < segment.coordinates.length; i += 1) {
|
for (let i = 1; i < segment.coordinates.length; i += 1) {
|
||||||
@@ -787,12 +945,13 @@
|
|||||||
return [...found.values()].sort((a, b) => a.distance - b.distance);
|
return [...found.values()].sort((a, b) => a.distance - b.distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTrafficAwarePositions(viewer, route, start, speed) {
|
function createTrafficAwarePositions(viewer, route, start, speed, isMoving = () => true) {
|
||||||
const state = { distance: 0, lastTime: start.clone() };
|
const state = { distance: 0, lastTime: start.clone() };
|
||||||
viewer.clock.onTick.addEventListener((clock) => {
|
viewer.clock.onTick.addEventListener((clock) => {
|
||||||
const elapsed = Cesium.JulianDate.secondsDifference(clock.currentTime, state.lastTime);
|
const elapsed = Cesium.JulianDate.secondsDifference(clock.currentTime, state.lastTime);
|
||||||
Cesium.JulianDate.clone(clock.currentTime, state.lastTime);
|
Cesium.JulianDate.clone(clock.currentTime, state.lastTime);
|
||||||
if (elapsed <= 0) return;
|
if (elapsed <= 0) return;
|
||||||
|
if (!isMoving()) return;
|
||||||
const next = nextRouteStop(route, state.distance);
|
const next = nextRouteStop(route, state.distance);
|
||||||
const advance = elapsed * speed;
|
const advance = elapsed * speed;
|
||||||
if (next && signalPhase(next.signal.phaseGroup, clock.currentTime, start).active !== "green") {
|
if (next && signalPhase(next.signal.phaseGroup, clock.currentTime, start).active !== "green") {
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
|
||||||
|
const SCHEMA = "osm-asset-package/v1";
|
||||||
|
const CATEGORIES = new Set(["scene", "roads", "buildings", "vegetation", "water"]);
|
||||||
|
const ROLES = new Set(["scene", "layer"]);
|
||||||
|
|
||||||
|
function relativeUri(uri) {
|
||||||
|
if (typeof uri !== "string" || !uri || uri.startsWith("/") || path.isAbsolute(uri) || uri.includes("\\") || uri.split("/").includes("..")) {
|
||||||
|
throw new Error(`Asset URI must be a package-relative forward-slash path: ${uri}`);
|
||||||
|
}
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateManifest(manifest, packageDir, options = {}) {
|
||||||
|
const errors = [];
|
||||||
|
const fail = (message) => errors.push(message);
|
||||||
|
if (!manifest || manifest.schema !== SCHEMA) fail(`schema must be '${SCHEMA}'`);
|
||||||
|
if (typeof manifest?.packageVersion !== "string" || !manifest.packageVersion) fail("packageVersion is required");
|
||||||
|
if (typeof manifest?.areaId !== "string" || !manifest.areaId) fail("areaId is required");
|
||||||
|
const coordinateSystem = manifest?.coordinateSystem || {};
|
||||||
|
if (coordinateSystem.axes !== "ENU" || coordinateSystem.units !== "meters" || coordinateSystem.x !== "east" || coordinateSystem.y !== "north" || coordinateSystem.z !== "up") fail("coordinateSystem must declare ENU meters (east/north/up)");
|
||||||
|
const placement = manifest?.placement || {};
|
||||||
|
for (const key of ["longitude", "latitude", "height", "headingCorrectionDegrees"]) if (!Number.isFinite(placement[key])) fail(`placement.${key} must be finite`);
|
||||||
|
if (Number.isFinite(placement.longitude) && (placement.longitude < -180 || placement.longitude > 180)) fail("placement.longitude is out of range");
|
||||||
|
if (Number.isFinite(placement.latitude) && (placement.latitude < -90 || placement.latitude > 90)) fail("placement.latitude is out of range");
|
||||||
|
const bounds = manifest?.bounds || {};
|
||||||
|
for (const key of ["minLon", "minLat", "maxLon", "maxLat"]) if (!Number.isFinite(bounds[key])) fail(`bounds.${key} must be finite`);
|
||||||
|
if (Number.isFinite(bounds.minLon) && Number.isFinite(bounds.maxLon) && bounds.minLon > bounds.maxLon) fail("bounds longitude order is invalid");
|
||||||
|
if (Number.isFinite(bounds.minLat) && Number.isFinite(bounds.maxLat) && bounds.minLat > bounds.maxLat) fail("bounds latitude order is invalid");
|
||||||
|
if (!Array.isArray(manifest?.assets) || !manifest.assets.length) fail("assets must be a non-empty array");
|
||||||
|
const ids = new Set(); let sceneCount = 0;
|
||||||
|
for (const asset of manifest?.assets || []) {
|
||||||
|
if (!asset || typeof asset.id !== "string" || !asset.id) { fail("asset id is required"); continue; }
|
||||||
|
if (ids.has(asset.id)) fail(`duplicate asset id '${asset.id}'`); ids.add(asset.id);
|
||||||
|
if (!ROLES.has(asset.role)) fail(`asset '${asset.id}' has invalid role`);
|
||||||
|
if (!CATEGORIES.has(asset.category)) fail(`asset '${asset.id}' has invalid category`);
|
||||||
|
if (typeof asset.defaultLoad !== "boolean") fail(`asset '${asset.id}' defaultLoad must be boolean`);
|
||||||
|
try { relativeUri(asset.uri); } catch (error) { fail(error.message); continue; }
|
||||||
|
if (asset.role === "scene") {
|
||||||
|
sceneCount += 1;
|
||||||
|
if (asset.category !== "scene" || !asset.defaultLoad) fail("scene asset must be category scene and defaultLoad true");
|
||||||
|
} else if (asset.category === "scene" || asset.defaultLoad) fail("layer assets must use a semantic category and defaultLoad false");
|
||||||
|
if (packageDir && options.requireFiles !== false) {
|
||||||
|
const resolved = path.resolve(packageDir, asset.uri);
|
||||||
|
if (!resolved.startsWith(`${path.resolve(packageDir)}${path.sep}`) || !fs.existsSync(resolved)) fail(`asset '${asset.id}' is missing from package: ${asset.uri}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (manifest.runtime !== undefined && !Array.isArray(manifest.runtime)) fail("runtime must be an array");
|
||||||
|
for (const runtime of manifest?.runtime || []) {
|
||||||
|
if (!runtime || typeof runtime.id !== "string" || !runtime.id) { fail("runtime asset id is required"); continue; }
|
||||||
|
if (ids.has(runtime.id)) fail(`duplicate asset id '${runtime.id}'`); ids.add(runtime.id);
|
||||||
|
if (typeof runtime.type !== "string" || !runtime.type) fail(`runtime '${runtime.id}' type is required`);
|
||||||
|
try { relativeUri(runtime.uri); } catch (error) { fail(error.message); continue; }
|
||||||
|
if (packageDir && options.requireFiles !== false) {
|
||||||
|
const resolved = path.resolve(packageDir, runtime.uri);
|
||||||
|
if (!resolved.startsWith(`${path.resolve(packageDir)}${path.sep}`) || !fs.existsSync(resolved)) fail(`runtime '${runtime.id}' is missing from package: ${runtime.uri}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sceneCount !== 1) fail("exactly one scene asset is required");
|
||||||
|
if (errors.length) throw new Error(`Invalid asset package manifest: ${errors.join("; ")}`);
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addIntegrity(manifest, packageDir) {
|
||||||
|
for (const asset of manifest.assets) {
|
||||||
|
const file = path.resolve(packageDir, asset.uri);
|
||||||
|
const buffer = fs.readFileSync(file);
|
||||||
|
asset.integrity = { bytes: buffer.length, sha256: crypto.createHash("sha256").update(buffer).digest("hex") };
|
||||||
|
}
|
||||||
|
for (const runtime of manifest.runtime || []) {
|
||||||
|
const file = path.resolve(packageDir, runtime.uri);
|
||||||
|
const buffer = fs.readFileSync(file);
|
||||||
|
runtime.integrity = { bytes: buffer.length, sha256: crypto.createHash("sha256").update(buffer).digest("hex") };
|
||||||
|
}
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { SCHEMA, CATEGORIES, ROLES, relativeUri, validateManifest, addIntegrity };
|
||||||
@@ -78,6 +78,10 @@ try {
|
|||||||
const stagedPath = path.join(stagingDir, layerFile(layer));
|
const stagedPath = path.join(stagingDir, layerFile(layer));
|
||||||
exportLayer(layer.id, stagedPath);
|
exportLayer(layer.id, stagedPath);
|
||||||
const collection = readCollection(stagedPath, layer.id);
|
const collection = readCollection(stagedPath, layer.id);
|
||||||
|
if (layer.id === "intersection_surface") {
|
||||||
|
restoreIntersectionSurfaceIds(collection);
|
||||||
|
fs.writeFileSync(stagedPath, JSON.stringify(collection));
|
||||||
|
}
|
||||||
console.log(`${layer.id}\tfeatures=${collection.features.length}`);
|
console.log(`${layer.id}\tfeatures=${collection.features.length}`);
|
||||||
return { layer, stagedPath, collection };
|
return { layer, stagedPath, collection };
|
||||||
});
|
});
|
||||||
@@ -180,6 +184,9 @@ function exportLayer(layerName, destination) {
|
|||||||
// precision-reduction pass, which drops vertices that collapse at the given
|
// precision-reduction pass, which drops vertices that collapse at the given
|
||||||
// resolution (measured: 28 points lost across 7 lane-arrow polygons).
|
// resolution (measured: 28 points lost across 7 lane-arrow polygons).
|
||||||
execFileSync(ogr2ogr, [
|
execFileSync(ogr2ogr, [
|
||||||
|
// GeoPackage reserves "id" as its FID column. Preserve it so the
|
||||||
|
// intersection surface can retain its osm2streets internal ID on export.
|
||||||
|
"-preserve_fid",
|
||||||
"-f", "GeoJSON",
|
"-f", "GeoJSON",
|
||||||
destination,
|
destination,
|
||||||
gpkgPath,
|
gpkgPath,
|
||||||
@@ -190,6 +197,23 @@ function exportLayer(layerName, destination) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restoreIntersectionSurfaceIds(collection) {
|
||||||
|
for (const [index, feature] of collection.features.entries()) {
|
||||||
|
if (!feature || typeof feature !== "object") {
|
||||||
|
throw new Error(`intersection_surface feature ${index + 1} is invalid`);
|
||||||
|
}
|
||||||
|
const existingId = Number(feature.properties?.id);
|
||||||
|
if (Number.isInteger(existingId)) continue;
|
||||||
|
const fid = Number(feature.id);
|
||||||
|
if (!Number.isInteger(fid)) {
|
||||||
|
throw new Error(
|
||||||
|
`intersection_surface feature ${index + 1} is missing its osm2streets internal ID`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
feature.properties = { ...(feature.properties || {}), id: fid };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function readCollection(file, layerName) {
|
function readCollection(file, layerName) {
|
||||||
let parsed;
|
let parsed;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -71,8 +71,13 @@ assert.equal(
|
|||||||
const configPath = path.join(tempDir, "area.json");
|
const configPath = path.join(tempDir, "area.json");
|
||||||
fs.writeFileSync(configPath, `${JSON.stringify(base)}\n`);
|
fs.writeFileSync(configPath, `${JSON.stringify(base)}\n`);
|
||||||
const area = normalizeAreaConfig(base);
|
const area = normalizeAreaConfig(base);
|
||||||
|
assert.equal(area.stages.compress, true);
|
||||||
|
assert.equal("compressedGlb" in area.outputs, false);
|
||||||
|
assert.equal("compressedMetadata" in area.outputs, false);
|
||||||
|
assert.equal("compressedCesiumPreview" in area.outputs, false);
|
||||||
fs.mkdirSync(area.outputs.geojsonDir, { recursive: true });
|
fs.mkdirSync(area.outputs.geojsonDir, { recursive: true });
|
||||||
for (const file of [area.outputs.glb, area.outputs.metadata, area.outputs.cesiumPreview, area.outputs.vehicleRoute, area.outputs.vehicleModel]) {
|
for (const file of [area.outputs.glb, area.outputs.metadata, area.outputs.cesiumPreview, area.outputs.vehicleRoute, area.outputs.vehicleModel]) {
|
||||||
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||||
fs.writeFileSync(file, "fixture\n");
|
fs.writeFileSync(file, "fixture\n");
|
||||||
}
|
}
|
||||||
const lanePolygons = path.join(area.outputs.geojsonDir, "lane_polygons.geojson");
|
const lanePolygons = path.join(area.outputs.geojsonDir, "lane_polygons.geojson");
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
const assert = require("assert");
|
||||||
|
const { resolveStages, canonicalStages } = require("./lib/build-stages");
|
||||||
|
assert.deepEqual(canonicalStages(resolveStages({}, ["compress", "blender", "preview"])), ["blender", "compress", "preview"]);
|
||||||
|
assert.deepEqual(canonicalStages(resolveStages({}, ["all"])), ["intermediates", "blender", "cesium", "compress", "package", "preview"]);
|
||||||
|
assert.deepEqual(canonicalStages(resolveStages({ intermediates: true, blender: true, cesium: true, compress: true, package: true })), ["intermediates", "blender", "cesium", "compress", "package"]);
|
||||||
|
assert.throws(() => resolveStages({}, ["intermediates", "reimport"]), /mutually exclusive/);
|
||||||
|
console.log("Build stage tests passed.");
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const assert = require("assert");
|
||||||
|
const fs = require("fs");
|
||||||
|
const os = require("os");
|
||||||
|
const path = require("path");
|
||||||
|
const { SCHEMA, validateManifest } = require("./lib/package-contract");
|
||||||
|
|
||||||
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "asset-package-"));
|
||||||
|
fs.mkdirSync(path.join(dir, "models"));
|
||||||
|
fs.writeFileSync(path.join(dir, "models", "area.glb"), "glb");
|
||||||
|
fs.writeFileSync(path.join(dir, "runtime.json"), "{}");
|
||||||
|
const valid = { schema: SCHEMA, packageVersion: "1.0.0", areaId: "area", coordinateSystem: { axes: "ENU", units: "meters", x: "east", y: "north", z: "up" }, placement: { longitude: 120, latitude: 30, height: 0, headingCorrectionDegrees: -90 }, bounds: { minLon: 119, minLat: 29, maxLon: 121, maxLat: 31 }, assets: [{ id: "main", role: "scene", category: "scene", uri: "models/area.glb", defaultLoad: true }], runtime: [{ id: "traffic-signals", type: "traffic-signal-anchors", uri: "runtime.json" }] };
|
||||||
|
assert.doesNotThrow(() => validateManifest(valid, dir));
|
||||||
|
for (const change of [
|
||||||
|
(m) => { m.schema = "bad"; }, (m) => { m.assets[0].uri = "../area.glb"; },
|
||||||
|
(m) => { m.assets[0].category = "dynamic"; }, (m) => { m.assets.push({ ...m.assets[0] }); },
|
||||||
|
(m) => { m.placement.longitude = 900; },
|
||||||
|
]) {
|
||||||
|
const manifest = JSON.parse(JSON.stringify(valid)); change(manifest);
|
||||||
|
assert.throws(() => validateManifest(manifest, dir));
|
||||||
|
}
|
||||||
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
|
console.log("Asset package contract tests passed.");
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
const assert = require("assert");
|
||||||
|
const { resolveAsset, resolveRuntime, placement } = require("../examples/asset-package-resolver");
|
||||||
|
const manifest = { coordinateSystem: { axes: "ENU" }, placement: { longitude: 120, latitude: 30, height: 2, headingCorrectionDegrees: -90 }, assets: [{ id: "main", uri: "models/a.glb" }, { id: "roads", uri: "models/roads.glb" }], runtime: [{ id: "traffic-signals", uri: "runtime/traffic-signals.json" }] };
|
||||||
|
assert.equal(resolveAsset("https://consumer.example/copied/manifest.json", manifest), "https://consumer.example/copied/models/a.glb");
|
||||||
|
assert.equal(resolveAsset("https://consumer.example/copied/manifest.json", manifest, "roads"), "https://consumer.example/copied/models/roads.glb");
|
||||||
|
assert.equal(resolveRuntime("https://consumer.example/copied/manifest.json", manifest, "traffic-signals"), "https://consumer.example/copied/runtime/traffic-signals.json");
|
||||||
|
assert.equal(placement(manifest).coordinateSystem.axes, "ENU");
|
||||||
|
console.log("Asset package example resolver tests passed.");
|
||||||
@@ -251,17 +251,31 @@ assert.match(html, /"glbName":"scene\\u003c\\u0026\\u003e\.glb"/);
|
|||||||
assert.match(html, /"vehicleModelNames":\["car-a\.gltf","truck-a\.gltf"\]/);
|
assert.match(html, /"vehicleModelNames":\["car-a\.gltf","truck-a\.gltf"\]/);
|
||||||
assert.match(html, /"trafficSignalsName":"traffic-signals\.json"/);
|
assert.match(html, /"trafficSignalsName":"traffic-signals\.json"/);
|
||||||
assert.match(html, /id="toggleSignals"/);
|
assert.match(html, /id="toggleSignals"/);
|
||||||
|
assert.match(html, /id="vehicleInfoCard" class="hidden"/);
|
||||||
|
assert.match(html, /id="vehicleIncidentNote"/);
|
||||||
|
assert.match(html, /data-vehicle-status="breakdown"/);
|
||||||
|
assert.match(html, /data-vehicle-status="accident"/);
|
||||||
assert.match(html, /id="toggleBuildingGhost"/);
|
assert.match(html, /id="toggleBuildingGhost"/);
|
||||||
assert.match(html, /id="viewMode"/);
|
assert.match(html, /id="viewMode"/);
|
||||||
assert.match(html, /data-view-mode="inspect"/);
|
assert.match(html, /data-view-mode="inspect"/);
|
||||||
assert.match(html, /id="semanticToggles" class="control-subgroup hidden"/);
|
assert.match(html, /id="semanticToggles" class="control-subgroup hidden"/);
|
||||||
|
|
||||||
const previewRuntime = fs.readFileSync(path.join(__dirname, "lib", "cesium-preview.js"), "utf8");
|
const previewRuntime = fs.readFileSync(path.join(__dirname, "lib", "cesium-preview.js"), "utf8");
|
||||||
|
const buildAreaSource = fs.readFileSync(path.join(__dirname, "build-area.js"), "utf8");
|
||||||
|
assert.match(buildAreaSource, /vehicleModelNames\.map\(\(name\) => `_preview\/\$\{name\}`\)/);
|
||||||
const countdownFont = path.join(__dirname, "..", "assets", "fonts", "7LED-1.ttf");
|
const countdownFont = path.join(__dirname, "..", "assets", "fonts", "7LED-1.ttf");
|
||||||
assert.ok(fs.existsSync(countdownFont), "7LED countdown font must be versioned with the project");
|
assert.ok(fs.existsSync(countdownFont), "7LED countdown font must be versioned with the project");
|
||||||
assert.doesNotMatch(previewRuntime, /cylinder: \{ length: 6\.7/);
|
assert.doesNotMatch(previewRuntime, /cylinder: \{ length: 6\.7/);
|
||||||
assert.doesNotMatch(previewRuntime, /Traffic Signal Housing/);
|
assert.doesNotMatch(previewRuntime, /Traffic Signal Housing/);
|
||||||
assert.match(previewRuntime, /asset\.category === "dynamic"/);
|
assert.match(previewRuntime, /asset\.category === "dynamic"/);
|
||||||
|
assert.match(previewRuntime, /new Cesium\.ScreenSpaceEventHandler/);
|
||||||
|
assert.match(previewRuntime, /vehicleId: record\.id/);
|
||||||
|
assert.match(previewRuntime, /status === "breakdown"\s+\? "vehicle-breakdown\.png"/);
|
||||||
|
assert.match(previewRuntime, /accident \? "vehicle-accident\.png"/);
|
||||||
|
assert.match(previewRuntime, /disableDepthTestDistance: Number\.POSITIVE_INFINITY/);
|
||||||
|
assert.match(previewRuntime, /routeEntity\.polyline\.material = accident \? Cesium\.Color\.RED : vehicle\.routeColor/);
|
||||||
|
assert.match(previewRuntime, /\(\) => record\?\.status === "normal"/);
|
||||||
|
assert.match(previewRuntime, /Cesium\.SceneTransforms\.worldToWindowCoordinates/);
|
||||||
assert.match(previewRuntime, /TrafficSignalDynamic_/);
|
assert.match(previewRuntime, /TrafficSignalDynamic_/);
|
||||||
assert.match(previewRuntime, /TrafficSignalDynamic_\$\{nodeKey\}_countdown_\$\{String\(value\)\.padStart\(2, "0"\)\}/);
|
assert.match(previewRuntime, /TrafficSignalDynamic_\$\{nodeKey\}_countdown_\$\{String\(value\)\.padStart\(2, "0"\)\}/);
|
||||||
assert.match(previewRuntime, /ColorBlendMode\.REPLACE/);
|
assert.match(previewRuntime, /ColorBlendMode\.REPLACE/);
|
||||||
|
|||||||
Reference in new issue
Block a user