通用化项目结构:Blender 脚本去硬编码、config 路径占位符、layerPrefix 配置
- blender/generate_nantaizi.py → blender/generate_scene.py(去硬编码路径, --geojson 改为可选,--office-overrides 替代硬编码 way ID) - blender/export_cesium.py CLI 参数改为必传,修复隐藏物体导出崩溃 - blender/README.md 重写为中文通用文档 - config/default.json 路径改为占位符,template.json 新增 blender 配置块 - scripts/build-osm2streets-qgis.js 新增 layerPrefix 配置驱动 QGIS 图层名 - package.json name → osm-gis-pipeline - README.md 重写并增加实际运行示例
This commit is contained in:
@@ -1,89 +1,66 @@
|
||||
# Nantaizi Lake Blender scene
|
||||
# Blender 3D 场景生成
|
||||
|
||||
This generator combines the source OSM building, water and height tags with
|
||||
the detailed osm2streets GeoJSON road layers.
|
||||
该生成器将 OSM 建筑、水体、植被标签,以及可选的 osm2streets GeoJSON 道路图层,组合为 Blender 3D 场景。
|
||||
|
||||
## Outputs
|
||||
## 生成场景
|
||||
|
||||
- `../outputs/nantaizi-lake-innovation-valley/nantaizi_lake_innovation_valley.blend`
|
||||
- `../outputs/nantaizi-lake-innovation-valley/nantaizi_lake_innovation_valley.png`
|
||||
- `../outputs/nantaizi-lake-innovation-valley/nantaizi_lake_innovation_valley_cesium.glb`
|
||||
- `../outputs/nantaizi-lake-innovation-valley/nantaizi_lake_innovation_valley_cesium.json`
|
||||
- `../outputs/nantaizi-lake-innovation-valley/nantaizi_cesium_preview.html`
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background --factory-startup \
|
||||
--python blender/generate_scene.py -- \
|
||||
--osm "/path/to/input.osm" \
|
||||
--geojson "/path/to/osm2streets_web_out" \
|
||||
--output "/path/to/output.blend" \
|
||||
--render "/path/to/preview.png"
|
||||
```
|
||||
|
||||
## Regenerate
|
||||
`--geojson` 为可选参数。不提供时,道路使用简单的 OSM highway 折线,而非详细 osm2streets 几何。
|
||||
|
||||
使用 `--office-overrides` 指定一组 OSM way ID(逗号分隔),这些建筑将渲染为办公楼风格,即使其 OSM 标签为 `building=industrial`:
|
||||
|
||||
```
|
||||
--office-overrides "117753521,117753535"
|
||||
```
|
||||
|
||||
### 说明
|
||||
|
||||
- OSM `bounds` 元素定义场景范围(排除远处的地铁等关系成员)
|
||||
- `natural=tree` 节点 → 独立树木(程序化或模型树冠)
|
||||
- `natural=tree_row` 路径 → 沿路径均匀分布的树木
|
||||
- `landuse=grass` → 绿色地面
|
||||
- `natural=scrub` → 低矮灌木丛
|
||||
- `amenity=fountain` → 低多边形喷泉
|
||||
- 建筑:`building=industrial` → 厂房风格;其他 → 办公楼风格(带窗带)
|
||||
- 植被和建筑高度从 OSM `height` 标签读取
|
||||
- 程序化细节(窗带、屋顶设备、树冠)不改变 OSM 体量
|
||||
- 纹理使用 Poly Haven 的 1K CC0 纹理,打包在 `.blend` 内
|
||||
|
||||
## 导出为 Cesium GLB
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background \
|
||||
--factory-startup \
|
||||
--python blender/generate_nantaizi.py -- \
|
||||
--osm "/Users/que01/Desktop/南台子湖创新谷OSM.osm" \
|
||||
--geojson "/Users/que01/osm2streets-qgis-workflow/outputs/nantaizi-lake-innovation-valley/osm2streets_web_out" \
|
||||
--output "/Users/que01/osm2streets-qgis-workflow/outputs/nantaizi-lake-innovation-valley/nantaizi_lake_innovation_valley.blend" \
|
||||
--render "/Users/que01/osm2streets-qgis-workflow/outputs/nantaizi-lake-innovation-valley/nantaizi_lake_innovation_valley.png"
|
||||
--python blender/export_cesium.py -- \
|
||||
--blend "/path/to/output.blend" \
|
||||
--glb "/path/to/output_cesium.glb" \
|
||||
--metadata "/path/to/output_cesium.json"
|
||||
```
|
||||
|
||||
The OSM file contains distant subway relation members. The generator uses the
|
||||
explicit OSM `bounds` element to keep the scene limited to the park.
|
||||
GLB 使用以 OSM bounds 中心为原点的局部 ENU 坐标系(X 东,Y 北,Z 上)。
|
||||
使用配套的 JSON 元数据文件将模型放置到 Cesium 中。
|
||||
|
||||
Vegetation is read from the OSM export: `natural=tree` nodes become individual
|
||||
trees, `natural=tree_row` ways become evenly spaced rows using their height,
|
||||
`landuse=grass` becomes green ground, and `natural=scrub` becomes low shrub
|
||||
volumes. `amenity=fountain` nodes become low-poly fountain basins and water
|
||||
sprays. No trees or fountains are inferred from open ground.
|
||||
导出脚本会:
|
||||
- 应用网格修改器并创建 UV
|
||||
- 将 Blender 特有材质转换为 glTF 兼容 PBR 材质
|
||||
- 烘焙色调覆盖基础色以实现干净的 Web 渲染
|
||||
- 将所有纹理图片嵌入 GLB
|
||||
- 写入包含 WGS84 锚点和 Cesium JS 辅助代码的 JSON 元数据
|
||||
|
||||
The renderer adds procedural presentation detail without changing OSM massing:
|
||||
rounded layered crowns and tapered trunks for trees, window bands and roof
|
||||
equipment for office buildings, and clerestory windows, skylights and roof
|
||||
equipment for `building=industrial` footprints.
|
||||
### 预览
|
||||
|
||||
Ordinary `building=yes` footprints below 30 meters are rendered as three-floor
|
||||
park offices at 11.4 meters plus a small roof unit. Explicit high-rises and all
|
||||
`building=industrial` heights remain sourced from OSM. White plaster, gray
|
||||
corrugated iron, grass and bark use 1K CC0 textures downloaded from Poly Haven.
|
||||
The images used by the scene are packed into the generated `.blend`; source and
|
||||
license details are recorded in `assets/textures/polyhaven/SOURCES.md`.
|
||||
|
||||
OSM ways `117753521` and `117753535` are explicitly rendered as three-floor
|
||||
white offices because the surveyed site use differs from their current
|
||||
`building=industrial` tags.
|
||||
|
||||
## Export for Cesium
|
||||
在输出目录上启动 HTTP 服务后打开预览页:
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender \
|
||||
--background \
|
||||
--python blender/export_cesium.py
|
||||
```
|
||||
|
||||
The GLB uses a local east-north-up meter frame centered on the OSM bounds. Its
|
||||
companion JSON records the WGS84 anchor used by the preview page. The export
|
||||
script applies mesh modifiers, creates UVs, converts Blender-only materials to
|
||||
glTF-compatible PBR materials, and embeds the used texture images in the GLB.
|
||||
For the Cesium preview, use this script rather than Blender's manual glTF
|
||||
export: it preserves the local ENU placement metadata and bakes/overrides the
|
||||
building display materials so the web preview stays close to Blender's clean
|
||||
material-preview look.
|
||||
|
||||
You can export directly from Blender for a quick material sanity check, but the
|
||||
manual GLB will not create/update `nantaizi_lake_innovation_valley_cesium.json`
|
||||
and therefore will not be positioned automatically by
|
||||
`nantaizi_cesium_preview.html`.
|
||||
|
||||
Serve the output directory over HTTP before opening the preview because web
|
||||
browsers do not allow the page to fetch GLB/JSON files from `file://`:
|
||||
|
||||
```bash
|
||||
cd outputs/nantaizi-lake-innovation-valley
|
||||
cd /path/to/output
|
||||
python3 -m http.server 8765
|
||||
```
|
||||
|
||||
Then open `http://localhost:8765/nantaizi_cesium_preview.html`.
|
||||
|
||||
## Blender MCP
|
||||
|
||||
The current machine has the `blosm` add-on but no Blender MCP add-on or Codex
|
||||
MCP server configuration. An MCP workflow requires both sides and a Codex
|
||||
restart after adding the server. The generator remains useful with MCP because
|
||||
it creates a stable base scene that can then be edited interactively.
|
||||
```
|
||||
Reference in New Issue
Block a user