import { BinaryClassSerializationAdapter } from "../../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
import { Camera } from "../Camera.js";

export class CameraSerializationAdapter extends BinaryClassSerializationAdapter {

    klass = Camera;
    version = 0;

    /**
     *
     * @param {BinaryBuffer} buffer
     * @param {Camera} value
     */
    serialize(buffer, value) {
        buffer.writeUint8(value.autoClip ? 1 : 0);
        value.active.toBinaryBuffer(buffer);

        // TODO serialize hysteresis

        // TODO serialize fov
    }

    /**
     *
     * @param {BinaryBuffer} buffer
     * @param {Camera} value
     */
    deserialize(buffer, value) {
        value.autoClip = buffer.readUint8() !== 0;
        value.active.fromBinaryBuffer(buffer);
    }
}
