( imageUrlBase: string | null, imageNames: string[], concurrency: number = 5, imageNameToUrl?: Record<string, string> )
| 234 | * Useful for preloading visible frustum images. |
| 235 | */ |
| 236 | export 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. |
no test coverage detected