@allmaps/render
Version:
Render functions for WebGL and image buffers
47 lines (46 loc) • 1.42 kB
JavaScript
import { BaseRenderer } from "./BaseRenderer.js";
import { createWarpedMapFactory } from "../maps/WarpedMap.js";
import { CacheableIntArrayTile } from "../tilecache/CacheableIntArrayTile.js";
import { renderToIntArray } from "../shared/render-to-int-array.js";
const CHANNELS = 4;
class IntArrayRenderer extends BaseRenderer {
getImageDataValue;
getImageDataSize;
constructor(getImageData, getImageDataValue, getImageDataSize, options) {
super(
CacheableIntArrayTile.createFactory(getImageData),
createWarpedMapFactory(),
options
);
this.getImageDataValue = getImageDataValue;
this.getImageDataSize = getImageDataSize;
}
/**
* Render the map for a given viewport.
*
* @param viewport - the viewport to render
*/
async render(viewport) {
this.viewport = viewport;
await Promise.allSettled(this.loadMissingImageInfosInViewport());
this.assureProjection();
this.requestFetchableTiles();
await this.tileCache.allRequestedTilesLoaded();
const intArray = new Uint8ClampedArray(
this.viewport.canvasSize[0] * this.viewport.canvasSize[1] * CHANNELS
);
await renderToIntArray(
this.warpedMapList,
this.tileCache,
this.viewport,
this.getImageDataValue,
this.getImageDataSize,
intArray
);
return intArray;
}
}
export {
IntArrayRenderer
};
//# sourceMappingURL=IntArrayRenderer.js.map