switch to reused float array where possible

This commit is contained in:
2025-01-22 23:21:36 -06:00
parent 7d7b92678b
commit cb60d22549
6 changed files with 28 additions and 32 deletions
+5 -6
View File
@@ -1,10 +1,9 @@
import chunk from '../chunk';
const floatArray = new Float32Array(3);
export default (x: number, y: number, z: number): Uint8Array => {
const buf = new DataView(new ArrayBuffer(12));
buf.setFloat32(0, x, true);
buf.setFloat32(4, y, true);
buf.setFloat32(8, z, true);
return chunk(0x0002, new Uint8Array(buf.buffer), false);
floatArray[0] = x;
floatArray[1] = y;
floatArray[2] = z;
return chunk(0x0002, new Uint8Array(floatArray.buffer), false);
};