// main.js window.onload = init; class Vector2 { constructor (x, y) { this.x = x; this.y = y; } } const canvas = document.getElementById('canvas'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; // Create the renderer (it will load default shaders if not provided) const renderer = new Renderer(canvas, "bumpmap_vert", "bumpmap_frag"); const spriteImage = new Image(); spriteImage.src = 'sprite.png'; const normalImage = new Image(); normalImage.src = 'normal.png'; const position = new Vector2(200, 200); const scale = new Vector2(0.4, 0.4); var angle = 45; var texture; var normalTexture; // TODO: See if we can use the old Framework way of loading images, better than this spriteImage.onload = () => { texture = renderer.loadTexture(spriteImage); }; normalImage.onload = () => { normalTexture = renderer.loadTexture(normalImage); }; function init () { setInterval(() => { drawLoop(); }, 10); } function drawLoop () { angle += 0.3; // Update the light direction const angleInRadians = (angle % 360) * (Math.PI / 180); const lightDirection = [ Math.cos(angleInRadians), Math.sin(angleInRadians), 0.2 // A default z-component for the light direction, adjust as needed ]; renderer.bindTexture(normalTexture, renderer.gl.TEXTURE1); // Render your sprite renderer.render( texture, position, scale, 0, canvas.width, canvas.height, { 'u_normalMap': { unit: 1 }, // Example uniform 'u_lightDirection': [lightDirection[0], lightDirection[1], lightDirection[2]] } ); }