This is the documentation of version 1.0.0-rc.4. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias MapEffectsPass

    A full-screen GPU pass of your own, run inside the plugin's WebGL chain, such as a watercolour or posterise stylisation that the rest of the effects should then work on.

    type MapEffectsPass = {
        fragment: string;
        id: string;
        mipmapped?: boolean;
        placement?: MapEffectsPassPlacement;
        textures?: Record<
            string,
            TexImageSource
            | (() => TexImageSource | undefined),
        >;
        uniforms?: MapEffectsPassUniforms | (() => MapEffectsPassUniforms);
    }
    Index
    fragment: string

    A GLSL ES 3.00 fragment shader with your own uniforms and main. The plugin declares the version, the precisions, uniform sampler2D uSource (the picture so far), in vec2 vUv and out vec4 fragColor. Declaring any of them again is a compile error.

    id: string

    Names the pass for MapEffects.removePass. Adding a pass under an id in use replaces it in place.

    mipmapped?: boolean

    Whether the shader reads uSource at mip levels other than 0, with textureLod. The plugin then builds the picture's mip levels before the pass. Without it, every level reads as level 0.

    Defaults to before-depth-of-field.

    textures?: Record<string, TexImageSource | (() => TexImageSource | undefined)>

    The textures the shader samples besides uSource, each under the name of the uniform sampler2D it declares, or a function returning one, called on every draw. They bind to texture units 1 to 15, in the order given.

    • A video or a canvas is uploaded on every draw, since its pixels change under the same object. An image, an ImageBitmap, a VideoFrame or ImageData is uploaded once: to change its picture, hand a new object.
    • A texture is uploaded the same way up as uSource, so texture(uPaper, vUv) lays it over the frame upright. It is sampled linearly, repeats past its edges and has no mip levels.
    • An image that has not loaded, a video without a frame, or a function returning undefined, skips the pass for that draw. Its textures are freed when the pass is removed.

    The uniform values, or a function returning them, called on every draw. A function that throws skips the pass for that draw, with one warning.