MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / generateThumbnailsForModels

Function generateThumbnailsForModels

renderer.js:10972–11196  ·  view source on GitHub ↗
(models)

Source from the content-addressed store, hash-verified

10970 const modelsContainer = document.createElement('div');
10971
10972 // Process each model - use for...of to support async operations
10973 for (const [index, modelData] of finalUniqueModels.entries()) {
10974 const { model, generatedTags, existingTags, errorMessage } = modelData;
10975 const fileName = model.fileName || model.filePath?.split(/[/\\]/).pop() || 'Unknown';
10976 const filePath = model.filePath || 'Unknown path';
10977
10978 // Create model section with unique ID to prevent duplicate rendering
10979 const normalizedModelPath = normalizeFilePath(model.filePath);
10980 const existingSection = modelsContainer.querySelector(`[data-normalized-path="${normalizedModelPath}"]`);
10981 if (existingSection) {
10982 console.warn(`[Tag Preview] Skipping duplicate model section for: ${model.filePath}`);
10983 continue; // Skip if this model section already exists
10984 }
10985
10986 const modelSection = document.createElement('div');
10987 modelSection.style.marginBottom = '25px';
10988 modelSection.style.padding = '15px';
10989 modelSection.style.backgroundColor = '#2a2a2a';
10990 modelSection.style.border = '1px solid #444';
10991 modelSection.style.borderRadius = '8px';
10992 modelSection.dataset.filePath = model.filePath;
10993 modelSection.dataset.normalizedPath = normalizedModelPath;
10994
10995 // Model header with thumbnail
10996 const modelHeader = document.createElement('div');
10997 modelHeader.style.display = 'flex';
10998 modelHeader.style.gap = '12px';
10999 modelHeader.style.marginBottom = '12px';
11000 modelHeader.style.paddingBottom = '10px';
11001 modelHeader.style.borderBottom = '1px solid #444';
11002
11003 // Thumbnail
11004 const thumbnailContainer = document.createElement('div');
11005 thumbnailContainer.style.flexShrink = '0';
11006 thumbnailContainer.style.width = '80px';
11007 thumbnailContainer.style.height = '80px';
11008 thumbnailContainer.style.backgroundColor = '#1a1a1a';
11009 thumbnailContainer.style.border = '1px solid #444';
11010 thumbnailContainer.style.borderRadius = '6px';
11011 thumbnailContainer.style.overflow = 'hidden';
11012 thumbnailContainer.style.display = 'flex';
11013 thumbnailContainer.style.alignItems = 'center';
11014 thumbnailContainer.style.justifyContent = 'center';
11015
11016 const thumbnailImg = document.createElement('img');
11017
11018 // Handle thumbnail loading - especially for 3MF files which may have thumbnails stored differently
11019 let thumbnailSrc = null;
11020
11021 if (model.thumbnail) {
11022 // Check if it's a delimited string (multiple thumbnails)
11023 if (model.thumbnail.includes('::')) {
11024 const thumbnails = model.thumbnail.split('::').filter(t =>
11025 t && t !== '3d.png' && t.length > 0 && t.startsWith('data:image')
11026 );
11027 thumbnailSrc = thumbnails.length > 0 ? thumbnails[0] : null;
11028 } else if (model.thumbnail !== '3d.png' && model.thumbnail.startsWith('data:image')) {
11029 // Single thumbnail

Callers 2

renderer.jsFile · 0.85
promptPendingThumbnailsFunction · 0.85

Calls 1

processModelFunction · 0.85

Tested by

no test coverage detected