do-serialization
do-serialization copied to clipboard
explicit schemas
it may be wise to use explicit schemas instead of using the SoA objects themselves as the schema, and then pass the SoA objects into the reader/writer functions themselves. this would allow reading/writing from/to different SoA objects that have the same schemas
e.g.
const n = 100
const Vector3SoA = { x: new Float32Array(n), y: new Float32Array(n), z: new Float32Array(n) }
const Vector3Schema = { x: Float32Array, y: Float32Array, z: Float32Array }
const config = [Vector3Schema]
const objects = [Vector3SoA]
const write = createDataWriter(config)
const read = createDataRead(config)
const indices = [1,2,3,4]
const data = write(objects, indices)
read(objects, data)