From 18ed948462bd71e4cb3b1e8fa3f55df84ef0ff33 Mon Sep 17 00:00:00 2001 From: sanine Date: Fri, 31 Mar 2023 18:20:15 -0500 Subject: implement nice MapView object --- src/main.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/main.js') diff --git a/src/main.js b/src/main.js index f1d3635..db8963d 100644 --- a/src/main.js +++ b/src/main.js @@ -1,6 +1,6 @@ import Canvas from './Canvas.js'; import { Mat3, Vec3, Point, Shape } from './Geometry.js'; -import { MapGrid } from './MapView.js'; +import { MapGrid, MapView } from './MapView.js'; const $ = id => document.getElementById(id) @@ -12,12 +12,9 @@ window.onload = () => { const zaxis = new Vec3(0, 0, 1); const grid = new MapGrid(30, 30); - console.log(grid) + const map = new MapView(canvas); - let view = new Mat3().rotation(xaxis, -0.3*Math.PI); - let angle = 0; - - canvas.onDraw = ct => { + map.onDraw = (ct, view) => { ct.fillStyle = "#01162B" ct.fillRect(-10,-10, 100, 100); ct.lineWidth = 0.005; @@ -27,10 +24,4 @@ window.onload = () => { grid.render(ct, view); }; canvas.draw(); - - setInterval(() => { - angle = angle + 0.01*Math.PI; - view.rotation(xaxis, angle); - canvas.draw(); - }, 50); } -- cgit v1.2.1