Use case: I want to be able to access the player’s position from a Web Worker. Ideally, I would use this for picking, but also maybe for some ticks in an ECS
Rather than copy Vector3 objects frequently, would it be possible for the x, y, and z values to come from an ArrayBuffer? If I just subclass Vector3 and swap out _x, _y, and _z, and assign the new Vector3 subclass to the meshes, will it work or will there be weird bugs?
Do you remember if each Vector3 backed by an array was its own independent ArrayBuffer or was it one big pooled ArrayBuffer and each Float32Array a length / offset of that single ArrayBuffer? I’ve read fewer, larger ArrayBuffers are faster since you allocate fewer objects, but it probably won’t make the getters any faster
That would also be potentially a good optimization for Vector3 objects since it would make it easier to recycle them if you have thousands of them instead of creating new ones each time