Closed RobinVanCauter closed 3 years ago
I've found the issue is not with the nesting, but rather with me re-using the Vector3 schema for multiple arrays of values.
I suspect the schemaid is used as an anchor inside the ArrayBuffer, thus causing the values of my positions to be read from the velocity index instead.
Tested it with 2 distinct schemas instead and that worked without issues!
const positionSchema = BufferSchema.schema('position', {
id: uint8,
x: { type: float32 },
y: { type: float32 },
z: { type: float32 },
});
// Buffer thingy
const velocitySchema = BufferSchema.schema('velocity', {
id: uint8,
x: { type: float32 },
y: { type: float32 },
z: { type: float32 },
});
const snapshotSchema = BufferSchema.schema('snapshot', {
id: { type: string8, length: 6 },
state: { positions: [positionSchema], velocities: [velocitySchema] },
time: uint64,
});
I'll close the issue as it's not really the bug I thought it was, maybe this limitation / behavior can be documented.
This should be reopened (with a more accurate name), as this is probably fixable.
Describe the bug I'm trying to use the following schema and while the resulting object structure is correct, the values inside positions/velocities (which are nested inside
state
) are incorrectly de-serialized and lost. I would expect this to work, as you use this nested state structure inside the compression example over at https://github.com/geckosio/snapshot-interpolation#compressionThe following schema does not have the same problem ;