aboutsummaryrefslogtreecommitdiff
path: root/web/pw-visualizer
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-visualizer')
-rw-r--r--web/pw-visualizer/assets/shaders/frag/msdf.glsl3
-rw-r--r--web/pw-visualizer/src/index.ts29
2 files changed, 29 insertions, 3 deletions
diff --git a/web/pw-visualizer/assets/shaders/frag/msdf.glsl b/web/pw-visualizer/assets/shaders/frag/msdf.glsl
index 5d2325b..23bacfc 100644
--- a/web/pw-visualizer/assets/shaders/frag/msdf.glsl
+++ b/web/pw-visualizer/assets/shaders/frag/msdf.glsl
@@ -24,6 +24,7 @@ void main() {
float sd = median(msd.r, msd.g, msd.b);
float screenPxRange = max(u_distanceRange, scale);
float screenPxDistance = screenPxRange*(sd - 0.5);
- float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
+ // float opacity = clamp(screenPxDistance + 0.5, 0.0, 1.0);
+ float opacity = clamp(0.0, 1.0, screenPxDistance + 0.5);
gl_FragColor = vec4(u_fgColor.rgb, u_fgColor.a * opacity);
} \ No newline at end of file
diff --git a/web/pw-visualizer/src/index.ts b/web/pw-visualizer/src/index.ts
index 97bdb3d..4c99311 100644
--- a/web/pw-visualizer/src/index.ts
+++ b/web/pw-visualizer/src/index.ts
@@ -140,6 +140,7 @@ export class GameInstance {
renderer: Renderer;
planet_count: number;
+ planet_names: string[];
vor_builder: VoronoiBuilder;
@@ -162,7 +163,12 @@ export class GameInstance {
) {
this.game = game;
const planets = game.get_planets();
- this.planet_count = planets.length;
+ this.planet_count = planets.length / 3;
+
+ this.planet_names = [];
+ for (let i = 0; i < this.planet_count; i++) {
+ this.planet_names.push(this.game.get_planet_name(i));
+ }
this.shader = shaders["normal"].create_shader(GL, {
MAX_CIRCLES: "" + planets.length,
@@ -285,7 +291,7 @@ export class GameInstance {
1,
0,
-planets[i * 3],
- -planets[i * 3 + 1] - 1.171875,
+ -planets[i * 3 + 1] + 0.2 - 2*1.171875,
1,
]);
@@ -293,6 +299,24 @@ export class GameInstance {
this.planet_labels.push(label);
this.renderer.addRenderable(label.getRenderable(), LAYERS.planet_label);
}
+
+ {
+ const transform = new UniformMatrix3fv([
+ 1,
+ 0,
+ 0,
+ 0,
+ 1,
+ 0,
+ -planets[i * 3],
+ -planets[i * 3 + 1] + 0.2 - 1*1.171875,
+ 1,
+ ]);
+
+ const label = this.msdf_text_factory.build(GL, transform);
+ label.setText(GL, this.planet_names[i], Align.Middle, Align.Begin);
+ this.renderer.addRenderable(label.getRenderable(), LAYERS.planet_label);
+ }
}
}
@@ -337,6 +361,7 @@ export class GameInstance {
this.planet_labels[i].setText(
GL,
+ // this.planet_names[i] + " " +
"" + planet_ships[i],
Align.Middle,
Align.Begin