Attributes
"attributes" are inputs to a vertex shader that get their data from buffers.
to each vertex, an attribute might be a point of vec3
, or a float, or other vectors.
Triadica tried some ways of reprensenting that, while trying not to be slow.
Simplest way of passing attributes is create a list and pass points directly:
object $ {}
:draw-mode :triangles
:points $ []
[] 1 2 3
[] 4 5 6
[] 4 5 6
notice that :points
and :indices
are used by twgl.js for creating a_position
attributes.
internally it's turning into AugmentedTypedArray that consumes by twgl.js .
object $ {}
:draw-mode :triangles
:attributes $ {}
:positions $ []
[] 1 2 3
[] 4 5 6
[] 7 8 9
To make it easier to support complicated logics, there are other ways of passing attributes.
:packed-attrs
To make it easier, we can collect attributes of a single vertex in a map, and nest them in lists:
object $ {}
:draw-mode :triangles
:packed-attrs $ []
[]
{}
:position $ [] 1 2 3
:color_type 0
{}
:position $ [] 4 5 6
:color_type 1
{}
:position $ [] 7 8 9
:color_type 2
This could make building some shapes that requires multiple attributes easier by aligning the length of arrays, with some extra performance penalties.