【发布时间】:2020-04-05 14:35:15
【问题描述】:
我正在尝试通过 gltf 显示多个框(具有不同的大小和位置)。
我使用https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/Box/glTF/Box.gltf 示例作为模板,只需将节点替换为新节点即可。
当我创建节点时
gltf["scenes"][0]["nodes"]=[]
gltf["nodes"]=[]
nodeId=0
for x, y, z, w, h, d in boxes:
gltf["nodes"]+=[{ "mesh": 0, "translation": [x, y, z], "scale":[w, h, d]}]
gltf["scenes"][0]["nodes"]+=[nodeId]
nodeId+=1
盒子(彼此相邻)碰撞(不仅在边缘)。所以 3d 是错误的。
当我创建没有缩放的盒子(从很多小盒子)时,它可以工作:
gltf["scenes"][0]["nodes"]=[]
gltf["nodes"]=[]
nodeId=0
for x, y, z, w, h, d in boxes:
for x1 in range(x, w+w):
for y1 in range(y, y+w):
for z1 in range(z, z+d):
gltf["nodes"]+=[{"mesh": 0, "translation": [x1, y1, z1]}]
gltf["scences"][0]["nodes"]+=[nodeId]
nodeId+=1
但这当然是一个更大更复杂的 gltf。
方框中的坐标是左下角前角(x、y 和 z 值的最小值)
【问题讨论】: