UNPKG

d2k

Version:

rendering engine from the Dark side of the Force - wip

68 lines (52 loc) 1.39 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>rendering-engine - hello world</title> <style> * { box-sizing: border-box; } html, body { width: 100%; height: 100%; } body { margin: 0; font-family: sans-serif; font-size: 12px; } canvas { position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: 100; margin: auto; } </style> </head> <body> <script src="../../src/rendering-engine/index.js"></script> <script> const { Box, Camera, Renderer, Scene } = d2k; const scene = new Scene(); const camera = new Camera( { type: 'perspective' } ); camera.position.z = -8; const renderer = new Renderer(); const box = new Box(); scene.add( box ); document.body.appendChild( renderer.canvas ); window.addEventListener( 'resize', _ => renderer.resize(), false ); renderer.onrender( ( { time } ) => { camera.rotation.y += Math.PI / 180; camera.rotation.z += Math.PI / 180; renderer.render( { scene, camera } ); } ); console.log( { box, camera, renderer, scene } ); </script> </body> </html>