mirror of
https://github.com/seigler/webgl-threejs-hello
synced 2025-07-27 01:36:14 +00:00
:chick: initial commit
This commit is contained in:
parent
321e7e5612
commit
2eeebe06e8
17 changed files with 8470 additions and 0 deletions
47
app/main.js
Normal file
47
app/main.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
import Webgl from 'js/core/Webgl';
|
||||
import loop from 'js/core/Loop';
|
||||
import props from 'js/core/props';
|
||||
import Example from 'js/components/Example';
|
||||
|
||||
|
||||
// ##
|
||||
// INIT
|
||||
const webgl = new Webgl(window.innerWidth, window.innerHeight);
|
||||
document.body.appendChild(webgl.dom);
|
||||
// - Add object update to loop
|
||||
loop.add(webgl.onUpdate);
|
||||
|
||||
// ##
|
||||
// GUI
|
||||
const gui = new dat.GUI();
|
||||
gui.add(props, 'rotation', 0.01, 1);
|
||||
gui.close();
|
||||
|
||||
// ##
|
||||
// EXAMPLE LIGHT
|
||||
const light = new THREE.DirectionalLight(0xffffff, 0.5);
|
||||
light.position.set(1, 1, 1);
|
||||
webgl.add(light);
|
||||
|
||||
// ##
|
||||
// EXAMPLE BOX
|
||||
const example = new Example();
|
||||
webgl.add(example);
|
||||
loop.add(example.onUpdate);
|
||||
|
||||
// ##
|
||||
// RENDERER
|
||||
loop.start();
|
||||
|
||||
|
||||
// ##
|
||||
// ON RESIZE / ORIENTATION CHANGE
|
||||
function onResize() {
|
||||
const w = window.innerWidth;
|
||||
const h = window.innerHeight;
|
||||
|
||||
webgl.onResize(w, h);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
window.addEventListener('orientationchange', onResize);
|
Loading…
Add table
Add a link
Reference in a new issue