MCPcopy Create free account
hub / github.com/ColmapView/Colmapview.github.io / prefetchUrlImages

Function prefetchUrlImages

src/utils/urlImageFiles.ts:236–249  ·  view source on GitHub ↗
(
  imageUrlBase: string | null,
  imageNames: string[],
  concurrency: number = 5,
  imageNameToUrl?: Record<string, string>
)

Source from the content-addressed store, hash-verified

234 * Useful for preloading visible frustum images.
235 */
236export async function prefetchUrlImages(
237 imageUrlBase: string | null,
238 imageNames: string[],
239 concurrency: number = 5,
240 imageNameToUrl?: Record<string, string>
241): Promise<void> {
242 const toFetch = imageNames.filter(name => !urlImageState.hasCached(name));
243 if (toFetch.length === 0) return;
244
245 for (let i = 0; i < toFetch.length; i += concurrency) {
246 const batch = toFetch.slice(i, i + concurrency);
247 await Promise.all(batch.map(name => fetchUrlImage(imageUrlBase, name, imageNameToUrl?.[name])));
248 }
249}
250
251/**
252 * Get URL image cache statistics.

Callers 2

prefetchImagesFunction · 0.90

Calls 2

fetchUrlImageFunction · 0.85
hasCachedMethod · 0.80

Tested by

no test coverage detected