import { Texture, Mesh, Camera, ISize } from '../loader/babylonjs-import';
import { Icon } from './Icon';
import { BimCoreApi } from '../BimCoreApi';
import { SelectablesRenderOperation } from '../loader/Selectables';
/** Common icon atlas options. */
export interface IconAtlasOptionsCommon {
    /** Power of 2 texture, containing squared icons in grayscale or color. You can use {@link getTexture} to load texture from URL. */
    iconAtlasTexture: Texture;
    /** E.g in a texture with 4 X 4 icons, the total amount is 16 */
    totalNumberOfIconsAndStyles: number;
    /** The number of different icon in the same style. All icons in the set needs to have the same amount of style variations. */
    numberOfIconsInAStyle: number;
    /** Set the maximum size a icon can have. If not specified default is 16. Each icon can scale this value down by setting {@link Icon.size} to a skale between 0-1 */
    iconMaxSize?: number;
    /**
     * If specified occlusion culling occurs at this interval in ms.
     * If 0 occlusion culling occurs on every frame (very expensive)
     * */
    occlusionCullingIntervalMs?: number;
}
/** Icon atlas options only relevant for icons where icon alpha is only used for
 *  masking out fully transparent areas of the icons. For example the glass pixels of a magnifying glass
 *  may have a alpha of 0. The icon will therefore be rendered with a "see through" hole at those pixels
 *  while the remaining pixels will be rendered as is.
 */
export interface IconAtlasOptionsNoAlpha extends IconAtlasOptionsCommon {
    /** Texture contains no alpha.*/
    hasAlpha: false;
}
/** Icon atlas options only relevant for icons where icon alpha is used for opacity */
export interface IconAtlasOptionsAlpha extends IconAtlasOptionsCommon {
    /**
     * Texture atlas contains alpha, all the icons will be alpha sorted
     * at interval specified by {@link alphaSortIntervalInMs}. It is very expensive
     * to alpha sort icons so use with care and try not to use too many icons.
     * The more there are the more expensive the sort operation will become.
     * Framerate and navigation will degrade quickly. How much depends on how powerful
     * the device running the code is.
     * */
    hasAlpha: true;
    /**
     * If specified alpha sorting occurs at this interval (in ms).
     * If 0 alpha sorting occurs on every rendered frame. This is expensive
     * Defaults to 500ms if not specified.
     */
    alphaSortIntervalInMs?: number;
}
export type IconAtlasOptions = IconAtlasOptionsNoAlpha | IconAtlasOptionsAlpha;
/**
 * Icon Handler is a class for handling a set of Icon:s.
 * Make a instance and setIconAtlas with a texture.
 * Then addIcons to provide a array of Icon[].
 * Each Icon in the handler can be updated using forEach().
 * Followed by update().
 */
export declare class IconHandler {
    readonly api: BimCoreApi;
    private static _iconHandlerNextId;
    private static readonly _defaultAlphaSortInterval;
    private static readonly _defaultIconMaxSize;
    private readonly _icons;
    private readonly _iconsById;
    private readonly _iconBaseSize;
    private readonly _material;
    private readonly _vertexData;
    private readonly _pointMesh;
    private _textureHasAlpha;
    private _numberOfIconsInARow;
    private _numberOfIconsInStyle;
    private _pixelsPerIcon;
    private _iconMaxSize;
    private readonly _beforeRenderObserver;
    private readonly _stopWatch;
    private _beforeRenderOptions;
    /**
     * Dirty icons
     * @hidden
     * @internal
     */
    readonly _dirtyIcons: Set<Icon>;
    /** Unique id of {@link IconHandler}. */
    readonly id: number;
    /**
     * Defines how often the {@link Icon}s in the {@link IconHandler} are
     * occlusion culled in milliseconds.
     * - If 0 then occlusion culling runs every frame. Very expensive. Avoid
     * - If > 0 then occlusion culling runs only when the interval is exceeded.
     * - If < 0 occlusion culling is disabled.
     * - Defaults to -1
     */
    occlusionCullingInterval: number;
    /**
     * Defines how often the {@link Icon}s in the {@link IconHandler} are
     * alpha sorted (back to front) relative the camera if icons are transparent.
     * - If 0 then alpha sort  runs every frame. Very expensive. Avoid
     * - If > 0 then alpha sort culling runs only when the interval is exceeded.
     * - If < 0 alpha sort is disabled.
     * - Defaults to 500 ms.
     */
    alphaSortInterval: number;
    /**
     * A Icon Handler holds and handle interaction of icons and it´s gpu representation.
     * @param api The API is required for accessing current scene.
     * @param options Here you can provide a everything you need to set the icon texture atlas.
     * @example
     * ```typescript
     * // Create an IconHandler instance.
     * const iconHandler = new IconHandler(api);
     * // Add a icon atlas to use for all icons. Provide the babylonTextre, the total icon count, the amount of icons in a group and if the texture use the alpha channel.
     * iconHandler.setIconAtlas({
     *     texture: (await getTexture('./icon.png')),
     *     totalNumberOfIconsAndStyles: 100,
     *     numberOfIconsInAStyle: 1,
     *     hasAlpha: true
     * });
     * // Add a icon to be renderd.
     * iconHandler.attach(new Icon(
     *    "someId",
     *    Math.floor(Math.random() * 100), // Use a random icon form the 10X10 icon atlas.
     *    0, // Use a style index, in this case there is no groups of icons in the texture atlas, so we use the first icon.
     *    1, // Size
     *    new Vector3(0, 0, 0), // Add a position for the icon. (at origin in this case).
     *    new Color4(Math.random(), Math.random(), Math.random(), 1) // Add a random color to the icon, and the max size to the icon. (1).
     * ));
     * ```
     */
    constructor(api: BimCoreApi, options?: IconAtlasOptions);
    /**
     * Sets the render group id 0-4 for all icons.
     * Use this with a larger value to render it on top of other geometry in the engine.
     */
    set renderGroup(i: number);
    /** Render group icons are rendered in.*/
    get renderGroup(): number;
    /** Number if icons. */
    get iconCount(): number;
    /** Icons currently attached to {@link IconHandler}. */
    icons(): IterableIterator<Icon>;
    /***
     * Get Icon by id.
     * @param id Id of icon to get.
     * @return {@link Icon} or `undefined` if no {@link Icon} was found.
     */
    getIconById(id: string): Icon | undefined;
    /**
     * Returns the internal mesh.
     * @hidden
     * @internal
     */
    get _mesh(): Mesh;
    private get _viewCamera();
    /**
     * This function adds a texture and metadata about it to the icon handler.
     * Changes are automatically reflected in rendering.
     * @param o - Option in the form of IconAtlasOptions.
     */
    setIconAtlas(o: IconAtlasOptions): void;
    /**
     * This function insert icons to the handler.
     * @param icons A array of icons or a icon to render in scene.
     */
    attach(icons: Icon[] | Icon): void;
    /**
     * This function detach icons from the handler and remove it from picking if it´s clickable.
     * @param icons A array of icons or a icon to remove from scene.
     */
    detach(icons: Icon[] | Icon): void;
    /**
     * Clears icon handler of all currently attached icons. Attached icons will
     * be detached.
     */
    clear(): void;
    /**
     * Disposes icon handler. Call when it is no longer in use.
     * After call the icon handler cannot be used again.
     */
    dispose(): void;
    /**
     * Iterate over each icon in the handler. See also  {@link icons}.
     * @param action This method will run on each icon in the handler. This is a easy way for updating its position or color.
     */
    forEach(action: (i: Icon) => unknown): void;
    /**
     * Only for internal use. {@link GpuSelectables} calls this method
     * right before initiating a GPU picking render operation. The method
     * sets the {@link IconHandler} to GPU picking render mode and resets
     * it when {@link SelectablesRenderOperation.done} is called on the returned value
     * @hidden
     * @internal
     * @param camera GPU picking camera
     * @param targetSize GPU picking render target texture size
     * @returns {@link SelectablesRenderOperation}. {@link SelectablesRenderOperation.done} is called on it when
     * {@link GpuSelectables} has finished the GPU pick render pass.
     */
    _beginGpuPickingOperation(camera: Camera, targetSize: ISize): SelectablesRenderOperation;
    private applyPendingOperationsBeforeRender;
    private copyIconsToVertexBufferAndApplyToMesh;
    /**
     * Get all icons that are not occluded if seeen from the camera. Icons cannot be occluded by windows.
     * Warning. This is a very expensive operation. Do not call on every frame if scene is complex or there
     * is a lot of icons.
     */
    private occlusionCullIcons;
    private updateIsOccludedState;
    private ensureWindowIsInvisible;
    private ensureIconIsPickableAndNotOccluded;
    private copyToPositions;
    private copyToColors;
    private copyToNormals;
    /**
     * Sorts and update icons based on icon distance to position.
     * Sort order is automatically reflected in rendering.
     * @param position position to measure icon distance to.
     */
    private sortIconsBackToFront;
    /**
     * Sets relative icon size, based on camera and render target texture size.
     * If no parameters are provided as arguments, the icon size will be reset based on default Pivot Target Camera.
     * @param camera Camera to use for compute relative icon size. If not provided, use twinfinity default Pivot Target Camera as view camera.
     * @param targetTextureWidth Width of target texture to be render. If not provided, do not calculate relative icon size to target texture.
     * @param targetTextureHeight Height of target texture to be render. If not provided, do not calculate relative icon size to target texture.
     */
    private setOrResetRelativeIconSize;
    private throwIfIconAttachedToOtherIconHandler;
    private static addShaders;
}
//# sourceMappingURL=IconHandler.d.ts.map