new LayerGl()
WebGL for tile layers. runs each tile layer cell image data or other form of tile-based data through WebGL shaders
- Source:
Extends
- L.GridLayer
Members
(static) _CRSBuffer :WebGLBuffer
the easting, northing
CRS coords buffer
Type:
- WebGLBuffer
- Source:
(static) _glProgram :WebGLProgram
primary WebGLProgram
created
Type:
- WebGLProgram
- Source:
(static) _LatLngBuffer :WebGLBuffer
the easting, northing
lat/lng coords buffer
Type:
- WebGLBuffer
- Source:
(static) _TexCoordsBuffer :WebGLBuffer
the texel coords buffer
Type:
- WebGLBuffer
- Source:
(static) _uniformSizes :Object
determines the size of the default values given for the uniforms and loads the uniform name from the shader header
Type:
- Object
- Source:
(static) _VertexCoordsBuffer :WebGLBuffer
the vertex coords buffer
Type:
- WebGLBuffer
- Source:
options :Object
layer options
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
uniforms |
object | a key-value list of names and initial values for shader uniforms. values must be |
tileLayers |
object | a key-value list of tile layers where the key is the texture uniform referenced in the shader
|
vertexShader |
string | string representing the GLSL vertex shader to be run. vertex shaders handle the processing of individual vertices. vertex shader must include:
|
fragmentShader |
string | string representing the GLSL fragment shader to be run. fragment shaders handle the processing of individual vertex fragments fragments shader must include:
|
extensions |
array | extensions to load into the WebGL program.
the default program requires linear filtering for floating-point textures so
|
- Source:
Methods
initialize(optionsopt)
leaflet initialize method instantiating the layer will initialize all the GL context and upload shaders and vertex buffers to the GPU (the vertices will stay the same for all tiles).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
object |
<optional> |
{} | layer options |
- Source:
(inner) _bindTexture(index, imageData)
binds a ImageData
(HTMLImageElement
, HTMLCanvasElement
or ImageBitmap
) to a texture, given its index
(0 to 7). the image data is assumed to be in 8-bit RGBA format. TEXTURE0 corresponds to the
WebGL pointer 0x84C0 - add index integer to specify texture channel pointer
Parameters:
Name | Type | Description |
---|---|---|
index |
number | index of texture uniform |
imageData |
TexImageSource | image data from tile data ref: |
- Source:
(inner) _bindTextureArrays(index, arrays)
binds an array of TypedArrays
(array containing Float32Array
) , given its index (0 to 7).
the image data is assumed to not be in 8-bit RGBA format.
type is inferred from the type of the typed array.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | index of texture uniform |
arrays |
ArrayBufferView | image data from tile data ref: |
- Source:
(inner) _getUniformSizes()
determines the size of the default values given for the uniforms.
loads a string value for defining the uniforms in the shader header into _uniformSizes
- Source:
(inner) _initUniforms(program)
initializes the u_Now
uniform, and user-provided uniforms from the current GL program.
sets the _isReRenderable
property if there are any set uniforms.
Parameters:
Name | Type | Description |
---|---|---|
program |
WebGLProgram | WebGlProgram (using as param to support multiple programs in the future)
|
- Source:
(inner) _linkShader(shaderCode, type) → {WebGLShader}
shader type being linked
Parameters:
Name | Type | Description |
---|---|---|
shaderCode |
string | shader code to compile and link |
type |
'VERTEX_SHADER' | 'FRAGMENT_SHADER' |
|
- Source:
Returns:
returns WebGLShader
if link succeeds
- Type
- WebGLShader
(inner) _loadGLProgram()
create, compile, link, and use the primary webgl program
once loaded and uniforms initialized, create three data buffer with 8 elements each
_CRSBuffer
- theeasting, northing
CRS coords_LatLngBuffer
- theeasting, northing
lat/lng coords- the
s, t
(also referred to asu, v
) texture coords and the viewport coords for each of the 4 vertices
data for the texel and viewport coords is static, and needs to be declared only once
- Source:
(inner) _render(coords)
called once per tile - uses the layer's GL context to render a tile, passing the complex space coordinates to the GPU, and asking to render the vertexes (as triangles) again. it is not necessary to clear the WebGL context, because the shader will overwrite all the pixel values.
Parameters:
Name | Type | Description |
---|---|---|
coords |
Object | coords passed in from |
- Source:
(inner) createTile(coords, done) → {*}
reference leaflet docs
Parameters:
Name | Type | Description |
---|---|---|
coords |
Object | tile coordinates |
done |
function | callback |
- Source:
Returns:
- tile
- Type
- *
(inner) getGlError() → {string|undefined}
if any compiling/linking errors occur in the shaders, returns a string with information about that error
- Source:
Returns:
- glError if exists
- Type
- string | undefined