diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-11-06 21:44:56 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-11-06 21:44:56 +0100 |
commit | 9ed7d7ab2fc70f971aa18d61f5ea04b346c836a3 (patch) | |
tree | eb3c73ca2fdcdcb2a7ede69ae066c289d3f14883 /web/pw-visualizer/src | |
parent | fdc2ab9421c6a38c6bbd9b621c4da4f2c147a773 (diff) | |
download | planetwars.dev-9ed7d7ab2fc70f971aa18d61f5ea04b346c836a3.tar.xz planetwars.dev-9ed7d7ab2fc70f971aa18d61f5ea04b346c836a3.zip |
render planet names
Diffstat (limited to 'web/pw-visualizer/src')
-rw-r--r-- | web/pw-visualizer/src/index.ts | 29 |
1 files changed, 27 insertions, 2 deletions
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 |