UNPKG

@equinor/videx-map

Version:

Component for Pixi-overlay in Leaflet.

82 lines (81 loc) 2.49 kB
import * as PIXI from 'pixi.js'; import { ModuleInterface } from './ModuleInterface'; export interface OutlineData { coordinates: [number, number][][]; meta: { defaultOn: boolean; fill: string; name: string; stroke: [number, number, number]; type: string; }; } interface Uniforms { color: [number, number, number]; /** Additional width of outline */ width: number; visible: boolean; } /** Interface for outline config. */ interface InputConfig { /** Base with without any scaling. (Default: 0.1) */ baseWidth?: number; minZoom?: number; maxZoom?: number; /** Extra width of line at max zoom. (Default: 0.1) */ minExtraWidth?: number; /** Extra width of line at min zoom. (Default: 10.0) */ maxExtraWidth?: number; } /** Interface for outline config. */ interface Config { /** Base with without any scaling. (Default: 0.1) */ baseWidth: number; /** Reference value for min zoom. (Default: 0) */ minZoom: number; /** Reference value for max zoom. (Default: 18) */ maxZoom: number; /** Extra width of line at max zoom. (Default: 0.0) */ minExtraWidth: number; /** Extra width of line at min zoom. (Default: 0.3) */ maxExtraWidth: number; } /** Current width of outline. */ interface State { extraWidth: number; } /** Module for displaying outlines. */ export default class OutlineModule extends ModuleInterface { /** Mapping outline collection name with corresponding uniforms. */ outlineDict: { [key: string]: Uniforms; }; /** Graphic elements currently existing in world space. */ spawned: PIXI.Mesh[]; /** Vertex shader for the outlines. */ static vertexShader: string; /** Fragment shader for the outlines. */ static fragmentShader: string; /** Default config. */ config: Config; state: State; scaling: (zoom: number) => number; constructor(config?: InputConfig); /** * Set collection of outlines to display. Clears previous content on execution. * @param data Outlines to draw */ set(data: OutlineData[]): void; /** * Set visibility for outline layers. * @param names Names of collections to modify * * @example * setVisibleLayers(['OWC', 'GOC']); */ setVisibleLayers(names: string[]): void; /** Clear all spawned graphic elements and return to pool. */ clear(): void; resize(zoom: number): void; } export {};