mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-17 05:34:37 +00:00
add configurable dot size for zoomed-out structures
Structures collapse to a dot when zoomed out past dotsZoomThreshold. The dot scale was hardcoded to 1.0 / 2.5 (≈0.4) in structure.vert.glsl. Promote it to a render setting (`structure.dotScale`) so it's tunable alongside iconSize / dotsZoomThreshold. Default 0.4 preserves current behavior. Plumbed via uDotScale uniform on StructurePass.
This commit is contained in:
@@ -74,6 +74,7 @@ export class StructurePass {
|
|||||||
private uZoom: WebGLUniformLocation;
|
private uZoom: WebGLUniformLocation;
|
||||||
private uIconSize: WebGLUniformLocation;
|
private uIconSize: WebGLUniformLocation;
|
||||||
private uDotsThreshold: WebGLUniformLocation;
|
private uDotsThreshold: WebGLUniformLocation;
|
||||||
|
private uDotScale: WebGLUniformLocation;
|
||||||
private uScaleFactor: WebGLUniformLocation;
|
private uScaleFactor: WebGLUniformLocation;
|
||||||
private uShapeScales: WebGLUniformLocation;
|
private uShapeScales: WebGLUniformLocation;
|
||||||
private uIconFills: WebGLUniformLocation;
|
private uIconFills: WebGLUniformLocation;
|
||||||
@@ -140,6 +141,7 @@ export class StructurePass {
|
|||||||
this.uCamera = gl.getUniformLocation(this.program, "uCamera")!;
|
this.uCamera = gl.getUniformLocation(this.program, "uCamera")!;
|
||||||
this.uZoom = gl.getUniformLocation(this.program, "uZoom")!;
|
this.uZoom = gl.getUniformLocation(this.program, "uZoom")!;
|
||||||
this.uIconSize = gl.getUniformLocation(this.program, "uIconSize")!;
|
this.uIconSize = gl.getUniformLocation(this.program, "uIconSize")!;
|
||||||
|
this.uDotScale = gl.getUniformLocation(this.program, "uDotScale")!;
|
||||||
this.uDotsThreshold = gl.getUniformLocation(
|
this.uDotsThreshold = gl.getUniformLocation(
|
||||||
this.program,
|
this.program,
|
||||||
"uDotsThreshold",
|
"uDotsThreshold",
|
||||||
@@ -330,6 +332,7 @@ export class StructurePass {
|
|||||||
gl.uniform1f(this.uZoom, zoom);
|
gl.uniform1f(this.uZoom, zoom);
|
||||||
gl.uniform1f(this.uIconSize, ss.iconSize);
|
gl.uniform1f(this.uIconSize, ss.iconSize);
|
||||||
gl.uniform1f(this.uDotsThreshold, ss.dotsZoomThreshold);
|
gl.uniform1f(this.uDotsThreshold, ss.dotsZoomThreshold);
|
||||||
|
gl.uniform1f(this.uDotScale, ss.dotScale);
|
||||||
gl.uniform1f(this.uScaleFactor, ss.iconScaleFactorZoomedOut);
|
gl.uniform1f(this.uScaleFactor, ss.iconScaleFactorZoomedOut);
|
||||||
|
|
||||||
// Build per-structure uniform arrays from settings, ordered by atlas column
|
// Build per-structure uniform arrays from settings, ordered by atlas column
|
||||||
|
|||||||
@@ -82,9 +82,10 @@
|
|||||||
"railAlpha": 1
|
"railAlpha": 1
|
||||||
},
|
},
|
||||||
"structure": {
|
"structure": {
|
||||||
"iconSize": 35,
|
"iconSize": 65,
|
||||||
"dotsZoomThreshold": 0.5,
|
"dotsZoomThreshold": 1.2,
|
||||||
"iconScaleFactorZoomedOut": 1.4,
|
"dotScale": 0.3,
|
||||||
|
"iconScaleFactorZoomedOut": 3.5,
|
||||||
"shapes": {
|
"shapes": {
|
||||||
"City": {
|
"City": {
|
||||||
"scale": 1,
|
"scale": 1,
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ export interface RenderSettings {
|
|||||||
structure: {
|
structure: {
|
||||||
iconSize: number;
|
iconSize: number;
|
||||||
dotsZoomThreshold: number;
|
dotsZoomThreshold: number;
|
||||||
|
/** Icon size multiplier when zoomed out past dotsZoomThreshold. */
|
||||||
|
dotScale: number;
|
||||||
iconScaleFactorZoomedOut: number;
|
iconScaleFactorZoomedOut: number;
|
||||||
shapes: Record<string, { scale: number; iconFill: number }>;
|
shapes: Record<string, { scale: number; iconFill: number }>;
|
||||||
highlightOutlineWidth: number;
|
highlightOutlineWidth: number;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ uniform float uZoom;
|
|||||||
|
|
||||||
uniform float uIconSize;
|
uniform float uIconSize;
|
||||||
uniform float uDotsThreshold;
|
uniform float uDotsThreshold;
|
||||||
|
uniform float uDotScale;
|
||||||
uniform float uScaleFactor;
|
uniform float uScaleFactor;
|
||||||
uniform float uShapeScales[ATLAS_COLS];
|
uniform float uShapeScales[ATLAS_COLS];
|
||||||
uniform float uIconFills[ATLAS_COLS];
|
uniform float uIconFills[ATLAS_COLS];
|
||||||
@@ -36,7 +37,7 @@ void main() {
|
|||||||
|
|
||||||
float iconScale;
|
float iconScale;
|
||||||
if (uZoom <= uDotsThreshold) {
|
if (uZoom <= uDotsThreshold) {
|
||||||
iconScale = 1.0 / 2.5;
|
iconScale = uDotScale;
|
||||||
} else {
|
} else {
|
||||||
iconScale = min(1.0, uZoom / uScaleFactor);
|
iconScale = min(1.0, uZoom / uScaleFactor);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user