// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import { NumericType } from "@foxglove/schemas";
import { estimateObjectSize } from "@foxglove/studio-base/players/messageMemoryEstimation.js";
import { fromMillis } from "../../utils.js";
export function deserializePointCloudData({ topic, message, callback }) {
    const receiveTime = fromMillis(Date.now());
    const foxgloveMessage = {
        timestamp: receiveTime,
        frame_id: `pointcloud-${topic}-frame`,
        point_stride: 12,
        pose: {
            position: { x: 0, y: 0, z: 0 },
            orientation: { x: 0, y: 0, z: 1, w: 0 }
        },
        fields: [
            { name: "x", offset: 0, type: NumericType.FLOAT32 },
            { name: "y", offset: 4, type: NumericType.FLOAT32 },
            { name: "z", offset: 8, type: NumericType.FLOAT32 },
        ],
        data: message.data
    };
    if (message.color) {
        foxgloveMessage.fields.push({ name: "red", offset: 12, type: NumericType.UINT8 }, { name: "green", offset: 13, type: NumericType.UINT8 }, { name: "blue", offset: 14, type: NumericType.UINT8 }, { name: "alpha", offset: 15, type: NumericType.UINT8 });
        foxgloveMessage.point_stride = 16;
    }
    callback({
        topic,
        receiveTime,
        message: foxgloveMessage,
        sizeInBytes: estimateObjectSize(foxgloveMessage),
        schemaName: "foxglove.PointCloud.Colored",
    });
}
//# sourceMappingURL=point-cloud.js.map