Skip to content

Commit 4e93f4e

Browse files
committed
Update background block to just take a single color.
1 parent 2932b88 commit 4e93f4e

File tree

3 files changed

+3
-57
lines changed

3 files changed

+3
-57
lines changed

.replit

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,6 @@ localPort = 9323
7373
externalPort = 3003
7474
exposeLocalhost = true
7575

76-
[[ports]]
77-
localPort = 42921
78-
externalPort = 8008
79-
8076
[[ports]]
8177
localPort = 44471
8278
externalPort = 8000

api/scene.js

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,59 +25,8 @@ export const flockScene = {
2525
flock.sky = null;
2626
}
2727

28-
// Dispose any previous background layer
29-
if (flock.backgroundLayer) {
30-
flock.backgroundLayer.dispose();
31-
flock.backgroundLayer = null;
32-
}
33-
34-
// --- BACKGROUND ONLY (flat clear color or gradient) ---
28+
// --- BACKGROUND ONLY (flat clear color) ---
3529
if (clear === true) {
36-
// For arrays, create a flat gradient background layer (not a dome)
37-
if (Array.isArray(color) && color.length >= 2) {
38-
// Create a vertical gradient texture
39-
const size = 512;
40-
const dt = new flock.BABYLON.DynamicTexture(
41-
"backgroundGradientDT",
42-
{ width: 1, height: size },
43-
flock.scene,
44-
false
45-
);
46-
const ctx = dt.getContext();
47-
const h = dt.getSize().height;
48-
49-
// Build canvas gradient (top to bottom)
50-
const grad = ctx.createLinearGradient(0, 0, 0, h);
51-
const n = Math.max(2, color.length);
52-
for (let i = 0; i < n; i++) {
53-
const stop = i / (n - 1);
54-
const hex = flock.getColorFromString(color[i]);
55-
const c3 = flock.BABYLON.Color3.FromHexString(hex);
56-
const rgb = `rgb(${Math.round(c3.r * 255)}, ${Math.round(c3.g * 255)}, ${Math.round(c3.b * 255)})`;
57-
grad.addColorStop(stop, rgb);
58-
}
59-
60-
// Paint the gradient
61-
ctx.fillStyle = grad;
62-
ctx.fillRect(0, 0, 1, h);
63-
dt.update(false);
64-
65-
// Create a background layer with the gradient texture
66-
const layer = new flock.BABYLON.Layer("backgroundGradientLayer", null, flock.scene, true);
67-
layer.texture = dt;
68-
layer.isBackground = true;
69-
70-
// Ensure the layer is completely unlit and unaffected by scene lighting
71-
layer.alphaBlendingMode = flock.BABYLON.Constants.ALPHA_DISABLE;
72-
dt.hasAlpha = false;
73-
dt.wrapU = flock.BABYLON.Texture.CLAMP_ADDRESSMODE;
74-
dt.wrapV = flock.BABYLON.Texture.CLAMP_ADDRESSMODE;
75-
76-
flock.backgroundLayer = layer;
77-
return;
78-
}
79-
80-
// Single color - just set clear color
8130
const c3 = flock.BABYLON.Color3.FromHexString(flock.getColorFromString(color));
8231
flock.scene.clearColor = c3;
8332
return;

blocks/scene.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function createSceneColorBlock(config) {
3636
type: "input_value",
3737
name: config.inputName || "COLOR",
3838
colour: config.inputColor,
39-
check: ["Colour", "Array", "Material"],
39+
check: config.check || ["Colour", "Array", "Material"],
4040
});
4141

4242
this.jsonInit({
@@ -121,6 +121,7 @@ export function defineSceneBlocks() {
121121
Blockly.Blocks["set_background_color"] = createSceneColorBlock({
122122
type: "set_background_color",
123123
inputColor: "#6495ED",
124+
check: ["Colour"],
124125
});
125126

126127
Blockly.Blocks["create_map"] = {

0 commit comments

Comments
 (0)