diff options
author | metamuffin <metamuffin@disroot.org> | 2025-03-28 02:44:12 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-03-28 02:44:12 +0100 |
commit | b3cc7d7dbc6f9f28d91acab77a65f976a3c996a9 (patch) | |
tree | 5b00e621e1b3d0857b8f31b45083712edfe1fec6 /viewer/main.ts | |
parent | 3be73a3c424bd7f72e6efecd6d954fbb08e960e0 (diff) | |
download | wearemapping-b3cc7d7dbc6f9f28d91acab77a65f976a3c996a9.tar wearemapping-b3cc7d7dbc6f9f28d91acab77a65f976a3c996a9.tar.bz2 wearemapping-b3cc7d7dbc6f9f28d91acab77a65f976a3c996a9.tar.zst |
it draws stuff
Diffstat (limited to 'viewer/main.ts')
-rw-r--r-- | viewer/main.ts | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/viewer/main.ts b/viewer/main.ts index e0c2fde..f59bb1c 100644 --- a/viewer/main.ts +++ b/viewer/main.ts @@ -18,12 +18,16 @@ function draw() { ctx.fillStyle = "black" ctx.fillRect(0, 0, canvas.width, canvas.height) - loader?.root.children + loader?.root.draw() requestAnimationFrame(draw) } - -canvas.addEventListener("resize", () => draw()) +function resize() { + canvas.width = globalThis.innerWidth + canvas.height = globalThis.innerHeight +} +canvas.addEventListener("resize", () => resize()) +resize() draw() @@ -42,7 +46,7 @@ async function init() { } init() -let limit = 100; +let limit = 10000; class Loader { view: AABB @@ -64,8 +68,10 @@ class SNode { this.children = new Array(data.child.length).fill(undefined) } async load(view: AABB) { - if (this.data.prefab && !this.prefab) this.prefab = await get_prefab(this.data.prefab) - if (this.prefab?.graphics[0] && !this.graphics) this.graphics = await get_graphics_part(this.prefab.graphics[0][1]) + if (this.data.prefab && !this.prefab) + this.prefab = await get_prefab(this.data.prefab) + if (this.prefab?.graphics[0] && !this.graphics) + this.graphics = await get_graphics_part(this.prefab.graphics[0][1]) for (let i = 0; i < this.data.child.length; i++) { const [aabb, child_data_hash] = this.data.child[i]; if (!aabb_overlap(aabb, view)) continue @@ -82,8 +88,14 @@ class SNode { if (c) c.draw() } if (!this.graphics) return + ctx.fillStyle = "red" + ctx.save() + ctx.scale(100000, 100000) + ctx.translate(-0.155, -0.63) + ctx.translate(this.prefab!.transform![10], this.prefab!.transform![11]) for (const c of this.graphics.read()) { - console.log(c); + if (c.point) ctx.fillRect(c.point.x, c.point.y, 0.00003, 0.00003) } + ctx.restore() } } |