From 71ee6c99e963d96286cae8d0bfc2f20a9c9c920b Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Wed, 29 Dec 2021 22:54:30 +0100 Subject: move assets to visualizer package --- web/pw-visualizer/src/webgl/index.ts | 15 +++++++++++---- web/pw-visualizer/src/webgl/text.ts | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'web/pw-visualizer/src/webgl') diff --git a/web/pw-visualizer/src/webgl/index.ts b/web/pw-visualizer/src/webgl/index.ts index fdb7886..1742713 100644 --- a/web/pw-visualizer/src/webgl/index.ts +++ b/web/pw-visualizer/src/webgl/index.ts @@ -4,15 +4,22 @@ import { VertexBuffer, IndexBuffer } from './buffer'; import { VertexArray, VertexBufferLayout } from './vertexBufferLayout'; import { Renderer } from './renderer'; import { Texture } from './texture'; +import * as assets from "../assets"; -const URL = window.location.origin+window.location.pathname; -const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1); +// const URL = window.location.origin+window.location.pathname; +// const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1); async function create_texture_from_svg(gl: WebGLRenderingContext, name: string, path: string, width: number, height: number): Promise { const [mesh, factory] = await Promise.all([ url_to_mesh(path), - ShaderFactory.create_factory(LOCATION + "static/shaders/frag/static_color.glsl", LOCATION + "static/shaders/vert/svg.glsl") + ShaderFactory.create_factory( + // assets.simpleFragmentShader, + // assets.simpleVertexShader, + // TODO: previously: this was the old code, which was not working. + // what is the correct shader here? + "static/shaders/frag/static_color.glsl", "static/shaders/vert/svg.glsl" + ) ]); const program = factory.create_shader(gl); @@ -54,7 +61,7 @@ async function main() { console.log(Math.max(...mesh.positions), Math.min(...mesh.positions)); const renderer = new Renderer(); - const factory = await ShaderFactory.create_factory(LOCATION + "static/shaders/frag/static_color.glsl", LOCATION + "static/shaders/vert/simple.glsl"); + const factory = await ShaderFactory.create_factory(assets.simpleFragmentShader, assets.simpleVertexShader); const program = factory.create_shader(gl); var positionBuffer = new VertexBuffer(gl, mesh.positions); diff --git a/web/pw-visualizer/src/webgl/text.ts b/web/pw-visualizer/src/webgl/text.ts index 3f1cec6..fdfbc55 100644 --- a/web/pw-visualizer/src/webgl/text.ts +++ b/web/pw-visualizer/src/webgl/text.ts @@ -4,6 +4,7 @@ import { Texture } from "./texture"; import { DefaultRenderable } from "./renderer"; import { IndexBuffer, VertexBuffer } from "./buffer"; import { VertexBufferLayout, VertexArray } from "./vertexBufferLayout"; +import { fontPng } from "../assets"; export enum Align { @@ -188,5 +189,5 @@ export function defaultLabelFactory(gl: WebGLRenderingContext, shader: Shader): }, }; - return new LabelFactory(gl, '/static/res/assets/font.png', fontInfo, shader); + return new LabelFactory(gl, fontPng, fontInfo, shader); } -- cgit v1.2.3