[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] Overload set() with a numeric value.
When you create a typed array, its values are automatically initialized to zero. However, there seems to be no good way to do this after the array is created and modified.
* Iterate through the array, setting the values as you go. Unnecessarily CPU-intensive.
* use .set() with a new Typed Array instance, e.g.
var arr = new Float32Array(20)
// do something with the array
but this comes with a memory allocation overhead and possibly GC as well.
* Keep a reference to an array full of zeroes, and use .set() with this. This doesn't suffer from the earlier problems, but significantly reduces the code readability and might require a lot of memory, especially if you're reusing the array for multiple targets for best performance gain.
I suggest adding an overload to TypedArray#set(), taking a number to which all of the array is set to.