diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-29 22:54:30 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-29 22:54:30 +0100 |
commit | 71ee6c99e963d96286cae8d0bfc2f20a9c9c920b (patch) | |
tree | c4d290c4a658853436477cb07cd469684c64f8e3 /web/pw-visualizer/src/index.ts | |
parent | 0c6d978442b244ca3f29c1ffdd44b5007ae7ad93 (diff) | |
download | planetwars.dev-71ee6c99e963d96286cae8d0bfc2f20a9c9c920b.tar.xz planetwars.dev-71ee6c99e963d96286cae8d0bfc2f20a9c9c920b.zip |
move assets to visualizer package
Diffstat (limited to 'web/pw-visualizer/src/index.ts')
-rw-r--r-- | web/pw-visualizer/src/index.ts | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/web/pw-visualizer/src/index.ts b/web/pw-visualizer/src/index.ts index 363a1c5..df2c3c2 100644 --- a/web/pw-visualizer/src/index.ts +++ b/web/pw-visualizer/src/index.ts @@ -27,6 +27,7 @@ import { VertexBuffer, IndexBuffer } from "./webgl/buffer"; import { VertexBufferLayout, VertexArray } from "./webgl/vertexBufferLayout"; import { defaultLabelFactory, LabelFactory, Align, Label } from "./webgl/text"; import { VoronoiBuilder } from "./voronoi/voronoi"; +import * as assets from "./assets"; // svg-mesh requires global to exist (window as any).global = window; @@ -585,34 +586,38 @@ var meshes: Mesh[]; var shaders: Dictionary<ShaderFactory>; export async function set_instance(source: string): Promise<GameInstance> { + // TODO: embed shader programs if (!meshes || !shaders) { - const mesh_promises = ["ship.svg", "earth.svg", "mars.svg", "venus.svg"] - .map((name) => "/static/res/assets/" + name) - .map(url_to_mesh); + const mesh_promises = [ + assets.shipSvg, + assets.earthSvg, + assets.marsSvg, + assets.venusSvg, + ].map(url_to_mesh); const shader_promies = [ (async () => <[string, ShaderFactory]>[ "normal", await ShaderFactory.create_factory( - "/static/shaders/frag/simple.glsl", - "/static/shaders/vert/simple.glsl" + assets.simpleFragmentShader, + assets.simpleVertexShader, ), ])(), (async () => <[string, ShaderFactory]>[ "vor", await ShaderFactory.create_factory( - "/static/shaders/frag/vor.glsl", - "/static/shaders/vert/vor.glsl" + assets.vorFragmentShader, + assets.vorVertexShader, ), ])(), (async () => <[string, ShaderFactory]>[ "image", await ShaderFactory.create_factory( - "/static/shaders/frag/image.glsl", - "/static/shaders/vert/simple.glsl" + assets.imageFragmentShader, + assets.simpleVertexShader, ), ])(), ]; |