We need to initialize and configure our canvas and gl instances:
function configure() {
canvas = utils.getCanvas('webgl-canvas');
utils.autoResizeCanvas(canvas);
gl = utils.getGLContext(canvas);
// ...
}
Then, we need to initialize scene, clock, and program:
clock = new Clock();
program = new Program(gl, 'vertex-shader', 'fragment-shader');
scene = new Scene(gl, program);
These core components are defined globally so that we can reference them throughout our application.
Finally, we need to set the background color and the depth test properties, as follows:
gl.clearColor(...clearColor);
gl.clearDepth(1);
gl.enable(gl.DEPTH_TEST);
gl.depthFunc(gl.LESS);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);