mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +09:00
Working timelapse rendering functionality
This commit is contained in:
1 parent
be21f22707
commit
9dc5f8ff37
1 file changed
+17
-17
@@ -217,19 +217,9 @@ export default function CanvasMinimapPage() {
|
|||||||
const sortedTicks = Array.from(allTicks).sort((a, b) => a - b);
|
const sortedTicks = Array.from(allTicks).sort((a, b) => a - b);
|
||||||
setAvailableTicks(sortedTicks);
|
setAvailableTicks(sortedTicks);
|
||||||
|
|
||||||
console.log(`Timelapse Summary:`);
|
|
||||||
console.log(`- Checked tiles: ${tilesChecked} (${leftTile},${topTile} to ${rightTile},${bottomTile})`);
|
|
||||||
console.log(`- Tiles with data: ${tilesWithData}`);
|
|
||||||
console.log(`- Total unique timestamps: ${sortedTicks.length}`);
|
|
||||||
console.log(`- Timestamps:`, sortedTicks);
|
|
||||||
|
|
||||||
// Set current tick to latest if not set
|
// Set current tick to latest if not set
|
||||||
if (sortedTicks.length > 0 && currentTick === null) {
|
if (sortedTicks.length > 0 && currentTick === null) {
|
||||||
const latestTick = sortedTicks[sortedTicks.length - 1];
|
setCurrentTick(sortedTicks[sortedTicks.length - 1]);
|
||||||
console.log(`Setting current tick to latest:`, latestTick);
|
|
||||||
setCurrentTick(latestTick);
|
|
||||||
} else if (sortedTicks.length === 0) {
|
|
||||||
console.log(`No timestamps found - currentTick will remain null`);
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Failed to load available ticks:", err);
|
console.error("Failed to load available ticks:", err);
|
||||||
@@ -255,13 +245,15 @@ export default function CanvasMinimapPage() {
|
|||||||
|
|
||||||
const stepToTick = (tickIndex: number) => {
|
const stepToTick = (tickIndex: number) => {
|
||||||
if (tickIndex >= 0 && tickIndex < availableTicks.length) {
|
if (tickIndex >= 0 && tickIndex < availableTicks.length) {
|
||||||
setCurrentTick(availableTicks[tickIndex]);
|
const newTick = availableTicks[tickIndex];
|
||||||
|
|
||||||
// Clear caches to force reload with new tick
|
// Clear caches to force reload with new tick
|
||||||
virtualTiles.current.clear();
|
virtualTiles.current.clear();
|
||||||
tileCache.current.clear();
|
tileCache.current.clear();
|
||||||
chunkCache.current.clear();
|
chunkCache.current.clear();
|
||||||
loadingTiles.current.clear();
|
loadingTiles.current.clear();
|
||||||
|
|
||||||
|
setCurrentTick(newTick);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -506,7 +498,7 @@ export default function CanvasMinimapPage() {
|
|||||||
cancelAnimationFrame(animationFrameRef.current);
|
cancelAnimationFrame(animationFrameRef.current);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [selectedInstance, selectedSurface, selectedForce, viewState, resizeCounter]);
|
}, [selectedInstance, selectedSurface, selectedForce, viewState, resizeCounter, currentTick, isTimelapseMode]);
|
||||||
|
|
||||||
const loadInstances = async () => {
|
const loadInstances = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -580,10 +572,8 @@ export default function CanvasMinimapPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the tile data to get RGB565 pixels
|
// Parse the tile data to get RGB565 pixels
|
||||||
const pixels = await renderTileToPixels(
|
const targetTick = isTimelapseMode ? currentTick || undefined : undefined;
|
||||||
tileData,
|
const pixels = await renderTileToPixels(tileData, targetTick);
|
||||||
isTimelapseMode ? currentTick || undefined : undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
// Convert to ImageData
|
// Convert to ImageData
|
||||||
const tileImageData = pixelsToImageData(pixels);
|
const tileImageData = pixelsToImageData(pixels);
|
||||||
@@ -926,6 +916,16 @@ export default function CanvasMinimapPage() {
|
|||||||
}
|
}
|
||||||
}, [selectedInstance, instances]);
|
}, [selectedInstance, instances]);
|
||||||
|
|
||||||
|
// Clear caches when currentTick changes (React state timing fix)
|
||||||
|
useEffect(() => {
|
||||||
|
if (isTimelapseMode) {
|
||||||
|
virtualTiles.current.clear();
|
||||||
|
tileCache.current.clear();
|
||||||
|
chunkCache.current.clear();
|
||||||
|
loadingTiles.current.clear();
|
||||||
|
}
|
||||||
|
}, [currentTick, isTimelapseMode]);
|
||||||
|
|
||||||
// Reload ticks when instance, surface, force, or view changes
|
// Reload ticks when instance, surface, force, or view changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isTimelapseMode && selectedInstance && selectedSurface && selectedForce) {
|
if (isTimelapseMode && selectedInstance && selectedSurface && selectedForce) {
|
||||||
|
|||||||
Reference in new issue
Block a user