/** @internal NOTE: Internal APIs. Subject to change. Use of these APIs in production applications is not supported. */ /** */
import { BimProductMesh } from './BimProductMesh';
import { BimIfcObject } from './bim-ifc-object';
import { Vector3, Geometry, Mesh, Engine } from './babylonjs-import';
import { GeometryArrays, GeometryBuffer } from './GeometryBuffer';
import { Writeable } from '../Types';
/** Lookup for finding all the meshes of an IFC object  */
export type BimIfcProductsAndMeshes = ReadonlyMap<BimIfcObject, ReadonlySet<BimProductMesh>>;
/**
 * Represents a handle for a 3D geometry.
 * Can be used to unload the geometry from the GPU.
 */
export declare class Geometry3dHandle {
    readonly id: string;
    readonly aabb: {
        min: Vector3;
        max: Vector3;
    };
    readonly isTransparent: boolean;
    readonly productsAndMeshes: BimIfcProductsAndMeshes;
    readonly cullingDistance: number;
    readonly center: Vector3;
    /**
     * Creates a new instance of the {@link Geometry3dHandle} class.
     * @param id - The unique identifier for the geometry.
     * @param aabb - The axis-aligned bounding box of the geometry.
     * @param isTransparent - Indicates whether the geometry is transparent.
     * @param productsAndMeshes - The products and meshes associated with the geometry.
     * @param cullingDistance - The distance at which the geometry should be culled.
     * @param center - The center of the geometry's axis-aligned bounding box in IFC space.
     */
    constructor(id: string, aabb: {
        min: Vector3;
        max: Vector3;
    }, isTransparent: boolean, productsAndMeshes: BimIfcProductsAndMeshes, cullingDistance: number, center: Vector3);
    /**
     * Flags all the {@link IfcProductMesh} instances this instance
     * refers to as being not on the GPU. Allows for them to be remeshed
     * in a call tocalling {@link BimIfcLoaderElement.geometryBuilder}.
     * Not intended to be called by the user.
     * @hidden
     */
    _resetBuildId(): void;
}
/** Represents a geometry that consists of one or more IFC objects */
export interface Geometry3d extends GeometryArrays, Geometry3dHandle {
    /** Applies geometry to a babylon {@link Geometry}. */
    applyToGeometry(babylonGeometry: Geometry, engine: Engine): void;
    /** Applies geometry to a babylon {@link Mesh}. */
    applyToMesh(mesh: Mesh, engine: Engine): void;
    /** Copies normals to existing array. */
    copyNormalsTo<T extends Writeable<ArrayLike<number>>>(dst: T): T;
    /**
     * Handle for this geometry. Can be used to unload the geometry from the GPU.
     */
    toHandle(): Geometry3dHandle;
    /**
     * Specifies whether to cull the geometry when the camera moves.
     */
    cullOnCameraMove: boolean;
}
/**
 * Options for merging vertex data.
 */
export interface VertexDataMergeOptions {
    /**
     * Specifies whether to disable transparency and merge ID checks.
     */
    disableTransparencyAndMergeIdChecks?: boolean;
    /**
     * Specifies whether to include normals in the merged vertex data.
     * Not including it speeds up the {@link VertexDataMerge.merge} operation.
     * However calling {@link VertexDataMerge.applyToMesh} or {@link VertexDataMerge.applyToGeometry}
     * will then not include the normals
     */
    includeNormals?: boolean;
    /**
     * Specifies whether to cull the geometry when the camera moves.
     */
    cullOnCameraMove?: boolean;
    /**
     * Specifies whether to use the transform cache when writing vertex data.
     * Defaults to `true`. When set to `false`, the transform cache will not be used to optimize vertex data writing.
     * This can improve performance when merging large amounts of geometry.
     * It does however increase memory usage since transforms are kept in cache until {@link BimIfcLoaderElement.transformsRepository.clear} is called.
     */
    noTransformCache?: boolean;
    /**
     * If `true`, {@link VertexDataMerge.merge} will replace its internal geometry arrays with tightly-sized copies
     * of the actually-written prefix once merging completes. This releases the slack reserved in the
     * backing {@link GeometryBuffer} (which is over-estimated for per-face-normal expansion / vertex dedup)
     * so the underlying ArrayBuffers become GC-eligible as soon as no other references exist.
     *
     * Use this when the {@link GeometryBuffer} is dedicated to a single merge and the resulting geometry
     * is handed to a long-lived consumer. Do NOT use it when the {@link GeometryBuffer} is pooled across
     * many merges — compaction would defeat the pool by allocating fresh arrays per merge.
     *
     * Defaults to `false`.
     */
    compactAfterMerge?: boolean;
}
/**
 * Returns the number of primitive (vertex) slots that must be reserved in a {@link GeometryBuffer}
 * for `mesh` before a merge runs. For `t8gd` meshes with `includeNormals` true this is the worst-case
 * `descriptor.i` (per-face-normal expansion before WASM dedup); otherwise `descriptor.p`.
 *
 * Single source of truth shared between {@link VertexDataMerge}'s constructor and external callers
 * that pre-size the buffer (e.g. `BimIfcObject.initializeCreateGeometryFrom`).
 */
export declare function reservedPrimitiveCount(mesh: BimProductMesh, includeNormals: boolean): number;
export declare class VertexDataMerge implements Geometry3d {
    readonly id: string;
    private _meshes;
    private static readonly _emptyFloat32Array;
    private static readonly _emptyUint16Array;
    private _cullingDistance;
    primitiveCount: number;
    indiceCount: number;
    get positions(): typeof this._geometry.positions;
    get uvs(): typeof this._geometry.uvs;
    get indices(): typeof this._geometry.indices;
    get cullingDistance(): number;
    private _geometry;
    private _currentOffset;
    readonly isTransparent: boolean;
    private _options;
    private readonly _aabb;
    constructor(id: string, geometryBuffer: GeometryBuffer, _meshes: BimProductMesh[], options?: VertexDataMergeOptions);
    /**
     * Not intended to be called by the user. Use `this.toHandle()._resetBuildId()` instead.
     * @hidden
     */
    _resetBuildId(): void;
    readonly productsAndMeshes: Map<BimIfcObject, Set<BimProductMesh>>;
    get cullOnCameraMove(): boolean;
    get aabb(): {
        min: Vector3;
        max: Vector3;
    };
    get center(): Vector3;
    /**
     * Applies the geometry data this instances represents ({@link positions}, {@link uvs}, {@link indices}, {@link aabb} and optionally `normals`.)
     * to the specified {@link Mesh}.
     * @param mesh {@link Mesh} to receive geometry data.
     */
    applyToMesh(mesh: Mesh, engine: Engine): void;
    /**
     * Applies the geometry data this instances represents ({@link positions}, {@link uvs}, {@link indices}, {@link aabb} and optionally `normals`.)
     * to the specified {@link Geometry}.
     * Notice that the geometry is in IFC space. If geometry is assing to a {@link Mesh} one can use {@link coordinateSystems.toBabylonTransform}
     * as the mesh pretransform matrix. This will ensure that mesh behaves as if it is in BabylonJS worldspace.
     * @param babylonGeometry {@link Geometry} to receive geometry data.
     */
    applyToGeometry(babylonGeometry: Geometry, engine: Engine): void;
    copyNormalsTo<T extends Writeable<ArrayLike<number>>>(dst: T): T;
    merge(): Geometry3d;
    /**
     * Replaces the internal geometry arrays with tightly-sized copies of the actually-written prefix.
     * After this call, the views into the {@link GeometryBuffer} that backed the merge are dropped, so the
     * underlying ArrayBuffers become GC-eligible once the {@link GeometryBuffer} itself goes out of scope.
     *
     * Safe to call only after {@link merge}. Result-equivalent on repeated calls but each call performs
     * a fresh allocation; do not call more than once per merge. {@link _currentOffset} is preserved so
     * that {@link applyToGeometry} and {@link copyNormalsTo} continue to compute identical bounds.
     *
     * The indices array constructor (Uint16Array vs Uint32Array) is preserved; we deliberately do NOT
     * downgrade Uint32 to Uint16 even when the actual position count fits, because consumers may hold
     * references typed against the original choice.
     */
    compact(): void;
    toHandle(): Geometry3dHandle;
}
//# sourceMappingURL=vertex-data-merge.d.ts.map