From 246da0019a453c00ca280aafd201de2fe9343425 Mon Sep 17 00:00:00 2001 From: math-pixel <59537610+math-pixel@users.noreply.github.com> Date: Wed, 20 May 2026 16:56:01 +0200 Subject: [PATCH] add transparency gps --- public/map_background.png | 4 ++-- src/components/ebike/EbikeGPSMap.tsx | 22 +++++++++++++--------- src/pages/backgroundmap/page.tsx | 2 +- src/world/debug/TestMap.tsx | 20 ++++++++++++-------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/public/map_background.png b/public/map_background.png index 1c439a9..680bb4e 100644 --- a/public/map_background.png +++ b/public/map_background.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:330ec029e4398006c02c40d4fb1b57d7d100b857220dd83d092b5f38e33be683 -size 731900 +oid sha256:2e67d0ab997e0470c66d023cee3dae28be952a09a8dc4c96e047ee79cc4ba995 +size 1070216 diff --git a/src/components/ebike/EbikeGPSMap.tsx b/src/components/ebike/EbikeGPSMap.tsx index 140ed3b..441bb92 100644 --- a/src/components/ebike/EbikeGPSMap.tsx +++ b/src/components/ebike/EbikeGPSMap.tsx @@ -58,7 +58,7 @@ export const EbikeGPSMap: React.FC = ({ height = 1, }) => { const [waypoints, setWaypoints] = useState([]); - const [mapImage, setMapImage] = useState(null); + const [mapImage, setMapImage] = useState(null); // Offscreen high-res canvas for crystal clear rendering const [offscreenCanvas] = useState(() => { @@ -102,7 +102,8 @@ export const EbikeGPSMap: React.FC = ({ }); }, []); - // Pre-load background map image if provided + // Pre-load background map image (standard HTML5 Image loader) + // Since the user's PNG is already transparent, we don't need fetch or pixel manipulation! useEffect(() => { if (!mapImageUrl) { setMapImage(null); @@ -110,7 +111,9 @@ export const EbikeGPSMap: React.FC = ({ } const img = new Image(); - img.onload = () => setMapImage(img); + img.onload = () => { + setMapImage(img); + }; img.onerror = () => { console.warn(`[GPS Component] Failed to load map background image from ${mapImageUrl}. Falling back to dynamic vector map.`); setMapImage(null); @@ -170,11 +173,12 @@ export const EbikeGPSMap: React.FC = ({ return { x: px, y: py }; }; + + // Draw loop const draw = () => { const canvas = offscreenCanvas; - const ctx = canvas.getContext('2d'); - ctx.globalAlpha = 0.5; + const ctx = canvas.getContext('2d', { willReadFrequently: true, alpha: true }); if (!ctx) return; const size = canvas.width; @@ -184,10 +188,9 @@ export const EbikeGPSMap: React.FC = ({ // 1. Draw Map Background (Image or premium blueprint vectors) if (mapImage) { ctx.drawImage(mapImage, 0, 0, size, size); + ctx.globalAlpha = 1.0; } else { - // Dynamic Sci-fi background grid - ctx.fillStyle = '#0a0d16'; // Deep space black - ctx.fillRect(0, 0, size, size); + // Dynamic Sci-fi background grid (Background is transparent!) // Sci-fi subgrid ctx.strokeStyle = 'rgba(30, 41, 59, 0.4)'; @@ -377,11 +380,12 @@ export const EbikeGPSMap: React.FC = ({ return ( - + diff --git a/src/pages/backgroundmap/page.tsx b/src/pages/backgroundmap/page.tsx index ee67366..23c6174 100644 --- a/src/pages/backgroundmap/page.tsx +++ b/src/pages/backgroundmap/page.tsx @@ -147,7 +147,7 @@ export function BackgroundMapPage() { const width = maxX - minX; const height = maxZ - minZ; const maxDim = Math.max(width, height); - + const centerX = (minX + maxX) / 2; const centerZ = (minZ + maxZ) / 2; diff --git a/src/world/debug/TestMap.tsx b/src/world/debug/TestMap.tsx index ea2868a..4aa9aa0 100644 --- a/src/world/debug/TestMap.tsx +++ b/src/world/debug/TestMap.tsx @@ -238,16 +238,20 @@ export function TestMap({ onOctreeReady }: TestMapProps): React.JSX.Element { {/* Dynamic Futuristic 3D GPS Dashboard Preview */} - {/* Futuristic glowing screen frame */} + {/* Futuristic glowing screen frame (commented out to show true 3D transparency!) */} + {/* - + - {/* Glow accent border */} + */} + {/* Glow accent border (commented out to remove any orange transparency tint!) */} + {/* - + + */} {/* GPS Map screen plane */}