@@ -174,17 +174,25 @@ def to_glb(cm):
174174 triList = []
175175 for shell in geom ['boundaries' ]:
176176 for face in shell :
177- tri = geom_help .triangulate_face (face , vertexlist )
178- for t in tri :
179- triList .append (list (t ))
177+ tri , success = geom_help .triangulate_face (face , vertexlist )
178+ if success :
179+ for t in tri :
180+ triList .append (list (t ))
181+ else :
182+ # TODO: logging
183+ print (f"Failed to triangulate face in CityObject { theid } " )
180184 trigeom = (flatten (triList ))
181185
182186 elif (geom ['type' ] == 'MultiSurface' ) or (geom ['type' ] == 'CompositeSurface' ):
183187 triList = []
184188 for face in geom ['boundaries' ]:
185- tri = geom_help .triangulate_face (face , vertexlist )
186- for t in tri :
187- triList .append (t )
189+ tri , success = geom_help .triangulate_face (face , vertexlist )
190+ if success :
191+ for t in tri :
192+ triList .append (t )
193+ else :
194+ # TODO: logging
195+ print (f"Failed to triangulate face in CityObject { theid } " )
188196 trigeom = (flatten (triList ))
189197 flatgeom = trigeom
190198 forimax .append (flatgeom )
@@ -199,7 +207,10 @@ def to_glb(cm):
199207 # Need to swap the axis, because gltf uses a right-handed coordinate
200208 # system. glTF defines +Y as up, +Z as forward, and -X as right;
201209 # the front of a glTF asset faces +Z.
202- vtx_np [i ] = np .array ((vertexlist [v ][1 ], vertexlist [v ][2 ], vertexlist [v ][0 ]))
210+ try :
211+ vtx_np [i ] = np .array ((vertexlist [v ][1 ], vertexlist [v ][2 ], vertexlist [v ][0 ]))
212+ except IndexError as e :
213+ print (i , v )
203214 vtx_idx_np [i ] = i
204215 bin_vtx = vtx_np .astype (np .float32 ).tostring ()
205216 # convert geometry indices to binary
0 commit comments