/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { vertexvis } from "@vertexvis/frame-streaming-protos";
import { Vector3f } from "@vertexvis/scene-view-protos/core/protos/geometry_pb";
import { ModelEntity } from "@vertexvis/scene-view-protos/core/protos/model_entity_pb";
import { MeasureEntity } from "@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb";
import { Mapper } from "@vertexvis/utils";
import { fromPbVector3f } from "../mappers";
export class MeasurementEntity {
    constructor(point, modelEntity) {
        this.point = point;
        this.modelEntity = modelEntity;
    }
    static fromHit(hit) {
        if (hit.hitPoint != null && hit.modelEntity != null) {
            const hitPoint = Mapper.ifInvalidThrow(fromPbVector3f)(hit.hitPoint);
            const modelEntity = vertexvis.protobuf.core.ModelEntity.encode(hit.modelEntity).finish();
            return new MeasurementEntity(hitPoint, modelEntity);
        }
        else {
            throw new Error('Cannot create MeasurementEntity from Hit. Hit is missing hit point and model entity');
        }
    }
    toProto() {
        const entity = new MeasureEntity();
        const point = new Vector3f();
        point.setX(this.point.x);
        point.setY(this.point.y);
        point.setZ(this.point.z);
        entity.setPoint(point);
        const modelEntity = ModelEntity.deserializeBinary(this.modelEntity);
        entity.setModelEntity(modelEntity);
        return entity;
    }
}
//# sourceMappingURL=entities.js.map
