@allmaps/render
Version:
Render functions for WebGL and image buffers
281 lines (279 loc) • 8.71 kB
TypeScript
import { BaseRenderer } from './BaseRenderer.js';
import { WebGL2WarpedMap } from '../maps/WebGL2WarpedMap.js';
import { Viewport } from '../viewport/Viewport.js';
import { FetchableTile } from '../tilecache/FetchableTile.js';
import { Renderer, RenderOptions, RemoveColorOptions, ColorizeOptions, GridOptions, WebGL2RendererOptions } from '../shared/types.js';
/**
* Class that renders WarpedMaps to a WebGL 2 context
*/
export declare class WebGL2Renderer extends BaseRenderer<WebGL2WarpedMap, ImageData> implements Renderer {
#private;
gl: WebGL2RenderingContext;
partialWebgl2RendererOptions: Partial<WebGL2RendererOptions>;
mapProgram: WebGLProgram;
linesProgram: WebGLProgram;
pointsProgram: WebGLProgram;
previousSignificantViewport: Viewport | undefined;
opacity: number;
saturation: number;
renderOptions: RenderOptions;
lastAnimationFrameRequestId: number | undefined;
animating: boolean;
transformaterTransitionStart: number | undefined;
animationProgress: number;
disableRender: boolean;
private throttledPrepareRenderInternal;
private throttledChanged;
/**
* Creates an instance of WebGL2Renderer.
*
* @constructor
* @param gl - WebGL 2 rendering context
* @param options - options
*/
constructor(gl: WebGL2RenderingContext, options?: Partial<WebGL2RendererOptions>);
initializeWebGL(gl: WebGL2RenderingContext): void;
/**
* Get the opacity of the renderer
*
* @returns
*/
getOpacity(): number | undefined;
/**
* Set the opacity of the renderer
*
* @param opacity - opacity to set
*/
setOpacity(opacity: number): void;
/**
* Reset the opacity of the renderer
*/
resetOpacity(): void;
/**
* Get the opacity of a map
*
* @param mapId - ID of the map
* @returns
*/
getMapOpacity(mapId: string): number | undefined;
/**
* Set the opacity of a map
*
* @param mapId - ID of the map
* @param opacity - opacity to set
*/
setMapOpacity(mapId: string, opacity: number): void;
/**
* Rreset the opacity of a map
*
* @param mapId - ID of the map
*/
resetMapOpacity(mapId: string): void;
/**
* Get the remove color options of the renderer
*
* @returns
*/
getRemoveColorOptions(): Partial<RemoveColorOptions> | undefined;
/**
* Set the remove color options of the renderer
*
* @param removeColorOptions
*/
setRemoveColorOptions(removeColorOptions: RemoveColorOptions): void;
/**
* Reset the remove color options of the renderer
*/
resetRemoveColorOptions(): void;
/**
* Get the remove color options of a map
*
* @param mapId - ID of the map
* @returns
*/
getMapRemoveColorOptions(mapId: string): Partial<RemoveColorOptions> | undefined;
/**
* Set the WebGL2 Renderer options
*
* @param partialWebgl2RendererOptions - Options
*/
setOptions(partialWebgl2RendererOptions?: Partial<WebGL2RendererOptions>): void;
/**
* Set the remove color options of a map
*
* @param mapId - ID of the map
* @param removeColorOptions - the 'remove color options' to set
*/
setMapRemoveColorOptions(mapId: string, removeColorOptions: RemoveColorOptions): void;
/**
* Reset the remove color options of a map
*
* @param mapId - ID of the map
*/
resetMapRemoveColorOptions(mapId: string): void;
/**
* Get the colorize options of the renderer
*
* @returns
*/
getColorizeOptions(): Partial<ColorizeOptions> | undefined;
/**
* Set the colorize options of the renderer
*
* @param colorizeOptions - the colorize options to set
*/
setColorizeOptions(colorizeOptions: ColorizeOptions): void;
/**
* Reset the colorize options of the renderer
*/
resetColorizeOptions(): void;
/**
* Get the colorize options of a map
*
* @param mapId - ID of the map
* @returns Colorize options
*/
getMapColorizeOptions(mapId: string): Partial<ColorizeOptions> | undefined;
/**
* Set the colorize options of a map
*
* @param mapId - ID of the map
* @param colorizeOptions - the colorize options to set
*/
setMapColorizeOptions(mapId: string, colorizeOptions: ColorizeOptions): void;
/**
* Reset the colorize options of a map
*
* @param mapId - ID of the map
*/
resetMapColorizeOptions(mapId: string): void;
/**
* Get the grid options of the renderer
*
* @returns
*/
getGridOptions(): Partial<GridOptions> | undefined;
/**
* Set the grid options of the renderer
*
* @param gridOptions - the grid options to set
*/
setGridOptions(gridOptions: GridOptions): void;
/**
* Reset the grid options of the renderer
*/
resetGridOptions(): void;
/**
* Get the grid options of a map
*
* @param mapId - ID of the map
* @returns
*/
getMapGridOptions(mapId: string): Partial<GridOptions> | undefined;
/**
* Set the grid options of a map
*
* @param mapId - ID of the map
* @param gridOptions - the grid options to set
*/
setMapGridOptions(mapId: string, gridOptions: GridOptions): void;
/**
* Reset the grid options of a map
*
* @param mapId - ID of the map
*/
resetMapGridOptions(mapId: string): void;
/**
* Get the saturation of the renderer
*
* @returns
*/
getSaturation(): number;
/**
* Set the saturation of the renderer
*
* 0 - grayscale, 1 - original colors
*
* @param saturation - the satuation to set
*/
setSaturation(saturation: number): void;
/**
* Reset the satuation of the renderer
*/
resetSaturation(): void;
/**
* Get the saturation of a map
*
* @param mapId - ID of the map
* @returns
*/
getMapSaturation(mapId: string): number | undefined;
/**
* Set the saturation of a map
*
* 0 - grayscale, 1 - original colors
*
* @param mapId - ID of the map
* @param saturation - the saturation to set
*/
setMapSaturation(mapId: string, saturation: number): void;
/**
* Reset the saturation of a map
*
* @param mapId - ID of the map
*/
resetMapSaturation(mapId: string): void;
/**
* Render the map for a given viewport.
*
* If no viewport is specified the current viewport is rerendered.
* If no current viewport is known, a viewport is deduced based on the WarpedMapList and canvas width and hight.
*
* @param viewport - the current viewport
*/
render(viewport?: Viewport): void;
clear(): void;
cancelThrottledFunctions(): void;
destroy(): void;
protected updateMapsForViewport(tiles: FetchableTile[]): {
mapsEnteringViewport: string[];
mapsLeavingViewport: string[];
};
protected resetPrevious(mapIds?: string[]): void;
protected updateVertexBuffers(mapIds?: string[]): void;
private prepareRenderInternal;
protected shouldRequestFetchableTiles(): boolean;
protected shouldAnticipateInteraction(): boolean;
private renderInternal;
private renderMapsInternal;
private renderLinesInternal;
private renderPointsInternal;
private setMapProgramUniforms;
private setMapProgramRenderOptionsUniforms;
private setMapProgramMapUniforms;
private setLinesProgramUniforms;
private setLinesProgramMapUniforms;
private setPointsProgramUniforms;
private setPointsProgramMapUniforms;
private startTransformerTransition;
private transformerTransitionFrame;
private finishTransformerTransition;
private changed;
protected imageInfoLoaded(event: Event): void;
protected clearMap(mapId: string): void;
protected mapTileLoaded(event: Event): void;
protected mapTileRemoved(event: Event): void;
protected warpedMapAdded(event: Event): void;
protected preChange(event: Event): void;
protected optionsChanged(event: Event): void;
protected gcpsChanged(event: Event): void;
protected resourceMaskChanged(event: Event): void;
protected transformationChanged(event: Event): void;
protected distortionChanged(event: Event): void;
protected internalProjectionChanged(event: Event): void;
protected projectionChanged(event: Event): void;
private addEventListenersToWebGL2WarpedMap;
private removeEventListenersFromWebGL2WarpedMap;
contextLost(): void;
contextRestored(): void;
}