There's lots of trace data that's like
{
someField: number;
someOtherField: number;
textureSerial: number;
}
And there is code that converts textureSerial: number to texture: someReplayTexture
It made me wonder if there would be any benefit from trying to make that code just scan every trace object for xxxSerial and then do auto convert. Something like
function deserilize(traceObject, replay) {
const kSerial = 'Serial';
for (const [key, value] of Object.entries(traceObject)) {
if (Array.isArray(value)) {
for (const elem of value) {
if (typeof elem === 'object') {
deserialize(elem, replay);
}
}
} else if (typeof value === 'object') {
deserialize(value, replay)
} else if (key.endsWith(kSerial)) {
const type = key.substring(0, key.length - kSerial.length);
traceObject[type] = replay[`${type}s`][value];
delete traceObject[key]; // probably needs to be moved out of loop
}
}
}
I don't know if that would be generic enough or if there'd be so many exceptions it's not worth it.
There's lots of trace data that's like
And there is code that converts
textureSerial: numbertotexture: someReplayTextureIt made me wonder if there would be any benefit from trying to make that code just scan every trace object for
xxxSerialand then do auto convert. Something likeI don't know if that would be generic enough or if there'd be so many exceptions it's not worth it.