MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / getOrLoadFrustumBitmap

Function getOrLoadFrustumBitmap

src/hooks/frustumTextureCache.ts:54–75  ·  view source on GitHub ↗
(
  url: string,
  imageName: string,
  bitmapCache: FrustumBitmapCache,
  deps: LoadFrustumBitmapDeps = {}
)

Source from the content-addressed store, hash-verified

52}
53
54export async function getOrLoadFrustumBitmap(
55 url: string,
56 imageName: string,
57 bitmapCache: FrustumBitmapCache,
58 deps: LoadFrustumBitmapDeps = {}
59): Promise<ImageBitmap | null> {
60 const cached = getCachedFrustumBitmap(bitmapCache, imageName, deps.now);
61 if (cached) return cached;
62
63 try {
64 const fetchBlob = deps.fetchBlob ?? ((input: string) => fetch(input));
65 const createBitmap = deps.createBitmap ?? createImageBitmap;
66 const response = await fetchBlob(url);
67 const blob = await response.blob();
68 const bitmap = await createBitmap(blob);
69
70 bitmapCache.set(imageName, { bitmap, lastUsed: (deps.now ?? Date.now)() });
71 return bitmap;
72 } catch {
73 return null;
74 }
75}
76
77export function getActiveFrustumTexture(
78 activeTextures: FrustumTextureCache,

Callers 1

Calls 3

getCachedFrustumBitmapFunction · 0.85
blobMethod · 0.80
createBitmapFunction · 0.70

Tested by

no test coverage detected