BlueGit

timfa questward

Black void behind unloaded chunks; editor loads a 5×5 ring.

Scene clear uses black instead of Framework white, and the editor
neighborhood matches STATIC_CHUNK_RADIUS so selection neighbors stay visible.

timfa Tim Falken · pushed by timfa

Authored 2026-09-08 · 2 months ago

Hash
07bf78c8c57af1c9455312dba074314bf9a5305b
Parent
19dde185
3 files changed +24 −5
client/src/editor/main.js +11 −5
@@ -1,4 +1,4 @@
1 import { MessageType, CHUNK_SIZE, SPRITE_SIZE_PX, VISIBLE_CHUNK_RADIUS } from "/shared/protocol/constants.js";
1 import { MessageType, CHUNK_SIZE, SPRITE_SIZE_PX, STATIC_CHUNK_RADIUS } from "/shared/protocol/constants.js";
2 2 import
3 3 {
4 4 GROUND_DEFINITIONS,
@@ -243,17 +243,20 @@ function previewFromTool ()
243 243 return { block: { typeId: tool.typeId, state, config: null } };
244 244 }
245 245
246 /** Editor map neighborhood (Chebyshev); 2 → 5×5 chunks around the selection. */
247 const EDITOR_VIEW_CHUNK_RADIUS = STATIC_CHUNK_RADIUS;
248
246 249 function inEditorView (x, y)
247 250 {
248 return Math.abs(x - chunkX) <= VISIBLE_CHUNK_RADIUS && Math.abs(y - chunkY) <= VISIBLE_CHUNK_RADIUS;
251 return Math.abs(x - chunkX) <= EDITOR_VIEW_CHUNK_RADIUS && Math.abs(y - chunkY) <= EDITOR_VIEW_CHUNK_RADIUS;
249 252 }
250 253
251 254 function neighborhoodCoords (centerX, centerY)
252 255 {
253 256 const coords = [];
254 for (let dy = -VISIBLE_CHUNK_RADIUS; dy <= VISIBLE_CHUNK_RADIUS; dy++)
257 for (let dy = -EDITOR_VIEW_CHUNK_RADIUS; dy <= EDITOR_VIEW_CHUNK_RADIUS; dy++)
255 258 {
256 for (let dx = -VISIBLE_CHUNK_RADIUS; dx <= VISIBLE_CHUNK_RADIUS; dx++)
259 for (let dx = -EDITOR_VIEW_CHUNK_RADIUS; dx <= EDITOR_VIEW_CHUNK_RADIUS; dx++)
257 260 { coords.push({ chunkX: centerX + dx, chunkY: centerY + dy }); }
258 261 }
259 262 return coords;
@@ -1079,7 +1082,7 @@ function layoutScene ()
1079 1082 scene.size.y = height;
1080 1083 scene.g_fixSize();
1081 1084 useNearestNeighbour(scene, game.images);
1082 const fit = Math.min(width, height) / (CHUNK_SIZE * 3 * SPRITE_SIZE_PX);
1085 const fit = Math.min(width, height) / (CHUNK_SIZE * (EDITOR_VIEW_CHUNK_RADIUS * 2 + 1) * SPRITE_SIZE_PX);
1083 1086 if (editorZoom == null)
1084 1087 { editorZoom = fit; }
1085 1088 else
@@ -1278,6 +1281,9 @@ async function main ()
1278 1281 });
1279 1282 applySpriteSheets(game.images, catalog);
1280 1283 scene = new Scene(250, 56, 64, 64);
1284 scene.backgroundColor.r = 0;
1285 scene.backgroundColor.g = 0;
1286 scene.backgroundColor.b = 0;
1281 1287 game.loadScene(scene);
1282 1288 view = new WorldView(game, scene, catalog);
1283 1289 view.followPlayer = false;
@@ -1,4 +1,4 @@
1import { MessageType, CHUNK_SIZE, SPRITE_SIZE_PX, VISIBLE_CHUNK_RADIUS } from "/shared/protocol/constants.js";
1import { MessageType, CHUNK_SIZE, SPRITE_SIZE_PX, STATIC_CHUNK_RADIUS } from "/shared/protocol/constants.js";
2import
2import
3{
3{
4 GROUND_DEFINITIONS,
4 GROUND_DEFINITIONS,
@@ -243,17 +243,20 @@ function previewFromTool ()
243 return { block: { typeId: tool.typeId, state, config: null } };
243 return { block: { typeId: tool.typeId, state, config: null } };
244}
244}
245
245
246/** Editor map neighborhood (Chebyshev); 2 → 5×5 chunks around the selection. */
247const EDITOR_VIEW_CHUNK_RADIUS = STATIC_CHUNK_RADIUS;
248
246function inEditorView (x, y)
249function inEditorView (x, y)
247{
250{
248 return Math.abs(x - chunkX) <= VISIBLE_CHUNK_RADIUS && Math.abs(y - chunkY) <= VISIBLE_CHUNK_RADIUS;
251 return Math.abs(x - chunkX) <= EDITOR_VIEW_CHUNK_RADIUS && Math.abs(y - chunkY) <= EDITOR_VIEW_CHUNK_RADIUS;
249}
252}
250
253
251function neighborhoodCoords (centerX, centerY)
254function neighborhoodCoords (centerX, centerY)
252{
255{
253 const coords = [];
256 const coords = [];
254 for (let dy = -VISIBLE_CHUNK_RADIUS; dy <= VISIBLE_CHUNK_RADIUS; dy++)
257 for (let dy = -EDITOR_VIEW_CHUNK_RADIUS; dy <= EDITOR_VIEW_CHUNK_RADIUS; dy++)
255 {
258 {
256 for (let dx = -VISIBLE_CHUNK_RADIUS; dx <= VISIBLE_CHUNK_RADIUS; dx++)
259 for (let dx = -EDITOR_VIEW_CHUNK_RADIUS; dx <= EDITOR_VIEW_CHUNK_RADIUS; dx++)
257 { coords.push({ chunkX: centerX + dx, chunkY: centerY + dy }); }
260 { coords.push({ chunkX: centerX + dx, chunkY: centerY + dy }); }
258 }
261 }
259 return coords;
262 return coords;
@@ -1079,7 +1082,7 @@ function layoutScene ()
1079 scene.size.y = height;
1082 scene.size.y = height;
1080 scene.g_fixSize();
1083 scene.g_fixSize();
1081 useNearestNeighbour(scene, game.images);
1084 useNearestNeighbour(scene, game.images);
1082 const fit = Math.min(width, height) / (CHUNK_SIZE * 3 * SPRITE_SIZE_PX);
1085 const fit = Math.min(width, height) / (CHUNK_SIZE * (EDITOR_VIEW_CHUNK_RADIUS * 2 + 1) * SPRITE_SIZE_PX);
1083 if (editorZoom == null)
1086 if (editorZoom == null)
1084 { editorZoom = fit; }
1087 { editorZoom = fit; }
1085 else
1088 else
@@ -1278,6 +1281,9 @@ async function main ()
1278 });
1281 });
1279 applySpriteSheets(game.images, catalog);
1282 applySpriteSheets(game.images, catalog);
1280 scene = new Scene(250, 56, 64, 64);
1283 scene = new Scene(250, 56, 64, 64);
1284 scene.backgroundColor.r = 0;
1285 scene.backgroundColor.g = 0;
1286 scene.backgroundColor.b = 0;
1281 game.loadScene(scene);
1287 game.loadScene(scene);
1282 view = new WorldView(game, scene, catalog);
1288 view = new WorldView(game, scene, catalog);
1283 view.followPlayer = false;
1289 view.followPlayer = false;
client/src/play/main.js +6 −0
@@ -1780,6 +1780,9 @@ function startPlay (payload)
1780 1780 if (!scene)
1781 1781 {
1782 1782 scene = new Scene(0, 0, window.innerWidth, window.innerHeight);
1783 scene.backgroundColor.r = 0;
1784 scene.backgroundColor.g = 0;
1785 scene.backgroundColor.b = 0;
1783 1786 game.loadScene(scene);
1784 1787 useNearestNeighbour(scene, game.images);
1785 1788 }
@@ -1924,6 +1927,9 @@ async function main ()
1924 1927 if (!scene)
1925 1928 {
1926 1929 scene = new Scene(0, 0, window.innerWidth, window.innerHeight);
1930 scene.backgroundColor.r = 0;
1931 scene.backgroundColor.g = 0;
1932 scene.backgroundColor.b = 0;
1927 1933 game.loadScene(scene);
1928 1934 }
1929 1935 setAssetLoading(false);
@@ -1780,6 +1780,9 @@ function startPlay (payload)
1780 if (!scene)
1780 if (!scene)
1781 {
1781 {
1782 scene = new Scene(0, 0, window.innerWidth, window.innerHeight);
1782 scene = new Scene(0, 0, window.innerWidth, window.innerHeight);
1783 scene.backgroundColor.r = 0;
1784 scene.backgroundColor.g = 0;
1785 scene.backgroundColor.b = 0;
1783 game.loadScene(scene);
1786 game.loadScene(scene);
1784 useNearestNeighbour(scene, game.images);
1787 useNearestNeighbour(scene, game.images);
1785 }
1788 }
@@ -1924,6 +1927,9 @@ async function main ()
1924 if (!scene)
1927 if (!scene)
1925 {
1928 {
1926 scene = new Scene(0, 0, window.innerWidth, window.innerHeight);
1929 scene = new Scene(0, 0, window.innerWidth, window.innerHeight);
1930 scene.backgroundColor.r = 0;
1931 scene.backgroundColor.g = 0;
1932 scene.backgroundColor.b = 0;
1927 game.loadScene(scene);
1933 game.loadScene(scene);
1928 }
1934 }
1929 setAssetLoading(false);
1935 setAssetLoading(false);
client/src/render/worldView.js +7 −0
@@ -1062,6 +1062,13 @@ export class WorldView
1062 1062 {
1063 1063 this.game = game;
1064 1064 this.scene = scene;
1065 // Framework defaults to white clear; unloaded map areas should read as void.
1066 if (scene?.backgroundColor)
1067 {
1068 scene.backgroundColor.r = 0;
1069 scene.backgroundColor.g = 0;
1070 scene.backgroundColor.b = 0;
1071 }
1065 1072 this.catalog = catalog;
1066 1073 this.preview = null;
1067 1074 this.zoom = 2;
@@ -1062,6 +1062,13 @@ export class WorldView
1062 {
1062 {
1063 this.game = game;
1063 this.game = game;
1064 this.scene = scene;
1064 this.scene = scene;
1065 // Framework defaults to white clear; unloaded map areas should read as void.
1066 if (scene?.backgroundColor)
1067 {
1068 scene.backgroundColor.r = 0;
1069 scene.backgroundColor.g = 0;
1070 scene.backgroundColor.b = 0;
1071 }
1065 this.catalog = catalog;
1072 this.catalog = catalog;
1066 this.preview = null;
1073 this.preview = null;
1067 this.zoom = 2;
1074 this.zoom = 2;