@@ -172,9 +172,14 @@ def make_buffer_from_data(self, data: ShaderDataType) -> dict[str, Any]:
172172 flat_positions = list (flatten (positions ))
173173 flat_colors = list (flatten ([color .rgba for color in colors ]))
174174 flat_elements = list (flatten (elements ))
175+
176+ # Add object_index data (all zeros for grid since it uses is_grid flag)
177+ object_indices = [0.0 ] * (len (flat_positions ) // 3 )
178+
175179 return {
176180 "positions" : make_vertex_buffer (flat_positions ),
177181 "colors" : make_vertex_buffer (flat_colors ),
182+ "object_indices" : make_vertex_buffer (object_indices ),
178183 "elements" : make_index_buffer (flat_elements ),
179184 "n" : len (flat_elements ),
180185 }
@@ -185,8 +190,11 @@ def draw(self, shader: Shader):
185190 shader .uniform1i ("is_grid" , True )
186191 shader .enable_attribute ("position" )
187192 shader .enable_attribute ("color" )
193+ shader .enable_attribute ("object_index" )
188194 shader .bind_attribute ("position" , self ._lines_buffer ["positions" ])
189195 shader .bind_attribute ("color" , self ._lines_buffer ["colors" ], step = 4 )
196+ shader .bind_attribute ("object_index" , self ._lines_buffer ["object_indices" ], step = 1 )
190197 shader .draw_lines (elements = self ._lines_buffer ["elements" ], n = self ._lines_buffer ["n" ], width = 1 , background = True )
191198 shader .disable_attribute ("position" )
192199 shader .disable_attribute ("color" )
200+ shader .disable_attribute ("object_index" )
0 commit comments