Open vorg opened 5 years ago
@dmnsgn would you find proposed auto-buffer
useful?
Yes I would. Any way to have it as a bunch of static functions like pex-math (but also keeping a reference to build buffer and update count)?
I imagine there's a package already but couldn't find it.
I imagine having only two functions add/reset and the object itself as {data, length}
. Not sure if API like this is much helpful:
var gar = require('growing-array')
var arr = gar.create({ type: Float32Array, count: 32 }) //{data, length}
gar.push(arr, [0.0, 1.0, 2.0])
console.log(arr.length) //3
console.log(arr.data.length) //32
gar.reset(arr)
Because vec3 as [x, y, z] is standalone and useful while {data, length} is not.
One has to be also careful with name choosing. We use it for buffers that are actually (typed)arrays.
Currently we come with assumptions about supported attributes e.g. that positions are always enabled
a more generic API could be as follows:
The
builder.add('positions', [])
fees weird, it should bebuilder.add('position', [])
but then how do we guess the name? By addings
automatically?Also
Also if we change API so much this should be new module e.g.
auto-expanding-buffer
. What makes it geometry specific is assumption that all attributes grow at the same rate which is actually not always true (e.g. instancing). Would the api be thenbuilder.count('position')
and orbuilder.count('cells')
?auto-buffer
auto-buffer
auto expanding buffer. Is there something similar on npm already?That also leads to
builder.resetAll()
and more granularbuilder.reset('position')
... which leads to fact that maybe we need builder per buffer?