關閉
標題:glb 切成細的 b3dm glb 要自己先切碎
內容:
pip install pygltflib
要自己先切碎
# glbtosplitglb.py
from pygltflib import GLTF2
# 讀取原始 GLB
gltf = GLTF2().load("28.glb")
# 假設按 mesh 拆
for i, mesh in enumerate(gltf.meshes):
new_gltf = GLTF2()
new_gltf.meshes.append(mesh)
# node 必須指向這個 mesh
new_gltf.nodes.append(gltf.nodes[i])
new_gltf.scenes = gltf.scenes
new_gltf.save(f"tile_{i}.glb")
glb 轉成 b3dm
mkdir -p b3dm_tiles
for f in tile_*.glb; do
filename=$(basename "$f" .glb)
npx 3d-tiles-tools glbToB3dm --input "$f" --output "b3dm_tiles/${filename}.b3dm" --force
done
多執行緒
ls tile_*.glb | parallel -j 4 'filename=$(basename {} .glb); npx 3d-tiles-tools glbToB3dm --input {} --output b3dm_tiles/${filename}.b3dm --force'