@maptiler/sdk
Version: 
The Javascript & TypeScript map SDK tailored for MapTiler Cloud
42 lines (41 loc) • 1.69 kB
TypeScript
import { CubemapFaces } from './types';
interface LoadCubemapTextureOptions {
    gl: WebGLRenderingContext | WebGL2RenderingContext;
    faces?: CubemapFaces;
    onReady: (texture: WebGLTexture, images?: HTMLImageElement[]) => void;
    forceRefresh?: boolean;
}
/**
 * Loads a cubemap texture from a set of image URLs.
 *
 * This function creates and configures a WebGL cubemap texture from a set of images.
 * It memoizes the created texture to avoid redundant loading of the same faces,
 * unless the `forceRefresh` flag is set.
 *
 * @param {Object} options - The options object.
 * @param {WebGLRenderingContext | WebGL2RenderingContext} options.gl - The WebGL rendering context.
 * @param {CubemapFaces} options.faces - An object containing URLs for each face of the cubemap.
 *                                        Must contain exactly 6 faces.
 * @param {Function} [options.onReady] - Optional callback function to be called when all faces are loaded.
 * @param {boolean} [options.forceRefresh] - If true, forces creation of a new texture instead of returning the memoized one.
 *
 * @returns {WebGLTexture | undefined} The created WebGL cubemap texture, or undefined if there was an error.
 *
 * @see {@link facesKey}
 * @see {@link memoizedReturnValue}
 * @example
 * const texture = loadCubemapTexture({
 *   gl: webglContext,
 *   faces: {
 *     px: 'right.jpg',
 *     nx: 'left.jpg',
 *     py: 'top.jpg',
 *     ny: 'bottom.jpg',
 *     pz: 'front.jpg',
 *     nz: 'back.jpg'
 *   },
 *   onReady: () => console.log('Cubemap loaded')
 * });
 */
export declare function loadCubemapTexture({ gl, faces, onReady, forceRefresh }: LoadCubemapTextureOptions): void;
export {};