Closed myaaaaaaaaa closed 4 months ago
Having a reflection-based API opens the door for an unbounded number of feature requests, as it would never be expressive enough to cover each niche use-case.
IMO reading and writing attributes is already pretty straightforward, maybe a little verbose due to error handling -which I suppose is why you have submitted this proposal- but that's on Go itself.
In that case, how about reducing the scope to just Array-of-Structures (which requires reflection, and was the main motivator for this proposal)?
Structure-of-Arrays (which gltf/modeler
's APIs are currently all based on) may have superior runtime performance, but it does make mesh processing more awkward.
Example pseudocode as follows:
Array-of-Structures example
~Structure-of-Arrays example~
```go attrs := struct { Position [][3]float `gltf:"required"` Normal [][3]float }{} ```~Array-of-Pointer-to-Structures example~
```go // modeler.ReadAttributes() should internally allocate an Array-of-Structures // to which the returned Array-of-Pointer-to-Structures all point to, to reduce allocator/GC pressure attrs := []*struct { Position [3]float `gltf:"required"` Normal [3]float }{} ```