import * as THREE from 'three'; import type { PageImage } from './options.js'; export interface PageLoaderEvents { onLoad(page: number, texture: THREE.Texture): void; /** The page's texture was freed; show plain paper until it loads again. */ onUnload(page: number): void; onError(page: number, error: unknown): void; } /** * Loads page images into textures, nearest the visible pages first. Pages within `radius` * of the visible ones load; pages more than twice as far unload. Pages show plain paper * until their image arrives. */ export declare class PageLoader { private sources; private readonly renderer; private radius; private readonly events; /** Loaded textures by page; missing pages are still loading, unloaded or failed. */ textures: (THREE.Texture | undefined)[]; private readonly owned; private readonly inFlight; private readonly failed; private readonly pending; private cancelUploads; private first; private from; private to; private around; private wrap; private waiting; private settleFirst; private disposed; constructor(sources: PageImage[], renderer: THREE.WebGLRenderer, radius: number, events: PageLoaderEvents); /** * Starts loading around the visible pages `from`–`to`. Resolves once the `first` pages * within reach are in (or failed). */ start(from: number, to: number, first: number[]): Promise; /** Changes page sources while keeping decoded textures for sources still in the magazine. */ setSources(sources: PageImage[]): void; private showReadyTextures; /** * Follows the reader: loads around the pages in view (`from`–`to`), the page being read * (`around`) first, and unloads pages left far behind. */ focus(from: number, to?: number, around?: number): void; setWrap(wrap: boolean): void; setRadius(radius: number): void; /** Loads the pages that failed again. */ retry(): void; dispose(): void; private distance; private pump; private load; private show; private scheduleUploads; private uploadSome; private createTexture; } /** Loads the paper grain option into a tiling texture. */ export declare function loadGrain(source: string | HTMLImageElement | HTMLCanvasElement): Promise;